INTEGRATION: CWS lobeta2 (1.12.14); FILE MERGED

2005/02/07 14:32:48 jl 1.12.14.3: RESYNC: (1.12-1.13); FILE MERGED
2004/12/16 16:35:18 lo 1.12.14.2: #112849# convert file urls to internal form on the command line
2004/12/09 13:36:55 lo 1.12.14.1: #i32939# set CJK and CTL document locale according to user lang, if not yet set
This commit is contained in:
Vladimir Glazounov 2005-03-11 09:47:45 +00:00
parent e2fc077661
commit 860e791259

View file

@ -2,8 +2,8 @@
* *
* $RCSfile: langselect.cxx,v $ * $RCSfile: langselect.cxx,v $
* *
* $Revision: 1.13 $ * $Revision: 1.14 $
* last change: $Author: obo $ $Date: 2005-01-27 12:27:15 $ * last change: $Author: vg $ $Date: 2005-03-11 10:47:45 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
@ -117,6 +117,7 @@ Locale LanguageSelection::IsoStringToLocale(const OUString& str)
bool LanguageSelection::prepareLanguage() bool LanguageSelection::prepareLanguage()
{ {
// get the selected UI language as string
OUString aLocaleString = getLanguageString(); OUString aLocaleString = getLanguageString();
if ( aLocaleString.getLength() > 0 ) if ( aLocaleString.getLength() > 0 )
{ {
@ -124,6 +125,9 @@ bool LanguageSelection::prepareLanguage()
Reference< XMultiServiceFactory > theMSF = comphelper::getProcessServiceFactory(); Reference< XMultiServiceFactory > theMSF = comphelper::getProcessServiceFactory();
try try
{ {
// prepare default config provider by localizing it to the selected locale
// this will ensure localized configuration settings to be selected accoring to the
// UI language.
Reference< XLocalizable > theConfigProvider( Reference< XLocalizable > theConfigProvider(
theMSF->createInstance( sConfigSrvc ),UNO_QUERY_THROW ); theMSF->createInstance( sConfigSrvc ),UNO_QUERY_THROW );
Locale loc = LanguageSelection::IsoStringToLocale(aLocaleString); Locale loc = LanguageSelection::IsoStringToLocale(aLocaleString);
@ -131,8 +135,16 @@ bool LanguageSelection::prepareLanguage()
Reference< XPropertySet > xProp(getConfigAccess("org.openoffice.Setup/L10N/", sal_True), UNO_QUERY_THROW); Reference< XPropertySet > xProp(getConfigAccess("org.openoffice.Setup/L10N/", sal_True), UNO_QUERY_THROW);
xProp->setPropertyValue(OUString::createFromAscii("ooLocale"), makeAny(aLocaleString)); xProp->setPropertyValue(OUString::createFromAscii("ooLocale"), makeAny(aLocaleString));
Reference< XChangesBatch >(xProp, UNO_QUERY_THROW)->commitChanges(); Reference< XChangesBatch >(xProp, UNO_QUERY_THROW)->commitChanges();
// #i32939# setting of default document locale
setDefaultLocale(aLocaleString);
return true; return true;
} }
catch ( PropertyVetoException& )
{
// we are not allowed to change this
}
catch (Exception& e) catch (Exception& e)
{ {
OString aMsg = OUStringToOString(e.Message, RTL_TEXTENCODING_ASCII_US); OString aMsg = OUStringToOString(e.Message, RTL_TEXTENCODING_ASCII_US);
@ -143,6 +155,49 @@ bool LanguageSelection::prepareLanguage()
return false; return false;
} }
void LanguageSelection::setDefaultLocale(const OUString& usUILocale)
{
// #i32939# setting of default document locale
// org.openoffice.Office.Linguistic/General/DefaultLocale
// org.openoffice.Office.Linguistic/General/DefaultLocale_CJK
// org.openoffice.Office.Linguistic/General/DefaultLocale_CTL
// determine script type of UI locale
LanguageType ltUILocale = ConvertIsoStringToLanguage(usUILocale);
sal_uInt16 nScriptType = SvtLanguageOptions::GetScriptTypeOfLanguage(ltUILocale);
Reference< XPropertySet > xProp(getConfigAccess(
"org.openoffice.Office.Linguistic/General/", sal_True), UNO_QUERY_THROW);
OUString usName = OUString::createFromAscii("DefaultLocale");
switch (nScriptType)
{
case SCRIPTTYPE_ASIAN:
usName = OUString::createFromAscii("DefaultLocale_CJK");
break;
case SCRIPTTYPE_COMPLEX:
usName = OUString::createFromAscii("DefaultLocale_CTL");
break;
}
OUString usValue;
xProp->getPropertyValue(usName) >>= usValue;
if (usValue.getLength() == 0)
{
// there is no document language set, for the script type selected
// in the UI
// covert the LanguageType we've got from the LanguageTable back to
// an iso string and store it
OUString usDefault = ConvertLanguageToIsoString(ltUILocale);
try
{
xProp->setPropertyValue(usName, makeAny(usDefault));
Reference< XChangesBatch >(xProp, UNO_QUERY_THROW)->commitChanges();
}
catch ( PropertyVetoException )
{
// we are not allowed to change this
}
}
}
OUString LanguageSelection::getLanguageString() OUString LanguageSelection::getLanguageString()
{ {
@ -330,6 +385,10 @@ void LanguageSelection::resetUserLanguage()
xProp->setPropertyValue(OUString::createFromAscii("UILocale"), makeAny(OUString::createFromAscii(""))); xProp->setPropertyValue(OUString::createFromAscii("UILocale"), makeAny(OUString::createFromAscii("")));
Reference< XChangesBatch >(xProp, UNO_QUERY_THROW)->commitChanges(); Reference< XChangesBatch >(xProp, UNO_QUERY_THROW)->commitChanges();
} }
catch ( PropertyVetoException& )
{
// we are not allowed to change this
}
catch ( Exception& e) catch ( Exception& e)
{ {
OString aMsg = OUStringToOString(e.Message, RTL_TEXTENCODING_ASCII_US); OString aMsg = OUStringToOString(e.Message, RTL_TEXTENCODING_ASCII_US);