[Libreoffice-commits] .: sc/source
Markus Mohrhard
mmohrhard at kemper.freedesktop.org
Mon Jul 4 19:23:45 PDT 2011
sc/source/core/data/documen3.cxx | 39 +++---
sc/source/core/data/documen4.cxx | 58 ++++++----
sc/source/core/data/documen9.cxx | 7 -
sc/source/core/data/document.cxx | 222 +++++++++++++++++++++++----------------
4 files changed, 195 insertions(+), 131 deletions(-)
New commits:
commit 06ac7e32af715a4e09759f5aa5a91b303fe5e92b
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Tue Jul 5 04:21:41 2011 +0200
change from manual loop to ScMarkData::iterator in calc/source/core
diff --git a/sc/source/core/data/documen3.cxx b/sc/source/core/data/documen3.cxx
index 05a86b1..9c98c68 100644
--- a/sc/source/core/data/documen3.cxx
+++ b/sc/source/core/data/documen3.cxx
@@ -1046,12 +1046,13 @@ void ScDocument::Fill(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, const
{
PutInOrder( nCol1, nCol2 );
PutInOrder( nRow1, nRow2 );
- for (SCTAB i=0; i < static_cast<SCTAB>(maTabs.size()); i++)
- if (maTabs[i])
- if (rMark.GetTableSelect(i))
- maTabs[i]->Fill(nCol1, nRow1, nCol2, nRow2,
- nFillCount, eFillDir, eFillCmd, eFillDateCmd,
- nStepValue, nMaxValue);
+ SCTAB nMax = maTabs.size();
+ ScMarkData::iterator itr = rMark.begin(), itrEnd = rMark.end();
+ for (; itr != itrEnd && *itr < nMax; ++itr)
+ if (maTabs[*itr])
+ maTabs[*itr]->Fill(nCol1, nRow1, nCol2, nRow2,
+ nFillCount, eFillDir, eFillCmd, eFillDateCmd,
+ nStepValue, nMaxValue);
}
String ScDocument::GetAutoFillPreview( const ScRange& rSource, SCCOL nEndX, SCROW nEndY )
@@ -1068,10 +1069,11 @@ void ScDocument::AutoFormat( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SC
{
PutInOrder( nStartCol, nEndCol );
PutInOrder( nStartRow, nEndRow );
- for (SCTAB i=0; i < static_cast<SCTAB>(maTabs.size()); i++)
- if (maTabs[i])
- if (rMark.GetTableSelect(i))
- maTabs[i]->AutoFormat( nStartCol, nStartRow, nEndCol, nEndRow, nFormatNo );
+ SCTAB nMax = maTabs.size();
+ ScMarkData::iterator itr = rMark.begin(), itrEnd = rMark.end();
+ for (; itr != itrEnd && *itr < nMax; ++itr)
+ if (maTabs[*itr])
+ maTabs[*itr]->AutoFormat( nStartCol, nStartRow, nEndCol, nEndRow, nFormatNo );
}
void ScDocument::GetAutoFormatData(SCTAB nTab, SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
@@ -1195,16 +1197,15 @@ sal_Bool ScDocument::SearchAndReplace(const SvxSearchItem& rSearchItem,
if ( nCommand == SVX_SEARCHCMD_FIND_ALL ||
nCommand == SVX_SEARCHCMD_REPLACE_ALL )
{
- for (nTab = 0; nTab < static_cast<SCTAB>(maTabs.size()); nTab++)
- if (maTabs[nTab])
+ SCTAB nMax = maTabs.size();
+ ScMarkData::iterator itr = rMark.begin(), itrEnd = rMark.end();
+ for (; itr != itrEnd && *itr < nMax; ++itr)
+ if (maTabs[*itr])
{
- if (rMark.GetTableSelect(nTab))
- {
- nCol = 0;
- nRow = 0;
- bFound |= maTabs[nTab]->SearchAndReplace(
- rSearchItem, nCol, nRow, rMark, rUndoStr, pUndoDoc );
- }
+ nCol = 0;
+ nRow = 0;
+ bFound |= maTabs[*itr]->SearchAndReplace(
+ rSearchItem, nCol, nRow, rMark, rUndoStr, pUndoDoc );
}
// Markierung wird innen schon komplett gesetzt
diff --git a/sc/source/core/data/documen4.cxx b/sc/source/core/data/documen4.cxx
index c2f5f89..be4efb3 100644
--- a/sc/source/core/data/documen4.cxx
+++ b/sc/source/core/data/documen4.cxx
@@ -138,10 +138,13 @@ void ScDocument::InsertMatrixFormula(SCCOL nCol1, SCROW nRow1,
SCROW k;
i = 0;
bool bStop = false;
- for (;i < static_cast<SCTAB>(maTabs.size()); ++i)
+ SCTAB nMax = static_cast<SCTAB>(maTabs.size());
+ ScMarkData::iterator itr = rMark.begin(), itrEnd = rMark.end();
+ for (; itr != itrEnd && *itr < nMax; ++itr)
{
- if (maTabs[i] && rMark.GetTableSelect(i))
+ if (maTabs[i])
{
+ i = *itr;
bStop = true;
break;
}
@@ -161,14 +164,15 @@ void ScDocument::InsertMatrixFormula(SCCOL nCol1, SCROW nRow1,
else
pCell = new ScFormulaCell( this, aPos, rFormula, eGram, MM_FORMULA );
pCell->SetMatColsRows( nCol2 - nCol1 + 1, nRow2 - nRow1 + 1 );
- for (i = 0; i < static_cast<SCTAB>(maTabs.size()); i++)
+ itr = rMark.begin();
+ for (; itr != itrEnd && *itr < nMax; ++itr)
{
- if (maTabs[i] && rMark.GetTableSelect(i))
+ if (maTabs[*itr])
{
- if (i == nTab1)
- maTabs[i]->PutCell(nCol1, nRow1, pCell);
+ if (*itr == nTab1)
+ maTabs[*itr]->PutCell(nCol1, nRow1, pCell);
else
- maTabs[i]->PutCell(nCol1, nRow1, pCell->CloneWithoutNote(*this, ScAddress( nCol1, nRow1, i), SC_CLONECELL_STARTLISTENING));
+ maTabs[*itr]->PutCell(nCol1, nRow1, pCell->CloneWithoutNote(*this, ScAddress( nCol1, nRow1, *itr), SC_CLONECELL_STARTLISTENING));
}
}
@@ -185,15 +189,16 @@ void ScDocument::InsertMatrixFormula(SCCOL nCol1, SCROW nRow1,
ScTokenArray aArr;
ScToken* t = static_cast<ScToken*>(aArr.AddMatrixSingleReference( aRefData));
- for (i = 0; i < static_cast<SCTAB>(maTabs.size()); i++)
+ itr = rMark.begin();
+ for (; itr != itrEnd && *itr < nMax; ++itr)
{
- if (maTabs[i] && rMark.GetTableSelect(i))
+ if (maTabs[*itr])
{
- maTabs[i]->DoColResize( nCol1, nCol2, static_cast<SCSIZE>(nRow2 - nRow1 + 1) );
- if (i != nTab1)
+ maTabs[*itr]->DoColResize( nCol1, nCol2, static_cast<SCSIZE>(nRow2 - nRow1 + 1) );
+ if (*itr != nTab1)
{
- aRefData.nTab = i;
- aRefData.nRelTab = i - nTab1;
+ aRefData.nTab = *itr;
+ aRefData.nRelTab = *itr - nTab1;
t->GetSingleRef() = aRefData;
}
for (j = nCol1; j <= nCol2; j++)
@@ -204,10 +209,10 @@ void ScDocument::InsertMatrixFormula(SCCOL nCol1, SCROW nRow1,
{
// Array muss geklont werden, damit jede
// Zelle ein eigenes Array erhaelt!
- aPos = ScAddress( j, k, i );
+ aPos = ScAddress( j, k, *itr );
t->CalcRelFromAbs( aPos );
pCell = new ScFormulaCell( this, aPos, aArr.Clone(), eGram, MM_REFERENCE );
- maTabs[i]->PutCell(j, k, (ScBaseCell*) pCell);
+ maTabs[*itr]->PutCell(j, k, (ScBaseCell*) pCell);
}
}
}
@@ -226,10 +231,13 @@ void ScDocument::InsertTableOp(const ScTabOpParam& rParam, // Mehrfachopera
SCROW k;
i = 0;
bool bStop = false;
- for (;i < static_cast<SCTAB>(maTabs.size()); ++i)
+ SCTAB nMax = static_cast<SCTAB>(maTabs.size());
+ ScMarkData::iterator itr = rMark.begin(), itrEnd = rMark.end();
+ for (; itr != itrEnd && *itr < nMax; ++itr)
{
- if (maTabs[i] && rMark.GetTableSelect(i))
+ if (maTabs[*itr])
{
+ i = *itr;
bStop = true;
break;
}
@@ -296,8 +304,12 @@ void ScDocument::InsertTableOp(const ScTabOpParam& rParam, // Mehrfachopera
for( j = nCol1; j <= nCol2; j++ )
for( k = nRow1; k <= nRow2; k++ )
for (i = 0; i < static_cast<SCTAB>(maTabs.size()); i++)
- if( maTabs[i] && rMark.GetTableSelect(i) )
- maTabs[i]->PutCell( j, k, aRefCell.CloneWithoutNote( *this, ScAddress( j, k, i ), SC_CLONECELL_STARTLISTENING ) );
+ {
+ itr = rMark.begin();
+ for (; itr != itrEnd && *itr < nMax; ++itr)
+ if( maTabs[*itr] )
+ maTabs[*itr]->PutCell( j, k, aRefCell.CloneWithoutNote( *this, ScAddress( j, k, *itr ), SC_CLONECELL_STARTLISTENING ) );
+ }
}
namespace {
@@ -499,9 +511,11 @@ sal_Bool ScDocument::GetSelectionFunction( ScSubTotalFunc eFunc,
SCCOL nEndCol = aSingle.aEnd.Col();
SCROW nEndRow = aSingle.aEnd.Row();
- for (SCTAB nTab=0; nTab< static_cast<SCTAB>(maTabs.size()) && !aData.bError; nTab++)
- if (maTabs[nTab] && rMark.GetTableSelect(nTab))
- maTabs[nTab]->UpdateSelectionFunction( aData,
+ SCTAB nMax = static_cast<SCTAB>(maTabs.size());
+ ScMarkData::iterator itr = rMark.begin(), itrEnd = rMark.end();
+ for (; itr != itrEnd && *itr < nMax && !aData.bError; ++itr)
+ if (maTabs[*itr])
+ maTabs[*itr]->UpdateSelectionFunction( aData,
nStartCol, nStartRow, nEndCol, nEndRow, rMark );
//! rMark an UpdateSelectionFunction uebergeben !!!!!
diff --git a/sc/source/core/data/documen9.cxx b/sc/source/core/data/documen9.cxx
index e544e13..c19ae21 100644
--- a/sc/source/core/data/documen9.cxx
+++ b/sc/source/core/data/documen9.cxx
@@ -276,9 +276,10 @@ void ScDocument::DeleteObjectsInArea( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCR
return;
SCTAB nTabCount = GetTableCount();
- for (SCTAB nTab=0; nTab<nTabCount; nTab++)
- if (maTabs[nTab] && rMark.GetTableSelect(nTab))
- pDrawLayer->DeleteObjectsInArea( nTab, nCol1, nRow1, nCol2, nRow2 );
+ ScMarkData::iterator itr = rMark.begin(), itrEnd = rMark.end();
+ for (; itr != itrEnd && *itr < nTabCount; ++itr)
+ if (maTabs[*itr])
+ pDrawLayer->DeleteObjectsInArea( *itr, nCol1, nRow1, nCol2, nRow2 );
}
void ScDocument::DeleteObjectsInSelection( const ScMarkData& rMark )
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 1822f00..67b31a9 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -1040,7 +1040,7 @@ void lcl_GetFirstTabRange( SCTAB& rTabRangeStart, SCTAB& rTabRangeEnd, const ScM
if (pTabMark->GetTableSelect(nTab))
{
// find first range of consecutive selected sheets
- rTabRangeStart = nTab;
+ rTabRangeStart = pTabMark->GetFirstSelected();
while ( nTab+1 < aMaxTab && pTabMark->GetTableSelect(nTab+1) )
++nTab;
rTabRangeEnd = nTab;
@@ -2210,10 +2210,11 @@ void ScDocument::UpdateRangeNamesInFormulas(
{
do
{
- for (SCTAB k = 0; k < static_cast<SCTAB>(maTabs.size()); k++)
+ ScMarkData::iterator itr = rMark.begin(), itrEnd = rMark.end();
+ for (; itr != itrEnd; ++itr)
{
- if ( maTabs[k] && rMark.GetTableSelect(k) )
- maTabs[k]->ReplaceRangeNamesInUse(nC1, nR1,
+ if ( maTabs[*itr] )
+ maTabs[*itr]->ReplaceRangeNamesInUse(nC1, nR1,
nC2, nR2, rRangeNames.maRangeMap);
}
nC1 = nC2 + 1;
@@ -2256,10 +2257,11 @@ void ScDocument::StartListeningFromClip( SCCOL nCol1, SCROW nRow1,
{
if (nInsFlag & IDF_CONTENTS)
{
- for (SCTAB i = 0; i < static_cast<SCTAB>(maTabs.size()); i++)
- if (maTabs[i])
- if (rMark.GetTableSelect(i))
- maTabs[i]->StartListeningInArea( nCol1, nRow1, nCol2, nRow2 );
+ SCTAB nMax = static_cast<SCTAB>(maTabs.size());
+ ScMarkData::iterator itr = rMark.begin(), itrEnd = rMark.end();
+ for (; itr != itrEnd && *itr < nMax; ++itr)
+ if (maTabs[*itr])
+ maTabs[*itr]->StartListeningInArea( nCol1, nRow1, nCol2, nRow2 );
}
}
@@ -2271,10 +2273,11 @@ void ScDocument::BroadcastFromClip( SCCOL nCol1, SCROW nRow1,
if (nInsFlag & IDF_CONTENTS)
{
ScBulkBroadcast aBulkBroadcast( GetBASM());
- for (SCTAB i = 0; i < static_cast<SCTAB>(maTabs.size()); i++)
- if (maTabs[i])
- if (rMark.GetTableSelect(i))
- maTabs[i]->BroadcastInArea( nCol1, nRow1, nCol2, nRow2 );
+ SCTAB nMax = static_cast<SCTAB>(maTabs.size());
+ ScMarkData::iterator itr = rMark.begin(), itrEnd = rMark.end();
+ for (; itr != itrEnd && *itr < nMax; ++itr)
+ if (maTabs[*itr])
+ maTabs[*itr]->BroadcastInArea( nCol1, nRow1, nCol2, nRow2 );
}
}
@@ -2495,13 +2498,15 @@ void ScDocument::CopyFromClip( const ScRange& rDestRange, const ScMarkData& rMar
// die Draw-Seitengroesse neu berechnet werden muss
//! nur wenn ganze Zeilen/Spalten kopiert werden?
- for (SCTAB j = 0; j < static_cast<SCTAB>(maTabs.size()); j++)
- if (maTabs[j] && rMark.GetTableSelect(j))
+ SCTAB nMax = static_cast<SCTAB>(maTabs.size());
+ ScMarkData::iterator itr = rMark.begin(), itrEnd = rMark.end();
+ for (; itr != itrEnd && *itr < nMax; ++itr)
+ if (maTabs[*itr])
{
- if ( j < aCBFCP.nTabStart )
- aCBFCP.nTabStart = j;
- aCBFCP.nTabEnd = j;
- maTabs[j]->IncRecalcLevel();
+ if ( *itr < aCBFCP.nTabStart )
+ aCBFCP.nTabStart = *itr;
+ aCBFCP.nTabEnd = *itr;
+ maTabs[*itr]->IncRecalcLevel();
}
ScRangeList aLocalRangeList;
@@ -2581,9 +2586,10 @@ void ScDocument::CopyFromClip( const ScRange& rDestRange, const ScMarkData& rMar
ScColumn::bDoubleAlloc = bOldDouble;
- for (SCTAB k = 0; k < static_cast<SCTAB>(maTabs.size()); k++)
- if (maTabs[k] && rMark.GetTableSelect(k))
- maTabs[k]->DecRecalcLevel();
+ itr = rMark.begin();
+ for (; itr != itrEnd && *itr < nMax; ++itr)
+ if (maTabs[*itr] )
+ maTabs[*itr]->DecRecalcLevel();
bInsertingFromOtherDoc = false;
@@ -2647,14 +2653,16 @@ void ScDocument::CopyMultiRangeFromClip(
aCBFCP.nTabStart = MAXTAB;
aCBFCP.nTabEnd = 0;
- for (SCTAB j = 0; j < static_cast<SCTAB>(maTabs.size()); ++j)
+ SCTAB nMax = static_cast<SCTAB>(maTabs.size());
+ ScMarkData::iterator itr = rMark.begin(), itrEnd = rMark.end();
+ for (; itr != itrEnd && *itr < nMax; ++itr)
{
- if (maTabs[j] && rMark.GetTableSelect(j))
+ if (maTabs[*itr])
{
- if ( j < aCBFCP.nTabStart )
- aCBFCP.nTabStart = j;
- aCBFCP.nTabEnd = j;
- maTabs[j]->IncRecalcLevel();
+ if ( *itr < aCBFCP.nTabStart )
+ aCBFCP.nTabStart = *itr;
+ aCBFCP.nTabEnd = *itr;
+ maTabs[*itr]->IncRecalcLevel();
}
}
@@ -2717,9 +2725,10 @@ void ScDocument::CopyMultiRangeFromClip(
nCol1 += p->aEnd.Col() - p->aStart.Col() + 1;
}
- for (SCTAB i = 0; i < static_cast<SCTAB>(maTabs.size()); i++)
- if (maTabs[i] && rMark.GetTableSelect(i))
- maTabs[i]->DecRecalcLevel();
+ itr = rMark.begin();
+ for (; itr != itrEnd && *itr < nMax; ++itr)
+ if (maTabs[*itr])
+ maTabs[*itr]->DecRecalcLevel();
bInsertingFromOtherDoc = false;
@@ -2886,9 +2895,11 @@ void ScDocument::FillTab( const ScRange& rSrcArea, const ScMarkData& rMark,
SetAutoCalc( false ); // avoid multiple calculations
SCTAB nCount = static_cast<SCTAB>(maTabs.size());
- for (SCTAB i=0; i<nCount; i++)
- if ( i!=nSrcTab && maTabs[i] && rMark.GetTableSelect(i) )
+ ScMarkData::iterator itr = rMark.begin(), itrEnd = rMark.end();
+ for (; itr != itrEnd && *itr < nCount; ++itr)
+ if ( *itr!=nSrcTab && maTabs[*itr])
{
+ SCTAB i = *itr;
if (bDoMix)
{
if (!pMixDoc)
@@ -2945,9 +2956,11 @@ void ScDocument::FillTabMarked( SCTAB nSrcTab, const ScMarkData& rMark,
SCROW nEndRow = aArea.aEnd.Row();
SCTAB nCount = static_cast<SCTAB>(maTabs.size());
- for (SCTAB i=0; i<nCount; i++)
- if ( i!=nSrcTab && maTabs[i] && rMark.GetTableSelect(i) )
+ ScMarkData::iterator itr = rMark.begin(), itrEnd = rMark.end();
+ for (; itr != itrEnd && *itr < nCount; ++itr)
+ if ( *itr!=nSrcTab && maTabs[*itr] )
{
+ SCTAB i = *itr;
if (bDoMix)
{
if (!pMixDoc)
@@ -4245,9 +4258,11 @@ void ScDocument::ApplyPatternArea( SCCOL nStartCol, SCROW nStartRow,
const ScPatternAttr& rAttr,
ScEditDataArray* pDataArray )
{
- for (SCTAB i=0; i < static_cast<SCTAB>(maTabs.size()); i++)
- if (maTabs[i] && rMark.GetTableSelect(i))
- maTabs[i]->ApplyPatternArea( nStartCol, nStartRow, nEndCol, nEndRow, rAttr, pDataArray );
+ SCTAB nMax = static_cast<SCTAB>(maTabs.size());
+ ScMarkData::iterator itr = rMark.begin(), itrEnd = rMark.end();
+ for (; itr != itrEnd && *itr < nMax; ++itr)
+ if (maTabs[*itr])
+ maTabs[*itr]->ApplyPatternArea( nStartCol, nStartRow, nEndCol, nEndRow, rAttr, pDataArray );
}
@@ -4270,9 +4285,11 @@ bool ScDocument::SetAttrEntries(SCCOL nCol, SCTAB nTab, ScAttrEntry* pData, SCSI
void ScDocument::ApplyPatternIfNumberformatIncompatible( const ScRange& rRange,
const ScMarkData& rMark, const ScPatternAttr& rPattern, short nNewType )
{
- for (SCTAB i=0; i < static_cast<SCTAB>(maTabs.size()); i++)
- if (maTabs[i] && rMark.GetTableSelect(i))
- maTabs[i]->ApplyPatternIfNumberformatIncompatible( rRange, rPattern, nNewType );
+ SCTAB nMax = static_cast<SCTAB>(maTabs.size());
+ ScMarkData::iterator itr = rMark.begin(), itrEnd = rMark.end();
+ for (; itr != itrEnd && *itr < nMax; ++itr)
+ if (maTabs[*itr])
+ maTabs[*itr]->ApplyPatternIfNumberformatIncompatible( rRange, rPattern, nNewType );
}
@@ -4289,9 +4306,11 @@ void ScDocument::ApplyStyleArea( SCCOL nStartCol, SCROW nStartRow,
const ScMarkData& rMark,
const ScStyleSheet& rStyle)
{
- for (SCTAB i=0; i < static_cast<SCTAB>(maTabs.size()); i++)
- if (maTabs[i] && rMark.GetTableSelect(i))
- maTabs[i]->ApplyStyleArea( nStartCol, nStartRow, nEndCol, nEndRow, rStyle );
+ SCTAB nMax = static_cast<SCTAB>(maTabs.size());
+ ScMarkData::iterator itr = rMark.begin(), itrEnd = rMark.end();
+ for (; itr != itrEnd && *itr < nMax; ++itr)
+ if (maTabs[*itr])
+ maTabs[*itr]->ApplyStyleArea( nStartCol, nStartRow, nEndCol, nEndRow, rStyle );
}
@@ -4316,9 +4335,11 @@ void ScDocument::ApplySelectionStyle(const ScStyleSheet& rStyle, const ScMarkDat
}
else
{
- for (SCTAB i=0; i< static_cast<SCTAB>(maTabs.size()); i++)
- if ( maTabs[i] && rMark.GetTableSelect(i) )
- maTabs[i]->ApplySelectionStyle( rStyle, rMark );
+ SCTAB nMax = static_cast<SCTAB>(maTabs.size());
+ ScMarkData::iterator itr = rMark.begin(), itrEnd = rMark.end();
+ for (; itr != itrEnd && *itr < nMax; ++itr)
+ if ( maTabs[*itr] )
+ maTabs[*itr]->ApplySelectionStyle( rStyle, rMark );
}
}
@@ -4329,9 +4350,11 @@ void ScDocument::ApplySelectionLineStyle( const ScMarkData& rMark,
if ( bColorOnly && !pLine )
return;
- for (SCTAB i=0; i< static_cast<SCTAB>(maTabs.size()); i++)
- if (maTabs[i] && rMark.GetTableSelect(i))
- maTabs[i]->ApplySelectionLineStyle( rMark, pLine, bColorOnly );
+ SCTAB nMax = static_cast<SCTAB>(maTabs.size());
+ ScMarkData::iterator itr = rMark.begin(), itrEnd = rMark.end();
+ for (; itr != itrEnd && *itr < nMax; ++itr)
+ if (maTabs[*itr])
+ maTabs[*itr]->ApplySelectionLineStyle( rMark, pLine, bColorOnly );
}
@@ -4353,10 +4376,13 @@ const ScStyleSheet* ScDocument::GetSelectionStyle( const ScMarkData& rMark ) con
const ScStyleSheet* pNewStyle;
if ( rMark.IsMultiMarked() )
- for (SCTAB i=0; i< static_cast<SCTAB>(maTabs.size()) && bEqual; i++)
- if (maTabs[i] && rMark.GetTableSelect(i))
+ {
+ SCTAB nMax = static_cast<SCTAB>(maTabs.size());
+ ScMarkData::iterator itr = rMark.begin(), itrEnd = rMark.end();
+ for (; itr != itrEnd && *itr < nMax; ++itr)
+ if (maTabs[*itr])
{
- pNewStyle = maTabs[i]->GetSelectionStyle( rMark, bFound );
+ pNewStyle = maTabs[*itr]->GetSelectionStyle( rMark, bFound );
if (bFound)
{
if ( !pNewStyle || ( pStyle && pNewStyle != pStyle ) )
@@ -4364,6 +4390,7 @@ const ScStyleSheet* ScDocument::GetSelectionStyle( const ScMarkData& rMark ) con
pStyle = pNewStyle;
}
}
+ }
if ( rMark.IsMarked() )
{
ScRange aRange;
@@ -4495,17 +4522,21 @@ ScPatternAttr* ScDocument::CreateSelectionPattern( const ScMarkData& rMark, sal_
if ( rMark.IsMultiMarked() ) // multi selection
{
- for (SCTAB i=0; i< static_cast<SCTAB>(maTabs.size()); i++)
- if (maTabs[i] && rMark.GetTableSelect(i))
- maTabs[i]->MergeSelectionPattern( aState, rMark, bDeep );
+ SCTAB nMax = static_cast<SCTAB>(maTabs.size());
+ ScMarkData::iterator itr = rMark.begin(), itrEnd = rMark.end();
+ for (; itr != itrEnd && *itr < nMax; ++itr)
+ if (maTabs[*itr])
+ maTabs[*itr]->MergeSelectionPattern( aState, rMark, bDeep );
}
if ( rMark.IsMarked() ) // simle selection
{
ScRange aRange;
rMark.GetMarkArea(aRange);
- for (SCTAB i=0; i< static_cast<SCTAB>(maTabs.size()); i++)
- if (maTabs[i] && rMark.GetTableSelect(i))
- maTabs[i]->MergePatternArea( aState,
+ SCTAB nMax = static_cast<SCTAB>(maTabs.size());
+ ScMarkData::iterator itr = rMark.begin(), itrEnd = rMark.end();
+ for (; itr != itrEnd && *itr < nMax; ++itr)
+ if (maTabs[*itr])
+ maTabs[*itr]->MergePatternArea( aState,
aRange.aStart.Col(), aRange.aStart.Row(),
aRange.aEnd.Col(), aRange.aEnd.Row(), bDeep );
}
@@ -4550,9 +4581,11 @@ void ScDocument::GetSelectionFrame( const ScMarkData& rMark,
rMark.GetMarkArea(aRange);
rLineInner.EnableHor( aRange.aStart.Row() != aRange.aEnd.Row() );
rLineInner.EnableVer( aRange.aStart.Col() != aRange.aEnd.Col() );
- for (SCTAB i=0; i< static_cast<SCTAB>(maTabs.size()); i++)
- if (maTabs[i] && rMark.GetTableSelect(i))
- maTabs[i]->MergeBlockFrame( &rLineOuter, &rLineInner, aFlags,
+ SCTAB nMax = static_cast<SCTAB>(maTabs.size());
+ ScMarkData::iterator itr = rMark.begin(), itrEnd = rMark.end();
+ for (; itr != itrEnd && *itr < nMax; ++itr)
+ if (maTabs[*itr])
+ maTabs[*itr]->MergeBlockFrame( &rLineOuter, &rLineInner, aFlags,
aRange.aStart.Col(), aRange.aStart.Row(),
aRange.aEnd.Col(), aRange.aEnd.Row() );
}
@@ -4795,13 +4828,15 @@ sal_Bool ScDocument::IsSelectionEditable( const ScMarkData& rMark,
sal_Bool bOk = sal_True;
sal_Bool bMatrix = ( pOnlyNotBecauseOfMatrix != NULL );
- for ( SCTAB i=0; i< static_cast<SCTAB>(maTabs.size()) && (bOk || bMatrix); i++ )
+ SCTAB nMax = static_cast<SCTAB>(maTabs.size());
+ ScMarkData::iterator itr = rMark.begin(), itrEnd = rMark.end();
+ for (; itr != itrEnd && *itr < nMax && (bOk || bMatrix); ++itr)
{
- if ( maTabs[i] && rMark.GetTableSelect(i) )
+ if ( maTabs[*itr] )
{
if (rMark.IsMarked())
{
- if ( !maTabs[i]->IsBlockEditable( aRange.aStart.Col(),
+ if ( !maTabs[*itr]->IsBlockEditable( aRange.aStart.Col(),
aRange.aStart.Row(), aRange.aEnd.Col(),
aRange.aEnd.Row(), pOnlyNotBecauseOfMatrix ) )
{
@@ -4812,7 +4847,7 @@ sal_Bool ScDocument::IsSelectionEditable( const ScMarkData& rMark,
}
if (rMark.IsMultiMarked())
{
- if ( !maTabs[i]->IsSelectionEditable( rMark, pOnlyNotBecauseOfMatrix ) )
+ if ( !maTabs[*itr]->IsSelectionEditable( rMark, pOnlyNotBecauseOfMatrix ) )
{
bOk = false;
if ( pOnlyNotBecauseOfMatrix )
@@ -4834,9 +4869,11 @@ sal_Bool ScDocument::HasSelectedBlockMatrixFragment( SCCOL nStartCol, SCROW nSta
const ScMarkData& rMark ) const
{
sal_Bool bOk = sal_True;
- for (SCTAB i=0; i< static_cast<SCTAB>(maTabs.size()) && bOk; i++)
- if (maTabs[i] && rMark.GetTableSelect(i))
- if (maTabs[i]->HasBlockMatrixFragment( nStartCol, nStartRow, nEndCol, nEndRow ))
+ SCTAB nMax = static_cast<SCTAB>(maTabs.size());
+ ScMarkData::iterator itr = rMark.begin(), itrEnd = rMark.end();
+ for (; itr != itrEnd && *itr < nMax && bOk; ++itr)
+ if (maTabs[*itr])
+ if (maTabs[*itr]->HasBlockMatrixFragment( nStartCol, nStartRow, nEndCol, nEndRow ))
bOk = false;
return !bOk;
@@ -4962,12 +4999,14 @@ sal_Bool ScDocument::ExtendMergeSel( SCCOL nStartCol, SCROW nStartRow,
SCCOL nOldEndCol = rEndCol;
SCROW nOldEndRow = rEndRow;
- for (SCTAB nTab = 0; nTab < static_cast<SCTAB>(maTabs.size()); nTab++)
- if ( maTabs[nTab] && rMark.GetTableSelect(nTab) )
+ SCTAB nMax = static_cast<SCTAB>(maTabs.size());
+ ScMarkData::iterator itr = rMark.begin(), itrEnd = rMark.end();
+ for (; itr != itrEnd && *itr < nMax; ++itr)
+ if ( maTabs[*itr] )
{
SCCOL nThisEndCol = nOldEndCol;
SCROW nThisEndRow = nOldEndRow;
- if ( ExtendMerge( nStartCol, nStartRow, nThisEndCol, nThisEndRow, nTab, bRefresh, bAttrs ) )
+ if ( ExtendMerge( nStartCol, nStartRow, nThisEndCol, nThisEndRow, *itr, bRefresh, bAttrs ) )
bFound = sal_True;
if ( nThisEndCol > rEndCol )
rEndCol = nThisEndCol;
@@ -5190,14 +5229,16 @@ void ScDocument::ApplySelectionFrame( const ScMarkData& rMark,
ScRangeList aRangeList;
rMark.FillRangeListWithMarks( &aRangeList, false );
size_t nRangeCount = aRangeList.size();
- for (SCTAB i=0; i< static_cast<SCTAB>(maTabs.size()); i++)
+ SCTAB nMax = static_cast<SCTAB>(maTabs.size());
+ ScMarkData::iterator itr = rMark.begin(), itrEnd = rMark.end();
+ for (; itr != itrEnd && *itr < nMax; ++itr)
{
- if (maTabs[i] && rMark.GetTableSelect(i))
+ if (maTabs[*itr])
{
for ( size_t j=0; j < nRangeCount; j++ )
{
ScRange aRange = *aRangeList[ j ];
- maTabs[i]->ApplyBlockFrame( pLineOuter, pLineInner,
+ maTabs[*itr]->ApplyBlockFrame( pLineOuter, pLineInner,
aRange.aStart.Col(), aRange.aStart.Row(),
aRange.aEnd.Col(), aRange.aEnd.Row() );
}
@@ -5242,10 +5283,11 @@ void ScDocument::ApplySelectionPattern( const ScPatternAttr& rAttr, const ScMark
else
{
SfxItemPoolCache aCache( xPoolHelper->GetDocPool(), pSet );
- for (SCTAB nTab=0; nTab< static_cast<SCTAB>(maTabs.size()); nTab++)
- if (maTabs[nTab])
- if (rMark.GetTableSelect(nTab))
- maTabs[nTab]->ApplySelectionCache( &aCache, rMark, pDataArray );
+ SCTAB nMax = static_cast<SCTAB>(maTabs.size());
+ ScMarkData::iterator itr = rMark.begin(), itrEnd = rMark.end();
+ for (; itr != itrEnd && *itr < nMax; ++itr)
+ if (maTabs[*itr])
+ maTabs[*itr]->ApplySelectionCache( &aCache, rMark, pDataArray );
}
}
}
@@ -5253,25 +5295,31 @@ void ScDocument::ApplySelectionPattern( const ScPatternAttr& rAttr, const ScMark
void ScDocument::ChangeSelectionIndent( sal_Bool bIncrement, const ScMarkData& rMark )
{
- for (SCTAB i=0; i< static_cast<SCTAB>(maTabs.size()); i++)
- if (maTabs[i] && rMark.GetTableSelect(i))
- maTabs[i]->ChangeSelectionIndent( bIncrement, rMark );
+ SCTAB nMax = static_cast<SCTAB>(maTabs.size());
+ ScMarkData::iterator itr = rMark.begin(), itrEnd = rMark.end();
+ for (; itr != itrEnd && *itr < nMax; ++itr)
+ if (maTabs[*itr])
+ maTabs[*itr]->ChangeSelectionIndent( bIncrement, rMark );
}
void ScDocument::ClearSelectionItems( const sal_uInt16* pWhich, const ScMarkData& rMark )
{
- for (SCTAB i=0; i< static_cast<SCTAB>(maTabs.size()); i++)
- if (maTabs[i] && rMark.GetTableSelect(i))
- maTabs[i]->ClearSelectionItems( pWhich, rMark );
+ SCTAB nMax = static_cast<SCTAB>(maTabs.size());
+ ScMarkData::iterator itr = rMark.begin(), itrEnd = rMark.end();
+ for (; itr != itrEnd && *itr < nMax; ++itr)
+ if (maTabs[*itr])
+ maTabs[*itr]->ClearSelectionItems( pWhich, rMark );
}
void ScDocument::DeleteSelection( sal_uInt16 nDelFlag, const ScMarkData& rMark )
{
- for (SCTAB i=0; i< static_cast<SCTAB>(maTabs.size()); i++)
- if (maTabs[i] && rMark.GetTableSelect(i))
- maTabs[i]->DeleteSelection( nDelFlag, rMark );
+ SCTAB nMax = static_cast<SCTAB>(maTabs.size());
+ ScMarkData::iterator itr = rMark.begin(), itrEnd = rMark.end();
+ for (; itr != itrEnd && *itr < nMax; ++itr)
+ if (maTabs[*itr])
+ maTabs[*itr]->DeleteSelection( nDelFlag, rMark );
}
More information about the Libreoffice-commits
mailing list