summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@gmail.com>2013-03-27 12:44:33 -0400
committerKohei Yoshida <kohei.yoshida@gmail.com>2013-03-28 01:12:48 -0400
commit6f0aa08753407ab1bfd62f9c733bbf54fb365c0d (patch)
tree58554daf174fc9e0e4bd1900c033269206561d9a
parentcdef3ead120149cc4db9f44a4ab3a5124ca450c6 (diff)
Make viewfunc.cxx free of ScBaseCell.
Change-Id: I15a2682d2739a1c7be0d52b98c45b8d5a82c1686
-rw-r--r--sc/inc/column.hxx1
-rw-r--r--sc/inc/document.hxx1
-rw-r--r--sc/inc/table.hxx1
-rw-r--r--sc/source/core/data/column3.cxx14
-rw-r--r--sc/source/core/data/document.cxx12
-rw-r--r--sc/source/core/data/table2.cxx8
-rw-r--r--sc/source/ui/view/viewfunc.cxx14
7 files changed, 41 insertions, 10 deletions
diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index dc81438ededa..ba18278341dd 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -279,6 +279,7 @@ public:
void GetInputString( SCROW nRow, rtl::OUString& rString ) const;
double GetValue( SCROW nRow ) const;
const EditTextObject* GetEditText( SCROW nRow ) const;
+ void RemoveEditTextCharAttribs( SCROW nRow, const ScPatternAttr& rAttr );
void GetFormula( SCROW nRow, rtl::OUString& rFormula ) const;
const ScTokenArray* GetFormulaTokens( SCROW nRow ) const;
const ScFormulaCell* GetFormulaCell( SCROW nRow ) const;
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 9953006f8b39..a245da805252 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -820,6 +820,7 @@ public:
SC_DLLPUBLIC double GetValue( SCCOL nCol, SCROW nRow, SCTAB nTab ) const { ScAddress aAdr(nCol, nRow, nTab); return GetValue(aAdr);}
SC_DLLPUBLIC void GetValue( SCCOL nCol, SCROW nRow, SCTAB nTab, double& rValue ) const;
SC_DLLPUBLIC const EditTextObject* GetEditText( const ScAddress& rPos ) const;
+ void RemoveEditTextCharAttribs( const ScAddress& rPos, const ScPatternAttr& rAttr );
SC_DLLPUBLIC double RoundValueAsShown( double fVal, sal_uInt32 nFormat ) const;
SC_DLLPUBLIC void GetNumberFormat( SCCOL nCol, SCROW nRow, SCTAB nTab,
sal_uInt32& rFormat ) const;
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index 0a12ead224d8..3ddcbfc46cb9 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -328,6 +328,7 @@ public:
}
double GetValue( SCCOL nCol, SCROW nRow ) const;
const EditTextObject* GetEditText( SCCOL nCol, SCROW nRow ) const;
+ void RemoveEditTextCharAttribs( SCCOL nCol, SCROW nRow, const ScPatternAttr& rAttr );
void GetFormula( SCCOL nCol, SCROW nRow, rtl::OUString& rFormula ) const;
const ScTokenArray* GetFormulaTokens( SCCOL nCol, SCROW nRow ) const;
const ScFormulaCell* GetFormulaCell( SCCOL nCol, SCROW nRow ) const;
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index aa04f39c8067..fb5e26119681 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -1835,6 +1835,20 @@ const EditTextObject* ScColumn::GetEditText( SCROW nRow ) const
return pEditCell->GetData();
}
+void ScColumn::RemoveEditTextCharAttribs( SCROW nRow, const ScPatternAttr& rAttr )
+{
+ SCSIZE nIndex;
+ if (!Search(nRow, nIndex))
+ return;
+
+ ScBaseCell* pCell = maItems[nIndex].pCell;
+ if (pCell->GetCellType() != CELLTYPE_EDIT)
+ return;
+
+ ScEditCell* pEditCell = static_cast<ScEditCell*>(pCell);
+ pEditCell->RemoveCharAttribs(rAttr);
+}
+
void ScColumn::GetFormula( SCROW nRow, rtl::OUString& rFormula ) const
{
SCSIZE nIndex;
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 1603d23d1cb3..93ddc9feb584 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -3132,7 +3132,7 @@ sal_uInt16 ScDocument::GetStringForFormula( const ScAddress& rPos, OUString& rSt
void ScDocument::GetValue( SCCOL nCol, SCROW nRow, SCTAB nTab, double& rValue ) const
{
- if ( ValidTab(nTab) && nTab < static_cast<SCTAB>(maTabs.size()) && maTabs[nTab] )
+ if (TableExists(nTab))
rValue = maTabs[nTab]->GetValue( nCol, nRow );
else
rValue = 0.0;
@@ -3141,12 +3141,20 @@ void ScDocument::GetValue( SCCOL nCol, SCROW nRow, SCTAB nTab, double& rValue )
const EditTextObject* ScDocument::GetEditText( const ScAddress& rPos ) const
{
SCTAB nTab = rPos.Tab();
- if (!ValidTab(nTab) || nTab >= static_cast<SCTAB>(maTabs.size()) || !maTabs[nTab])
+ if (!TableExists(nTab))
return NULL;
return maTabs[nTab]->GetEditText(rPos.Col(), rPos.Row());
}
+void ScDocument::RemoveEditTextCharAttribs( const ScAddress& rPos, const ScPatternAttr& rAttr )
+{
+ if (!TableExists(rPos.Tab()))
+ return;
+
+ return maTabs[rPos.Tab()]->RemoveEditTextCharAttribs(rPos.Col(), rPos.Row(), rAttr);
+}
+
double ScDocument::GetValue( 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 319226f5acb9..253032b79c2d 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -1436,6 +1436,14 @@ const EditTextObject* ScTable::GetEditText( SCCOL nCol, SCROW nRow ) const
return aCol[nCol].GetEditText(nRow);
}
+void ScTable::RemoveEditTextCharAttribs( SCCOL nCol, SCROW nRow, const ScPatternAttr& rAttr )
+{
+ if (!ValidColRow(nCol, nRow))
+ return;
+
+ return aCol[nCol].RemoveEditTextCharAttribs(nRow, rAttr);
+}
+
void ScTable::GetFormula( SCCOL nCol, SCROW nRow, rtl::OUString& rFormula ) const
{
if (ValidColRow(nCol,nRow))
diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx
index e46a6bd47f64..065373cbf0be 100644
--- a/sc/source/ui/view/viewfunc.cxx
+++ b/sc/source/ui/view/viewfunc.cxx
@@ -1222,19 +1222,17 @@ void ScViewFunc::ApplySelectionPattern( const ScPatternAttr& rAttr,
SCROW nRow = pViewData->GetCurY();
SCTAB nTab = pViewData->GetTabNo();
- ScBaseCell* pCell;
- pDoc->GetCell(nCol, nRow, nTab, pCell);
EditTextObject* pOldEditData = NULL;
EditTextObject* pNewEditData = NULL;
- if (pCell && pCell->GetCellType() == CELLTYPE_EDIT)
+ ScAddress aPos(nCol, nRow, nTab);
+ if (pDoc->GetCellType(aPos) == CELLTYPE_EDIT)
{
- ScEditCell* pEditCell = static_cast<ScEditCell*>(pCell);
- pOldEditData = pEditCell->GetData()->Clone();
- pEditCell->RemoveCharAttribs(rAttr);
- pNewEditData = pEditCell->GetData()->Clone();
+ pOldEditData = pDoc->GetEditText(aPos)->Clone();
+ pDoc->RemoveEditTextCharAttribs(aPos, rAttr);
+ pNewEditData = pDoc->GetEditText(aPos)->Clone();
}
- aChangeRanges.Append( ScRange( nCol, nRow, nTab ) );
+ aChangeRanges.Append(aPos);
ScPatternAttr* pOldPat = new ScPatternAttr(*pDoc->GetPattern( nCol, nRow, nTab ));
pDoc->ApplyPattern( nCol, nRow, nTab, rAttr );