sc/source/ui/app/drwtrans.cxx | 28 +++++++++++----------------- sc/source/ui/app/seltrans.cxx | 2 +- sc/source/ui/inc/drwtrans.hxx | 2 +- sc/source/ui/navipi/content.cxx | 26 +++++++++++++------------- sc/source/ui/view/drawvie4.cxx | 6 +++--- 5 files changed, 29 insertions(+), 35 deletions(-)
New commits: commit 335d23999d7210d310287e143a725a805233d1d8 Author: Xisco Fauli <xiscofa...@libreoffice.org> AuthorDate: Mon May 26 22:32:21 2025 +0200 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Tue May 27 08:37:41 2025 +0200 ScDrawTransferObj: pass ScDocShell by ref After commit d8ab8992bd35aedfc1d2b0debebab0d623aa8d09 Author: Xisco Fauli <xiscofa...@libreoffice.org> Date: Mon May 26 11:06:06 2025 +0200 ScViewData: pass ScDocShell by ref Change-Id: I346b5576e31acf8d08de9423558a7ad405a6385e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185869 Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> Tested-by: Jenkins diff --git a/sc/source/ui/app/drwtrans.cxx b/sc/source/ui/app/drwtrans.cxx index 10d163e580c8..df9abffe67a1 100644 --- a/sc/source/ui/app/drwtrans.cxx +++ b/sc/source/ui/app/drwtrans.cxx @@ -69,7 +69,7 @@ constexpr sal_uInt32 SCDRAWTRANS_TYPE_EMBOBJ = 1; constexpr sal_uInt32 SCDRAWTRANS_TYPE_DRAWMODEL = 2; constexpr sal_uInt32 SCDRAWTRANS_TYPE_DOCUMENT = 3; -ScDrawTransferObj::ScDrawTransferObj( std::unique_ptr<SdrModel> pClipModel, ScDocShell* pContainerShell, +ScDrawTransferObj::ScDrawTransferObj( std::unique_ptr<SdrModel> pClipModel, ScDocShell& rContainerShell, TransferableObjectDescriptor aDesc ) : m_pModel( std::move(pClipModel) ), m_aObjDesc(std::move( aDesc )), @@ -78,7 +78,7 @@ ScDrawTransferObj::ScDrawTransferObj( std::unique_ptr<SdrModel> pClipModel, ScDo m_bOleObj( false ), m_nDragSourceFlags( ScDragSrc::Undefined ), m_bDragWasInternal( false ), - maShellID(SfxObjectShell::CreateShellID(pContainerShell)) + maShellID(SfxObjectShell::CreateShellID(&rContainerShell)) { // check what kind of objects are contained @@ -147,16 +147,13 @@ ScDrawTransferObj::ScDrawTransferObj( std::unique_ptr<SdrModel> pClipModel, ScDo { OUString aUrl = sTmp; OUString aAbs = aUrl; - if (pContainerShell) + const SfxMedium* pMedium = rContainerShell.GetMedium(); + if (pMedium) { - const SfxMedium* pMedium = pContainerShell->GetMedium(); - if (pMedium) - { - bool bWasAbs = true; - aAbs = pMedium->GetURLObject().smartRel2Abs( aUrl, bWasAbs ). - GetMainURL(INetURLObject::DecodeMechanism::NONE); - // full path as stored INetBookmark must be encoded - } + bool bWasAbs = true; + aAbs = pMedium->GetURLObject().smartRel2Abs( aUrl, bWasAbs ). + GetMainURL(INetURLObject::DecodeMechanism::NONE); + // full path as stored INetBookmark must be encoded } // Label @@ -201,13 +198,10 @@ ScDrawTransferObj::ScDrawTransferObj( std::unique_ptr<SdrModel> pClipModel, ScDo // remember a unique ID of the source document - if ( pContainerShell ) + ScDocument& rDoc = rContainerShell.GetDocument(); + if ( pPage ) { - ScDocument& rDoc = pContainerShell->GetDocument(); - if ( pPage ) - { - ScChartHelper::FillProtectedChartRangesVector( m_aProtectedChartRangesVector, rDoc, pPage ); - } + ScChartHelper::FillProtectedChartRangesVector( m_aProtectedChartRangesVector, rDoc, pPage ); } } diff --git a/sc/source/ui/app/seltrans.cxx b/sc/source/ui/app/seltrans.cxx index 5ad42cdb90da..94275e8771cc 100644 --- a/sc/source/ui/app/seltrans.cxx +++ b/sc/source/ui/app/seltrans.cxx @@ -337,7 +337,7 @@ void ScSelectionTransferObj::CreateDrawData() aObjDesc.maDisplayName = rDocSh.GetMedium()->GetURLObject().GetURLNoPass(); // maSize is set in ScDrawTransferObj ctor - rtl::Reference<ScDrawTransferObj> pTransferObj = new ScDrawTransferObj( std::move(pModel), &rDocSh, std::move(aObjDesc) ); + rtl::Reference<ScDrawTransferObj> pTransferObj = new ScDrawTransferObj( std::move(pModel), rDocSh, std::move(aObjDesc) ); pTransferObj->SetDrawPersist(aDragShellRef); // keep persist for ole objects alive pTransferObj->SetDragSource( pDrawView ); // copies selection diff --git a/sc/source/ui/inc/drwtrans.hxx b/sc/source/ui/inc/drwtrans.hxx index 001c64cbd016..cff8f1c68ab3 100644 --- a/sc/source/ui/inc/drwtrans.hxx +++ b/sc/source/ui/inc/drwtrans.hxx @@ -65,7 +65,7 @@ private: void CreateOLEData(); public: - ScDrawTransferObj( std::unique_ptr<SdrModel> pClipModel, ScDocShell* pContainerShell, + ScDrawTransferObj( std::unique_ptr<SdrModel> pClipModel, ScDocShell& rContainerShell, TransferableObjectDescriptor aDesc ); virtual ~ScDrawTransferObj() override; diff --git a/sc/source/ui/navipi/content.cxx b/sc/source/ui/navipi/content.cxx index 51e7347b7254..8ce1163c23e3 100644 --- a/sc/source/ui/navipi/content.cxx +++ b/sc/source/ui/navipi/content.cxx @@ -1131,11 +1131,11 @@ static bool lcl_GetRange( const ScDocument& rDoc, ScContentId nType, const OUStr return bFound; } -static bool lcl_DoDragObject( ScDocShell* pSrcShell, std::u16string_view rName, ScContentId nType, weld::TreeView& rTreeView ) +static bool lcl_DoDragObject( ScDocShell& rSrcShell, std::u16string_view rName, ScContentId nType, weld::TreeView& rTreeView ) { bool bDisallow = true; - ScDocument& rSrcDoc = pSrcShell->GetDocument(); + ScDocument& rSrcDoc = rSrcShell.GetDocument(); ScDrawLayer* pModel = rSrcDoc.GetDrawLayer(); if (pModel) { @@ -1168,11 +1168,11 @@ static bool lcl_DoDragObject( ScDocShell* pSrcShell, std::u16string_view rName, ScDrawLayer::SetGlobalDrawPersist(nullptr); TransferableObjectDescriptor aObjDesc; - pSrcShell->FillTransferableObjectDescriptor( aObjDesc ); - aObjDesc.maDisplayName = pSrcShell->GetMedium()->GetURLObject().GetURLNoPass(); + rSrcShell.FillTransferableObjectDescriptor( aObjDesc ); + aObjDesc.maDisplayName = rSrcShell.GetMedium()->GetURLObject().GetURLNoPass(); // maSize is set in ScDrawTransferObj ctor - rtl::Reference<ScDrawTransferObj> pTransferObj = new ScDrawTransferObj( std::move(pDragModel), pSrcShell, std::move(aObjDesc) ); + rtl::Reference<ScDrawTransferObj> pTransferObj = new ScDrawTransferObj( std::move(pDragModel), rSrcShell, std::move(aObjDesc) ); pTransferObj->SetDragSourceObj( *pObject, nTab ); pTransferObj->SetDragSourceFlags(ScDragSrc::Navigator); @@ -1189,11 +1189,11 @@ static bool lcl_DoDragObject( ScDocShell* pSrcShell, std::u16string_view rName, return bDisallow; } -static bool lcl_DoDragCells( ScDocShell* pSrcShell, const ScRange& rRange, ScDragSrc nFlags, weld::TreeView& rTreeView ) +static bool lcl_DoDragCells( ScDocShell& rSrcShell, const ScRange& rRange, ScDragSrc nFlags, weld::TreeView& rTreeView ) { bool bDisallow = true; - ScDocument& rSrcDoc = pSrcShell->GetDocument(); + ScDocument& rSrcDoc = rSrcShell.GetDocument(); ScMarkData aMark(rSrcDoc.GetSheetLimits()); aMark.SelectTable( rRange.aStart.Tab(), true ); aMark.SetMarkArea( rRange ); @@ -1208,13 +1208,13 @@ static bool lcl_DoDragCells( ScDocShell* pSrcShell, const ScRange& rRange, ScDra // pClipDoc->ExtendMerge( rRange, sal_True ); TransferableObjectDescriptor aObjDesc; - pSrcShell->FillTransferableObjectDescriptor( aObjDesc ); - aObjDesc.maDisplayName = pSrcShell->GetMedium()->GetURLObject().GetURLNoPass(); + rSrcShell.FillTransferableObjectDescriptor( aObjDesc ); + aObjDesc.maDisplayName = rSrcShell.GetMedium()->GetURLObject().GetURLNoPass(); // maSize is set in ScTransferObj ctor rtl::Reference<ScTransferObj> pTransferObj = new ScTransferObj( std::move(pClipDoc), std::move(aObjDesc) ); - pTransferObj->SetDragSource( pSrcShell, aMark ); + pTransferObj->SetDragSource( &rSrcShell, aMark ); pTransferObj->SetDragSourceFlags( nFlags ); ScModule::get()->SetDragObject(pTransferObj.get(), nullptr); // for internal D&D @@ -1325,7 +1325,7 @@ IMPL_LINK(ScContentTree, DragBeginHdl, bool&, rUnsetDragIcon, bool) ScRange aRange; if ( lcl_GetRange( rSrcDoc, nType, aText, aRange ) ) { - bDisallow = lcl_DoDragCells( pSrcShell, aRange, ScDragSrc::Navigator, *m_xTreeView ); + bDisallow = lcl_DoDragCells( *pSrcShell, aRange, ScDragSrc::Navigator, *m_xTreeView ); } } else if ( nType == ScContentId::TABLE ) @@ -1334,13 +1334,13 @@ IMPL_LINK(ScContentTree, DragBeginHdl, bool&, rUnsetDragIcon, bool) if ( rSrcDoc.GetTable( aText, nTab ) ) { ScRange aRange(0, 0, nTab, rSrcDoc.MaxCol(), rSrcDoc.MaxRow(), nTab); - bDisallow = lcl_DoDragCells( pSrcShell, aRange, (ScDragSrc::Navigator | ScDragSrc::Table), *m_xTreeView ); + bDisallow = lcl_DoDragCells( *pSrcShell, aRange, (ScDragSrc::Navigator | ScDragSrc::Table), *m_xTreeView ); } } else if ( nType == ScContentId::GRAPHIC || nType == ScContentId::OLEOBJECT || nType == ScContentId::DRAWING ) { - bDisallow = lcl_DoDragObject( pSrcShell, aText, nType, *m_xTreeView ); + bDisallow = lcl_DoDragObject( *pSrcShell, aText, nType, *m_xTreeView ); // during ExecuteDrag the navigator can be deleted // -> don't access member anymore !!! diff --git a/sc/source/ui/view/drawvie4.cxx b/sc/source/ui/view/drawvie4.cxx index 030f1abdf426..7e3940912e04 100644 --- a/sc/source/ui/view/drawvie4.cxx +++ b/sc/source/ui/view/drawvie4.cxx @@ -92,7 +92,7 @@ void ScDrawView::BeginDrag( vcl::Window* pWindow, const Point& rStartPos ) aObjDesc.maDisplayName = rDocSh.GetMedium()->GetURLObject().GetURLNoPass(); // maSize is set in ScDrawTransferObj ctor - rtl::Reference<ScDrawTransferObj> pTransferObj = new ScDrawTransferObj( std::move(pModel), &rDocSh, std::move(aObjDesc) ); + rtl::Reference<ScDrawTransferObj> pTransferObj = new ScDrawTransferObj( std::move(pModel), rDocSh, std::move(aObjDesc) ); pTransferObj->SetDrawPersist(aDragShellRef); // keep persist for ole objects alive pTransferObj->SetDragSource( this ); // copies selection @@ -361,7 +361,7 @@ void ScDrawView::DoCopy() aObjDesc.maDisplayName = rDocSh.GetMedium()->GetURLObject().GetURLNoPass(); // maSize is set in ScDrawTransferObj ctor - rtl::Reference<ScDrawTransferObj> pTransferObj(new ScDrawTransferObj( std::move(pModel), &rDocSh, std::move(aObjDesc) )); + rtl::Reference<ScDrawTransferObj> pTransferObj(new ScDrawTransferObj( std::move(pModel), rDocSh, std::move(aObjDesc) )); if ( ScGlobal::xDrawClipDocShellRef.is() ) { @@ -395,7 +395,7 @@ uno::Reference<datatransfer::XTransferable> ScDrawView::CopyToTransferable() aObjDesc.maDisplayName = rDocSh.GetMedium()->GetURLObject().GetURLNoPass(); // maSize is set in ScDrawTransferObj ctor - rtl::Reference<ScDrawTransferObj> pTransferObj = new ScDrawTransferObj( std::move(pModel), &rDocSh, std::move(aObjDesc) ); + rtl::Reference<ScDrawTransferObj> pTransferObj = new ScDrawTransferObj( std::move(pModel), rDocSh, std::move(aObjDesc) ); if ( ScGlobal::xDrawClipDocShellRef.is() ) {