summaryrefslogtreecommitdiff
path: root/sw/source
diff options
context:
space:
mode:
authorMuhammet Kara <muhammet.kara@collabora.com>2019-06-28 02:30:51 +0300
committerMuhammet Kara <muhammet.kara@collabora.com>2019-07-11 20:38:25 +0200
commit6193948d171a549a9902d68167f294732e618aaa (patch)
tree2b9a009e5126c9671e3e25466533a90f37baa726 /sw/source
parent1d49600541d941681bfd600c3e360a027b2024e4 (diff)
Prepare PasteSpecial for Async-ness (sw, basesh.cxx)
Change-Id: I2653b2131f1b2293a9e3c21f308a0951bbfd3878 Reviewed-on: https://gerrit.libreoffice.org/75412 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Muhammet Kara <muhammet.kara@collabora.com>
Diffstat (limited to 'sw/source')
-rw-r--r--sw/source/uibase/dochdl/swdtflvr.cxx59
-rw-r--r--sw/source/uibase/inc/swdtflvr.hxx7
-rw-r--r--sw/source/uibase/shells/basesh.cxx42
3 files changed, 97 insertions, 11 deletions
diff --git a/sw/source/uibase/dochdl/swdtflvr.cxx b/sw/source/uibase/dochdl/swdtflvr.cxx
index d9f35769d070..3dcce3cf71ed 100644
--- a/sw/source/uibase/dochdl/swdtflvr.cxx
+++ b/sw/source/uibase/dochdl/swdtflvr.cxx
@@ -129,6 +129,7 @@
#include <comphelper/lok.hxx>
#include <sfx2/classificationhelper.hxx>
#include <sfx2/sfxresid.hxx>
+#include <sfx2/sfxdlg.hxx>
#include <memory>
@@ -2940,6 +2941,64 @@ bool SwTransferable::PasteUnformatted( SwWrtShell& rSh, TransferableDataHelper&
return SwTransferable::PasteFormat( rSh, rData, SotClipboardFormatId::STRING );
}
+void SwTransferable::PrePasteSpecial( SwWrtShell& rSh, TransferableDataHelper& rData, VclPtr<SfxAbstractPasteDialog>& pDlg )
+{
+ DataFlavorExVector aFormats( rData.GetDataFlavorExVector() );
+ TransferableObjectDescriptor aDesc;
+
+ SotExchangeDest nDest = SwTransferable::GetSotDestination( rSh );
+
+ SwTransferable *pClipboard = GetSwTransferable( rData );
+ if( pClipboard )
+ {
+ aDesc = pClipboard->m_aObjDesc;
+ const char* pResId;
+ if( pClipboard->m_eBufferType & TransferBufferType::Document )
+ pResId = STR_PRIVATETEXT;
+ else if( pClipboard->m_eBufferType & TransferBufferType::Graphic )
+ pResId = STR_PRIVATEGRAPHIC;
+ else if( pClipboard->m_eBufferType == TransferBufferType::Ole )
+ pResId = STR_PRIVATEOLE;
+ else
+ pResId = nullptr;
+
+ if (pResId)
+ {
+ if (strcmp(STR_PRIVATEOLE, pResId) == 0 || strcmp(STR_PRIVATEGRAPHIC, pResId) == 0)
+ {
+ // add SotClipboardFormatId::EMBED_SOURCE to the formats. This
+ // format display then the private format name.
+ DataFlavorEx aFlavorEx;
+ aFlavorEx.mnSotId = SotClipboardFormatId::EMBED_SOURCE;
+ aFormats.insert( aFormats.begin(), aFlavorEx );
+ }
+ pDlg->SetObjName( pClipboard->m_aObjDesc.maClassName,
+ SwResId(pResId) );
+ pDlg->Insert( SotClipboardFormatId::EMBED_SOURCE, aEmptyOUStr );
+ }
+ }
+ else
+ {
+ if( rData.HasFormat( SotClipboardFormatId::OBJECTDESCRIPTOR ) )
+ {
+ (void)rData.GetTransferableObjectDescriptor(
+ SotClipboardFormatId::OBJECTDESCRIPTOR, aDesc );
+ }
+
+ if( SwTransferable::TestAllowedFormat( rData, SotClipboardFormatId::EMBED_SOURCE, nDest ))
+ pDlg->Insert( SotClipboardFormatId::EMBED_SOURCE, aEmptyOUStr );
+ if( SwTransferable::TestAllowedFormat( rData, SotClipboardFormatId::LINK_SOURCE, nDest ))
+ pDlg->Insert( SotClipboardFormatId::LINK_SOURCE, aEmptyOUStr );
+ }
+
+ if( SwTransferable::TestAllowedFormat( rData, SotClipboardFormatId::LINK, nDest ))
+ pDlg->Insert( SotClipboardFormatId::LINK, SwResId(STR_DDEFORMAT) );
+
+ for( SotClipboardFormatId* pIds = aPasteSpecialIds; *pIds != SotClipboardFormatId::NONE; ++pIds )
+ if( SwTransferable::TestAllowedFormat( rData, *pIds, nDest ))
+ pDlg->Insert( *pIds, aEmptyOUStr );
+}
+
bool SwTransferable::PasteSpecial( SwWrtShell& rSh, TransferableDataHelper& rData, SotClipboardFormatId& rFormatUsed )
{
bool bRet = false;
diff --git a/sw/source/uibase/inc/swdtflvr.hxx b/sw/source/uibase/inc/swdtflvr.hxx
index 640d972cc631..4896dfd10324 100644
--- a/sw/source/uibase/inc/swdtflvr.hxx
+++ b/sw/source/uibase/inc/swdtflvr.hxx
@@ -32,6 +32,7 @@ class Graphic;
class ImageMap;
class INetBookmark;
class INetImage;
+class SfxAbstractPasteDialog;
class SwDoc;
class SwDocFac;
class SwTextBlocks;
@@ -185,6 +186,12 @@ public:
static bool IsPasteSpecial( const SwWrtShell& rWrtShell,
const TransferableDataHelper& );
static bool PasteUnformatted( SwWrtShell& rSh, TransferableDataHelper& );
+ /**
+ * @brief PrePasteSpecial Prepares the given dialog without actually running it
+ * @param rSh
+ * @param rFormatUsed
+ */
+ static void PrePasteSpecial( SwWrtShell& rSh, TransferableDataHelper&, VclPtr<SfxAbstractPasteDialog>& pDlg );
static bool PasteSpecial( SwWrtShell& rSh, TransferableDataHelper&, SotClipboardFormatId& rFormatUsed );
static bool PasteFormat( SwWrtShell& rSh, TransferableDataHelper& rData,
SotClipboardFormatId nFormat );
diff --git a/sw/source/uibase/shells/basesh.cxx b/sw/source/uibase/shells/basesh.cxx
index f3820f141fa9..8a7f3ca4a2e3 100644
--- a/sw/source/uibase/shells/basesh.cxx
+++ b/sw/source/uibase/shells/basesh.cxx
@@ -380,23 +380,43 @@ void SwBaseShell::ExecClpbrd(SfxRequest &rReq)
// destroyed after the paste.
SwView* pView = &rView;
SotClipboardFormatId nFormatId = SotClipboardFormatId::NONE;
+
rReq.Ignore();
bIgnore = true;
- if(SwTransferable::PasteSpecial( rSh, aDataHelper, nFormatId ))
+ bool bRet = false;
+
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ VclPtr<SfxAbstractPasteDialog> pDlg(pFact->CreatePasteDialog( &rSh.GetView().GetEditWin() ));
+
+ // Prepare the dialog
+ SwTransferable::PrePasteSpecial(rSh, aDataHelper, pDlg);
+ pDlg->PreGetFormat(aDataHelper);
+
+ if (pDlg->Execute() == RET_OK)
{
- SfxViewFrame* pViewFrame = pView->GetViewFrame();
- uno::Reference< frame::XDispatchRecorder > xRecorder =
- pViewFrame->GetBindings().GetRecorder();
- if(xRecorder.is()) {
- SfxRequest aReq( pViewFrame, SID_CLIPBOARD_FORMAT_ITEMS );
- aReq.AppendItem( SfxUInt32Item( SID_CLIPBOARD_FORMAT_ITEMS, static_cast<sal_uInt32>(nFormatId) ) );
- aReq.Done();
+ nFormatId = pDlg->GetFormatOnly();
+
+ if( nFormatId != SotClipboardFormatId::NONE )
+ bRet = SwTransferable::PasteFormat( rSh, aDataHelper, nFormatId );
+
+ if (bRet)
+ {
+ SfxViewFrame* pViewFrame = pView->GetViewFrame();
+ uno::Reference< frame::XDispatchRecorder > xRecorder =
+ pViewFrame->GetBindings().GetRecorder();
+ if(xRecorder.is()) {
+ SfxRequest aReq( pViewFrame, SID_CLIPBOARD_FORMAT_ITEMS );
+ aReq.AppendItem( SfxUInt32Item( SID_CLIPBOARD_FORMAT_ITEMS, static_cast<sal_uInt32>(nFormatId) ) );
+ aReq.Done();
+ }
}
+
+ if (rSh.IsFrameSelected() || rSh.IsObjSelected())
+ rSh.EnterSelFrameMode();
+ pView->AttrChangedNotify( &rSh );
}
- if (rSh.IsFrameSelected() || rSh.IsObjSelected())
- rSh.EnterSelFrameMode();
- pView->AttrChangedNotify( &rSh );
+ pDlg->disposeOnce();
}
else
return;