summaryrefslogtreecommitdiff
path: root/filter
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@collabora.com>2014-06-10 19:27:40 +0200
committerJan Holesovsky <kendy@collabora.com>2014-06-10 19:33:12 +0200
commit71457cb2cb61f20ef569d1600b430ef41a878ec9 (patch)
tree3f91698ca7d83186197af14506616b0261c0e085 /filter
parentce90fa303234e9e6628bf9dfcc7f81565a639d06 (diff)
pct import: Unit test for the clipping import fix.
Change-Id: I8f9df1d92c86c087e37f77209f413ff8c1c6358f
Diffstat (limited to 'filter')
-rw-r--r--filter/qa/cppunit/data/pict/clipping-problem.pctbin0 -> 32768 bytes
-rw-r--r--filter/qa/cppunit/filters-pict-test.cxx35
-rw-r--r--filter/source/graphicfilter/ipict/ipict.cxx11
-rw-r--r--filter/source/graphicfilter/ipict/ipict.hxx25
4 files changed, 69 insertions, 2 deletions
diff --git a/filter/qa/cppunit/data/pict/clipping-problem.pct b/filter/qa/cppunit/data/pict/clipping-problem.pct
new file mode 100644
index 000000000000..37fe66c80f7a
--- /dev/null
+++ b/filter/qa/cppunit/data/pict/clipping-problem.pct
Binary files differ
diff --git a/filter/qa/cppunit/filters-pict-test.cxx b/filter/qa/cppunit/filters-pict-test.cxx
index 7ba01456fc7f..0512b9b22287 100644
--- a/filter/qa/cppunit/filters-pict-test.cxx
+++ b/filter/qa/cppunit/filters-pict-test.cxx
@@ -10,12 +10,17 @@
#include <unotest/filters-test.hxx>
#include <test/bootstrapfixture.hxx>
#include <vcl/FilterConfigItem.hxx>
+#include <test/mtfxmldump.hxx>
+#include <test/xmltesttools.hxx>
#include <tools/stream.hxx>
#include <vcl/graph.hxx>
+#include <vcl/metaactiontypes.hxx>
#include <osl/file.hxx>
#include <osl/process.h>
+#include "../../source/graphicfilter/ipict/ipict.hxx"
+
extern "C"
{
SAL_DLLPUBLIC_EXPORT bool SAL_CALL
@@ -30,6 +35,7 @@ using namespace ::com::sun::star;
class PictFilterTest
: public test::FiltersTest
, public test::BootstrapFixture
+ , public XmlTestTools
{
public:
PictFilterTest() : BootstrapFixture(true, false) {}
@@ -38,13 +44,21 @@ public:
const OUString &rURL, const OUString &,
unsigned int, unsigned int, unsigned int) SAL_OVERRIDE;
+ OUString pictURL()
+ {
+ return getURLFromSrc("/filter/qa/cppunit/data/pict/");
+ }
+
/**
* Ensure CVEs remain unbroken
*/
void testCVEs();
+ void testDontClipTooMuch();
+
CPPUNIT_TEST_SUITE(PictFilterTest);
CPPUNIT_TEST(testCVEs);
+ CPPUNIT_TEST(testDontClipTooMuch);
CPPUNIT_TEST_SUITE_END();
};
@@ -60,10 +74,29 @@ bool PictFilterTest::load(const OUString &,
void PictFilterTest::testCVEs()
{
testDir(OUString(),
- getURLFromSrc("/filter/qa/cppunit/data/pict/"),
+ pictURL(),
OUString());
}
+void PictFilterTest::testDontClipTooMuch()
+{
+ SvFileStream aFileStream(pictURL() + "clipping-problem.pct", STREAM_READ);
+ GDIMetaFile aGDIMetaFile;
+ pict::ReadPictFile(aFileStream, aGDIMetaFile);
+
+ MetafileXmlDump dumper;
+ dumper.filterAllActionTypes();
+ dumper.filterActionType(META_CLIPREGION_ACTION, false);
+ xmlDocPtr pDoc = dumper.dumpAndParse(aGDIMetaFile);
+
+ CPPUNIT_ASSERT (pDoc);
+
+ assertXPath(pDoc, "/metafile/clipregion[5]", "top", "0");
+ assertXPath(pDoc, "/metafile/clipregion[5]", "left", "0");
+ assertXPath(pDoc, "/metafile/clipregion[5]", "bottom", "-32767");
+ assertXPath(pDoc, "/metafile/clipregion[5]", "right", "-32767");
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(PictFilterTest);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/filter/source/graphicfilter/ipict/ipict.cxx b/filter/source/graphicfilter/ipict/ipict.cxx
index e1304299d27c..8d3af9e71cd5 100644
--- a/filter/source/graphicfilter/ipict/ipict.cxx
+++ b/filter/source/graphicfilter/ipict/ipict.cxx
@@ -17,7 +17,6 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-
#include <string.h>
#include <osl/thread.h>
#include <vcl/bmpacc.hxx>
@@ -26,6 +25,7 @@
#include <vcl/virdev.hxx>
#include <math.h>
+#include "ipict.hxx"
#include "shape.hxx"
#include <boost/scoped_array.hpp>
@@ -1940,5 +1940,14 @@ GraphicImport( SvStream& rIStm, Graphic & rGraphic, FilterConfigItem* )
return bRet;
}
+namespace pict {
+
+SAL_DLLPUBLIC_EXPORT void ReadPictFile(SvStream &rStreamPict, GDIMetaFile& rGDIMetaFile)
+{
+ PictReader aPictReader;
+ aPictReader.ReadPict(rStreamPict, rGDIMetaFile);
+}
+
+}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/filter/source/graphicfilter/ipict/ipict.hxx b/filter/source/graphicfilter/ipict/ipict.hxx
new file mode 100644
index 000000000000..1ba3dbef1cca
--- /dev/null
+++ b/filter/source/graphicfilter/ipict/ipict.hxx
@@ -0,0 +1,25 @@
+/* -*- 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/.
+ */
+
+#ifndef INCLUDED_FILTER_SOURCE_GRAPHICFILTER_IPICT_HXX
+#define INCLUDED_FILTER_SOURCE_GRAPHICFILTER_IPICT_HXX
+
+class GDIMetaFile;
+class SvStream;
+
+namespace pict {
+
+/// Function to access PictReader::ReadPict for unit testing.
+void ReadPictFile(SvStream &rStreamPict, GDIMetaFile& rGDIMetaFile);
+
+}
+
+#endif // INCLUDED_FILTER_SOURCE_GRAPHICFILTER_IPICT_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */