diff options
author | Kohei Yoshida <kyoshida@novell.com> | 2010-10-05 10:32:10 -0400 |
---|---|---|
committer | Kohei Yoshida <kyoshida@novell.com> | 2010-10-05 10:32:10 -0400 |
commit | 35c75a3c2f07c9662893af50789fd21586ccc88c (patch) | |
tree | 71aa09abceca6e8326884a0c70c73e9a859b3b8d /sc/source/ui | |
parent | 52dc6590c55a2edd17afd252789cc5606a594c4f (diff) |
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.
Diffstat (limited to 'sc/source/ui')
-rw-r--r-- | sc/source/ui/docshell/docsh6.cxx | 71 | ||||
-rw-r--r-- | sc/source/ui/docshell/makefile.mk | 1 | ||||
-rw-r--r-- | sc/source/ui/inc/docsh.hxx | 2 | ||||
-rw-r--r-- | sc/source/ui/src/globstr.src | 4 | ||||
-rw-r--r-- | sc/source/ui/view/gridwin.cxx | 1 |
5 files changed, 79 insertions, 0 deletions
diff --git a/sc/source/ui/docshell/docsh6.cxx b/sc/source/ui/docshell/docsh6.cxx index 93ac54726781..332811365814 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 99a7495b6b49..dcfd0429bd50 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 bae92e1c0cad..5c3d33ccb374 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 2fd50d5f97f3..6f0b1f1fd789 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 6c4f557a4453..67ea292086ed 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(); } |