sw/source/uibase/dochdl/swdtflvr.cxx | 10 ++--- sw/source/uibase/inc/swdtflvr.hxx | 10 ++--- sw/source/uibase/shells/basesh.cxx | 64 ++++++++++++++++++----------------- 3 files changed, 43 insertions(+), 41 deletions(-)
New commits: commit ffe0f40bd70f96f9b57a8bde1625dd56534a149e Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Thu Feb 1 13:58:29 2024 +0100 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Fri Feb 2 07:32:11 2024 +0100 sw: Use a const TransferableDataHelper (ref) here All these methods don't modify the object, so can use a const reference. Change-Id: Ic30f84931358c61999ba27e0da303fdf4bb6f50a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162923 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/sw/source/uibase/dochdl/swdtflvr.cxx b/sw/source/uibase/dochdl/swdtflvr.cxx index 0a6d9f5cadba..64d1d6fe5a9b 100644 --- a/sw/source/uibase/dochdl/swdtflvr.cxx +++ b/sw/source/uibase/dochdl/swdtflvr.cxx @@ -1688,7 +1688,7 @@ bool SwTransferable::Paste(SwWrtShell& rSh, TransferableDataHelper& rData, RndSt nDestination, false, false, nullptr, 0, false, nAnchorType, bIgnoreComments, &aPasteContext, ePasteTable); } -bool SwTransferable::PasteData( TransferableDataHelper& rData, +bool SwTransferable::PasteData( const TransferableDataHelper& rData, SwWrtShell& rSh, sal_uInt8 nAction, SotExchangeActionFlags nActionFlags, SotClipboardFormatId nFormat, SotExchangeDest nDestination, bool bIsPasteFormat, @@ -2237,7 +2237,7 @@ bool SwTransferable::PasteFileContent( const TransferableDataHelper& rData, return bRet; } -bool SwTransferable::PasteOLE( TransferableDataHelper& rData, SwWrtShell& rSh, +bool SwTransferable::PasteOLE( const TransferableDataHelper& rData, SwWrtShell& rSh, SotClipboardFormatId nFormat, SotExchangeActionFlags nActionFlags, bool bMsg ) { bool bRet = false; @@ -3096,7 +3096,7 @@ bool SwTransferable::PasteAsHyperlink( const TransferableDataHelper& rData, return bRet; } -bool SwTransferable::PasteFileName( TransferableDataHelper& rData, +bool SwTransferable::PasteFileName( const TransferableDataHelper& rData, SwWrtShell& rSh, SotClipboardFormatId nFormat, SwPasteSdr nAction, const Point* pPt, SotExchangeActionFlags nActionFlags, @@ -3376,7 +3376,7 @@ bool SwTransferable::IsPasteOwnFormat( const TransferableDataHelper& rData ) } bool SwTransferable::PasteFormat( SwWrtShell& rSh, - TransferableDataHelper& rData, + const TransferableDataHelper& rData, SotClipboardFormatId nFormat ) { SwWait aWait( *rSh.GetView().GetDocShell(), false ); @@ -3465,7 +3465,7 @@ bool SwTransferable::PasteUnformatted( SwWrtShell& rSh, TransferableDataHelper& return SwTransferable::PasteFormat( rSh, rData, SotClipboardFormatId::STRING ); } -void SwTransferable::PrePasteSpecial( const SwWrtShell& rSh, TransferableDataHelper& rData, const VclPtr<SfxAbstractPasteDialog>& pDlg ) +void SwTransferable::PrePasteSpecial( const SwWrtShell& rSh, const TransferableDataHelper& rData, const VclPtr<SfxAbstractPasteDialog>& pDlg ) { DataFlavorExVector aFormats( rData.GetDataFlavorExVector() ); TransferableObjectDescriptor aDesc; diff --git a/sw/source/uibase/inc/swdtflvr.hxx b/sw/source/uibase/inc/swdtflvr.hxx index 6234bd37294b..18c9bc0c44b9 100644 --- a/sw/source/uibase/inc/swdtflvr.hxx +++ b/sw/source/uibase/inc/swdtflvr.hxx @@ -114,7 +114,7 @@ class SW_DLLPUBLIC SwTransferable final : public TransferableHelper static bool PasteFileContent( const TransferableDataHelper&, SwWrtShell& rSh, SotClipboardFormatId nFormat, bool bMsg, bool bIgnoreComments = false ); - static bool PasteOLE( TransferableDataHelper& rData, SwWrtShell& rSh, + static bool PasteOLE( const TransferableDataHelper& rData, SwWrtShell& rSh, SotClipboardFormatId nFormat, SotExchangeActionFlags nActionFlags, bool bMsg ); static bool PasteTargetURL( const TransferableDataHelper& rData, SwWrtShell& rSh, SwPasteSdr nAction, const Point* pPt, bool bInsertGRF ); @@ -136,7 +136,7 @@ class SW_DLLPUBLIC SwTransferable final : public TransferableHelper static bool PasteAsHyperlink( const TransferableDataHelper& rData, SwWrtShell& rSh, SotClipboardFormatId nFormat ); - static bool PasteFileName( TransferableDataHelper& rData, + static bool PasteFileName( const TransferableDataHelper& rData, SwWrtShell& rSh, SotClipboardFormatId nFormat, SwPasteSdr nAction, const Point* pPt, SotExchangeActionFlags nActionFlags, bool * graphicInserted ); @@ -194,7 +194,7 @@ public: static bool IsPaste( const SwWrtShell&, const TransferableDataHelper& ); static bool Paste( SwWrtShell&, TransferableDataHelper&, RndStdIds nAnchorType = RndStdIds::FLY_AT_PARA, bool bIgnoreComments = false, PasteTableType ePasteTable = PasteTableType::PASTE_DEFAULT ); - static bool PasteData( TransferableDataHelper& rData, + static bool PasteData( const TransferableDataHelper& rData, SwWrtShell& rSh, sal_uInt8 nAction, SotExchangeActionFlags nActionFlags, SotClipboardFormatId nFormat, SotExchangeDest nDestination, bool bIsPasteFormat, @@ -214,8 +214,8 @@ public: * @param rSh * @param rFormatUsed */ - static void PrePasteSpecial( const SwWrtShell& rSh, TransferableDataHelper&, const VclPtr<SfxAbstractPasteDialog>& pDlg ); - static bool PasteFormat( SwWrtShell& rSh, TransferableDataHelper& rData, + static void PrePasteSpecial( const SwWrtShell& rSh, const TransferableDataHelper&, const VclPtr<SfxAbstractPasteDialog>& pDlg ); + static bool PasteFormat( SwWrtShell& rSh, const TransferableDataHelper& rData, SotClipboardFormatId nFormat ); static void FillClipFormatItem( const SwWrtShell& rSh, diff --git a/sw/source/uibase/shells/basesh.cxx b/sw/source/uibase/shells/basesh.cxx index 45f5525884d3..9e9095faed2d 100644 --- a/sw/source/uibase/shells/basesh.cxx +++ b/sw/source/uibase/shells/basesh.cxx @@ -447,7 +447,7 @@ void SwBaseShell::ExecClpbrd(SfxRequest &rReq) case SID_PASTE_SPECIAL: { - std::shared_ptr<TransferableDataHelper> aDataHelper = + std::shared_ptr<const TransferableDataHelper> aDataHelper = std::make_shared<TransferableDataHelper>(TransferableDataHelper::CreateFromSystemClipboard( &rSh.GetView().GetEditWin())); if( aDataHelper->GetXTransferable().is() commit 59317e7b1b822cf06effcd5b3ce004019d95e0ef Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Thu Feb 1 13:47:03 2024 +0100 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Fri Feb 2 07:32:01 2024 +0100 sw: Increase indentation for StartExecuteAsync params This way it's easier to spot that the (now further indented) code is the lambda expression passed as param to `StartExecuteAsync`. Change-Id: Iaa56b0838be4d1607bfde9e740f1397021604b7b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162922 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/sw/source/uibase/shells/basesh.cxx b/sw/source/uibase/shells/basesh.cxx index fa2f03ab63a3..45f5525884d3 100644 --- a/sw/source/uibase/shells/basesh.cxx +++ b/sw/source/uibase/shells/basesh.cxx @@ -465,41 +465,43 @@ void SwBaseShell::ExecClpbrd(SfxRequest &rReq) pDlg->PreGetFormat(*aDataHelper); - pDlg->StartExecuteAsync([aDataHelper, pDlg, &rSh, this](sal_Int32 nResult){ - if (nResult == RET_OK) - { - // Temporary variables, because the shell could already be - // destroyed after the paste. - SwView* pView = &m_rView; - bool bRet = false; - SotClipboardFormatId nFormatId = pDlg->GetFormatOnly(); - - if( nFormatId != SotClipboardFormatId::NONE ) - bRet = SwTransferable::PasteFormat( rSh, *aDataHelper, nFormatId ); - - if (bRet) + pDlg->StartExecuteAsync( + [aDataHelper, pDlg, &rSh, this](sal_Int32 nResult) { - SfxViewFrame& rViewFrame = pView->GetViewFrame(); - uno::Reference< frame::XDispatchRecorder > xRecorder = - rViewFrame.GetBindings().GetRecorder(); - if(xRecorder.is()) { - SfxRequest aReq(rViewFrame, SID_CLIPBOARD_FORMAT_ITEMS); - aReq.AppendItem( SfxUInt32Item( SID_CLIPBOARD_FORMAT_ITEMS, static_cast<sal_uInt32>(nFormatId) ) ); - aReq.Done(); - } - } + if (nResult == RET_OK) + { + // Temporary variables, because the shell could already be + // destroyed after the paste. + SwView* pView = &m_rView; + bool bRet = false; + SotClipboardFormatId nFormatId = pDlg->GetFormatOnly(); - if (rSh.IsFrameSelected() || rSh.IsObjSelected()) - rSh.EnterSelFrameMode(); - pView->AttrChangedNotify(nullptr); + if( nFormatId != SotClipboardFormatId::NONE ) + bRet = SwTransferable::PasteFormat( rSh, *aDataHelper, nFormatId ); - // Fold pasted outlines that have outline content visible attribute false - MakeAllOutlineContentTemporarilyVisible a(rSh.GetDoc()); - } + if (bRet) + { + SfxViewFrame& rViewFrame = pView->GetViewFrame(); + uno::Reference< frame::XDispatchRecorder > xRecorder = + rViewFrame.GetBindings().GetRecorder(); + if(xRecorder.is()) { + SfxRequest aReq(rViewFrame, SID_CLIPBOARD_FORMAT_ITEMS); + aReq.AppendItem( SfxUInt32Item( SID_CLIPBOARD_FORMAT_ITEMS, static_cast<sal_uInt32>(nFormatId) ) ); + aReq.Done(); + } + } - pDlg->disposeOnce(); + if (rSh.IsFrameSelected() || rSh.IsObjSelected()) + rSh.EnterSelFrameMode(); + pView->AttrChangedNotify(nullptr); - }); + // Fold pasted outlines that have outline content visible attribute false + MakeAllOutlineContentTemporarilyVisible a(rSh.GetDoc()); + } + + pDlg->disposeOnce(); + } + ); } else return;