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

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Sun Sep 2 16:07:24 UTC 2018


 sw/sdi/drwtxtsh.sdi                  |   19 +++++--
 sw/source/uibase/shells/drwtxtex.cxx |   86 ++++++++++++++++++++++++++++++-----
 2 files changed, 88 insertions(+), 17 deletions(-)

New commits:
commit 8fb5567dc05397e9b28b821b2d3ff2735ccdeb33
Author:     Maxim Monastirsky <momonasmon at gmail.com>
AuthorDate: Sun Sep 2 13:20:07 2018 +0300
Commit:     Maxim Monastirsky <momonasmon at gmail.com>
CommitDate: Sun Sep 2 18:07:04 2018 +0200

    tdf#118674 Paste special and unformatted for shapes in Writer
    
    Change-Id: I348a6f93b61ea644077dcd3a16ba9d9fe17afb91
    Reviewed-on: https://gerrit.libreoffice.org/59905
    Tested-by: Jenkins
    Reviewed-by: Maxim Monastirsky <momonasmon at gmail.com>

diff --git a/sw/sdi/drwtxtsh.sdi b/sw/sdi/drwtxtsh.sdi
index b24f0e8e43f2..a8e79c298b4f 100644
--- a/sw/sdi/drwtxtsh.sdi
+++ b/sw/sdi/drwtxtsh.sdi
@@ -44,17 +44,26 @@ interface TextDrawText
         DisableFlags="SfxDisableFlags::SwOnProtectedCursor";
     ]
 
+    SID_PASTE_UNFORMATTED  // api:
+    [
+        ExecMethod = ExecClpbrd ;
+        StateMethod = StateClpbrd ;
+        DisableFlags="SfxDisableFlags::SwOnProtectedCursor";
+    ]
+
     SID_PASTE_SPECIAL  // api:
     [
+        ExecMethod = ExecClpbrd ;
         StateMethod = StateClpbrd ;
         DisableFlags="SfxDisableFlags::SwOnProtectedCursor";
     ]
 
-        SID_CLIPBOARD_FORMAT_ITEMS  // api:
-        [
-                StateMethod = StateClpbrd ;
-                DisableFlags="SfxDisableFlags::SwOnProtectedCursor";
-        ]
+    SID_CLIPBOARD_FORMAT_ITEMS  // api:
+    [
+        ExecMethod = ExecClpbrd ;
+        StateMethod = StateClpbrd ;
+        DisableFlags="SfxDisableFlags::SwOnProtectedCursor";
+    ]
 
     FN_ESCAPE // api:
     [
diff --git a/sw/source/uibase/shells/drwtxtex.cxx b/sw/source/uibase/shells/drwtxtex.cxx
index 15bd355de83d..8328b9ffd8c2 100644
--- a/sw/source/uibase/shells/drwtxtex.cxx
+++ b/sw/source/uibase/shells/drwtxtex.cxx
@@ -54,7 +54,9 @@
 #include <svl/languageoptions.hxx>
 #include <editeng/flditem.hxx>
 #include <editeng/editstat.hxx>
+#include <svx/clipfmtitem.hxx>
 #include <svx/hlnkitem.hxx>
+#include <svx/svxdlg.hxx>
 #include <sfx2/htmlmode.hxx>
 #include <svl/slstitm.hxx>
 #include <editeng/langitem.hxx>
@@ -995,6 +997,54 @@ void SwDrawTextShell::ExecClpbrd(SfxRequest const &rReq)
             pOLV->PasteSpecial();
             break;
 
+        case SID_PASTE_UNFORMATTED:
+            pOLV->Paste();
+            break;
+
+        case SID_PASTE_SPECIAL:
+        {
+            SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+            ScopedVclPtr<SfxAbstractPasteDialog> pDlg(pFact->CreatePasteDialog(GetView().GetEditWin().GetFrameWeld()));
+
+            pDlg->Insert(SotClipboardFormatId::STRING, OUString());
+            pDlg->Insert(SotClipboardFormatId::RTF, OUString());
+            pDlg->Insert(SotClipboardFormatId::RICHTEXT, OUString());
+
+            TransferableDataHelper aDataHelper(TransferableDataHelper::CreateFromSystemClipboard(&GetView().GetEditWin()));
+            SotClipboardFormatId nFormat = pDlg->GetFormat(aDataHelper.GetTransferable());
+
+            if (nFormat != SotClipboardFormatId::NONE)
+            {
+                if (nFormat == SotClipboardFormatId::STRING)
+                    pOLV->Paste();
+                else
+                    pOLV->PasteSpecial();
+            }
+
+            break;
+        }
+
+        case SID_CLIPBOARD_FORMAT_ITEMS:
+        {
+            SotClipboardFormatId nFormat = SotClipboardFormatId::NONE;
+            const SfxPoolItem* pItem;
+            if (rReq.GetArgs() && rReq.GetArgs()->GetItemState(nId, true, &pItem) == SfxItemState::SET)
+            {
+                if (const SfxUInt32Item* pUInt32Item = dynamic_cast<const SfxUInt32Item *>(pItem))
+                    nFormat = static_cast<SotClipboardFormatId>(pUInt32Item->GetValue());
+            }
+
+            if (nFormat != SotClipboardFormatId::NONE)
+            {
+                if (nFormat == SotClipboardFormatId::STRING)
+                    pOLV->Paste();
+                else
+                    pOLV->PasteSpecial();
+            }
+
+            break;
+        }
+
         default:
             OSL_FAIL("wrong dispatcher");
             return;
@@ -1011,6 +1061,11 @@ void SwDrawTextShell::StateClpbrd(SfxItemSet &rSet)
     const bool bCopy = (aSel.nStartPara != aSel.nEndPara) ||
         (aSel.nStartPos != aSel.nEndPos);
 
+    TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( &GetView().GetEditWin() ) );
+    const bool bPaste = aDataHelper.HasFormat( SotClipboardFormatId::STRING ) ||
+                        aDataHelper.HasFormat( SotClipboardFormatId::RTF ) ||
+                        aDataHelper.HasFormat( SotClipboardFormatId::RICHTEXT );
+
     SfxWhichIter aIter(rSet);
     sal_uInt16 nWhich = aIter.FirstWhich();
 
@@ -1025,21 +1080,28 @@ void SwDrawTextShell::StateClpbrd(SfxItemSet &rSet)
             break;
 
         case SID_PASTE:
-            {
-                TransferableDataHelper aDataHelper(
-                    TransferableDataHelper::CreateFromSystemClipboard( &GetView().GetEditWin() ) );
-
-                if( !aDataHelper.GetXTransferable().is()
-                    || !SwTransferable::IsPaste( GetShell(), aDataHelper ) )
-                {
-                    rSet.DisableItem( nWhich );
-                }
-            }
+        case SID_PASTE_UNFORMATTED:
+        case SID_PASTE_SPECIAL:
+            if( !bPaste )
+                rSet.DisableItem( nWhich );
             break;
 
-        case SID_PASTE_SPECIAL:
         case SID_CLIPBOARD_FORMAT_ITEMS:
-            rSet.DisableItem( nWhich );
+            if( bPaste )
+            {
+                SvxClipboardFormatItem aFormats( SID_CLIPBOARD_FORMAT_ITEMS );
+
+                if ( aDataHelper.HasFormat( SotClipboardFormatId::STRING ) )
+                    aFormats.AddClipbrdFormat( SotClipboardFormatId::STRING );
+                if ( aDataHelper.HasFormat( SotClipboardFormatId::RTF ) )
+                    aFormats.AddClipbrdFormat( SotClipboardFormatId::RTF );
+                if ( aDataHelper.HasFormat( SotClipboardFormatId::RICHTEXT ) )
+                    aFormats.AddClipbrdFormat( SotClipboardFormatId::RICHTEXT );
+
+                rSet.Put( aFormats );
+            }
+            else
+                rSet.DisableItem( nWhich );
             break;
         }
 


More information about the Libreoffice-commits mailing list