[ooo-build-commit] patches/dev300

Kohei Yoshida kohei at kemper.freedesktop.org
Tue Dec 15 22:03:11 PST 2009


 patches/dev300/apply                                            |    9 
 patches/dev300/calc-formula-variable-sep-config-check-sc.diff   |  309 ++++++++++
 patches/dev300/calc-formula-variable-sep-config-check-sfx2.diff |   73 ++
 3 files changed, 390 insertions(+), 1 deletion(-)

New commits:
commit eec04d0d5c18838acdab3e071a91d2e9b9235393
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Wed Dec 16 00:46:04 2009 -0500

    Check for potential conflict between formula and decimal separators.
    
    See n#556142 for details.
    
    * patches/dev300/apply:
    
    * patches/dev300/calc-formula-variable-sep-config-check-sc.diff: handle
      option checking, and if needed, reset the formula separators to their
      default values.  When done, launch a nice warning dialog alerting the
      user of its action.
    
    * patches/dev300/calc-formula-variable-sep-config-check-sfx2.diff: adds
      new virtual method to SfxObjectModel, to handle config option checking
      and handling.

diff --git a/patches/dev300/apply b/patches/dev300/apply
index 0dccfde..426041e 100644
--- a/patches/dev300/apply
+++ b/patches/dev300/apply
@@ -3358,7 +3358,14 @@ svtools-embedemf.diff, i#107291, rodo
 
 [ CalcRowLimit ]
 
-# Improve import performance of dbf files by ~75%.
+# Improve import performance of dbf files by ~80%.
 calc-perf-import-dbf-connectivity.diff, n#558505, kohei
 calc-perf-import-dbf-dbaccess.diff,     n#558505, kohei
 calc-perf-import-dbf-sc.diff,           n#558505, kohei
+
+[ CalcFixes ]
+
+# Check for separator options' potential conflict with custom locale setting.
+calc-formula-variable-sep-config-check-sfx2.diff, n#556142, i#106959, kohei
+calc-formula-variable-sep-config-check-sc.diff,   n#556142, i#106959, kohei
+
diff --git a/patches/dev300/calc-formula-variable-sep-config-check-sc.diff b/patches/dev300/calc-formula-variable-sep-config-check-sc.diff
new file mode 100644
index 0000000..9d68484
--- /dev/null
+++ b/patches/dev300/calc-formula-variable-sep-config-check-sc.diff
@@ -0,0 +1,309 @@
+diff --git sc/inc/docoptio.hxx sc/inc/docoptio.hxx
+index 1184554..e95a9d0 100644
+--- sc/inc/docoptio.hxx
++++ sc/inc/docoptio.hxx
+@@ -120,7 +120,8 @@ public:
+     void SetFormulaSepArrayCol(const ::rtl::OUString& rSep) { aFormulaSepArrayCol = rSep; }
+     ::rtl::OUString GetFormulaSepArrayCol() const { return aFormulaSepArrayCol; }
+ 
+-    const LocaleDataWrapper& GetLocaleDataWrapper() const;
++    static void ResetFormulaSeparators(::rtl::OUString& rArgSep, ::rtl::OUString& rColSep, ::rtl::OUString& rRowSep);
++    static const LocaleDataWrapper& GetLocaleDataWrapper();
+ };
+ 
+ 
+diff --git sc/inc/globstr.hrc sc/inc/globstr.hrc
+index 8a72b7e..94e2b98 100644
+--- sc/inc/globstr.hrc
++++ sc/inc/globstr.hrc
+@@ -591,8 +591,10 @@
+ #define STR_FORM_DROPDOWN           448
+ #define STR_FORM_SPINNER            449
+ #define STR_FORM_SCROLLBAR          450
++
++#define STR_OPTIONS_WARN_SEPARATORS 451
+                                        
+-#define STR_COUNT                   451
++#define STR_COUNT                   452
+ 
+ #endif
+ 
+diff --git sc/source/core/tool/docoptio.cxx sc/source/core/tool/docoptio.cxx
+index b0188ee..f4c744e 100644
+--- sc/source/core/tool/docoptio.cxx
++++ sc/source/core/tool/docoptio.cxx
+@@ -140,63 +140,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();
++    ResetFormulaSeparators(aFormulaSepArg, aFormulaSepArrayCol, aFormulaSepArrayRow);
++}
+ 
+-        if (!rDecSep.getLength() || !rListSep.getLength())
+-            // Something is wrong.  Stick with the default separators.
+-            break;
++void ScDocOptions::ResetFormulaSeparators(OUString& rArgSep, OUString& rColSep, OUString& rRowSep)
++{
++    // Defaults to the old separator values.
++    rArgSep = OUString::createFromAscii(";");
++    rColSep = OUString::createFromAscii(";");
++    rRowSep = 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;
+ 
+-        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& 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.
++    rArgSep = 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.
++        rArgSep = OUString::createFromAscii(";");
++
++    rColSep = OUString::createFromAscii(",");
++    if (cDecSep == sal_Unicode(','))
++        rColSep = OUString::createFromAscii(".");
++    rRowSep = OUString::createFromAscii(";");
+ }
+ 
+-const LocaleDataWrapper& ScDocOptions::GetLocaleDataWrapper() const
++const LocaleDataWrapper& ScDocOptions::GetLocaleDataWrapper()
+ {
+     return *ScGlobal::pLocaleData;
+ }
+diff --git sc/source/ui/docshell/docsh6.cxx sc/source/ui/docshell/docsh6.cxx
+index e356bed..9a17f35 100644
+--- sc/source/ui/docshell/docsh6.cxx
++++ sc/source/ui/docshell/docsh6.cxx
+@@ -56,6 +56,30 @@
+ #include "tabvwsh.hxx"
+ #include "tablink.hxx"
+ #include "collect.hxx"
++#include "docoptio.hxx"
++#include "globstr.hrc"
++
++#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
+ {
+@@ -63,6 +87,12 @@ struct ScStylePair
+     SfxStyleSheetBase *pDest;
+ };
+ 
++inline OUString C2U(const char* s)
++{
++    return OUString::createFromAscii(s);
++}
++
++}
+ 
+ // STATIC DATA -----------------------------------------------------------
+ 
+@@ -469,4 +499,62 @@ BOOL ScDocShell::ReloadTabLinks()
+     return TRUE;		//! Fehler erkennen
+ }
+ 
++void ScDocShell::CheckConfigOptions()
++{
++    try
++    {
++        Reference<XMultiServiceFactory> xMSF = ::comphelper::getProcessServiceFactory();
++        Reference<XMultiServiceFactory> theConfigProvider = 
++            Reference<XMultiServiceFactory>(
++                xMSF->createInstance(C2U("com.sun.star.configuration.ConfigurationProvider")), UNO_QUERY_THROW);
++
++        Sequence<Any> theArgs(1);
++        theArgs[0] <<= C2U("org.openoffice.Office.Calc/Formula/Syntax");
++        Reference<XNameAccess> xNA = Reference<XNameAccess>(
++            theConfigProvider->createInstanceWithArguments(
++                C2U("com.sun.star.configuration.ConfigurationUpdateAccess"), theArgs), UNO_QUERY_THROW);
++
++        Reference<XPropertySet> xPropSet(xNA, UNO_QUERY_THROW);
++        OUString aSepArg, aSepArrRow, aSepArrCol;
++        xPropSet->getPropertyValue(C2U("SeparatorArg")) >>= aSepArg;
++        xPropSet->getPropertyValue(C2U("SeparatorArrayCol")) >>= aSepArrCol;
++        xPropSet->getPropertyValue(C2U("SeparatorArrayRow")) >>= aSepArrRow;
++
++        OUString aDecSep = ScGlobal::GetpLocaleData()->getNumDecimalSep();
++        if (aDecSep == aSepArg || aDecSep == aSepArrRow || aDecSep == aSepArrCol)
++        {
++            // One of arg separators conflicts with the current decimal
++            // separator.  Reset them to default.
++            ScDocOptions::ResetFormulaSeparators(aSepArg, aSepArrCol, aSepArrRow);
++            Any any;
++            any <<= aSepArg;
++            xPropSet->setPropertyValue(C2U("SeparatorArg"), any);
++            any <<= aSepArrCol;
++            xPropSet->setPropertyValue(C2U("SeparatorArrayCol"), any);
++            any <<= aSepArrRow;
++            xPropSet->setPropertyValue(C2U("SeparatorArrayRow"), any);
++            Reference<XChangesBatch>(xPropSet, UNO_QUERY_THROW)->commitChanges();
++
++            ::formula::FormulaCompiler::UpdateSeparatorsNative(aSepArg, aSepArrCol, aSepArrRow);
++
++            // 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.
++        }
++    }
++    catch (const Exception&)
++    {
++    }
++}
++
+ 
+diff --git sc/source/ui/docshell/makefile.mk sc/source/ui/docshell/makefile.mk
+index 00b6410..897458e 100644
+--- sc/source/ui/docshell/makefile.mk
++++ sc/source/ui/docshell/makefile.mk
+@@ -103,6 +103,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 sc/source/ui/inc/docsh.hxx sc/source/ui/inc/docsh.hxx
+index a317cfa..d999580 100644
+--- sc/source/ui/inc/docsh.hxx
++++ sc/source/ui/inc/docsh.hxx
+@@ -328,6 +328,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 sc/source/ui/src/globstr.src sc/source/ui/src/globstr.src
+index 0f48b1d..2d0fd78 100644
+--- sc/source/ui/src/globstr.src
++++ sc/source/ui/src/globstr.src
+@@ -1804,5 +1804,9 @@ Resource RID_GLOBSTR
+     {
+         Text [ en-US ] = "Page Styles";
+     };
++    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.";
++    };
+ };
+ 
+diff --git sc/source/ui/view/gridwin.cxx sc/source/ui/view/gridwin.cxx
+index 014dbde..a8a01e6 100644
+--- sc/source/ui/view/gridwin.cxx
++++ sc/source/ui/view/gridwin.cxx
+@@ -4577,6 +4577,7 @@ void __EXPORT ScGridWindow::GetFocus()
+                             //		  auf dem Mac
+     }
+ 
++    pViewData->GetDocShell()->CheckConfigOptions();
+     Window::GetFocus();
+ }
+ 
diff --git a/patches/dev300/calc-formula-variable-sep-config-check-sfx2.diff b/patches/dev300/calc-formula-variable-sep-config-check-sfx2.diff
new file mode 100644
index 0000000..e1f9b0b
--- /dev/null
+++ b/patches/dev300/calc-formula-variable-sep-config-check-sfx2.diff
@@ -0,0 +1,73 @@
+diff --git sfx2/inc/sfx2/objsh.hxx sfx2/inc/sfx2/objsh.hxx
+index 488acea..d87dff2 100644
+--- sfx2/inc/sfx2/objsh.hxx
++++ sfx2/inc/sfx2/objsh.hxx
+@@ -354,6 +354,11 @@ public:
+     virtual sal_Bool            SwitchPersistance(
+                                     const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage );
+     virtual void                UpdateLinks();
++    /** 
++     * Called when the Options dialog is dismissed with the OK button, to 
++     * handle potentially conflicting option settings.
++     */
++    virtual void                CheckConfigOptions();
+ 
+     sal_Bool                    SaveChildren(BOOL bObjectsOnly=FALSE);
+     sal_Bool                    SaveAsChildren( SfxMedium &rMedium );
+diff --git sfx2/source/appl/appserv.cxx sfx2/source/appl/appserv.cxx
+index b511170..04db6d4 100644
+--- sfx2/source/appl/appserv.cxx
++++ sfx2/source/appl/appserv.cxx
+@@ -855,6 +855,23 @@ namespace
+     }
+ }
+ 
++namespace {
++
++void inspectNewOptions()
++{
++    SfxViewFrame* pCurView = SfxViewFrame::Current();
++    if (!pCurView)
++        return;
++
++    SfxObjectShell* pShell = pCurView->GetObjectShell();
++    if (!pShell)
++        return;
++
++    pShell->CheckConfigOptions();
++}
++
++}
++
+ void SfxApplication::OfaExec_Impl( SfxRequest& rReq )
+ {
+     DBG_MEMTEST();
+@@ -876,7 +893,11 @@ void SfxApplication::OfaExec_Impl( SfxRequest& rReq )
+             {
+                 VclAbstractDialog* pDlg =
+                     pFact->CreateFrameDialog( NULL, xFrame, rReq.GetSlot(), sPageURL );
+-                  pDlg->Execute();
++                  if (pDlg->Execute() == RET_OK)
++                  {
++                      // Do extra sanity check for potentially clashing options.
++                      inspectNewOptions();
++                  }
+                   delete pDlg;
+                 SfxViewFrame* pView = SfxViewFrame::GetFirst();
+                 while ( pView )
+diff --git sfx2/source/doc/objstor.cxx sfx2/source/doc/objstor.cxx
+index e9856fe..5930374 100644
+--- sfx2/source/doc/objstor.cxx
++++ sfx2/source/doc/objstor.cxx
+@@ -4001,6 +4001,11 @@ void SfxObjectShell::UpdateLinks()
+ {
+ }
+ 
++void SfxObjectShell::CheckConfigOptions()
++{
++	// not implemented.
++}
++
+ sal_Bool SfxObjectShell::QuerySaveSizeExceededModules_Impl( const uno::Reference< task::XInteractionHandler >& xHandler )
+ {
+     if ( !HasBasic() )


More information about the ooo-build-commit mailing list