diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2011-07-05 00:41:08 +0200 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2011-07-05 00:44:41 +0200 |
commit | 4551eb2197ed39375978def0e1b881bd183342b9 (patch) | |
tree | e1fd2cb151ccbf34c4e248e2ae1b6297cbc18bc1 | |
parent | 1fed62c9e3f875c077b98e0282f8cf566e5b0cc8 (diff) |
change from manual loop to ScMarkData::iterator
in most situations it's much faster to use the iterator instead of the
manual loop + ScMarkData::GetTableSelect
-rw-r--r-- | sc/source/ui/view/pfuncache.cxx | 43 | ||||
-rw-r--r-- | sc/source/ui/view/spelldialog.cxx | 10 | ||||
-rw-r--r-- | sc/source/ui/view/tabvwshf.cxx | 106 | ||||
-rw-r--r-- | sc/source/ui/view/viewdata.cxx | 23 | ||||
-rw-r--r-- | sc/source/ui/view/viewfun2.cxx | 187 | ||||
-rw-r--r-- | sc/source/ui/view/viewfun3.cxx | 31 | ||||
-rw-r--r-- | sc/source/ui/view/viewfun4.cxx | 79 | ||||
-rw-r--r-- | sc/source/ui/view/viewfunc.cxx | 577 | ||||
-rw-r--r-- | sc/source/ui/view/viewutil.cxx | 28 |
9 files changed, 524 insertions, 560 deletions
diff --git a/sc/source/ui/view/pfuncache.cxx b/sc/source/ui/view/pfuncache.cxx index 25c90813136a..0c94ed3937bb 100644 --- a/sc/source/ui/view/pfuncache.cxx +++ b/sc/source/ui/view/pfuncache.cxx @@ -111,35 +111,34 @@ void ScPrintFuncCache::InitLocations( const ScMarkData& rMark, OutputDevice* pDe ScDocument* pDoc = pDocSh->GetDocument(); SCTAB nTabCount = pDoc->GetTableCount(); - for ( SCTAB nTab=0; nTab<nTabCount; nTab++ ) + ScMarkData::iterator itr = rMark.begin(), itrEnd = rMark.end(); + for (; itr != itrEnd && (*itr) < nTabCount; ++itr) { - if ( rMark.GetTableSelect( nTab ) ) - { - ScPrintFunc aFunc( pDev, pDocSh, nTab, nFirstAttr[nTab], nTotalPages, pSelRange, &aSelection.GetOptions() ); - aFunc.SetRenderFlag( sal_True ); - - long nDisplayStart = GetDisplayStart( nTab ); + SCTAB nTab = *itr; + ScPrintFunc aFunc( pDev, pDocSh, nTab, nFirstAttr[nTab], nTotalPages, pSelRange, &aSelection.GetOptions() ); + aFunc.SetRenderFlag( sal_True ); - for ( long nPage=0; nPage<nPages[nTab]; nPage++ ) - { - Range aPageRange( nRenderer+1, nRenderer+1 ); - MultiSelection aPage( aPageRange ); - aPage.SetTotalRange( Range(0,RANGE_MAX) ); - aPage.Select( aPageRange ); + long nDisplayStart = GetDisplayStart( nTab ); - ScPreviewLocationData aLocData( pDoc, pDev ); - aFunc.DoPrint( aPage, nTabStart, nDisplayStart, false, NULL, &aLocData ); + for ( long nPage=0; nPage<nPages[nTab]; nPage++ ) + { + Range aPageRange( nRenderer+1, nRenderer+1 ); + MultiSelection aPage( aPageRange ); + aPage.SetTotalRange( Range(0,RANGE_MAX) ); + aPage.Select( aPageRange ); - ScRange aCellRange; - Rectangle aPixRect; - if ( aLocData.GetMainCellRange( aCellRange, aPixRect ) ) - aLocations.push_back( ScPrintPageLocation( nRenderer, aCellRange, aPixRect ) ); + ScPreviewLocationData aLocData( pDoc, pDev ); + aFunc.DoPrint( aPage, nTabStart, nDisplayStart, false, NULL, &aLocData ); - ++nRenderer; - } + ScRange aCellRange; + Rectangle aPixRect; + if ( aLocData.GetMainCellRange( aCellRange, aPixRect ) ) + aLocations.push_back( ScPrintPageLocation( nRenderer, aCellRange, aPixRect ) ); - nTabStart += nPages[nTab]; + ++nRenderer; } + + nTabStart += nPages[nTab]; } bLocInitialized = true; diff --git a/sc/source/ui/view/spelldialog.cxx b/sc/source/ui/view/spelldialog.cxx index 25c3b859ad62..33dea9c1977c 100644 --- a/sc/source/ui/view/spelldialog.cxx +++ b/sc/source/ui/view/spelldialog.cxx @@ -237,13 +237,13 @@ void ScSpellDialogChildWindow::Init() if ( rMarkData.GetSelectCount() > 1 ) { - SCTAB nTabCount = mpDoc->GetTableCount(); - for( SCTAB nOtherTab = 0; nOtherTab < nTabCount; ++nOtherTab ) + ScMarkData::iterator itr = rMarkData.begin(), itrEnd = rMarkData.end(); + for (; itr != itrEnd; ++itr) { - if( rMarkData.GetTableSelect( nOtherTab ) && (nOtherTab != nTab) ) + if( *itr != nTab ) { - mxUndoDoc->AddUndoTab( nOtherTab, nOtherTab ); - mxRedoDoc->AddUndoTab( nOtherTab, nOtherTab ); + mxUndoDoc->AddUndoTab( *itr, *itr ); + mxRedoDoc->AddUndoTab( *itr, *itr ); } } } diff --git a/sc/source/ui/view/tabvwshf.cxx b/sc/source/ui/view/tabvwshf.cxx index 613c10d83174..876b93c7e128 100644 --- a/sc/source/ui/view/tabvwshf.cxx +++ b/sc/source/ui/view/tabvwshf.cxx @@ -634,7 +634,7 @@ void ScTabViewShell::ExecuteTable( SfxRequest& rReq ) { SCTAB nNewTab = nCurrentTab; SCTAB nFirstTab=0; - sal_Bool bTabFlag=false; + bool bTabFlag=false; ScMarkData& rMark = pViewData->GetMarkData(); std::vector<SCTAB> TheTabs; for(SCTAB i=0;i<nTabCount;i++) @@ -672,9 +672,9 @@ void ScTabViewShell::ExecuteTable( SfxRequest& rReq ) String aUndo = ScGlobal::GetRscString( STR_UNDO_TAB_RTL ); pUndoManager->EnterListAction( aUndo, aUndo ); - for (SCTAB nTab=0; nTab<nTabCount; nTab++) - if ( rMark.GetTableSelect(nTab) ) - aFunc.SetLayoutRTL( nTab, bSet, false ); + ScMarkData::iterator itr = rMark.begin(), itrEnd = rMark.end(); + for (; itr != itrEnd; ++itr) + aFunc.SetLayoutRTL( *itr, bSet, false ); pUndoManager->LeaveListAction(); } @@ -723,11 +723,12 @@ void ScTabViewShell::ExecuteTable( SfxRequest& rReq ) { scoped_ptr<ScUndoTabColorInfo::List> pTabColorList(new ScUndoTabColorInfo::List); - for (SCTAB nTab=0; nTab<nTabCount; nTab++) + ScMarkData::iterator itr = rMark.begin(), itrEnd = rMark.end(); + for (; itr != itrEnd; ++itr) { - if ( rMark.GetTableSelect(nTab) && !pDoc->IsTabProtected(nTab) ) + if ( !pDoc->IsTabProtected(*itr) ) { - ScUndoTabColorInfo aTabColorInfo(nTab); + ScUndoTabColorInfo aTabColorInfo(*itr); aTabColorInfo.maNewTabBgColor = aColor; pTabColorList->push_back(aTabColorInfo); } @@ -771,69 +772,70 @@ void ScTabViewShell::ExecuteTable( SfxRequest& rReq ) pTabColorList(new ScUndoTabColorInfo::List); if ( nTabSelCount > 1 ) { - for (SCTAB nTab=0; nTab<nTabCount; nTab++) - { - if ( rMark.GetTableSelect(nTab) && !pDoc->IsTabProtected(nTab) ) + ScMarkData::iterator itr = rMark.begin(), itrEnd = rMark.end(); + for (; itr != itrEnd; ++itr) { - ScUndoTabColorInfo aTabColorInfo(nTab); - aTabColorInfo.maNewTabBgColor = aSelectedColor; - pTabColorList->push_back(aTabColorInfo); + if ( !pDoc->IsTabProtected(*itr) ) + { + ScUndoTabColorInfo aTabColorInfo(*itr); + aTabColorInfo.maNewTabBgColor = aSelectedColor; + pTabColorList->push_back(aTabColorInfo); + } } + bDone = SetTabBgColor( *pTabColorList ); } - bDone = SetTabBgColor( *pTabColorList ); - } - else - { - bDone = SetTabBgColor( aSelectedColor, nCurrentTab ); //ScViewFunc.SetTabBgColor - } - if ( bDone ) - { - rReq.AppendItem( SvxColorItem( aTabBgColor, nSlot ) ); - rReq.Done(); - } - else - { - if( rReq.IsAPI() ) + else + { + bDone = SetTabBgColor( aSelectedColor, nCurrentTab ); //ScViewFunc.SetTabBgColor + } + if ( bDone ) { - StarBASIC::Error( SbERR_SETPROP_FAILED ); + rReq.AppendItem( SvxColorItem( aTabBgColor, nSlot ) ); + rReq.Done(); + } + else + { + if( rReq.IsAPI() ) + { + StarBASIC::Error( SbERR_SETPROP_FAILED ); + } } } } + delete( pDlg ); } - delete( pDlg ); } - } - break; + break; - case FID_TAB_EVENTS: - { - ScDocShell* pDocSh = pViewData->GetDocShell(); - uno::Reference<container::XNameReplace> xEvents( new ScSheetEventsObj( pDocSh, nCurrentTab ) ); - uno::Reference<frame::XFrame> xFrame = GetViewFrame()->GetFrame().GetFrameInterface(); - SvxAbstractDialogFactory* pDlgFactory = SvxAbstractDialogFactory::Create(); - if (pDlgFactory) + case FID_TAB_EVENTS: { - std::auto_ptr<VclAbstractDialog> pDialog( pDlgFactory->CreateSvxMacroAssignDlg( - GetDialogParent(), xFrame, false, xEvents, 0 ) ); - if ( pDialog.get() && pDialog->Execute() == RET_OK ) + ScDocShell* pDocSh = pViewData->GetDocShell(); + uno::Reference<container::XNameReplace> xEvents( new ScSheetEventsObj( pDocSh, nCurrentTab ) ); + uno::Reference<frame::XFrame> xFrame = GetViewFrame()->GetFrame().GetFrameInterface(); + SvxAbstractDialogFactory* pDlgFactory = SvxAbstractDialogFactory::Create(); + if (pDlgFactory) { - // the dialog modifies the settings directly + std::auto_ptr<VclAbstractDialog> pDialog( pDlgFactory->CreateSvxMacroAssignDlg( + GetDialogParent(), xFrame, false, xEvents, 0 ) ); + if ( pDialog.get() && pDialog->Execute() == RET_OK ) + { + // the dialog modifies the settings directly + } } } - } - break; + break; - default: - OSL_FAIL("Unbekannte Message bei ViewShell"); - break; + default: + OSL_FAIL("Unbekannte Message bei ViewShell"); + break; + } } -} -//------------------------------------------------------------------ + //------------------------------------------------------------------ -void ScTabViewShell::GetStateTable( SfxItemSet& rSet ) -{ - ScViewData* pViewData = GetViewData(); + void ScTabViewShell::GetStateTable( SfxItemSet& rSet ) + { + ScViewData* pViewData = GetViewData(); ScDocument* pDoc = pViewData->GetDocument(); ScDocShell* pDocShell = pViewData->GetDocShell(); ScMarkData& rMark = GetViewData()->GetMarkData(); diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx index 7cb1a7bb93fd..81b6b3a65b8a 100644 --- a/sc/source/ui/view/viewdata.cxx +++ b/sc/source/ui/view/viewdata.cxx @@ -591,12 +591,8 @@ void ScViewData::SetZoomType( SvxZoomType eNew, sal_Bool bAll ) std::vector< SCTAB > vTabs; // Empty for all tabs if ( !bAll ) // get selected tabs { - SCTAB nTabCount = pDoc->GetTableCount(); - for (SCTAB i=0; i<nTabCount; i++) - { - if ( aMarkData.GetTableSelect(i) ) - vTabs.push_back( i ); - } + ScMarkData::iterator itr = aMarkData.begin(), itrEnd = aMarkData.end(); + vTabs.insert(vTabs.begin(), itr, itrEnd); } SetZoomType( eNew, vTabs ); } @@ -680,12 +676,8 @@ void ScViewData::SetZoom( const Fraction& rNewX, const Fraction& rNewY, sal_Bool std::vector< SCTAB > vTabs; if ( !bAll ) // get selected tabs { - SCTAB nTabCount = pDoc->GetTableCount(); - for (SCTAB i=0; i<nTabCount; i++) - { - if ( aMarkData.GetTableSelect(i) ) - vTabs.push_back( i ); - } + ScMarkData::iterator itr = aMarkData.begin(), itrEnd = aMarkData.end(); + vTabs.insert(vTabs.begin(), itr, itrEnd); } SetZoom( rNewX, rNewY, vTabs ); } @@ -1434,10 +1426,9 @@ void ScViewData::CreateTabData( SCTAB nNewTab ) void ScViewData::CreateSelectedTabData() { - SCTAB nTabCount = aMarkData.GetLastSelected(); - for (SCTAB i=0; i<nTabCount; i++) - if ( aMarkData.GetTableSelect(i)) - CreateTabData(i); + ScMarkData::iterator itr = aMarkData.begin(), itrEnd = aMarkData.end(); + for (; itr != itrEnd; ++itr) + CreateTabData(*itr); } void ScViewData::EnsureTabDataSize(size_t nSize) diff --git a/sc/source/ui/view/viewfun2.cxx b/sc/source/ui/view/viewfun2.cxx index acbc952e74d4..ac3736d189a8 100644 --- a/sc/source/ui/view/viewfun2.cxx +++ b/sc/source/ui/view/viewfun2.cxx @@ -145,30 +145,28 @@ sal_Bool ScViewFunc::AdjustBlockHeight( sal_Bool bPaint, ScMarkData* pMarkData ) } sal_Bool bAnyChanged = false; - SCTAB nTabCount = pDoc->GetTableCount(); - for (SCTAB nTab=0; nTab<nTabCount; nTab++) - { - if (pMarkData->GetTableSelect(nTab)) - { - SCCOLROW* pOneRange = pRanges; - sal_Bool bChanged = false; - SCROW nPaintY = 0; - for (SCROW nRangeNo=0; nRangeNo<nRangeCnt; nRangeNo++) + ScMarkData::iterator itr = pMarkData->begin(), itrEnd = pMarkData->end(); + for (; itr != itrEnd; ++itr) + { + SCTAB nTab = *itr; + SCCOLROW* pOneRange = pRanges; + sal_Bool bChanged = false; + SCROW nPaintY = 0; + for (SCROW nRangeNo=0; nRangeNo<nRangeCnt; nRangeNo++) + { + SCROW nStartNo = *(pOneRange++); + SCROW nEndNo = *(pOneRange++); + if (pDoc->SetOptimalHeight( nStartNo, nEndNo, nTab, 0, aProv.GetDevice(), + nPPTX, nPPTY, aZoomX, aZoomY, false )) { - SCROW nStartNo = *(pOneRange++); - SCROW nEndNo = *(pOneRange++); - if (pDoc->SetOptimalHeight( nStartNo, nEndNo, nTab, 0, aProv.GetDevice(), - nPPTX, nPPTY, aZoomX, aZoomY, false )) - { - if (!bChanged) - nPaintY = nStartNo; - bAnyChanged = bChanged = sal_True; - } + if (!bChanged) + nPaintY = nStartNo; + bAnyChanged = bChanged = sal_True; } - if ( bPaint && bChanged ) - pDocSh->PostPaint( 0, nPaintY, nTab, MAXCOL, MAXROW, nTab, - PAINT_GRID | PAINT_LEFT ); } + if ( bPaint && bChanged ) + pDocSh->PostPaint( 0, nPaintY, nTab, MAXCOL, MAXROW, nTab, + PAINT_GRID | PAINT_LEFT ); } delete[] pRanges; @@ -953,7 +951,6 @@ void ScViewFunc::SetPrintRanges( sal_Bool bEntireSheet, const String* pPrint, ScDocShell* pDocSh = GetViewData()->GetDocShell(); ScDocument* pDoc = pDocSh->GetDocument(); - SCTAB nTabCount = pDoc->GetTableCount(); ScMarkData& rMark = GetViewData()->GetMarkData(); SCTAB nTab; sal_Bool bUndo (pDoc->IsUndoEnabled()); @@ -962,75 +959,76 @@ void ScViewFunc::SetPrintRanges( sal_Bool bEntireSheet, const String* pPrint, ScAddress::Details aDetails(pDoc->GetAddressConvention(), 0, 0); - for (nTab=0; nTab<nTabCount; nTab++) - if (rMark.GetTableSelect(nTab)) - { - ScRange aRange( 0,0,nTab ); + ScMarkData::iterator itr = rMark.begin(), itrEnd = rMark.end(); + for (; itr != itrEnd; ++itr) + { + nTab = *itr; + ScRange aRange( 0,0,nTab ); - // print ranges + // print ranges - if( !bAddPrint ) - pDoc->ClearPrintRanges( nTab ); + if( !bAddPrint ) + pDoc->ClearPrintRanges( nTab ); - if( bEntireSheet ) - { - pDoc->SetPrintEntireSheet( nTab ); - } - else if ( pPrint ) + if( bEntireSheet ) + { + pDoc->SetPrintEntireSheet( nTab ); + } + else if ( pPrint ) + { + if ( pPrint->Len() ) { - if ( pPrint->Len() ) + const sal_Unicode sep = ScCompiler::GetNativeSymbol(ocSep).GetChar(0); + sal_uInt16 nTCount = pPrint->GetTokenCount(sep); + for (sal_uInt16 i=0; i<nTCount; i++) { - const sal_Unicode sep = ScCompiler::GetNativeSymbol(ocSep).GetChar(0); - sal_uInt16 nTCount = pPrint->GetTokenCount(sep); - for (sal_uInt16 i=0; i<nTCount; i++) - { - String aToken = pPrint->GetToken(i, sep); - if ( aRange.ParseAny( aToken, pDoc, aDetails ) & SCA_VALID ) - pDoc->AddPrintRange( nTab, aRange ); - } + String aToken = pPrint->GetToken(i, sep); + if ( aRange.ParseAny( aToken, pDoc, aDetails ) & SCA_VALID ) + pDoc->AddPrintRange( nTab, aRange ); } } - else // NULL = use selection (print range is always set), use empty string to delete all ranges + } + else // NULL = use selection (print range is always set), use empty string to delete all ranges + { + if ( GetViewData()->GetSimpleArea( aRange ) == SC_MARK_SIMPLE ) { - if ( GetViewData()->GetSimpleArea( aRange ) == SC_MARK_SIMPLE ) - { - pDoc->AddPrintRange( nTab, aRange ); - } - else if ( rMark.IsMultiMarked() ) + pDoc->AddPrintRange( nTab, aRange ); + } + else if ( rMark.IsMultiMarked() ) + { + rMark.MarkToMulti(); + ScRangeListRef pList( new ScRangeList ); + rMark.FillRangeListWithMarks( pList, false ); + for (size_t i = 0, n = pList->size(); i < n; ++i) { - rMark.MarkToMulti(); - ScRangeListRef pList( new ScRangeList ); - rMark.FillRangeListWithMarks( pList, false ); - for (size_t i = 0, n = pList->size(); i < n; ++i) - { - ScRange* pR = (*pList)[i]; - pDoc->AddPrintRange(nTab, *pR); - } + ScRange* pR = (*pList)[i]; + pDoc->AddPrintRange(nTab, *pR); } } + } - // repeat columns + // repeat columns - if ( pRepCol ) - { - if ( !pRepCol->Len() ) - pDoc->SetRepeatColRange( nTab, NULL ); - else - if ( aRange.ParseAny( *pRepCol, pDoc, aDetails ) & SCA_VALID ) - pDoc->SetRepeatColRange( nTab, &aRange ); - } + if ( pRepCol ) + { + if ( !pRepCol->Len() ) + pDoc->SetRepeatColRange( nTab, NULL ); + else + if ( aRange.ParseAny( *pRepCol, pDoc, aDetails ) & SCA_VALID ) + pDoc->SetRepeatColRange( nTab, &aRange ); + } - // repeat rows + // repeat rows - if ( pRepRow ) - { - if ( !pRepRow->Len() ) - pDoc->SetRepeatRowRange( nTab, NULL ); - else - if ( aRange.ParseAny( *pRepRow, pDoc, aDetails ) & SCA_VALID ) - pDoc->SetRepeatRowRange( nTab, &aRange ); - } + if ( pRepRow ) + { + if ( !pRepRow->Len() ) + pDoc->SetRepeatRowRange( nTab, NULL ); + else + if ( aRange.ParseAny( *pRepRow, pDoc, aDetails ) & SCA_VALID ) + pDoc->SetRepeatRowRange( nTab, &aRange ); } + } // undo (for all tables) if (bUndo) @@ -1043,9 +1041,9 @@ void ScViewFunc::SetPrintRanges( sal_Bool bEntireSheet, const String* pPrint, // update page breaks - for (nTab=0; nTab<nTabCount; nTab++) - if (rMark.GetTableSelect(nTab)) - ScPrintFunc( pDocSh, pDocSh->GetPrinter(), nTab ).UpdatePages(); + itr = rMark.begin(); + for (; itr != itrEnd; ++itr) + ScPrintFunc( pDocSh, pDocSh->GetPrinter(), *itr ).UpdatePages(); SfxBindings& rBindings = GetViewData()->GetBindings(); rBindings.Invalidate( SID_DELETE_PRINTAREA ); @@ -1118,14 +1116,11 @@ sal_Bool ScViewFunc::MergeCells( sal_Bool bApi, sal_Bool& rDoContents, sal_Bool // Check for the contents of all selected tables. bool bAskDialog = false; - SCTAB nTabCount = pDoc->GetTableCount(); ScCellMergeOption aMergeOption(nStartCol, nStartRow, nEndCol, nEndRow, bCenter); - for (SCTAB i = 0; i < nTabCount; ++i) + ScMarkData::iterator itr = rMark.begin(), itrEnd = rMark.end(); + for (; itr != itrEnd; ++itr) { - if (!rMark.GetTableSelect(i)) - // this table is not selected. - continue; - + SCTAB i = *itr; aMergeOption.maTabs.insert(i); if (!pDoc->IsBlockEmpty(i, nStartCol, nStartRow+1, nStartCol, nEndRow) || @@ -1233,18 +1228,15 @@ sal_Bool ScViewFunc::RemoveMerge( sal_Bool bRecord ) pDoc->ExtendMerge( aExtended ); ScDocShell* pDocSh = GetViewData()->GetDocShell(); const ScMarkData& rMark = GetViewData()->GetMarkData(); - SCTAB nTabCount = pDoc->GetTableCount(); ScCellMergeOption aOption(aRange.aStart.Col(), aRange.aStart.Row(), aRange.aEnd.Col(), aRange.aEnd.Row()); bool bExtended = false; do { bExtended = false; - for (SCTAB i = 0; i < nTabCount; ++i) + ScMarkData::iterator itr = rMark.begin(), itrEnd = rMark.end(); + for (; itr != itrEnd; ++itr) { - if (!rMark.GetTableSelect(i)) - // This table is not selected. - continue; - + SCTAB i = *itr; aOption.maTabs.insert(i); aExtended.aStart.SetTab(i); aExtended.aEnd.SetTab(i); @@ -1415,10 +1407,11 @@ void ScViewFunc::FillTab( sal_uInt16 nFlags, sal_uInt16 nFunction, sal_Bool bSki pUndoDoc = new ScDocument( SCDOCMODE_UNDO ); pUndoDoc->InitUndo( pDoc, nTab, nTab ); - SCTAB nTabCount = pDoc->GetTableCount(); - for (SCTAB i=0; i<nTabCount; i++) - if (i != nTab && rMark.GetTableSelect(i)) + ScMarkData::iterator itr = rMark.begin(), itrEnd = rMark.end(); + for (; itr != itrEnd; ++itr) + if (*itr != nTab ) { + SCTAB i = *itr; pUndoDoc->AddUndoTab( i, i ); aMarkRange.aStart.SetTab( i ); aMarkRange.aEnd.SetTab( i ); @@ -1624,12 +1617,8 @@ void ScViewFunc::SearchAndReplace( const SvxSearchItem* pSearchItem, } else { //! at least one is always selected - nStartTab = nEndTab = rMark.GetFirstSelected(); - for ( SCTAB j = nStartTab + 1; j <= nLastTab; j++ ) - { - if ( rMark.GetTableSelect( j ) ) - nEndTab = j; - } + nStartTab = rMark.GetFirstSelected(); + nEndTab = rMark.GetLastSelected(); } if ( nCommand == SVX_SEARCHCMD_FIND diff --git a/sc/source/ui/view/viewfun3.cxx b/sc/source/ui/view/viewfun3.cxx index c8d9123e667a..6c936573147c 100644 --- a/sc/source/ui/view/viewfun3.cxx +++ b/sc/source/ui/view/viewfun3.cxx @@ -924,9 +924,9 @@ sal_Bool ScViewFunc::PasteOnDrawObject( const uno::Reference<datatransfer::XTran sal_Bool lcl_SelHasAttrib( ScDocument* pDoc, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, const ScMarkData& rTabSelection, sal_uInt16 nMask ) { - SCTAB nTabCount = pDoc->GetTableCount(); - for (SCTAB nTab=0; nTab<nTabCount; nTab++) - if ( rTabSelection.GetTableSelect(nTab) && pDoc->HasAttrib( nCol1, nRow1, nTab, nCol2, nRow2, nTab, nMask ) ) + ScMarkData::iterator itr = rTabSelection.begin(), itrEnd = rTabSelection.end(); + for (; itr != itrEnd; ++itr) + if ( pDoc->HasAttrib( nCol1, nRow1, *itr, nCol2, nRow2, *itr, nMask ) ) return sal_True; return false; } @@ -959,13 +959,10 @@ private: bool lcl_checkDestRangeForOverwrite(const ScRange& rDestRange, const ScDocument* pDoc, const ScMarkData& rMark, Window* pParentWnd) { bool bIsEmpty = true; - SCTAB nTabCount = pDoc->GetTableCount(); - for (SCTAB nTab=0; nTab < nTabCount && bIsEmpty; ++nTab) + ScMarkData::iterator itr = rMark.begin(), itrEnd = rMark.end(); + for (; itr != itrEnd && bIsEmpty; ++itr) { - if (!rMark.GetTableSelect(nTab)) - continue; - - bIsEmpty = pDoc->IsBlockEmpty(nTab, rDestRange.aStart.Col(), rDestRange.aStart.Row(), + bIsEmpty = pDoc->IsBlockEmpty(*itr, rDestRange.aStart.Col(), rDestRange.aStart.Row(), rDestRange.aEnd.Col(), rDestRange.aEnd.Row()); } @@ -1732,7 +1729,6 @@ void ScViewFunc::PostPasteFromClip(const ScRange& rPasteRange, const ScMarkData& { ScViewData* pViewData = GetViewData(); ScDocShell* pDocSh = pViewData->GetDocShell(); - ScDocument* pDoc = pViewData->GetDocument(); pDocSh->UpdateOle(pViewData); SelectionChanged(); @@ -1742,16 +1738,13 @@ void ScViewFunc::PostPasteFromClip(const ScRange& rPasteRange, const ScMarkData& if ( pModelObj && pModelObj->HasChangesListeners() ) { ScRangeList aChangeRanges; - SCTAB nTabCount = pDoc->GetTableCount(); - for ( SCTAB i = 0; i < nTabCount; ++i ) + ScMarkData::iterator itr = rMark.begin(), itrEnd = rMark.end(); + for (; itr != itrEnd; ++itr) { - if ( rMark.GetTableSelect( i ) ) - { - ScRange aChangeRange(rPasteRange); - aChangeRange.aStart.SetTab( i ); - aChangeRange.aEnd.SetTab( i ); - aChangeRanges.Append( aChangeRange ); - } + ScRange aChangeRange(rPasteRange); + aChangeRange.aStart.SetTab( *itr ); + aChangeRange.aEnd.SetTab( *itr ); + aChangeRanges.Append( aChangeRange ); } pModelObj->NotifyChanges( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "cell-change" ) ), aChangeRanges ); } diff --git a/sc/source/ui/view/viewfun4.cxx b/sc/source/ui/view/viewfun4.cxx index 17523bcab9d3..e0e4ee3bd537 100644 --- a/sc/source/ui/view/viewfun4.cxx +++ b/sc/source/ui/view/viewfun4.cxx @@ -227,9 +227,10 @@ void ScViewFunc::DoRefConversion( sal_Bool bRecord ) if ( rMark.GetSelectCount() > 1 ) { - for (SCTAB i=0; i<nTabCount; i++) - if ( rMark.GetTableSelect(i) && i != nTab ) - pUndoDoc->AddUndoTab( i, i ); + ScMarkData::iterator itr = rMark.begin(), itrEnd = rMark.end(); + for (; itr != itrEnd; ++itr) + if ( *itr != nTab ) + pUndoDoc->AddUndoTab( *itr, *itr ); } ScRange aCopyRange = aMarkRange; aCopyRange.aStart.SetTab(0); @@ -241,41 +242,40 @@ void ScViewFunc::DoRefConversion( sal_Bool bRecord ) GetViewData()->GetMultiArea( xRanges ); size_t nCount = xRanges->size(); - for (SCTAB i=0; i<nTabCount; i++) + ScMarkData::iterator itr = rMark.begin(), itrEnd = rMark.end(); + for (; itr != itrEnd; ++itr) { - if (rMark.GetTableSelect(i)) + SCTAB i = *itr; + for (size_t j = 0; j < nCount; ++j) { - for (size_t j = 0; j < nCount; ++j) + ScRange aRange = *(*xRanges)[j]; + aRange.aStart.SetTab(i); + aRange.aEnd.SetTab(i); + ScCellIterator aIter( pDoc, aRange ); + ScBaseCell* pCell = aIter.GetFirst(); + while ( pCell ) { - ScRange aRange = *(*xRanges)[j]; - aRange.aStart.SetTab(i); - aRange.aEnd.SetTab(i); - ScCellIterator aIter( pDoc, aRange ); - ScBaseCell* pCell = aIter.GetFirst(); - while ( pCell ) + if (pCell->GetCellType() == CELLTYPE_FORMULA) { - if (pCell->GetCellType() == CELLTYPE_FORMULA) + String aOld; + ((ScFormulaCell*)pCell)->GetFormula(aOld); + xub_StrLen nLen = aOld.Len(); + ScRefFinder aFinder( aOld, aIter.GetPos(), pDoc, pDoc->GetAddressConvention() ); + aFinder.ToggleRel( 0, nLen ); + if (aFinder.GetFound()) { - String aOld; - ((ScFormulaCell*)pCell)->GetFormula(aOld); - xub_StrLen nLen = aOld.Len(); - ScRefFinder aFinder( aOld, aIter.GetPos(), pDoc, pDoc->GetAddressConvention() ); - aFinder.ToggleRel( 0, nLen ); - if (aFinder.GetFound()) - { - ScAddress aPos = ((ScFormulaCell*)pCell)->aPos; - String aNew = aFinder.GetText(); - ScCompiler aComp( pDoc, aPos); - aComp.SetGrammar(pDoc->GetGrammar()); - ScTokenArray* pArr = aComp.CompileString( aNew ); - ScFormulaCell* pNewCell = new ScFormulaCell( pDoc, aPos, - pArr,formula::FormulaGrammar::GRAM_DEFAULT, MM_NONE ); - pDoc->PutCell( aPos, pNewCell ); - bOk = sal_True; - } + ScAddress aPos = ((ScFormulaCell*)pCell)->aPos; + String aNew = aFinder.GetText(); + ScCompiler aComp( pDoc, aPos); + aComp.SetGrammar(pDoc->GetGrammar()); + ScTokenArray* pArr = aComp.CompileString( aNew ); + ScFormulaCell* pNewCell = new ScFormulaCell( pDoc, aPos, + pArr,formula::FormulaGrammar::GRAM_DEFAULT, MM_NONE ); + pDoc->PutCell( aPos, pNewCell ); + bOk = sal_True; } - pCell = aIter.GetNext(); } + pCell = aIter.GetNext(); } } } @@ -287,9 +287,10 @@ void ScViewFunc::DoRefConversion( sal_Bool bRecord ) if ( rMark.GetSelectCount() > 1 ) { - for (SCTAB i=0; i<nTabCount; i++) - if ( rMark.GetTableSelect(i) && i != nTab ) - pRedoDoc->AddUndoTab( i, i ); + itr = rMark.begin(); + for (; itr != itrEnd; ++itr) + if ( *itr != nTab ) + pRedoDoc->AddUndoTab( *itr, *itr ); } ScRange aCopyRange = aMarkRange; aCopyRange.aStart.SetTab(0); @@ -518,12 +519,12 @@ void ScViewFunc::DoSheetConversion( const ScConversionParam& rConvParam, sal_Boo if ( rMark.GetSelectCount() > 1 ) { - SCTAB nTabCount = pDoc->GetTableCount(); - for (SCTAB i=0; i<nTabCount; i++) - if ( rMark.GetTableSelect(i) && i != nTab ) + ScMarkData::iterator itr = rMark.begin(), itrEnd = rMark.end(); + for (; itr != itrEnd; ++itr) + if ( *itr != nTab ) { - pUndoDoc->AddUndoTab( i, i ); - pRedoDoc->AddUndoTab( i, i ); + pUndoDoc->AddUndoTab( *itr, *itr ); + pRedoDoc->AddUndoTab( *itr, *itr ); } } } diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx index 2f02565f0d0c..8e49287fb3be 100644 --- a/sc/source/ui/view/viewfunc.cxx +++ b/sc/source/ui/view/viewfunc.cxx @@ -360,7 +360,6 @@ void ScViewFunc::EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab, const String& rS { ScDocument* pDoc = GetViewData()->GetDocument(); ScMarkData& rMark = GetViewData()->GetMarkData(); - SCTAB nTabCount = pDoc->GetTableCount(); SCTAB nSelCount = rMark.GetSelectCount(); SCTAB i; if (bRecord && !pDoc->IsUndoEnabled()) @@ -389,42 +388,43 @@ void ScViewFunc::EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab, const String& rS pTabs = new SCTAB[nSelCount]; nUndoPos = 0; - for (i=0; i<nTabCount; i++) - if (rMark.GetTableSelect(i)) + ScMarkData::iterator itr = rMark.begin(), itrEnd = rMark.end(); + for (; itr != itrEnd; ++itr) + { + i = *itr; + pTabs[nUndoPos] = i; + ScBaseCell* pDocCell; + pDoc->GetCell( nCol, nRow, i, pDocCell ); + if ( pDocCell ) { - pTabs[nUndoPos] = i; - ScBaseCell* pDocCell; - pDoc->GetCell( nCol, nRow, i, pDocCell ); - if ( pDocCell ) - { - ppOldCells[nUndoPos] = pDocCell->CloneWithoutNote( *pDoc ); - if ( pDocCell->GetCellType() == CELLTYPE_EDIT ) - bEditDeleted = sal_True; - - sal_uInt8 nDocScript = pDoc->GetScriptType( nCol, nRow, i, pDocCell ); - if ( nOldScript == 0 ) - nOldScript = nDocScript; - else if ( nDocScript != nOldScript ) - bEditDeleted = sal_True; - } - else - { - ppOldCells[nUndoPos] = NULL; - } - - const SfxPoolItem* pItem; - const ScPatternAttr* pPattern = pDoc->GetPattern(nCol, nRow, i); - if ( SFX_ITEM_SET == pPattern->GetItemSet().GetItemState( - ATTR_VALUE_FORMAT,false,&pItem) ) - { - pHasFormat[nUndoPos] = sal_True; - pOldFormats[nUndoPos] = ((const SfxUInt32Item*)pItem)->GetValue(); - } - else - pHasFormat[nUndoPos] = false; + ppOldCells[nUndoPos] = pDocCell->CloneWithoutNote( *pDoc ); + if ( pDocCell->GetCellType() == CELLTYPE_EDIT ) + bEditDeleted = sal_True; + + sal_uInt8 nDocScript = pDoc->GetScriptType( nCol, nRow, i, pDocCell ); + if ( nOldScript == 0 ) + nOldScript = nDocScript; + else if ( nDocScript != nOldScript ) + bEditDeleted = sal_True; + } + else + { + ppOldCells[nUndoPos] = NULL; + } - ++nUndoPos; + const SfxPoolItem* pItem; + const ScPatternAttr* pPattern = pDoc->GetPattern(nCol, nRow, i); + if ( SFX_ITEM_SET == pPattern->GetItemSet().GetItemState( + ATTR_VALUE_FORMAT,false,&pItem) ) + { + pHasFormat[nUndoPos] = sal_True; + pOldFormats[nUndoPos] = ((const SfxUInt32Item*)pItem)->GetValue(); } + else + pHasFormat[nUndoPos] = false; + + ++nUndoPos; + } OSL_ENSURE( nUndoPos==nSelCount, "nUndoPos!=nSelCount" ); @@ -472,9 +472,7 @@ void ScViewFunc::EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab, const String& rS sal_Bool bNumFmtChanged = false; if ( bFormula ) { // Formel, compile mit AutoCorrection - for (i=0; i<nTabCount; i++) - if (rMark.GetTableSelect(i)) - break; + i = rMark.GetFirstSelected(); ScAddress aPos( nCol, nRow, i ); ScCompiler aComp( pDoc, aPos); aComp.SetGrammar(pDoc->GetGrammar()); @@ -585,63 +583,61 @@ void ScViewFunc::EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab, const String& rS delete pArr; sal_Bool bAutoCalc = pDoc->GetAutoCalc(); SvNumberFormatter* pFormatter = pDoc->GetFormatTable(); - for ( ; i<nTabCount; i++) + ScMarkData::iterator itr = rMark.begin(), itrEnd = rMark.end(); + for (; itr != itrEnd; ++itr) { - if (rMark.GetTableSelect(i)) + i = *itr; + aPos.SetTab( i ); + sal_uLong nIndex = (sal_uLong) ((SfxUInt32Item*) pDoc->GetAttr( + nCol, nRow, i, ATTR_VALUE_FORMAT ))->GetValue(); + if ( pFormatter->GetType( nIndex ) == NUMBERFORMAT_TEXT || + ( ( rString.GetChar(0) == '+' || rString.GetChar(0) == '-' ) && nError && rString.Equals( aFormula ) ) ) { - aPos.SetTab( i ); - sal_uLong nIndex = (sal_uLong) ((SfxUInt32Item*) pDoc->GetAttr( - nCol, nRow, i, ATTR_VALUE_FORMAT ))->GetValue(); - if ( pFormatter->GetType( nIndex ) == NUMBERFORMAT_TEXT || - ( ( rString.GetChar(0) == '+' || rString.GetChar(0) == '-' ) && nError && rString.Equals( aFormula ) ) ) + if ( pData ) { - if ( pData ) - { - ScEditCell* pCell = new ScEditCell( pData, pDoc, NULL ); - pDoc->PutCell( aPos, pCell ); - } - else - { - ScStringCell* pCell = new ScStringCell( aFormula ); - pDoc->PutCell( aPos, pCell ); - } + ScEditCell* pCell = new ScEditCell( pData, pDoc, NULL ); + pDoc->PutCell( aPos, pCell ); } else { - DELETEZ(pUndoData); - ScFormulaCell* pCell = new ScFormulaCell( aCell, *pDoc, aPos ); - if ( nError ) - { - pCell->GetCode()->DelRPN(); - pCell->SetErrCode( nError ); - if(pCell->GetCode()->IsHyperLink()) - pCell->GetCode()->SetHyperLink(false); - } + ScStringCell* pCell = new ScStringCell( aFormula ); pDoc->PutCell( aPos, pCell ); - if ( !bAutoCalc ) - { // einmal nur die Zelle berechnen und wieder dirty setzen - pCell->Interpret(); - pCell->SetDirtyVar(); - pDoc->PutInFormulaTree( pCell ); - } } - + } + else + { + DELETEZ(pUndoData); + ScFormulaCell* pCell = new ScFormulaCell( aCell, *pDoc, aPos ); + if ( nError ) + { + pCell->GetCode()->DelRPN(); + pCell->SetErrCode( nError ); + if(pCell->GetCode()->IsHyperLink()) + pCell->GetCode()->SetHyperLink(false); + } + pDoc->PutCell( aPos, pCell ); + if ( !bAutoCalc ) + { // einmal nur die Zelle berechnen und wieder dirty setzen + pCell->Interpret(); + pCell->SetDirtyVar(); + pDoc->PutInFormulaTree( pCell ); + } } } } else { - for (i=0; i<nTabCount; i++) - if (rMark.GetTableSelect(i)) - if (pDoc->SetString( nCol, nRow, i, rString )) - bNumFmtChanged = sal_True; + ScMarkData::iterator itr = rMark.begin(), itrEnd = rMark.end(); + for (; itr != itrEnd; ++itr) + if (pDoc->SetString( nCol, nRow, *itr, rString )) + bNumFmtChanged = true; } // row height must be changed if new text has a different script type - for (i=0; i<nTabCount && !bEditDeleted; i++) - if (rMark.GetTableSelect(i)) - if ( pDoc->GetScriptType( nCol, nRow, i ) != nOldScript ) - bEditDeleted = sal_True; + ScMarkData::iterator itr = rMark.begin(), itrEnd = rMark.end(); + for (; itr != itrEnd && !bEditDeleted; ++itr) + if ( pDoc->GetScriptType( nCol, nRow, *itr ) != nOldScript ) + bEditDeleted = true; HideAllCursors(); @@ -660,9 +656,9 @@ void ScViewFunc::EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab, const String& rS rString, pUndoData ) ); } - for (i=0; i<nTabCount; i++) - if (rMark.GetTableSelect(i)) - pDocSh->PostPaintCell( nCol, nRow, i ); + itr = rMark.begin(); + for (; itr != itrEnd; ++itr) + pDocSh->PostPaintCell( nCol, nRow, *itr ); ShowAllCursors(); @@ -673,12 +669,10 @@ void ScViewFunc::EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab, const String& rS if ( pModelObj && pModelObj->HasChangesListeners() ) { ScRangeList aChangeRanges; - for ( i = 0; i < nTabCount; ++i ) + itr = rMark.begin(); + for (; itr != itrEnd; ++itr) { - if ( rMark.GetTableSelect( i ) ) - { - aChangeRanges.Append( ScRange( nCol, nRow, i ) ); - } + aChangeRanges.Append( ScRange( nCol, nRow, *itr ) ); } pModelObj->NotifyChanges( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "cell-change" ) ), aChangeRanges ); } @@ -793,9 +787,7 @@ void ScViewFunc::EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab, const EditTextOb // Undo // - SCTAB nTabCount = pDoc->GetTableCount(); SCTAB nSelCount = rMark.GetSelectCount(); - SCTAB i; ScBaseCell** ppOldCells = NULL; SCTAB* pTabs = NULL; SCTAB nPos = 0; @@ -806,15 +798,15 @@ void ScViewFunc::EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab, const EditTextOb pTabs = new SCTAB[nSelCount]; nPos = 0; - for (i=0; i<nTabCount; i++) - if (rMark.GetTableSelect(i)) - { - pTabs[nPos] = i; - ScBaseCell* pDocCell; - pDoc->GetCell( nCol, nRow, i, pDocCell ); - ppOldCells[nPos] = pDocCell ? pDocCell->CloneWithoutNote( *pDoc ) : 0; - ++nPos; - } + ScMarkData::iterator itr = rMark.begin(), itrEnd = rMark.end(); + for (; itr != itrEnd; ++itr) + { + pTabs[nPos] = *itr; + ScBaseCell* pDocCell; + pDoc->GetCell( nCol, nRow, *itr, pDocCell ); + ppOldCells[nPos] = pDocCell ? pDocCell->CloneWithoutNote( *pDoc ) : 0; + ++nPos; + } OSL_ENSURE( nPos==nSelCount, "nPos!=nSelCount" ); @@ -837,9 +829,9 @@ void ScViewFunc::EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab, const EditTextOb } else { - for (i=0; i<nTabCount; i++) - if (rMark.GetTableSelect(i)) - pDoc->PutCell( nCol, nRow, i, new ScEditCell( pData, pDoc, NULL ) ); + ScMarkData::iterator itr = rMark.begin(), itrEnd = rMark.end(); + for (; itr != itrEnd; ++itr) + pDoc->PutCell( nCol, nRow, *itr, new ScEditCell( pData, pDoc, NULL ) ); if ( bRecord ) { // wg. ChangeTrack erst jetzt @@ -853,9 +845,9 @@ void ScViewFunc::EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab, const EditTextOb AdjustRowHeight(nRow,nRow); - for (i=0; i<nTabCount; i++) - if (rMark.GetTableSelect(i)) - pDocSh->PostPaintCell( nCol, nRow, i ); + itr = rMark.begin(); + for (; itr != itrEnd; ++itr) + pDocSh->PostPaintCell( nCol, nRow, *itr ); ShowAllCursors(); @@ -866,12 +858,10 @@ void ScViewFunc::EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab, const EditTextOb if ( pModelObj && pModelObj->HasChangesListeners() ) { ScRangeList aChangeRanges; - for ( i = 0; i < nTabCount; ++i ) + itr = rMark.begin(); + for (; itr != itrEnd; ++itr) { - if ( rMark.GetTableSelect( i ) ) - { - aChangeRanges.Append( ScRange( nCol, nRow, i ) ); - } + aChangeRanges.Append( ScRange( nCol, nRow, *itr ) ); } pModelObj->NotifyChanges( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "cell-change" ) ), aChangeRanges ); } @@ -1220,9 +1210,10 @@ void ScViewFunc::ApplyPatternLines( const ScPatternAttr& rAttr, const SvxBoxItem SCTAB nStartTab = aMarkRange.aStart.Tab(); SCTAB nTabCount = pDoc->GetTableCount(); pUndoDoc->InitUndo( pDoc, nStartTab, nStartTab ); - for (SCTAB i=0; i<nTabCount; i++) - if (i != nStartTab && aFuncMark.GetTableSelect(i)) - pUndoDoc->AddUndoTab( i, i ); + ScMarkData::iterator itr = aFuncMark.begin(), itrEnd = aFuncMark.end(); + for (; itr != itrEnd; ++itr) + if (*itr != nStartTab) + pUndoDoc->AddUndoTab( *itr, *itr ); ScRange aCopyRange = aMarkRange; aCopyRange.aStart.SetTab(0); @@ -1305,15 +1296,13 @@ void ScViewFunc::ApplySelectionPattern( const ScPatternAttr& rAttr, ScRange aMarkRange; aFuncMark.GetMultiMarkArea( aMarkRange ); SCTAB nTabCount = pDoc->GetTableCount(); - for ( SCTAB i = 0; i < nTabCount; ++i ) + ScMarkData::iterator itr = aFuncMark.begin(), itrEnd = aFuncMark.end(); + for (; itr != itrEnd; ++itr) { - if ( aFuncMark.GetTableSelect( i ) ) - { - ScRange aChangeRange( aMarkRange ); - aChangeRange.aStart.SetTab( i ); - aChangeRange.aEnd.SetTab( i ); - aChangeRanges.Append( aChangeRange ); - } + ScRange aChangeRange( aMarkRange ); + aChangeRange.aStart.SetTab( *itr ); + aChangeRange.aEnd.SetTab( *itr ); + aChangeRanges.Append( aChangeRange ); } SCCOL nStartCol = aMarkRange.aStart.Col(); @@ -1333,9 +1322,10 @@ void ScViewFunc::ApplySelectionPattern( const ScPatternAttr& rAttr, ScDocument* pUndoDoc = new ScDocument( SCDOCMODE_UNDO ); pUndoDoc->InitUndo( pDoc, nStartTab, nStartTab ); - for (SCTAB i=0; i<nTabCount; i++) - if (i != nStartTab && aFuncMark.GetTableSelect(i)) - pUndoDoc->AddUndoTab( i, i ); + itr = aFuncMark.begin(); + for (; itr != itrEnd; ++itr) + if (*itr != nStartTab) + pUndoDoc->AddUndoTab( *itr, *itr ); pDoc->CopyToDocument( aCopyRange, IDF_ATTRIB, bMulti, pUndoDoc, &aFuncMark ); aFuncMark.MarkToMulti(); @@ -1505,9 +1495,10 @@ void ScViewFunc::SetStyleSheetToMarked( SfxStyleSheet* pStyleSheet, sal_Bool bRe SCTAB nTab = pViewData->GetTabNo(); ScDocument* pUndoDoc = new ScDocument( SCDOCMODE_UNDO ); pUndoDoc->InitUndo( pDoc, nTab, nTab ); - for (SCTAB i=0; i<nTabCount; i++) - if (i != nTab && aFuncMark.GetTableSelect(i)) - pUndoDoc->AddUndoTab( i, i ); + ScMarkData::iterator itr = aFuncMark.begin(), itrEnd = aFuncMark.end(); + for (; itr != itrEnd; ++itr) + if (*itr != nTab) + pUndoDoc->AddUndoTab( *itr, *itr ); ScRange aCopyRange = aMarkRange; aCopyRange.aStart.SetTab(0); @@ -1537,9 +1528,10 @@ void ScViewFunc::SetStyleSheetToMarked( SfxStyleSheet* pStyleSheet, sal_Bool bRe { ScDocument* pUndoDoc = new ScDocument( SCDOCMODE_UNDO ); pUndoDoc->InitUndo( pDoc, nTab, nTab ); - for (SCTAB i=0; i<nTabCount; i++) - if (i != nTab && aFuncMark.GetTableSelect(i)) - pUndoDoc->AddUndoTab( i, i ); + ScMarkData::iterator itr = aFuncMark.begin(), itrEnd = aFuncMark.end(); + for (; itr != itrEnd; ++itr) + if (*itr != nTab) + pUndoDoc->AddUndoTab( *itr, *itr ); ScRange aCopyRange( nCol, nRow, 0, nCol, nRow, nTabCount-1 ); pDoc->CopyToDocument( aCopyRange, IDF_ATTRIB, false, pUndoDoc ); @@ -1553,9 +1545,10 @@ void ScViewFunc::SetStyleSheetToMarked( SfxStyleSheet* pStyleSheet, sal_Bool bRe new ScUndoSelectionStyle( pDocSh, aUndoMark, aMarkRange, aName, pUndoDoc ) ); } - for (SCTAB i=0; i<nTabCount; i++) - if (aFuncMark.GetTableSelect(i)) - pDoc->ApplyStyle( nCol, nRow, i, (ScStyleSheet&)*pStyleSheet ); + ScMarkData::iterator itr = aFuncMark.begin(), itrEnd = aFuncMark.end(); + for (; itr != itrEnd; ++itr) + if (*itr != nTab) + pDoc->ApplyStyle( nCol, nRow, *itr, (ScStyleSheet&)*pStyleSheet ); if (!AdjustBlockHeight()) pViewData->GetDocShell()->PostPaintCell( nCol, nRow, nTab ); @@ -1985,9 +1978,9 @@ void ScViewFunc::DeleteContents( sal_uInt16 nFlags, sal_Bool bRecord ) if ( nFlags & IDF_OBJECTS ) { bObjects = sal_True; - SCTAB nTabCount = pDoc->GetTableCount(); - for (SCTAB nTab=0; nTab<nTabCount; nTab++) - if (aFuncMark.GetTableSelect(nTab) && pDoc->IsTabProtected(nTab)) + ScMarkData::iterator itr = aFuncMark.begin(), itrEnd = aFuncMark.end(); + for (; itr != itrEnd; ++itr) + if (pDoc->IsTabProtected(*itr)) bObjects = false; } @@ -2022,9 +2015,10 @@ void ScViewFunc::DeleteContents( sal_uInt16 nFlags, sal_Bool bRecord ) SCTAB nTab = aMarkRange.aStart.Tab(); pUndoDoc->InitUndo( pDoc, nTab, nTab ); SCTAB nTabCount = pDoc->GetTableCount(); - for (SCTAB i=0; i<nTabCount; i++) - if (i != nTab && aFuncMark.GetTableSelect(i)) - pUndoDoc->AddUndoTab( i, i ); + ScMarkData::iterator itr = aFuncMark.begin(), itrEnd = aFuncMark.end(); + for (; itr != itrEnd; ++itr) + if (*itr != nTab) + pUndoDoc->AddUndoTab( *itr, *itr ); ScRange aCopyRange = aExtendedRange; aCopyRange.aStart.SetTab(0); aCopyRange.aEnd.SetTab(nTabCount-1); @@ -2109,7 +2103,6 @@ void ScViewFunc::SetWidthOrHeight( sal_Bool bWidth, SCCOLROW nRangeCnt, SCCOLROW ScDocShell* pDocSh = GetViewData()->GetDocShell(); ScDocument* pDoc = pDocSh->GetDocument(); - SCTAB nTabCount = pDoc->GetTableCount(); SCTAB nFirstTab = pMarkData->GetFirstSelected(); SCTAB nCurTab = GetViewData()->GetTabNo(); SCTAB nTab; @@ -2119,22 +2112,20 @@ void ScViewFunc::SetWidthOrHeight( sal_Bool bWidth, SCCOLROW nRangeCnt, SCCOLROW ScDocShellModificator aModificator( *pDocSh ); sal_Bool bAllowed = sal_True; - for (nTab=0; nTab<nTabCount && bAllowed; nTab++) - if (pMarkData->GetTableSelect(nTab)) + ScMarkData::iterator itr = pMarkData->begin(), itrEnd = pMarkData->end(); + for (; itr != itrEnd && bAllowed; ++itr) + for ( SCCOLROW i=0; i<nRangeCnt && bAllowed; i++ ) { - for ( SCCOLROW i=0; i<nRangeCnt && bAllowed; i++ ) - { - sal_Bool bOnlyMatrix; - if (bWidth) - bAllowed = pDoc->IsBlockEditable( nTab, - static_cast<SCCOL>(pRanges[2*i]),0, - static_cast<SCCOL>(pRanges[2*i+1]),MAXROW, - &bOnlyMatrix ) || bOnlyMatrix; - else - bAllowed = pDoc->IsBlockEditable( nTab, 0,pRanges[2*i], - MAXCOL,pRanges[2*i+1], &bOnlyMatrix ) || - bOnlyMatrix; - } + sal_Bool bOnlyMatrix; + if (bWidth) + bAllowed = pDoc->IsBlockEditable( *itr, + static_cast<SCCOL>(pRanges[2*i]),0, + static_cast<SCCOL>(pRanges[2*i+1]),MAXROW, + &bOnlyMatrix ) || bOnlyMatrix; + else + bAllowed = pDoc->IsBlockEditable( *itr, 0,pRanges[2*i], + MAXCOL,pRanges[2*i+1], &bOnlyMatrix ) || + bOnlyMatrix; } // Allow users to resize cols/rows in readonly docs despite the r/o state. @@ -2164,28 +2155,28 @@ void ScViewFunc::SetWidthOrHeight( sal_Bool bWidth, SCCOLROW nRangeCnt, SCCOLROW pDoc->BeginDrawUndo(); // Drawing Updates pUndoDoc = new ScDocument( SCDOCMODE_UNDO ); - for (nTab=0; nTab<nTabCount; nTab++) - if (pMarkData->GetTableSelect(nTab)) + itr = pMarkData->begin(); + for (; itr != itrEnd; ++itr) + { + if (bWidth) { - if (bWidth) - { - if ( nTab == nFirstTab ) - pUndoDoc->InitUndo( pDoc, nTab, nTab, sal_True, false ); - else - pUndoDoc->AddUndoTab( nTab, nTab, sal_True, false ); - pDoc->CopyToDocument( static_cast<SCCOL>(nStart), 0, nTab, - static_cast<SCCOL>(nEnd), MAXROW, nTab, IDF_NONE, - false, pUndoDoc ); - } + if ( *itr == nFirstTab ) + pUndoDoc->InitUndo( pDoc, *itr, *itr, true, false ); else - { - if ( nTab == nFirstTab ) - pUndoDoc->InitUndo( pDoc, nTab, nTab, false, sal_True ); - else - pUndoDoc->AddUndoTab( nTab, nTab, false, sal_True ); - pDoc->CopyToDocument( 0, nStart, nTab, MAXCOL, nEnd, nTab, IDF_NONE, false, pUndoDoc ); - } + pUndoDoc->AddUndoTab( *itr, *itr, true, false ); + pDoc->CopyToDocument( static_cast<SCCOL>(nStart), 0, *itr, + static_cast<SCCOL>(nEnd), MAXROW, *itr, IDF_NONE, + false, pUndoDoc ); + } + else + { + if ( *itr == nFirstTab ) + pUndoDoc->InitUndo( pDoc, *itr, *itr, false, true ); + else + pUndoDoc->AddUndoTab( *itr, *itr, false, true ); + pDoc->CopyToDocument( 0, nStart, *itr, MAXCOL, nEnd, *itr, IDF_NONE, false, pUndoDoc ); } + } pUndoRanges = new SCCOLROW[ 2*nRangeCnt ]; memmove( pUndoRanges, pRanges, 2*nRangeCnt*sizeof(SCCOLROW) ); @@ -2202,110 +2193,111 @@ void ScViewFunc::SetWidthOrHeight( sal_Bool bWidth, SCCOLROW nRangeCnt, SCCOLROW sal_Bool bShow = nSizeTwips > 0 || eMode != SC_SIZE_DIRECT; sal_Bool bOutline = false; - for (nTab=0; nTab<nTabCount; nTab++) - if (pMarkData->GetTableSelect(nTab)) + itr = pMarkData->begin(); + for (; itr != itrEnd; ++itr) + { + nTab = *itr; + const SCCOLROW* pTabRanges = pRanges; + + pDoc->InitializeNoteCaptions( nTab ); + for (SCCOLROW nRangeNo=0; nRangeNo<nRangeCnt; nRangeNo++) { - const SCCOLROW* pTabRanges = pRanges; + SCCOLROW nStartNo = *(pTabRanges++); + SCCOLROW nEndNo = *(pTabRanges++); - pDoc->InitializeNoteCaptions( nTab ); - for (SCCOLROW nRangeNo=0; nRangeNo<nRangeCnt; nRangeNo++) + if ( !bWidth ) // Hoehen immer blockweise { - SCCOLROW nStartNo = *(pTabRanges++); - SCCOLROW nEndNo = *(pTabRanges++); - - if ( !bWidth ) // Hoehen immer blockweise + if ( eMode==SC_SIZE_OPTIMAL || eMode==SC_SIZE_VISOPT ) { - if ( eMode==SC_SIZE_OPTIMAL || eMode==SC_SIZE_VISOPT ) + sal_Bool bAll = ( eMode==SC_SIZE_OPTIMAL ); + if (!bAll) { - sal_Bool bAll = ( eMode==SC_SIZE_OPTIMAL ); - if (!bAll) + // fuer alle eingeblendeten CR_MANUALSIZE loeschen, + // dann SetOptimalHeight mit bShrink = FALSE + for (SCROW nRow = nStartNo; nRow <= nEndNo; ++nRow) { - // fuer alle eingeblendeten CR_MANUALSIZE loeschen, - // dann SetOptimalHeight mit bShrink = FALSE - for (SCROW nRow = nStartNo; nRow <= nEndNo; ++nRow) + SCROW nLastRow = nRow; + if (pDoc->RowHidden(nRow, nTab, NULL, &nLastRow)) { - SCROW nLastRow = nRow; - if (pDoc->RowHidden(nRow, nTab, NULL, &nLastRow)) - { - nRow = nLastRow; - continue; - } - - sal_uInt8 nOld = pDoc->GetRowFlags(nRow, nTab); - if (nOld & CR_MANUALSIZE) - pDoc->SetRowFlags(nRow, nTab, nOld & ~CR_MANUALSIZE); + nRow = nLastRow; + continue; } - } - - double nPPTX = GetViewData()->GetPPTX(); - double nPPTY = GetViewData()->GetPPTY(); - Fraction aZoomX = GetViewData()->GetZoomX(); - Fraction aZoomY = GetViewData()->GetZoomY(); - ScSizeDeviceProvider aProv(pDocSh); - if (aProv.IsPrinter()) - { - nPPTX = aProv.GetPPTX(); - nPPTY = aProv.GetPPTY(); - aZoomX = aZoomY = Fraction( 1, 1 ); + sal_uInt8 nOld = pDoc->GetRowFlags(nRow, nTab); + if (nOld & CR_MANUALSIZE) + pDoc->SetRowFlags(nRow, nTab, nOld & ~CR_MANUALSIZE); } + } - pDoc->SetOptimalHeight( nStartNo, nEndNo, nTab, nSizeTwips, aProv.GetDevice(), - nPPTX, nPPTY, aZoomX, aZoomY, bAll ); - if (bAll) - pDoc->ShowRows( nStartNo, nEndNo, nTab, sal_True ); + double nPPTX = GetViewData()->GetPPTX(); + double nPPTY = GetViewData()->GetPPTY(); + Fraction aZoomX = GetViewData()->GetZoomX(); + Fraction aZoomY = GetViewData()->GetZoomY(); - // Manual-Flag wird bei bAll=sal_True schon in SetOptimalHeight gesetzt - // (an bei Extra-Height, sonst aus). - } - else if ( eMode==SC_SIZE_DIRECT ) + ScSizeDeviceProvider aProv(pDocSh); + if (aProv.IsPrinter()) { - if (nSizeTwips) - { - pDoc->SetRowHeightRange( nStartNo, nEndNo, nTab, nSizeTwips ); - pDoc->SetManualHeight( nStartNo, nEndNo, nTab, sal_True ); // height was set manually - } - pDoc->ShowRows( nStartNo, nEndNo, nTab, nSizeTwips != 0 ); + nPPTX = aProv.GetPPTX(); + nPPTY = aProv.GetPPTY(); + aZoomX = aZoomY = Fraction( 1, 1 ); } - else if ( eMode==SC_SIZE_SHOW ) - { + + pDoc->SetOptimalHeight( nStartNo, nEndNo, nTab, nSizeTwips, aProv.GetDevice(), + nPPTX, nPPTY, aZoomX, aZoomY, bAll ); + if (bAll) pDoc->ShowRows( nStartNo, nEndNo, nTab, sal_True ); + + // Manual-Flag wird bei bAll=sal_True schon in SetOptimalHeight gesetzt + // (an bei Extra-Height, sonst aus). + } + else if ( eMode==SC_SIZE_DIRECT ) + { + if (nSizeTwips) + { + pDoc->SetRowHeightRange( nStartNo, nEndNo, nTab, nSizeTwips ); + pDoc->SetManualHeight( nStartNo, nEndNo, nTab, sal_True ); // height was set manually } + pDoc->ShowRows( nStartNo, nEndNo, nTab, nSizeTwips != 0 ); } - else // Spaltenbreiten + else if ( eMode==SC_SIZE_SHOW ) { - for (SCCOL nCol=static_cast<SCCOL>(nStartNo); nCol<=static_cast<SCCOL>(nEndNo); nCol++) + pDoc->ShowRows( nStartNo, nEndNo, nTab, sal_True ); + } + } + else // Spaltenbreiten + { + for (SCCOL nCol=static_cast<SCCOL>(nStartNo); nCol<=static_cast<SCCOL>(nEndNo); nCol++) + { + if ( eMode != SC_SIZE_VISOPT || !pDoc->ColHidden(nCol, nTab) ) { - if ( eMode != SC_SIZE_VISOPT || !pDoc->ColHidden(nCol, nTab) ) - { - sal_uInt16 nThisSize = nSizeTwips; + sal_uInt16 nThisSize = nSizeTwips; - if ( eMode==SC_SIZE_OPTIMAL || eMode==SC_SIZE_VISOPT ) - nThisSize = nSizeTwips + GetOptimalColWidth( nCol, nTab, bFormula ); - if ( nThisSize ) - pDoc->SetColWidth( nCol, nTab, nThisSize ); + if ( eMode==SC_SIZE_OPTIMAL || eMode==SC_SIZE_VISOPT ) + nThisSize = nSizeTwips + GetOptimalColWidth( nCol, nTab, bFormula ); + if ( nThisSize ) + pDoc->SetColWidth( nCol, nTab, nThisSize ); - pDoc->ShowCol( nCol, nTab, bShow ); - } + pDoc->ShowCol( nCol, nTab, bShow ); } } + } // Outline anpassen - if (bWidth) - { - if ( pDoc->UpdateOutlineCol( static_cast<SCCOL>(nStartNo), - static_cast<SCCOL>(nEndNo), nTab, bShow ) ) - bOutline = sal_True; - } - else - { - if ( pDoc->UpdateOutlineRow( nStartNo, nEndNo, nTab, bShow ) ) - bOutline = sal_True; - } + if (bWidth) + { + if ( pDoc->UpdateOutlineCol( static_cast<SCCOL>(nStartNo), + static_cast<SCCOL>(nEndNo), nTab, bShow ) ) + bOutline = sal_True; + } + else + { + if ( pDoc->UpdateOutlineRow( nStartNo, nEndNo, nTab, bShow ) ) + bOutline = sal_True; } - pDoc->SetDrawPageSize(nTab); } + pDoc->SetDrawPageSize(nTab); + } if (!bOutline) @@ -2320,9 +2312,9 @@ void ScViewFunc::SetWidthOrHeight( sal_Bool bWidth, SCCOLROW nRangeCnt, SCCOLROW pUndoTab, eMode, nSizeTwips, bWidth ) ); } - for (nTab=0; nTab<nTabCount; nTab++) - if (pMarkData->GetTableSelect(nTab)) - pDoc->UpdatePageBreaks( nTab ); + itr = pMarkData->begin(); + for (; itr != itrEnd; ++itr) + pDoc->UpdatePageBreaks( *itr ); GetViewData()->GetView()->UpdateScrollBars(); @@ -2330,29 +2322,30 @@ void ScViewFunc::SetWidthOrHeight( sal_Bool bWidth, SCCOLROW nRangeCnt, SCCOLROW { HideCursor(); - for (nTab=0; nTab<nTabCount; nTab++) - if (pMarkData->GetTableSelect(nTab)) + itr = pMarkData->begin(); + for (; itr != itrEnd; ++itr) + { + nTab = *itr; + if (bWidth) { - if (bWidth) - { - if (pDoc->HasAttrib( static_cast<SCCOL>(nStart),0,nTab, - static_cast<SCCOL>(nEnd),MAXROW,nTab, - HASATTR_MERGED | HASATTR_OVERLAPPED )) - nStart = 0; - if (nStart > 0) // weiter oben anfangen wegen Linien und Cursor - --nStart; - pDocSh->PostPaint( static_cast<SCCOL>(nStart), 0, nTab, - MAXCOL, MAXROW, nTab, PAINT_GRID | PAINT_TOP ); - } - else - { - if (pDoc->HasAttrib( 0,nStart,nTab, MAXCOL,nEnd,nTab, HASATTR_MERGED | HASATTR_OVERLAPPED )) - nStart = 0; - if (nStart != 0) - --nStart; - pDocSh->PostPaint( 0, nStart, nTab, MAXCOL, MAXROW, nTab, PAINT_GRID | PAINT_LEFT ); - } + if (pDoc->HasAttrib( static_cast<SCCOL>(nStart),0,nTab, + static_cast<SCCOL>(nEnd),MAXROW,nTab, + HASATTR_MERGED | HASATTR_OVERLAPPED )) + nStart = 0; + if (nStart > 0) // weiter oben anfangen wegen Linien und Cursor + --nStart; + pDocSh->PostPaint( static_cast<SCCOL>(nStart), 0, nTab, + MAXCOL, MAXROW, nTab, PAINT_GRID | PAINT_TOP ); } + else + { + if (pDoc->HasAttrib( 0,nStart,nTab, MAXCOL,nEnd,nTab, HASATTR_MERGED | HASATTR_OVERLAPPED )) + nStart = 0; + if (nStart != 0) + --nStart; + pDocSh->PostPaint( 0, nStart, nTab, MAXCOL, MAXROW, nTab, PAINT_GRID | PAINT_LEFT ); + } + } pDocSh->UpdateOle(GetViewData()); if( !pDocSh->IsReadOnly() ) @@ -2368,19 +2361,18 @@ void ScViewFunc::SetWidthOrHeight( sal_Bool bWidth, SCCOLROW nRangeCnt, SCCOLROW if ( pModelObj && pModelObj->HasChangesListeners() ) { ScRangeList aChangeRanges; - for ( nTab = 0; nTab < nTabCount; ++nTab ) + itr = pMarkData->begin(); + for (; itr != itrEnd; ++itr) { - if ( pMarkData->GetTableSelect( nTab ) ) + nTab = *itr; + const SCCOLROW* pTabRanges = pRanges; + for ( SCCOLROW nRange = 0; nRange < nRangeCnt; ++nRange ) { - const SCCOLROW* pTabRanges = pRanges; - for ( SCCOLROW nRange = 0; nRange < nRangeCnt; ++nRange ) + SCCOL nStartCol = static_cast< SCCOL >( *(pTabRanges++) ); + SCCOL nEndCol = static_cast< SCCOL >( *(pTabRanges++) ); + for ( SCCOL nCol = nStartCol; nCol <= nEndCol; ++nCol ) { - SCCOL nStartCol = static_cast< SCCOL >( *(pTabRanges++) ); - SCCOL nEndCol = static_cast< SCCOL >( *(pTabRanges++) ); - for ( SCCOL nCol = nStartCol; nCol <= nEndCol; ++nCol ) - { - aChangeRanges.Append( ScRange( nCol, 0, nTab ) ); - } + aChangeRanges.Append( ScRange( nCol, 0, nTab ) ); } } } @@ -2583,10 +2575,9 @@ void ScViewFunc::ProtectSheet( SCTAB nTab, const ScTableProtection& rProtect ) pDocSh->GetUndoManager()->EnterListAction( aUndo, aUndo ); } - SCTAB nCount = pDocSh->GetDocument()->GetTableCount(); - for ( SCTAB i=0; i<nCount; i++ ) - if ( rMark.GetTableSelect(i) ) - aFunc.ProtectSheet(i, rProtect); + ScMarkData::iterator itr = rMark.begin(), itrEnd = rMark.end(); + for (; itr != itrEnd; ++itr) + aFunc.ProtectSheet(*itr, rProtect); if (bUndo) pDocSh->GetUndoManager()->LeaveListAction(); @@ -2614,10 +2605,9 @@ void ScViewFunc::Protect( SCTAB nTab, const String& rPassword ) pDocSh->GetUndoManager()->EnterListAction( aUndo, aUndo ); } - SCTAB nCount = pDocSh->GetDocument()->GetTableCount(); - for ( SCTAB i=0; i<nCount; i++ ) - if ( rMark.GetTableSelect(i) ) - aFunc.Protect( i, rPassword, false ); + ScMarkData::iterator itr = rMark.begin(), itrEnd = rMark.end(); + for (; itr != itrEnd; ++itr) + aFunc.Protect( *itr, rPassword, false ); if (bUndo) pDocSh->GetUndoManager()->LeaveListAction(); @@ -2647,10 +2637,9 @@ sal_Bool ScViewFunc::Unprotect( SCTAB nTab, const String& rPassword ) pDocSh->GetUndoManager()->EnterListAction( aUndo, aUndo ); } - SCTAB nCount = pDocSh->GetDocument()->GetTableCount(); - for ( SCTAB i=0; i<nCount; i++ ) - if ( rMark.GetTableSelect(i) ) - if ( aFunc.Unprotect( i, rPassword, false ) ) + ScMarkData::iterator itr = rMark.begin(), itrEnd = rMark.end(); + for (; itr != itrEnd; ++itr) + if ( aFunc.Unprotect( *itr, rPassword, false ) ) bChanged = sal_True; if (bUndo) diff --git a/sc/source/ui/view/viewutil.cxx b/sc/source/ui/view/viewutil.cxx index a7cd41fc4578..482b6743a675 100644 --- a/sc/source/ui/view/viewutil.cxx +++ b/sc/source/ui/view/viewutil.cxx @@ -259,24 +259,24 @@ void ScViewUtil::UnmarkFiltered( ScMarkData& rMark, ScDocument* pDoc ) SCROW nEndRow = aMultiArea.aEnd.Row(); bool bChanged = false; - SCTAB nTabCount = pDoc->GetTableCount(); - for (SCTAB nTab=0; nTab<nTabCount; nTab++) - if ( rMark.GetTableSelect(nTab ) ) + ScMarkData::iterator itr = rMark.begin(), itrEnd = rMark.end(); + for (; itr != itrEnd; ++itr) + { + SCTAB nTab = *itr; + for (SCROW nRow = nStartRow; nRow <= nEndRow; ++nRow) { - for (SCROW nRow = nStartRow; nRow <= nEndRow; ++nRow) + SCROW nLastRow = nRow; + if (pDoc->RowFiltered(nRow, nTab, NULL, &nLastRow)) { - SCROW nLastRow = nRow; - if (pDoc->RowFiltered(nRow, nTab, NULL, &nLastRow)) - { - // use nStartCol/nEndCol, so the multi mark area isn't extended to all columns - // (visible in repaint for indentation) - rMark.SetMultiMarkArea( - ScRange(nStartCol, nRow, nTab, nEndCol, nLastRow, nTab), false); - bChanged = true; - nRow = nLastRow; - } + // use nStartCol/nEndCol, so the multi mark area isn't extended to all columns + // (visible in repaint for indentation) + rMark.SetMultiMarkArea( + ScRange(nStartCol, nRow, nTab, nEndCol, nLastRow, nTab), false); + bChanged = true; + nRow = nLastRow; } } + } if ( bChanged && !rMark.HasAnyMultiMarks() ) rMark.ResetMark(); |