summaryrefslogtreecommitdiff
path: root/unotools
diff options
context:
space:
mode:
authorMathias Bauer <mba@openoffice.org>2009-10-12 11:49:13 +0200
committerMathias Bauer <mba@openoffice.org>2009-10-12 11:49:13 +0200
commit9a4d0581c72653e60562d1b8e2121772d21f8a9e (patch)
treec6c31d21be1d0489ecec6d49496d45cc4ebdfb50 /unotools
parente0cea8e136b36724c6b1298e6546a4dbb8f09d00 (diff)
#i103496#: move SysLocale stuff to unotools
Diffstat (limited to 'unotools')
-rw-r--r--unotools/inc/unotools/configitem.hxx1
-rw-r--r--unotools/inc/unotools/misccfg.hxx70
-rw-r--r--unotools/inc/unotools/options.hxx3
-rw-r--r--unotools/inc/unotools/syslocale.hxx82
-rw-r--r--unotools/inc/unotools/syslocaleoptions.hxx162
-rw-r--r--unotools/source/config/configitem.cxx1
-rw-r--r--unotools/source/config/itemholder1.cxx10
-rw-r--r--unotools/source/config/makefile.mk2
-rw-r--r--unotools/source/config/misccfg.cxx312
-rw-r--r--unotools/source/config/options.cxx23
-rw-r--r--unotools/source/config/syslocaleoptions.cxx584
-rw-r--r--unotools/source/config/undoopt.cxx4
-rw-r--r--unotools/source/config/useroptions.cxx4
-rw-r--r--unotools/source/misc/makefile.mk1
-rw-r--r--unotools/source/misc/syslocale.cxx205
15 files changed, 1450 insertions, 14 deletions
diff --git a/unotools/inc/unotools/configitem.hxx b/unotools/inc/unotools/configitem.hxx
index 2af7a089bb54..0e938cedd47f 100644
--- a/unotools/inc/unotools/configitem.hxx
+++ b/unotools/inc/unotools/configitem.hxx
@@ -88,7 +88,6 @@ namespace utl
com::sun::star::uno::Reference< com::sun::star::util::XChangesListener >
xChangeLstnr;
ConfigItem_Impl* pImpl;
- IMPL_ConfigurationListenerList* mpList;
ConfigItem();//
void RemoveChangesListener();
diff --git a/unotools/inc/unotools/misccfg.hxx b/unotools/inc/unotools/misccfg.hxx
new file mode 100644
index 000000000000..2a1383d307a5
--- /dev/null
+++ b/unotools/inc/unotools/misccfg.hxx
@@ -0,0 +1,70 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: misccfg.hxx,v $
+ * $Revision: 1.5 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _UTL_MISCCFG_HXX
+#define _UTL_MISCCFG_HXX
+
+#include "unotools/unotoolsdllapi.h"
+#include "tools/solar.h"
+#include "unotools/options.hxx"
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+namespace utl
+{
+ class SfxMiscCfg;
+
+class UNOTOOLS_DLLPUBLIC MiscCfg : public detail::Options
+{
+ SfxMiscCfg* pImpl;
+
+public:
+ MiscCfg( );
+ virtual ~MiscCfg( );
+
+ BOOL IsNotFoundWarning() const;
+ void SetNotFoundWarning( BOOL bSet);
+
+ BOOL IsPaperSizeWarning() const;
+ void SetPaperSizeWarning(BOOL bSet);
+
+ BOOL IsPaperOrientationWarning() const;
+ void SetPaperOrientationWarning( BOOL bSet);
+
+ // 0 ... 99
+ sal_Int32 GetYear2000() const;
+ void SetYear2000( sal_Int32 nSet );
+};
+
+};
+
+#endif // _MISCCFG_HXX
+
+
diff --git a/unotools/inc/unotools/options.hxx b/unotools/inc/unotools/options.hxx
index 6e3b40075a04..ca8d70657f0f 100644
--- a/unotools/inc/unotools/options.hxx
+++ b/unotools/inc/unotools/options.hxx
@@ -48,12 +48,15 @@ namespace utl {
class UNOTOOLS_DLLPUBLIC ConfigurationBroadcaster
{
IMPL_ConfigurationListenerList* mpList;
+ sal_Int32 m_nBroadcastBlocked; // broadcast only if this is 0
+
public:
void AddListener( utl::ConfigurationListener* pListener );
void RemoveListener( utl::ConfigurationListener* pListener );
void NotifyListeners();
ConfigurationBroadcaster();
~ConfigurationBroadcaster();
+ void BlockBroadcasts( bool bBlock );
};
namespace detail {
diff --git a/unotools/inc/unotools/syslocale.hxx b/unotools/inc/unotools/syslocale.hxx
new file mode 100644
index 000000000000..87482abbb117
--- /dev/null
+++ b/unotools/inc/unotools/syslocale.hxx
@@ -0,0 +1,82 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: syslocale.hxx,v $
+ * $Revision: 1.3 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef INCLUDED_SVTOOLS_SYSLOCALE_HXX
+#define INCLUDED_SVTOOLS_SYSLOCALE_HXX
+
+#include "unotools/unotoolsdllapi.h"
+#include <unotools/localedatawrapper.hxx>
+#include <unotools/charclass.hxx>
+#include <sal/types.h>
+#include <i18npool/lang.h>
+
+class SvtSysLocale_Impl;
+class SvtSysLocaleOptions;
+
+namespace osl { class Mutex; }
+class LocaleDataWrapper;
+
+/**
+ SvtSysLocale provides a refcounted single instance of an application wide
+ <type>LocaleDataWrapper</type> and <type>CharClass</type> which always
+ follow the locale as it is currently configured by the user. You may use
+ it anywhere to access the locale data elements like decimal separator and
+ simple date formatting and so on. Contructing and destructing a
+ SvtSysLocale is not expensive as long as there is at least one instance
+ left.
+ */
+class UNOTOOLS_DLLPUBLIC SvtSysLocale
+{
+ friend class SvtSysLocale_Impl; // access to mutex
+
+ static SvtSysLocale_Impl* pImpl;
+ static sal_Int32 nRefCount;
+
+ UNOTOOLS_DLLPRIVATE static ::osl::Mutex& GetMutex();
+
+public:
+ SvtSysLocale();
+ ~SvtSysLocale();
+
+ const LocaleDataWrapper& GetLocaleData() const;
+ const CharClass& GetCharClass() const;
+
+ /** It is safe to store the pointers locally and use them AS LONG AS THE
+ INSTANCE OF SvtSysLocale LIVES!
+ It is a faster access but be sure what you do!
+ */
+ const LocaleDataWrapper* GetLocaleDataPtr() const;
+ const CharClass* GetCharClassPtr() const;
+ SvtSysLocaleOptions& GetOptions() const;
+ com::sun::star::lang::Locale GetLocale() const;
+ LanguageType GetLanguage() const;
+};
+
+#endif // INCLUDED_SVTOOLS_SYSLOCALE_HXX
diff --git a/unotools/inc/unotools/syslocaleoptions.hxx b/unotools/inc/unotools/syslocaleoptions.hxx
new file mode 100644
index 000000000000..6c48c83a8500
--- /dev/null
+++ b/unotools/inc/unotools/syslocaleoptions.hxx
@@ -0,0 +1,162 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: syslocaleoptions.hxx,v $
+ * $Revision: 1.3 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef INCLUDED_SVTOOLS_SYSLOCALEOPTIONS_HXX
+#define INCLUDED_SVTOOLS_SYSLOCALEOPTIONS_HXX
+
+#include "unotools/unotoolsdllapi.h"
+#include <sal/types.h>
+#include <rtl/ustring.hxx>
+#include <tools/solar.h>
+#include <tools/link.hxx>
+#include <i18npool/lang.h>
+#include <tools/string.hxx>
+#include <unotools/options.hxx>
+
+// bits for broadcasting hints of changes in a SfxSimpleHint, may be combined
+const ULONG SYSLOCALEOPTIONS_HINT_LOCALE = 0x00000001;
+const ULONG SYSLOCALEOPTIONS_HINT_CURRENCY = 0x00000002;
+
+class SvtSysLocaleOptions_Impl;
+class SvtListener;
+namespace osl { class Mutex; }
+
+class UNOTOOLS_DLLPUBLIC SvtSysLocaleOptions: public utl::detail::Options
+{
+ static SvtSysLocaleOptions_Impl* pOptions;
+ static sal_Int32 nRefCount;
+
+ UNOTOOLS_DLLPRIVATE static ::osl::Mutex& GetMutex();
+
+public:
+
+ enum EOption
+ {
+ E_LOCALE,
+ E_CURRENCY
+ };
+ SvtSysLocaleOptions();
+ virtual ~SvtSysLocaleOptions();
+
+ // ConfigItem methods
+
+ sal_Bool IsModified();
+ void Commit();
+
+ /** Add a listener to react on config changes
+ which are broadcasted in a SfxSimpleHint
+ @return
+ <TRUE/> if added
+ <FALSE/> if not added
+ */
+
+ /** Block broadcasts and accumulate hints. This may be useful if, for
+ example, the locale and currency are changed and the currency was
+ empty before, since changing the locale with an empty currency does
+ also broadcast a change hint for the currency which would result in
+ two currency changes broadcasted.
+
+ @param bBlock
+ <TRUE/>: broadcasts are blocked until reversed.
+ <FALSE/>: broadcasts are not blocked anymore. Pending hints are
+ broadcasted if no other instance blocks the broadcast.
+
+ @ATTENTION
+ All SvtSysLocaleOptions instances point to exactly one refcounted
+ internal representation instance and broadcast blocks are counted.
+ Thus if you issue a BlockBroadcasts(TRUE) you MUST issue a matching
+ BlockBroadcasts(FALSE) or otherwise pending hints would never be
+ broadcasted again.
+ */
+ void BlockBroadcasts( BOOL bBlock );
+
+ // config value access methods
+
+ /// The config string may be empty to denote the SYSTEM locale
+ const ::rtl::OUString& GetLocaleConfigString() const;
+ void SetLocaleConfigString( const ::rtl::OUString& rStr );
+
+ /// The config string may be empty to denote the default currency of the locale
+ const ::rtl::OUString& GetCurrencyConfigString() const;
+ void SetCurrencyConfigString( const ::rtl::OUString& rStr );
+ // determine whether the decimal separator defined in the keyboard layout is used
+ // or the one approriate to the locale
+ sal_Bool IsDecimalSeparatorAsLocale() const;
+ void SetDecimalSeparatorAsLocale( sal_Bool bSet);
+
+ // convenience methods
+
+ /** Get the LanguageType of the current locale, may be LANGUAGE_SYSTEM if
+ LocaleConfigString is empty. If you need the real locale used in the
+ application, call Application::GetSettings().GetLanguage() instead */
+ LanguageType GetLocaleLanguageType() const;
+
+ /// Get currency abbreviation and locale from an USD-en-US or EUR-de-DE string
+ static void GetCurrencyAbbrevAndLanguage(
+ String& rAbbrev,
+ LanguageType& eLang,
+ const ::rtl::OUString& rConfigString );
+
+ /// Create an USD-en-US or EUR-de-DE string
+ static ::rtl::OUString CreateCurrencyConfigString(
+ const String& rAbbrev,
+ LanguageType eLang );
+
+ void GetCurrencyAbbrevAndLanguage(
+ String& rAbbrev,
+ LanguageType& eLang ) const
+ {
+ GetCurrencyAbbrevAndLanguage( rAbbrev,
+ eLang, GetCurrencyConfigString() );
+ }
+
+ void SetCurrencyAbbrevAndLanguage(
+ const String& rAbbrev,
+ LanguageType eLang )
+ {
+ SetCurrencyConfigString(
+ CreateCurrencyConfigString(
+ rAbbrev, eLang ) );
+ }
+
+ /** Set a link to a method to be called whenever the default currency
+ changes. This can be only one method, and normally it is the static
+ link method which calls SvNumberFormatter::SetDefaultSystemCurrency().
+ This is needed because the number formatter isn't part of the svl light
+ library, otherwise we could call SetDefaultSystemCurrency() directly.
+ */
+ static void SetCurrencyChangeLink( const Link& rLink );
+ static const Link& GetCurrencyChangeLink();
+
+ /** return the readonly state of the queried option. */
+ sal_Bool IsReadOnly( EOption eOption ) const;
+};
+
+#endif // INCLUDED_SVTOOLS_SYSLOCALEOPTIONS_HXX
diff --git a/unotools/source/config/configitem.cxx b/unotools/source/config/configitem.cxx
index 38aee1b39d16..ad83b9b79cae 100644
--- a/unotools/source/config/configitem.cxx
+++ b/unotools/source/config/configitem.cxx
@@ -1427,3 +1427,4 @@ void ConfigItem::UnlockTree()
m_xHierarchyAccess = 0;
}
+
diff --git a/unotools/source/config/itemholder1.cxx b/unotools/source/config/itemholder1.cxx
index cf1194f6e652..214b5a9b4276 100644
--- a/unotools/source/config/itemholder1.cxx
+++ b/unotools/source/config/itemholder1.cxx
@@ -38,6 +38,7 @@
#include <comphelper/processfactory.hxx>
#include <com/sun/star/lang/XComponent.hpp>
+#include <unotools/misccfg.hxx>
#include <unotools/undoopt.hxx>
#include <unotools/useroptions.hxx>
#include <unotools/accelcfg.hxx>
@@ -70,6 +71,7 @@
#include <unotools/workingsetoptions.hxx>
#include <unotools/xmlaccelcfg.hxx>
#include <unotools/options.hxx>
+#include <unotools/syslocaleoptions.hxx>
//-----------------------------------------------
// namespaces
@@ -252,8 +254,8 @@ void ItemHolder1::impl_newItem(TItemInfo& rItem)
rItem.pItem = new SvtPrintWarningOptions();
break;
- case E_REGOPTIONS :
-// no ref count rItem.pItem = new ::utl::RegOptions();
+ case E_MISCCFG :
+ rItem.pItem = new ::utl::MiscCfg();
break;
case E_SAVEOPTIONS :
@@ -308,6 +310,10 @@ void ItemHolder1::impl_newItem(TItemInfo& rItem)
rItem.pItem = new SvtUserOptions();
break;
+ case E_SYSLOCALEOPTIONS :
+ rItem.pItem = new SvtSysLocaleOptions();
+ break;
+
default:
OSL_ASSERT( "unknown item type" );
break;
diff --git a/unotools/source/config/makefile.mk b/unotools/source/config/makefile.mk
index edc0c9f2ad4f..eee8d4af9d73 100644
--- a/unotools/source/config/makefile.mk
+++ b/unotools/source/config/makefile.mk
@@ -45,6 +45,7 @@ ENABLE_EXCEPTIONS=TRUE
# --- Files -------------------------------------
SLOFILES=\
+ $(SLO)$/syslocaleoptions.obj \
$(SLO)$/configvaluecontainer.obj \
$(SLO)$/confignode.obj \
$(SLO)$/configitem.obj \
@@ -69,6 +70,7 @@ SLOFILES=\
$(SLO)$/javaoptions.obj \
$(SLO)$/lingucfg.obj \
$(SLO)$/localisationoptions.obj \
+ $(SLO)$/misccfg.obj \
$(SLO)$/moduleoptions.obj \
$(SLO)$/options.obj \
$(SLO)$/optionsdlg.obj \
diff --git a/unotools/source/config/misccfg.cxx b/unotools/source/config/misccfg.cxx
new file mode 100644
index 000000000000..febb3610f6a2
--- /dev/null
+++ b/unotools/source/config/misccfg.cxx
@@ -0,0 +1,312 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: misccfg.cxx,v $
+ * $Revision: 1.9 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_unotools.hxx"
+
+#include <unotools/misccfg.hxx>
+#include "rtl/instance.hxx"
+#include <unotools/configmgr.hxx>
+#include <unotools/configitem.hxx>
+#include <tools/debug.hxx>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <vos/mutex.hxx>
+#include <osl/mutex.hxx>
+#include <rtl/logfile.hxx>
+#include "itemholder1.hxx"
+
+#define DEFAULT_TAB 2000
+
+#define DEF_INCH 2540L
+#define DEF_RELTWIP 1440L
+
+using namespace rtl;
+using namespace com::sun::star::uno;
+
+#define C2U(cChar) OUString::createFromAscii(cChar)
+
+namespace utl
+{
+
+static SfxMiscCfg* pOptions = NULL;
+static sal_Int32 nRefCount = 0;
+
+class SfxMiscCfg : public utl::ConfigItem
+{
+ BOOL bPaperSize; // printer warnings
+ BOOL bPaperOrientation;
+ BOOL bNotFound;
+ sal_Int32 nYear2000; // two digit year representation
+
+ const com::sun::star::uno::Sequence<rtl::OUString>& GetPropertyNames();
+ void Load();
+
+public:
+ SfxMiscCfg( );
+ ~SfxMiscCfg( );
+
+ virtual void Notify( const com::sun::star::uno::Sequence<rtl::OUString>& aPropertyNames);
+ virtual void Commit();
+
+ BOOL IsNotFoundWarning() const {return bNotFound;}
+ void SetNotFoundWarning( BOOL bSet);
+
+ BOOL IsPaperSizeWarning() const {return bPaperSize;}
+ void SetPaperSizeWarning(BOOL bSet);
+
+ BOOL IsPaperOrientationWarning() const {return bPaperOrientation;}
+ void SetPaperOrientationWarning( BOOL bSet);
+
+ // 0 ... 99
+ sal_Int32 GetYear2000() const { return nYear2000; }
+ void SetYear2000( sal_Int32 nSet );
+
+};
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+SfxMiscCfg::SfxMiscCfg() :
+ ConfigItem(C2U("Office.Common") ),
+ bPaperSize(FALSE),
+ bPaperOrientation (FALSE),
+ bNotFound (FALSE),
+ nYear2000( 1930 )
+{
+ RTL_LOGFILE_CONTEXT(aLog, "svl SfxMiscCfg::SfxMiscCfg()");
+
+ Load();
+}
+/* -----------------------------02.03.01 15:31--------------------------------
+
+ ---------------------------------------------------------------------------*/
+SfxMiscCfg::~SfxMiscCfg()
+{
+}
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+void SfxMiscCfg::SetNotFoundWarning( BOOL bSet)
+{
+ if(bNotFound != bSet)
+ SetModified();
+ bNotFound = bSet;
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+void SfxMiscCfg::SetPaperSizeWarning( BOOL bSet)
+{
+ if(bPaperSize != bSet)
+ SetModified();
+ bPaperSize = bSet;
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+void SfxMiscCfg::SetPaperOrientationWarning( BOOL bSet)
+{
+ if(bPaperOrientation != bSet)
+ SetModified();
+ bPaperOrientation = bSet;
+}
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+void SfxMiscCfg::SetYear2000( sal_Int32 nSet )
+{
+ if(nYear2000 != nSet)
+ SetModified();
+ nYear2000 = nSet;
+}
+/* -----------------------------02.03.01 15:31--------------------------------
+
+ ---------------------------------------------------------------------------*/
+const Sequence<OUString>& SfxMiscCfg::GetPropertyNames()
+{
+ static Sequence<OUString> aNames;
+ if(!aNames.getLength())
+ {
+ static const char* aPropNames[] =
+ {
+ "Print/Warning/PaperSize", // 0
+ "Print/Warning/PaperOrientation", // 1
+ "Print/Warning/NotFound", // 2
+ "DateFormat/TwoDigitYear", // 3
+ };
+ const int nCount = 4;
+ aNames.realloc(nCount);
+ OUString* pNames = aNames.getArray();
+ for(int i = 0; i < nCount; i++)
+ pNames[i] = OUString::createFromAscii(aPropNames[i]);
+ }
+ return aNames;
+}
+/* -----------------------------02.03.01 15:31--------------------------------
+
+ ---------------------------------------------------------------------------*/
+void SfxMiscCfg::Load()
+{
+ const Sequence<OUString>& aNames = GetPropertyNames();
+ Sequence<Any> aValues = GetProperties(aNames);
+ EnableNotification(aNames);
+ const Any* pValues = aValues.getConstArray();
+ DBG_ASSERT(aValues.getLength() == aNames.getLength(), "GetProperties failed");
+ if(aValues.getLength() == aNames.getLength())
+ {
+ for(int nProp = 0; nProp < aNames.getLength(); nProp++)
+ {
+ if(pValues[nProp].hasValue())
+ {
+ switch(nProp)
+ {
+ case 0: bPaperSize = *(sal_Bool*)pValues[nProp].getValue(); break; //"Print/Warning/PaperSize",
+ case 1: bPaperOrientation = *(sal_Bool*)pValues[nProp].getValue(); break; //"Print/Warning/PaperOrientation",
+ case 2: bNotFound = *(sal_Bool*)pValues[nProp].getValue() ; break; //"Print/Warning/NotFound",
+ case 3: pValues[nProp] >>= nYear2000;break; //"DateFormat/TwoDigitYear",
+ }
+ }
+ }
+ }
+}
+/* -----------------------------02.03.01 15:31--------------------------------
+
+ ---------------------------------------------------------------------------*/
+void SfxMiscCfg::Notify( const com::sun::star::uno::Sequence<rtl::OUString>& )
+{
+ Load();
+}
+/* -----------------------------02.03.01 15:31--------------------------------
+
+ ---------------------------------------------------------------------------*/
+void SfxMiscCfg::Commit()
+{
+ const Sequence<OUString>& aNames = GetPropertyNames();
+ Sequence<Any> aValues(aNames.getLength());
+ Any* pValues = aValues.getArray();
+
+ const Type& rType = ::getBooleanCppuType();
+ for(int nProp = 0; nProp < aNames.getLength(); nProp++)
+ {
+ switch(nProp)
+ {
+ case 0: pValues[nProp].setValue(&bPaperSize, rType);break; //"Print/Warning/PaperSize",
+ case 1: pValues[nProp].setValue(&bPaperOrientation, rType);break; //"Print/Warning/PaperOrientation",
+ case 2: pValues[nProp].setValue(&bNotFound, rType);break; //"Print/Warning/NotFound",
+ case 3: pValues[nProp] <<= nYear2000;break; //"DateFormat/TwoDigitYear",
+ }
+ }
+ PutProperties(aNames, aValues);
+}
+// -----------------------------------------------------------------------
+namespace
+{
+ class LocalSingleton : public rtl::Static< osl::Mutex, LocalSingleton >
+ {
+ };
+}
+
+MiscCfg::MiscCfg( )
+{
+ // Global access, must be guarded (multithreading)
+ ::osl::MutexGuard aGuard( LocalSingleton::get() );
+ if ( !pOptions )
+ {
+ RTL_LOGFILE_CONTEXT(aLog, "unotools ( ??? ) SfxMiscCfg::ctor()");
+ pOptions = new SfxMiscCfg;
+
+ ItemHolder1::holdConfigItem(E_MISCCFG);
+ }
+
+ ++nRefCount;
+ pImpl = pOptions;
+ pImpl->AddListener(this);
+}
+
+MiscCfg::~MiscCfg( )
+{
+ // Global access, must be guarded (multithreading)
+ ::osl::MutexGuard aGuard( LocalSingleton::get() );
+ pImpl->RemoveListener(this);
+ if ( !--nRefCount )
+ {
+ if ( pOptions->IsModified() )
+ pOptions->Commit();
+ DELETEZ( pOptions );
+ }
+}
+
+BOOL MiscCfg::IsNotFoundWarning() const
+{
+ return pImpl->IsNotFoundWarning();
+}
+
+void MiscCfg::SetNotFoundWarning( BOOL bSet)
+{
+ pImpl->SetNotFoundWarning( bSet );
+}
+
+BOOL MiscCfg::IsPaperSizeWarning() const
+{
+ return pImpl->IsPaperSizeWarning();
+}
+
+void MiscCfg::SetPaperSizeWarning(BOOL bSet)
+{
+ pImpl->SetPaperSizeWarning( bSet );
+}
+
+BOOL MiscCfg::IsPaperOrientationWarning() const
+{
+ return pImpl->IsPaperOrientationWarning();
+}
+
+void MiscCfg::SetPaperOrientationWarning( BOOL bSet)
+{
+ pImpl->SetPaperOrientationWarning( bSet );
+}
+
+sal_Int32 MiscCfg::GetYear2000() const
+{
+ return pImpl->GetYear2000();
+}
+
+void MiscCfg::SetYear2000( sal_Int32 nSet )
+{
+ pImpl->SetYear2000( nSet );
+}
+
+} \ No newline at end of file
diff --git a/unotools/source/config/options.cxx b/unotools/source/config/options.cxx
index eba75b347edf..b4e9aec8c6dd 100644
--- a/unotools/source/config/options.cxx
+++ b/unotools/source/config/options.cxx
@@ -45,6 +45,7 @@ using utl::ConfigurationBroadcaster;
ConfigurationBroadcaster::ConfigurationBroadcaster()
: mpList(0)
+, m_nBroadcastBlocked( 0 )
{
}
@@ -68,9 +69,15 @@ void ConfigurationBroadcaster::RemoveListener( utl::ConfigurationListener* pList
void ConfigurationBroadcaster::NotifyListeners()
{
- if ( mpList )
- for ( sal_uInt32 n=0; n<mpList->Count(); n++ )
- mpList->GetObject(n)->ConfigurationChanged(this);
+// if ( m_nBroadcastBlocked )
+// m_nBlockedHint |= nHint;
+// else
+ if (!m_nBroadcastBlocked)
+ {
+ if ( mpList )
+ for ( sal_uInt32 n=0; n<mpList->Count(); n++ )
+ mpList->GetObject(n)->ConfigurationChanged(this);
+ }
}
Options::Options()
@@ -86,3 +93,13 @@ void Options::ConfigurationChanged( utl::ConfigurationBroadcaster* )
NotifyListeners();
}
+void ConfigurationBroadcaster::BlockBroadcasts( bool bBlock )
+{
+ if ( bBlock )
+ ++m_nBroadcastBlocked;
+ else if ( m_nBroadcastBlocked )
+ {
+ if ( --m_nBroadcastBlocked == 0 )
+ NotifyListeners();
+ }
+}
diff --git a/unotools/source/config/syslocaleoptions.cxx b/unotools/source/config/syslocaleoptions.cxx
new file mode 100644
index 000000000000..3815136b27f0
--- /dev/null
+++ b/unotools/source/config/syslocaleoptions.cxx
@@ -0,0 +1,584 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: syslocaleoptions.cxx,v $
+ * $Revision: 1.23 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_unotools.hxx"
+
+#include <unotools/syslocaleoptions.hxx>
+#include <i18npool/mslangid.hxx>
+#include <tools/string.hxx>
+#include <rtl/ustrbuf.hxx>
+#include <rtl/instance.hxx>
+#include <unotools/configmgr.hxx>
+#include <unotools/configitem.hxx>
+#include <tools/debug.hxx>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <rtl/logfile.hxx>
+
+#include "itemholder1.hxx"
+
+
+#define CFG_READONLY_DEFAULT sal_False
+
+using namespace osl;
+using namespace utl;
+using namespace rtl;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+
+
+SvtSysLocaleOptions_Impl* SvtSysLocaleOptions::pOptions = NULL;
+sal_Int32 SvtSysLocaleOptions::nRefCount = 0;
+namespace
+{
+ struct CurrencyChangeLink
+ : public rtl::Static<Link, CurrencyChangeLink> {};
+}
+
+class SvtSysLocaleOptions_Impl : public utl::ConfigItem
+{
+ OUString m_aLocaleString; // en-US or de-DE or empty for SYSTEM
+ LanguageType m_eLocaleLanguageType; // same for convenience access
+ OUString m_aCurrencyString; // USD-en-US or EUR-de-DE
+ ULONG m_nBlockedHint; // pending hints
+ sal_Bool m_bDecimalSeparator; //use decimal separator same as locale
+
+ sal_Bool m_bROLocale;
+ sal_Bool m_bROCurrency;
+ sal_Bool m_bRODecimalSeparator;
+
+ static const Sequence< /* const */ OUString > GetPropertyNames();
+
+ ULONG ChangeLocaleSettings();
+ void ChangeDefaultCurrency() const;
+
+public:
+ SvtSysLocaleOptions_Impl();
+ virtual ~SvtSysLocaleOptions_Impl();
+
+ virtual void Notify( const com::sun::star::uno::Sequence< rtl::OUString >& aPropertyNames );
+ virtual void Commit();
+
+ const OUString& GetLocaleString() const
+ { return m_aLocaleString; }
+ void SetLocaleString( const OUString& rStr );
+ LanguageType GetLocaleLanguageType() const
+ { return m_eLocaleLanguageType; }
+
+ const OUString& GetCurrencyString() const
+ { return m_aCurrencyString; }
+ void SetCurrencyString( const OUString& rStr );
+
+ sal_Bool IsDecimalSeparatorAsLocale() const { return m_bDecimalSeparator;}
+ void SetDecimalSeparatorAsLocale( sal_Bool bSet);
+
+ sal_Bool IsReadOnly( SvtSysLocaleOptions::EOption eOption ) const;
+};
+
+
+#define ROOTNODE_SYSLOCALE OUString(RTL_CONSTASCII_USTRINGPARAM("Setup/L10N"))
+
+#define PROPERTYNAME_LOCALE OUString(RTL_CONSTASCII_USTRINGPARAM("ooSetupSystemLocale"))
+#define PROPERTYNAME_CURRENCY OUString(RTL_CONSTASCII_USTRINGPARAM("ooSetupCurrency"))
+#define PROPERTYNAME_DECIMALSEPARATOR OUString(RTL_CONSTASCII_USTRINGPARAM("DecimalSeparatorAsLocale"))
+
+#define PROPERTYHANDLE_LOCALE 0
+#define PROPERTYHANDLE_CURRENCY 1
+#define PROPERTYHANDLE_DECIMALSEPARATOR 2
+
+#define PROPERTYCOUNT 3
+
+const Sequence< OUString > SvtSysLocaleOptions_Impl::GetPropertyNames()
+{
+ static const OUString pProperties[] =
+ {
+ PROPERTYNAME_LOCALE,
+ PROPERTYNAME_CURRENCY,
+ PROPERTYNAME_DECIMALSEPARATOR
+ };
+ static const Sequence< OUString > seqPropertyNames( pProperties, PROPERTYCOUNT );
+ return seqPropertyNames;
+}
+
+
+// -----------------------------------------------------------------------
+
+SvtSysLocaleOptions_Impl::SvtSysLocaleOptions_Impl()
+ : ConfigItem( ROOTNODE_SYSLOCALE )
+ , m_nBlockedHint( 0 )
+ , m_bDecimalSeparator( sal_True )
+ , m_bROLocale(CFG_READONLY_DEFAULT)
+ , m_bROCurrency(CFG_READONLY_DEFAULT)
+ , m_bRODecimalSeparator(sal_False)
+
+{
+ if ( !IsValidConfigMgr() )
+ ChangeLocaleSettings(); // assume SYSTEM defaults during Setup
+ else
+ {
+ const Sequence< OUString > aNames = GetPropertyNames();
+ Sequence< Any > aValues = GetProperties( aNames );
+ Sequence< sal_Bool > aROStates = GetReadOnlyStates( aNames );
+ const Any* pValues = aValues.getConstArray();
+ const sal_Bool* pROStates = aROStates.getConstArray();
+ DBG_ASSERT( aValues.getLength() == aNames.getLength(), "GetProperties failed" );
+ DBG_ASSERT( aROStates.getLength() == aNames.getLength(), "GetReadOnlyStates failed" );
+ if ( aValues.getLength() == aNames.getLength() && aROStates.getLength() == aNames.getLength() )
+ {
+ for ( sal_Int32 nProp = 0; nProp < aNames.getLength(); nProp++ )
+ {
+ DBG_ASSERT( pValues[nProp].hasValue(), "property value missing" );
+ if ( pValues[nProp].hasValue() )
+ {
+ switch ( nProp )
+ {
+ case PROPERTYHANDLE_LOCALE :
+ {
+ OUString aStr;
+ if ( pValues[nProp] >>= aStr )
+ m_aLocaleString = aStr;
+ else
+ {
+ DBG_ERRORFILE( "Wrong property type!" );
+ }
+ m_bROLocale = pROStates[nProp];
+ }
+ break;
+ case PROPERTYHANDLE_CURRENCY :
+ {
+ OUString aStr;
+ if ( pValues[nProp] >>= aStr )
+ m_aCurrencyString = aStr;
+ else
+ {
+ DBG_ERRORFILE( "Wrong property type!" );
+ }
+ m_bROCurrency = pROStates[nProp];
+ }
+ break;
+ case PROPERTYHANDLE_DECIMALSEPARATOR:
+ {
+ sal_Bool bValue = sal_Bool();
+ if ( pValues[nProp] >>= bValue )
+ m_bDecimalSeparator = bValue;
+ else
+ {
+ DBG_ERRORFILE( "Wrong property type!" );
+ }
+ m_bRODecimalSeparator = pROStates[nProp];
+ }
+ break;
+ default:
+ DBG_ERRORFILE( "Wrong property type!" );
+ }
+ }
+ }
+ }
+// UpdateMiscSettings_Impl();
+ ChangeLocaleSettings();
+ EnableNotification( aNames );
+ }
+}
+
+
+SvtSysLocaleOptions_Impl::~SvtSysLocaleOptions_Impl()
+{
+ if ( IsModified() )
+ Commit();
+}
+
+
+sal_Bool SvtSysLocaleOptions_Impl::IsReadOnly( SvtSysLocaleOptions::EOption eOption ) const
+{
+ sal_Bool bReadOnly = CFG_READONLY_DEFAULT;
+ switch(eOption)
+ {
+ case SvtSysLocaleOptions::E_LOCALE :
+ {
+ bReadOnly = m_bROLocale;
+ break;
+ }
+ case SvtSysLocaleOptions::E_CURRENCY :
+ {
+ bReadOnly = m_bROCurrency;
+ break;
+ }
+ }
+ return bReadOnly;
+}
+
+
+/*void SvtSysLocaleOptions_Impl::Broadcast( ULONG nHint )
+{
+ if ( m_nBroadcastBlocked )
+ m_nBlockedHint |= nHint;
+ else
+ {
+ nHint |= m_nBlockedHint;
+ m_nBlockedHint = 0;
+ if ( nHint )
+ {
+ if ( nHint & SYSLOCALEOPTIONS_HINT_CURRENCY )
+ ChangeDefaultCurrency();
+ SfxSimpleHint aHint( nHint );
+ GetBroadcaster().Broadcast( aHint );
+ }
+ }
+}*/
+
+
+void SvtSysLocaleOptions_Impl::Commit()
+{
+ const Sequence< OUString > aOrgNames = GetPropertyNames();
+ sal_Int32 nOrgCount = aOrgNames.getLength();
+
+ Sequence< OUString > aNames( nOrgCount );
+ Sequence< Any > aValues( nOrgCount );
+
+ OUString* pNames = aNames.getArray();
+ Any* pValues = aValues.getArray();
+ sal_Int32 nRealCount = 0;
+
+ for ( sal_Int32 nProp = 0; nProp < nOrgCount; nProp++ )
+ {
+ switch ( nProp )
+ {
+ case PROPERTYHANDLE_LOCALE :
+ {
+ if (!m_bROLocale)
+ {
+ pNames[nRealCount] = aOrgNames[nProp];
+ pValues[nRealCount] <<= m_aLocaleString;
+ ++nRealCount;
+ }
+ }
+ break;
+ case PROPERTYHANDLE_CURRENCY :
+ {
+ if (!m_bROLocale)
+ {
+ pNames[nRealCount] = aOrgNames[nProp];
+ pValues[nRealCount] <<= m_aCurrencyString;
+ ++nRealCount;
+ }
+ }
+ break;
+ case PROPERTYHANDLE_DECIMALSEPARATOR:
+ if( !m_bRODecimalSeparator )
+ {
+ pNames[nRealCount] = aOrgNames[nProp];
+ pValues[nRealCount] <<= m_bDecimalSeparator;
+ ++nRealCount;
+ }
+ break;
+ default:
+ DBG_ERRORFILE( "invalid index to save a path" );
+ }
+ }
+ aNames.realloc(nRealCount);
+ aValues.realloc(nRealCount);
+ PutProperties( aNames, aValues );
+ ClearModified();
+}
+
+
+void SvtSysLocaleOptions_Impl::SetLocaleString( const OUString& rStr )
+{
+ if (!m_bROLocale && rStr != m_aLocaleString )
+ {
+ m_aLocaleString = rStr;
+ SetModified();
+ ULONG nHint = SYSLOCALEOPTIONS_HINT_LOCALE;
+ nHint |= ChangeLocaleSettings();
+ //Broadcast( nHint );
+ NotifyListeners();
+ }
+}
+
+
+ULONG SvtSysLocaleOptions_Impl::ChangeLocaleSettings()
+{
+ // An empty config value denotes SYSTEM locale
+ if ( m_aLocaleString.getLength() )
+ m_eLocaleLanguageType = MsLangId::convertIsoStringToLanguage( m_aLocaleString );
+ else
+ m_eLocaleLanguageType = LANGUAGE_SYSTEM;
+ ULONG nHint = 0;
+ // new locale and no fixed currency => locale default currency might change
+ if ( !m_aCurrencyString.getLength() )
+ nHint |= SYSLOCALEOPTIONS_HINT_CURRENCY;
+ return nHint;
+}
+
+
+void SvtSysLocaleOptions_Impl::SetCurrencyString( const OUString& rStr )
+{
+ if (!m_bROCurrency && rStr != m_aCurrencyString )
+ {
+ m_aCurrencyString = rStr;
+ SetModified();
+ //Broadcast( SYSLOCALEOPTIONS_HINT_CURRENCY );
+ NotifyListeners();
+ }
+}
+
+void SvtSysLocaleOptions_Impl::SetDecimalSeparatorAsLocale( sal_Bool bSet)
+{
+ if(bSet != m_bDecimalSeparator)
+ {
+ m_bDecimalSeparator = bSet;
+ SetModified();
+ //UpdateMiscSettings_Impl();
+ NotifyListeners();
+ }
+}
+
+
+void SvtSysLocaleOptions_Impl::ChangeDefaultCurrency() const
+{
+ const Link& rLink = SvtSysLocaleOptions::GetCurrencyChangeLink();
+ if ( rLink.IsSet() )
+ rLink.Call( NULL );
+}
+
+
+void SvtSysLocaleOptions_Impl::Notify( const Sequence< rtl::OUString >& seqPropertyNames )
+{
+ ULONG nHint = 0;
+ Sequence< Any > seqValues = GetProperties( seqPropertyNames );
+ Sequence< sal_Bool > seqROStates = GetReadOnlyStates( seqPropertyNames );
+ sal_Int32 nCount = seqPropertyNames.getLength();
+ for( sal_Int32 nProp = 0; nProp < nCount; ++nProp )
+ {
+ if( seqPropertyNames[nProp] == PROPERTYNAME_LOCALE )
+ {
+ DBG_ASSERT( seqValues[nProp].getValueTypeClass() == TypeClass_STRING, "Locale property type" );
+ seqValues[nProp] >>= m_aLocaleString;
+ m_bROLocale = seqROStates[nProp];
+ nHint |= SYSLOCALEOPTIONS_HINT_LOCALE;
+ nHint |= ChangeLocaleSettings();
+ }
+ else if( seqPropertyNames[nProp] == PROPERTYNAME_CURRENCY )
+ {
+ DBG_ASSERT( seqValues[nProp].getValueTypeClass() == TypeClass_STRING, "Currency property type" );
+ seqValues[nProp] >>= m_aCurrencyString;
+ m_bROCurrency = seqROStates[nProp];
+ nHint |= SYSLOCALEOPTIONS_HINT_CURRENCY;
+ }
+ else if( seqPropertyNames[nProp] == PROPERTYNAME_DECIMALSEPARATOR )
+ {
+ seqValues[nProp] >>= m_bDecimalSeparator;
+ m_bRODecimalSeparator = seqROStates[nProp];
+ }
+ }
+ if ( nHint )
+ //Broadcast( nHint );
+ NotifyListeners();
+}
+
+// ====================================================================
+
+SvtSysLocaleOptions::SvtSysLocaleOptions()
+{
+ MutexGuard aGuard( GetMutex() );
+ if ( !pOptions )
+ {
+ RTL_LOGFILE_CONTEXT(aLog, "svl ( ??? ) ::SvtSysLocaleOptions_Impl::ctor()");
+ pOptions = new SvtSysLocaleOptions_Impl;
+
+ ItemHolder1::holdConfigItem(E_SYSLOCALEOPTIONS);
+ }
+ ++nRefCount;
+}
+
+
+SvtSysLocaleOptions::~SvtSysLocaleOptions()
+{
+ MutexGuard aGuard( GetMutex() );
+ if ( !--nRefCount )
+ {
+ delete pOptions;
+ pOptions = NULL;
+ }
+}
+
+
+// static
+Mutex& SvtSysLocaleOptions::GetMutex()
+{
+ static Mutex* pMutex = NULL;
+ if( !pMutex )
+ {
+ MutexGuard aGuard( Mutex::getGlobalMutex() );
+ if( !pMutex )
+ {
+ // #i77768# Due to a static reference in the toolkit lib
+ // we need a mutex that lives longer than the svl library.
+ // Otherwise the dtor would use a destructed mutex!!
+ pMutex = new Mutex;
+ }
+ }
+ return *pMutex;
+}
+
+
+sal_Bool SvtSysLocaleOptions::IsModified()
+{
+ MutexGuard aGuard( GetMutex() );
+ return pOptions->IsModified();
+}
+
+
+void SvtSysLocaleOptions::Commit()
+{
+ MutexGuard aGuard( GetMutex() );
+ pOptions->Commit();
+}
+
+
+void SvtSysLocaleOptions::BlockBroadcasts( BOOL bBlock )
+{
+ MutexGuard aGuard( GetMutex() );
+ pOptions->BlockBroadcasts( bBlock );
+}
+
+
+const OUString& SvtSysLocaleOptions::GetLocaleConfigString() const
+{
+ MutexGuard aGuard( GetMutex() );
+ return pOptions->GetLocaleString();
+}
+
+
+void SvtSysLocaleOptions::SetLocaleConfigString( const OUString& rStr )
+{
+ MutexGuard aGuard( GetMutex() );
+ pOptions->SetLocaleString( rStr );
+}
+
+
+const OUString& SvtSysLocaleOptions::GetCurrencyConfigString() const
+{
+ MutexGuard aGuard( GetMutex() );
+ return pOptions->GetCurrencyString();
+}
+
+
+void SvtSysLocaleOptions::SetCurrencyConfigString( const OUString& rStr )
+{
+ MutexGuard aGuard( GetMutex() );
+ pOptions->SetCurrencyString( rStr );
+}
+
+
+LanguageType SvtSysLocaleOptions::GetLocaleLanguageType() const
+{
+ MutexGuard aGuard( GetMutex() );
+ return pOptions->GetLocaleLanguageType();
+}
+
+/*-- 11.02.2004 13:31:41---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+sal_Bool SvtSysLocaleOptions::IsDecimalSeparatorAsLocale() const
+{
+ MutexGuard aGuard( GetMutex() );
+ return pOptions->IsDecimalSeparatorAsLocale();
+}
+/*-- 11.02.2004 13:31:41---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SvtSysLocaleOptions::SetDecimalSeparatorAsLocale( sal_Bool bSet)
+{
+ MutexGuard aGuard( GetMutex() );
+ pOptions->SetDecimalSeparatorAsLocale(bSet);
+}
+
+
+sal_Bool SvtSysLocaleOptions::IsReadOnly( EOption eOption ) const
+{
+ MutexGuard aGuard( GetMutex() );
+ return pOptions->IsReadOnly( eOption );
+}
+
+// static
+void SvtSysLocaleOptions::GetCurrencyAbbrevAndLanguage( String& rAbbrev,
+ LanguageType& eLang, const ::rtl::OUString& rConfigString )
+{
+ sal_Int32 nDelim = rConfigString.indexOf( '-' );
+ if ( nDelim >= 0 )
+ {
+ rAbbrev = rConfigString.copy( 0, nDelim );
+ String aIsoStr( rConfigString.copy( nDelim+1 ) );
+ eLang = MsLangId::convertIsoStringToLanguage( aIsoStr );
+ }
+ else
+ {
+ rAbbrev = rConfigString;
+ eLang = (rAbbrev.Len() ? LANGUAGE_NONE : LANGUAGE_SYSTEM);
+ }
+}
+
+
+// static
+::rtl::OUString SvtSysLocaleOptions::CreateCurrencyConfigString(
+ const String& rAbbrev, LanguageType eLang )
+{
+ String aIsoStr( MsLangId::convertLanguageToIsoString( eLang ) );
+ if ( aIsoStr.Len() )
+ {
+ ::rtl::OUStringBuffer aStr( rAbbrev.Len() + 1 + aIsoStr.Len() );
+ aStr.append( rAbbrev.GetBuffer(), rAbbrev.Len() );
+ aStr.append( sal_Unicode('-') );
+ aStr.append( aIsoStr.GetBuffer(), aIsoStr.Len() );
+ return aStr.makeStringAndClear();
+ }
+ else
+ return rAbbrev;
+}
+
+
+// static
+void SvtSysLocaleOptions::SetCurrencyChangeLink( const Link& rLink )
+{
+ MutexGuard aGuard( GetMutex() );
+ DBG_ASSERT( !CurrencyChangeLink::get().IsSet(), "SvtSysLocaleOptions::SetCurrencyChangeLink: already set" );
+ CurrencyChangeLink::get() = rLink;
+}
+
+
+// static
+const Link& SvtSysLocaleOptions::GetCurrencyChangeLink()
+{
+ MutexGuard aGuard( GetMutex() );
+ return CurrencyChangeLink::get();
+}
+
diff --git a/unotools/source/config/undoopt.cxx b/unotools/source/config/undoopt.cxx
index 006de02e084a..9b1712032e18 100644
--- a/unotools/source/config/undoopt.cxx
+++ b/unotools/source/config/undoopt.cxx
@@ -30,10 +30,6 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_unotools.hxx"
-#ifdef SVL_DLLIMPLEMENTATION
-#undef SVL_DLLIMPLEMENTATION
-#endif
-#define SVT_DLLIMPLEMENTATION
#include <unotools/undoopt.hxx>
#include "rtl/instance.hxx"
diff --git a/unotools/source/config/useroptions.cxx b/unotools/source/config/useroptions.cxx
index ad5f50977114..3b62e8225730 100644
--- a/unotools/source/config/useroptions.cxx
+++ b/unotools/source/config/useroptions.cxx
@@ -30,10 +30,6 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_unotools.hxx"
-#ifdef SVL_DLLIMPLEMENTATION
-#undef SVL_DLLIMPLEMENTATION
-#endif
-#define SVT_DLLIMPLEMENTATION
#include <unotools/useroptions.hxx>
#include <unotools/useroptions_const.hxx>
diff --git a/unotools/source/misc/makefile.mk b/unotools/source/misc/makefile.mk
index 8e505e41aaac..4d9f7f40746b 100644
--- a/unotools/source/misc/makefile.mk
+++ b/unotools/source/misc/makefile.mk
@@ -45,6 +45,7 @@ ENABLE_EXCEPTIONS=TRUE
SLOFILES= $(SLO)$/atom.obj \
$(SLO)$/datetime.obj \
+ $(SLO)$/syslocale.obj \
$(SLO)$/eventlisteneradapter.obj \
$(SLO)$/desktopterminationobserver.obj \
$(SLO)$/sharedunocomponent.obj \
diff --git a/unotools/source/misc/syslocale.cxx b/unotools/source/misc/syslocale.cxx
new file mode 100644
index 000000000000..a299867f83e8
--- /dev/null
+++ b/unotools/source/misc/syslocale.cxx
@@ -0,0 +1,205 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: syslocale.cxx,v $
+ * $Revision: 1.11 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_unotools.hxx"
+#ifndef GCC
+#endif
+
+#include <unotools/syslocale.hxx>
+#include <tools/string.hxx>
+#include <unotools/syslocaleoptions.hxx>
+#include <unotools/localedatawrapper.hxx>
+#include <comphelper/processfactory.hxx>
+#include <i18npool/mslangid.hxx>
+
+using namespace osl;
+using namespace com::sun::star;
+
+
+SvtSysLocale_Impl* SvtSysLocale::pImpl = NULL;
+sal_Int32 SvtSysLocale::nRefCount = 0;
+
+
+class SvtSysLocale_Impl : public utl::ConfigurationListener
+{
+ friend class SvtSysLocale;
+
+ SvtSysLocaleOptions aSysLocaleOptions;
+ LocaleDataWrapper* pLocaleData;
+ CharClass* pCharClass;
+ com::sun::star::lang::Locale maLocale;
+
+public:
+ SvtSysLocale_Impl();
+ virtual ~SvtSysLocale_Impl();
+
+ CharClass* GetCharClass();
+ SvtSysLocaleOptions& GetOptions() { return aSysLocaleOptions; }
+ void ConfigurationChanged( utl::ConfigurationBroadcaster* );
+ com::sun::star::lang::Locale GetLocale();
+};
+
+com::sun::star::lang::Locale SvtSysLocale_Impl::GetLocale()
+{
+ // ask configuration
+ rtl::OUString aLocaleString = aSysLocaleOptions.GetLocaleConfigString();
+ if (!aLocaleString.getLength())
+ // if no configuration is set, use system locale
+ return maLocale;
+
+ com::sun::star::lang::Locale aLocale;
+ sal_Int32 nSep = aLocaleString.indexOf('-');
+ if (nSep < 0)
+ aLocale.Language = aLocaleString;
+ else
+ {
+ aLocale.Language = aLocaleString.copy(0, nSep);
+ if (nSep < aLocaleString.getLength())
+ aLocale.Country = aLocaleString.copy(nSep+1, aLocaleString.getLength() - (nSep+1));
+ }
+
+ return aLocale;
+}
+
+// -----------------------------------------------------------------------
+
+SvtSysLocale_Impl::SvtSysLocale_Impl() : pCharClass(NULL)
+{
+ // first initialize maLocale with system locale
+ MsLangId::convertLanguageToLocale( MsLangId::getSystemLanguage(), maLocale );
+
+ pLocaleData = new LocaleDataWrapper( ::comphelper::getProcessServiceFactory(), GetLocale() );
+
+ // listen for further changes
+ aSysLocaleOptions.AddListener( this );
+}
+
+
+SvtSysLocale_Impl::~SvtSysLocale_Impl()
+{
+ aSysLocaleOptions.RemoveListener( this );
+ delete pCharClass;
+ delete pLocaleData;
+}
+
+CharClass* SvtSysLocale_Impl::GetCharClass()
+{
+ if ( !pCharClass )
+ pCharClass = new CharClass(::comphelper::getProcessServiceFactory(), GetLocale() );
+ return pCharClass;
+}
+
+void SvtSysLocale_Impl::ConfigurationChanged( utl::ConfigurationBroadcaster* )
+{
+ MutexGuard aGuard( SvtSysLocale::GetMutex() );
+ lang::Locale aLocale = GetLocale();
+ pLocaleData->setLocale( aLocale );
+ GetCharClass()->setLocale( aLocale );
+}
+
+// ====================================================================
+
+SvtSysLocale::SvtSysLocale()
+{
+ MutexGuard aGuard( GetMutex() );
+ if ( !pImpl )
+ pImpl = new SvtSysLocale_Impl;
+ ++nRefCount;
+}
+
+
+SvtSysLocale::~SvtSysLocale()
+{
+ MutexGuard aGuard( GetMutex() );
+ if ( !--nRefCount )
+ {
+ delete pImpl;
+ pImpl = NULL;
+ }
+}
+
+
+// static
+Mutex& SvtSysLocale::GetMutex()
+{
+ static Mutex* pMutex = NULL;
+ if( !pMutex )
+ {
+ MutexGuard aGuard( Mutex::getGlobalMutex() );
+ if( !pMutex )
+ {
+ // #i77768# Due to a static reference in the toolkit lib
+ // we need a mutex that lives longer than the svl library.
+ // Otherwise the dtor would use a destructed mutex!!
+ pMutex = new Mutex;
+ }
+ }
+ return *pMutex;
+}
+
+
+const LocaleDataWrapper& SvtSysLocale::GetLocaleData() const
+{
+ return *(pImpl->pLocaleData);
+}
+
+
+const LocaleDataWrapper* SvtSysLocale::GetLocaleDataPtr() const
+{
+ return pImpl->pLocaleData;
+}
+
+
+const CharClass& SvtSysLocale::GetCharClass() const
+{
+ return *(pImpl->GetCharClass());
+}
+
+
+const CharClass* SvtSysLocale::GetCharClassPtr() const
+{
+ return pImpl->GetCharClass();
+}
+
+SvtSysLocaleOptions& SvtSysLocale::GetOptions() const
+{
+ return pImpl->GetOptions();
+}
+
+com::sun::star::lang::Locale SvtSysLocale::GetLocale() const
+{
+ return pImpl->GetLocale();
+}
+
+LanguageType SvtSysLocale::GetLanguage() const
+{
+ return MsLangId::convertLocaleToLanguage( pImpl->GetLocale() );
+} \ No newline at end of file