summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSarper Akdemir <sarper.akdemir@collabora.com>2023-04-06 13:01:02 +0300
committerTomaž Vajngerl <quikee@gmail.com>2023-04-10 08:52:51 +0200
commit60bce1af8aab2115d603781193bb659b35d1aedb (patch)
treed8eb9bfad0f39f2931e1d37a030e082a1e7567de
parent1934698260222f6727ac43118933094fa84dcdea (diff)
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 <quikee@gmail.com>
-rw-r--r--oox/inc/drawingml/textbodyproperties.hxx2
-rw-r--r--oox/source/drawingml/shape.cxx5
-rw-r--r--oox/source/drawingml/textbodypropertiescontext.cxx14
-rw-r--r--oox/source/export/drawingml.cxx5
-rw-r--r--oox/source/token/properties.txt1
-rw-r--r--svx/qa/unit/data/clip-vertical-overflow.pptxbin0 -> 32324 bytes
-rw-r--r--svx/qa/unit/svdraw.cxx44
7 files changed, 66 insertions, 5 deletions
diff --git a/oox/inc/drawingml/textbodyproperties.hxx b/oox/inc/drawingml/textbodyproperties.hxx
index 1daa5d592a30..d935f940638d 100644
--- a/oox/inc/drawingml/textbodyproperties.hxx
+++ b/oox/inc/drawingml/textbodyproperties.hxx
@@ -51,7 +51,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 fbd3e79c5a6e..69f3bf5a4d60 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -1792,9 +1792,8 @@ Reference< XShape > const & Shape::createAndInsert(
auto sHorzOverflow = getTextBody()->getTextProperties().msHorzOverflow;
if (!sHorzOverflow.isEmpty())
putPropertyToGrabBag("horzOverflow", uno::Any(getTextBody()->getTextProperties().msHorzOverflow));
- auto nVertOverflow = getTextBody()->getTextProperties().msVertOverflow;
- if (!nVertOverflow.isEmpty())
- putPropertyToGrabBag("vertOverflow", uno::Any(getTextBody()->getTextProperties().msVertOverflow));
+ if (XML_ellipsis == getTextBody()->getTextProperties().moVertOverflow)
+ putPropertyToGrabBag("vertOverflow", uno::Any(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 47ef04797c93..46576c069c8e 100644
--- a/oox/source/drawingml/textbodypropertiescontext.cxx
+++ b/oox/source/drawingml/textbodypropertiescontext.cxx
@@ -83,7 +83,19 @@ TextBodyPropertiesContext::TextBodyPropertiesContext( ContextHandler2Helper cons
// ST_TextHorzOverflowType
mrTextBodyProp.msHorzOverflow = rAttribs.getStringDefaulted(XML_horzOverflow);
// ST_TextVertOverflowType
- mrTextBodyProp.msVertOverflow = rAttribs.getStringDefaulted(XML_vertOverflow);
+ if( rAttribs.hasAttribute(XML_vertOverflow) )
+ {
+ mrTextBodyProp.moVertOverflow = rAttribs.getToken(XML_vertOverflow);
+ 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 59d67393bed5..270d961d6d5a 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -3868,6 +3868,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 edf799c2c8df..fd2c3a0c6497 100644
--- a/oox/source/token/properties.txt
+++ b/oox/source/token/properties.txt
@@ -547,6 +547,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
--- /dev/null
+++ b/svx/qa/unit/data/clip-vertical-overflow.pptx
Binary files differ
diff --git a/svx/qa/unit/svdraw.cxx b/svx/qa/unit/svdraw.cxx
index 0001a7f4d66a..de6ba067fe1f 100644
--- a/svx/qa/unit/svdraw.cxx
+++ b/svx/qa/unit/svdraw.cxx
@@ -669,6 +669,50 @@ CPPUNIT_TEST_FIXTURE(SvdrawTest, testRotatePoint)
CPPUNIT_ASSERT_EQUAL(Point(300, 300), aPoint);
}
}
+
+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
+ loadFromURL(u"clip-vertical-overflow.pptx");
+
+ 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: */