summaryrefslogtreecommitdiff
path: root/sc/qa/unit
diff options
context:
space:
mode:
authorZolnai Tamás <tamas.zolnai@collabora.com>2014-12-08 02:47:12 +0100
committerZolnai Tamás <tamas.zolnai@collabora.com>2014-12-08 15:56:34 +0100
commit5b3166ffd314a68afdc4f464312606afc881ac89 (patch)
treec1aa5f80dc94ba2ee72bdcff014b5b470c99a3d9 /sc/qa/unit
parent2264171e4c128b176b8544f91086489e0403c5bf (diff)
Test also Calc export / import of images with special ID
Change-Id: I6c47c4b78a1dcd76287cdca16265d3170d2794f5
Diffstat (limited to 'sc/qa/unit')
-rw-r--r--sc/qa/unit/data/ods/images_with_special_IDs.odsbin0 -> 175735 bytes
-rw-r--r--sc/qa/unit/subsequent_export-test.cxx74
2 files changed, 74 insertions, 0 deletions
diff --git a/sc/qa/unit/data/ods/images_with_special_IDs.ods b/sc/qa/unit/data/ods/images_with_special_IDs.ods
new file mode 100644
index 000000000000..f87fd8e3dc4d
--- /dev/null
+++ b/sc/qa/unit/data/ods/images_with_special_IDs.ods
Binary files differ
diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx
index 33312e46dce2..a57a652f8098 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -133,6 +133,7 @@ public:
void testSwappedOutImageExport();
void testLinkedGraphicRT();
+ void testImageWithSpecialID();
void testSupBookVirtualPath();
@@ -180,6 +181,7 @@ public:
#endif
CPPUNIT_TEST(testSwappedOutImageExport);
CPPUNIT_TEST(testLinkedGraphicRT);
+ CPPUNIT_TEST(testImageWithSpecialID);
CPPUNIT_TEST_SUITE_END();
@@ -2417,6 +2419,78 @@ void ScExportTest::testLinkedGraphicRT()
}
}
+void ScExportTest::testImageWithSpecialID()
+{
+ const char* aFilterNames[] = {
+ "calc8",
+ "MS Excel 97",
+ "Calc Office Open XML",
+ "generic_HTML",
+ };
+
+ // Trigger swap out mechanism to test swapped state factor too.
+ boost::shared_ptr< comphelper::ConfigurationChanges > batch(comphelper::ConfigurationChanges::create());
+ officecfg::Office::Common::Cache::GraphicManager::TotalCacheSize::set(sal_Int32(1), batch);
+ batch->commit();
+
+ for( size_t nFilter = 0; nFilter < SAL_N_ELEMENTS(aFilterNames); ++nFilter )
+ {
+ ScDocShellRef xDocSh = loadDoc("images_with_special_IDs.", ODS);
+
+ const OString sFailedMessage = OString("Failed on filter: ") + aFilterNames[nFilter];
+ CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), xDocSh.Is());
+
+ // Export the document and import again for a check
+ ScDocShellRef xDocSh2 = saveAndReload(xDocSh, nFilter);
+ xDocSh->DoClose();
+
+ // Check whether graphic was exported well
+ uno::Reference< frame::XModel > xModel = xDocSh2->GetModel();
+ uno::Reference< sheet::XSpreadsheetDocument > xDoc(xModel, UNO_QUERY_THROW);
+ uno::Reference< container::XIndexAccess > xIA(xDoc->getSheets(), UNO_QUERY_THROW);
+ uno::Reference< drawing::XDrawPageSupplier > xDrawPageSupplier( xIA->getByIndex(0), UNO_QUERY_THROW);
+ uno::Reference< container::XIndexAccess > xDraws(xDrawPageSupplier->getDrawPage(), UNO_QUERY_THROW);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(2), xDraws->getCount());
+
+ uno::Reference<drawing::XShape> xImage(xDraws->getByIndex(0), uno::UNO_QUERY);
+ uno::Reference< beans::XPropertySet > XPropSet( xImage, uno::UNO_QUERY_THROW );
+ // Check URL
+ {
+ OUString sURL;
+ XPropSet->getPropertyValue("GraphicURL") >>= sURL;
+ CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), sURL != OUString("vnd.sun.star.GraphicObject:00000000000000000000000000000000"));
+ }
+ // Check size
+ {
+ uno::Reference<graphic::XGraphic> xGraphic;
+ XPropSet->getPropertyValue("Graphic") >>= xGraphic;
+ uno::Reference<awt::XBitmap> xBitmap(xGraphic, uno::UNO_QUERY);
+ CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), xBitmap.is());
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(610), xBitmap->getSize().Width );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(381), xBitmap->getSize().Height );
+ }
+ // Second Image
+ xImage.set(xDraws->getByIndex(1), uno::UNO_QUERY);
+ XPropSet.set( xImage, uno::UNO_QUERY_THROW );
+ // Check URL
+ {
+ OUString sURL;
+ XPropSet->getPropertyValue("GraphicURL") >>= sURL;
+ CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), sURL != OUString("vnd.sun.star.GraphicObject:00000000000000000000000000000000"));
+ }
+ // Check size
+ {
+ uno::Reference<graphic::XGraphic> xGraphic;
+ XPropSet->getPropertyValue("Graphic") >>= xGraphic;
+ uno::Reference<awt::XBitmap> xBitmap(xGraphic, uno::UNO_QUERY);
+ CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), xBitmap.is());
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(900), xBitmap->getSize().Width );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(600), xBitmap->getSize().Height );
+ }
+ xDocSh2->DoClose();
+ }
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(ScExportTest);
CPPUNIT_PLUGIN_IMPLEMENT();