summaryrefslogtreecommitdiff
path: root/sc/source/ui/view
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2011-06-07 05:04:57 +0200
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2011-06-07 05:04:57 +0200
commit4c5e30555d20f17614f31c34a0b06fbca5f3fb02 (patch)
treef8b529e975eb61531468c63044ab932f2350789f /sc/source/ui/view
parentb2570e4a1cfbb71655b22596bb39861dfaa9ef33 (diff)
parentdb7fa1355626cef14de707a8cb415c05ab16b00c (diff)
Merge branch 'feature/unlimited-number-of-sheets'
Conflicts: sc/source/core/data/dociter.cxx sc/source/core/data/table1.cxx sc/source/ui/view/preview.cxx
Diffstat (limited to 'sc/source/ui/view')
-rw-r--r--sc/source/ui/view/cellsh3.cxx2
-rw-r--r--sc/source/ui/view/gridwin.cxx9
-rw-r--r--sc/source/ui/view/pfuncache.cxx17
-rw-r--r--sc/source/ui/view/preview.cxx22
-rw-r--r--sc/source/ui/view/tabvwsh5.cxx14
-rw-r--r--sc/source/ui/view/tabvwshf.cxx29
-rw-r--r--sc/source/ui/view/viewdata.cxx139
-rw-r--r--sc/source/ui/view/viewfun2.cxx101
-rw-r--r--sc/source/ui/view/viewfun3.cxx4
9 files changed, 204 insertions, 133 deletions
diff --git a/sc/source/ui/view/cellsh3.cxx b/sc/source/ui/view/cellsh3.cxx
index 862e8b7a9430..72cf8c94908f 100644
--- a/sc/source/ui/view/cellsh3.cxx
+++ b/sc/source/ui/view/cellsh3.cxx
@@ -460,7 +460,7 @@ void ScCellShell::Execute( SfxRequest& rReq )
bValid = !pDoc->GetTable( aName, nDummy );
++i;
}
- while ( !bValid && i <= 2*MAXTAB );
+ while ( !bValid && i <= MAXTAB + 2 );
if ( pReqArgs != NULL )
{
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index 9fd6585ded83..34dd1fb5a288 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -3952,22 +3952,21 @@ sal_Int8 ScGridWindow::DropTransferObj( ScTransferObj* pTransObj, SCCOL nDestPos
{
ScDocShell* pSrcShell = pTransObj->GetSourceDocShell();
- SCTAB nTabs[MAXTABCOUNT];
+ std::vector<SCTAB> nTabs;
ScMarkData aMark = pTransObj->GetSourceMarkData();
SCTAB nTabCount = pSourceDoc->GetTableCount();
- SCTAB nTabSelCount = 0;
for(SCTAB i=0; i<nTabCount; i++)
{
if(aMark.GetTableSelect(i))
{
- nTabs[nTabSelCount++]=i;
+ nTabs.push_back(i);
for(SCTAB j=i+1;j<nTabCount;j++)
{
if((!pSourceDoc->IsVisible(j))&&(pSourceDoc->IsScenario(j)))
{
- nTabs[nTabSelCount++]=j;
+ nTabs.push_back( j );
i=j;
}
else break;
@@ -3975,7 +3974,7 @@ sal_Int8 ScGridWindow::DropTransferObj( ScTransferObj* pTransObj, SCCOL nDestPos
}
}
- pView->ImportTables( pSrcShell,nTabSelCount, nTabs, bIsLink, nThisTab );
+ pView->ImportTables( pSrcShell,static_cast<SCTAB>(nTabs.size()), &nTabs[0], bIsLink, nThisTab );
bDone = sal_True;
}
}
diff --git a/sc/source/ui/view/pfuncache.cxx b/sc/source/ui/view/pfuncache.cxx
index 9359c5425cf9..25c90813136a 100644
--- a/sc/source/ui/view/pfuncache.cxx
+++ b/sc/source/ui/view/pfuncache.cxx
@@ -48,6 +48,8 @@ ScPrintFuncCache::ScPrintFuncCache( ScDocShell* pD, const ScMarkData& rMark,
aSelection( rStatus ),
pDocSh( pD ),
nTotalPages( 0 ),
+ nPages(),
+ nFirstAttr(),
bLocInitialized( false )
{
// page count uses the stored cell widths for the printer anyway,
@@ -77,12 +79,12 @@ ScPrintFuncCache::ScPrintFuncCache( ScDocShell* pD, const ScMarkData& rMark,
ScPrintFunc aFunc( pDocSh, pPrinter, nTab, nAttrPage, 0, pSelRange, &aSelection.GetOptions() );
nThisTab = aFunc.GetTotalPages();
- nFirstAttr[nTab] = aFunc.GetFirstPageNo(); // from page style or previous sheet
+ nFirstAttr.push_back( aFunc.GetFirstPageNo() ); // from page style or previous sheet
}
else
- nFirstAttr[nTab] = nAttrPage;
+ nFirstAttr.push_back( nAttrPage );
- nPages[nTab] = nThisTab;
+ nPages.push_back( nThisTab );
nTotalPages += nThisTab;
}
}
@@ -175,7 +177,7 @@ SCTAB ScPrintFuncCache::GetTabForPage( long nPage ) const
long ScPrintFuncCache::GetTabStart( SCTAB nTab ) const
{
long nRet = 0;
- for ( SCTAB i=0; i<nTab; i++ )
+ for ( SCTAB i=0; i<nTab&& i < static_cast<SCTAB>(nPages.size()); i++ )
nRet += nPages[i];
return nRet;
}
@@ -191,7 +193,12 @@ long ScPrintFuncCache::GetDisplayStart( SCTAB nTab ) const
if ( pDoc->NeedPageResetAfterTab(i) )
nDisplayStart = 0;
else
- nDisplayStart += nPages[i];
+ {
+ if ( i < static_cast<SCTAB>(nPages.size()) )
+ nDisplayStart += nPages[i];
+ else
+ OSL_FAIL("nPages out of bounds, FIX IT!");
+ }
}
return nDisplayStart;
}
diff --git a/sc/source/ui/view/preview.cxx b/sc/source/ui/view/preview.cxx
index 35e03864c582..1e39c3b5a8c9 100644
--- a/sc/source/ui/view/preview.cxx
+++ b/sc/source/ui/view/preview.cxx
@@ -81,7 +81,7 @@
#define SC_PREVIEW_SHADOWSIZE 2
-long lcl_GetDisplayStart( SCTAB nTab, ScDocument* pDoc, long* pPages )
+long lcl_GetDisplayStart( SCTAB nTab, ScDocument* pDoc, std::vector<long>& nPages )
{
long nDisplayStart = 0;
for (SCTAB i=0; i<nTab; i++)
@@ -89,7 +89,7 @@ long lcl_GetDisplayStart( SCTAB nTab, ScDocument* pDoc, long* pPages )
if ( pDoc->NeedPageResetAfterTab(i) )
nDisplayStart = 0;
else
- nDisplayStart += pPages[i];
+ nDisplayStart += nPages[i];
}
return nDisplayStart;
}
@@ -101,6 +101,8 @@ ScPreview::ScPreview( Window* pParent, ScDocShell* pDocSh, ScPreviewShell* pView
nZoom( 100 ),
bValid( false ),
nTabsTested( 0 ),
+ nPages(),
+ nFirstAttr(),
nTab( 0 ),
nTabStart( 0 ),
nDisplayStart( 0 ),
@@ -190,10 +192,10 @@ void ScPreview::TestLastPage()
if (nTotalPages)
{
nPageNo = nTotalPages - 1;
- nTab = nTabCount - 1;
+ nTab = static_cast<SCTAB>(nPages.size()) -1;
while (nTab > 0 && !nPages[nTab]) // letzte nicht leere Tabelle
--nTab;
- OSL_ENSURE(nPages[nTab],"alle Tabellen leer?");
+ OSL_ENSURE(0 < static_cast<SCTAB>(nPages.size()),"alle Tabellen leer?");
nTabPage = nPages[nTab] - 1;
nTabStart = 0;
for (sal_uInt16 i=0; i<nTab; i++)
@@ -245,8 +247,16 @@ void ScPreview::CalcPages( SCTAB /*nToWhichTab*/ )
ScMarkData aMarkData;
aMarkData.SelectTable( nCurTab, true );
+ while (nStart > static_cast<SCTAB>(nPages.size()))
+ nPages.push_back(0);
+ while (nStart > static_cast<SCTAB>(nFirstAttr.size()))
+ nFirstAttr.push_back(0);
for (SCTAB i=nStart; i<nAnz; i++)
{
+ if ( i == static_cast<SCTAB>(nPages.size()))
+ nPages.push_back(0);
+ if ( i == static_cast<SCTAB>(nFirstAttr.size()))
+ nFirstAttr.push_back(0);
if (!aOptions.GetAllSheets() && !aMarkData.GetTableSelect( i )) {
nPages[i] = 0;
nFirstAttr[i] = 0;
@@ -308,7 +318,7 @@ void ScPreview::RecalcPages() // nur nPageNo geaendert
if (!bDone)
{
long nPartPages = 0;
- for (SCTAB i=0; i<nTabsTested; i++)
+ for (SCTAB i=0; i<nTabsTested && nTab < static_cast<SCTAB>(nPages.size()); i++)
{
long nThisStart = nPartPages;
nPartPages += nPages[i];
@@ -806,6 +816,8 @@ void ScPreview::SetPageNo( long nPage )
long ScPreview::GetFirstPage(SCTAB nTabP)
{
+ if (nTabP >= static_cast<SCTAB>(nPages.size()) )
+ OSL_FAIL("nPages out ouf bounds, FIX IT");
SCTAB nDocTabCount = pDocShell->GetDocument()->GetTableCount();
if (nTabP >= nDocTabCount)
nTabP = nDocTabCount-1;
diff --git a/sc/source/ui/view/tabvwsh5.cxx b/sc/source/ui/view/tabvwsh5.cxx
index 030c26f3ef71..1bc112d13e78 100644
--- a/sc/source/ui/view/tabvwsh5.cxx
+++ b/sc/source/ui/view/tabvwsh5.cxx
@@ -239,6 +239,12 @@ void ScTabViewShell::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
break;
case SC_TAB_HIDDEN:
break;
+ case SC_TABS_INSERTED:
+ GetViewData()->InsertTabs( nTab1, nTab2 );
+ break;
+ case SC_TABS_DELETED:
+ GetViewData()->DeleteTabs( nTab1, nTab2 );
+ break;
default:
OSL_FAIL("unbekannter ScTablesHint");
}
@@ -282,6 +288,14 @@ 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;
+ case SC_TABS_DELETED:
+ if ( nTab1 < nNewTab )
+ nNewTab -= nTab2;
+ break;
}
ScDocument* pDoc = GetViewData()->GetDocument();
diff --git a/sc/source/ui/view/tabvwshf.cxx b/sc/source/ui/view/tabvwshf.cxx
index 8f57091af5db..c6266ef308cf 100644
--- a/sc/source/ui/view/tabvwshf.cxx
+++ b/sc/source/ui/view/tabvwshf.cxx
@@ -252,21 +252,20 @@ void ScTabViewShell::ExecuteTable( SfxRequest& rReq )
{
if (pDlg->GetTablesFromFile())
{
- SCTAB nTabs[MAXTABCOUNT];
- SCTAB nCount = 0;
+ std::vector<SCTAB> nTabs;
sal_uInt16 n = 0;
const String* pStr = pDlg->GetFirstTable( &n );
while ( pStr )
{
- nTabs[nCount++] = static_cast<SCTAB>(n);
+ nTabs.push_back( static_cast<SCTAB>(n) );
pStr = pDlg->GetNextTable( &n );
}
sal_Bool bLink = pDlg->GetTablesAsLink();
- if (nCount != 0)
+ if (0 < nTabs.size())
{
if(pDlg->IsTableBefore())
{
- ImportTables( pDlg->GetDocShellTables(), nCount, nTabs,
+ ImportTables( pDlg->GetDocShellTables(), nTabs.size(), &nTabs[0],
bLink,nTabNr );
}
else
@@ -282,7 +281,7 @@ void ScTabViewShell::ExecuteTable( SfxRequest& rReq )
}
}
- ImportTables( pDlg->GetDocShellTables(), nCount, nTabs,
+ ImportTables( pDlg->GetDocShellTables(), nTabs.size(), &nTabs[0],
bLink,nTabAfter );
}
}
@@ -301,20 +300,15 @@ 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
{
SCTAB nTabAfter = nTabNr+1;
- SCTAB nSelHigh=0;
-
- for(SCTAB i=0;i<nTabCount;i++)
- {
- if(rMark.GetTableSelect(i))
- {
- nSelHigh=i;
- }
- }
+ SCTAB nSelHigh = rMark.GetLastSelected();
for(SCTAB j=nSelHigh+1;j<nTabCount;j++)
{
@@ -337,7 +331,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/viewdata.cxx b/sc/source/ui/view/viewdata.cxx
index c82bd6e8ccc2..019cf107735e 100644
--- a/sc/source/ui/view/viewdata.cxx
+++ b/sc/source/ui/view/viewdata.cxx
@@ -296,7 +296,8 @@ void ScViewDataTable::ReadUserDataSequence(const uno::Sequence <beans::PropertyV
}
ScViewData::ScViewData( ScDocShell* pDocSh, ScTabViewShell* pViewSh )
- : pDocShell ( pDocSh ),
+ : pTabData(),
+ pDocShell ( pDocSh ),
pDoc ( NULL ),
pView ( pViewSh ),
pViewShell ( pViewSh ),
@@ -331,9 +332,7 @@ ScViewData::ScViewData( ScDocShell* pDocSh, ScTabViewShell* pViewSh )
aScrSize = Size( (long) ( STD_COL_WIDTH * PIXEL_PER_TWIPS * OLE_STD_CELLS_X ),
(long) ( ScGlobal::nStdRowHeight * PIXEL_PER_TWIPS * OLE_STD_CELLS_Y ) );
- pTabData[0] = new ScViewDataTable;
- for ( SCTAB i = 1; i <= MAXTAB; i++ )
- pTabData[i] = NULL;
+ pTabData.push_back( new ScViewDataTable() );
pThisTab = pTabData[nTabNo];
for (sal_uInt16 j=0; j<4; j++)
{
@@ -355,9 +354,11 @@ ScViewData::ScViewData( ScDocShell* pDocSh, ScTabViewShell* pViewSh )
if (pDoc && !pDoc->IsVisible(nTabNo))
{
while ( !pDoc->IsVisible(nTabNo) && pDoc->HasTable(nTabNo+1) )
+ {
++nTabNo;
-
- pTabData[nTabNo] = new ScViewDataTable;
+ pTabData.push_back(NULL);
+ }
+ pTabData[nTabNo] = new ScViewDataTable() ;
pThisTab = pTabData[nTabNo];
}
@@ -365,7 +366,8 @@ ScViewData::ScViewData( ScDocShell* pDocSh, ScTabViewShell* pViewSh )
}
ScViewData::ScViewData( const ScViewData& rViewData )
- : pDocShell ( rViewData.pDocShell ),
+ : pTabData( rViewData.pTabData ),
+ pDocShell ( rViewData.pDocShell ),
pDoc ( rViewData.pDoc ),
pView ( rViewData.pView ),
pViewShell ( rViewData.pViewShell ),
@@ -398,11 +400,7 @@ ScViewData::ScViewData( const ScViewData& rViewData )
SetOutlineMode ( rViewData.IsOutlineMode() );
aScrSize = rViewData.aScrSize;
- for ( SCTAB i = 0; i <= MAXTAB; i++ )
- if (rViewData.pTabData[i])
- pTabData[i] = new ScViewDataTable( *rViewData.pTabData[i] );
- else
- pTabData[i] = NULL;
+
pThisTab = pTabData[nTabNo];
for (sal_uInt16 j=0; j<4; j++)
{
@@ -436,10 +434,6 @@ ScDocument* ScViewData::GetDocument() const
ScViewData::~ScViewData()
{
- for (SCTAB i=0; i<=MAXTAB; i++)
- if (pTabData[i])
- delete pTabData[i];
-
KillEditView();
delete pOptions;
}
@@ -454,7 +448,9 @@ void ScViewData::UpdateThis()
if (nTabNo>0)
--nTabNo;
else
- pThisTab = pTabData[0] = new ScViewDataTable;
+ {
+ pThisTab = pTabData[0] = new ScViewDataTable();
+ }
// hier keine Assertion, weil sonst Paints kommen, bevor alles initialisiert ist!
}
@@ -464,29 +460,52 @@ void ScViewData::UpdateThis()
void ScViewData::InsertTab( SCTAB nTab )
{
- delete pTabData[MAXTAB];
-
- for (SCTAB i=MAXTAB; i>nTab; i--)
- pTabData[i] = pTabData[i-1];
-
- pTabData[nTab] = NULL; // force creating new
+ 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];
- for (SCTAB i=nTab; i<MAXTAB; i++)
- pTabData[i] = pTabData[i+1];
+ pTabData.erase(pTabData.begin() + nTab);
+ UpdateThis();
+ aMarkData.DeleteTab( nTab );
+}
- pTabData[MAXTAB] = NULL;
+void ScViewData::DeleteTabs( SCTAB nTab, SCTAB nSheets )
+{
+ for (SCTAB aTab = 0; aTab < nSheets; ++aTab)
+ {
+ aMarkData.DeleteTab( nTab + aTab );
+ delete pTabData[nTab + aTab];
+ }
+ pTabData.erase(pTabData.begin() + nTab, pTabData.begin()+ nTab+nSheets);
UpdateThis();
- aMarkData.DeleteTab( nTab );
+
}
void ScViewData::CopyTab( SCTAB nSrcTab, SCTAB nDestTab )
@@ -500,15 +519,15 @@ void ScViewData::CopyTab( SCTAB nSrcTab, SCTAB nDestTab )
return;
}
- delete pTabData[MAXTAB];
-
- for (SCTAB i=MAXTAB; i>nDestTab; i--)
- pTabData[i] = pTabData[i-1];
+ if (nSrcTab >= static_cast<SCTAB>(pTabData.size()))
+ OSL_FAIL("pTabData out of bounds, FIX IT");
+ while( nDestTab >= static_cast<SCTAB>(pTabData.size()))
+ pTabData.push_back(NULL);
if ( pTabData[nSrcTab] )
- pTabData[nDestTab] = new ScViewDataTable( *pTabData[nSrcTab] );
+ pTabData.insert(pTabData.begin() + nDestTab, new ScViewDataTable( *pTabData[nSrcTab] ));
else
- pTabData[nDestTab] = NULL;
+ pTabData.insert(pTabData.begin() + nDestTab, NULL);
UpdateThis();
aMarkData.InsertTab( nDestTab );
@@ -518,26 +537,27 @@ void ScViewData::MoveTab( SCTAB nSrcTab, SCTAB nDestTab )
{
if (nDestTab==SC_TAB_APPEND)
nDestTab = pDoc->GetTableCount() - 1;
-
- SCTAB i;
- ScViewDataTable* pTab = pTabData[nSrcTab];
-
- SCTAB nInsTab = nDestTab;
- if ( nSrcTab < nDestTab )
+ ScViewDataTable* pTab;
+ if (nSrcTab < static_cast<SCTAB>(pTabData.size()))
{
- --nInsTab;
- for (i=nSrcTab; i<nDestTab; i++)
- pTabData[i] = pTabData[i+1];
+ pTab = pTabData[nSrcTab];
+ pTabData.erase( pTabData.begin() + nSrcTab );
}
else
- for (i=nSrcTab; i>nDestTab; i--)
- pTabData[i] = pTabData[i-1];
+ pTab = NULL;
- pTabData[nDestTab] = pTab;
+ if (nDestTab < static_cast<SCTAB>(pTabData.size()))
+ pTabData.insert( pTabData.begin() + nDestTab, pTab );
+ else
+ {
+ while (nDestTab > static_cast<SCTAB>(pTabData.size()))
+ pTabData.push_back(NULL);
+ pTabData.push_back(pTab);
+ }
UpdateThis();
aMarkData.DeleteTab( nSrcTab );
- aMarkData.InsertTab( nInsTab ); // ggf. angepasst
+ aMarkData.InsertTab( nDestTab ); // ggf. angepasst
}
void ScViewData::CreateTabData( std::vector< SCTAB >& rvTabs )
@@ -557,7 +577,7 @@ void ScViewData::SetZoomType( SvxZoomType eNew, std::vector< SCTAB >& tabs )
if ( bAll )
{
- for ( SCTAB i = 0; i <= MAXTAB; ++i )
+ for ( SCTAB i = 0; i < static_cast<SCTAB>(pTabData.size()); ++i )
{
if ( pTabData[i] )
pTabData[i]->eZoomType = eNew;
@@ -571,7 +591,7 @@ void ScViewData::SetZoomType( SvxZoomType eNew, std::vector< SCTAB >& tabs )
for ( ; it != it_end; ++it )
{
SCTAB i = *it;
- if ( pTabData[i] )
+ if ( *it < static_cast<SCTAB>(pTabData.size()) && pTabData[i] )
pTabData[i]->eZoomType = eNew;
}
}
@@ -614,7 +634,7 @@ void ScViewData::SetZoom( const Fraction& rNewX, const Fraction& rNewY, std::vec
if ( bAll )
{
- for ( SCTAB i = 0; i <= MAXTAB; ++i )
+ for ( SCTAB i = 0; i < static_cast<SCTAB>(pTabData.size()); ++i )
{
if ( pTabData[i] )
{
@@ -648,7 +668,7 @@ void ScViewData::SetZoom( const Fraction& rNewX, const Fraction& rNewY, std::vec
for ( ; it != it_end; ++it )
{
SCTAB i = *it;
- if ( pTabData[i] )
+ if ( i < static_cast<SCTAB>(pTabData.size()) && pTabData[i] )
{
if ( bPagebreak )
{
@@ -1409,6 +1429,8 @@ void ScViewData::GetEditView( ScSplitPos eWhich, EditView*& rViewPtr, SCCOL& rCo
void ScViewData::CreateTabData( SCTAB nNewTab )
{
+ while(nNewTab >= static_cast<SCTAB>(pTabData.size()))
+ pTabData.push_back(NULL);
if (!pTabData[nNewTab])
{
pTabData[nNewTab] = new ScViewDataTable;
@@ -1423,7 +1445,7 @@ void ScViewData::CreateTabData( SCTAB nNewTab )
void ScViewData::CreateSelectedTabData()
{
- SCTAB nTabCount = pDoc->GetTableCount();
+ SCTAB nTabCount = aMarkData.GetLastSelected();
for (SCTAB i=0; i<nTabCount; i++)
if ( aMarkData.GetTableSelect(i) && !pTabData[i] )
CreateTabData( i );
@@ -2181,7 +2203,7 @@ void ScViewData::WriteUserData(String& rData)
for (SCTAB i=0; i<nTabCount; i++)
{
rData += ';'; // Numerierung darf auf keinen Fall durcheinanderkommen
- if (pTabData[i])
+ if (i < static_cast<SCTAB>(pTabData.size()) && pTabData[i])
{
sal_Unicode cTabSep = SC_OLD_TABSEP; // wie 3.1
if ( pTabData[i]->nCurY > MAXROW_30 ||
@@ -2280,6 +2302,10 @@ void ScViewData::ReadUserData(const String& rData)
while ( nCount > nPos+nTabStart )
{
aTabOpt = rData.GetToken(static_cast<xub_StrLen>(nPos+nTabStart));
+ while(nPos >= static_cast<SCTAB>(pTabData.size()))
+ {
+ pTabData.push_back(NULL);
+ }
if (!pTabData[nPos])
pTabData[nPos] = new ScViewDataTable;
@@ -2356,7 +2382,7 @@ void ScViewData::WriteExtOptions( ScExtDocOptions& rDocOpt ) const
rDocSett.mfTabBarWidth = pView->GetRelTabBarWidth();
// sheet settings
- for( SCTAB nTab = 0, nTabCount = pDoc->GetTableCount(); nTab < nTabCount; ++nTab )
+ for( SCTAB nTab = 0; nTab < static_cast<SCTAB>(pTabData.size()); ++nTab )
{
if( const ScViewDataTable* pViewTab = pTabData[ nTab ] )
{
@@ -2458,7 +2484,7 @@ void ScViewData::ReadExtOptions( const ScExtDocOptions& rDocOpt )
pView->SetPendingRelTabBarWidth( rDocSett.mfTabBarWidth );
// sheet settings
- for( SCTAB nTab = 0, nTabCount = pDoc->GetTableCount(); nTab < nTabCount; ++nTab )
+ for( SCTAB nTab = 0; nTab < static_cast<SCTAB>(pTabData.size()); ++nTab )
{
if( const ScExtTabSettings* pTabSett = rDocOpt.GetTabSettings( nTab ) )
{
@@ -2605,7 +2631,6 @@ void ScViewData::WriteUserDataSequence(uno::Sequence <beans::PropertyValue>& rSe
SvXMLUnitConverter::convertNumber(sBuffer, static_cast<sal_Int32>(nViewID));
pSettings[SC_VIEW_ID].Value <<= sBuffer.makeStringAndClear();
- SCTAB nTabCount (pDoc->GetTableCount());
uno::Reference<lang::XMultiServiceFactory> xServiceFactory =
comphelper::getProcessServiceFactory();
OSL_ENSURE( xServiceFactory.is(), "got no service manager" );
@@ -2615,7 +2640,7 @@ void ScViewData::WriteUserDataSequence(uno::Sequence <beans::PropertyValue>& rSe
uno::Reference<container::XNameContainer> xNameContainer = uno::Reference<container::XNameContainer>(xServiceFactory->createInstance(sName), uno::UNO_QUERY);
if (xNameContainer.is())
{
- for (SCTAB nTab=0; nTab<nTabCount; nTab++)
+ for (SCTAB nTab=0; nTab<static_cast<SCTAB>(pTabData.size()); nTab++)
{
if (pTabData[nTab])
{
@@ -2855,7 +2880,7 @@ void ScViewData::ReadUserDataSequence(const uno::Sequence <beans::PropertyValue>
}
// copy default zoom to sheets where a different one wasn't specified
- for (SCTAB nZoomTab=0; nZoomTab<=MAXTAB; ++nZoomTab)
+ for (SCTAB nZoomTab=0; nZoomTab< static_cast<SCTAB>(pTabData.size()); ++nZoomTab)
if (pTabData[nZoomTab] && ( nZoomTab >= static_cast<SCTAB>(aHasZoomVect.size()) || !aHasZoomVect[nZoomTab] ))
{
pTabData[nZoomTab]->eZoomType = eDefZoomType;
diff --git a/sc/source/ui/view/viewfun2.cxx b/sc/source/ui/view/viewfun2.cxx
index d2dfad0ab766..acbc952e74d4 100644
--- a/sc/source/ui/view/viewfun2.cxx
+++ b/sc/source/ui/view/viewfun2.cxx
@@ -1973,70 +1973,46 @@ 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;
+ bool bFlag=false;
- String aValTabName;
- String *pStr;
-
- 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))
- {
- bFlag=sal_True;
- pDocSh->Broadcast( ScTablesHint( SC_TAB_INSERTED, nTab+i ) );
- }
- else
- {
- break;
- }
-
- if(pNameList!=NULL)
- pNameList->Insert(new String(*pStr),pNameList->Count());
-
+ pDoc->CreateValidTabNames(aNames, nCount);
+ }
+ if (pDoc->InsertTabs(nTab, aNames, false))
+ {
+ pDocSh->Broadcast( ScTablesHint( SC_TABS_INSERTED, nTab, nCount ) );
+ 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
{
@@ -2097,11 +2073,54 @@ sal_Bool ScViewFunc::DeleteTable( SCTAB nTab, sal_Bool bRecord )
return bSuccess;
}
+//only use this method for undo for now, all sheets must be connected
+//this method doesn't support undo for now, merge it when it with the other method later
+bool ScViewFunc::DeleteTables( const SCTAB nTab, SCTAB nSheets )
+{
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ ScDocument* pDoc = pDocSh->GetDocument();
+ bool bVbaEnabled = pDoc->IsInVBAMode();
+ SCTAB nNewTab = nTab;
+ WaitObject aWait( GetFrameWin() );
+
+ while ( nNewTab > 0 && !pDoc->IsVisible( nNewTab ) )
+ --nNewTab;
+
+ if (pDoc->DeleteTabs(nTab, nSheets, NULL))
+ {
+ if( bVbaEnabled )
+ {
+ for (SCTAB aTab = 0; aTab < nSheets; ++aTab)
+ {
+ String sCodeName;
+ bool bHasCodeName = pDoc->GetCodeName( nTab + aTab, sCodeName );
+ if ( bHasCodeName )
+ VBA_DeleteModule( *pDocSh, sCodeName );
+ }
+ }
+
+ pDocSh->Broadcast( ScTablesHint( SC_TABS_DELETED, nTab, nSheets ) );
+ if ( nNewTab >= pDoc->GetTableCount() )
+ nNewTab = pDoc->GetTableCount() - 1;
+ SetTabNo( nNewTab, sal_True );
+
+ pDocSh->PostPaintExtras();
+ pDocSh->SetDocumentModified();
+
+ SfxApplication* pSfxApp = SFX_APP(); // Navigator
+ pSfxApp->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) );
+ pSfxApp->Broadcast( SfxSimpleHint( SC_HINT_DBAREAS_CHANGED ) );
+ pSfxApp->Broadcast( SfxSimpleHint( SC_HINT_AREALINKS_CHANGED ) );
+ return true;
+ }
+ return false;
+}
+
sal_Bool ScViewFunc::DeleteTables(const vector<SCTAB> &TheTabs, sal_Bool bRecord )
{
ScDocShell* pDocSh = GetViewData()->GetDocShell();
ScDocument* pDoc = pDocSh->GetDocument();
- sal_Bool bVbaEnabled = pDoc ? pDoc->IsInVBAMode() : false;
+ sal_Bool bVbaEnabled = pDoc->IsInVBAMode();
SCTAB nNewTab = TheTabs[0];
WaitObject aWait( GetFrameWin() );
if (bRecord && !pDoc->IsUndoEnabled())
diff --git a/sc/source/ui/view/viewfun3.cxx b/sc/source/ui/view/viewfun3.cxx
index 1c13f3f629bb..c8d9123e667a 100644
--- a/sc/source/ui/view/viewfun3.cxx
+++ b/sc/source/ui/view/viewfun3.cxx
@@ -1268,7 +1268,7 @@ sal_Bool ScViewFunc::PasteFromClip( sal_uInt16 nFlags, ScDocument* pClipDoc,
// #i68690# ExtendMerge for the clip doc must be called with the clipboard's sheet numbers.
// The same end column/row can be used for all calls because the clip doc doesn't contain
// content outside the clip area.
- for (SCTAB nClipTab=0; nClipTab<=MAXTAB; nClipTab++)
+ for (SCTAB nClipTab=0; nClipTab < pClipDoc->GetTableCount(); nClipTab++)
if ( pClipDoc->HasTable(nClipTab) )
if ( pClipDoc->ExtendMerge( nClipStartX,nClipStartY, nUndoEndCol,nUndoEndRow, nClipTab, false ) )
bClipOver = sal_True;
@@ -1604,7 +1604,7 @@ bool ScViewFunc::PasteMultiRangesFromClip(
// Determine the first and last selected sheet numbers.
SCTAB nTab1 = aMark.GetFirstSelected();
SCTAB nTab2 = nTab1;
- for (SCTAB i = nTab1+1; i <= MAXTAB; ++i)
+ for (SCTAB i = nTab1+1; i < aMark.GetLastSelected(); ++i)
if (aMark.GetTableSelect(i))
nTab2 = i;