diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2011-05-27 05:16:37 +0200 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2011-05-27 05:16:37 +0200 |
commit | c70b1baac5b6b85048c894c206b8024e1eb537f3 (patch) | |
tree | edc5885ba5721d386bfeff6ad317cb2fcaa7733c /sc/source/ui/view | |
parent | 2b8c2cfaba21f5ac70b6520f69ea146579e4093d (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
Diffstat (limited to 'sc/source/ui/view')
-rw-r--r-- | sc/source/ui/view/tabvwshf.cxx | 8 | ||||
-rw-r--r-- | sc/source/ui/view/viewfun2.cxx | 53 |
2 files changed, 22 insertions, 39 deletions
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 { |