[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source
Kohei Yoshida
kohei.yoshida at gmail.com
Fri Mar 15 15:02:19 PDT 2013
sc/inc/column.hxx | 2 ++
sc/source/core/data/column.cxx | 36 ++++++++++++++++++++++++++++--------
sc/source/core/data/column3.cxx | 10 ++++++++++
3 files changed, 40 insertions(+), 8 deletions(-)
New commits:
commit b2f4fa2b9011b6463b363c084e0fa8b44daf5684
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Fri Mar 15 17:55:55 2013 -0400
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
diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 1b01787..a4a2fc3 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 c73fa94..404dc48 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 9537bf6..3c1dc96 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 )
More information about the Libreoffice-commits
mailing list