From fb66a6bffaf822bfb26f8a8ed2ce981979de19ce Mon Sep 17 00:00:00 2001 From: Markus Mohrhard Date: Wed, 18 May 2011 02:42:28 +0200 Subject: rework ScViewData to work with unlimited number of sheets --- sc/source/ui/inc/viewdata.hxx | 2 +- sc/source/ui/view/viewdata.cxx | 94 +++++++++++++++--------------------------- 2 files changed, 35 insertions(+), 61 deletions(-) (limited to 'sc/source/ui') diff --git a/sc/source/ui/inc/viewdata.hxx b/sc/source/ui/inc/viewdata.hxx index 83a15fc79b60..31578b85945f 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 pTabData; ScViewDataTable* pThisTab; // Daten der angezeigten Tabelle ScDocShell* pDocShell; ScDocument* pDoc; diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx index b7c2e3c14a05..9fc97e8f8edf 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 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 +367,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 +401,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 +435,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 +449,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,12 +461,7 @@ 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 + pTabData.insert( pTabData.begin() + nTab, NULL ); CreateTabData( nTab ); UpdateThis(); @@ -480,11 +472,7 @@ void ScViewData::DeleteTab( SCTAB nTab ) { delete pTabData[nTab]; - for (SCTAB i=nTab; inDestTab; i--) - pTabData[i] = pTabData[i-1]; - 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 ); @@ -519,25 +502,13 @@ 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 ) - { - --nInsTab; - for (i=nSrcTab; inDestTab; i--) - pTabData[i] = pTabData[i-1]; - - pTabData[nDestTab] = pTab; + pTabData.erase( pTabData.begin() + nSrcTab ); + pTabData.insert( pTabData.begin() + nDestTab, pTab ); UpdateThis(); aMarkData.DeleteTab( nSrcTab ); - aMarkData.InsertTab( nInsTab ); // ggf. angepasst + aMarkData.InsertTab( nDestTab ); // ggf. angepasst } void ScViewData::CreateTabData( std::vector< SCTAB >& rvTabs ) @@ -557,7 +528,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(pTabData.size()); ++i ) { if ( pTabData[i] ) pTabData[i]->eZoomType = eNew; @@ -571,7 +542,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(pTabData.size()) && pTabData[i] ) pTabData[i]->eZoomType = eNew; } } @@ -614,7 +585,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(pTabData.size()); ++i ) { if ( pTabData[i] ) { @@ -648,7 +619,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(pTabData.size()) && pTabData[i] ) { if ( bPagebreak ) { @@ -1423,7 +1394,7 @@ void ScViewData::CreateTabData( SCTAB nNewTab ) void ScViewData::CreateSelectedTabData() { - SCTAB nTabCount = pDoc->GetTableCount(); + SCTAB nTabCount = aMarkData.GetLastSelected(); for (SCTAB i=0; i(pTabData.size()) && pTabData[i]) { sal_Unicode cTabSep = SC_OLD_TABSEP; // wie 3.1 if ( pTabData[i]->nCurY > MAXROW_30 || @@ -2280,6 +2251,10 @@ void ScViewData::ReadUserData(const String& rData) while ( nCount > nPos+nTabStart ) { aTabOpt = rData.GetToken(static_cast(nPos+nTabStart)); + while(nPos >= static_cast(pTabData.size())) + { + pTabData.push_back(NULL); + } if (!pTabData[nPos]) pTabData[nPos] = new ScViewDataTable; @@ -2356,7 +2331,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(pTabData.size()); ++nTab ) { if( const ScViewDataTable* pViewTab = pTabData[ nTab ] ) { @@ -2458,7 +2433,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(pTabData.size()); ++nTab ) { if( const ScExtTabSettings* pTabSett = rDocOpt.GetTabSettings( nTab ) ) { @@ -2605,7 +2580,6 @@ void ScViewData::WriteUserDataSequence(uno::Sequence & rSe SvXMLUnitConverter::convertNumber(sBuffer, static_cast(nViewID)); pSettings[SC_VIEW_ID].Value <<= sBuffer.makeStringAndClear(); - SCTAB nTabCount (pDoc->GetTableCount()); uno::Reference xServiceFactory = comphelper::getProcessServiceFactory(); DBG_ASSERT( xServiceFactory.is(), "got no service manager" ); @@ -2615,7 +2589,7 @@ void ScViewData::WriteUserDataSequence(uno::Sequence & rSe uno::Reference xNameContainer = uno::Reference(xServiceFactory->createInstance(sName), uno::UNO_QUERY); if (xNameContainer.is()) { - for (SCTAB nTab=0; nTab(pTabData.size()); nTab++) { if (pTabData[nTab]) { @@ -2855,7 +2829,7 @@ void ScViewData::ReadUserDataSequence(const uno::Sequence } // 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(pTabData.size()); ++nZoomTab) if (pTabData[nZoomTab] && ( nZoomTab >= static_cast(aHasZoomVect.size()) || !aHasZoomVect[nZoomTab] )) { pTabData[nZoomTab]->eZoomType = eDefZoomType; -- cgit From 52bd6de2d9ccc7eb6591e258989dccf9c86703fc Mon Sep 17 00:00:00 2001 From: Markus Mohrhard Date: Wed, 18 May 2011 15:21:46 +0200 Subject: rework ScPrintFuncCache to work with unlimited number of sheets --- sc/source/ui/inc/pfuncache.hxx | 4 ++-- sc/source/ui/view/pfuncache.cxx | 17 ++++++++++++----- 2 files changed, 14 insertions(+), 7 deletions(-) (limited to 'sc/source/ui') 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 nPages; + std::vector nFirstAttr; std::vector aLocations; bool bLocInitialized; 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(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(nPages.size()) ) + nDisplayStart += nPages[i]; + else + OSL_FAIL("nPages out of bounds, FIX IT!"); + } } return nDisplayStart; } -- cgit From edd1216b163b7824c7a79ffa3e9d9f68b56d6754 Mon Sep 17 00:00:00 2001 From: Markus Mohrhard Date: Wed, 18 May 2011 15:55:20 +0200 Subject: rework ScPreview to work with unlimited number of sheets --- sc/source/ui/inc/preview.hxx | 6 ++++-- sc/source/ui/view/preview.cxx | 22 +++++++++++++++++----- 2 files changed, 21 insertions(+), 7 deletions(-) (limited to 'sc/source/ui') 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 #include "printfun.hxx" // ScPrintState +#include + 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 nPages; + std::vector nFirstAttr; SCTAB nTab; // Tabelle long nTabPage; // Seite von Tabelle long nTabStart; // erste Seite der Tabelle (wirklich) diff --git a/sc/source/ui/view/preview.cxx b/sc/source/ui/view/preview.cxx index a58eef8e2335..42d7f3098d10 100644 --- a/sc/source/ui/view/preview.cxx +++ b/sc/source/ui/view/preview.cxx @@ -82,7 +82,7 @@ #define SC_PREVIEW_SHADOWSIZE 2 -long lcl_GetDisplayStart( SCTAB nTab, ScDocument* pDoc, long* pPages ) +long lcl_GetDisplayStart( SCTAB nTab, ScDocument* pDoc, std::vector& nPages ) { long nDisplayStart = 0; for (SCTAB i=0; iNeedPageResetAfterTab(i) ) nDisplayStart = 0; else - nDisplayStart += pPages[i]; + nDisplayStart += nPages[i]; } return nDisplayStart; } @@ -102,6 +102,8 @@ ScPreview::ScPreview( Window* pParent, ScDocShell* pDocSh, ScPreviewShell* pView nZoom( 100 ), bValid( false ), nTabsTested( 0 ), + nPages(), + nFirstAttr(), nTab( 0 ), nTabStart( 0 ), nDisplayStart( 0 ), @@ -191,10 +193,10 @@ void ScPreview::TestLastPage() if (nTotalPages) { nPageNo = nTotalPages - 1; - nTab = nTabCount - 1; + nTab = static_cast(nPages.size()) -1; while (nTab > 0 && !nPages[nTab]) // letzte nicht leere Tabelle --nTab; - DBG_ASSERT(nPages[nTab],"alle Tabellen leer?"); + DBG_ASSERT(0 < static_cast(nPages.size()),"alle Tabellen leer?"); nTabPage = nPages[nTab] - 1; nTabStart = 0; for (sal_uInt16 i=0; i static_cast(nPages.size())) + nPages.push_back(0); + while (nStart > static_cast(nFirstAttr.size())) + nFirstAttr.push_back(0); for (SCTAB i=nStart; i(nPages.size())) + nPages.push_back(0); + if ( i == static_cast(nFirstAttr.size())) + nFirstAttr.push_back(0); if (!aOptions.GetAllSheets() && !aMarkData.GetTableSelect( i )) { nPages[i] = 0; nFirstAttr[i] = 0; @@ -309,7 +319,7 @@ void ScPreview::RecalcPages() // nur nPageNo geaendert if (!bDone) { long nPartPages = 0; - for (SCTAB i=0; i(nPages.size()); i++) { long nThisStart = nPartPages; nPartPages += nPages[i]; @@ -807,6 +817,8 @@ void ScPreview::SetPageNo( long nPage ) long ScPreview::GetFirstPage(SCTAB nTabP) { + if (nTabP >= static_cast(nPages.size()) ) + OSL_FAIL("nPages out ouf bounds, FIX IT"); SCTAB nDocTabCount = pDocShell->GetDocument()->GetTableCount(); if (nTabP >= nDocTabCount) nTabP = nDocTabCount-1; -- cgit From e37e21299a2c6fb611e2c2039903c5669dcc899c Mon Sep 17 00:00:00 2001 From: Markus Mohrhard Date: Thu, 19 May 2011 02:21:03 +0200 Subject: fix some bugs introduced with the last patches and rework some parts --- sc/source/ui/app/transobj.cxx | 6 +++--- sc/source/ui/view/gridwin.cxx | 9 ++++----- sc/source/ui/view/tabvwshf.cxx | 11 +++++------ sc/source/ui/view/viewdata.cxx | 29 +++++++++++++++++++++++++---- sc/source/ui/view/viewfun3.cxx | 4 ++-- 5 files changed, 39 insertions(+), 20 deletions(-) (limited to 'sc/source/ui') diff --git a/sc/source/ui/app/transobj.cxx b/sc/source/ui/app/transobj.cxx index b584c7e86f7c..6aa0a7621736 100644 --- a/sc/source/ui/app/transobj.cxx +++ b/sc/source/ui/app/transobj.cxx @@ -160,7 +160,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) @@ -766,10 +766,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 (nSrcTabHasTable(nSrcTab)) + while (nSrcTabGetTableCount() && !pDoc->HasTable(nSrcTab)) ++nSrcTab; SCTAB nDestTab = 0; - while (nDestTabHasTable(nDestTab)) + while (nDestTabGetTableCount() && !pDestDoc->HasTable(nDestTab)) ++nDestTab; if (!pDoc->HasTable(nSrcTab) || !pDestDoc->HasTable(nDestTab)) diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx index 0c37dd79cf20..c12b72a1bb8e 100644 --- a/sc/source/ui/view/gridwin.cxx +++ b/sc/source/ui/view/gridwin.cxx @@ -3951,22 +3951,21 @@ sal_Int8 ScGridWindow::DropTransferObj( ScTransferObj* pTransObj, SCCOL nDestPos { ScDocShell* pSrcShell = pTransObj->GetSourceDocShell(); - SCTAB nTabs[MAXTABCOUNT]; + std::vector nTabs; ScMarkData aMark = pTransObj->GetSourceMarkData(); SCTAB nTabCount = pSourceDoc->GetTableCount(); - SCTAB nTabSelCount = 0; for(SCTAB i=0; iIsVisible(j))&&(pSourceDoc->IsScenario(j))) { - nTabs[nTabSelCount++]=j; + nTabs.push_back( j ); i=j; } else break; @@ -3974,7 +3973,7 @@ sal_Int8 ScGridWindow::DropTransferObj( ScTransferObj* pTransObj, SCCOL nDestPos } } - pView->ImportTables( pSrcShell,nTabSelCount, nTabs, bIsLink, nThisTab ); + pView->ImportTables( pSrcShell,static_cast(nTabs.size()), &nTabs[0], bIsLink, nThisTab ); bDone = sal_True; } } diff --git a/sc/source/ui/view/tabvwshf.cxx b/sc/source/ui/view/tabvwshf.cxx index b4d6cdc6ac1e..e9553352ebdd 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 nTabs; sal_uInt16 n = 0; const String* pStr = pDlg->GetFirstTable( &n ); while ( pStr ) { - nTabs[nCount++] = static_cast(n); + nTabs.push_back( static_cast(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 ); } } diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx index 9fc97e8f8edf..452dd68dba2f 100644 --- a/sc/source/ui/view/viewdata.cxx +++ b/sc/source/ui/view/viewdata.cxx @@ -333,7 +333,6 @@ 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.push_back( new ScViewDataTable() ); - for ( SCTAB i = 1; i <= MAXTAB; i++ ) pThisTab = pTabData[nTabNo]; for (sal_uInt16 j=0; j<4; j++) { @@ -461,6 +460,8 @@ void ScViewData::UpdateThis() void ScViewData::InsertTab( SCTAB nTab ) { + while( nTab >= static_cast(pTabData.size())) + pTabData.push_back(NULL); pTabData.insert( pTabData.begin() + nTab, NULL ); CreateTabData( nTab ); @@ -488,6 +489,11 @@ void ScViewData::CopyTab( SCTAB nSrcTab, SCTAB nDestTab ) return; } + if (nSrcTab >= static_cast(pTabData.size())) + OSL_FAIL("pTabData out of bounds, FIX IT"); + + while( nDestTab >= static_cast(pTabData.size())) + pTabData.push_back(NULL); if ( pTabData[nSrcTab] ) pTabData.insert(pTabData.begin() + nDestTab, new ScViewDataTable( *pTabData[nSrcTab] )); else @@ -501,10 +507,23 @@ void ScViewData::MoveTab( SCTAB nSrcTab, SCTAB nDestTab ) { if (nDestTab==SC_TAB_APPEND) nDestTab = pDoc->GetTableCount() - 1; + ScViewDataTable* pTab; + if (nSrcTab < static_cast(pTabData.size())) + { + pTab = pTabData[nSrcTab]; + pTabData.erase( pTabData.begin() + nSrcTab ); + } + else + pTab = NULL; - ScViewDataTable* pTab = pTabData[nSrcTab]; - pTabData.erase( pTabData.begin() + nSrcTab ); - pTabData.insert( pTabData.begin() + nDestTab, pTab ); + if (nDestTab < static_cast(pTabData.size())) + pTabData.insert( pTabData.begin() + nDestTab, pTab ); + else + { + while (nDestTab > static_cast(pTabData.size())) + pTabData.push_back(NULL); + pTabData.push_back(pTab); + } UpdateThis(); aMarkData.DeleteTab( nSrcTab ); @@ -1380,6 +1399,8 @@ void ScViewData::GetEditView( ScSplitPos eWhich, EditView*& rViewPtr, SCCOL& rCo void ScViewData::CreateTabData( SCTAB nNewTab ) { + while(nNewTab >= static_cast(pTabData.size())) + pTabData.push_back(NULL); if (!pTabData[nNewTab]) { pTabData[nNewTab] = new ScViewDataTable; 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; -- cgit From adcc45eef14b34ca3a49bb3a86e6d4c32bcfb721 Mon Sep 17 00:00:00 2001 From: Markus Mohrhard Date: Thu, 19 May 2011 23:34:14 +0200 Subject: rework some additional parts --- sc/source/ui/app/scmod.cxx | 11 ++--------- sc/source/ui/docshell/docsh.cxx | 4 +--- 2 files changed, 3 insertions(+), 12 deletions(-) (limited to 'sc/source/ui') diff --git a/sc/source/ui/app/scmod.cxx b/sc/source/ui/app/scmod.cxx index 41ba2db31cbe..c5f48071fc47 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/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx index b7771b938286..475b4024fec2 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; } -- cgit From c70b1baac5b6b85048c894c206b8024e1eb537f3 Mon Sep 17 00:00:00 2001 From: Markus Mohrhard Date: Fri, 27 May 2011 05:16:37 +0200 Subject: 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 --- sc/source/ui/inc/undotab.hxx | 4 ++-- sc/source/ui/inc/viewfunc.hxx | 2 +- sc/source/ui/undo/undotab.cxx | 20 ++++------------ sc/source/ui/view/tabvwshf.cxx | 8 +++++-- sc/source/ui/view/viewfun2.cxx | 53 +++++++++++++----------------------------- 5 files changed, 30 insertions(+), 57 deletions(-) (limited to 'sc/source/ui') 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& newNameList); virtual ~ScUndoInsertTables(); virtual void Undo(); @@ -107,7 +107,7 @@ public: private: SdrUndoAction* pDrawUndo; - SvStrings* pNameList; + std::vector aNameList; sal_uLong nStartChangeAction; sal_uLong nEndChangeAction; SCTAB nTab; diff --git a/sc/source/ui/inc/viewfunc.hxx b/sc/source/ui/inc/viewfunc.hxx index 785b730d6945..a0914aa49899 100644 --- a/sc/source/ui/inc/viewfunc.hxx +++ b/sc/source/ui/inc/viewfunc.hxx @@ -260,7 +260,7 @@ 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& aNames, SCTAB nTab, SCTAB nCount, sal_Bool bRecord = sal_True); sal_Bool AppendTable( const String& rName, sal_Bool bRecord = sal_True ); diff --git a/sc/source/ui/undo/undotab.cxx b/sc/source/ui/undo/undotab.cxx index 97f2549711e1..a6b5b4645040 100644 --- a/sc/source/ui/undo/undotab.cxx +++ b/sc/source/ui/undo/undotab.cxx @@ -193,13 +193,13 @@ sal_Bool ScUndoInsertTab::CanRepeat(SfxRepeatTarget& rTarget) const ScUndoInsertTables::ScUndoInsertTables( ScDocShell* pNewDocShell, SCTAB nTabNum, - sal_Bool bApp,SvStrings *pNewNameList) : + sal_Bool bApp,std::vector& newNameList) : ScSimpleUndo( pNewDocShell ), pDrawUndo( NULL ), + aNameList( newNameList ), nTab( nTabNum ), bAppend( bApp ) { - pNameList = pNewNameList; pDrawUndo = GetSdrUndoAction( pDocShell->GetDocument() ); SetChangeTrack(); @@ -208,16 +208,6 @@ ScUndoInsertTables::ScUndoInsertTables( ScDocShell* pNewDocShell, ScUndoInsertTables::~ScUndoInsertTables() { String *pStr=NULL; - if(pNameList!=NULL) - { - for(int i=0;iCount();i++) - { - pStr=pNameList->GetObject(sal::static_int_cast(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( int i = 0; i < aNameList.size(); i++ ) { aRange.aStart.SetTab( sal::static_int_cast( nTab + i ) ); aRange.aEnd.SetTab( sal::static_int_cast( nTab + i ) ); @@ -255,7 +245,7 @@ void ScUndoInsertTables::Undo() bDrawIsInUndo = sal_True; vector TheTabs; - for(int i=0; iCount(); ++i) + for(int i=0; i< aNameList.size(); ++i) { TheTabs.push_back(nTab+i); } @@ -284,7 +274,7 @@ void ScUndoInsertTables::Redo() pDocShell->SetInUndo( sal_True ); //! BeginRedo bDrawIsInUndo = sal_True; pViewShell->SetTabNo(nTab); - pViewShell->InsertTables( pNameList, nTab, static_cast(pNameList->Count()),false ); + pViewShell->InsertTables( aNameList, nTab, static_cast(aNameList.size()),false ); bDrawIsInUndo = false; pDocShell->SetInUndo( false ); //! EndRedo 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 aNames(0); + InsertTables( aNames, nTabNr,nCount ); + } } else { @@ -336,7 +339,8 @@ void ScTabViewShell::ExecuteTable( SfxRequest& rReq ) } else { - InsertTables( NULL, nTabAfter,nCount); + std::vector 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& 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;iGetObject(static_cast(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;iBroadcast( 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 { -- cgit From ca9b2b5b3bb8c92bd9d901ff23f92e04e2830175 Mon Sep 17 00:00:00 2001 From: Markus Mohrhard Date: Fri, 27 May 2011 07:01:52 +0200 Subject: 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 --- 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(-) (limited to 'sc/source/ui') diff --git a/sc/source/ui/inc/uiitems.hxx b/sc/source/ui/inc/uiitems.hxx index 584b6e5dc815..f65c5a0f9542 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 31578b85945f..f09069d040c8 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 a6b5b4645040..95b524b47a1c 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( nTab + i ) ); aRange.aEnd.SetTab( sal::static_int_cast( nTab + i ) ); @@ -245,7 +244,7 @@ void ScUndoInsertTables::Undo() bDrawIsInUndo = sal_True; vector TheTabs; - for(int i=0; i< aNameList.size(); ++i) + for(SCTAB i=0; i< static_cast(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 030c26f3ef71..12abbd3f2f60 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 452dd68dba2f..17d7acde30c3 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(pTabData.size())) - pTabData.push_back(NULL); - pTabData.insert( pTabData.begin() + nTab, NULL ); + if( nTab >= static_cast(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(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 c803177f340f..a5bbae6c4fe4 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& aNames, SCTAB nTab } if (pDoc->InsertTabs(nTab, aNames, false)) { - for (SCTAB i=0;iBroadcast( ScTablesHint( SC_TAB_INSERTED, nTab+i ) ); - } + pDocSh->Broadcast( ScTablesHint( SC_TABS_INSERTED, nTab, nCount ) ); bFlag = true; } -- cgit From 4b9c570facedb799130ef6c585055d76f6d26f24 Mon Sep 17 00:00:00 2001 From: Markus Mohrhard Date: Sun, 29 May 2011 20:22:30 +0200 Subject: notify vba correctly about inserting of several worksheets --- sc/source/ui/docshell/docsh.cxx | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'sc/source/ui') diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx index 475b4024fec2..ff9d0bd1276e 100644 --- a/sc/source/ui/docshell/docsh.cxx +++ b/sc/source/ui/docshell/docsh.cxx @@ -542,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 ) ) { -- cgit From 17e4f58216020aaead24b5dcbaf6767e15e834e1 Mon Sep 17 00:00:00 2001 From: Markus Mohrhard Date: Tue, 31 May 2011 21:44:01 +0200 Subject: some minor performance improvements --- sc/source/ui/view/tabvwsh5.cxx | 1 + sc/source/ui/view/tabvwshf.cxx | 10 +--------- 2 files changed, 2 insertions(+), 9 deletions(-) (limited to 'sc/source/ui') diff --git a/sc/source/ui/view/tabvwsh5.cxx b/sc/source/ui/view/tabvwsh5.cxx index 12abbd3f2f60..4b47f9610108 100644 --- a/sc/source/ui/view/tabvwsh5.cxx +++ b/sc/source/ui/view/tabvwsh5.cxx @@ -241,6 +241,7 @@ void ScTabViewShell::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) break; case SC_TABS_INSERTED: GetViewData()->InsertTabs( nTab1, nTab2 ); + break; default: OSL_FAIL("unbekannter ScTablesHint"); } diff --git a/sc/source/ui/view/tabvwshf.cxx b/sc/source/ui/view/tabvwshf.cxx index 1f44d3147900..7e34c15b287c 100644 --- a/sc/source/ui/view/tabvwshf.cxx +++ b/sc/source/ui/view/tabvwshf.cxx @@ -308,15 +308,7 @@ void ScTabViewShell::ExecuteTable( SfxRequest& rReq ) else { SCTAB nTabAfter = nTabNr+1; - SCTAB nSelHigh=0; - - for(SCTAB i=0;i Date: Wed, 1 Jun 2011 21:37:42 +0200 Subject: we cant't check for 2*MAXTAB anymore, this is out of bounds --- sc/source/ui/view/cellsh3.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sc/source/ui') diff --git a/sc/source/ui/view/cellsh3.cxx b/sc/source/ui/view/cellsh3.cxx index 06c960a8ac0a..e6bdc02d1262 100644 --- a/sc/source/ui/view/cellsh3.cxx +++ b/sc/source/ui/view/cellsh3.cxx @@ -458,7 +458,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 ) { -- cgit From d4a8a64c218a4640e9701356aa87701d5a80589b Mon Sep 17 00:00:00 2001 From: Markus Mohrhard Date: Wed, 1 Jun 2011 21:38:53 +0200 Subject: change to SCTAB from sal_Int16 and sal_Int32 for sheet index --- sc/source/ui/vba/vbaquerytable.cxx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'sc/source/ui') 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 -- cgit From ea7fe02f4d149466bb2170b4bf0a45676936112b Mon Sep 17 00:00:00 2001 From: Markus Mohrhard Date: Fri, 3 Jun 2011 06:03:40 +0200 Subject: improve performance of ScUndoInsertTables::Undo we can now insert several sheets and then undo in nearly no time --- sc/source/ui/inc/uiitems.hxx | 1 + sc/source/ui/inc/viewdata.hxx | 1 + sc/source/ui/inc/viewfunc.hxx | 1 + sc/source/ui/undo/undotab.cxx | 8 +------- sc/source/ui/view/tabvwsh5.cxx | 7 +++++++ sc/source/ui/view/viewdata.cxx | 13 ++++++++++++ sc/source/ui/view/viewfun2.cxx | 45 +++++++++++++++++++++++++++++++++++++++++- 7 files changed, 68 insertions(+), 8 deletions(-) (limited to 'sc/source/ui') diff --git a/sc/source/ui/inc/uiitems.hxx b/sc/source/ui/inc/uiitems.hxx index f65c5a0f9542..7f71a152684e 100644 --- a/sc/source/ui/inc/uiitems.hxx +++ b/sc/source/ui/inc/uiitems.hxx @@ -93,6 +93,7 @@ public: #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/viewdata.hxx b/sc/source/ui/inc/viewdata.hxx index f09069d040c8..d0160ba2708e 100644 --- a/sc/source/ui/inc/viewdata.hxx +++ b/sc/source/ui/inc/viewdata.hxx @@ -279,6 +279,7 @@ public: 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 a0914aa49899..bfec3eee672d 100644 --- a/sc/source/ui/inc/viewfunc.hxx +++ b/sc/source/ui/inc/viewfunc.hxx @@ -267,6 +267,7 @@ public: sal_Bool DeleteTable( SCTAB nTabNr, sal_Bool bRecord = true ); sal_Bool DeleteTables(const std::vector& 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 95b524b47a1c..5d61267fd3e8 100644 --- a/sc/source/ui/undo/undotab.cxx +++ b/sc/source/ui/undo/undotab.cxx @@ -243,13 +243,7 @@ void ScUndoInsertTables::Undo() pDocShell->SetInUndo( sal_True ); //! BeginUndo bDrawIsInUndo = sal_True; - vector TheTabs; - for(SCTAB i=0; i< static_cast(aNameList.size()); ++i) - { - TheTabs.push_back(nTab+i); - } - pViewShell->DeleteTables( TheTabs, false ); - TheTabs.clear(); + pViewShell->DeleteTables( nTab, static_cast(aNameList.size()) ); bDrawIsInUndo = false; pDocShell->SetInUndo( false ); //! EndUndo diff --git a/sc/source/ui/view/tabvwsh5.cxx b/sc/source/ui/view/tabvwsh5.cxx index 4b47f9610108..1bc112d13e78 100644 --- a/sc/source/ui/view/tabvwsh5.cxx +++ b/sc/source/ui/view/tabvwsh5.cxx @@ -242,6 +242,9 @@ void ScTabViewShell::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) case SC_TABS_INSERTED: GetViewData()->InsertTabs( nTab1, nTab2 ); break; + case SC_TABS_DELETED: + GetViewData()->DeleteTabs( nTab1, nTab2 ); + break; default: OSL_FAIL("unbekannter ScTablesHint"); } @@ -289,6 +292,10 @@ void ScTabViewShell::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) 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/viewdata.cxx b/sc/source/ui/view/viewdata.cxx index 17d7acde30c3..551dffbb2b67 100644 --- a/sc/source/ui/view/viewdata.cxx +++ b/sc/source/ui/view/viewdata.cxx @@ -495,6 +495,19 @@ void ScViewData::DeleteTab( SCTAB nTab ) aMarkData.DeleteTab( nTab ); } +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(); + +} + void ScViewData::CopyTab( SCTAB nSrcTab, SCTAB nDestTab ) { if (nDestTab==SC_TAB_APPEND) diff --git a/sc/source/ui/view/viewfun2.cxx b/sc/source/ui/view/viewfun2.cxx index a5bbae6c4fe4..16402be06c35 100644 --- a/sc/source/ui/view/viewfun2.cxx +++ b/sc/source/ui/view/viewfun2.cxx @@ -2089,11 +2089,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 &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()) -- cgit From a1fd032f8b9ec6172a37b1defe6a5ac208a56dea Mon Sep 17 00:00:00 2001 From: Markus Mohrhard Date: Mon, 6 Jun 2011 22:35:01 +0200 Subject: move ScProgress out of ScDocument::MoveTab --- sc/source/ui/docshell/docsh5.cxx | 9 ++++++++- sc/source/ui/undo/undotab.cxx | 17 +++++++++++++---- 2 files changed, 21 insertions(+), 5 deletions(-) (limited to 'sc/source/ui') 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 > pSrcList(new vector(1, nSrcTab)); diff --git a/sc/source/ui/undo/undotab.cxx b/sc/source/ui/undo/undotab.cxx index 5d61267fd3e8..26d9731db0de 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 @@ -553,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) @@ -569,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; @@ -580,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) @@ -589,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 -- cgit