oox/qa/unit/data/tdf134401_ExportAutoGrowToTextWordWrap.odp |binary
 oox/qa/unit/export.cxx                                      |   17 ++++++++++++
 oox/source/export/drawingml.cxx                             |   16 +++++++++++
 3 files changed, 33 insertions(+)

New commits:
commit 1c7c0cdb90f703b963ec88180d12324e4b3afa2e
Author:     Attila Szűcs <attila.sz...@collabora.com>
AuthorDate: Tue Jan 16 04:29:49 2024 +0100
Commit:     Andras Timar <andras.ti...@collabora.com>
CommitDate: Fri Jan 19 14:01:36 2024 +0100

    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.mcnam...@collabora.com>
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>
    (cherry picked from commit dc5a761df436f5d9de781d1fa6cf7d010f8be0e8)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162210
    Reviewed-by: Andras Timar <andras.ti...@collabora.com>

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
Binary files /dev/null and 
b/oox/qa/unit/data/tdf134401_ExportAutoGrowToTextWordWrap.odp 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;

Reply via email to