summaryrefslogtreecommitdiff
path: root/sc/source/ui/undo/undotab.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'sc/source/ui/undo/undotab.cxx')
-rw-r--r--sc/source/ui/undo/undotab.cxx44
1 files changed, 18 insertions, 26 deletions
diff --git a/sc/source/ui/undo/undotab.cxx b/sc/source/ui/undo/undotab.cxx
index d5264317c86d..96f8d46ea4bb 100644
--- a/sc/source/ui/undo/undotab.cxx
+++ b/sc/source/ui/undo/undotab.cxx
@@ -49,6 +49,7 @@
#include "chgtrack.hxx"
#include "tabprotection.hxx"
#include "viewdata.hxx"
+#include "progress.hxx"
// for ScUndoRenameObject - might me moved to another file later
#include <svx/svditer.hxx>
@@ -193,13 +194,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();
@@ -207,17 +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( size_t 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 ) );
@@ -254,13 +244,7 @@ void ScUndoInsertTables::Undo()
pDocShell->SetInUndo( sal_True ); //! BeginUndo
bDrawIsInUndo = sal_True;
- vector<SCTAB> TheTabs;
- for(int i=0; i<pNameList->Count(); ++i)
- {
- TheTabs.push_back(nTab+i);
- }
- pViewShell->DeleteTables( TheTabs, false );
- TheTabs.clear();
+ pViewShell->DeleteTables( nTab, static_cast<SCTAB>(aNameList.size()) );
bDrawIsInUndo = false;
pDocShell->SetInUndo( false ); //! EndUndo
@@ -284,7 +268,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
@@ -570,14 +554,17 @@ void ScUndoMoveTab::DoChange( sal_Bool bUndo ) const
if (bUndo) // UnDo
{
- for (size_t i = mpNewTabs->size(); i > 0; --i)
+ size_t i = mpNewTabs->size();
+ ScProgress* pProgress = new ScProgress(pDocShell , ScGlobal::GetRscString(STR_UNDO_MOVE_TAB),
+ i * pDoc->GetCodeCount());
+ for (; i > 0; --i)
{
SCTAB nDestTab = (*mpNewTabs)[i-1];
SCTAB nOldTab = (*mpOldTabs)[i-1];
if (nDestTab > MAXTAB) // angehaengt ?
nDestTab = pDoc->GetTableCount() - 1;
- pDoc->MoveTab( nDestTab, nOldTab );
+ pDoc->MoveTab( nDestTab, nOldTab, pProgress );
pViewShell->GetViewData()->MoveTab( nDestTab, nOldTab );
pViewShell->SetTabNo( nOldTab, true );
if (mpOldNames)
@@ -586,10 +573,14 @@ void ScUndoMoveTab::DoChange( sal_Bool bUndo ) const
pDoc->RenameTab(nOldTab, rOldName);
}
}
+ delete pProgress;
}
else
{
- for (size_t i = 0, n = mpNewTabs->size(); i < n; ++i)
+ size_t n = mpNewTabs->size();
+ ScProgress* pProgress = new ScProgress(pDocShell , ScGlobal::GetRscString(STR_UNDO_MOVE_TAB),
+ n * pDoc->GetCodeCount());
+ for (size_t i = 0; i < n; ++i)
{
SCTAB nDestTab = (*mpNewTabs)[i];
SCTAB nNewTab = nDestTab;
@@ -597,7 +588,7 @@ void ScUndoMoveTab::DoChange( sal_Bool bUndo ) const
if (nDestTab > MAXTAB) // angehaengt ?
nDestTab = pDoc->GetTableCount() - 1;
- pDoc->MoveTab( nOldTab, nNewTab );
+ pDoc->MoveTab( nOldTab, nNewTab, pProgress );
pViewShell->GetViewData()->MoveTab( nOldTab, nNewTab );
pViewShell->SetTabNo( nDestTab, true );
if (mpNewNames)
@@ -606,6 +597,7 @@ void ScUndoMoveTab::DoChange( sal_Bool bUndo ) const
pDoc->RenameTab(nNewTab, rNewName);
}
}
+ delete pProgress;
}
SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) ); // Navigator