[Libreoffice-commits] core.git: Branch 'libreoffice-6-3' - svx/qa svx/source toolkit/source

Miklos Vajna (via logerrit) logerrit at kemper.freedesktop.org
Thu Sep 5 09:05:22 UTC 2019


 svx/qa/unit/data/tdf93998.odp             |binary
 svx/qa/unit/unodraw.cxx                   |   33 ++++++++++++++++++++++++++++++
 svx/source/unodraw/unoshap2.cxx           |   10 ++++-----
 toolkit/source/controls/dialogcontrol.cxx |   25 ++++++++++++++++++++--
 toolkit/source/helper/property.cxx        |    2 -
 5 files changed, 61 insertions(+), 9 deletions(-)

New commits:
commit ef1224b6c80f478127d4b1ee10916b379dee56ec
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Mon Aug 26 17:54:50 2019 +0200
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Thu Sep 5 11:04:41 2019 +0200

    tdf#93998 toolkit: restore support for setting dialog background from shape
    
    Regression from commit fb29e6eeeaad5255bb924ff59162a83ed80bfb0a (svx:
    removing GraphicURL and OWN_ATTR_GRAFURL, fix writerfilter, 2018-03-08),
    the problem was that an in-document macro tried to assign a bitmap shape
    to a dialog background, which broke during the image handling rework.
    
    Note that in this case the actual type of the "URL" is not interesting,
    we can just return an XGraphic and then take it on the other side as
    well, without re-introducing the intentionally removed graphic URLs
    which point to memory addresses.
    
    This also made it necessary to extend
    UnoDialogControl::ImplModelPropertiesChanged(), so that in case a
    graphic is assigned to the dialog model, then the dialog model -> dialog
    sync code doesn't just copy over the empty image URL string. With this,
    finally clicking on the button of the bugdoc makes the dialog show up
    with the correct background.
    
    (cherry picked from commit 3341986547b69bcb4c38e4ccb2f0853a3a569bb5)
    
    Change-Id: Id78269643289efb435b96a6a0b9f8a93fa49ec04
    Reviewed-on: https://gerrit.libreoffice.org/78171
    Tested-by: Jenkins
    Tested-by: Xisco Faulí <xiscofauli at libreoffice.org>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/svx/qa/unit/data/tdf93998.odp b/svx/qa/unit/data/tdf93998.odp
new file mode 100644
index 000000000000..889aeeb0216f
Binary files /dev/null and b/svx/qa/unit/data/tdf93998.odp differ
diff --git a/svx/qa/unit/unodraw.cxx b/svx/qa/unit/unodraw.cxx
index f3d28bda4bac..7ad6c6f6f9a1 100644
--- a/svx/qa/unit/unodraw.cxx
+++ b/svx/qa/unit/unodraw.cxx
@@ -13,6 +13,10 @@
 #include <com/sun/star/drawing/GraphicExportFilter.hpp>
 #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
 #include <com/sun/star/frame/Desktop.hpp>
+#include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/awt/XControl.hpp>
+#include <com/sun/star/graphic/XGraphic.hpp>
 
 #include <comphelper/processfactory.hxx>
 #include <comphelper/propertysequence.hxx>
@@ -77,6 +81,35 @@ CPPUNIT_TEST_FIXTURE(UnodrawTest, testWriterGraphicExport)
                                            { "MediaType", uno::Any(OUString("image/jpeg")) } }));
     CPPUNIT_ASSERT(xExportFilter->filter(aProperties));
 }
+
+CPPUNIT_TEST_FIXTURE(UnodrawTest, testTdf93998)
+{
+    mxComponent = loadFromDesktop(m_directories.getURLFromSrc(DATA_DIRECTORY) + "tdf93998.odp");
+    uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(mxComponent, uno::UNO_QUERY);
+    CPPUNIT_ASSERT(xDrawPagesSupplier.is());
+
+    uno::Reference<drawing::XDrawPage> xDrawPage(xDrawPagesSupplier->getDrawPages()->getByIndex(0),
+                                                 uno::UNO_QUERY);
+    CPPUNIT_ASSERT(xDrawPage.is());
+
+    uno::Reference<beans::XPropertySet> xShape(xDrawPage->getByIndex(0), uno::UNO_QUERY);
+    CPPUNIT_ASSERT(xShape.is());
+
+    uno::Reference<lang::XMultiServiceFactory> xFactory = comphelper::getProcessServiceFactory();
+    uno::Reference<awt::XControlModel> xModel(
+        xFactory->createInstance("com.sun.star.awt.UnoControlDialogModel"), uno::UNO_QUERY);
+    CPPUNIT_ASSERT(xModel.is());
+
+    uno::Reference<beans::XPropertySet> xModelProps(xModel, uno::UNO_QUERY);
+    CPPUNIT_ASSERT(xModelProps.is());
+
+    // This resulted in a uno::RuntimeException, assigning a shape to a dialog model's image was
+    // broken.
+    xModelProps->setPropertyValue("ImageURL", xShape->getPropertyValue("GraphicURL"));
+    uno::Reference<graphic::XGraphic> xGraphic;
+    xModelProps->getPropertyValue("Graphic") >>= xGraphic;
+    CPPUNIT_ASSERT(xGraphic.is());
+}
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/unodraw/unoshap2.cxx b/svx/source/unodraw/unoshap2.cxx
index 760b6eb4da6a..b3d224dedd78 100644
--- a/svx/source/unodraw/unoshap2.cxx
+++ b/svx/source/unodraw/unoshap2.cxx
@@ -1475,13 +1475,13 @@ bool SvxGraphicObject::getPropertyValueImpl( const OUString& rName, const SfxIte
     }
 
     case OWN_ATTR_GRAPHIC_URL:
-    {
-        throw uno::RuntimeException("Getting from this property is not supported");
-        break;
-    }
-
     case OWN_ATTR_VALUE_GRAPHIC:
     {
+        if (pProperty->nWID == OWN_ATTR_GRAPHIC_URL)
+        {
+            SAL_WARN("svx", "Getting Graphic by URL is not supported, getting it by value");
+        }
+
         Reference<graphic::XGraphic> xGraphic;
         auto pSdrGraphicObject = static_cast<SdrGrafObj*>(GetSdrObject());
         if (pSdrGraphicObject->GetGraphicObject().GetType() != GraphicType::NONE)
diff --git a/toolkit/source/controls/dialogcontrol.cxx b/toolkit/source/controls/dialogcontrol.cxx
index ef23735bdc25..d8da13850688 100644
--- a/toolkit/source/controls/dialogcontrol.cxx
+++ b/toolkit/source/controls/dialogcontrol.cxx
@@ -278,8 +278,18 @@ void SAL_CALL UnoControlDialogModel::setFastPropertyValue_NoBroadcast( sal_Int32
         if ( nHandle == BASEPROPERTY_IMAGEURL && ImplHasProperty( BASEPROPERTY_GRAPHIC ) )
         {
             OUString sImageURL;
-            OSL_VERIFY( rValue >>= sImageURL );
-            setPropertyValue( GetPropertyName( BASEPROPERTY_GRAPHIC ), uno::makeAny( ImageHelper::getGraphicAndGraphicObjectFromURL_nothrow( mxGrfObj, sImageURL ) ) );
+            uno::Reference<graphic::XGraphic> xGraphic;
+            if (rValue >>= sImageURL)
+            {
+                setPropertyValue(
+                    GetPropertyName(BASEPROPERTY_GRAPHIC),
+                    uno::makeAny(ImageHelper::getGraphicAndGraphicObjectFromURL_nothrow(
+                        mxGrfObj, sImageURL)));
+            }
+            else if (rValue >>= xGraphic)
+            {
+                setPropertyValue("Graphic", uno::makeAny(xGraphic));
+            }
         }
     }
     catch( const css::uno::Exception& )
@@ -618,7 +628,7 @@ void UnoDialogControl::ImplModelPropertiesChanged( const Sequence< PropertyChang
         const PropertyChangeEvent& rEvt = rEvents.getConstArray()[i];
         Reference< XControlModel > xModel( rEvt.Source, UNO_QUERY );
         bool bOwnModel = xModel.get() == getModel().get();
-        if ( bOwnModel && rEvt.PropertyName == "ImageURL" )
+        if (bOwnModel && rEvt.PropertyName == "ImageURL" && !ImplHasProperty(BASEPROPERTY_GRAPHIC))
         {
             OUString aImageURL;
             Reference< graphic::XGraphic > xGraphic;
@@ -631,6 +641,15 @@ void UnoDialogControl::ImplModelPropertiesChanged( const Sequence< PropertyChang
             ImplSetPropertyValue(  GetPropertyName( BASEPROPERTY_GRAPHIC), uno::makeAny( xGraphic ), true );
             break;
         }
+        else if (bOwnModel && rEvt.PropertyName == "Graphic")
+        {
+            uno::Reference<graphic::XGraphic> xGraphic;
+            if (ImplGetPropertyValue("Graphic") >>= xGraphic)
+            {
+                ImplSetPropertyValue("Graphic", uno::makeAny(xGraphic), true);
+            }
+            break;
+        }
     }
     ControlContainerBase::ImplModelPropertiesChanged(rEvents);
 }
diff --git a/toolkit/source/helper/property.cxx b/toolkit/source/helper/property.cxx
index e6ce48ab826a..ad9ca0c89edf 100644
--- a/toolkit/source/helper/property.cxx
+++ b/toolkit/source/helper/property.cxx
@@ -161,7 +161,7 @@ static ImplPropertyInfo* ImplGetPropertyInfos( sal_uInt16& rElementCount )
         DECL_PROP_2     ( "HardLineBreaks",         HARDLINEBREAKS,     bool,               BOUND, MAYBEDEFAULT ),
         DECL_PROP_2     ( "ImageAlign",             IMAGEALIGN,         sal_Int16,          BOUND, MAYBEDEFAULT),
         DECL_PROP_2     ( "ImagePosition",          IMAGEPOSITION,      sal_Int16,          BOUND, MAYBEDEFAULT),
-        DECL_PROP_2     ( "ImageURL",               IMAGEURL,           OUString,           BOUND, MAYBEDEFAULT ),
+        DECL_PROP_2     ( "ImageURL",               IMAGEURL,           css::uno::Any,      BOUND, MAYBEDEFAULT ),
         DECL_PROP_3     ( "ItemSeparatorPos",       ITEM_SEPARATOR_POS, sal_Int16,          BOUND, MAYBEDEFAULT, MAYBEVOID ),
         DECL_PROP_2     ( "Label",                  LABEL,              OUString,           BOUND, MAYBEDEFAULT ),
         DECL_PROP_3     ( "LineColor",              LINECOLOR,          sal_Int32,          BOUND, MAYBEDEFAULT, MAYBEVOID ),


More information about the Libreoffice-commits mailing list