[Libreoffice-commits] .: Branch 'distro/suse/suse-3.6' - sc/inc sc/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Wed Jan 30 16:38:06 PST 2013


 sc/inc/column.hxx                |    2 ++
 sc/inc/document.hxx              |   12 ++++++++++++
 sc/inc/table.hxx                 |    2 ++
 sc/source/core/data/column.cxx   |   35 +++++++++++++++++++++++++++++++++++
 sc/source/core/data/document.cxx |   16 ++++++++++++++++
 sc/source/core/data/table2.cxx   |   12 ++++++++++++
 sc/source/ui/app/scmod.cxx       |   29 +++++++++++++++++++++++------
 7 files changed, 102 insertions(+), 6 deletions(-)

New commits:
commit 54d2ba39f961996667a6de9e443fb9c7225a508f
Author: Kohei Yoshida <kohei.yoshida at 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

diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 446f4de..43a6c10 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -275,6 +275,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 7a8cf20..84791a0 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -882,6 +882,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 78cd977..60d440e 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -458,6 +458,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 79bf31f..df78d02 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -2078,6 +2078,41 @@ 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);
+        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 f17e72d..e9309d7 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -3417,6 +3417,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 cb9ae98..6591c5b 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -1561,6 +1561,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 46e9140..e76370c 100644
--- a/sc/source/ui/app/scmod.cxx
+++ b/sc/source/ui/app/scmod.cxx
@@ -114,6 +114,7 @@
 #include "scslots.hxx"
 
 #include "scabstdlg.hxx"
+#include "formula/errorcodes.hxx"
 
 #define SC_IDLE_MIN     150
 #define SC_IDLE_MAX     3000
@@ -1014,12 +1015,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;
 
     //--------------------------------------------------------------------------
 
@@ -1081,6 +1083,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 )
@@ -1329,6 +1338,14 @@ 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.
+        bCalcAll = pDoc->CompileErrorCells(ScErrorCodes::errNoName);
+    }
+
     if ( pDoc && bCalcAll )
     {
         WaitObject aWait( pDocSh->GetActiveDialogParent() );


More information about the Libreoffice-commits mailing list