summaryrefslogtreecommitdiff
path: root/sw/qa
diff options
context:
space:
mode:
authorZolnai Tamás <tamas.zolnai@collabora.com>2014-11-16 15:12:54 +0100
committerZolnai Tamás <tamas.zolnai@collabora.com>2014-11-16 20:30:57 +0100
commit286e2f5c6ec829bc0987b1be7016699f7ef03e5e (patch)
tree2fc69714c8ed08cb0827b09b27585676d21ddd21 /sw/qa
parentc454a0cd0cc7b315b1353b151a2e95654df72c69 (diff)
Related fdo#82953: Forget package URL of image after it is loaded
It causes problems if we handle those imported images differently which are identified by a package URL, so after the first load remove this URL and handle images on the same way as inserted images. Some related bugs: * #i44367# * #i124946# * #i114361# * fdo#73270 The image in the test document has a special ID which is different from that one which is generated by LO internally so after ODF export the new generated image URL is different from the imported one. Change-Id: I4e7d3490674c5f86bec5c7c6e1c975dcafd7c265
Diffstat (limited to 'sw/qa')
-rw-r--r--sw/qa/extras/odfexport/data/document_with_two_images_with_special_IDs.odtbin0 -> 169400 bytes
-rw-r--r--sw/qa/extras/odfexport/odfexport.cxx50
2 files changed, 50 insertions, 0 deletions
diff --git a/sw/qa/extras/odfexport/data/document_with_two_images_with_special_IDs.odt b/sw/qa/extras/odfexport/data/document_with_two_images_with_special_IDs.odt
new file mode 100644
index 000000000000..867c075c41b4
--- /dev/null
+++ b/sw/qa/extras/odfexport/data/document_with_two_images_with_special_IDs.odt
Binary files differ
diff --git a/sw/qa/extras/odfexport/odfexport.cxx b/sw/qa/extras/odfexport/odfexport.cxx
index c1405407d5d0..d7360ba7651a 100644
--- a/sw/qa/extras/odfexport/odfexport.cxx
+++ b/sw/qa/extras/odfexport/odfexport.cxx
@@ -17,6 +17,9 @@
#include <com/sun/star/text/RelOrientation.hpp>
#include <com/sun/star/text/XDocumentIndex.hpp>
#include <com/sun/star/drawing/TextVerticalAdjust.hpp>
+#include <com/sun/star/awt/XBitmap.hpp>
+#include <com/sun/star/graphic/XGraphic.hpp>
+#include <officecfg/Office/Common.hxx>
class Test : public SwModelTestBase
{
@@ -401,6 +404,53 @@ 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();