oox/source/drawingml/table/tablecell.cxx | 37 +++++++++++++++---------------- sd/qa/unit/layout-tests.cxx | 21 +++++++++++++++++ 2 files changed, 40 insertions(+), 18 deletions(-)
New commits: commit fa0312aaa687366168ed9ead00bb78eedcd054cf Author: Sarper Akdemir <sarper.akde...@collabora.com> AuthorDate: Thu Apr 20 23:31:20 2023 +0300 Commit: Andras Timar <andras.ti...@collabora.com> CommitDate: Sun Apr 23 22:09:30 2023 +0200 related tdf#154501: pptx import: push cell's RotateAngle after text It appears to matter whether "RotateAngle" property is set before or after insertion of the text for cells. It only renders correctly when it is pushed after the text insertion. RotateAngle appears to end up in the property set either way with correct values, so I don't really know why this is the case. Adds a unit test that covers rendering of vertical text in table cells on import from an example pptx file. Change-Id: Ifb8caa0b74920758fea2815b16dae7fd60587cc7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150734 Reviewed-by: Andras Timar <andras.ti...@collabora.com> Tested-by: Andras Timar <andras.ti...@collabora.com> diff --git a/oox/source/drawingml/table/tablecell.cxx b/oox/source/drawingml/table/tablecell.cxx index 37408aaf4ba5..8692e3ffb33f 100644 --- a/oox/source/drawingml/table/tablecell.cxx +++ b/oox/source/drawingml/table/tablecell.cxx @@ -553,7 +553,24 @@ void TableCell::pushToXCell( const ::oox::core::XmlFilterBase& rFilterBase, cons { xPropSet->setPropertyValue("TextWritingMode", Any(css::text::WritingMode_TB_RL)); } - else if ( getVertToken() == XML_vert ) + + getTextBody()->insertAt( rFilterBase, xText, xAt, aTextStyleProps, pMasterTextListStyle ); + + // tdf#144092 For empty cells push character styles & endParaRPr to the Cell's properties + const TextParagraphVector& rParagraphs = getTextBody()->getParagraphs(); + if (rParagraphs.size() == 1) + { + const auto pFirstParagraph = rParagraphs.at(0); + if (pFirstParagraph->getRuns().empty()) + { + TextCharacterProperties aTextCharacterProps{ pFirstParagraph->getCharacterStyle( + aTextStyleProps, *pMasterTextListStyle, getTextBody()->getTextListStyle()) }; + aTextCharacterProps.assignUsed(pFirstParagraph->getEndProperties()); + aTextCharacterProps.pushToPropSet(aPropSet, rFilterBase); + } + } + + if ( getVertToken() == XML_vert ) { xPropSet->setPropertyValue("RotateAngle", Any(short(27000))); } @@ -561,7 +578,7 @@ void TableCell::pushToXCell( const ::oox::core::XmlFilterBase& rFilterBase, cons { xPropSet->setPropertyValue("RotateAngle", Any(short(9000))); } - else if ( getVertToken() != XML_horz ) + else if ( getVertToken() != XML_horz && getVertToken() != XML_eaVert ) { // put the vert value in the grab bag for roundtrip const Sequence<sal_Int8>& aTokenNameSeq = StaticTokenMap().getUtf8TokenName(getVertToken()); @@ -583,22 +600,6 @@ void TableCell::pushToXCell( const ::oox::core::XmlFilterBase& rFilterBase, cons } xPropSet->setPropertyValue("CellInteropGrabBag", Any(aGrabBag)); } - - getTextBody()->insertAt( rFilterBase, xText, xAt, aTextStyleProps, pMasterTextListStyle ); - - // tdf#144092 For empty cells push character styles & endParaRPr to the Cell's properties - const TextParagraphVector& rParagraphs = getTextBody()->getParagraphs(); - if (rParagraphs.size() == 1) - { - const auto pFirstParagraph = rParagraphs.at(0); - if (pFirstParagraph->getRuns().empty()) - { - TextCharacterProperties aTextCharacterProps{ pFirstParagraph->getCharacterStyle( - aTextStyleProps, *pMasterTextListStyle, getTextBody()->getTextListStyle()) }; - aTextCharacterProps.assignUsed(pFirstParagraph->getEndProperties()); - aTextCharacterProps.pushToPropSet(aPropSet, rFilterBase); - } - } } } diff --git a/sd/qa/unit/layout-tests.cxx b/sd/qa/unit/layout-tests.cxx index 25366afedc0f..afd3e5210027 100644 --- a/sd/qa/unit/layout-tests.cxx +++ b/sd/qa/unit/layout-tests.cxx @@ -320,6 +320,27 @@ CPPUNIT_TEST_FIXTURE(SdLayoutTest, testFitToFrameTextFitting) #endif } +CPPUNIT_TEST_FIXTURE(SdLayoutTest, testTableVerticalText) +{ + sd::DrawDocShellRef xDocShRef = loadURL( + m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/tcPr-vert-roundtrip.pptx"), PPTX); + + std::shared_ptr<GDIMetaFile> xMetaFile = xDocShRef->GetPreviewMetaFile(); + MetafileXmlDump dumper; + + xmlDocUniquePtr pXmlDoc = XmlTestTools::dumpAndParse(dumper, *xMetaFile); + CPPUNIT_ASSERT(pXmlDoc); + + // Without the accompanying fix, would fail with: + // - Expected: -900 + // - Actual : 0 + // - In <>, attribute 'orientation' of '//font[1]' incorrect value. + // i.e. table cell text that was supposed to be vertical (rotated 90 + // degrees) was not vertical. + assertXPath(pXmlDoc, "//font[1]", "orientation", "-900"); + assertXPath(pXmlDoc, "//font[2]", "orientation", "900"); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */