[Libreoffice-commits] .: Branch 'feature/unlimited-number-of-sheets' - sc/source
Markus Mohrhard
mmohrhard at kemper.freedesktop.org
Thu May 26 22:05:37 PDT 2011
sc/source/ui/inc/uiitems.hxx | 1 +
sc/source/ui/inc/viewdata.hxx | 1 +
sc/source/ui/undo/undotab.cxx | 5 ++---
sc/source/ui/view/tabvwsh5.cxx | 6 ++++++
sc/source/ui/view/viewdata.cxx | 23 ++++++++++++++++++++---
sc/source/ui/view/viewfun2.cxx | 5 +----
6 files changed, 31 insertions(+), 10 deletions(-)
New commits:
commit 10d8872ce3a9f20a4d05a77266df4a19a11490dc
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Fri May 27 07:01:52 2011 +0200
some performance improvements for inserting sheets
only update the viewshell once instead of every time, this allows the creation of a large amount of sheets nearly immediately
diff --git a/sc/source/ui/inc/uiitems.hxx b/sc/source/ui/inc/uiitems.hxx
index 3e64b48..aaa8903 100644
--- a/sc/source/ui/inc/uiitems.hxx
+++ b/sc/source/ui/inc/uiitems.hxx
@@ -92,6 +92,7 @@ public:
#define SC_TAB_MOVED 3
#define SC_TAB_COPIED 4
#define SC_TAB_HIDDEN 5
+#define SC_TABS_INSERTED 6
class ScTablesHint : public SfxHint
{
diff --git a/sc/source/ui/inc/viewdata.hxx b/sc/source/ui/inc/viewdata.hxx
index c1a5448..303ca6e 100644
--- a/sc/source/ui/inc/viewdata.hxx
+++ b/sc/source/ui/inc/viewdata.hxx
@@ -277,6 +277,7 @@ public:
void UpdateThis();
void InsertTab( SCTAB nTab );
+ void InsertTabs( SCTAB nTab, SCTAB nNewSheets );
void DeleteTab( SCTAB nTab );
void CopyTab( SCTAB nSrcTab, SCTAB nDestTab );
void MoveTab( SCTAB nSrcTab, SCTAB nDestTab );
diff --git a/sc/source/ui/undo/undotab.cxx b/sc/source/ui/undo/undotab.cxx
index 0ba6e9b..0842c93 100644
--- a/sc/source/ui/undo/undotab.cxx
+++ b/sc/source/ui/undo/undotab.cxx
@@ -207,7 +207,6 @@ ScUndoInsertTables::ScUndoInsertTables( ScDocShell* pNewDocShell,
ScUndoInsertTables::~ScUndoInsertTables()
{
- String *pStr=NULL;
DeleteSdrUndoAction( pDrawUndo );
}
@@ -224,7 +223,7 @@ void ScUndoInsertTables::SetChangeTrack()
nStartChangeAction = pChangeTrack->GetActionMax() + 1;
nEndChangeAction = 0;
ScRange aRange( 0, 0, nTab, MAXCOL, MAXROW, nTab );
- for( int i = 0; i < aNameList.size(); 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 ) );
@@ -245,7 +244,7 @@ void ScUndoInsertTables::Undo()
bDrawIsInUndo = sal_True;
vector<SCTAB> TheTabs;
- for(int i=0; i< aNameList.size(); ++i)
+ for(SCTAB i=0; i< static_cast<SCTAB>(aNameList.size()); ++i)
{
TheTabs.push_back(nTab+i);
}
diff --git a/sc/source/ui/view/tabvwsh5.cxx b/sc/source/ui/view/tabvwsh5.cxx
index e6d849e..fffc035 100644
--- a/sc/source/ui/view/tabvwsh5.cxx
+++ b/sc/source/ui/view/tabvwsh5.cxx
@@ -239,6 +239,8 @@ void ScTabViewShell::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
break;
case SC_TAB_HIDDEN:
break;
+ case SC_TABS_INSERTED:
+ GetViewData()->InsertTabs( nTab1, nTab2 );
default:
OSL_FAIL("unbekannter ScTablesHint");
}
@@ -282,6 +284,10 @@ void ScTabViewShell::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
if ( nTab1 == nNewTab ) // aktuelle ausgeblendet
bStayOnActiveTab = false;
break;
+ case SC_TABS_INSERTED:
+ if ( nTab1 <= nNewTab )
+ nNewTab += nTab2;
+ break;
}
ScDocument* pDoc = GetViewData()->GetDocument();
diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx
index 575eb3c..88ddd7c 100644
--- a/sc/source/ui/view/viewdata.cxx
+++ b/sc/source/ui/view/viewdata.cxx
@@ -460,15 +460,32 @@ void ScViewData::UpdateThis()
void ScViewData::InsertTab( SCTAB nTab )
{
- while( nTab >= static_cast<SCTAB>(pTabData.size()))
- pTabData.push_back(NULL);
- pTabData.insert( pTabData.begin() + nTab, NULL );
+ if( nTab >= static_cast<SCTAB>(pTabData.size()))
+ pTabData.resize(nTab+1, NULL);
+ else
+ pTabData.insert( pTabData.begin() + nTab, NULL );
CreateTabData( nTab );
UpdateThis();
aMarkData.InsertTab( nTab );
}
+void ScViewData::InsertTabs( SCTAB nTab, SCTAB nNewSheets )
+{
+ if( nTab+nNewSheets >= static_cast<SCTAB>(pTabData.size()))
+ pTabData.resize(nTab+nNewSheets, NULL);
+ else
+ {
+ pTabData.insert( pTabData.begin() + nTab, nNewSheets, NULL );
+ }
+ for (SCTAB aTab = nTab; aTab < nTab + nNewSheets; ++aTab)
+ {
+ CreateTabData( aTab );
+ aMarkData.InsertTab( aTab );
+ }
+ UpdateThis();
+}
+
void ScViewData::DeleteTab( SCTAB nTab )
{
delete pTabData[nTab];
diff --git a/sc/source/ui/view/viewfun2.cxx b/sc/source/ui/view/viewfun2.cxx
index 53d4796..7b53ffc 100644
--- a/sc/source/ui/view/viewfun2.cxx
+++ b/sc/source/ui/view/viewfun2.cxx
@@ -2012,10 +2012,7 @@ sal_Bool ScViewFunc::InsertTables(std::vector<rtl::OUString>& aNames, SCTAB nTab
}
if (pDoc->InsertTabs(nTab, aNames, false))
{
- for (SCTAB i=0;i<nCount; i++)
- {
- pDocSh->Broadcast( ScTablesHint( SC_TAB_INSERTED, nTab+i ) );
- }
+ pDocSh->Broadcast( ScTablesHint( SC_TABS_INSERTED, nTab, nCount ) );
bFlag = true;
}
More information about the Libreoffice-commits
mailing list