summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@gmail.com>2013-06-21 13:47:18 -0400
committerKohei Yoshida <kohei.yoshida@gmail.com>2013-06-24 16:51:39 -0400
commit92a78a052efcb3122932894fb446c62733daad42 (patch)
treea90a038f8364eccb6712c316c7220375904285ce
parent5f188d659e8601e577f3a837c9dd3459761371ac (diff)
Don't allow outside code to set text attributes.
Also, use position() to update the value, to avoid performing position lookups twice (once for getting the current value, and once for setting the updated one). Change-Id: Iaa1575a4938b996266c01c8b3170e6a65b871961
-rw-r--r--sc/inc/document.hxx1
-rw-r--r--sc/inc/table.hxx1
-rw-r--r--sc/source/core/data/column2.cxx31
-rw-r--r--sc/source/core/data/document.cxx7
-rw-r--r--sc/source/core/data/table2.cxx5
5 files changed, 12 insertions, 33 deletions
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 64f66e991e13..9d4224451004 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -1942,7 +1942,6 @@ public:
void SetSubTotalCellsDirty(const ScRange& rDirtyRange);
sal_uInt16 GetTextWidth( const ScAddress& rPos ) const;
- void SetTextWidth( const ScAddress& rPos, sal_uInt16 nWidth );
sal_uInt8 GetScriptType( const ScAddress& rPos ) const;
void SetScriptType( const ScAddress& rPos, sal_uInt8 nType );
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index c5c02862e4cc..65cb18042bfe 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -220,7 +220,6 @@ public:
sal_uLong GetCodeCount() const; // RPN code in formula
sal_uInt16 GetTextWidth(SCCOL nCol, SCROW nRow) const;
- void SetTextWidth(SCCOL nCol, SCROW nRow, sal_uInt16 nWidth);
bool SetOutlineTable( const ScOutlineTable* pNewOutline );
void StartOutlineTable();
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index 565335c4c385..70d57e0525f3 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -1710,9 +1710,12 @@ sal_uInt16 ScColumn::GetTextWidth(SCROW nRow) const
void ScColumn::SetTextWidth(SCROW nRow, sal_uInt16 nWidth)
{
- sc::CellTextAttr aVal = maCellTextAttrs.get<sc::CellTextAttr>(nRow);
- aVal.mnTextWidth = nWidth;
- maCellTextAttrs.set(nRow, aVal);
+ sc::CellTextAttrStoreType::position_type aPos = maCellTextAttrs.position(nRow);
+ if (aPos.first->type != sc::element_type_celltextattr)
+ return;
+
+ // Set new value only when the slot is not empty.
+ sc::celltextattr_block::at(*aPos.first->data, aPos.second).mnTextWidth = nWidth;
CellStorageModified();
}
@@ -1799,23 +1802,13 @@ void ScColumn::SetScriptType( SCROW nRow, sal_uInt8 nType )
if (!ValidRow(nRow))
return;
- if (!nType)
- {
- if (maCellTextAttrs.is_empty(nRow))
- return;
+ sc::CellTextAttrStoreType::position_type aPos = maCellTextAttrs.position(nRow);
+ if (aPos.first->type != sc::element_type_celltextattr)
+ // Set new value only when the slot is already set.
+ return;
- sc::CellTextAttr aVal = maCellTextAttrs.get<sc::CellTextAttr>(nRow);
- aVal.mnScriptType = nType;
- maCellTextAttrs.set(nRow, aVal);
- CellStorageModified();
- }
- else
- {
- sc::CellTextAttr aVal = maCellTextAttrs.get<sc::CellTextAttr>(nRow);
- aVal.mnScriptType = nType;
- maCellTextAttrs.set(nRow, aVal);
- CellStorageModified();
- }
+ sc::celltextattr_block::at(*aPos.first->data, aPos.second).mnScriptType = nType;
+ CellStorageModified();
}
size_t ScColumn::GetFormulaHash( SCROW nRow ) const
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 853c204fec6f..f40e416a5ba6 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -5921,13 +5921,6 @@ sal_uInt16 ScDocument::GetTextWidth( const ScAddress& rPos ) const
return 0;
}
-void ScDocument::SetTextWidth( const ScAddress& rPos, sal_uInt16 nWidth )
-{
- SCTAB nTab = rPos.Tab();
- if (ValidTab(nTab) && nTab < static_cast<SCTAB>(maTabs.size()) && maTabs[nTab])
- maTabs[nTab]->SetTextWidth(rPos.Col(), rPos.Row(), nWidth);
-}
-
sal_uInt8 ScDocument::GetScriptType( const ScAddress& rPos ) const
{
SCTAB nTab = rPos.Tab();
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index 2192be62f646..3d7b746894e8 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -64,11 +64,6 @@ sal_uInt16 ScTable::GetTextWidth(SCCOL nCol, SCROW nRow) const
return aCol[nCol].GetTextWidth(nRow);
}
-void ScTable::SetTextWidth(SCCOL nCol, SCROW nRow, sal_uInt16 nWidth)
-{
- aCol[nCol].SetTextWidth(nRow, nWidth);
-}
-
bool ScTable::SetOutlineTable( const ScOutlineTable* pNewOutline )
{
sal_uInt16 nOldSizeX = 0;