[Libreoffice-commits] core.git: editeng/source sw/source

Tomaž Vajngerl tomaz.vajngerl at collabora.co.uk
Wed Mar 7 01:37:35 UTC 2018


 editeng/source/items/frmitems.cxx      |   52 +++++++++++++++++++++++++++------
 sw/source/core/unocore/swunohelper.cxx |    2 +
 sw/source/core/unocore/unoframe.cxx    |    9 +++++
 sw/source/core/unocore/unotbl.cxx      |    1 
 4 files changed, 55 insertions(+), 9 deletions(-)

New commits:
commit 6b39ed0eaffabb6ffe11496d833053c094c72f7b
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Thu Mar 1 06:33:30 2018 +0900

    MID_GRAPHIC as alternative to set graphic to the SvxBrushItem
    
    Change-Id: I6e17d1a34f0bd17a0eafd7c741162f23279e9d1a
    Reviewed-on: https://gerrit.libreoffice.org/50539
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>

diff --git a/editeng/source/items/frmitems.cxx b/editeng/source/items/frmitems.cxx
index 5d3f3370bbde..f7a73d190229 100644
--- a/editeng/source/items/frmitems.cxx
+++ b/editeng/source/items/frmitems.cxx
@@ -44,6 +44,7 @@
 #include <com/sun/star/frame/status/UpperLowerMarginScale.hpp>
 #include <com/sun/star/frame/status/LeftRightMarginScale.hpp>
 #include <com/sun/star/drawing/ShadingPattern.hpp>
+#include <com/sun/star/graphic/XGraphic.hpp>
 
 #include <i18nutil/unicode.hxx>
 #include <unotools/ucbstreamhelper.hxx>
@@ -84,6 +85,7 @@
 #include <editeng/editerr.hxx>
 #include <libxml/xmlwriter.h>
 #include <o3tl/enumrange.hxx>
+#include <vcl/GraphicLoader.hxx>
 
 using namespace ::editeng;
 using namespace ::com::sun::star;
@@ -3190,10 +3192,6 @@ bool SvxBrushItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
             rVal <<= static_cast<style::GraphicLocation>(static_cast<sal_Int16>(eGraphicPos));
         break;
 
-        case MID_GRAPHIC:
-            SAL_WARN( "editeng.items", "not implemented" );
-        break;
-
         case MID_GRAPHIC_TRANSPARENT:
             rVal <<= ( aColor.GetTransparency() == 0xff );
         break;
@@ -3214,6 +3212,22 @@ bool SvxBrushItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
         }
         break;
 
+        case MID_GRAPHIC:
+        {
+            uno::Reference<graphic::XGraphic> xGraphic;
+            if (!maStrLink.isEmpty())
+            {
+                Graphic aGraphic(vcl::graphic::loadFromURL(maStrLink));
+                xGraphic = aGraphic.GetXGraphic();
+            }
+            else if (xGraphicObject)
+            {
+                xGraphic = xGraphicObject->GetGraphic().GetXGraphic();
+            }
+            rVal <<= xGraphic;
+        }
+        break;
+
         case MID_GRAPHIC_FILTER:
         {
             rVal <<= maStrFilter;
@@ -3276,10 +3290,6 @@ bool SvxBrushItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
         }
         break;
 
-        case MID_GRAPHIC:
-            SAL_WARN( "editeng.items", "not implemented" );
-        break;
-
         case MID_GRAPHIC_TRANSPARENT:
             aColor.SetTransparency( Any2Bool( rVal ) ? 0xff : 0 );
         break;
@@ -3316,6 +3326,32 @@ bool SvxBrushItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
         }
         break;
 
+        case MID_GRAPHIC:
+        {
+            if (rVal.getValueType() == cppu::UnoType<graphic::XGraphic>::get())
+            {
+                auto xGraphic = rVal.get<uno::Reference<graphic::XGraphic>>();
+
+                Graphic aGraphic(xGraphic);
+                maStrLink.clear();
+
+                std::unique_ptr<GraphicObject> xOldGrfObj(std::move(xGraphicObject));
+                xGraphicObject.reset(new GraphicObject(aGraphic));
+                ApplyGraphicTransparency_Impl();
+                xOldGrfObj.reset();
+
+                if (aGraphic && eGraphicPos == GPOS_NONE)
+                {
+                    eGraphicPos = GPOS_MM;
+                }
+                else if (!aGraphic)
+                {
+                    eGraphicPos = GPOS_NONE;
+                }
+            }
+        }
+        break;
+
         case MID_GRAPHIC_FILTER:
         {
             if( rVal.getValueType() == ::cppu::UnoType<OUString>::get() )
diff --git a/sw/source/core/unocore/swunohelper.cxx b/sw/source/core/unocore/swunohelper.cxx
index 354ff65703a5..9d2040e87d55 100644
--- a/sw/source/core/unocore/swunohelper.cxx
+++ b/sw/source/core/unocore/swunohelper.cxx
@@ -313,6 +313,8 @@ bool needToMapFillItemsToSvxBrushItemTypes(const SfxItemSet& rSet,
             {
                 case MID_GRAPHIC_URL:
                     return SfxItemState::SET == rSet.GetItemState(XATTR_FILLBITMAP);
+                case MID_GRAPHIC:
+                    return SfxItemState::SET == rSet.GetItemState(XATTR_FILLBITMAP);
                 case MID_GRAPHIC_POSITION:
                     return SfxItemState::SET == rSet.GetItemState(XATTR_FILLBMP_STRETCH)
                         || SfxItemState::SET == rSet.GetItemState(XATTR_FILLBMP_TILE)
diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx
index f93ed469dd21..bb2f794d7a3e 100644
--- a/sw/source/core/unocore/unoframe.cxx
+++ b/sw/source/core/unocore/unoframe.cxx
@@ -212,12 +212,14 @@ bool BaseFrameProperties_Impl::FillBaseProperties(SfxItemSet& rToSet, const SfxI
     const ::uno::Any* pTrans = nullptr; GetProperty(RES_BACKGROUND, MID_GRAPHIC_TRANSPARENT, pTrans );
     const ::uno::Any* pGrLoc = nullptr; GetProperty(RES_BACKGROUND, MID_GRAPHIC_POSITION, pGrLoc );
     const ::uno::Any* pGrURL = nullptr; GetProperty(RES_BACKGROUND, MID_GRAPHIC_URL, pGrURL     );
+    const ::uno::Any* pGraphic = nullptr; GetProperty(RES_BACKGROUND, MID_GRAPHIC, pGraphic     );
     const ::uno::Any* pGrFilter = nullptr; GetProperty(RES_BACKGROUND, MID_GRAPHIC_FILTER, pGrFilter     );
     const ::uno::Any* pGrTranparency = nullptr; GetProperty(RES_BACKGROUND, MID_GRAPHIC_TRANSPARENCY, pGrTranparency     );
     const bool bSvxBrushItemPropertiesUsed(
         pCol ||
         pTrans ||
         pGrURL ||
+        pGraphic ||
         pGrFilter ||
         pGrLoc ||
         pGrTranparency ||
@@ -264,7 +266,7 @@ bool BaseFrameProperties_Impl::FillBaseProperties(SfxItemSet& rToSet, const SfxI
     // but there is a GraphicURL
     const bool bFillStyleUsed(pXFillStyleItem && pXFillStyleItem->hasValue() &&
         (pXFillStyleItem->get<drawing::FillStyle>() != drawing::FillStyle_SOLID
-         || !pGrURL));
+         || !pGrURL || !pGraphic));
     SAL_INFO_IF(pXFillStyleItem && pXFillStyleItem->hasValue() && !bFillStyleUsed,
             "sw.uno", "FillBaseProperties: ignoring invalid FillStyle");
     const bool bXFillStyleItemUsed(
@@ -329,6 +331,11 @@ bool BaseFrameProperties_Impl::FillBaseProperties(SfxItemSet& rToSet, const SfxI
             bRet &= static_cast<SfxPoolItem&>(aBrush).PutValue(*pGrURL, MID_GRAPHIC_URL);
         }
 
+        if (pGraphic)
+        {
+            bRet &= static_cast<SfxPoolItem&>(aBrush).PutValue(*pGraphic, MID_GRAPHIC);
+        }
+
         if(pGrFilter)
         {
             bRet &= static_cast<SfxPoolItem&>(aBrush).PutValue(*pGrFilter, MID_GRAPHIC_FILTER);
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index 73217063f9e4..ea14bc88228c 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -1839,6 +1839,7 @@ void SwTableProperties_Impl::ApplyTableAttr(const SwTable& rTable, SwDoc& rDoc)
         MID_GRAPHIC_TRANSPARENT,
         MID_GRAPHIC_POSITION,
         MID_GRAPHIC_URL,
+        MID_GRAPHIC,
         MID_GRAPHIC_FILTER });
 
     bool bPutBreak = true;


More information about the Libreoffice-commits mailing list