summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZolnai Tamás <tamas.zolnai@collabora.com>2014-12-05 00:40:55 +0100
committerZolnai Tamás <tamas.zolnai@collabora.com>2014-12-07 16:24:51 +0100
commit3bebda6335340e6bc15f1bf8427ed95813340d80 (patch)
treeb5035c7d2597b525eb549d5e498c573fbfadc9e0
parentTest for linked graphic export / import of Impress (diff)
downloadcore-3bebda6335340e6bc15f1bf8427ed95813340d80.tar.gz
core-3bebda6335340e6bc15f1bf8427ed95813340d80.zip
Test for linked graphic export / import of Calc
To avoid regression fixed by: 02b17c1bbdd19a978b9de646c0dacdad179c60de Change-Id: Iaf2dea0cf221cb0e53debe4c1c611aab86dc29ff (cherry picked from commit ff8f2cb8ebde75cce65bb715fefcad778d568fe4)
-rw-r--r--sc/qa/unit/data/ods/document_with_linked_graphic.odsbin0 -> 41370 bytes
-rw-r--r--sc/qa/unit/data/ods/linked_graphic.jpgbin0 -> 35738 bytes
-rw-r--r--sc/qa/unit/subsequent_export-test.cxx42
3 files changed, 42 insertions, 0 deletions
diff --git a/sc/qa/unit/data/ods/document_with_linked_graphic.ods b/sc/qa/unit/data/ods/document_with_linked_graphic.ods
new file mode 100644
index 000000000000..14cad8c84bd2
--- /dev/null
+++ b/sc/qa/unit/data/ods/document_with_linked_graphic.ods
Binary files differ
diff --git a/sc/qa/unit/data/ods/linked_graphic.jpg b/sc/qa/unit/data/ods/linked_graphic.jpg
new file mode 100644
index 000000000000..2218cdd72df0
--- /dev/null
+++ b/sc/qa/unit/data/ods/linked_graphic.jpg
Binary files differ
diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx
index 8aff9e11b58a..33312e46dce2 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -130,7 +130,9 @@ public:
void testPivotTableXLSX();
void testPivotTableTwoDataFieldsXLSX();
+
void testSwappedOutImageExport();
+ void testLinkedGraphicRT();
void testSupBookVirtualPath();
@@ -177,6 +179,7 @@ public:
CPPUNIT_TEST(testSupBookVirtualPath);
#endif
CPPUNIT_TEST(testSwappedOutImageExport);
+ CPPUNIT_TEST(testLinkedGraphicRT);
CPPUNIT_TEST_SUITE_END();
@@ -2375,6 +2378,45 @@ void ScExportTest::testSupBookVirtualPath()
xDocSh->DoClose();
}
+void ScExportTest::testLinkedGraphicRT()
+{
+ // Problem was with linked images
+ const char* aFilterNames[] = {
+ "calc8",
+ "MS Excel 97",
+ "Calc Office Open XML",
+ "generic_HTML",
+ };
+
+ for( size_t nFilter = 0; nFilter < SAL_N_ELEMENTS(aFilterNames); ++nFilter )
+ {
+ // Load the original file with one image
+ ScDocShellRef xDocSh = loadDoc("document_with_linked_graphic.", ODS);
+ const OString sFailedMessage = OString("Failed on filter: ") + aFilterNames[nFilter];
+
+ // Export the document and import again for a check
+ ScDocShellRef xDocSh2 = saveAndReload(xDocSh, nFilter);
+ xDocSh->DoClose();
+
+ // Check whether graphic imported well after export
+ ScDocument& rDoc = xDocSh->GetDocument();
+ ScDrawLayer* pDrawLayer = rDoc.GetDrawLayer();
+ CPPUNIT_ASSERT_MESSAGE( sFailedMessage.getStr(), pDrawLayer != NULL );
+ const SdrPage *pPage = pDrawLayer->GetPage(0);
+ CPPUNIT_ASSERT_MESSAGE( sFailedMessage.getStr(), pPage != NULL );
+ SdrGrafObj* pObject = dynamic_cast<SdrGrafObj*>(pPage->GetObj(0));
+ CPPUNIT_ASSERT_MESSAGE( sFailedMessage.getStr(), pObject != NULL );
+ CPPUNIT_ASSERT_MESSAGE( sFailedMessage.getStr(), pObject->IsLinkedGraphic() );
+
+ const GraphicObject& rGraphicObj = pObject->GetGraphicObject(true);
+ CPPUNIT_ASSERT_MESSAGE( sFailedMessage.getStr(), !rGraphicObj.IsSwappedOut());
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( sFailedMessage.getStr(), GRAPHIC_BITMAP, rGraphicObj.GetGraphic().GetType());
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( sFailedMessage.getStr(), sal_uLong(864900), rGraphicObj.GetSizeBytes());
+
+ xDocSh2->DoClose();
+ }
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(ScExportTest);
CPPUNIT_PLUGIN_IMPLEMENT();