sc/source/core/data/colorscale.cxx | 54 ++++++++----------------------------- sc/source/core/data/conditio.cxx | 30 ++++++-------------- sc/source/core/tool/chartarr.cxx | 9 +++--- sc/source/ui/view/tabvwsha.cxx | 22 +++++++-------- 4 files changed, 37 insertions(+), 78 deletions(-)
New commits: commit 1cc2d4115e7e36f01dde759209802e2ac2477117 Author: Aleksas Pantechovskis <alex.pan...@gmail.com> Date: Sat Mar 26 22:20:15 2016 +0200 tdf#98893 Remove expensive calls to GetCellType + GetValue/... in calc Conflicts: sc/source/core/tool/cellform.cxx Change-Id: Id949800f6e13e268df798d2f1868f26deff66191 Reviewed-on: https://gerrit.libreoffice.org/23543 Reviewed-by: Markus Mohrhard <markus.mohrh...@googlemail.com> Tested-by: Jenkins <c...@libreoffice.org> diff --git a/sc/source/core/data/colorscale.cxx b/sc/source/core/data/colorscale.cxx index f5b4d52..bdf306f 100644 --- a/sc/source/core/data/colorscale.cxx +++ b/sc/source/core/data/colorscale.cxx @@ -413,21 +413,12 @@ std::vector<double>& ScColorFormat::getValues() const for(SCROW nRow = nRowStart; nRow <= nRowEnd; ++nRow) { ScAddress aAddr(nCol, nRow, nTab); - CellType eType = mpDoc->GetCellType(aAddr); - if(eType == CELLTYPE_VALUE) + ScRefCellValue rCell(*mpDoc, aAddr); + if(rCell.hasNumeric()) { - double aVal = mpDoc->GetValue(nCol, nRow, nTab); + double aVal = rCell.getValue(); rValues.push_back(aVal); } - else if(eType == CELLTYPE_FORMULA) - { - ScFormulaCell *pCell = mpDoc->GetFormulaCell(aAddr); - if (pCell && pCell->IsValue()) - { - double aVal = mpDoc->GetValue(nCol, nRow, nTab); - rValues.push_back(aVal); - } - } } } } @@ -540,19 +531,12 @@ double ScColorScaleFormat::CalcValue(double nMin, double nMax, ScColorScaleEntri Color* ScColorScaleFormat::GetColor( const ScAddress& rAddr ) const { - CellType eCellType = mpDoc->GetCellType(rAddr); - if(eCellType != CELLTYPE_VALUE && eCellType != CELLTYPE_FORMULA) + ScRefCellValue rCell(*mpDoc, rAddr); + if(!rCell.hasNumeric()) return nullptr; - if (eCellType == CELLTYPE_FORMULA) - { - ScFormulaCell *pCell = mpDoc->GetFormulaCell(rAddr); - if (!pCell || !pCell->IsValue()) - return nullptr; - } - // now we have for sure a value - double nVal = mpDoc->GetValue(rAddr); + double nVal = rCell.getValue(); if (maColorScales.size() < 2) return nullptr; @@ -796,17 +780,10 @@ double ScDataBarFormat::getMax(double nMin, double nMax) const ScDataBarInfo* ScDataBarFormat::GetDataBarInfo(const ScAddress& rAddr) const { - CellType eCellType = mpDoc->GetCellType(rAddr); - if(eCellType != CELLTYPE_VALUE && eCellType != CELLTYPE_FORMULA) + ScRefCellValue rCell(*mpDoc, rAddr); + if(!rCell.hasNumeric()) return nullptr; - if (eCellType == CELLTYPE_FORMULA) - { - ScFormulaCell *pCell = mpDoc->GetFormulaCell(rAddr); - if (!pCell || !pCell->IsValue()) - return nullptr; - } - // now we have for sure a value double nValMin = getMinValue(); @@ -816,7 +793,7 @@ ScDataBarInfo* ScDataBarFormat::GetDataBarInfo(const ScAddress& rAddr) const double nMinLength = mpFormatData->mnMinLength; double nMaxLength = mpFormatData->mnMaxLength; - double nValue = mpDoc->GetValue(rAddr); + double nValue = rCell.getValue(); ScDataBarInfo* pInfo = new ScDataBarInfo(); if(mpFormatData->meAxisPosition == databar::NONE) @@ -982,19 +959,12 @@ const ScIconSetFormatData* ScIconSetFormat::GetIconSetData() const ScIconSetInfo* ScIconSetFormat::GetIconSetInfo(const ScAddress& rAddr) const { - CellType eCellType = mpDoc->GetCellType(rAddr); - if(eCellType != CELLTYPE_VALUE && eCellType != CELLTYPE_FORMULA) + ScRefCellValue rCell(*mpDoc, rAddr); + if(!rCell.hasNumeric()) return nullptr; - if (eCellType == CELLTYPE_FORMULA) - { - ScFormulaCell *pCell = mpDoc->GetFormulaCell(rAddr); - if (!pCell || !pCell->IsValue()) - return nullptr; - } - // now we have for sure a value - double nVal = mpDoc->GetValue(rAddr); + double nVal = rCell.getValue(); if (mpFormatData->m_Entries.size() < 2) return nullptr; diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx index 57f3718..8cbc8ef 100644 --- a/sc/source/core/data/conditio.cxx +++ b/sc/source/core/data/conditio.cxx @@ -1029,22 +1029,14 @@ bool ScConditionEntry::IsAboveAverage( double nArg, bool bEqual ) const bool ScConditionEntry::IsError( const ScAddress& rPos ) const { - switch (mpDoc->GetCellType(rPos)) + ScRefCellValue rCell(*mpDoc, rPos); + + if (rCell.meType == CELLTYPE_FORMULA) { - case CELLTYPE_VALUE: - return false; - case CELLTYPE_FORMULA: - { - ScFormulaCell* pFormulaCell = mpDoc->GetFormulaCell(rPos); - if (pFormulaCell && pFormulaCell->GetErrCode()) - return true; - } - case CELLTYPE_STRING: - case CELLTYPE_EDIT: - return false; - default: - break; + if (rCell.mpFormula->GetErrCode()) + return true; } + return false; } @@ -1620,13 +1612,9 @@ ScCondDateFormatEntry::ScCondDateFormatEntry( ScDocument* pDoc, const ScCondDate bool ScCondDateFormatEntry::IsValid( const ScAddress& rPos ) const { - CellType eCellType = mpDoc->GetCellType(rPos); - - if (eCellType == CELLTYPE_NONE) - // empty cell. - return false; + ScRefCellValue rCell(*mpDoc, rPos); - if (eCellType != CELLTYPE_VALUE && eCellType != CELLTYPE_FORMULA) + if (!rCell.hasNumeric()) // non-numerical cell. return false; @@ -1637,7 +1625,7 @@ bool ScCondDateFormatEntry::IsValid( const ScAddress& rPos ) const SvNumberFormatter* pFormatter = mpDoc->GetFormatTable(); long nCurrentDate = rActDate - *(pFormatter->GetNullDate()); - double nVal = mpDoc->GetValue(rPos); + double nVal = rCell.getValue(); long nCellDate = (long) ::rtl::math::approxFloor(nVal); Date aCellDate = *(pFormatter->GetNullDate()); aCellDate += (long) ::rtl::math::approxFloor(nVal); diff --git a/sc/source/core/tool/chartarr.cxx b/sc/source/core/tool/chartarr.cxx index eab0e71..e373b3b 100644 --- a/sc/source/core/tool/chartarr.cxx +++ b/sc/source/core/tool/chartarr.cxx @@ -23,6 +23,7 @@ #include <float.h> #include "chartarr.hxx" +#include "cellvalue.hxx" #include "document.hxx" #include "rechead.hxx" #include "globstr.hrc" @@ -105,12 +106,12 @@ double getCellValue( ScDocument& rDoc, const ScAddress& rPos, double fDefault, b { double fRet = fDefault; - CellType eType = rDoc.GetCellType(rPos); - switch (eType) + ScRefCellValue aCell(rDoc, rPos); + switch (aCell.meType) { case CELLTYPE_VALUE: { - fRet = rDoc.GetValue(rPos); + fRet = aCell.getValue(); if (bCalcAsShown && fRet != 0.0) { sal_uInt32 nFormat = rDoc.GetNumberFormat(rPos); @@ -120,7 +121,7 @@ double getCellValue( ScDocument& rDoc, const ScAddress& rPos, double fDefault, b break; case CELLTYPE_FORMULA: { - ScFormulaCell* pFCell = rDoc.GetFormulaCell(rPos); + ScFormulaCell* pFCell = aCell.mpFormula; if (pFCell && !pFCell->GetErrCode() && pFCell->IsValue()) fRet = pFCell->GetValue(); } diff --git a/sc/source/ui/view/tabvwsha.cxx b/sc/source/ui/view/tabvwsha.cxx index 9d34f76..c005614 100644 --- a/sc/source/ui/view/tabvwsha.cxx +++ b/sc/source/ui/view/tabvwsha.cxx @@ -37,6 +37,7 @@ #include "global.hxx" #include "attrib.hxx" #include "patattr.hxx" +#include "cellform.hxx" #include "document.hxx" #include "formulacell.hxx" #include "globstr.hrc" @@ -625,7 +626,6 @@ void ScTabViewShell::UpdateInputHandler( bool bForce /* = sal_False */, bool bSt const EditTextObject* pObject = nullptr; ScViewData& rViewData = GetViewData(); ScDocument* pDoc = rViewData.GetDocument(); - CellType eType; SCCOL nPosX = rViewData.GetCurX(); SCROW nPosY = rViewData.GetCurY(); SCTAB nTab = rViewData.GetTabNo(); @@ -658,28 +658,28 @@ void ScTabViewShell::UpdateInputHandler( bool bForce /* = sal_False */, bool bSt if (!bHideAll) { - eType = pDoc->GetCellType(aPos); - if (eType == CELLTYPE_FORMULA) + ScRefCellValue rCell(*pDoc, aPos); + if (rCell.meType == CELLTYPE_FORMULA) { if (!bHideFormula) - pDoc->GetFormula( nPosX, nPosY, nTab, aString ); + rCell.mpFormula->GetFormula(aString); } - else if (eType == CELLTYPE_EDIT) + else if (rCell.meType == CELLTYPE_EDIT) { - pObject = pDoc->GetEditText(aPos); + pObject = rCell.mpEditText; } else { - pDoc->GetInputString( nPosX, nPosY, nTab, aString ); - if (eType == CELLTYPE_STRING) + SvNumberFormatter* pFormatter = pDoc->GetFormatTable(); + sal_uInt32 nNumFmt = pDoc->GetNumberFormat( aPos ); + + ScCellFormat::GetInputString( rCell, nNumFmt, aString, *pFormatter, pDoc ); + if (rCell.meType == CELLTYPE_STRING) { // Put a ' in front if necessary, so that the string is not // unintentionally interpreted as a number, and to show the // user that it is a string (#35060#). //! also for numberformat "Text"? -> then remove when editing - SvNumberFormatter* pFormatter = pDoc->GetFormatTable(); - sal_uInt32 nNumFmt; - pDoc->GetNumberFormat( nPosX, nPosY, nTab, nNumFmt ); double fDummy; if ( pFormatter->IsNumberFormat(aString, nNumFmt, fDummy) ) aString = "'" + aString; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits