diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-06-29 11:07:23 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-06-29 10:36:21 +0000 |
commit | 71b2dc0de9514d9972211f03641f64b7ed9ed8f3 (patch) | |
tree | 0d1dc0d54a0a0d36575b43e7f2800be0488c7491 /svtools/qa | |
parent | 488fd60c2dc2372f3dc33f5a5313e4f032adf968 (diff) |
vcl: handle PDF data in Read/WriteImpGraphic()
Initially I wrote the test to cover
f7d6f3e4e3fda3cd4936880918e2831246634a3e (svtools: survive swapout/in of
graphic with embedded pdf, 2016-06-28), but as it turns out the actual
swapin/out code is in vcl, so extend that as well to support pdf data.
Change-Id: I320ea729dce9440b84a5089607807322ea7b0b04
Reviewed-on: https://gerrit.libreoffice.org/26755
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'svtools/qa')
-rw-r--r-- | svtools/qa/unit/GraphicObjectTest.cxx | 34 | ||||
-rw-r--r-- | svtools/qa/unit/data/pdf.odt | bin | 0 -> 18113 bytes |
2 files changed, 34 insertions, 0 deletions
diff --git a/svtools/qa/unit/GraphicObjectTest.cxx b/svtools/qa/unit/GraphicObjectTest.cxx index 22664425677f..c785fadd4890 100644 --- a/svtools/qa/unit/GraphicObjectTest.cxx +++ b/svtools/qa/unit/GraphicObjectTest.cxx @@ -41,6 +41,7 @@ public: void testSizeBasedAutoSwap(); void testTdf88836(); void testTdf88935(); + void testPdf(); virtual void setUp() override @@ -59,6 +60,7 @@ private: CPPUNIT_TEST(testSizeBasedAutoSwap); CPPUNIT_TEST(testTdf88836); CPPUNIT_TEST(testTdf88935); + CPPUNIT_TEST(testPdf); CPPUNIT_TEST_SUITE_END(); }; @@ -307,6 +309,38 @@ void GraphicObjectTest::testTdf88935() xComponent->dispose(); } +void GraphicObjectTest::testPdf() +{ + uno::Reference<lang::XComponent> xComponent = loadFromDesktop(m_directories.getURLFromSrc("svtools/qa/unit/data/pdf.odt"), "com.sun.star.text.TextDocument"); + SwXTextDocument* pTxtDoc = dynamic_cast<SwXTextDocument*>(xComponent.get()); + CPPUNIT_ASSERT(pTxtDoc); + SwDoc* pDoc = pTxtDoc->GetDocShell()->GetDoc(); + CPPUNIT_ASSERT(pDoc); + SwNodes& aNodes = pDoc->GetNodes(); + + // Find images + GraphicObject* pGraphicObject = nullptr; + for( sal_uLong nIndex = 0; nIndex < aNodes.Count(); ++nIndex) + { + if( aNodes[nIndex]->IsGrfNode() ) + { + SwGrfNode* pGrfNode = aNodes[nIndex]->GetGrfNode(); + CPPUNIT_ASSERT(pGrfNode); + pGraphicObject = const_cast<GraphicObject*>(&pGrfNode->GetGrfObj()); + break; + } + } + CPPUNIT_ASSERT_MESSAGE("Missing image", pGraphicObject); + + CPPUNIT_ASSERT(pGraphicObject->GetGraphic().getPdfData().hasElements()); + pGraphicObject->SwapOut(); + pGraphicObject->SwapIn(); + // This failed, swap out + swap in lost the PDF data. + CPPUNIT_ASSERT(pGraphicObject->GetGraphic().getPdfData().hasElements()); + + xComponent->dispose(); +} + CPPUNIT_TEST_SUITE_REGISTRATION(GraphicObjectTest); } diff --git a/svtools/qa/unit/data/pdf.odt b/svtools/qa/unit/data/pdf.odt Binary files differnew file mode 100644 index 000000000000..f20b389207d6 --- /dev/null +++ b/svtools/qa/unit/data/pdf.odt |