[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/qa sc/source
Kohei Yoshida
kohei.yoshida at gmail.com
Tue Mar 26 20:46:18 PDT 2013
sc/inc/document.hxx | 4 +--
sc/qa/unit/helper/csv_handler.hxx | 6 +++--
sc/source/filter/oox/formulabuffer.cxx | 6 +----
sc/source/filter/orcus/interface.cxx | 7 ++---
sc/source/filter/xml/XMLExportIterator.cxx | 1
sc/source/filter/xml/XMLExportIterator.hxx | 6 +----
sc/source/filter/xml/xmlexprt.cxx | 34 ++++++++++++++---------------
sc/source/ui/collab/sendfunc.hxx | 22 ------------------
sc/source/ui/docshell/externalrefmgr.cxx | 6 ++---
sc/source/ui/undo/undoblk3.cxx | 14 +++++------
sc/source/ui/unoobj/chart2uno.cxx | 13 ++++++-----
sc/source/ui/view/cellsh.cxx | 10 +++-----
12 files changed, 51 insertions(+), 78 deletions(-)
New commits:
commit cce51b7a00d3ab3bafe741e01b49e018925f95d4
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Tue Mar 26 23:48:30 2013 -0400
More ScBaseCell reduction...
Change-Id: I3a9f9ce79de7117e7b1410c45b217e5bfe005db7
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 892d18f..9953006 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -834,8 +834,8 @@ public:
const ScAddress& rPos, const ScBaseCell* pCell ) const;
void GetFormula( SCCOL nCol, SCROW nRow, SCTAB nTab, String& rFormula ) const;
const ScTokenArray* GetFormulaTokens( const ScAddress& rPos ) const;
- const ScFormulaCell* GetFormulaCell( const ScAddress& rPos ) const;
- ScFormulaCell* GetFormulaCell( const ScAddress& rPos );
+ SC_DLLPUBLIC const ScFormulaCell* GetFormulaCell( const ScAddress& rPos ) const;
+ SC_DLLPUBLIC ScFormulaCell* GetFormulaCell( const ScAddress& rPos );
SC_DLLPUBLIC void GetFormula( SCCOL nCol, SCROW nRow, SCTAB nTab, rtl::OUString& rFormula ) const;
SC_DLLPUBLIC void GetCellType( SCCOL nCol, SCROW nRow, SCTAB nTab, CellType& rCellType ) const;
SC_DLLPUBLIC CellType GetCellType( const ScAddress& rPos ) const;
diff --git a/sc/qa/unit/helper/csv_handler.hxx b/sc/qa/unit/helper/csv_handler.hxx
index e23efb1..41589f1 100644
--- a/sc/qa/unit/helper/csv_handler.hxx
+++ b/sc/qa/unit/helper/csv_handler.hxx
@@ -34,6 +34,7 @@
#include "scitems.hxx"
#include "document.hxx"
#include "cellform.hxx"
+#include "cellvalue.hxx"
#define DEBUG_CSV_HANDLER 0
@@ -43,8 +44,9 @@ rtl::OUString getConditionalFormatString(ScDocument* pDoc, SCCOL nCol, SCROW nRo
{
rtl::OUString aString;
Color* pColor;
- ScBaseCell* pCell = pDoc->GetCell(ScAddress(nCol, nRow, nTab));
- if(!pCell)
+ ScRefCellValue aCell;
+ aCell.assign(*pDoc, ScAddress(nCol, nRow, nTab));
+ if (aCell.isEmpty())
return aString;
const SfxItemSet* pCondSet = pDoc->GetCondResult( nCol, nRow, nTab );
diff --git a/sc/source/filter/oox/formulabuffer.cxx b/sc/source/filter/oox/formulabuffer.cxx
index 53b556c..59b9221 100644
--- a/sc/source/filter/oox/formulabuffer.cxx
+++ b/sc/source/filter/oox/formulabuffer.cxx
@@ -145,11 +145,9 @@ void FormulaBuffer::applyCellFormulaValues( const std::vector< ValueAddressPair
{
ScAddress aCellPos;
ScUnoConversion::FillScAddress( aCellPos, it->first );
- ScBaseCell* pBaseCell = rDoc.GetCell( aCellPos );
- SAL_WARN_IF( !pBaseCell, "sc", "why is the formula not imported? bug?");
- if ( pBaseCell && pBaseCell->GetCellType() == CELLTYPE_FORMULA )
+ ScFormulaCell* pCell = rDoc.GetFormulaCell(aCellPos);
+ if (pCell)
{
- ScFormulaCell* pCell = static_cast< ScFormulaCell* >( pBaseCell );
pCell->SetHybridDouble( it->second );
pCell->ResetDirty();
pCell->ResetChanged();
diff --git a/sc/source/filter/orcus/interface.cxx b/sc/source/filter/orcus/interface.cxx
index 6e5464f..a8588a5 100644
--- a/sc/source/filter/orcus/interface.cxx
+++ b/sc/source/filter/orcus/interface.cxx
@@ -123,16 +123,15 @@ void ScOrcusSheet::set_formula(
void ScOrcusSheet::set_formula_result(row_t row, col_t col, const char* p, size_t n)
{
- ScBaseCell* pCell;
- mrDoc.GetCell( col, row, mnTab, pCell );
- if(!pCell || pCell->GetCellType() != CELLTYPE_FORMULA)
+ ScFormulaCell* pCell = mrDoc.GetFormulaCell(ScAddress(col, row, mnTab));
+ if (!pCell)
{
SAL_WARN("sc", "trying to set formula result for non formula \
cell! Col: " << col << ";Row: " << row << ";Tab: " << mnTab);
return;
}
OUString aResult( p, n, RTL_TEXTENCODING_UTF8);
- static_cast<ScFormulaCell*>(pCell)->SetHybridString(aResult);
+ pCell->SetHybridString(aResult);
}
void ScOrcusSheet::set_shared_formula(
diff --git a/sc/source/filter/xml/XMLExportIterator.cxx b/sc/source/filter/xml/XMLExportIterator.cxx
index 520ff51..4a593ff 100644
--- a/sc/source/filter/xml/XMLExportIterator.cxx
+++ b/sc/source/filter/xml/XMLExportIterator.cxx
@@ -600,7 +600,6 @@ ScMyCell::ScMyCell() :
aDetectiveObjVec(),
fValue(0.0),
nValidationIndex(-1),
- pBaseCell(NULL),
bIsAutoStyle( false ),
bHasShape( false ),
bIsMergedBase( false ),
diff --git a/sc/source/filter/xml/XMLExportIterator.hxx b/sc/source/filter/xml/XMLExportIterator.hxx
index aa2c10e..3d13403 100644
--- a/sc/source/filter/xml/XMLExportIterator.hxx
+++ b/sc/source/filter/xml/XMLExportIterator.hxx
@@ -34,12 +34,12 @@
#include "detfunc.hxx"
#include "detdata.hxx"
#include "postit.hxx"
+#include "cellvalue.hxx"
class ScHorizontalCellIterator;
struct ScMyCell;
class ScXMLExport;
class ScFormatRangeStyles;
-class ScBaseCell;
//==============================================================================
@@ -291,8 +291,6 @@ public:
// contains data to export for the current cell position
struct ScMyCell
{
-// com::sun::star::uno::Reference<com::sun::star::table::XCell> xCell;
-// com::sun::star::uno::Reference<com::sun::star::text::XText> xText;
com::sun::star::uno::Reference<com::sun::star::sheet::XSheetAnnotation> xAnnotation;
com::sun::star::uno::Reference<com::sun::star::drawing::XShape> xNoteShape;
com::sun::star::table::CellAddress aCellAddress;
@@ -313,7 +311,7 @@ struct ScMyCell
sal_Int32 nNumberFormat;
com::sun::star::table::CellContentType nType;
- ScBaseCell* pBaseCell;
+ ScRefCellValue maBaseCell;
bool bIsAutoStyle;
diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx
index 8057551..48b53cd 100644
--- a/sc/source/filter/xml/xmlexprt.cxx
+++ b/sc/source/filter/xml/xmlexprt.cxx
@@ -58,6 +58,7 @@
#include "cachedattraccess.hxx"
#include "colorscale.hxx"
#include "conditio.hxx"
+#include "cellvalue.hxx"
#include <xmloff/xmltoken.hxx>
#include <xmloff/xmlnmspe.hxx>
@@ -2899,11 +2900,12 @@ void ScXMLExport::WriteCell(ScMyCell& aCell, sal_Int32 nEqualCellCount)
break;
case table::CellContentType_FORMULA :
{
- ScBaseCell* pBaseCell = pDoc ? pDoc->GetCell(aCellPos) : NULL;
- if (pBaseCell && pBaseCell->GetCellType() == CELLTYPE_FORMULA)
+ ScRefCellValue aCellVal;
+ aCellVal.assign(*pDoc, aCellPos);
+ if (aCellVal.meType == CELLTYPE_FORMULA)
{
rtl::OUStringBuffer sFormula;
- ScFormulaCell* pFormulaCell((ScFormulaCell*) pBaseCell);
+ ScFormulaCell* pFormulaCell = aCellVal.mpFormula;
if (!bIsMatrix || (bIsMatrix && bIsFirstMatrixCell))
{
const formula::FormulaGrammar::Grammar eGrammar = pDoc->GetStorageGrammar();
@@ -3369,13 +3371,14 @@ bool ScXMLExport::IsEditCell(const com::sun::star::table::CellAddress& aAddress,
ScAddress aCoreAddress(static_cast<SCCOL>(aAddress.Column),
static_cast<SCROW>(aAddress.Row),
static_cast<SCTAB>(aAddress.Sheet));
- ScBaseCell* pBaseCell = GetDocument() ? GetDocument()->GetCell(aCoreAddress) : NULL;
+
+ ScRefCellValue aCell;
+ aCell.assign(const_cast<ScDocument&>(*GetDocument()), aCoreAddress);
+
if (pMyCell)
- pMyCell->pBaseCell = pBaseCell;
+ pMyCell->maBaseCell = aCell;
- if (pBaseCell)
- return (pBaseCell->GetCellType() == CELLTYPE_EDIT);
- return false;
+ return (aCell.meType == CELLTYPE_EDIT);
}
bool ScXMLExport::IsEditCell(ScMyCell& rCell) const
@@ -3392,26 +3395,23 @@ bool ScXMLExport::IsEditCell(ScMyCell& rCell) const
bool ScXMLExport::IsMultiLineFormulaCell(ScMyCell& rCell) const
{
- if (rCell.pBaseCell)
+ if (!rCell.maBaseCell.isEmpty())
{
- if (rCell.pBaseCell->GetCellType() != CELLTYPE_FORMULA)
+ if (rCell.maBaseCell.meType != CELLTYPE_FORMULA)
return false;
- return static_cast<ScFormulaCell*>(rCell.pBaseCell)->IsMultilineResult();
+ return rCell.maBaseCell.mpFormula->IsMultilineResult();
}
ScAddress aAddr(static_cast<SCCOL>(rCell.aCellAddress.Column),
static_cast<SCROW>(rCell.aCellAddress.Row),
static_cast<SCTAB>(rCell.aCellAddress.Sheet));
- ScBaseCell* pBaseCell = pDoc ? pDoc->GetCell(aAddr) : NULL;
- if (!pBaseCell)
- return false;
- rCell.pBaseCell = pBaseCell;
- if (rCell.pBaseCell->GetCellType() != CELLTYPE_FORMULA)
+ rCell.maBaseCell.assign(*pDoc, aAddr);
+ if (rCell.maBaseCell.meType != CELLTYPE_FORMULA)
return false;
- return static_cast<ScFormulaCell*>(rCell.pBaseCell)->IsMultilineResult();
+ return rCell.maBaseCell.mpFormula->IsMultilineResult();
}
bool ScXMLExport::IsCellEqual (ScMyCell& aCell1, ScMyCell& aCell2)
diff --git a/sc/source/ui/collab/sendfunc.hxx b/sc/source/ui/collab/sendfunc.hxx
index 5e4d147..797246d 100644
--- a/sc/source/ui/collab/sendfunc.hxx
+++ b/sc/source/ui/collab/sendfunc.hxx
@@ -18,12 +18,6 @@ class ScBaseCell;
namespace {
-rtl::OUString cellToString( ScBaseCell *pCell )
-{
- (void)pCell; // FIXME: implement me
- return rtl::OUString();
-}
-
OUString formulaCellToString( ScFormulaCell *pCell )
{
(void)pCell; // FIXME: implement me
@@ -42,12 +36,6 @@ EditTextObject stringToEdit( const OUString& rStr )
return EditTextObject();
}
-ScBaseCell* stringToCell( const rtl::OUString &rString )
-{
- (void)rString; // FIXME: implement me
- return NULL;
-}
-
ScFormulaCell* stringToFormulaCell( const OUString &rString )
{
(void)rString; // FIXME: implement me
@@ -105,11 +93,6 @@ public:
appendSeparator();
}
- void appendCell( ScBaseCell *pCell )
- {
- appendString( cellToString( pCell ) );
- }
-
void appendFormulaCell( ScFormulaCell *pCell )
{
appendString( formulaCellToString( pCell ) );
@@ -231,11 +214,6 @@ public:
return getString( n ).equalsIgnoreAsciiCase( "true" );
}
- ScBaseCell *getCell( sal_Int32 n )
- {
- return stringToCell( getString( n ) );
- }
-
ScFormulaCell* getFormulaCell( sal_Int32 n )
{
return stringToFormulaCell( getString( n ) );
diff --git a/sc/source/ui/docshell/externalrefmgr.cxx b/sc/source/ui/docshell/externalrefmgr.cxx
index 7a61019..6c6a059 100644
--- a/sc/source/ui/docshell/externalrefmgr.cxx
+++ b/sc/source/ui/docshell/externalrefmgr.cxx
@@ -1870,9 +1870,9 @@ void ScExternalRefManager::insertRefCell(sal_uInt16 nFileId, const ScAddress& rC
itr = r.first;
}
- ScBaseCell* pCell = mpDoc->GetCell(rCell);
- if (pCell && pCell->GetCellType() == CELLTYPE_FORMULA)
- itr->second.insert(static_cast<ScFormulaCell*>(pCell));
+ ScFormulaCell* pCell = mpDoc->GetFormulaCell(rCell);
+ if (pCell)
+ itr->second.insert(pCell);
}
void ScExternalRefManager::fillCellFormat(sal_uLong nFmtIndex, ScExternalRefCache::CellFormat* pFmt) const
diff --git a/sc/source/ui/undo/undoblk3.cxx b/sc/source/ui/undo/undoblk3.cxx
index 6cfbf9b..23a3a4d 100644
--- a/sc/source/ui/undo/undoblk3.cxx
+++ b/sc/source/ui/undo/undoblk3.cxx
@@ -439,25 +439,23 @@ void ScUndoSelectionAttr::ChangeEditData( const bool bUndo )
ScDocument* pDoc = pDocShell->GetDocument();
for (const ScEditDataArray::Item* pItem = mpDataArray->First(); pItem; pItem = mpDataArray->Next())
{
- ScBaseCell* pCell;
- pDoc->GetCell(pItem->GetCol(), pItem->GetRow(), pItem->GetTab(), pCell);
- if (!pCell || pCell->GetCellType() != CELLTYPE_EDIT)
+ ScAddress aPos(pItem->GetCol(), pItem->GetRow(), pItem->GetTab());
+ if (pDoc->GetCellType(aPos) != CELLTYPE_EDIT)
continue;
- ScEditCell* pEditCell = static_cast<ScEditCell*>(pCell);
if (bUndo)
{
if (pItem->GetOldData())
- pEditCell->SetData(*pItem->GetOldData(), NULL);
+ pDoc->SetEditText(aPos, *pItem->GetOldData(), NULL);
else
- pEditCell->ClearData();
+ pDoc->SetEmptyCell(aPos);
}
else
{
if (pItem->GetNewData())
- pEditCell->SetData(*pItem->GetNewData(), NULL);
+ pDoc->SetEditText(aPos, *pItem->GetNewData(), NULL);
else
- pEditCell->ClearData();
+ pDoc->SetEmptyCell(aPos);
}
}
}
diff --git a/sc/source/ui/unoobj/chart2uno.cxx b/sc/source/ui/unoobj/chart2uno.cxx
index 8eed3b7..60e65dc 100644
--- a/sc/source/ui/unoobj/chart2uno.cxx
+++ b/sc/source/ui/unoobj/chart2uno.cxx
@@ -35,6 +35,7 @@
#include "stlalgorithm.hxx"
#include "tokenuno.hxx"
#include "docsh.hxx"
+#include "cellvalue.hxx"
#include "formula/opcode.hxx"
@@ -3262,12 +3263,13 @@ sal_uLong getDisplayNumberFormat(ScDocument* pDoc, const ScAddress& rPos)
if (!pFormatter)
return nFormat;
- ScBaseCell* pCell = pDoc->GetCell(rPos);
- if (!pCell || pCell->GetCellType() != CELLTYPE_FORMULA || nFormat)
+ ScRefCellValue aCell;
+ aCell.assign(*pDoc, rPos);
+ if (aCell.isEmpty() || aCell.meType != CELLTYPE_FORMULA || nFormat)
return nFormat;
// With formula cell, the format may be inferred from the formula result.
- return static_cast<ScFormulaCell*>(pCell)->GetStandardFormat(*pFormatter, nFormat);
+ return aCell.mpFormula->GetStandardFormat(*pFormatter, nFormat);
}
}
@@ -3328,8 +3330,9 @@ sal_uLong getDisplayNumberFormat(ScDocument* pDoc, const ScAddress& rPos)
{
// TODO: use nicer heuristic
// return format of first non-empty cell
- ScBaseCell* pCell = m_pDocument->GetCell(aPos);
- if (pCell)
+ ScRefCellValue aCell;
+ aCell.assign(*m_pDocument, aPos);
+ if (!aCell.isEmpty())
return static_cast<sal_Int32>(getDisplayNumberFormat(m_pDocument, aPos));
}
else if( nCount == nIndex )
diff --git a/sc/source/ui/view/cellsh.cxx b/sc/source/ui/view/cellsh.cxx
index 32222b4..bed44c3 100644
--- a/sc/source/ui/view/cellsh.cxx
+++ b/sc/source/ui/view/cellsh.cxx
@@ -678,13 +678,11 @@ void ScCellShell::GetState(SfxItemSet &rSet)
else
{
sal_uInt16 nErrCode = 0;
- ScBaseCell* pCell;
- pDoc->GetCell( nPosX, nPosY, nTab, pCell );
- if ( pCell && pCell->GetCellType() == CELLTYPE_FORMULA )
+ ScFormulaCell* pCell = pDoc->GetFormulaCell(ScAddress(nPosX, nPosY, nTab));
+ if (pCell)
{
- ScFormulaCell* pFCell = (ScFormulaCell*) pCell;
- if (!pFCell->IsRunning())
- nErrCode = pFCell->GetErrCode();
+ if (!pCell->IsRunning())
+ nErrCode = pCell->GetErrCode();
}
String aFuncStr;
More information about the Libreoffice-commits
mailing list