Don't access broken service mgr during bootstrap failure

...so that displaying a (non-translated) error box upon BE_UNO_SERVICEMANAGER
works after all.  Augment the error text with an exception message where
appropriate.  This allows to revert fdfb7a3c4b
"Related fdo#51252: Report uncaught exceptions with MessageBox on Windows" as
that was to catch and display failures from instantiating the service mgr.

Change-Id: I049a38e95342634796eb0e940e2ee8e55193c9d3
This commit is contained in:
Stephan Bergmann
2012-09-18 12:40:57 +02:00
parent a0659cc41d
commit cccc6bcfa0
16 changed files with 172 additions and 142 deletions

View File

@@ -103,15 +103,16 @@ class Desktop : public Application
static ResMgr* GetDesktopResManager();
static CommandLineArgs& GetCommandLineArgs();
void HandleBootstrapErrors( BootstrapError );
void SetBootstrapError( BootstrapError nError )
void HandleBootstrapErrors(
BootstrapError nError, OUString const & aMessage );
void SetBootstrapError(
BootstrapError nError, OUString const & aMessage )
{
if ( m_aBootstrapError == BE_OK )
{
m_aBootstrapError = nError;
}
BootstrapError GetBootstrapError() const
{
return m_aBootstrapError;
m_aBootstrapErrorMessage = aMessage;
}
}
void SetBootstrapStatus( BootstrapStatus nStatus )
@@ -135,8 +136,6 @@ class Desktop : public Application
void SetSplashScreenText( const ::rtl::OUString& rText );
void SetSplashScreenProgress( sal_Int32 );
static void ensureProcessServiceFactory();
private:
// Bootstrap methods
static ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > CreateApplicationServiceManager();
@@ -159,9 +158,6 @@ class Desktop : public Application
void HandleBootstrapPathErrors( ::utl::Bootstrap::Status, const ::rtl::OUString& aMsg );
void StartSetup( const ::rtl::OUString& aParameters );
// Get a resource message string securely e.g. if resource cannot be retrieved return aFaultBackMsg
::rtl::OUString GetMsgString( sal_uInt16 nId, const ::rtl::OUString& aFaultBackMsg );
// Create a error message depending on bootstrap failure code and an optional file url
::rtl::OUString CreateErrorMsgString( utl::Bootstrap::FailureCode nFailureCode,
const ::rtl::OUString& aFileURL );
@@ -200,6 +196,7 @@ class Desktop : public Application
bool m_bCleanedExtensionCache;
bool m_bServicesRegistered;
BootstrapError m_aBootstrapError;
OUString m_aBootstrapErrorMessage;
BootstrapStatus m_aBootstrapStatus;
std::auto_ptr< Lockfile > m_pLockfile;

View File

@@ -378,28 +378,34 @@ ResMgr* Desktop::GetDesktopResManager()
return Desktop::pResMgr;
}
namespace {
// ----------------------------------------------------------------------------
// Get a message string securely. There is a fallback string if the resource
// is not available.
OUString Desktop::GetMsgString( sal_uInt16 nId, const OUString& aFaultBackMsg )
OUString GetMsgString(
sal_uInt16 nId, const OUString& aFaultBackMsg,
bool bAlwaysUseFaultBackMsg = false )
{
ResMgr* resMgr = GetDesktopResManager();
if ( !resMgr )
return aFaultBackMsg;
else
return OUString( String( ResId( nId, *resMgr )));
if ( !bAlwaysUseFaultBackMsg )
{
ResMgr* resMgr = Desktop::GetDesktopResManager();
if ( resMgr )
return OUString( String( ResId( nId, *resMgr )));
}
return aFaultBackMsg;
}
OUString MakeStartupErrorMessage(OUString const & aErrorMessage)
OUString MakeStartupErrorMessage(
OUString const & aErrorMessage, bool bAlwaysUseFaultBackMsg = false )
{
OUStringBuffer aDiagnosticMessage( 100 );
ResMgr* pResMgr = Desktop::GetDesktopResManager();
if ( pResMgr )
aDiagnosticMessage.append( OUString(String(ResId(STR_BOOTSTRAP_ERR_CANNOT_START, *pResMgr))) );
else
aDiagnosticMessage.appendAscii( "The program cannot be started." );
aDiagnosticMessage.append(
GetMsgString(
STR_BOOTSTRAP_ERR_CANNOT_START, "The program cannot be started.",
bAlwaysUseFaultBackMsg ) );
aDiagnosticMessage.appendAscii( "\n" );
@@ -468,9 +474,8 @@ static bool ShouldSuppressUI(const CommandLineArgs& rCmdLine)
rCmdLine.IsQuickstart();
}
namespace
{
struct theCommandLineArgs : public rtl::Static< CommandLineArgs, theCommandLineArgs > {};
struct theCommandLineArgs : public rtl::Static< CommandLineArgs, theCommandLineArgs > {};
}
CommandLineArgs& Desktop::GetCommandLineArgs()
@@ -591,29 +596,30 @@ void Desktop::Init()
// We need to have service factory before going further, but see fdo#37195.
// Doing this will mmap common.rdb, making it not overwritable on windows,
// so this can't happen before the synchronization above. Lets rework this
// so that the above is called *from* ensureProcessServiceFactory or
// so that the above is called *from* CreateApplicationServiceManager or
// something to enforce this gotcha
ensureProcessServiceFactory();
if( !::comphelper::getProcessServiceFactory().is())
try
{
OSL_FAIL("Service factory should have been crated in soffice_main().");
SetBootstrapError( BE_UNO_SERVICEMANAGER );
comphelper::setProcessServiceFactory(CreateApplicationServiceManager());
}
catch (css::uno::Exception & e)
{
SetBootstrapError( BE_UNO_SERVICEMANAGER, e.Message );
}
if ( GetBootstrapError() == BE_OK )
if ( m_aBootstrapError == BE_OK )
{
// prepare language
if ( !LanguageSelection::prepareLanguage() )
{
if ( LanguageSelection::getStatus() == LanguageSelection::LS_STATUS_CANNOT_DETERMINE_LANGUAGE )
SetBootstrapError( BE_LANGUAGE_MISSING );
SetBootstrapError( BE_LANGUAGE_MISSING, OUString() );
else
SetBootstrapError( BE_OFFICECONFIG_BROKEN );
SetBootstrapError( BE_OFFICECONFIG_BROKEN, OUString() );
}
}
if ( GetBootstrapError() == BE_OK )
if ( m_aBootstrapError == BE_OK )
{
const CommandLineArgs& rCmdLineArgs = GetCommandLineArgs();
// start ipc thread only for non-remote offices
@@ -621,7 +627,7 @@ void Desktop::Init()
OfficeIPCThread::Status aStatus = OfficeIPCThread::EnableOfficeIPCThread();
if ( aStatus == OfficeIPCThread::IPC_STATUS_BOOTSTRAP_ERROR )
{
SetBootstrapError( BE_PATHINFO_MISSING );
SetBootstrapError( BE_PATHINFO_MISSING, OUString() );
}
else if ( aStatus == OfficeIPCThread::IPC_STATUS_2ND_OFFICE )
{
@@ -644,29 +650,6 @@ void Desktop::InitFinished()
CloseSplashScreen();
}
// GetCommandLineArgs() requires this code to work, otherwise it will abort, and
// on Unix command line args needs to be checked before Desktop::Init()
void Desktop::ensureProcessServiceFactory()
{
if (!comphelper::getProcessServiceFactory().is())
{
try
{
comphelper::setProcessServiceFactory(
CreateApplicationServiceManager());
}
catch (const css::uno::Exception& e)
{
// Application::ShowNativeErrorBox would only work after InitVCL, so
// all we can realistically do here is hope the user can see stderr:
std::cerr << "UNO Exception: " << e.Message << std::endl;
// Let exceptions escape and tear down the process, it is completely
// broken anyway:
throw;
}
}
}
void Desktop::DeInit()
{
RTL_LOGFILE_CONTEXT( aLog, "desktop (cd100003) ::Desktop::DeInit" );
@@ -881,7 +864,8 @@ void Desktop::HandleBootstrapPathErrors( ::utl::Bootstrap::Status aBootstrapStat
return MakeStartupErrorMessage( aMsg );
}
void Desktop::HandleBootstrapErrors( BootstrapError aBootstrapError )
void Desktop::HandleBootstrapErrors(
BootstrapError aBootstrapError, OUString const & aErrorMessage )
{
if ( aBootstrapError == BE_PATHINFO_MISSING )
{
@@ -962,16 +946,18 @@ void Desktop::HandleBootstrapErrors( BootstrapError aBootstrapError )
// PropertyValue is available). To give the user a hint even if
// generating and displaying a message box below crashes, print a
// hard-coded message on stderr first:
fputs(
aBootstrapError == BE_UNO_SERVICEMANAGER
? ("The application cannot be started. " "\n"
"The component manager is not available." "\n")
// STR_BOOTSTRAP_ERR_CANNOT_START, STR_BOOTSTRAP_ERR_NO_SERVICE
: ("The application cannot be started. " "\n"
"The configuration service is not available." "\n"),
// STR_BOOTSTRAP_ERR_CANNOT_START,
// STR_BOOTSTRAP_ERR_NO_CFG_SERVICE
stderr);
std::cerr
<< "The application cannot be started.\n"
// STR_BOOTSTRAP_ERR_CANNOT_START
<< (aBootstrapError == BE_UNO_SERVICEMANAGER
? "The component manager is not available.\n"
// STR_BOOTSTRAP_ERR_NO_SERVICE
: "The configuration service is not available.\n");
// STR_BOOTSTRAP_ERR_NO_CFG_SERVICE
if ( !aErrorMessage.isEmpty() )
{
std::cerr << "(\"" << aErrorMessage << "\")\n";
}
// First sentence. We cannot bootstrap office further!
OUString aMessage;
@@ -980,24 +966,32 @@ void Desktop::HandleBootstrapErrors( BootstrapError aBootstrapError )
OUString aErrorMsg;
if ( aBootstrapError == BE_UNO_SERVICEMANAGER )
aErrorMsg = GetMsgString( STR_BOOTSTRAP_ERR_NO_SERVICE,
OUString( "The service manager is not available." ) );
aErrorMsg = "The service manager is not available.";
else
aErrorMsg = GetMsgString( STR_BOOTSTRAP_ERR_NO_CFG_SERVICE,
OUString( "The configuration service is not available." ) );
aDiagnosticMessage.append( aErrorMsg );
aDiagnosticMessage.appendAscii( "\n" );
if ( !aErrorMessage.isEmpty() )
{
aDiagnosticMessage.appendAscii( "(\"" );
aDiagnosticMessage.append( aErrorMessage );
aDiagnosticMessage.appendAscii( "\")\n" );
}
// Due to the fact the we haven't a backup applicat.rdb file anymore it is not possible to
// repair the installation with the setup executable besides the office executable. Now
// we have to ask the user to start the setup on CD/installation directory manually!!
OUString aStartSetupManually( GetMsgString(
STR_ASK_START_SETUP_MANUALLY,
OUString( "Start setup application to repair the installation from CD, or the folder containing the installation packages." ) ));
OUString( "Start setup application to repair the installation from CD, or the folder containing the installation packages." ),
aBootstrapError == BE_UNO_SERVICEMANAGER ) );
aDiagnosticMessage.append( aStartSetupManually );
aMessage = MakeStartupErrorMessage( aDiagnosticMessage.makeStringAndClear() );
aMessage = MakeStartupErrorMessage(
aDiagnosticMessage.makeStringAndClear(),
aBootstrapError == BE_UNO_SERVICEMANAGER );
FatalError( aMessage);
}
@@ -1378,10 +1372,9 @@ int Desktop::Main()
com::sun::star::uno::ContextLayer layer(
com::sun::star::uno::getCurrentContext() );
BootstrapError eError = GetBootstrapError();
if ( eError != BE_OK )
if ( m_aBootstrapError != BE_OK )
{
HandleBootstrapErrors( eError );
HandleBootstrapErrors( m_aBootstrapError, m_aBootstrapErrorMessage );
return EXIT_FAILURE;
}
@@ -1415,11 +1408,12 @@ int Desktop::Main()
{
OSL_FAIL("userinstall failed");
if ( inst_fin == UserInstall::E_NoDiskSpace )
HandleBootstrapErrors( BE_USERINSTALL_NOTENOUGHDISKSPACE );
HandleBootstrapErrors(
BE_USERINSTALL_NOTENOUGHDISKSPACE, OUString() );
else if ( inst_fin == UserInstall::E_NoWriteAccess )
HandleBootstrapErrors( BE_USERINSTALL_NOWRITEACCESS );
HandleBootstrapErrors( BE_USERINSTALL_NOWRITEACCESS, OUString() );
else
HandleBootstrapErrors( BE_USERINSTALL_FAILED );
HandleBootstrapErrors( BE_USERINSTALL_FAILED, OUString() );
return EXIT_FAILURE;
}
// refresh path information
@@ -1797,9 +1791,10 @@ bool Desktop::InitializeConfiguration()
comphelper::getProcessComponentContext() );
return true;
}
catch( const ::com::sun::star::lang::ServiceNotRegisteredException& )
catch( ::com::sun::star::lang::ServiceNotRegisteredException & e )
{
this->HandleBootstrapErrors( Desktop::BE_UNO_SERVICE_CONFIG_MISSING );
this->HandleBootstrapErrors(
Desktop::BE_UNO_SERVICE_CONFIG_MISSING, e.Message );
}
catch( const ::com::sun::star::configuration::MissingBootstrapFileException& e )
{

View File

@@ -51,7 +51,6 @@
#define STR_BOOTSTRAP_ERR_NO_SUPPORT (RID_DESKTOP_STRING_START+107)
#define STR_BOOTSTRAP_ERR_LANGUAGE_MISSING (RID_DESKTOP_STRING_START+108)
#define STR_BOOTSTRAP_ERR_NO_SERVICE (RID_DESKTOP_STRING_START+120)
#define STR_BOOTSTRAP_ERR_NO_CFG_SERVICE (RID_DESKTOP_STRING_START+121)
#define STR_BOOTSTRAP_ERR_CFG_DATAACCESS (RID_DESKTOP_STRING_START+122)
#define STR_BOOTSTRAP_ERR_NO_PATHSET_SERVICE (RID_DESKTOP_STRING_START+123)

View File

@@ -88,11 +88,6 @@ String STR_BOOTSTRAP_ERR_LANGUAGE_MISSING
Text [ en-US ] = "The user interface language cannot be determined.";
};
String STR_BOOTSTRAP_ERR_NO_SERVICE
{
Text [ en-US ] = "The component manager is not available.";
};
String STR_BOOTSTRAP_ERR_NO_CFG_SERVICE
{
Text [ en-US ] = "The configuration service is not available.";

View File

@@ -38,21 +38,14 @@
#include <rtl/bootstrap.hxx>
#include <tools/extendapplicationenvironment.hxx>
#if defined WNT
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#endif
int SVMain();
// -=-= main() -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
extern "C" int DESKTOP_DLLPUBLIC soffice_main()
{
#if defined ANDROID || defined WNT
#if defined ANDROID
try {
#endif
#if defined(ANDROID)
rtl::Bootstrap::setIniFilename(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("file:///assets/program/lofficerc")));
#endif
@@ -83,20 +76,10 @@ extern "C" int DESKTOP_DLLPUBLIC soffice_main()
}
#endif
return SVMain();
#if defined ANDROID || defined WNT
} catch (const ::com::sun::star::uno::Exception &e) {
#if defined ANDROID
} catch (const ::com::sun::star::uno::Exception &e) {
fprintf (stderr, "Not handled UNO exception at main: '%s'\n",
rtl::OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8).getStr());
#elif defined WNT
MessageBoxW(
0,
reinterpret_cast< LPCWSTR >(
rtl::OUString("Unhandled exception:\n" + e.Message).getStr()),
reinterpret_cast< LPCWSTR >(rtl::OUString("Fatal Error").getStr()),
(MB_OK | MB_ICONERROR | MB_DEFBUTTON1 | MB_TASKMODAL
| MB_SETFOREGROUND | MB_TOPMOST));
#endif
throw; // to get exception type printed
}
#endif

View File

@@ -106,9 +106,13 @@ rtl::OUString AquaSalSystem::GetDisplayScreenName( unsigned int nScreen )
return aRet;
}
static NSString* getStandardString( int nButtonId )
static NSString* getStandardString( int nButtonId, bool bUseResources )
{
rtl::OUString aText( Button::GetStandardText( nButtonId ) );
rtl::OUString aText;
if( bUseResources )
{
aText = Button::GetStandardText( nButtonId );
}
if( aText.isEmpty() ) // this is for bad cases, we might be missing the vcl resource
{
switch( nButtonId )
@@ -127,7 +131,7 @@ static NSString* getStandardString( int nButtonId )
int AquaSalSystem::ShowNativeMessageBox( const rtl::OUString& rTitle,
const rtl::OUString& rMessage,
int nButtonCombination,
int nDefaultButton)
int nDefaultButton, bool bUseResources)
{
NSString* pTitle = CreateNSString( rTitle );
NSString* pMessage = CreateNSString( rMessage );
@@ -166,11 +170,14 @@ int AquaSalSystem::ShowNativeMessageBox( const rtl::OUString& rTitle,
if( aButtonIds[nC].nDefaultButton == nDefaultButton )
{
if( aButtonIds[nC].nTextIds[0] != -1 )
pDefText = getStandardString( aButtonIds[nC].nTextIds[0] );
pDefText = getStandardString(
aButtonIds[nC].nTextIds[0], bUseResources );
if( aButtonIds[nC].nTextIds[1] != -1 )
pAltText = getStandardString( aButtonIds[nC].nTextIds[1] );
pAltText = getStandardString(
aButtonIds[nC].nTextIds[1], bUseResources );
if( aButtonIds[nC].nTextIds[2] != -1 )
pOthText = getStandardString( aButtonIds[nC].nTextIds[2] );
pOthText = getStandardString(
aButtonIds[nC].nTextIds[2], bUseResources );
break;
}
}

View File

@@ -47,6 +47,47 @@
using namespace com::sun::star;
namespace {
OUString GetNativeMessageBoxButtonText( int nButtonId, bool bUseResources )
{
OUString aText;
if( bUseResources )
{
aText = Button::GetStandardText( nButtonId );
}
if( aText.isEmpty() )
{
switch( nButtonId )
{
case BUTTON_OK:
aText = "OK";
break;
case BUTTON_CANCEL:
aText = "Cancel";
break;
case BUTTON_ABORT:
aText = "Abort";
break;
case BUTTON_RETRY:
aText = "Retry";
break;
case BUTTON_IGNORE:
aText = "Ignore";
break;
case BUTTON_YES:
aText = "Yes";
break;
case BUTTON_NO:
aText = "No";
break;
}
}
return aText;
}
}
SalGenericSystem::SalGenericSystem()
{
}
@@ -56,7 +97,8 @@ SalGenericSystem::~SalGenericSystem()
}
int SalGenericSystem::ShowNativeMessageBox( const rtl::OUString& rTitle, const rtl::OUString& rMessage,
int nButtonCombination, int nDefaultButton )
int nButtonCombination, int nDefaultButton,
bool bUseResources )
{
int nDefButton = 0;
std::list< rtl::OUString > aButtons;
@@ -67,15 +109,15 @@ int SalGenericSystem::ShowNativeMessageBox( const rtl::OUString& rTitle, const r
if( nButtonCombination == SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_OK ||
nButtonCombination == SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_OK_CANCEL )
{
aButtons.push_back( Button::GetStandardText( BUTTON_OK ) );
aButtons.push_back( GetNativeMessageBoxButtonText( BUTTON_OK, bUseResources ) );
nButtonIds[nBut++] = SALSYSTEM_SHOWNATIVEMSGBOX_BTN_OK;
}
if( nButtonCombination == SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_YES_NO_CANCEL ||
nButtonCombination == SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_YES_NO )
{
aButtons.push_back( Button::GetStandardText( BUTTON_YES ) );
aButtons.push_back( GetNativeMessageBoxButtonText( BUTTON_YES, bUseResources ) );
nButtonIds[nBut++] = SALSYSTEM_SHOWNATIVEMSGBOX_BTN_YES;
aButtons.push_back( Button::GetStandardText( BUTTON_NO ) );
aButtons.push_back( GetNativeMessageBoxButtonText( BUTTON_NO, bUseResources ) );
nButtonIds[nBut++] = SALSYSTEM_SHOWNATIVEMSGBOX_BTN_NO;
if( nDefaultButton == SALSYSTEM_SHOWNATIVEMSGBOX_BTN_NO )
nDefButton = 1;
@@ -86,21 +128,21 @@ int SalGenericSystem::ShowNativeMessageBox( const rtl::OUString& rTitle, const r
{
if( nButtonCombination == SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_RETRY_CANCEL )
{
aButtons.push_back( Button::GetStandardText( BUTTON_RETRY ) );
aButtons.push_back( GetNativeMessageBoxButtonText( BUTTON_RETRY, bUseResources ) );
nButtonIds[nBut++] = SALSYSTEM_SHOWNATIVEMSGBOX_BTN_RETRY;
}
aButtons.push_back( Button::GetStandardText( BUTTON_CANCEL ) );
aButtons.push_back( GetNativeMessageBoxButtonText( BUTTON_CANCEL, bUseResources ) );
nButtonIds[nBut++] = SALSYSTEM_SHOWNATIVEMSGBOX_BTN_CANCEL;
if( nDefaultButton == SALSYSTEM_SHOWNATIVEMSGBOX_BTN_CANCEL )
nDefButton = aButtons.size()-1;
}
if( nButtonCombination == SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_ABORT_RETRY_IGNORE )
{
aButtons.push_back( Button::GetStandardText( BUTTON_ABORT ) );
aButtons.push_back( GetNativeMessageBoxButtonText( BUTTON_ABORT, bUseResources ) );
nButtonIds[nBut++] = SALSYSTEM_SHOWNATIVEMSGBOX_BTN_ABORT;
aButtons.push_back( Button::GetStandardText( BUTTON_RETRY ) );
aButtons.push_back( GetNativeMessageBoxButtonText( BUTTON_RETRY, bUseResources ) );
nButtonIds[nBut++] = SALSYSTEM_SHOWNATIVEMSGBOX_BTN_RETRY;
aButtons.push_back( Button::GetStandardText( BUTTON_IGNORE ) );
aButtons.push_back( GetNativeMessageBoxButtonText( BUTTON_IGNORE, bUseResources ) );
nButtonIds[nBut++] = SALSYSTEM_SHOWNATIVEMSGBOX_BTN_IGNORE;
switch( nDefaultButton )
{

View File

@@ -52,7 +52,7 @@ public:
virtual int ShowNativeMessageBox( const rtl::OUString& rTitle,
const rtl::OUString& rMessage,
int nButtonCombination,
int nDefaultButton);
int nDefaultButton, bool bUseResources);
};

View File

@@ -50,7 +50,7 @@ class VCL_DLLPUBLIC SalGenericSystem : public SalSystem
virtual int ShowNativeMessageBox( const rtl::OUString& rTitle,
const rtl::OUString& rMessage,
int nButtonCombination,
int nDefaultButton);
int nDefaultButton, bool bUseResources);
// simple helpers primarily for X Windowing W_CLASS hints
static const char *getFrameResName();

View File

@@ -46,7 +46,7 @@ public:
virtual int ShowNativeMessageBox( const rtl::OUString& rTitle,
const rtl::OUString& rMessage,
int nButtonCombination,
int nDefaultButton);
int nDefaultButton, bool bUseResources);
};
#endif // _SV_SALSYS_H

View File

@@ -133,6 +133,10 @@ public:
The effect of specifying a button that doesn't belong
to the specified button combination is undefined.
@param bUseResources
If false, assume initialization of the application failed early and do
not try to access any resources.
@returns the identifier of the button that was pressed by the user.
See button identifier above. If the function fails the
return value is 0.
@@ -140,7 +144,8 @@ public:
virtual int ShowNativeMessageBox( const rtl::OUString& rTitle,
const rtl::OUString& rMessage,
int nButtonCombination,
int nDefaultButton) = 0;
int nDefaultButton,
bool bUseResources ) = 0;
};
SalSystem* ImplGetSalSystem();

View File

@@ -76,7 +76,7 @@ public:
virtual int ShowNativeMessageBox( const rtl::OUString& rTitle,
const rtl::OUString& rMessage,
int nButtonCombination,
int nDefaultButton);
int nDefaultButton, bool bUseResources);
bool initMonitors();
// discards monitorinfo; used by WM_DISPLAYCHANGED handler
void clearMonitors();

View File

@@ -106,9 +106,13 @@ rtl::OUString IosSalSystem::GetDisplayScreenName( unsigned int nScreen )
return aRet;
}
static NSString* getStandardString( int nButtonId )
static NSString* getStandardString( int nButtonId, bool bUseResources )
{
rtl::OUString aText( Button::GetStandardText( nButtonId ) );
rtl::OUString aText;
if( bUseResources )
{
aText = Button::GetStandardText( nButtonId );
}
if( ! aText.getLength() ) // this is for bad cases, we might be missing the vcl resource
{
switch( nButtonId )
@@ -150,7 +154,7 @@ static NSString* getStandardString( int nButtonId )
int IosSalSystem::ShowNativeMessageBox( const rtl::OUString& rTitle,
const rtl::OUString& rMessage,
int nButtonCombination,
int nDefaultButton)
int nDefaultButton, bool bUseResources)
{
NSString* pTitle = CreateNSString( rTitle );
NSString* pMessage = CreateNSString( rMessage );
@@ -189,11 +193,14 @@ int IosSalSystem::ShowNativeMessageBox( const rtl::OUString& rTitle,
if( aButtonIds[nC].nDefaultButton == nDefaultButton )
{
if( aButtonIds[nC].nTextIds[0] != -1 )
pDefText = getStandardString( aButtonIds[nC].nTextIds[0] );
pDefText = getStandardString(
aButtonIds[nC].nTextIds[0], bUseResources );
if( aButtonIds[nC].nTextIds[1] != -1 )
pAltText = getStandardString( aButtonIds[nC].nTextIds[1] );
pAltText = getStandardString(
aButtonIds[nC].nTextIds[1], bUseResources );
if( aButtonIds[nC].nTextIds[2] != -1 )
pOthText = getStandardString( aButtonIds[nC].nTextIds[2] );
pOthText = getStandardString(
aButtonIds[nC].nTextIds[2], bUseResources );
break;
}
}

View File

@@ -1716,7 +1716,7 @@ void Application::ShowNativeErrorBox(const String& sTitle ,
sTitle,
sMessage,
SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_OK,
SALSYSTEM_SHOWNATIVEMSGBOX_BTN_OK);
SALSYSTEM_SHOWNATIVEMSGBOX_BTN_OK, false);
if (btn != SALSYSTEM_SHOWNATIVEMSGBOX_BTN_OK) {
OSL_TRACE("ShowNativeMessageBox returned %d", btn);
}

View File

@@ -407,7 +407,7 @@ bool ImplInitAccessBridge(sal_Bool bAllowCancel, sal_Bool &rCancelled)
aTitle,
ReplaceJavaErrorMessages(aMessage.makeStringAndClear()),
SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_OK_CANCEL,
SALSYSTEM_SHOWNATIVEMSGBOX_BTN_CANCEL);
SALSYSTEM_SHOWNATIVEMSGBOX_BTN_CANCEL, true);
// Do not change the setting in case the user chooses to cancel
if( SALSYSTEM_SHOWNATIVEMSGBOX_BTN_CANCEL == ret )
@@ -430,7 +430,7 @@ bool ImplInitAccessBridge(sal_Bool bAllowCancel, sal_Bool &rCancelled)
aTitle,
ReplaceJavaErrorMessages(aMessage.makeStringAndClear()),
SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_OK_CANCEL,
SALSYSTEM_SHOWNATIVEMSGBOX_BTN_CANCEL);
SALSYSTEM_SHOWNATIVEMSGBOX_BTN_CANCEL, true);
// Do not change the setting in case the user chooses to cancel
if( SALSYSTEM_SHOWNATIVEMSGBOX_BTN_CANCEL == ret )
@@ -453,7 +453,7 @@ bool ImplInitAccessBridge(sal_Bool bAllowCancel, sal_Bool &rCancelled)
aTitle,
ReplaceJavaErrorMessages(aMessage.makeStringAndClear()),
SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_OK_CANCEL,
SALSYSTEM_SHOWNATIVEMSGBOX_BTN_CANCEL);
SALSYSTEM_SHOWNATIVEMSGBOX_BTN_CANCEL, true);
// Do not change the setting in case the user chooses to cancel
if( SALSYSTEM_SHOWNATIVEMSGBOX_BTN_CANCEL == ret )
@@ -476,7 +476,7 @@ bool ImplInitAccessBridge(sal_Bool bAllowCancel, sal_Bool &rCancelled)
aTitle,
ReplaceJavaErrorMessages(aMessage.makeStringAndClear()),
SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_OK_CANCEL,
SALSYSTEM_SHOWNATIVEMSGBOX_BTN_CANCEL);
SALSYSTEM_SHOWNATIVEMSGBOX_BTN_CANCEL, true);
// Do not change the setting in case the user chooses to cancel
if( SALSYSTEM_SHOWNATIVEMSGBOX_BTN_CANCEL == ret )
@@ -515,7 +515,7 @@ bool ImplInitAccessBridge(sal_Bool bAllowCancel, sal_Bool &rCancelled)
aTitle,
ReplaceJavaErrorMessages(aMessage.makeStringAndClear()),
SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_OK_CANCEL,
SALSYSTEM_SHOWNATIVEMSGBOX_BTN_CANCEL);
SALSYSTEM_SHOWNATIVEMSGBOX_BTN_CANCEL, true);
// Do not change the setting in case the user chooses to cancel
if( SALSYSTEM_SHOWNATIVEMSGBOX_BTN_CANCEL == ret )
@@ -529,7 +529,7 @@ bool ImplInitAccessBridge(sal_Bool bAllowCancel, sal_Bool &rCancelled)
aTitle,
ReplaceJavaErrorMessages(aMessage.makeStringAndClear()),
SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_OK,
SALSYSTEM_SHOWNATIVEMSGBOX_BTN_OK);
SALSYSTEM_SHOWNATIVEMSGBOX_BTN_OK, true);
}
}
}

View File

@@ -220,7 +220,7 @@ static int DEFAULT_BTN_MAPPING_TABLE[][8] =
{ MB_DEFBUTTON1, MB_DEFBUTTON1, MB_DEFBUTTON2, MB_DEFBUTTON1, MB_DEFBUTTON1, MB_DEFBUTTON1, MB_DEFBUTTON1, MB_DEFBUTTON1 } //RETRY_CANCEL
};
int WinSalSystem::ShowNativeMessageBox(const rtl::OUString& rTitle, const rtl::OUString& rMessage, int nButtonCombination, int nDefaultButton)
int WinSalSystem::ShowNativeMessageBox(const rtl::OUString& rTitle, const rtl::OUString& rMessage, int nButtonCombination, int nDefaultButton, SAL_UNUSED_PARAMETER bool)
{
DBG_ASSERT( nButtonCombination >= SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_OK &&
nButtonCombination <= SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_RETRY_CANCEL &&