[Libreoffice-commits] core.git: Branch 'libreoffice-6-1' - include/svx sd/qa svx/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Sun Dec 9 21:15:45 UTC 2018


 include/svx/unoshprp.hxx        |    2 -
 sd/qa/unit/data/tdf120527.jpg   |binary
 sd/qa/unit/misc-tests.cxx       |   44 ++++++++++++++++++++++++++++++++++++++++
 svx/source/unodraw/unoshap2.cxx |   14 ++++++++++++
 4 files changed, 59 insertions(+), 1 deletion(-)

New commits:
commit 323d12f278d3b0a51c7c2b8d3a362a27a6a232d3
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Mon Nov 26 21:14:39 2018 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Sun Dec 9 22:15:24 2018 +0100

    tdf#120527 svx GraphicObjectShape: handle XBitmap for GraphicURL
    
    This restores compatibility for API users who called getByName() on the
    bitmap table and expected that the result can be set as a value for the
    GraphicURL property.
    
    The case is similar to the Writer images, which was handled in commit
    587803ba46055d43b5b108be744fdde17aeabc7c (sw TextGraphicObject: handle
    XBitmap for GraphicURL, 2018-08-08) already.
    
    (cherry picked from commit e30f3e76a9350e2b027d99bba5a46aa0a0ff8256)
    
    Conflicts:
            sd/qa/unit/misc-tests.cxx
    
    Change-Id: I3740a68989b306425d0d6c4d4e350ac163cb4170
    Reviewed-on: https://gerrit.libreoffice.org/64643
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/include/svx/unoshprp.hxx b/include/svx/unoshprp.hxx
index 6341c37f3dc6..a09f242506a9 100644
--- a/include/svx/unoshprp.hxx
+++ b/include/svx/unoshprp.hxx
@@ -431,7 +431,7 @@
     { OUString(UNO_NAME_GRAPHOBJ_GRAFSTREAMURL),        OWN_ATTR_GRAFSTREAMURL      , ::cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::MAYBEVOID, 0 }, \
     { OUString(UNO_NAME_GRAPHOBJ_FILLBITMAP),           OWN_ATTR_VALUE_FILLBITMAP   , cppu::UnoType<css::awt::XBitmap>::get()  ,    0,     0},    \
     { OUString(UNO_NAME_GRAPHOBJ_GRAPHIC),              OWN_ATTR_VALUE_GRAPHIC      , cppu::UnoType<css::graphic::XGraphic>::get()  ,   0,     0}, \
-    { OUString(UNO_NAME_GRAPHOBJ_GRAPHIC_URL),          OWN_ATTR_GRAPHIC_URL        , cppu::UnoType<OUString>::get(), 0, 0 }, \
+    { OUString(UNO_NAME_GRAPHOBJ_GRAPHIC_URL),          OWN_ATTR_GRAPHIC_URL        , cppu::UnoType<css::uno::Any>::get(), 0, 0 }, \
     { OUString(UNO_NAME_GRAPHOBJ_IS_SIGNATURELINE),     OWN_ATTR_IS_SIGNATURELINE   , cppu::UnoType<bool>::get(), 0, 0}, \
     { OUString(UNO_NAME_GRAPHOBJ_SIGNATURELINE_ID),     OWN_ATTR_SIGNATURELINE_ID   , cppu::UnoType<OUString>::get(), 0, 0}, \
     { OUString(UNO_NAME_GRAPHOBJ_SIGNATURELINE_SUGGESTED_SIGNER_NAME), OWN_ATTR_SIGNATURELINE_SUGGESTED_SIGNER_NAME, cppu::UnoType<OUString>::get(), 0, 0}, \
diff --git a/sd/qa/unit/data/tdf120527.jpg b/sd/qa/unit/data/tdf120527.jpg
new file mode 100644
index 000000000000..12b393569efb
Binary files /dev/null and b/sd/qa/unit/data/tdf120527.jpg differ
diff --git a/sd/qa/unit/misc-tests.cxx b/sd/qa/unit/misc-tests.cxx
index ace77cdcc96e..445129b4ece7 100644
--- a/sd/qa/unit/misc-tests.cxx
+++ b/sd/qa/unit/misc-tests.cxx
@@ -62,6 +62,7 @@ public:
     void testFillGradient();
     void testTdf44774();
     void testTdf38225();
+    void testTdf120527();
 
     CPPUNIT_TEST_SUITE(SdMiscTest);
     CPPUNIT_TEST(testTdf96206);
@@ -71,6 +72,7 @@ public:
     CPPUNIT_TEST(testFillGradient);
     CPPUNIT_TEST(testTdf44774);
     CPPUNIT_TEST(testTdf38225);
+    CPPUNIT_TEST(testTdf120527);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -361,6 +363,48 @@ void SdMiscTest::testTdf38225()
     CPPUNIT_ASSERT(pStyle);
 }
 
+void SdMiscTest::testTdf120527()
+{
+    sd::DrawDocShellRef xDocShRef
+        = new sd::DrawDocShell(SfxObjectCreateMode::EMBEDDED, false, DocumentType::Draw);
+    uno::Reference<frame::XLoadable> xLoadable(xDocShRef->GetModel(), uno::UNO_QUERY);
+    CPPUNIT_ASSERT(xLoadable.is());
+    xLoadable->initNew();
+
+    // Load a bitmap into the bitmap table.
+    uno::Reference<lang::XMultiServiceFactory> xFactory(xDocShRef->GetModel(), uno::UNO_QUERY);
+    CPPUNIT_ASSERT(xFactory.is());
+    uno::Reference<container::XNameContainer> xBitmaps(
+        xFactory->createInstance("com.sun.star.drawing.BitmapTable"), uno::UNO_QUERY);
+    CPPUNIT_ASSERT(xBitmaps.is());
+    OUString aGraphicURL = m_directories.getURLFromSrc("/sd/qa/unit/data/tdf120527.jpg");
+    xBitmaps->insertByName("test", uno::makeAny(aGraphicURL));
+
+    // Create a graphic.
+    uno::Reference<drawing::XShape> xShape(
+        xFactory->createInstance("com.sun.star.drawing.GraphicObjectShape"), uno::UNO_QUERY);
+    CPPUNIT_ASSERT(xShape.is());
+    uno::Reference<beans::XPropertySet> xShapeProperySet(xShape, uno::UNO_QUERY);
+    CPPUNIT_ASSERT(xShapeProperySet.is());
+    xShapeProperySet->setPropertyValue("GraphicURL", xBitmaps->getByName("test"));
+
+    // Insert it.
+    uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(xDocShRef->GetModel(),
+                                                                   uno::UNO_QUERY);
+    CPPUNIT_ASSERT(xDrawPagesSupplier.is());
+    uno::Reference<drawing::XDrawPages> xDrawPages = xDrawPagesSupplier->getDrawPages();
+    CPPUNIT_ASSERT(xDrawPages.is());
+    uno::Reference<drawing::XDrawPage> xDrawPage(xDrawPages->getByIndex(0), uno::UNO_QUERY);
+    CPPUNIT_ASSERT(xDrawPage.is());
+    // This failed with a lang.IllegalArgumentException.
+    xDrawPage->add(xShape);
+
+    // Verify that the graphic was actually consumed.
+    uno::Reference<graphic::XGraphic> xGraphic;
+    xShapeProperySet->getPropertyValue("Graphic") >>= xGraphic;
+    CPPUNIT_ASSERT(xGraphic.is());
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SdMiscTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/svx/source/unodraw/unoshap2.cxx b/svx/source/unodraw/unoshap2.cxx
index 6214ef5b360d..ccd37a7250ce 100644
--- a/svx/source/unodraw/unoshap2.cxx
+++ b/svx/source/unodraw/unoshap2.cxx
@@ -1367,6 +1367,7 @@ bool SvxGraphicObject::setPropertyValueImpl( const OUString& rName, const SfxIte
     case OWN_ATTR_GRAPHIC_URL:
     {
         OUString aURL;
+        uno::Reference<awt::XBitmap> xBitmap;
         if (rValue >>= aURL)
         {
             Graphic aGraphic = vcl::graphic::loadFromURL(aURL);
@@ -1376,6 +1377,19 @@ bool SvxGraphicObject::setPropertyValueImpl( const OUString& rName, const SfxIte
                 bOk = true;
             }
         }
+        else if (rValue >>= xBitmap)
+        {
+            uno::Reference<graphic::XGraphic> xGraphic(xBitmap, uno::UNO_QUERY);
+            if (xGraphic.is())
+            {
+                Graphic aGraphic = xGraphic;
+                if (aGraphic)
+                {
+                    static_cast<SdrGrafObj*>(GetSdrObject())->SetGraphic(aGraphic);
+                    bOk = true;
+                }
+            }
+        }
         break;
     }
 


More information about the Libreoffice-commits mailing list