diff options
Diffstat (limited to 'desktop/source/app/langselect.cxx')
-rw-r--r-- | desktop/source/app/langselect.cxx | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/desktop/source/app/langselect.cxx b/desktop/source/app/langselect.cxx index f505fe3c2d..d4077b1b67 100644 --- a/desktop/source/app/langselect.cxx +++ b/desktop/source/app/langselect.cxx @@ -113,6 +113,47 @@ static OUString locateSofficeIniFile() return aSofficeIniFileURL; } +static sal_Bool existsURL( OUString const& sURL ) +{ + using namespace osl; + DirectoryItem aDirItem; + + if (sURL.getLength() != 0) + return ( DirectoryItem::get( sURL, aDirItem ) == DirectoryItem::E_None ); + + return sal_False; +} + +// locate soffice.ini/.rc file +static OUString locateSofficeIniFile() +{ + OUString aUserDataPath; + OUString aSofficeIniFileURL; + + // Retrieve the default file URL for the soffice.ini/rc + rtl::Bootstrap().getIniName( aSofficeIniFileURL ); + + if ( utl::Bootstrap::locateUserData( aUserDataPath ) == utl::Bootstrap::PATH_EXISTS ) + { + const char CONFIG_DIR[] = "/config"; + + sal_Int32 nIndex = aSofficeIniFileURL.lastIndexOf( '/'); + if ( nIndex > 0 ) + { + OUString aUserSofficeIniFileURL; + OUStringBuffer aBuffer( aUserDataPath ); + aBuffer.appendAscii( CONFIG_DIR ); + aBuffer.append( aSofficeIniFileURL.copy( nIndex )); + aUserSofficeIniFileURL = aBuffer.makeStringAndClear(); + + if ( existsURL( aUserSofficeIniFileURL )) + return aUserSofficeIniFileURL; + } + } + // Fallback try to use the soffice.ini/rc from program folder + return aSofficeIniFileURL; +} + Locale LanguageSelection::IsoStringToLocale(const OUString& str) { Locale l; |