From efff12770fb16df8f8b405a08d28339e2a82a4b1 Mon Sep 17 00:00:00 2001 From: Jan Holesovsky Date: Thu, 12 Mar 2020 19:01:36 +0100 Subject: [PATCH] pdfium: Test insertion of PDF into a document. Change-Id: Ide2643349fbf5cdf79e68c2c504d1cd486c09d7f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90996 Tested-by: Jenkins Reviewed-by: Jan Holesovsky --- sw/qa/extras/uiwriter/data/hello-world.pdf | Bin 0 -> 6961 bytes sw/qa/extras/uiwriter/uiwriter.cxx | 38 +++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 sw/qa/extras/uiwriter/data/hello-world.pdf diff --git a/sw/qa/extras/uiwriter/data/hello-world.pdf b/sw/qa/extras/uiwriter/data/hello-world.pdf new file mode 100644 index 0000000000000000000000000000000000000000..ae2fa81b9841b7cb6c2cef709373f15cc0214de3 GIT binary patch literal 6961 zcmai32UJtp)|RFc5Cx@(ln7F!rI990x=58SJwSla0wf?!dat6=l%^mcMXI1w1wvD# zs)Q;aT@Xc@fc}Zkc{B6oz4hO#o(q5i z!9cvNGeA}rq=j{NBsu|M6p21a4d+V4dV$njF+{8i)(&rvm6rz)h+bHX8^AY9GOiKO zcKMX*{$89p(^*I1{ftO#d(Ux=@cU&wlI@zKrZ@N-JY-E5xU2N=VsjYTtLf?<$Zrw%?3*bk4?r;07 ziCiMy!*y~VYVrmGu}Nr)If`twJc2Dvw48!x8E+}vl3<*8wssGZ zo4Q(#>{}Rin|QshQ@5qX=i?JCP0m43Kbsl)RsXcxQQT5{xF470*LoGgEZyVOsoZ%h5$4u-`k{m6}IjpUqR4&;ntN;nb$q%pYieCs>( zKwO{99(I10_TyC7Cx#5=AS)@_+^C`{bt!t?7ec$eZdOVj%<^GX2XcYwu2B`Xr59!- zA4Vs)yEtu07EJD26&9bx+lirkn6~yenB`7npV>c^f0<=VkMGF~wAU#~N6#EbW5;@QfL*zWZaU_~_*H}Q_Rq*GKvVyKZ@-xm* zRa^%j9=nP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PjFDAd#{I z^70^MO6U~d1R#}h*Z)f!P=leiH^tDu10?|d5gp*q@F)v@#YYVZNGZ7{&YoZn{FMWB zs*LxhR_QM;Ab(-`fB8_xP#PQWNU4V-CH-IJ0DyEou)HA~TU$#J|*UfF2DxR9p0qnQ8op+2L!q{yk^z$kJkB{Uf950{keRVc4KL{%<9sTwfK zdj%wAfD#8oM8IH?i+`!AuNT$<00u&&0TfHWFCYRAhrxjkz~3@B3PAxp^#Z#8Ap?UU z6p;Ui3`)h|-(?6ejM6=Smw}1-;(F;R4`n{;oHo*B~DWwAGOGz_kSLdpaFe-&yIsNn6Cov?N; z1aCJW2&$^8qK1SjDx;7pFf}j*B}$4=MW_lyO<5JKtfoYTGJ%NkBL3P^gftQb5E4?= HRRjDV)Zg#^ literal 0 HcmV?d00001 diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx index aab02513762f..dc14133f6e08 100644 --- a/sw/qa/extras/uiwriter/uiwriter.cxx +++ b/sw/qa/extras/uiwriter/uiwriter.cxx @@ -369,6 +369,9 @@ public: void testTdf38394(); void testTdf59666(); void testInconsistentBookmark(); +#if HAVE_FEATURE_PDFIUM + void testInsertPdf(); +#endif CPPUNIT_TEST_SUITE(SwUiWriterTest); CPPUNIT_TEST(testReplaceForward); @@ -579,6 +582,9 @@ public: CPPUNIT_TEST(testTdf54409); CPPUNIT_TEST(testTdf38394); CPPUNIT_TEST(testTdf59666); +#if HAVE_FEATURE_PDFIUM + CPPUNIT_TEST(testInsertPdf); +#endif CPPUNIT_TEST_SUITE_END(); private: @@ -7191,6 +7197,38 @@ void SwUiWriterTest::testTdf59666() CPPUNIT_ASSERT_EQUAL(sReplaced, static_cast(pDoc->GetNodes()[nIndex])->GetText()); } +#if HAVE_FEATURE_PDFIUM +void SwUiWriterTest::testInsertPdf() +{ + createDoc(); + SwXTextDocument *pTextDoc = dynamic_cast(mxComponent.get()); + CPPUNIT_ASSERT(pTextDoc); + + // insert the PDF into the document + uno::Sequence aArgs(comphelper::InitPropertySequence({ + {"FileName", uno::Any(m_directories.getURLFromSrc(DATA_DIRECTORY) + "hello-world.pdf")} + })); + dispatchCommand(mxComponent, ".uno:InsertGraphic", aArgs); + + // Save and load cycle + utl::TempFile aTempFile; + save("writer8", aTempFile); + loadURL(aTempFile.GetURL(), nullptr); + pTextDoc = dynamic_cast(mxComponent.get()); + CPPUNIT_ASSERT(pTextDoc); + + uno::Reference xShape = getShape(1); + // Assert that we have a replacement graphics + auto xReplacementGraphic = getProperty>(xShape, "ReplacementGraphic"); + CPPUNIT_ASSERT(xReplacementGraphic.is()); + + auto xGraphic = getProperty>(xShape, "Graphic"); + CPPUNIT_ASSERT(xGraphic.is()); + // Assert that the graphic is a PDF + CPPUNIT_ASSERT_EQUAL(OUString("application/pdf"), getProperty(xGraphic, "MimeType")); +} +#endif + CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest); CPPUNIT_PLUGIN_IMPLEMENT();