summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sc/inc/clipcontext.hxx28
-rw-r--r--sc/inc/column.hxx3
-rw-r--r--sc/inc/document.hxx6
-rw-r--r--sc/inc/table.hxx2
-rw-r--r--sc/source/core/data/clipcontext.cxx49
-rw-r--r--sc/source/core/data/column3.cxx20
-rw-r--r--sc/source/core/data/document.cxx141
-rw-r--r--sc/source/core/data/table2.cxx17
8 files changed, 152 insertions, 114 deletions
diff --git a/sc/inc/clipcontext.hxx b/sc/inc/clipcontext.hxx
index 00049f169771..ca6760fbccf9 100644
--- a/sc/inc/clipcontext.hxx
+++ b/sc/inc/clipcontext.hxx
@@ -10,13 +10,39 @@
#ifndef SC_CLIPCONTEXT_HXX
#define SC_CLIPCONTEXT_HXX
+#include "address.hxx"
+
+class ScDocument;
+
namespace sc {
class CopyFromClipContext
{
+ ScDocument* mpRefUndoDoc;
+ ScDocument* mpClipDoc;
+ sal_uInt16 mnInsertFlag;
+ SCTAB mnTabStart;
+ SCTAB mnTabEnd;
+ bool mbAsLink:1;
+ bool mbSkipAttrForEmptyCells:1;
+
+ CopyFromClipContext(); // disabled
public:
- CopyFromClipContext();
+ CopyFromClipContext(
+ ScDocument* pRefUndoDoc, ScDocument* pClipDoc, sal_uInt16 nInsertFlag,
+ bool bAsLink, bool bSkipAttrForEmptyCells);
+
+ void setTabRange(SCTAB nStart, SCTAB nEnd);
+
~CopyFromClipContext();
+
+ ScDocument* getUndoDoc();
+ ScDocument* getClipDoc();
+ sal_uInt16 getInsertFlag() const;
+ SCTAB getTabStart() const;
+ SCTAB getTabEnd() const;
+ bool isAsLink() const;
+ bool isSkipAttrForEmptyCells() const;
};
}
diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 9d810e1d59a1..cf171ae319bd 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -236,8 +236,7 @@ public:
void CopyStaticToDocument(SCROW nRow1, SCROW nRow2, ScColumn& rDestCol);
void CopyCellToDocument( SCROW nSrcRow, SCROW nDestRow, ScColumn& rDestCol );
void CopyFromClip(
- sc::CopyFromClipContext& rCxt, SCROW nRow1, SCROW nRow2, long nDy,
- sal_uInt16 nInsFlag, bool bAsLink, bool bSkipAttrForEmpty, ScColumn& rColumn );
+ sc::CopyFromClipContext& rCxt, SCROW nRow1, SCROW nRow2, long nDy, ScColumn& rColumn );
void StartListeningInArea( SCROW nRow1, SCROW nRow2 );
void BroadcastInArea( SCROW nRow1, SCROW nRow2 );
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 7b7ea40fa27f..00cd7abdae0d 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -144,7 +144,6 @@ class ScRowBreakIterator;
struct ScSetStringParam;
class ScDocRowHeightUpdater;
struct ScColWidthParam;
-struct ScCopyBlockFromClipParams;
class ScSheetEvents;
class ScProgress;
class SvtListener;
@@ -1143,11 +1142,10 @@ public:
SCTAB nTab, ScDocument* pClipDoc = NULL);
void CopyBlockFromClip(
sc::CopyFromClipContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
- const ScMarkData& rMark, SCsCOL nDx, SCsROW nDy, const ScCopyBlockFromClipParams* pCBFCP );
+ const ScMarkData& rMark, SCsCOL nDx, SCsROW nDy );
void CopyNonFilteredFromClip(
sc::CopyFromClipContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
- const ScMarkData& rMark, SCsCOL nDx, SCsROW nDy, const ScCopyBlockFromClipParams* pCBFCP,
- SCROW & rClipStartRow );
+ const ScMarkData& rMark, SCsCOL nDx, SCsROW nDy, SCROW & rClipStartRow );
void StartListeningFromClip( SCCOL nCol1, SCROW nRow1,
SCCOL nCol2, SCROW nRow2,
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index ac2b2bff23c6..70fc1cf2ac2f 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -386,7 +386,7 @@ public:
void CopyCellToDocument( SCCOL nSrcCol, SCROW nSrcRow, SCCOL nDestCol, SCROW nDestRow, ScTable& rDestTab );
void CopyFromClip(
sc::CopyFromClipContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
- SCsCOL nDx, SCsROW nDy, sal_uInt16 nInsFlag, bool bAsLink, bool bSkipAttrForEmpty, ScTable* pTable );
+ SCsCOL nDx, SCsROW nDy, ScTable* pTable );
void StartListeningInArea( SCCOL nCol1, SCROW nRow1,
SCCOL nCol2, SCROW nRow2 );
diff --git a/sc/source/core/data/clipcontext.cxx b/sc/source/core/data/clipcontext.cxx
index adfbfbb63186..5dcbdddaa96d 100644
--- a/sc/source/core/data/clipcontext.cxx
+++ b/sc/source/core/data/clipcontext.cxx
@@ -11,9 +11,56 @@
namespace sc {
-CopyFromClipContext::CopyFromClipContext() {}
+CopyFromClipContext::CopyFromClipContext(
+ ScDocument* pRefUndoDoc, ScDocument* pClipDoc, sal_uInt16 nInsertFlag,
+ bool bAsLink, bool bSkipAttrForEmptyCells) :
+ mpRefUndoDoc(pRefUndoDoc), mpClipDoc(pClipDoc), mnInsertFlag(nInsertFlag),
+ mnTabStart(0), mnTabEnd(0),
+ mbAsLink(bAsLink), mbSkipAttrForEmptyCells(bSkipAttrForEmptyCells) {}
+
CopyFromClipContext::~CopyFromClipContext() {}
+void CopyFromClipContext::setTabRange(SCTAB nStart, SCTAB nEnd)
+{
+ mnTabStart = nStart;
+ mnTabEnd = nEnd;
+}
+
+ScDocument* CopyFromClipContext::getUndoDoc()
+{
+ return mpRefUndoDoc;
+}
+
+ScDocument* CopyFromClipContext::getClipDoc()
+{
+ return mpClipDoc;
+}
+
+sal_uInt16 CopyFromClipContext::getInsertFlag() const
+{
+ return mnInsertFlag;
+}
+
+SCTAB CopyFromClipContext::getTabStart() const
+{
+ return mnTabStart;
+}
+
+SCTAB CopyFromClipContext::getTabEnd() const
+{
+ return mnTabEnd;
+}
+
+bool CopyFromClipContext::isAsLink() const
+{
+ return mbAsLink;
+}
+
+bool CopyFromClipContext::isSkipAttrForEmptyCells() const
+{
+ return mbSkipAttrForEmptyCells;
+}
+
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index 2939be02e903..0e15327f6240 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -49,6 +49,7 @@
#include "cellvalue.hxx"
#include "tokenarray.hxx"
#include "stlalgorithm.hxx"
+#include "clipcontext.hxx"
#include <com/sun/star/i18n/LocaleDataItem.hpp>
@@ -565,12 +566,11 @@ ScFormulaCell* ScColumn::CreateRefCell( ScDocument* pDestDoc, const ScAddress& r
// nRow1, nRow2 = target position
void ScColumn::CopyFromClip(
- sc::CopyFromClipContext& rCxt, SCROW nRow1, SCROW nRow2, long nDy,
- sal_uInt16 nInsFlag, bool bAsLink, bool bSkipAttrForEmpty, ScColumn& rColumn )
+ sc::CopyFromClipContext& rCxt, SCROW nRow1, SCROW nRow2, long nDy, ScColumn& rColumn )
{
- if ((nInsFlag & IDF_ATTRIB) != 0)
+ if ((rCxt.getInsertFlag() & IDF_ATTRIB) != 0)
{
- if ( bSkipAttrForEmpty )
+ if (rCxt.isSkipAttrForEmptyCells())
{
// copy only attributes for non-empty cells
// (notes are not counted as non-empty here, to match the content behavior)
@@ -599,10 +599,10 @@ void ScColumn::CopyFromClip(
else
rColumn.pAttrArray->CopyAreaSafe( nRow1, nRow2, nDy, *pAttrArray );
}
- if ((nInsFlag & IDF_CONTENTS) == 0)
+ if ((rCxt.getInsertFlag() & IDF_CONTENTS) == 0)
return;
- if ( bAsLink && nInsFlag == IDF_ALL )
+ if (rCxt.isAsLink() && rCxt.getInsertFlag() == IDF_ALL)
{
// We also reference empty cells for "ALL"
// IDF_ALL must always contain more flags when compared to "Insert contents" as
@@ -637,7 +637,7 @@ void ScColumn::CopyFromClip(
SCSIZE nColCount = rColumn.maItems.size();
// ignore IDF_FORMULA - "all contents but no formulas" results in the same number of cells
- if ((nInsFlag & ( IDF_CONTENTS & ~IDF_FORMULA )) == ( IDF_CONTENTS & ~IDF_FORMULA ) && nRow2-nRow1 >= 64)
+ if ((rCxt.getInsertFlag() & ( IDF_CONTENTS & ~IDF_FORMULA )) == ( IDF_CONTENTS & ~IDF_FORMULA ) && nRow2-nRow1 >= 64)
{
//! Always do the Resize from the outside, where the number of repetitions is known
//! (then it can be removed here)
@@ -658,9 +658,9 @@ void ScColumn::CopyFromClip(
ScAddress aDestPos( nCol, (SCROW)nDestRow, nTab );
- ScBaseCell* pNewCell = bAsLink ?
- rColumn.CreateRefCell( pDocument, aDestPos, i, nInsFlag ) :
- rColumn.CloneCell( i, nInsFlag, *pDocument, aDestPos );
+ ScBaseCell* pNewCell = rCxt.isAsLink() ?
+ rColumn.CreateRefCell(pDocument, aDestPos, i, rCxt.getInsertFlag()) :
+ rColumn.CloneCell(i, rCxt.getInsertFlag(), *pDocument, aDestPos);
if (pNewCell)
Insert( aDestPos.Row(), pNewCell );
}
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index c603687d7fa5..6e54c3bcf9d9 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -103,17 +103,28 @@ using ::com::sun::star::uno::Sequence;
using ::com::sun::star::sheet::TablePageBreakData;
using ::std::set;
-// The constant parameters to CopyBlockFromClip
-struct ScCopyBlockFromClipParams
-{
- ScDocument* pRefUndoDoc;
- ScDocument* pClipDoc;
- sal_uInt16 nInsFlag;
- SCTAB nTabStart;
- SCTAB nTabEnd;
- bool bAsLink;
- bool bSkipAttrForEmpty;
-};
+namespace {
+
+std::pair<SCTAB,SCTAB> getMarkedTableRange(const std::vector<ScTable*>& rTables, const ScMarkData& rMark)
+{
+ SCTAB nTabStart = MAXTAB;
+ SCTAB nTabEnd = 0;
+ SCTAB nMax = static_cast<SCTAB>(rTables.size());
+ ScMarkData::const_iterator itr = rMark.begin(), itrEnd = rMark.end();
+ for (; itr != itrEnd && *itr < nMax; ++itr)
+ {
+ if (!rTables[*itr])
+ continue;
+
+ if (*itr < nTabStart)
+ nTabStart = *itr;
+ nTabEnd = *itr;
+ }
+
+ return std::pair<SCTAB,SCTAB>(nTabStart,nTabEnd);
+}
+
+}
struct ScDefaultAttr
{
@@ -2302,21 +2313,21 @@ void ScDocument::BroadcastFromClip( SCCOL nCol1, SCROW nRow1,
void ScDocument::CopyBlockFromClip(
sc::CopyFromClipContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
- const ScMarkData& rMark, SCsCOL nDx, SCsROW nDy, const ScCopyBlockFromClipParams* pCBFCP )
+ const ScMarkData& rMark, SCsCOL nDx, SCsROW nDy )
{
- TableContainer& rClipTabs = pCBFCP->pClipDoc->maTabs;
- SCTAB nTabEnd = pCBFCP->nTabEnd;
+ TableContainer& rClipTabs = rCxt.getClipDoc()->maTabs;
+ SCTAB nTabEnd = rCxt.getTabEnd();
SCTAB nClipTab = 0;
- for (SCTAB i = pCBFCP->nTabStart; i <= nTabEnd && i < static_cast<SCTAB>(maTabs.size()); i++)
+ for (SCTAB i = rCxt.getTabStart(); i <= nTabEnd && i < static_cast<SCTAB>(maTabs.size()); i++)
{
if (maTabs[i] && rMark.GetTableSelect(i) )
{
while (!rClipTabs[nClipTab]) nClipTab = (nClipTab+1) % (static_cast<SCTAB>(rClipTabs.size()));
- maTabs[i]->CopyFromClip(rCxt, nCol1, nRow1, nCol2, nRow2, nDx, nDy,
- pCBFCP->nInsFlag, pCBFCP->bAsLink, pCBFCP->bSkipAttrForEmpty, rClipTabs[nClipTab]);
+ maTabs[i]->CopyFromClip(
+ rCxt, nCol1, nRow1, nCol2, nRow2, nDx, nDy, rClipTabs[nClipTab]);
- if ( pCBFCP->pClipDoc->pDrawLayer && ( pCBFCP->nInsFlag & IDF_OBJECTS ) )
+ if (rCxt.getClipDoc()->pDrawLayer && (rCxt.getInsertFlag() & IDF_OBJECTS))
{
// also copy drawing objects
@@ -2329,10 +2340,10 @@ void ScDocument::CopyBlockFromClip(
// (copied in an extra step before pasting, or updated after pasting cells, but
// before pasting objects).
- Rectangle aSourceRect = pCBFCP->pClipDoc->GetMMRect(
+ Rectangle aSourceRect = rCxt.getClipDoc()->GetMMRect(
nCol1-nDx, nRow1-nDy, nCol2-nDx, nRow2-nDy, nClipTab );
Rectangle aDestRect = GetMMRect( nCol1, nRow1, nCol2, nRow2, i );
- pDrawLayer->CopyFromClip( pCBFCP->pClipDoc->pDrawLayer, nClipTab, aSourceRect,
+ pDrawLayer->CopyFromClip(rCxt.getClipDoc()->pDrawLayer, nClipTab, aSourceRect,
ScAddress( nCol1, nRow1, i ), aDestRect );
}
}
@@ -2340,10 +2351,10 @@ void ScDocument::CopyBlockFromClip(
nClipTab = (nClipTab+1) % (static_cast<SCTAB>(rClipTabs.size()));
}
}
- if ( pCBFCP->nInsFlag & IDF_CONTENTS )
+ if (rCxt.getInsertFlag() & IDF_CONTENTS)
{
nClipTab = 0;
- for (SCTAB i = pCBFCP->nTabStart; i <= nTabEnd && i < static_cast<SCTAB>(maTabs.size()); i++)
+ for (SCTAB i = rCxt.getTabStart(); i <= nTabEnd && i < static_cast<SCTAB>(maTabs.size()); i++)
{
if (maTabs[i] && rMark.GetTableSelect(i) )
{
@@ -2359,19 +2370,19 @@ void ScDocument::CopyBlockFromClip(
&& rClipTabs[(nClipTab + nFollow + 1) % static_cast<SCTAB>(rClipTabs.size())] )
++nFollow;
- if ( pCBFCP->pClipDoc->GetClipParam().mbCutMode )
+ if (rCxt.getClipDoc()->GetClipParam().mbCutMode)
{
bool bOldInserting = IsInsertingFromOtherDoc();
SetInsertingFromOtherDoc( true);
UpdateReference( URM_MOVE,
nCol1, nRow1, i, nCol2, nRow2, i+nFollow,
- nDx, nDy, nDz, pCBFCP->pRefUndoDoc, false );
+ nDx, nDy, nDz, rCxt.getUndoDoc(), false );
SetInsertingFromOtherDoc( bOldInserting);
}
else
UpdateReference( URM_COPY,
nCol1, nRow1, i, nCol2, nRow2, i+nFollow,
- nDx, nDy, nDz, pCBFCP->pRefUndoDoc, false );
+ nDx, nDy, nDz, rCxt.getUndoDoc(), false );
nClipTab = (nClipTab+nFollow+1) % (static_cast<SCTAB>(rClipTabs.size()));
i = sal::static_int_cast<SCTAB>( i + nFollow );
@@ -2383,34 +2394,33 @@ void ScDocument::CopyBlockFromClip(
void ScDocument::CopyNonFilteredFromClip(
sc::CopyFromClipContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
- const ScMarkData& rMark, SCsCOL nDx, SCsROW /*nDy*/, const ScCopyBlockFromClipParams* pCBFCP,
- SCROW & rClipStartRow )
+ const ScMarkData& rMark, SCsCOL nDx, SCsROW /*nDy*/, SCROW & rClipStartRow )
{
// call CopyBlockFromClip for ranges of consecutive non-filtered rows
// nCol1/nRow1 etc. is in target doc
// filtered state is taken from first used table in clipboard (as in GetClipArea)
SCTAB nFlagTab = 0;
- TableContainer& rClipTabs = pCBFCP->pClipDoc->maTabs;
+ TableContainer& rClipTabs = rCxt.getClipDoc()->maTabs;
while ( nFlagTab < static_cast<SCTAB>(rClipTabs.size()) && !rClipTabs[nFlagTab] )
++nFlagTab;
SCROW nSourceRow = rClipStartRow;
SCROW nSourceEnd = 0;
- if ( !pCBFCP->pClipDoc->GetClipParam().maRanges.empty() )
- nSourceEnd = pCBFCP->pClipDoc->GetClipParam().maRanges.front()->aEnd.Row();
+ if (!rCxt.getClipDoc()->GetClipParam().maRanges.empty())
+ nSourceEnd = rCxt.getClipDoc()->GetClipParam().maRanges.front()->aEnd.Row();
SCROW nDestRow = nRow1;
while ( nSourceRow <= nSourceEnd && nDestRow <= nRow2 )
{
// skip filtered rows
- nSourceRow = pCBFCP->pClipDoc->FirstNonFilteredRow(nSourceRow, nSourceEnd, nFlagTab);
+ nSourceRow = rCxt.getClipDoc()->FirstNonFilteredRow(nSourceRow, nSourceEnd, nFlagTab);
if ( nSourceRow <= nSourceEnd )
{
// look for more non-filtered rows following
SCROW nLastRow = nSourceRow;
- pCBFCP->pClipDoc->RowFiltered(nSourceRow, nFlagTab, NULL, &nLastRow);
+ rCxt.getClipDoc()->RowFiltered(nSourceRow, nFlagTab, NULL, &nLastRow);
SCROW nFollow = nLastRow - nSourceRow;
if (nFollow > nSourceEnd - nSourceRow)
@@ -2420,7 +2430,7 @@ void ScDocument::CopyNonFilteredFromClip(
SCsROW nNewDy = ((SCsROW)nDestRow) - nSourceRow;
CopyBlockFromClip(
- rCxt, nCol1, nDestRow, nCol2, nDestRow + nFollow, rMark, nDx, nNewDy, pCBFCP);
+ rCxt, nCol1, nDestRow, nCol2, nDestRow + nFollow, rMark, nDx, nNewDy);
nSourceRow += nFollow + 1;
nDestRow += nFollow + 1;
@@ -2501,28 +2511,9 @@ void ScDocument::CopyFromClip( const ScRange& rDestRange, const ScMarkData& rMar
if ( ( nInsFlag & IDF_ATTRIB ) && !bSkipAttrForEmpty )
nDelFlag |= IDF_ATTRIB;
- ScCopyBlockFromClipParams aCBFCP;
- aCBFCP.pRefUndoDoc = pRefUndoDoc;
- aCBFCP.pClipDoc = pClipDoc;
- aCBFCP.nInsFlag = nInsFlag;
- aCBFCP.bAsLink = bAsLink;
- aCBFCP.bSkipAttrForEmpty = bSkipAttrForEmpty;
- aCBFCP.nTabStart = MAXTAB; // wird in der Schleife angepasst
- aCBFCP.nTabEnd = 0; // wird in der Schleife angepasst
-
- // Inc/DecRecalcLevel einmal aussen, damit nicht fuer jeden Block
- // die Draw-Seitengroesse neu berechnet werden muss
- //! nur wenn ganze Zeilen/Spalten kopiert werden?
-
- SCTAB nMax = static_cast<SCTAB>(maTabs.size());
- ScMarkData::const_iterator itr = rMark.begin(), itrEnd = rMark.end();
- for (; itr != itrEnd && *itr < nMax; ++itr)
- if (maTabs[*itr])
- {
- if ( *itr < aCBFCP.nTabStart )
- aCBFCP.nTabStart = *itr;
- aCBFCP.nTabEnd = *itr;
- }
+ sc::CopyFromClipContext aCxt(pRefUndoDoc, pClipDoc, nInsFlag, bAsLink, bSkipAttrForEmpty);
+ std::pair<SCTAB,SCTAB> aTabRanges = getMarkedTableRange(maTabs, rMark);
+ aCxt.setTabRange(aTabRanges.first, aTabRanges.second);
ScRangeList aLocalRangeList;
if (!pDestRanges)
@@ -2533,8 +2524,6 @@ void ScDocument::CopyFromClip( const ScRange& rDestRange, const ScMarkData& rMar
bInsertingFromOtherDoc = true; // kein Broadcast/Listener aufbauen bei Insert
- sc::CopyFromClipContext aCxt;
-
SCCOL nClipStartCol = aClipRange.aStart.Col();
SCROW nClipStartRow = aClipRange.aStart.Row();
SCROW nClipEndRow = aClipRange.aEnd.Row();
@@ -2573,13 +2562,13 @@ void ScDocument::CopyFromClip( const ScRange& rDestRange, const ScMarkData& rMar
if ( bIncludeFiltered )
{
CopyBlockFromClip(
- aCxt, nC1, nR1, nC2, nR2, rMark, nDx, nDy, &aCBFCP);
+ aCxt, nC1, nR1, nC2, nR2, rMark, nDx, nDy);
nClipStartRow += nR2 - nR1 + 1;
}
else
{
CopyNonFilteredFromClip(
- aCxt, nC1, nR1, nC2, nR2, rMark, nDx, nDy, &aCBFCP, nClipStartRow);
+ aCxt, nC1, nR1, nC2, nR2, rMark, nDx, nDy, nClipStartRow);
}
nC1 = nC2 + 1;
nC2 = std::min((SCCOL)(nC1 + nXw), nCol2);
@@ -2595,8 +2584,6 @@ void ScDocument::CopyFromClip( const ScRange& rDestRange, const ScMarkData& rMar
} while (nR1 <= nRow2);
}
- itr = rMark.begin();
-
bInsertingFromOtherDoc = false;
// Listener aufbauen nachdem alles inserted wurde
@@ -2643,26 +2630,9 @@ void ScDocument::CopyMultiRangeFromClip(
SCROW nRow1 = rDestPos.Row();
ScClipParam& rClipParam = pClipDoc->GetClipParam();
- ScCopyBlockFromClipParams aCBFCP;
- aCBFCP.pRefUndoDoc = NULL;
- aCBFCP.pClipDoc = pClipDoc;
- aCBFCP.nInsFlag = nInsFlag;
- aCBFCP.bAsLink = bAsLink;
- aCBFCP.bSkipAttrForEmpty = bSkipAttrForEmpty;
- aCBFCP.nTabStart = MAXTAB;
- aCBFCP.nTabEnd = 0;
-
- SCTAB nMax = static_cast<SCTAB>(maTabs.size());
- ScMarkData::const_iterator itr = rMark.begin(), itrEnd = rMark.end();
- for (; itr != itrEnd && *itr < nMax; ++itr)
- {
- if (maTabs[*itr])
- {
- if ( *itr < aCBFCP.nTabStart )
- aCBFCP.nTabStart = *itr;
- aCBFCP.nTabEnd = *itr;
- }
- }
+ sc::CopyFromClipContext aCxt(NULL, pClipDoc, nInsFlag, bAsLink, bSkipAttrForEmpty);
+ std::pair<SCTAB,SCTAB> aTabRanges = getMarkedTableRange(maTabs, rMark);
+ aCxt.setTabRange(aTabRanges.first, aTabRanges.second);
ScRange aDestRange;
rMark.GetMarkArea(aDestRange);
@@ -2672,9 +2642,8 @@ void ScDocument::CopyMultiRangeFromClip(
SCROW nBegRow = nRow1;
sal_uInt16 nDelFlag = IDF_CONTENTS;
- const ScBitMaskCompressedArray<SCROW, sal_uInt8>& rFlags = GetRowFlagsArray(aCBFCP.nTabStart);
+ const ScBitMaskCompressedArray<SCROW, sal_uInt8>& rFlags = GetRowFlagsArray(aCxt.getTabStart());
- sc::CopyFromClipContext aCxt;
for ( size_t i = 0, n = rClipParam.maRanges.size(); i < n; ++i )
{
ScRange* p = rClipParam.maRanges[ i ];
@@ -2691,7 +2660,7 @@ void ScDocument::CopyMultiRangeFromClip(
if (!bSkipAttrForEmpty)
DeleteArea(nCol1, nBegRow, nCol2, nEndRow, rMark, nDelFlag);
- CopyBlockFromClip(aCxt, nCol1, nBegRow, nCol2, nEndRow, rMark, nDx, nDy, &aCBFCP);
+ CopyBlockFromClip(aCxt, nCol1, nBegRow, nCol2, nEndRow, rMark, nDx, nDy);
nRowCount -= nEndRow - nBegRow + 1;
while (nRowCount > 0)
@@ -2710,7 +2679,7 @@ void ScDocument::CopyMultiRangeFromClip(
if (!bSkipAttrForEmpty)
DeleteArea(nCol1, nBegRow, nCol2, nEndRow, rMark, nDelFlag);
- CopyBlockFromClip(aCxt, nCol1, nBegRow, nCol2, nEndRow, rMark, nDx, nDy, &aCBFCP);
+ CopyBlockFromClip(aCxt, nCol1, nBegRow, nCol2, nEndRow, rMark, nDx, nDy);
nRowCount -= nEndRow - nBegRow + 1;
}
@@ -2724,8 +2693,6 @@ void ScDocument::CopyMultiRangeFromClip(
nCol1 += p->aEnd.Col() - p->aStart.Col() + 1;
}
- itr = rMark.begin();
-
bInsertingFromOtherDoc = false;
ScRangeList aRanges;
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index 7e9b4c06d745..48f86ba29b2f 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -43,6 +43,7 @@
#include "dbdata.hxx"
#include "colorscale.hxx"
#include "tokenarray.hxx"
+#include "clipcontext.hxx"
#include "scitems.hxx"
#include <editeng/boxitem.hxx>
@@ -747,7 +748,7 @@ void ScTable::CopyConditionalFormat( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCRO
void ScTable::CopyFromClip(
sc::CopyFromClipContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
- SCsCOL nDx, SCsROW nDy, sal_uInt16 nInsFlag, bool bAsLink, bool bSkipAttrForEmpty, ScTable* pTable )
+ SCsCOL nDx, SCsROW nDy, ScTable* pTable )
{
if (nCol2 > MAXCOL)
@@ -758,10 +759,10 @@ void ScTable::CopyFromClip(
if (ValidColRow(nCol1, nRow1) && ValidColRow(nCol2, nRow2))
{
for ( SCCOL i = nCol1; i <= nCol2; i++)
- aCol[i].CopyFromClip(rCxt, nRow1, nRow2, nDy, nInsFlag, bAsLink, bSkipAttrForEmpty, pTable->aCol[i - nDx]);
+ aCol[i].CopyFromClip(rCxt, nRow1, nRow2, nDy, pTable->aCol[i - nDx]);
- if(nInsFlag != IDF_OBJECTS)
+ if (rCxt.getInsertFlag() != IDF_OBJECTS)
{
// make sure that there are no old references to the cond formats
sal_uInt16 nWhichArray[2];
@@ -772,18 +773,18 @@ void ScTable::CopyFromClip(
}
//remove old notes
- if (nInsFlag & (IDF_NOTE|IDF_ADDNOTES))
+ if (rCxt.getInsertFlag() & (IDF_NOTE|IDF_ADDNOTES))
maNotes.erase(nCol1, nRow1, nCol2, nRow2);
- bool bAddNotes = nInsFlag & (IDF_NOTE | IDF_ADDNOTES);
+ bool bAddNotes = rCxt.getInsertFlag() & (IDF_NOTE | IDF_ADDNOTES);
if (bAddNotes)
{
- bool bCloneCaption = (nInsFlag & IDF_NOCAPTIONS) == 0;
+ bool bCloneCaption = (rCxt.getInsertFlag() & IDF_NOCAPTIONS) == 0;
maNotes.CopyFromClip(pTable->maNotes, pDocument, nCol1, nRow1, nCol2, nRow2, nDx, nDy, nTab, bCloneCaption);
}
- if ((nInsFlag & IDF_ATTRIB) != 0)
+ if ((rCxt.getInsertFlag() & IDF_ATTRIB) != 0)
{
if (nRow1==0 && nRow2==MAXROW && pColWidth && pTable->pColWidth)
for (SCCOL i=nCol1; i<=nCol2; i++)
@@ -804,7 +805,7 @@ void ScTable::CopyFromClip(
}
// Zellschutz auf geschuetzter Tabelle nicht setzen
- if ( IsProtected() && (nInsFlag & IDF_ATTRIB) )
+ if (IsProtected() && (rCxt.getInsertFlag() & IDF_ATTRIB))
{
ScPatternAttr aPattern(pDocument->GetPool());
aPattern.GetItemSet().Put( ScProtectionAttr( false ) );