diff options
author | Kohei Yoshida <kohei.yoshida@suse.com> | 2011-09-12 11:36:44 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@suse.com> | 2011-09-12 13:22:07 -0400 |
commit | 458fd23a540465ad308300de250e118a4a7ef50f (patch) | |
tree | db70fc6996e4635240fec1454229fb06898b942a /sc/source/ui/view | |
parent | abccf9b8e5f331a27f188ec5246a9e0f64f287dd (diff) |
Moved the code that checks destination ranges to ScClipUtil.
Diffstat (limited to 'sc/source/ui/view')
-rw-r--r-- | sc/source/ui/view/cliputil.cxx | 35 | ||||
-rw-r--r-- | sc/source/ui/view/viewfun3.cxx | 31 |
2 files changed, 39 insertions, 27 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; +} 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(); |