sc/inc/scmod.hxx | 2 sc/source/ui/app/scmod.cxx | 86 +++++++++++++++++++++++++++++++---------- sc/source/ui/app/transobj.cxx | 5 +- sc/source/ui/inc/tabvwsh.hxx | 10 ++++ sc/source/ui/view/tabvwsh4.cxx | 38 +++++++++++++++++- 5 files changed, 119 insertions(+), 22 deletions(-)
New commits: commit 24bf5c002cbeecef109e4e409e51305f03ea9fe6 Author: Szymon Kłos <szymon.k...@collabora.com> AuthorDate: Wed Oct 6 18:22:36 2021 +0200 Commit: Henry Castro <hcas...@collabora.com> CommitDate: Fri Feb 18 15:48:48 2022 +0100 lok: deglobalize SetDragObject and other Drag and Drop related functions Change-Id: Idbaec91c0ed396da9888c8ed562d2eff35686cca Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123209 Tested-by: Szymon Kłos <szymon.k...@collabora.com> Reviewed-by: Szymon Kłos <szymon.k...@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129466 Tested-by: Jenkins Reviewed-by: Henry Castro <hcas...@collabora.com> diff --git a/sc/inc/scmod.hxx b/sc/inc/scmod.hxx index c21082043ceb..a0a6e17e8423 100644 --- a/sc/inc/scmod.hxx +++ b/sc/inc/scmod.hxx @@ -137,7 +137,7 @@ public: void AnythingChanged(); // Drag & Drop: - const ScDragData& GetDragData() const { return *m_pDragData;} + const ScDragData& GetDragData() const; void SetDragObject( ScTransferObj* pCellObj, ScDrawTransferObj* pDrawObj ); void ResetDragObject(); void SetDragLink( diff --git a/sc/source/ui/app/scmod.cxx b/sc/source/ui/app/scmod.cxx index d2aae8fee013..b48f81192ac7 100644 --- a/sc/source/ui/app/scmod.cxx +++ b/sc/source/ui/app/scmod.cxx @@ -576,40 +576,88 @@ void ScModule::HideDisabledSlots( SfxItemSet& rSet ) void ScModule::ResetDragObject() { - m_pDragData->pCellTransfer = nullptr; - m_pDragData->pDrawTransfer = nullptr; - m_pDragData->pJumpLocalDoc = nullptr; - m_pDragData->aLinkDoc.clear(); - m_pDragData->aLinkTable.clear(); - m_pDragData->aLinkArea.clear(); - m_pDragData->aJumpTarget.clear(); - m_pDragData->aJumpText.clear(); + if (comphelper::LibreOfficeKit::isActive()) + { + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if (pViewShell) + pViewShell->ResetDragObject(); + } + else + { + m_pDragData->pCellTransfer = nullptr; + m_pDragData->pDrawTransfer = nullptr; + m_pDragData->pJumpLocalDoc = nullptr; + m_pDragData->aLinkDoc.clear(); + m_pDragData->aLinkTable.clear(); + m_pDragData->aLinkArea.clear(); + m_pDragData->aJumpTarget.clear(); + m_pDragData->aJumpText.clear(); + } +} + +const ScDragData& ScModule::GetDragData() const +{ + if (comphelper::LibreOfficeKit::isActive()) + { + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + assert(pViewShell); + return pViewShell->GetDragData(); + } + else + return *m_pDragData; } void ScModule::SetDragObject( ScTransferObj* pCellObj, ScDrawTransferObj* pDrawObj ) { - ResetDragObject(); - m_pDragData->pCellTransfer = pCellObj; - m_pDragData->pDrawTransfer = pDrawObj; + if (comphelper::LibreOfficeKit::isActive()) + { + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if (pViewShell) + pViewShell->SetDragObject(pCellObj, pDrawObj); + } + else + { + ResetDragObject(); + m_pDragData->pCellTransfer = pCellObj; + m_pDragData->pDrawTransfer = pDrawObj; + } } void ScModule::SetDragLink( const OUString& rDoc, const OUString& rTab, const OUString& rArea ) { - ResetDragObject(); - m_pDragData->aLinkDoc = rDoc; - m_pDragData->aLinkTable = rTab; - m_pDragData->aLinkArea = rArea; + if (comphelper::LibreOfficeKit::isActive()) + { + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if (pViewShell) + pViewShell->SetDragLink(rDoc, rTab, rArea); + } + else + { + ResetDragObject(); + m_pDragData->aLinkDoc = rDoc; + m_pDragData->aLinkTable = rTab; + m_pDragData->aLinkArea = rArea; + } } void ScModule::SetDragJump( ScDocument* pLocalDoc, const OUString& rTarget, const OUString& rText ) { - ResetDragObject(); + if (comphelper::LibreOfficeKit::isActive()) + { + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if (pViewShell) + pViewShell->SetDragJump(pLocalDoc, rTarget, rText); + } + else + { + ResetDragObject(); - m_pDragData->pJumpLocalDoc = pLocalDoc; - m_pDragData->aJumpTarget = rTarget; - m_pDragData->aJumpText = rText; + m_pDragData->pJumpLocalDoc = pLocalDoc; + m_pDragData->aJumpTarget = rTarget; + m_pDragData->aJumpText = rText; + } } ScDocument* ScModule::GetClipDoc() diff --git a/sc/source/ui/app/transobj.cxx b/sc/source/ui/app/transobj.cxx index 438e922297a4..245209e822bb 100644 --- a/sc/source/ui/app/transobj.cxx +++ b/sc/source/ui/app/transobj.cxx @@ -28,6 +28,7 @@ #include <unotools/tempfile.hxx> #include <unotools/ucbstreamhelper.hxx> #include <comphelper/fileformat.h> +#include <comphelper/lok.hxx> #include <comphelper/storagehelper.hxx> #include <comphelper/servicehelper.hxx> #include <sot/storage.hxx> @@ -51,6 +52,7 @@ #include <scmod.hxx> #include <dragdata.hxx> #include <sortparam.hxx> +#include <tabvwsh.hxx> #include <editeng/paperinf.hxx> #include <editeng/sizeitem.hxx> @@ -176,8 +178,9 @@ ScTransferObj::~ScTransferObj() { SolarMutexGuard aSolarGuard; + bool bIsDisposing = comphelper::LibreOfficeKit::isActive() && !ScTabViewShell::GetActiveViewShell(); ScModule* pScMod = SC_MOD(); - if (pScMod && pScMod->GetDragData().pCellTransfer == this) + if (pScMod && !bIsDisposing && pScMod->GetDragData().pCellTransfer == this) { OSL_FAIL("ScTransferObj wasn't released"); pScMod->ResetDragObject(); diff --git a/sc/source/ui/inc/tabvwsh.hxx b/sc/source/ui/inc/tabvwsh.hxx index af9161b3689d..957dab0efcda 100644 --- a/sc/source/ui/inc/tabvwsh.hxx +++ b/sc/source/ui/inc/tabvwsh.hxx @@ -31,6 +31,7 @@ #include <shellids.hxx> #include <tabprotection.hxx> #include <com/sun/star/ui/dialogs/DialogClosedEvent.hpp> +#include <dragdata.hxx> #include <memory> #include <map> @@ -58,6 +59,7 @@ class ScPageBreakShell; class ScDPObject; class ScNavigatorSettings; class ScRangeName; +class ScDrawTransferObj; struct ScHeaderFieldData; @@ -161,6 +163,8 @@ private: bool mbInSwitch; OUString maName; OUString maScope; + + std::unique_ptr<ScDragData> m_pDragData; private: void Construct( TriState nForceDesignMode ); @@ -406,6 +410,12 @@ public: void EnableEditHyperlink(); virtual tools::Rectangle getLOKVisibleArea() const override; + + const ScDragData& GetDragData() const { return *m_pDragData; } + void SetDragObject(ScTransferObj* pCellObj, ScDrawTransferObj* pDrawObj); + void ResetDragObject(); + void SetDragLink(const OUString& rDoc, const OUString& rTab, const OUString& rArea); + void SetDragJump(ScDocument* pLocalDoc, const OUString& rTarget, const OUString& rText); }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/view/tabvwsh4.cxx b/sc/source/ui/view/tabvwsh4.cxx index 8130ac4c0e12..e50484525fdb 100644 --- a/sc/source/ui/view/tabvwsh4.cxx +++ b/sc/source/ui/view/tabvwsh4.cxx @@ -1674,7 +1674,8 @@ ScTabViewShell::ScTabViewShell( SfxViewFrame* pViewFrame, bInPrepareClose(false), bInDispose(false), nCurRefDlgId(0), - mbInSwitch(false) + mbInSwitch(false), + m_pDragData(new ScDragData) { const ScAppOptions& rAppOpt = SC_MOD()->GetAppOptions(); @@ -1865,4 +1866,39 @@ tools::Rectangle ScTabViewShell::getLOKVisibleArea() const return GetViewData().getLOKVisibleArea(); } +void ScTabViewShell::SetDragObject(ScTransferObj* pCellObj, ScDrawTransferObj* pDrawObj) +{ + ResetDragObject(); + m_pDragData->pCellTransfer = pCellObj; + m_pDragData->pDrawTransfer = pDrawObj; +} + +void ScTabViewShell::ResetDragObject() +{ + m_pDragData->pCellTransfer = nullptr; + m_pDragData->pDrawTransfer = nullptr; + m_pDragData->pJumpLocalDoc = nullptr; + m_pDragData->aLinkDoc.clear(); + m_pDragData->aLinkTable.clear(); + m_pDragData->aLinkArea.clear(); + m_pDragData->aJumpTarget.clear(); + m_pDragData->aJumpText.clear(); +} + +void ScTabViewShell::SetDragLink(const OUString& rDoc, const OUString& rTab, const OUString& rArea) +{ + ResetDragObject(); + m_pDragData->aLinkDoc = rDoc; + m_pDragData->aLinkTable = rTab; + m_pDragData->aLinkArea = rArea; +} + +void ScTabViewShell::SetDragJump(ScDocument* pLocalDoc, const OUString& rTarget, const OUString& rText) +{ + ResetDragObject(); + m_pDragData->pJumpLocalDoc = pLocalDoc; + m_pDragData->aJumpTarget = rTarget; + m_pDragData->aJumpText = rText; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */