[ooo-build-commit] .: sc/inc sc/source

Kohei Yoshida kohei at kemper.freedesktop.org
Tue Oct 5 07:34:57 PDT 2010


 sc/inc/docoptio.hxx               |    3 -
 sc/inc/globstr.hrc                |    4 +
 sc/source/core/tool/docoptio.cxx  |   97 ++++++++++++++++++--------------------
 sc/source/ui/docshell/docsh6.cxx  |   71 +++++++++++++++++++++++++++
 sc/source/ui/docshell/makefile.mk |    1 
 sc/source/ui/inc/docsh.hxx        |    2 
 sc/source/ui/src/globstr.src      |    4 +
 sc/source/ui/view/gridwin.cxx     |    1 
 8 files changed, 132 insertions(+), 51 deletions(-)

New commits:
commit 87af8ec8345117fd1cfcd05eb02bc5e4128a207a
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Tue Oct 5 10:32:10 2010 -0400

    Ported calc-formula-variable-sep-config-check-sc.diff from ooo-build.
    
    This code handles situations where the formula arg separator is in
    conflict with the locale specific decimal and/or thousand separators.

diff --git a/sc/inc/docoptio.hxx b/sc/inc/docoptio.hxx
index 76c9f2f..ac0c0ae 100644
--- a/sc/inc/docoptio.hxx
+++ b/sc/inc/docoptio.hxx
@@ -117,7 +117,8 @@ public:
     void SetFormulaSepArrayCol(const ::rtl::OUString& rSep) { aFormulaSepArrayCol = rSep; }
     ::rtl::OUString GetFormulaSepArrayCol() const { return aFormulaSepArrayCol; }
 
-    const LocaleDataWrapper& GetLocaleDataWrapper() const;
+    void ResetFormulaSeparators();
+    static const LocaleDataWrapper& GetLocaleDataWrapper();
 };
 
 
diff --git a/sc/inc/globstr.hrc b/sc/inc/globstr.hrc
index 560b437..7003ceb 100644
--- a/sc/inc/globstr.hrc
+++ b/sc/inc/globstr.hrc
@@ -578,7 +578,9 @@
 #define STR_UNDO_INSERT_CURRENT_DATE    440
 #define STR_UNDO_INSERT_CURRENT_TIME    441
 
-#define STR_COUNT                       442
+#define STR_OPTIONS_WARN_SEPARATORS     442
+
+#define STR_COUNT                       443
 
 #endif
 
diff --git a/sc/source/core/tool/docoptio.cxx b/sc/source/core/tool/docoptio.cxx
index 5b74ba5..195f3fb 100644
--- a/sc/source/core/tool/docoptio.cxx
+++ b/sc/source/core/tool/docoptio.cxx
@@ -137,63 +137,62 @@ void ScDocOptions::ResetDocOptions()
     bFormulaRegexEnabled= TRUE;
     eFormulaGrammar     = ::formula::FormulaGrammar::GRAM_NATIVE;
 
-    do
-    {
-        const Locale& rLocale = *ScGlobal::GetLocale();
-        const OUString& rLang = rLocale.Language;
-        if (rLang.equalsAscii("ru"))
-            // Don't do automatic guess for these languages, and fall back to
-            // the old separator set.
-            break;
-
-        const LocaleDataWrapper& rLocaleData = GetLocaleDataWrapper();
-        const OUString& rDecSep  = rLocaleData.getNumDecimalSep();
-        const OUString& rListSep = rLocaleData.getListSep();
-
-        if (!rDecSep.getLength() || !rListSep.getLength())
-            // Something is wrong.  Stick with the default separators.
-            break;
-
-        sal_Unicode cDecSep  = rDecSep.getStr()[0];
-        sal_Unicode cListSep = rListSep.getStr()[0];
-
-        // Excel by default uses system's list separator as the parameter
-        // separator, which in English locales is a comma.  However, OOo's list
-        // separator value is set to ';' for all English locales.  Because of this
-        // discrepancy, we will hardcode the separator value here, for now.
-        if (cDecSep == sal_Unicode('.'))
-            cListSep = sal_Unicode(',');
-
-        // Special case for de_CH locale.
-        if (rLocale.Language.equalsAsciiL("de", 2) && rLocale.Country.equalsAsciiL("CH", 2))
-            cListSep = sal_Unicode(';');
+    ResetFormulaSeparators();
+}
 
-        // by default, the parameter separator equals the locale-specific
-        // list separator.
-        aFormulaSepArg = OUString(cListSep);
+void ScDocOptions::ResetFormulaSeparators()
+{
+    // Defaults to the old separator values.
+    aFormulaSepArg = OUString::createFromAscii(";");
+    aFormulaSepArrayCol = OUString::createFromAscii(";");
+    aFormulaSepArrayRow = OUString::createFromAscii("|");
 
-        if (cDecSep == cListSep && cDecSep != sal_Unicode(';'))
-            // if the decimal and list separators are equal, set the
-            // parameter separator to be ';', unless they are both
-            // semicolon in which case don't change the decimal separator.
-            aFormulaSepArg = OUString::createFromAscii(";");
+    const Locale& rLocale = *ScGlobal::GetLocale();
+    const OUString& rLang = rLocale.Language;
+    if (rLang.equalsAscii("ru"))
+        // Don't do automatic guess for these languages, and fall back to
+        // the old separator set.
+        return;
 
-        aFormulaSepArrayCol = OUString::createFromAscii(",");
-        if (cDecSep == sal_Unicode(','))
-            aFormulaSepArrayCol = OUString::createFromAscii(".");
-        aFormulaSepArrayRow = OUString::createFromAscii(";");
+    const LocaleDataWrapper& rLocaleData = GetLocaleDataWrapper();
+    const OUString& rDecSep  = rLocaleData.getNumDecimalSep();
+    const OUString& rListSep = rLocaleData.getListSep();
 
+    if (!rDecSep.getLength() || !rListSep.getLength())
+        // Something is wrong.  Stick with the default separators.
         return;
-    }
-    while (false);
 
-    // Defaults to the old separator values.
-    aFormulaSepArg      = OUString::createFromAscii(";");
-    aFormulaSepArrayCol = OUString::createFromAscii(";");
-    aFormulaSepArrayRow = OUString::createFromAscii("|");
+    sal_Unicode cDecSep  = rDecSep.getStr()[0];
+    sal_Unicode cListSep = rListSep.getStr()[0];
+
+    // Excel by default uses system's list separator as the parameter
+    // separator, which in English locales is a comma.  However, OOo's list
+    // separator value is set to ';' for all English locales.  Because of this
+    // discrepancy, we will hardcode the separator value here, for now.
+    if (cDecSep == sal_Unicode('.'))
+        cListSep = sal_Unicode(',');
+
+    // Special case for de_CH locale.
+    if (rLocale.Language.equalsAsciiL("de", 2) && rLocale.Country.equalsAsciiL("CH", 2))
+        cListSep = sal_Unicode(';');
+
+    // by default, the parameter separator equals the locale-specific
+    // list separator.
+    aFormulaSepArg = OUString(cListSep);
+
+    if (cDecSep == cListSep && cDecSep != sal_Unicode(';'))
+        // if the decimal and list separators are equal, set the
+        // parameter separator to be ';', unless they are both
+        // semicolon in which case don't change the decimal separator.
+        aFormulaSepArg = OUString::createFromAscii(";");
+
+    aFormulaSepArrayCol = OUString::createFromAscii(",");
+    if (cDecSep == sal_Unicode(','))
+        aFormulaSepArrayCol = OUString::createFromAscii(".");
+    aFormulaSepArrayRow = OUString::createFromAscii(";");
 }
 
-const LocaleDataWrapper& ScDocOptions::GetLocaleDataWrapper() const
+const LocaleDataWrapper& ScDocOptions::GetLocaleDataWrapper()
 {
     return *ScGlobal::pLocaleData;
 }
diff --git a/sc/source/ui/docshell/docsh6.cxx b/sc/source/ui/docshell/docsh6.cxx
index c71658c..3dc6d5a 100644
--- a/sc/source/ui/docshell/docsh6.cxx
+++ b/sc/source/ui/docshell/docsh6.cxx
@@ -51,6 +51,31 @@
 #include "tabvwsh.hxx"
 #include "tablink.hxx"
 #include "collect.hxx"
+#include "docoptio.hxx"
+#include "globstr.hrc"
+#include "scmod.hxx"
+
+#include "formula/FormulaCompiler.hxx"
+#include "comphelper/processfactory.hxx"
+#include "vcl/msgbox.hxx"
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/util/XChangesBatch.hpp>
+
+using ::com::sun::star::beans::XPropertySet;
+using ::com::sun::star::lang::XMultiServiceFactory;
+using ::com::sun::star::container::XNameAccess;
+using ::com::sun::star::util::XChangesBatch;
+using ::com::sun::star::uno::Any;
+using ::com::sun::star::uno::Exception;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Sequence;
+using ::com::sun::star::uno::UNO_QUERY_THROW;
+using ::rtl::OUString;
+
+namespace {
 
 struct ScStylePair
 {
@@ -58,6 +83,12 @@ struct ScStylePair
     SfxStyleSheetBase *pDest;
 };
 
+inline OUString C2U(const char* s)
+{
+    return OUString::createFromAscii(s);
+}
+
+}
 
 // STATIC DATA -----------------------------------------------------------
 
@@ -457,4 +488,44 @@ BOOL ScDocShell::ReloadTabLinks()
     return TRUE;		//! Fehler erkennen
 }
 
+void ScDocShell::CheckConfigOptions()
+{
+    if (IsConfigOptionsChecked())
+        // no need to check repeatedly.
+        return;
+
+    OUString aDecSep = ScGlobal::GetpLocaleData()->getNumDecimalSep();
+
+    ScModule* pScMod = SC_MOD();
+    const ScDocOptions& rOpt = pScMod->GetDocOptions();
+    OUString aSepArg = rOpt.GetFormulaSepArg();
+    OUString aSepArrRow = rOpt.GetFormulaSepArrayRow();
+    OUString aSepArrCol = rOpt.GetFormulaSepArrayCol();
+
+    if (aDecSep == aSepArg || aDecSep == aSepArrRow || aDecSep == aSepArrCol)
+    {
+        // One of arg separators conflicts with the current decimal
+        // separator.  Reset them to default.
+        ScDocOptions aNew = rOpt;
+        aNew.ResetFormulaSeparators();
+        aDocument.SetDocOptions(aNew);
+        pScMod->SetDocOptions(aNew);
+
+        // Launch a nice warning dialog to let the users know of this change.
+        ScTabViewShell* pViewShell = GetBestViewShell();
+        if (pViewShell)
+        {
+            Window* pParent = pViewShell->GetFrameWin();
+            InfoBox aBox(pParent, ScGlobal::GetRscString(STR_OPTIONS_WARN_SEPARATORS));
+            aBox.Execute();
+        }
+
+        // For now, this is the only option setting that could launch info
+        // dialog.  But in the future we may want to implement a nicer
+        // dialog to display a list of warnings in case we have several
+        // pieces of information to display.
+    }
+
+    SetConfigOptionsChecked(true);
+}
 
diff --git a/sc/source/ui/docshell/makefile.mk b/sc/source/ui/docshell/makefile.mk
index 99a7495..dcfd042 100644
--- a/sc/source/ui/docshell/makefile.mk
+++ b/sc/source/ui/docshell/makefile.mk
@@ -98,6 +98,7 @@ EXCEPTIONSFILES= \
         $(SLO)$/docsh.obj \
         $(SLO)$/docsh3.obj	\
         $(SLO)$/docsh4.obj \
+        $(SLO)$/docsh6.obj \
         $(SLO)$/docsh8.obj \
         $(SLO)$/externalrefmgr.obj \
         $(SLO)$/dbdocimp.obj \
diff --git a/sc/source/ui/inc/docsh.hxx b/sc/source/ui/inc/docsh.hxx
index 5d39f9f..b04d55e 100644
--- a/sc/source/ui/inc/docsh.hxx
+++ b/sc/source/ui/inc/docsh.hxx
@@ -323,6 +323,8 @@ public:
     void			UpdateLinks();			// Link-Eintraege aktuallisieren
     BOOL			ReloadTabLinks();		// Links ausfuehren (Inhalt aktualisieren)
 
+    virtual void    CheckConfigOptions();
+
     void            PostEditView( ScEditEngineDefaulter* pEditEngine, const ScAddress& rCursorPos );
 
     void            PostPaint( SCCOL nStartCol, SCROW nStartRow, SCTAB nStartTab,
diff --git a/sc/source/ui/src/globstr.src b/sc/source/ui/src/globstr.src
index c769258..a022c66 100644
--- a/sc/source/ui/src/globstr.src
+++ b/sc/source/ui/src/globstr.src
@@ -1738,6 +1738,10 @@ Resource RID_GLOBSTR
     {
         Text [ en-US ] = "DataPilot table needs at least two rows of data to create or refresh." ;
     };
+    String STR_OPTIONS_WARN_SEPARATORS
+    {
+        Text [ en-US ] = "Because the current formula separator settings conflict with the locale, the formula separators have been reset to their default values.";
+    };
     String STR_UNDO_INSERT_CURRENT_DATE
     {
         Text [ en-US ] = "Insert Current Date";
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index 9e53b3c..b3c73b7 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -4592,6 +4592,7 @@ void __EXPORT ScGridWindow::GetFocus()
                             //		  auf dem Mac
     }
 
+    pViewData->GetDocShell()->CheckConfigOptions();
     Window::GetFocus();
 }
 


More information about the ooo-build-commit mailing list