2010-10-14 08:27:31 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-07-11 09:51:50 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2001-06-18 08:32:41 +00:00
|
|
|
|
2009-10-16 00:05:16 +02:00
|
|
|
#include <com/sun/star/uno/Sequence.hxx>
|
2001-06-18 08:32:41 +00:00
|
|
|
#include <rtl/ustrbuf.hxx>
|
2004-06-25 16:25:24 +00:00
|
|
|
#include <rtl/instance.hxx>
|
2013-04-05 18:40:39 +02:00
|
|
|
#include <i18nlangtag/mslangid.hxx>
|
|
|
|
#include <i18nlangtag/languagetag.hxx>
|
2009-10-16 00:05:16 +02:00
|
|
|
#include <tools/debug.hxx>
|
|
|
|
#include <unotools/syslocaleoptions.hxx>
|
2001-06-18 08:32:41 +00:00
|
|
|
#include <unotools/configmgr.hxx>
|
|
|
|
#include <unotools/configitem.hxx>
|
|
|
|
#include <com/sun/star/uno/Any.hxx>
|
2005-04-13 09:50:11 +00:00
|
|
|
|
2009-10-12 11:49:13 +02:00
|
|
|
#include "itemholder1.hxx"
|
2004-11-15 16:23:45 +00:00
|
|
|
|
2013-07-01 10:33:48 -05:00
|
|
|
#define CFG_READONLY_DEFAULT false
|
2003-03-27 13:40:07 +00:00
|
|
|
|
2001-06-18 08:32:41 +00:00
|
|
|
using namespace osl;
|
|
|
|
using namespace utl;
|
|
|
|
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
|
|
|
|
{
|
2012-11-16 12:29:37 +01:00
|
|
|
LanguageTag m_aRealLocale;
|
|
|
|
LanguageTag m_aRealUILocale;
|
2001-06-21 16:58:16 +00:00
|
|
|
OUString m_aLocaleString; // en-US or de-DE or empty for SYSTEM
|
2009-10-16 00:05:16 +02:00
|
|
|
OUString m_aUILocaleString; // en-US or de-DE or empty for SYSTEM
|
2001-06-18 08:32:41 +00:00
|
|
|
OUString m_aCurrencyString; // USD-en-US or EUR-de-DE
|
2012-08-29 20:49:01 +02:00
|
|
|
OUString m_aDatePatternsString; // "Y-M-D;M-D"
|
2013-07-01 10:33:48 -05:00
|
|
|
bool m_bDecimalSeparator; //use decimal separator same as locale
|
|
|
|
bool m_bIgnoreLanguageChange; //OS language change doesn't affect LO document language
|
2004-03-17 09:12:23 +00:00
|
|
|
|
2013-07-01 10:33:48 -05:00
|
|
|
bool m_bROLocale;
|
|
|
|
bool m_bROUILocale;
|
|
|
|
bool m_bROCurrency;
|
|
|
|
bool m_bRODatePatterns;
|
|
|
|
bool m_bRODecimalSeparator;
|
|
|
|
bool m_bROIgnoreLanguageChange;
|
2003-03-27 13:40:07 +00:00
|
|
|
|
2009-10-26 15:10:09 +01:00
|
|
|
static const Sequence< /* const */ OUString > GetPropertyNames();
|
|
|
|
void MakeRealLocale();
|
|
|
|
void MakeRealUILocale();
|
2001-06-18 08:32:41 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
SvtSysLocaleOptions_Impl();
|
|
|
|
virtual ~SvtSysLocaleOptions_Impl();
|
|
|
|
|
2014-03-26 16:37:00 +01:00
|
|
|
virtual void Notify( const com::sun::star::uno::Sequence< OUString >& aPropertyNames ) SAL_OVERRIDE;
|
|
|
|
virtual void Commit() SAL_OVERRIDE;
|
2001-06-18 08:32:41 +00:00
|
|
|
|
|
|
|
const OUString& GetLocaleString() const
|
|
|
|
{ return m_aLocaleString; }
|
|
|
|
void SetLocaleString( const OUString& rStr );
|
2009-10-16 00:05:16 +02:00
|
|
|
|
|
|
|
void SetUILocaleString( const OUString& rStr );
|
2001-06-18 08:32:41 +00:00
|
|
|
|
|
|
|
const OUString& GetCurrencyString() const
|
|
|
|
{ return m_aCurrencyString; }
|
|
|
|
void SetCurrencyString( const OUString& rStr );
|
|
|
|
|
2012-08-29 20:49:01 +02:00
|
|
|
const OUString& GetDatePatternsString() const
|
|
|
|
{ return m_aDatePatternsString; }
|
|
|
|
void SetDatePatternsString( const OUString& rStr );
|
|
|
|
|
2013-07-01 10:33:48 -05:00
|
|
|
bool IsDecimalSeparatorAsLocale() const { return m_bDecimalSeparator;}
|
|
|
|
void SetDecimalSeparatorAsLocale( bool bSet);
|
2012-11-15 12:53:36 +01:00
|
|
|
|
2013-07-01 10:33:48 -05:00
|
|
|
bool IsIgnoreLanguageChange() const { return m_bIgnoreLanguageChange;}
|
|
|
|
void SetIgnoreLanguageChange( bool bSet);
|
2004-03-17 09:12:23 +00:00
|
|
|
|
2013-07-01 10:33:48 -05:00
|
|
|
bool IsReadOnly( SvtSysLocaleOptions::EOption eOption ) const;
|
2012-11-21 18:34:53 +01:00
|
|
|
const LanguageTag& GetRealLocale() { return m_aRealLocale; }
|
|
|
|
const LanguageTag& GetRealUILocale() { return m_aRealUILocale; }
|
2001-06-18 08:32:41 +00:00
|
|
|
};
|
|
|
|
|
2013-03-10 20:44:01 +01:00
|
|
|
#define ROOTNODE_SYSLOCALE OUString("Setup/L10N")
|
|
|
|
|
2014-12-18 13:38:27 +01:00
|
|
|
#define PROPERTYNAME_LOCALE "ooSetupSystemLocale"
|
|
|
|
#define PROPERTYNAME_UILOCALE "ooLocale"
|
|
|
|
#define PROPERTYNAME_CURRENCY "ooSetupCurrency"
|
|
|
|
#define PROPERTYNAME_DECIMALSEPARATOR "DecimalSeparatorAsLocale"
|
|
|
|
#define PROPERTYNAME_DATEPATTERNS "DateAcceptancePatterns"
|
|
|
|
#define PROPERTYNAME_IGNORELANGCHANGE "IgnoreLanguageChange"
|
2001-06-18 08:32:41 +00:00
|
|
|
|
2009-10-16 00:05:16 +02:00
|
|
|
#define PROPERTYHANDLE_LOCALE 0
|
|
|
|
#define PROPERTYHANDLE_UILOCALE 1
|
|
|
|
#define PROPERTYHANDLE_CURRENCY 2
|
|
|
|
#define PROPERTYHANDLE_DECIMALSEPARATOR 3
|
2012-08-29 20:49:01 +02:00
|
|
|
#define PROPERTYHANDLE_DATEPATTERNS 4
|
2012-11-11 08:06:46 +01:00
|
|
|
#define PROPERTYHANDLE_IGNORELANGCHANGE 5
|
2001-06-18 08:32:41 +00:00
|
|
|
|
2012-11-11 08:06:46 +01:00
|
|
|
//#define PROPERTYCOUNT 5
|
|
|
|
#define PROPERTYCOUNT 6
|
2001-06-18 08:32:41 +00:00
|
|
|
|
|
|
|
const Sequence< OUString > SvtSysLocaleOptions_Impl::GetPropertyNames()
|
|
|
|
{
|
2011-06-01 09:23:41 +01:00
|
|
|
const OUString pProperties[] =
|
2001-06-18 08:32:41 +00:00
|
|
|
{
|
|
|
|
PROPERTYNAME_LOCALE,
|
2009-10-16 00:05:16 +02:00
|
|
|
PROPERTYNAME_UILOCALE,
|
2004-03-17 09:12:23 +00:00
|
|
|
PROPERTYNAME_CURRENCY,
|
2012-08-29 20:49:01 +02:00
|
|
|
PROPERTYNAME_DECIMALSEPARATOR,
|
2012-11-11 08:06:46 +01:00
|
|
|
PROPERTYNAME_DATEPATTERNS,
|
2012-11-15 12:53:36 +01:00
|
|
|
PROPERTYNAME_IGNORELANGCHANGE
|
2001-06-18 08:32:41 +00:00
|
|
|
};
|
2011-06-01 09:23:41 +01:00
|
|
|
const Sequence< OUString > seqPropertyNames( pProperties, PROPERTYCOUNT );
|
2001-06-18 08:32:41 +00:00
|
|
|
return seqPropertyNames;
|
|
|
|
}
|
|
|
|
|
|
|
|
SvtSysLocaleOptions_Impl::SvtSysLocaleOptions_Impl()
|
|
|
|
: ConfigItem( ROOTNODE_SYSLOCALE )
|
2012-11-16 12:29:37 +01:00
|
|
|
, m_aRealLocale( LANGUAGE_SYSTEM)
|
|
|
|
, m_aRealUILocale( LANGUAGE_SYSTEM)
|
2013-07-01 10:33:48 -05:00
|
|
|
, m_bDecimalSeparator( true )
|
2014-01-29 23:32:20 -06:00
|
|
|
, m_bIgnoreLanguageChange( false)
|
2003-03-27 13:40:07 +00:00
|
|
|
, m_bROLocale(CFG_READONLY_DEFAULT)
|
2009-10-16 00:05:16 +02:00
|
|
|
, m_bROUILocale(CFG_READONLY_DEFAULT)
|
2003-03-27 13:40:07 +00:00
|
|
|
, m_bROCurrency(CFG_READONLY_DEFAULT)
|
2012-08-29 20:49:01 +02:00
|
|
|
, m_bRODatePatterns(CFG_READONLY_DEFAULT)
|
2013-07-01 10:33:48 -05:00
|
|
|
, m_bRODecimalSeparator(false)
|
|
|
|
, m_bROIgnoreLanguageChange(false)
|
2004-03-17 09:12:23 +00:00
|
|
|
|
2001-06-18 08:32:41 +00:00
|
|
|
{
|
2013-11-20 23:39:21 +01:00
|
|
|
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() )
|
2001-06-18 08:32:41 +00:00
|
|
|
{
|
2013-11-20 23:39:21 +01:00
|
|
|
for ( sal_Int32 nProp = 0; nProp < aNames.getLength(); nProp++ )
|
2001-06-18 08:32:41 +00:00
|
|
|
{
|
2013-11-20 23:39:21 +01:00
|
|
|
if ( pValues[nProp].hasValue() )
|
2001-06-18 08:32:41 +00:00
|
|
|
{
|
2013-11-20 23:39:21 +01:00
|
|
|
switch ( nProp )
|
2001-06-18 08:32:41 +00:00
|
|
|
{
|
2013-11-20 23:39:21 +01:00
|
|
|
case PROPERTYHANDLE_LOCALE :
|
2001-06-18 08:32:41 +00:00
|
|
|
{
|
2013-11-20 23:39:21 +01:00
|
|
|
OUString aStr;
|
|
|
|
if ( pValues[nProp] >>= aStr )
|
|
|
|
m_aLocaleString = aStr;
|
|
|
|
else
|
2004-03-17 09:12:23 +00:00
|
|
|
{
|
2013-11-20 23:39:21 +01:00
|
|
|
SAL_WARN( "unotools.config", "Wrong property type!" );
|
2004-03-17 09:12:23 +00:00
|
|
|
}
|
2013-11-20 23:39:21 +01:00
|
|
|
m_bROLocale = pROStates[nProp];
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case PROPERTYHANDLE_UILOCALE :
|
|
|
|
{
|
|
|
|
OUString aStr;
|
|
|
|
if ( pValues[nProp] >>= aStr )
|
|
|
|
m_aUILocaleString = aStr;
|
|
|
|
else
|
|
|
|
{
|
2012-01-16 18:03:17 +01:00
|
|
|
SAL_WARN( "unotools.config", "Wrong property type!" );
|
2013-11-20 23:39:21 +01:00
|
|
|
}
|
|
|
|
m_bROUILocale = pROStates[nProp];
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case PROPERTYHANDLE_CURRENCY :
|
|
|
|
{
|
|
|
|
OUString aStr;
|
|
|
|
if ( pValues[nProp] >>= aStr )
|
|
|
|
m_aCurrencyString = aStr;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SAL_WARN( "unotools.config", "Wrong property type!" );
|
|
|
|
}
|
|
|
|
m_bROCurrency = pROStates[nProp];
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case PROPERTYHANDLE_DECIMALSEPARATOR:
|
|
|
|
{
|
|
|
|
bool bValue = false;
|
|
|
|
if ( pValues[nProp] >>= bValue )
|
|
|
|
m_bDecimalSeparator = bValue;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SAL_WARN( "unotools.config", "Wrong property type!" );
|
|
|
|
}
|
|
|
|
m_bRODecimalSeparator = pROStates[nProp];
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case PROPERTYHANDLE_DATEPATTERNS :
|
|
|
|
{
|
|
|
|
OUString aStr;
|
|
|
|
if ( pValues[nProp] >>= aStr )
|
|
|
|
m_aDatePatternsString = aStr;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SAL_WARN( "unotools.config", "Wrong property type!" );
|
|
|
|
}
|
|
|
|
m_bRODatePatterns = pROStates[nProp];
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case PROPERTYHANDLE_IGNORELANGCHANGE :
|
|
|
|
{
|
|
|
|
bool bValue = false;
|
|
|
|
if ( pValues[nProp] >>= bValue )
|
|
|
|
m_bIgnoreLanguageChange = bValue;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SAL_WARN( "unotools.config", "Wrong property type!" );
|
|
|
|
}
|
|
|
|
m_bROIgnoreLanguageChange = pROStates[nProp];
|
2001-06-18 08:32:41 +00:00
|
|
|
}
|
2013-11-20 23:39:21 +01:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
SAL_WARN( "unotools.config", "Wrong property type!" );
|
2001-06-18 08:32:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-11-20 23:39:21 +01:00
|
|
|
EnableNotification( aNames );
|
2009-10-26 15:10:09 +01:00
|
|
|
|
|
|
|
MakeRealLocale();
|
|
|
|
MakeRealUILocale();
|
2001-06-18 08:32:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SvtSysLocaleOptions_Impl::~SvtSysLocaleOptions_Impl()
|
|
|
|
{
|
|
|
|
if ( IsModified() )
|
|
|
|
Commit();
|
|
|
|
}
|
|
|
|
|
2009-10-26 15:10:09 +01:00
|
|
|
void SvtSysLocaleOptions_Impl::MakeRealLocale()
|
|
|
|
{
|
2012-11-16 12:29:37 +01:00
|
|
|
if (m_aLocaleString.isEmpty())
|
2009-10-26 15:10:09 +01:00
|
|
|
{
|
2012-11-16 12:29:37 +01:00
|
|
|
LanguageType nLang = MsLangId::getSystemLanguage();
|
2013-09-26 22:58:34 +02:00
|
|
|
m_aRealLocale.reset( nLang).makeFallback();
|
2009-10-26 15:10:09 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-09-26 22:58:34 +02:00
|
|
|
m_aRealLocale.reset( m_aLocaleString).makeFallback();
|
2009-10-26 15:10:09 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SvtSysLocaleOptions_Impl::MakeRealUILocale()
|
|
|
|
{
|
2012-11-16 12:29:37 +01:00
|
|
|
if (m_aUILocaleString.isEmpty())
|
2009-10-26 15:10:09 +01:00
|
|
|
{
|
2012-11-16 12:29:37 +01:00
|
|
|
LanguageType nLang = MsLangId::getSystemUILanguage();
|
2013-09-26 22:58:34 +02:00
|
|
|
m_aRealUILocale.reset( nLang).makeFallback();
|
2011-05-06 18:19:22 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-09-26 22:58:34 +02:00
|
|
|
m_aRealUILocale.reset( m_aUILocaleString).makeFallback();
|
2009-10-26 15:10:09 +01:00
|
|
|
}
|
|
|
|
}
|
2001-06-18 08:32:41 +00:00
|
|
|
|
2013-07-01 10:33:48 -05:00
|
|
|
bool SvtSysLocaleOptions_Impl::IsReadOnly( SvtSysLocaleOptions::EOption eOption ) const
|
2003-03-27 13:40:07 +00:00
|
|
|
{
|
2013-07-01 10:33:48 -05:00
|
|
|
bool bReadOnly = CFG_READONLY_DEFAULT;
|
2003-03-27 13:40:07 +00:00
|
|
|
switch(eOption)
|
|
|
|
{
|
|
|
|
case SvtSysLocaleOptions::E_LOCALE :
|
|
|
|
{
|
|
|
|
bReadOnly = m_bROLocale;
|
|
|
|
break;
|
|
|
|
}
|
2009-10-16 00:05:16 +02:00
|
|
|
case SvtSysLocaleOptions::E_UILOCALE :
|
|
|
|
{
|
|
|
|
bReadOnly = m_bROUILocale;
|
|
|
|
break;
|
|
|
|
}
|
2003-03-27 13:40:07 +00:00
|
|
|
case SvtSysLocaleOptions::E_CURRENCY :
|
|
|
|
{
|
|
|
|
bReadOnly = m_bROCurrency;
|
|
|
|
break;
|
|
|
|
}
|
2012-08-29 20:49:01 +02:00
|
|
|
case SvtSysLocaleOptions::E_DATEPATTERNS :
|
|
|
|
{
|
|
|
|
bReadOnly = m_bRODatePatterns;
|
|
|
|
break;
|
|
|
|
}
|
2003-03-27 13:40:07 +00:00
|
|
|
}
|
|
|
|
return bReadOnly;
|
|
|
|
}
|
|
|
|
|
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;
|
2009-10-16 00:05:16 +02:00
|
|
|
case PROPERTYHANDLE_UILOCALE :
|
|
|
|
{
|
|
|
|
if (!m_bROUILocale)
|
|
|
|
{
|
|
|
|
pNames[nRealCount] = aOrgNames[nProp];
|
|
|
|
pValues[nRealCount] <<= m_aUILocaleString;
|
|
|
|
++nRealCount;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2001-06-18 08:32:41 +00:00
|
|
|
case PROPERTYHANDLE_CURRENCY :
|
2003-03-27 13:40:07 +00:00
|
|
|
{
|
2009-10-16 00:05:16 +02:00
|
|
|
if (!m_bROCurrency)
|
2003-03-27 13:40:07 +00:00
|
|
|
{
|
|
|
|
pNames[nRealCount] = aOrgNames[nProp];
|
|
|
|
pValues[nRealCount] <<= m_aCurrencyString;
|
|
|
|
++nRealCount;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2012-11-11 08:06:46 +01:00
|
|
|
case PROPERTYHANDLE_DECIMALSEPARATOR:
|
2004-03-17 09:12:23 +00:00
|
|
|
if( !m_bRODecimalSeparator )
|
|
|
|
{
|
|
|
|
pNames[nRealCount] = aOrgNames[nProp];
|
|
|
|
pValues[nRealCount] <<= m_bDecimalSeparator;
|
|
|
|
++nRealCount;
|
|
|
|
}
|
|
|
|
break;
|
2012-08-29 20:49:01 +02:00
|
|
|
case PROPERTYHANDLE_DATEPATTERNS :
|
|
|
|
if (!m_bRODatePatterns)
|
|
|
|
{
|
|
|
|
pNames[nRealCount] = aOrgNames[nProp];
|
|
|
|
pValues[nRealCount] <<= m_aDatePatternsString;
|
|
|
|
++nRealCount;
|
|
|
|
}
|
|
|
|
break;
|
2012-11-15 12:53:36 +01:00
|
|
|
case PROPERTYHANDLE_IGNORELANGCHANGE :
|
|
|
|
if (!m_bROIgnoreLanguageChange)
|
|
|
|
{
|
|
|
|
pNames[nRealCount] = aOrgNames[nProp];
|
|
|
|
pValues[nRealCount] <<= m_bIgnoreLanguageChange;
|
|
|
|
++nRealCount;
|
|
|
|
}
|
|
|
|
break;
|
2001-06-18 08:32:41 +00:00
|
|
|
default:
|
2012-01-16 18:03:17 +01:00
|
|
|
SAL_WARN( "unotools.config", "invalid index to save a path" );
|
2001-06-18 08:32:41 +00:00
|
|
|
}
|
|
|
|
}
|
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;
|
2009-10-26 15:10:09 +01:00
|
|
|
MakeRealLocale();
|
2013-12-18 18:08:09 +01:00
|
|
|
LanguageTag::setConfiguredSystemLanguage( m_aRealLocale.getLanguageType() );
|
2001-06-18 08:32:41 +00:00
|
|
|
SetModified();
|
2011-01-12 16:24:50 +01:00
|
|
|
sal_uLong nHint = SYSLOCALEOPTIONS_HINT_LOCALE;
|
2012-01-19 16:01:33 -02:00
|
|
|
if ( m_aCurrencyString.isEmpty() )
|
2009-10-16 00:05:16 +02:00
|
|
|
nHint |= SYSLOCALEOPTIONS_HINT_CURRENCY;
|
|
|
|
NotifyListeners( nHint );
|
2001-06-18 08:32:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-10-16 00:05:16 +02:00
|
|
|
void SvtSysLocaleOptions_Impl::SetUILocaleString( const OUString& rStr )
|
2001-06-21 16:58:16 +00:00
|
|
|
{
|
2009-10-16 00:05:16 +02:00
|
|
|
if (!m_bROUILocale && rStr != m_aUILocaleString )
|
|
|
|
{
|
|
|
|
m_aUILocaleString = rStr;
|
2011-05-06 18:19:22 +02:00
|
|
|
|
2009-10-26 15:10:09 +01:00
|
|
|
// as we can't switch UILocale at runtime, we only store changes in the configuration
|
|
|
|
MakeRealUILocale();
|
2009-10-16 00:05:16 +02:00
|
|
|
SetModified();
|
|
|
|
NotifyListeners( SYSLOCALEOPTIONS_HINT_UILOCALE );
|
|
|
|
}
|
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();
|
2009-10-16 00:05:16 +02:00
|
|
|
NotifyListeners( SYSLOCALEOPTIONS_HINT_CURRENCY );
|
2001-06-18 08:32:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-29 20:49:01 +02:00
|
|
|
void SvtSysLocaleOptions_Impl::SetDatePatternsString( const OUString& rStr )
|
|
|
|
{
|
|
|
|
if (!m_bRODatePatterns && rStr != m_aDatePatternsString )
|
|
|
|
{
|
|
|
|
m_aDatePatternsString = rStr;
|
|
|
|
SetModified();
|
|
|
|
NotifyListeners( SYSLOCALEOPTIONS_HINT_DATEPATTERNS );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-01 10:33:48 -05:00
|
|
|
void SvtSysLocaleOptions_Impl::SetDecimalSeparatorAsLocale( bool bSet)
|
2004-03-17 09:12:23 +00:00
|
|
|
{
|
|
|
|
if(bSet != m_bDecimalSeparator)
|
|
|
|
{
|
|
|
|
m_bDecimalSeparator = bSet;
|
|
|
|
SetModified();
|
2009-10-16 00:05:16 +02:00
|
|
|
NotifyListeners( SYSLOCALEOPTIONS_HINT_DECSEP );
|
2004-03-17 09:12:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-01 10:33:48 -05:00
|
|
|
void SvtSysLocaleOptions_Impl::SetIgnoreLanguageChange( bool bSet)
|
2012-11-11 08:06:46 +01:00
|
|
|
{
|
|
|
|
if(bSet != m_bIgnoreLanguageChange)
|
|
|
|
{
|
|
|
|
m_bIgnoreLanguageChange = bSet;
|
|
|
|
SetModified();
|
|
|
|
NotifyListeners( SYSLOCALEOPTIONS_HINT_IGNORELANG );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
void SvtSysLocaleOptions_Impl::Notify( const Sequence< OUString >& seqPropertyNames )
|
2001-06-18 08:32:41 +00:00
|
|
|
{
|
2011-01-12 16:24:50 +01:00
|
|
|
sal_uLong nHint = 0;
|
2001-06-18 08:32:41 +00:00
|
|
|
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;
|
2012-01-19 16:01:33 -02:00
|
|
|
if ( m_aCurrencyString.isEmpty() )
|
2009-10-16 00:05:16 +02:00
|
|
|
nHint |= SYSLOCALEOPTIONS_HINT_CURRENCY;
|
2009-10-26 15:10:09 +01:00
|
|
|
MakeRealLocale();
|
2009-10-16 00:05:16 +02:00
|
|
|
}
|
|
|
|
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;
|
2009-10-26 15:10:09 +01:00
|
|
|
MakeRealUILocale();
|
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];
|
|
|
|
}
|
2012-11-15 12:53:36 +01:00
|
|
|
else if( seqPropertyNames[nProp] == PROPERTYNAME_IGNORELANGCHANGE )
|
|
|
|
{
|
|
|
|
seqValues[nProp] >>= m_bIgnoreLanguageChange;
|
|
|
|
m_bROIgnoreLanguageChange = seqROStates[nProp];
|
|
|
|
}
|
2012-08-29 20:49:01 +02:00
|
|
|
else if( seqPropertyNames[nProp] == PROPERTYNAME_DATEPATTERNS )
|
|
|
|
{
|
|
|
|
DBG_ASSERT( seqValues[nProp].getValueTypeClass() == TypeClass_STRING, "DatePatterns property type" );
|
|
|
|
seqValues[nProp] >>= m_aDatePatternsString;
|
|
|
|
m_bRODatePatterns = seqROStates[nProp];
|
|
|
|
nHint |= SYSLOCALEOPTIONS_HINT_DATEPATTERNS;
|
|
|
|
}
|
2001-06-18 08:32:41 +00:00
|
|
|
}
|
|
|
|
if ( nHint )
|
2009-10-16 00:05:16 +02:00
|
|
|
NotifyListeners( nHint );
|
2004-03-17 09:12:23 +00:00
|
|
|
}
|
2001-06-18 08:32:41 +00:00
|
|
|
|
|
|
|
SvtSysLocaleOptions::SvtSysLocaleOptions()
|
|
|
|
{
|
|
|
|
MutexGuard aGuard( GetMutex() );
|
|
|
|
if ( !pOptions )
|
2004-11-15 16:23:45 +00:00
|
|
|
{
|
2001-06-18 08:32:41 +00:00
|
|
|
pOptions = new SvtSysLocaleOptions_Impl;
|
2004-11-15 16:23:45 +00:00
|
|
|
|
2009-10-12 11:49:13 +02:00
|
|
|
ItemHolder1::holdConfigItem(E_SYSLOCALEOPTIONS);
|
2004-11-15 16:23:45 +00:00
|
|
|
}
|
2001-06-18 08:32:41 +00:00
|
|
|
++nRefCount;
|
2009-10-16 00:05:16 +02:00
|
|
|
pOptions->AddListener(this);
|
2001-06-18 08:32:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SvtSysLocaleOptions::~SvtSysLocaleOptions()
|
|
|
|
{
|
|
|
|
MutexGuard aGuard( GetMutex() );
|
2009-10-16 00:05:16 +02:00
|
|
|
pOptions->RemoveListener(this);
|
2001-06-18 08:32:41 +00:00
|
|
|
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
|
2009-10-08 16:59:48 +02:00
|
|
|
// we need a mutex that lives longer than the svl library.
|
2007-08-01 09:55:53 +00:00
|
|
|
// Otherwise the dtor would use a destructed mutex!!
|
|
|
|
pMutex = new Mutex;
|
2001-06-18 08:32:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return *pMutex;
|
|
|
|
}
|
|
|
|
|
2013-07-01 10:33:48 -05:00
|
|
|
bool SvtSysLocaleOptions::IsModified()
|
2001-06-18 08:32:41 +00:00
|
|
|
{
|
|
|
|
MutexGuard aGuard( GetMutex() );
|
|
|
|
return pOptions->IsModified();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SvtSysLocaleOptions::Commit()
|
|
|
|
{
|
|
|
|
MutexGuard aGuard( GetMutex() );
|
|
|
|
pOptions->Commit();
|
|
|
|
}
|
|
|
|
|
2009-11-03 18:41:58 +01:00
|
|
|
void SvtSysLocaleOptions::BlockBroadcasts( bool bBlock )
|
2001-06-26 11:36:41 +00:00
|
|
|
{
|
|
|
|
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 );
|
|
|
|
}
|
|
|
|
|
2009-10-16 00:05:16 +02:00
|
|
|
void SvtSysLocaleOptions::SetUILocaleConfigString( const OUString& rStr )
|
|
|
|
{
|
|
|
|
MutexGuard aGuard( GetMutex() );
|
|
|
|
pOptions->SetUILocaleString( rStr );
|
|
|
|
}
|
2001-06-18 08:32:41 +00:00
|
|
|
|
|
|
|
const OUString& SvtSysLocaleOptions::GetCurrencyConfigString() const
|
|
|
|
{
|
|
|
|
MutexGuard aGuard( GetMutex() );
|
|
|
|
return pOptions->GetCurrencyString();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SvtSysLocaleOptions::SetCurrencyConfigString( const OUString& rStr )
|
|
|
|
{
|
|
|
|
MutexGuard aGuard( GetMutex() );
|
|
|
|
pOptions->SetCurrencyString( rStr );
|
|
|
|
}
|
|
|
|
|
2012-08-29 20:49:01 +02:00
|
|
|
const OUString& SvtSysLocaleOptions::GetDatePatternsConfigString() const
|
|
|
|
{
|
|
|
|
MutexGuard aGuard( GetMutex() );
|
|
|
|
return pOptions->GetDatePatternsString();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SvtSysLocaleOptions::SetDatePatternsConfigString( const OUString& rStr )
|
|
|
|
{
|
|
|
|
MutexGuard aGuard( GetMutex() );
|
|
|
|
pOptions->SetDatePatternsString( rStr );
|
|
|
|
}
|
|
|
|
|
2013-07-01 10:33:48 -05:00
|
|
|
bool SvtSysLocaleOptions::IsDecimalSeparatorAsLocale() const
|
2004-03-17 09:12:23 +00:00
|
|
|
{
|
|
|
|
MutexGuard aGuard( GetMutex() );
|
|
|
|
return pOptions->IsDecimalSeparatorAsLocale();
|
|
|
|
}
|
|
|
|
|
2013-07-01 10:33:48 -05:00
|
|
|
void SvtSysLocaleOptions::SetDecimalSeparatorAsLocale( bool bSet)
|
2004-03-17 09:12:23 +00:00
|
|
|
{
|
|
|
|
MutexGuard aGuard( GetMutex() );
|
|
|
|
pOptions->SetDecimalSeparatorAsLocale(bSet);
|
|
|
|
}
|
|
|
|
|
2013-07-01 10:33:48 -05:00
|
|
|
bool SvtSysLocaleOptions::IsIgnoreLanguageChange() const
|
2012-11-11 08:06:46 +01:00
|
|
|
{
|
|
|
|
MutexGuard aGuard( GetMutex() );
|
|
|
|
return pOptions->IsIgnoreLanguageChange();
|
|
|
|
}
|
|
|
|
|
2013-07-01 10:33:48 -05:00
|
|
|
void SvtSysLocaleOptions::SetIgnoreLanguageChange( bool bSet)
|
2012-11-11 08:06:46 +01:00
|
|
|
{
|
|
|
|
MutexGuard aGuard( GetMutex() );
|
|
|
|
pOptions->SetIgnoreLanguageChange(bSet);
|
|
|
|
}
|
2004-03-17 09:12:23 +00:00
|
|
|
|
2013-07-01 10:33:48 -05:00
|
|
|
bool SvtSysLocaleOptions::IsReadOnly( EOption eOption ) const
|
2003-03-27 13:40:07 +00:00
|
|
|
{
|
|
|
|
MutexGuard aGuard( GetMutex() );
|
|
|
|
return pOptions->IsReadOnly( eOption );
|
|
|
|
}
|
2001-06-21 16:58:16 +00:00
|
|
|
|
2001-06-18 08:32:41 +00:00
|
|
|
// static
|
2013-07-01 10:33:48 -05:00
|
|
|
void SvtSysLocaleOptions::GetCurrencyAbbrevAndLanguage( OUString& rAbbrev,
|
|
|
|
LanguageType& eLang,
|
|
|
|
const OUString& rConfigString )
|
2001-06-18 08:32:41 +00:00
|
|
|
{
|
|
|
|
sal_Int32 nDelim = rConfigString.indexOf( '-' );
|
|
|
|
if ( nDelim >= 0 )
|
|
|
|
{
|
|
|
|
rAbbrev = rConfigString.copy( 0, nDelim );
|
2013-07-01 10:33:48 -05:00
|
|
|
OUString aIsoStr( rConfigString.copy( nDelim+1 ) );
|
2013-09-03 20:08:39 +02:00
|
|
|
eLang = LanguageTag::convertToLanguageTypeWithFallback( aIsoStr );
|
2001-06-18 08:32:41 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
rAbbrev = rConfigString;
|
2013-07-01 10:33:48 -05:00
|
|
|
eLang = (rAbbrev.isEmpty() ? LANGUAGE_SYSTEM : LANGUAGE_NONE);
|
2001-06-18 08:32:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString SvtSysLocaleOptions::CreateCurrencyConfigString(
|
2013-07-01 10:33:48 -05:00
|
|
|
const OUString& rAbbrev, LanguageType eLang )
|
2001-06-18 08:32:41 +00:00
|
|
|
{
|
2013-07-13 02:54:05 +02:00
|
|
|
OUString aIsoStr( LanguageTag::convertToBcp47( eLang ) );
|
2013-07-01 10:33:48 -05:00
|
|
|
if ( !aIsoStr.isEmpty() )
|
2001-06-18 08:32:41 +00:00
|
|
|
{
|
2013-07-01 10:33:48 -05:00
|
|
|
OUStringBuffer aStr( rAbbrev.getLength() + 1 + aIsoStr.getLength() );
|
2012-06-24 21:46:31 +01:00
|
|
|
aStr.append( rAbbrev );
|
2013-11-14 08:16:35 +02:00
|
|
|
aStr.append( '-' );
|
2012-06-24 21:46:31 +01:00
|
|
|
aStr.append( aIsoStr );
|
2001-06-18 08:32:41 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2009-10-16 00:05:16 +02:00
|
|
|
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 );
|
|
|
|
}
|
|
|
|
|
2012-11-21 18:34:53 +01:00
|
|
|
LanguageTag SvtSysLocaleOptions::GetLanguageTag() const
|
2009-10-16 00:05:16 +02:00
|
|
|
{
|
2012-11-21 18:34:53 +01:00
|
|
|
return LanguageTag( GetLocaleConfigString() );
|
2009-10-16 00:05:16 +02:00
|
|
|
}
|
|
|
|
|
2012-11-21 18:34:53 +01:00
|
|
|
const LanguageTag & SvtSysLocaleOptions::GetRealLanguageTag() const
|
2009-10-26 15:10:09 +01:00
|
|
|
{
|
|
|
|
return pOptions->GetRealLocale();
|
|
|
|
}
|
|
|
|
|
2012-11-21 18:34:53 +01:00
|
|
|
const LanguageTag & SvtSysLocaleOptions::GetRealUILanguageTag() const
|
2009-10-26 15:10:09 +01:00
|
|
|
{
|
|
|
|
return pOptions->GetRealUILocale();
|
|
|
|
}
|
|
|
|
|
2010-10-14 08:27:31 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|