Hi,
I have submitted a patch for review:
https://gerrit.libreoffice.org/1931
To pull it, you can do:
git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/31/1931/1
bnc#615317: 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
---
M sc/inc/column.hxx
M sc/inc/document.hxx
M sc/inc/table.hxx
M sc/source/core/data/column.cxx
M sc/source/core/data/document.cxx
M sc/source/core/data/table2.cxx
M sc/source/ui/app/scmod.cxx
7 files changed, 102 insertions(+), 6 deletions(-)
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 @@
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 @@
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 @@
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..7bdb927 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -2149,6 +2149,41 @@
}
}
+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);
+ pFCell->SetCompile(true);
+ 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 @@
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 @@
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..28b72b8 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 @@
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;
//--------------------------------------------------------------------------
@@ -1064,6 +1066,13 @@
if (!pFormulaCfg || (*pFormulaCfg != rOpt))
// 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 );
@@ -1313,6 +1322,14 @@
// 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.
+ bCalcAll = pDoc->CompileErrorCells(ScErrorCodes::errNoName);
+ }
+
if ( pDoc && bCalcAll )
{
WaitObject aWait( pDocSh->GetActiveDialogParent() );
--
To view, visit https://gerrit.libreoffice.org/1931
To unsubscribe, visit https://gerrit.libreoffice.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Id340ce9b5db3ed368b98e814861be5c3f96df071
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: libreoffice-4-0
Gerrit-Owner: Kohei Yoshida <kohei.yoshida@gmail.com>
Context
- Change in core[libreoffice-4-0]: bnc#615317: Recompile cells with #NAME! for English function... · Kohei Yoshida (via Code Review)
Privacy Policy |
Impressum (Legal Info) |
Copyright information: Unless otherwise specified, all text and images
on this website are licensed under the
Creative Commons Attribution-Share Alike 3.0 License.
This does not include the source code of LibreOffice, which is
licensed under the Mozilla Public License (
MPLv2).
"LibreOffice" and "The Document Foundation" are
registered trademarks of their corresponding registered owners or are
in actual use as trademarks in one or more countries. Their respective
logos and icons are also subject to international copyright laws. Use
thereof is explained in our
trademark policy.