diff options
author | Carsten Driesner <cd@openoffice.org> | 2010-06-22 17:08:07 +0200 |
---|---|---|
committer | Carsten Driesner <cd@openoffice.org> | 2010-06-22 17:08:07 +0200 |
commit | 122581b430e564bcde272a0753f36d64f3aaefb1 (patch) | |
tree | 57ac89bf815021698679555709cdb2d5e7a40a8c /desktop/source | |
parent | 34dd33af79caf3a13ec3a4e7098616ac0b16cf50 (diff) |
fwk147: Provide better error message if there is no configuration access on startup
Diffstat (limited to 'desktop/source')
-rw-r--r-- | desktop/source/app/app.cxx | 20 | ||||
-rw-r--r-- | desktop/source/app/langselect.cxx | 23 | ||||
-rw-r--r-- | desktop/source/app/langselect.hxx | 19 |
3 files changed, 53 insertions, 9 deletions
diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx index 6f00d47332ac..05311010f455 100644 --- a/desktop/source/app/app.cxx +++ b/desktop/source/app/app.cxx @@ -474,6 +474,8 @@ void Desktop::Init() RTL_LOGFILE_CONTEXT( aLog, "desktop (cd100003) ::Desktop::Init" ); SetBootstrapStatus(BS_OK); + Sleep(10000); + // create service factory... Reference < XMultiServiceFactory > rSMgr = CreateApplicationServiceManager(); if( rSMgr.is() ) @@ -489,7 +491,12 @@ void Desktop::Init() { // prepare language if ( !LanguageSelection::prepareLanguage() ) - SetBootstrapError( BE_LANGUAGE_MISSING ); + { + if ( LanguageSelection::getStatus() == LanguageSelection::LS_STATUS_CANNOT_DETERMINE_LANGUAGE ) + SetBootstrapError( BE_LANGUAGE_MISSING ); + else + SetBootstrapError( BE_OFFICECONFIG_BROKEN ); + } } if ( GetBootstrapError() == BE_OK ) @@ -870,6 +877,17 @@ void Desktop::HandleBootstrapErrors( BootstrapError aBootstrapError ) FatalError( aMessage); } + else if ( aBootstrapError == BE_OFFICECONFIG_BROKEN ) + { + OUString aMessage; + OUStringBuffer aDiagnosticMessage( 100 ); + OUString aErrorMsg; + aErrorMsg = GetMsgString( STR_CONFIG_ERR_ACCESS_GENERAL, + OUString( RTL_CONSTASCII_USTRINGPARAM( "A general error occurred while accessing your central configuration." )) ); + aDiagnosticMessage.append( aErrorMsg ); + aMessage = MakeStartupErrorMessage( aDiagnosticMessage.makeStringAndClear() ); + FatalError(aMessage); + } else if ( aBootstrapError == BE_USERINSTALL_FAILED ) { OUString aMessage; diff --git a/desktop/source/app/langselect.cxx b/desktop/source/app/langselect.cxx index 5e2145b03729..9df8d82a37ff 100644 --- a/desktop/source/app/langselect.cxx +++ b/desktop/source/app/langselect.cxx @@ -64,10 +64,12 @@ namespace desktop { static char const SOFFICE_BOOTSTRAP[] = "Bootstrap"; static char const SOFFICE_STARTLANG[] = "STARTLANG"; + sal_Bool LanguageSelection::bFoundLanguage = sal_False; OUString LanguageSelection::aFoundLanguage; -const OUString LanguageSelection::usFallbackLanguage = OUString::createFromAscii("en-US"); +LanguageSelection::LanguageSelectionStatus LanguageSelection::m_eStatus = LS_STATUS_OK; +const OUString LanguageSelection::usFallbackLanguage = OUString::createFromAscii("en-US"); static sal_Bool existsURL( OUString const& sURL ) { @@ -122,6 +124,7 @@ Locale LanguageSelection::IsoStringToLocale(const OUString& str) bool LanguageSelection::prepareLanguage() { + m_eStatus = LS_STATUS_OK; OUString sConfigSrvc = OUString::createFromAscii("com.sun.star.configuration.ConfigurationProvider"); Reference< XMultiServiceFactory > theMSF = comphelper::getProcessServiceFactory(); Reference< XLocalizable > theConfigProvider; @@ -131,7 +134,9 @@ bool LanguageSelection::prepareLanguage() } catch(const Exception&) { + m_eStatus = LS_STATUS_CONFIGURATIONACCESS_BROKEN; } + if(!theConfigProvider.is()) return false; @@ -149,6 +154,7 @@ bool LanguageSelection::prepareLanguage() } catch(const Exception&) { + m_eStatus = LS_STATUS_CONFIGURATIONACCESS_BROKEN; } // #i32939# use system locale to set document default locale @@ -162,6 +168,7 @@ bool LanguageSelection::prepareLanguage() } catch (Exception&) { + m_eStatus = LS_STATUS_CONFIGURATIONACCESS_BROKEN; } // get the selected UI language as string @@ -350,8 +357,10 @@ OUString LanguageSelection::getLanguageString() aFoundLanguage = usFallbackLanguage; return aFoundLanguage; } + // fallback didn't work use first installed language aUserLanguage = getFirstInstalledLanguage(); + bFoundLanguage = sal_True; aFoundLanguage = aUserLanguage; return aFoundLanguage; @@ -455,7 +464,7 @@ sal_Bool LanguageSelection::isInstalledLanguage(OUString& usLocale, sal_Bool bEx // requested locale starts with the installed locale // (i.e. installed locale has index 0 in requested locale) bInstalled = sal_True; - usLocale = seqLanguages[i]; + usLocale = seqLanguages[i]; break; } } @@ -484,10 +493,12 @@ OUString LanguageSelection::getUserLanguage() } catch ( NoSuchElementException const & ) { + m_eStatus = LS_STATUS_CONFIGURATIONACCESS_BROKEN; return OUString(); } catch ( WrappedTargetException const & ) { + m_eStatus = LS_STATUS_CONFIGURATIONACCESS_BROKEN; return OUString(); } } @@ -506,10 +517,12 @@ OUString LanguageSelection::getSystemLanguage() } catch ( NoSuchElementException const & ) { + m_eStatus = LS_STATUS_CONFIGURATIONACCESS_BROKEN; return OUString(); } catch ( WrappedTargetException const & ) { + m_eStatus = LS_STATUS_CONFIGURATIONACCESS_BROKEN; return OUString(); } } @@ -533,9 +546,13 @@ void LanguageSelection::resetUserLanguage() { OString aMsg = OUStringToOString(e.Message, RTL_TEXTENCODING_ASCII_US); OSL_ENSURE(sal_False, aMsg.getStr()); + m_eStatus = LS_STATUS_CONFIGURATIONACCESS_BROKEN; } - } +LanguageSelection::LanguageSelectionStatus LanguageSelection::getStatus() +{ + return m_eStatus; +} } // namespace desktop diff --git a/desktop/source/app/langselect.hxx b/desktop/source/app/langselect.hxx index 60308164690f..bdf3cd6364de 100644 --- a/desktop/source/app/langselect.hxx +++ b/desktop/source/app/langselect.hxx @@ -40,10 +40,24 @@ namespace desktop class LanguageSelection { +public: + enum LanguageSelectionStatus + { + LS_STATUS_OK, + LS_STATUS_CANNOT_DETERMINE_LANGUAGE, + LS_STATUS_CONFIGURATIONACCESS_BROKEN + }; + + static com::sun::star::lang::Locale IsoStringToLocale(const rtl::OUString& str); + static rtl::OUString getLanguageString(); + static bool prepareLanguage(); + static LanguageSelectionStatus getStatus(); + private: static const rtl::OUString usFallbackLanguage; static rtl::OUString aFoundLanguage; static sal_Bool bFoundLanguage; + static LanguageSelectionStatus m_eStatus; static com::sun::star::uno::Reference< com::sun::star::container::XNameAccess > getConfigAccess(const sal_Char* pPath, sal_Bool bUpdate=sal_False); @@ -55,11 +69,6 @@ private: static rtl::OUString getSystemLanguage(); static void resetUserLanguage(); static void setDefaultLanguage(const rtl::OUString&); - -public: - static com::sun::star::lang::Locale IsoStringToLocale(const rtl::OUString& str); - static rtl::OUString getLanguageString(); - static bool prepareLanguage(); }; } //namespace desktop |