sc/inc/documentimport.hxx | 2 sc/inc/formulacell.hxx | 18 +++-- sc/source/core/data/column.cxx | 2 sc/source/core/data/column3.cxx | 14 +-- sc/source/core/data/conditio.cxx | 8 +- sc/source/core/data/documen4.cxx | 4 - sc/source/core/data/documentimport.cxx | 10 +- sc/source/core/data/formulacell.cxx | 95 ++++++++++++++++++++++++--- sc/source/core/data/table2.cxx | 4 - sc/source/core/data/table3.cxx | 2 sc/source/core/data/validat.cxx | 4 - sc/source/core/tool/consoli.cxx | 4 - sc/source/filter/excel/excform.cxx | 2 sc/source/filter/excel/impop.cxx | 2 sc/source/filter/excel/xipivot.cxx | 2 sc/source/filter/lotus/lotimpop.cxx | 2 sc/source/filter/lotus/op.cxx | 4 - sc/source/filter/oox/formulabuffer.cxx | 8 -- sc/source/filter/oox/worksheethelper.cxx | 2 sc/source/filter/orcus/interface.cxx | 4 - sc/source/filter/qpro/qpro.cxx | 2 sc/source/filter/xcl97/XclImpChangeTrack.cxx | 2 sc/source/filter/xml/xmlcelli.cxx | 2 sc/source/ui/docshell/impex.cxx | 2 sc/source/ui/unoobj/cellsuno.cxx | 2 sc/source/ui/unoobj/funcuno.cxx | 5 - sc/source/ui/view/viewfun4.cxx | 2 sc/source/ui/view/viewfunc.cxx | 2 28 files changed, 148 insertions(+), 64 deletions(-)
New commits: commit 74d06e3c2715936b1a055b9fb0b0bb8a82ef60cc Author: Kohei Yoshida <[email protected]> Date: Mon Nov 4 22:52:26 2013 -0500 Avoid duplication of ScTokenArray during formula cell construction. For slightly less overhead. Change-Id: Ie5861d585d6e22fbd19dfd57edfebae4f4504839 diff --git a/sc/inc/documentimport.hxx b/sc/inc/documentimport.hxx index d034292..d2aa994 100644 --- a/sc/inc/documentimport.hxx +++ b/sc/inc/documentimport.hxx @@ -67,7 +67,7 @@ public: void setStringCell(const ScAddress& rPos, const OUString& rStr); void setEditCell(const ScAddress& rPos, EditTextObject* pEditText); void setFormulaCell(const ScAddress& rPos, const OUString& rFormula, formula::FormulaGrammar::Grammar eGrammar); - void setFormulaCell(const ScAddress& rPos, const ScTokenArray& rArray); + void setFormulaCell(const ScAddress& rPos, ScTokenArray* pArray); void setFormulaCell(const ScAddress& rPos, ScFormulaCell* pCell); void setMatrixCells( diff --git a/sc/inc/formulacell.hxx b/sc/inc/formulacell.hxx index 46a68c4..c2e578b 100644 --- a/sc/inc/formulacell.hxx +++ b/sc/inc/formulacell.hxx @@ -153,6 +153,15 @@ public: ScFormulaCell( ScDocument* pDoc, const ScAddress& rPos ); + /** + * Transfer the ownership of the passed token array instance to the + * formula cell being constructed. The caller <i>must not</i> pass a NULL + * token array pointer. + */ + ScFormulaCell( ScDocument* pDoc, const ScAddress& rPos, ScTokenArray* pArray, + const formula::FormulaGrammar::Grammar eGrammar = formula::FormulaGrammar::GRAM_DEFAULT, + sal_uInt8 cMatInd = MM_NONE ); + ScFormulaCell( ScDocument* pDoc, const ScAddress& rPos, const ScTokenArray& rArray, const formula::FormulaGrammar::Grammar eGrammar = formula::FormulaGrammar::GRAM_DEFAULT, sal_uInt8 cMatInd = MM_NONE ); diff --git a/sc/source/core/data/documentimport.cxx b/sc/source/core/data/documentimport.cxx index 3bb16dc..5a8911d 100644 --- a/sc/source/core/data/documentimport.cxx +++ b/sc/source/core/data/documentimport.cxx @@ -202,7 +202,7 @@ void ScDocumentImport::setFormulaCell( rCells.set(pBlockPos->miCellPos, rPos.Row(), new ScFormulaCell(&mpImpl->mrDoc, rPos, rFormula, eGrammar)); } -void ScDocumentImport::setFormulaCell(const ScAddress& rPos, const ScTokenArray& rArray) +void ScDocumentImport::setFormulaCell(const ScAddress& rPos, ScTokenArray* pArray) { ScTable* pTab = mpImpl->mrDoc.FetchTable(rPos.Tab()); if (!pTab) @@ -216,7 +216,7 @@ void ScDocumentImport::setFormulaCell(const ScAddress& rPos, const ScTokenArray& sc::CellStoreType& rCells = pTab->aCol[rPos.Col()].maCells; pBlockPos->miCellPos = - rCells.set(pBlockPos->miCellPos, rPos.Row(), new ScFormulaCell(&mpImpl->mrDoc, rPos, rArray)); + rCells.set(pBlockPos->miCellPos, rPos.Row(), new ScFormulaCell(&mpImpl->mrDoc, rPos, pArray)); } void ScDocumentImport::setFormulaCell(const ScAddress& rPos, ScFormulaCell* pCell) diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx index 15c3b98..b0ffb74 100644 --- a/sc/source/core/data/formulacell.cxx +++ b/sc/source/core/data/formulacell.cxx @@ -487,6 +487,54 @@ ScFormulaCell::ScFormulaCell( ScDocument* pDoc, const ScAddress& rPos, } ScFormulaCell::ScFormulaCell( + ScDocument* pDoc, const ScAddress& rPos, ScTokenArray* pArray, + const FormulaGrammar::Grammar eGrammar, sal_uInt8 cMatInd ) : + eTempGrammar( eGrammar), + pCode(pArray), + pDocument( pDoc ), + pPrevious(0), + pNext(0), + pPreviousTrack(0), + pNextTrack(0), + nSeenInIteration(0), + cMatrixFlag ( cMatInd ), + nFormatType ( NUMBERFORMAT_NUMBER ), + bDirty( true ), + bChanged( false ), + bRunning( false ), + bCompile( false ), + bSubTotal( false ), + bIsIterCell( false ), + bInChangeTrack( false ), + bTableOpDirty( false ), + bNeedListening( false ), + mbNeedsNumberFormat( false ), + aPos( rPos ) +{ + assert(pArray); // Never pass a NULL pointer here. + + // Generate RPN token array. + if (pCode->GetLen() && !pCode->GetCodeError() && !pCode->GetCodeLen()) + { + ScCompiler aComp( pDocument, aPos, *pCode); + aComp.SetGrammar(eTempGrammar); + bSubTotal = aComp.CompileTokenArray(); + nFormatType = aComp.GetNumFormatType(); + } + else + { + pCode->Reset(); + if (pCode->GetNextOpCodeRPN(ocSubTotal)) + bSubTotal = true; + } + + if (bSubTotal) + pDocument->AddSubTotalCell(this); + + pCode->GenHash(); +} + +ScFormulaCell::ScFormulaCell( ScDocument* pDoc, const ScAddress& rPos, const ScTokenArray& rArray, const FormulaGrammar::Grammar eGrammar, sal_uInt8 cMatInd ) : eTempGrammar( eGrammar), diff --git a/sc/source/filter/oox/formulabuffer.cxx b/sc/source/filter/oox/formulabuffer.cxx index 3dde87b..bc074a2 100644 --- a/sc/source/filter/oox/formulabuffer.cxx +++ b/sc/source/filter/oox/formulabuffer.cxx @@ -27,8 +27,6 @@ #include "externalrefmgr.hxx" #include "oox/token/tokens.hxx" -#include <boost/scoped_ptr.hpp> - using namespace com::sun::star; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::table; @@ -99,11 +97,11 @@ void FormulaBuffer::applyCellFormulas( const std::vector< TokenAddressItem >& rV ScExternalRefManager::ApiGuard aExtRefGuard(&rDoc.getDoc()); ScCompiler aCompiler(&rDoc.getDoc(), aPos); aCompiler.SetGrammar(formula::FormulaGrammar::GRAM_ENGLISH_XL_OOX); - boost::scoped_ptr<ScTokenArray> pCode(aCompiler.CompileString(it->maTokenStr)); + ScTokenArray* pCode = aCompiler.CompileString(it->maTokenStr); if (!pCode) continue; - rDoc.setFormulaCell(aPos, *pCode); + rDoc.setFormulaCell(aPos, pCode); } } diff --git a/sc/source/filter/oox/worksheethelper.cxx b/sc/source/filter/oox/worksheethelper.cxx index fb5eadd..148118b 100644 --- a/sc/source/filter/oox/worksheethelper.cxx +++ b/sc/source/filter/oox/worksheethelper.cxx @@ -1583,7 +1583,7 @@ void WorksheetHelper::putFormulaTokens( const CellAddress& rAddress, const ApiTo ScAddress aCellPos; ScUnoConversion::FillScAddress( aCellPos, rAddress ); ScTokenConversion::ConvertToTokenArray(rDoc.getDoc(), aTokenArray, rTokens); - rDoc.setFormulaCell(aCellPos, aTokenArray); + rDoc.setFormulaCell(aCellPos, new ScTokenArray(aTokenArray)); } void WorksheetHelper::initializeWorksheetImport() commit 89d0ab72fd70b159fa6073452cc334e9c88b54c7 Author: Kohei Yoshida <[email protected]> Date: Mon Nov 4 22:24:39 2013 -0500 Modify ScFormulaCell's ctor to take a const reference to ScTokenArray. Instead of a pointer to ScTokenArray, and then clone its instance. If the token array gets cloned in ctor, take a const reference. Change-Id: I280fd7eb9eaea9905dbf954a1ace904ab0814dfe diff --git a/sc/inc/formulacell.hxx b/sc/inc/formulacell.hxx index 9d27558..46a68c4 100644 --- a/sc/inc/formulacell.hxx +++ b/sc/inc/formulacell.hxx @@ -151,10 +151,11 @@ public: ScFormulaCell* Clone() const; - /** Empty formula cell, or with a preconstructed token array. */ - ScFormulaCell( ScDocument*, const ScAddress&, const ScTokenArray* = NULL, - const formula::FormulaGrammar::Grammar = formula::FormulaGrammar::GRAM_DEFAULT, - sal_uInt8 = MM_NONE ); + ScFormulaCell( ScDocument* pDoc, const ScAddress& rPos ); + + ScFormulaCell( ScDocument* pDoc, const ScAddress& rPos, const ScTokenArray& rArray, + const formula::FormulaGrammar::Grammar eGrammar = formula::FormulaGrammar::GRAM_DEFAULT, + sal_uInt8 cMatInd = MM_NONE ); ScFormulaCell( ScDocument* pDoc, const ScAddress& rPos, const ScFormulaCellGroupRef& xGroup, const formula::FormulaGrammar::Grammar = formula::FormulaGrammar::GRAM_DEFAULT, diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx index 512ccc5..12fc80a 100644 --- a/sc/source/core/data/column.cxx +++ b/sc/source/core/data/column.cxx @@ -1643,7 +1643,7 @@ class CopyAsLinkHandler ScTokenArray aArr; aArr.AddSingleReference(aRef); - return new ScFormulaCell(&mrDestCol.GetDoc(), ScAddress(mrDestCol.GetCol(), nRow, mrDestCol.GetTab()), &aArr); + return new ScFormulaCell(&mrDestCol.GetDoc(), ScAddress(mrDestCol.GetCol(), nRow, mrDestCol.GetTab()), aArr); } void createRefBlock(const sc::CellStoreType::value_type& aNode, size_t nOffset, size_t nDataSize) diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx index 61f5326..a400935 100644 --- a/sc/source/core/data/column3.cxx +++ b/sc/source/core/data/column3.cxx @@ -700,7 +700,7 @@ class CopyCellsFromClipHandler aArr.AddSingleReference(aRef); mrDestCol.SetFormulaCell( - maDestBlockPos, nDestRow, new ScFormulaCell(&mrDestCol.GetDoc(), aDestPos, &aArr)); + maDestBlockPos, nDestRow, new ScFormulaCell(&mrDestCol.GetDoc(), aDestPos, aArr)); } void duplicateNotes(SCROW nStartRow, size_t nDataSize, bool bCloneCaption ) @@ -968,7 +968,7 @@ void ScColumn::CopyFromClip( ScTokenArray aArr; aArr.AddSingleReference( aRef ); - SetFormulaCell(nDestRow, new ScFormulaCell(pDocument, aDestPos, &aArr)); + SetFormulaCell(nDestRow, new ScFormulaCell(pDocument, aDestPos, aArr)); } return; @@ -1117,7 +1117,7 @@ public: miNewCellsPos = maNewCells.set( miNewCellsPos, nRow-mnRowOffset, new ScFormulaCell( - &mrDestColumn.GetDoc(), ScAddress(mrDestColumn.GetCol(), nRow, mrDestColumn.GetTab()), &aArr)); + &mrDestColumn.GetDoc(), ScAddress(mrDestColumn.GetCol(), nRow, mrDestColumn.GetTab()), aArr)); } break; case sc::element_type_string: @@ -1174,7 +1174,7 @@ public: miNewCellsPos = maNewCells.set( miNewCellsPos, nRow-mnRowOffset, new ScFormulaCell( - &mrDestColumn.GetDoc(), ScAddress(mrDestColumn.GetCol(), nRow, mrDestColumn.GetTab()), &aArr)); + &mrDestColumn.GetDoc(), ScAddress(mrDestColumn.GetCol(), nRow, mrDestColumn.GetTab()), aArr)); } break; case sc::element_type_formula: @@ -1203,7 +1203,7 @@ public: miNewCellsPos = maNewCells.set( miNewCellsPos, nRow-mnRowOffset, new ScFormulaCell( - &mrDestColumn.GetDoc(), ScAddress(mrDestColumn.GetCol(), nRow, mrDestColumn.GetTab()), &aArr)); + &mrDestColumn.GetDoc(), ScAddress(mrDestColumn.GetCol(), nRow, mrDestColumn.GetTab()), aArr)); } break; case sc::element_type_string: @@ -1282,7 +1282,7 @@ public: miNewCellsPos = maNewCells.set( miNewCellsPos, nDestRow-mnRowOffset, new ScFormulaCell( - &mrDestColumn.GetDoc(), ScAddress(mrDestColumn.GetCol(), nDestRow, mrDestColumn.GetTab()), &aArr)); + &mrDestColumn.GetDoc(), ScAddress(mrDestColumn.GetCol(), nDestRow, mrDestColumn.GetTab()), aArr)); } break; default: @@ -1709,7 +1709,7 @@ void ScColumn::SetFormula( SCROW nRow, const ScTokenArray& rArray, formula::Form ScAddress aPos(nCol, nRow, nTab); sc::CellStoreType::iterator it = GetPositionToInsert(nRow); - ScFormulaCell* pCell = new ScFormulaCell(pDocument, aPos, &rArray, eGram); + ScFormulaCell* pCell = new ScFormulaCell(pDocument, aPos, rArray, eGram); sal_uInt32 nCellFormat = GetNumberFormat(nRow); if( (nCellFormat % SV_COUNTRY_LANGUAGE_OFFSET) == 0) pCell->SetNeedNumberFormat(true); diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx index c0d6f0d..cd1d2df 100644 --- a/sc/source/core/data/conditio.cxx +++ b/sc/source/core/data/conditio.cxx @@ -414,13 +414,13 @@ void ScConditionEntry::MakeCells( const ScAddress& rPos ) // Formelzel { if ( pFormula1 && !pFCell1 && !bRelRef1 ) { - pFCell1 = new ScFormulaCell( mpDoc, rPos, pFormula1 ); + pFCell1 = new ScFormulaCell(mpDoc, rPos, *pFormula1); pFCell1->StartListeningTo( mpDoc ); } if ( pFormula2 && !pFCell2 && !bRelRef2 ) { - pFCell2 = new ScFormulaCell( mpDoc, rPos, pFormula2 ); + pFCell2 = new ScFormulaCell(mpDoc, rPos, *pFormula2); pFCell2->StartListeningTo( mpDoc ); } } @@ -630,7 +630,7 @@ void ScConditionEntry::Interpret( const ScAddress& rPos ) ScFormulaCell* pEff1 = pFCell1; if ( bRelRef1 ) { - pTemp1 = new ScFormulaCell( mpDoc, rPos, pFormula1 ); // ohne Listening + pTemp1 = pFormula1 ? new ScFormulaCell(mpDoc, rPos, *pFormula1) : new ScFormulaCell(mpDoc, rPos); pEff1 = pTemp1; } if ( pEff1 ) @@ -660,7 +660,7 @@ void ScConditionEntry::Interpret( const ScAddress& rPos ) ScFormulaCell* pEff2 = pFCell2; //@ 1!=2 if ( bRelRef2 ) { - pTemp2 = new ScFormulaCell( mpDoc, rPos, pFormula2 ); // ohne Listening + pTemp2 = pFormula2 ? new ScFormulaCell(mpDoc, rPos, *pFormula2) : new ScFormulaCell(mpDoc, rPos); pEff2 = pTemp2; } if ( pEff2 ) diff --git a/sc/source/core/data/documen4.cxx b/sc/source/core/data/documen4.cxx index 65005bd..0aa6383 100644 --- a/sc/source/core/data/documen4.cxx +++ b/sc/source/core/data/documen4.cxx @@ -272,7 +272,7 @@ void ScDocument::InsertMatrixFormula(SCCOL nCol1, SCROW nRow1, ScFormulaCell* pCell; ScAddress aPos( nCol1, nRow1, nTab1 ); if (pArr) - pCell = new ScFormulaCell( this, aPos, pArr, eGram, MM_FORMULA ); + pCell = new ScFormulaCell(this, aPos, *pArr, eGram, MM_FORMULA); else pCell = new ScFormulaCell( this, aPos, rFormula, eGram, MM_FORMULA ); pCell->SetMatColsRows( nCol2 - nCol1 + 1, nRow2 - nRow1 + 1, bDirtyFlag ); @@ -336,7 +336,7 @@ void ScDocument::InsertMatrixFormula(SCCOL nCol1, SCROW nRow1, aRefData.SetAddress(aBasePos, aPos); t->GetSingleRef() = aRefData; boost::scoped_ptr<ScTokenArray> pTokArr(aArr.Clone()); - pCell = new ScFormulaCell( this, aPos, pTokArr.get(), eGram, MM_REFERENCE ); + pCell = new ScFormulaCell(this, aPos, *pTokArr, eGram, MM_REFERENCE); pTab->SetFormulaCell(nCol, nRow, pCell); } } diff --git a/sc/source/core/data/documentimport.cxx b/sc/source/core/data/documentimport.cxx index 3b33f46..3bb16dc 100644 --- a/sc/source/core/data/documentimport.cxx +++ b/sc/source/core/data/documentimport.cxx @@ -216,7 +216,7 @@ void ScDocumentImport::setFormulaCell(const ScAddress& rPos, const ScTokenArray& sc::CellStoreType& rCells = pTab->aCol[rPos.Col()].maCells; pBlockPos->miCellPos = - rCells.set(pBlockPos->miCellPos, rPos.Row(), new ScFormulaCell(&mpImpl->mrDoc, rPos, &rArray)); + rCells.set(pBlockPos->miCellPos, rPos.Row(), new ScFormulaCell(&mpImpl->mrDoc, rPos, rArray)); } void ScDocumentImport::setFormulaCell(const ScAddress& rPos, ScFormulaCell* pCell) @@ -254,7 +254,7 @@ void ScDocumentImport::setMatrixCells( sc::CellStoreType& rCells = pTab->aCol[rBasePos.Col()].maCells; // Set the master cell. - ScFormulaCell* pCell = new ScFormulaCell(&mpImpl->mrDoc, rBasePos, &rArray, eGram, MM_FORMULA); + ScFormulaCell* pCell = new ScFormulaCell(&mpImpl->mrDoc, rBasePos, rArray, eGram, MM_FORMULA); pBlockPos->miCellPos = rCells.set(pBlockPos->miCellPos, rBasePos.Row(), pCell); @@ -283,7 +283,7 @@ void ScDocumentImport::setMatrixCells( aRefData.SetAddress(rBasePos, aPos); t->GetSingleRef() = aRefData; boost::scoped_ptr<ScTokenArray> pTokArr(aArr.Clone()); - pCell = new ScFormulaCell(&mpImpl->mrDoc, aPos, pTokArr.get(), eGram, MM_REFERENCE); + pCell = new ScFormulaCell(&mpImpl->mrDoc, aPos, *pTokArr, eGram, MM_REFERENCE); pBlockPos->miCellPos = rCells.set(pBlockPos->miCellPos, aPos.Row(), pCell); } @@ -303,7 +303,7 @@ void ScDocumentImport::setMatrixCells( aRefData.SetAddress(rBasePos, aPos); t->GetSingleRef() = aRefData; boost::scoped_ptr<ScTokenArray> pTokArr(aArr.Clone()); - pCell = new ScFormulaCell(&mpImpl->mrDoc, aPos, pTokArr.get(), eGram, MM_REFERENCE); + pCell = new ScFormulaCell(&mpImpl->mrDoc, aPos, *pTokArr, eGram, MM_REFERENCE); pBlockPos->miCellPos = rColCells.set(pBlockPos->miCellPos, aPos.Row(), pCell); } diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx index 4f27592..15c3b98 100644 --- a/sc/source/core/data/formulacell.cxx +++ b/sc/source/core/data/formulacell.cxx @@ -429,6 +429,31 @@ void ScFormulaCellGroup::compileCode( // ============================================================================ +ScFormulaCell::ScFormulaCell( ScDocument* pDoc, const ScAddress& rPos ) : + eTempGrammar(formula::FormulaGrammar::GRAM_DEFAULT), + pCode(new ScTokenArray), + pDocument(pDoc), + pPrevious(0), + pNext(0), + pPreviousTrack(0), + pNextTrack(0), + nSeenInIteration(0), + cMatrixFlag(MM_NONE), + nFormatType(NUMBERFORMAT_NUMBER), + bDirty(false), + bChanged(false), + bRunning(false), + bCompile(false), + bSubTotal(false), + bIsIterCell(false), + bInChangeTrack(false), + bTableOpDirty(false), + bNeedListening(false), + mbNeedsNumberFormat(false), + aPos(rPos) +{ +} + ScFormulaCell::ScFormulaCell( ScDocument* pDoc, const ScAddress& rPos, const OUString& rFormula, const FormulaGrammar::Grammar eGrammar, @@ -461,22 +486,20 @@ ScFormulaCell::ScFormulaCell( ScDocument* pDoc, const ScAddress& rPos, pCode = new ScTokenArray; } -// Used by import filters - -ScFormulaCell::ScFormulaCell( ScDocument* pDoc, const ScAddress& rPos, - const ScTokenArray* pArr, - const FormulaGrammar::Grammar eGrammar, sal_uInt8 cInd ) : +ScFormulaCell::ScFormulaCell( + ScDocument* pDoc, const ScAddress& rPos, const ScTokenArray& rArray, + const FormulaGrammar::Grammar eGrammar, sal_uInt8 cMatInd ) : eTempGrammar( eGrammar), - pCode( pArr ? new ScTokenArray( *pArr ) : new ScTokenArray ), + pCode(new ScTokenArray(rArray)), pDocument( pDoc ), pPrevious(0), pNext(0), pPreviousTrack(0), pNextTrack(0), nSeenInIteration(0), - cMatrixFlag ( cInd ), + cMatrixFlag ( cMatInd ), nFormatType ( NUMBERFORMAT_NUMBER ), - bDirty( NULL != pArr ), // -> Because of the use of the Auto Pilot Function was: cInd != 0 + bDirty( true ), bChanged( false ), bRunning( false ), bCompile( false ), @@ -2319,7 +2342,10 @@ void setOldCodeToUndo( if (pUndoDoc->GetCellType(aUndoPos) == CELLTYPE_FORMULA) return; - ScFormulaCell* pFCell = new ScFormulaCell(pUndoDoc, aUndoPos, pOldCode, eTempGrammar, cMatrixFlag); + ScFormulaCell* pFCell = + new ScFormulaCell( + pUndoDoc, aUndoPos, pOldCode ? *pOldCode : ScTokenArray(), eTempGrammar, cMatrixFlag); + pFCell->SetResultToken(NULL); // to recognize it as changed later (Cut/Paste!) pUndoDoc->SetFormulaCell(aUndoPos, pFCell); } @@ -2919,8 +2945,9 @@ void ScFormulaCell::UpdateTranspose( const ScRange& rSource, const ScAddress& rD { if (pUndoDoc) { - ScFormulaCell* pFCell = new ScFormulaCell( pUndoDoc, aPos, pOld, - eTempGrammar, cMatrixFlag); + ScFormulaCell* pFCell = new ScFormulaCell( + pUndoDoc, aPos, pOld ? *pOld : ScTokenArray(), eTempGrammar, cMatrixFlag); + pFCell->aResult.SetToken( NULL); // to recognize it as changed later (Cut/Paste!) pUndoDoc->SetFormulaCell(aPos, pFCell); } diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx index c94d66a..b44122e 100644 --- a/sc/source/core/data/table2.cxx +++ b/sc/source/core/data/table2.cxx @@ -751,7 +751,7 @@ class TransClipHandler ScTokenArray aArr; aArr.AddSingleReference(aRef); - return new ScFormulaCell(&mrClipTab.GetDoc(), rDestPos, &aArr); + return new ScFormulaCell(&mrClipTab.GetDoc(), rDestPos, aArr); } void setLink(size_t nRow) @@ -853,7 +853,7 @@ void ScTable::TransposeClip( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, pTransClip->SetFormulaCell( static_cast<SCCOL>(nRow-nRow1), static_cast<SCROW>(nCol-nCol1), - new ScFormulaCell(pDestDoc, aDestPos, &aArr)); + new ScFormulaCell(pDestDoc, aDestPos, aArr)); } } else diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx index a79add4..99d1c8e 100644 --- a/sc/source/core/data/table3.cxx +++ b/sc/source/core/data/table3.cxx @@ -1056,7 +1056,7 @@ bool ScTable::DoSubTotals( ScSubTotalParam& rParam ) aArr.AddOpCode( ocClose ); aArr.AddOpCode( ocStop ); ScFormulaCell* pCell = new ScFormulaCell( - pDocument, ScAddress(nResCols[nResult], iEntry->nDestRow, nTab), &aArr); + pDocument, ScAddress(nResCols[nResult], iEntry->nDestRow, nTab), aArr); SetFormulaCell(nResCols[nResult], iEntry->nDestRow, pCell); diff --git a/sc/source/core/data/validat.cxx b/sc/source/core/data/validat.cxx index 5a12649..0adc60a 100644 --- a/sc/source/core/data/validat.cxx +++ b/sc/source/core/data/validat.cxx @@ -632,8 +632,8 @@ bool ScValidationData::GetSelectionFromFormula( if( NULL == pDocument ) return false; - ScFormulaCell aValidationSrc( pDocument, rPos, &rTokArr, - formula::FormulaGrammar::GRAM_DEFAULT, MM_FORMULA); + ScFormulaCell aValidationSrc( + pDocument, rPos, rTokArr, formula::FormulaGrammar::GRAM_DEFAULT, MM_FORMULA); // Make sure the formula gets interpreted and a result is delivered, // regardless of the AutoCalc setting. diff --git a/sc/source/core/tool/consoli.cxx b/sc/source/core/tool/consoli.cxx index 25492bb..3dbe8f9 100644 --- a/sc/source/core/tool/consoli.cxx +++ b/sc/source/core/tool/consoli.cxx @@ -735,7 +735,7 @@ void ScConsData::OutputToDocument( ScDocument* pDestDoc, SCCOL nCol, SCROW nRow, aRefArr.AddOpCode(ocStop); ScAddress aDest( sal::static_int_cast<SCCOL>(nCol+nArrX), sal::static_int_cast<SCROW>(nRow+nArrY+nPos), nTab ); - ScFormulaCell* pCell = new ScFormulaCell( pDestDoc, aDest, &aRefArr ); + ScFormulaCell* pCell = new ScFormulaCell(pDestDoc, aDest, aRefArr); pDestDoc->SetFormulaCell(aDest, pCell); } } @@ -755,7 +755,7 @@ void ScConsData::OutputToDocument( ScDocument* pDestDoc, SCCOL nCol, SCROW nRow, aArr.AddDoubleReference(aCRef); aArr.AddOpCode(ocClose); aArr.AddOpCode(ocStop); - ScFormulaCell* pCell = new ScFormulaCell( pDestDoc, aDest, &aArr ); + ScFormulaCell* pCell = new ScFormulaCell(pDestDoc, aDest, aArr); pDestDoc->SetFormulaCell(aDest, pCell); } } diff --git a/sc/source/filter/excel/excform.cxx b/sc/source/filter/excel/excform.cxx index 74b0ea0..e2e2470 100644 --- a/sc/source/filter/excel/excform.cxx +++ b/sc/source/filter/excel/excform.cxx @@ -174,7 +174,7 @@ void ImportExcel::Formula( if (pResult) { - pCell = new ScFormulaCell(&rDoc.getDoc(), aScPos, pResult); + pCell = new ScFormulaCell(&rDoc.getDoc(), aScPos, *pResult); rDoc.getDoc().EnsureTable(aScPos.Tab()); rDoc.setFormulaCell(aScPos, pCell); SetLastFormula(aScPos.Col(), aScPos.Row(), fCurVal, nXF, pCell); diff --git a/sc/source/filter/excel/impop.cxx b/sc/source/filter/excel/impop.cxx index b86ea72..8db86c3 100644 --- a/sc/source/filter/excel/impop.cxx +++ b/sc/source/filter/excel/impop.cxx @@ -390,7 +390,7 @@ void ImportExcel::ReadBoolErr() double fValue; const ScTokenArray* pScTokArr = ErrorToFormula( nType, nValue, fValue ); - ScFormulaCell* pCell = new ScFormulaCell( pD, aScPos, pScTokArr ); + ScFormulaCell* pCell = pScTokArr ? new ScFormulaCell(pD, aScPos, *pScTokArr) : new ScFormulaCell(pD, aScPos); pCell->SetHybridDouble( fValue ); GetDoc().SetFormulaCell(aScPos, pCell); } diff --git a/sc/source/filter/excel/xipivot.cxx b/sc/source/filter/excel/xipivot.cxx index 99ceb86..30af343 100644 --- a/sc/source/filter/excel/xipivot.cxx +++ b/sc/source/filter/excel/xipivot.cxx @@ -121,7 +121,7 @@ void XclImpPCItem::WriteToSource( XclImpRoot& rRoot, const ScAddress& rScPos ) c sal_uInt8 nErrCode = static_cast< sal_uInt8 >( *pnError ); const ScTokenArray* pScTokArr = rRoot.GetOldFmlaConverter().GetBoolErr( XclTools::ErrorToEnum( fValue, EXC_BOOLERR_ERROR, nErrCode ) ); - ScFormulaCell* pCell = new ScFormulaCell(&rDoc.getDoc(), rScPos, pScTokArr); + ScFormulaCell* pCell = pScTokArr ? new ScFormulaCell(&rDoc.getDoc(), rScPos, *pScTokArr) : new ScFormulaCell(&rDoc.getDoc(), rScPos); pCell->SetHybridDouble( fValue ); rDoc.setFormulaCell(rScPos, pCell); } diff --git a/sc/source/filter/lotus/lotimpop.cxx b/sc/source/filter/lotus/lotimpop.cxx index ad27360..f8fc773 100644 --- a/sc/source/filter/lotus/lotimpop.cxx +++ b/sc/source/filter/lotus/lotimpop.cxx @@ -290,7 +290,7 @@ ScFormulaCell *ImportLotus::Formulacell( sal_uInt16 n ) aConv.SetWK3(); aConv.Convert( pErg, nRest ); - ScFormulaCell* pCell = new ScFormulaCell( pD, aAddr, pErg ); + ScFormulaCell* pCell = pErg ? new ScFormulaCell(pD, aAddr, *pErg) : new ScFormulaCell(pD, aAddr); pCell->AddRecalcMode( RECALCMODE_ONLOAD_ONCE ); pD->EnsureTable(aAddr.Tab()); pD->SetFormulaCell(aAddr, pCell); diff --git a/sc/source/filter/lotus/op.cxx b/sc/source/filter/lotus/op.cxx index 9e777a7..c42211d 100644 --- a/sc/source/filter/lotus/op.cxx +++ b/sc/source/filter/lotus/op.cxx @@ -169,7 +169,7 @@ void OP_Formula( SvStream& r, sal_uInt16 /*n*/ ) if (ValidColRow( static_cast<SCCOL>(nCol), nRow)) { - ScFormulaCell* pCell = new ScFormulaCell( pLotusRoot->pDoc, aAddress, pErg ); + ScFormulaCell* pCell = new ScFormulaCell(pLotusRoot->pDoc, aAddress, *pErg); pCell->AddRecalcMode( RECALCMODE_ONLOAD_ONCE ); pDoc->EnsureTable(nTab); pDoc->SetFormulaCell(ScAddress(nCol,nRow,nTab), pCell); @@ -413,7 +413,7 @@ void OP_Formula123( SvStream& r, sal_uInt16 n ) if (ValidColRow( static_cast<SCCOL>(nCol), nRow) && nTab <= pDoc->GetMaxTableNumber()) { - ScFormulaCell* pCell = new ScFormulaCell( pLotusRoot->pDoc, aAddress, pErg ); + ScFormulaCell* pCell = new ScFormulaCell(pLotusRoot->pDoc, aAddress, *pErg); pCell->AddRecalcMode( RECALCMODE_ONLOAD_ONCE ); pDoc->EnsureTable(nTab); pDoc->SetFormulaCell(ScAddress(nCol,nRow,nTab), pCell); diff --git a/sc/source/filter/oox/formulabuffer.cxx b/sc/source/filter/oox/formulabuffer.cxx index cf5b73e..3dde87b 100644 --- a/sc/source/filter/oox/formulabuffer.cxx +++ b/sc/source/filter/oox/formulabuffer.cxx @@ -173,7 +173,7 @@ void FormulaBuffer::applySharedFormulas( sal_Int32 nTab ) ScAddress aPos; ScUnoConversion::FillScAddress(aPos, rAddr); - ScFormulaCell* pCell = new ScFormulaCell(&rDoc.getDoc(), aPos, pArray); + ScFormulaCell* pCell = new ScFormulaCell(&rDoc.getDoc(), aPos, *pArray); rDoc.setFormulaCell(aPos, pCell); if (it->maCellValue.isEmpty()) { diff --git a/sc/source/filter/orcus/interface.cxx b/sc/source/filter/orcus/interface.cxx index 1372d775..df8c992 100644 --- a/sc/source/filter/orcus/interface.cxx +++ b/sc/source/filter/orcus/interface.cxx @@ -358,7 +358,7 @@ void ScOrcusSheet::set_shared_formula( maFormulaGroups.set(sindex, pArray); - ScFormulaCell* pCell = new ScFormulaCell(&mrDoc.getDoc(), aPos, pArray); + ScFormulaCell* pCell = new ScFormulaCell(&mrDoc.getDoc(), aPos, *pArray); mrDoc.setFormulaCell(aPos, pCell); cellInserted(); @@ -381,7 +381,7 @@ void ScOrcusSheet::set_shared_formula(os::row_t row, os::col_t col, size_t sinde if (!pArray) return; - ScFormulaCell* pCell = new ScFormulaCell(&mrDoc.getDoc(), aPos, pArray); + ScFormulaCell* pCell = new ScFormulaCell(&mrDoc.getDoc(), aPos, *pArray); mrDoc.setFormulaCell(aPos, pCell); cellInserted(); diff --git a/sc/source/filter/qpro/qpro.cxx b/sc/source/filter/qpro/qpro.cxx index bff702b..77dc5dca 100644 --- a/sc/source/filter/qpro/qpro.cxx +++ b/sc/source/filter/qpro/qpro.cxx @@ -110,7 +110,7 @@ FltError ScQProReader::readSheet( SCTAB nTab, ScDocument* pDoc, ScQProStyle *pSt eRet = eERR_FORMAT; else { - ScFormulaCell *pFormula = new ScFormulaCell( pDoc, aAddr, pArray ); + ScFormulaCell* pFormula = new ScFormulaCell(pDoc, aAddr, *pArray); nStyle = nStyle >> 3; pFormula->AddRecalcMode( RECALCMODE_ONLOAD_ONCE ); pStyle->SetFormat( pDoc, nCol, nRow, nTab, nStyle ); diff --git a/sc/source/filter/xcl97/XclImpChangeTrack.cxx b/sc/source/filter/xcl97/XclImpChangeTrack.cxx index a2f1dde..4892861 100644 --- a/sc/source/filter/xcl97/XclImpChangeTrack.cxx +++ b/sc/source/filter/xcl97/XclImpChangeTrack.cxx @@ -272,7 +272,7 @@ void XclImpChangeTrack::ReadCell( if( pStrm->IsValid() && pTokenArray ) { rCell.meType = CELLTYPE_FORMULA; - rCell.mpFormula = new ScFormulaCell(GetDocPtr(), rPosition, pTokenArray); + rCell.mpFormula = new ScFormulaCell(GetDocPtr(), rPosition, *pTokenArray); } delete pTokenArray; } diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx index a3f3a0f0..39fe093 100644 --- a/sc/source/filter/xml/xmlcelli.cxx +++ b/sc/source/filter/xml/xmlcelli.cxx @@ -1366,7 +1366,7 @@ void ScXMLTableRowCellContext::PutFormulaCell( const ScAddress& rCellPos ) pCode->AddStringXML( aFormulaNmsp ); rDoc.getDoc().IncXMLImportedFormulaCount( aText.getLength() ); - ScFormulaCell* pNewCell = new ScFormulaCell(pDoc, rCellPos, pCode.get(), eGrammar, MM_NONE); + ScFormulaCell* pNewCell = new ScFormulaCell(pDoc, rCellPos, *pCode, eGrammar, MM_NONE); SetFormulaCell(pNewCell); rDoc.setFormulaCell(rCellPos, pNewCell); pNewCell->SetNeedNumberFormat( true ); diff --git a/sc/source/ui/docshell/impex.cxx b/sc/source/ui/docshell/impex.cxx index 025737f..e9c050b 100644 --- a/sc/source/ui/docshell/impex.cxx +++ b/sc/source/ui/docshell/impex.cxx @@ -1842,7 +1842,7 @@ bool ScImportExport::Sylk2Doc( SvStream& rStrm ) else { ScFormulaCell* pFCell = new ScFormulaCell( - pDoc, aPos, pCode, eGrammar, MM_NONE); + pDoc, aPos, *pCode, eGrammar, MM_NONE); pDoc->SetFormulaCell(aPos, pFCell); } delete pCode; // ctor/InsertMatrixFormula did copy TokenArray diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx index f128f66..8da1198 100644 --- a/sc/source/ui/unoobj/cellsuno.cxx +++ b/sc/source/ui/unoobj/cellsuno.cxx @@ -6661,7 +6661,7 @@ void SAL_CALL ScCellObj::setTokens( const uno::Sequence<sheet::FormulaToken>& rT ScTokenArray aTokenArray; (void)ScTokenConversion::ConvertToTokenArray( *pDoc, aTokenArray, rTokens ); - ScFormulaCell* pNewCell = new ScFormulaCell( pDoc, aCellPos, &aTokenArray ); + ScFormulaCell* pNewCell = new ScFormulaCell(pDoc, aCellPos, aTokenArray); (void)pDocSh->GetDocFunc().SetFormulaCell(aCellPos, pNewCell, false); } } diff --git a/sc/source/ui/unoobj/funcuno.cxx b/sc/source/ui/unoobj/funcuno.cxx index 7bf321a..174b6a6 100644 --- a/sc/source/ui/unoobj/funcuno.cxx +++ b/sc/source/ui/unoobj/funcuno.cxx @@ -643,8 +643,9 @@ uno::Any SAL_CALL ScFunctionAccess::callFunction( const OUString& aName, ScAddress aFormulaPos( 0, 0, nTempSheet ); // GRAM_PODF_A1 doesn't really matter for the token array but fits with // other API compatibility grammars. - ScFormulaCell* pFormula = new ScFormulaCell( pDoc, aFormulaPos, - &aTokenArr, formula::FormulaGrammar::GRAM_PODF_A1, (sal_uInt8)(mbArray ? MM_FORMULA : MM_NONE) ); + ScFormulaCell* pFormula = new ScFormulaCell( + pDoc, aFormulaPos, aTokenArr, formula::FormulaGrammar::GRAM_PODF_A1, + (sal_uInt8)(mbArray ? MM_FORMULA : MM_NONE) ); pFormula = pDoc->SetFormulaCell(aFormulaPos, pFormula); // call GetMatrix before GetErrCode because GetMatrix always recalculates diff --git a/sc/source/ui/view/viewfun4.cxx b/sc/source/ui/view/viewfun4.cxx index e924b34..91584fd 100644 --- a/sc/source/ui/view/viewfun4.cxx +++ b/sc/source/ui/view/viewfun4.cxx @@ -261,7 +261,7 @@ void ScViewFunc::DoRefConversion( sal_Bool bRecord ) boost::scoped_ptr<ScTokenArray> pArr(aComp.CompileString(aNew)); ScFormulaCell* pNewCell = new ScFormulaCell( - pDoc, aPos, pArr.get(), formula::FormulaGrammar::GRAM_DEFAULT, MM_NONE); + pDoc, aPos, *pArr, formula::FormulaGrammar::GRAM_DEFAULT, MM_NONE); pDoc->SetFormulaCell(aPos, pNewCell); bOk = true; diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx index ec2abd2..4afab0f 100644 --- a/sc/source/ui/view/viewfunc.cxx +++ b/sc/source/ui/view/viewfunc.cxx @@ -509,7 +509,7 @@ void ScViewFunc::EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab, } } - ScFormulaCell aCell( pDoc, aPos, pArr,formula::FormulaGrammar::GRAM_DEFAULT, MM_NONE ); + ScFormulaCell aCell(pDoc, aPos, *pArr, formula::FormulaGrammar::GRAM_DEFAULT, MM_NONE); delete pArr; SvNumberFormatter* pFormatter = pDoc->GetFormatTable(); _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
