Kaydet (Commit) 37e36eca authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Related fdo#68240: Rework langselect to provide better error messages

...and in general removed lots of cruft from that code.

Change-Id: Ie673413d8abf5a8ec78c02f4abee2647bdf10a04
üst 38b58556
...@@ -36,7 +36,9 @@ ...@@ -36,7 +36,9 @@
#include "exithelper.h" #include "exithelper.h"
#include "migration.hxx" #include "migration.hxx"
#include <svl/languageoptions.hxx>
#include <svtools/javacontext.hxx> #include <svtools/javacontext.hxx>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/frame/AutoRecovery.hpp> #include <com/sun/star/frame/AutoRecovery.hpp>
#include <com/sun/star/frame/GlobalEventBroadcaster.hpp> #include <com/sun/star/frame/GlobalEventBroadcaster.hpp>
#include <com/sun/star/frame/SessionListener.hpp> #include <com/sun/star/frame/SessionListener.hpp>
...@@ -334,7 +336,7 @@ ResMgr* Desktop::GetDesktopResManager() ...@@ -334,7 +336,7 @@ ResMgr* Desktop::GetDesktopResManager()
// Use VCL to get the correct language specific message as we // Use VCL to get the correct language specific message as we
// are in the bootstrap process and not able to get the installed // are in the bootstrap process and not able to get the installed
// language!! // language!!
OUString aUILocaleString = LanguageSelection::getLanguageString(); OUString aUILocaleString = langselect::getEmergencyLocale();
LanguageTag aLanguageTag( aUILocaleString); LanguageTag aLanguageTag( aUILocaleString);
//! ResMgr may modify the Locale for fallback! //! ResMgr may modify the Locale for fallback!
Desktop::pResMgr = ResMgr::SearchCreateResMgr( "dkt", aLanguageTag); Desktop::pResMgr = ResMgr::SearchCreateResMgr( "dkt", aLanguageTag);
...@@ -580,13 +582,16 @@ void Desktop::Init() ...@@ -580,13 +582,16 @@ void Desktop::Init()
if ( m_aBootstrapError == BE_OK ) if ( m_aBootstrapError == BE_OK )
{ {
// prepare language try
if ( !LanguageSelection::prepareLanguage() )
{ {
if ( LanguageSelection::getStatus() == LanguageSelection::LS_STATUS_CANNOT_DETERMINE_LANGUAGE ) if (!langselect::prepareLocale())
{
SetBootstrapError( BE_LANGUAGE_MISSING, OUString() ); SetBootstrapError( BE_LANGUAGE_MISSING, OUString() );
else }
SetBootstrapError( BE_OFFICECONFIG_BROKEN, OUString() ); }
catch (css::uno::Exception & e)
{
SetBootstrapError( BE_OFFICECONFIG_BROKEN, e.Message );
} }
} }
...@@ -979,14 +984,15 @@ void Desktop::HandleBootstrapErrors( ...@@ -979,14 +984,15 @@ void Desktop::HandleBootstrapErrors(
} }
else if ( aBootstrapError == BE_OFFICECONFIG_BROKEN ) else if ( aBootstrapError == BE_OFFICECONFIG_BROKEN )
{ {
OUString aMessage; OUString msg(
OUStringBuffer aDiagnosticMessage( 100 ); GetMsgString(
OUString aErrorMsg; STR_CONFIG_ERR_ACCESS_GENERAL,
aErrorMsg = GetMsgString( STR_CONFIG_ERR_ACCESS_GENERAL, ("A general error occurred while accessing your central"
OUString( "A general error occurred while accessing your central configuration." ) ); " configuration.")));
aDiagnosticMessage.append( aErrorMsg ); if (!aErrorMessage.isEmpty()) {
aMessage = MakeStartupErrorMessage( aDiagnosticMessage.makeStringAndClear() ); msg += "\n(\"" + aErrorMessage + "\")";
FatalError(aMessage); }
FatalError(MakeStartupErrorMessage(msg));
} }
else if ( aBootstrapError == BE_USERINSTALL_FAILED ) else if ( aBootstrapError == BE_USERINSTALL_FAILED )
{ {
......
...@@ -17,49 +17,21 @@ ...@@ -17,49 +17,21 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 . * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/ */
#include <list> #ifndef INCLUDED_DESKTOP_SOURCE_APP_LANGSELECT_HXX
#include <sal/types.h> #define INCLUDED_DESKTOP_SOURCE_APP_LANGSELECT_HXX
#include <rtl/ustring.hxx>
#include <tools/resid.hxx>
#include <com/sun/star/lang/Locale.hpp>
#include <com/sun/star/container/XNameAccess.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <svl/languageoptions.hxx>
namespace desktop #include "sal/config.h"
{
class LanguageSelection #include "rtl/ustring.hxx"
{
public:
enum LanguageSelectionStatus
{
LS_STATUS_OK,
LS_STATUS_CANNOT_DETERMINE_LANGUAGE,
LS_STATUS_CONFIGURATIONACCESS_BROKEN
};
static OUString getLanguageString(); namespace desktop { namespace langselect {
static bool prepareLanguage();
static LanguageSelectionStatus getStatus();
private: OUString getEmergencyLocale();
static OUString aFoundLanguage;
static sal_Bool bFoundLanguage;
static LanguageSelectionStatus m_eStatus;
static com::sun::star::uno::Reference< com::sun::star::container::XNameAccess > bool prepareLocale();
getConfigAccess(const sal_Char* pPath, sal_Bool bUpdate=sal_False);
static com::sun::star::uno::Sequence< OUString > getInstalledLanguages();
static sal_Bool isInstalledLanguage(OUString& usLocale, sal_Bool bExact=sal_False);
static OUString getFirstInstalledLanguage();
static OUString getUserUILanguage();
static OUString getUserLanguage();
static OUString getSystemLanguage();
static void resetUserLanguage();
static void setDefaultLanguage(const OUString&);
};
} //namespace desktop } }
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment