summaryrefslogtreecommitdiff
path: root/unotools/inc
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/inc
parente0cea8e136b36724c6b1298e6546a4dbb8f09d00 (diff)
#i103496#: move SysLocale stuff to unotools
Diffstat (limited to 'unotools/inc')
-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
5 files changed, 317 insertions, 1 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