[Libreoffice-commits] core.git: Branch 'libreoffice-6-0' - dtrans/source sd/source sot/source svx/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Mon Oct 29 10:31:25 UTC 2018


 dtrans/source/win32/ftransl/ftransl.cxx |    2 -
 sd/source/ui/view/sdview2.cxx           |   20 +++++++++++-------
 sd/source/ui/view/sdview3.cxx           |   35 ++++++++++++++++++++------------
 sot/source/base/exchange.cxx            |    2 -
 svx/source/tbxctrls/colrctrl.cxx        |   32 +++++++++++++----------------
 5 files changed, 52 insertions(+), 39 deletions(-)

New commits:
commit 24ccbc35e8857cc8de784154d0648800d39ab20b
Author:     Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Sat Oct 27 23:39:27 2018 +0200
Commit:     Michael Stahl <Michael.Stahl at cib.de>
CommitDate: Mon Oct 29 11:31:02 2018 +0100

    tdf#119235 svx,sd: fix drag&drop from ColorBar
    
    This was using the SfxPoolItem serialisation of XATTR_FILL* items,
    where only XFillColorItem and XFillStyleItem were actually used;
    the binary serialisation was removed without being aware of this
    feature.
    
    Fix this by using uno::Any instead, rather than reviving the binary
    serialisation.
    
    Also change the clipboard format strings, just to be safe.
    
    (regression from 97b889b8b2b2554ce33fd6b3f0359fc18f39832d)
    
    Change-Id: I1828621a9aae606a1ca47835eef608062efe64a0
    Reviewed-on: https://gerrit.libreoffice.org/62455
    Reviewed-by: Michael Stahl <Michael.Stahl at cib.de>
    Tested-by: Michael Stahl <Michael.Stahl at cib.de>
    (cherry picked from commit 0a6813ad5d57d0df72562c797a8b0581bfd65a11)
    Reviewed-on: https://gerrit.libreoffice.org/62472
    Tested-by: Jenkins
    Reviewed-by: Armin Le Grand <Armin.Le.Grand at cib.de>

diff --git a/dtrans/source/win32/ftransl/ftransl.cxx b/dtrans/source/win32/ftransl/ftransl.cxx
index 64962aecf05a..8f079c646e22 100644
--- a/dtrans/source/win32/ftransl/ftransl.cxx
+++ b/dtrans/source/win32/ftransl/ftransl.cxx
@@ -144,7 +144,7 @@ static const std::vector< FormatEntry > g_TranslTable {
     // SotClipboardFormatId::SVIM
         FormatEntry("application/x-openoffice-svim;windows_formatname=\"SVIM (StarView ImageMap)\"", "SVIM (StarView ImageMap)", nullptr, CF_INVALID, CPPUTYPE_DEFAULT),
     // SotClipboardFormatId::XFA
-        FormatEntry("application/x-openoffice-xfa;windows_formatname=\"XFA (XOutDev FillAttr)\"", "XFA (XOutDev FillAttr)", nullptr, CF_INVALID, CPPUTYPE_DEFAULT),
+        FormatEntry("application/x-libreoffice-xfa;windows_formatname=\"XFA (XOutDev FillAttr Any)\"", "XFA (XOutDev FillAttr Any)", nullptr, CF_INVALID, CPPUTYPE_DEFAULT),
     // SotClipboardFormatId::EDITENGINE_ODF_TEXT_FLAT
         FormatEntry("application/vnd.oasis.opendocument.text-flat-xml", "EditEngine ODF", nullptr, CF_INVALID, CPPUTYPE_DEFAULT),
     // SotClipboardFormatId::INTERNALLINK_STATE
diff --git a/sd/source/ui/view/sdview2.cxx b/sd/source/ui/view/sdview2.cxx
index 4df02ee52385..62fa687f1de1 100644
--- a/sd/source/ui/view/sdview2.cxx
+++ b/sd/source/ui/view/sdview2.cxx
@@ -21,6 +21,7 @@
 
 #include <vector>
 #include <com/sun/star/embed/XEmbedPersist.hpp>
+#include <comphelper/sequenceashashmap.hxx>
 #include <tools/urlobj.hxx>
 #include <vcl/msgbox.hxx>
 #include <svx/svdetc.hxx>
@@ -673,14 +674,19 @@ sal_Int8 View::ExecuteDrop( const ExecuteDropEvent& rEvt,
                     {
                         if(pIAOHandle->getOverlayObjectList().isHitPixel(rEvt.maPosPixel))
                         {
-                            ::tools::SvRef<SotStorageStream> xStm;
-
-                            if( aDataHelper.GetSotStorageStream( SotClipboardFormatId::XFA, xStm ) && xStm.is() )
+                            uno::Any const data(aDataHelper.GetAny(SotClipboardFormatId::XFA, ""));
+                            uno::Sequence<beans::NamedValue> props;
+                            if (data >>= props)
                             {
-                                XFillExchangeData aFillData( XFillAttrSetItem( &mrDoc.GetPool() ) );
-
-                                ReadXFillExchangeData( *xStm, aFillData );
-                                const Color aColor( aFillData.GetXFillAttrSetItem()->GetItemSet().Get( XATTR_FILLCOLOR ).GetColorValue() );
+                                ::comphelper::SequenceAsHashMap const map(props);
+                                Color aColor(COL_BLACK);
+                                auto const it = map.find("FillColor");
+                                if (it != map.end())
+                                {
+                                    XFillColorItem color;
+                                    color.PutValue(it->second, 0);
+                                    aColor = color.GetColorValue();
+                                }
                                 static_cast< SdrHdlColor* >( pIAOHandle )->SetColor( aColor, true );
                                 nRet = nDropAction;
                             }
diff --git a/sd/source/ui/view/sdview3.cxx b/sd/source/ui/view/sdview3.cxx
index 24e22a0f0dc5..01c415bff69f 100644
--- a/sd/source/ui/view/sdview3.cxx
+++ b/sd/source/ui/view/sdview3.cxx
@@ -71,6 +71,7 @@
 #include <ViewClipboard.hxx>
 #include <sfx2/ipclient.hxx>
 #include <sfx2/classificationhelper.hxx>
+#include <comphelper/sequenceashashmap.hxx>
 #include <comphelper/storagehelper.hxx>
 #include <comphelper/processfactory.hxx>
 #include <tools/stream.hxx>
@@ -1317,14 +1318,10 @@ bool View::InsertData( const TransferableDataHelper& rDataHelper,
 
     if(!bReturn && pPickObj && CHECK_FORMAT_TRANS( SotClipboardFormatId::XFA ) )
     {
-        ::tools::SvRef<SotStorageStream> xStm;
-
-        if( aDataHelper.GetSotStorageStream( SotClipboardFormatId::XFA, xStm ) )
+        uno::Any const data(aDataHelper.GetAny(SotClipboardFormatId::XFA, ""));
+        uno::Sequence<beans::NamedValue> props;
+        if (data >>= props)
         {
-            XFillExchangeData aFillData( XFillAttrSetItem( &mrDoc.GetPool() ) );
-
-            ReadXFillExchangeData( *xStm, aFillData );
-
             if( IsUndoEnabled() )
             {
                 BegUndo( SdResId(STR_UNDO_DRAGDROP) );
@@ -1332,15 +1329,27 @@ bool View::InsertData( const TransferableDataHelper& rDataHelper,
                 EndUndo();
             }
 
-            XFillAttrSetItem*   pSetItem = aFillData.GetXFillAttrSetItem();
-            SfxItemSet          rSet = pSetItem->GetItemSet();
-            drawing::FillStyle eFill = rSet.Get( XATTR_FILLSTYLE ).GetValue();
+            ::comphelper::SequenceAsHashMap const map(props);
+            drawing::FillStyle eFill(drawing::FillStyle_BITMAP); // default to something that's ignored
+            Color aColor(COL_BLACK);
+            auto it = map.find("FillStyle");
+            if (it != map.end())
+            {
+                XFillStyleItem style;
+                style.PutValue(it->second, 0);
+                eFill = style.GetValue();
+            }
+            it = map.find("FillColor");
+            if (it != map.end())
+            {
+                XFillColorItem color;
+                color.PutValue(it->second, 0);
+                aColor = color.GetColorValue();
+            }
 
             if( eFill == drawing::FillStyle_SOLID || eFill == drawing::FillStyle_NONE )
             {
-                const XFillColorItem&   rColItem = rSet.Get( XATTR_FILLCOLOR );
-                Color                   aColor( rColItem.GetColorValue() );
-                OUString                aName( rColItem.GetName() );
+                OUString                aName;
                 SfxItemSet              aSet( mrDoc.GetPool() );
                 bool                    bClosed = pPickObj->IsClosedObj();
                 ::sd::Window* pWin = mpViewSh->GetActiveWindow();
diff --git a/sot/source/base/exchange.cxx b/sot/source/base/exchange.cxx
index e69ae15d8ae8..8dbc5bfd4686 100644
--- a/sot/source/base/exchange.cxx
+++ b/sot/source/base/exchange.cxx
@@ -72,7 +72,7 @@ namespace
             /* 11 SotClipboardFormatId::DRAWING*/                { "application/x-openoffice-drawing;windows_formatname=\"Drawing Format\"", "Drawing Format", &cppu::UnoType<Sequence<sal_Int8>>::get() },
             /* 12 SotClipboardFormatId::SVXB*/                   { "application/x-openoffice-svxb;windows_formatname=\"SVXB (StarView Bitmap/Animation)\"", "SVXB (StarView Bitmap/Animation)", &cppu::UnoType<Sequence<sal_Int8>>::get() },
             /* 13 SotClipboardFormatId::SVIM*/                   { "application/x-openoffice-svim;windows_formatname=\"SVIM (StarView ImageMap)\"", "SVIM (StarView ImageMap)", &cppu::UnoType<Sequence<sal_Int8>>::get() },
-            /* 14 SotClipboardFormatId::XFA*/                    { "application/x-openoffice-xfa;windows_formatname=\"XFA (XOutDev FillAttr)\"", "XFA (XOutDev FillAttr)", &cppu::UnoType<Sequence<sal_Int8>>::get() },
+            /* 14 SotClipboardFormatId::XFA*/                    { "application/x-libreoffice-xfa;windows_formatname=\"XFA (XOutDev FillAttr Any)\"", "XFA (XOutDev FillAttr Any)", &cppu::UnoType<Sequence<sal_Int8>>::get() },
             /* 15 SotClipboardFormatId::EDITENGINE_ODF_TEXT_FLAT*/ { "application/vnd.oasis.opendocument.text-flat-xml", "EditEngine ODF", &cppu::UnoType<Sequence<sal_Int8>>::get() },
             /* 16 SotClipboardFormatId::INTERNALLINK_STATE*/     { "application/x-openoffice-internallink-state;windows_formatname=\"StatusInfo vom SvxInternalLink\"", "StatusInfo vom SvxInternalLink", &cppu::UnoType<Sequence<sal_Int8>>::get() },
             /* 17 SotClipboardFormatId::SOLK*/                   { "application/x-openoffice-solk;windows_formatname=\"SOLK (StarOffice Link)\"", "SOLK (StarOffice Link)", &cppu::UnoType<Sequence<sal_Int8>>::get() },
diff --git a/svx/source/tbxctrls/colrctrl.cxx b/svx/source/tbxctrls/colrctrl.cxx
index 3a22aa10863f..8f4854fc1d2a 100644
--- a/svx/source/tbxctrls/colrctrl.cxx
+++ b/svx/source/tbxctrls/colrctrl.cxx
@@ -48,18 +48,18 @@ class SvxColorValueSetData : public TransferableHelper
 {
 private:
 
-    XFillExchangeData       maData;
+    uno::Sequence<beans::NamedValue> m_Data;
 
 protected:
 
     virtual void            AddSupportedFormats() override;
     virtual bool GetData( const css::datatransfer::DataFlavor& rFlavor, const OUString& rDestDoc ) override;
-    virtual bool            WriteObject( tools::SvRef<SotStorageStream>& rxOStm, void* pUserObject, sal_uInt32 nUserObjectId, const css::datatransfer::DataFlavor& rFlavor ) override;
 
 public:
 
-    explicit SvxColorValueSetData( const XFillAttrSetItem& rSetItem ) :
-        maData( rSetItem ) {}
+    explicit SvxColorValueSetData(const uno::Sequence<beans::NamedValue>& rProps)
+        : m_Data(rProps)
+    {}
 };
 
 void SvxColorValueSetData::AddSupportedFormats()
@@ -73,19 +73,13 @@ bool SvxColorValueSetData::GetData( const css::datatransfer::DataFlavor& rFlavor
 
     if( SotExchange::GetFormat( rFlavor ) == SotClipboardFormatId::XFA )
     {
-        SetObject( &maData, 0, rFlavor );
+        SetAny(uno::makeAny(m_Data));
         bRet = true;
     }
 
     return bRet;
 }
 
-bool SvxColorValueSetData::WriteObject( tools::SvRef<SotStorageStream>& rxOStm, void*, sal_uInt32, const css::datatransfer::DataFlavor&  )
-{
-    WriteXFillExchangeData( *rxOStm, maData );
-    return( rxOStm->GetError() == ERRCODE_NONE );
-}
-
 SvxColorValueSet_docking::SvxColorValueSet_docking( vcl::Window* _pParent ) :
     SvxColorValueSet( _pParent, WB_ITEMBORDER ),
     DragSourceHelper( this ),
@@ -149,14 +143,18 @@ void SvxColorValueSet_docking::DoDrag()
 
     if( pDocSh && nItemId )
     {
-        XFillAttrSetItem    aXFillSetItem( &pDocSh->GetPool() );
-        SfxItemSet&         rSet = aXFillSetItem.GetItemSet();
-
-        rSet.Put( XFillColorItem( GetItemText( nItemId ), GetItemColor( nItemId ) ) );
-        rSet.Put(XFillStyleItem( ( 1 == nItemId ) ? drawing::FillStyle_NONE : drawing::FillStyle_SOLID ) );
+        uno::Sequence<beans::NamedValue> props(2);
+        XFillColorItem const color(GetItemText(nItemId), GetItemColor(nItemId));
+        props[0].Name = "FillColor";
+        color.QueryValue(props[0].Value, 0);
+        XFillStyleItem const style((1 == nItemId)
+                ? drawing::FillStyle_NONE
+                : drawing::FillStyle_SOLID);
+        props[1].Name = "FillStyle";
+        style.QueryValue(props[1].Value, 0);
 
         EndSelection();
-        ( new SvxColorValueSetData( aXFillSetItem ) )->StartDrag( this, DND_ACTION_COPY );
+        ( new SvxColorValueSetData(props) )->StartDrag( this, DND_ACTION_COPY );
         ReleaseMouse();
     }
 }


More information about the Libreoffice-commits mailing list