[Libreoffice-commits] core.git: Branch 'libreoffice-4-3' - svx/source sw/CppunitTest_sw_odfexport.mk sw/qa sw/source

Zolnai Tamás tamas.zolnai at collabora.com
Mon Nov 17 01:19:47 PST 2014


 svx/source/svdraw/svdograf.cxx                                            |    2 
 sw/CppunitTest_sw_odfexport.mk                                            |    4 
 sw/qa/extras/odfexport/data/document_with_two_images_with_special_IDs.odt |binary
 sw/qa/extras/odfexport/odfexport.cxx                                      |   50 ++++++++++
 sw/source/core/graphic/ndgrf.cxx                                          |    4 
 5 files changed, 59 insertions(+), 1 deletion(-)

New commits:
commit 33ab79d7e324489194b086812c920af06870e032
Author: Zolnai Tamás <tamas.zolnai at collabora.com>
Date:   Sun Nov 16 21:38:11 2014 +0100

    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.
    
    (cherry picked from commit 286e2f5c6ec829bc0987b1be7016699f7ef03e5e)
    
    Change-Id: Ic80adf76c72123af8e89ca3daa4dfa57d7c362a6
    Reviewed-on: https://gerrit.libreoffice.org/12503
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/svx/source/svdraw/svdograf.cxx b/svx/source/svdraw/svdograf.cxx
index 5a9496f..fcc9d14 100644
--- a/svx/source/svdraw/svdograf.cxx
+++ b/svx/source/svdraw/svdograf.cxx
@@ -1374,7 +1374,7 @@ IMPL_LINK( SdrGrafObj, ImpSwapHdl, GraphicObject*, pO )
                         const OUString aNewUserData( pGraphic->GetUserData() );
 
                         pGraphic->SetGraphic( aGraphic );
-                        pGraphic->SetUserData( aNewUserData );
+                        pGraphic->SetUserData();
 
                         // Graphic successfully swapped in.
                         pRet = GRFMGR_AUTOSWAPSTREAM_LOADED;
diff --git a/sw/CppunitTest_sw_odfexport.mk b/sw/CppunitTest_sw_odfexport.mk
index 2c0e19a..5cfc8f0 100644
--- a/sw/CppunitTest_sw_odfexport.mk
+++ b/sw/CppunitTest_sw_odfexport.mk
@@ -79,6 +79,10 @@ $(eval $(call gb_CppunitTest_use_components,sw_odfexport,\
     xmloff/util/xo \
 ))
 
+$(eval $(call gb_CppunitTest_use_custom_headers,sw_odfexport,\
+    officecfg/registry \
+))
+
 $(eval $(call gb_CppunitTest_use_configuration,sw_odfexport))
 
 $(eval $(call gb_CppunitTest_use_unittest_configuration,sw_odfexport))
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 0000000..867c075
Binary files /dev/null and b/sw/qa/extras/odfexport/data/document_with_two_images_with_special_IDs.odt differ
diff --git a/sw/qa/extras/odfexport/odfexport.cxx b/sw/qa/extras/odfexport/odfexport.cxx
index c0b42c0..1a4c9d5 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
 {
@@ -386,6 +389,53 @@ DECLARE_ODFEXPORT_TEST(testShapeRelsize, "shape-relsize.odt")
     CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME, getProperty<sal_Int16>(xShape, "RelativeHeightRelation"));
 }
 
+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();
diff --git a/sw/source/core/graphic/ndgrf.cxx b/sw/source/core/graphic/ndgrf.cxx
index 00e383d..83bc6fc 100644
--- a/sw/source/core/graphic/ndgrf.cxx
+++ b/sw/source/core/graphic/ndgrf.cxx
@@ -578,6 +578,10 @@ bool SwGrfNode::SwapIn( bool bWaitForData )
                 {
                     bRet = ImportGraphic( *pStrm );
                     delete pStrm;
+                    if( bRet )
+                    {
+                        maGrfObj.SetUserData();
+                    }
                 }
             }
             catch (const uno::Exception&)


More information about the Libreoffice-commits mailing list