sc/inc/cellvalue.hxx | 6 + sc/qa/unit/subsequent_filters_test.cxx | 4 - sc/source/core/data/cellvalue.cxx | 52 ++++++++--------- sc/source/core/data/column3.cxx | 4 - sc/source/core/data/column4.cxx | 2 sc/source/core/data/conditio.cxx | 2 sc/source/core/data/dociter.cxx | 6 - sc/source/core/data/document.cxx | 2 sc/source/core/data/documentimport.cxx | 4 - sc/source/core/data/queryevaluator.cxx | 4 - sc/source/core/data/queryiter.cxx | 2 sc/source/core/data/table3.cxx | 2 sc/source/core/data/table4.cxx | 36 +++++------ sc/source/core/data/validat.cxx | 2 sc/source/core/tool/cellform.cxx | 4 - sc/source/core/tool/chgtrack.cxx | 6 - sc/source/core/tool/interpr4.cxx | 10 +-- sc/source/filter/excel/xetable.cxx | 2 sc/source/filter/html/htmlexp.cxx | 2 sc/source/filter/xcl97/XclExpChangeTrack.cxx | 2 sc/source/filter/xml/XMLChangeTrackingExportHelper.cxx | 2 sc/source/filter/xml/xmlexprt.cxx | 6 - sc/source/ui/docshell/externalrefmgr.cxx | 4 - sc/source/ui/undo/undocell.cxx | 2 sc/source/ui/view/output2.cxx | 2 sc/source/ui/view/tabvwsh5.cxx | 2 26 files changed, 87 insertions(+), 85 deletions(-)
New commits: commit c2518134a55658218c924b43b5c87e4fbdaed1d4 Author: Noel Grandin <noelgran...@gmail.com> AuthorDate: Thu Jun 16 16:29:18 2022 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Thu Jun 16 20:39:23 2022 +0200 create getter for ScCellValue::mfValue so we can assert that has the correct tag type Change-Id: I0d626130cb014e19239e88a6988018c83d061f68 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136001 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/sc/inc/cellvalue.hxx b/sc/inc/cellvalue.hxx index 942cf006cab5..9513fcfc99d5 100644 --- a/sc/inc/cellvalue.hxx +++ b/sc/inc/cellvalue.hxx @@ -38,7 +38,7 @@ private: CellType meType; public: union { - double mfValue; + double mfValue1; svl::SharedString* mpString; EditTextObject* mpEditText; ScFormulaCell* mpFormula; @@ -62,6 +62,7 @@ public: void set( ScFormulaCell* pFormula ); CellType getType() const { return meType; } + double getDouble() const { assert(meType == CELLTYPE_VALUE); return mfValue1; } /** * Take cell value from specified position in specified document. @@ -111,7 +112,7 @@ private: CellType meType; public: union { - double mfValue; + double mfValue1; const svl::SharedString* mpString; const EditTextObject* mpEditText; ScFormulaCell* mpFormula; @@ -132,6 +133,7 @@ public: void clear(); CellType getType() const { return meType; } + double getDouble() const { assert(meType == CELLTYPE_VALUE); return mfValue1; } /** * Take cell value from specified position in specified document. diff --git a/sc/qa/unit/subsequent_filters_test.cxx b/sc/qa/unit/subsequent_filters_test.cxx index c1dd83f791a2..cb61bdd5a08a 100644 --- a/sc/qa/unit/subsequent_filters_test.cxx +++ b/sc/qa/unit/subsequent_filters_test.cxx @@ -552,7 +552,7 @@ void ScFiltersTest::testDeleteCircleInMergedCellODS() aMergedCell.assign(rDoc, aPosMergedCell); // The value of merged cell change to 6. - aMergedCell.mfValue = 6; + aMergedCell = ScRefCellValue(6); // Check that the data is valid.(True if the value = 6) const ScValidationData* pData = rDoc.GetValidationEntry(1); @@ -584,7 +584,7 @@ void ScFiltersTest::testBasicCellContentODS() aCell.assign(rDoc, ScAddress(1,4,0)); // B5 CPPUNIT_ASSERT_EQUAL_MESSAGE( "This cell must be numeric.", CELLTYPE_VALUE, aCell.getType()); - CPPUNIT_ASSERT_EQUAL(0.0, aCell.mfValue); + CPPUNIT_ASSERT_EQUAL(0.0, aCell.getDouble()); xDocSh->DoClose(); } diff --git a/sc/source/core/data/cellvalue.cxx b/sc/source/core/data/cellvalue.cxx index c565e0a488d6..cfc879802446 100644 --- a/sc/source/core/data/cellvalue.cxx +++ b/sc/source/core/data/cellvalue.cxx @@ -92,7 +92,7 @@ bool equalsWithoutFormatImpl( const T& left, const T& right ) case CELLTYPE_NONE: return true; case CELLTYPE_VALUE: - return left.mfValue == right.mfValue; + return left.getDouble() == right.getDouble(); case CELLTYPE_STRING: { OUString aStr1 = getString(left); @@ -118,7 +118,7 @@ void commitToColumn( const ScCellValue& rCell, ScColumn& rColumn, SCROW nRow ) rColumn.SetEditText(nRow, ScEditUtil::Clone(*rCell.mpEditText, rColumn.GetDoc())); break; case CELLTYPE_VALUE: - rColumn.SetValue(nRow, rCell.mfValue); + rColumn.SetValue(nRow, rCell.getDouble()); break; case CELLTYPE_FORMULA: { @@ -164,7 +164,7 @@ OUString getStringImpl( const CellT& rCell, const ScDocument* pDoc ) switch (rCell.getType()) { case CELLTYPE_VALUE: - return OUString::number(rCell.mfValue); + return OUString::number(rCell.getDouble()); case CELLTYPE_STRING: return rCell.mpString->getString(); case CELLTYPE_EDIT: @@ -185,7 +185,7 @@ OUString getRawStringImpl( const CellT& rCell, const ScDocument& rDoc ) switch (rCell.getType()) { case CELLTYPE_VALUE: - return OUString::number(rCell.mfValue); + return OUString::number(rCell.mfValue1); case CELLTYPE_STRING: return rCell.mpString->getString(); case CELLTYPE_EDIT: @@ -202,9 +202,9 @@ OUString getRawStringImpl( const CellT& rCell, const ScDocument& rDoc ) } -ScCellValue::ScCellValue() : meType(CELLTYPE_NONE), mfValue(0.0) {} +ScCellValue::ScCellValue() : meType(CELLTYPE_NONE), mfValue1(0.0) {} -ScCellValue::ScCellValue( const ScRefCellValue& rCell ) : meType(rCell.getType()), mfValue(rCell.mfValue) +ScCellValue::ScCellValue( const ScRefCellValue& rCell ) : meType(rCell.getType()), mfValue1(rCell.mfValue1) { switch (rCell.getType()) { @@ -222,13 +222,13 @@ ScCellValue::ScCellValue( const ScRefCellValue& rCell ) : meType(rCell.getType() } } -ScCellValue::ScCellValue( double fValue ) : meType(CELLTYPE_VALUE), mfValue(fValue) {} +ScCellValue::ScCellValue( double fValue ) : meType(CELLTYPE_VALUE), mfValue1(fValue) {} ScCellValue::ScCellValue( const svl::SharedString& rString ) : meType(CELLTYPE_STRING), mpString(new svl::SharedString(rString)) {} ScCellValue::ScCellValue( std::unique_ptr<EditTextObject> xEdit ) : meType(CELLTYPE_EDIT), mpEditText(xEdit.release()) {} -ScCellValue::ScCellValue( const ScCellValue& r ) : meType(r.meType), mfValue(r.mfValue) +ScCellValue::ScCellValue( const ScCellValue& r ) : meType(r.meType), mfValue1(r.mfValue1) { switch (r.meType) { @@ -248,7 +248,7 @@ ScCellValue::ScCellValue( const ScCellValue& r ) : meType(r.meType), mfValue(r.m ScCellValue::ScCellValue(ScCellValue&& r) noexcept : meType(r.meType) - , mfValue(r.mfValue) + , mfValue1(r.mfValue1) { switch (r.meType) { @@ -291,14 +291,14 @@ void ScCellValue::clear() noexcept // Reset to empty value. meType = CELLTYPE_NONE; - mfValue = 0.0; + mfValue1 = 0.0; } void ScCellValue::set( double fValue ) { clear(); meType = CELLTYPE_VALUE; - mfValue = fValue; + mfValue1 = fValue; } void ScCellValue::set( const svl::SharedString& rStr ) @@ -346,7 +346,7 @@ void ScCellValue::assign( const ScDocument& rDoc, const ScAddress& rPos ) mpEditText = aRefVal.mpEditText->Clone().release(); break; case CELLTYPE_VALUE: - mfValue = aRefVal.mfValue; + mfValue1 = aRefVal.mfValue1; break; case CELLTYPE_FORMULA: mpFormula = aRefVal.mpFormula->Clone(); @@ -390,7 +390,7 @@ void ScCellValue::assign(const ScCellValue& rOther, ScDocument& rDestDoc, ScClon } break; case CELLTYPE_VALUE: - mfValue = rOther.mfValue; + mfValue1 = rOther.mfValue1; break; case CELLTYPE_FORMULA: // Switch to the destination document. @@ -416,7 +416,7 @@ void ScCellValue::commit( ScDocument& rDoc, const ScAddress& rPos ) const rDoc.SetEditText(rPos, mpEditText->Clone()); break; case CELLTYPE_VALUE: - rDoc.SetValue(rPos, mfValue); + rDoc.SetValue(rPos, mfValue1); break; case CELLTYPE_FORMULA: rDoc.SetFormulaCell(rPos, mpFormula->Clone()); @@ -449,7 +449,7 @@ void ScCellValue::release( ScDocument& rDoc, const ScAddress& rPos ) rDoc.SetEditText(rPos, std::unique_ptr<EditTextObject>(mpEditText)); break; case CELLTYPE_VALUE: - rDoc.SetValue(rPos, mfValue); + rDoc.SetValue(rPos, mfValue1); break; case CELLTYPE_FORMULA: // This formula cell instance is directly placed in the document without copying. @@ -460,7 +460,7 @@ void ScCellValue::release( ScDocument& rDoc, const ScAddress& rPos ) } meType = CELLTYPE_NONE; - mfValue = 0.0; + mfValue1 = 0.0; } void ScCellValue::release( ScColumn& rColumn, SCROW nRow, sc::StartListeningType eListenType ) @@ -479,7 +479,7 @@ void ScCellValue::release( ScColumn& rColumn, SCROW nRow, sc::StartListeningType rColumn.SetEditText(nRow, std::unique_ptr<EditTextObject>(mpEditText)); break; case CELLTYPE_VALUE: - rColumn.SetValue(nRow, mfValue); + rColumn.SetValue(nRow, mfValue1); break; case CELLTYPE_FORMULA: // This formula cell instance is directly placed in the document without copying. @@ -490,7 +490,7 @@ void ScCellValue::release( ScColumn& rColumn, SCROW nRow, sc::StartListeningType } meType = CELLTYPE_NONE; - mfValue = 0.0; + mfValue1 = 0.0; } OUString ScCellValue::getString( const ScDocument& rDoc ) const @@ -520,7 +520,7 @@ ScCellValue& ScCellValue::operator=(ScCellValue&& rCell) noexcept clear(); meType = rCell.meType; - mfValue = rCell.mfValue; + mfValue1 = rCell.mfValue1; switch (rCell.meType) { case CELLTYPE_STRING: @@ -555,11 +555,11 @@ void ScCellValue::swap( ScCellValue& r ) // double is 8 bytes, whereas a pointer may be 4 or 8 bytes depending on // the platform. Swap by double values. - std::swap(mfValue, r.mfValue); + std::swap(mfValue1, r.mfValue1); } -ScRefCellValue::ScRefCellValue() : meType(CELLTYPE_NONE), mfValue(0.0) {} -ScRefCellValue::ScRefCellValue( double fValue ) : meType(CELLTYPE_VALUE), mfValue(fValue) {} +ScRefCellValue::ScRefCellValue() : meType(CELLTYPE_NONE), mfValue1(0.0) {} +ScRefCellValue::ScRefCellValue( double fValue ) : meType(CELLTYPE_VALUE), mfValue1(fValue) {} ScRefCellValue::ScRefCellValue( const svl::SharedString* pString ) : meType(CELLTYPE_STRING), mpString(pString) {} ScRefCellValue::ScRefCellValue( const EditTextObject* pEditText ) : meType(CELLTYPE_EDIT), mpEditText(pEditText) {} ScRefCellValue::ScRefCellValue( ScFormulaCell* pFormula ) : meType(CELLTYPE_FORMULA), mpFormula(pFormula) {} @@ -578,7 +578,7 @@ void ScRefCellValue::clear() { // Reset to empty value. meType = CELLTYPE_NONE; - mfValue = 0.0; + mfValue1 = 0.0; } void ScRefCellValue::assign( ScDocument& rDoc, const ScAddress& rPos ) @@ -606,7 +606,7 @@ void ScRefCellValue::commit( ScDocument& rDoc, const ScAddress& rPos ) const rDoc.SetEditText(rPos, ScEditUtil::Clone(*mpEditText, rDoc)); break; case CELLTYPE_VALUE: - rDoc.SetValue(rPos, mfValue); + rDoc.SetValue(rPos, mfValue1); break; case CELLTYPE_FORMULA: rDoc.SetFormulaCell(rPos, new ScFormulaCell(*mpFormula, rDoc, rPos)); @@ -636,7 +636,7 @@ double ScRefCellValue::getValue() switch (meType) { case CELLTYPE_VALUE: - return mfValue; + return mfValue1; case CELLTYPE_FORMULA: return mpFormula->GetValue(); default: @@ -650,7 +650,7 @@ double ScRefCellValue::getRawValue() const switch (meType) { case CELLTYPE_VALUE: - return mfValue; + return mfValue1; case CELLTYPE_FORMULA: return mpFormula->GetRawValue(); default: diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx index 8511c5bed016..e8a14b75b498 100644 --- a/sc/source/core/data/column3.cxx +++ b/sc/source/core/data/column3.cxx @@ -2557,7 +2557,7 @@ class FilterEntriesHandler switch (rCell.getType()) { case CELLTYPE_VALUE: - fVal = rCell.mfValue; + fVal = rCell.getDouble(); break; case CELLTYPE_FORMULA: @@ -2882,7 +2882,7 @@ public: switch (r.maValue.getType()) { case CELLTYPE_VALUE: - rColumn.SetValue(aBlockPos, r.mnRow, r.maValue.mfValue, false); + rColumn.SetValue(aBlockPos, r.mnRow, r.maValue.getDouble(), false); break; case CELLTYPE_STRING: rColumn.SetRawString(aBlockPos, r.mnRow, *r.maValue.mpString, false); diff --git a/sc/source/core/data/column4.cxx b/sc/source/core/data/column4.cxx index bae865233180..7861ed5ce55e 100644 --- a/sc/source/core/data/column4.cxx +++ b/sc/source/core/data/column4.cxx @@ -277,7 +277,7 @@ void ScColumn::CopyOneCellFromClip( sc::CopyFromClipContext& rCxt, SCROW nRow1, { case CELLTYPE_VALUE: { - std::vector<double> aVals(nDestSize, rSrcCell.mfValue); + std::vector<double> aVals(nDestSize, rSrcCell.getDouble()); pBlockPos->miCellPos = maCells.set(pBlockPos->miCellPos, nRow1, aVals.begin(), aVals.end()); pBlockPos->miCellTextAttrPos = diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx index 61fb80669574..6c4213888017 100644 --- a/sc/source/core/data/conditio.cxx +++ b/sc/source/core/data/conditio.cxx @@ -731,7 +731,7 @@ static bool lcl_GetCellContent( ScRefCellValue& rCell, bool bIsStr1, double& rAr switch (rCell.getType()) { case CELLTYPE_VALUE: - rArg = rCell.mfValue; + rArg = rCell.getDouble(); break; case CELLTYPE_FORMULA: { diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx index c82838d34cfe..3efaa48d7b5a 100644 --- a/sc/source/core/data/dociter.cxx +++ b/sc/source/core/data/dociter.cxx @@ -405,7 +405,7 @@ bool ScDBQueryDataIterator::DataAccessInternal::getCurrent(Value& rValue) { case CELLTYPE_VALUE: { - rValue.mfValue = aCell.mfValue; + rValue.mfValue = aCell.getDouble(); rValue.mbIsNumber = true; if ( bCalcAsShown ) { @@ -981,7 +981,7 @@ ScCellValue ScCellIterator::getCellValue() const return ScCellValue(maCurCell.mpEditText->Clone()); break; case CELLTYPE_VALUE: - return ScCellValue(maCurCell.mfValue); + return ScCellValue(maCurCell.getDouble()); break; case CELLTYPE_FORMULA: return ScCellValue(maCurCell.mpFormula->Clone()); @@ -1310,7 +1310,7 @@ bool ScHorizontalValueIterator::GetNext( double& rValue, FormulaError& rErr ) { case CELLTYPE_VALUE: { - rValue = pCell->mfValue; + rValue = pCell->getDouble(); rErr = FormulaError::NONE; if ( bCalcAsShown ) { diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx index 15058251b83a..f3c34ab49493 100644 --- a/sc/source/core/data/document.cxx +++ b/sc/source/core/data/document.cxx @@ -3628,7 +3628,7 @@ FormulaError ScDocument::GetStringForFormula( const ScAddress& rPos, OUString& r break; case CELLTYPE_VALUE: { - double fVal = aCell.mfValue; + double fVal = aCell.getDouble(); sal_uInt32 nIndex = pFormatter->GetStandardFormat( SvNumFormatType::NUMBER, ScGlobal::eLnge); diff --git a/sc/source/core/data/documentimport.cxx b/sc/source/core/data/documentimport.cxx index cdb7cc2d91ff..867a16a6f1ec 100644 --- a/sc/source/core/data/documentimport.cxx +++ b/sc/source/core/data/documentimport.cxx @@ -232,7 +232,7 @@ void ScDocumentImport::setAutoInput(const ScAddress& rPos, const OUString& rStr, aCell.mpEditText = nullptr; break; case CELLTYPE_VALUE: - pBlockPos->miCellPos = rCells.set(pBlockPos->miCellPos, rPos.Row(), aCell.mfValue); + pBlockPos->miCellPos = rCells.set(pBlockPos->miCellPos, rPos.Row(), aCell.getDouble()); break; case CELLTYPE_FORMULA: if (!pStringParam) @@ -576,7 +576,7 @@ void ScDocumentImport::fillDownCells(const ScAddress& rPos, SCROW nFillSize) { case CELLTYPE_VALUE: { - std::vector<double> aCopied(nFillSize, aRefCell.mfValue); + std::vector<double> aCopied(nFillSize, aRefCell.getDouble()); pBlockPos->miCellPos = rCells.set( pBlockPos->miCellPos, rPos.Row()+1, aCopied.begin(), aCopied.end()); break; diff --git a/sc/source/core/data/queryevaluator.cxx b/sc/source/core/data/queryevaluator.cxx index 695921ab6d73..ef1ef6e1c0f3 100644 --- a/sc/source/core/data/queryevaluator.cxx +++ b/sc/source/core/data/queryevaluator.cxx @@ -205,7 +205,7 @@ std::pair<bool, bool> ScQueryEvaluator::compareByValue(const ScRefCellValue& rCe switch (rCell.getType()) { case CELLTYPE_VALUE: - nCellVal = rCell.mfValue; + nCellVal = rCell.getDouble(); break; case CELLTYPE_FORMULA: nCellVal = rCell.mpFormula->GetValue(); @@ -722,7 +722,7 @@ std::pair<bool, bool> ScQueryEvaluator::processEntry(SCROW nRow, SCCOL nCol, ScR // that has a value and is not an error (those are compared as strings). This // is basically simplified isQueryByValue(). if (aCell.getType() == CELLTYPE_VALUE) - value = aCell.mfValue; + value = aCell.getDouble(); else if (aCell.getType() == CELLTYPE_FORMULA && aCell.mpFormula->GetErrCode() != FormulaError::NONE && aCell.mpFormula->IsValue()) diff --git a/sc/source/core/data/queryiter.cxx b/sc/source/core/data/queryiter.cxx index ed1a9251544c..7d51fff4e601 100644 --- a/sc/source/core/data/queryiter.cxx +++ b/sc/source/core/data/queryiter.cxx @@ -435,7 +435,7 @@ bool ScQueryCellIteratorBase< accessType, queryType >::BinarySearch( SCCOL col, switch (aCell.getType()) { case CELLTYPE_VALUE : - fLastInRangeValue = aCell.mfValue; + fLastInRangeValue = aCell.getDouble(); break; case CELLTYPE_FORMULA : fLastInRangeValue = aCell.mpFormula->GetValue(); diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx index 6bcf75225f7c..19db5e6c08dc 100644 --- a/sc/source/core/data/table3.cxx +++ b/sc/source/core/data/table3.cxx @@ -732,7 +732,7 @@ void fillSortedColumnArray( break; case CELLTYPE_VALUE: assert(rCell.mpAttr); - rCellStore.push_back(rCell.maCell.mfValue); + rCellStore.push_back(rCell.maCell.getDouble()); break; case CELLTYPE_EDIT: assert(rCell.mpAttr); diff --git a/sc/source/core/data/table4.cxx b/sc/source/core/data/table4.cxx index e16e93ae19f9..80d656d4dd59 100644 --- a/sc/source/core/data/table4.cxx +++ b/sc/source/core/data/table4.cxx @@ -316,7 +316,7 @@ void ScTable::FillAnalyse( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, tools::Long nDDiff = 0, nMDiff = 0, nYDiff = 0; // to avoid warnings Date aNullDate = rDocument.GetFormatTable()->GetNullDate(); Date aCurrDate = aNullDate, aPrevDate = aNullDate; - aCurrDate.AddDays(aCurrCell.mfValue); + aCurrDate.AddDays(aCurrCell.getDouble()); for (SCSIZE i = 1; i < nValueCount && bVal; i++) { aPrevCell = aCurrCell; @@ -326,7 +326,7 @@ void ScTable::FillAnalyse( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, aCurrCell = GetCellValue(nColCurr, nRowCurr); if (aCurrCell.getType() == CELLTYPE_VALUE) { - aCurrDate = aNullDate + static_cast<sal_Int32>(aCurrCell.mfValue); + aCurrDate = aNullDate + static_cast<sal_Int32>(aCurrCell.getDouble()); if (eType != FILL_DAY) { nDDiff = aCurrDate.GetDay() - static_cast<tools::Long>(aPrevDate.GetDay()); @@ -386,7 +386,7 @@ void ScTable::FillAnalyse( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, } } else if (nCurrCellFormatType == SvNumFormatType::LOGICAL - && ((fVal = aCurrCell.mfValue) == 0.0 || fVal == 1.0)) + && ((fVal = aCurrCell.getDouble()) == 0.0 || fVal == 1.0)) { } else if (nValueCount >= 2) @@ -399,12 +399,12 @@ void ScTable::FillAnalyse( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, aCurrCell = GetCellValue(nColCurr, nRowCurr); if (aCurrCell.getType() == CELLTYPE_VALUE) { - double nDiff = approxDiff(aCurrCell.mfValue, aPrevCell.mfValue); + double nDiff = approxDiff(aCurrCell.getDouble(), aPrevCell.getDouble()); if (i == 1) rInc = nDiff; if (!::rtl::math::approxEqual(nDiff, rInc, 13)) bVal = false; - else if ((aCurrCell.mfValue == 0.0 || aCurrCell.mfValue == 1.0) + else if ((aCurrCell.getDouble() == 0.0 || aCurrCell.getDouble() == 1.0) && (rDocument.GetFormatTable()->GetType( GetNumberFormat(nColCurr, nRowCurr)) == SvNumFormatType::LOGICAL)) @@ -525,7 +525,7 @@ void ScTable::FillAnalyse( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, double nVal; Date aNullDate = rDocument.GetFormatTable()->GetNullDate(); Date aDate1 = aNullDate; - nVal = aFirstCell.mfValue; + nVal = aFirstCell.getDouble(); aDate1.AddDays(nVal); Date aDate2 = aNullDate; nVal = GetValue(nCol+nAddX, nRow+nAddY); @@ -561,7 +561,7 @@ void ScTable::FillAnalyse( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ScRefCellValue aCell = GetCellValue(nCol,nRow); if (aCell.getType() == CELLTYPE_VALUE) { - nVal = aCell.mfValue; + nVal = aCell.getDouble(); aDate2 = aNullDate + static_cast<sal_Int32>(nVal); if ( eType == FILL_DAY ) { @@ -612,7 +612,7 @@ void ScTable::FillAnalyse( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, rInc = 1.0; } } - else if (bBooleanCell && ((fVal = aFirstCell.mfValue) == 0.0 || fVal == 1.0)) + else if (bBooleanCell && ((fVal = aFirstCell.getDouble()) == 0.0 || fVal == 1.0)) { // Nothing, rInc stays 0.0, no specific fill mode. } @@ -620,7 +620,7 @@ void ScTable::FillAnalyse( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, { if (nCount > 1) { - double nVal1 = aFirstCell.mfValue; + double nVal1 = aFirstCell.getDouble(); double nVal2 = GetValue(nCol+nAddX, nRow+nAddY); rInc = approxDiff( nVal2, nVal1); nCol = sal::static_int_cast<SCCOL>( nCol + nAddX ); @@ -631,7 +631,7 @@ void ScTable::FillAnalyse( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ScRefCellValue aCell = GetCellValue(nCol,nRow); if (aCell.getType() == CELLTYPE_VALUE) { - nVal2 = aCell.mfValue; + nVal2 = aCell.getDouble(); double nDiff = approxDiff( nVal2, nVal1); if ( !::rtl::math::approxEqual( nDiff, rInc, 13 ) ) bVal = false; @@ -1434,7 +1434,7 @@ OUString ScTable::GetAutoFillPreview( const ScRange& rSource, SCCOL nEndX, SCROW { sal_uInt32 nNumFmt = GetNumberFormat( nSrcX, nSrcY ); // overflow is possible... - double nVal = aCell.mfValue; + double nVal = aCell.getDouble(); if ( !(nScFillModeMouseModifier & KEY_MOD1) ) { const SvNumFormatType nFormatType = rDocument.GetFormatTable()->GetType(nNumFmt); @@ -1492,7 +1492,7 @@ OUString ScTable::GetAutoFillPreview( const ScRange& rSource, SCCOL nEndX, SCROW } break; case CELLTYPE_VALUE: - nStart = aCell.mfValue; + nStart = aCell.getDouble(); break; case CELLTYPE_FORMULA: nStart = aCell.mpFormula->GetValue(); @@ -1942,12 +1942,12 @@ void ScTable::FillAutoSimple( case CELLTYPE_VALUE: { double fVal; - if (bBooleanCell && ((fVal = aSrcCell.mfValue) == 0.0 || fVal == 1.0)) - aCol[rCol].SetValue(rRow, aSrcCell.mfValue); + if (bBooleanCell && ((fVal = aSrcCell.getDouble()) == 0.0 || fVal == 1.0)) + aCol[rCol].SetValue(rRow, aSrcCell.getDouble()); else if(bPercentCell) - aCol[rCol].SetValue(rRow, aSrcCell.mfValue + nDelta * 0.01); // tdf#89998 increment by 1% at a time + aCol[rCol].SetValue(rRow, aSrcCell.getDouble() + nDelta * 0.01); // tdf#89998 increment by 1% at a time else - aCol[rCol].SetValue(rRow, aSrcCell.mfValue + nDelta); + aCol[rCol].SetValue(rRow, aSrcCell.getDouble() + nDelta); } break; case CELLTYPE_STRING: @@ -2234,7 +2234,7 @@ void ScTable::FillSeries( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, { double nStartVal; if (aSrcCell.getType() == CELLTYPE_VALUE) - nStartVal = aSrcCell.mfValue; + nStartVal = aSrcCell.getDouble(); else nStartVal = aSrcCell.mpFormula->GetValue(); if (eFillCmd == FILL_LINEAR) @@ -2362,7 +2362,7 @@ void ScTable::FillSeries( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, } else if (eCellType == CELLTYPE_VALUE || eCellType == CELLTYPE_FORMULA) { - const double nStartVal = (eCellType == CELLTYPE_VALUE ? aSrcCell.mfValue : + const double nStartVal = (eCellType == CELLTYPE_VALUE ? aSrcCell.getDouble() : aSrcCell.mpFormula->GetValue()); double nVal = nStartVal; tools::Long nIndex = 0; diff --git a/sc/source/core/data/validat.cxx b/sc/source/core/data/validat.cxx index cc3cff507bf8..abe48eecb3a9 100644 --- a/sc/source/core/data/validat.cxx +++ b/sc/source/core/data/validat.cxx @@ -576,7 +576,7 @@ bool ScValidationData::IsDataValid( ScRefCellValue& rCell, const ScAddress& rPos switch (rCell.getType()) { case CELLTYPE_VALUE: - nVal = rCell.mfValue; + nVal = rCell.getDouble(); break; case CELLTYPE_STRING: aString = rCell.mpString->getString(); diff --git a/sc/source/core/tool/cellform.cxx b/sc/source/core/tool/cellform.cxx index 3a8b21a435ff..742e896e03b1 100644 --- a/sc/source/core/tool/cellform.cxx +++ b/sc/source/core/tool/cellform.cxx @@ -50,7 +50,7 @@ OUString ScCellFormat::GetString( const ScRefCellValue& rCell, sal_uInt32 nForma } case CELLTYPE_VALUE: { - const double & nValue = rCell.mfValue; + const double nValue = rCell.getDouble(); if (!bNullVals && nValue == 0.0) return OUString(); else @@ -140,7 +140,7 @@ OUString ScCellFormat::GetInputString( case CELLTYPE_VALUE: { OUString str; - rFormatter.GetInputLineString(rCell.mfValue, nFormat, str, bFiltering, bForceSystemLocale); + rFormatter.GetInputLineString(rCell.getDouble(), nFormat, str, bFiltering, bForceSystemLocale); return str; } break; diff --git a/sc/source/core/tool/chgtrack.cxx b/sc/source/core/tool/chgtrack.cxx index 2efd4d6edec1..cf6cd43ffd0c 100644 --- a/sc/source/core/tool/chgtrack.cxx +++ b/sc/source/core/tool/chgtrack.cxx @@ -1560,7 +1560,7 @@ OUString ScChangeActionContent::GetStringOfCell( case CELLTYPE_VALUE: { OUString str; - pDoc->GetFormatTable()->GetInputLineString(rCell.mfValue, nFormat, str); + pDoc->GetFormatTable()->GetInputLineString(rCell.getDouble(), nFormat, str); return str; } case CELLTYPE_STRING: @@ -1656,7 +1656,7 @@ void ScChangeActionContent::SetValue( case CELLTYPE_VALUE : { // E.g.: Remember date as such pFromDoc->GetFormatTable()->GetInputLineString( - rOrgCell.mfValue, nFormat, rStr); + rOrgCell.getDouble(), nFormat, rStr); } break; case CELLTYPE_FORMULA : @@ -1682,7 +1682,7 @@ void ScChangeActionContent::SetCell( OUString& rStr, ScCellValue& rCell, sal_uLo { case CELLTYPE_VALUE : // e.g. remember date as date string - pDoc->GetFormatTable()->GetInputLineString(rCell.mfValue, nFormat, rStr); + pDoc->GetFormatTable()->GetInputLineString(rCell.getDouble(), nFormat, rStr); break; case CELLTYPE_FORMULA : rCell.mpFormula->SetInChangeTrack(true); diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx index faab8bd4832e..4d0723140294 100644 --- a/sc/source/core/tool/interpr4.cxx +++ b/sc/source/core/tool/interpr4.cxx @@ -217,7 +217,7 @@ double ScInterpreter::GetCellValueOrZero( const ScAddress& rPos, ScRefCellValue& break; case CELLTYPE_VALUE: { - fValue = rCell.mfValue; + fValue = rCell.getDouble(); nCurFmtIndex = mrDoc.GetNumberFormat( mrContext, rPos ); nCurFmtType = mrContext.GetNumberFormatType( nCurFmtIndex ); if ( bCalcAsShown && fValue != 0.0 ) @@ -265,7 +265,7 @@ void ScInterpreter::GetCellString( svl::SharedString& rStr, ScRefCellValue& rCel break; case CELLTYPE_VALUE: { - rStr = GetStringFromDouble( rCell.mfValue ); + rStr = GetStringFromDouble( rCell.getDouble() ); } break; default: @@ -320,7 +320,7 @@ bool ScInterpreter::CreateDoubleArr(SCCOL nCol1, SCROW nRow1, SCTAB nTab1, switch (aCell.getType()) { case CELLTYPE_VALUE : - nVal = GetValueCellValue(aAdr, aCell.mfValue); + nVal = GetValueCellValue(aAdr, aCell.getDouble()); break; case CELLTYPE_FORMULA : if (aCell.mpFormula->IsValue()) @@ -508,7 +508,7 @@ bool ScInterpreter::CreateCellArr(SCCOL nCol1, SCROW nRow1, SCTAB nTab1, nType = 1; break; case CELLTYPE_VALUE : - nVal = GetValueCellValue(aAdr, aCell.mfValue); + nVal = GetValueCellValue(aAdr, aCell.getDouble()); break; case CELLTYPE_FORMULA : nErr = aCell.mpFormula->GetErrCode(); @@ -3546,7 +3546,7 @@ bool ScInterpreter::SetSbxVariable( SbxVariable* pVar, const ScAddress& rPos ) switch (aCell.getType()) { case CELLTYPE_VALUE : - nVal = GetValueCellValue(rPos, aCell.mfValue); + nVal = GetValueCellValue(rPos, aCell.getDouble()); pVar->PutDouble( nVal ); break; case CELLTYPE_STRING : diff --git a/sc/source/filter/excel/xetable.cxx b/sc/source/filter/excel/xetable.cxx index 713a6c6b3c38..6a65d5c7dd8f 100644 --- a/sc/source/filter/excel/xetable.cxx +++ b/sc/source/filter/excel/xetable.cxx @@ -2628,7 +2628,7 @@ XclExpCellTable::XclExpCellTable( const XclExpRoot& rRoot ) : { case CELLTYPE_VALUE: { - double fValue = rScCell.mfValue; + double fValue = rScCell.getDouble(); if (pPattern) { diff --git a/sc/source/filter/html/htmlexp.cxx b/sc/source/filter/html/htmlexp.cxx index e8696478e5ad..eac7155dd2cc 100644 --- a/sc/source/filter/html/htmlexp.cxx +++ b/sc/source/filter/html/htmlexp.cxx @@ -1091,7 +1091,7 @@ void ScHTMLExport::WriteCell( sc::ColumnBlockPosition& rBlockPos, SCCOL nCol, SC switch (aCell.getType()) { case CELLTYPE_VALUE: - fVal = aCell.mfValue; + fVal = aCell.getDouble(); if ( bCalcAsShown && fVal != 0.0 ) fVal = pDoc->RoundValueAsShown( fVal, nFormat ); break; diff --git a/sc/source/filter/xcl97/XclExpChangeTrack.cxx b/sc/source/filter/xcl97/XclExpChangeTrack.cxx index 1c7ffcbf8489..93fce08f6f24 100644 --- a/sc/source/filter/xcl97/XclExpChangeTrack.cxx +++ b/sc/source/filter/xcl97/XclExpChangeTrack.cxx @@ -847,7 +847,7 @@ void XclExpChTrCellContent::GetCellData( { case CELLTYPE_VALUE: { - rpData->fValue = rScCell.mfValue; + rpData->fValue = rScCell.getDouble(); if( XclTools::GetRKFromDouble( rpData->nRKValue, rpData->fValue ) ) { rpData->nType = EXC_CHTR_TYPE_RK; diff --git a/sc/source/filter/xml/XMLChangeTrackingExportHelper.cxx b/sc/source/filter/xml/XMLChangeTrackingExportHelper.cxx index a9dd5a5e7fc5..4263c0b0740e 100644 --- a/sc/source/filter/xml/XMLChangeTrackingExportHelper.cxx +++ b/sc/source/filter/xml/XMLChangeTrackingExportHelper.cxx @@ -254,7 +254,7 @@ void ScChangeTrackingExportHelper::WriteValueCell(const ScCellValue& rCell, cons { assert(rCell.getType() == CELLTYPE_VALUE); - SetValueAttributes(rCell.mfValue, sValue); + SetValueAttributes(rCell.getDouble(), sValue); SvXMLElementExport aElemC(rExport, XML_NAMESPACE_TABLE, XML_CHANGE_TRACK_TABLE_CELL, true, true); } diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx index 529b34388f18..d896d7900403 100644 --- a/sc/source/filter/xml/xmlexprt.cxx +++ b/sc/source/filter/xml/xmlexprt.cxx @@ -3147,10 +3147,10 @@ void ScXMLExport::WriteCell(ScMyCell& aCell, sal_Int32 nEqualCellCount) case table::CellContentType_VALUE : { GetNumberFormatAttributesExportHelper()->SetNumberFormatAttributes( - aCell.nNumberFormat, aCell.maBaseCell.mfValue); + aCell.nNumberFormat, aCell.maBaseCell.getDouble()); if (getSaneDefaultVersion() & SvtSaveOptions::ODFSVER_EXTENDED) GetNumberFormatAttributesExportHelper()->SetNumberFormatAttributes( - aCell.nNumberFormat, aCell.maBaseCell.mfValue, false, XML_NAMESPACE_CALC_EXT, false); + aCell.nNumberFormat, aCell.maBaseCell.getDouble(), false, XML_NAMESPACE_CALC_EXT, false); } break; case table::CellContentType_TEXT : @@ -3836,7 +3836,7 @@ bool ScXMLExport::IsCellEqual (const ScMyCell& aCell1, const ScMyCell& aCell2) // #i29101# number format may be different from column default styles, // but can lead to different value types, so it must also be compared bIsEqual = (aCell1.nNumberFormat == aCell2.nNumberFormat) && - (aCell1.maBaseCell.mfValue == aCell2.maBaseCell.mfValue); + (aCell1.maBaseCell.getDouble() == aCell2.maBaseCell.getDouble()); } break; case table::CellContentType_TEXT : diff --git a/sc/source/ui/docshell/externalrefmgr.cxx b/sc/source/ui/docshell/externalrefmgr.cxx index 6b9920245706..c05a42812729 100644 --- a/sc/source/ui/docshell/externalrefmgr.cxx +++ b/sc/source/ui/docshell/externalrefmgr.cxx @@ -1518,7 +1518,7 @@ static FormulaToken* convertToToken( ScDocument& rHostDoc, const ScDocument& rSr return new formula::FormulaStringToken(aSS); } case CELLTYPE_VALUE: - return new formula::FormulaDoubleToken(rCell.mfValue); + return new formula::FormulaDoubleToken(rCell.getDouble()); case CELLTYPE_FORMULA: { ScFormulaCell* pFCell = rCell.mpFormula; @@ -2944,7 +2944,7 @@ public: } break; case CELLTYPE_VALUE: - pTok.reset(new formula::FormulaDoubleToken(aCell.mfValue)); + pTok.reset(new formula::FormulaDoubleToken(aCell.getDouble())); break; case CELLTYPE_FORMULA: { diff --git a/sc/source/ui/undo/undocell.cxx b/sc/source/ui/undo/undocell.cxx index ff9520c47768..007c0f862c9d 100644 --- a/sc/source/ui/undo/undocell.cxx +++ b/sc/source/ui/undo/undocell.cxx @@ -456,7 +456,7 @@ void ScUndoSetCell::SetValue( const ScCellValue& rVal ) rDoc.SetEmptyCell(maPos); break; case CELLTYPE_VALUE: - rDoc.SetValue(maPos, rVal.mfValue); + rDoc.SetValue(maPos, rVal.getDouble()); break; case CELLTYPE_STRING: { diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx index a66ce5b80d78..a879923f9ca4 100644 --- a/sc/source/ui/view/output2.cxx +++ b/sc/source/ui/view/output2.cxx @@ -492,7 +492,7 @@ void ScDrawStringsVars::SetPatternSimple( const ScPatternAttr* pNew, const SfxIt static bool SameValue( const ScRefCellValue& rCell, const ScRefCellValue& rOldCell ) { return rOldCell.getType() == CELLTYPE_VALUE && rCell.getType() == CELLTYPE_VALUE && - rCell.mfValue == rOldCell.mfValue; + rCell.getDouble() == rOldCell.getDouble(); } bool ScDrawStringsVars::SetText( const ScRefCellValue& rCell ) diff --git a/sc/source/ui/view/tabvwsh5.cxx b/sc/source/ui/view/tabvwsh5.cxx index 36228c3a7b25..7a6bde95c7fd 100644 --- a/sc/source/ui/view/tabvwsh5.cxx +++ b/sc/source/ui/view/tabvwsh5.cxx @@ -325,7 +325,7 @@ std::unique_ptr<SvxNumberInfoItem> ScTabViewShell::MakeNumberInfoItem( ScDocumen { case CELLTYPE_VALUE: { - nCellValue = aCell.mfValue; + nCellValue = aCell.getDouble(); eValType = SvxNumberValueType::Number; } break;