[Libreoffice-commits] core.git: 12 commits - sc/inc sc/qa sc/source
Kohei Yoshida
kohei.yoshida at gmail.com
Tue Mar 26 21:07:25 PDT 2013
sc/inc/cellform.hxx | 18 +-
sc/inc/cellvalue.hxx | 6
sc/inc/column.hxx | 3
sc/inc/dociter.hxx | 14 -
sc/inc/document.hxx | 4
sc/inc/externalrefmgr.hxx | 10 -
sc/qa/unit/helper/csv_handler.hxx | 6
sc/source/core/data/cellvalue.cxx | 43 ++++++
sc/source/core/data/column.cxx | 11 +
sc/source/core/data/column2.cxx | 52 +++----
sc/source/core/data/column3.cxx | 40 +++--
sc/source/core/data/dociter.cxx | 81 ++++-------
sc/source/core/data/table3.cxx | 5
sc/source/core/tool/cellform.cxx | 206 ++++++++++++-----------------
sc/source/core/tool/rangeseq.cxx | 44 ++----
sc/source/filter/dif/difexp.cxx | 94 ++++++-------
sc/source/filter/excel/xetable.cxx | 29 +---
sc/source/filter/html/htmlexp.cxx | 92 +++++-------
sc/source/filter/inc/htmlexp.hxx | 4
sc/source/filter/inc/xetable.hxx | 7
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/docsh.cxx | 8 -
sc/source/ui/docshell/externalrefmgr.cxx | 94 +++++--------
sc/source/ui/inc/output.hxx | 19 +-
sc/source/ui/undo/undoblk3.cxx | 14 -
sc/source/ui/unoobj/cellsuno.cxx | 6
sc/source/ui/unoobj/chart2uno.cxx | 13 +
sc/source/ui/view/cellsh.cxx | 10 -
sc/source/ui/view/output2.cxx | 155 +++++++++++----------
sc/source/ui/view/tabvwsh5.cxx | 77 ++++------
35 files changed, 592 insertions(+), 649 deletions(-)
New commits:
commit 26343a5a3123315795d0352ee01a1fb5ee0a931a
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;
commit 6a2a132661ae2ae535a7259c802d31c817717bd3
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Tue Mar 26 22:24:07 2013 -0400
Remove this hack.
Change-Id: Ibaf4f478c25e5c8b429ffb45a70d9a8a170053ef
diff --git a/sc/inc/dociter.hxx b/sc/inc/dociter.hxx
index 7161ac2..4477ba3 100644
--- a/sc/inc/dociter.hxx
+++ b/sc/inc/dociter.hxx
@@ -249,9 +249,6 @@ public:
bool first();
bool next();
-
- // TODO: Remove this later.
- ScBaseCell* getHackedBaseCell();
};
class ScQueryCellIterator // walk through all non-empty cells in an area
diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx
index dadf501..f64837e 100644
--- a/sc/source/core/data/dociter.cxx
+++ b/sc/source/core/data/dociter.cxx
@@ -1164,11 +1164,6 @@ bool ScCellIterator::next()
return getCurrent();
}
-ScBaseCell* ScCellIterator::getHackedBaseCell()
-{
- return mpDoc->GetCell(maCurPos);
-}
-
//-------------------------------------------------------------------------------
ScQueryCellIterator::ScQueryCellIterator(ScDocument* pDocument, SCTAB nTable,
commit 48dfa346ccb37f144efabad2ba271821c895c0d3
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Tue Mar 26 22:10:21 2013 -0400
ScRefCellValue is actually a struct, not a class.
Change-Id: Iadd6d706e5ba9d51cb82d4dd387e59318da1f322
diff --git a/sc/inc/cellform.hxx b/sc/inc/cellform.hxx
index 094eaff..373d6e6 100644
--- a/sc/inc/cellform.hxx
+++ b/sc/inc/cellform.hxx
@@ -27,7 +27,7 @@ class SvNumberFormatter;
class Color;
class ScDocument;
class ScAddress;
-class ScRefCellValue;
+struct ScRefCellValue;
enum ScForceTextFmt {
ftDontForce, // numbers as numbers
commit 7d647beac3aa2c2e0853424cac19ebad4849861e
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Tue Mar 26 22:09:09 2013 -0400
We don't need this.
Change-Id: I93a13b3fb4203909765841806a7cde017ee85b6a
diff --git a/sc/inc/cellform.hxx b/sc/inc/cellform.hxx
index 15f233e..094eaff 100644
--- a/sc/inc/cellform.hxx
+++ b/sc/inc/cellform.hxx
@@ -23,7 +23,6 @@
#include <tools/solar.h>
#include "scdllapi.h"
-class ScBaseCell;
class SvNumberFormatter;
class Color;
class ScDocument;
commit 22571debb0071b0a134f9e4aff3db0f98fd19ca6
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Tue Mar 26 22:07:12 2013 -0400
GetInputString() now takes ScRefCellValue instead of ScBaseCell.
Change-Id: Ibf746351eb111a03be4f00ec719a4428c5fe47a4
diff --git a/sc/inc/cellform.hxx b/sc/inc/cellform.hxx
index c7083ec..15f233e 100644
--- a/sc/inc/cellform.hxx
+++ b/sc/inc/cellform.hxx
@@ -53,8 +53,8 @@ public:
Color** ppColor, SvNumberFormatter& rFormatter, bool bNullVals = true,
bool bFormula = false, ScForceTextFmt eForceTextFmt = ftDontForce, bool bUseStarFormat = false );
- static void GetInputString( ScBaseCell* pCell, sal_uLong nFormat, rtl::OUString& rString,
- SvNumberFormatter& rFormatter );
+ static void GetInputString(
+ ScRefCellValue& rCell, sal_uLong nFormat, OUString& rString, SvNumberFormatter& rFormatter );
};
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index 8a70ce6..aa04f39 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -1527,9 +1527,11 @@ void ScColumn::GetFilterEntries(SCROW nStartRow, SCROW nEndRow, std::vector<ScTy
break;
ScBaseCell* pCell = maItems[nIndex].pCell;
+ ScRefCellValue aCell;
+ aCell.assign(*maItems[nIndex].pCell);
sal_uLong nFormat = GetNumberFormat( nRow );
- ScCellFormat::GetInputString( pCell, nFormat, aString, *pFormatter );
+ ScCellFormat::GetInputString(aCell, nFormat, aString, *pFormatter);
if ( pDocument->HasStringData( nCol, nRow, nTab ) )
{
@@ -1778,11 +1780,12 @@ void ScColumn::GetInputString( SCROW nRow, rtl::OUString& rString ) const
SCSIZE nIndex;
if (Search(nRow, nIndex))
{
- ScBaseCell* pCell = maItems[nIndex].pCell;
- if (pCell->GetCellType() != CELLTYPE_NOTE)
+ ScRefCellValue aCell;
+ aCell.assign(*maItems[nIndex].pCell);
+ if (aCell.meType != CELLTYPE_NOTE)
{
sal_uLong nFormat = GetNumberFormat( nRow );
- ScCellFormat::GetInputString( pCell, nFormat, rString, *(pDocument->GetFormatTable()) );
+ ScCellFormat::GetInputString(aCell, nFormat, rString, *(pDocument->GetFormatTable()));
}
else
rString = rtl::OUString();
@@ -1996,14 +1999,15 @@ xub_StrLen ScColumn::GetMaxNumberStringLen(
Search( nRowStart, nIndex );
while ( nIndex < maItems.size() && (nRow = maItems[nIndex].nRow) <= nRowEnd )
{
- ScBaseCell* pCell = maItems[nIndex].pCell;
- CellType eType = pCell->GetCellType();
+ ScRefCellValue aCell;
+ aCell.assign(*maItems[nIndex].pCell);
+ CellType eType = aCell.meType;
if ( eType == CELLTYPE_VALUE || (eType == CELLTYPE_FORMULA
- && ((ScFormulaCell*)pCell)->IsValue()) )
+ && aCell.mpFormula->IsValue()) )
{
sal_uLong nFormat = (sal_uLong) ((SfxUInt32Item*) GetAttr(
nRow, ATTR_VALUE_FORMAT ))->GetValue();
- ScCellFormat::GetInputString( pCell, nFormat, aString, *pNumFmt );
+ ScCellFormat::GetInputString(aCell, nFormat, aString, *pNumFmt);
xub_StrLen nLen = aString.getLength();
if ( nLen )
{
diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx
index 6d8f758..dadf501 100644
--- a/sc/source/core/data/dociter.cxx
+++ b/sc/source/core/data/dociter.cxx
@@ -1482,6 +1482,7 @@ ScBaseCell* ScQueryCellIterator::BinarySearch()
if (!pCol->maItems.size())
return 0;
+ ScRefCellValue aCell;
ScBaseCell* pCell;
SCSIZE nHi, nLo;
CollatorWrapper* pCollator = (mpParam->bCaseSens ? ScGlobal::GetCaseCollator() :
@@ -1503,8 +1504,8 @@ ScBaseCell* ScQueryCellIterator::BinarySearch()
{
rtl::OUString aCellStr;
sal_uLong nFormat = pCol->GetNumberFormat( pCol->maItems[nLo].nRow);
- ScCellFormat::GetInputString( pCol->maItems[nLo].pCell, nFormat, aCellStr,
- rFormatter);
+ aCell.assign(*pCol->maItems[nLo].pCell);
+ ScCellFormat::GetInputString(aCell, nFormat, aCellStr, rFormatter);
sal_Int32 nTmp = pCollator->compareString(aCellStr, rEntry.GetQueryItem().maString);
if ((rEntry.eOp == SC_LESS_EQUAL && nTmp > 0) ||
(rEntry.eOp == SC_GREATER_EQUAL && nTmp < 0) ||
@@ -1529,27 +1530,24 @@ ScBaseCell* ScQueryCellIterator::BinarySearch()
aLastInRangeString.Assign( sal_Unicode(0xFFFF));
if (nLastInRange < pCol->maItems.size())
{
- pCell = pCol->maItems[nLastInRange].pCell;
- if (pCell->HasStringData())
+ aCell.assign(*pCol->maItems[nLastInRange].pCell);
+ if (aCell.hasString())
{
sal_uLong nFormat = pCol->GetNumberFormat( pCol->maItems[nLastInRange].nRow);
- rtl::OUString aStr;
- ScCellFormat::GetInputString( pCell, nFormat, aStr,
- rFormatter);
+ OUString aStr;
+ ScCellFormat::GetInputString(aCell, nFormat, aStr, rFormatter);
aLastInRangeString = aStr;
}
else
{
- switch ( pCell->GetCellType() )
+ switch (aCell.meType)
{
case CELLTYPE_VALUE :
- fLastInRangeValue =
- static_cast<ScValueCell*>(pCell)->GetValue();
- break;
+ fLastInRangeValue = aCell.mfValue;
+ break;
case CELLTYPE_FORMULA :
- fLastInRangeValue =
- static_cast<ScFormulaCell*>(pCell)->GetValue();
- break;
+ fLastInRangeValue = aCell.mpFormula->GetValue();
+ break;
default:
{
// added to avoid warnings
@@ -1639,8 +1637,9 @@ ScBaseCell* ScQueryCellIterator::BinarySearch()
{
rtl::OUString aCellStr;
sal_uLong nFormat = pCol->GetNumberFormat( pCol->maItems[i].nRow);
- ScCellFormat::GetInputString( pCol->maItems[i].pCell, nFormat, aCellStr,
- rFormatter);
+ aCell.assign(*pCol->maItems[i].pCell);
+ ScCellFormat::GetInputString(aCell, nFormat, aCellStr, rFormatter);
+
nRes = pCollator->compareString(aCellStr, rEntry.GetQueryItem().maString);
if (nRes < 0 && bLessEqual)
{
diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index f8e4413..a16d945 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -52,6 +52,7 @@
#include "segmenttree.hxx"
#include "subtotalparam.hxx"
#include "docpool.hxx"
+#include "cellvalue.hxx"
#include <vector>
#include <boost/unordered_set.hpp>
@@ -1367,7 +1368,9 @@ public:
else if (pCell->GetCellType() != CELLTYPE_NOTE)
{
sal_uLong nFormat = mrTab.GetNumberFormat( static_cast<SCCOL>(rEntry.nField), nRow );
- ScCellFormat::GetInputString(pCell, nFormat, aCellStr, *mrDoc.GetFormatTable());
+ ScRefCellValue aCell;
+ aCell.assign(*pCell);
+ ScCellFormat::GetInputString(aCell, nFormat, aCellStr, *mrDoc.GetFormatTable());
}
}
else
diff --git a/sc/source/core/tool/cellform.cxx b/sc/source/core/tool/cellform.cxx
index 8d0a903..d60627b 100644
--- a/sc/source/core/tool/cellform.cxx
+++ b/sc/source/core/tool/cellform.cxx
@@ -231,60 +231,42 @@ OUString ScCellFormat::GetString(
return aString;
}
-void ScCellFormat::GetInputString( ScBaseCell* pCell, sal_uLong nFormat, OUString& rString,
- SvNumberFormatter& rFormatter )
+void ScCellFormat::GetInputString(
+ ScRefCellValue& rCell, sal_uLong nFormat, OUString& rString, SvNumberFormatter& rFormatter )
{
- if (&rFormatter==NULL)
+ if (&rFormatter == NULL)
{
- rString = OUString();
+ rString = EMPTY_OUSTRING;
return;
}
- String aString = rString;
- CellType eType = pCell->GetCellType();
- switch(eType)
+ OUString aString = rString;
+ switch (rCell.meType)
{
case CELLTYPE_STRING:
- {
- aString = ((ScStringCell*)pCell)->GetString();
- }
- break;
case CELLTYPE_EDIT:
- {
- aString = ((ScEditCell*)pCell)->GetString();
- }
- break;
+ aString = rCell.getString();
+ break;
case CELLTYPE_VALUE:
- {
- double nValue = ((ScValueCell*)pCell)->GetValue();
- rFormatter.GetInputLineString( nValue, nFormat, aString );
- }
- break;
+ rFormatter.GetInputLineString(rCell.mfValue, nFormat, aString );
+ break;
case CELLTYPE_FORMULA:
- {
- if (((ScFormulaCell*)pCell)->IsEmptyDisplayedAsString())
- {
- aString.Erase();
- }
- else if (((ScFormulaCell*)pCell)->IsValue())
- {
- double nValue = ((ScFormulaCell*)pCell)->GetValue();
- rFormatter.GetInputLineString( nValue, nFormat, aString );
- }
- else
- {
- aString = ((ScFormulaCell*)pCell)->GetString();
- }
+ {
+ ScFormulaCell* pFC = rCell.mpFormula;
+ if (pFC->IsEmptyDisplayedAsString())
+ aString = EMPTY_OUSTRING;
+ else if (pFC->IsValue())
+ rFormatter.GetInputLineString(pFC->GetValue(), nFormat, aString);
+ else
+ aString = pFC->GetString();
- sal_uInt16 nErrCode = ((ScFormulaCell*)pCell)->GetErrCode();
- if (nErrCode != 0)
- {
- aString.Erase();
- }
- }
- break;
+ sal_uInt16 nErrCode = pFC->GetErrCode();
+ if (nErrCode != 0)
+ aString = EMPTY_OUSTRING;
+ }
+ break;
default:
- aString.Erase();
+ aString = EMPTY_OUSTRING;
break;
}
rString = aString;
diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx
index cf4bcac..b87bb7b 100644
--- a/sc/source/ui/docshell/docsh.cxx
+++ b/sc/source/ui/docshell/docsh.cxx
@@ -1921,7 +1921,9 @@ void ScDocShell::AsciiSave( SvStream& rStream, const ScImportOptions& rAsciiOpt
}
else
{
- ScCellFormat::GetInputString( pCell, nFormat, aString, rFormatter );
+ ScRefCellValue aCell;
+ aCell.assign(*pCell);
+ ScCellFormat::GetInputString(aCell, nFormat, aString, rFormatter);
bString = false;
}
}
@@ -1971,7 +1973,9 @@ void ScDocShell::AsciiSave( SvStream& rStream, const ScImportOptions& rAsciiOpt
}
else
{
- ScCellFormat::GetInputString( pCell, nFormat, aString, rFormatter );
+ ScRefCellValue aCell;
+ aCell.assign(*pCell);
+ ScCellFormat::GetInputString(aCell, nFormat, aString, rFormatter);
bString = false;
}
}
diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx
index aa403d7..45e41da 100644
--- a/sc/source/ui/unoobj/cellsuno.cxx
+++ b/sc/source/ui/unoobj/cellsuno.cxx
@@ -1427,7 +1427,11 @@ static String lcl_GetInputString( ScDocument* pDoc, const ScAddress& rPosition,
}
}
else
- ScCellFormat::GetInputString( pCell, nNumFmt, aVal, *pFormatter );
+ {
+ ScRefCellValue aCell;
+ aCell.assign(*pCell);
+ ScCellFormat::GetInputString(aCell, nNumFmt, aVal, *pFormatter);
+ }
// ggf. ein ' davorhaengen wie in ScTabViewShell::UpdateInputHandler
if ( eType == CELLTYPE_STRING || eType == CELLTYPE_EDIT )
commit eff4f0c0aa8f91ff5ea65cb44b35cfc901524198
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Tue Mar 26 21:35:20 2013 -0400
Kill more ScBaseCell usages.
Change-Id: I6fdcdd6763e6da1fd25c6bded22960a1be6d7f66
diff --git a/sc/source/ui/inc/output.hxx b/sc/source/ui/inc/output.hxx
index 2f1330c..ffe26d1 100644
--- a/sc/source/ui/inc/output.hxx
+++ b/sc/source/ui/inc/output.hxx
@@ -21,6 +21,7 @@
#define SC_OUTPUT_HXX
#include "address.hxx"
+#include "cellvalue.hxx"
#include <tools/color.hxx>
#include <tools/fract.hxx>
#include <com/sun/star/embed/XEmbeddedObject.hpp>
@@ -84,14 +85,14 @@ private:
long mnPosX;
long mnPosY;
long mnInitPosX;
- bool mbBreak;
- bool mbCellIsValue;
- bool mbAsianVertical;
- bool mbPixelToLogic;
- bool mbHyphenatorSet;
- bool mbRTL;
+ bool mbBreak:1;
+ bool mbCellIsValue:1;
+ bool mbAsianVertical:1;
+ bool mbPixelToLogic:1;
+ bool mbHyphenatorSet:1;
+ bool mbRTL:1;
ScFieldEditEngine* mpEngine;
- ScBaseCell* mpCell;
+ ScRefCellValue maCell;
const ScPatternAttr* mpPattern;
const SfxItemSet* mpCondSet;
const ScPatternAttr* mpOldPattern;
@@ -223,8 +224,8 @@ private:
long& rEngineWidth, long& rEngineHeight, long& rNeededPixel,
bool& rLeftClip, bool& rRightClip );
- void SetSyntaxColor( Font* pFont, ScBaseCell* pCell );
- void SetEditSyntaxColor( EditEngine& rEngine, ScBaseCell* pCell );
+ void SetSyntaxColor( Font* pFont, const ScRefCellValue& rCell );
+ void SetEditSyntaxColor( EditEngine& rEngine, ScRefCellValue& rCell );
double GetStretch();
diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx
index b9e1201..e66631a 100644
--- a/sc/source/ui/view/output2.cxx
+++ b/sc/source/ui/view/output2.cxx
@@ -53,7 +53,6 @@
#include "progress.hxx"
#include "scmod.hxx"
#include "fillinfo.hxx"
-#include "cellvalue.hxx"
#include <com/sun/star/i18n/DirectionProperty.hpp>
#include <comphelper/string.hxx>
@@ -124,7 +123,10 @@ public:
// SetPattern = ex-SetVars
// SetPatternSimple: ohne Font
- void SetPattern( const ScPatternAttr* pNew, const SfxItemSet* pSet, ScBaseCell* pCell, sal_uInt8 nScript );
+ void SetPattern(
+ const ScPatternAttr* pNew, const SfxItemSet* pSet, const ScRefCellValue& rCell,
+ sal_uInt8 nScript );
+
void SetPatternSimple( const ScPatternAttr* pNew, const SfxItemSet* pSet );
sal_Bool SetText( ScBaseCell* pCell ); // TRUE -> pOldPattern vergessen
@@ -272,8 +274,9 @@ bool lcl_GetBoolValue(const ScPatternAttr& rPattern, sal_uInt16 nWhich, const Sf
}
-void ScDrawStringsVars::SetPattern( const ScPatternAttr* pNew, const SfxItemSet* pSet,
- ScBaseCell* pCell, sal_uInt8 nScript )
+void ScDrawStringsVars::SetPattern(
+ const ScPatternAttr* pNew, const SfxItemSet* pSet, const ScRefCellValue& rCell,
+ sal_uInt8 nScript )
{
nMaxDigitWidth = 0;
nSignWidth = 0;
@@ -375,7 +378,7 @@ void ScDrawStringsVars::SetPattern( const ScPatternAttr* pNew, const SfxItemSet*
// Syntax-Modus
if (pOutput->mbSyntaxMode)
- pOutput->SetSyntaxColor( &aFont, pCell );
+ pOutput->SetSyntaxColor(&aFont, rCell);
pDev->SetFont( aFont );
if ( pFmtDevice != pDev )
@@ -836,15 +839,15 @@ double ScOutputData::GetStretch()
// output strings
//
-static void lcl_DoHyperlinkResult( OutputDevice* pDev, const Rectangle& rRect, ScBaseCell* pCell )
+static void lcl_DoHyperlinkResult( OutputDevice* pDev, const Rectangle& rRect, ScRefCellValue& rCell )
{
vcl::PDFExtOutDevData* pPDFData = PTR_CAST( vcl::PDFExtOutDevData, pDev->GetExtOutDevData() );
- rtl::OUString aCellText;
- rtl::OUString aURL;
- if ( pCell && pCell->GetCellType() == CELLTYPE_FORMULA )
+ OUString aCellText;
+ OUString aURL;
+ if (rCell.meType == CELLTYPE_FORMULA)
{
- ScFormulaCell* pFCell = static_cast<ScFormulaCell*>(pCell);
+ ScFormulaCell* pFCell = rCell.mpFormula;
if ( pFCell->IsHyperLinkCell() )
pFCell->GetURLResult( aURL, aCellText );
}
@@ -859,25 +862,22 @@ static void lcl_DoHyperlinkResult( OutputDevice* pDev, const Rectangle& rRect, S
}
}
-void ScOutputData::SetSyntaxColor( Font* pFont, ScBaseCell* pCell )
+void ScOutputData::SetSyntaxColor( Font* pFont, const ScRefCellValue& rCell )
{
- if (pCell)
+ switch (rCell.meType)
{
- switch (pCell->GetCellType())
+ case CELLTYPE_VALUE:
+ pFont->SetColor(*pValueColor);
+ break;
+ case CELLTYPE_STRING:
+ pFont->SetColor(*pTextColor);
+ break;
+ case CELLTYPE_FORMULA:
+ pFont->SetColor(*pFormulaColor);
+ break;
+ default:
{
- case CELLTYPE_VALUE:
- pFont->SetColor( *pValueColor );
- break;
- case CELLTYPE_STRING:
- pFont->SetColor( *pTextColor );
- break;
- case CELLTYPE_FORMULA:
- pFont->SetColor( *pFormulaColor );
- break;
- default:
- {
- // added to avoid warnings
- }
+ // added to avoid warnings
}
}
}
@@ -891,29 +891,26 @@ static void lcl_SetEditColor( EditEngine& rEngine, const Color& rColor )
// function is called with update mode set to FALSE
}
-void ScOutputData::SetEditSyntaxColor( EditEngine& rEngine, ScBaseCell* pCell )
+void ScOutputData::SetEditSyntaxColor( EditEngine& rEngine, ScRefCellValue& rCell )
{
- if (pCell)
+ Color aColor;
+ switch (rCell.meType)
{
- Color aColor;
- switch (pCell->GetCellType())
+ case CELLTYPE_VALUE:
+ aColor = *pValueColor;
+ break;
+ case CELLTYPE_STRING:
+ aColor = *pTextColor;
+ break;
+ case CELLTYPE_FORMULA:
+ aColor = *pFormulaColor;
+ break;
+ default:
{
- case CELLTYPE_VALUE:
- aColor = *pValueColor;
- break;
- case CELLTYPE_STRING:
- aColor = *pTextColor;
- break;
- case CELLTYPE_FORMULA:
- aColor = *pFormulaColor;
- break;
- default:
- {
- // added to avoid warnings
- }
+ // added to avoid warnings
}
- lcl_SetEditColor( rEngine, aColor );
}
+ lcl_SetEditColor( rEngine, aColor );
}
sal_Bool ScOutputData::GetMergeOrigin( SCCOL nX, SCROW nY, SCSIZE nArrY,
@@ -1612,7 +1609,11 @@ void ScOutputData::DrawStrings( sal_Bool bPixelToLogic )
{
if ( StringDiffer(pOldPattern,pPattern) ||
pCondSet != pOldCondSet || nScript != nOldScript || mbSyntaxMode )
- aVars.SetPattern( pPattern, pCondSet, pCell, nScript );
+ {
+ ScRefCellValue aCell;
+ aCell.assign(*pCell);
+ aVars.SetPattern(pPattern, pCondSet, aCell, nScript);
+ }
else
aVars.SetPatternSimple( pPattern, pCondSet );
pOldPattern = pPattern;
@@ -2005,7 +2006,10 @@ void ScOutputData::DrawStrings( sal_Bool bPixelToLogic )
if ( bHasURL )
{
Rectangle aURLRect( aURLStart, aVars.GetTextSize() );
- lcl_DoHyperlinkResult( mpDev, aURLRect, pCell );
+ ScRefCellValue aCell;
+ if (pCell)
+ aCell.assign(*pCell);
+ lcl_DoHyperlinkResult(mpDev, aURLRect, aCell);
}
}
}
@@ -2242,7 +2246,6 @@ ScOutputData::DrawEditParam::DrawEditParam(const ScPatternAttr* pPattern, const
mbHyphenatorSet(false),
mbRTL(false),
mpEngine(NULL),
- mpCell(NULL),
mpPattern(pPattern),
mpCondSet(pCondSet),
mpOldPattern(NULL),
@@ -2253,15 +2256,9 @@ ScOutputData::DrawEditParam::DrawEditParam(const ScPatternAttr* pPattern, const
bool ScOutputData::DrawEditParam::readCellContent(
ScDocument* pDoc, bool bShowNullValues, bool bShowFormulas, bool bSyntaxMode, bool bUseStyleColor, bool bForceAutoColor, bool& rWrapFields)
{
- if (!mpCell)
+ if (maCell.meType == CELLTYPE_EDIT)
{
- OSL_FAIL("pCell == NULL");
- return false;
- }
-
- if (mpCell->GetCellType() == CELLTYPE_EDIT)
- {
- const EditTextObject* pData = static_cast<ScEditCell*>(mpCell)->GetData();
+ const EditTextObject* pData = maCell.mpEditText;
if (pData)
{
mpEngine->SetText(*pData);
@@ -2286,9 +2283,7 @@ bool ScOutputData::DrawEditParam::readCellContent(
pDoc->GetFormatTable(), mpCondSet );
OUString aString;
Color* pColor;
- ScRefCellValue aCell;
- aCell.assign(*mpCell);
- ScCellFormat::GetString( aCell,
+ ScCellFormat::GetString( maCell,
nFormat,aString, &pColor,
*pDoc->GetFormatTable(),
bShowNullValues,
@@ -2413,13 +2408,10 @@ bool ScOutputData::DrawEditParam::hasLineBreak() const
bool ScOutputData::DrawEditParam::isHyperlinkCell() const
{
- if (!mpCell)
- return false;
-
- if (mpCell->GetCellType() != CELLTYPE_FORMULA)
+ if (maCell.meType != CELLTYPE_FORMULA)
return false;
- return static_cast<ScFormulaCell*>(mpCell)->IsHyperLinkCell();
+ return maCell.mpFormula->IsHyperLinkCell();
}
bool ScOutputData::DrawEditParam::isVerticallyOriented() const
@@ -2554,13 +2546,12 @@ void ScOutputData::DrawEditParam::setAlignmentToEngine()
}
mpEngine->SetVertical(mbAsianVertical);
- if (mpCell && mpCell->GetCellType() == CELLTYPE_EDIT)
+ if (maCell.meType == CELLTYPE_EDIT)
{
// We need to synchronize the vertical mode in the EditTextObject
// instance too. No idea why we keep this state in two separate
// instances.
- ScEditCell* pEditCell = static_cast<ScEditCell*>(mpCell);
- const EditTextObject* pData = pEditCell->GetData();
+ const EditTextObject* pData = maCell.mpEditText;
if (pData)
const_cast<EditTextObject*>(pData)->SetVertical(mbAsianVertical);
}
@@ -2623,7 +2614,7 @@ void ScOutputData::DrawEditParam::adjustForHyperlinkInPDF(Point aURLStart, Outpu
aURLStart.X() -= nURLWidth;
Rectangle aURLRect( aURLStart, Size( nURLWidth, nURLHeight ) );
- lcl_DoHyperlinkResult( pDev, aURLRect, mpCell );
+ lcl_DoHyperlinkResult(pDev, aURLRect, maCell);
}
void ScOutputData::DrawEditStandard(DrawEditParam& rParam)
@@ -2748,7 +2739,7 @@ void ScOutputData::DrawEditStandard(DrawEditParam& rParam)
return;
if ( mbSyntaxMode )
- SetEditSyntaxColor( *rParam.mpEngine, rParam.mpCell );
+ SetEditSyntaxColor(*rParam.mpEngine, rParam.maCell);
else if ( mbUseStyleColor && mbForceAutoColor )
lcl_SetEditColor( *rParam.mpEngine, COL_AUTO ); //! or have a flag at EditEngine
@@ -3130,7 +3121,7 @@ void ScOutputData::DrawEditBottomTop(DrawEditParam& rParam)
return;
if ( mbSyntaxMode )
- SetEditSyntaxColor( *rParam.mpEngine, rParam.mpCell );
+ SetEditSyntaxColor( *rParam.mpEngine, rParam.maCell );
else if ( mbUseStyleColor && mbForceAutoColor )
lcl_SetEditColor( *rParam.mpEngine, COL_AUTO ); //! or have a flag at EditEngine
@@ -3500,7 +3491,7 @@ void ScOutputData::DrawEditTopBottom(DrawEditParam& rParam)
return;
if ( mbSyntaxMode )
- SetEditSyntaxColor( *rParam.mpEngine, rParam.mpCell );
+ SetEditSyntaxColor( *rParam.mpEngine, rParam.maCell );
else if ( mbUseStyleColor && mbForceAutoColor )
lcl_SetEditColor( *rParam.mpEngine, COL_AUTO ); //! or have a flag at EditEngine
@@ -3884,7 +3875,7 @@ void ScOutputData::DrawEditStacked(DrawEditParam& rParam)
return;
if ( mbSyntaxMode )
- SetEditSyntaxColor( *rParam.mpEngine, rParam.mpCell );
+ SetEditSyntaxColor( *rParam.mpEngine, rParam.maCell );
else if ( mbUseStyleColor && mbForceAutoColor )
lcl_SetEditColor( *rParam.mpEngine, COL_AUTO ); //! or have a flag at EditEngine
@@ -4293,7 +4284,7 @@ void ScOutputData::DrawEditAsianVertical(DrawEditParam& rParam)
return;
if ( mbSyntaxMode )
- SetEditSyntaxColor( *rParam.mpEngine, rParam.mpCell );
+ SetEditSyntaxColor( *rParam.mpEngine, rParam.maCell );
else if ( mbUseStyleColor && mbForceAutoColor )
lcl_SetEditColor( *rParam.mpEngine, COL_AUTO ); //! or have a flag at EditEngine
@@ -4675,7 +4666,8 @@ void ScOutputData::DrawEdit(sal_Bool bPixelToLogic)
aParam.mbHyphenatorSet = bHyphenatorSet;
aParam.mbRTL = beginsWithRTLCharacter(aStr);
aParam.mpEngine = pEngine;
- aParam.mpCell = pCell;
+ if (pCell)
+ aParam.maCell.assign(*pCell);
aParam.mnArrY = nArrY;
aParam.mnX = nX;
aParam.mnY = nY;
@@ -5013,7 +5005,11 @@ void ScOutputData::DrawRotated(sal_Bool bPixelToLogic)
}
if ( mbSyntaxMode )
- SetEditSyntaxColor( *pEngine, pCell );
+ {
+ ScRefCellValue aCell;
+ aCell.assign(*pCell);
+ SetEditSyntaxColor(*pEngine, aCell);
+ }
else if ( mbUseStyleColor && mbForceAutoColor )
lcl_SetEditColor( *pEngine, COL_AUTO ); //! or have a flag at EditEngine
}
commit 63fb74aead373e62a3be36fde3a81fb08964d3e0
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Tue Mar 26 21:06:14 2013 -0400
Remove variant of GetCellString() that takes ScBaseCell*.
Change-Id: Ide78ab011e1f06bdb61ac2b29bc7c170cdb8d245
diff --git a/sc/inc/cellform.hxx b/sc/inc/cellform.hxx
index e2935a0..c7083ec 100644
--- a/sc/inc/cellform.hxx
+++ b/sc/inc/cellform.hxx
@@ -41,12 +41,6 @@ enum ScForceTextFmt {
class SC_DLLPUBLIC ScCellFormat
{
public:
- static void GetString( ScBaseCell* pCell, sal_uLong nFormat, rtl::OUString& rString,
- Color** ppColor, SvNumberFormatter& rFormatter,
- sal_Bool bNullVals = sal_True,
- sal_Bool bFormula = false,
- ScForceTextFmt eForceTextFmt = ftDontForce,
- bool bUseStarFormat = false );
static void GetString(
ScRefCellValue& rCell, sal_uLong nFormat, rtl::OUString& rString,
diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index ac329b2..dc81438 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -73,6 +73,8 @@ struct ScSetStringParam;
struct ScColWidthParam;
class ScColumnTextWidthIterator;
struct ScFormulaCellGroup;
+struct ScRefCellValue;
+
typedef ::boost::intrusive_ptr<ScFormulaCellGroup> ScFormulaCellGroupRef;
struct ScNeededSizeOptions
@@ -152,6 +154,7 @@ public:
bool Search( SCROW nRow, SCSIZE& nIndex ) const;
ScBaseCell* GetCell( SCROW nRow ) const;
+ ScRefCellValue GetCellValue( SCROW nRow ) const;
void Insert( SCROW nRow, ScBaseCell* pCell );
void Insert( SCROW nRow, sal_uInt32 nFormatIndex, ScBaseCell* pCell );
void Append( SCROW nRow, ScBaseCell* pCell );
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index 5607211..cf09270 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -30,6 +30,7 @@
#include "detfunc.hxx" // for Notes in Sort/Swap
#include "postit.hxx"
#include "globalnames.hxx"
+#include "cellvalue.hxx"
#include <svl/poolcach.hxx>
#include <svl/zforlist.hxx>
@@ -794,6 +795,16 @@ ScBaseCell* ScColumn::GetCell( SCROW nRow ) const
return NULL;
}
+ScRefCellValue ScColumn::GetCellValue( SCROW nRow ) const
+{
+ ScRefCellValue aVal;
+ SCSIZE nIndex;
+ if (Search(nRow, nIndex))
+ aVal.assign(*maItems[nIndex].pCell);
+
+ return aVal;
+}
+
void ScColumn::ReserveSize( SCSIZE nSize )
{
if (nSize > sal::static_int_cast<SCSIZE>(MAXROWCOUNT))
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index 4108cdc..e4a9931 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -53,6 +53,7 @@
#include "fillinfo.hxx"
#include "segmenttree.hxx"
#include "docparam.hxx"
+#include "cellvalue.hxx"
#include <math.h>
@@ -97,7 +98,9 @@ long ScColumn::GetNeededSize(
double nPPT = bWidth ? nPPTX : nPPTY;
if (Search(nRow,nIndex))
{
- ScBaseCell* pCell = maItems[nIndex].pCell;
+ ScRefCellValue aCell;
+ aCell.assign(*maItems[nIndex].pCell);
+
const ScPatternAttr* pPattern = rOptions.pPattern;
if (!pPattern)
pPattern = pAttrArray->GetPattern( nRow );
@@ -148,11 +151,11 @@ long ScColumn::GetNeededSize(
SvNumberFormatter* pFormatter = pDocument->GetFormatTable();
sal_uLong nFormat = pPattern->GetNumberFormat( pFormatter, pCondSet );
// #i111387# disable automatic line breaks only for "General" number format
- if ( bBreak && pCell->HasValueData() && ( nFormat % SV_COUNTRY_LANGUAGE_OFFSET ) == 0 )
+ if (bBreak && aCell.hasNumeric() && ( nFormat % SV_COUNTRY_LANGUAGE_OFFSET ) == 0 )
{
// also take formula result type into account for number format
- if ( pCell->GetCellType() != CELLTYPE_FORMULA ||
- ( static_cast<ScFormulaCell*>(pCell)->GetStandardFormat(*pFormatter, nFormat) % SV_COUNTRY_LANGUAGE_OFFSET ) == 0 )
+ if (aCell.meType != CELLTYPE_FORMULA ||
+ (aCell.mpFormula->GetStandardFormat(*pFormatter, nFormat) % SV_COUNTRY_LANGUAGE_OFFSET) == 0)
bBreak = false;
}
@@ -229,20 +232,20 @@ long ScColumn::GetNeededSize(
}
bool bAddMargin = true;
- CellType eCellType = pCell->GetCellType();
+ CellType eCellType = aCell.meType;
- bool bEditEngine = ( eCellType == CELLTYPE_EDIT ||
- eOrient == SVX_ORIENTATION_STACKED ||
- IsAmbiguousScript( nScript ) ||
- ((eCellType == CELLTYPE_FORMULA) && ((ScFormulaCell*)pCell)->IsMultilineResult()) );
+ bool bEditEngine = (eCellType == CELLTYPE_EDIT ||
+ eOrient == SVX_ORIENTATION_STACKED ||
+ IsAmbiguousScript(nScript) ||
+ ((eCellType == CELLTYPE_FORMULA) && aCell.mpFormula->IsMultilineResult()));
if (!bEditEngine) // direct output
{
Color* pColor;
rtl::OUString aValStr;
- ScCellFormat::GetString( pCell, nFormat, aValStr, &pColor,
- *pFormatter,
- true, rOptions.bFormula, ftCheck );
+ ScCellFormat::GetString(
+ aCell, nFormat, aValStr, &pColor, *pFormatter, true, rOptions.bFormula, ftCheck);
+
if (!aValStr.isEmpty())
{
// SetFont is moved up
@@ -394,18 +397,18 @@ long ScColumn::GetNeededSize(
}
pEngine->SetPaperSize(aPaper);
- if ( pCell->GetCellType() == CELLTYPE_EDIT )
+ if (aCell.meType == CELLTYPE_EDIT)
{
- const EditTextObject* pData = static_cast<ScEditCell*>(pCell)->GetData();
- pEngine->SetTextNewDefaults(*pData, pSet);
+ pEngine->SetTextNewDefaults(*aCell.mpEditText, pSet);
}
else
{
Color* pColor;
- rtl::OUString aString;
- ScCellFormat::GetString( pCell, nFormat, aString, &pColor,
- *pFormatter,
- true, rOptions.bFormula, ftCheck );
+ OUString aString;
+ ScCellFormat::GetString(
+ aCell, nFormat, aString, &pColor, *pFormatter, true,
+ rOptions.bFormula, ftCheck);
+
if (!aString.isEmpty())
pEngine->SetTextNewDefaults(aString, pSet);
else
@@ -560,9 +563,9 @@ sal_uInt16 ScColumn::GetOptimalColWidth(
Color* pColor;
if (pParam->mnMaxTextRow >= 0)
{
- ScBaseCell* pCell = GetCell(pParam->mnMaxTextRow);
+ ScRefCellValue aCell = GetCellValue(pParam->mnMaxTextRow);
ScCellFormat::GetString(
- pCell, nFormat, aLongStr, &pColor, *pFormatter, true, false, ftCheck );
+ aCell, nFormat, aLongStr, &pColor, *pFormatter, true, false, ftCheck);
}
else
{
@@ -573,10 +576,11 @@ sal_uInt16 ScColumn::GetOptimalColWidth(
// Out-of-bound reached. No need to keep going.
break;
- ScBaseCell* pCell = maItems[nIndex].pCell;
- rtl::OUString aValStr;
+ ScRefCellValue aCell;
+ aCell.assign(*maItems[nIndex].pCell);
+ OUString aValStr;
ScCellFormat::GetString(
- pCell, nFormat, aValStr, &pColor, *pFormatter, true, false, ftCheck );
+ aCell, nFormat, aValStr, &pColor, *pFormatter, true, false, ftCheck);
if (aValStr.getLength() > nLongLen)
{
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index 3a591cd..8a70ce6 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -45,6 +45,7 @@
#include "stringutil.hxx"
#include "docpool.hxx"
#include "globalnames.hxx"
+#include "cellvalue.hxx"
#include <com/sun/star/i18n/LocaleDataItem.hpp>
@@ -1745,17 +1746,18 @@ void ScColumn::GetString( SCROW nRow, rtl::OUString& rString ) const
Color* pColor;
if (Search(nRow, nIndex))
{
- ScBaseCell* pCell = maItems[nIndex].pCell;
- if (pCell->GetCellType() != CELLTYPE_NOTE)
+ ScRefCellValue aCell;
+ aCell.assign(*maItems[nIndex].pCell);
+ if (aCell.meType != CELLTYPE_NOTE)
{
sal_uLong nFormat = GetNumberFormat( nRow );
- ScCellFormat::GetString( pCell, nFormat, rString, &pColor, *(pDocument->GetFormatTable()) );
+ ScCellFormat::GetString(aCell, nFormat, rString, &pColor, *(pDocument->GetFormatTable()));
}
else
- rString = rtl::OUString();
+ rString = EMPTY_OUSTRING;
}
else
- rString = rtl::OUString();
+ rString = EMPTY_OUSTRING;
}
const OUString* ScColumn::GetStringCell( SCROW nRow ) const
@@ -1942,14 +1944,14 @@ sal_Int32 ScColumn::GetMaxStringLen( SCROW nRowStart, SCROW nRowEnd, CharSet eCh
Search( nRowStart, nIndex );
while ( nIndex < maItems.size() && (nRow = maItems[nIndex].nRow) <= nRowEnd )
{
- ScBaseCell* pCell = maItems[nIndex].pCell;
- if ( pCell->GetCellType() != CELLTYPE_NOTE )
+ ScRefCellValue aCell;
+ aCell.assign(*maItems[nIndex].pCell);
+ if (aCell.meType != CELLTYPE_NOTE)
{
Color* pColor;
sal_uLong nFormat = (sal_uLong) ((SfxUInt32Item*) GetAttr(
nRow, ATTR_VALUE_FORMAT ))->GetValue();
- ScCellFormat::GetString( pCell, nFormat, aString, &pColor,
- *pNumFmt );
+ ScCellFormat::GetString(aCell, nFormat, aString, &pColor, *pNumFmt);
sal_Int32 nLen;
if (bIsOctetTextEncoding)
{
diff --git a/sc/source/core/tool/cellform.cxx b/sc/source/core/tool/cellform.cxx
index 8254a96..8d0a903 100644
--- a/sc/source/core/tool/cellform.cxx
+++ b/sc/source/core/tool/cellform.cxx
@@ -33,117 +33,6 @@
// Err527 Workaround
const ScFormulaCell* pLastFormulaTreeTop = 0;
-void ScCellFormat::GetString( ScBaseCell* pCell, sal_uLong nFormat, OUString& rString,
- Color** ppColor, SvNumberFormatter& rFormatter,
- sal_Bool bNullVals,
- sal_Bool bFormula,
- ScForceTextFmt eForceTextFmt,
- bool bUseStarFormat )
-{
- *ppColor = NULL;
- if (&rFormatter==NULL)
- {
- rString = OUString();
- return;
- }
-
- CellType eType = pCell->GetCellType();
- switch(eType)
- {
- case CELLTYPE_STRING:
- {
- OUString aCellString = ((ScStringCell*)pCell)->GetString();
- rFormatter.GetOutputString( aCellString, nFormat, rString, ppColor, bUseStarFormat );
- }
- break;
- case CELLTYPE_EDIT:
- {
- OUString aCellString = ((ScEditCell*)pCell)->GetString();
- rFormatter.GetOutputString( aCellString, nFormat, rString, ppColor );
- }
- break;
- case CELLTYPE_VALUE:
- {
- double nValue = ((ScValueCell*)pCell)->GetValue();
- if ( !bNullVals && nValue == 0.0 )
- rString = OUString();
- else
- {
- if( eForceTextFmt == ftCheck )
- {
- if( nFormat && rFormatter.IsTextFormat( nFormat ) )
- eForceTextFmt = ftForce;
- }
- if( eForceTextFmt == ftForce )
- {
- OUString aTemp;
- rFormatter.GetOutputString( nValue, 0, aTemp, ppColor );
- rFormatter.GetOutputString( aTemp, nFormat, rString, ppColor );
- }
- else
- rFormatter.GetOutputString( nValue, nFormat, rString, ppColor, bUseStarFormat );
- }
- }
- break;
- case CELLTYPE_FORMULA:
- {
- ScFormulaCell* pFCell = (ScFormulaCell*)pCell;
- if ( bFormula )
- {
- pFCell->GetFormula( rString );
- }
- else
- {
- // A macro started from the interpreter, which has
- // access to Formular Cells, becomes a CellText, even if
- // that triggers further interpretation, except if those
- // cells are already being interpreted.
- // IdleCalc generally doesn't trigger futher interpretation,
- // as not to get Err522 (circular).
- if ( pFCell->GetDocument()->IsInInterpreter() &&
- (!pFCell->GetDocument()->GetMacroInterpretLevel()
- || pFCell->IsRunning()) )
- {
- rString = OUString("...");
- }
- else
- {
- sal_uInt16 nErrCode = pFCell->GetErrCode();
-
- // get the number format only after interpretation (GetErrCode):
- if ( (nFormat % SV_COUNTRY_LANGUAGE_OFFSET) == 0 )
- nFormat = pFCell->GetStandardFormat( rFormatter,
- nFormat );
-
- if (nErrCode != 0)
- rString = ScGlobal::GetErrorString(nErrCode);
- else if ( pFCell->IsEmptyDisplayedAsString() )
- rString = OUString();
- else if ( pFCell->IsValue() )
- {
- double fValue = pFCell->GetValue();
- if ( !bNullVals && fValue == 0.0 )
- rString = OUString();
- else if ( pFCell->IsHybridValueCell() )
- rString = pFCell->GetString();
- else
- rFormatter.GetOutputString( fValue, nFormat, rString, ppColor, bUseStarFormat );
- }
- else
- {
- OUString aCellString = pFCell->GetString();
- rFormatter.GetOutputString( aCellString, nFormat, rString, ppColor, bUseStarFormat );
- }
- }
- }
- }
- break;
- default:
- rString = OUString();
- break;
- }
-}
-
void ScCellFormat::GetString( ScRefCellValue& rCell, sal_uLong nFormat, OUString& rString,
Color** ppColor, SvNumberFormatter& rFormatter,
bool bNullVals, bool bFormula, ScForceTextFmt eForceTextFmt,
diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx
index 449f9de..b9e1201 100644
--- a/sc/source/ui/view/output2.cxx
+++ b/sc/source/ui/view/output2.cxx
@@ -53,6 +53,7 @@
#include "progress.hxx"
#include "scmod.hxx"
#include "fillinfo.hxx"
+#include "cellvalue.hxx"
#include <com/sun/star/i18n/DirectionProperty.hpp>
#include <comphelper/string.hxx>
@@ -478,7 +479,7 @@ inline sal_Bool SameValue( ScBaseCell* pCell, ScBaseCell* pOldCell ) // pCell
sal_Bool ScDrawStringsVars::SetText( ScBaseCell* pCell )
{
- sal_Bool bChanged = false;
+ bool bChanged = false;
if (pCell)
{
@@ -488,8 +489,10 @@ sal_Bool ScDrawStringsVars::SetText( ScBaseCell* pCell )
Color* pColor;
sal_uLong nFormat = GetValueFormat();
- rtl::OUString aOUString = aString;
- ScCellFormat::GetString( pCell,
+ OUString aOUString = aString;
+ ScRefCellValue aCell;
+ aCell.assign(*pCell);
+ ScCellFormat::GetString( aCell,
nFormat, aOUString, &pColor,
*pOutput->mpDoc->GetFormatTable(),
pOutput->mbShowNullValues,
@@ -2281,9 +2284,11 @@ bool ScOutputData::DrawEditParam::readCellContent(
{
sal_uLong nFormat = mpPattern->GetNumberFormat(
pDoc->GetFormatTable(), mpCondSet );
- rtl::OUString aString;
+ OUString aString;
Color* pColor;
- ScCellFormat::GetString( mpCell,
+ ScRefCellValue aCell;
+ aCell.assign(*mpCell);
+ ScCellFormat::GetString( aCell,
nFormat,aString, &pColor,
*pDoc->GetFormatTable(),
bShowNullValues,
@@ -4993,7 +4998,9 @@ void ScOutputData::DrawRotated(sal_Bool bPixelToLogic)
mpDoc->GetFormatTable(), pCondSet );
rtl::OUString aString;
Color* pColor;
- ScCellFormat::GetString( pCell,
+ ScRefCellValue aCell;
+ aCell.assign(*pCell);
+ ScCellFormat::GetString( aCell,
nFormat,aString, &pColor,
*mpDoc->GetFormatTable(),
mbShowNullValues,
commit f1211bc84d62598be18d9a61e8d63563a0d74f5a
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Tue Mar 26 19:38:24 2013 -0400
Converted the external ref manager code.
Change-Id: Ifbce13bc8a941e548b1ba647519cf9765b7f55d0
diff --git a/sc/inc/cellvalue.hxx b/sc/inc/cellvalue.hxx
index d4ef307..fb7c175 100644
--- a/sc/inc/cellvalue.hxx
+++ b/sc/inc/cellvalue.hxx
@@ -130,6 +130,8 @@ struct SC_DLLPUBLIC ScRefCellValue
bool isEmpty() const;
+ bool hasEmptyValue();
+
bool equalsWithoutFormat( const ScRefCellValue& r ) const;
ScRefCellValue& operator= ( const ScRefCellValue& r );
diff --git a/sc/inc/externalrefmgr.hxx b/sc/inc/externalrefmgr.hxx
index 87693a3..c49ec90 100644
--- a/sc/inc/externalrefmgr.hxx
+++ b/sc/inc/externalrefmgr.hxx
@@ -690,7 +690,7 @@ private:
void fillCellFormat(sal_uLong nFmtIndex, ScExternalRefCache::CellFormat* pFmt) const;
ScExternalRefCache::TokenRef getSingleRefTokenFromSrcDoc(
- sal_uInt16 nFileId, const ScDocument* pSrcDoc, const ScAddress& rCell,
+ sal_uInt16 nFileId, ScDocument* pSrcDoc, const ScAddress& rPos,
ScExternalRefCache::CellFormat* pFmt);
/**
@@ -708,7 +708,7 @@ private:
* @return range token array
*/
ScExternalRefCache::TokenArrayRef getDoubleRefTokensFromSrcDoc(
- const ScDocument* pSrcDoc, const ::rtl::OUString& rTabName, ScRange& rRange,
+ ScDocument* pSrcDoc, const ::rtl::OUString& rTabName, ScRange& rRange,
::std::vector<ScExternalRefCache::SingleRangeData>& rCacheData);
/**
@@ -724,10 +724,10 @@ private:
* @return range name token array
*/
ScExternalRefCache::TokenArrayRef getRangeNameTokensFromSrcDoc(
- sal_uInt16 nFileId, const ScDocument* pSrcDoc, ::rtl::OUString& rName);
+ sal_uInt16 nFileId, ScDocument* pSrcDoc, ::rtl::OUString& rName);
- const ScDocument* getInMemorySrcDocument(sal_uInt16 nFileId);
- const ScDocument* getSrcDocument(sal_uInt16 nFileId);
+ ScDocument* getInMemorySrcDocument(sal_uInt16 nFileId);
+ ScDocument* getSrcDocument(sal_uInt16 nFileId);
SfxObjectShellRef loadSrcDocument(sal_uInt16 nFileId, ::rtl::OUString& rFilter);
void maybeLinkExternalFile(sal_uInt16 nFileId);
diff --git a/sc/source/core/data/cellvalue.cxx b/sc/source/core/data/cellvalue.cxx
index e4f0c2e..7ef5bda 100644
--- a/sc/source/core/data/cellvalue.cxx
+++ b/sc/source/core/data/cellvalue.cxx
@@ -514,6 +514,17 @@ bool ScRefCellValue::isEmpty() const
return meType == CELLTYPE_NOTE || meType == CELLTYPE_NONE;
}
+bool ScRefCellValue::hasEmptyValue()
+{
+ if (isEmpty())
+ return true;
+
+ if (meType == CELLTYPE_FORMULA)
+ return mpFormula->IsEmpty();
+
+ return false;
+}
+
bool ScRefCellValue::equalsWithoutFormat( const ScRefCellValue& r ) const
{
return equalsWithoutFormatImpl(*this, r);
diff --git a/sc/source/ui/docshell/externalrefmgr.cxx b/sc/source/ui/docshell/externalrefmgr.cxx
index fc49c7c..7a61019 100644
--- a/sc/source/ui/docshell/externalrefmgr.cxx
+++ b/sc/source/ui/docshell/externalrefmgr.cxx
@@ -31,6 +31,7 @@
#include "tabvwsh.hxx"
#include "sc.hrc"
#include "globstr.hrc"
+#include "cellvalue.hxx"
#include "sfx2/app.hxx"
#include "sfx2/docfilt.hxx"
@@ -1261,34 +1262,24 @@ IMPL_LINK_NOARG(ScExternalRefLink, ExternalRefEndEditHdl)
// ============================================================================
-static FormulaToken* lcl_convertToToken(ScBaseCell* pCell)
+static FormulaToken* convertToToken( ScRefCellValue& rCell )
{
- if (!pCell || pCell->HasEmptyData())
+ if (rCell.hasEmptyValue())
{
- bool bInherited = (pCell && pCell->GetCellType() == CELLTYPE_FORMULA);
- return new ScEmptyCellToken( bInherited, false);
+ bool bInherited = (rCell.meType == CELLTYPE_FORMULA);
+ return new ScEmptyCellToken(bInherited, false);
}
- switch (pCell->GetCellType())
+ switch (rCell.meType)
{
case CELLTYPE_EDIT:
- {
- rtl::OUString aStr = static_cast<ScEditCell*>(pCell)->GetString();
- return new formula::FormulaStringToken(aStr);
- }
case CELLTYPE_STRING:
- {
- rtl::OUString aStr = static_cast<ScStringCell*>(pCell)->GetString();
- return new formula::FormulaStringToken(aStr);
- }
+ return new formula::FormulaStringToken(rCell.getString());
case CELLTYPE_VALUE:
- {
- double fVal = static_cast<ScValueCell*>(pCell)->GetValue();
- return new formula::FormulaDoubleToken(fVal);
- }
+ return new formula::FormulaDoubleToken(rCell.mfValue);
case CELLTYPE_FORMULA:
{
- ScFormulaCell* pFCell = static_cast<ScFormulaCell*>(pCell);
+ ScFormulaCell* pFCell = rCell.mpFormula;
sal_uInt16 nError = pFCell->GetErrCode();
if (nError)
return new FormulaErrorToken( nError);
@@ -1299,7 +1290,7 @@ static FormulaToken* lcl_convertToToken(ScBaseCell* pCell)
}
else
{
- rtl::OUString aStr = pFCell->GetString();
+ OUString aStr = pFCell->GetString();
return new formula::FormulaStringToken(aStr);
}
}
@@ -1310,8 +1301,8 @@ static FormulaToken* lcl_convertToToken(ScBaseCell* pCell)
return NULL;
}
-static ScTokenArray* lcl_convertToTokenArray(const ScDocument* pSrcDoc, ScRange& rRange,
- vector<ScExternalRefCache::SingleRangeData>& rCacheData)
+static ScTokenArray* convertToTokenArray(
+ ScDocument* pSrcDoc, ScRange& rRange, vector<ScExternalRefCache::SingleRangeData>& rCacheData )
{
ScAddress& s = rRange.aStart;
ScAddress& e = rRange.aEnd;
@@ -1356,40 +1347,31 @@ static ScTokenArray* lcl_convertToTokenArray(const ScDocument* pSrcDoc, ScRange&
ScMatrixRef xMat = new ScMatrix(
static_cast<SCSIZE>(nCol2-nCol1+1), static_cast<SCSIZE>(nRow2-nRow1+1));
+ ScRefCellValue aCell;
for (SCCOL nCol = nDataCol1; nCol <= nDataCol2; ++nCol)
{
for (SCROW nRow = nDataRow1; nRow <= nDataRow2; ++nRow)
{
SCSIZE nC = nCol - nCol1, nR = nRow - nRow1;
- ScBaseCell* pCell;
- pSrcDoc->GetCell(nCol, nRow, nTab, pCell);
- if (!pCell || pCell->HasEmptyData())
+
+ aCell.assign(*pSrcDoc, ScAddress(nCol, nRow, nTab));
+
+ if (aCell.hasEmptyValue())
// Skip empty cells. Matrix's default values are empty elements.
continue;
- switch (pCell->GetCellType())
+ switch (aCell.meType)
{
case CELLTYPE_EDIT:
- {
- rtl::OUString aStr = static_cast<ScEditCell*>(pCell)->GetString();
- xMat->PutString(aStr, nC, nR);
- }
- break;
case CELLTYPE_STRING:
- {
- rtl::OUString aStr = static_cast<ScStringCell*>(pCell)->GetString();
- xMat->PutString(aStr, nC, nR);
- }
+ xMat->PutString(aCell.getString(), nC, nR);
break;
case CELLTYPE_VALUE:
- {
- double fVal = static_cast<ScValueCell*>(pCell)->GetValue();
- xMat->PutDouble(fVal, nC, nR);
- }
+ xMat->PutDouble(aCell.mfValue, nC, nR);
break;
case CELLTYPE_FORMULA:
{
- ScFormulaCell* pFCell = static_cast<ScFormulaCell*>(pCell);
+ ScFormulaCell* pFCell = aCell.mpFormula;
sal_uInt16 nError = pFCell->GetErrCode();
if (nError)
xMat->PutDouble( CreateDoubleError( nError), nC, nR);
@@ -1400,7 +1382,7 @@ static ScTokenArray* lcl_convertToTokenArray(const ScDocument* pSrcDoc, ScRange&
}
else
{
- rtl::OUString aStr = pFCell->GetString();
+ OUString aStr = pFCell->GetString();
xMat->PutString(aStr, nC, nR);
}
}
@@ -1684,7 +1666,7 @@ ScExternalRefCache::TokenRef ScExternalRefManager::getSingleRefToken(
if (pFmt)
pFmt->mbIsSet = false;
- const ScDocument* pSrcDoc = getInMemorySrcDocument(nFileId);
+ ScDocument* pSrcDoc = getInMemorySrcDocument(nFileId);
if (pSrcDoc)
{
// source document already loaded in memory. Re-use this instance.
@@ -1771,7 +1753,7 @@ ScExternalRefCache::TokenArrayRef ScExternalRefManager::getDoubleRefTokens(
maybeLinkExternalFile(nFileId);
ScRange aDataRange(rRange);
- const ScDocument* pSrcDoc = getInMemorySrcDocument(nFileId);
+ ScDocument* pSrcDoc = getInMemorySrcDocument(nFileId);
if (pSrcDoc)
{
// Document already loaded in memory.
@@ -1817,7 +1799,7 @@ ScExternalRefCache::TokenArrayRef ScExternalRefManager::getRangeNameTokens(
maybeLinkExternalFile(nFileId);
OUString aName = rName; // make a copy to have the casing corrected.
- const ScDocument* pSrcDoc = getInMemorySrcDocument(nFileId);
+ ScDocument* pSrcDoc = getInMemorySrcDocument(nFileId);
if (pSrcDoc)
{
// Document already loaded in memory.
@@ -1908,13 +1890,13 @@ void ScExternalRefManager::fillCellFormat(sal_uLong nFmtIndex, ScExternalRefCach
}
ScExternalRefCache::TokenRef ScExternalRefManager::getSingleRefTokenFromSrcDoc(
- sal_uInt16 nFileId, const ScDocument* pSrcDoc, const ScAddress& rCell,
+ sal_uInt16 nFileId, ScDocument* pSrcDoc, const ScAddress& rPos,
ScExternalRefCache::CellFormat* pFmt)
{
// Get the cell from src doc, and convert it into a token.
- ScBaseCell* pCell = NULL;
- pSrcDoc->GetCell(rCell.Col(), rCell.Row(), rCell.Tab(), pCell);
- ScExternalRefCache::TokenRef pToken(lcl_convertToToken(pCell));
+ ScRefCellValue aCell;
+ aCell.assign(*pSrcDoc, rPos);
+ ScExternalRefCache::TokenRef pToken(convertToToken(aCell));
if (!pToken.get())
{
@@ -1924,14 +1906,14 @@ ScExternalRefCache::TokenRef ScExternalRefManager::getSingleRefTokenFromSrcDoc(
// Get number format information.
sal_uInt32 nFmtIndex = 0;
- pSrcDoc->GetNumberFormat(rCell.Col(), rCell.Row(), rCell.Tab(), nFmtIndex);
+ pSrcDoc->GetNumberFormat(rPos.Col(), rPos.Row(), rPos.Tab(), nFmtIndex);
nFmtIndex = getMappedNumberFormat(nFileId, nFmtIndex, pSrcDoc);
fillCellFormat(nFmtIndex, pFmt);
return pToken;
}
ScExternalRefCache::TokenArrayRef ScExternalRefManager::getDoubleRefTokensFromSrcDoc(
- const ScDocument* pSrcDoc, const OUString& rTabName, ScRange& rRange,
+ ScDocument* pSrcDoc, const OUString& rTabName, ScRange& rRange,
vector<ScExternalRefCache::SingleRangeData>& rCacheData)
{
ScExternalRefCache::TokenArrayRef pArray;
@@ -1967,14 +1949,14 @@ ScExternalRefCache::TokenArrayRef ScExternalRefManager::getDoubleRefTokensFromSr
aRange.aStart.SetTab(nTab1);
aRange.aEnd.SetTab(nTab1 + nTabSpan);
- pArray.reset(lcl_convertToTokenArray(pSrcDoc, aRange, aCacheData));
+ pArray.reset(convertToTokenArray(pSrcDoc, aRange, aCacheData));
rRange = aRange;
rCacheData.swap(aCacheData);
return pArray;
}
ScExternalRefCache::TokenArrayRef ScExternalRefManager::getRangeNameTokensFromSrcDoc(
- sal_uInt16 nFileId, const ScDocument* pSrcDoc, OUString& rName)
+ sal_uInt16 nFileId, ScDocument* pSrcDoc, OUString& rName)
{
ScRangeName* pExtNames = pSrcDoc->GetRangeName();
String aUpperName = ScGlobal::pCharClass->uppercase(rName);
@@ -2027,7 +2009,7 @@ ScExternalRefCache::TokenArrayRef ScExternalRefManager::getRangeNameTokensFromSr
return pNew;
}
-const ScDocument* ScExternalRefManager::getInMemorySrcDocument(sal_uInt16 nFileId)
+ScDocument* ScExternalRefManager::getInMemorySrcDocument(sal_uInt16 nFileId)
{
const OUString* pFileName = getExternalFileName(nFileId);
if (!pFileName)
@@ -2071,7 +2053,7 @@ const ScDocument* ScExternalRefManager::getInMemorySrcDocument(sal_uInt16 nFileI
return pSrcDoc;
}
-const ScDocument* ScExternalRefManager::getSrcDocument(sal_uInt16 nFileId)
+ScDocument* ScExternalRefManager::getSrcDocument(sal_uInt16 nFileId)
{
if (!mpDoc->IsExecuteLinkEnabled())
return NULL;
commit f051163d699c802dc51be0b9af9a9879bcee5307
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Tue Mar 26 19:13:21 2013 -0400
More of the same...
Change-Id: I829d221d6bf164cd6087d41c65e26240108aa021
diff --git a/sc/inc/cellform.hxx b/sc/inc/cellform.hxx
index e6314fc..e2935a0 100644
--- a/sc/inc/cellform.hxx
+++ b/sc/inc/cellform.hxx
@@ -28,6 +28,7 @@ class SvNumberFormatter;
class Color;
class ScDocument;
class ScAddress;
+class ScRefCellValue;
enum ScForceTextFmt {
ftDontForce, // numbers as numbers
@@ -47,6 +48,12 @@ public:
ScForceTextFmt eForceTextFmt = ftDontForce,
bool bUseStarFormat = false );
+ static void GetString(
+ ScRefCellValue& rCell, sal_uLong nFormat, rtl::OUString& rString,
+ Color** ppColor, SvNumberFormatter& rFormatter, bool bNullVals = true,
+ bool bFormula = false, ScForceTextFmt eForceTextFmt = ftDontForce,
+ bool bUseStarFormat = false );
+
static OUString GetString(
const ScDocument& rDoc, const ScAddress& rPos, sal_uLong nFormat,
Color** ppColor, SvNumberFormatter& rFormatter, bool bNullVals = true,
diff --git a/sc/source/core/tool/cellform.cxx b/sc/source/core/tool/cellform.cxx
index 254bb43..8254a96 100644
--- a/sc/source/core/tool/cellform.cxx
+++ b/sc/source/core/tool/cellform.cxx
@@ -24,6 +24,7 @@
#include "cellform.hxx"
#include "cell.hxx"
#include "document.hxx"
+#include "cellvalue.hxx"
#include "formula/errorcodes.hxx"
#include "sc.hrc"
@@ -143,6 +144,108 @@ void ScCellFormat::GetString( ScBaseCell* pCell, sal_uLong nFormat, OUString& rS
}
}
+void ScCellFormat::GetString( ScRefCellValue& rCell, sal_uLong nFormat, OUString& rString,
+ Color** ppColor, SvNumberFormatter& rFormatter,
+ bool bNullVals, bool bFormula, ScForceTextFmt eForceTextFmt,
+ bool bUseStarFormat )
+{
+ *ppColor = NULL;
+ if (&rFormatter==NULL)
+ {
+ rString = OUString();
+ return;
+ }
+
+ switch (rCell.meType)
+ {
+ case CELLTYPE_STRING:
+ rFormatter.GetOutputString(*rCell.mpString, nFormat, rString, ppColor, bUseStarFormat);
+ break;
+ case CELLTYPE_EDIT:
+ rFormatter.GetOutputString(rCell.getString(), nFormat, rString, ppColor );
+ break;
+ case CELLTYPE_VALUE:
+ {
+ double nValue = rCell.mfValue;
+ if (!bNullVals && nValue == 0.0)
+ rString = OUString();
+ else
+ {
+ if( eForceTextFmt == ftCheck )
+ {
+ if( nFormat && rFormatter.IsTextFormat( nFormat ) )
+ eForceTextFmt = ftForce;
+ }
+ if( eForceTextFmt == ftForce )
+ {
+ OUString aTemp;
+ rFormatter.GetOutputString( nValue, 0, aTemp, ppColor );
+ rFormatter.GetOutputString( aTemp, nFormat, rString, ppColor );
+ }
+ else
+ rFormatter.GetOutputString( nValue, nFormat, rString, ppColor, bUseStarFormat );
+ }
+ }
+ break;
+ case CELLTYPE_FORMULA:
+ {
+ ScFormulaCell* pFCell = rCell.mpFormula;
+ if ( bFormula )
+ {
+ pFCell->GetFormula( rString );
+ }
+ else
+ {
+ // A macro started from the interpreter, which has
+ // access to Formular Cells, becomes a CellText, even if
+ // that triggers further interpretation, except if those
+ // cells are already being interpreted.
+ // IdleCalc generally doesn't trigger futher interpretation,
+ // as not to get Err522 (circular).
+ if ( pFCell->GetDocument()->IsInInterpreter() &&
+ (!pFCell->GetDocument()->GetMacroInterpretLevel()
+ || pFCell->IsRunning()) )
+ {
+ rString = OUString("...");
+ }
+ else
+ {
+ sal_uInt16 nErrCode = pFCell->GetErrCode();
+
+ // get the number format only after interpretation (GetErrCode):
+ if ( (nFormat % SV_COUNTRY_LANGUAGE_OFFSET) == 0 )
+ nFormat = pFCell->GetStandardFormat( rFormatter,
+ nFormat );
+
+ if (nErrCode != 0)
+ rString = ScGlobal::GetErrorString(nErrCode);
+ else if ( pFCell->IsEmptyDisplayedAsString() )
+ rString = OUString();
+ else if ( pFCell->IsValue() )
+ {
+ double fValue = pFCell->GetValue();
+ if ( !bNullVals && fValue == 0.0 )
+ rString = OUString();
+ else if ( pFCell->IsHybridValueCell() )
+ rString = pFCell->GetString();
+ else
+ rFormatter.GetOutputString( fValue, nFormat, rString, ppColor, bUseStarFormat );
+ }
+ else
+ {
+ OUString aCellString = pFCell->GetString();
+ rFormatter.GetOutputString( aCellString, nFormat, rString, ppColor, bUseStarFormat );
+ }
+ }
+ }
+ }
+ break;
+ default:
+ rString = OUString();
+ break;
+ }
+}
+
OUString ScCellFormat::GetString(
const ScDocument& rDoc, const ScAddress& rPos, sal_uLong nFormat, Color** ppColor,
SvNumberFormatter& rFormatter, bool bNullVals, bool bFormula, ScForceTextFmt eForceTextFmt,
diff --git a/sc/source/filter/dif/difexp.cxx b/sc/source/filter/dif/difexp.cxx
index 2bca320..d55a02a 100644
--- a/sc/source/filter/dif/difexp.cxx
+++ b/sc/source/filter/dif/difexp.cxx
@@ -30,6 +30,7 @@
#include "progress.hxx"
#include <rtl/tencinfo.h>
#include "ftools.hxx"
+#include "cellvalue.hxx"
#include "rtl/strbuf.hxx"
FltError ScFormatFilterPluginImpl::ScExportDif( SvStream& rStream, ScDocument* pDoc,
@@ -143,7 +144,8 @@ FltError ScFormatFilterPluginImpl::ScExportDif( SvStream& rOut, ScDocument* pDoc
SCCOL nColCnt;
SCROW nRowCnt;
- ScBaseCell* pAkt;
+
+ ScRefCellValue aCell;
for( nRowCnt = rRange.aStart.Row() ; nRowCnt <= nEndRow ; nRowCnt++ )
{
@@ -156,20 +158,43 @@ FltError ScFormatFilterPluginImpl::ScExportDif( SvStream& rOut, ScDocument* pDoc
{
OSL_ASSERT(aOS.getLength() == 0);
bool bWriteStringData = false;
- pDoc->GetCell( nColCnt, nRowCnt, nTab, pAkt );
- if( pAkt )
+ aCell.assign(*pDoc, ScAddress(nColCnt, nRowCnt, nTab));
+
+ switch (aCell.meType)
{
- switch( pAkt->GetCellType() )
- {
- case CELLTYPE_NONE:
- case CELLTYPE_NOTE:
- aOS.appendAscii(pEmptyData);
- break;
- case CELLTYPE_VALUE:
+ case CELLTYPE_NONE:
+ case CELLTYPE_NOTE:
+ aOS.appendAscii(pEmptyData);
+ break;
+ case CELLTYPE_VALUE:
+ aOS.appendAscii(pNumData);
+ if( bPlain )
+ {
+ aOS.append(
+ rtl::math::doubleToUString(
+ aCell.mfValue, rtl_math_StringFormat_G, 14, '.', true));
+ }
+ else
+ {
+ pDoc->GetInputString( nColCnt, nRowCnt, nTab, aString );
+ aOS.append(aString);
+ }
+ aOS.appendAscii("\nV\n");
+ break;
+ case CELLTYPE_EDIT:
+ case CELLTYPE_STRING:
+ aString = aCell.getString();
+ bWriteStringData = true;
+ break;
+ case CELLTYPE_FORMULA:
+ if (aCell.mpFormula->GetErrCode())
+ aOS.appendAscii(pNumDataERROR);
+ else if (aCell.mpFormula->IsValue())
+ {
aOS.appendAscii(pNumData);
if( bPlain )
{
- fVal = static_cast<ScValueCell*>(pAkt)->GetValue();
+ fVal = aCell.mpFormula->GetValue();
aOS.append(
rtl::math::doubleToUString(
fVal, rtl_math_StringFormat_G, 14, '.', true));
@@ -180,49 +205,16 @@ FltError ScFormatFilterPluginImpl::ScExportDif( SvStream& rOut, ScDocument* pDoc
aOS.append(aString);
}
aOS.appendAscii("\nV\n");
- break;
- case CELLTYPE_EDIT:
- aString = static_cast<ScEditCell*>(pAkt)->GetString();
- bWriteStringData = true;
- break;
- case CELLTYPE_STRING:
- aString = static_cast<ScStringCell*>(pAkt)->GetString();
+ }
+ else
+ {
+ aString = aCell.mpFormula->GetString();
bWriteStringData = true;
- break;
- case CELLTYPE_FORMULA:
- if (static_cast<ScFormulaCell*>(pAkt)->GetErrCode())
- aOS.appendAscii(pNumDataERROR);
- else if( pAkt->HasValueData() )
- {
- aOS.appendAscii(pNumData);
- if( bPlain )
- {
- fVal = static_cast<ScFormulaCell*>(pAkt)->GetValue();
- aOS.append(
- rtl::math::doubleToUString(
- fVal, rtl_math_StringFormat_G, 14, '.', true));
- }
- else
- {
- pDoc->GetInputString( nColCnt, nRowCnt, nTab, aString );
- aOS.append(aString);
- }
- aOS.appendAscii("\nV\n");
- }
- else if( pAkt->HasStringData() )
- {
- aString = static_cast<ScFormulaCell*>(pAkt)->GetString();
- bWriteStringData = true;
- }
- else
- aOS.appendAscii(pNumDataERROR);
+ }
- break;
- default:;
- }
+ break;
+ default:;
}
- else
- aOS.appendAscii(pEmptyData);
if ( !bWriteStringData )
rOut.WriteUnicodeOrByteText(aOS.makeStringAndClear());
diff --git a/sc/source/filter/html/htmlexp.cxx b/sc/source/filter/html/htmlexp.cxx
index 4dafed6..5853f7a 100644
--- a/sc/source/filter/html/htmlexp.cxx
+++ b/sc/source/filter/html/htmlexp.cxx
@@ -62,7 +62,7 @@
#include "docoptio.hxx"
#include "editutil.hxx"
#include "ftools.hxx"
-
+#include "cellvalue.hxx"
#include <editeng/flditem.hxx>
#include <editeng/borderline.hxx>
@@ -876,24 +876,19 @@ void ScHTMLExport::WriteCell( SCCOL nCol, SCROW nRow, SCTAB nTab )
}
}
- ScBaseCell* pCell = pDoc->GetCell( aPos );
+ ScRefCellValue aCell;
+ aCell.assign(*pDoc, aPos);
+
sal_uLong nFormat = pAttr->GetNumberFormat( pFormatter );
- sal_Bool bValueData;
- sal_uInt8 nScriptType;
- if ( pCell )
- {
- bValueData = pCell->HasValueData();
+ bool bValueData = aCell.hasNumeric();
+ sal_uInt8 nScriptType = 0;
+ if (!aCell.isEmpty())
nScriptType = pDoc->GetScriptType(nCol, nRow, nTab);
- }
- else
- {
- bValueData = false;
- nScriptType = 0;
- }
+
if ( nScriptType == 0 )
nScriptType = aHTMLStyle.nDefaultScriptType;
- rtl::OStringBuffer aStrTD(OOO_STRING_SVTOOLS_HTML_tabledata);
+ OStringBuffer aStrTD(OOO_STRING_SVTOOLS_HTML_tabledata);
// border of the cells
SvxBoxItem* pBorder = (SvxBoxItem*) pDoc->GetAttr( nCol, nRow, nTab, ATTR_BORDER );
@@ -1061,24 +1056,21 @@ void ScHTMLExport::WriteCell( SCCOL nCol, SCROW nRow, SCTAB nTab )
double fVal = 0.0;
if ( bValueData )
{
- if ( pCell )
+ switch (aCell.meType)
{
- switch ( pCell->GetCellType() )
- {
- case CELLTYPE_VALUE:
- fVal = ((ScValueCell*)pCell)->GetValue();
- if ( bCalcAsShown && fVal != 0.0 )
- fVal = pDoc->RoundValueAsShown( fVal, nFormat );
- break;
- case CELLTYPE_FORMULA:
- fVal = ((ScFormulaCell*)pCell)->GetValue();
- if ( (nFormat % SV_COUNTRY_LANGUAGE_OFFSET) == 0 )
- nFormat = ScGlobal::GetStandardFormat( fVal, *pFormatter,
- nFormat, ((ScFormulaCell*)pCell)->GetFormatType() );
- break;
- default:
- OSL_FAIL( "value data with unsupported cell type" );
- }
+ case CELLTYPE_VALUE:
+ fVal = aCell.mfValue;
+ if ( bCalcAsShown && fVal != 0.0 )
+ fVal = pDoc->RoundValueAsShown( fVal, nFormat );
+ break;
+ case CELLTYPE_FORMULA:
+ fVal = aCell.mpFormula->GetValue();
+ if ( (nFormat % SV_COUNTRY_LANGUAGE_OFFSET) == 0 )
+ nFormat = ScGlobal::GetStandardFormat( fVal, *pFormatter,
+ nFormat, aCell.mpFormula->GetFormatType() );
+ break;
+ default:
+ OSL_FAIL( "value data with unsupported cell type" );
}
}
@@ -1140,25 +1132,24 @@ void ScHTMLExport::WriteCell( SCCOL nCol, SCROW nRow, SCTAB nTab )
TAG_ON(aStr.makeStringAndClear().getStr());
}
- rtl::OUString aStrOut;
- sal_Bool bFieldText = false;
- if ( pCell )
- { // cell content
- Color* pColor;
- switch ( pCell->GetCellType() )
- {
- case CELLTYPE_NOTE :
- // nothing
- break;
- case CELLTYPE_EDIT :
- bFieldText = WriteFieldText( (const ScEditCell*) pCell );
- if ( bFieldText )
- break;
- //! else: fallthru
- default:
- ScCellFormat::GetString( pCell, nFormat, aStrOut, &pColor, *pFormatter );
- }
+ OUString aStrOut;
+ bool bFieldText = false;
+
+ Color* pColor;
+ switch (aCell.meType)
+ {
+ case CELLTYPE_NOTE :
+ // nothing
+ break;
+ case CELLTYPE_EDIT :
+ bFieldText = WriteFieldText(aCell.mpEditText);
+ if ( bFieldText )
+ break;
+ //! else: fallthru
+ default:
+ ScCellFormat::GetString(aCell, nFormat, aStrOut, &pColor, *pFormatter);
}
+
if ( !bFieldText )
{
if ( aStrOut.isEmpty() )
@@ -1201,10 +1192,9 @@ void ScHTMLExport::WriteCell( SCCOL nCol, SCROW nRow, SCTAB nTab )
}
-sal_Bool ScHTMLExport::WriteFieldText( const ScEditCell* pCell )
+bool ScHTMLExport::WriteFieldText( const EditTextObject* pData )
{
bool bFields = false;
- const EditTextObject* pData = pCell->GetData();
// text and anchor of URL fields, Doc-Engine is a ScFieldEditEngine
EditEngine& rEngine = pDoc->GetEditEngine();
rEngine.SetText( *pData );
diff --git a/sc/source/filter/inc/htmlexp.hxx b/sc/source/filter/inc/htmlexp.hxx
index f5855fc..71fc58b 100644
--- a/sc/source/filter/inc/htmlexp.hxx
+++ b/sc/source/filter/inc/htmlexp.hxx
@@ -37,7 +37,7 @@ class Graphic;
class SdrObject;
class OutputDevice;
class ScDrawLayer;
-class ScEditCell;
+class EditTextObject;
namespace editeng { class SvxBorderLine; }
@@ -128,7 +128,7 @@ class ScHTMLExport : public ScExportBase
// nXOutFlags fuer XOutBitmap::WriteGraphic
// write to stream if and only if URL fields in edit cell
- sal_Bool WriteFieldText( const ScEditCell* pCell );
+ bool WriteFieldText( const EditTextObject* pData );
// kopiere ggfs. eine lokale Datei ins Internet
sal_Bool CopyLocalFileToINet( String& rFileNm,
commit e45f3aa3580cb4ba05a778f192c60e42db8a3500
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Tue Mar 26 18:42:19 2013 -0400
More on killing direct use of cell classes.
Change-Id: Ie2b6819652f330a493b7f9fe557736b27e402803
diff --git a/sc/inc/cellvalue.hxx b/sc/inc/cellvalue.hxx
index 84127cd..d4ef307 100644
--- a/sc/inc/cellvalue.hxx
+++ b/sc/inc/cellvalue.hxx
@@ -124,6 +124,10 @@ struct SC_DLLPUBLIC ScRefCellValue
bool hasNumeric() const;
+ double getValue();
+
+ OUString getString();
+
bool isEmpty() const;
bool equalsWithoutFormat( const ScRefCellValue& r ) const;
diff --git a/sc/inc/dociter.hxx b/sc/inc/dociter.hxx
index b50c68a..7161ac2 100644
--- a/sc/inc/dociter.hxx
+++ b/sc/inc/dociter.hxx
@@ -237,7 +237,7 @@ public:
const EditTextObject* getEditText() const;
ScFormulaCell* getFormulaCell();
const ScFormulaCell* getFormulaCell() const;
- double getValue() const;
+ double getValue();
ScCellValue getCellValue() const;
const ScRefCellValue& getRefCellValue() const;
diff --git a/sc/source/core/data/cellvalue.cxx b/sc/source/core/data/cellvalue.cxx
index 5b853a3..e4f0c2e 100644
--- a/sc/source/core/data/cellvalue.cxx
+++ b/sc/source/core/data/cellvalue.cxx
@@ -477,6 +477,38 @@ bool ScRefCellValue::hasNumeric() const
return hasNumericImpl(meType, mpFormula);
}
+double ScRefCellValue::getValue()
+{
+ switch (meType)
+ {
+ case CELLTYPE_VALUE:
+ return mfValue;
+ case CELLTYPE_FORMULA:
+ return mpFormula->GetValue();
+ default:
+ ;
+ }
+ return 0.0;
+}
+
+OUString ScRefCellValue::getString()
+{
+ switch (meType)
+ {
+ case CELLTYPE_STRING:
+ return *mpString;
+ case CELLTYPE_EDIT:
+ if (mpEditText)
+ return ScEditUtil::GetString(*mpEditText);
+ break;
+ case CELLTYPE_FORMULA:
+ return mpFormula->GetString();
+ default:
+ ;
+ }
+ return EMPTY_OUSTRING;
+}
+
bool ScRefCellValue::isEmpty() const
{
return meType == CELLTYPE_NOTE || meType == CELLTYPE_NONE;
diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx
index 8cfa1eb..6d8f758 100644
--- a/sc/source/core/data/dociter.cxx
+++ b/sc/source/core/data/dociter.cxx
@@ -1060,20 +1060,7 @@ CellType ScCellIterator::getType() const
OUString ScCellIterator::getString()
{
- switch (maCurCell.meType)
- {
- case CELLTYPE_STRING:
- return *maCurCell.mpString;
- case CELLTYPE_EDIT:
- if (maCurCell.mpEditText)
- return ScEditUtil::GetString(*maCurCell.mpEditText);
- break;
- case CELLTYPE_FORMULA:
- return maCurCell.mpFormula->GetString();
- default:
- ;
- }
- return EMPTY_OUSTRING;
+ return maCurCell.getString();
}
const EditTextObject* ScCellIterator::getEditText() const
@@ -1091,18 +1078,9 @@ const ScFormulaCell* ScCellIterator::getFormulaCell() const
return maCurCell.mpFormula;
}
-double ScCellIterator::getValue() const
+double ScCellIterator::getValue()
{
- switch (maCurCell.meType)
- {
- case CELLTYPE_VALUE:
- return maCurCell.mfValue;
- case CELLTYPE_FORMULA:
- return maCurCell.mpFormula->GetValue();
- default:
- ;
- }
- return 0.0;
+ return maCurCell.getValue();
}
ScCellValue ScCellIterator::getCellValue() const
diff --git a/sc/source/core/tool/rangeseq.cxx b/sc/source/core/tool/rangeseq.cxx
index 114354c..9e08c89 100644
--- a/sc/source/core/tool/rangeseq.cxx
+++ b/sc/source/core/tool/rangeseq.cxx
@@ -243,22 +243,6 @@ sal_Bool ScRangeToSequence::FillStringArray( uno::Any& rAny, const ScMatrix* pMa
return sal_True;
}
-//------------------------------------------------------------------------
-
-static double lcl_GetValueFromCell( ScBaseCell& rCell )
-{
- //! ScBaseCell member function?
-
- CellType eType = rCell.GetCellType();
- if ( eType == CELLTYPE_VALUE )
- return ((ScValueCell&)rCell).GetValue();
- else if ( eType == CELLTYPE_FORMULA )
- return ((ScFormulaCell&)rCell).GetValue(); // called only if result is value
-
- OSL_FAIL( "GetValueFromCell: wrong type" );
- return 0;
-}
-
sal_Bool ScRangeToSequence::FillMixedArray( uno::Any& rAny, ScDocument* pDoc, const ScRange& rRange,
sal_Bool bAllowNV )
{
@@ -281,22 +265,24 @@ sal_Bool ScRangeToSequence::FillMixedArray( uno::Any& rAny, ScDocument* pDoc, co
uno::Any& rElement = pColAry[nCol];
ScAddress aPos( (SCCOL)(nStartCol+nCol), (SCROW)(nStartRow+nRow), nTab );
- ScBaseCell* pCell = pDoc->GetCell( aPos );
- if ( pCell )
+ ScRefCellValue aCell;
+ aCell.assign(*pDoc, aPos);
+
+ if (aCell.isEmpty())
{
- if ( pCell->GetCellType() == CELLTYPE_FORMULA &&
- ((ScFormulaCell*)pCell)->GetErrCode() != 0 )
- {
- // if NV is allowed, leave empty for errors
- bHasErrors = sal_True;
- }
- else if ( pCell->HasValueData() )
- rElement <<= (double) lcl_GetValueFromCell( *pCell );
- else
- rElement <<= rtl::OUString( pCell->GetStringData() );
+ rElement <<= EMPTY_OUSTRING;
+ continue;
+ }
+
+ if (aCell.meType == CELLTYPE_FORMULA && aCell.mpFormula->GetErrCode() != 0)
+ {
+ // if NV is allowed, leave empty for errors
+ bHasErrors = true;
}
+ else if (aCell.hasNumeric())
+ rElement <<= aCell.getValue();
else
- rElement <<= rtl::OUString(); // empty: empty string
+ rElement <<= aCell.getString();
}
pRowAry[nRow] = aColSeq;
}
diff --git a/sc/source/ui/view/tabvwsh5.cxx b/sc/source/ui/view/tabvwsh5.cxx
index 2eeb98b..4787b61 100644
--- a/sc/source/ui/view/tabvwsh5.cxx
+++ b/sc/source/ui/view/tabvwsh5.cxx
@@ -37,7 +37,7 @@
#include "uiitems.hxx"
#include "editsh.hxx"
#include "hints.hxx"
-
+#include "cellvalue.hxx"
//==================================================================
@@ -314,62 +314,47 @@ void ScTabViewShell::MakeNumberInfoItem( ScDocument* pDoc,
//------------------------------
// NumberInfo-Item konstruieren:
//------------------------------
... etc. - the rest is truncated
More information about the Libreoffice-commits
mailing list