[Libreoffice-commits] core.git: 5 commits - sc/qa sd/qa svx/source sw/CppunitTest_sw_globalfilter.mk sw/qa

Zolnai Tamás tamas.zolnai at collabora.com
Mon Dec 8 06:57:22 PST 2014


 dev/null                                                   |binary
 sc/qa/unit/data/ods/images_with_special_IDs.ods            |binary
 sc/qa/unit/subsequent_export-test.cxx                      |   74 +++++
 sd/qa/unit/data/odp/images_with_special_IDs.odp            |binary
 sd/qa/unit/export-tests.cxx                                |   82 ++++++
 svx/source/svdraw/svdograf.cxx                             |    2 
 sw/CppunitTest_sw_globalfilter.mk                          |    1 
 sw/qa/extras/globalfilter/data/graphic_shape.odt           |binary
 sw/qa/extras/globalfilter/data/images_with_special_IDs.odt |binary
 sw/qa/extras/globalfilter/globalfilter.cxx                 |  174 +++++++++++++
 sw/qa/extras/odfexport/odfexport.cxx                       |   47 ---
 11 files changed, 332 insertions(+), 48 deletions(-)

New commits:
commit 9ff7aac6c8f1fa6bce8df8b95f20993d789a51a7
Author: Zolnai Tamás <tamas.zolnai at collabora.com>
Date:   Mon Dec 8 03:38:36 2014 +0100

    Test for Writer import / export of graphic shapes
    
    Graphic shapes are those images which are created not in
    Writer (but e.g. Impress, Calc) and moved to Writer later
    (e.g. copy&paste).
    
    Embedded image is ok, but MS filters broke the linked
    graphic shape.
    
    Change-Id: I0c86a5d09afb3e40f7d9e5986c05801457d4c13f

diff --git a/sw/CppunitTest_sw_globalfilter.mk b/sw/CppunitTest_sw_globalfilter.mk
index f02bd41..fd2001e 100644
--- a/sw/CppunitTest_sw_globalfilter.mk
+++ b/sw/CppunitTest_sw_globalfilter.mk
@@ -63,6 +63,7 @@ $(eval $(call gb_CppunitTest_use_components,sw_globalfilter,\
 	forms/util/frm \
 	framework/util/fwk \
 	i18npool/util/i18npool \
+	linguistic/source/lng \
 	oox/util/oox \
 	package/source/xstor/xstor \
 	package/util/package2 \
diff --git a/sw/qa/extras/globalfilter/data/graphic_shape.odt b/sw/qa/extras/globalfilter/data/graphic_shape.odt
new file mode 100644
index 0000000..425e8c2
Binary files /dev/null and b/sw/qa/extras/globalfilter/data/graphic_shape.odt differ
diff --git a/sw/qa/extras/globalfilter/globalfilter.cxx b/sw/qa/extras/globalfilter/globalfilter.cxx
index 23695a2..c4b9811 100644
--- a/sw/qa/extras/globalfilter/globalfilter.cxx
+++ b/sw/qa/extras/globalfilter/globalfilter.cxx
@@ -27,11 +27,13 @@ public:
     void testSwappedOutImageExport();
     void testLinkedGraphicRT();
     void testImageWithSpecialID();
+    void testGraphicShape();
 
     CPPUNIT_TEST_SUITE(Test);
     CPPUNIT_TEST(testSwappedOutImageExport);
     CPPUNIT_TEST(testLinkedGraphicRT);
     CPPUNIT_TEST(testImageWithSpecialID);
+    CPPUNIT_TEST(testGraphicShape);
     CPPUNIT_TEST_SUITE_END();
 };
 
@@ -261,6 +263,94 @@ void Test::testImageWithSpecialID()
     }
 }
 
+void Test::testGraphicShape()
+{
+    // There are two kind of images in Writer: 1) Writer specific handled by SwGrfNode and
+    // 2) graphic shape handled by SdrGrafObj (e.g. after copy&paste from Impress).
+
+    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/graphic_shape.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 );
+        // First image is embedded
+        // 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 );
+        }
+
+        // MS filters make this kind of linked images broken !?
+        if( aFilterNames[nFilter] != "writer8" )
+            return;
+
+        // Second image is a linked one
+        xImage = getShape(2);
+        XPropSet.set( xImage, uno::UNO_QUERY_THROW );
+        // Check URL
+        {
+            OUString sURL;
+            XPropSet->getPropertyValue("GraphicURL") >>= sURL;
+            CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), sURL.endsWith("linked_graphic.jpg"));
+        }
+        // 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>(620), xBitmap->getSize().Width );
+            CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(465), xBitmap->getSize().Height );
+        }
+    }
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
commit 3650b66c366177877d30f6aae83a33bf683d3457
Author: Zolnai Tamás <tamas.zolnai at collabora.com>
Date:   Mon Dec 8 03:11:18 2014 +0100

    Copying linked graphic between components is broken
    
    IsLinkedGraphic() is better to use here.
    
    Reproducer steps:
    -Insert an image to Impress as a link.
    -Copy this image (CTRL+C & CTRL+V) to Writer.
    Result: Image is not displayed.
    
    Change-Id: Iaf9b686b5c87caf5a0cc15425f8c5988f857bfe6

diff --git a/svx/source/svdraw/svdograf.cxx b/svx/source/svdraw/svdograf.cxx
index a353e0f..b60cdd1 100644
--- a/svx/source/svdraw/svdograf.cxx
+++ b/svx/source/svdraw/svdograf.cxx
@@ -840,7 +840,7 @@ SdrGrafObj& SdrGrafObj::operator=( const SdrGrafObj& rObj )
     aFilterName = rObj.aFilterName;
     bMirrored = rObj.bMirrored;
 
-    if( rObj.pGraphicLink != NULL)
+    if( rObj.IsLinkedGraphic() )
     {
         SetGraphicLink( aFileName, rObj.aReferer, aFilterName );
     }
commit 5b3166ffd314a68afdc4f464312606afc881ac89
Author: Zolnai Tamás <tamas.zolnai at collabora.com>
Date:   Mon Dec 8 02:47:12 2014 +0100

    Test also Calc export / import of images with special ID
    
    Change-Id: I6c47c4b78a1dcd76287cdca16265d3170d2794f5

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 0000000..f87fd8e
Binary files /dev/null and b/sc/qa/unit/data/ods/images_with_special_IDs.ods differ
diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx
index 33312e4..a57a652 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();
commit 2264171e4c128b176b8544f91086489e0403c5bf
Author: Zolnai Tamás <tamas.zolnai at collabora.com>
Date:   Mon Dec 8 02:34:32 2014 +0100

    Test also Impress export / import of images with special ID
    
    Change-Id: If040bb32bb5289a282f315cd6ca90cbed76f9b8f

diff --git a/sd/qa/unit/data/odp/images_with_special_IDs.odp b/sd/qa/unit/data/odp/images_with_special_IDs.odp
new file mode 100644
index 0000000..f6a5545
Binary files /dev/null and b/sd/qa/unit/data/odp/images_with_special_IDs.odp differ
diff --git a/sd/qa/unit/export-tests.cxx b/sd/qa/unit/export-tests.cxx
index 7b17668..2641b71 100644
--- a/sd/qa/unit/export-tests.cxx
+++ b/sd/qa/unit/export-tests.cxx
@@ -80,6 +80,7 @@ public:
     void testFdo79731();
     void testSwappedOutImageExport();
     void testLinkedGraphicRT();
+    void testImageWithSpecialID();
 
     CPPUNIT_TEST_SUITE(SdExportTest);
     CPPUNIT_TEST(testN821567);
@@ -98,6 +99,7 @@ public:
     CPPUNIT_TEST(testFdo79731);
     CPPUNIT_TEST(testSwappedOutImageExport);
     CPPUNIT_TEST(testLinkedGraphicRT);
+    CPPUNIT_TEST(testImageWithSpecialID);
     CPPUNIT_TEST_SUITE_END();
 };
 
@@ -638,6 +640,86 @@ void SdExportTest::testLinkedGraphicRT()
     }
 }
 
+void SdExportTest::testImageWithSpecialID()
+{
+    // Check how LO handles when the imported graphic's ID is different from that one
+    // which is generated by LO.
+    const sal_Int32 vFormats[] = {
+        ODP,
+        PPT,
+        PPTX,
+    };
+
+    // 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 nExportFormat = 0; nExportFormat < SAL_N_ELEMENTS(vFormats); ++nExportFormat )
+    {
+        // Load the original file
+        ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/odp/images_with_special_IDs.odp"), ODP);
+        const OString sFailedMessage = OString("Failed on filter: ") + OString(aFileFormats[vFormats[nExportFormat]].pFilterName);
+
+        // Export the document and import again for a check
+        uno::Reference< lang::XComponent > xComponent(xDocShRef->GetModel(), uno::UNO_QUERY);
+        uno::Reference<frame::XStorable> xStorable(xComponent, uno::UNO_QUERY);
+        utl::MediaDescriptor aMediaDescriptor;
+        aMediaDescriptor["FilterName"] <<= OStringToOUString(OString(aFileFormats[vFormats[nExportFormat]].pFilterName), RTL_TEXTENCODING_UTF8);
+
+        utl::TempFile aTempFile;
+        aTempFile.EnableKillingFile();
+        xStorable->storeToURL(aTempFile.GetURL(), aMediaDescriptor.getAsConstPropertyValueList());
+        xComponent.set(xStorable, uno::UNO_QUERY);
+        xComponent->dispose();
+        xDocShRef = loadURL(aTempFile.GetURL(), nExportFormat);
+
+        // Check whether graphic was exported well
+        uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(xDocShRef->GetModel(), uno::UNO_QUERY);
+        CPPUNIT_ASSERT_MESSAGE( sFailedMessage.getStr(), xDrawPagesSupplier->getDrawPages()->getCount() == 2 );
+        uno::Reference< drawing::XDrawPage > xDrawPage( xDrawPagesSupplier->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW );
+
+        uno::Reference<drawing::XShape> xImage(xDrawPage->getByIndex(2), 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
+        xDrawPage.set(xDrawPagesSupplier->getDrawPages()->getByIndex(1), uno::UNO_QUERY_THROW );
+        xImage.set(xDrawPage->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 );
+        }
+        xDocShRef->DoClose();
+    }
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SdExportTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
commit 614d2f062f104b3ac588814156cb82379cb458af
Author: Zolnai Tamás <tamas.zolnai at collabora.com>
Date:   Sun Dec 7 21:30:12 2014 +0100

    Generalize this test for other Writer filters
    
    Change-Id: I17bc641373eafc49367d5605072270db6f7fe77b

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
similarity index 88%
rename from sw/qa/extras/odfexport/data/document_with_two_images_with_special_IDs.odt
rename to sw/qa/extras/globalfilter/data/images_with_special_IDs.odt
index 867c075..d4c62f5 100644
Binary files a/sw/qa/extras/odfexport/data/document_with_two_images_with_special_IDs.odt and b/sw/qa/extras/globalfilter/data/images_with_special_IDs.odt differ
diff --git a/sw/qa/extras/globalfilter/globalfilter.cxx b/sw/qa/extras/globalfilter/globalfilter.cxx
index 8e88ef0..23695a2 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 d7360ba..dc0c928 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();


More information about the Libreoffice-commits mailing list