Kaydet (Commit) 458fd23a authored tarafından Kohei Yoshida's avatar Kohei Yoshida

Moved the code that checks destination ranges to ScClipUtil.

üst abccf9b8
...@@ -28,8 +28,13 @@ ...@@ -28,8 +28,13 @@
#ifndef __SC_CLIPUTIL_HXX__ #ifndef __SC_CLIPUTIL_HXX__
#define __SC_CLIPUTIL_HXX__ #define __SC_CLIPUTIL_HXX__
#include "address.hxx"
class ScViewData; class ScViewData;
class ScTabViewShell; class ScTabViewShell;
class ScDocument;
class ScMarkData;
class ScRangeList;
class ScClipUtil class ScClipUtil
{ {
...@@ -37,6 +42,10 @@ class ScClipUtil ...@@ -37,6 +42,10 @@ class ScClipUtil
~ScClipUtil(); ~ScClipUtil();
public: public:
static void PasteFromClipboard( ScViewData* pViewData, ScTabViewShell* pTabViewShell, bool bShowDialog ); 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 #endif
...@@ -33,6 +33,8 @@ ...@@ -33,6 +33,8 @@
#include "dpobject.hxx" #include "dpobject.hxx"
#include "globstr.hrc" #include "globstr.hrc"
#include "clipparam.hxx" #include "clipparam.hxx"
#include "rangelst.hxx"
#include "viewutil.hxx"
#include "vcl/waitobj.hxx" #include "vcl/waitobj.hxx"
...@@ -85,3 +87,36 @@ void ScClipUtil::PasteFromClipboard( ScViewData* pViewData, ScTabViewShell* pTab ...@@ -85,3 +87,36 @@ void ScClipUtil::PasteFromClipboard( ScViewData* pViewData, ScTabViewShell* pTab
} }
pTabViewShell->CellContentChanged(); // => PasteFromSystem() ??? 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;
}
...@@ -182,6 +182,7 @@ ...@@ -182,6 +182,7 @@
#include "clipparam.hxx" #include "clipparam.hxx"
#include "undodat.hxx" #include "undodat.hxx"
#include "drawview.hxx" #include "drawview.hxx"
#include "cliputil.hxx"
using namespace com::sun::star; using namespace com::sun::star;
...@@ -1736,34 +1737,10 @@ bool ScViewFunc::PasteFromClipToMultiRanges( ...@@ -1736,34 +1737,10 @@ bool ScViewFunc::PasteFromClipToMultiRanges(
ScRangeList aRanges; ScRangeList aRanges;
aMark.MarkToSimple(); aMark.MarkToSimple();
aMark.FillRangeListWithMarks(&aRanges, false); 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]; ErrorMessage(STR_MSSG_PASTEFROMCLIP_0);
// Check for filtered rows in all selected sheets. return false;
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;
}
} }
ScDocShell* pDocSh = rViewData.GetDocShell(); ScDocShell* pDocSh = rViewData.GetDocShell();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment