From a5d355fef3896f3109c74c153f2a34b82fe6be38 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Sat, 18 Jun 2022 11:50:42 +0200 Subject: clean up Sc*CellValue after my recent commits (*) make more fields private (*) rename fields (remove suffix "1") now that I am sure I got everything. Change-Id: I0f8b9b1a534181c8b66532f9da5a0d16aa049cf0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136074 Tested-by: Jenkins Reviewed-by: Noel Grandin --- sc/inc/cellvalue.hxx | 18 ++++++------ sc/source/core/data/cellvalue.cxx | 54 +++++++++++++++++----------------- sc/source/core/data/queryevaluator.cxx | 2 +- 3 files changed, 37 insertions(+), 37 deletions(-) (limited to 'sc') diff --git a/sc/inc/cellvalue.hxx b/sc/inc/cellvalue.hxx index caf42d2c0155..5cf4cb3ba57d 100644 --- a/sc/inc/cellvalue.hxx +++ b/sc/inc/cellvalue.hxx @@ -30,8 +30,10 @@ struct ColumnBlockPosition; */ struct SC_DLLPUBLIC ScCellValue { +private: /// bool is there to indicate CellType::NONE std::variant maData; +public: ScCellValue(); ScCellValue( const ScRefCellValue& rCell ); @@ -102,17 +104,15 @@ struct SC_DLLPUBLIC ScCellValue */ struct SC_DLLPUBLIC ScRefCellValue { - /// bool is there to indicate CellType::NONE - std::variant maData; private: CellType meType; -public: union { - double mfValue1; + double mfValue; const svl::SharedString* mpString; - const EditTextObject* mpEditText1; - ScFormulaCell* mpFormula1; + const EditTextObject* mpEditText; + ScFormulaCell* mpFormula; }; +public: ScRefCellValue(); ScRefCellValue( double fValue ); @@ -129,10 +129,10 @@ public: void clear(); CellType getType() const { return meType; } - double getDouble() const { assert(meType == CELLTYPE_VALUE); return mfValue1; } + double getDouble() const { assert(meType == CELLTYPE_VALUE); return mfValue; } const svl::SharedString* getSharedString() const { assert(meType == CELLTYPE_STRING); return mpString; } - const EditTextObject* getEditText() const { assert(meType == CELLTYPE_EDIT); return mpEditText1; } - ScFormulaCell* getFormula() const { assert(meType == CELLTYPE_FORMULA); return mpFormula1; } + const EditTextObject* getEditText() const { assert(meType == CELLTYPE_EDIT); return mpEditText; } + ScFormulaCell* getFormula() const { assert(meType == CELLTYPE_FORMULA); return mpFormula; } /** * Take cell value from specified position in specified document. diff --git a/sc/source/core/data/cellvalue.cxx b/sc/source/core/data/cellvalue.cxx index e3786771d5e4..bf4099e023a6 100644 --- a/sc/source/core/data/cellvalue.cxx +++ b/sc/source/core/data/cellvalue.cxx @@ -100,7 +100,7 @@ bool equalsWithoutFormatImpl( const T& left, const T& right ) return aStr1 == aStr2; } case CELLTYPE_FORMULA: - return equalsFormulaCells(left.mpFormula1, right.mpFormula1); + return equalsFormulaCells(left.getFormula(), right.getFormula()); default: ; } @@ -212,15 +212,15 @@ OUString getRawStringImpl( const CellT& rCell, const ScDocument& rDoc ) switch (rCell.getType()) { case CELLTYPE_VALUE: - return OUString::number(rCell.mfValue1); + return OUString::number(rCell.getDouble()); case CELLTYPE_STRING: - return rCell.mpString->getString(); + return rCell.getSharedString()->getString(); case CELLTYPE_EDIT: - if (rCell.mpEditText1) - return ScEditUtil::GetString(*rCell.mpEditText1, &rDoc); + if (rCell.getEditText()) + return ScEditUtil::GetString(*rCell.getEditText(), &rDoc); break; case CELLTYPE_FORMULA: - return rCell.mpFormula1->GetRawString().getString(); + return rCell.getFormula()->GetRawString().getString(); default: ; } @@ -236,7 +236,7 @@ ScCellValue::ScCellValue( const ScRefCellValue& rCell ) switch (rCell.getType()) { case CELLTYPE_STRING: - maData = *rCell.mpString; + maData = *rCell.getSharedString(); break; case CELLTYPE_EDIT: maData = rCell.getEditText()->Clone().release(); @@ -360,16 +360,16 @@ void ScCellValue::assign( const ScDocument& rDoc, const ScAddress& rPos ) switch (aRefVal.getType()) { case CELLTYPE_STRING: - maData = *aRefVal.mpString; + maData = *aRefVal.getSharedString(); break; case CELLTYPE_EDIT: - maData = aRefVal.mpEditText1 ? aRefVal.mpEditText1->Clone().release() : static_cast(nullptr); + maData = aRefVal.getEditText() ? aRefVal.getEditText()->Clone().release() : static_cast(nullptr); break; case CELLTYPE_VALUE: - maData = aRefVal.mfValue1; + maData = aRefVal.getDouble(); break; case CELLTYPE_FORMULA: - maData = aRefVal.mpFormula1->Clone(); + maData = aRefVal.getFormula()->Clone(); break; default: ; // leave empty } @@ -548,11 +548,11 @@ void ScCellValue::swap( ScCellValue& r ) std::swap(maData, r.maData); } -ScRefCellValue::ScRefCellValue() : meType(CELLTYPE_NONE), mfValue1(0.0) {} -ScRefCellValue::ScRefCellValue( double fValue ) : meType(CELLTYPE_VALUE), mfValue1(fValue) {} +ScRefCellValue::ScRefCellValue() : meType(CELLTYPE_NONE), mfValue(0.0) {} +ScRefCellValue::ScRefCellValue( double fValue ) : meType(CELLTYPE_VALUE), mfValue(fValue) {} ScRefCellValue::ScRefCellValue( const svl::SharedString* pString ) : meType(CELLTYPE_STRING), mpString(pString) {} -ScRefCellValue::ScRefCellValue( const EditTextObject* pEditText ) : meType(CELLTYPE_EDIT), mpEditText1(pEditText) {} -ScRefCellValue::ScRefCellValue( ScFormulaCell* pFormula ) : meType(CELLTYPE_FORMULA), mpFormula1(pFormula) {} +ScRefCellValue::ScRefCellValue( const EditTextObject* pEditText ) : meType(CELLTYPE_EDIT), mpEditText(pEditText) {} +ScRefCellValue::ScRefCellValue( ScFormulaCell* pFormula ) : meType(CELLTYPE_FORMULA), mpFormula(pFormula) {} ScRefCellValue::ScRefCellValue( ScDocument& rDoc, const ScAddress& rPos ) { @@ -568,7 +568,7 @@ void ScRefCellValue::clear() { // Reset to empty value. meType = CELLTYPE_NONE; - mfValue1 = 0.0; + mfValue = 0.0; } void ScRefCellValue::assign( ScDocument& rDoc, const ScAddress& rPos ) @@ -593,13 +593,13 @@ void ScRefCellValue::commit( ScDocument& rDoc, const ScAddress& rPos ) const } break; case CELLTYPE_EDIT: - rDoc.SetEditText(rPos, ScEditUtil::Clone(*mpEditText1, rDoc)); + rDoc.SetEditText(rPos, ScEditUtil::Clone(*mpEditText, rDoc)); break; case CELLTYPE_VALUE: - rDoc.SetValue(rPos, mfValue1); + rDoc.SetValue(rPos, mfValue); break; case CELLTYPE_FORMULA: - rDoc.SetFormulaCell(rPos, new ScFormulaCell(*mpFormula1, rDoc, rPos)); + rDoc.SetFormulaCell(rPos, new ScFormulaCell(*mpFormula, rDoc, rPos)); break; default: rDoc.SetEmptyCell(rPos); @@ -608,17 +608,17 @@ void ScRefCellValue::commit( ScDocument& rDoc, const ScAddress& rPos ) const bool ScRefCellValue::hasString() const { - return hasStringImpl(meType, mpFormula1); + return hasStringImpl(meType, mpFormula); } bool ScRefCellValue::hasNumeric() const { - return hasNumericImpl(meType, mpFormula1); + return hasNumericImpl(meType, mpFormula); } bool ScRefCellValue::hasError() const { - return meType == CELLTYPE_FORMULA && mpFormula1->GetErrCode() != FormulaError::NONE; + return meType == CELLTYPE_FORMULA && mpFormula->GetErrCode() != FormulaError::NONE; } double ScRefCellValue::getValue() @@ -626,9 +626,9 @@ double ScRefCellValue::getValue() switch (meType) { case CELLTYPE_VALUE: - return mfValue1; + return mfValue; case CELLTYPE_FORMULA: - return mpFormula1->GetValue(); + return mpFormula->GetValue(); default: ; } @@ -640,9 +640,9 @@ double ScRefCellValue::getRawValue() const switch (meType) { case CELLTYPE_VALUE: - return mfValue1; + return mfValue; case CELLTYPE_FORMULA: - return mpFormula1->GetRawValue(); + return mpFormula->GetRawValue(); default: ; } @@ -670,7 +670,7 @@ bool ScRefCellValue::hasEmptyValue() return true; if (meType == CELLTYPE_FORMULA) - return mpFormula1->IsEmpty(); + return mpFormula->IsEmpty(); return false; } diff --git a/sc/source/core/data/queryevaluator.cxx b/sc/source/core/data/queryevaluator.cxx index a63084726083..4e35eeffcd62 100644 --- a/sc/source/core/data/queryevaluator.cxx +++ b/sc/source/core/data/queryevaluator.cxx @@ -320,7 +320,7 @@ OUString ScQueryEvaluator::getCellString(const ScRefCellValue& rCell, SCROW nRow } else if (rCell.getType() == CELLTYPE_STRING) { - *sharedString = rCell.mpString; + *sharedString = rCell.getSharedString(); return OUString(); } else -- cgit