oox/inc/drawingml/textbodyproperties.hxx | 2 oox/source/drawingml/shape.cxx | 5 -- oox/source/drawingml/textbodypropertiescontext.cxx | 14 ++++++ oox/source/export/drawingml.cxx | 5 ++ oox/source/token/properties.txt | 1 svx/qa/unit/data/clip-vertical-overflow.pptx |binary svx/qa/unit/svdraw.cxx | 45 +++++++++++++++++++++ 7 files changed, 67 insertions(+), 5 deletions(-)
New commits: commit 37006e138407017366c3a0cb62ee71a6f7418c5d Author: Sarper Akdemir <[email protected]> AuthorDate: Thu Apr 6 13:01:02 2023 +0300 Commit: Andras Timar <[email protected]> CommitDate: Wed Apr 12 23:28:26 2023 +0200 pptx import/export: consider TextClipVerticalOverflow for vertOverflow Also adds a unit test that tests TextClipVerticalOverflow on 4 different scenarios. Change-Id: I6232935765641c796046d90fe2207d67ae4b3eb5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150107 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <[email protected]> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150237 Reviewed-by: Andras Timar <[email protected]> Tested-by: Andras Timar <[email protected]> diff --git a/oox/inc/drawingml/textbodyproperties.hxx b/oox/inc/drawingml/textbodyproperties.hxx index 7cc1b9d8041c..1945a2c185df 100644 --- a/oox/inc/drawingml/textbodyproperties.hxx +++ b/oox/inc/drawingml/textbodyproperties.hxx @@ -48,7 +48,7 @@ struct TextBodyProperties /// Normal autofit: font scale (default: 100%). sal_Int32 mnFontScale = 100000; OUString msHorzOverflow; - OUString msVertOverflow; + std::optional< sal_Int32 > moVertOverflow{}; std::array<std::optional<sal_Int32>, 4> maTextDistanceValues; diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx index 2f4a85854dba..ae564c91ccb8 100644 --- a/oox/source/drawingml/shape.cxx +++ b/oox/source/drawingml/shape.cxx @@ -1611,9 +1611,8 @@ Reference< XShape > const & Shape::createAndInsert( auto sHorzOverflow = getTextBody()->getTextProperties().msHorzOverflow; if (!sHorzOverflow.isEmpty()) putPropertyToGrabBag("horzOverflow", uno::makeAny(getTextBody()->getTextProperties().msHorzOverflow)); - auto nVertOverflow = getTextBody()->getTextProperties().msVertOverflow; - if (!nVertOverflow.isEmpty()) - putPropertyToGrabBag("vertOverflow", uno::makeAny(getTextBody()->getTextProperties().msVertOverflow)); + if (XML_ellipsis == getTextBody()->getTextProperties().moVertOverflow) + putPropertyToGrabBag("vertOverflow", uno::makeAny(OUString{"ellipsis"})); } // Note that the script oox/source/drawingml/customshapes/generatePresetsData.pl looks diff --git a/oox/source/drawingml/textbodypropertiescontext.cxx b/oox/source/drawingml/textbodypropertiescontext.cxx index f7d4abd4e685..3c3950762c3d 100644 --- a/oox/source/drawingml/textbodypropertiescontext.cxx +++ b/oox/source/drawingml/textbodypropertiescontext.cxx @@ -85,7 +85,19 @@ TextBodyPropertiesContext::TextBodyPropertiesContext( ContextHandler2Helper cons // ST_TextHorzOverflowType mrTextBodyProp.msHorzOverflow = rAttribs.getString(XML_horzOverflow, ""); // ST_TextVertOverflowType - mrTextBodyProp.msVertOverflow = rAttribs.getString(XML_vertOverflow, ""); + if( rAttribs.hasAttribute(XML_vertOverflow) ) + { + mrTextBodyProp.moVertOverflow = rAttribs.getToken(XML_vertOverflow).get(XML_overflow); + switch( mrTextBodyProp.moVertOverflow.value_or(XML_overflow) ) + { + case XML_ellipsis: + case XML_clip: + mrTextBodyProp.maPropertyMap.setProperty(PROP_TextClipVerticalOverflow, true); + break; + default: + break; + } + } // ST_TextColumnCount if (const sal_Int32 nColumns = rAttribs.getInteger(XML_numCol, 0); nColumns > 0) diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx index 36006e2af562..2999f1fcd8d7 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -3510,6 +3510,11 @@ void DrawingML::WriteText(const Reference<XInterface>& rXIface, bool bBodyPr, bo } } + if (!sVertOverflow && GetProperty(rXPropSet, "TextClipVerticalOverflow") && mAny.get<bool>()) + { + sVertOverflow = "clip"; + } + mpFS->startElementNS( (nXmlNamespace ? nXmlNamespace : XML_a), XML_bodyPr, XML_numCol, sax_fastparser::UseIf(OString::number(nCols), nCols > 0), XML_spcCol, sax_fastparser::UseIf(OString::number(oox::drawingml::convertHmmToEmu(nColSpacing)), nCols > 0 && nColSpacing >= 0), diff --git a/oox/source/token/properties.txt b/oox/source/token/properties.txt index e31885499992..cea3ea503703 100644 --- a/oox/source/token/properties.txt +++ b/oox/source/token/properties.txt @@ -545,6 +545,7 @@ TextAutoGrowHeight TextBox TextBreak TextCameraZRotateAngle +TextClipVerticalOverflow TextColor TextColumns TextContourFrame diff --git a/svx/qa/unit/data/clip-vertical-overflow.pptx b/svx/qa/unit/data/clip-vertical-overflow.pptx new file mode 100644 index 000000000000..703f92e54b30 Binary files /dev/null and b/svx/qa/unit/data/clip-vertical-overflow.pptx differ diff --git a/svx/qa/unit/svdraw.cxx b/svx/qa/unit/svdraw.cxx index 04cdb43f0584..a5ff20135aaf 100644 --- a/svx/qa/unit/svdraw.cxx +++ b/svx/qa/unit/svdraw.cxx @@ -537,6 +537,51 @@ CPPUNIT_TEST_FIXTURE(SvdrawTest, testPageViewDrawLayerClip) // i.e. the 2nd page had a line shape from the first page's footer. CPPUNIT_ASSERT_EQUAL(2, pPage2->getObjectCount()); } + +CPPUNIT_TEST_FIXTURE(SvdrawTest, testClipVerticalTextOverflow) +{ + // File contains a slide with 4 rectangle shapes with text inside + // each have <a:bodyPr vertOverflow="clip"> + // 1-) Text overflowing the rectangle + // 2-) Text not overflowing the rectangle + // 3-) (Vertical text) Text overflowing the rectangle + // 4-) (Vertical text) Text not overflowing the rectangle + OUString aURL = m_directories.getURLFromSrc(u"svx/qa/unit/data/clip-vertical-overflow.pptx"); + mxComponent = loadFromDesktop(aURL, "com.sun.star.presentation.PresentationDocument"); + + SdrPage* pSdrPage = getFirstDrawPageWithAssert(); + xmlDocUniquePtr pDocument = lcl_dumpAndParseFirstObjectWithAssert(pSdrPage); + + // Test vertically overflowing text + // Without the accompanying fix in place, this test would have failed with: + // equality assertion failed + // - Expected: 6 + // - Actual : 13 + // - In <>, XPath contents of child does not match + // i.e. the vertically overflowing text wasn't clipped & overflowing text + // was drawn anyways. + assertXPathContent(pDocument, "count((//sdrblocktext)[4]//textsimpleportion)", "6"); + + // make sure text is aligned correctly after the overflowing text is clipped + assertXPath(pDocument, "((//sdrblocktext)[4]//textsimpleportion)[1]", "y", "3749"); + assertXPath(pDocument, "((//sdrblocktext)[4]//textsimpleportion)[6]", "y", "7559"); + + // make sure the text that isn't overflowing is still aligned properly + assertXPathContent(pDocument, "count((//sdrblocktext)[5]//textsimpleportion)", "3"); + assertXPath(pDocument, "((//sdrblocktext)[5]//textsimpleportion)[1]", "y", "5073"); + assertXPath(pDocument, "((//sdrblocktext)[5]//textsimpleportion)[3]", "y", "6597"); + + // Test vertically overflowing text, with vertical text direction + assertXPathContent(pDocument, "count((//sdrblocktext)[6]//textsimpleportion)", "12"); + // make sure text is aligned correctly after the overflowing text is clipped + assertXPath(pDocument, "((//sdrblocktext)[6]//textsimpleportion)[1]", "x", "13093"); + assertXPath(pDocument, "((//sdrblocktext)[6]//textsimpleportion)[12]", "x", "4711"); + + // make sure the text that isn't overflowing is still aligned properly + assertXPathContent(pDocument, "count((//sdrblocktext)[7]//textsimpleportion)", "3"); + assertXPath(pDocument, "((//sdrblocktext)[7]//textsimpleportion)[1]", "x", "25417"); + assertXPath(pDocument, "((//sdrblocktext)[7]//textsimpleportion)[3]", "x", "23893"); +} } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
