sc/inc/column.hxx | 2 ++ sc/inc/document.hxx | 12 ++++++++++++ sc/inc/table.hxx | 2 ++ sc/source/core/data/column.cxx | 34 ++++++++++++++++++++++++++++++++++ sc/source/core/data/document.cxx | 16 ++++++++++++++++ sc/source/core/data/table2.cxx | 12 ++++++++++++ sc/source/ui/app/scmod.cxx | 30 ++++++++++++++++++++++++------ 7 files changed, 102 insertions(+), 6 deletions(-)
New commits: commit cad24bc49681e0a765bee01b00825ab02d537705 Author: Kohei Yoshida <kohei.yosh...@gmail.com> Date: Wed Jan 30 15:55:58 2013 -0500 bnc#615357: Recompile cells with #NAME! for English function name option. When the option for using English function name changes, we should re-compile all cells with #NAME! as the error may have been caused by unresolved function name which may be fixed after the option change. Change-Id: Id340ce9b5db3ed368b98e814861be5c3f96df071 Reviewed-on: https://gerrit.libreoffice.org/1931 Reviewed-by: Markus Mohrhard <markus.mohrh...@googlemail.com> Tested-by: Markus Mohrhard <markus.mohrh...@googlemail.com> diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx index 3e927c8..930caba 100644 --- a/sc/inc/column.hxx +++ b/sc/inc/column.hxx @@ -250,6 +250,8 @@ public: void CompileAll(); void CompileXML( ScProgress& rProgress ); + bool CompileErrorCells(sal_uInt16 nErrCode); + void ResetChanged( SCROW nStartRow, SCROW nEndRow ); bool UpdateReference( UpdateRefMode eUpdateRefMode, SCCOL nCol1, SCROW nRow1, SCTAB nTab1, diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx index c7c09d8..31c5ac2 100644 --- a/sc/inc/document.hxx +++ b/sc/inc/document.hxx @@ -863,6 +863,18 @@ public: void CompileAll(); void CompileXML(); + /** + * Re-compile formula cells with error. + * + * @param nErrCode specified error code to match. Only those cells with + * this error code will be re-compiled. If this value is + * 0, cells with any error values will be re-compiled. + * + * @return true if at least one cell is re-compiled, false if no cells are + * re-compiled. + */ + bool CompileErrorCells(sal_uInt16 nErrCode); + ScAutoNameCache* GetAutoNameCache() { return pAutoNameCache; } SC_DLLPUBLIC void SetAutoNameCache( ScAutoNameCache* pCache ); diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx index 26d5a69..061c830 100644 --- a/sc/inc/table.hxx +++ b/sc/inc/table.hxx @@ -446,6 +446,8 @@ public: void CompileAll(); void CompileXML( ScProgress& rProgress ); + bool CompileErrorCells(sal_uInt16 nErrCode); + void UpdateReference( UpdateRefMode eUpdateRefMode, SCCOL nCol1, SCROW nRow1, SCTAB nTab1, SCCOL nCol2, SCROW nRow2, SCTAB nTab2, SCsCOL nDx, SCsROW nDy, SCsTAB nDz, diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx index 462abe7..5fb98a2 100644 --- a/sc/source/core/data/column.cxx +++ b/sc/source/core/data/column.cxx @@ -2149,6 +2149,40 @@ void ScColumn::CompileXML( ScProgress& rProgress ) } } +bool ScColumn::CompileErrorCells(sal_uInt16 nErrCode) +{ + if (maItems.empty()) + return false; + + bool bCompiled = false; + std::vector<ColEntry>::iterator it = maItems.begin(), itEnd = maItems.end(); + for (; it != itEnd; ++it) + { + ScBaseCell* pCell = it->pCell; + if (pCell->GetCellType() != CELLTYPE_FORMULA) + // Not a formula cell. Skip it. + continue; + + ScFormulaCell* pFCell = static_cast<ScFormulaCell*>(pCell); + sal_uInt16 nCurError = pFCell->GetRawError(); + if (!nCurError) + // It's not an error cell. Skip it. + continue; + + if (nErrCode && nCurError != nErrCode) + // Error code is specified, and it doesn't match. Skip it. + continue; + + pFCell->GetCode()->SetCodeError(0); + OUStringBuffer aBuf; + pFCell->GetFormula(aBuf, pDocument->GetGrammar()); + pFCell->Compile(aBuf.makeStringAndClear(), false, pDocument->GetGrammar()); + + bCompiled = true; + } + + return bCompiled; +} void ScColumn::CalcAfterLoad() { diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx index 95018d7..8cc1713 100644 --- a/sc/source/core/data/document.cxx +++ b/sc/source/core/data/document.cxx @@ -3377,6 +3377,22 @@ void ScDocument::CompileXML() SetAutoCalc( bOldAutoCalc ); } +bool ScDocument::CompileErrorCells(sal_uInt16 nErrCode) +{ + bool bCompiled = false; + TableContainer::iterator it = maTabs.begin(), itEnd = maTabs.end(); + for (; it != itEnd; ++it) + { + ScTable* pTab = *it; + if (!pTab) + continue; + + if (pTab->CompileErrorCells(nErrCode)) + bCompiled = true; + } + + return bCompiled; +} void ScDocument::CalcAfterLoad() { diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx index f0bd119..918a602 100644 --- a/sc/source/core/data/table2.cxx +++ b/sc/source/core/data/table2.cxx @@ -1539,6 +1539,18 @@ void ScTable::CompileXML( ScProgress& rProgress ) mpCondFormatList->CompileXML(); } +bool ScTable::CompileErrorCells(sal_uInt16 nErrCode) +{ + bool bCompiled = false; + for (SCCOL i = 0; i <= MAXCOL; ++i) + { + if (aCol[i].CompileErrorCells(nErrCode)) + bCompiled = true; + } + + return bCompiled; +} + void ScTable::CalcAfterLoad() { for (SCCOL i=0; i <= MAXCOL; i++) aCol[i].CalcAfterLoad(); diff --git a/sc/source/ui/app/scmod.cxx b/sc/source/ui/app/scmod.cxx index 9f406d7..d093f8b 100644 --- a/sc/source/ui/app/scmod.cxx +++ b/sc/source/ui/app/scmod.cxx @@ -100,6 +100,7 @@ #include "scslots.hxx" #include "scabstdlg.hxx" +#include "formula/errorcodes.hxx" #define SC_IDLE_MIN 150 #define SC_IDLE_MAX 3000 @@ -998,12 +999,13 @@ void ScModule::ModifyOptions( const SfxItemSet& rOptSet ) ScDocShell* pDocSh = PTR_CAST(ScDocShell, SfxObjectShell::Current()); ScDocument* pDoc = pDocSh ? pDocSh->GetDocument() : NULL; const SfxPoolItem* pItem = NULL; - sal_Bool bRepaint = false; - sal_Bool bUpdateMarks = false; - sal_Bool bUpdateRefDev = false; - sal_Bool bCalcAll = false; - sal_Bool bSaveAppOptions = false; - sal_Bool bSaveInputOptions = false; + bool bRepaint = false; + bool bUpdateMarks = false; + bool bUpdateRefDev = false; + bool bCalcAll = false; + bool bSaveAppOptions = false; + bool bSaveInputOptions = false; + bool bCompileErrorCells = false; //-------------------------------------------------------------------------- @@ -1065,6 +1067,13 @@ void ScModule::ModifyOptions( const SfxItemSet& rOptSet ) // Formula options have changed. Repaint the column headers. bRepaint = true; + if (pFormulaCfg && pFormulaCfg->GetUseEnglishFuncName() != rOpt.GetUseEnglishFuncName()) + { + // Re-compile formula cells with error as the error may have been + // caused by unresolved function names. + bCompileErrorCells = true; + } + SetFormulaOptions( rOpt ); if ( pDocSh ) @@ -1313,6 +1322,15 @@ void ScModule::ModifyOptions( const SfxItemSet& rOptSet ) // Neuberechnung anstossen? + if (pDoc && bCompileErrorCells) + { + // Re-compile cells with name error, and recalc if at least one cell + // has been re-compiled. In the future we may want to find a way to + // recalc only those that are affected. + if (pDoc->CompileErrorCells(ScErrorCodes::errNoName)) + bCalcAll = true; + } + if ( pDoc && bCalcAll ) { WaitObject aWait( pDocSh->GetActiveDialogParent() ); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits