summaryrefslogtreecommitdiff
path: root/emfio/qa
diff options
context:
space:
mode:
authorArmin Le Grand <Armin.Le.Grand@cib.de>2017-06-09 19:55:17 +0200
committerThorsten Behrens <Thorsten.Behrens@CIB.de>2017-07-15 11:01:29 +0200
commit83535a28c57ffb59f795dd35332d6b3426071e32 (patch)
treea35406c5ed8c7971681385cbb081aad325e1cf54 /emfio/qa
parent79f5cb620984c4d04d53a497e698472b2192d2bb (diff)
emfplus: create a wmf/emf/emf+ primitive based importer
First steps to organize an importer that can read/interpret wmf/emf/emf+ and deliver a primitive representation for the content by parsing it. Use the same mechanisms as already applied for Svg, so to reuse abilities to keep original binary data to allow save again and embedding in files and have an implemented replacement bitmap based representation. For this, unify the used helper classes to handle more than just Svg. For 1st try, add test code and static bool switches Change-Id: I6e0a82943541d811a8f8d65a84115569fcd8cee7
Diffstat (limited to 'emfio/qa')
-rw-r--r--emfio/qa/cppunit/EmfImportTest.cxx102
-rw-r--r--emfio/qa/cppunit/data/fdo79679-2.emfbin0 -> 34236 bytes
2 files changed, 102 insertions, 0 deletions
diff --git a/emfio/qa/cppunit/EmfImportTest.cxx b/emfio/qa/cppunit/EmfImportTest.cxx
new file mode 100644
index 000000000000..f315fc8937d0
--- /dev/null
+++ b/emfio/qa/cppunit/EmfImportTest.cxx
@@ -0,0 +1,102 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <sal/config.h>
+
+#include <test/bootstrapfixture.hxx>
+#include <test/primitive2dxmldump.hxx>
+#include <test/xmltesttools.hxx>
+
+#include <comphelper/processfactory.hxx>
+#include <comphelper/seqstream.hxx>
+#include <comphelper/sequence.hxx>
+
+#include <com/sun/star/graphic/EmfTools.hpp>
+#include <com/sun/star/graphic/Primitive2DTools.hpp>
+#include <com/sun/star/graphic/XPrimitive2D.hpp>
+
+#include <drawinglayer/primitive2d/baseprimitive2d.hxx>
+
+#include <memory>
+
+namespace
+{
+
+using namespace css::uno;
+using namespace css::io;
+using namespace css::graphic;
+using drawinglayer::primitive2d::Primitive2DSequence;
+using drawinglayer::primitive2d::Primitive2DContainer;
+
+class Test : public test::BootstrapFixture, public XmlTestTools
+{
+ void checkRectPrimitive(Primitive2DSequence& rPrimitive);
+
+ void testWorking();
+
+ Primitive2DSequence parseEmf(const char* aSource);
+
+public:
+ CPPUNIT_TEST_SUITE(Test);
+ CPPUNIT_TEST(testWorking);
+ CPPUNIT_TEST_SUITE_END();
+};
+
+Primitive2DSequence Test::parseEmf(const char* aSource)
+{
+ const Reference<XEmfParser> xEmfParser = EmfTools::create(m_xContext);
+
+ OUString aUrl = m_directories.getURLFromSrc(aSource);
+ OUString aPath = m_directories.getPathFromSrc(aSource);
+
+ SvFileStream aFileStream(aUrl, StreamMode::READ);
+ std::size_t nSize = aFileStream.remainingSize();
+ std::unique_ptr<sal_Int8[]> pBuffer(new sal_Int8[nSize + 1]);
+ aFileStream.ReadBytes(pBuffer.get(), nSize);
+ pBuffer[nSize] = 0;
+
+ Sequence<sal_Int8> aData(pBuffer.get(), nSize + 1);
+ Reference<XInputStream> aInputStream(new comphelper::SequenceInputStream(aData));
+
+ return xEmfParser->getDecomposition(aInputStream, aPath);
+}
+
+void Test::checkRectPrimitive(Primitive2DSequence& rPrimitive)
+{
+ Primitive2dXmlDump dumper;
+ xmlDocPtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer<Primitive2DContainer>(rPrimitive));
+
+ CPPUNIT_ASSERT (pDocument);
+
+ // emfio: add examples
+ // assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor", "color", "#00cc00"); // rect background color
+ // assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor", "height", "100"); // rect background height
+ // assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor", "width", "100"); // rect background width
+ // assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor", "minx", "10");
+ // assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor", "miny", "10");
+ // assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor", "maxx", "110");
+ // assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor", "maxy", "110");
+ // assertXPath(pDocument, "/primitive2D/transform/polypolygonstroke/line", "color", "#ff0000"); // rect stroke color
+ // assertXPath(pDocument, "/primitive2D/transform/polypolygonstroke/line", "width", "3"); // rect stroke width
+}
+
+void Test::testWorking()
+{
+ Primitive2DSequence aSequenceRect = parseEmf("/emfio/qa/cppunit/data/fdo79679-2.emf");
+ CPPUNIT_ASSERT_EQUAL(1, (int) aSequenceRect.getLength());
+ checkRectPrimitive(aSequenceRect);
+}
+
+CPPUNIT_TEST_SUITE_REGISTRATION(Test);
+
+}
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/emfio/qa/cppunit/data/fdo79679-2.emf b/emfio/qa/cppunit/data/fdo79679-2.emf
new file mode 100644
index 000000000000..0962dc122152
--- /dev/null
+++ b/emfio/qa/cppunit/data/fdo79679-2.emf
Binary files differ