diff options
author | Szymon Kłos <szymon.klos@collabora.com> | 2021-10-06 18:22:36 +0200 |
---|---|---|
committer | Henry Castro <hcastro@collabora.com> | 2022-02-18 15:48:48 +0100 |
commit | 24bf5c002cbeecef109e4e409e51305f03ea9fe6 (patch) | |
tree | 05d95fee6ddbf3f8ebbea3543c2c122bcef51119 /sc/source/ui | |
parent | 321f6577cdafa728f73d1b679d86581f1c0db110 (diff) |
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.klos@collabora.com>
Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129466
Tested-by: Jenkins
Reviewed-by: Henry Castro <hcastro@collabora.com>
Diffstat (limited to 'sc/source/ui')
-rw-r--r-- | sc/source/ui/app/scmod.cxx | 86 | ||||
-rw-r--r-- | sc/source/ui/app/transobj.cxx | 5 | ||||
-rw-r--r-- | sc/source/ui/inc/tabvwsh.hxx | 10 | ||||
-rw-r--r-- | sc/source/ui/view/tabvwsh4.cxx | 38 |
4 files changed, 118 insertions, 21 deletions
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: */ |