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

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Thu Dec 20 11:43:05 PST 2012


 officecfg/registry/schema/org/openoffice/Office/Calc.xcs |   27 +++++++
 sc/inc/formulaopt.hxx                                    |    4 +
 sc/source/core/tool/formulaopt.cxx                       |   55 ++++++++++++++-
 sc/source/ui/docshell/docsh.cxx                          |   29 +++++--
 sc/source/ui/inc/optdlg.hrc                              |    5 +
 sc/source/ui/inc/tpformula.hxx                           |    3 
 sc/source/ui/optdlg/tpformula.cxx                        |   46 ++++--------
 sc/source/ui/src/optdlg.src                              |   31 ++++++++
 8 files changed, 156 insertions(+), 44 deletions(-)

New commits:
commit 3d21bda6a739a5a026fdaa6aa51aee563da75ca4
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Thu Dec 20 14:41:56 2012 -0500

    Make use of the recalc option when loading ODF documents.
    
    Change-Id: If33dd77c1b54cdfb5a8ff75c5b6e13db09b0c19f

diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx
index 1a7ec1a..9377f94 100644
--- a/sc/source/ui/docshell/docsh.cxx
+++ b/sc/source/ui/docshell/docsh.cxx
@@ -17,6 +17,8 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include "docsh.hxx"
+
 #include "scitems.hxx"
 #include <editeng/justifyitem.hxx>
 #include <sot/clsids.hxx>
@@ -92,11 +94,11 @@
 #include "tabprotection.hxx"
 #include "docparam.hxx"
 
-#include "docsh.hxx"
 #include "docshimp.hxx"
 #include "sizedev.hxx"
 #include <rtl/logfile.hxx>
 
+#include <officecfg/Office/Calc.hxx>
 #include <comphelper/processfactory.hxx>
 #include <comphelper/string.hxx>
 #include "uiitems.hxx"
@@ -428,17 +430,28 @@ sal_Bool ScDocShell::LoadXML( SfxMedium* pLoadMedium, const ::com::sun::star::un
     uno::Reference<document::XDocumentProperties> xDocProps = xDPS->getDocumentProperties();
     rtl::OUString sGenerator = xDocProps->getGenerator();
 
+    Reference<uno::XComponentContext> xContext = comphelper::getProcessComponentContext();
+    ScRecalcOptions nRecalcMode =
+        static_cast<ScRecalcOptions>(officecfg::Office::Calc::Formula::Load::ODFRecalcMode::get(xContext));
+
     bool bHardRecalc = false;
-    if (aDocument.IsUserInteractionEnabled() && xDocProps->getGenerator().indexOf("LibreOffice") == -1)
+    if (nRecalcMode == RECALC_ASK)
     {
-        // Generator is not LibreOffice.  Ask if the user wants to perform
-        // full re-calculation.
-        QueryBox aBox(
-            GetActiveDialogParent(), WinBits(WB_YES_NO | WB_DEF_YES),
-            ScGlobal::GetRscString(STR_QUERY_FORMULA_RECALC_ONLOAD_ODS));
+        if (aDocument.IsUserInteractionEnabled() && xDocProps->getGenerator().indexOf("LibreOffice") == -1)
+        {
+            // Generator is not LibreOffice.  Ask if the user wants to perform
+            // full re-calculation.
+            QueryBox aBox(
+                GetActiveDialogParent(), WinBits(WB_YES_NO | WB_DEF_YES),
+                ScGlobal::GetRscString(STR_QUERY_FORMULA_RECALC_ONLOAD_ODS));
 
-        bHardRecalc = aBox.Execute() == RET_YES;
+            bHardRecalc = aBox.Execute() == RET_YES;
+        }
     }
+    else if (nRecalcMode == RECALC_ALWAYS)
+        bHardRecalc = true;
+
+    fprintf(stdout, "ScDocShell::LoadXML:   hard recalc = %d\n", bHardRecalc);
 
     if (bHardRecalc)
         DoHardRecalc(false);
commit 8bba6a94a470224171df1abba697ca5d82d6167b
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Thu Dec 20 14:32:04 2012 -0500

    Add ODF recalc option bits to the UI and configuration.
    
    Change-Id: I2a72956f3e91b650b7434c676722d34b2f3394e4

diff --git a/sc/inc/formulaopt.hxx b/sc/inc/formulaopt.hxx
index fe585fe..ff56096 100644
--- a/sc/inc/formulaopt.hxx
+++ b/sc/inc/formulaopt.hxx
@@ -49,6 +49,7 @@ private:
     ::rtl::OUString aFormulaSepArrayCol;
 
     ScRecalcOptions meOOXMLRecalc;
+    ScRecalcOptions meODFRecalc;
 
 public:
     ScFormulaOptions();
@@ -79,6 +80,9 @@ public:
     void SetOOXMLRecalcOptions( ScRecalcOptions eOpt ) { meOOXMLRecalc = eOpt; }
     ScRecalcOptions GetOOXMLRecalcOptions() const { return meOOXMLRecalc; }
 
+    void SetODFRecalcOptions( ScRecalcOptions eOpt ) { meODFRecalc = eOpt; }
+    ScRecalcOptions GetODFRecalcOptions() const { return meODFRecalc; }
+
     void ResetFormulaSeparators();
 
     static void GetDefaultFormulaSeparators(rtl::OUString& rSepArg, rtl::OUString& rSepArrayCol, rtl::OUString& rSepArrayRow);
diff --git a/sc/source/core/tool/formulaopt.cxx b/sc/source/core/tool/formulaopt.cxx
index a14463b..3dc9938 100644
--- a/sc/source/core/tool/formulaopt.cxx
+++ b/sc/source/core/tool/formulaopt.cxx
@@ -59,7 +59,8 @@ ScFormulaOptions::ScFormulaOptions( const ScFormulaOptions& rCpy ) :
     aFormulaSepArg      ( rCpy.aFormulaSepArg ),
     aFormulaSepArrayRow ( rCpy.aFormulaSepArrayRow ),
     aFormulaSepArrayCol ( rCpy.aFormulaSepArrayCol ),
-    meOOXMLRecalc       ( rCpy.meOOXMLRecalc )
+    meOOXMLRecalc       ( rCpy.meOOXMLRecalc ),
+    meODFRecalc         ( rCpy.meODFRecalc )
 {
 }
 
@@ -72,6 +73,7 @@ void ScFormulaOptions::SetDefaults()
     bUseEnglishFuncName = false;
     eFormulaGrammar     = ::formula::FormulaGrammar::GRAM_NATIVE;
     meOOXMLRecalc = RECALC_ASK;
+    meODFRecalc = RECALC_ASK;
 
     // unspecified means use the current formula syntax.
     aCalcConfig.reset();
@@ -151,6 +153,7 @@ ScFormulaOptions& ScFormulaOptions::operator=( const ScFormulaOptions& rCpy )
     aFormulaSepArrayRow = rCpy.aFormulaSepArrayRow;
     aFormulaSepArrayCol = rCpy.aFormulaSepArrayCol;
     meOOXMLRecalc       = rCpy.meOOXMLRecalc;
+    meODFRecalc         = rCpy.meODFRecalc;
     return *this;
 }
 
@@ -162,7 +165,8 @@ bool ScFormulaOptions::operator==( const ScFormulaOptions& rOpt ) const
         && aFormulaSepArg      == rOpt.aFormulaSepArg
         && aFormulaSepArrayRow == rOpt.aFormulaSepArrayRow
         && aFormulaSepArrayCol == rOpt.aFormulaSepArrayCol
-        && meOOXMLRecalc       == rOpt.meOOXMLRecalc;
+        && meOOXMLRecalc       == rOpt.meOOXMLRecalc
+        && meODFRecalc         == rOpt.meODFRecalc;
 }
 
 bool ScFormulaOptions::operator!=( const ScFormulaOptions& rOpt ) const
@@ -219,7 +223,8 @@ SfxPoolItem* ScTpFormulaItem::Clone( SfxItemPool * ) const
 #define SCFORMULAOPT_STRING_REF_SYNTAX    5
 #define SCFORMULAOPT_EMPTY_STRING_AS_ZERO 6
 #define SCFORMULAOPT_OOXML_RECALC         7
-#define SCFORMULAOPT_COUNT                8
+#define SCFORMULAOPT_ODF_RECALC           8
+#define SCFORMULAOPT_COUNT                9
 
 Sequence<OUString> ScFormulaCfg::GetPropertyNames()
 {
@@ -233,6 +238,7 @@ Sequence<OUString> ScFormulaCfg::GetPropertyNames()
         "Syntax/StringRefAddressSyntax", // SCFORMULAOPT_STRING_REF_SYNTAX
         "Syntax/EmptyStringAsZero",      // SCFORMULAOPT_EMPTY_STRING_AS_ZERO
         "Load/OOXMLRecalcMode",          // SCFORMULAOPT_OOXML_RECALC
+        "Load/ODFRecalcMode",            // SCFORMULAOPT_ODF_RECALC
     };
     Sequence<OUString> aNames(SCFORMULAOPT_COUNT);
     OUString* pNames = aNames.getArray();
@@ -380,6 +386,30 @@ ScFormulaCfg::ScFormulaCfg() :
                     SetOOXMLRecalcOptions(eOpt);
                 }
                 break;
+                case SCFORMULAOPT_ODF_RECALC:
+                {
+                    ScRecalcOptions eOpt = RECALC_ASK;
+                    if (pValues[nProp] >>= nIntVal)
+                    {
+                        switch (nIntVal)
+                        {
+                            case 0:
+                                eOpt = RECALC_ALWAYS;
+                                break;
+                            case 1:
+                                eOpt = RECALC_NEVER;
+                                break;
+                            case 2:
+                                eOpt = RECALC_ASK;
+                                break;
+                            default:
+                                SAL_WARN("sc", "unknown odf recalc option!");
+                        }
+                    }
+
+                    SetODFRecalcOptions(eOpt);
+                }
+                break;
                 default:
                     ;
                 }
@@ -463,6 +493,25 @@ void ScFormulaCfg::Commit()
                 pValues[nProp] <<= nVal;
             }
             break;
+            case SCFORMULAOPT_ODF_RECALC:
+            {
+                sal_Int32 nVal = 2;
+                switch (GetODFRecalcOptions())
+                {
+                    case RECALC_ALWAYS:
+                        nVal = 0;
+                        break;
+                    case RECALC_NEVER:
+                        nVal = 1;
+                        break;
+                    case RECALC_ASK:
+                        nVal = 2;
+                        break;
+                }
+
+                pValues[nProp] <<= nVal;
+            }
+            break;
             default:
                 ;
         }
diff --git a/sc/source/ui/inc/optdlg.hrc b/sc/source/ui/inc/optdlg.hrc
index ed982c2..a1c8e0a 100644
--- a/sc/source/ui/inc/optdlg.hrc
+++ b/sc/source/ui/inc/optdlg.hrc
@@ -167,7 +167,10 @@
 #define BTN_CUSTOM_CALC_CUSTOM    94
 #define BTN_CUSTOM_CALC_DETAILS   95
 #define FL_RECALC_OPTIONS         96
-#define LB_OOXML_RECALC           97
+#define FT_OOXML_RECALC           97
+#define LB_OOXML_RECALC           98
+#define FT_ODF_RECALC             99
+#define LB_ODF_RECALC            100
 
 // TP_COMPATIBILITY
 #define FL_KEY_BINDINGS       1
diff --git a/sc/source/ui/inc/tpformula.hxx b/sc/source/ui/inc/tpformula.hxx
index 55ea854..b895235 100644
--- a/sc/source/ui/inc/tpformula.hxx
+++ b/sc/source/ui/inc/tpformula.hxx
@@ -76,7 +76,10 @@ private:
     PushButton maBtnSepReset;
 
     FixedLine maFlRecalcOptions;
+    FixedText maFtOOXMLRecalc;
     ListBox maLbOOXMLRecalcOptions;
+    FixedText maFtODFRecalc;
+    ListBox maLbODFRecalcOptions;
 
     /** Stores old separator value of currently focused separator edit box.
         This value is used to revert undesired value change. */
diff --git a/sc/source/ui/optdlg/tpformula.cxx b/sc/source/ui/optdlg/tpformula.cxx
index ba34d6f..800ab62 100644
--- a/sc/source/ui/optdlg/tpformula.cxx
+++ b/sc/source/ui/optdlg/tpformula.cxx
@@ -63,7 +63,10 @@ ScTpFormulaOptions::ScTpFormulaOptions(Window* pParent, const SfxItemSet& rCoreA
     maEdSepArrayRow(this, ScResId(ED_FORMULA_SEP_ARRAY_R)),
     maBtnSepReset(this, ScResId(BTN_FORMULA_SEP_RESET)),
     maFlRecalcOptions(this, ScResId(FL_RECALC_OPTIONS)),
-    maLbOOXMLRecalcOptions( this, ScResId(LB_OOXML_RECALC)),
+    maFtOOXMLRecalc(this, ScResId(FT_OOXML_RECALC)),
+    maLbOOXMLRecalcOptions(this, ScResId(LB_OOXML_RECALC)),
+    maFtODFRecalc(this, ScResId(FT_ODF_RECALC)),
+    maLbODFRecalcOptions(this, ScResId(LB_ODF_RECALC)),
     mnDecSep(0)
 {
     maLbFormulaSyntax.InsertEntry(ScResId(SCSTR_FORMULA_SYNTAX_CALC_A1).toString());
@@ -248,7 +251,8 @@ sal_Bool ScTpFormulaOptions::FillItemSet(SfxItemSet& rCoreSet)
     OUString aSep             = maEdSepFuncArg.GetText();
     OUString aSepArrayCol     = maEdSepArrayCol.GetText();
     OUString aSepArrayRow     = maEdSepArrayRow.GetText();
-    sal_Int16 aOOXMLRecalcMode = maLbOOXMLRecalcOptions.GetSelectEntryPos();
+    sal_Int16 nOOXMLRecalcMode = maLbOOXMLRecalcOptions.GetSelectEntryPos();
+    sal_Int16 nODFRecalcMode = maLbODFRecalcOptions.GetSelectEntryPos();
 
     if (maBtnCustomCalcDefault.IsChecked())
     {
@@ -261,7 +265,8 @@ 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
+         || maLbOOXMLRecalcOptions.GetSavedValue() != nOOXMLRecalcMode
+         || maLbODFRecalcOptions.GetSavedValue() != nODFRecalcMode
          || maSavedConfig != maCurrentConfig )
     {
         ::formula::FormulaGrammar::Grammar eGram = ::formula::FormulaGrammar::GRAM_DEFAULT;
@@ -279,19 +284,8 @@ sal_Bool ScTpFormulaOptions::FillItemSet(SfxItemSet& rCoreSet)
         break;
         }
 
-        ScRecalcOptions eOOXMLRecalc = RECALC_ASK;
-        switch (aOOXMLRecalcMode)
-        {
-            case 0:
-                eOOXMLRecalc = RECALC_ALWAYS;
-                break;
-            case 1:
-                eOOXMLRecalc = RECALC_NEVER;
-                break;
-            case 2:
-                eOOXMLRecalc = RECALC_ASK;
-                break;
-        };
+        ScRecalcOptions eOOXMLRecalc = static_cast<ScRecalcOptions>(nOOXMLRecalcMode);
+        ScRecalcOptions eODFRecalc = static_cast<ScRecalcOptions>(nODFRecalcMode);
 
         aOpt.SetFormulaSyntax(eGram);
         aOpt.SetUseEnglishFuncName(bEnglishFuncName);
@@ -300,6 +294,7 @@ sal_Bool ScTpFormulaOptions::FillItemSet(SfxItemSet& rCoreSet)
         aOpt.SetFormulaSepArrayRow(aSepArrayRow);
         aOpt.SetCalcConfig(maCurrentConfig);
         aOpt.SetOOXMLRecalcOptions(eOOXMLRecalc);
+        aOpt.SetODFRecalcOptions(eODFRecalc);
 
         rCoreSet.Put( ScTpFormulaItem( SID_SCFORMULAOPTIONS, aOpt ) );
         bRet = true;
@@ -336,22 +331,13 @@ void ScTpFormulaOptions::Reset(const SfxItemSet& rCoreSet)
     maLbFormulaSyntax.SaveValue();
 
     ScRecalcOptions eOOXMLRecalc = aOpt.GetOOXMLRecalcOptions();
-
-    switch (eOOXMLRecalc)
-    {
-        case RECALC_ALWAYS:
-            maLbOOXMLRecalcOptions.SelectEntryPos(0);
-            break;
-        case RECALC_NEVER:
-            maLbOOXMLRecalcOptions.SelectEntryPos(1);
-            break;
-        case RECALC_ASK:
-            maLbOOXMLRecalcOptions.SelectEntryPos(2);
-            break;
-    }
-
+    maLbOOXMLRecalcOptions.SelectEntryPos(static_cast<sal_uInt16>(eOOXMLRecalc));
     maLbOOXMLRecalcOptions.SaveValue();
 
+    ScRecalcOptions eODFRecalc = aOpt.GetODFRecalcOptions();
+    maLbODFRecalcOptions.SelectEntryPos(static_cast<sal_uInt16>(eODFRecalc));
+    maLbODFRecalcOptions.SaveValue();
+
     // english function name.
     maCbEnglishFuncName.Check( aOpt.GetUseEnglishFuncName() );
     maCbEnglishFuncName.SaveValue();
diff --git a/sc/source/ui/src/optdlg.src b/sc/source/ui/src/optdlg.src
index e1c5a28..4f6f5ab 100644
--- a/sc/source/ui/src/optdlg.src
+++ b/sc/source/ui/src/optdlg.src
@@ -291,9 +291,38 @@ TabPage RID_SCPAGE_FORMULA
         Size = MAP_APPFONT( 248, 8 );
         Text [ en-US ] = "Recalculation on file load";
     };
+
+    FixedText FT_OOXML_RECALC
+    {
+        Pos = MAP_APPFONT ( 21, 149 );
+        Size = MAP_APPFONT ( 120, 8 );
+        Text [ en-US ] = "Excel 2007 and newer";
+    };
+
     ListBox LB_OOXML_RECALC
     {
-        Pos = MAP_APPFONT( 21, 147 );
+        Pos = MAP_APPFONT( 151, 147 );
+        Size = MAP_APPFONT( 80, 50 );
+        Border = TRUE;
+        DropDown = TRUE;
+        StringList [ en-US ] =
+        {
+            "Always recalculate";
+            "Never recalculate";
+            "Prompt user";
+        };
+    };
+
+    FixedText FT_ODF_RECALC
+    {
+        Pos = MAP_APPFONT ( 21, 165 );
+        Size = MAP_APPFONT ( 120, 8 );
+        Text [ en-US ] = "ODF Spreadsheet (not saved by LibreOffice)";
+    };
+
+    ListBox LB_ODF_RECALC
+    {
+        Pos = MAP_APPFONT( 151, 163 );
         Size = MAP_APPFONT( 80, 50 );
         Border = TRUE;
         DropDown = TRUE;
commit aa5e5de62dd80a4c8be64f809d1607c4d7407fa4
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Thu Dec 20 12:50:29 2012 -0500

    Add new option for recalculation policy when loading ODF into Calc.
    
    This applies only to those documents that are generated by non-LibreOffice
    applications.
    
    Change-Id: I98a7877df36c5de74e4f6f6d09a67e171cbab4a3

diff --git a/officecfg/registry/schema/org/openoffice/Office/Calc.xcs b/officecfg/registry/schema/org/openoffice/Office/Calc.xcs
index cc61d83..ee5c513 100644
--- a/officecfg/registry/schema/org/openoffice/Office/Calc.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/Calc.xcs
@@ -1514,7 +1514,32 @@
                     <!-- UIHint: Tools - Options - Spreadsheet - Formula -->
                     <info>
                         <author>Markus Mohrhard</author>
-                        <desc>Specifies whether to force a hard recalc after load</desc>
+                        <desc>Specifies whether to force a hard recalc after load on OOXML-based Excel documents (2007 and newer).</desc>
+                    </info>
+                    <constraints>
+                        <enumeration oor:value="0">
+                            <info>
+                                <desc>Recalc always</desc>
+                            </info>
+                        </enumeration>
+                        <enumeration oor:value="1">
+                            <info>
+                                <desc>Recalc never</desc>
+                            </info>
+                        </enumeration>
+                        <enumeration oor:value="2">
+                            <info>
+                                <desc>Ask before Recalc</desc>
+                            </info>
+                        </enumeration>
+                    </constraints>
+                    <value>1</value>
+                </prop>
+                <prop oor:name="ODFRecalcMode" oor:type="xs:int" oor:nillable="false">
+                    <!-- UIHint: Tools - Options - Spreadsheet - Formula -->
+                    <info>
+                        <author>Kohei Yoshida</author>
+                        <desc>Specifies whether to force a hard recalc after load on non-LibreOffice-generated ODF documents.</desc>
                     </info>
                     <constraints>
                         <enumeration oor:value="0">


More information about the Libreoffice-commits mailing list