[Libreoffice-commits] .: officecfg/registry sc/inc sc/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Mon Dec 10 06:18:54 PST 2012


 officecfg/registry/schema/org/openoffice/Office/Calc.xcs |   30 +++++++
 sc/inc/formulaopt.hxx                                    |   13 +++
 sc/inc/globstr.hrc                                       |    4 
 sc/inc/scmod.hxx                                         |    4 
 sc/source/core/tool/formulaopt.cxx                       |   55 ++++++++++++-
 sc/source/filter/oox/workbookfragment.cxx                |   62 +++++++++++++--
 sc/source/ui/inc/optdlg.hrc                              |    2 
 sc/source/ui/inc/tpformula.hxx                           |    3 
 sc/source/ui/optdlg/tpformula.cxx                        |   37 ++++++++
 sc/source/ui/src/globstr.src                             |    9 ++
 sc/source/ui/src/optdlg.src                              |   19 ++++
 11 files changed, 224 insertions(+), 14 deletions(-)

New commits:
commit 34c157e0032e182a044979ce210009decb20e755
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Mon Dec 10 11:19:38 2012 +0100

    improve the recalc dialog for ooxml
    
    Change-Id: I94ea2d52f86a340ce3802ea4b63642cfc637bd2d

diff --git a/officecfg/registry/schema/org/openoffice/Office/Calc.xcs b/officecfg/registry/schema/org/openoffice/Office/Calc.xcs
index 14ce6ca..2dd5d7c 100644
--- a/officecfg/registry/schema/org/openoffice/Office/Calc.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/Calc.xcs
@@ -1506,6 +1506,36 @@
                     <value>false</value>
                 </prop>
             </group>
+            <group oor:name="Load">
+                <info>
+                    <desc>Contains settings that affect formula handling while laoding.</desc>
+                </info>
+                <prop oor:name="OOXMLRecalcMode" oor:type="xs:int" oor:nillable="false">
+                    <!-- UIHint: Tools - Options - Spreadsheet - Formula -->
+                    <info>
+                        <author>Markus Mohrhard</author>
+                        <desc>Specifies whether to force a hard recalc after load</desc>
+                    </info>
+                    <constraints>
+                        <enumeration oor:value="0">
+                            <info>
+                                <desc>Recalc always</desc>
+                            </info>
+                        </enumeration>
+                        <enumeration oor:value="1">
+                            <info>
+                                <desc>Ask before Recalc</desc>
+                            </info>
+                        </enumeration>
+                        <enumeration oor:value="2">
+                            <info>
+                                <desc>Recalc never</desc>
+                            </info>
+                        </enumeration>
+                    </constraints>
+                    <value>1</value>
+                </prop>
+            </group>
         </group>
 		<group oor:name="Revision">
 			<info>
diff --git a/sc/inc/formulaopt.hxx b/sc/inc/formulaopt.hxx
index 7cc2dd8..4f07c40 100644
--- a/sc/inc/formulaopt.hxx
+++ b/sc/inc/formulaopt.hxx
@@ -37,6 +37,14 @@
 #include "global.hxx"
 #include "calcconfig.hxx"
 
+// have to match the registry values
+enum SC_DLLPUBLIC ScRecalcOptions
+{
+    RECALC_ALWAYS = 0,
+    RECALC_ASK = 1,
+    RECALC_NEVER = 2
+};
+
 class SC_DLLPUBLIC ScFormulaOptions
 {
 private:
@@ -48,6 +56,8 @@ private:
     ::rtl::OUString aFormulaSepArrayRow;
     ::rtl::OUString aFormulaSepArrayCol;
 
+    ScRecalcOptions meOOXMLRecalc;
+
 public:
     ScFormulaOptions();
     ScFormulaOptions( const ScFormulaOptions& rCpy );
@@ -74,6 +84,9 @@ public:
     void SetFormulaSepArrayCol(const ::rtl::OUString& rSep) { aFormulaSepArrayCol = rSep; }
     ::rtl::OUString GetFormulaSepArrayCol() const { return aFormulaSepArrayCol; }
 
+    void SetOOXMLRecalcOptions( ScRecalcOptions eOpt ) { meOOXMLRecalc = eOpt; }
+    ScRecalcOptions GetOOXMLRecalcOptions() const { return meOOXMLRecalc; }
+
     void ResetFormulaSeparators();
 
     static void GetDefaultFormulaSeparators(rtl::OUString& rSepArg, rtl::OUString& rSepArrayCol, rtl::OUString& rSepArrayRow);
diff --git a/sc/inc/globstr.hrc b/sc/inc/globstr.hrc
index 3f23dc1..c1873b5 100644
--- a/sc/inc/globstr.hrc
+++ b/sc/inc/globstr.hrc
@@ -618,7 +618,9 @@
 
 #define STR_QUERY_FORMULA_RECALC_ONLOAD_ODS 492
 #define STR_QUERY_FORMULA_RECALC_ONLOAD_XLS 493
+#define STR_ALWAYS                  494
+#define STR_NEVER                   495
 
-#define STR_COUNT                   494
+#define STR_COUNT                   496
 
 #endif
diff --git a/sc/inc/scmod.hxx b/sc/inc/scmod.hxx
index e023546..acc0e17 100644
--- a/sc/inc/scmod.hxx
+++ b/sc/inc/scmod.hxx
@@ -173,14 +173,14 @@ public:
     const ScDocOptions&     GetDocOptions   ();
 SC_DLLPUBLIC    const ScAppOptions&     GetAppOptions   ();
 SC_DLLPUBLIC    const ScDefaultsOptions&   GetDefaultsOptions ();
-    const ScFormulaOptions&   GetFormulaOptions ();
+    SC_DLLPUBLIC const ScFormulaOptions&   GetFormulaOptions ();
     const ScInputOptions&   GetInputOptions ();
 SC_DLLPUBLIC    const ScPrintOptions&   GetPrintOptions ();
     void                    SetViewOptions  ( const ScViewOptions& rOpt );
     void                    SetDocOptions   ( const ScDocOptions& rOpt );
 SC_DLLPUBLIC    void                    SetAppOptions   ( const ScAppOptions& rOpt );
     void                    SetDefaultsOptions ( const ScDefaultsOptions& rOpt );
-    void                    SetFormulaOptions ( const ScFormulaOptions& rOpt );
+    SC_DLLPUBLIC void                    SetFormulaOptions ( const ScFormulaOptions& rOpt );
     void                    SetInputOptions ( const ScInputOptions& rOpt );
     void                    SetPrintOptions ( const ScPrintOptions& rOpt );
     void                    InsertEntryToLRUList(sal_uInt16 nFIndex);
diff --git a/sc/source/core/tool/formulaopt.cxx b/sc/source/core/tool/formulaopt.cxx
index b5989ad..fe54621 100644
--- a/sc/source/core/tool/formulaopt.cxx
+++ b/sc/source/core/tool/formulaopt.cxx
@@ -58,7 +58,8 @@ ScFormulaOptions::ScFormulaOptions( const ScFormulaOptions& rCpy ) :
     aCalcConfig(rCpy.aCalcConfig),
     aFormulaSepArg      ( rCpy.aFormulaSepArg ),
     aFormulaSepArrayRow ( rCpy.aFormulaSepArrayRow ),
-    aFormulaSepArrayCol ( rCpy.aFormulaSepArrayCol )
+    aFormulaSepArrayCol ( rCpy.aFormulaSepArrayCol ),
+    meOOXMLRecalc       ( rCpy.meOOXMLRecalc )
 {
 }
 
@@ -70,6 +71,7 @@ void ScFormulaOptions::SetDefaults()
 {
     bUseEnglishFuncName = false;
     eFormulaGrammar     = ::formula::FormulaGrammar::GRAM_NATIVE;
+    meOOXMLRecalc = RECALC_ASK;
 
     // unspecified means use the current formula syntax.
     aCalcConfig.reset();
@@ -148,6 +150,7 @@ ScFormulaOptions& ScFormulaOptions::operator=( const ScFormulaOptions& rCpy )
     aFormulaSepArg      = rCpy.aFormulaSepArg;
     aFormulaSepArrayRow = rCpy.aFormulaSepArrayRow;
     aFormulaSepArrayCol = rCpy.aFormulaSepArrayCol;
+    meOOXMLRecalc       = rCpy.meOOXMLRecalc;
     return *this;
 }
 
@@ -158,7 +161,8 @@ bool ScFormulaOptions::operator==( const ScFormulaOptions& rOpt ) const
         && aCalcConfig == rOpt.aCalcConfig
         && aFormulaSepArg      == rOpt.aFormulaSepArg
         && aFormulaSepArrayRow == rOpt.aFormulaSepArrayRow
-        && aFormulaSepArrayCol == rOpt.aFormulaSepArrayCol;
+        && aFormulaSepArrayCol == rOpt.aFormulaSepArrayCol
+        && meOOXMLRecalc       == rOpt.meOOXMLRecalc;
 }
 
 bool ScFormulaOptions::operator!=( const ScFormulaOptions& rOpt ) const
@@ -214,7 +218,8 @@ SfxPoolItem* ScTpFormulaItem::Clone( SfxItemPool * ) const
 #define SCFORMULAOPT_SEP_ARRAY_COL        4
 #define SCFORMULAOPT_STRING_REF_SYNTAX    5
 #define SCFORMULAOPT_EMPTY_STRING_AS_ZERO 6
-#define SCFORMULAOPT_COUNT                7
+#define SCFORMULAOPT_OOXML_RECALC         7
+#define SCFORMULAOPT_COUNT                8
 
 Sequence<OUString> ScFormulaCfg::GetPropertyNames()
 {
@@ -227,6 +232,7 @@ Sequence<OUString> ScFormulaCfg::GetPropertyNames()
         "Syntax/SeparatorArrayCol",      // SCFORMULAOPT_SEP_ARRAY_COL
         "Syntax/StringRefAddressSyntax", // SCFORMULAOPT_STRING_REF_SYNTAX
         "Syntax/EmptyStringAsZero",      // SCFORMULAOPT_EMPTY_STRING_AS_ZERO
+        "Load/OOXMLRecalcMode",          // SCFORMULAOPT_OOXML_RECALC
     };
     Sequence<OUString> aNames(SCFORMULAOPT_COUNT);
     OUString* pNames = aNames.getArray();
@@ -350,6 +356,30 @@ ScFormulaCfg::ScFormulaCfg() :
                     GetCalcConfig().mbEmptyStringAsZero = bVal;
                 }
                 break;
+                case SCFORMULAOPT_OOXML_RECALC:
+                {
+                    ScRecalcOptions eOpt = RECALC_ASK;
+                    if (pValues[nProp] >>= nIntVal)
+                    {
+                        switch (nIntVal)
+                        {
+                            case 0:
+                                eOpt = RECALC_ALWAYS;
+                                break;
+                            case 1:
+                                eOpt = RECALC_ASK;
+                                break;
+                            case 2:
+                                eOpt = RECALC_NEVER;
+                                break;
+                            default:
+                                SAL_WARN("sc", "unknown ooxml recalc option!");
+                        }
+                    }
+
+                    SetOOXMLRecalcOptions(eOpt);
+                }
+                break;
                 default:
                     ;
                 }
@@ -414,6 +444,25 @@ void ScFormulaCfg::Commit()
                 pValues[nProp] <<= bVal;
             }
             break;
+            case SCFORMULAOPT_OOXML_RECALC:
+            {
+                sal_Int32 nVal = 1;
+                switch (GetOOXMLRecalcOptions())
+                {
+                    case RECALC_ALWAYS:
+                        nVal = 0;
+                        break;
+                    case RECALC_ASK:
+                        nVal = 1;
+                        break;
+                    case RECALC_NEVER:
+                        nVal = 2;
+                        break;
+                }
+
+                pValues[nProp] <<= nVal;
+            }
+            break;
             default:
                 ;
         }
diff --git a/sc/source/filter/oox/workbookfragment.cxx b/sc/source/filter/oox/workbookfragment.cxx
index 3c696b6..5c12d5b 100644
--- a/sc/source/filter/oox/workbookfragment.cxx
+++ b/sc/source/filter/oox/workbookfragment.cxx
@@ -48,6 +48,9 @@
 #include "docsh.hxx"
 #include "globstr.hrc"
 
+#include <comphelper/processfactory.hxx>
+#include <officecfg/Office/Calc.hxx>
+
 namespace oox {
 namespace xls {
 
@@ -315,18 +318,63 @@ void WorkbookFragment::finalizeImport()
     finalizeWorkbookImport();
 
     // Recalculate formula cells.
-    bool bHardRecalc = false;
     ScDocument& rDoc = getScDocument();
     ScDocShell* pDocSh = static_cast<ScDocShell*>(rDoc.GetDocumentShell());
-    if (rDoc.IsUserInteractionEnabled())
+    Reference< XComponentContext > xContext = comphelper::getProcessComponentContext();
+    sal_Int32 nRecalcMode = officecfg::Office::Calc::Formula::Load::OOXMLRecalcMode::get(xContext);
+    bool bHardRecalc = false;
+    if (nRecalcMode == 1)
     {
-        // Ask the user if full re-calculation is desired.
-        QueryBox aBox(
-            pDocSh->GetActiveDialogParent(), WinBits(WB_YES_NO | WB_DEF_YES),
-            ScGlobal::GetRscString(STR_QUERY_FORMULA_RECALC_ONLOAD_XLS));
+        if (rDoc.IsUserInteractionEnabled())
+        {
 
-        bHardRecalc = aBox.Execute() == RET_YES;
+#define RET_ALWAYS 10
+#define RET_NEVER 11
+            // Ask the user if full re-calculation is desired.
+            QueryBox aBox(
+                pDocSh->GetActiveDialogParent(), WinBits(WB_YES_NO | WB_DEF_YES),
+                ScGlobal::GetRscString(STR_QUERY_FORMULA_RECALC_ONLOAD_XLS));
+            aBox.AddButton(ScGlobal::GetRscString(STR_ALWAYS), RET_ALWAYS, 0);
+            aBox.AddButton(ScGlobal::GetRscString(STR_NEVER), RET_NEVER, 0);
+
+            boost::shared_ptr< comphelper::ConfigurationChanges > batch( comphelper::ConfigurationChanges::create() );
+            sal_Int32 nRet = aBox.Execute();
+            switch (nRet)
+            {
+                case RET_YES:
+                    bHardRecalc = true;
+                    break;
+                case RET_NO:
+                    bHardRecalc = false;
+                    break;
+                case RET_ALWAYS:
+                    {
+                        bHardRecalc = true;
+                        officecfg::Office::Calc::Formula::Load::OOXMLRecalcMode::set(sal_Int32(0), batch);
+                        ScFormulaOptions aOpt = SC_MOD()->GetFormulaOptions();
+                        aOpt.SetOOXMLRecalcOptions(RECALC_ALWAYS);
+                        SC_MOD()->SetFormulaOptions(aOpt);
+                    }
+                    break;
+                case RET_NEVER:
+                    {
+                        bHardRecalc = false;
+                        officecfg::Office::Calc::Formula::Load::OOXMLRecalcMode::set(sal_Int32(2), batch);
+                        ScFormulaOptions aOpt = SC_MOD()->GetFormulaOptions();
+                        aOpt.SetOOXMLRecalcOptions(RECALC_NEVER);
+                        SC_MOD()->SetFormulaOptions(aOpt);
+                    }
+                    break;
+                default:
+                    SAL_WARN("sc", "unknown return value!");
+                    bHardRecalc = true;
+            }
+            batch->commit();
+        }
     }
+    else if(nRecalcMode == 0)
+        bHardRecalc = true;
+
 
     if (bHardRecalc)
         pDocSh->DoHardRecalc(false);
diff --git a/sc/source/ui/inc/optdlg.hrc b/sc/source/ui/inc/optdlg.hrc
index 3b5b4e3..ed982c2 100644
--- a/sc/source/ui/inc/optdlg.hrc
+++ b/sc/source/ui/inc/optdlg.hrc
@@ -166,6 +166,8 @@
 #define BTN_CUSTOM_CALC_DEFAULT   93
 #define BTN_CUSTOM_CALC_CUSTOM    94
 #define BTN_CUSTOM_CALC_DETAILS   95
+#define FL_RECALC_OPTIONS         96
+#define LB_OOXML_RECALC           97
 
 // TP_COMPATIBILITY
 #define FL_KEY_BINDINGS       1
diff --git a/sc/source/ui/inc/tpformula.hxx b/sc/source/ui/inc/tpformula.hxx
index ff2ca27..646f429 100644
--- a/sc/source/ui/inc/tpformula.hxx
+++ b/sc/source/ui/inc/tpformula.hxx
@@ -75,6 +75,9 @@ private:
     RadioButton maBtnCustomCalcCustom;
     PushButton maBtnCustomCalcDetails;
 
+    FixedLine maFlRecalcOptions;
+    ListBox maLbOOXMLRecalcOptions;
+
     /** Stores old separator value of currently focused separator edit box.
         This value is used to revert undesired value change. */
     ::rtl::OUString maOldSepValue;
diff --git a/sc/source/ui/optdlg/tpformula.cxx b/sc/source/ui/optdlg/tpformula.cxx
index 663b1ee..5b60bd3 100644
--- a/sc/source/ui/optdlg/tpformula.cxx
+++ b/sc/source/ui/optdlg/tpformula.cxx
@@ -60,7 +60,8 @@ ScTpFormulaOptions::ScTpFormulaOptions(Window* pParent, const SfxItemSet& rCoreA
     maBtnCustomCalcDefault(this, ScResId(BTN_CUSTOM_CALC_DEFAULT)),
     maBtnCustomCalcCustom(this, ScResId(BTN_CUSTOM_CALC_CUSTOM)),
     maBtnCustomCalcDetails(this, ScResId(BTN_CUSTOM_CALC_DETAILS)),
-
+    maFlRecalcOptions(this, ScResId(FL_RECALC_OPTIONS)),
+    maLbOOXMLRecalcOptions( this, ScResId(LB_OOXML_RECALC)),
     mnDecSep(0)
 {
     maLbFormulaSyntax.InsertEntry(ScResId(SCSTR_FORMULA_SYNTAX_CALC_A1).toString());
@@ -245,6 +246,7 @@ sal_Bool ScTpFormulaOptions::FillItemSet(SfxItemSet& rCoreSet)
     OUString aSep             = maEdSepFuncArg.GetText();
     OUString aSepArrayCol     = maEdSepArrayCol.GetText();
     OUString aSepArrayRow     = maEdSepArrayRow.GetText();
+    sal_Int16 aOOXMLRecalcMode = maLbOOXMLRecalcOptions.GetSelectEntryPos();
 
     if (maBtnCustomCalcDefault.IsChecked())
     {
@@ -257,6 +259,7 @@ sal_Bool ScTpFormulaOptions::FillItemSet(SfxItemSet& rCoreSet)
          || static_cast<OUString>(maEdSepFuncArg.GetSavedValue()) != aSep
          || static_cast<OUString>(maEdSepArrayCol.GetSavedValue()) != aSepArrayCol
          || static_cast<OUString>(maEdSepArrayRow.GetSavedValue()) != aSepArrayRow
+         || maLbOOXMLRecalcOptions.GetSavedValue() != aOOXMLRecalcMode
          || maSavedConfig != maCurrentConfig )
     {
         ::formula::FormulaGrammar::Grammar eGram = ::formula::FormulaGrammar::GRAM_DEFAULT;
@@ -274,12 +277,27 @@ sal_Bool ScTpFormulaOptions::FillItemSet(SfxItemSet& rCoreSet)
         break;
         }
 
+        ScRecalcOptions eOOXMLRecalc = RECALC_ASK;
+        switch (aOOXMLRecalcMode)
+        {
+            case 0:
+                eOOXMLRecalc = RECALC_ALWAYS;
+                break;
+            case 1:
+                eOOXMLRecalc = RECALC_ASK;
+                break;
+            case 2:
+                eOOXMLRecalc = RECALC_NEVER;
+                break;
+        };
+
         aOpt.SetFormulaSyntax(eGram);
         aOpt.SetUseEnglishFuncName(bEnglishFuncName);
         aOpt.SetFormulaSepArg(aSep);
         aOpt.SetFormulaSepArrayCol(aSepArrayCol);
         aOpt.SetFormulaSepArrayRow(aSepArrayRow);
         aOpt.SetCalcConfig(maCurrentConfig);
+        aOpt.SetOOXMLRecalcOptions(eOOXMLRecalc);
 
         rCoreSet.Put( ScTpFormulaItem( SID_SCFORMULAOPTIONS, aOpt ) );
         bRet = true;
@@ -315,6 +333,23 @@ void ScTpFormulaOptions::Reset(const SfxItemSet& rCoreSet)
 
     maLbFormulaSyntax.SaveValue();
 
+    ScRecalcOptions eOOXMLRecalc = aOpt.GetOOXMLRecalcOptions();
+
+    switch (eOOXMLRecalc)
+    {
+        case RECALC_ALWAYS:
+            maLbOOXMLRecalcOptions.SelectEntryPos(0);
+            break;
+        case RECALC_ASK:
+            maLbOOXMLRecalcOptions.SelectEntryPos(1);
+            break;
+        case RECALC_NEVER:
+            maLbOOXMLRecalcOptions.SelectEntryPos(2);
+            break;
+    }
+
+    maLbOOXMLRecalcOptions.SaveValue();
+
     // english function name.
     maCbEnglishFuncName.Check( aOpt.GetUseEnglishFuncName() );
     maCbEnglishFuncName.SaveValue();
diff --git a/sc/source/ui/src/globstr.src b/sc/source/ui/src/globstr.src
index d4be6fa..88cb11c 100644
--- a/sc/source/ui/src/globstr.src
+++ b/sc/source/ui/src/globstr.src
@@ -1956,5 +1956,14 @@ Resource RID_GLOBSTR
     {
         Text [ en-US ] = "This document was last saved by Excel.  Some formula cells may produce different results when recalculated.\n\nDo you want to recalculate all formula cells now?";
     };
+
+    String STR_ALWAYS
+    {
+        Text [ en-US ] = "Always";
+    };
+    String STR_NEVER
+    {
+        Text [ en-US ] = "Never";
+    };
 };
 
diff --git a/sc/source/ui/src/optdlg.src b/sc/source/ui/src/optdlg.src
index 8253106..e3a1175 100644
--- a/sc/source/ui/src/optdlg.src
+++ b/sc/source/ui/src/optdlg.src
@@ -284,6 +284,25 @@ TabPage RID_SCPAGE_FORMULA
         Size = MAP_APPFONT ( 60, 14 ) ;
         Text [ en-US ] = "Details...";
     };
+    FixedLine FL_RECALC_OPTIONS
+    {
+        Pos = MAP_APPFONT ( 6, 178 );
+        Size = MAP_APPFONT( 248, 8 );
+        Text [ en-US ] = "Recalculation after laod settings";
+    };
+    ListBox LB_OOXML_RECALC
+    {
+        Pos = MAP_APPFONT( 21, 188);
+        Size = MAP_APPFONT( 100, 50 );
+        Border = TRUE;
+        DropDown = TRUE;
+        StringList [ en-US ] =
+        {
+            "Recalculate always";
+            "Ask before recalculation";
+            "Recalculate never";
+        };
+    };
 };
 
 TabPage RID_SCPAGE_COMPATIBILITY


More information about the Libreoffice-commits mailing list