summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@gmail.com>2013-03-13 22:59:38 -0400
committerKohei Yoshida <kohei.yoshida@gmail.com>2013-03-14 15:35:54 -0400
commit63ee16274ba64c803e38a3bfba6e5fc9e9d772b6 (patch)
tree730394de2cac62fd3e0407d807fe0e5975458dee /sc
parentd4d282e342a014f0416b7d4b725d918558dab18d (diff)
InvalidateTextWidth() now uses the new iterator.
No more SetTextWidth() directly to the cells. Change-Id: I0a2aba63685ea1461b763e8d628052ecd4c71c25
Diffstat (limited to 'sc')
-rw-r--r--sc/source/core/data/table5.cxx94
1 files changed, 51 insertions, 43 deletions
diff --git a/sc/source/core/data/table5.cxx b/sc/source/core/data/table5.cxx
index 74af647dc41e..355d2f1059bd 100644
--- a/sc/source/core/data/table5.cxx
+++ b/sc/source/core/data/table5.cxx
@@ -36,6 +36,8 @@
#include "tabprotection.hxx"
#include "globstr.hrc"
#include "segmenttree.hxx"
+#include "columniterator.hxx"
+
#include <com/sun/star/sheet/TablePageBreakData.hpp>
#include <algorithm>
@@ -1145,20 +1147,64 @@ void ScTable::InvalidateTextWidth( const ScAddress* pAdrFrom, const ScAddress* p
{
if ( pAdrFrom && !pAdrTo )
{
- ScBaseCell* pCell = aCol[pAdrFrom->Col()].GetCell( pAdrFrom->Row() );
- if ( pCell )
+ // Special case: only process the "from" cell.
+ SCCOL nCol = pAdrFrom->Col();
+ SCROW nRow = pAdrFrom->Row();
+ ScColumn& rCol = aCol[nCol];
+ ScBaseCell* pCell = rCol.GetCell(nRow);
+ if (!pCell)
+ return;
+
+ rCol.SetTextWidth(nRow, TEXTWIDTH_DIRTY);
+
+ if ( bNumFormatChanged )
+ pCell->SetScriptType( SC_SCRIPTTYPE_UNKNOWN );
+
+ if ( bBroadcast )
+ { // nur bei CalcAsShown
+ switch ( pCell->GetCellType() )
+ {
+ case CELLTYPE_VALUE :
+ pDocument->Broadcast(SC_HINT_DATACHANGED, ScAddress(nCol, nRow, nTab), pCell);
+ break;
+ case CELLTYPE_FORMULA :
+ ((ScFormulaCell*)pCell)->SetDirty();
+ break;
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+ }
+
+ return;
+ }
+
+ const SCCOL nCol1 = pAdrFrom ? pAdrFrom->Col() : 0;
+ const SCROW nRow1 = pAdrFrom ? pAdrFrom->Row() : 0;
+ const SCCOL nCol2 = pAdrTo ? pAdrTo->Col() : MAXCOL;
+ const SCROW nRow2 = pAdrTo ? pAdrTo->Row() : MAXROW;
+
+ for (SCCOL nCol = nCol1; nCol <= nCol2; ++nCol)
+ {
+ ScColumnTextWidthIterator aIter(aCol[nCol], nRow1, nRow2);
+
+ for (; aIter.hasCell(); aIter.next())
{
- pCell->SetTextWidth( TEXTWIDTH_DIRTY );
+ SCROW nRow = aIter.getPos();
+ aIter.setValue(TEXTWIDTH_DIRTY);
+ ScBaseCell* pCell = aCol[nCol].GetCell(nRow);
+
if ( bNumFormatChanged )
pCell->SetScriptType( SC_SCRIPTTYPE_UNKNOWN );
+
if ( bBroadcast )
{ // nur bei CalcAsShown
switch ( pCell->GetCellType() )
{
case CELLTYPE_VALUE :
pDocument->Broadcast( SC_HINT_DATACHANGED,
- ScAddress( pAdrFrom->Col(), pAdrFrom->Row(), nTab ),
- pCell );
+ ScAddress( nCol, nRow, nTab ), pCell );
break;
case CELLTYPE_FORMULA :
((ScFormulaCell*)pCell)->SetDirty();
@@ -1171,44 +1217,6 @@ void ScTable::InvalidateTextWidth( const ScAddress* pAdrFrom, const ScAddress* p
}
}
}
- else
- {
- const SCCOL nColStart = pAdrFrom ? pAdrFrom->Col() : 0;
- const SCROW nRowStart = pAdrFrom ? pAdrFrom->Row() : 0;
- const SCCOL nColEnd = pAdrTo ? pAdrTo->Col() : MAXCOL;
- const SCROW nRowEnd = pAdrTo ? pAdrTo->Row() : MAXROW;
-
- for ( SCCOL nCol=nColStart; nCol<=nColEnd; nCol++ )
- {
- ScColumnIterator aIter( &aCol[nCol], nRowStart, nRowEnd );
- ScBaseCell* pCell = NULL;
- SCROW nRow = nRowStart;
-
- while ( aIter.Next( nRow, pCell ) )
- {
- pCell->SetTextWidth( TEXTWIDTH_DIRTY );
- if ( bNumFormatChanged )
- pCell->SetScriptType( SC_SCRIPTTYPE_UNKNOWN );
- if ( bBroadcast )
- { // nur bei CalcAsShown
- switch ( pCell->GetCellType() )
- {
- case CELLTYPE_VALUE :
- pDocument->Broadcast( SC_HINT_DATACHANGED,
- ScAddress( nCol, nRow, nTab ), pCell );
- break;
- case CELLTYPE_FORMULA :
- ((ScFormulaCell*)pCell)->SetDirty();
- break;
- default:
- {
- // added to avoid warnings
- }
- }
- }
- }
- }
- }
}