emfio/source/reader/wmfreader.cxx   |    5 +++--
 sd/qa/unit/SVGExportTests.cxx       |   15 +++++++++++++++
 sd/qa/unit/data/pptx/tdf145873.pptx |binary
 3 files changed, 18 insertions(+), 2 deletions(-)

New commits:
commit 149bd802623d6d83ec9aa04514b938494f7f01f6
Author:     Hossein <hoss...@libreoffice.org>
AuthorDate: Thu Nov 25 18:24:46 2021 +0100
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Fri Nov 26 13:31:01 2021 +0100

    tdf#145873 Fix FILEOPEN: EMF file not displayed
    
    EMF can have WMF embedded inside it. The sample PPTX file contains an
    EMF file consisting of several GDIcomment records in which embed a
    Placeable WMF file without some records related to the size of the
    WMF. It reaches pStm->SetError( SVSTREAM_FILEFORMAT_ERROR ); in
    emfio/source/reader/wmfreader.cxx:1982 which causes to the problem
    in loading the file.
    
    With this fix, the EMF file will be displayed. Without the fix, the
    EMF file will be displayed as blank.
    
    Regression from
        commit 5e4e1cdb1e14354b42838e1dfcf82873b3071896
        tdf#88163 Fix font size for placeable wmf files
    
    The fix can be tested with:
    
        make CPPUNIT_TEST_NAME="testTdf145873" -sr \
            CppunitTest_sd_svg_export_tests
    
    Change-Id: I04babd5029ba123fdd03758eef2be69faf45fda8
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125796
    Tested-by: Jenkins
    Reviewed-by: Bartosz Kosiorek <gan...@poczta.onet.pl>

diff --git a/emfio/source/reader/wmfreader.cxx 
b/emfio/source/reader/wmfreader.cxx
index eeb6e106cf00..47513101777d 100644
--- a/emfio/source/reader/wmfreader.cxx
+++ b/emfio/source/reader/wmfreader.cxx
@@ -44,6 +44,7 @@ namespace
     // MS Windows defines
     enum WMFRecords
     {
+        W_META_EOF                  = 0x0000,
         W_META_SETBKCOLOR           = 0x0201,
         W_META_SETBKMODE            = 0x0102,
         W_META_SETMAPMODE           = 0x0103,
@@ -1572,7 +1573,7 @@ namespace emfio
                     if (
                          !mpInputStream->good() ||
                          (mnRecSize < 3) ||
-                         (mnRecSize == 3 && nFunction == 0)
+                         (mnRecSize == 3 && nFunction == W_META_EOF)
                        )
                     {
                         if( mpInputStream->eof() )
@@ -1689,7 +1690,7 @@ namespace emfio
                     bRet = false;
                     break;
                 }
-                else if ( nRSize==3 && nFunction==0 )
+                else if ( nFunction == W_META_EOF )
                 {
                     break;
                 }
diff --git a/sd/qa/unit/SVGExportTests.cxx b/sd/qa/unit/SVGExportTests.cxx
index d43815264d26..1257478e5ed2 100644
--- a/sd/qa/unit/SVGExportTests.cxx
+++ b/sd/qa/unit/SVGExportTests.cxx
@@ -35,6 +35,7 @@
 #define SVG_USE *[name()='use']
 #define SVG_PATTERN *[name()='pattern']
 #define SVG_RECT *[name()='rect']
+#define SVG_FONT *[name()='font']
 
 using namespace css;
 
@@ -334,6 +335,19 @@ public:
         assertXPathContent(svgDoc, SAL_STRINGIFY( 
/SVG_SVG/SVG_DEFS[9]/SVG_G[2]/SVG_G[2]/SVG_G[7]/SVG_G/SVG_TEXT/SVG_TSPAN/SVG_TSPAN/SVG_TSPAN
 ), "<number>");
     }
 
+    void testTdf145873()
+    {
+        load( u"/sd/qa/unit/data/pptx/", "tdf145873.pptx" );
+        save();
+
+        xmlDocUniquePtr svgDoc = parseXml(maTempFile);
+        CPPUNIT_ASSERT(svgDoc);
+
+        // Witout the fix in place, it would have filed with:
+        // - Expected: 22 - Actual  : 3 - number of child-nodes is incorrect
+        assertXPathChildren(svgDoc, SAL_STRINGIFY( 
/SVG_SVG/SVG_DEFS[6]/SVG_FONT ), 22);
+    }
+
     CPPUNIT_TEST_SUITE(SdSVGFilterTest);
     CPPUNIT_TEST(testSVGExportTextDecorations);
     CPPUNIT_TEST(testSVGExportJavascriptURL);
@@ -342,6 +356,7 @@ public:
     CPPUNIT_TEST(testSVGExportSlideBitmapBackground);
     CPPUNIT_TEST(testSVGExportSlideTileBitmapBackground);
     CPPUNIT_TEST(testSVGPlaceholderLocale);
+    CPPUNIT_TEST(testTdf145873);
     CPPUNIT_TEST_SUITE_END();
 };
 
diff --git a/sd/qa/unit/data/pptx/tdf145873.pptx 
b/sd/qa/unit/data/pptx/tdf145873.pptx
new file mode 100644
index 000000000000..8a5eaa83824a
Binary files /dev/null and b/sd/qa/unit/data/pptx/tdf145873.pptx differ

Reply via email to