sc/source/core/tool/cellform.cxx | 87 +------------------------------------- sc/source/filter/xml/xmlexprt.cxx | 18 +++++-- 2 files changed, 16 insertions(+), 89 deletions(-)
New commits: commit d9c1921c5031e5b372ee9d8db1e00fe7211cdd31 Author: Markus Mohrhard <markus.mohrh...@googlemail.com> Date: Fri Mar 25 01:48:21 2016 +0100 use the ScRefCellValue that is already available, tdf#93405 Change-Id: I68a2ddbe5049d10b5c11c2d77b26dce8dc55ab28 diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx index e4e45c7..bf19552 100644 --- a/sc/source/filter/xml/xmlexprt.cxx +++ b/sc/source/filter/xml/xmlexprt.cxx @@ -213,20 +213,28 @@ OUString lcl_RangeSequenceToString( return aResult.makeStringAndClear(); } -OUString lcl_GetFormattedString( ScDocument* pDoc, const ScAddress& rPos ) +OUString lcl_GetFormattedString(ScDocument* pDoc, ScRefCellValue& rCell, const ScAddress& rAddr) { // return text/edit cell string content, with line feeds in edit cells if (!pDoc) return EMPTY_OUSTRING; - switch (pDoc->GetCellType(rPos)) + switch (rCell.meType) { case CELLTYPE_STRING: - return pDoc->GetString(rPos); + { + OUString aStr; + Color* pColor; + SvNumberFormatter* pFormatter = pDoc->GetFormatTable(); + + sal_uLong nFormat = pDoc->GetNumberFormat(rAddr); + ScCellFormat::GetString(rCell, nFormat, aStr, &pColor, *pFormatter, pDoc); + return aStr; + } case CELLTYPE_EDIT: { - const EditTextObject* pData = pDoc->GetEditText(rPos); + const EditTextObject* pData = rCell.mpEditText; if (!pData) return EMPTY_OUSTRING; @@ -3095,7 +3103,7 @@ void ScXMLExport::WriteCell(ScMyCell& aCell, sal_Int32 nEqualCellCount) break; case table::CellContentType_TEXT : { - OUString sFormattedString(lcl_GetFormattedString(pDoc, aCell.maCellAddress)); + OUString sFormattedString(lcl_GetFormattedString(pDoc, aCell.maBaseCell, aCell.maCellAddress)); OUString sCellString = aCell.maBaseCell.getString(pDoc); GetNumberFormatAttributesExportHelper()->SetNumberFormatAttributes( sCellString, sFormattedString); commit 4518faa31dec03ffabee30437e6960558a940957 Author: Markus Mohrhard <markus.mohrh...@googlemail.com> Date: Fri Mar 25 01:47:34 2016 +0100 we already pass the ScRefCellValue as parameter, tdf#93405 Change-Id: I27f7e8ffe93545fe872a0c5b64f26dc90cb70e6f diff --git a/sc/source/core/tool/cellform.cxx b/sc/source/core/tool/cellform.cxx index 758d3f4..a9877ce 100644 --- a/sc/source/core/tool/cellform.cxx +++ b/sc/source/core/tool/cellform.cxx @@ -199,7 +199,7 @@ OUString ScCellFormat::GetOutputString( ScDocument& rDoc, const ScAddress& rPos, // like in GetString for document (column) Color* pColor; sal_uLong nNumFmt = rDoc.GetNumberFormat(rPos); - aVal = GetString(rDoc, rPos, nNumFmt, &pColor, *rDoc.GetFormatTable()); + GetString(rCell, nNumFmt, aVal, &pColor, *rDoc.GetFormatTable(), &rDoc); } return aVal; } commit ee98f0e691e3cf945725a9f1daa90542407e3358 Author: Markus Mohrhard <markus.mohrh...@googlemail.com> Date: Fri Mar 25 01:22:32 2016 +0100 these two methods are identical copies, related tdf#93405 This already gives a 15% improvement as we now only query the cell twice instead of three times. Change-Id: I2e0533f05ace6773ad0710b2c586ca325aeae91b diff --git a/sc/source/core/tool/cellform.cxx b/sc/source/core/tool/cellform.cxx index c588676..758d3f4 100644 --- a/sc/source/core/tool/cellform.cxx +++ b/sc/source/core/tool/cellform.cxx @@ -133,89 +133,8 @@ OUString ScCellFormat::GetString( OUString aString; *ppColor = nullptr; - CellType eType = rDoc.GetCellType(rPos); - switch (eType) - { - case CELLTYPE_STRING: - { - ScRefCellValue aCell(rDoc, rPos); - rFormatter.GetOutputString(aCell.mpString->getString(), nFormat, aString, ppColor); - } - break; - case CELLTYPE_EDIT: - { - ScRefCellValue aCell(rDoc, rPos); - rFormatter.GetOutputString(aCell.getString(&rDoc), nFormat, aString, ppColor); - } - break; - case CELLTYPE_VALUE: - { - double nValue = rDoc.GetValue(rPos); - if (!bNullVals && nValue == 0.0) aString.clear(); - else - { - if (eForceTextFmt == ftCheck) - { - if (nFormat && rFormatter.IsTextFormat(nFormat)) eForceTextFmt = ftForce; - } - if (eForceTextFmt == ftForce) - { - OUString aTemp; - rFormatter.GetOutputString(nValue, 0, aTemp, ppColor); - rFormatter.GetOutputString(aTemp, nFormat, aString, ppColor); - } - else rFormatter.GetOutputString(nValue, nFormat, aString, ppColor); - } - } - break; - case CELLTYPE_FORMULA: - { - ScFormulaCell* pFCell = rDoc.GetFormulaCell(rPos); - if (!pFCell) - return aString; - if (bFormula) - { - pFCell->GetFormula(aString); - } - else - { - // A macro started from the interpreter, which has - // access to Formular Cells, becomes a CellText, even if - // that triggers further interpretation, except if those - // cells are already being interpreted. - // IdleCalc generally doesn't trigger further interpretation, - // as not to get Err522 (circular). - if (pFCell->GetDocument()->IsInInterpreter() && - (!pFCell->GetDocument()->GetMacroInterpretLevel() - || pFCell->IsRunning())) - { - aString = "..."; - } - else - { - sal_uInt16 nErrCode = pFCell->GetErrCode(); - - if (nErrCode != 0) aString = ScGlobal::GetErrorString(nErrCode); - else if (pFCell->IsEmptyDisplayedAsString()) aString.clear(); - else if (pFCell->IsValue()) - { - double fValue = pFCell->GetValue(); - if (!bNullVals && fValue == 0.0) aString.clear(); - else if (pFCell->IsHybridValueCell()) aString = pFCell->GetString().getString(); - else rFormatter.GetOutputString(fValue, nFormat, aString, ppColor); - } - else - { - rFormatter.GetOutputString(pFCell->GetString().getString(), - nFormat, aString, ppColor); - } - } - } - } - break; - default: - ; - } + ScRefCellValue aCell(rDoc, rPos); + GetString(aCell, nFormat, aString, ppColor, rFormatter, &rDoc, bNullVals, bFormula, eForceTextFmt); return aString; } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits