Kaydet (Commit) 5b3166ff authored tarafından Zolnai Tamás's avatar Zolnai Tamás

Test also Calc export / import of images with special ID

Change-Id: I6c47c4b78a1dcd76287cdca16265d3170d2794f5
üst 2264171e
...@@ -133,6 +133,7 @@ public: ...@@ -133,6 +133,7 @@ public:
void testSwappedOutImageExport(); void testSwappedOutImageExport();
void testLinkedGraphicRT(); void testLinkedGraphicRT();
void testImageWithSpecialID();
void testSupBookVirtualPath(); void testSupBookVirtualPath();
...@@ -180,6 +181,7 @@ public: ...@@ -180,6 +181,7 @@ public:
#endif #endif
CPPUNIT_TEST(testSwappedOutImageExport); CPPUNIT_TEST(testSwappedOutImageExport);
CPPUNIT_TEST(testLinkedGraphicRT); CPPUNIT_TEST(testLinkedGraphicRT);
CPPUNIT_TEST(testImageWithSpecialID);
CPPUNIT_TEST_SUITE_END(); CPPUNIT_TEST_SUITE_END();
...@@ -2417,6 +2419,78 @@ void ScExportTest::testLinkedGraphicRT() ...@@ -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_TEST_SUITE_REGISTRATION(ScExportTest);
CPPUNIT_PLUGIN_IMPLEMENT(); CPPUNIT_PLUGIN_IMPLEMENT();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment