summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorAttila Szűcs <attila.szucs@collabora.com>2024-01-16 04:29:49 +0100
committerAndras Timar <andras.timar@collabora.com>2024-01-20 19:25:18 +0100
commit845378ff42a6dca19730c0464af577521700b222 (patch)
tree7fef1c2cd1b76692c5ce4ada835f03b814752733 /oox
parent891ce7b9687e343fa4fbad3d3a180a00ee1f71fa (diff)
tdf#134401 SD: export to pptx: autoGrow->textWordWrap
PPTX doesn't have autoGrowWidth and autoGrowHeight, but it does have TextWordWrap which is similar. If autoGrowWidth and autoGrowHeight are set in the document, then they are exported to PPTX as TextWordWrap = "none". Without this patch, PowerPoint may wrap some texts into more lines as Impress does. This is because some text may rendered at sligtly different sizes in PowerPoint as in Impress. (maybe it is just a rounding difference) Even 1% (or less) size difference is enought, because when autoGrowthWidth and autoGrowthHeight is set, then there is a good chance, the textbox rectangle is exactly as big as the text. Change-Id: I2cdba68c66c43507c5007a9e395b87ddeeea2372 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162152 Tested-by: Jenkins Tested-by: Caolán McNamara <caolan.mcnamara@collabora.com> Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com> (cherry picked from commit dc5a761df436f5d9de781d1fa6cf7d010f8be0e8) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162210 Reviewed-by: Andras Timar <andras.timar@collabora.com>
Diffstat (limited to 'oox')
-rw-r--r--oox/qa/unit/data/tdf134401_ExportAutoGrowToTextWordWrap.odpbin0 -> 18925 bytes
-rw-r--r--oox/qa/unit/export.cxx17
-rw-r--r--oox/source/export/drawingml.cxx16
3 files changed, 33 insertions, 0 deletions
diff --git a/oox/qa/unit/data/tdf134401_ExportAutoGrowToTextWordWrap.odp b/oox/qa/unit/data/tdf134401_ExportAutoGrowToTextWordWrap.odp
new file mode 100644
index 000000000000..9fcebfe0f448
--- /dev/null
+++ b/oox/qa/unit/data/tdf134401_ExportAutoGrowToTextWordWrap.odp
Binary files differ
diff --git a/oox/qa/unit/export.cxx b/oox/qa/unit/export.cxx
index 415c5fe8d02f..aa9690efdb4a 100644
--- a/oox/qa/unit/export.cxx
+++ b/oox/qa/unit/export.cxx
@@ -1345,6 +1345,23 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf157289CircularArrowExport)
assertXPath(pXmlDoc, "//a:pathLst/a:path/a:arcTo[1]"_ostr, "wR"_ostr, "6750");
assertXPath(pXmlDoc, "//a:pathLst/a:path/a:arcTo[1]"_ostr, "hR"_ostr, "6750");
}
+
+CPPUNIT_TEST_FIXTURE(Test, testTdf134401_ExportAutoGrowToTextWordWrap)
+{
+ // pptx doesn't have autoGrowWidth and autoGrowHeight, but it does have TextWordWrap
+ // which is similar. If autoGrowWidth and autoGrowHeight are set in the document,
+ // then they are exported to pptx as TextWordWrap = "none".
+ loadFromFile(u"tdf134401_ExportAutoGrowToTextWordWrap.odp");
+ save("Impress Office Open XML");
+
+ // There are 2 shapes in the test file.
+ // The 1. shape is without autoGrowWidth/Height.
+ // The 2. shape is with autoGrowWidth/Height.
+ // Check if wrap="none" is exported for shape 2, but no wrap is exported for shape 1.
+ xmlDocUniquePtr pXmlDoc = parseExport("ppt/slides/slide1.xml");
+ assertXPathNoAttribute(pXmlDoc, "//p:sp[1]/p:txBody/a:bodyPr"_ostr, "wrap"_ostr);
+ assertXPath(pXmlDoc, "//p:sp[2]/p:txBody/a:bodyPr"_ostr, "wrap"_ostr, "none");
+}
}
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 05c96c9ad798..a3e5356c0523 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -4061,6 +4061,22 @@ void DrawingML::WriteText(const Reference<XInterface>& rXIface, bool bBodyPr, bo
bHasWrap = true;
}
+ // tdf#134401: If AUTOGROWWIDTH and AUTOGROWHEIGHT are set, then export it as TextWordWrap
+ if (SvxShapeText* pShpTxt = dynamic_cast<SvxShapeText*>(rXIface.get()))
+ {
+ const sdr::properties::BaseProperties& rProperties
+ = pShpTxt->GetSdrObject()->GetProperties();
+
+ const SdrOnOffItem& rSdrTextFitWidth = rProperties.GetItem(SDRATTR_TEXT_AUTOGROWWIDTH);
+ const SdrOnOffItem& rSdrTextFitHeight = rProperties.GetItem(SDRATTR_TEXT_AUTOGROWHEIGHT);
+
+ if (rSdrTextFitWidth.GetValue() == true && rSdrTextFitHeight.GetValue() == true)
+ {
+ bHasWrap = true;
+ bWrap = false;
+ }
+ }
+
if (bBodyPr)
{
const char* pWrap = (bHasWrap && !bWrap) || bIsFontworkShape ? "none" : nullptr;