sc/inc/cellform.hxx | 19 + sc/inc/chgtrack.hxx | 49 +--- sc/inc/column.hxx | 26 +- sc/inc/document.hxx | 14 - sc/inc/formulacell.hxx | 9 sc/inc/rangenam.hxx | 4 sc/inc/table.hxx | 10 sc/qa/extras/macros-test.cxx | 3 sc/qa/unit/datacache.cxx | 3 sc/qa/unit/filters-test.cxx | 23 -- sc/qa/unit/helper/csv_handler.hxx | 3 sc/qa/unit/helper/qahelper.cxx | 9 sc/qa/unit/parallelism.cxx | 2 sc/qa/unit/subsequent_export_test.cxx | 8 sc/qa/unit/subsequent_export_test2.cxx | 18 - sc/qa/unit/subsequent_filters_test.cxx | 43 +-- sc/qa/unit/subsequent_filters_test2.cxx | 31 +- sc/qa/unit/ucalc.cxx | 91 +++----- sc/qa/unit/ucalc_copypaste.cxx | 40 +-- sc/qa/unit/ucalc_formula.cxx | 132 +++++------ sc/qa/unit/ucalc_sharedformula.cxx | 3 sc/qa/unit/uicalc/uicalc.cxx | 92 +++----- sc/source/core/data/colorscale.cxx | 5 sc/source/core/data/column2.cxx | 19 - sc/source/core/data/column3.cxx | 26 -- sc/source/core/data/column4.cxx | 6 sc/source/core/data/dociter.cxx | 9 sc/source/core/data/documen2.cxx | 2 sc/source/core/data/documen3.cxx | 6 sc/source/core/data/documen4.cxx | 5 sc/source/core/data/documen6.cxx | 2 sc/source/core/data/document.cxx | 55 +--- sc/source/core/data/formulacell.cxx | 31 -- sc/source/core/data/table2.cxx | 23 -- sc/source/core/data/table3.cxx | 48 ++-- sc/source/core/data/table4.cxx | 17 - sc/source/core/data/table6.cxx | 10 sc/source/core/data/validat.cxx | 4 sc/source/core/tool/cellform.cxx | 102 +++++---- sc/source/core/tool/chgtrack.cxx | 191 +++++++---------- sc/source/core/tool/consoli.cxx | 3 sc/source/core/tool/doubleref.cxx | 4 sc/source/core/tool/interpr1.cxx | 4 sc/source/core/tool/rangenam.cxx | 10 sc/source/core/tool/rangeutl.cxx | 4 sc/source/filter/dif/difexp.cxx | 4 sc/source/filter/excel/xename.cxx | 4 sc/source/filter/excel/xicontent.cxx | 3 sc/source/filter/html/htmlexp.cxx | 2 sc/source/filter/xcl97/xcl97rec.cxx | 2 sc/source/filter/xml/XMLChangeTrackingExportHelper.cxx | 12 - sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx | 3 sc/source/filter/xml/XMLConverter.cxx | 35 +-- sc/source/filter/xml/XMLConverter.hxx | 15 - sc/source/filter/xml/XMLExportDataPilot.cxx | 9 sc/source/filter/xml/XMLExportDatabaseRanges.cxx | 3 sc/source/filter/xml/xmlcelli.cxx | 4 sc/source/filter/xml/xmlexprt.cxx | 16 - sc/source/ui/app/transobj.cxx | 3 sc/source/ui/dataprovider/datatransformation.cxx | 129 +++-------- sc/source/ui/dbgui/sfiltdlg.cxx | 3 sc/source/ui/docshell/docfunc.cxx | 6 sc/source/ui/docshell/docsh.cxx | 17 - sc/source/ui/docshell/docsh3.cxx | 11 sc/source/ui/docshell/docsh4.cxx | 2 sc/source/ui/docshell/docsh8.cxx | 12 - sc/source/ui/docshell/externalrefmgr.cxx | 3 sc/source/ui/docshell/impex.cxx | 16 - sc/source/ui/formdlg/formula.cxx | 3 sc/source/ui/miscdlgs/acredlin.cxx | 29 +- sc/source/ui/miscdlgs/conflictsdlg.cxx | 3 sc/source/ui/miscdlgs/redcom.cxx | 3 sc/source/ui/miscdlgs/solvrdlg.cxx | 8 sc/source/ui/namedlg/namemgrtable.cxx | 3 sc/source/ui/pagedlg/areasdlg.cxx | 3 sc/source/ui/unoobj/cellsuno.cxx | 11 sc/source/ui/unoobj/nameuno.cxx | 6 sc/source/ui/unoobj/textuno.cxx | 3 sc/source/ui/vba/vbaname.cxx | 2 sc/source/ui/view/cellsh.cxx | 5 sc/source/ui/view/cellsh1.cxx | 18 - sc/source/ui/view/formatsh.cxx | 13 - sc/source/ui/view/gridwin5.cxx | 3 sc/source/ui/view/output2.cxx | 17 - sc/source/ui/view/spelleng.cxx | 3 sc/source/ui/view/tabvwsh.cxx | 5 sc/source/ui/view/tabvwsha.cxx | 6 sc/source/ui/view/viewfun2.cxx | 10 sc/source/ui/view/viewfun4.cxx | 6 sc/source/ui/view/viewfunc.cxx | 19 - sc/source/ui/view/viewutil.cxx | 3 91 files changed, 750 insertions(+), 964 deletions(-)
New commits: commit ec0edb0969c23b25576f4d1b3b2ee5d3f21990ad Author: Luboš Luňák <l.lu...@collabora.com> AuthorDate: Mon Nov 8 17:29:41 2021 +0100 Commit: Luboš Luňák <l.lu...@collabora.com> CommitDate: Mon Nov 8 20:34:23 2021 +0100 optimize VLOOKUP by returning SharedString if possible (tdf#139444) Profiling shows that the slowness mostly comes from converting the cell's SharedString to OUString and then the comparison converts it back. To improve performance, return the SharedString if possible and ignore the OUString. Change-Id: Idb190bd0354cea3185e5ff9ebaf92cab63f23f70 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124880 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lu...@collabora.com> diff --git a/sc/inc/cellform.hxx b/sc/inc/cellform.hxx index 65d0fc232ee9..cd9b28f7692c 100644 --- a/sc/inc/cellform.hxx +++ b/sc/inc/cellform.hxx @@ -21,6 +21,7 @@ #include "scdllapi.h" #include <rtl/ustring.hxx> +#include <svl/sharedstring.hxx> class SvNumberFormatter; class Color; @@ -42,9 +43,17 @@ public: const Color** ppColor, SvNumberFormatter& rFormatter, bool bNullVals = true, bool bFormula = false ); + // Note that if pShared is set and a value is returned that way, the returned OUString is empty. static OUString GetInputString( const ScRefCellValue& rCell, sal_uInt32 nFormat, SvNumberFormatter& rFormatter, - const ScDocument& rDoc, bool bFiltering = false ); + const ScDocument& rDoc, const svl::SharedString** pShared = nullptr, bool bFiltering = false ); + + static OUString GetInputString( + const ScRefCellValue& rCell, sal_uInt32 nFormat, SvNumberFormatter& rFormatter, + const ScDocument& rDoc, bool bFiltering) + { + return GetInputString( rCell, nFormat, rFormatter, rDoc, nullptr, bFiltering ); + } static OUString GetOutputString( ScDocument& rDoc, const ScAddress& rPos, const ScRefCellValue& rCell ); diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx index c25de8a028bc..91e5b5c3fc22 100644 --- a/sc/inc/column.hxx +++ b/sc/inc/column.hxx @@ -368,10 +368,12 @@ public: const ScInterpreterContext* pContext = nullptr ) const { return GetString( GetCellValue( rBlockPos, nRow ), nRow, pContext ); } double* GetValueCell( SCROW nRow ); - OUString GetInputString( SCROW nRow ) const - { return GetInputString( GetCellValue( nRow ), nRow ); } - OUString GetInputString( sc::ColumnBlockConstPosition& rBlockPos, SCROW nRow ) const - { return GetInputString( GetCellValue( rBlockPos, nRow ), nRow ); } + // Note that if pShared is set and a value is returned that way, the returned OUString is empty. + OUString GetInputString( SCROW nRow, const svl::SharedString** pShared = nullptr ) const + { return GetInputString( GetCellValue( nRow ), nRow, pShared ); } + OUString GetInputString( sc::ColumnBlockConstPosition& rBlockPos, SCROW nRow, + const svl::SharedString** pShared = nullptr ) const + { return GetInputString( GetCellValue( rBlockPos, nRow ), nRow, pShared ); } double GetValue( SCROW nRow ) const; const EditTextObject* GetEditText( SCROW nRow ) const; void RemoveEditTextCharAttribs( SCROW nRow, const ScPatternAttr& rAttr ); @@ -747,7 +749,7 @@ private: SCROW FindNextVisibleRow(SCROW nRow, bool bForward) const; OUString GetString( const ScRefCellValue& cell, SCROW nRow, const ScInterpreterContext* pContext = nullptr ) const; - OUString GetInputString( const ScRefCellValue& cell, SCROW nRow ) const; + OUString GetInputString( const ScRefCellValue& cell, SCROW nRow, const svl::SharedString** pShared = nullptr ) const; /** * Called whenever the state of cell array gets modified i.e. new cell diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx index 7ff8fbcb4fbe..0ed322c541ab 100644 --- a/sc/inc/document.hxx +++ b/sc/inc/document.hxx @@ -1189,7 +1189,9 @@ public: void BlockFormulaGroupContextDiscard( bool block ) { mbFormulaGroupCxtBlockDiscard = block; } - SC_DLLPUBLIC OUString GetInputString( SCCOL nCol, SCROW nRow, SCTAB nTab ) const; + // Note that if pShared is set and a value is returned that way, the returned OUString is empty. + SC_DLLPUBLIC OUString GetInputString( SCCOL nCol, SCROW nRow, SCTAB nTab, + const svl::SharedString** pShared = nullptr ) const; FormulaError GetStringForFormula( const ScAddress& rPos, OUString& rString ); SC_DLLPUBLIC double GetValue( const ScAddress& rPos ) const; SC_DLLPUBLIC double GetValue( SCCOL nCol, SCROW nRow, SCTAB nTab ) const; diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx index 06dca697c790..40806e70f31a 100644 --- a/sc/inc/table.hxx +++ b/sc/inc/table.hxx @@ -448,7 +448,8 @@ public: void SetRawString( SCCOL nCol, SCROW nRow, const svl::SharedString& rStr ); OUString GetString( SCCOL nCol, SCROW nRow, const ScInterpreterContext* pContext = nullptr ) const; double* GetValueCell( SCCOL nCol, SCROW nRow ); - OUString GetInputString( SCCOL nCol, SCROW nRow ) const; + // Note that if pShared is set and a value is returned that way, the returned OUString is empty. + OUString GetInputString( SCCOL nCol, SCROW nRow, const svl::SharedString** pShared = nullptr ) const; double GetValue( SCCOL nCol, SCROW nRow ) const; const EditTextObject* GetEditText( SCCOL nCol, SCROW nRow ) const; void RemoveEditTextCharAttribs( SCCOL nCol, SCROW nRow, const ScPatternAttr& rAttr ); diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx index dfc6b23a5fba..8361018c41c8 100644 --- a/sc/source/core/data/column3.cxx +++ b/sc/source/core/data/column3.cxx @@ -2996,10 +2996,10 @@ double* ScColumn::GetValueCell( SCROW nRow ) return &sc::numeric_block::at(*it->data, aPos.second); } -OUString ScColumn::GetInputString( const ScRefCellValue& aCell, SCROW nRow ) const +OUString ScColumn::GetInputString( const ScRefCellValue& aCell, SCROW nRow, const svl::SharedString** pShared ) const { sal_uLong nFormat = GetNumberFormat(GetDoc().GetNonThreadedContext(), nRow); - return ScCellFormat::GetInputString(aCell, nFormat, *(GetDoc().GetFormatTable()), GetDoc()); + return ScCellFormat::GetInputString(aCell, nFormat, *(GetDoc().GetFormatTable()), GetDoc(), pShared); } double ScColumn::GetValue( SCROW nRow ) const diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx index 71665e4d6ad6..a16c82bf33ff 100644 --- a/sc/source/core/data/document.cxx +++ b/sc/source/core/data/document.cxx @@ -3561,10 +3561,10 @@ void ScDocument::DiscardFormulaGroupContext() mpFormulaGroupCxt.reset(); } -OUString ScDocument::GetInputString( SCCOL nCol, SCROW nRow, SCTAB nTab ) const +OUString ScDocument::GetInputString( SCCOL nCol, SCROW nRow, SCTAB nTab, const svl::SharedString** pShared ) const { if ( ValidTab(nTab) && nTab < static_cast<SCTAB>(maTabs.size()) && maTabs[nTab] ) - return maTabs[nTab]->GetInputString( nCol, nRow ); + return maTabs[nTab]->GetInputString( nCol, nRow, pShared ); else return OUString(); } diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx index 70fb4e798555..b234825546a1 100644 --- a/sc/source/core/data/table2.cxx +++ b/sc/source/core/data/table2.cxx @@ -1756,10 +1756,10 @@ double* ScTable::GetValueCell( SCCOL nCol, SCROW nRow ) return CreateColumnIfNotExists(nCol).GetValueCell(nRow); } -OUString ScTable::GetInputString( SCCOL nCol, SCROW nRow ) const +OUString ScTable::GetInputString( SCCOL nCol, SCROW nRow, const svl::SharedString** pShared ) const { if (ValidColRow(nCol, nRow) && nCol < GetAllocatedColumnsCount()) - return aCol[nCol].GetInputString( nRow ); + return aCol[nCol].GetInputString( nRow, pShared ); else return OUString(); } diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx index db4e9c25ec24..9c7417278658 100644 --- a/sc/source/core/data/table3.cxx +++ b/sc/source/core/data/table3.cxx @@ -2607,13 +2607,20 @@ public: sal_uInt32 nFormat = pContext ? mrTab.GetNumberFormat( *pContext, ScAddress(static_cast<SCCOL>(rEntry.nField), nRow, mrTab.GetTab()) ) : mrTab.GetNumberFormat( static_cast<SCCOL>(rEntry.nField), nRow ); SvNumberFormatter* pFormatter = pContext ? pContext->GetFormatTable() : mrDoc.GetFormatTable(); - OUString aStr = ScCellFormat::GetInputString(rCell, nFormat, *pFormatter, mrDoc, rEntry.bDoQuery); + const svl::SharedString* sharedString = nullptr; + OUString aStr = ScCellFormat::GetInputString(rCell, nFormat, *pFormatter, mrDoc, &sharedString, rEntry.bDoQuery); + // Use the shared string for less conversions, if available. + if( sharedString != nullptr ) + return compareByStringComparator(rEntry, rItem, sharedString, nullptr); return compareByStringComparator(rEntry, rItem, nullptr, &aStr); } } else { - OUString aStr = mrTab.GetInputString(static_cast<SCCOL>(rEntry.nField), nRow); + const svl::SharedString* sharedString = nullptr; + OUString aStr = mrTab.GetInputString(static_cast<SCCOL>(rEntry.nField), nRow, &sharedString); + if( sharedString != nullptr ) + return compareByStringComparator(rEntry, rItem, sharedString, nullptr); return compareByStringComparator(rEntry, rItem, nullptr, &aStr); } } diff --git a/sc/source/core/tool/cellform.cxx b/sc/source/core/tool/cellform.cxx index dd52379bbc29..699f7d88cecb 100644 --- a/sc/source/core/tool/cellform.cxx +++ b/sc/source/core/tool/cellform.cxx @@ -128,7 +128,8 @@ OUString ScCellFormat::GetString( } OUString ScCellFormat::GetInputString( - const ScRefCellValue& rCell, sal_uInt32 nFormat, SvNumberFormatter& rFormatter, const ScDocument& rDoc, bool bFiltering ) + const ScRefCellValue& rCell, sal_uInt32 nFormat, SvNumberFormatter& rFormatter, const ScDocument& rDoc, + const svl::SharedString** pShared, bool bFiltering ) { switch (rCell.meType) { @@ -151,11 +152,23 @@ OUString ScCellFormat::GetInputString( else if (pFC->IsValue()) rFormatter.GetInputLineString(pFC->GetValue(), nFormat, str, bFiltering); else - str = pFC->GetString().getString(); + { + const svl::SharedString& shared = pFC->GetString(); + // Allow callers to optimize by avoiding converting later back to OUString. + // To avoid refcounting that won't be needed, do not even return the OUString. + if( pShared != nullptr ) + *pShared = &shared; + else + str = shared.getString(); + } const FormulaError nErrCode = pFC->GetErrCode(); if (nErrCode != FormulaError::NONE) + { str.clear(); + if( pShared != nullptr ) + *pShared = nullptr; + } return str; } commit 1a588c71a0b60d200077138eaff54fced14c4fe2 Author: Luboš Luňák <l.lu...@collabora.com> AuthorDate: Mon Nov 8 15:31:51 2021 +0100 Commit: Luboš Luňák <l.lu...@collabora.com> CommitDate: Mon Nov 8 20:34:09 2021 +0100 make a number of Calc functions return value by actually returning it All these returned their value using a reference argument, for apprently no good reason. Change-Id: I6a33417e7df2aac67427c16e5003dfaaa1a814d7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124872 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lu...@collabora.com> diff --git a/sc/inc/cellform.hxx b/sc/inc/cellform.hxx index 02ea8b6e6347..65d0fc232ee9 100644 --- a/sc/inc/cellform.hxx +++ b/sc/inc/cellform.hxx @@ -32,8 +32,8 @@ class SC_DLLPUBLIC ScCellFormat { public: - static void GetString( - const ScRefCellValue& rCell, sal_uInt32 nFormat, OUString& rString, + static OUString GetString( + const ScRefCellValue& rCell, sal_uInt32 nFormat, const Color** ppColor, SvNumberFormatter& rFormatter, const ScDocument& rDoc, bool bNullVals = true, bool bFormula = false, bool bUseStarFormat = false ); @@ -42,8 +42,8 @@ public: const Color** ppColor, SvNumberFormatter& rFormatter, bool bNullVals = true, bool bFormula = false ); - static void GetInputString( - const ScRefCellValue& rCell, sal_uInt32 nFormat, OUString& rString, SvNumberFormatter& rFormatter, + static OUString GetInputString( + const ScRefCellValue& rCell, sal_uInt32 nFormat, SvNumberFormatter& rFormatter, const ScDocument& rDoc, bool bFiltering = false ); static OUString GetOutputString( diff --git a/sc/inc/chgtrack.hxx b/sc/inc/chgtrack.hxx index 2806d75096fb..6cbb7a0d89f5 100644 --- a/sc/inc/chgtrack.hxx +++ b/sc/inc/chgtrack.hxx @@ -336,12 +336,10 @@ public: // description will be appended to string // with bSplitRange only one column/row will be considered for delete // (for a listing of entries) - virtual void GetDescription( - OUString& rStr, ScDocument& rDoc, - bool bSplitRange = false, bool bWarning = true ) const; + virtual OUString GetDescription( + ScDocument& rDoc, bool bSplitRange = false, bool bWarning = true ) const; - virtual void GetRefString( - OUString& rStr, ScDocument& rDoc, bool bFlag3D = false ) const; + virtual OUString GetRefString( ScDocument& rDoc, bool bFlag3D = false ) const; // for DocumentMerge set old date of the other // action, fetched by GetDateTimeUTC @@ -391,8 +389,8 @@ public: const ScChangeActionType eType, bool bEndOfList = false ); - virtual void GetDescription( - OUString& rStr, ScDocument& rDoc, bool bSplitRange = false, bool bWarning = true) const override; + virtual OUString GetDescription( + ScDocument& rDoc, bool bSplitRange = false, bool bWarning = true) const override; SC_DLLPUBLIC bool IsEndOfList() const; }; @@ -486,8 +484,8 @@ public: const ScChangeActionIns* GetCutOffInsert() const { return pCutOff; } short GetCutOffCount() const { return nCutOff; } - virtual void GetDescription( - OUString& rStr, ScDocument& rDoc, bool bSplitRange = false, bool bWarning = true ) const override; + virtual OUString GetDescription( + ScDocument& rDoc, bool bSplitRange = false, bool bWarning = true ) const override; void SetCutOffInsert( ScChangeActionIns* p, short n ) { pCutOff = p; nCutOff = n; } // only to use in the XML import @@ -557,12 +555,10 @@ public: const ScBigRange& GetFromRange() const { return aFromRange; } SC_DLLPUBLIC void GetDelta( sal_Int32& nDx, sal_Int32& nDy, sal_Int32& nDz ) const; - virtual void GetDescription( - OUString& rStr, ScDocument& rDoc, bool bSplitRange = false, - bool bWarning = true ) const override; + virtual OUString GetDescription( + ScDocument& rDoc, bool bSplitRange = false, bool bWarning = true ) const override; - virtual void GetRefString( - OUString& rStr, ScDocument& rDoc, bool bFlag3D = false ) const override; + virtual OUString GetRefString( ScDocument& rDoc, bool bFlag3D = false ) const override; }; ScChangeActionDelMoveEntry::ScChangeActionDelMoveEntry( @@ -636,11 +632,11 @@ class SAL_DLLPUBLIC_RTTI ScChangeActionContent final : public ScChangeAction void ClearTrack(); - static void GetStringOfCell( - OUString& rStr, const ScCellValue& rCell, const ScDocument* pDoc, const ScAddress& rPos ); + static OUString GetStringOfCell( + const ScCellValue& rCell, const ScDocument* pDoc, const ScAddress& rPos ); - static void GetStringOfCell( - OUString& rStr, const ScCellValue& rCell, const ScDocument* pDoc, sal_uLong nFormat ); + static OUString GetStringOfCell( + const ScCellValue& rCell, const ScDocument* pDoc, sal_uLong nFormat ); static void SetValue( OUString& rStr, ScCellValue& rCell, const ScAddress& rPos, const ScCellValue& rOrgCell, const ScDocument* pFromDoc, @@ -656,10 +652,10 @@ class SAL_DLLPUBLIC_RTTI ScChangeActionContent final : public ScChangeAction void SetValueString( OUString& rValue, ScCellValue& rCell, const OUString& rStr, ScDocument* pDoc ); - void GetValueString( OUString& rStr, const OUString& rValue, const ScCellValue& rCell, - const ScDocument* pDoc ) const; + OUString GetValueString( const OUString& rValue, const ScCellValue& rCell, + const ScDocument* pDoc ) const; - void GetFormulaString( OUString& rStr, const ScFormulaCell* pCell ) const; + OUString GetFormulaString( const ScFormulaCell* pCell ) const; virtual void AddContent( ScChangeActionContent* ) override {} virtual void DeleteCellEntries() override {} @@ -740,15 +736,14 @@ public: // assigns string / creates formula cell void SetOldValue( const OUString& rOld, ScDocument* pDoc ); - void GetOldString( OUString& rStr, const ScDocument* pDoc ) const; - void GetNewString( OUString& rStr, const ScDocument* pDoc ) const; + OUString GetOldString( const ScDocument* pDoc ) const; + OUString GetNewString( const ScDocument* pDoc ) const; const ScCellValue& GetOldCell() const { return maOldCell;} const ScCellValue& GetNewCell() const { return maNewCell;} - virtual void GetDescription( - OUString& rStr, ScDocument& rDoc, bool bSplitRange = false, bool bWarning = true ) const override; + virtual OUString GetDescription( + ScDocument& rDoc, bool bSplitRange = false, bool bWarning = true ) const override; - virtual void GetRefString( - OUString& rStr, ScDocument& rDoc, bool bFlag3D = false ) const override; + virtual OUString GetRefString( ScDocument& rDoc, bool bFlag3D = false ) const override; static ScChangeActionContentCellType GetContentCellType( const ScCellValue& rCell ); static ScChangeActionContentCellType GetContentCellType( const ScRefCellValue& rIter ); diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx index 4c08e7b41479..c25de8a028bc 100644 --- a/sc/inc/column.hxx +++ b/sc/inc/column.hxx @@ -362,20 +362,20 @@ public: void SetValue( sc::ColumnBlockPosition& rBlockPos, SCROW nRow, double fVal, bool bBroadcast = true ); void SetError( SCROW nRow, const FormulaError nError); - void GetString( SCROW nRow, OUString& rString, const ScInterpreterContext* pContext = nullptr ) const - { return GetString( GetCellValue( nRow ), nRow, rString, pContext ); } - void GetString( sc::ColumnBlockConstPosition& rBlockPos, SCROW nRow, - OUString& rString, const ScInterpreterContext* pContext = nullptr ) const - { return GetString( GetCellValue( rBlockPos, nRow ), nRow, rString, pContext ); } + OUString GetString( SCROW nRow, const ScInterpreterContext* pContext = nullptr ) const + { return GetString( GetCellValue( nRow ), nRow, pContext ); } + OUString GetString( sc::ColumnBlockConstPosition& rBlockPos, SCROW nRow, + const ScInterpreterContext* pContext = nullptr ) const + { return GetString( GetCellValue( rBlockPos, nRow ), nRow, pContext ); } double* GetValueCell( SCROW nRow ); - void GetInputString( SCROW nRow, OUString& rString ) const - { return GetInputString( GetCellValue( nRow ), nRow, rString ); } - void GetInputString( sc::ColumnBlockConstPosition& rBlockPos, SCROW nRow, OUString& rString ) const - { return GetInputString( GetCellValue( rBlockPos, nRow ), nRow, rString ); } + OUString GetInputString( SCROW nRow ) const + { return GetInputString( GetCellValue( nRow ), nRow ); } + OUString GetInputString( sc::ColumnBlockConstPosition& rBlockPos, SCROW nRow ) const + { return GetInputString( GetCellValue( rBlockPos, nRow ), nRow ); } double GetValue( SCROW nRow ) const; const EditTextObject* GetEditText( SCROW nRow ) const; void RemoveEditTextCharAttribs( SCROW nRow, const ScPatternAttr& rAttr ); - void GetFormula( SCROW nRow, OUString& rFormula ) const; + OUString GetFormula( SCROW nRow ) const; const ScFormulaCell* GetFormulaCell( SCROW nRow ) const; ScFormulaCell* GetFormulaCell( SCROW nRow ); ScFormulaCell * const * GetFormulaCellBlockAddress( SCROW nRow, size_t& rBlockSize ) const; @@ -746,8 +746,8 @@ private: sc::CellStoreType::const_iterator& itPos, SCROW nRow, bool bForward) const; SCROW FindNextVisibleRow(SCROW nRow, bool bForward) const; - void GetString( const ScRefCellValue& cell, SCROW nRow, OUString& rString, const ScInterpreterContext* pContext = nullptr ) const; - void GetInputString( const ScRefCellValue& cell, SCROW nRow, OUString& rString ) const; + OUString GetString( const ScRefCellValue& cell, SCROW nRow, const ScInterpreterContext* pContext = nullptr ) const; + OUString GetInputString( const ScRefCellValue& cell, SCROW nRow ) const; /** * Called whenever the state of cell array gets modified i.e. new cell diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx index 5f41d1878db1..7ff8fbcb4fbe 100644 --- a/sc/inc/document.hxx +++ b/sc/inc/document.hxx @@ -1189,16 +1189,14 @@ public: void BlockFormulaGroupContextDiscard( bool block ) { mbFormulaGroupCxtBlockDiscard = block; } - SC_DLLPUBLIC void GetInputString( SCCOL nCol, SCROW nRow, SCTAB nTab, OUString& rString ); + SC_DLLPUBLIC OUString GetInputString( SCCOL nCol, SCROW nRow, SCTAB nTab ) const; FormulaError GetStringForFormula( const ScAddress& rPos, OUString& rString ); SC_DLLPUBLIC double GetValue( const ScAddress& rPos ) const; SC_DLLPUBLIC double GetValue( SCCOL nCol, SCROW nRow, SCTAB nTab ) const; - SC_DLLPUBLIC void GetValue( SCCOL nCol, SCROW nRow, SCTAB nTab, double& rValue ) const; SC_DLLPUBLIC const EditTextObject* GetEditText( const ScAddress& rPos ) const; void RemoveEditTextCharAttribs( const ScAddress& rPos, const ScPatternAttr& rAttr ); SC_DLLPUBLIC double RoundValueAsShown( double fVal, sal_uInt32 nFormat, const ScInterpreterContext* pContext = nullptr ) const; - SC_DLLPUBLIC void GetNumberFormat( SCCOL nCol, SCROW nRow, SCTAB nTab, - sal_uInt32& rFormat ) const; + SC_DLLPUBLIC sal_uInt32 GetNumberFormat( SCCOL nCol, SCROW nRow, SCTAB nTab ) const; sal_uInt32 GetNumberFormat( const ScRange& rRange ) const; SC_DLLPUBLIC sal_uInt32 GetNumberFormat( const ScInterpreterContext& rContext, const ScAddress& ) const; void SetNumberFormat( const ScAddress& rPos, sal_uInt32 nNumberFormat ); @@ -1206,8 +1204,8 @@ public: void GetNumberFormatInfo( const ScInterpreterContext& rContext, SvNumFormatType& nType, sal_uInt32& nIndex, const ScAddress& rPos ) const; 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, OUString& rFormula ) const; - SC_DLLPUBLIC void GetCellType( SCCOL nCol, SCROW nRow, SCTAB nTab, CellType& rCellType ) const; + SC_DLLPUBLIC OUString GetFormula( SCCOL nCol, SCROW nRow, SCTAB nTab ) const; + SC_DLLPUBLIC CellType GetCellType( SCCOL nCol, SCROW nRow, SCTAB nTab ) const; SC_DLLPUBLIC CellType GetCellType( const ScAddress& rPos ) const; SC_DLLPUBLIC bool HasData( SCCOL nCol, SCROW nRow, SCTAB nTab ); @@ -2079,7 +2077,7 @@ public: void PrepareQuery( SCTAB nTab, ScQueryParam& rQueryParam ); SCSIZE Query( SCTAB nTab, const ScQueryParam& rQueryParam, bool bKeepSub ); SC_DLLPUBLIC bool CreateQueryParam( const ScRange& rRange, ScQueryParam& rQueryParam ); - void GetUpperCellString(SCCOL nCol, SCROW nRow, SCTAB nTab, OUString& rStr); + OUString GetUpperCellString(SCCOL nCol, SCROW nRow, SCTAB nTab); /** * Get a list of unique strings to use in filtering criteria. The string diff --git a/sc/inc/formulacell.hxx b/sc/inc/formulacell.hxx index 9349447e9ff4..e3939e18974e 100644 --- a/sc/inc/formulacell.hxx +++ b/sc/inc/formulacell.hxx @@ -226,13 +226,8 @@ public: size_t GetHash() const; - void GetFormula( OUString& rFormula, - const formula::FormulaGrammar::Grammar = formula::FormulaGrammar::GRAM_DEFAULT, - const ScInterpreterContext* pContext = nullptr ) const; - void GetFormula( OUStringBuffer& rBuffer, - const formula::FormulaGrammar::Grammar = formula::FormulaGrammar::GRAM_DEFAULT, - const ScInterpreterContext* pContext = nullptr ) const; - + OUString GetFormula( const formula::FormulaGrammar::Grammar = formula::FormulaGrammar::GRAM_DEFAULT, + const ScInterpreterContext* pContext = nullptr ) const; OUString GetFormula( sc::CompileFormulaContext& rCxt, const ScInterpreterContext* pContext = nullptr ) const; void SetDirty( bool bDirtyFlag=true ); diff --git a/sc/inc/rangenam.hxx b/sc/inc/rangenam.hxx index b98a9a1d93c3..f7217d567e87 100644 --- a/sc/inc/rangenam.hxx +++ b/sc/inc/rangenam.hxx @@ -125,8 +125,8 @@ public: Type GetType() const { return eType; } bool HasType( Type nType ) const; sal_uInt32 GetUnoType() const; - SC_DLLPUBLIC void GetSymbol( OUString& rSymbol, const formula::FormulaGrammar::Grammar eGrammar = formula::FormulaGrammar::GRAM_DEFAULT ) const; - SC_DLLPUBLIC void GetSymbol( OUString& rSymbol, const ScAddress& rPos, const formula::FormulaGrammar::Grammar eGrammar = formula::FormulaGrammar::GRAM_DEFAULT ) const; + SC_DLLPUBLIC OUString GetSymbol( const formula::FormulaGrammar::Grammar eGrammar = formula::FormulaGrammar::GRAM_DEFAULT ) const; + SC_DLLPUBLIC OUString GetSymbol( const ScAddress& rPos, const formula::FormulaGrammar::Grammar eGrammar = formula::FormulaGrammar::GRAM_DEFAULT ) const; void UpdateSymbol( OUStringBuffer& rBuffer, const ScAddress& ); /** diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx index cfe47f5f73e1..06dca697c790 100644 --- a/sc/inc/table.hxx +++ b/sc/inc/table.hxx @@ -446,14 +446,13 @@ public: bool ReservePatternCount( SCCOL nCol, SCSIZE nReserve ); void SetRawString( SCCOL nCol, SCROW nRow, const svl::SharedString& rStr ); - void GetString( SCCOL nCol, SCROW nRow, OUString& rString, - const ScInterpreterContext* pContext = nullptr ) const; + OUString GetString( SCCOL nCol, SCROW nRow, const ScInterpreterContext* pContext = nullptr ) const; double* GetValueCell( SCCOL nCol, SCROW nRow ); - void GetInputString( SCCOL nCol, SCROW nRow, OUString& rString ) const; + OUString GetInputString( SCCOL nCol, SCROW nRow ) const; double GetValue( SCCOL nCol, SCROW nRow ) const; const EditTextObject* GetEditText( SCCOL nCol, SCROW nRow ) const; void RemoveEditTextCharAttribs( SCCOL nCol, SCROW nRow, const ScPatternAttr& rAttr ); - void GetFormula( SCCOL nCol, SCROW nRow, OUString& rFormula ) const; + OUString GetFormula( SCCOL nCol, SCROW nRow ) const; const ScFormulaCell* GetFormulaCell( SCCOL nCol, SCROW nRow ) const; ScFormulaCell* GetFormulaCell( SCCOL nCol, SCROW nRow ); @@ -1210,7 +1209,7 @@ private: bool CreateExcelQuery(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ScQueryParam& rQueryParam); bool CreateStarQuery(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ScQueryParam& rQueryParam); - void GetUpperCellString(SCCOL nCol, SCROW nRow, OUString& rStr); + OUString GetUpperCellString(SCCOL nCol, SCROW nRow); bool RefVisible(const ScFormulaCell* pCell); diff --git a/sc/qa/extras/macros-test.cxx b/sc/qa/extras/macros-test.cxx index 42797af572da..f888deffd25e 100644 --- a/sc/qa/extras/macros-test.cxx +++ b/sc/qa/extras/macros-test.cxx @@ -234,8 +234,7 @@ void ScMacrosTest::testStarBasic() xComponent, "vnd.sun.Star.script:Standard.Module1.Macro1?language=Basic&location=document", aParams, aRet, aOutParamIndex, aOutParam); - double aValue; - rDoc.GetValue(0,0,0,aValue); + double aValue = rDoc.GetValue(0,0,0); CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("script did not change the value of Sheet1.A1",2.0, aValue, 0.00001); pDocSh->DoClose(); } diff --git a/sc/qa/unit/datacache.cxx b/sc/qa/unit/datacache.cxx index 6440e9fe9428..e3ee2058f63b 100644 --- a/sc/qa/unit/datacache.cxx +++ b/sc/qa/unit/datacache.cxx @@ -109,8 +109,7 @@ void ScCacheTest::testCacheFormula() std::vector<OUString> aFormulas = { "=B1", "=B2", "=B3", "=B4", "=B5", "=B1" }; for (SCROW nRow = 0; nRow <= 5; ++nRow) { - OUString aFormula; - aNewDoc.GetFormula(0, nRow, 0, aFormula); + OUString aFormula = aNewDoc.GetFormula(0, nRow, 0); CPPUNIT_ASSERT_EQUAL(aFormulas[nRow], aFormula); } } diff --git a/sc/qa/unit/filters-test.cxx b/sc/qa/unit/filters-test.cxx index 1a888725154c..e6a736799663 100644 --- a/sc/qa/unit/filters-test.cxx +++ b/sc/qa/unit/filters-test.cxx @@ -167,21 +167,20 @@ void testRangeNameImpl(const ScDocument& rDoc) //add some more checks here ScRangeData* pRangeData = rDoc.GetRangeName()->findByUpperName(OUString("GLOBAL1")); CPPUNIT_ASSERT_MESSAGE("range name Global1 not found", pRangeData); - double aValue; - rDoc.GetValue(1,0,0,aValue); + double aValue = rDoc.GetValue(1,0,0); ASSERT_DOUBLES_EQUAL_MESSAGE("range name Global1 should reference Sheet1.A1", 1.0, aValue); pRangeData = rDoc.GetRangeName(0)->findByUpperName(OUString("LOCAL1")); CPPUNIT_ASSERT_MESSAGE("range name Sheet1.Local1 not found", pRangeData); - rDoc.GetValue(1,2,0,aValue); + aValue = rDoc.GetValue(1,2,0); ASSERT_DOUBLES_EQUAL_MESSAGE("range name Sheet1.Local1 should reference Sheet1.A3", 3.0, aValue); pRangeData = rDoc.GetRangeName(1)->findByUpperName(OUString("LOCAL2")); CPPUNIT_ASSERT_MESSAGE("range name Sheet2.Local2 not found", pRangeData); //check for correct results for the remaining formulas - rDoc.GetValue(1,1,0, aValue); + aValue = rDoc.GetValue(1,1,0); ASSERT_DOUBLES_EQUAL_MESSAGE("=global2 should be 2", 2.0, aValue); - rDoc.GetValue(1,3,0, aValue); + aValue = rDoc.GetValue(1,3,0); ASSERT_DOUBLES_EQUAL_MESSAGE("=local2 should be 4", 4.0, aValue); - rDoc.GetValue(2,0,0, aValue); + aValue = rDoc.GetValue(2,0,0); ASSERT_DOUBLES_EQUAL_MESSAGE("=SUM(global3) should be 10", 10.0, aValue); } @@ -210,9 +209,9 @@ void testContentImpl(ScDocument& rDoc, sal_Int32 nFormat ) //same code for ods, { double fValue; //check value import - rDoc.GetValue(0,0,0,fValue); + fValue = rDoc.GetValue(0,0,0); ASSERT_DOUBLES_EQUAL_MESSAGE("value not imported correctly", 1.0, fValue); - rDoc.GetValue(0,1,0,fValue); + fValue = rDoc.GetValue(0,1,0); ASSERT_DOUBLES_EQUAL_MESSAGE("value not imported correctly", 2.0, fValue); OUString aString = rDoc.GetString(1, 0, 0); @@ -223,13 +222,13 @@ void testContentImpl(ScDocument& rDoc, sal_Int32 nFormat ) //same code for ods, //check basic formula import // in case of DIF it just contains values - rDoc.GetValue(2,0,0,fValue); + fValue = rDoc.GetValue(2,0,0); ASSERT_DOUBLES_EQUAL_MESSAGE("=2*3", 6.0, fValue); - rDoc.GetValue(2,1,0,fValue); + fValue = rDoc.GetValue(2,1,0); ASSERT_DOUBLES_EQUAL_MESSAGE("=2+3", 5.0, fValue); - rDoc.GetValue(2,2,0,fValue); + fValue = rDoc.GetValue(2,2,0); ASSERT_DOUBLES_EQUAL_MESSAGE("=2-3", -1.0, fValue); - rDoc.GetValue(2,3,0,fValue); + fValue = rDoc.GetValue(2,3,0); ASSERT_DOUBLES_EQUAL_MESSAGE("=C1+C2", 11.0, fValue); //check merged cells import diff --git a/sc/qa/unit/helper/csv_handler.hxx b/sc/qa/unit/helper/csv_handler.hxx index 14b6df78a90b..537c1e12b33d 100644 --- a/sc/qa/unit/helper/csv_handler.hxx +++ b/sc/qa/unit/helper/csv_handler.hxx @@ -138,8 +138,7 @@ public: } else { - double aValue; - mpDoc->GetValue(mnCol, mnRow, mnTab, aValue); + double aValue = mpDoc->GetValue(mnCol, mnRow, mnTab); #if DEBUG_CSV_HANDLER std::cout << "Value: " << aValue << std::endl; std::cout << "CSVValue: " << nValue << std::endl; diff --git a/sc/qa/unit/helper/qahelper.cxx b/sc/qa/unit/helper/qahelper.cxx index 64c23cef7c36..c1d42a2a1a6a 100644 --- a/sc/qa/unit/helper/qahelper.cxx +++ b/sc/qa/unit/helper/qahelper.cxx @@ -1037,17 +1037,12 @@ OUString getRangeByName(ScDocument* pDoc, const OUString& aRangeName) { ScRangeData* pName = pDoc->GetRangeName()->findByUpperName(aRangeName.toAsciiUpperCase()); CPPUNIT_ASSERT(pName); - OUString aSymbol; - pName->GetSymbol(aSymbol, pDoc->GetGrammar()); - - return aSymbol; + return pName->GetSymbol(pDoc->GetGrammar()); } OUString getFormula(ScDocument* pDoc, SCCOL nCol, SCROW nRow, SCTAB nTab) { - OUString aFormula; - pDoc->GetFormula(nCol, nRow, nTab, aFormula); - return aFormula; + return pDoc->GetFormula(nCol, nRow, nTab); } #if CALC_DEBUG_OUTPUT != 0 diff --git a/sc/qa/unit/parallelism.cxx b/sc/qa/unit/parallelism.cxx index 5f25cf3c582e..37dcd79e546c 100644 --- a/sc/qa/unit/parallelism.cxx +++ b/sc/qa/unit/parallelism.cxx @@ -230,7 +230,7 @@ void ScParallelismTest::testSUMIFS() m_pDoc->GetValue(5, i, 0) << " " << m_pDoc->GetValue(11, i, 0) << "," << m_pDoc->GetValue(12, i, 0) << " \""; - m_pDoc->GetFormula(15, i, 0, sFormula); + sFormula = m_pDoc->GetFormula(15, i, 0); std::cerr << sFormula << "\": \"" << m_pDoc->GetString(15, i, 0) << "\": " << m_pDoc->GetValue(15, i, 0) << std::endl; diff --git a/sc/qa/unit/subsequent_export_test.cxx b/sc/qa/unit/subsequent_export_test.cxx index ad27741d4ad8..8fbe40a10ac9 100644 --- a/sc/qa/unit/subsequent_export_test.cxx +++ b/sc/qa/unit/subsequent_export_test.cxx @@ -3164,8 +3164,7 @@ void ScExportTest::testTrackChangesSimpleXLSX() CPPUNIT_ASSERT(pCT); ScChangeAction* pAction = pCT->GetAction(1); CPPUNIT_ASSERT(pAction); - OUString aDesc; - pAction->GetDescription(aDesc, *pDoc); + OUString aDesc = pAction->GetDescription(*pDoc); CPPUNIT_ASSERT_EQUAL(OUString("Cell B2 changed from '<empty>' to '1'"), aDesc); bGood = aTest.checkRevisionUserAndTime(*pDoc, aOwnerName); @@ -4067,12 +4066,11 @@ void ScExportTest::testSheetLocalRangeNameXLS() CPPUNIT_ASSERT(pRangeName); CPPUNIT_ASSERT_EQUAL(size_t(2), pRangeName->size()); - OUString aFormula; - rDoc.GetFormula(3, 11, 0, aFormula); + OUString aFormula = rDoc.GetFormula(3, 11, 0); CPPUNIT_ASSERT_EQUAL(OUString("=SUM(local_name2)"), aFormula); ASSERT_DOUBLES_EQUAL(14.0, rDoc.GetValue(3, 11, 0)); - rDoc.GetFormula(6, 4, 0, aFormula); + aFormula = rDoc.GetFormula(6, 4, 0); CPPUNIT_ASSERT_EQUAL(OUString("=local_name1"), aFormula); xDocSh2->DoClose(); diff --git a/sc/qa/unit/subsequent_export_test2.cxx b/sc/qa/unit/subsequent_export_test2.cxx index 025941239507..c585d2394c27 100644 --- a/sc/qa/unit/subsequent_export_test2.cxx +++ b/sc/qa/unit/subsequent_export_test2.cxx @@ -994,8 +994,7 @@ void ScExportTest2::testExponentWithoutSignFormatXLSX() CPPUNIT_ASSERT(xDocSh.is()); ScDocument& rDoc = xDocSh->GetDocument(); - sal_uInt32 nNumberFormat; - rDoc.GetNumberFormat(0, 0, 0, nNumberFormat); + sal_uInt32 nNumberFormat = rDoc.GetNumberFormat(0, 0, 0); const SvNumberformat* pNumberFormat = rDoc.GetFormatTable()->GetEntry(nNumberFormat); const OUString& rFormatStr = pNumberFormat->GetFormatstring(); @@ -1035,7 +1034,6 @@ void ScExportTest2::testExtendedLCIDXLSX() // Check import ScDocument& rDoc = xDocSh->GetDocument(); SvNumberFormatter* pNumFormatter = rDoc.GetFormatTable(); - sal_uInt32 nNumberFormat; const OUString aLang[5] = { "[$-41E]", "[$-411]", "[$-40D]", "[$-401]", "[$-500]" }; const OUString aCalendar[5] = { "[~buddhist]DD-MM-YYYY", "DD-MM-EE", "[~jewish]DD-MM-YYYY", "[~hijri]DD-MM-YYYY", "[~dangi]YYYY/MM/DD" }; @@ -1046,7 +1044,7 @@ void ScExportTest2::testExtendedLCIDXLSX() { for (sal_Int16 nRow = 1; nRow <= 4; nRow++) { - rDoc.GetNumberFormat(nCol, nRow, 0, nNumberFormat); + sal_uInt32 nNumberFormat = rDoc.GetNumberFormat(nCol, nRow, 0); const SvNumberformat* pNumberFormat = pNumFormatter->GetEntry(nNumberFormat); const OUString& rFormatStr = pNumberFormat->GetFormatstring(); const OUString aExpectedFormatStr @@ -2328,8 +2326,7 @@ void ScExportTest2::testTdf87973_externalLinkSkipUnuseds() ScDocument& rDoc = pShell->GetDocument(); // change external link to: 87973_externalSource.ods - OUString aFormula, aFormula2; - rDoc.GetFormula(3, 1, 0, aFormula); + OUString aFormula = rDoc.GetFormula(3, 1, 0); auto nIdxOfFilename = aFormula.indexOf("tdf132105_external.ods"); aFormula = aFormula.replaceAt(nIdxOfFilename, 22, "87973_externalSource.ods"); auto nIdxOfFile = aFormula.indexOf("file"); @@ -2345,7 +2342,7 @@ void ScExportTest2::testTdf87973_externalLinkSkipUnuseds() rDoc.SetFormula(ScAddress(3, 1, 0), aFormula, formula::FormulaGrammar::GRAM_NATIVE_UI); // tdf#138832: test the same thing with singleref link - rDoc.GetFormula(3, 2, 0, aFormula); + aFormula = rDoc.GetFormula(3, 2, 0); nIdxOfFilename = aFormula.indexOf("tdf132105_external.ods"); aFormula = aFormula.replaceAt(nIdxOfFilename, 22, "87973_externalSource.ods"); nIdxOfFile = aFormula.indexOf("file"); @@ -2359,10 +2356,10 @@ void ScExportTest2::testTdf87973_externalLinkSkipUnuseds() // check if the new filename is present in the link (and not replaced by '[2]') ScDocument& rDoc2 = pDocSh->GetDocument(); - rDoc2.GetFormula(3, 1, 0, aFormula2); + OUString aFormula2 = rDoc2.GetFormula(3, 1, 0); CPPUNIT_ASSERT(aFormula2.indexOf("tdf132105_external.ods") < 0); CPPUNIT_ASSERT(aFormula2.indexOf("87973_externalSource.ods") >= 0); - rDoc2.GetFormula(3, 2, 0, aFormula2); + aFormula2 = rDoc2.GetFormula(3, 2, 0); CPPUNIT_ASSERT(aFormula2.indexOf("tdf132105_external.ods") < 0); CPPUNIT_ASSERT(aFormula2.indexOf("87973_externalSource.ods") >= 0); @@ -2423,8 +2420,7 @@ void ScExportTest2::testTdf138824_linkToParentDirectory() aTempFilename = aTempFilename.copy(0, nIdxOfTmpFile + 1); // change external link to tmp directory - OUString aFormula; - rDoc.GetFormula(3, 1, 0, aFormula); + OUString aFormula = rDoc.GetFormula(3, 1, 0); auto nIdxOfFilename = aFormula.indexOf("tdf138824_externalSource.ods"); auto nIdxOfFile = aFormula.indexOf("file"); diff --git a/sc/qa/unit/subsequent_filters_test.cxx b/sc/qa/unit/subsequent_filters_test.cxx index de4cea5dc961..d19d35c23607 100644 --- a/sc/qa/unit/subsequent_filters_test.cxx +++ b/sc/qa/unit/subsequent_filters_test.cxx @@ -354,28 +354,27 @@ void testRangeNameImpl(const ScDocument& rDoc) //add some more checks here ScRangeData* pRangeData = rDoc.GetRangeName()->findByUpperName(OUString("GLOBAL1")); CPPUNIT_ASSERT_MESSAGE("range name Global1 not found", pRangeData); - double aValue; - rDoc.GetValue(1,0,0,aValue); + double aValue = rDoc.GetValue(1,0,0); CPPUNIT_ASSERT_EQUAL_MESSAGE("range name Global1 should reference Sheet1.A1", 1.0, aValue); pRangeData = rDoc.GetRangeName(0)->findByUpperName(OUString("LOCAL1")); CPPUNIT_ASSERT_MESSAGE("range name Sheet1.Local1 not found", pRangeData); - rDoc.GetValue(1,2,0,aValue); + aValue = rDoc.GetValue(1,2,0); CPPUNIT_ASSERT_EQUAL_MESSAGE("range name Sheet1.Local1 should reference Sheet1.A3", 3.0, aValue); pRangeData = rDoc.GetRangeName(1)->findByUpperName(OUString("LOCAL2")); CPPUNIT_ASSERT_MESSAGE("range name Sheet2.Local2 not found", pRangeData); - rDoc.GetValue(1,1,1,aValue); + aValue = rDoc.GetValue(1,1,1); CPPUNIT_ASSERT_EQUAL_MESSAGE("range name Sheet2.Local2 should reference Sheet2.A2", 7.0, aValue); //check for correct results for the remaining formulas - rDoc.GetValue(1,1,0, aValue); + aValue = rDoc.GetValue(1,1,0); CPPUNIT_ASSERT_EQUAL_MESSAGE("=global2 should be 2", 2.0, aValue); - rDoc.GetValue(1,3,0, aValue); + aValue = rDoc.GetValue(1,3,0); CPPUNIT_ASSERT_EQUAL_MESSAGE("=local2 should be 4", 4.0, aValue); - rDoc.GetValue(2,0,0, aValue); + aValue = rDoc.GetValue(2,0,0); CPPUNIT_ASSERT_EQUAL_MESSAGE("=SUM(global3) should be 10", 10.0, aValue); - rDoc.GetValue(1,0,1,aValue); + aValue = rDoc.GetValue(1,0,1); CPPUNIT_ASSERT_EQUAL_MESSAGE("range name Sheet2.local1 should reference Sheet1.A5", 5.0, aValue); // Test if Global5 ( which depends on Global6 ) is evaluated - rDoc.GetValue(0,5,1, aValue); + aValue = rDoc.GetValue(0,5,1); CPPUNIT_ASSERT_EQUAL_MESSAGE("formula Global5 should reference Global6 ( which is evaluated as local1 )", 5.0, aValue); } @@ -668,11 +667,10 @@ void ScFiltersTest::testBooleanFormatXLSX() const OUString aBooleanTypeStr = "BOOLEAN"; CPPUNIT_ASSERT_MESSAGE("Failed to load check-boolean.xlsx", xDocSh.is()); - sal_uInt32 nNumberFormat; for (SCROW i = 0; i <= 1; i++) { - rDoc.GetNumberFormat(0, i, 0, nNumberFormat); + sal_uInt32 nNumberFormat = rDoc.GetNumberFormat(0, i, 0); const SvNumberformat* pNumberFormat = pNumFormatter->GetEntry(nNumberFormat); const OUString& rFormatStr = pNumberFormat->GetFormatstring(); CPPUNIT_ASSERT_EQUAL_MESSAGE("Number format != boolean", aBooleanTypeStr, rFormatStr); @@ -687,8 +685,7 @@ void ScFiltersTest::testTdf143809() ScDocument& rDoc = xDocSh->GetDocument(); - OUString aFormula; - rDoc.GetFormula(0, 0, 0, aFormula); + OUString aFormula = rDoc.GetFormula(0, 0, 0); CPPUNIT_ASSERT_EQUAL(OUString("=SUMPRODUCT(IFERROR(CEILING.MATH(DURATIONS,300),0))"), aFormula); // Without the fix in place, this test would have failed with @@ -696,7 +693,7 @@ void ScFiltersTest::testTdf143809() // - Actual : Err:502 CPPUNIT_ASSERT_EQUAL(OUString("53700"), rDoc.GetString(0, 0, 0)); - rDoc.GetFormula(0, 1, 0, aFormula); + aFormula = rDoc.GetFormula(0, 1, 0); CPPUNIT_ASSERT_EQUAL( OUString("=SUMPRODUCT(IFERROR(CEILING(SUMIFS(DURATIONS,IDS,IDS),300)/COUNTIFS(IDS,IDS),0))"), aFormula); CPPUNIT_ASSERT_EQUAL(OUString("51900"), rDoc.GetString(0, 1, 0)); @@ -710,8 +707,7 @@ void ScFiltersTest::testTdf76310() ScDocument& rDoc = xDocSh->GetDocument(); - OUString aFormula; - rDoc.GetFormula(0, 0, 0, aFormula); + OUString aFormula = rDoc.GetFormula(0, 0, 0); // Without the fix in place, this test would have failed with // - Expected: =1 // + @@ -749,12 +745,11 @@ void ScFiltersTest::testRangeNameLocalXLS() CPPUNIT_ASSERT(pRangeName); CPPUNIT_ASSERT_EQUAL(size_t(2), pRangeName->size()); - OUString aFormula; - rDoc.GetFormula(3, 11, 0, aFormula); + OUString aFormula = rDoc.GetFormula(3, 11, 0); CPPUNIT_ASSERT_EQUAL(OUString("=SUM(local_name2)"), aFormula); ASSERT_DOUBLES_EQUAL(14.0, rDoc.GetValue(3, 11, 0)); - rDoc.GetFormula(6, 4, 0, aFormula); + aFormula = rDoc.GetFormula(6, 4, 0); CPPUNIT_ASSERT_EQUAL(OUString("=local_name1"), aFormula); xDocSh->DoClose(); @@ -1081,16 +1076,14 @@ void testDBRanges_Impl(ScDocument& rDoc, sal_Int32 nFormat) CPPUNIT_ASSERT_EQUAL_MESSAGE("Sheet1: row 6-end should be visible", MAXROW, nRow2); if (nFormat == FORMAT_ODS) //excel doesn't support named db ranges { - double aValue; - rDoc.GetValue(0,10,1, aValue); + double aValue = rDoc.GetValue(0,10,1); CPPUNIT_ASSERT_EQUAL_MESSAGE("Sheet2: A11: formula result is incorrect", 4.0, aValue); - rDoc.GetValue(1, 10, 1, aValue); + aValue = rDoc.GetValue(1, 10, 1); CPPUNIT_ASSERT_EQUAL_MESSAGE("Sheet2: B11: formula result is incorrect", 2.0, aValue); } - double aValue; - rDoc.GetValue(3,10,1, aValue); + double aValue = rDoc.GetValue(3,10,1); CPPUNIT_ASSERT_EQUAL_MESSAGE("Sheet2: D11: formula result is incorrect", 4.0, aValue); - rDoc.GetValue(4, 10, 1, aValue); + aValue = rDoc.GetValue(4, 10, 1); CPPUNIT_ASSERT_EQUAL_MESSAGE("Sheet2: E11: formula result is incorrect", 2.0, aValue); } diff --git a/sc/qa/unit/subsequent_filters_test2.cxx b/sc/qa/unit/subsequent_filters_test2.cxx index 754aa687c7c5..28f42b25dab6 100644 --- a/sc/qa/unit/subsequent_filters_test2.cxx +++ b/sc/qa/unit/subsequent_filters_test2.cxx @@ -784,11 +784,10 @@ void ScFiltersTest2::testSharedFormulaXLS() CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(1), pFC->GetSharedTopRow()); CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(10), pFC->GetSharedLength()); - OUString aFormula; - rDoc.GetFormula(2, 1, 0, aFormula); + OUString aFormula = rDoc.GetFormula(2, 1, 0); CPPUNIT_ASSERT_EQUAL(OUString("=SUM(B9:D9)"), aFormula); - rDoc.GetFormula(2, 10, 0, aFormula); + aFormula = rDoc.GetFormula(2, 10, 0); CPPUNIT_ASSERT_EQUAL(OUString("=SUM(B18:D18)"), aFormula); } @@ -803,11 +802,10 @@ void ScFiltersTest2::testSharedFormulaXLS() CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(8), pFC->GetSharedTopRow()); CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(10), pFC->GetSharedLength()); - OUString aFormula; - rDoc.GetFormula(4, 8, 0, aFormula); + OUString aFormula = rDoc.GetFormula(4, 8, 0); CPPUNIT_ASSERT_EQUAL(OUString("=SUM(G9:EY9)"), aFormula); - rDoc.GetFormula(4, 17, 0, aFormula); + aFormula = rDoc.GetFormula(4, 17, 0); CPPUNIT_ASSERT_EQUAL(OUString("=SUM(G18:EY18)"), aFormula); } @@ -822,11 +820,10 @@ void ScFiltersTest2::testSharedFormulaXLS() CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(15), pFC->GetSharedTopRow()); CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(10), pFC->GetSharedLength()); - OUString aFormula; - rDoc.GetFormula(6, 15, 0, aFormula); + OUString aFormula = rDoc.GetFormula(6, 15, 0); CPPUNIT_ASSERT_EQUAL(OUString("=SUM(A16:A40000)"), aFormula); - rDoc.GetFormula(6, 24, 0, aFormula); + aFormula = rDoc.GetFormula(6, 24, 0); CPPUNIT_ASSERT_EQUAL(OUString("=SUM(A25:A40009)"), aFormula); } @@ -1329,14 +1326,13 @@ void ScFiltersTest2::testTdf136364() // Without the fix in place, it would have failed with // - Expected: =SUM((B2:B3~C4:C5~D6:D7)) // - Actual : =SUM((B2:B3~C4:C5,D6:D7)) - OUString aFormula; - rDoc.GetFormula(4, 0, 0, aFormula); + OUString aFormula = rDoc.GetFormula(4, 0, 0); CPPUNIT_ASSERT_EQUAL(OUString("=SUM((B2:B3~C4:C5~D6:D7))"), aFormula); CPPUNIT_ASSERT_EQUAL(27.0, rDoc.GetValue(ScAddress(4, 0, 0))); // - Expected: =SUM((B2~C4~D6)) // - Actual : =SUM((B2~C4,D6)) - rDoc.GetFormula(4, 1, 0, aFormula); + aFormula = rDoc.GetFormula(4, 1, 0); CPPUNIT_ASSERT_EQUAL(OUString("=SUM((B2~C4~D6))"), aFormula); CPPUNIT_ASSERT_EQUAL(12.0, rDoc.GetValue(ScAddress(4, 1, 0))); @@ -2372,8 +2368,7 @@ void ScFiltersTest2::testTdf112780() // - Actual : #VALUE! CPPUNIT_ASSERT_EQUAL(OUString(""), rDoc.GetString(ScAddress(3, 5, 0))); - OUString aFormula; - rDoc.GetFormula(3, 5, 0, aFormula); + OUString aFormula = rDoc.GetFormula(3, 5, 0); CPPUNIT_ASSERT_EQUAL(OUString("=G6+J6+M6"), aFormula); xDocSh->DoClose(); @@ -2452,8 +2447,7 @@ void ScFiltersTest2::testVBAMacroFunctionODS() ScDocShellRef xDocSh = loadDoc(u"vba_macro_functions.", FORMAT_ODS); ScDocument& rDoc = xDocSh->GetDocument(); - OUString aFunction; - rDoc.GetFormula(2, 0, 0, aFunction); + OUString aFunction = rDoc.GetFormula(2, 0, 0); std::cout << aFunction << std::endl; CPPUNIT_ASSERT_DOUBLES_EQUAL(10.0, rDoc.GetValue(2, 0, 0), 1e-6); @@ -2933,13 +2927,12 @@ void ScFiltersTest2::testInvalidBareBiff5() // Row 2 aPos = ScAddress(0, 1, 0); CPPUNIT_ASSERT_EQUAL(CELLTYPE_FORMULA, rDoc.GetCellType(aPos)); - OUString sFormula; - rDoc.GetFormula(aPos.Col(), aPos.Row(), aPos.Tab(), sFormula); + OUString sFormula = rDoc.GetFormula(aPos.Col(), aPos.Row(), aPos.Tab()); CPPUNIT_ASSERT_EQUAL(OUString("=TRUE()"), sFormula); CPPUNIT_ASSERT_EQUAL(1.0, rDoc.GetValue(aPos)); aPos.IncCol(); CPPUNIT_ASSERT_EQUAL(CELLTYPE_FORMULA, rDoc.GetCellType(aPos)); - rDoc.GetFormula(aPos.Col(), aPos.Row(), aPos.Tab(), sFormula); + sFormula = rDoc.GetFormula(aPos.Col(), aPos.Row(), aPos.Tab()); CPPUNIT_ASSERT_EQUAL(OUString("=FALSE()"), sFormula); CPPUNIT_ASSERT_EQUAL(0.0, rDoc.GetValue(aPos)); aPos.IncCol(); diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx index 9626071fd0b1..cc101bfe2253 100644 --- a/sc/qa/unit/ucalc.cxx +++ b/sc/qa/unit/ucalc.cxx @@ -688,8 +688,7 @@ void Test::testTdf90698() // Without the fix in place, this would have failed with // - Expected: =(1;2) // - Actual : =(1~2) - OUString aFormula; - m_pDoc->GetFormula(0,0,0, aFormula); + OUString aFormula = m_pDoc->GetFormula(0,0,0); CPPUNIT_ASSERT_EQUAL(OUString("=(1;2)"), aFormula); m_pDoc->DeleteTab(0); @@ -1678,15 +1677,14 @@ void Test::testFuncParam() // First, the normal case, with no missing parameters. m_pDoc->SetString(0, 0, 0, "=AVERAGE(1;2;3)"); m_pDoc->CalcFormulaTree(false, false); - double val; - m_pDoc->GetValue(0, 0, 0, val); + double val = m_pDoc->GetValue(0, 0, 0); ASSERT_DOUBLES_EQUAL_MESSAGE("incorrect result", 2.0, val); // Now function with missing parameters. Missing values should be treated // as zeros. m_pDoc->SetString(0, 0, 0, "=AVERAGE(1;;;)"); m_pDoc->CalcFormulaTree(false, false); - m_pDoc->GetValue(0, 0, 0, val); + val = m_pDoc->GetValue(0, 0, 0); ASSERT_DOUBLES_EQUAL_MESSAGE("incorrect result", 0.25, val); // Conversion of string to numeric argument. @@ -1704,15 +1702,15 @@ void Test::testFuncParam() aConfig.mbEmptyStringAsZero = true; m_pDoc->SetCalcConfig(aConfig); m_pDoc->CalcAll(); - m_pDoc->GetValue(0, 0, 0, val); + val = m_pDoc->GetValue(0, 0, 0); ASSERT_DOUBLES_EQUAL_MESSAGE("incorrect result", 3.0, val); - m_pDoc->GetValue(0, 1, 0, val); + val = m_pDoc->GetValue(0, 1, 0); ASSERT_DOUBLES_EQUAL_MESSAGE("incorrect result", 3.0, val); - m_pDoc->GetValue(0, 2, 0, val); + val = m_pDoc->GetValue(0, 2, 0); ASSERT_DOUBLES_EQUAL_MESSAGE("incorrect result", 7.0, val); aVal = m_pDoc->GetString( 0, 3, 0); CPPUNIT_ASSERT_EQUAL_MESSAGE("incorrect result", OUString("#VALUE!"), aVal); - m_pDoc->GetValue(0, 4, 0, val); + val = m_pDoc->GetValue(0, 4, 0); ASSERT_DOUBLES_EQUAL_MESSAGE("incorrect result", 7.4, val); // With "Convert also locale dependent" and "Empty string as zero"=False option. @@ -1724,11 +1722,11 @@ void Test::testFuncParam() CPPUNIT_ASSERT_EQUAL_MESSAGE("incorrect result", OUString("#VALUE!"), aVal); aVal = m_pDoc->GetString( 0, 1, 0); CPPUNIT_ASSERT_EQUAL_MESSAGE("incorrect result", OUString("#VALUE!"), aVal); - m_pDoc->GetValue(0, 2, 0, val); + val = m_pDoc->GetValue(0, 2, 0); ASSERT_DOUBLES_EQUAL_MESSAGE("incorrect result", 7.0, val); aVal = m_pDoc->GetString( 0, 3, 0); CPPUNIT_ASSERT_EQUAL_MESSAGE("incorrect result", OUString("#VALUE!"), aVal); - m_pDoc->GetValue(0, 4, 0, val); + val = m_pDoc->GetValue(0, 4, 0); ASSERT_DOUBLES_EQUAL_MESSAGE("incorrect result", 7.4, val); // With "Convert only unambiguous" and "Empty string as zero"=True option. @@ -1736,11 +1734,11 @@ void Test::testFuncParam() aConfig.mbEmptyStringAsZero = true; m_pDoc->SetCalcConfig(aConfig); m_pDoc->CalcAll(); - m_pDoc->GetValue(0, 0, 0, val); + val = m_pDoc->GetValue(0, 0, 0); ASSERT_DOUBLES_EQUAL_MESSAGE("incorrect result", 3.0, val); - m_pDoc->GetValue(0, 1, 0, val); + val = m_pDoc->GetValue(0, 1, 0); ASSERT_DOUBLES_EQUAL_MESSAGE("incorrect result", 3.0, val); - m_pDoc->GetValue(0, 2, 0, val); + val = m_pDoc->GetValue(0, 2, 0); ASSERT_DOUBLES_EQUAL_MESSAGE("incorrect result", 7.0, val); aVal = m_pDoc->GetString( 0, 3, 0); CPPUNIT_ASSERT_EQUAL_MESSAGE("incorrect result", OUString("#VALUE!"), aVal); @@ -1756,7 +1754,7 @@ void Test::testFuncParam() CPPUNIT_ASSERT_EQUAL_MESSAGE("incorrect result", OUString("#VALUE!"), aVal); aVal = m_pDoc->GetString( 0, 1, 0); CPPUNIT_ASSERT_EQUAL_MESSAGE("incorrect result", OUString("#VALUE!"), aVal); - m_pDoc->GetValue(0, 2, 0, val); + m_pDoc->GetValue(0, 2, 0); ASSERT_DOUBLES_EQUAL_MESSAGE("incorrect result", 7.0, val); aVal = m_pDoc->GetString( 0, 3, 0); CPPUNIT_ASSERT_EQUAL_MESSAGE("incorrect result", OUString("#VALUE!"), aVal); @@ -1768,15 +1766,15 @@ void Test::testFuncParam() aConfig.mbEmptyStringAsZero = true; m_pDoc->SetCalcConfig(aConfig); m_pDoc->CalcAll(); - m_pDoc->GetValue(0, 0, 0, val); + val = m_pDoc->GetValue(0, 0, 0); ASSERT_DOUBLES_EQUAL_MESSAGE("incorrect result", 3.0, val); - m_pDoc->GetValue(0, 1, 0, val); + val = m_pDoc->GetValue(0, 1, 0); ASSERT_DOUBLES_EQUAL_MESSAGE("incorrect result", 3.0, val); - m_pDoc->GetValue(0, 2, 0, val); + val = m_pDoc->GetValue(0, 2, 0); ASSERT_DOUBLES_EQUAL_MESSAGE("incorrect result", 3.0, val); - m_pDoc->GetValue(0, 3, 0, val); + val = m_pDoc->GetValue(0, 3, 0); ASSERT_DOUBLES_EQUAL_MESSAGE("incorrect result", 3.0, val); - m_pDoc->GetValue(0, 4, 0, val); + val = m_pDoc->GetValue(0, 4, 0); ASSERT_DOUBLES_EQUAL_MESSAGE("incorrect result", 3.0, val); // With "Generate #VALUE! error" ("Empty string as zero" is ignored). @@ -1832,8 +1830,7 @@ void Test::testNamedRange() m_pDoc->SetString (1, 0, 0, "=A1/Divisor"); m_pDoc->CalcAll(); - double result; - m_pDoc->GetValue (1, 0, 0, result); + double result = m_pDoc->GetValue (1, 0, 0); ASSERT_DOUBLES_EQUAL_MESSAGE ("calculation failed", 1.0, result); // Test copy-ability of range names. @@ -1866,8 +1863,7 @@ void Test::testNamedRange() ScAddress aPos(1,0,1); OUString aFormula("=Sheet1.local1+Sheet1.local2+Sheet1.local3+Sheet1.local4"); m_pDoc->SetString(aPos, aFormula); - OUString aString; - m_pDoc->GetFormula(1,0,1, aString); + OUString aString = m_pDoc->GetFormula(1,0,1); CPPUNIT_ASSERT_EQUAL_MESSAGE("formula string should be equal", aFormula, aString); double fValue = m_pDoc->GetValue(aPos); ASSERT_DOUBLES_EQUAL_MESSAGE("value should be 4 times Sheet1.A1", 404.0, fValue); @@ -3787,10 +3783,9 @@ void Test::testTdf98642() CPPUNIT_ASSERT_EQUAL(OUString("test"), m_pDoc->GetString(1, 0, 0)); CPPUNIT_ASSERT_EQUAL(OUString("test"), m_pDoc->GetString(1, 1, 0)); - OUString aFormula; - m_pDoc->GetFormula(1,0,0, aFormula); + OUString aFormula = m_pDoc->GetFormula(1,0,0); CPPUNIT_ASSERT_EQUAL(OUString("=name1"), aFormula); - m_pDoc->GetFormula(1,1,0, aFormula); + aFormula = m_pDoc->GetFormula(1,1,0); // Without the fix in place, this test would have failed with // - Expected: =name2 @@ -3912,54 +3907,52 @@ void Test::testUpdateReference() m_pDoc->SetString(2,1,2, "=Sheet4.B2+A1"); double aValue; - m_pDoc->GetValue(2,0,2, aValue); + aValue = m_pDoc->GetValue(2,0,2); ASSERT_DOUBLES_EQUAL_MESSAGE("formula does not return correct result", aValue, 3); - m_pDoc->GetValue(2,1,2, aValue); + aValue = m_pDoc->GetValue(2,1,2); ASSERT_DOUBLES_EQUAL_MESSAGE("formula does not return correct result", aValue, 5); //test deleting both sheets: one is not directly before the sheet, the other one is m_pDoc->DeleteTab(0); - m_pDoc->GetValue(2,0,1, aValue); + aValue = m_pDoc->GetValue(2,0,1); ASSERT_DOUBLES_EQUAL_MESSAGE("after deleting first sheet formula does not return correct result", aValue, 3); - m_pDoc->GetValue(2,1,1, aValue); + aValue = m_pDoc->GetValue(2,1,1); ASSERT_DOUBLES_EQUAL_MESSAGE("after deleting first sheet formula does not return correct result", aValue, 5); m_pDoc->DeleteTab(0); - m_pDoc->GetValue(2,0,0, aValue); + aValue = m_pDoc->GetValue(2,0,0); ASSERT_DOUBLES_EQUAL_MESSAGE("after deleting second sheet formula does not return correct result", aValue, 3); - m_pDoc->GetValue(2,1,0, aValue); + aValue = m_pDoc->GetValue(2,1,0); ASSERT_DOUBLES_EQUAL_MESSAGE("after deleting second sheet formula does not return correct result", aValue, 5); //test adding two sheets m_pDoc->InsertTab(0, "Sheet2"); - m_pDoc->GetValue(2,0,1, aValue); + aValue = m_pDoc->GetValue(2,0,1); ASSERT_DOUBLES_EQUAL_MESSAGE("after inserting first sheet formula does not return correct result", aValue, 3); - m_pDoc->GetValue(2,1,1, aValue); + aValue = m_pDoc->GetValue(2,1,1); ASSERT_DOUBLES_EQUAL_MESSAGE("after inserting first sheet formula does not return correct result", aValue, 5); m_pDoc->InsertTab(0, "Sheet1"); - m_pDoc->GetValue(2,0,2, aValue); + aValue = m_pDoc->GetValue(2,0,2); ASSERT_DOUBLES_EQUAL_MESSAGE("after inserting second sheet formula does not return correct result", aValue, 3); - m_pDoc->GetValue(2,1,2, aValue); + aValue = m_pDoc->GetValue(2,1,2); ASSERT_DOUBLES_EQUAL_MESSAGE("after inserting second sheet formula does not return correct result", aValue, 5); //test new DeleteTabs/InsertTabs methods m_pDoc->DeleteTabs(0, 2); - m_pDoc->GetValue(2, 0, 0, aValue); + aValue = m_pDoc->GetValue(2, 0, 0); ASSERT_DOUBLES_EQUAL_MESSAGE("after deleting sheets formula does not return correct result", aValue, 3); - m_pDoc->GetValue(2, 1, 0, aValue); + aValue = m_pDoc->GetValue(2, 1, 0); ASSERT_DOUBLES_EQUAL_MESSAGE("after deleting sheets formula does not return correct result", aValue, 5); std::vector<OUString> aSheets; aSheets.emplace_back("Sheet1"); aSheets.emplace_back("Sheet2"); m_pDoc->InsertTabs(0, aSheets, true); - m_pDoc->GetValue(2, 0, 2, aValue); - OUString aFormula; - m_pDoc->GetFormula(2,0,2, aFormula); + aValue = m_pDoc->GetValue(2, 0, 2); ASSERT_DOUBLES_EQUAL_MESSAGE("after inserting sheets formula does not return correct result", aValue, 3); - m_pDoc->GetValue(2, 1, 2, aValue); + aValue = m_pDoc->GetValue(2, 1, 2); ASSERT_DOUBLES_EQUAL_MESSAGE("after inserting sheets formula does not return correct result", aValue, 5); m_pDoc->DeleteTab(3); @@ -3973,13 +3966,13 @@ void Test::testUpdateReference() m_pDoc->InsertTab(1, "Sheet2"); m_pDoc->SetString(0,1,0, "s1"); m_pDoc->SetString(0,0,1, "=MATCH(\"s1\";Sheet1.A:A;0)"); - m_pDoc->GetValue(0,0,1, aValue); + aValue = m_pDoc->GetValue(0,0,1); ASSERT_DOUBLES_EQUAL_MESSAGE("unexpected MATCH result", 2, aValue); m_pDoc->InsertRow(0,0,MAXCOL,0,0,1); // insert 1 row before row 1 in Sheet1 - m_pDoc->GetValue(0,0,1, aValue); + aValue = m_pDoc->GetValue(0,0,1); ASSERT_DOUBLES_EQUAL_MESSAGE("unexpected MATCH result", 3, aValue); m_pDoc->DeleteRow(0,0,MAXCOL,0,0,1); // delete row 1 in Sheet1 - m_pDoc->GetValue(0,0,1, aValue); + aValue = m_pDoc->GetValue(0,0,1); ASSERT_DOUBLES_EQUAL_MESSAGE("unexpected MATCH result", 2, aValue); m_pDoc->DeleteTab(1); m_pDoc->DeleteTab(0); @@ -4274,8 +4267,7 @@ void Test::testAutoFill() for(SCROW nRow = 110; nRow >= 100; --nRow) { OUString aExpected = "=A" + OUString::number(nRow +1); - OUString aFormula; - m_pDoc->GetFormula(100, nRow, 0, aFormula); + OUString aFormula = m_pDoc->GetFormula(100, nRow, 0); CPPUNIT_ASSERT_EQUAL(aExpected, aFormula); } @@ -5824,9 +5816,8 @@ void Test::testSetFormula() for(size_t i = 0; i < SAL_N_ELEMENTS(aTest); ++i) { - OUString aBuffer; m_pDoc->SetFormula(ScAddress(aTest[i].nCol, aTest[i].nRow, 0), OUString::createFromAscii(aTest[i].aFormula1), aTest[i].eGram); - m_pDoc->GetFormula(aTest[i].nCol, aTest[i].nRow, 0, aBuffer); + OUString aBuffer = m_pDoc->GetFormula(aTest[i].nCol, aTest[i].nRow, 0); CPPUNIT_ASSERT_EQUAL_MESSAGE("Failed to set formula", OUString::createFromAscii(aTest[i].aFormula2), aBuffer); } diff --git a/sc/qa/unit/ucalc_copypaste.cxx b/sc/qa/unit/ucalc_copypaste.cxx index fea5efb9b7a7..4909bc3fbe6d 100644 --- a/sc/qa/unit/ucalc_copypaste.cxx +++ b/sc/qa/unit/ucalc_copypaste.cxx @@ -543,8 +543,7 @@ void TestCopyPaste::testCopyPaste() m_pDoc->CopyFromClip(aRange, aMark, InsertDeleteFlags::ALL, nullptr, &aClipDoc); //check values after copying - OUString aString; - m_pDoc->GetFormula(1, 1, 1, aString); + OUString aString = m_pDoc->GetFormula(1, 1, 1); CPPUNIT_ASSERT_EQUAL_MESSAGE("formula string was not copied correctly", aString, aFormulaString); // Only the global range points to Sheet1.A1, all copied sheet-local ranges @@ -621,7 +620,7 @@ void TestCopyPaste::testCopyPaste() ASSERT_DOUBLES_EQUAL_MESSAGE("formula should return 1 after redo", 1.0, fValue); aString = m_pDoc->GetString(2, 1, 1); CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell Sheet2.C2 should contain: test", OUString("test"), aString); - m_pDoc->GetFormula(1, 1, 1, aString); + aString = m_pDoc->GetFormula(1, 1, 1); CPPUNIT_ASSERT_EQUAL_MESSAGE("Formula should be correct again", aFormulaString, aString); CPPUNIT_ASSERT_MESSAGE("After Redo, there should be a note on Sheet2.A2", @@ -649,8 +648,7 @@ void TestCopyPaste::testCopyPaste() // The global2 range must not have changed. pGlobal2 = m_pDoc->GetRangeName()->findByUpperName("GLOBAL2"); CPPUNIT_ASSERT_MESSAGE("GLOBAL2 name not found", pGlobal2); - OUString aSymbol; - pGlobal2->GetSymbol(aSymbol); + OUString aSymbol = pGlobal2->GetSymbol(); CPPUNIT_ASSERT_EQUAL_MESSAGE("GLOBAL2 named range changed", aGlobal2Symbol, aSymbol); m_pDoc->DeleteTab(1); @@ -735,7 +733,7 @@ void TestCopyPaste::testCopyPasteTranspose() ASSERT_DOUBLES_EQUAL_MESSAGE("transposed copied cell should return 1", 1, fValue); fValue = m_pDoc->GetValue(ScAddress(3, 2, 1)); ASSERT_DOUBLES_EQUAL_MESSAGE("transposed copied formula should return 2", 2, fValue); - m_pDoc->GetFormula(3, 2, 1, aString); + aString = m_pDoc->GetFormula(3, 2, 1); CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed formula should point on Sheet2.D2", OUString("=D2+1"), aString); @@ -2931,9 +2929,8 @@ void TestCopyPaste::checkCopyPasteSpecial(bool bSkipEmpty, bool bCut) CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(8, 2, destSheet)); CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(8, 3, destSheet)); } - OUString aStr; double fValue = m_pDoc->GetValue(8, 4, destSheet); - m_pDoc->GetFormula(8, 4, destSheet, aStr); + OUString aStr = m_pDoc->GetFormula(8, 4, destSheet); if (!bCut) { CPPUNIT_ASSERT_EQUAL(OUString("=E$3+$B$5+80"), aStr); @@ -3563,8 +3560,7 @@ void TestCopyPaste::checkCopyPasteSpecialTranspose(bool bSkipEmpty, bool bCut) CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 6, destSheet)); } double fValue = m_pDoc->GetValue(6, 6, destSheet); // G7 - OUString aStr; - m_pDoc->GetFormula(6, 6, destSheet, aStr); // G7 + OUString aStr = m_pDoc->GetFormula(6, 6, destSheet); // G7 if (!bCut) { CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed G7", OUString("=C$3+$B$5+80"), aStr); @@ -9685,7 +9681,7 @@ void TestCopyPaste::testCutPasteGroupRefUndo() OUString aString = m_pDoc->GetString(0, i, 0); CPPUNIT_ASSERT_EQUAL_MESSAGE("Initial data failure", OUString::createFromAscii(aDataCheck[i][0]), aString); - m_pDoc->GetFormula(0, i, 0, aString); + aString = m_pDoc->GetFormula(0, i, 0); CPPUNIT_ASSERT_EQUAL_MESSAGE("Initial formula failure", OUString::createFromAscii(aDataCheck[i][1]), aString); } @@ -9735,7 +9731,7 @@ void TestCopyPaste::testCutPasteGroupRefUndo() OUString aString = m_pDoc->GetString(j, i, 0); CPPUNIT_ASSERT_EQUAL_MESSAGE("Paste data failure", OUString::createFromAscii(aPasteCheck[i][j]), aString); - m_pDoc->GetFormula(j, i, 0, aString); + aString = m_pDoc->GetFormula(j, i, 0); CPPUNIT_ASSERT_EQUAL_MESSAGE("Paste formula failure", OUString::createFromAscii(aPasteCheck[i][2 + j]), aString); } @@ -9757,7 +9753,7 @@ void TestCopyPaste::testCutPasteGroupRefUndo() OUString aString = m_pDoc->GetString(0, i, 0); CPPUNIT_ASSERT_EQUAL_MESSAGE("Undo Cut data failure", OUString::createFromAscii(aDataCheck[i][0]), aString); - m_pDoc->GetFormula(0, i, 0, aString); + aString = m_pDoc->GetFormula(0, i, 0); CPPUNIT_ASSERT_EQUAL_MESSAGE("Undo Cut formula failure", OUString::createFromAscii(aDataCheck[i][1]), aString); } @@ -9888,7 +9884,7 @@ void TestCopyPaste::testMoveBlock() //check cell content OUString aString = m_pDoc->GetString(3, 0, 0); CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell D1 should contain: test", OUString("test"), aString); - m_pDoc->GetFormula(2, 0, 0, aString); + aString = m_pDoc->GetFormula(2, 0, 0); CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell C1 should contain an updated formula", OUString("=B1+1"), aString); double fValue = m_pDoc->GetValue(aAddrB1); @@ -10204,21 +10200,20 @@ void TestCopyPaste::testCopyPasteFormulasExternalDoc() aMarkData2.SetMarkArea(aRange); rExtDoc.CopyFromClip(aRange, aMarkData2, InsertDeleteFlags::ALL, nullptr, &aClipDoc); - OUString aFormula; - rExtDoc.GetFormula(1, 1, 1, aFormula); + OUString aFormula = rExtDoc.GetFormula(1, 1, 1); //adjust absolute refs pointing to the copy area CPPUNIT_ASSERT_EQUAL(OUString("=COLUMN($B$2)"), aFormula); - rExtDoc.GetFormula(1, 2, 1, aFormula); + aFormula = rExtDoc.GetFormula(1, 2, 1); //adjust absolute refs and keep relative refs CPPUNIT_ASSERT_EQUAL(OUString("=$B$2+C3"), aFormula); - rExtDoc.GetFormula(1, 3, 1, aFormula); + aFormula = rExtDoc.GetFormula(1, 3, 1); // make absolute sheet refs external refs CPPUNIT_ASSERT_EQUAL(OUString("='file:///source.fake'#$Sheet2.B2"), aFormula); - rExtDoc.GetFormula(1, 4, 1, aFormula); + aFormula = rExtDoc.GetFormula(1, 4, 1); CPPUNIT_ASSERT_EQUAL(OUString("='file:///source.fake'#$Sheet2.$A$1"), aFormula); - rExtDoc.GetFormula(1, 5, 1, aFormula); + aFormula = rExtDoc.GetFormula(1, 5, 1); CPPUNIT_ASSERT_EQUAL(OUString("='file:///source.fake'#$Sheet2.B$1"), aFormula); - rExtDoc.GetFormula(1, 6, 1, aFormula); + aFormula = rExtDoc.GetFormula(1, 6, 1); CPPUNIT_ASSERT_EQUAL(OUString("=$ExtSheet2.$B$2"), aFormula); xExtDocSh->DoClose(); @@ -10256,8 +10251,7 @@ void TestCopyPaste::testCopyPasteReferencesExternalDoc() aMarkData2.SetMarkArea(aRange); rExtDoc.CopyFromClip(aRange, aMarkData2, InsertDeleteFlags::ALL, nullptr, &aClipDoc); - OUString aFormula; - rExtDoc.GetFormula(0, 3, 0, aFormula); + OUString aFormula = rExtDoc.GetFormula(0, 3, 0); //adjust absolute refs pointing to the copy area CPPUNIT_ASSERT_EQUAL(OUString("=SUM('file:///source.fake'#$Sheet1.A#REF!:A3)"), aFormula); diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx index 9ad8705c0c45..551834284f76 100644 --- a/sc/qa/unit/ucalc_formula.cxx +++ b/sc/qa/unit/ucalc_formula.cxx @@ -2803,8 +2803,7 @@ void TestFormula::testFormulaRefUpdateInsertColumns() // Check that the named reference points to the moved cell, now D2. ScRangeData* pName = m_pDoc->GetRangeName()->findByUpperName("ROWRELATIVERANGE"); CPPUNIT_ASSERT(pName); - OUString aSymbol; - pName->GetSymbol(aSymbol, aNamePos, formula::FormulaGrammar::GRAM_ENGLISH); + OUString aSymbol = pName->GetSymbol(aNamePos, formula::FormulaGrammar::GRAM_ENGLISH); CPPUNIT_ASSERT_EQUAL(OUString("$Formula.$D2"), aSymbol); // Check that the formula using the name, now in E2, still has the same result. @@ -2815,7 +2814,7 @@ void TestFormula::testFormulaRefUpdateInsertColumns() // Check that the named column reference points to the moved column, now D. pName = m_pDoc->GetRangeName()->findByUpperName("ENTIRECOLUMN"); CPPUNIT_ASSERT(pName); - pName->GetSymbol(aSymbol, aNamePos, formula::FormulaGrammar::GRAM_ENGLISH); + aSymbol = pName->GetSymbol(aNamePos, formula::FormulaGrammar::GRAM_ENGLISH); CPPUNIT_ASSERT_EQUAL(OUString("$D:$D"), aSymbol); // Check that the formula using the name, now in E3, still has the same result. @@ -2827,7 +2826,7 @@ void TestFormula::testFormulaRefUpdateInsertColumns() // and does not have a #REF! error due to inserted columns. pName = m_pDoc->GetRangeName()->findByUpperName("ENTIREROW"); CPPUNIT_ASSERT(pName); - pName->GetSymbol(aSymbol, aNamePos, formula::FormulaGrammar::GRAM_ENGLISH); + aSymbol = pName->GetSymbol(aNamePos, formula::FormulaGrammar::GRAM_ENGLISH); CPPUNIT_ASSERT_EQUAL(OUString("$2:$2"), aSymbol); // Check that the formula using the name, now in E4, still has the same result. @@ -3761,8 +3760,7 @@ void TestFormula::testFormulaRefUpdateName() // This should shift the absolute range B10:B12 that MyRange references. pName = pGlobalNames->findByUpperName("MYRANGE"); CPPUNIT_ASSERT_MESSAGE("Failed to find named expression 'MyRange' in the global scope.", pName); - OUString aExpr; - pName->GetSymbol(aExpr); + OUString aExpr = pName->GetSymbol(); CPPUNIT_ASSERT_EQUAL(OUString("$D$10:$D$12"), aExpr); // This move shouldn't affect the value of C8. @@ -3807,14 +3805,14 @@ void TestFormula::testFormulaRefUpdateName() *m_pDoc, "MyRange", "$B$1:$C$6", ScAddress(0,0,0), ScRangeData::Type::Name, formula::FormulaGrammar::GRAM_NATIVE); bInserted = pGlobalNames->insert(pName); CPPUNIT_ASSERT_MESSAGE("Failed to insert a new name.", bInserted); - pName->GetSymbol(aExpr); + aExpr = pName->GetSymbol(); CPPUNIT_ASSERT_EQUAL(OUString("$B$1:$C$6"), aExpr); // Insert range of cells to shift right. The range partially overlaps the named range. m_pDoc->InsertCol(ScRange(2,4,0,3,8,0)); // This should not alter the range. - pName->GetSymbol(aExpr); + aExpr = pName->GetSymbol(); CPPUNIT_ASSERT_EQUAL(OUString("$B$1:$C$6"), aExpr); m_pDoc->DeleteTab(0); @@ -3841,8 +3839,7 @@ void TestFormula::testFormulaRefUpdateNameMove() ScRangeData* pData = m_pDoc->GetRangeName()->findByUpperName("MYRANGE"); CPPUNIT_ASSERT(pData); - OUString aSymbol; - pData->GetSymbol(aSymbol, m_pDoc->GetGrammar()); + OUString aSymbol = pData->GetSymbol(m_pDoc->GetGrammar()); CPPUNIT_ASSERT_EQUAL(OUString("$Test.$B$2:$B$4"), aSymbol); // Move B2:B4 to D3. @@ -3851,7 +3848,7 @@ void TestFormula::testFormulaRefUpdateNameMove() CPPUNIT_ASSERT(bMoved); // The named range should have moved as well. - pData->GetSymbol(aSymbol, m_pDoc->GetGrammar()); + aSymbol = pData->GetSymbol(m_pDoc->GetGrammar()); CPPUNIT_ASSERT_EQUAL(OUString("$Test.$D$3:$D$5"), aSymbol); // The value of A10 should remain unchanged. @@ -3865,7 +3862,7 @@ void TestFormula::testFormulaRefUpdateNameMove() pData = m_pDoc->GetRangeName()->findByUpperName("MYRANGE"); CPPUNIT_ASSERT(pData); - pData->GetSymbol(aSymbol, m_pDoc->GetGrammar()); + aSymbol = pData->GetSymbol(m_pDoc->GetGrammar()); CPPUNIT_ASSERT_EQUAL(OUString("$Test.$B$2:$B$4"), aSymbol); CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc->GetValue(ScAddress(0,9,0))); @@ -3874,7 +3871,7 @@ void TestFormula::testFormulaRefUpdateNameMove() pData = m_pDoc->GetRangeName()->findByUpperName("MYRANGE"); CPPUNIT_ASSERT(pData); - pData->GetSymbol(aSymbol, m_pDoc->GetGrammar()); + aSymbol = pData->GetSymbol(m_pDoc->GetGrammar()); CPPUNIT_ASSERT_EQUAL(OUString("$Test.$D$3:$D$5"), aSymbol); CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc->GetValue(ScAddress(0,9,0))); @@ -3948,8 +3945,7 @@ void TestFormula::testFormulaRefUpdateNameExpandRef() rFunc.InsertCells(ScRange(0,3,0,m_pDoc->MaxCol(),3,0), &aMark, INS_INSROWS_BEFORE, false, true); ScRangeData* pName = m_pDoc->GetRangeName()->findByUpperName("MYRANGE"); CPPUNIT_ASSERT(pName); - OUString aSymbol; - pName->GetSymbol(aSymbol, m_pDoc->GetGrammar()); + OUString aSymbol = pName->GetSymbol(m_pDoc->GetGrammar()); CPPUNIT_ASSERT_EQUAL(OUString("$A$1:$A$4"), aSymbol); // Make sure the listening area has been expanded as well. Note the @@ -3962,7 +3958,7 @@ void TestFormula::testFormulaRefUpdateNameExpandRef() rFunc.InsertCells(ScRange(1,0,0,1,m_pDoc->MaxRow(),0), &aMark, INS_INSCOLS_BEFORE, false, true); pName = m_pDoc->GetRangeName()->findByUpperName("MYRANGE"); CPPUNIT_ASSERT(pName); - pName->GetSymbol(aSymbol, m_pDoc->GetGrammar()); + aSymbol = pName->GetSymbol(m_pDoc->GetGrammar()); CPPUNIT_ASSERT_EQUAL(OUString("$A$1:$A$4"), aSymbol); // Make sure the referenced area has not changed. @@ -3993,7 +3989,7 @@ void TestFormula::testFormulaRefUpdateNameExpandRef() pName = m_pDoc->GetRangeName()->findByUpperName("MYRANGE"); CPPUNIT_ASSERT(pName); - pName->GetSymbol(aSymbol, m_pDoc->GetGrammar()); + aSymbol = pName->GetSymbol(m_pDoc->GetGrammar()); CPPUNIT_ASSERT_EQUAL(OUString("$B$4:$B$9"), aSymbol); // Clear the document and start over. @@ -4064,8 +4060,7 @@ void TestFormula::testFormulaRefUpdateNameExpandRef2() rFunc.InsertCells(ScRange(1,0,0,1,m_pDoc->MaxRow(),0), &aMark, INS_INSCOLS_BEFORE, false, true); ScRangeData* pName = m_pDoc->GetRangeName()->findByUpperName("MYRANGE"); CPPUNIT_ASSERT(pName); - OUString aSymbol; - pName->GetSymbol(aSymbol, m_pDoc->GetGrammar()); + OUString aSymbol = pName->GetSymbol(m_pDoc->GetGrammar()); CPPUNIT_ASSERT_EQUAL(OUString("$A$1:$C$3"), aSymbol); m_pDoc->DeleteTab(0); @@ -4399,9 +4394,9 @@ void TestFormula::testFormulaRefUpdateSheetLocalMove() CPPUNIT_ASSERT_EQUAL_MESSAGE("Move x: Sheet1.B3", 1.0, m_pDoc->GetValue(ScAddress(1,2,nSheet1))); CPPUNIT_ASSERT_EQUAL_MESSAGE("Move x: Sheet2.B3", 2.0, m_pDoc->GetValue(ScAddress(1,2,nSheet2))); // Formulas not changed. - m_pDoc->GetFormula( 1,2,nSheet1, aFormula); + aFormula = m_pDoc->GetFormula( 1,2,nSheet1); CPPUNIT_ASSERT_EQUAL_MESSAGE("Move x: Sheet1.B3", OUString("=MyCell"), aFormula); - m_pDoc->GetFormula( 1,2,nSheet2, aFormula); + aFormula = m_pDoc->GetFormula( 1,2,nSheet2); CPPUNIT_ASSERT_EQUAL_MESSAGE("Move x: Sheet2.B3", OUString("=MyCell"), aFormula); // Move Sheet2.B2 ("2.0") to Sheet1.C2 @@ -4411,9 +4406,9 @@ void TestFormula::testFormulaRefUpdateSheetLocalMove() CPPUNIT_ASSERT_EQUAL_MESSAGE("Move 2.0: Sheet1.B3", 1.0, m_pDoc->GetValue(ScAddress(1,2,nSheet1))); CPPUNIT_ASSERT_EQUAL_MESSAGE("Move 2.0: Sheet2.B3", 2.0, m_pDoc->GetValue(ScAddress(1,2,nSheet2))); // Formulas not changed. - m_pDoc->GetFormula( 1,2,nSheet1, aFormula); + aFormula = m_pDoc->GetFormula( 1,2,nSheet1); CPPUNIT_ASSERT_EQUAL_MESSAGE("Move 2.0: Sheet1.B3", OUString("=MyCell"), aFormula); - m_pDoc->GetFormula( 1,2,nSheet2, aFormula); + aFormula = m_pDoc->GetFormula( 1,2,nSheet2); CPPUNIT_ASSERT_EQUAL_MESSAGE("Move 2.0: Sheet2.B3", OUString("=MyCell"), aFormula); ScRangeData* pName; @@ -4422,7 +4417,7 @@ void TestFormula::testFormulaRefUpdateSheetLocalMove() // Sheet1.C2 pName = m_pDoc->GetRangeName(nSheet2)->findByUpperName("MYCELL"); CPPUNIT_ASSERT(pName); - pName->GetSymbol( aFormula, ScAddress(), formula::FormulaGrammar::GRAM_ENGLISH); + aFormula = pName->GetSymbol( ScAddress(), formula::FormulaGrammar::GRAM_ENGLISH); CPPUNIT_ASSERT_EQUAL_MESSAGE("Move 2.0: Sheet2 sheet-local name", OUString("$Sheet1.$C$2"), aFormula); // Move Sheet2.B3 ("=MyCell") to Sheet1.C3 @@ -4433,23 +4428,23 @@ void TestFormula::testFormulaRefUpdateSheetLocalMove() CPPUNIT_ASSERT_EQUAL_MESSAGE("Move =MyCell: Sheet2.B3", 0.0, m_pDoc->GetValue(ScAddress(1,2,nSheet2))); CPPUNIT_ASSERT_EQUAL_MESSAGE("Move =MyCell: Sheet1.C3", 2.0, m_pDoc->GetValue(ScAddress(2,2,nSheet1))); // One formula identical, one adjusted. - m_pDoc->GetFormula( 1,2,nSheet1, aFormula); + aFormula = m_pDoc->GetFormula( 1,2,nSheet1); CPPUNIT_ASSERT_EQUAL_MESSAGE("Move =MyCell: Sheet1.B3", OUString("=MyCell"), aFormula); - m_pDoc->GetFormula( 2,2,nSheet1, aFormula); + aFormula = m_pDoc->GetFormula( 2,2,nSheet1); CPPUNIT_ASSERT_EQUAL_MESSAGE("Move =MyCell: Sheet1.C3", OUString("=Sheet2.MyCell"), aFormula); // Check that the sheet-local named reference in Sheet1 still points to the // original cell Sheet1.B2 pName = m_pDoc->GetRangeName(nSheet1)->findByUpperName("MYCELL"); CPPUNIT_ASSERT(pName); - pName->GetSymbol( aFormula, ScAddress(), formula::FormulaGrammar::GRAM_ENGLISH); + aFormula = pName->GetSymbol( ScAddress(), formula::FormulaGrammar::GRAM_ENGLISH); CPPUNIT_ASSERT_EQUAL_MESSAGE("Move =MyCell: Sheet1 sheet-local name", OUString("$Sheet1.$B$2"), aFormula); // Check that the sheet-local named reference in Sheet2 still points to the // moved cell, now Sheet1.C2 pName = m_pDoc->GetRangeName(nSheet2)->findByUpperName("MYCELL"); CPPUNIT_ASSERT(pName); - pName->GetSymbol( aFormula, ScAddress(), formula::FormulaGrammar::GRAM_ENGLISH); + aFormula = pName->GetSymbol( ScAddress(), formula::FormulaGrammar::GRAM_ENGLISH); CPPUNIT_ASSERT_EQUAL_MESSAGE("Move =MyCell: Sheet2 sheet-local name", OUString("$Sheet1.$C$2"), aFormula); // Insert sheet before the others. @@ -4460,17 +4455,17 @@ void TestFormula::testFormulaRefUpdateSheetLocalMove() // Nothing changed. CPPUNIT_ASSERT_EQUAL_MESSAGE("Insert Sheet0: Sheet1.B3", 1.0, m_pDoc->GetValue(ScAddress(1,2,nSheet1))); CPPUNIT_ASSERT_EQUAL_MESSAGE("Insert Sheet0: Sheet1.C3", 2.0, m_pDoc->GetValue(ScAddress(2,2,nSheet1))); - m_pDoc->GetFormula( 1,2,nSheet1, aFormula); + aFormula = m_pDoc->GetFormula( 1,2,nSheet1); CPPUNIT_ASSERT_EQUAL_MESSAGE("Insert Sheet0: Sheet1.B3", OUString("=MyCell"), aFormula); - m_pDoc->GetFormula( 2,2,nSheet1, aFormula); + aFormula = m_pDoc->GetFormula( 2,2,nSheet1); CPPUNIT_ASSERT_EQUAL_MESSAGE("Insert Sheet0: Sheet1.C3", OUString("=Sheet2.MyCell"), aFormula); pName = m_pDoc->GetRangeName(nSheet1)->findByUpperName("MYCELL"); CPPUNIT_ASSERT(pName); - pName->GetSymbol( aFormula, ScAddress(), formula::FormulaGrammar::GRAM_ENGLISH); + aFormula = pName->GetSymbol( ScAddress(), formula::FormulaGrammar::GRAM_ENGLISH); CPPUNIT_ASSERT_EQUAL_MESSAGE("Insert Sheet0: Sheet1 sheet-local name", OUString("$Sheet1.$B$2"), aFormula); pName = m_pDoc->GetRangeName(nSheet2)->findByUpperName("MYCELL"); CPPUNIT_ASSERT(pName); - pName->GetSymbol( aFormula, ScAddress(), formula::FormulaGrammar::GRAM_ENGLISH); + aFormula = pName->GetSymbol( ScAddress(), formula::FormulaGrammar::GRAM_ENGLISH); CPPUNIT_ASSERT_EQUAL_MESSAGE("Insert Sheet0: Sheet2 sheet-local name", OUString("$Sheet1.$C$2"), aFormula); // Delete sheet before the others. @@ -4481,17 +4476,17 @@ void TestFormula::testFormulaRefUpdateSheetLocalMove() // Nothing changed. CPPUNIT_ASSERT_EQUAL_MESSAGE("Delete Sheet0: Sheet1.B3", 1.0, m_pDoc->GetValue(ScAddress(1,2,nSheet1))); CPPUNIT_ASSERT_EQUAL_MESSAGE("Delete Sheet0: Sheet1.C3", 2.0, m_pDoc->GetValue(ScAddress(2,2,nSheet1))); - m_pDoc->GetFormula( 1,2,nSheet1, aFormula); + aFormula = m_pDoc->GetFormula( 1,2,nSheet1); CPPUNIT_ASSERT_EQUAL_MESSAGE("Delete Sheet0: Sheet1.B3", OUString("=MyCell"), aFormula); - m_pDoc->GetFormula( 2,2,nSheet1, aFormula); + aFormula = m_pDoc->GetFormula( 2,2,nSheet1); CPPUNIT_ASSERT_EQUAL_MESSAGE("Delete Sheet0: Sheet1.C3", OUString("=Sheet2.MyCell"), aFormula); pName = m_pDoc->GetRangeName(nSheet1)->findByUpperName("MYCELL"); CPPUNIT_ASSERT(pName); - pName->GetSymbol( aFormula, ScAddress(), formula::FormulaGrammar::GRAM_ENGLISH); + aFormula = pName->GetSymbol( ScAddress(), formula::FormulaGrammar::GRAM_ENGLISH); CPPUNIT_ASSERT_EQUAL_MESSAGE("Delete Sheet0: Sheet1 sheet-local name", OUString("$Sheet1.$B$2"), aFormula); pName = m_pDoc->GetRangeName(nSheet2)->findByUpperName("MYCELL"); CPPUNIT_ASSERT(pName); - pName->GetSymbol( aFormula, ScAddress(), formula::FormulaGrammar::GRAM_ENGLISH); + aFormula = pName->GetSymbol( ScAddress(), formula::FormulaGrammar::GRAM_ENGLISH); CPPUNIT_ASSERT_EQUAL_MESSAGE("Delete Sheet0: Sheet2 sheet-local name", OUString("$Sheet1.$C$2"), aFormula); // Delete last sheet with sheet-local name. @@ -4504,13 +4499,13 @@ void TestFormula::testFormulaRefUpdateSheetLocalMove() CPPUNIT_ASSERT_EQUAL_MESSAGE("Delete Sheet2: Sheet1.B3", 1.0, m_pDoc->GetValue(ScAddress(1,2,nSheet1))); CPPUNIT_ASSERT_EQUAL_MESSAGE("Delete Sheet2: Sheet1.C3", 0.0, m_pDoc->GetValue(ScAddress(2,2,nSheet1))); CPPUNIT_ASSERT_EQUAL_MESSAGE("Delete Sheet2: Sheet1.C3", OUString("#NAME?"), m_pDoc->GetString(ScAddress(2,2,nSheet1))); - m_pDoc->GetFormula( 1,2,nSheet1, aFormula); + aFormula = m_pDoc->GetFormula( 1,2,nSheet1); CPPUNIT_ASSERT_EQUAL_MESSAGE("Delete Sheet2: Sheet1.B3", OUString("=MyCell"), aFormula); - m_pDoc->GetFormula( 2,2,nSheet1, aFormula); + aFormula = m_pDoc->GetFormula( 2,2,nSheet1); CPPUNIT_ASSERT_EQUAL_MESSAGE("Delete Sheet2: Sheet1.C3", OUString("=#NAME?"), aFormula); pName = m_pDoc->GetRangeName(nSheet1)->findByUpperName("MYCELL"); CPPUNIT_ASSERT(pName); - pName->GetSymbol( aFormula, ScAddress(), formula::FormulaGrammar::GRAM_ENGLISH); + aFormula = pName->GetSymbol( ScAddress(), formula::FormulaGrammar::GRAM_ENGLISH); CPPUNIT_ASSERT_EQUAL_MESSAGE("Delete Sheet2: Sheet1 sheet-local name", OUString("$Sheet1.$B$2"), aFormula); CPPUNIT_ASSERT(!m_pDoc->GetRangeName(nSheet2)); nSheet2 = -1; @@ -5108,9 +5103,8 @@ void TestFormula::testFuncSUMXMY2() m_pDoc->SetValue(ScAddress(2,2,0), 1.0); // C3 CPPUNIT_ASSERT_EQUAL(9.0, m_pDoc->GetValue(aPos)); - double result = 0.0; m_pDoc->SetString(0, 4, 0, "=SUMXMY2({2;3;4};{4;3;2})"); - m_pDoc->GetValue(0, 4, 0, result); + double result = m_pDoc->GetValue(0, 4, 0); ASSERT_DOUBLES_EQUAL_MESSAGE("Calculation of SUMXMY2 with inline arrays failed", 8.0, result); m_pDoc->DeleteTab(0); @@ -5220,7 +5214,7 @@ void TestFormula::testFuncN() }; for (size_t i = 0; i < SAL_N_ELEMENTS(checks1); ++i) { - m_pDoc->GetValue(1, i, 0, result); + result = m_pDoc->GetValue(1, i, 0); bool bGood = result == checks1[i]; if (!bGood) { @@ -5233,7 +5227,7 @@ void TestFormula::testFuncN() }; for (size_t i = 0; i < SAL_N_ELEMENTS(checks2); ++i) { - m_pDoc->GetValue(1, i+2, 0, result); + result = m_pDoc->GetValue(1, i+2, 0); bool bGood = result == checks2[i]; if (!bGood) { @@ -5302,9 +5296,8 @@ void TestFormula::testFuncCOUNTIF() for (SCROW i = 0; i < nRows; ++i) { - double result; SCROW nRow = 20 + i; - m_pDoc->GetValue(0, nRow, 0, result); + double result = m_pDoc->GetValue(0, nRow, 0); bool bGood = result == aChecks[i].fResult; if (!bGood) { @@ -5345,10 +5338,9 @@ void TestFormula::testFuncCOUNTIF() aMark.SelectOneTable(0); m_pDoc->InsertMatrixFormula(0,0, 0,1, aMark, "=COUNTIF(B1:B5;C1:C2)"); // As we will be testing for 0.0 values, check that formulas are actually present. - OUString aFormula; - m_pDoc->GetFormula(0,0,0, aFormula); + OUString aFormula = m_pDoc->GetFormula(0,0,0); CPPUNIT_ASSERT_EQUAL(OUString("{=COUNTIF(B1:B5;C1:C2)}"), aFormula); - m_pDoc->GetFormula(0,1,0, aFormula); + aFormula = m_pDoc->GetFormula(0,1,0); CPPUNIT_ASSERT_EQUAL(OUString("{=COUNTIF(B1:B5;C1:C2)}"), aFormula); // The 0.0 results expected. CPPUNIT_ASSERT_EQUAL(0.0, m_pDoc->GetValue(ScAddress(0,0,0))); @@ -5556,8 +5548,7 @@ void TestFormula::testFuncSHEET() m_pDoc->SetString(0, 0, 0, "=SHEETS()"); m_pDoc->CalcFormulaTree(false, false); - double original; - m_pDoc->GetValue(0, 0, 0, original); + double original = m_pDoc->GetValue(0, 0, 0); CPPUNIT_ASSERT_EQUAL_MESSAGE("result of SHEETS() should equal the number of sheets, but doesn't.", static_cast<SCTAB>(original), m_pDoc->GetTableCount()); @@ -5565,15 +5556,14 @@ void TestFormula::testFuncSHEET() CPPUNIT_ASSERT_MESSAGE ("failed to insert sheet", m_pDoc->InsertTab (SC_TAB_APPEND, "test2")); - double modified; - m_pDoc->GetValue(0, 0, 0, modified); + double modified = m_pDoc->GetValue(0, 0, 0); ASSERT_DOUBLES_EQUAL_MESSAGE("result of SHEETS() did not get updated after sheet insertion.", 1.0, modified - original); SCTAB nTabCount = m_pDoc->GetTableCount(); m_pDoc->DeleteTab(--nTabCount); - m_pDoc->GetValue(0, 0, 0, modified); + modified = m_pDoc->GetValue(0, 0, 0); ASSERT_DOUBLES_EQUAL_MESSAGE("result of SHEETS() did not get updated after sheet removal.", 0.0, modified - original); @@ -5588,22 +5578,19 @@ void TestFormula::testFuncNOW() double val = 1; m_pDoc->SetValue(0, 0, 0, val); m_pDoc->SetString(0, 1, 0, "=IF(A1>0;NOW();0"); - double now1; - m_pDoc->GetValue(0, 1, 0, now1); + double now1 = m_pDoc->GetValue(0, 1, 0); CPPUNIT_ASSERT_MESSAGE("Value of NOW() should be positive.", now1 > 0.0); val = 0; m_pDoc->SetValue(0, 0, 0, val); m_pDoc->CalcFormulaTree(false, false); - double zero; - m_pDoc->GetValue(0, 1, 0, zero); + double zero = m_pDoc->GetValue(0, 1, 0); ASSERT_DOUBLES_EQUAL_MESSAGE("Result should equal the 3rd parameter of IF, which is zero.", 0.0, zero); val = 1; m_pDoc->SetValue(0, 0, 0, val); m_pDoc->CalcFormulaTree(false, false); - double now2; - m_pDoc->GetValue(0, 1, 0, now2); + double now2 = m_pDoc->GetValue(0, 1, 0); CPPUNIT_ASSERT_MESSAGE("Result should be the value of NOW() again.", (now2 - now1) >= 0.0); m_pDoc->DeleteTab(0); @@ -6461,18 +6448,17 @@ void TestFormula::testFormulaDepTracking() // B2 listens on D2. m_pDoc->SetString(1, 1, 0, "=D2"); - double val = -999.0; // dummy initial value - m_pDoc->GetValue(1, 1, 0, val); + double val = m_pDoc->GetValue(1, 1, 0); ASSERT_DOUBLES_EQUAL_MESSAGE("Referencing an empty cell should yield zero.", 0.0, val); // Changing the value of D2 should trigger recalculation of B2. m_pDoc->SetValue(3, 1, 0, 1.1); - m_pDoc->GetValue(1, 1, 0, val); + val = m_pDoc->GetValue(1, 1, 0); ASSERT_DOUBLES_EQUAL_MESSAGE("Failed to recalculate on value change.", 1.1, val); // And again. m_pDoc->SetValue(3, 1, 0, 2.2); - m_pDoc->GetValue(1, 1, 0, val); + val = m_pDoc->GetValue(1, 1, 0); ASSERT_DOUBLES_EQUAL_MESSAGE("Failed to recalculate on value change.", 2.2, val); clearRange(m_pDoc, ScRange(0, 0, 0, 10, 10, 0)); @@ -6481,12 +6467,12 @@ void TestFormula::testFormulaDepTracking() // B2 listens on D2:E6. m_pDoc->SetString(1, 1, 0, "=SUM(D2:E6)"); - m_pDoc->GetValue(1, 1, 0, val); + val = m_pDoc->GetValue(1, 1, 0); ASSERT_DOUBLES_EQUAL_MESSAGE("Summing an empty range should yield zero.", 0.0, val); // Set value to E3. This should trigger recalc on B2. m_pDoc->SetValue(4, 2, 0, 2.4); - m_pDoc->GetValue(1, 1, 0, val); + val = m_pDoc->GetValue(1, 1, 0); ASSERT_DOUBLES_EQUAL_MESSAGE("Failed to recalculate on single value change.", 2.4, val); // Set value to D5 to trigger recalc again. Note that this causes an @@ -6494,32 +6480,32 @@ void TestFormula::testFormulaDepTracking() // rounding error. We need to use approxEqual to assess its value. m_pDoc->SetValue(3, 4, 0, 1.2); - m_pDoc->GetValue(1, 1, 0, val); + val = m_pDoc->GetValue(1, 1, 0); CPPUNIT_ASSERT_MESSAGE("Failed to recalculate on single value change.", rtl::math::approxEqual(val, 3.6)); // Change the value of D2 (boundary case). m_pDoc->SetValue(3, 1, 0, 1.0); - m_pDoc->GetValue(1, 1, 0, val); + val = m_pDoc->GetValue(1, 1, 0); CPPUNIT_ASSERT_MESSAGE("Failed to recalculate on single value change.", rtl::math::approxEqual(val, 4.6)); // Change the value of E6 (another boundary case). m_pDoc->SetValue(4, 5, 0, 2.0); - m_pDoc->GetValue(1, 1, 0, val); + val = m_pDoc->GetValue(1, 1, 0); CPPUNIT_ASSERT_MESSAGE("Failed to recalculate on single value change.", rtl::math::approxEqual(val, 6.6)); // Change the value of D6 (another boundary case). m_pDoc->SetValue(3, 5, 0, 3.0); - m_pDoc->GetValue(1, 1, 0, val); + val = m_pDoc->GetValue(1, 1, 0); CPPUNIT_ASSERT_MESSAGE("Failed to recalculate on single value change.", rtl::math::approxEqual(val, 9.6)); // Change the value of E2 (another boundary case). m_pDoc->SetValue(4, 1, 0, 0.4); - m_pDoc->GetValue(1, 1, 0, val); + val = m_pDoc->GetValue(1, 1, 0); CPPUNIT_ASSERT_MESSAGE("Failed to recalculate on single value change.", rtl::math::approxEqual(val, 10.0)); // Change the existing non-empty value cell (E2). m_pDoc->SetValue(4, 1, 0, 2.4); - m_pDoc->GetValue(1, 1, 0, val); + val = m_pDoc->GetValue(1, 1, 0); CPPUNIT_ASSERT_MESSAGE("Failed to recalculate on single value change.", rtl::math::approxEqual(val, 12.0)); clearRange(m_pDoc, ScRange(0, 0, 0, 10, 10, 0)); @@ -6913,7 +6899,7 @@ void TestFormula::testExternalRef() double pChecks[] = { 10, 11, 12, 13, 0 }; for (size_t i = 0; i < SAL_N_ELEMENTS(pChecks); ++i) { - m_pDoc->GetValue(1, static_cast<SCROW>(i+1), 0, val); + val = m_pDoc->GetValue(1, static_cast<SCROW>(i+1), 0); ASSERT_DOUBLES_EQUAL_MESSAGE("Unexpected cell value.", pChecks[i], val); } } @@ -7152,7 +7138,7 @@ void TestFormula::testExternalRefFunctions() for (size_t i = 0; i < SAL_N_ELEMENTS(aChecks); ++i) { m_pDoc->SetString(0, 0, 0, OUString::createFromAscii(aChecks[i].pFormula)); - m_pDoc->GetValue(0, 0, 0, val); + val = m_pDoc->GetValue(0, 0, 0); CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("unexpected result involving external ranges.", aChecks[i].fResult, val, 1e-15); } diff --git a/sc/qa/unit/ucalc_sharedformula.cxx b/sc/qa/unit/ucalc_sharedformula.cxx index 3e96ed80ce57..944c611c5742 100644 --- a/sc/qa/unit/ucalc_sharedformula.cxx +++ b/sc/qa/unit/ucalc_sharedformula.cxx @@ -2744,8 +2744,7 @@ void TestSharedFormula::testSharedFormulaCutCopyMoveWithRef() const std::u16string_view sForm[] = { u"=SUM(A1:B1)", u"=SUM(A2:B2)", u"=SUM(A1:B1)", u"=SUM(A4:B4)" }; for (SCROW i=0; i < 4; ++i) { - OUString aFormula; - m_pDoc->GetFormula( 2,i,0, aFormula); + OUString aFormula = m_pDoc->GetFormula( 2,i,0 ); CPPUNIT_ASSERT_EQUAL( OUString(sForm[i]), aFormula); } diff --git a/sc/qa/unit/uicalc/uicalc.cxx b/sc/qa/unit/uicalc/uicalc.cxx index f2541660d42b..fbcfb2f59511 100644 --- a/sc/qa/unit/uicalc/uicalc.cxx +++ b/sc/qa/unit/uicalc/uicalc.cxx @@ -274,20 +274,19 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf100582) pDoc = pModelObj->GetDocument(); CPPUNIT_ASSERT(pDoc); - OUString aFormula; - pDoc->GetFormula(3, 10, 0, aFormula); + OUString aFormula = pDoc->GetFormula(3, 10, 0); // Without the fix in place, this test would have failed with // - Expected: {=SUM(($B$3:$B$7=$B11)*(D$3:D$7))} //- Actual : CPPUNIT_ASSERT_EQUAL(OUString("{=SUM(($B$3:$B$7=$B11)*(D$3:D$7))}"), aFormula); - pDoc->GetFormula(4, 10, 0, aFormula); + aFormula = pDoc->GetFormula(4, 10, 0); CPPUNIT_ASSERT_EQUAL(OUString("{=SUM(($B$3:$B$7=$B11)*(E$3:E$7))}"), aFormula); - pDoc->GetFormula(5, 10, 0, aFormula); + aFormula = pDoc->GetFormula(5, 10, 0); CPPUNIT_ASSERT_EQUAL(OUString("{=SUM(($B$3:$B$7=$B11)*(F$3:F$7))}"), aFormula); - pDoc->GetFormula(6, 10, 0, aFormula); + aFormula = pDoc->GetFormula(6, 10, 0); CPPUNIT_ASSERT_EQUAL(OUString("{=SUM(($B$3:$B$7=$B11)*(G$3:G$7))}"), aFormula); - pDoc->GetFormula(7, 10, 0, aFormula); + aFormula = pDoc->GetFormula(7, 10, 0); CPPUNIT_ASSERT_EQUAL(OUString("{=SUM(($B$3:$B$7=$B11)*(H$3:H$7))}"), aFormula); // Restore previous status @@ -644,7 +643,7 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testPasteTransposed) CPPUNIT_ASSERT_EQUAL(OUString("1"), pDoc->GetString(0, 0, 0)); // A1 CPPUNIT_ASSERT_EQUAL(1.0, pDoc->GetValue(0, 0, 0)); // A1 CPPUNIT_ASSERT_EQUAL(OUString("a"), pDoc->GetString(1, 0, 0)); // B1 - pDoc->GetFormula(2, 0, 0, aFormula); // C1 + aFormula = pDoc->GetFormula(2, 0, 0); // C1 CPPUNIT_ASSERT_EQUAL(OUString("=A1"), aFormula); // C1 CPPUNIT_ASSERT_EQUAL(OUString("1"), pDoc->GetString(2, 0, 0)); // C1 CPPUNIT_ASSERT_EQUAL(1.0, pDoc->GetValue(2, 0, 0)); // C1 @@ -696,12 +695,11 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testPasteAsLink) dispatchCommand(mxComponent, ".uno:PasteAsLink", {}); - OUString aFormula; - pDoc->GetFormula(2, 0, 0, aFormula); + OUString aFormula = pDoc->GetFormula(2, 0, 0); CPPUNIT_ASSERT_EQUAL(OUString("=$Sheet1.$A$1"), aFormula); // C1 - pDoc->GetFormula(2, 1, 0, aFormula); + aFormula = pDoc->GetFormula(2, 1, 0); CPPUNIT_ASSERT_EQUAL(OUString("=$Sheet1.$A$2"), aFormula); // C2 - pDoc->GetFormula(2, 2, 0, aFormula); + aFormula = pDoc->GetFormula(2, 2, 0); CPPUNIT_ASSERT_EQUAL(OUString("=$Sheet1.$A$3"), aFormula); // C3 CPPUNIT_ASSERT_EQUAL(1.0, pDoc->GetValue(2, 0, 0)); // C1 CPPUNIT_ASSERT_EQUAL(1.0, pDoc->GetValue(2, 2, 0)); // C3 @@ -841,14 +839,13 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf108654) dispatchCommand(mxComponent, ".uno:Paste", {}); - OUString aFormula; - pDoc->GetFormula(3, 126, 1, aFormula); + OUString aFormula = pDoc->GetFormula(3, 126, 1); CPPUNIT_ASSERT_EQUAL(OUString("=VLOOKUP(C127,#REF!,D$1,0)"), aFormula); dispatchCommand(mxComponent, ".uno:Undo", {}); Scheduler::ProcessEventsToIdle(); - pDoc->GetFormula(3, 126, 1, aFormula); + aFormula = pDoc->GetFormula(3, 126, 1); CPPUNIT_ASSERT_EQUAL(OUString(""), aFormula); CPPUNIT_ASSERT_EQUAL(static_cast<SCTAB>(2), pDoc->GetTableCount()); @@ -870,20 +867,19 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf133326) insertNewSheet(*pDoc); - OUString aFormula; - pDoc->GetFormula(0, 0, 1, aFormula); + OUString aFormula = pDoc->GetFormula(0, 0, 1); CPPUNIT_ASSERT_EQUAL(OUString(""), aFormula); dispatchCommand(mxComponent, ".uno:Paste", {}); - pDoc->GetFormula(0, 0, 1, aFormula); + aFormula = pDoc->GetFormula(0, 0, 1); CPPUNIT_ASSERT_EQUAL(OUString("=RAND()*1000000"), aFormula); CPPUNIT_ASSERT_EQUAL(static_cast<SCTAB>(2), pDoc->GetTableCount()); dispatchCommand(mxComponent, ".uno:Undo", {}); Scheduler::ProcessEventsToIdle(); - pDoc->GetFormula(0, 0, 1, aFormula); + aFormula = pDoc->GetFormula(0, 0, 1); CPPUNIT_ASSERT_EQUAL(OUString(""), aFormula); CPPUNIT_ASSERT_EQUAL(static_cast<SCTAB>(2), pDoc->GetTableCount()); @@ -896,14 +892,14 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf133326) Scheduler::ProcessEventsToIdle(); CPPUNIT_ASSERT_EQUAL(static_cast<SCTAB>(2), pDoc->GetTableCount()); - pDoc->GetFormula(0, 0, 1, aFormula); + aFormula = pDoc->GetFormula(0, 0, 1); CPPUNIT_ASSERT_EQUAL(OUString(""), aFormula); // Without the fix in place, it would have crashed here dispatchCommand(mxComponent, ".uno:Redo", {}); Scheduler::ProcessEventsToIdle(); - pDoc->GetFormula(0, 0, 1, aFormula); + aFormula = pDoc->GetFormula(0, 0, 1); CPPUNIT_ASSERT_EQUAL(OUString("=RAND()*1000000"), aFormula); CPPUNIT_ASSERT_EQUAL(static_cast<SCTAB>(2), pDoc->GetTableCount()); } @@ -1110,14 +1106,13 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf142010) goToCell("A1"); - OUString aFormula; - pDoc->GetFormula(5, 71, 0, aFormula); + OUString aFormula = pDoc->GetFormula(5, 71, 0); CPPUNIT_ASSERT_EQUAL(OUString("=MOD(F$71+$C72,9)"), aFormula); CPPUNIT_ASSERT_EQUAL(5.0, pDoc->GetValue(ScAddress(5, 71, 0))); dispatchCommand(mxComponent, ".uno:InsertColumnsBefore", {}); - pDoc->GetFormula(6, 71, 0, aFormula); + aFormula = pDoc->GetFormula(6, 71, 0); // Without the fix in place, this test would have failed with // - Expected: =MOD(G$71+$D72,9) @@ -1127,7 +1122,7 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf142010) dispatchCommand(mxComponent, ".uno:Undo", {}); - pDoc->GetFormula(5, 71, 0, aFormula); + aFormula = pDoc->GetFormula(5, 71, 0); CPPUNIT_ASSERT_EQUAL(OUString("=MOD(F$71+$C72,9)"), aFormula); CPPUNIT_ASSERT_EQUAL(5.0, pDoc->GetValue(ScAddress(5, 71, 0))); } @@ -1138,8 +1133,7 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf132431) ScDocument* pDoc = pModelObj->GetDocument(); CPPUNIT_ASSERT(pDoc); - OUString aFormula; ... etc. - the rest is truncated