diff options
author | Maxim Monastirsky <momonasmon@gmail.com> | 2018-09-02 13:20:07 +0300 |
---|---|---|
committer | Maxim Monastirsky <momonasmon@gmail.com> | 2018-09-02 18:07:04 +0200 |
commit | 8fb5567dc05397e9b28b821b2d3ff2735ccdeb33 (patch) | |
tree | b54958e16e4173add4960f4298753cb7b5a77732 /sw/source/uibase | |
parent | a201c5c8c3e7ea14001b5634f330dbce2b1f4314 (diff) |
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@gmail.com>
Diffstat (limited to 'sw/source/uibase')
-rw-r--r-- | sw/source/uibase/shells/drwtxtex.cxx | 86 |
1 files changed, 74 insertions, 12 deletions
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; } |