summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@gmail.com>2013-03-15 17:55:55 -0400
committerKohei Yoshida <kohei.yoshida@gmail.com>2013-03-15 22:12:42 -0400
commit61dc77d7ecfdd72770d5b20db39e6c46cfdbd4a8 (patch)
tree172844ab5ae6ed705835dd8d2cabe035d3997d85 /sc
parent86f704a2e984073c217dd549836bec9265afad58 (diff)
More script type handling.
Basically I'm just following maTextWidths' call sites. Some things are handled differently though for script types, since empty elements may correspond with either empty or non-empty cells (unlike the text width array). Change-Id: If98bcb81e9048b24d75b2bc9fc972a7d74cbbf89
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/column.hxx2
-rw-r--r--sc/source/core/data/column.cxx36
-rw-r--r--sc/source/core/data/column3.cxx10
3 files changed, 40 insertions, 8 deletions
diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 1b017874738a..a4a2fc3bee7b 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -128,6 +128,8 @@ friend class ScColumnTextWidthIterator;
ScColumn(const ScColumn&); // disabled
ScColumn& operator= (const ScColumn&); // disabled
+ static void SwapScriptTypes( ScriptType& rSrc, SCROW nSrcRow, ScriptType& rDest, SCROW nDestRow );
+
public:
ScColumn();
~ScColumn();
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index c73fa947c483..404dc485a246 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -59,6 +59,27 @@ ScNeededSizeOptions::ScNeededSizeOptions() :
{
}
+void ScColumn::SwapScriptTypes( ScriptType& rSrc, SCROW nSrcRow, ScriptType& rDest, SCROW nDestRow )
+{
+ unsigned short nSrcVal = SC_SCRIPTTYPE_UNKNOWN;
+ unsigned short nDestVal = SC_SCRIPTTYPE_UNKNOWN;
+
+ if (!rSrc.is_empty(nSrcRow))
+ nSrcVal = rSrc.get<unsigned short>(nSrcRow);
+ if (!rDest.is_empty(nDestRow))
+ nDestVal = rDest.get<unsigned short>(nDestRow);
+
+ if (nDestVal == SC_SCRIPTTYPE_UNKNOWN)
+ rSrc.set_empty(nSrcRow, nSrcRow);
+ else
+ rSrc.set(nSrcRow, nDestVal);
+
+ if (nSrcVal == SC_SCRIPTTYPE_UNKNOWN)
+ rDest.set_empty(nDestRow, nDestRow);
+ else
+ rDest.set(nDestRow, nSrcVal);
+}
+
ScColumn::ScColumn() :
maTextWidths(MAXROWCOUNT),
maScriptTypes(MAXROWCOUNT),
@@ -865,10 +886,7 @@ void ScColumn::SwapRow(SCROW nRow1, SCROW nRow2)
maTextWidths.set<unsigned short>(nRow2, nVal1);
// Swap script types.
- nVal1 = maScriptTypes.get<unsigned short>(nRow1);
- nVal2 = maScriptTypes.get<unsigned short>(nRow2);
- maScriptTypes.set(nRow1, nVal2);
- maScriptTypes.set(nRow2, nVal1);
+ SwapScriptTypes(maScriptTypes, nRow1, maScriptTypes, nRow2);
CellStorageModified();
}
@@ -1028,10 +1046,7 @@ void ScColumn::SwapCell( SCROW nRow, ScColumn& rCol)
rCol.maTextWidths.set<unsigned short>(nRow, nVal1);
// Swap script types.
- nVal1 = maScriptTypes.get<unsigned short>(nRow);
- nVal2 = rCol.maScriptTypes.get<unsigned short>(nRow);
- maScriptTypes.set(nRow, nVal2);
- rCol.maScriptTypes.set(nRow, nVal1);
+ SwapScriptTypes(maScriptTypes, nRow, rCol.maScriptTypes, nRow);
CellStorageModified();
rCol.CellStorageModified();
@@ -1206,7 +1221,10 @@ void ScColumn::InsertRow( SCROW nStartRow, SCSIZE nSize )
pDocument->SetAutoCalc( bOldAutoCalc );
maTextWidths.insert_empty(nStartRow, nSize);
+ maTextWidths.resize(MAXROWCOUNT);
maScriptTypes.insert_empty(nStartRow, nSize);
+ maScriptTypes.resize(MAXROWCOUNT);
+
CellStorageModified();
}
@@ -1615,6 +1633,7 @@ void ScColumn::SwapCol(ScColumn& rCol)
{
maItems.swap(rCol.maItems);
maTextWidths.swap(rCol.maTextWidths);
+ maScriptTypes.swap(rCol.maScriptTypes);
CellStorageModified();
rCol.CellStorageModified();
@@ -1718,6 +1737,7 @@ void ScColumn::MoveTo(SCROW nStartRow, SCROW nEndRow, ScColumn& rCol)
if (bErased)
{
maTextWidths.set_empty(nStartRow, nEndRow);
+ maScriptTypes.set_empty(nStartRow, nEndRow);
CellStorageModified();
}
}
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index 9537bf6d38d0..3c1dc965a091 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -97,6 +97,7 @@ void ScColumn::Insert( SCROW nRow, ScBaseCell* pNewCell )
}
maTextWidths.set<unsigned short>(nRow, TEXTWIDTH_DIRTY);
+ maScriptTypes.set_empty(nRow, nRow); // empty element represents unknown script state.
CellStorageModified();
}
// When we insert from the Clipboard we still have wrong (old) References!
@@ -142,6 +143,7 @@ void ScColumn::Append( SCROW nRow, ScBaseCell* pCell )
maItems.back().nRow = nRow;
maTextWidths.set<unsigned short>(nRow, TEXTWIDTH_DIRTY);
+ maScriptTypes.set_empty(nRow, nRow); // empty element represents unknown script state.
CellStorageModified();
}
@@ -166,6 +168,7 @@ void ScColumn::Delete( SCROW nRow )
pNoteCell->Delete();
maItems.erase( maItems.begin() + nIndex);
maTextWidths.set_empty(nRow, nRow);
+ maScriptTypes.set_empty(nRow, nRow);
// Should we free memory here (delta)? It'll be slower!
}
pCell->EndListeningTo( pDocument );
@@ -190,6 +193,7 @@ void ScColumn::DeleteAtIndex( SCSIZE nIndex )
pCell->Delete();
maTextWidths.set_empty(nRow, nRow);
+ maScriptTypes.set_empty(nRow, nRow);
CellStorageModified();
}
@@ -203,6 +207,8 @@ void ScColumn::FreeAll()
// Text width should keep a logical empty range of 0-MAXROW when the cell array is empty.
maTextWidths.clear();
maTextWidths.resize(MAXROWCOUNT);
+ maScriptTypes.clear();
+ maScriptTypes.resize(MAXROWCOUNT);
CellStorageModified();
}
@@ -264,6 +270,8 @@ void ScColumn::DeleteRow( SCROW nStartRow, SCSIZE nSize )
// Shift the text width array too (before the broadcast).
maTextWidths.erase(nStartRow, nEndRow);
maTextWidths.resize(MAXROWCOUNT);
+ maScriptTypes.erase(nStartRow, nEndRow);
+ maScriptTypes.resize(MAXROWCOUNT);
ScAddress aAdr( nCol, 0, nTab );
ScHint aHint( SC_HINT_DATACHANGED, aAdr, NULL ); // only areas (ScBaseCell* == NULL)
@@ -508,6 +516,7 @@ void ScColumn::DeleteRange( SCSIZE nStartIndex, SCSIZE nEndIndex, sal_uInt16 nDe
maItems.erase(itErase, itEraseEnd);
maTextWidths.set_empty(nStartRow, nEndRow);
+ maScriptTypes.set_empty(nStartRow, nEndRow);
nEndSegment = nStartSegment;
}
@@ -1438,6 +1447,7 @@ bool ScColumn::SetString( SCROW nRow, SCTAB nTabP, const String& rString,
pOldCell->Delete();
maItems[i].pCell = pNewCell; // Replace
maTextWidths.set<unsigned short>(nRow, TEXTWIDTH_DIRTY);
+ maScriptTypes.set_empty(nRow, nRow); // empty element represents unknown script state.
CellStorageModified();
if ( pNewCell->GetCellType() == CELLTYPE_FORMULA )