[Libreoffice-commits] .: Branch 'libreoffice-3-6' - desktop/inc desktop/source vcl/aqua vcl/generic vcl/inc vcl/ios vcl/source vcl/win

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Thu Sep 20 04:13:22 PDT 2012


 desktop/inc/app.hxx                |   19 ++---
 desktop/source/app/app.cxx         |  139 +++++++++++++++++--------------------
 desktop/source/app/desktop.hrc     |    1 
 desktop/source/app/desktop.src     |    5 -
 desktop/source/app/sofficemain.cxx |   21 -----
 vcl/aqua/source/app/salsys.cxx     |   19 +++--
 vcl/generic/app/gensys.cxx         |   60 +++++++++++++--
 vcl/inc/aqua/salsys.h              |    2 
 vcl/inc/generic/gensys.h           |    2 
 vcl/inc/ios/salsys.h               |    2 
 vcl/inc/salsys.hxx                 |    7 +
 vcl/inc/win/salsys.h               |    2 
 vcl/ios/source/app/salsys.cxx      |   19 +++--
 vcl/source/app/svapp.cxx           |    2 
 vcl/source/app/svdata.cxx          |   12 +--
 vcl/win/source/app/salinfo.cxx     |    2 
 16 files changed, 172 insertions(+), 142 deletions(-)

New commits:
commit 98acef27d06dfa63274ec4ce0ec934fc52e5a15d
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Tue Sep 18 12:40:57 2012 +0200

    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 fdfb7a3c4b3a89b73ab5546b9620348bc4984d8f
    "Related fdo#51252: Report uncaught exceptions with MessageBox on Windows" as
    that was to catch and display failures from instantiating the service mgr.
    
    (cherry picked from commit cccc6bcfa095121c91e8bbc396f5bcf7e95424b9)
    
    Change-Id: I049a38e95342634796eb0e940e2ee8e55193c9d3
    Reviewed-on: https://gerrit.libreoffice.org/654
    Reviewed-by: Michael Stahl <mstahl at redhat.com>
    Tested-by: Michael Stahl <mstahl at redhat.com>

diff --git a/desktop/inc/app.hxx b/desktop/inc/app.hxx
index c830b02..8805c57 100644
--- a/desktop/inc/app.hxx
+++ b/desktop/inc/app.hxx
@@ -107,15 +107,16 @@ class Desktop : public Application
         static ResMgr*          GetDesktopResManager();
         static CommandLineArgs& GetCommandLineArgs();
 
-        void                    HandleBootstrapErrors( BootstrapError );
-        void                    SetBootstrapError( BootstrapError nError )
+        void                    HandleBootstrapErrors(
+            BootstrapError nError, rtl::OUString const & aMessage );
+        void                    SetBootstrapError(
+            BootstrapError nError, rtl::OUString const & aMessage )
         {
             if ( m_aBootstrapError == BE_OK )
+            {
                 m_aBootstrapError = nError;
-        }
-        BootstrapError          GetBootstrapError() const
-        {
-            return m_aBootstrapError;
+                m_aBootstrapErrorMessage = aMessage;
+            }
         }
 
         void                    SetBootstrapStatus( BootstrapStatus nStatus )
@@ -139,8 +140,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();
@@ -163,9 +162,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 );
@@ -207,6 +203,7 @@ class Desktop : public Application
         bool                            m_bServicesRegistered;
         sal_uInt16                          m_nAppEvents;
         BootstrapError                  m_aBootstrapError;
+        rtl::OUString                   m_aBootstrapErrorMessage;
         BootstrapStatus                 m_aBootstrapStatus;
 
         std::auto_ptr< Lockfile > m_pLockfile;
diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx
index 5fb653b..ea350ca 100644
--- a/desktop/source/app/app.cxx
+++ b/desktop/source/app/app.cxx
@@ -373,28 +373,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" );
 
@@ -463,9 +469,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()
@@ -583,29 +588,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
+    {
+        comphelper::setProcessServiceFactory(CreateApplicationServiceManager());
+    }
+    catch (css::uno::Exception & e)
     {
-        OSL_FAIL("Service factory should have been crated in soffice_main().");
-        SetBootstrapError( BE_UNO_SERVICEMANAGER );
+        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
@@ -613,7 +619,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 )
         {
@@ -636,29 +642,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" );
@@ -873,7 +856,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 )
     {
@@ -954,16 +938,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;
@@ -972,24 +958,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);
     }
@@ -1386,10 +1380,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;
     }
 
@@ -1423,11 +1416,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
@@ -1805,9 +1799,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 )
     {
diff --git a/desktop/source/app/desktop.hrc b/desktop/source/app/desktop.hrc
index 9c68d7b..83aa711 100644
--- a/desktop/source/app/desktop.hrc
+++ b/desktop/source/app/desktop.hrc
@@ -67,7 +67,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)
diff --git a/desktop/source/app/desktop.src b/desktop/source/app/desktop.src
index 0b6bc3f..913f88b 100644
--- a/desktop/source/app/desktop.src
+++ b/desktop/source/app/desktop.src
@@ -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.";
diff --git a/desktop/source/app/sofficemain.cxx b/desktop/source/app/sofficemain.cxx
index a0fba04..e867601 100755
--- a/desktop/source/app/sofficemain.cxx
+++ b/desktop/source/app/sofficemain.cxx
@@ -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
diff --git a/vcl/aqua/source/app/salsys.cxx b/vcl/aqua/source/app/salsys.cxx
index 7c6f683..6c65178 100644
--- a/vcl/aqua/source/app/salsys.cxx
+++ b/vcl/aqua/source/app/salsys.cxx
@@ -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;
             }
         }
diff --git a/vcl/generic/app/gensys.cxx b/vcl/generic/app/gensys.cxx
index ded4900..4a26a4b 100644
--- a/vcl/generic/app/gensys.cxx
+++ b/vcl/generic/app/gensys.cxx
@@ -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 )
         {
diff --git a/vcl/inc/aqua/salsys.h b/vcl/inc/aqua/salsys.h
index 6491cab..d352ebb 100644
--- a/vcl/inc/aqua/salsys.h
+++ b/vcl/inc/aqua/salsys.h
@@ -52,7 +52,7 @@ public:
     virtual int ShowNativeMessageBox( const rtl::OUString& rTitle,
                                       const rtl::OUString& rMessage,
                                       int nButtonCombination,
-                                      int nDefaultButton);
+                                      int nDefaultButton, bool bUseResources);
 };
 
 
diff --git a/vcl/inc/generic/gensys.h b/vcl/inc/generic/gensys.h
index e485cc5..bf98fe6 100644
--- a/vcl/inc/generic/gensys.h
+++ b/vcl/inc/generic/gensys.h
@@ -51,7 +51,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();
diff --git a/vcl/inc/ios/salsys.h b/vcl/inc/ios/salsys.h
index 2184d2b..17c831c 100644
--- a/vcl/inc/ios/salsys.h
+++ b/vcl/inc/ios/salsys.h
@@ -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
diff --git a/vcl/inc/salsys.hxx b/vcl/inc/salsys.hxx
index 6c9eb37..60b89ad 100644
--- a/vcl/inc/salsys.hxx
+++ b/vcl/inc/salsys.hxx
@@ -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();
diff --git a/vcl/inc/win/salsys.h b/vcl/inc/win/salsys.h
index b15c1a7..c70b032 100644
--- a/vcl/inc/win/salsys.h
+++ b/vcl/inc/win/salsys.h
@@ -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();
diff --git a/vcl/ios/source/app/salsys.cxx b/vcl/ios/source/app/salsys.cxx
index 02cd644..8501e3f 100644
--- a/vcl/ios/source/app/salsys.cxx
+++ b/vcl/ios/source/app/salsys.cxx
@@ -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;
             }
         }
diff --git a/vcl/source/app/svapp.cxx b/vcl/source/app/svapp.cxx
index 7e6d544..b98f3a6 100644
--- a/vcl/source/app/svapp.cxx
+++ b/vcl/source/app/svapp.cxx
@@ -1736,7 +1736,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);
     }
diff --git a/vcl/source/app/svdata.cxx b/vcl/source/app/svdata.cxx
index c1c0954..c7432ef 100644
--- a/vcl/source/app/svdata.cxx
+++ b/vcl/source/app/svdata.cxx
@@ -410,7 +410,7 @@ bool ImplInitAccessBridge(sal_Bool bAllowCancel, sal_Bool &rCancelled)
                 aTitle,
                 ReplaceJavaErrorMessages(aMessage),
                 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 )
@@ -434,7 +434,7 @@ bool ImplInitAccessBridge(sal_Bool bAllowCancel, sal_Bool &rCancelled)
                 aTitle,
                 ReplaceJavaErrorMessages(aMessage),
                 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 )
@@ -458,7 +458,7 @@ bool ImplInitAccessBridge(sal_Bool bAllowCancel, sal_Bool &rCancelled)
                 aTitle,
                 ReplaceJavaErrorMessages(aMessage),
                 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 )
@@ -482,7 +482,7 @@ bool ImplInitAccessBridge(sal_Bool bAllowCancel, sal_Bool &rCancelled)
                 aTitle,
                 ReplaceJavaErrorMessages(aMessage),
                 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 )
@@ -522,7 +522,7 @@ bool ImplInitAccessBridge(sal_Bool bAllowCancel, sal_Bool &rCancelled)
                         aTitle,
                         ReplaceJavaErrorMessages(aMessage),
                         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 )
@@ -536,7 +536,7 @@ bool ImplInitAccessBridge(sal_Bool bAllowCancel, sal_Bool &rCancelled)
                         aTitle,
                         ReplaceJavaErrorMessages(aMessage),
                         SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_OK,
-                        SALSYSTEM_SHOWNATIVEMSGBOX_BTN_OK);
+                        SALSYSTEM_SHOWNATIVEMSGBOX_BTN_OK, true);
                 }
             }
         }
diff --git a/vcl/win/source/app/salinfo.cxx b/vcl/win/source/app/salinfo.cxx
index b5576c9..0a0dcac 100644
--- a/vcl/win/source/app/salinfo.cxx
+++ b/vcl/win/source/app/salinfo.cxx
@@ -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 &&


More information about the Libreoffice-commits mailing list