summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorofftkp <parisoplop@gmail.com>2022-07-30 19:51:14 +0300
committerHossein <hossein@libreoffice.org>2022-07-31 15:42:34 +0200
commit826fea9d77dbb7f4ea71f934bbe137008aa8b7f0 (patch)
treee133b5ff536d4439665253e708ce0e6f75c9715b
parent0f195db61d3df5e34b82318115152a1103be17b9 (diff)
tdf#150201 Fix endianness for placeable WMF
The constant PLACEABLE_SIGNATURE in graphicfilter2.cxx had wrong endianness, which would cause the WMF file detection to fail for placeable WMFs. Changed endianness since WMF files are in little endian. Also added test using placeable and non-placeable WMFs. To run the test: make CPPUNIT_TEST_NAME="testDetectWMF" -sr CppunitTest_vcl_graphic_test Change-Id: Ia3c61bae5ab27375636f21bc902f773804cf9273 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137634 Tested-by: Jenkins Reviewed-by: Hossein <hossein@libreoffice.org>
-rw-r--r--vcl/qa/cppunit/GraphicDescriptorTest.cxx24
-rw-r--r--vcl/source/filter/graphicfilter2.cxx2
2 files changed, 25 insertions, 1 deletions
diff --git a/vcl/qa/cppunit/GraphicDescriptorTest.cxx b/vcl/qa/cppunit/GraphicDescriptorTest.cxx
index c86d95edebdb..a0bbd027160b 100644
--- a/vcl/qa/cppunit/GraphicDescriptorTest.cxx
+++ b/vcl/qa/cppunit/GraphicDescriptorTest.cxx
@@ -36,6 +36,7 @@ class GraphicDescriptorTest : public test::BootstrapFixtureBase
void testDetectBMP();
void testDetectWEBP();
void testDetectEMF();
+ void testDetectWMF();
CPPUNIT_TEST_SUITE(GraphicDescriptorTest);
CPPUNIT_TEST(testDetectPNG);
@@ -45,6 +46,7 @@ class GraphicDescriptorTest : public test::BootstrapFixtureBase
CPPUNIT_TEST(testDetectBMP);
CPPUNIT_TEST(testDetectWEBP);
CPPUNIT_TEST(testDetectEMF);
+ CPPUNIT_TEST(testDetectWMF);
CPPUNIT_TEST_SUITE_END();
};
@@ -169,6 +171,28 @@ void GraphicDescriptorTest::testDetectEMF()
CPPUNIT_ASSERT_EQUAL(tools::Long(300), aDescriptor.GetSize_100TH_MM().Height());
}
+void GraphicDescriptorTest::testDetectWMF()
+{
+ // Test placeable wmf
+ {
+ SvFileStream aFileStream(m_directories.getURLFromSrc(u"/emfio/qa/cppunit/wmf/data/")
+ + "tdf88163-wrong-font-size.wmf",
+ StreamMode::READ);
+ GraphicDescriptor aDescriptor(aFileStream, nullptr);
+ aDescriptor.Detect(true);
+ CPPUNIT_ASSERT_EQUAL(GraphicFileFormat::WMF, aDescriptor.GetFileFormat());
+ }
+ // Test non-placeable wmf
+ {
+ SvFileStream aFileStream(m_directories.getURLFromSrc(u"/emfio/qa/cppunit/wmf/data/")
+ + "tdf88163-non-placeable.wmf",
+ StreamMode::READ);
+ GraphicDescriptor aDescriptor(aFileStream, nullptr);
+ aDescriptor.Detect(true);
+ CPPUNIT_ASSERT_EQUAL(GraphicFileFormat::WMF, aDescriptor.GetFileFormat());
+ }
+}
+
} // namespace
CPPUNIT_TEST_SUITE_REGISTRATION(GraphicDescriptorTest);
diff --git a/vcl/source/filter/graphicfilter2.cxx b/vcl/source/filter/graphicfilter2.cxx
index fb001ee14a25..fafaa180bd56 100644
--- a/vcl/source/filter/graphicfilter2.cxx
+++ b/vcl/source/filter/graphicfilter2.cxx
@@ -34,7 +34,7 @@ constexpr sal_uInt32 EMF_CHECK_SIZE = 44;
constexpr sal_uInt32 WMF_CHECK_SIZE = 32;
constexpr sal_uInt32 EMR_HEADER = 0x00000001;
constexpr sal_uInt32 ENHMETA_SIGNATURE = 0x464d4520;
-constexpr sal_uInt32 PLACEABLE_SIGNATURE = 0xd7cdc69a;
+constexpr sal_uInt32 PLACEABLE_SIGNATURE = 0x9ac6cdd7;
namespace
{
enum class MetafileType : sal_uInt16