[Libreoffice-commits] core.git: include/editeng include/svx offapi/com offapi/type_reference svx/source sw/inc sw/source

Tomaž Vajngerl tomaz.vajngerl at collabora.co.uk
Thu May 3 11:06:56 UTC 2018


 include/editeng/unoprnms.hxx                       |    1 
 include/svx/unoshprp.hxx                           |    3 +
 offapi/com/sun/star/drawing/GraphicObjectShape.idl |   21 ++++++++---
 offapi/com/sun/star/style/NumberingLevel.idl       |   17 +++++++--
 offapi/com/sun/star/text/TextGraphicObject.idl     |   15 ++++++--
 offapi/type_reference/offapi.idl                   |    5 +-
 svx/source/unodraw/unoshap2.cxx                    |   22 ++++++++++++
 sw/inc/cmdid.h                                     |    2 -
 sw/source/core/unocore/unoframe.cxx                |   37 ++++++++++++++++-----
 sw/source/core/unocore/unomap1.cxx                 |    1 
 10 files changed, 99 insertions(+), 25 deletions(-)

New commits:
commit 2bf4d69e0bfa98d641939e62945a7f8915441297
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Thu Apr 26 19:28:35 2018 +0900

    [API CHANGE] revert and deprecate GraphicURL, modify Graphic prop.
    
    Revert the state of GraphicURL property so it supports setting a
    external URL, but getting throws and exception.
    
    Modify the Graphic property, so it reflects what was used with
    GraphicURL before.
    
    Change-Id: Ia05b8ea37997b5ed8c75215557cce9979630c898
    Reviewed-on: https://gerrit.libreoffice.org/53509
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>

diff --git a/include/editeng/unoprnms.hxx b/include/editeng/unoprnms.hxx
index d90be0f6b45d..8ac52ede237f 100644
--- a/include/editeng/unoprnms.hxx
+++ b/include/editeng/unoprnms.hxx
@@ -165,6 +165,7 @@
 #define UNO_NAME_GRAPHOBJ_GRAFSTREAMURL         "GraphicStreamURL"
 #define UNO_NAME_GRAPHOBJ_URLPKGPREFIX          "vnd.sun.star.Package:"
 #define UNO_NAME_GRAPHOBJ_GRAPHIC               "Graphic"
+#define UNO_NAME_GRAPHOBJ_GRAPHIC_URL           "GraphicURL"
 #define UNO_NAME_GRAPHOBJ_IS_SIGNATURELINE      "IsSignatureLine"
 #define UNO_NAME_GRAPHOBJ_SIGNATURELINE_ID      "SignatureLineId"
 #define UNO_NAME_GRAPHOBJ_SIGNATURELINE_SUGGESTED_SIGNER_NAME "SignatureLineSuggestedSignerName"
diff --git a/include/svx/unoshprp.hxx b/include/svx/unoshprp.hxx
index 1794f1d9d96d..6341c37f3dc6 100644
--- a/include/svx/unoshprp.hxx
+++ b/include/svx/unoshprp.hxx
@@ -98,7 +98,7 @@
 #define OWN_ATTR_LDNAME                         (OWN_ATTR_VALUE_START+30)
 #define OWN_ATTR_LDBITMAP                       (OWN_ATTR_VALUE_START+31)
 #define OWN_ATTR_OLESIZE                        (OWN_ATTR_VALUE_START+32)
-//#define free                                  (OWN_ATTR_VALUE_START+33)
+#define OWN_ATTR_GRAPHIC_URL                    (OWN_ATTR_VALUE_START+33)
 #define OWN_ATTR_OLEMODEL                       (OWN_ATTR_VALUE_START+34)
 #define OWN_ATTR_MIRRORED                       (OWN_ATTR_VALUE_START+35)
 #define OWN_ATTR_CLSID                          (OWN_ATTR_VALUE_START+36)
@@ -431,6 +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_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/offapi/com/sun/star/drawing/GraphicObjectShape.idl b/offapi/com/sun/star/drawing/GraphicObjectShape.idl
index 522d0019bd48..7ca7706b3f2c 100644
--- a/offapi/com/sun/star/drawing/GraphicObjectShape.idl
+++ b/offapi/com/sun/star/drawing/GraphicObjectShape.idl
@@ -50,15 +50,28 @@ published service GraphicObjectShape
     service com::sun::star::drawing::RotationDescriptor;
 
     /** This is an url to the source bitmap for this graphic shape.
+
+        @deprecated as of LibreOffice 6.1 - use Graphic instead
+
+        Note the new behaviour since it was deprecated:
+        This property can only be set and only external URLs are
+        supported (no more vnd.sun.star.GraphicObject scheme). When a
+        URL is set, then it will load the image and set the Graphic
+        property.
     */
     [property] string GraphicURL;
 
+    /** This is the graphic that represents this graphic shape
+    */
+    [property] com::sun::star::graphic::XGraphic Graphic;
+
     /** This is an url to the stream ("in document" or linked graphic) for this graphic shape.
     */
     [property] string GraphicStreamURL;
 
-    /** Deprecated. Use graphic property instead!
-        This is the bitmap that represents this graphic shape.
+    /** This is the bitmap that represents this graphic shape.
+
+         @deprecated Use graphic property instead!
     */
     [optional, property] com::sun::star::awt::XBitmap GraphicObjectFillBitmap;
 
@@ -107,10 +120,6 @@ published service GraphicObjectShape
     */
     [optional, property] com::sun::star::container::XIndexContainer ImageMap;
 
-    /** This is the graphic that represents this graphic shape
-    */
-    [optional, property] com::sun::star::graphic::XGraphic Graphic;
-
     /// Whether this shape is actually a signature line.
     [optional, property] boolean IsSignatureLine;
 
diff --git a/offapi/com/sun/star/style/NumberingLevel.idl b/offapi/com/sun/star/style/NumberingLevel.idl
index fac43e5e82b3..f006e66c4360 100644
--- a/offapi/com/sun/star/style/NumberingLevel.idl
+++ b/offapi/com/sun/star/style/NumberingLevel.idl
@@ -19,14 +19,12 @@
 #ifndef __com_sun_star_style_NumberingLevel_idl__
 #define __com_sun_star_style_NumberingLevel_idl__
 
-
+#include <com/sun/star/graphic/XGraphic.idl>
 
  module com {  module sun {  module star {  module style {
 
 /** These properties describe the numbering of a paragraph.
 
-
-
     <p>NumberType determines the type of the numbering symbol.
     Depending on this setting, some of the following values will be
     ignored.</p>
@@ -63,6 +61,14 @@ published service NumberingLevel
     [property] string BulletFontName;
 
     /** This is the URL of a graphic file to use as a symbol.
+
+        @deprecated as of LibreOffice 6.1, use Graphic instead
+
+        Note the new behaviour since it this was deprecated:
+        This property can only be set and only external URLs are
+        supported (no more vnd.sun.star.GraphicObject scheme). When an
+        URL is set, then it will load the graphic and set the Graphic
+        property.
      */
     [property] string GraphicURL;
 
@@ -70,6 +76,11 @@ published service NumberingLevel
      */
     [property] short StartWith;
 
+    /** This is the graphic file to use as a symbol.
+
+        @since LibreOffice 6.1
+     */
+    [property] com::sun::star::graphic::XGraphic Graphic;
 };
 
 
diff --git a/offapi/com/sun/star/text/TextGraphicObject.idl b/offapi/com/sun/star/text/TextGraphicObject.idl
index 32c7dde0db03..071e15048a79 100644
--- a/offapi/com/sun/star/text/TextGraphicObject.idl
+++ b/offapi/com/sun/star/text/TextGraphicObject.idl
@@ -74,9 +74,20 @@ published service TextGraphicObject
     [property] boolean VertMirrored;
 
     /** contains the URL of the background graphic of the object
+
+        @deprecated as of LibreOffice 6.1 - use Graphic instead
+
+        Note the new behaviour since it was deprecated:
+        This property can only be set and only external URLs are
+        supported (no more vnd.sun.star.GraphicObject scheme). When a
+        URL is set, then it will load the image and set the Graphic
+        property.
      */
     [property] string GraphicURL;
 
+    /** contains the background graphic of the object.
+     */
+    [property] com::sun::star::graphic::XGraphic Graphic;
 
     /** contains the name of the filter of the background graphic of the object.
      */
@@ -119,10 +130,6 @@ published service TextGraphicObject
     /** contains the ColorMode as com::sun::star::drawing::ColorMode.
      */
     [property] com::sun::star::drawing::ColorMode  GraphicColorMode;
-    /** contains the graphic.
-     */
-    [optional, property] com::sun::star::graphic::XGraphic    Graphic;
-
 };
 
 
diff --git a/offapi/type_reference/offapi.idl b/offapi/type_reference/offapi.idl
index 99ad946e8f05..1c534cb024d9 100644
--- a/offapi/type_reference/offapi.idl
+++ b/offapi/type_reference/offapi.idl
@@ -5604,6 +5604,7 @@ module com {
      service ::com::sun::star::drawing::ShadowProperties;
      service ::com::sun::star::drawing::RotationDescriptor;
      [property] string GraphicURL;
+     [property] ::com::sun::star::graphic::XGraphic Graphic;
      [property] string GraphicStreamURL;
      [property, optional] ::com::sun::star::awt::XBitmap GraphicObjectFillBitmap;
      [property] short AdjustLuminance;
@@ -5615,7 +5616,6 @@ module com {
      [property] short Transparency;
      [property] ::com::sun::star::drawing::ColorMode GraphicColorMode;
      [property, optional] ::com::sun::star::container::XIndexContainer ImageMap;
-     [property, optional] ::com::sun::star::graphic::XGraphic Graphic;
     };
     /** @deprecated */ published interface XShapeGroup {
      interface ::com::sun::star::drawing::XShape;
@@ -13394,6 +13394,7 @@ module com {
      [property] string BulletFontName;
      [property] string GraphicURL;
      [property] short StartWith;
+     [property] ::com::sun::star::graphic::XGraphic Graphic;
     };
     published service NumberingRule {
      service ::com::sun::star::style::NumberingAlignment;
@@ -14959,6 +14960,7 @@ module com {
      [property] boolean HoriMirroredOnOddPages;
      [property] boolean VertMirrored;
      [property] string GraphicURL;
+     [property] ::com::sun::star::graphic::XGraphic Graphic;
      [property] string GraphicFilter;
      [property] ::com::sun::star::awt::Size ActualSize;
      [property] short AdjustLuminance;
@@ -14970,7 +14972,6 @@ module com {
      [property] boolean GraphicIsInverted;
      [property] short Transparency;
      [property] ::com::sun::star::drawing::ColorMode GraphicColorMode;
-     [property, optional] ::com::sun::star::graphic::XGraphic Graphic;
     };
     published service TextGraphicObjects {
      interface ::com::sun::star::container::XNameAccess;
diff --git a/svx/source/unodraw/unoshap2.cxx b/svx/source/unodraw/unoshap2.cxx
index 6a726a7deca0..fbed04557448 100644
--- a/svx/source/unodraw/unoshap2.cxx
+++ b/svx/source/unodraw/unoshap2.cxx
@@ -38,6 +38,7 @@
 #include <vcl/graphicfilter.hxx>
 #include <vcl/wmf.hxx>
 #include <vcl/cvtgrf.hxx>
+#include <vcl/GraphicLoader.hxx>
 
 #include <svx/svdpool.hxx>
 
@@ -1363,6 +1364,21 @@ bool SvxGraphicObject::setPropertyValueImpl( const OUString& rName, const SfxIte
         break;
     }
 
+    case OWN_ATTR_GRAPHIC_URL:
+    {
+        OUString aURL;
+        if (rValue >>= aURL)
+        {
+            Graphic aGraphic = vcl::graphic::loadFromURL(aURL);
+            if (aGraphic)
+            {
+                static_cast<SdrGrafObj*>(GetSdrObject())->SetGraphic(aGraphic);
+                bOk = true;
+            }
+        }
+        break;
+    }
+
     case OWN_ATTR_VALUE_GRAPHIC:
     {
         Reference< graphic::XGraphic > xGraphic( rValue, uno::UNO_QUERY );
@@ -1531,6 +1547,12 @@ bool SvxGraphicObject::getPropertyValueImpl( const OUString& rName, const SfxIte
         break;
     }
 
+    case OWN_ATTR_GRAPHIC_URL:
+    {
+        throw uno::RuntimeException("Getting from this property is not unsupported");
+        break;
+    }
+
     case OWN_ATTR_VALUE_GRAPHIC:
     {
         Reference<graphic::XGraphic> xGraphic;
diff --git a/sw/inc/cmdid.h b/sw/inc/cmdid.h
index 28de05b41c2f..fccfd6c87bb9 100644
--- a/sw/inc/cmdid.h
+++ b/sw/inc/cmdid.h
@@ -548,7 +548,7 @@
 #define FN_UNO_IS_PIXEL_CONTOUR             (FN_EXTRA2 + 83)
 #define FN_UNO_ALTERNATIVE_TEXT             (FN_EXTRA2 + 84)
 #define FN_UNO_ACTUAL_SIZE                  (FN_EXTRA2 + 85)
-// #define free                             (FN_EXTRA2 + 86)
+#define FN_UNO_GRAPHIC_URL                  (FN_EXTRA2 + 86)
 #define FN_UNO_GRAPHIC_FILTER               (FN_EXTRA2 + 87)
 #define FN_UNO_CELL_NAME                    (FN_EXTRA2 + 88)
 #define FN_INSERT_GLOSSARY                  (FN_EXTRA2 + 89)
diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx
index e18c20dfce84..f8a500a53f7b 100644
--- a/sw/source/core/unocore/unoframe.cxx
+++ b/sw/source/core/unocore/unoframe.cxx
@@ -1575,14 +1575,31 @@ void SwXFrame::setPropertyValue(const OUString& rPropertyName, const ::uno::Any&
                 pFormat->GetDoc()->getIDocumentContentOperations().ReRead(aGrfPaM, sGrfName, sFltName, nullptr);
             }
         }
-        else if (FN_UNO_GRAPHIC == pEntry->nWID)
+        else if (FN_UNO_GRAPHIC == pEntry->nWID || FN_UNO_GRAPHIC_URL == pEntry->nWID)
         {
-            uno::Reference< graphic::XGraphic > xGraphic;
-            aValue >>= xGraphic;
-            if(xGraphic.is())
+            Graphic aGraphic;
+            if (aValue.has<OUString>())
+            {
+                OUString aURL = aValue.get<OUString>();
+                if (!aURL.isEmpty())
+                {
+                    aGraphic = vcl::graphic::loadFromURL(aURL);
+                }
+            }
+            else if (aValue.has<uno::Reference<graphic::XGraphic>>())
+            {
+                uno::Reference<graphic::XGraphic> xGraphic;
+                xGraphic = aValue.get<uno::Reference<graphic::XGraphic>>();
+                if (xGraphic.is())
+                {
+                    aGraphic = Graphic(xGraphic);
+                }
+            }
+
+            if (aGraphic)
             {
                 const ::SwNodeIndex* pIdx = pFormat->GetContent().GetContentIdx();
-                if(pIdx)
+                if (pIdx)
                 {
                     SwNodeIndex aIdx(*pIdx, 1);
                     SwGrfNode* pGrfNode = aIdx.GetNode().GetGrfNode();
@@ -1591,8 +1608,7 @@ void SwXFrame::setPropertyValue(const OUString& rPropertyName, const ::uno::Any&
                         throw uno::RuntimeException();
                     }
                     SwPaM aGrfPaM(*pGrfNode);
-                    Graphic aGraphic( xGraphic );
-                    pFormat->GetDoc()->getIDocumentContentOperations().ReRead( aGrfPaM, OUString(), OUString(), &aGraphic );
+                    pFormat->GetDoc()->getIDocumentContentOperations().ReRead(aGrfPaM, OUString(), OUString(), &aGraphic);
                 }
             }
         }
@@ -2030,6 +2046,10 @@ uno::Any SwXFrame::getPropertyValue(const OUString& rPropertyName)
             SwDoc::GetGrfNms( *static_cast<SwFlyFrameFormat*>(pFormat), nullptr, &sFltName );
                 aAny <<= sFltName;
         }
+        else if( FN_UNO_GRAPHIC_URL == pEntry->nWID )
+        {
+            throw uno::RuntimeException("Getting from this property is not unsupported");
+        }
         else if( FN_UNO_GRAPHIC == pEntry->nWID )
         {
             const SwNodeIndex* pIdx = pFormat->GetContent().GetContentIdx();
@@ -2311,7 +2331,8 @@ uno::Sequence< beans::PropertyState > SwXFrame::getPropertyStates(
                 pEntry->nWID == FN_PARAM_LINK_DISPLAY_NAME||
                 FN_UNO_FRAME_STYLE_NAME == pEntry->nWID||
                 FN_UNO_GRAPHIC == pEntry->nWID||
-                FN_UNO_GRAPHIC_FILTER     == pEntry->nWID||
+                FN_UNO_GRAPHIC_URL == pEntry->nWID||
+                FN_UNO_GRAPHIC_FILTER == pEntry->nWID||
                 FN_UNO_ACTUAL_SIZE == pEntry->nWID||
                 FN_UNO_ALTERNATIVE_TEXT == pEntry->nWID)
             {
diff --git a/sw/source/core/unocore/unomap1.cxx b/sw/source/core/unocore/unomap1.cxx
index f7a3d0eff130..35723c4a3893 100644
--- a/sw/source/core/unocore/unomap1.cxx
+++ b/sw/source/core/unocore/unomap1.cxx
@@ -843,6 +843,7 @@ const SfxItemPropertyMapEntry*  SwUnoPropertyMapProvider::GetGraphicPropertyMap(
         { OUString(UNO_NAME_REPLACEMENT_GRAPHIC), FN_UNO_REPLACEMENT_GRAPHIC, cppu::UnoType<css::graphic::XGraphic>::get(), 0, 0 },
         { OUString(UNO_NAME_GRAPHIC_FILTER), FN_UNO_GRAPHIC_FILTER,      cppu::UnoType<OUString>::get(), 0, 0 },
         { OUString(UNO_NAME_GRAPHIC), FN_UNO_GRAPHIC, cppu::UnoType<css::graphic::XGraphic>::get(), 0, 0 },
+        { OUString(UNO_NAME_GRAPHIC_URL), FN_UNO_GRAPHIC_URL, cppu::UnoType<OUString>::get(), 0, 0 },
         { OUString(UNO_NAME_ACTUAL_SIZE), FN_UNO_ACTUAL_SIZE,    cppu::UnoType<css::awt::Size>::get(),  PropertyAttribute::READONLY, CONVERT_TWIPS},
         { OUString(UNO_NAME_CONTOUR_POLY_POLYGON), FN_PARAM_CONTOUR_PP, cppu::UnoType<css::drawing::PointSequenceSequence>::get(), PropertyAttribute::MAYBEVOID, 0 },
         { OUString(UNO_NAME_IS_PIXEL_CONTOUR), FN_UNO_IS_PIXEL_CONTOUR, cppu::UnoType<bool>::get(), PROPERTY_NONE, 0 },


More information about the Libreoffice-commits mailing list