summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSzymon Kłos <szymon.klos@collabora.com>2021-10-06 18:22:36 +0200
committerSzymon Kłos <szymon.klos@collabora.com>2021-10-08 10:18:51 +0200
commitdb36743d46578fb4abfaee4b6c3dc18d346d7f27 (patch)
treef9faf1b11f9a5486da5e83c0454e34fbf9096b0a
parentlok: sc: simplify drag & drop functions (diff)
downloadcore-db36743d46578fb4abfaee4b6c3dc18d346d7f27.tar.gz
core-db36743d46578fb4abfaee4b6c3dc18d346d7f27.zip
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>
-rw-r--r--sc/inc/scmod.hxx2
-rw-r--r--sc/source/ui/app/scmod.cxx86
-rw-r--r--sc/source/ui/app/transobj.cxx5
-rw-r--r--sc/source/ui/inc/tabvwsh.hxx10
-rw-r--r--sc/source/ui/view/tabvwsh4.cxx38
5 files changed, 119 insertions, 22 deletions
diff --git a/sc/inc/scmod.hxx b/sc/inc/scmod.hxx
index 20dc94e9e9e8..c139afe9244c 100644
--- a/sc/inc/scmod.hxx
+++ b/sc/inc/scmod.hxx
@@ -139,7 +139,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 f0a992e774bf..54fba8044957 100644
--- a/sc/source/ui/app/scmod.cxx
+++ b/sc/source/ui/app/scmod.cxx
@@ -579,40 +579,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 1b11a56aa89c..a51d39e1919e 100644
--- a/sc/source/ui/app/transobj.cxx
+++ b/sc/source/ui/app/transobj.cxx
@@ -27,6 +27,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>
@@ -49,6 +50,7 @@
#include <docfunc.hxx>
#include <scmod.hxx>
#include <dragdata.hxx>
+#include <tabvwsh.hxx>
#include <editeng/paperinf.hxx>
#include <editeng/sizeitem.hxx>
@@ -174,8 +176,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 7a07d476eb0b..fd608a345b24 100644
--- a/sc/source/ui/inc/tabvwsh.hxx
+++ b/sc/source/ui/inc/tabvwsh.hxx
@@ -33,6 +33,7 @@
#include <shellids.hxx>
#include <tabprotection.hxx>
#include <com/sun/star/ui/dialogs/XDialogClosedListener.hpp>
+#include <dragdata.hxx>
#include <memory>
#include <map>
@@ -60,6 +61,7 @@ class ScPageBreakShell;
class ScDPObject;
class ScNavigatorSettings;
class ScRangeName;
+class ScDrawTransferObj;
struct ScHeaderFieldData;
@@ -163,6 +165,8 @@ private:
bool mbInSwitch;
OUString maName;
OUString maScope;
+
+ std::unique_ptr<ScDragData> m_pDragData;
private:
void Construct( TriState nForceDesignMode );
@@ -402,6 +406,12 @@ public:
ScFormEditData* GetFormEditData() { return mpFormEditData.get(); }
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);
};
#endif
diff --git a/sc/source/ui/view/tabvwsh4.cxx b/sc/source/ui/view/tabvwsh4.cxx
index 0a1d2212f1fb..dfc97880f263 100644
--- a/sc/source/ui/view/tabvwsh4.cxx
+++ b/sc/source/ui/view/tabvwsh4.cxx
@@ -1672,7 +1672,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();
@@ -1863,4 +1864,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: */