summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZolnai Tamás <tamas.zolnai@collabora.com>2014-12-07 21:30:12 +0100
committerZolnai Tamás <tamas.zolnai@collabora.com>2014-12-08 15:56:34 +0100
commit614d2f062f104b3ac588814156cb82379cb458af (patch)
tree8c553e456213ff22c749fae7cc7148111ab53ce6
parent27d006e512028cfbc8aae00c5409d873259297d2 (diff)
Generalize this test for other Writer filters
Change-Id: I17bc641373eafc49367d5605072270db6f7fe77b
-rw-r--r--sw/qa/extras/globalfilter/data/images_with_special_IDs.odt (renamed from sw/qa/extras/odfexport/data/document_with_two_images_with_special_IDs.odt)bin169400 -> 169464 bytes
-rw-r--r--sw/qa/extras/globalfilter/globalfilter.cxx84
-rw-r--r--sw/qa/extras/odfexport/odfexport.cxx47
3 files changed, 84 insertions, 47 deletions
diff --git a/sw/qa/extras/odfexport/data/document_with_two_images_with_special_IDs.odt b/sw/qa/extras/globalfilter/data/images_with_special_IDs.odt
index 867c075c41b4..d4c62f5d2b07 100644
--- a/sw/qa/extras/odfexport/data/document_with_two_images_with_special_IDs.odt
+++ b/sw/qa/extras/globalfilter/data/images_with_special_IDs.odt
Binary files differ
diff --git a/sw/qa/extras/globalfilter/globalfilter.cxx b/sw/qa/extras/globalfilter/globalfilter.cxx
index 8e88ef0e5474..23695a2719c5 100644
--- a/sw/qa/extras/globalfilter/globalfilter.cxx
+++ b/sw/qa/extras/globalfilter/globalfilter.cxx
@@ -26,10 +26,12 @@ public:
void testSwappedOutImageExport();
void testLinkedGraphicRT();
+ void testImageWithSpecialID();
CPPUNIT_TEST_SUITE(Test);
CPPUNIT_TEST(testSwappedOutImageExport);
CPPUNIT_TEST(testLinkedGraphicRT);
+ CPPUNIT_TEST(testImageWithSpecialID);
CPPUNIT_TEST_SUITE_END();
};
@@ -177,6 +179,88 @@ void Test::testLinkedGraphicRT()
}
}
+void Test::testImageWithSpecialID()
+{
+ // Check how LO handles when the imported graphic's ID is different from that one
+ // which is generated by LO.
+
+ const OUString aFilterNames[] = {
+ "writer8",
+ "Rich Text Format",
+ "MS Word 97",
+ "Office Open XML Text",
+ };
+
+ // 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 )
+ {
+ if (mxComponent.is())
+ mxComponent->dispose();
+ mxComponent = loadFromDesktop(getURLFromSrc("/sw/qa/extras/globalfilter/data/images_with_special_IDs.odt"), "com.sun.star.text.TextDocument");
+
+ // 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");
+
+ // Check whether graphic exported well
+ uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
+
+ const OString sFailedMessage = OString("Failed on filter: ")
+ + OUStringToOString(aFilterNames[nFilter], RTL_TEXTENCODING_ASCII_US);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(2), xDraws->getCount());
+
+ uno::Reference<drawing::XShape> xImage = getShape(1);
+ uno::Reference< beans::XPropertySet > XPropSet( xImage, uno::UNO_QUERY_THROW );
+ // Check URL
+ {
+ OUString sURL;
+ XPropSet->getPropertyValue("GraphicURL") >>= sURL;
+ CPPUNIT_ASSERT(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(xBitmap.is());
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(610), xBitmap->getSize().Width );
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(381), xBitmap->getSize().Height );
+ }
+ // Second Image
+ xImage = getShape(2);
+ XPropSet.set( xImage, uno::UNO_QUERY_THROW );
+ // Check URL
+ {
+ OUString sURL;
+ XPropSet->getPropertyValue("GraphicURL") >>= sURL;
+ CPPUNIT_ASSERT(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(xBitmap.is());
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(900), xBitmap->getSize().Width );
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(600), xBitmap->getSize().Height );
+ }
+ }
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(Test);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/qa/extras/odfexport/odfexport.cxx b/sw/qa/extras/odfexport/odfexport.cxx
index d7360ba7651a..dc0c9280680d 100644
--- a/sw/qa/extras/odfexport/odfexport.cxx
+++ b/sw/qa/extras/odfexport/odfexport.cxx
@@ -404,53 +404,6 @@ DECLARE_ODFEXPORT_TEST(testTextboxRoundedCorners, "textbox-rounded-corners.odt")
CPPUNIT_ASSERT_EQUAL(OUString("a"), xCell->getString());
}
-DECLARE_ODFEXPORT_TEST(testImageWithSpecialID, "document_with_two_images_with_special_IDs.odt")
-{
- // Here the problem was that LO did not handle well those image URLs in the ODT file which are
- // not match with that one which is generated by LO internaly (based on the image's size, type and so on)
-
- // 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();
-
- uno::Reference<drawing::XShape> xImage = getShape(1);
- uno::Reference< beans::XPropertySet > XPropSet( xImage, uno::UNO_QUERY_THROW );
- // Check URL
- {
- OUString sURL;
- XPropSet->getPropertyValue("GraphicURL") >>= sURL;
- CPPUNIT_ASSERT(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(xBitmap.is());
- CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(610), xBitmap->getSize().Width );
- CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(381), xBitmap->getSize().Height );
- }
- // Second Image
- xImage = getShape(2);
- XPropSet.set( xImage, uno::UNO_QUERY_THROW );
- // Check URL
- {
- OUString sURL;
- XPropSet->getPropertyValue("GraphicURL") >>= sURL;
- CPPUNIT_ASSERT(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(xBitmap.is());
- CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(900), xBitmap->getSize().Width );
- CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(600), xBitmap->getSize().Height );
- }
-}
-
#endif
CPPUNIT_PLUGIN_IMPLEMENT();