summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHossein <hossein@libreoffice.org>2021-11-25 18:24:46 +0100
committerXisco Fauli <xiscofauli@libreoffice.org>2021-11-26 13:31:01 +0100
commit149bd802623d6d83ec9aa04514b938494f7f01f6 (patch)
tree3ad911bd5631dbf8a449c110f9e9c7368bc58efd
parent00455b22f0544159e60e9f9f9fd1a7c41855fb58 (diff)
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 <gang65@poczta.onet.pl>
-rw-r--r--emfio/source/reader/wmfreader.cxx5
-rw-r--r--sd/qa/unit/SVGExportTests.cxx15
-rw-r--r--sd/qa/unit/data/pptx/tdf145873.pptxbin0 -> 52342 bytes
3 files changed, 18 insertions, 2 deletions
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
--- /dev/null
+++ b/sd/qa/unit/data/pptx/tdf145873.pptx
Binary files differ