summaryrefslogtreecommitdiff
path: root/sdext/source/pdfimport/test
diff options
context:
space:
mode:
Diffstat (limited to 'sdext/source/pdfimport/test')
-rw-r--r--sdext/source/pdfimport/test/outputwrap.hxx27
-rw-r--r--sdext/source/pdfimport/test/testTdf96993.pdfbin0 -> 12665 bytes
-rw-r--r--sdext/source/pdfimport/test/tests.cxx31
3 files changed, 58 insertions, 0 deletions
diff --git a/sdext/source/pdfimport/test/outputwrap.hxx b/sdext/source/pdfimport/test/outputwrap.hxx
index 015a3e288e88..aa4c541229df 100644
--- a/sdext/source/pdfimport/test/outputwrap.hxx
+++ b/sdext/source/pdfimport/test/outputwrap.hxx
@@ -25,6 +25,7 @@
#include <cppuhelper/compbase.hxx>
#include <com/sun/star/io/XOutputStream.hpp>
#include <osl/file.hxx>
+#include <rtl/strbuf.hxx>
namespace pdfi
{
@@ -59,6 +60,32 @@ typedef ::cppu::WeakComponentImplHelper<
maFile.close();
}
};
+
+ class OutputWrapString : private cppu::BaseMutex, public OutputWrapBase
+ {
+ OString& mrString;
+ OStringBuffer maBuffer;
+
+ public:
+
+ explicit OutputWrapString(OString& rString) : OutputWrapBase(m_aMutex), mrString(rString), maBuffer(rString)
+ {
+ }
+
+ virtual void SAL_CALL writeBytes(const css::uno::Sequence< ::sal_Int8 >& aData) throw (css::io::NotConnectedException, css::io::BufferSizeExceededException, css::io::IOException, css::uno::RuntimeException, std::exception) override
+ {
+ maBuffer.append(reinterpret_cast<const sal_Char *>(aData.getConstArray()), aData.getLength());
+ }
+
+ virtual void SAL_CALL flush() throw (css::io::NotConnectedException, css::io::BufferSizeExceededException, css::io::IOException, css::uno::RuntimeException, std::exception) override
+ {
+ }
+
+ virtual void SAL_CALL closeOutput() throw (css::io::NotConnectedException, css::io::BufferSizeExceededException, css::io::IOException, css::uno::RuntimeException, std::exception) override
+ {
+ mrString = maBuffer.makeStringAndClear();
+ }
+ };
}
#endif
diff --git a/sdext/source/pdfimport/test/testTdf96993.pdf b/sdext/source/pdfimport/test/testTdf96993.pdf
new file mode 100644
index 000000000000..73abbd129eb1
--- /dev/null
+++ b/sdext/source/pdfimport/test/testTdf96993.pdf
Binary files differ
diff --git a/sdext/source/pdfimport/test/tests.cxx b/sdext/source/pdfimport/test/tests.cxx
index cdad633c0ded..e2b043c9defc 100644
--- a/sdext/source/pdfimport/test/tests.cxx
+++ b/sdext/source/pdfimport/test/tests.cxx
@@ -496,10 +496,41 @@ namespace
osl::File::remove( tempFileURL );
}
+ void testTdf96993()
+ {
+ uno::Reference<pdfi::PDFIRawAdaptor> xAdaptor(new pdfi::PDFIRawAdaptor(OUString(), getComponentContext()));
+ xAdaptor->setTreeVisitorFactory(createDrawTreeVisitorFactory());
+
+ OString aOutput;
+ CPPUNIT_ASSERT_MESSAGE("Exporting to ODF",
+ xAdaptor->odfConvert(getURLFromSrc("/sdext/source/pdfimport/test/testTdf96993.pdf"),
+ new OutputWrapString(aOutput),
+ nullptr));
+ // This ensures that the imported image arrives properly flipped
+ CPPUNIT_ASSERT(aOutput.indexOf("draw:transform=\"matrix(18520.8333333333 0 0 26281.9444444444 0 0)\"") != -1);
+ }
+
+ void testTdf98421()
+ {
+ uno::Reference<pdfi::PDFIRawAdaptor> xAdaptor(new pdfi::PDFIRawAdaptor(OUString(), getComponentContext()));
+ xAdaptor->setTreeVisitorFactory(createWriterTreeVisitorFactory());
+
+ OString aOutput;
+ CPPUNIT_ASSERT_MESSAGE("Exporting to ODF",
+ xAdaptor->odfConvert(getURLFromSrc("/sdext/source/pdfimport/test/testTdf96993.pdf"),
+ new OutputWrapString(aOutput),
+ nullptr));
+ // This ensures that the imported image arrives properly flipped
+ CPPUNIT_ASSERT(aOutput.indexOf("draw:transform=\"scale( 1.0 -1.0 ) translate( 0mm 0mm )\"") != -1);
+ CPPUNIT_ASSERT(aOutput.indexOf("svg:height=\"-262.82mm\"") != -1);
+ }
+
CPPUNIT_TEST_SUITE(PDFITest);
CPPUNIT_TEST(testXPDFParser);
CPPUNIT_TEST(testOdfWriterExport);
CPPUNIT_TEST(testOdfDrawExport);
+ CPPUNIT_TEST(testTdf96993);
+ CPPUNIT_TEST(testTdf98421);
CPPUNIT_TEST_SUITE_END();
};