summaryrefslogtreecommitdiffstats
path: root/sc/source/ui/view/cliputil.cxx
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/source/ui/view/cliputil.cxx
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/source/ui/view/cliputil.cxx')
-rw-r--r--sc/source/ui/view/cliputil.cxx35
1 files changed, 35 insertions, 0 deletions
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;
+}