[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source
Kohei Yoshida
kohei.yoshida at gmail.com
Wed Mar 27 09:42:21 PDT 2013
sc/inc/column.hxx | 1 +
sc/inc/document.hxx | 1 +
sc/inc/table.hxx | 1 +
sc/source/core/data/column3.cxx | 14 ++++++++++++++
sc/source/core/data/document.cxx | 12 ++++++++++--
sc/source/core/data/table2.cxx | 8 ++++++++
sc/source/ui/view/viewfunc.cxx | 14 ++++++--------
7 files changed, 41 insertions(+), 10 deletions(-)
New commits:
commit 0133017bb6f8b04cda9b79b9d89007319c1e9c20
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Wed Mar 27 12:44:33 2013 -0400
Make viewfunc.cxx free of ScBaseCell.
Change-Id: I15a2682d2739a1c7be0d52b98c45b8d5a82c1686
diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index dc81438..ba18278 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 9953006..a245da8 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 0a12ead..3ddcbfc 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 aa04f39..fb5e261 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 1603d23..93ddc9f 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 319226f..253032b 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 80e9c2f..f1a0f9c 100644
--- a/sc/source/ui/view/viewfunc.cxx
+++ b/sc/source/ui/view/viewfunc.cxx
@@ -1220,19 +1220,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 );
More information about the Libreoffice-commits
mailing list