[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

Kohei Yoshida kohei.yoshida at gmail.com
Wed May 15 09:03:52 PDT 2013


 sc/inc/clipcontext.hxx              |   28 ++++++-
 sc/inc/column.hxx                   |    3 
 sc/inc/document.hxx                 |    6 -
 sc/inc/table.hxx                    |    2 
 sc/source/core/data/clipcontext.cxx |   49 ++++++++++++
 sc/source/core/data/column3.cxx     |   20 ++---
 sc/source/core/data/document.cxx    |  141 +++++++++++++-----------------------
 sc/source/core/data/table2.cxx      |   17 ++--
 8 files changed, 152 insertions(+), 114 deletions(-)

New commits:
commit 4aa1318c8a48645ea7ff32818f616de144b31fa1
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Wed May 15 12:04:56 2013 -0400

    Move all clip params into the new context class. We don't need two buckets.
    
    Change-Id: Ida0542583242ebcdd7f1448931e31656aa542457

diff --git a/sc/inc/clipcontext.hxx b/sc/inc/clipcontext.hxx
index 00049f1..ca6760f 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 9d810e1..cf171ae 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 7b7ea40..00cd7ab 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 ac2b2bf..70fc1cf 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 adfbfbb..5dcbddd 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 2939be0..0e15327 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 7245efb..d0bc5a6 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
 {
@@ -2298,21 +2309,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
 
@@ -2325,10 +2336,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 );
                 }
             }
@@ -2336,10 +2347,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) )
             {
@@ -2355,19 +2366,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 );
@@ -2379,34 +2390,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)
@@ -2416,7 +2426,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;
@@ -2497,28 +2507,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)
@@ -2529,8 +2520,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();
@@ -2569,13 +2558,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);
@@ -2591,8 +2580,6 @@ void ScDocument::CopyFromClip( const ScRange& rDestRange, const ScMarkData& rMar
         } while (nR1 <= nRow2);
     }
 
-    itr = rMark.begin();
-
     bInsertingFromOtherDoc = false;
 
     // Listener aufbauen nachdem alles inserted wurde
@@ -2639,26 +2626,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);
@@ -2668,9 +2638,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 ];
@@ -2687,7 +2656,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)
@@ -2706,7 +2675,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;
         }
 
@@ -2720,8 +2689,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 7e9b4c0..48f86ba 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 ) );


More information about the Libreoffice-commits mailing list