oox/source/export/drawingml.cxx     |   15 ++++++++++++++-
 sd/qa/unit/data/pptx/tdf147121.pptx |binary
 sd/qa/unit/export-tests-ooxml3.cxx  |   32 ++++++++++++++++++++++++++++++++
 3 files changed, 46 insertions(+), 1 deletion(-)

New commits:
commit 2c06fba68d3cd194edfddf49cd2779c761b6bd38
Author:     Attila Bakos (NISZ) <bakos.attilakar...@nisz.hu>
AuthorDate: Wed Feb 16 16:09:00 2022 +0100
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Mon Mar 7 10:55:42 2022 +0100

    tdf#147121 PPTX: fix regression of font size export of empty lines
    
    If the empty line has got direct formatted font size,
    don't forget to export it, unless the master setting
    is applied.
    
    Regression from commit b6b02e0b4c9d739836e1f61a886ea45b01e6696e
    "tdf#111903 tdf#137152 PPTX export: fix placeholders".
    
    Change-Id: If686e487bca9c198fd7c96860a21e4efe91381bb
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130005
    Tested-by: László Németh <nem...@numbertext.org>
    Reviewed-by: László Németh <nem...@numbertext.org>
    (cherry picked from commit f29c14e8c36819296d0c66bb995201acf0a2647e)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130675
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 69f210cfe325..c457e65ac0c8 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -2450,6 +2450,10 @@ void DrawingML::WriteRun( const Reference< XTextRange >& 
rRun,
     if (GetProperty(rXPropSet, "NumberingIsNumber"))
         mAny >>= bNumberingIsNumber;
 
+    float nFontSize = -1;
+    if (GetProperty(rXPropSet, "CharHeight"))
+        mAny >>= nFontSize;
+
     bool bIsURLField = false;
     OUString sFieldValue = GetFieldValue( rRun, bIsURLField );
     bool bWriteField  = !( sFieldValue.isEmpty() || bIsURLField );
@@ -2482,7 +2486,16 @@ void DrawingML::WriteRun( const Reference< XTextRange >& 
rRun,
 
     if (sText == "\n")
     {
-        mpFS->singleElementNS(XML_a, XML_br);
+        // Empty run? Do not forget to write the font size in case of pptx:
+        if ((GetDocumentType() == DOCUMENT_PPTX) && (nFontSize != -1))
+        {
+            mpFS->startElementNS(XML_a, XML_br);
+            mpFS->singleElementNS(XML_a, XML_rPr, XML_sz,
+                                  OString::number(nFontSize * 100).getStr());
+            mpFS->endElementNS(XML_a, XML_br);
+        }
+        else
+            mpFS->singleElementNS(XML_a, XML_br);
     }
     else
     {
diff --git a/sd/qa/unit/data/pptx/tdf147121.pptx 
b/sd/qa/unit/data/pptx/tdf147121.pptx
new file mode 100644
index 000000000000..5762a4b9216b
Binary files /dev/null and b/sd/qa/unit/data/pptx/tdf147121.pptx differ
diff --git a/sd/qa/unit/export-tests-ooxml3.cxx 
b/sd/qa/unit/export-tests-ooxml3.cxx
index 1650680a2c30..db33ac9b88c4 100644
--- a/sd/qa/unit/export-tests-ooxml3.cxx
+++ b/sd/qa/unit/export-tests-ooxml3.cxx
@@ -123,6 +123,7 @@ public:
     void testTdf143222_embeddedWorksheet();
     void testTdf142235_TestPlaceholderTextAlignment();
     void testTdf143315();
+    void testTdf147121();
     void testTdf140912_PicturePlaceholder();
 
     CPPUNIT_TEST_SUITE(SdOOXMLExportTest3);
@@ -197,6 +198,7 @@ public:
     CPPUNIT_TEST(testTdf143222_embeddedWorksheet);
     CPPUNIT_TEST(testTdf142235_TestPlaceholderTextAlignment);
     CPPUNIT_TEST(testTdf143315);
+    CPPUNIT_TEST(testTdf147121);
     CPPUNIT_TEST(testTdf140912_PicturePlaceholder);
     CPPUNIT_TEST_SUITE_END();
 
@@ -1847,6 +1849,36 @@ void SdOOXMLExportTest3::testTdf143315()
     assertXPath(pXml, 
"/p:sld/p:cSld/p:spTree/p:sp/p:txBody/a:p/a:pPr/a:buChar", 0);
 }
 
+void SdOOXMLExportTest3::testTdf147121()
+{
+    // Get the bugdoc
+    ::sd::DrawDocShellRef xDocShRef
+        = 
loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/tdf147121.pptx"), 
PPTX);
+
+    CPPUNIT_ASSERT(xDocShRef);
+    // Get the second line props of the placeholder
+    uno::Reference<drawing::XDrawPage> xPage(getPage(0, xDocShRef));
+    uno::Reference<beans::XPropertySet> xShape(xPage->getByIndex(0), 
uno::UNO_QUERY_THROW);
+    uno::Reference<beans::XPropertySet> xRun(
+        getRunFromParagraph(2, getParagraphFromShape(0, xShape)), 
uno::UNO_QUERY_THROW);
+
+    // Save the font size
+    const auto nFontSizeBefore = 
xRun->getPropertyValue("CharHeight").get<float>() * 100;
+
+    // Save and reload
+    utl::TempFile tmpfile;
+    xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tmpfile);
+    xDocShRef->DoClose();
+
+    // Parse the export
+    xmlDocUniquePtr pXml = parseExport(tmpfile, "ppt/slides/slide1.xml");
+    const auto nFontSizeAfter
+        = getXPath(pXml, 
"/p:sld/p:cSld/p:spTree/p:sp/p:txBody/a:p/a:br[1]/a:rPr", "sz").toFloat();
+
+    // The font size was not saved before now it must be equal with the saved 
one.
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Unexpected font size", nFontSizeBefore, 
nFontSizeAfter);
+}
+
 void SdOOXMLExportTest3::testTdf140912_PicturePlaceholder()
 {
     ::sd::DrawDocShellRef xDocShRef = loadURL(

Reply via email to