diff options
author | Kohei Yoshida <kohei.yoshida@gmail.com> | 2013-05-17 15:08:23 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@gmail.com> | 2013-05-20 20:18:46 -0400 |
commit | 430d81e1fd44f51a91b81da91504a004ab7373d8 (patch) | |
tree | 30e2dd643b1b38d4f7114bc11616405fd2e44ca0 /sc | |
parent | 9cf69e73e6e20fda2518c27e617cc990e95d60ee (diff) |
Same with MixDocument(). But this one has additional bottleneck...
With the removal of existing cells. So, this change is not enough to
make this operation fly.
Change-Id: Ic468375f6d0c28e2cc7d5391fb0565d53ee7fb4e
Diffstat (limited to 'sc')
-rw-r--r-- | sc/inc/clipcontext.hxx | 7 | ||||
-rw-r--r-- | sc/inc/column.hxx | 11 | ||||
-rw-r--r-- | sc/inc/document.hxx | 2 | ||||
-rw-r--r-- | sc/inc/table.hxx | 12 | ||||
-rw-r--r-- | sc/source/core/data/clipcontext.cxx | 3 | ||||
-rw-r--r-- | sc/source/core/data/column3.cxx | 21 | ||||
-rw-r--r-- | sc/source/core/data/document.cxx | 43 | ||||
-rw-r--r-- | sc/source/core/data/table2.cxx | 14 |
8 files changed, 86 insertions, 27 deletions
diff --git a/sc/inc/clipcontext.hxx b/sc/inc/clipcontext.hxx index 4d9224f425b6..599da6efceb2 100644 --- a/sc/inc/clipcontext.hxx +++ b/sc/inc/clipcontext.hxx @@ -90,6 +90,13 @@ public: virtual ~CopyToDocContext(); }; +class MixDocContext : public ClipContextBase +{ +public: + MixDocContext(ScDocument& rDoc); + virtual ~MixDocContext(); +}; + } #endif diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx index 0e7ed533dc1c..c71ffeaba354 100644 --- a/sc/inc/column.hxx +++ b/sc/inc/column.hxx @@ -41,6 +41,7 @@ namespace sc { class CopyFromClipContext; class CopyToClipContext; class CopyToDocContext; + class MixDocContext; struct ColumnBlockPosition; } @@ -231,10 +232,12 @@ public: void RemoveEditAttribs( SCROW nStartRow, SCROW nEndRow ); // Selection (?) of this document - void MixMarked( const ScMarkData& rMark, sal_uInt16 nFunction, - bool bSkipEmpty, ScColumn& rSrcCol ); - void MixData( SCROW nRow1, SCROW nRow2, sal_uInt16 nFunction, bool bSkipEmpty, - ScColumn& rSrcCol ); + void MixMarked( + sc::MixDocContext& rCxt, const ScMarkData& rMark, sal_uInt16 nFunction, + bool bSkipEmpty, const ScColumn& rSrcCol ); + void MixData( + sc::MixDocContext& rCxt, SCROW nRow1, SCROW nRow2, sal_uInt16 nFunction, bool bSkipEmpty, + const ScColumn& rSrcCol ); ScFormulaCell* CreateRefCell( ScDocument* pDestDoc, const ScAddress& rDestPos, SCSIZE nIndex, sal_uInt16 nFlags ) const; diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx index 5f63d85a5586..f01e811eb94e 100644 --- a/sc/inc/document.hxx +++ b/sc/inc/document.hxx @@ -1988,6 +1988,8 @@ private: // CLOOK-Impl-methods }; bool TableExists( SCTAB nTab ) const; + ScTable* FetchTable( SCTAB nTab ); + const ScTable* FetchTable( SCTAB nTab ) const; void MergeNumberFormatter(ScDocument* pSrcDoc); diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx index 7d0836fdb26d..f04a9bbe0a47 100644 --- a/sc/inc/table.hxx +++ b/sc/inc/table.hxx @@ -53,6 +53,7 @@ namespace sc { class CopyFromClipContext; class CopyToClipContext; class CopyToDocContext; + class MixDocContext; struct ColumnBlockPosition; } @@ -412,10 +413,13 @@ public: ScTable* pTransClip, sal_uInt16 nFlags, bool bAsLink ); // mark of this document - void MixMarked( const ScMarkData& rMark, sal_uInt16 nFunction, - bool bSkipEmpty, ScTable* pSrcTab ); - void MixData( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, - sal_uInt16 nFunction, bool bSkipEmpty, ScTable* pSrcTab ); + void MixMarked( + sc::MixDocContext& rCxt, const ScMarkData& rMark, sal_uInt16 nFunction, + bool bSkipEmpty, const ScTable* pSrcTab ); + + void MixData( + sc::MixDocContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, + sal_uInt16 nFunction, bool bSkipEmpty, const ScTable* pSrcTab ); void CopyData( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, SCCOL nDestCol, SCROW nDestRow, SCTAB nDestTab ); diff --git a/sc/source/core/data/clipcontext.cxx b/sc/source/core/data/clipcontext.cxx index 8777aa3487b7..2c7abdfb05b6 100644 --- a/sc/source/core/data/clipcontext.cxx +++ b/sc/source/core/data/clipcontext.cxx @@ -120,6 +120,9 @@ bool CopyToClipContext::isCloneNotes() const CopyToDocContext::CopyToDocContext(ScDocument& rDoc) : ClipContextBase(rDoc) {} CopyToDocContext::~CopyToDocContext() {} +MixDocContext::MixDocContext(ScDocument& rDoc) : ClipContextBase(rDoc) {} +MixDocContext::~MixDocContext() {} + } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx index a29f7916fe27..b530184ee594 100644 --- a/sc/source/core/data/column3.cxx +++ b/sc/source/core/data/column3.cxx @@ -828,8 +828,9 @@ ScBaseCell* ScColumn::CloneCell( } -void ScColumn::MixMarked( const ScMarkData& rMark, sal_uInt16 nFunction, - bool bSkipEmpty, ScColumn& rSrcCol ) +void ScColumn::MixMarked( + sc::MixDocContext& rCxt, const ScMarkData& rMark, sal_uInt16 nFunction, + bool bSkipEmpty, const ScColumn& rSrcCol ) { SCROW nRow1, nRow2; @@ -837,7 +838,7 @@ void ScColumn::MixMarked( const ScMarkData& rMark, sal_uInt16 nFunction, { ScMarkArrayIter aIter( rMark.GetArray()+nCol ); while (aIter.Next( nRow1, nRow2 )) - MixData( nRow1, nRow2, nFunction, bSkipEmpty, rSrcCol ); + MixData(rCxt, nRow1, nRow2, nFunction, bSkipEmpty, rSrcCol); } } @@ -885,9 +886,9 @@ static void lcl_AddCode( ScTokenArray& rArr, ScFormulaCell* pCell ) } -void ScColumn::MixData( SCROW nRow1, SCROW nRow2, - sal_uInt16 nFunction, bool bSkipEmpty, - ScColumn& rSrcCol ) +void ScColumn::MixData( + sc::MixDocContext& rCxt, SCROW nRow1, SCROW nRow2, sal_uInt16 nFunction, + bool bSkipEmpty, const ScColumn& rSrcCol ) { SCSIZE nSrcCount = rSrcCol.maItems.size(); @@ -1023,12 +1024,18 @@ void ScColumn::MixData( SCROW nRow1, SCROW nRow2, if ( pNew || bDelete ) // New result? { + sc::ColumnBlockPosition* p = rCxt.getBlockPosition(nTab, nCol); if (pDest && !pNew) // Old cell present? { Delete(nRow); // -> Delete } if (pNew) - Insert(nRow, pNew); // Insert new one + { + if (p) + Insert(*p, nRow, pNew); + else + Insert(nRow, pNew); // Insert new one + } Search( nRow, nIndex ); // Everything could have moved if (pNew) diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx index 6ca6fc05e74d..5fbc1ac0e0d5 100644 --- a/sc/source/core/data/document.cxx +++ b/sc/source/core/data/document.cxx @@ -2264,6 +2264,22 @@ bool ScDocument::TableExists( SCTAB nTab ) const return ValidTab(nTab) && static_cast<size_t>(nTab) < maTabs.size() && maTabs[nTab]; } +ScTable* ScDocument::FetchTable( SCTAB nTab ) +{ + if (!TableExists(nTab)) + return NULL; + + return maTabs[nTab]; +} + +const ScTable* ScDocument::FetchTable( SCTAB nTab ) const +{ + if (!TableExists(nTab)) + return NULL; + + return maTabs[nTab]; +} + void ScDocument::MergeNumberFormatter(ScDocument* pSrcDoc) { SvNumberFormatter* pThisFormatter = xPoolHelper->GetFormTable(); @@ -2849,12 +2865,20 @@ void ScDocument::MixDocument( const ScRange& rRange, sal_uInt16 nFunction, bool { SCTAB nTab1 = rRange.aStart.Tab(); SCTAB nTab2 = rRange.aEnd.Tab(); + sc::MixDocContext aCxt(*this); + aCxt.setTabRange(nTab1, nTab2); SCTAB nMinSizeBothTabs = static_cast<SCTAB>(std::min(maTabs.size(), pSrcDoc->maTabs.size())); for (SCTAB i = nTab1; i <= nTab2 && i < nMinSizeBothTabs; i++) - if (maTabs[i] && pSrcDoc->maTabs[i]) - maTabs[i]->MixData( rRange.aStart.Col(), rRange.aStart.Row(), - rRange.aEnd.Col(), rRange.aEnd.Row(), - nFunction, bSkipEmpty, pSrcDoc->maTabs[i] ); + { + ScTable* pTab = FetchTable(i); + const ScTable* pSrcTab = pSrcDoc->FetchTable(i); + if (!pTab || !pSrcTab) + continue; + + pTab->MixData( + aCxt, rRange.aStart.Col(), rRange.aStart.Row(), rRange.aEnd.Col(), rRange.aEnd.Row(), + nFunction, bSkipEmpty, pSrcTab); + } } @@ -2882,6 +2906,9 @@ void ScDocument::FillTab( const ScRange& rSrcArea, const ScMarkData& rMark, sc::CopyToDocContext aCxt(*this); aCxt.setTabRange(rMark.GetFirstSelected(), rMark.GetLastSelected()); + sc::MixDocContext aMixDocCxt(*this); + aMixDocCxt.setTabRange(rMark.GetFirstSelected(), rMark.GetLastSelected()); + SCTAB nCount = static_cast<SCTAB>(maTabs.size()); ScMarkData::const_iterator itr = rMark.begin(), itrEnd = rMark.end(); for (; itr != itrEnd && *itr < nCount; ++itr) @@ -2897,6 +2924,8 @@ void ScDocument::FillTab( const ScRange& rSrcArea, const ScMarkData& rMark, } else pMixDoc->AddUndoTab( i, i ); + + // context used for copying content to the temporary mix document. sc::CopyToDocContext aMixCxt(*pMixDoc); aMixCxt.setTabRange(i, i); maTabs[i]->CopyToTable(aMixCxt, nStartCol,nStartRow, nEndCol,nEndRow, @@ -2907,7 +2936,7 @@ void ScDocument::FillTab( const ScRange& rSrcArea, const ScMarkData& rMark, nFlags, false, maTabs[i], NULL, bAsLink ); if (bDoMix) - maTabs[i]->MixData( nStartCol,nStartRow, nEndCol,nEndRow, + maTabs[i]->MixData(aMixDocCxt, nStartCol,nStartRow, nEndCol,nEndRow, nFunction, bSkipEmpty, pMixDoc->maTabs[i] ); } @@ -2945,6 +2974,8 @@ void ScDocument::FillTabMarked( SCTAB nSrcTab, const ScMarkData& rMark, sc::CopyToDocContext aCxt(*this); aCxt.setTabRange(rMark.GetFirstSelected(), rMark.GetLastSelected()); + sc::MixDocContext aMixDocCxt(*this); + aMixDocCxt.setTabRange(rMark.GetFirstSelected(), rMark.GetLastSelected()); SCTAB nCount = static_cast<SCTAB>(maTabs.size()); ScMarkData::const_iterator itr = rMark.begin(), itrEnd = rMark.end(); for (; itr != itrEnd && *itr < nCount; ++itr) @@ -2972,7 +3003,7 @@ void ScDocument::FillTabMarked( SCTAB nSrcTab, const ScMarkData& rMark, nFlags, true, maTabs[i], &rMark, bAsLink ); if (bDoMix) - maTabs[i]->MixMarked( rMark, nFunction, bSkipEmpty, pMixDoc->maTabs[i] ); + maTabs[i]->MixMarked(aMixDocCxt, rMark, nFunction, bSkipEmpty, pMixDoc->maTabs[i]); } SetAutoCalc( bOldAutoCalc ); diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx index 2eca7adc37e2..4af76be44514 100644 --- a/sc/source/core/data/table2.cxx +++ b/sc/source/core/data/table2.cxx @@ -831,20 +831,22 @@ void ScTable::CopyFromClip( } -void ScTable::MixData( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, - sal_uInt16 nFunction, bool bSkipEmpty, ScTable* pSrcTab ) +void ScTable::MixData( + sc::MixDocContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, + sal_uInt16 nFunction, bool bSkipEmpty, const ScTable* pSrcTab ) { for (SCCOL i=nCol1; i<=nCol2; i++) - aCol[i].MixData( nRow1, nRow2, nFunction, bSkipEmpty, pSrcTab->aCol[i] ); + aCol[i].MixData(rCxt, nRow1, nRow2, nFunction, bSkipEmpty, pSrcTab->aCol[i]); } // Markierung von diesem Dokument -void ScTable::MixMarked( const ScMarkData& rMark, sal_uInt16 nFunction, - bool bSkipEmpty, ScTable* pSrcTab ) +void ScTable::MixMarked( + sc::MixDocContext& rCxt, const ScMarkData& rMark, sal_uInt16 nFunction, + bool bSkipEmpty, const ScTable* pSrcTab ) { for (SCCOL i=0; i<=MAXCOL; i++) - aCol[i].MixMarked( rMark, nFunction, bSkipEmpty, pSrcTab->aCol[i] ); + aCol[i].MixMarked(rCxt, rMark, nFunction, bSkipEmpty, pSrcTab->aCol[i]); } |