summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorMarco Cecchetti <marco.cecchetti@collabora.com>2017-05-24 20:46:31 +0200
committerJan Holesovsky <kendy@collabora.com>2017-07-27 11:41:06 +0200
commitf0684222540b96d8366ce175c522b64472361b80 (patch)
tree58c3f185286be0e55baf7a9c7409841cbd9d3cb6 /sc
parentb064a22f716d81cf293c8428cf1c7862811041ed (diff)
lok: sc: copy / paste confusion -- workaround
Problem: 1. (a) copied April 2. (a) pasted -> April 3. (b) copied March 4. (a) pasted -> March [should have been April] where (a), (b) are different views Solution: A real solution would require to have one clipboard per view. This patch is only a workaround, which doesn't allow to paste content which has been copied in a different view; it takes also care to disable the "Paste" entry in the context menu. Change-Id: I3254f130af106299b0b519884a4ca03db08fc4c8 Reviewed-on: https://gerrit.libreoffice.org/40459 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Jan Holesovsky <kendy@collabora.com>
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)