summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2011-05-27 05:16:37 +0200
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2011-05-27 05:16:37 +0200
commitc70b1baac5b6b85048c894c206b8024e1eb537f3 (patch)
treeedc5885ba5721d386bfeff6ad317cb2fcaa7733c
parent2b8c2cfaba21f5ac70b6520f69ea146579e4093d (diff)
rework some other methods for performance improvements
inserting several sheets now happens at once and not for every sheet seperately, this accelerates inserting of sheets at all positions dramatically
-rw-r--r--sc/inc/cell.hxx2
-rw-r--r--sc/inc/column.hxx4
-rw-r--r--sc/inc/compiler.hxx2
-rw-r--r--sc/inc/rangenam.hxx4
-rw-r--r--sc/inc/table.hxx2
-rw-r--r--sc/source/core/data/cell2.cxx2
-rw-r--r--sc/source/core/data/column.cxx13
-rw-r--r--sc/source/core/data/table1.cxx5
-rw-r--r--sc/source/core/tool/compiler.cxx2
-rw-r--r--sc/source/core/tool/rangenam.cxx8
-rw-r--r--sc/source/ui/inc/undotab.hxx4
-rw-r--r--sc/source/ui/inc/viewfunc.hxx2
-rw-r--r--sc/source/ui/undo/undotab.cxx20
-rw-r--r--sc/source/ui/view/tabvwshf.cxx8
-rw-r--r--sc/source/ui/view/viewfun2.cxx53
15 files changed, 54 insertions, 77 deletions
diff --git a/sc/inc/cell.hxx b/sc/inc/cell.hxx
index ae5c3e7b880e..4d257e4d53f5 100644
--- a/sc/inc/cell.hxx
+++ b/sc/inc/cell.hxx
@@ -442,7 +442,7 @@ public:
void UpdateGrow( const ScRange& rArea, SCCOL nGrowX, SCROW nGrowY );
- void UpdateInsertTab(SCTAB nTable);
+ void UpdateInsertTab(SCTAB nTable, SCTAB nNewSheets = 1);
void UpdateInsertTabAbs(SCTAB nTable);
sal_Bool UpdateDeleteTab(SCTAB nTable, sal_Bool bIsMove = false);
void UpdateMoveTab(SCTAB nOldPos, SCTAB nNewPos, SCTAB nTabNo);
diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index c06d4786a286..b2c202a93031 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -290,8 +290,8 @@ public:
SCCOL nCol2, SCROW nRow2, SCTAB nTab2,
SCsCOL nDx, SCsROW nDy, SCsTAB nDz,
ScDocument* pUndoDoc = NULL );
- void UpdateInsertTab( SCTAB nTable);
- void UpdateInsertTabOnlyCells( SCTAB nTable);
+ void UpdateInsertTab( SCTAB nTable, SCTAB nNewSheets = 1);
+ void UpdateInsertTabOnlyCells( SCTAB nTable, SCTAB nNewSheets = 1);
void UpdateDeleteTab( SCTAB nTable, bool bIsMove, ScColumn* pRefUndo = NULL );
void UpdateMoveTab(SCTAB nOldPos, SCTAB nNewPos, SCTAB nTabNo);
void UpdateCompile( bool bForceIfNameInUse = false );
diff --git a/sc/inc/compiler.hxx b/sc/inc/compiler.hxx
index 81d6f7921c25..614051f9d5f7 100644
--- a/sc/inc/compiler.hxx
+++ b/sc/inc/compiler.hxx
@@ -444,7 +444,7 @@ public:
const ScAddress& rOldPos, const ScRange&,
SCsCOL nDx, SCsROW nDy, SCsTAB nDz );
- ScRangeData* UpdateInsertTab(SCTAB nTable, sal_Bool bIsName );
+ ScRangeData* UpdateInsertTab(SCTAB nTable, sal_Bool bIsName, SCTAB nNewSheets = 1 );
ScRangeData* UpdateDeleteTab(SCTAB nTable, sal_Bool bIsMove, sal_Bool bIsName, sal_Bool& bCompile);
ScRangeData* UpdateMoveTab(SCTAB nOldPos, SCTAB nNewPos, sal_Bool bIsName );
diff --git a/sc/inc/rangenam.hxx b/sc/inc/rangenam.hxx
index ebf2769e2baf..5d3ff4942e93 100644
--- a/sc/inc/rangenam.hxx
+++ b/sc/inc/rangenam.hxx
@@ -146,7 +146,7 @@ public:
SC_DLLPUBLIC sal_Bool IsValidReference( ScRange& rRef ) const;
sal_Bool IsRangeAtBlock( const ScRange& ) const;
- void UpdateTabRef(SCTAB nOldTable, sal_uInt16 nFlag, SCTAB nNewTable);
+ void UpdateTabRef(SCTAB nOldTable, sal_uInt16 nFlag, SCTAB nNewTable, SCTAB nNewSheets);
void TransferTabRef( SCTAB nOldTab, SCTAB nNewTab );
void ValidateTabRefs();
@@ -199,7 +199,7 @@ public:
SC_DLLPUBLIC ScRangeData* findByIndex(sal_uInt16 i);
void UpdateReference(UpdateRefMode eUpdateRefMode, const ScRange& rRange,
SCsCOL nDx, SCsROW nDy, SCsTAB nDz);
- void UpdateTabRef(SCTAB nTable, sal_uInt16 nFlag, SCTAB nNewTable = 0);
+ void UpdateTabRef(SCTAB nTable, sal_uInt16 nFlag, SCTAB nNewTable = 0, SCTAB nNewSheets = 1);
void UpdateTranspose(const ScRange& rSource, const ScAddress& rDest);
void UpdateGrow(const ScRange& rArea, SCCOL nGrowX, SCROW nGrowY);
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index ce94873da422..1ed9d4ccd206 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -476,7 +476,7 @@ public:
void UpdateGrow( const ScRange& rArea, SCCOL nGrowX, SCROW nGrowY );
- void UpdateInsertTab(SCTAB nTable);
+ void UpdateInsertTab(SCTAB nTable, SCTAB nNewSheets = 1);
void UpdateDeleteTab( SCTAB nTable, sal_Bool bIsMove, ScTable* pRefUndo = NULL );
void UpdateMoveTab(SCTAB nOldPos, SCTAB nNewPos, SCTAB nTabNo, ScProgress& );
void UpdateCompile( sal_Bool bForceIfNameInUse = false );
diff --git a/sc/source/core/data/cell2.cxx b/sc/source/core/data/cell2.cxx
index af99ddf3cf9f..dad359414b10 100644
--- a/sc/source/core/data/cell2.cxx
+++ b/sc/source/core/data/cell2.cxx
@@ -1129,7 +1129,7 @@ bool ScFormulaCell::UpdateReference(UpdateRefMode eUpdateRefMode,
return bCellStateChanged;
}
-void ScFormulaCell::UpdateInsertTab(SCTAB nTable)
+void ScFormulaCell::UpdateInsertTab(SCTAB nTable, SCTAB nNewSheets)
{
sal_Bool bPosChanged = ( aPos.Tab() >= nTable ? sal_True : false );
pCode->Reset();
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index 6aa581f6b2a7..174a858fbe34 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -1723,16 +1723,19 @@ void ScColumn::UpdateGrow( const ScRange& rArea, SCCOL nGrowX, SCROW nGrowY )
}
-void ScColumn::UpdateInsertTab( SCTAB nTable)
+void ScColumn::UpdateInsertTab( SCTAB nTable, SCTAB nNewSheets )
{
if (nTab >= nTable)
- pAttrArray->SetTab(++nTab);
+ {
+ nTab += nNewSheets;
+ pAttrArray->SetTab(nTab);
+ }
if( pItems )
- UpdateInsertTabOnlyCells( nTable );
+ UpdateInsertTabOnlyCells( nTable, nNewSheets );
}
-void ScColumn::UpdateInsertTabOnlyCells( SCTAB nTable)
+void ScColumn::UpdateInsertTabOnlyCells( SCTAB nTable, SCTAB nNewSheets )
{
if (pItems)
for (SCSIZE i = 0; i < nCount; i++)
@@ -1741,7 +1744,7 @@ void ScColumn::UpdateInsertTabOnlyCells( SCTAB nTable)
if( pCell->GetCellType() == CELLTYPE_FORMULA)
{
SCROW nRow = pItems[i].nRow;
- pCell->UpdateInsertTab(nTable);
+ pCell->UpdateInsertTab(nTable, nNewSheets);
if ( nRow != pItems[i].nRow )
Search( nRow, i ); // Listener geloescht/eingefuegt?
}
diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
index 379bd82613d5..87b1cdb15827 100644
--- a/sc/source/core/data/table1.cxx
+++ b/sc/source/core/data/table1.cxx
@@ -1398,9 +1398,10 @@ void ScTable::UpdateGrow( const ScRange& rArea, SCCOL nGrowX, SCROW nGrowY )
aCol[i].UpdateGrow( rArea, nGrowX, nGrowY );
}
-void ScTable::UpdateInsertTab(SCTAB nTable)
+void ScTable::UpdateInsertTab(SCTAB nTable, SCTAB nNewSheets)
{
- if (nTab >= nTable) nTab++;
+ if (nTab >= nTable)
+ nTab += nNewSheets;
for (SCCOL i=0; i <= MAXCOL; i++) aCol[i].UpdateInsertTab(nTable);
if (IsStreamValid())
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index c90ef51762b8..95e9bd2f5f9f 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -4480,7 +4480,7 @@ void ScCompiler::UpdateSharedFormulaReference( UpdateRefMode eUpdateRefMode,
}
-ScRangeData* ScCompiler::UpdateInsertTab( SCTAB nTable, sal_Bool bIsName )
+ScRangeData* ScCompiler::UpdateInsertTab( SCTAB nTable, sal_Bool bIsName , SCTAB nNewSheets)
{
ScRangeData* pRangeData = NULL;
SCTAB nPosTab = aPos.Tab(); // _after_ incremented!
diff --git a/sc/source/core/tool/rangenam.cxx b/sc/source/core/tool/rangenam.cxx
index df5f43617ae1..30cf3dd2c327 100644
--- a/sc/source/core/tool/rangenam.cxx
+++ b/sc/source/core/tool/rangenam.cxx
@@ -391,7 +391,7 @@ sal_Bool ScRangeData::IsValidReference( ScRange& rRange ) const
return false;
}
-void ScRangeData::UpdateTabRef(SCTAB nOldTable, sal_uInt16 nFlag, SCTAB nNewTable)
+void ScRangeData::UpdateTabRef(SCTAB nOldTable, sal_uInt16 nFlag, SCTAB nNewTable, SCTAB nNewSheets)
{
pCode->Reset();
if( pCode->GetNextReference() )
@@ -403,7 +403,7 @@ void ScRangeData::UpdateTabRef(SCTAB nOldTable, sal_uInt16 nFlag, SCTAB nNewTabl
switch (nFlag)
{
case 1: // einfache InsertTab (doc.cxx)
- pRangeData = aComp.UpdateInsertTab(nOldTable, sal_True ); // und CopyTab (doc2.cxx)
+ pRangeData = aComp.UpdateInsertTab(nOldTable, sal_True, nNewSheets ); // und CopyTab (doc2.cxx)
break;
case 2: // einfaches delete (doc.cxx)
pRangeData = aComp.UpdateDeleteTab(nOldTable, false, sal_True, bChanged);
@@ -784,11 +784,11 @@ void ScRangeName::UpdateReference(
itr->UpdateReference(eUpdateRefMode, rRange, nDx, nDy, nDz);
}
-void ScRangeName::UpdateTabRef(SCTAB nTable, sal_uInt16 nFlag, SCTAB nNewTable)
+void ScRangeName::UpdateTabRef(SCTAB nTable, sal_uInt16 nFlag, SCTAB nNewTable, SCTAB nNewSheets)
{
DataType::iterator itr = maData.begin(), itrEnd = maData.end();
for (; itr != itrEnd; ++itr)
- itr->UpdateTabRef(nTable, nFlag, nNewTable);
+ itr->UpdateTabRef(nTable, nFlag, nNewTable, nNewSheets);
}
void ScRangeName::UpdateTranspose(const ScRange& rSource, const ScAddress& rDest)
diff --git a/sc/source/ui/inc/undotab.hxx b/sc/source/ui/inc/undotab.hxx
index 0c6bec3782af..0d26ac84f9f9 100644
--- a/sc/source/ui/inc/undotab.hxx
+++ b/sc/source/ui/inc/undotab.hxx
@@ -94,7 +94,7 @@ public:
ScDocShell* pNewDocShell,
SCTAB nTabNum,
sal_Bool bApp,
- SvStrings *pNewNameList);
+ std::vector<rtl::OUString>& newNameList);
virtual ~ScUndoInsertTables();
virtual void Undo();
@@ -107,7 +107,7 @@ public:
private:
SdrUndoAction* pDrawUndo;
- SvStrings* pNameList;
+ std::vector<rtl::OUString> aNameList;
sal_uLong nStartChangeAction;
sal_uLong nEndChangeAction;
SCTAB nTab;
diff --git a/sc/source/ui/inc/viewfunc.hxx b/sc/source/ui/inc/viewfunc.hxx
index 785b730d6945..a0914aa49899 100644
--- a/sc/source/ui/inc/viewfunc.hxx
+++ b/sc/source/ui/inc/viewfunc.hxx
@@ -260,7 +260,7 @@ public:
void TabOp( const ScTabOpParam& rParam, sal_Bool bRecord = sal_True );
sal_Bool InsertTable( const String& rName, SCTAB nTabNr, sal_Bool bRecord = sal_True );
- sal_Bool InsertTables(SvStrings *pNames, SCTAB nTab, SCTAB nCount, sal_Bool bRecord = sal_True);
+ sal_Bool InsertTables(std::vector<rtl::OUString>& aNames, SCTAB nTab, SCTAB nCount, sal_Bool bRecord = sal_True);
sal_Bool AppendTable( const String& rName, sal_Bool bRecord = sal_True );
diff --git a/sc/source/ui/undo/undotab.cxx b/sc/source/ui/undo/undotab.cxx
index 97f2549711e1..a6b5b4645040 100644
--- a/sc/source/ui/undo/undotab.cxx
+++ b/sc/source/ui/undo/undotab.cxx
@@ -193,13 +193,13 @@ sal_Bool ScUndoInsertTab::CanRepeat(SfxRepeatTarget& rTarget) const
ScUndoInsertTables::ScUndoInsertTables( ScDocShell* pNewDocShell,
SCTAB nTabNum,
- sal_Bool bApp,SvStrings *pNewNameList) :
+ sal_Bool bApp,std::vector<rtl::OUString>& newNameList) :
ScSimpleUndo( pNewDocShell ),
pDrawUndo( NULL ),
+ aNameList( newNameList ),
nTab( nTabNum ),
bAppend( bApp )
{
- pNameList = pNewNameList;
pDrawUndo = GetSdrUndoAction( pDocShell->GetDocument() );
SetChangeTrack();
@@ -208,16 +208,6 @@ ScUndoInsertTables::ScUndoInsertTables( ScDocShell* pNewDocShell,
ScUndoInsertTables::~ScUndoInsertTables()
{
String *pStr=NULL;
- if(pNameList!=NULL)
- {
- for(int i=0;i<pNameList->Count();i++)
- {
- pStr=pNameList->GetObject(sal::static_int_cast<sal_uInt16>(i));
- delete pStr;
- }
- pNameList->Remove(0,pNameList->Count());
- delete pNameList;
- }
DeleteSdrUndoAction( pDrawUndo );
}
@@ -234,7 +224,7 @@ void ScUndoInsertTables::SetChangeTrack()
nStartChangeAction = pChangeTrack->GetActionMax() + 1;
nEndChangeAction = 0;
ScRange aRange( 0, 0, nTab, MAXCOL, MAXROW, nTab );
- for( int i = 0; i < pNameList->Count(); i++ )
+ for( int i = 0; i < aNameList.size(); i++ )
{
aRange.aStart.SetTab( sal::static_int_cast<SCTAB>( nTab + i ) );
aRange.aEnd.SetTab( sal::static_int_cast<SCTAB>( nTab + i ) );
@@ -255,7 +245,7 @@ void ScUndoInsertTables::Undo()
bDrawIsInUndo = sal_True;
vector<SCTAB> TheTabs;
- for(int i=0; i<pNameList->Count(); ++i)
+ for(int i=0; i< aNameList.size(); ++i)
{
TheTabs.push_back(nTab+i);
}
@@ -284,7 +274,7 @@ void ScUndoInsertTables::Redo()
pDocShell->SetInUndo( sal_True ); //! BeginRedo
bDrawIsInUndo = sal_True;
pViewShell->SetTabNo(nTab);
- pViewShell->InsertTables( pNameList, nTab, static_cast<SCTAB>(pNameList->Count()),false );
+ pViewShell->InsertTables( aNameList, nTab, static_cast<SCTAB>(aNameList.size()),false );
bDrawIsInUndo = false;
pDocShell->SetInUndo( false ); //! EndRedo
diff --git a/sc/source/ui/view/tabvwshf.cxx b/sc/source/ui/view/tabvwshf.cxx
index e9553352ebdd..1f44d3147900 100644
--- a/sc/source/ui/view/tabvwshf.cxx
+++ b/sc/source/ui/view/tabvwshf.cxx
@@ -300,7 +300,10 @@ void ScTabViewShell::ExecuteTable( SfxRequest& rReq )
InsertTable( *pDlg->GetFirstTable(), nTabNr );
}
else
- InsertTables( NULL, nTabNr,nCount );
+ {
+ std::vector<rtl::OUString> aNames(0);
+ InsertTables( aNames, nTabNr,nCount );
+ }
}
else
{
@@ -336,7 +339,8 @@ void ScTabViewShell::ExecuteTable( SfxRequest& rReq )
}
else
{
- InsertTables( NULL, nTabAfter,nCount);
+ std::vector<rtl::OUString> aNames(0);
+ InsertTables( aNames, nTabAfter,nCount);
}
}
}
diff --git a/sc/source/ui/view/viewfun2.cxx b/sc/source/ui/view/viewfun2.cxx
index 17bf069f274d..c803177f340f 100644
--- a/sc/source/ui/view/viewfun2.cxx
+++ b/sc/source/ui/view/viewfun2.cxx
@@ -1989,70 +1989,49 @@ sal_Bool ScViewFunc::InsertTable( const String& rName, SCTAB nTab, sal_Bool bRec
//----------------------------------------------------------------------------
// Insert tables
-sal_Bool ScViewFunc::InsertTables(SvStrings *pNames, SCTAB nTab,
+sal_Bool ScViewFunc::InsertTables(std::vector<rtl::OUString>& aNames, SCTAB nTab,
SCTAB nCount, sal_Bool bRecord )
{
- ScDocShell* pDocSh = GetViewData()->GetDocShell();
- ScDocument* pDoc = pDocSh->GetDocument();
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ ScDocument* pDoc = pDocSh->GetDocument();
if (bRecord && !pDoc->IsUndoEnabled())
bRecord = false;
- SvStrings *pNameList= NULL;
-
WaitObject aWait( GetFrameWin() );
if (bRecord)
{
- pNameList= new SvStrings;
- pDoc->BeginDrawUndo(); // InsertTab creates a SdrUndoNewPage
+ pDoc->BeginDrawUndo(); // InsertTab creates a SdrUndoNewPage
}
- sal_Bool bFlag=false;
-
- String aValTabName;
- String *pStr;
+ bool bFlag=false;
- for(SCTAB i=0;i<nCount;i++)
+ if(aNames.empty())
{
- if(pNames!=NULL)
- {
- pStr=pNames->GetObject(static_cast<sal_uInt16>(i));
- }
- else
- {
- aValTabName.Erase();
- pDoc->CreateValidTabName( aValTabName);
- pStr=&aValTabName;
- }
-
- if(pDoc->InsertTab( nTab+i,*pStr))
+ pDoc->CreateValidTabNames(aNames, nCount);
+ }
+ if (pDoc->InsertTabs(nTab, aNames, false))
+ {
+ for (SCTAB i=0;i<nCount; i++)
{
- bFlag=sal_True;
pDocSh->Broadcast( ScTablesHint( SC_TAB_INSERTED, nTab+i ) );
}
- else
- {
- break;
- }
-
- if(pNameList!=NULL)
- pNameList->Insert(new String(*pStr),pNameList->Count());
-
+ bFlag = true;
}
if (bFlag)
{
if (bRecord)
pDocSh->GetUndoManager()->AddUndoAction(
- new ScUndoInsertTables( pDocSh, nTab, false, pNameList));
+ new ScUndoInsertTables( pDocSh, nTab, false, aNames));
- // Update views
+ // Update views
- SetTabNo( nTab, sal_True );
+ SetTabNo( nTab, true );
pDocSh->PostPaintExtras();
pDocSh->SetDocumentModified();
SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) );
- return sal_True;
+ return true;
}
else
{