summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/clipparam.hxx6
-rw-r--r--sc/source/core/data/clipparam.cxx6
-rw-r--r--sc/source/ui/view/cellsh.cxx23
-rw-r--r--sc/source/ui/view/viewfun3.cxx25
4 files changed, 58 insertions, 2 deletions
diff --git a/sc/inc/clipparam.hxx b/sc/inc/clipparam.hxx
index 2e5dece711e8..16555225d074 100644
--- a/sc/inc/clipparam.hxx
+++ b/sc/inc/clipparam.hxx
@@ -26,6 +26,8 @@
#include <vector>
+class SfxViewShell;
+
/**
* This struct stores general clipboard parameters associated with a
* ScDocument instance created in clipboard mode.
@@ -38,6 +40,7 @@ struct ScClipParam
Direction meDirection;
bool mbCutMode;
sal_uInt32 mnSourceDocID;
+ SfxViewShell* mpSourceView;
ScRangeListVector maProtectedChartRangesVector;
ScClipParam();
@@ -67,6 +70,9 @@ struct ScClipParam
sal_uInt32 getSourceDocID() const { return mnSourceDocID; }
void setSourceDocID( sal_uInt32 nVal ) { mnSourceDocID = nVal; }
+
+ SfxViewShell* getSourceView() const { return mpSourceView; }
+ void setSourceView( SfxViewShell* pSourceView ) { mpSourceView = pSourceView; }
};
#endif
diff --git a/sc/source/core/data/clipparam.cxx b/sc/source/core/data/clipparam.cxx
index 9c08d6093dfc..bc856672fbba 100644
--- a/sc/source/core/data/clipparam.cxx
+++ b/sc/source/core/data/clipparam.cxx
@@ -23,14 +23,16 @@
ScClipParam::ScClipParam() :
meDirection(Unspecified),
mbCutMode(false),
- mnSourceDocID(0)
+ mnSourceDocID(0),
+ mpSourceView(nullptr)
{
}
ScClipParam::ScClipParam(const ScRange& rRange, bool bCutMode) :
meDirection(Unspecified),
mbCutMode(bCutMode),
- mnSourceDocID(0)
+ mnSourceDocID(0),
+ mpSourceView(nullptr)
{
maRanges.Append(rRange);
}
diff --git a/sc/source/ui/view/cellsh.cxx b/sc/source/ui/view/cellsh.cxx
index 202598956891..cf410346c6c1 100644
--- a/sc/source/ui/view/cellsh.cxx
+++ b/sc/source/ui/view/cellsh.cxx
@@ -605,6 +605,29 @@ void ScCellShell::GetClipState( SfxItemSet& rSet )
bDisable = true;
}
+ // This is only a workaround, we don't want that text content copied
+ // in one view is pasted in a different view.
+ // This part of the patch takes care to disable the "Paste" entry
+ // in the context menu.
+ // TODO: implement a solution providing one clipboard per view
+ if (comphelper::LibreOfficeKit::isActive())
+ {
+ ScTransferObj* pOwnClip = ScTransferObj::GetOwnClipboard(nullptr);
+ if (pOwnClip)
+ {
+ ScDocument* pClipDoc = pOwnClip->GetDocument();
+ if (pClipDoc)
+ {
+ ScTabViewShell* pThisView = GetViewData()->GetViewShell();
+ ScTabViewShell* pSourceView = dynamic_cast<ScTabViewShell*>(pClipDoc->GetClipParam().getSourceView());
+ if (pThisView && pSourceView && pThisView != pSourceView)
+ {
+ bDisable = true;
+ }
+ }
+ }
+ }
+
if (bDisable)
{
rSet.DisableItem( SID_PASTE );
diff --git a/sc/source/ui/view/viewfun3.cxx b/sc/source/ui/view/viewfun3.cxx
index 0c675ecd6c12..4fab715aafd5 100644
--- a/sc/source/ui/view/viewfun3.cxx
+++ b/sc/source/ui/view/viewfun3.cxx
@@ -37,6 +37,9 @@
#include <sot/exchange.hxx>
#include <memory>
+#include <comphelper/lok.hxx>
+#include <sfx2/lokhelper.hxx>
+
#include "attrib.hxx"
#include "patattr.hxx"
#include "dociter.hxx"
@@ -224,6 +227,14 @@ bool ScViewFunc::CopyToClip( ScDocument* pClipDoc, const ScRangeList& rRanges, b
// and lose the 'if' above
aClipParam.setSourceDocID( pDoc->GetDocumentID() );
+ // This is only a workaround, which doesn't allow to paste content
+ // in one view which has been copied in a different view.
+ // TODO: implement a solution providing one clipboard per view
+ if (comphelper::LibreOfficeKit::isActive())
+ {
+ aClipParam.setSourceView(GetViewData().GetViewShell());
+ }
+
if (SfxObjectShell* pObjectShell = pDoc->GetDocumentShell())
{
// Copy document properties from pObjectShell to pClipDoc (to its clip options, as it has no object shell).
@@ -862,6 +873,20 @@ bool ScViewFunc::PasteFromClip( InsertDeleteFlags nFlags, ScDocument* pClipDoc,
if (GetViewData().SelectionForbidsCellFill())
return false;
+ // This is only a workaround, which doesn't allow to paste content
+ // in one view which has been copied in a different view.
+ // TODO: implement a solution providing one clipboard per view
+ if (comphelper::LibreOfficeKit::isActive())
+ {
+ ScTabViewShell* pThisView = GetViewData().GetViewShell();
+ ScTabViewShell* pSourceView = dynamic_cast<ScTabViewShell*>(pClipDoc->GetClipParam().getSourceView());
+
+ if (pThisView && pSourceView && pThisView != pSourceView)
+ {
+ return false;
+ }
+ }
+
// undo: save all or no content
InsertDeleteFlags nContFlags = InsertDeleteFlags::NONE;
if (nFlags & InsertDeleteFlags::CONTENTS)