diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2011-06-07 05:04:57 +0200 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2011-06-07 05:04:57 +0200 |
commit | 4c5e30555d20f17614f31c34a0b06fbca5f3fb02 (patch) | |
tree | f8b529e975eb61531468c63044ab932f2350789f /sc/source/ui | |
parent | b2570e4a1cfbb71655b22596bb39861dfaa9ef33 (diff) | |
parent | db7fa1355626cef14de707a8cb415c05ab16b00c (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')
-rw-r--r-- | sc/source/ui/app/scmod.cxx | 11 | ||||
-rw-r--r-- | sc/source/ui/app/transobj.cxx | 6 | ||||
-rw-r--r-- | sc/source/ui/docshell/docsh.cxx | 13 | ||||
-rw-r--r-- | sc/source/ui/docshell/docsh5.cxx | 9 | ||||
-rw-r--r-- | sc/source/ui/inc/pfuncache.hxx | 4 | ||||
-rw-r--r-- | sc/source/ui/inc/preview.hxx | 6 | ||||
-rw-r--r-- | sc/source/ui/inc/uiitems.hxx | 2 | ||||
-rw-r--r-- | sc/source/ui/inc/undotab.hxx | 4 | ||||
-rw-r--r-- | sc/source/ui/inc/viewdata.hxx | 4 | ||||
-rw-r--r-- | sc/source/ui/inc/viewfunc.hxx | 3 | ||||
-rw-r--r-- | sc/source/ui/undo/undotab.cxx | 44 | ||||
-rw-r--r-- | sc/source/ui/vba/vbaquerytable.cxx | 6 | ||||
-rw-r--r-- | sc/source/ui/view/cellsh3.cxx | 2 | ||||
-rw-r--r-- | sc/source/ui/view/gridwin.cxx | 9 | ||||
-rw-r--r-- | sc/source/ui/view/pfuncache.cxx | 17 | ||||
-rw-r--r-- | sc/source/ui/view/preview.cxx | 22 | ||||
-rw-r--r-- | sc/source/ui/view/tabvwsh5.cxx | 14 | ||||
-rw-r--r-- | sc/source/ui/view/tabvwshf.cxx | 29 | ||||
-rw-r--r-- | sc/source/ui/view/viewdata.cxx | 139 | ||||
-rw-r--r-- | sc/source/ui/view/viewfun2.cxx | 101 | ||||
-rw-r--r-- | sc/source/ui/view/viewfun3.cxx | 4 |
21 files changed, 263 insertions, 186 deletions
diff --git a/sc/source/ui/app/scmod.cxx b/sc/source/ui/app/scmod.cxx index 503f584a92c7..764b8d91f801 100644 --- a/sc/source/ui/app/scmod.cxx +++ b/sc/source/ui/app/scmod.cxx @@ -1684,15 +1684,8 @@ void lcl_MarkedTabs( const ScMarkData& rMark, SCTAB& rStartTab, SCTAB& rEndTab ) { if (rMark.GetSelectCount() > 1) { - sal_Bool bFirst = sal_True; - for (SCTAB i=0; i<=MAXTAB; i++) - if (rMark.GetTableSelect(i)) - { - if (bFirst) - rStartTab = i; - rEndTab = i; - bFirst = false; - } + rEndTab = rMark.GetLastSelected(); + rStartTab = rMark.GetFirstSelected(); } } diff --git a/sc/source/ui/app/transobj.cxx b/sc/source/ui/app/transobj.cxx index 490c3791b140..d99b7a277509 100644 --- a/sc/source/ui/app/transobj.cxx +++ b/sc/source/ui/app/transobj.cxx @@ -161,7 +161,7 @@ ScTransferObj::ScTransferObj( ScDocument* pClipDoc, const TransferableObjectDesc SCTAB nTab1=0; SCTAB nTab2=0; sal_Bool bFirst = sal_True; - for (SCTAB i=0; i<=MAXTAB; i++) + for (SCTAB i=0; i< pDoc->GetTableCount(); i++) if (pDoc->HasTable(i)) { if (bFirst) @@ -767,10 +767,10 @@ void ScTransferObj::StripRefs( ScDocument* pDoc, // In a clipboard doc the data don't have to be on the first sheet SCTAB nSrcTab = 0; - while (nSrcTab<MAXTAB && !pDoc->HasTable(nSrcTab)) + while (nSrcTab<pDoc->GetTableCount() && !pDoc->HasTable(nSrcTab)) ++nSrcTab; SCTAB nDestTab = 0; - while (nDestTab<MAXTAB && !pDestDoc->HasTable(nDestTab)) + while (nDestTab<pDestDoc->GetTableCount() && !pDestDoc->HasTable(nDestTab)) ++nDestTab; if (!pDoc->HasTable(nSrcTab) || !pDestDoc->HasTable(nDestTab)) diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx index 62ac24675b23..6ff4a81d8204 100644 --- a/sc/source/ui/docshell/docsh.cxx +++ b/sc/source/ui/docshell/docsh.cxx @@ -246,9 +246,7 @@ SCTAB ScDocShell::GetSaveTab() if (pSh) { const ScMarkData& rMark = pSh->GetViewData()->GetMarkData(); - for ( nTab = 0; nTab <= MAXTAB; nTab++ ) // erste markierte Tabelle - if ( rMark.GetTableSelect( nTab ) ) - break; + nTab = rMark.GetFirstSelected(); } return nTab; } @@ -544,6 +542,15 @@ void ScDocShell::Notify( SfxBroadcaster&, const SfxHint& rHint ) aArgs[0] <<= rScHint.GetTab1(); xVbaEvents->processVbaEvent( WORKBOOK_NEWSHEET, aArgs ); } + else if (rScHint.GetId() == SC_TABS_INSERTED) + { + for (SCTAB i = 0; i < rScHint.GetTab2(); ++i) + { + uno::Sequence< uno::Any > aArgs( 1 ); + aArgs[0] <<= rScHint.GetTab1() + i; + xVbaEvents->processVbaEvent( WORKBOOK_NEWSHEET, aArgs ); + } + } } else if ( rHint.ISA( SfxEventHint ) ) { diff --git a/sc/source/ui/docshell/docsh5.cxx b/sc/source/ui/docshell/docsh5.cxx index 373c68f198ac..1e6c2474ffbc 100644 --- a/sc/source/ui/docshell/docsh5.cxx +++ b/sc/source/ui/docshell/docsh5.cxx @@ -59,6 +59,7 @@ #include "dbdocfun.hxx" #include "consoli.hxx" #include "dbdata.hxx" +#include "progress.hxx" #include "olinetab.hxx" #include "patattr.hxx" #include "attrib.hxx" @@ -973,8 +974,14 @@ sal_Bool ScDocShell::MoveTable( SCTAB nSrcTab, SCTAB nDestTab, sal_Bool bCopy, s return sal_True; // nothing to do, but valid } - if (!aDocument.MoveTab( nSrcTab, nDestTab )) + ScProgress* pProgress = new ScProgress(this, ScGlobal::GetRscString(STR_UNDO_MOVE_TAB), + aDocument.GetCodeCount()); + bool bDone = aDocument.MoveTab( nSrcTab, nDestTab, pProgress ); + delete pProgress; + if (!bDone) + { return false; + } else if (bRecord) { auto_ptr< vector<SCTAB> > pSrcList(new vector<SCTAB>(1, nSrcTab)); diff --git a/sc/source/ui/inc/pfuncache.hxx b/sc/source/ui/inc/pfuncache.hxx index b64e9753e43d..75d1d097f0cf 100644 --- a/sc/source/ui/inc/pfuncache.hxx +++ b/sc/source/ui/inc/pfuncache.hxx @@ -100,8 +100,8 @@ class ScPrintFuncCache ScPrintSelectionStatus aSelection; ScDocShell* pDocSh; long nTotalPages; - long nPages[MAXTABCOUNT]; - long nFirstAttr[MAXTABCOUNT]; + std::vector<long> nPages; + std::vector<long> nFirstAttr; std::vector<ScPrintPageLocation> aLocations; bool bLocInitialized; diff --git a/sc/source/ui/inc/preview.hxx b/sc/source/ui/inc/preview.hxx index 6988259526d0..1ea80fd92202 100644 --- a/sc/source/ui/inc/preview.hxx +++ b/sc/source/ui/inc/preview.hxx @@ -32,6 +32,8 @@ #include <vcl/window.hxx> #include "printfun.hxx" // ScPrintState +#include <vector> + class ScDocShell; class ScPreviewShell; class FmFormView; @@ -48,8 +50,8 @@ private: sal_Bool bValid; // folgende Werte gueltig SCTAB nTabCount; SCTAB nTabsTested; // fuer wieviele Tabellen ist nPages gueltig? - long nPages[MAXTABCOUNT]; - long nFirstAttr[MAXTABCOUNT]; + std::vector<long> nPages; + std::vector<long> nFirstAttr; SCTAB nTab; // Tabelle long nTabPage; // Seite von Tabelle long nTabStart; // erste Seite der Tabelle (wirklich) diff --git a/sc/source/ui/inc/uiitems.hxx b/sc/source/ui/inc/uiitems.hxx index 584b6e5dc815..7f71a152684e 100644 --- a/sc/source/ui/inc/uiitems.hxx +++ b/sc/source/ui/inc/uiitems.hxx @@ -92,6 +92,8 @@ public: #define SC_TAB_MOVED 3 #define SC_TAB_COPIED 4 #define SC_TAB_HIDDEN 5 +#define SC_TABS_INSERTED 6 +#define SC_TABS_DELETED 7 class ScTablesHint : public SfxHint { 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/viewdata.hxx b/sc/source/ui/inc/viewdata.hxx index 83a15fc79b60..d0160ba2708e 100644 --- a/sc/source/ui/inc/viewdata.hxx +++ b/sc/source/ui/inc/viewdata.hxx @@ -170,7 +170,7 @@ class SC_DLLPUBLIC ScViewData private: double nPPTX, nPPTY; // Scaling-Faktoren - ScViewDataTable* pTabData[MAXTABCOUNT]; + ::std::vector<ScViewDataTable*> pTabData; ScViewDataTable* pThisTab; // Daten der angezeigten Tabelle ScDocShell* pDocShell; ScDocument* pDoc; @@ -277,7 +277,9 @@ public: void UpdateThis(); void InsertTab( SCTAB nTab ); + void InsertTabs( SCTAB nTab, SCTAB nNewSheets ); void DeleteTab( SCTAB nTab ); + void DeleteTabs( SCTAB nTab, SCTAB nSheets ); void CopyTab( SCTAB nSrcTab, SCTAB nDestTab ); void MoveTab( SCTAB nSrcTab, SCTAB nDestTab ); diff --git a/sc/source/ui/inc/viewfunc.hxx b/sc/source/ui/inc/viewfunc.hxx index ed78ccf7e4a2..a162b86a2ec7 100644 --- a/sc/source/ui/inc/viewfunc.hxx +++ b/sc/source/ui/inc/viewfunc.hxx @@ -260,13 +260,14 @@ 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 ); sal_Bool DeleteTable( SCTAB nTabNr, sal_Bool bRecord = true ); sal_Bool DeleteTables(const std::vector<SCTAB>& TheTabs, sal_Bool bRecord = true ); + bool DeleteTables(SCTAB nTab, SCTAB nSheets); sal_Bool RenameTable( const String& rName, SCTAB nTabNr ); void MoveTable( sal_uInt16 nDestDocNo, SCTAB nDestTab, sal_Bool bCopy, const String* pNewTabName = NULL ); 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 diff --git a/sc/source/ui/vba/vbaquerytable.cxx b/sc/source/ui/vba/vbaquerytable.cxx index 159c7b75adf2..03e734a81548 100644 --- a/sc/source/ui/vba/vbaquerytable.cxx +++ b/sc/source/ui/vba/vbaquerytable.cxx @@ -59,9 +59,9 @@ ScVbaQueryTable::Refresh( const ::com::sun::star::uno::Any& /*aBackgroundQuery*/ { //Get parent Info - sal_Int32 nRow = m_pParent->getRow(); - sal_Int32 nClm = m_pParent->getColumn(); - sal_Int16 nTab = m_pParent->getWorksheet()->getIndex() - 1; //The vba index begin from 1. + SCROW nRow = m_pParent->getRow(); + SCCOL nClm = m_pParent->getColumn(); + SCTAB nTab = m_pParent->getWorksheet()->getIndex() - 1; //The vba index begin from 1. ScAddress crrRngAddr(nClm, nRow, nTab); //Get link info 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; |