sc/inc/document.hxx | 2 - sc/source/core/data/documen8.cxx | 24 +++++++++++----- sc/source/core/tool/chgtrack.cxx | 4 +- sc/source/core/tool/consoli.cxx | 8 ++--- sc/source/filter/excel/excform.cxx | 6 ++-- sc/source/filter/excel/impop.cxx | 10 +++--- sc/source/filter/lotus/lotimpop.cxx | 45 +++++++++++++++++-------------- sc/source/filter/oox/formulabuffer.cxx | 3 +- sc/source/ui/docshell/docfunc.cxx | 6 ++-- sc/source/ui/docshell/externalrefmgr.cxx | 9 +++--- sc/source/ui/docshell/impex.cxx | 2 - sc/source/ui/unoobj/cellsuno.cxx | 42 ++++++++++++++++++---------- sc/source/ui/unoobj/funcuno.cxx | 12 +++++--- 13 files changed, 105 insertions(+), 68 deletions(-)
New commits: commit 923e29e9915a9c231f7bba94af11839bd9bce7c3 Author: Kohei Yoshida <kohei.yosh...@gmail.com> Date: Wed Mar 20 22:24:57 2013 -0400 More on reducing the use of ScDocument::PutCell(). I'm getting tired of this already... Change-Id: I77c4f82fc61c9371e8a07fa559088851667949d6 diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx index 0f49166..c31c952 100644 --- a/sc/inc/document.hxx +++ b/sc/inc/document.hxx @@ -787,7 +787,7 @@ public: const ScAddress& rPos, const OUString& rFormula, formula::FormulaGrammar::Grammar eGram = formula::FormulaGrammar::GRAM_DEFAULT ); - void SetFormulaCell( const ScAddress& rPos, ScFormulaCell* pCell ); + SC_DLLPUBLIC void SetFormulaCell( const ScAddress& rPos, ScFormulaCell* pCell ); SC_DLLPUBLIC void InsertMatrixFormula(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, diff --git a/sc/source/core/data/documen8.cxx b/sc/source/core/data/documen8.cxx index 7c782f3..f535235 100644 --- a/sc/source/core/data/documen8.cxx +++ b/sc/source/core/data/documen8.cxx @@ -87,6 +87,7 @@ #include "scresid.hxx" #include "columniterator.hxx" #include "globalnames.hxx" +#include "stringutil.hxx" #include <memory> #include <boost/scoped_ptr.hpp> @@ -815,10 +816,14 @@ bool ScDocument::OnlineSpellInRange( const ScRange& rSpellRange, ScAddress& rSpe static_cast<ScEditCell*>(pCell)->SetData(pEngine->CreateTextObject()); else // The cell will take ownership of pNewData. - PutCell(nCol, nRow, nTab, new ScEditCell(pEngine->CreateTextObject(), this)); + SetEditText(ScAddress(nCol,nRow,nTab), pEngine->CreateTextObject()); + } + else + { + ScSetStringParam aParam; + aParam.setTextInput(); + SetString(ScAddress(nCol,nRow,nTab), pEngine->GetText(), &aParam); } - else // einfacher String - PutCell( nCol, nRow, nTab, new ScStringCell( pEngine->GetText() ) ); // Paint if (pShell) @@ -1652,12 +1657,13 @@ void ScDocument::TransliterateText( const ScMarkData& rMultiMark, sal_Int32 nTyp pEngine->SetDefaults( pEmpty, true ); // The cell will take ownership of the text object instance. - PutCell(nCol, nRow, nTab, new ScEditCell(pEngine->CreateTextObject(), this)); + SetEditText(ScAddress(nCol,nRow,nTab), pEngine->CreateTextObject()); } else { - rtl::OUString aNewStr = pEngine->GetText(); - PutCell( nCol, nRow, nTab, new ScStringCell( aNewStr ) ); + ScSetStringParam aParam; + aParam.setTextInput(); + SetString(ScAddress(nCol,nRow,nTab), pEngine->GetText(), &aParam); } } } @@ -1680,7 +1686,11 @@ void ScDocument::TransliterateText( const ScMarkData& rMultiMark, sal_Int32 nTyp rtl::OUString aNewStr = aTranslitarationWrapper.transliterate( aOldStr, nLanguage, 0, nOldLen, &aOffsets ); if ( aNewStr != aOldStr ) - PutCell( nCol, nRow, nTab, new ScStringCell( aNewStr ) ); + { + ScSetStringParam aParam; + aParam.setTextInput(); + SetString(ScAddress(nCol,nRow,nTab), aNewStr, &aParam); + } } bFound = GetNextMarkedCell( nCol, nRow, nTab, rMultiMark ); } diff --git a/sc/source/core/tool/chgtrack.cxx b/sc/source/core/tool/chgtrack.cxx index 4946884..d35fd7d 100644 --- a/sc/source/core/tool/chgtrack.cxx +++ b/sc/source/core/tool/chgtrack.cxx @@ -1957,10 +1957,10 @@ void ScChangeActionContent::PutValueToDoc( } } else - pDoc->PutCell( aPos, NULL ); + pDoc->SetEmptyCell(aPos); } else - pDoc->SetString( aPos.Col(), aPos.Row(), aPos.Tab(), rValue ); + pDoc->SetString(aPos, rValue); } diff --git a/sc/source/core/tool/consoli.cxx b/sc/source/core/tool/consoli.cxx index dfbf791..2d0e129 100644 --- a/sc/source/core/tool/consoli.cxx +++ b/sc/source/core/tool/consoli.cxx @@ -749,8 +749,8 @@ 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 ); - ScBaseCell* pCell = new ScFormulaCell( pDestDoc, aDest, &aRefArr ); - pDestDoc->PutCell( aDest.Col(), aDest.Row(), aDest.Tab(), pCell ); + ScFormulaCell* pCell = new ScFormulaCell( pDestDoc, aDest, &aRefArr ); + pDestDoc->SetFormulaCell(aDest, pCell); } } @@ -771,8 +771,8 @@ void ScConsData::OutputToDocument( ScDocument* pDestDoc, SCCOL nCol, SCROW nRow, aArr.AddDoubleReference(aCRef); aArr.AddOpCode(ocClose); aArr.AddOpCode(ocStop); - ScBaseCell* pCell = new ScFormulaCell( pDestDoc, aDest, &aArr ); - pDestDoc->PutCell( aDest.Col(), aDest.Row(), aDest.Tab(), pCell ); + 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 3a02917..289eee8 100644 --- a/sc/source/filter/excel/excform.cxx +++ b/sc/source/filter/excel/excform.cxx @@ -123,12 +123,12 @@ void ImportExcel::Formula( if (pResult) { pCell = new ScFormulaCell( pD, aScPos, pResult ); - pD->PutCell( aScPos.Col(), aScPos.Row(), aScPos.Tab(), pCell, true ); + pD->EnsureTable(aScPos.Tab()); + pD->SetFormulaCell(aScPos, pCell); } else { - CellType eCellType; - pD->GetCellType( aScPos.Col(), aScPos.Row(), aScPos.Tab(), eCellType ); + CellType eCellType = pD->GetCellType(aScPos); if( eCellType == CELLTYPE_FORMULA ) { ScBaseCell* pBaseCell; diff --git a/sc/source/filter/excel/impop.cxx b/sc/source/filter/excel/impop.cxx index 662e426..152f03c 100644 --- a/sc/source/filter/excel/impop.cxx +++ b/sc/source/filter/excel/impop.cxx @@ -291,7 +291,7 @@ void ImportExcel::ReadInteger() maStrm >> nValue; GetXFRangeBuffer().SetXF( aScPos, nXFIdx ); - GetDoc().PutCell( aScPos, new ScValueCell( nValue ) ); + GetDoc().SetValue(aScPos, nValue); } } @@ -308,7 +308,7 @@ void ImportExcel::ReadNumber() maStrm >> fValue; GetXFRangeBuffer().SetXF( aScPos, nXFIdx ); - GetDoc().PutCell( aScPos, new ScValueCell( fValue ) ); + GetDoc().SetValue(aScPos, fValue); } } @@ -363,7 +363,7 @@ void ImportExcel::ReadBoolErr() const ScTokenArray* pScTokArr = ErrorToFormula( nType, nValue, fValue ); ScFormulaCell* pCell = new ScFormulaCell( pD, aScPos, pScTokArr ); pCell->SetHybridDouble( fValue ); - GetDoc().PutCell( aScPos, pCell ); + GetDoc().SetFormulaCell(aScPos, pCell); } } @@ -380,7 +380,7 @@ void ImportExcel::ReadRk() maStrm >> nRk; GetXFRangeBuffer().SetXF( aScPos, nXFIdx ); - GetDoc().PutCell( aScPos, new ScValueCell( XclTools::GetDoubleFromRK( nRk ) ) ); + GetDoc().SetValue(aScPos, XclTools::GetDoubleFromRK(nRk)); } } @@ -853,7 +853,7 @@ void ImportExcel::Mulrk( void ) if( GetAddressConverter().ConvertAddress( aScPos, aCurrXclPos, GetCurrScTab(), true ) ) { GetXFRangeBuffer().SetXF( aScPos, nXF ); - GetDoc().PutCell( aScPos, new ScValueCell( XclTools::GetDoubleFromRK( nRkNum ) ) ); + GetDoc().SetValue(aScPos, XclTools::GetDoubleFromRK(nRkNum)); } } } diff --git a/sc/source/filter/lotus/lotimpop.cxx b/sc/source/filter/lotus/lotimpop.cxx index 1c44b54..19fe9ac 100644 --- a/sc/source/filter/lotus/lotimpop.cxx +++ b/sc/source/filter/lotus/lotimpop.cxx @@ -36,6 +36,7 @@ #include "namebuff.hxx" #include "lotrange.hxx" #include "lotattr.hxx" +#include "stringutil.hxx" LOTUS_ROOT::LOTUS_ROOT( ScDocument* pDocP, CharSet eQ ) : @@ -208,7 +209,10 @@ void ImportLotus::Errcell( void ) Read( aA ); - pD->PutCell( aA.Col(), aA.Row(), aA.Tab(), new ScStringCell( CREATE_STRING( "#ERR!" ) ), true ); + ScSetStringParam aParam; + aParam.setTextInput(); + pD->EnsureTable(aA.Tab()); + pD->SetString(aA, "#ERR!", &aParam); } @@ -218,7 +222,10 @@ void ImportLotus::Nacell( void ) Read( aA ); - pD->PutCell( aA.Col(), aA.Row(), aA.Tab(), new ScStringCell( CREATE_STRING( "#NA!" ) ), true ); + ScSetStringParam aParam; + aParam.setTextInput(); + pD->EnsureTable(aA.Tab()); + pD->SetString(aA, "#NA!", &aParam); } @@ -232,9 +239,10 @@ void ImportLotus::Labelcell( void ) Read( cAlign ); Read( aLabel ); -// aLabel.Convert( pLotusRoot->eCharsetQ ); - - pD->PutCell( aA.Col(), aA.Row(), aA.Tab(), new ScStringCell( aLabel ), true ); + ScSetStringParam aParam; + aParam.setTextInput(); + pD->EnsureTable(aA.Tab()); + pD->SetString(aA, aLabel, &aParam); } @@ -246,26 +254,26 @@ void ImportLotus::Numbercell( void ) Read( aAddr ); Read( fVal ); - pD->PutCell( aAddr.Col(), aAddr.Row(), aAddr.Tab(), - new ScValueCell( fVal ), true ); - } + pD->EnsureTable(aAddr.Tab()); + pD->SetValue(aAddr, fVal); +} void ImportLotus::Smallnumcell( void ) - { +{ ScAddress aAddr; sal_Int16 nVal; Read( aAddr ); Read( nVal ); - pD->PutCell( aAddr.Col(), aAddr.Row(), aAddr.Tab(), - new ScValueCell( SnumToDouble( nVal ) ), true ); - } + pD->EnsureTable(aAddr.Tab()); + pD->SetValue(aAddr, SnumToDouble(nVal)); +} ScFormulaCell *ImportLotus::Formulacell( sal_uInt16 n ) - { +{ OSL_ENSURE( pIn, "-ImportLotus::Formulacell(): Null-Stream -> Rums!" ); ScAddress aAddr; @@ -276,17 +284,16 @@ ScFormulaCell *ImportLotus::Formulacell( sal_uInt16 n ) n -= (n > 14) ? 14 : n; const ScTokenArray* pErg; - sal_Int32 nRest = n; + sal_Int32 nRest = n; aConv.Reset( aAddr ); aConv.SetWK3(); aConv.Convert( pErg, nRest ); - ScFormulaCell* pZelle = new ScFormulaCell( pD, aAddr, pErg ); - - pZelle->AddRecalcMode( RECALCMODE_ONLOAD_ONCE ); - - pD->PutCell( aAddr.Col(), aAddr.Row(), aAddr.Tab(), pZelle, true ); + ScFormulaCell* pCell = new ScFormulaCell( pD, aAddr, pErg ); + pCell->AddRecalcMode( RECALCMODE_ONLOAD_ONCE ); + pD->EnsureTable(aAddr.Tab()); + pD->SetFormulaCell(aAddr, pCell); return NULL; } diff --git a/sc/source/filter/oox/formulabuffer.cxx b/sc/source/filter/oox/formulabuffer.cxx index eb33c39..53b556c 100644 --- a/sc/source/filter/oox/formulabuffer.cxx +++ b/sc/source/filter/oox/formulabuffer.cxx @@ -123,7 +123,8 @@ void FormulaBuffer::applyCellFormula( ScDocument& rDoc, const ApiTokenSequence& ScTokenConversion::ConvertToTokenArray( rDoc, aTokenArray, rTokens ); ScFormulaCell* pNewCell = new ScFormulaCell( &rDoc, aCellPos, &aTokenArray ); pNewCell->StartListeningTo( &rDoc ); - rDoc.PutCell( aCellPos, pNewCell, sal_True ); + rDoc.EnsureTable(aCellPos.Tab()); + rDoc.SetFormulaCell(aCellPos, pNewCell); } void FormulaBuffer::applyCellFormulas( const std::vector< TokenAddressItem >& rVector ) diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx index 1357c96..c1ecbc5 100644 --- a/sc/source/ui/docshell/docfunc.cxx +++ b/sc/source/ui/docshell/docfunc.cxx @@ -5193,8 +5193,10 @@ sal_Bool ScDocFunc::InsertNameList( const ScAddress& rStartPos, sal_Bool bApi ) pData->UpdateSymbol(aContent, ScAddress( nStartCol, nOutRow, nTab )); aFormula = '='; aFormula += aContent.toString(); - pDoc->PutCell( nStartCol,nOutRow,nTab, new ScStringCell( aName ) ); - pDoc->PutCell( nEndCol ,nOutRow,nTab, new ScStringCell( aFormula ) ); + ScSetStringParam aParam; + aParam.setTextInput(); + pDoc->SetString(ScAddress(nStartCol,nOutRow,nTab), aName, &aParam); + pDoc->SetString(ScAddress(nEndCol,nOutRow,nTab), aFormula, &aParam); ++nOutRow; } diff --git a/sc/source/ui/docshell/externalrefmgr.cxx b/sc/source/ui/docshell/externalrefmgr.cxx index 0429fc8..fc49c7c 100644 --- a/sc/source/ui/docshell/externalrefmgr.cxx +++ b/sc/source/ui/docshell/externalrefmgr.cxx @@ -49,6 +49,7 @@ #include "unotools/ucbhelper.hxx" #include "unotools/localfilehelper.hxx" #include "vcl/msgbox.hxx" +#include "stringutil.hxx" #include <memory> #include <algorithm> @@ -174,14 +175,14 @@ public: if (pCell->IsValue()) { // Turn this into value cell. - double fVal = pCell->GetValue(); - mpDoc->PutCell(aPos, new ScValueCell(fVal)); + mpDoc->SetValue(aPos, pCell->GetValue()); } else { // string cell otherwise. - rtl::OUString aVal = pCell->GetString(); - mpDoc->PutCell(aPos, new ScStringCell(aVal)); + ScSetStringParam aParam; + aParam.setTextInput(); + mpDoc->SetString(aPos, pCell->GetString(), &aParam); } } private: diff --git a/sc/source/ui/docshell/impex.cxx b/sc/source/ui/docshell/impex.cxx index edc4b8f..d9858a5 100644 --- a/sc/source/ui/docshell/impex.cxx +++ b/sc/source/ui/docshell/impex.cxx @@ -1836,7 +1836,7 @@ bool ScImportExport::Sylk2Doc( SvStream& rStrm ) { ScFormulaCell* pFCell = new ScFormulaCell( pDoc, aPos, pCode, eGrammar, MM_NONE); - pDoc->PutCell( aPos, pFCell ); + 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 298b61a..04e7dec 100644 --- a/sc/source/ui/unoobj/cellsuno.cxx +++ b/sc/source/ui/unoobj/cellsuno.cxx @@ -1198,6 +1198,8 @@ static sal_Bool lcl_PutDataArray( ScDocShell& rDocShell, const ScRange& rRange, const uno::Any* pColArr = rColSeq.getConstArray(); for (long nCol=0; nCol<nCols; nCol++) { + ScAddress aPos(nDocCol, nDocRow, nTab); + const uno::Any& rElement = pColArr[nCol]; switch( rElement.getValueTypeClass() ) { @@ -1220,7 +1222,7 @@ static sal_Bool lcl_PutDataArray( ScDocShell& rDocShell, const ScRange& rRange, { double fVal(0.0); rElement >>= fVal; - pDoc->SetValue( nDocCol, nDocRow, nTab, fVal ); + pDoc->SetValue(aPos, fVal); } break; @@ -1229,7 +1231,11 @@ static sal_Bool lcl_PutDataArray( ScDocShell& rDocShell, const ScRange& rRange, rtl::OUString aUStr; rElement >>= aUStr; if ( !aUStr.isEmpty() ) - pDoc->PutCell( nDocCol, nDocRow, nTab, new ScStringCell( aUStr ) ); + { + ScSetStringParam aParam; + aParam.setTextInput(); + pDoc->SetString(aPos, aUStr, &aParam); + } } break; @@ -1241,9 +1247,7 @@ static sal_Bool lcl_PutDataArray( ScDocShell& rDocShell, const ScRange& rRange, { ScTokenArray aTokenArray; ScTokenConversion::ConvertToTokenArray( *pDoc, aTokenArray, aTokens ); - ScAddress aPos( nDocCol, nDocRow, nTab ); - ScBaseCell* pNewCell = new ScFormulaCell( pDoc, aPos, &aTokenArray ); - pDoc->PutCell( aPos, pNewCell ); + pDoc->SetFormula(aPos, aTokenArray); } else bError = true; @@ -3200,9 +3204,9 @@ void SAL_CALL ScCellRangesBase::setData( const uno::Sequence< uno::Sequence<doub { double fVal = pArray[nCol]; if ( fVal == DBL_MIN ) - pDoc->PutCell( *pPos, NULL ); // empty cell + pDoc->SetEmptyCell(*pPos); else - pDoc->SetValue( pPos->Col(), pPos->Row(), pPos->Tab(), pArray[nCol] ); + pDoc->SetValue(*pPos, pArray[nCol]); } } } @@ -3266,11 +3270,15 @@ void SAL_CALL ScCellRangesBase::setRowDescriptions( static_cast<SCSIZE>(nRow) ); if (pPos) { - String aStr = pArray[nRow]; - if ( aStr.Len() ) - pDoc->PutCell( *pPos, new ScStringCell( aStr ) ); + const OUString& aStr = pArray[nRow]; + if (aStr.isEmpty()) + pDoc->SetEmptyCell(*pPos); else - pDoc->PutCell( *pPos, NULL ); // empty cell + { + ScSetStringParam aParam; + aParam.setTextInput(); + pDoc->SetString(*pPos, aStr, &aParam); + } } } @@ -3334,11 +3342,15 @@ void SAL_CALL ScCellRangesBase::setColumnDescriptions( sal::static_int_cast<SCCOL>(nCol) ); if (pPos) { - String aStr(pArray[nCol]); - if ( aStr.Len() ) - pDoc->PutCell( *pPos, new ScStringCell( aStr ) ); + const OUString& aStr = pArray[nCol]; + if (aStr.isEmpty()) + pDoc->SetEmptyCell(*pPos); else - pDoc->PutCell( *pPos, NULL ); // empty cell + { + ScSetStringParam aParam; + aParam.setTextInput(); + pDoc->SetString(*pPos, aStr, &aParam); + } } } diff --git a/sc/source/ui/unoobj/funcuno.cxx b/sc/source/ui/unoobj/funcuno.cxx index 90d3b01..776f946 100644 --- a/sc/source/ui/unoobj/funcuno.cxx +++ b/sc/source/ui/unoobj/funcuno.cxx @@ -42,6 +42,7 @@ #include "attrib.hxx" #include "clipparam.hxx" #include "dociter.hxx" +#include "stringutil.hxx" using namespace com::sun::star; @@ -417,9 +418,12 @@ public: } void visitElem( long nCol, long nRow, const rtl::OUString& elem ) { - if ( !elem.isEmpty() ) - mpDoc->PutCell( (SCCOL) nCol, (SCROW) nRow, 0, - new ScStringCell( elem ) ); + if (!elem.isEmpty()) + { + ScSetStringParam aParam; + aParam.setTextInput(); + mpDoc->SetString(ScAddress(nCol,nRow,0), elem, &aParam); + } } void visitElem( long nCol, long nRow, const uno::Any& rElement ) { @@ -674,7 +678,7 @@ uno::Any SAL_CALL ScFunctionAccess::callFunction( const rtl::OUString& aName, // other API compatibility grammars. ScFormulaCell* pFormula = new ScFormulaCell( pDoc, aFormulaPos, &aTokenArr, formula::FormulaGrammar::GRAM_PODF_A1, (sal_uInt8)(mbArray ? MM_FORMULA : MM_NONE) ); - pDoc->PutCell( aFormulaPos, pFormula ); //! necessary? + pDoc->SetFormulaCell(aFormulaPos, pFormula); // call GetMatrix before GetErrCode because GetMatrix always recalculates // if there is no matrix result _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits