diff options
author | Kohei Yoshida <kohei.yoshida@gmail.com> | 2013-03-26 23:48:30 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@gmail.com> | 2013-03-27 00:07:18 -0400 |
commit | 26343a5a3123315795d0352ee01a1fb5ee0a931a (patch) | |
tree | bd2eded239880e02712b3ba0fb355576c123e324 /sc | |
parent | Remove this hack. (diff) | |
download | core-26343a5a3123315795d0352ee01a1fb5ee0a931a.tar.gz core-26343a5a3123315795d0352ee01a1fb5ee0a931a.zip |
More ScBaseCell reduction...
Change-Id: I3a9f9ce79de7117e7b1410c45b217e5bfe005db7
Diffstat (limited to 'sc')
-rw-r--r-- | sc/inc/document.hxx | 4 | ||||
-rw-r--r-- | sc/qa/unit/helper/csv_handler.hxx | 6 | ||||
-rw-r--r-- | sc/source/filter/oox/formulabuffer.cxx | 6 | ||||
-rw-r--r-- | sc/source/filter/orcus/interface.cxx | 7 | ||||
-rw-r--r-- | sc/source/filter/xml/XMLExportIterator.cxx | 1 | ||||
-rw-r--r-- | sc/source/filter/xml/XMLExportIterator.hxx | 6 | ||||
-rw-r--r-- | sc/source/filter/xml/xmlexprt.cxx | 34 | ||||
-rw-r--r-- | sc/source/ui/collab/sendfunc.hxx | 22 | ||||
-rw-r--r-- | sc/source/ui/docshell/externalrefmgr.cxx | 6 | ||||
-rw-r--r-- | sc/source/ui/undo/undoblk3.cxx | 14 | ||||
-rw-r--r-- | sc/source/ui/unoobj/chart2uno.cxx | 13 | ||||
-rw-r--r-- | sc/source/ui/view/cellsh.cxx | 10 |
12 files changed, 51 insertions, 78 deletions
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx index 892d18f2b2ec..9953006f8b39 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 e23efb185d25..41589f18310d 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 53b556c23390..59b922104710 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 6e5464f6bb1e..a8588a5276c1 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 520ff51a015e..4a593fff5fe5 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 aa2c10ee2e2b..3d13403b7835 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 8057551ae754..48b53cd6a1fb 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 5e4d147b4040..797246d20a43 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 7a610195781a..6c6a0595fb75 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 6cfbf9b3ff80..23a3a4d674af 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 8eed3b7b1cfa..60e65dc6038f 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 32222b46d5b5..bed44c39a146 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; |