diff options
author | Zolnai Tamás <tamas.zolnai@collabora.com> | 2014-12-05 00:40:55 +0100 |
---|---|---|
committer | Zolnai Tamás <tamas.zolnai@collabora.com> | 2014-12-07 16:21:41 +0100 |
commit | ff8f2cb8ebde75cce65bb715fefcad778d568fe4 (patch) | |
tree | 62cb1db5b5221b0e338fc3e1307e107e06fb7185 /sc/qa | |
parent | 33e49c711c988dfbbb75b605878850f83180a796 (diff) |
Test for linked graphic export / import of Calc
To avoid regression fixed by:
02b17c1bbdd19a978b9de646c0dacdad179c60de
Change-Id: Iaf2dea0cf221cb0e53debe4c1c611aab86dc29ff
Diffstat (limited to 'sc/qa')
-rw-r--r-- | sc/qa/unit/data/ods/document_with_linked_graphic.ods | bin | 0 -> 41370 bytes | |||
-rw-r--r-- | sc/qa/unit/data/ods/linked_graphic.jpg | bin | 0 -> 35738 bytes | |||
-rw-r--r-- | sc/qa/unit/subsequent_export-test.cxx | 42 |
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 Binary files differnew file mode 100644 index 000000000000..14cad8c84bd2 --- /dev/null +++ b/sc/qa/unit/data/ods/document_with_linked_graphic.ods diff --git a/sc/qa/unit/data/ods/linked_graphic.jpg b/sc/qa/unit/data/ods/linked_graphic.jpg Binary files differnew file mode 100644 index 000000000000..2218cdd72df0 --- /dev/null +++ b/sc/qa/unit/data/ods/linked_graphic.jpg 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(); |