summaryrefslogtreecommitdiff
path: root/sw/qa
diff options
context:
space:
mode:
authorZolnai Tamás <tamas.zolnai@collabora.com>2014-12-05 18:07:26 +0100
committerZolnai Tamás <tamas.zolnai@collabora.com>2014-12-07 16:25:05 +0100
commit3b89e351c128cb3d6eea6061d1a4e4a0bffdc9da (patch)
treedf7e58dd67d3a5836211354d991dedac130a11c0 /sw/qa
parent3bebda6335340e6bc15f1bf8427ed95813340d80 (diff)
Test for linked graphic export / import of Writer
Change-Id: Ib41921e9ceed30a05e16ace298d9c5dc87cc5458 (cherry picked from commit 3f28f67084f12fd806e05020ed8bac8d5a05c025)
Diffstat (limited to 'sw/qa')
-rw-r--r--sw/qa/extras/globalfilter/data/document_with_linked_graphic.odtbin0 -> 21466 bytes
-rw-r--r--sw/qa/extras/globalfilter/data/linked_graphic.jpgbin0 -> 35738 bytes
-rw-r--r--sw/qa/extras/globalfilter/globalfilter.cxx63
3 files changed, 63 insertions, 0 deletions
diff --git a/sw/qa/extras/globalfilter/data/document_with_linked_graphic.odt b/sw/qa/extras/globalfilter/data/document_with_linked_graphic.odt
new file mode 100644
index 000000000000..e7aeda6e2eef
--- /dev/null
+++ b/sw/qa/extras/globalfilter/data/document_with_linked_graphic.odt
Binary files differ
diff --git a/sw/qa/extras/globalfilter/data/linked_graphic.jpg b/sw/qa/extras/globalfilter/data/linked_graphic.jpg
new file mode 100644
index 000000000000..2218cdd72df0
--- /dev/null
+++ b/sw/qa/extras/globalfilter/data/linked_graphic.jpg
Binary files differ
diff --git a/sw/qa/extras/globalfilter/globalfilter.cxx b/sw/qa/extras/globalfilter/globalfilter.cxx
index a08c916e6eaa..7478753f4052 100644
--- a/sw/qa/extras/globalfilter/globalfilter.cxx
+++ b/sw/qa/extras/globalfilter/globalfilter.cxx
@@ -25,9 +25,11 @@ public:
Test() : SwModelTestBase() {}
void testSwappedOutImageExport();
+ void testLinkedGraphicRT();
CPPUNIT_TEST_SUITE(Test);
CPPUNIT_TEST(testSwappedOutImageExport);
+ CPPUNIT_TEST(testLinkedGraphicRT);
CPPUNIT_TEST_SUITE_END();
};
@@ -114,6 +116,67 @@ void Test::testSwappedOutImageExport()
}
}
+void Test::testLinkedGraphicRT()
+{
+ const std::vector<OUString> aFilterNames = {
+ "writer8",
+// "Rich Text Format", Note: picture is there, but SwGrfNode is not found?
+ "MS Word 97",
+ "Office Open XML Text",
+ };
+
+ for( size_t nFilter = 0; nFilter < aFilterNames.size(); ++nFilter )
+ {
+ if (mxComponent.is())
+ mxComponent->dispose();
+ mxComponent = loadFromDesktop(getURLFromSrc("/sw/qa/extras/globalfilter/data/document_with_linked_graphic.odt"), "com.sun.star.text.TextDocument");
+
+ const OString sFailedMessage = OString("Failed on filter: ")
+ + OUStringToOString(aFilterNames[nFilter], RTL_TEXTENCODING_ASCII_US);
+
+
+ // Export the document and import again for a check
+ uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY);
+
+ utl::MediaDescriptor aMediaDescriptor;
+ aMediaDescriptor["FilterName"] <<= aFilterNames[nFilter];
+
+ utl::TempFile aTempFile;
+ aTempFile.EnableKillingFile();
+ xStorable->storeToURL(aTempFile.GetURL(), aMediaDescriptor.getAsConstPropertyValueList());
+ uno::Reference< lang::XComponent > xComponent(xStorable, uno::UNO_QUERY);
+ xComponent->dispose();
+ mxComponent = loadFromDesktop(aTempFile.GetURL(), "com.sun.star.text.TextDocument");
+
+ SwXTextDocument* pTxtDoc = dynamic_cast<SwXTextDocument *>(mxComponent.get());
+ CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), pTxtDoc);
+ SwDoc* pDoc = pTxtDoc->GetDocShell()->GetDoc();
+ CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), pDoc);
+ SwNodes& aNodes = pDoc->GetNodes();
+
+ // Find the image
+ bool bImageFound = false;
+ for( sal_uLong nIndex = 0; nIndex < aNodes.Count(); ++nIndex)
+ {
+ if( aNodes[nIndex]->IsGrfNode() )
+ {
+ SwGrfNode* pGrfNode = aNodes[nIndex]->GetGrfNode();
+ // RT via DOCX makes linked graphic embedded?!
+ if( aFilterNames[nFilter] != "Office Open XML Text" )
+ {
+ CPPUNIT_ASSERT_MESSAGE( sFailedMessage.getStr(), pGrfNode->IsGrfLink());
+ }
+ const GraphicObject& rGraphicObj = pGrfNode->GetGrfObj(true);
+ CPPUNIT_ASSERT_MESSAGE( sFailedMessage.getStr(), !rGraphicObj.IsSwappedOut());
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( sFailedMessage.getStr(), GRAPHIC_BITMAP, rGraphicObj.GetType());
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( sFailedMessage.getStr(), sal_uLong(864900), rGraphicObj.GetSizeBytes());
+ bImageFound = true;
+ }
+ }
+ CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), bImageFound);
+ }
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(Test);
CPPUNIT_PLUGIN_IMPLEMENT();