summaryrefslogtreecommitdiff
path: root/unotools
diff options
context:
space:
mode:
authorMathias Bauer <mba@openoffice.org>2009-10-16 00:05:16 +0200
committerMathias Bauer <mba@openoffice.org>2009-10-16 00:05:16 +0200
commitad482351a6c12cddb06575f6a9a00ec1b72d92fb (patch)
treee97f35e966aef21423e70f325a66943664ed62a9 /unotools
parent9a4d0581c72653e60562d1b8e2121772d21f8a9e (diff)
#i103496#: split svtools; improve ConfitItems
Diffstat (limited to 'unotools')
-rw-r--r--unotools/inc/unotools/configitem.hxx4
-rw-r--r--unotools/inc/unotools/options.hxx26
-rw-r--r--unotools/inc/unotools/syslocale.hxx6
-rw-r--r--unotools/inc/unotools/syslocaleoptions.hxx15
-rw-r--r--unotools/source/config/cacheoptions.cxx5
-rw-r--r--unotools/source/config/configitem.cxx25
-rw-r--r--unotools/source/config/defaultoptions.cxx12
-rw-r--r--unotools/source/config/fltrcfg.cxx8
-rw-r--r--unotools/source/config/historyoptions.cxx2
-rw-r--r--unotools/source/config/javaoptions.cxx5
-rw-r--r--unotools/source/config/lingucfg.cxx3
-rw-r--r--unotools/source/config/localisationoptions.cxx2
-rw-r--r--unotools/source/config/options.cxx40
-rw-r--r--unotools/source/config/printwarningoptions.cxx5
-rw-r--r--unotools/source/config/searchopt.cxx5
-rw-r--r--unotools/source/config/sourceviewconfig.cxx2
-rw-r--r--unotools/source/config/syslocaleoptions.cxx214
-rw-r--r--unotools/source/config/undoopt.cxx2
-rw-r--r--unotools/source/config/useroptions.cxx2
-rw-r--r--unotools/source/misc/syslocale.cxx96
20 files changed, 310 insertions, 169 deletions
diff --git a/unotools/inc/unotools/configitem.hxx b/unotools/inc/unotools/configitem.hxx
index 0e938cedd47f..3cc0dc1b079e 100644
--- a/unotools/inc/unotools/configitem.hxx
+++ b/unotools/inc/unotools/configitem.hxx
@@ -186,7 +186,7 @@ namespace utl
/** is called from the ConfigManager before application ends of from the
PropertyChangeListener if the sub tree broadcasts changes. */
- virtual void Notify( const com::sun::star::uno::Sequence<rtl::OUString>& aPropertyNames);
+ virtual void Notify( const com::sun::star::uno::Sequence<rtl::OUString>& aPropertyNames)=0;
/** is called from the ConfigManager if it is destroyed before the ConfigItem. */
void ReleaseConfigMgr();
@@ -201,7 +201,7 @@ namespace utl
sal_Bool IsModified() const;
/** writes the changed values into the sub tree. Always called in the Dtor of the derived class. */
- virtual void Commit();
+ virtual void Commit()=0;
sal_Bool IsInValueChange() const;
diff --git a/unotools/inc/unotools/options.hxx b/unotools/inc/unotools/options.hxx
index ca8d70657f0f..f7254589150d 100644
--- a/unotools/inc/unotools/options.hxx
+++ b/unotools/inc/unotools/options.hxx
@@ -34,26 +34,40 @@
#include "sal/config.h"
#include "unotools/unotoolsdllapi.h"
+/*
+ The class utl::detail::Options provides a kind of multiplexer. It implements a ConfigurationListener
+ that is usually registered at a ConfigItem class. At the same time it implements a ConfigurationBroadcaster
+ that allows further ("external") listeners to register.
+ Once the class deriving from Options is notified about
+ configuration changes by the ConfigItem if its content has been changed by calling some of its methods,
+ a call of the Options::NotifyListeners() method will send out notifications to all external listeners.
+*/
+
namespace utl {
class ConfigurationBroadcaster;
class IMPL_ConfigurationListenerList;
+ // interface for configuration listener
class UNOTOOLS_DLLPUBLIC ConfigurationListener
{
public:
- virtual void ConfigurationChanged( ConfigurationBroadcaster* ) = 0;
+ virtual void ConfigurationChanged( ConfigurationBroadcaster* p, sal_uInt32 nHint=0 ) = 0;
};
+ // complete broadcasting implementation
class UNOTOOLS_DLLPUBLIC ConfigurationBroadcaster
{
IMPL_ConfigurationListenerList* mpList;
sal_Int32 m_nBroadcastBlocked; // broadcast only if this is 0
+ sal_uInt32 m_nBlockedHint;
public:
void AddListener( utl::ConfigurationListener* pListener );
void RemoveListener( utl::ConfigurationListener* pListener );
- void NotifyListeners();
+
+ // notify listeners; nHint is an implementation detail of the particular class deriving from ConfigurationBroadcaster
+ void NotifyListeners( sal_uInt32 nHint );
ConfigurationBroadcaster();
~ConfigurationBroadcaster();
void BlockBroadcasts( bool bBlock );
@@ -63,7 +77,9 @@ namespace detail {
// A base class for the various option classes supported by
// unotools/source/config/itemholderbase.hxx (which must be public, as it is
-// shared between svl and svt):
+// shared between unotools, svl and svt)
+// It also provides an implementation for a Configuration Listener and inherits a broadcaster implementation
+
class UNOTOOLS_DLLPUBLIC Options : public utl::ConfigurationBroadcaster, public utl::ConfigurationListener
{
public:
@@ -74,7 +90,9 @@ public:
private:
UNOTOOLS_DLLPRIVATE Options(Options &); // not defined
UNOTOOLS_DLLPRIVATE void operator =(Options &); // not defined
- virtual void ConfigurationChanged( utl::ConfigurationBroadcaster* );
+
+protected:
+ virtual void ConfigurationChanged( ::utl::ConfigurationBroadcaster* p, sal_uInt32 nHint=0 );
};
} }
diff --git a/unotools/inc/unotools/syslocale.hxx b/unotools/inc/unotools/syslocale.hxx
index 87482abbb117..adce66b7e84a 100644
--- a/unotools/inc/unotools/syslocale.hxx
+++ b/unotools/inc/unotools/syslocale.hxx
@@ -28,8 +28,8 @@
*
************************************************************************/
-#ifndef INCLUDED_SVTOOLS_SYSLOCALE_HXX
-#define INCLUDED_SVTOOLS_SYSLOCALE_HXX
+#ifndef INCLUDED_UNOTOOLS_SYSLOCALE_HXX
+#define INCLUDED_UNOTOOLS_SYSLOCALE_HXX
#include "unotools/unotoolsdllapi.h"
#include <unotools/localedatawrapper.hxx>
@@ -77,6 +77,8 @@ public:
SvtSysLocaleOptions& GetOptions() const;
com::sun::star::lang::Locale GetLocale() const;
LanguageType GetLanguage() const;
+ com::sun::star::lang::Locale GetUILocale() const;
+ LanguageType GetUILanguage() const;
};
#endif // INCLUDED_SVTOOLS_SYSLOCALE_HXX
diff --git a/unotools/inc/unotools/syslocaleoptions.hxx b/unotools/inc/unotools/syslocaleoptions.hxx
index 6c48c83a8500..2da102c161cc 100644
--- a/unotools/inc/unotools/syslocaleoptions.hxx
+++ b/unotools/inc/unotools/syslocaleoptions.hxx
@@ -43,6 +43,8 @@
// bits for broadcasting hints of changes in a SfxSimpleHint, may be combined
const ULONG SYSLOCALEOPTIONS_HINT_LOCALE = 0x00000001;
const ULONG SYSLOCALEOPTIONS_HINT_CURRENCY = 0x00000002;
+const ULONG SYSLOCALEOPTIONS_HINT_UILOCALE = 0x00000004;
+const ULONG SYSLOCALEOPTIONS_HINT_DECSEP = 0x00000008;
class SvtSysLocaleOptions_Impl;
class SvtListener;
@@ -54,12 +56,14 @@ class UNOTOOLS_DLLPUBLIC SvtSysLocaleOptions: public utl::detail::Options
static sal_Int32 nRefCount;
UNOTOOLS_DLLPRIVATE static ::osl::Mutex& GetMutex();
+ virtual void ConfigurationChanged( utl::ConfigurationBroadcaster* p, sal_uInt32 nHint );
public:
enum EOption
{
E_LOCALE,
+ E_UILOCALE,
E_CURRENCY
};
SvtSysLocaleOptions();
@@ -102,6 +106,12 @@ public:
/// The config string may be empty to denote the SYSTEM locale
const ::rtl::OUString& GetLocaleConfigString() const;
void SetLocaleConfigString( const ::rtl::OUString& rStr );
+ com::sun::star::lang::Locale GetLocale() const;
+
+ /// The config string may be empty to denote the SYSTEM locale
+ const ::rtl::OUString& GetUILocaleConfigString() const;
+ void SetUILocaleConfigString( const ::rtl::OUString& rStr );
+ com::sun::star::lang::Locale GetUILocale() const;
/// The config string may be empty to denote the default currency of the locale
const ::rtl::OUString& GetCurrencyConfigString() const;
@@ -113,11 +123,6 @@ public:
// 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,
diff --git a/unotools/source/config/cacheoptions.cxx b/unotools/source/config/cacheoptions.cxx
index c226e8b80921..dc8031ea0078 100644
--- a/unotools/source/config/cacheoptions.cxx
+++ b/unotools/source/config/cacheoptions.cxx
@@ -94,6 +94,7 @@ public:
//---------------------------------------------------------------------------------------------------------
virtual void Commit();
+ virtual void Notify( const com::sun::star::uno::Sequence< rtl::OUString >& aPropertyNames );
//---------------------------------------------------------------------------------------------------------
// public interface
@@ -247,6 +248,10 @@ void SvtCacheOptions_Impl::Commit()
PutProperties( aSeqNames, aSeqValues );
}
+void SvtCacheOptions_Impl::Notify( const Sequence< rtl::OUString >& )
+{
+}
+
//*****************************************************************************************************************
// public method
//*****************************************************************************************************************
diff --git a/unotools/source/config/configitem.cxx b/unotools/source/config/configitem.cxx
index ad83b9b79cae..3d70f99f4ec0 100644
--- a/unotools/source/config/configitem.cxx
+++ b/unotools/source/config/configitem.cxx
@@ -83,6 +83,13 @@ catch(Exception& rEx) \
#define CATCH_INFO(a) catch(Exception& ){}
#endif
+/*
+ The ConfigChangeListener_Impl receives notifications from the configuration about changes that
+ have happened. It forwards this notification to the ConfigItem it knows a pParent by calling its
+ "CallNotify" method. As ConfigItems are most probably not thread safe, the SolarMutex is acquired
+ before doing so.
+*/
+
namespace utl{
class ConfigChangeListener_Impl : public cppu::WeakImplHelper1
<
@@ -280,13 +287,6 @@ ConfigItem::~ConfigItem()
/* -----------------------------29.08.00 12:52--------------------------------
---------------------------------------------------------------------------*/
-void ConfigItem::Commit()
-{
- OSL_ENSURE(sal_False, "Base class called");
-}
-/* -----------------------------29.08.00 12:52--------------------------------
-
- ---------------------------------------------------------------------------*/
void ConfigItem::ReleaseConfigMgr()
{
Reference<XHierarchicalNameAccess> xHierarchyAccess = GetTree();
@@ -308,18 +308,13 @@ void ConfigItem::ReleaseConfigMgr()
---------------------------------------------------------------------------*/
void ConfigItem::CallNotify( const com::sun::star::uno::Sequence<OUString>& rPropertyNames )
{
+ // the call is forwarded to the virtual Notify() method
+ // it is pure virtual, so all classes deriving from ConfigItem have to decide how they
+ // want to notify listeners
if(!IsInValueChange() || pImpl->bEnableInternalNotification)
Notify(rPropertyNames);
- NotifyListeners();
}
-/* -----------------------------29.08.00 12:52--------------------------------
-
- ---------------------------------------------------------------------------*/
-void ConfigItem::Notify( const com::sun::star::uno::Sequence<OUString>& /*rPropertyNames*/)
-{
- OSL_ENSURE(sal_False, "Base class called");
-}
/* -----------------------------12.12.00 17:09--------------------------------
---------------------------------------------------------------------------*/
diff --git a/unotools/source/config/defaultoptions.cxx b/unotools/source/config/defaultoptions.cxx
index 36c79b451f45..baaa4a220a93 100644
--- a/unotools/source/config/defaultoptions.cxx
+++ b/unotools/source/config/defaultoptions.cxx
@@ -111,6 +111,8 @@ public:
SvtDefaultOptions_Impl();
String GetDefaultPath( USHORT nId ) const;
+ virtual void Commit();
+ virtual void Notify( const com::sun::star::uno::Sequence<rtl::OUString>& aPropertyNames);
};
// global ----------------------------------------------------------------
@@ -189,6 +191,16 @@ Sequence< OUString > GetDefaultPropertyNames()
return aNames;
}
+void SvtDefaultOptions_Impl::Notify( const Sequence< rtl::OUString >& )
+{
+ // no notification, will never be changed
+}
+
+void SvtDefaultOptions_Impl::Commit()
+{
+ // will never be changed
+}
+
// class SvtDefaultOptions_Impl ------------------------------------------
String SvtDefaultOptions_Impl::GetDefaultPath( USHORT nId ) const
diff --git a/unotools/source/config/fltrcfg.cxx b/unotools/source/config/fltrcfg.cxx
index 7050e4734401..a0870ff6a8a5 100644
--- a/unotools/source/config/fltrcfg.cxx
+++ b/unotools/source/config/fltrcfg.cxx
@@ -81,6 +81,7 @@ public:
bSaveVBA(sal_False) {}
~SvtAppFilterOptions_Impl();
virtual void Commit();
+ virtual void Notify( const com::sun::star::uno::Sequence<rtl::OUString>& aPropertyNames);
void Load();
sal_Bool IsLoad() const {return bLoadVBA;}
@@ -125,6 +126,13 @@ void SvtAppFilterOptions_Impl::Commit()
PutProperties(aNames, aValues);
}
+
+void SvtAppFilterOptions_Impl::Notify( const Sequence< rtl::OUString >& )
+{
+ // no listeners supported yet
+}
+
+
/* -----------------------------22.01.01 10:38--------------------------------
---------------------------------------------------------------------------*/
diff --git a/unotools/source/config/historyoptions.cxx b/unotools/source/config/historyoptions.cxx
index 73d006a27507..0a28884e24c2 100644
--- a/unotools/source/config/historyoptions.cxx
+++ b/unotools/source/config/historyoptions.cxx
@@ -648,7 +648,7 @@ SvtHistoryOptions::SvtHistoryOptions()
// ... and initialize ouer data container only if it not already exist!
if( m_pDataContainer == NULL )
{
- RTL_LOGFILE_CONTEXT(aLog, "svtools ( ??? ) ::SvtHistoryOptions_Impl::ctor()");
+ RTL_LOGFILE_CONTEXT(aLog, "unotools ( ??? ) ::SvtHistoryOptions_Impl::ctor()");
m_pDataContainer = new SvtHistoryOptions_Impl;
ItemHolder1::holdConfigItem(E_HISTORYOPTIONS);
diff --git a/unotools/source/config/javaoptions.cxx b/unotools/source/config/javaoptions.cxx
index 91a74f43b886..0eec89a31782 100644
--- a/unotools/source/config/javaoptions.cxx
+++ b/unotools/source/config/javaoptions.cxx
@@ -57,6 +57,7 @@ public:
SvtExecAppletsItem_Impl();
virtual void Commit();
+ void Notify( const Sequence< rtl::OUString >& );
sal_Bool IsExecuteApplets() const {return bExecute;}
void SetExecuteApplets(sal_Bool bSet);
@@ -108,6 +109,10 @@ void SvtExecAppletsItem_Impl::Commit()
PutProperties(aNames, aValues);
}
+void SvtExecAppletsItem_Impl::Notify( const Sequence< rtl::OUString >& )
+{
+ // no listeners supported yet
+}
struct SvtJavaOptions_Impl
{
diff --git a/unotools/source/config/lingucfg.cxx b/unotools/source/config/lingucfg.cxx
index 25da00dd4a26..d4eff83efec6 100644
--- a/unotools/source/config/lingucfg.cxx
+++ b/unotools/source/config/lingucfg.cxx
@@ -229,6 +229,7 @@ SvtLinguConfigItem::~SvtLinguConfigItem()
void SvtLinguConfigItem::Notify( const uno::Sequence< OUString > &rPropertyNames )
{
LoadOptions( rPropertyNames );
+ NotifyListeners(0);
}
@@ -573,6 +574,7 @@ BOOL SvtLinguConfigItem::SetProperty( INT32 nPropertyHandle, const uno::Any &rVa
if (bMod)
SetModified();
+ NotifyListeners(0);
return bSucc;
}
@@ -592,6 +594,7 @@ BOOL SvtLinguConfigItem::SetOptions( const SvtLinguOptions &rOptions )
aOpt = rOptions;
SetModified();
+ NotifyListeners(0);
return TRUE;
}
diff --git a/unotools/source/config/localisationoptions.cxx b/unotools/source/config/localisationoptions.cxx
index a341021ca926..2ac2524e7d08 100644
--- a/unotools/source/config/localisationoptions.cxx
+++ b/unotools/source/config/localisationoptions.cxx
@@ -271,6 +271,8 @@ void SvtLocalisationOptions_Impl::Notify( const Sequence< OUString >& seqPropert
else DBG_ASSERT( sal_False, "SvtLocalisationOptions_Impl::Notify()\nUnkown property detected ... I can't handle these!\n" );
#endif
}
+
+ NotifyListeners(0);
}
//*****************************************************************************************************************
diff --git a/unotools/source/config/options.cxx b/unotools/source/config/options.cxx
index b4e9aec8c6dd..5bd2ed46f7ec 100644
--- a/unotools/source/config/options.cxx
+++ b/unotools/source/config/options.cxx
@@ -46,6 +46,7 @@ using utl::ConfigurationBroadcaster;
ConfigurationBroadcaster::ConfigurationBroadcaster()
: mpList(0)
, m_nBroadcastBlocked( 0 )
+, m_nBlockedHint( 0 )
{
}
@@ -67,39 +68,42 @@ void ConfigurationBroadcaster::RemoveListener( utl::ConfigurationListener* pList
mpList->Remove( pListener );
}
-void ConfigurationBroadcaster::NotifyListeners()
+void ConfigurationBroadcaster::NotifyListeners( sal_uInt32 nHint )
{
-// if ( m_nBroadcastBlocked )
-// m_nBlockedHint |= nHint;
-// else
- if (!m_nBroadcastBlocked)
+ if ( m_nBroadcastBlocked )
+ m_nBlockedHint |= nHint;
+ else
{
+ nHint |= m_nBlockedHint;
+ m_nBlockedHint = 0;
if ( mpList )
for ( sal_uInt32 n=0; n<mpList->Count(); n++ )
- mpList->GetObject(n)->ConfigurationChanged(this);
+ mpList->GetObject(n)->ConfigurationChanged( this, nHint );
}
}
-Options::Options()
+void ConfigurationBroadcaster::BlockBroadcasts( bool bBlock )
{
+ if ( bBlock )
+ ++m_nBroadcastBlocked;
+ else if ( m_nBroadcastBlocked )
+ {
+ if ( --m_nBroadcastBlocked == 0 )
+ NotifyListeners( 0 );
+ }
}
-Options::~Options()
+Options::Options()
{
}
-void Options::ConfigurationChanged( utl::ConfigurationBroadcaster* )
+Options::~Options()
{
- NotifyListeners();
}
-void ConfigurationBroadcaster::BlockBroadcasts( bool bBlock )
+void Options::ConfigurationChanged( ConfigurationBroadcaster* p, sal_uInt32 nHint )
{
- if ( bBlock )
- ++m_nBroadcastBlocked;
- else if ( m_nBroadcastBlocked )
- {
- if ( --m_nBroadcastBlocked == 0 )
- NotifyListeners();
- }
+ NotifyListeners( nHint );
}
+
+
diff --git a/unotools/source/config/printwarningoptions.cxx b/unotools/source/config/printwarningoptions.cxx
index c64064c8fadc..29dfabd45ea7 100644
--- a/unotools/source/config/printwarningoptions.cxx
+++ b/unotools/source/config/printwarningoptions.cxx
@@ -91,6 +91,7 @@ public:
//---------------------------------------------------------------------------------------------------------
virtual void Commit();
+ virtual void Notify( const com::sun::star::uno::Sequence< rtl::OUString >& aPropertyNames );
//---------------------------------------------------------------------------------------------------------
// public interface
@@ -242,6 +243,10 @@ void SvtPrintWarningOptions_Impl::Commit()
PutProperties( aSeqNames, aSeqValues );
}
+void SvtPrintWarningOptions_Impl::Notify( const Sequence< rtl::OUString >& )
+{
+}
+
//*****************************************************************************************************************
// private method
//*****************************************************************************************************************
diff --git a/unotools/source/config/searchopt.cxx b/unotools/source/config/searchopt.cxx
index 7ca888e8ef7b..01fbd9a3216d 100644
--- a/unotools/source/config/searchopt.cxx
+++ b/unotools/source/config/searchopt.cxx
@@ -75,6 +75,7 @@ public:
// ConfigItem
virtual void Commit();
+ virtual void Notify( const com::sun::star::uno::Sequence< rtl::OUString >& aPropertyNames );
BOOL GetFlag( USHORT nOffset ) const;
void SetFlag( USHORT nOffset, BOOL bVal );
@@ -104,6 +105,10 @@ void SvtSearchOptions_Impl::Commit()
Save();
}
+void SvtSearchOptions_Impl::Notify( const Sequence< rtl::OUString >& )
+{
+}
+
BOOL SvtSearchOptions_Impl::GetFlag( USHORT nOffset ) const
{
diff --git a/unotools/source/config/sourceviewconfig.cxx b/unotools/source/config/sourceviewconfig.cxx
index 46c926ffb86e..3de0276643bf 100644
--- a/unotools/source/config/sourceviewconfig.cxx
+++ b/unotools/source/config/sourceviewconfig.cxx
@@ -191,7 +191,7 @@ void SourceViewConfig_Impl::Commit()
}
PutProperties( aNames, aValues );
- NotifyListeners();
+ NotifyListeners(0);
}
/*-- 28.08.2002 16:32:19---------------------------------------------------
diff --git a/unotools/source/config/syslocaleoptions.cxx b/unotools/source/config/syslocaleoptions.cxx
index 3815136b27f0..6c4071709e02 100644
--- a/unotools/source/config/syslocaleoptions.cxx
+++ b/unotools/source/config/syslocaleoptions.cxx
@@ -31,21 +31,20 @@
// 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 <com/sun/star/uno/Sequence.hxx>
#include <rtl/ustrbuf.hxx>
#include <rtl/instance.hxx>
+#include <rtl/logfile.hxx>
+#include <i18npool/mslangid.hxx>
+#include <tools/string.hxx>
+#include <tools/debug.hxx>
+#include <unotools/syslocaleoptions.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;
@@ -66,20 +65,18 @@ namespace
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_aUILocaleString; // en-US or de-DE or empty for SYSTEM
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_bROUILocale;
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();
@@ -90,8 +87,10 @@ public:
const OUString& GetLocaleString() const
{ return m_aLocaleString; }
void SetLocaleString( const OUString& rStr );
- LanguageType GetLocaleLanguageType() const
- { return m_eLocaleLanguageType; }
+
+ const OUString& GetUILocaleString() const
+ { return m_aUILocaleString; }
+ void SetUILocaleString( const OUString& rStr );
const OUString& GetCurrencyString() const
{ return m_aCurrencyString; }
@@ -104,23 +103,26 @@ public:
};
-#define ROOTNODE_SYSLOCALE OUString(RTL_CONSTASCII_USTRINGPARAM("Setup/L10N"))
+#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 PROPERTYNAME_LOCALE OUString(RTL_CONSTASCII_USTRINGPARAM("ooSetupSystemLocale"))
+#define PROPERTYNAME_UILOCALE OUString(RTL_CONSTASCII_USTRINGPARAM("ooLocale"))
+#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 PROPERTYHANDLE_LOCALE 0
+#define PROPERTYHANDLE_UILOCALE 1
+#define PROPERTYHANDLE_CURRENCY 2
+#define PROPERTYHANDLE_DECIMALSEPARATOR 3
-#define PROPERTYCOUNT 3
+#define PROPERTYCOUNT 4
const Sequence< OUString > SvtSysLocaleOptions_Impl::GetPropertyNames()
{
static const OUString pProperties[] =
{
PROPERTYNAME_LOCALE,
+ PROPERTYNAME_UILOCALE,
PROPERTYNAME_CURRENCY,
PROPERTYNAME_DECIMALSEPARATOR
};
@@ -128,7 +130,6 @@ const Sequence< OUString > SvtSysLocaleOptions_Impl::GetPropertyNames()
return seqPropertyNames;
}
-
// -----------------------------------------------------------------------
SvtSysLocaleOptions_Impl::SvtSysLocaleOptions_Impl()
@@ -136,13 +137,12 @@ SvtSysLocaleOptions_Impl::SvtSysLocaleOptions_Impl()
, m_nBlockedHint( 0 )
, m_bDecimalSeparator( sal_True )
, m_bROLocale(CFG_READONLY_DEFAULT)
+ , m_bROUILocale(CFG_READONLY_DEFAULT)
, m_bROCurrency(CFG_READONLY_DEFAULT)
, m_bRODecimalSeparator(sal_False)
{
- if ( !IsValidConfigMgr() )
- ChangeLocaleSettings(); // assume SYSTEM defaults during Setup
- else
+ if ( IsValidConfigMgr() )
{
const Sequence< OUString > aNames = GetPropertyNames();
Sequence< Any > aValues = GetProperties( aNames );
@@ -172,6 +172,18 @@ SvtSysLocaleOptions_Impl::SvtSysLocaleOptions_Impl()
m_bROLocale = pROStates[nProp];
}
break;
+ case PROPERTYHANDLE_UILOCALE :
+ {
+ OUString aStr;
+ if ( pValues[nProp] >>= aStr )
+ m_aUILocaleString = aStr;
+ else
+ {
+ DBG_ERRORFILE( "Wrong property type!" );
+ }
+ m_bROUILocale = pROStates[nProp];
+ }
+ break;
case PROPERTYHANDLE_CURRENCY :
{
OUString aStr;
@@ -203,7 +215,6 @@ SvtSysLocaleOptions_Impl::SvtSysLocaleOptions_Impl()
}
}
// UpdateMiscSettings_Impl();
- ChangeLocaleSettings();
EnableNotification( aNames );
}
}
@@ -226,6 +237,11 @@ sal_Bool SvtSysLocaleOptions_Impl::IsReadOnly( SvtSysLocaleOptions::EOption eOpt
bReadOnly = m_bROLocale;
break;
}
+ case SvtSysLocaleOptions::E_UILOCALE :
+ {
+ bReadOnly = m_bROUILocale;
+ break;
+ }
case SvtSysLocaleOptions::E_CURRENCY :
{
bReadOnly = m_bROCurrency;
@@ -236,25 +252,6 @@ sal_Bool SvtSysLocaleOptions_Impl::IsReadOnly( SvtSysLocaleOptions::EOption eOpt
}
-/*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();
@@ -281,9 +278,19 @@ void SvtSysLocaleOptions_Impl::Commit()
}
}
break;
+ case PROPERTYHANDLE_UILOCALE :
+ {
+ if (!m_bROUILocale)
+ {
+ pNames[nRealCount] = aOrgNames[nProp];
+ pValues[nRealCount] <<= m_aUILocaleString;
+ ++nRealCount;
+ }
+ }
+ break;
case PROPERTYHANDLE_CURRENCY :
{
- if (!m_bROLocale)
+ if (!m_bROCurrency)
{
pNames[nRealCount] = aOrgNames[nProp];
pValues[nRealCount] <<= m_aCurrencyString;
@@ -317,36 +324,29 @@ void SvtSysLocaleOptions_Impl::SetLocaleString( const OUString& rStr )
m_aLocaleString = rStr;
SetModified();
ULONG nHint = SYSLOCALEOPTIONS_HINT_LOCALE;
- nHint |= ChangeLocaleSettings();
- //Broadcast( nHint );
- NotifyListeners();
+ if ( !m_aCurrencyString.getLength() )
+ nHint |= SYSLOCALEOPTIONS_HINT_CURRENCY;
+ NotifyListeners( nHint );
}
}
-
-ULONG SvtSysLocaleOptions_Impl::ChangeLocaleSettings()
+void SvtSysLocaleOptions_Impl::SetUILocaleString( const OUString& rStr )
{
- // 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;
+ if (!m_bROUILocale && rStr != m_aUILocaleString )
+ {
+ m_aUILocaleString = rStr;
+ SetModified();
+ NotifyListeners( SYSLOCALEOPTIONS_HINT_UILOCALE );
+ }
}
-
void SvtSysLocaleOptions_Impl::SetCurrencyString( const OUString& rStr )
{
if (!m_bROCurrency && rStr != m_aCurrencyString )
{
m_aCurrencyString = rStr;
SetModified();
- //Broadcast( SYSLOCALEOPTIONS_HINT_CURRENCY );
- NotifyListeners();
+ NotifyListeners( SYSLOCALEOPTIONS_HINT_CURRENCY );
}
}
@@ -356,20 +356,10 @@ void SvtSysLocaleOptions_Impl::SetDecimalSeparatorAsLocale( sal_Bool bSet)
{
m_bDecimalSeparator = bSet;
SetModified();
- //UpdateMiscSettings_Impl();
- NotifyListeners();
+ NotifyListeners( SYSLOCALEOPTIONS_HINT_DECSEP );
}
}
-
-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;
@@ -384,7 +374,15 @@ void SvtSysLocaleOptions_Impl::Notify( const Sequence< rtl::OUString >& seqPrope
seqValues[nProp] >>= m_aLocaleString;
m_bROLocale = seqROStates[nProp];
nHint |= SYSLOCALEOPTIONS_HINT_LOCALE;
- nHint |= ChangeLocaleSettings();
+ if ( !m_aCurrencyString.getLength() )
+ nHint |= SYSLOCALEOPTIONS_HINT_CURRENCY;
+ }
+ if( seqPropertyNames[nProp] == PROPERTYNAME_UILOCALE )
+ {
+ DBG_ASSERT( seqValues[nProp].getValueTypeClass() == TypeClass_STRING, "Locale property type" );
+ seqValues[nProp] >>= m_aUILocaleString;
+ m_bROUILocale = seqROStates[nProp];
+ nHint |= SYSLOCALEOPTIONS_HINT_UILOCALE;
}
else if( seqPropertyNames[nProp] == PROPERTYNAME_CURRENCY )
{
@@ -400,8 +398,7 @@ void SvtSysLocaleOptions_Impl::Notify( const Sequence< rtl::OUString >& seqPrope
}
}
if ( nHint )
- //Broadcast( nHint );
- NotifyListeners();
+ NotifyListeners( nHint );
}
// ====================================================================
@@ -417,12 +414,14 @@ SvtSysLocaleOptions::SvtSysLocaleOptions()
ItemHolder1::holdConfigItem(E_SYSLOCALEOPTIONS);
}
++nRefCount;
+ pOptions->AddListener(this);
}
SvtSysLocaleOptions::~SvtSysLocaleOptions()
{
MutexGuard aGuard( GetMutex() );
+ pOptions->RemoveListener(this);
if ( !--nRefCount )
{
delete pOptions;
@@ -477,13 +476,23 @@ const OUString& SvtSysLocaleOptions::GetLocaleConfigString() const
return pOptions->GetLocaleString();
}
-
void SvtSysLocaleOptions::SetLocaleConfigString( const OUString& rStr )
{
MutexGuard aGuard( GetMutex() );
pOptions->SetLocaleString( rStr );
}
+const OUString& SvtSysLocaleOptions::GetUILocaleConfigString() const
+{
+ MutexGuard aGuard( GetMutex() );
+ return pOptions->GetUILocaleString();
+}
+
+void SvtSysLocaleOptions::SetUILocaleConfigString( const OUString& rStr )
+{
+ MutexGuard aGuard( GetMutex() );
+ pOptions->SetUILocaleString( rStr );
+}
const OUString& SvtSysLocaleOptions::GetCurrencyConfigString() const
{
@@ -499,11 +508,6 @@ void SvtSysLocaleOptions::SetCurrencyConfigString( const OUString& rStr )
}
-LanguageType SvtSysLocaleOptions::GetLocaleLanguageType() const
-{
- MutexGuard aGuard( GetMutex() );
- return pOptions->GetLocaleLanguageType();
-}
/*-- 11.02.2004 13:31:41---------------------------------------------------
@@ -582,3 +586,45 @@ const Link& SvtSysLocaleOptions::GetCurrencyChangeLink()
return CurrencyChangeLink::get();
}
+
+void SvtSysLocaleOptions::ConfigurationChanged( utl::ConfigurationBroadcaster* p, sal_uInt32 nHint )
+{
+ if ( nHint & SYSLOCALEOPTIONS_HINT_CURRENCY )
+ {
+ const Link& rLink = GetCurrencyChangeLink();
+ if ( rLink.IsSet() )
+ rLink.Call( NULL );
+ }
+
+ ::utl::detail::Options::ConfigurationChanged( p, nHint );
+}
+
+com::sun::star::lang::Locale lcl_str_to_locale( const ::rtl::OUString rStr )
+{
+ com::sun::star::lang::Locale aRet;
+ if ( rStr.getLength() )
+ {
+ aRet = com::sun::star::lang::Locale();
+ sal_Int32 nSep = rStr.indexOf('-');
+ if (nSep < 0)
+ aRet.Language = rStr;
+ else
+ {
+ aRet.Language = rStr.copy(0, nSep);
+ if (nSep < rStr.getLength())
+ aRet.Country = rStr.copy(nSep+1, rStr.getLength() - (nSep+1));
+ }
+ }
+
+ return aRet;
+}
+
+com::sun::star::lang::Locale SvtSysLocaleOptions::GetLocale() const
+{
+ return lcl_str_to_locale( GetLocaleConfigString() );
+}
+
+com::sun::star::lang::Locale SvtSysLocaleOptions::GetUILocale() const
+{
+ return lcl_str_to_locale( GetUILocaleConfigString() );
+}
diff --git a/unotools/source/config/undoopt.cxx b/unotools/source/config/undoopt.cxx
index 9b1712032e18..c2c79120995f 100644
--- a/unotools/source/config/undoopt.cxx
+++ b/unotools/source/config/undoopt.cxx
@@ -94,7 +94,7 @@ void SvtUndoOptions_Impl::Commit()
}
PutProperties( m_aPropertyNames, aValues );
- NotifyListeners();
+ NotifyListeners(0);
}
// -----------------------------------------------------------------------
diff --git a/unotools/source/config/useroptions.cxx b/unotools/source/config/useroptions.cxx
index 3b62e8225730..e06d6a794e20 100644
--- a/unotools/source/config/useroptions.cxx
+++ b/unotools/source/config/useroptions.cxx
@@ -772,7 +772,7 @@ void SvtUserOptions_Impl::SetApartment( const ::rtl::OUString& sApartment )
void SvtUserOptions_Impl::Notify()
{
- NotifyListeners();
+ NotifyListeners(0);
}
// -----------------------------------------------------------------------
diff --git a/unotools/source/misc/syslocale.cxx b/unotools/source/misc/syslocale.cxx
index a299867f83e8..f108cd2ed3df 100644
--- a/unotools/source/misc/syslocale.cxx
+++ b/unotools/source/misc/syslocale.cxx
@@ -50,53 +50,61 @@ sal_Int32 SvtSysLocale::nRefCount = 0;
class SvtSysLocale_Impl : public utl::ConfigurationListener
{
- friend class SvtSysLocale;
-
+public:
SvtSysLocaleOptions aSysLocaleOptions;
LocaleDataWrapper* pLocaleData;
CharClass* pCharClass;
com::sun::star::lang::Locale maLocale;
+ com::sun::star::lang::Locale maUILocale;
+ LanguageType meLanguage;
+ LanguageType meUILanguage;
-public:
- SvtSysLocale_Impl();
- virtual ~SvtSysLocale_Impl();
+ SvtSysLocale_Impl();
+ virtual ~SvtSysLocale_Impl();
- CharClass* GetCharClass();
- SvtSysLocaleOptions& GetOptions() { return aSysLocaleOptions; }
- void ConfigurationChanged( utl::ConfigurationBroadcaster* );
- com::sun::star::lang::Locale GetLocale();
+ CharClass* GetCharClass();
+ virtual void ConfigurationChanged( utl::ConfigurationBroadcaster*, sal_uInt32 );
+ void GetLocale();
+ void GetUILocale();
};
-com::sun::star::lang::Locale SvtSysLocale_Impl::GetLocale()
+void 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;
+ maLocale = aSysLocaleOptions.GetLocale();
+ if ( maLocale.Language.getLength() )
+ {
+ meLanguage = MsLangId::convertLocaleToLanguage( maLocale );
+ }
else
{
- aLocale.Language = aLocaleString.copy(0, nSep);
- if (nSep < aLocaleString.getLength())
- aLocale.Country = aLocaleString.copy(nSep+1, aLocaleString.getLength() - (nSep+1));
+ meLanguage = MsLangId::getSystemLanguage();
+ MsLangId::convertLanguageToLocale( meLanguage, maLocale );
}
+}
- return aLocale;
+void SvtSysLocale_Impl::GetUILocale()
+{
+ maLocale = aSysLocaleOptions.GetLocale();
+ if ( maUILocale.Language.getLength() )
+ {
+ meUILanguage = MsLangId::convertLocaleToLanguage( maUILocale );
+ }
+ else
+ {
+ meUILanguage = MsLangId::getSystemUILanguage();
+ MsLangId::convertLanguageToLocale( meUILanguage, maUILocale );
+ }
}
// -----------------------------------------------------------------------
SvtSysLocale_Impl::SvtSysLocale_Impl() : pCharClass(NULL)
{
- // first initialize maLocale with system locale
- MsLangId::convertLanguageToLocale( MsLangId::getSystemLanguage(), maLocale );
+ GetLocale();
+ GetUILocale();
- pLocaleData = new LocaleDataWrapper( ::comphelper::getProcessServiceFactory(), GetLocale() );
+ pLocaleData = new LocaleDataWrapper( ::comphelper::getProcessServiceFactory(), maLocale );
// listen for further changes
aSysLocaleOptions.AddListener( this );
@@ -113,16 +121,22 @@ SvtSysLocale_Impl::~SvtSysLocale_Impl()
CharClass* SvtSysLocale_Impl::GetCharClass()
{
if ( !pCharClass )
- pCharClass = new CharClass(::comphelper::getProcessServiceFactory(), GetLocale() );
+ pCharClass = new CharClass(::comphelper::getProcessServiceFactory(), maLocale );
return pCharClass;
}
-void SvtSysLocale_Impl::ConfigurationChanged( utl::ConfigurationBroadcaster* )
+void SvtSysLocale_Impl::ConfigurationChanged( utl::ConfigurationBroadcaster*, sal_uInt32 nHint )
{
MutexGuard aGuard( SvtSysLocale::GetMutex() );
- lang::Locale aLocale = GetLocale();
- pLocaleData->setLocale( aLocale );
- GetCharClass()->setLocale( aLocale );
+ if ( nHint & SYSLOCALEOPTIONS_HINT_LOCALE )
+ {
+ GetLocale();
+ pLocaleData->setLocale( maLocale );
+ GetCharClass()->setLocale( maLocale );
+ }
+
+ if ( nHint & SYSLOCALEOPTIONS_HINT_UILOCALE )
+ GetUILocale();
}
// ====================================================================
@@ -191,15 +205,27 @@ const CharClass* SvtSysLocale::GetCharClassPtr() const
SvtSysLocaleOptions& SvtSysLocale::GetOptions() const
{
- return pImpl->GetOptions();
+ return pImpl->aSysLocaleOptions;
}
com::sun::star::lang::Locale SvtSysLocale::GetLocale() const
{
- return pImpl->GetLocale();
+ return pImpl->maLocale;
}
LanguageType SvtSysLocale::GetLanguage() const
{
- return MsLangId::convertLocaleToLanguage( pImpl->GetLocale() );
-} \ No newline at end of file
+ return pImpl->meLanguage;
+}
+
+com::sun::star::lang::Locale SvtSysLocale::GetUILocale() const
+{
+ return pImpl->maUILocale;
+}
+
+LanguageType SvtSysLocale::GetUILanguage() const
+{
+ return pImpl->meUILanguage;
+}
+
+