2001-06-18 08:32:41 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-10 19:04:32 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2001-06-18 08:32:41 +00:00
|
|
|
*
|
2008-04-10 19:04:32 +00:00
|
|
|
* Copyright 2008 by Sun Microsystems, Inc.
|
2001-06-18 08:32:41 +00:00
|
|
|
*
|
2008-04-10 19:04:32 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2001-06-18 08:32:41 +00:00
|
|
|
*
|
2008-04-10 19:04:32 +00:00
|
|
|
* $RCSfile: syslocaleoptions.cxx,v $
|
|
|
|
* $Revision: 1.23 $
|
2001-06-18 08:32:41 +00:00
|
|
|
*
|
2008-04-10 19:04:32 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2001-06-18 08:32:41 +00:00
|
|
|
*
|
2008-04-10 19:04:32 +00:00
|
|
|
* 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.
|
2001-06-18 08:32:41 +00:00
|
|
|
*
|
2008-04-10 19:04:32 +00:00
|
|
|
* 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).
|
2001-06-18 08:32:41 +00:00
|
|
|
*
|
2008-04-10 19:04:32 +00:00
|
|
|
* 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.
|
2001-06-18 08:32:41 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2006-09-17 13:30:23 +00:00
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_svtools.hxx"
|
|
|
|
|
2005-04-13 09:50:11 +00:00
|
|
|
#ifdef SVL_DLLIMPLEMENTATION
|
|
|
|
#undef SVL_DLLIMPLEMENTATION
|
2004-06-16 09:09:43 +00:00
|
|
|
#endif
|
2005-04-13 09:50:11 +00:00
|
|
|
#define SVT_DLLIMPLEMENTATION
|
2001-06-18 08:32:41 +00:00
|
|
|
|
2007-06-27 20:17:26 +00:00
|
|
|
#include <svtools/syslocaleoptions.hxx>
|
2001-06-18 08:32:41 +00:00
|
|
|
#include <broadcast.hxx>
|
|
|
|
#include <listener.hxx>
|
2007-06-27 20:17:26 +00:00
|
|
|
#include <svtools/smplhint.hxx>
|
2006-04-07 14:57:36 +00:00
|
|
|
#include <i18npool/mslangid.hxx>
|
2001-06-18 08:32:41 +00:00
|
|
|
#include <tools/string.hxx>
|
|
|
|
#include <rtl/ustrbuf.hxx>
|
2004-06-25 16:25:24 +00:00
|
|
|
#include <rtl/instance.hxx>
|
2001-06-18 08:32:41 +00:00
|
|
|
#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>
|
2004-03-17 09:12:23 +00:00
|
|
|
#include <vcl/settings.hxx>
|
|
|
|
#include <vcl/svapp.hxx>
|
2005-04-13 09:50:11 +00:00
|
|
|
|
2004-11-15 16:23:45 +00:00
|
|
|
#include <rtl/logfile.hxx>
|
2005-04-13 09:50:11 +00:00
|
|
|
|
2004-11-15 16:23:45 +00:00
|
|
|
#include "itemholder2.hxx"
|
|
|
|
|
2001-06-18 08:32:41 +00:00
|
|
|
|
2003-03-27 13:40:07 +00:00
|
|
|
#define CFG_READONLY_DEFAULT sal_False
|
|
|
|
|
2001-06-18 08:32:41 +00:00
|
|
|
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;
|
2004-06-25 16:25:24 +00:00
|
|
|
namespace
|
|
|
|
{
|
|
|
|
struct CurrencyChangeLink
|
|
|
|
: public rtl::Static<Link, CurrencyChangeLink> {};
|
|
|
|
}
|
2001-06-18 08:32:41 +00:00
|
|
|
|
|
|
|
class SvtSysLocaleOptions_Impl : public utl::ConfigItem
|
|
|
|
{
|
2001-06-21 16:58:16 +00:00
|
|
|
OUString m_aLocaleString; // en-US or de-DE or empty for SYSTEM
|
|
|
|
LanguageType m_eLocaleLanguageType; // same for convenience access
|
2001-06-18 08:32:41 +00:00
|
|
|
OUString m_aCurrencyString; // USD-en-US or EUR-de-DE
|
|
|
|
SvtBroadcaster m_aBroadcaster;
|
2001-06-26 11:36:41 +00:00
|
|
|
ULONG m_nBlockedHint; // pending hints
|
|
|
|
sal_Int32 m_nBroadcastBlocked; // broadcast only if this is 0
|
2004-03-17 09:12:23 +00:00
|
|
|
sal_Bool m_bDecimalSeparator; //use decimal separator same as locale
|
|
|
|
|
2001-06-18 08:32:41 +00:00
|
|
|
|
2003-03-27 13:40:07 +00:00
|
|
|
sal_Bool m_bROLocale;
|
|
|
|
sal_Bool m_bROCurrency;
|
2004-03-17 09:12:23 +00:00
|
|
|
sal_Bool m_bRODecimalSeparator;
|
2003-03-27 13:40:07 +00:00
|
|
|
|
2001-06-18 08:32:41 +00:00
|
|
|
static const Sequence< /* const */ OUString > GetPropertyNames();
|
|
|
|
|
2004-03-17 09:12:23 +00:00
|
|
|
void UpdateMiscSettings_Impl();
|
2001-06-26 11:36:41 +00:00
|
|
|
ULONG ChangeLocaleSettings();
|
2001-06-21 16:58:16 +00:00
|
|
|
void ChangeDefaultCurrency() const;
|
2001-06-26 11:36:41 +00:00
|
|
|
void Broadcast( ULONG nHint );
|
2001-06-21 16:58:16 +00:00
|
|
|
|
2001-06-18 08:32:41 +00:00
|
|
|
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 );
|
2001-06-21 16:58:16 +00:00
|
|
|
LanguageType GetLocaleLanguageType() const
|
|
|
|
{ return m_eLocaleLanguageType; }
|
2001-06-18 08:32:41 +00:00
|
|
|
|
|
|
|
const OUString& GetCurrencyString() const
|
|
|
|
{ return m_aCurrencyString; }
|
|
|
|
void SetCurrencyString( const OUString& rStr );
|
|
|
|
|
2004-03-17 09:12:23 +00:00
|
|
|
sal_Bool IsDecimalSeparatorAsLocale() const { return m_bDecimalSeparator;}
|
|
|
|
void SetDecimalSeparatorAsLocale( sal_Bool bSet);
|
|
|
|
|
2001-06-18 08:32:41 +00:00
|
|
|
SvtBroadcaster& GetBroadcaster()
|
|
|
|
{ return m_aBroadcaster; }
|
2001-06-26 11:36:41 +00:00
|
|
|
void BlockBroadcasts( BOOL bBlock );
|
2003-03-27 13:40:07 +00:00
|
|
|
sal_Bool IsReadOnly( SvtSysLocaleOptions::EOption eOption ) const;
|
2001-06-18 08:32:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2001-06-22 07:24:50 +00:00
|
|
|
#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"))
|
2004-03-17 09:12:23 +00:00
|
|
|
#define PROPERTYNAME_DECIMALSEPARATOR OUString(RTL_CONSTASCII_USTRINGPARAM("DecimalSeparatorAsLocale"))
|
2001-06-18 08:32:41 +00:00
|
|
|
|
|
|
|
#define PROPERTYHANDLE_LOCALE 0
|
|
|
|
#define PROPERTYHANDLE_CURRENCY 1
|
2004-03-17 09:12:23 +00:00
|
|
|
#define PROPERTYHANDLE_DECIMALSEPARATOR 2
|
2001-06-18 08:32:41 +00:00
|
|
|
|
2004-03-17 09:12:23 +00:00
|
|
|
#define PROPERTYCOUNT 3
|
2001-06-18 08:32:41 +00:00
|
|
|
|
|
|
|
const Sequence< OUString > SvtSysLocaleOptions_Impl::GetPropertyNames()
|
|
|
|
{
|
|
|
|
static const OUString pProperties[] =
|
|
|
|
{
|
|
|
|
PROPERTYNAME_LOCALE,
|
2004-03-17 09:12:23 +00:00
|
|
|
PROPERTYNAME_CURRENCY,
|
|
|
|
PROPERTYNAME_DECIMALSEPARATOR
|
2001-06-18 08:32:41 +00:00
|
|
|
};
|
|
|
|
static const Sequence< OUString > seqPropertyNames( pProperties, PROPERTYCOUNT );
|
|
|
|
return seqPropertyNames;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
SvtSysLocaleOptions_Impl::SvtSysLocaleOptions_Impl()
|
|
|
|
: ConfigItem( ROOTNODE_SYSLOCALE )
|
2001-06-26 11:36:41 +00:00
|
|
|
, m_nBlockedHint( 0 )
|
|
|
|
, m_nBroadcastBlocked( 0 )
|
2006-06-19 19:49:04 +00:00
|
|
|
, m_bDecimalSeparator( sal_True )
|
2003-03-27 13:40:07 +00:00
|
|
|
, m_bROLocale(CFG_READONLY_DEFAULT)
|
|
|
|
, m_bROCurrency(CFG_READONLY_DEFAULT)
|
2004-03-17 09:12:23 +00:00
|
|
|
, m_bRODecimalSeparator(sal_False)
|
|
|
|
|
2001-06-18 08:32:41 +00:00
|
|
|
{
|
2002-09-23 12:44:43 +00:00
|
|
|
if ( !IsValidConfigMgr() )
|
|
|
|
ChangeLocaleSettings(); // assume SYSTEM defaults during Setup
|
|
|
|
else
|
2001-06-18 08:32:41 +00:00
|
|
|
{
|
2002-09-23 12:44:43 +00:00
|
|
|
const Sequence< OUString > aNames = GetPropertyNames();
|
|
|
|
Sequence< Any > aValues = GetProperties( aNames );
|
2003-03-27 13:40:07 +00:00
|
|
|
Sequence< sal_Bool > aROStates = GetReadOnlyStates( aNames );
|
2002-09-23 12:44:43 +00:00
|
|
|
const Any* pValues = aValues.getConstArray();
|
2003-03-27 13:40:07 +00:00
|
|
|
const sal_Bool* pROStates = aROStates.getConstArray();
|
2002-09-23 12:44:43 +00:00
|
|
|
DBG_ASSERT( aValues.getLength() == aNames.getLength(), "GetProperties failed" );
|
2003-03-27 13:40:07 +00:00
|
|
|
DBG_ASSERT( aROStates.getLength() == aNames.getLength(), "GetReadOnlyStates failed" );
|
|
|
|
if ( aValues.getLength() == aNames.getLength() && aROStates.getLength() == aNames.getLength() )
|
2001-06-18 08:32:41 +00:00
|
|
|
{
|
2002-09-23 12:44:43 +00:00
|
|
|
for ( sal_Int32 nProp = 0; nProp < aNames.getLength(); nProp++ )
|
2001-06-18 08:32:41 +00:00
|
|
|
{
|
2002-09-23 12:44:43 +00:00
|
|
|
DBG_ASSERT( pValues[nProp].hasValue(), "property value missing" );
|
|
|
|
if ( pValues[nProp].hasValue() )
|
2001-06-18 08:32:41 +00:00
|
|
|
{
|
2002-09-23 12:44:43 +00:00
|
|
|
switch ( nProp )
|
2001-06-18 08:32:41 +00:00
|
|
|
{
|
2002-09-23 12:44:43 +00:00
|
|
|
case PROPERTYHANDLE_LOCALE :
|
|
|
|
{
|
|
|
|
OUString aStr;
|
|
|
|
if ( pValues[nProp] >>= aStr )
|
|
|
|
m_aLocaleString = aStr;
|
|
|
|
else
|
2008-10-28 15:03:16 +00:00
|
|
|
{
|
2002-09-23 12:44:43 +00:00
|
|
|
DBG_ERRORFILE( "Wrong property type!" );
|
2008-10-28 15:03:16 +00:00
|
|
|
}
|
2003-03-27 13:40:07 +00:00
|
|
|
m_bROLocale = pROStates[nProp];
|
2002-09-23 12:44:43 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case PROPERTYHANDLE_CURRENCY :
|
|
|
|
{
|
|
|
|
OUString aStr;
|
|
|
|
if ( pValues[nProp] >>= aStr )
|
|
|
|
m_aCurrencyString = aStr;
|
|
|
|
else
|
2008-10-28 15:03:16 +00:00
|
|
|
{
|
2002-09-23 12:44:43 +00:00
|
|
|
DBG_ERRORFILE( "Wrong property type!" );
|
2008-10-28 15:03:16 +00:00
|
|
|
}
|
2003-03-27 13:40:07 +00:00
|
|
|
m_bROCurrency = pROStates[nProp];
|
2002-09-23 12:44:43 +00:00
|
|
|
}
|
2004-03-17 09:12:23 +00:00
|
|
|
break;
|
|
|
|
case PROPERTYHANDLE_DECIMALSEPARATOR:
|
|
|
|
{
|
2006-08-29 10:11:55 +00:00
|
|
|
sal_Bool bValue = sal_Bool();
|
2004-03-17 09:12:23 +00:00
|
|
|
if ( pValues[nProp] >>= bValue )
|
|
|
|
m_bDecimalSeparator = bValue;
|
|
|
|
else
|
2008-10-28 15:03:16 +00:00
|
|
|
{
|
2004-03-17 09:12:23 +00:00
|
|
|
DBG_ERRORFILE( "Wrong property type!" );
|
2008-10-28 15:03:16 +00:00
|
|
|
}
|
2004-03-17 09:12:23 +00:00
|
|
|
m_bRODecimalSeparator = pROStates[nProp];
|
|
|
|
}
|
|
|
|
break;
|
2002-09-23 12:44:43 +00:00
|
|
|
default:
|
2001-06-18 08:32:41 +00:00
|
|
|
DBG_ERRORFILE( "Wrong property type!" );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-03-17 09:12:23 +00:00
|
|
|
UpdateMiscSettings_Impl();
|
2002-09-23 12:44:43 +00:00
|
|
|
ChangeLocaleSettings();
|
|
|
|
EnableNotification( aNames );
|
2001-06-18 08:32:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SvtSysLocaleOptions_Impl::~SvtSysLocaleOptions_Impl()
|
|
|
|
{
|
|
|
|
if ( IsModified() )
|
|
|
|
Commit();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-26 11:36:41 +00:00
|
|
|
void SvtSysLocaleOptions_Impl::BlockBroadcasts( BOOL bBlock )
|
|
|
|
{
|
|
|
|
if ( bBlock )
|
|
|
|
++m_nBroadcastBlocked;
|
|
|
|
else if ( m_nBroadcastBlocked )
|
|
|
|
{
|
|
|
|
if ( --m_nBroadcastBlocked == 0 )
|
|
|
|
Broadcast( 0 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-03-27 13:40:07 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2001-06-26 11:36:41 +00:00
|
|
|
|
|
|
|
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 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-18 08:32:41 +00:00
|
|
|
void SvtSysLocaleOptions_Impl::Commit()
|
|
|
|
{
|
2003-03-27 13:40:07 +00:00
|
|
|
const Sequence< OUString > aOrgNames = GetPropertyNames();
|
|
|
|
sal_Int32 nOrgCount = aOrgNames.getLength();
|
|
|
|
|
|
|
|
Sequence< OUString > aNames( nOrgCount );
|
|
|
|
Sequence< Any > aValues( nOrgCount );
|
|
|
|
|
|
|
|
OUString* pNames = aNames.getArray();
|
2001-06-18 08:32:41 +00:00
|
|
|
Any* pValues = aValues.getArray();
|
2003-03-27 13:40:07 +00:00
|
|
|
sal_Int32 nRealCount = 0;
|
|
|
|
|
|
|
|
for ( sal_Int32 nProp = 0; nProp < nOrgCount; nProp++ )
|
2001-06-18 08:32:41 +00:00
|
|
|
{
|
|
|
|
switch ( nProp )
|
|
|
|
{
|
|
|
|
case PROPERTYHANDLE_LOCALE :
|
2003-03-27 13:40:07 +00:00
|
|
|
{
|
|
|
|
if (!m_bROLocale)
|
|
|
|
{
|
|
|
|
pNames[nRealCount] = aOrgNames[nProp];
|
|
|
|
pValues[nRealCount] <<= m_aLocaleString;
|
|
|
|
++nRealCount;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2001-06-18 08:32:41 +00:00
|
|
|
case PROPERTYHANDLE_CURRENCY :
|
2003-03-27 13:40:07 +00:00
|
|
|
{
|
|
|
|
if (!m_bROLocale)
|
|
|
|
{
|
|
|
|
pNames[nRealCount] = aOrgNames[nProp];
|
|
|
|
pValues[nRealCount] <<= m_aCurrencyString;
|
|
|
|
++nRealCount;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2004-03-17 09:12:23 +00:00
|
|
|
case PROPERTYHANDLE_DECIMALSEPARATOR:
|
|
|
|
if( !m_bRODecimalSeparator )
|
|
|
|
{
|
|
|
|
pNames[nRealCount] = aOrgNames[nProp];
|
|
|
|
pValues[nRealCount] <<= m_bDecimalSeparator;
|
|
|
|
++nRealCount;
|
|
|
|
}
|
|
|
|
break;
|
2001-06-18 08:32:41 +00:00
|
|
|
default:
|
|
|
|
DBG_ERRORFILE( "invalid index to save a path" );
|
|
|
|
}
|
|
|
|
}
|
2003-03-27 13:40:07 +00:00
|
|
|
aNames.realloc(nRealCount);
|
|
|
|
aValues.realloc(nRealCount);
|
2001-06-18 08:32:41 +00:00
|
|
|
PutProperties( aNames, aValues );
|
|
|
|
ClearModified();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SvtSysLocaleOptions_Impl::SetLocaleString( const OUString& rStr )
|
|
|
|
{
|
2003-03-27 13:40:07 +00:00
|
|
|
if (!m_bROLocale && rStr != m_aLocaleString )
|
2001-06-18 08:32:41 +00:00
|
|
|
{
|
|
|
|
m_aLocaleString = rStr;
|
|
|
|
SetModified();
|
2001-06-26 11:36:41 +00:00
|
|
|
ULONG nHint = SYSLOCALEOPTIONS_HINT_LOCALE;
|
|
|
|
nHint |= ChangeLocaleSettings();
|
|
|
|
Broadcast( nHint );
|
2001-06-18 08:32:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-26 11:36:41 +00:00
|
|
|
ULONG SvtSysLocaleOptions_Impl::ChangeLocaleSettings()
|
2001-06-21 16:58:16 +00:00
|
|
|
{
|
|
|
|
// An empty config value denotes SYSTEM locale
|
|
|
|
if ( m_aLocaleString.getLength() )
|
2006-04-07 14:57:36 +00:00
|
|
|
m_eLocaleLanguageType = MsLangId::convertIsoStringToLanguage( m_aLocaleString );
|
2001-06-21 16:58:16 +00:00
|
|
|
else
|
|
|
|
m_eLocaleLanguageType = LANGUAGE_SYSTEM;
|
2001-06-26 11:36:41 +00:00
|
|
|
ULONG nHint = 0;
|
|
|
|
// new locale and no fixed currency => locale default currency might change
|
|
|
|
if ( !m_aCurrencyString.getLength() )
|
|
|
|
nHint |= SYSLOCALEOPTIONS_HINT_CURRENCY;
|
|
|
|
return nHint;
|
2001-06-21 16:58:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-18 08:32:41 +00:00
|
|
|
void SvtSysLocaleOptions_Impl::SetCurrencyString( const OUString& rStr )
|
|
|
|
{
|
2003-03-27 13:40:07 +00:00
|
|
|
if (!m_bROCurrency && rStr != m_aCurrencyString )
|
2001-06-18 08:32:41 +00:00
|
|
|
{
|
|
|
|
m_aCurrencyString = rStr;
|
|
|
|
SetModified();
|
2001-06-26 11:36:41 +00:00
|
|
|
Broadcast( SYSLOCALEOPTIONS_HINT_CURRENCY );
|
2001-06-18 08:32:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-03-17 09:12:23 +00:00
|
|
|
void SvtSysLocaleOptions_Impl::SetDecimalSeparatorAsLocale( sal_Bool bSet)
|
|
|
|
{
|
|
|
|
if(bSet != m_bDecimalSeparator)
|
|
|
|
{
|
|
|
|
m_bDecimalSeparator = bSet;
|
|
|
|
SetModified();
|
|
|
|
UpdateMiscSettings_Impl();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-06-18 08:32:41 +00:00
|
|
|
|
|
|
|
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 );
|
2003-03-27 13:40:07 +00:00
|
|
|
Sequence< sal_Bool > seqROStates = GetReadOnlyStates( seqPropertyNames );
|
2001-06-18 08:32:41 +00:00
|
|
|
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;
|
2003-03-27 13:40:07 +00:00
|
|
|
m_bROLocale = seqROStates[nProp];
|
2001-06-18 08:32:41 +00:00
|
|
|
nHint |= SYSLOCALEOPTIONS_HINT_LOCALE;
|
2001-06-26 11:36:41 +00:00
|
|
|
nHint |= ChangeLocaleSettings();
|
2001-06-18 08:32:41 +00:00
|
|
|
}
|
|
|
|
else if( seqPropertyNames[nProp] == PROPERTYNAME_CURRENCY )
|
|
|
|
{
|
|
|
|
DBG_ASSERT( seqValues[nProp].getValueTypeClass() == TypeClass_STRING, "Currency property type" );
|
|
|
|
seqValues[nProp] >>= m_aCurrencyString;
|
2003-03-27 13:40:07 +00:00
|
|
|
m_bROCurrency = seqROStates[nProp];
|
2001-06-18 08:32:41 +00:00
|
|
|
nHint |= SYSLOCALEOPTIONS_HINT_CURRENCY;
|
|
|
|
}
|
2004-03-17 09:12:23 +00:00
|
|
|
else if( seqPropertyNames[nProp] == PROPERTYNAME_DECIMALSEPARATOR )
|
|
|
|
{
|
|
|
|
seqValues[nProp] >>= m_bDecimalSeparator;
|
|
|
|
m_bRODecimalSeparator = seqROStates[nProp];
|
|
|
|
UpdateMiscSettings_Impl();
|
|
|
|
}
|
2001-06-18 08:32:41 +00:00
|
|
|
}
|
|
|
|
if ( nHint )
|
2001-06-26 11:36:41 +00:00
|
|
|
Broadcast( nHint );
|
2001-06-18 08:32:41 +00:00
|
|
|
}
|
2004-03-17 09:12:23 +00:00
|
|
|
/* -----------------10.02.2004 15:25-----------------
|
2001-06-18 08:32:41 +00:00
|
|
|
|
2004-03-17 09:12:23 +00:00
|
|
|
--------------------------------------------------*/
|
|
|
|
void SvtSysLocaleOptions_Impl::UpdateMiscSettings_Impl()
|
|
|
|
{
|
|
|
|
AllSettings aAllSettings( Application::GetSettings() );
|
|
|
|
MiscSettings aMiscSettings = aAllSettings.GetMiscSettings();
|
|
|
|
aMiscSettings.SetEnableLocalizedDecimalSep(m_bDecimalSeparator);
|
|
|
|
aAllSettings.SetMiscSettings( aMiscSettings );
|
|
|
|
Application::SetSettings( aAllSettings );
|
|
|
|
}
|
2001-06-18 08:32:41 +00:00
|
|
|
|
|
|
|
// ====================================================================
|
|
|
|
|
|
|
|
SvtSysLocaleOptions::SvtSysLocaleOptions()
|
|
|
|
{
|
|
|
|
MutexGuard aGuard( GetMutex() );
|
|
|
|
if ( !pOptions )
|
2004-11-15 16:23:45 +00:00
|
|
|
{
|
2006-06-19 19:49:04 +00:00
|
|
|
RTL_LOGFILE_CONTEXT(aLog, "svtools ( ??? ) ::SvtSysLocaleOptions_Impl::ctor()");
|
2001-06-18 08:32:41 +00:00
|
|
|
pOptions = new SvtSysLocaleOptions_Impl;
|
2004-11-15 16:23:45 +00:00
|
|
|
|
2005-11-11 07:54:43 +00:00
|
|
|
ItemHolder2::holdConfigItem(E_SYSLOCALEOPTIONS);
|
2004-11-15 16:23:45 +00:00
|
|
|
}
|
2001-06-18 08:32:41 +00:00
|
|
|
++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 )
|
|
|
|
{
|
2007-08-01 09:55:53 +00:00
|
|
|
// #i77768# Due to a static reference in the toolkit lib
|
|
|
|
// we need a mutex that lives longer than the svtools library.
|
|
|
|
// Otherwise the dtor would use a destructed mutex!!
|
|
|
|
pMutex = new Mutex;
|
2001-06-18 08:32:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return *pMutex;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
sal_Bool SvtSysLocaleOptions::IsModified()
|
|
|
|
{
|
|
|
|
MutexGuard aGuard( GetMutex() );
|
|
|
|
return pOptions->IsModified();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SvtSysLocaleOptions::Commit()
|
|
|
|
{
|
|
|
|
MutexGuard aGuard( GetMutex() );
|
|
|
|
pOptions->Commit();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
BOOL SvtSysLocaleOptions::AddListener( SvtListener& rLst )
|
|
|
|
{
|
|
|
|
MutexGuard aGuard( GetMutex() );
|
|
|
|
return rLst.StartListening( pOptions->GetBroadcaster() );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
BOOL SvtSysLocaleOptions::RemoveListener( SvtListener& rLst )
|
|
|
|
{
|
|
|
|
MutexGuard aGuard( GetMutex() );
|
|
|
|
return rLst.EndListening( pOptions->GetBroadcaster() );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-26 11:36:41 +00:00
|
|
|
void SvtSysLocaleOptions::BlockBroadcasts( BOOL bBlock )
|
|
|
|
{
|
|
|
|
MutexGuard aGuard( GetMutex() );
|
|
|
|
pOptions->BlockBroadcasts( bBlock );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-18 08:32:41 +00:00
|
|
|
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 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-21 16:58:16 +00:00
|
|
|
LanguageType SvtSysLocaleOptions::GetLocaleLanguageType() const
|
|
|
|
{
|
|
|
|
MutexGuard aGuard( GetMutex() );
|
|
|
|
return pOptions->GetLocaleLanguageType();
|
|
|
|
}
|
|
|
|
|
2004-03-17 09:12:23 +00:00
|
|
|
/*-- 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);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-03-27 13:40:07 +00:00
|
|
|
sal_Bool SvtSysLocaleOptions::IsReadOnly( EOption eOption ) const
|
|
|
|
{
|
|
|
|
MutexGuard aGuard( GetMutex() );
|
|
|
|
return pOptions->IsReadOnly( eOption );
|
|
|
|
}
|
2001-06-21 16:58:16 +00:00
|
|
|
|
2001-06-18 08:32:41 +00:00
|
|
|
// 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 ) );
|
2006-04-07 14:57:36 +00:00
|
|
|
eLang = MsLangId::convertIsoStringToLanguage( aIsoStr );
|
2001-06-18 08:32:41 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
rAbbrev = rConfigString;
|
2001-06-26 11:36:41 +00:00
|
|
|
eLang = (rAbbrev.Len() ? LANGUAGE_NONE : LANGUAGE_SYSTEM);
|
2001-06-18 08:32:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// static
|
|
|
|
::rtl::OUString SvtSysLocaleOptions::CreateCurrencyConfigString(
|
|
|
|
const String& rAbbrev, LanguageType eLang )
|
|
|
|
{
|
2006-04-07 14:57:36 +00:00
|
|
|
String aIsoStr( MsLangId::convertLanguageToIsoString( eLang ) );
|
2001-06-18 08:32:41 +00:00
|
|
|
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() );
|
2004-06-25 16:25:24 +00:00
|
|
|
DBG_ASSERT( !CurrencyChangeLink::get().IsSet(), "SvtSysLocaleOptions::SetCurrencyChangeLink: already set" );
|
|
|
|
CurrencyChangeLink::get() = rLink;
|
2001-06-18 08:32:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// static
|
|
|
|
const Link& SvtSysLocaleOptions::GetCurrencyChangeLink()
|
|
|
|
{
|
|
|
|
MutexGuard aGuard( GetMutex() );
|
2004-06-25 16:25:24 +00:00
|
|
|
return CurrencyChangeLink::get();
|
2001-06-18 08:32:41 +00:00
|
|
|
}
|
|
|
|
|