summaryrefslogtreecommitdiffstats
path: root/sc
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@suse.com>2011-09-12 11:36:44 -0400
committerKohei Yoshida <kohei.yoshida@suse.com>2011-09-12 13:22:07 -0400
commit458fd23a540465ad308300de250e118a4a7ef50f (patch)
treedb70fc6996e4635240fec1454229fb06898b942a /sc
parentMoved PasteFromClipboard() from ScCellShell to ScClipUtil (new class). (diff)
downloadcore-458fd23a540465ad308300de250e118a4a7ef50f.tar.gz
core-458fd23a540465ad308300de250e118a4a7ef50f.zip
Moved the code that checks destination ranges to ScClipUtil.
Diffstat (limited to 'sc')
-rw-r--r--sc/source/ui/inc/cliputil.hxx9
-rw-r--r--sc/source/ui/view/cliputil.cxx35
-rw-r--r--sc/source/ui/view/viewfun3.cxx31
3 files changed, 48 insertions, 27 deletions
diff --git a/sc/source/ui/inc/cliputil.hxx b/sc/source/ui/inc/cliputil.hxx
index 04a966c34242..f5ddc474099f 100644
--- a/sc/source/ui/inc/cliputil.hxx
+++ b/sc/source/ui/inc/cliputil.hxx
@@ -28,8 +28,13 @@
#ifndef __SC_CLIPUTIL_HXX__
#define __SC_CLIPUTIL_HXX__
+#include "address.hxx"
+
class ScViewData;
class ScTabViewShell;
+class ScDocument;
+class ScMarkData;
+class ScRangeList;
class ScClipUtil
{
@@ -37,6 +42,10 @@ class ScClipUtil
~ScClipUtil();
public:
static void PasteFromClipboard( ScViewData* pViewData, ScTabViewShell* pTabViewShell, bool bShowDialog );
+
+ static bool CheckDestRanges(
+ ScDocument* pDoc, SCCOL nSrcCols, SCROW nSrcRows, const ScMarkData& rMark,
+ const ScRangeList& rDest);
};
#endif
diff --git a/sc/source/ui/view/cliputil.cxx b/sc/source/ui/view/cliputil.cxx
index d7a6f882677c..620b9c07cef7 100644
--- a/sc/source/ui/view/cliputil.cxx
+++ b/sc/source/ui/view/cliputil.cxx
@@ -33,6 +33,8 @@
#include "dpobject.hxx"
#include "globstr.hrc"
#include "clipparam.hxx"
+#include "rangelst.hxx"
+#include "viewutil.hxx"
#include "vcl/waitobj.hxx"
@@ -85,3 +87,36 @@ void ScClipUtil::PasteFromClipboard( ScViewData* pViewData, ScTabViewShell* pTab
}
pTabViewShell->CellContentChanged(); // => PasteFromSystem() ???
}
+
+bool ScClipUtil::CheckDestRanges(
+ ScDocument* pDoc, SCCOL nSrcCols, SCROW nSrcRows, const ScMarkData& rMark, const ScRangeList& rDest)
+{
+ for (size_t i = 0, n = rDest.size(); i < n; ++i)
+ {
+ ScRange aTest = *rDest[i];
+ // Check for filtered rows in all selected sheets.
+ ScMarkData::const_iterator itrTab = rMark.begin(), itrTabEnd = rMark.end();
+ for (; itrTab != itrTabEnd; ++itrTab)
+ {
+ aTest.aStart.SetTab(*itrTab);
+ aTest.aEnd.SetTab(*itrTab);
+ if (ScViewUtil::HasFiltered(aTest, pDoc))
+ {
+ // I don't know how to handle pasting into filtered rows yet.
+ return false;
+ }
+ }
+
+ // Destination range must be an exact multiple of the source range.
+ SCROW nRows = aTest.aEnd.Row() - aTest.aStart.Row() + 1;
+ SCCOL nCols = aTest.aEnd.Col() - aTest.aStart.Col() + 1;
+ SCROW nRowTest = (nRows / nSrcRows) * nSrcRows;
+ SCCOL nColTest = (nCols / nSrcCols) * nSrcCols;
+ if (nRows != nRowTest || nCols != nColTest)
+ {
+ // Destination range is not a multiple of the source range. Bail out.
+ return false;
+ }
+ }
+ return true;
+}
diff --git a/sc/source/ui/view/viewfun3.cxx b/sc/source/ui/view/viewfun3.cxx
index aaa07f94577a..028b68cdb97d 100644
--- a/sc/source/ui/view/viewfun3.cxx
+++ b/sc/source/ui/view/viewfun3.cxx
@@ -182,6 +182,7 @@
#include "clipparam.hxx"
#include "undodat.hxx"
#include "drawview.hxx"
+#include "cliputil.hxx"
using namespace com::sun::star;
@@ -1736,34 +1737,10 @@ bool ScViewFunc::PasteFromClipToMultiRanges(
ScRangeList aRanges;
aMark.MarkToSimple();
aMark.FillRangeListWithMarks(&aRanges, false);
- for (size_t i = 0, n = aRanges.size(); i < n; ++i)
+ if (!ScClipUtil::CheckDestRanges(pDoc, nColSize, nRowSize, aMark, aRanges))
{
- ScRange aTest = *aRanges[i];
- // Check for filtered rows in all selected sheets.
- ScMarkData::const_iterator itrTab = aMark.begin(), itrTabEnd = aMark.end();
- for (; itrTab != itrTabEnd; ++itrTab)
- {
- aTest.aStart.SetTab(*itrTab);
- aTest.aEnd.SetTab(*itrTab);
- if (ScViewUtil::HasFiltered(aTest, pDoc))
- {
- // I don't know how to handle pasting into filtered rows yet.
- ErrorMessage(STR_MSSG_PASTEFROMCLIP_0);
- return false;
- }
- }
-
- // Destination range must be an exact multiple of the source range.
- SCROW nRows = aTest.aEnd.Row() - aTest.aStart.Row() + 1;
- SCCOL nCols = aTest.aEnd.Col() - aTest.aStart.Col() + 1;
- SCROW nRowTest = (nRows / nRowSize) * nRowSize;
- SCCOL nColTest = (nCols / nColSize) * nColSize;
- if (nRows != nRowTest || nCols != nColTest)
- {
- // Destination range is not a multiple of the source range. Bail out.
- ErrorMessage(STR_MSSG_PASTEFROMCLIP_0);
- return false;
- }
+ ErrorMessage(STR_MSSG_PASTEFROMCLIP_0);
+ return false;
}
ScDocShell* pDocSh = rViewData.GetDocShell();