diff options
author | Mathias Bauer <mba@openoffice.org> | 2001-07-17 07:34:12 +0000 |
---|---|---|
committer | Mathias Bauer <mba@openoffice.org> | 2001-07-17 07:34:12 +0000 |
commit | c9f5b3017bc38b6aff7ef6ee4e13a53532a9f042 (patch) | |
tree | 6b17e1f0634175299385d469ef9e96e04ebf6c9a /desktop/source | |
parent | ff68af298f223f942d9d49cad2ebfc5bbf0be331 (diff) |
#89023#: move crash guard because of startup optimizations
Diffstat (limited to 'desktop/source')
-rw-r--r-- | desktop/source/app/app.cxx | 195 | ||||
-rw-r--r-- | desktop/source/app/desktop.hrc | 5 | ||||
-rw-r--r-- | desktop/source/app/desktop.src | 34 |
3 files changed, 220 insertions, 14 deletions
diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx index 18486b704ad9..3c9acf87d793 100644 --- a/desktop/source/app/app.cxx +++ b/desktop/source/app/app.cxx @@ -2,9 +2,9 @@ * * $RCSfile: app.cxx,v $ * - * $Revision: 1.24 $ + * $Revision: 1.25 $ * - * last change: $Author: cd $ $Date: 2001-07-16 12:52:33 $ + * last change: $Author: mba $ $Date: 2001-07-17 08:34:12 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -70,6 +70,18 @@ #include "appsys.hxx" #include "desktopresid.hxx" +#ifndef _COM_SUN_STAR_FRAME_XSTORABLE_HPP_ +#include <com/sun/star/frame/XStorable.hpp> +#endif +#ifndef _COM_SUN_STAR_UTIL_XMODIFIABLE_HPP_ +#include <com/sun/star/util/XModifiable.hpp> +#endif +#ifndef _COM_SUN_STAR_SYSTEM_XSYSTEMSHELLEXECUTE_HPP_ +#include <com/sun/star/system/XSystemShellExecute.hpp> +#endif +#ifndef _COM_SUN_STAR_SYSTEM_SYSTEMSHELLEXECUTEFLAGS_HPP_ +#include <com/sun/star/system/SystemShellExecuteFlags.hpp> +#endif #ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_ #include <com/sun/star/beans/XPropertySet.hpp> #endif @@ -129,6 +141,8 @@ #include <svtools/pathoptions.hxx> #include <svtools/cjkoptions.hxx> #include <svtools/internaloptions.hxx> +#include <unotools/tempfile.hxx> +#include <osl/file.hxx> #include <rtl/logfile.hxx> #include <setup2/installer.hxx> @@ -151,11 +165,13 @@ using namespace ::com::sun::star::bridge; using namespace ::com::sun::star::frame; using namespace ::com::sun::star::document; using namespace ::com::sun::star::view; +using namespace ::com::sun::star::system; static SalMainPipeExchangeSignalHandler* pSignalHandler = 0; OOfficeAcceptorThread* pOfficeAcceptThread = 0; ResMgr* Desktop::pResMgr = 0; +static PluginAcceptThread* pPluginAcceptThread = 0; // ---------------------------------------------------------------------------- @@ -298,10 +314,173 @@ BOOL Desktop::QueryExit() USHORT Desktop::Exception(USHORT nError) { - // first test implementation!! + // protect against recursive calls + static BOOL bInException = FALSE; + sal_uInt16 nOldMode = Application::GetSystemWindowMode(); Application::SetSystemWindowMode( nOldMode & ~SYSTEMWINDOW_MODE_NOAUTOMODE ); - return Application::Exception( nError ); + Application::SetDefModalDialogParent( NULL ); + + if ( bInException ) + { + String aDoubleExceptionString; + Application::Abort( aDoubleExceptionString ); + } + + bInException = TRUE; + + // save all modified documents + if( Application::IsInExecute() ) + { + // store to backup path + String aSavePath( SvtPathOptions().GetBackupPath() ); + SvtInternalOptions aOpt; + + // iterate tasks + Reference< ::com::sun::star::frame::XTasksSupplier > + xDesktop( ::comphelper::getProcessServiceFactory()->createInstance( OUSTRING(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.Desktop")) ), + UNO_QUERY ); + Reference< ::com::sun::star::frame::XTask > xTask; + Reference< ::com::sun::star::container::XEnumeration > xList = xDesktop->getTasks()->createEnumeration(); + while( xList->hasMoreElements() ) + { + xList->nextElement() >>= xTask; + + // ask for controller + Reference< ::com::sun::star::frame::XController > xCtrl = xTask->getController(); + if ( xCtrl.is() ) + { + // ask for model + Reference< ::com::sun::star::frame::XModel > xModel( xCtrl->getModel(), UNO_QUERY ); + Reference< ::com::sun::star::util::XModifiable > xModifiable( xModel, UNO_QUERY ); + if ( xModifiable.is() && xModifiable->isModified() ) + { + // ask if modified + Reference< ::com::sun::star::frame::XStorable > xStor( xModel, UNO_QUERY ); + if ( xStor.is() ) + { + // get the media descriptor and retrieve filter name and password + ::rtl::OUString aOrigPassword, aOrigFilterName; + Sequence < PropertyValue > aArgs( xModel->getArgs() ); + sal_Int32 nProps = aArgs.getLength(); + for ( sal_Int32 nProp = 0; nProp<nProps; nProp++ ) + { + const PropertyValue& rProp = aArgs[nProp]; + if( rProp.Name == OUString(RTL_CONSTASCII_USTRINGPARAM("FilterName")) ) + rProp.Value >>= aOrigFilterName; + if( rProp.Name == OUString(RTL_CONSTASCII_USTRINGPARAM("Password")) ) + rProp.Value >>= aOrigPassword; + } + + // save document as tempfile in backup directory + // remember old name or title + ::rtl::OUString aOrigURL = xModel->getURL(); + ::rtl::OUString aOldName, aSaveURL; + if ( aOrigURL.getLength() ) + { + ::utl::TempFile aTempFile( &aSavePath ); + aSaveURL = aTempFile.GetURL(); + aOldName = aOrigURL; + } + else + { + // untitled document + String aExt( DEFINE_CONST_UNICODE( ".sav" ) ); + ::utl::TempFile aTempFile( DEFINE_CONST_UNICODE( "exc" ), &aExt, &aSavePath ); + aSaveURL = aTempFile.GetURL(); + // aOldName = Title; + } + + if ( aOrigPassword.getLength() ) + { + // if the document was loaded with a password, it should be stored with password + Sequence < PropertyValue > aSaveArgs(1); + aSaveArgs[0].Name = DEFINE_CONST_UNICODE("Password"); + aSaveArgs[0].Value <<= aOrigPassword; + + xStor->storeToURL( aSaveURL, aSaveArgs ); + } + else + xStor->storeToURL( aSaveURL, Sequence < PropertyValue >() ); + + // remember original name and filter + aOpt.PushRecoveryItem( aOldName, aOrigFilterName, aSaveURL ); + } + } + } + } + + if ( ( nError & EXC_MAJORTYPE ) != EXC_DISPLAY && ( nError & EXC_MAJORTYPE ) != EXC_REMOTE ) + WarningBox( NULL, DesktopResId(STR_RECOVER_PREPARED) ).Execute(); + } + + // store configuration data + ::utl::ConfigManager::GetConfigManager()->StoreConfigItems(); + + // because there is no method to flush the condiguration data, we must dispose the ConfigManager + Reference < XComponent > xComp( ::utl::ConfigManager::GetConfigManager()->GetConfigurationProvider(), UNO_QUERY ); + xComp->dispose(); + + switch( nError & EXC_MAJORTYPE ) + { +/* + case EXC_USER: + if( nError == EXC_OUTOFMEMORY ) + { + // not possible without a special NewHandler! + String aMemExceptionString; + Application::Abort( aMemExceptionString ); + } + break; +*/ + case EXC_RSCNOTLOADED: + { + String aResExceptionString; + Application::Abort( aResExceptionString ); + break; + } + + case EXC_SYSOBJNOTCREATED: + { + String aSysResExceptionString; + Application::Abort( aSysResExceptionString ); + break; + } + + default: + { + if( !pPluginAcceptThread && !Application::IsRemoteServer() ) + { + OfficeIPCThread::DisableOfficeIPCThread(); + if( pSignalHandler ) + DELETEZ( pSignalHandler ); + + ::rtl::OUString aProgName, aTmp; + ::vos::OStartupInfo aInfo; + aInfo.getExecutableFile( aProgName ); + + Reference< XSystemShellExecute > xSystemShellExecute( ::comphelper::getProcessServiceFactory()->createInstance( + ::rtl::OUString::createFromAscii( "com.sun.star.system.SystemShellExecute" )), UNO_QUERY ); + if ( xSystemShellExecute.is() ) + { + ::rtl::OUString aSysPathFileName; + ::osl::FileBase::RC nError = ::osl::FileBase::getSystemPathFromFileURL( aProgName, aSysPathFileName ); + if ( nError == ::osl::FileBase::E_None ) + xSystemShellExecute->execute( aSysPathFileName, ::rtl::OUString(), SystemShellExecuteFlags::DEFAULTS ); + } + } + + exit( 333 ); +// Application::Abort( String() ); + break; + } + } + + return TRUE; + + // ConfigManager is disposed, so no way to continue + // bInException = sal_False; + // return Application::Exception( nError ); } void Desktop::Property( ApplicationProperty& ) @@ -395,7 +574,6 @@ void Desktop::Main() Reference< XConnectionBroker > xServiceManagerBroker; Reference< XConnectionBroker > xPalmPilotManagerBroker; - PluginAcceptThread* pPluginAcceptThread = 0; RemoteControl aControl; @@ -525,12 +703,11 @@ void Desktop::OpenClients() ::com::sun::star::uno::UNO_QUERY ); // create the parameter array - Sequence < PropertyValue > aArgs( 5 ); + Sequence < PropertyValue > aArgs( 4 ); aArgs[0].Name = ::rtl::OUString::createFromAscii("Referer"); aArgs[1].Name = ::rtl::OUString::createFromAscii("AsTemplate"); aArgs[2].Name = ::rtl::OUString::createFromAscii("FilterName"); - aArgs[3].Name = ::rtl::OUString::createFromAscii("RealURL"); - aArgs[4].Name = ::rtl::OUString::createFromAscii("SalvagedFile"); + aArgs[3].Name = ::rtl::OUString::createFromAscii("SalvagedFile"); // mark it as a user request aArgs[0].Value <<= ::rtl::OUString::createFromAscii("private:user"); @@ -560,14 +737,12 @@ void Desktop::OpenClients() // get the original URL for the recovered document aArgs[1].Value <<= sal_False; aArgs[3].Value <<= ::rtl::OUString( sRealFileName ); - aArgs[4].Value <<= ::rtl::OUString( sRealFileName ); } else { // this was an untitled document ( open as template ) aArgs[1].Value <<= sal_True; aArgs[3].Value <<= ::rtl::OUString(); - aArgs[4].Value <<= ::rtl::OUString(); } // load the document diff --git a/desktop/source/app/desktop.hrc b/desktop/source/app/desktop.hrc index b28959703b61..3689961fc48a 100644 --- a/desktop/source/app/desktop.hrc +++ b/desktop/source/app/desktop.hrc @@ -2,9 +2,9 @@ * * $RCSfile: desktop.hrc,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: cd $ $Date: 2001-07-16 12:52:33 $ + * last change: $Author: mba $ $Date: 2001-07-17 08:34:12 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -71,5 +71,6 @@ #define STR_RECOVER_QUERY (RID_DESKTOP_STRING_START+0) #define STR_RECOVER_TITLE (RID_DESKTOP_STRING_START+1) +#define STR_RECOVER_PREPARED (RID_DESKTOP_STRING_START+2) #endif // _DESKTOP_HRC_ diff --git a/desktop/source/app/desktop.src b/desktop/source/app/desktop.src index 0b67922f92b0..71d200932ac5 100644 --- a/desktop/source/app/desktop.src +++ b/desktop/source/app/desktop.src @@ -2,9 +2,9 @@ * * $RCSfile: desktop.src,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: cd $ $Date: 2001-07-16 12:52:33 $ + * last change: $Author: mba $ $Date: 2001-07-17 08:34:12 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -118,3 +118,33 @@ String STR_RECOVER_TITLE Text[ catalan ] = "Recuperar archivo"; Text[ finnish ] = "Tiedoston palautus"; }; + +WarningBox STR_RECOVER_PREPARED +{ + Message = "Es ist ein nicht behebbarer Fehler aufgetreten.\n\nAlle modifizierten Dateien wurden jedoch\ngesichert und knnen voraussichtlich beim nchsten\nProgrammstart wiederhergestellt werden." ; + Message [ ENGLISH ] = "An unrecoverable error has occured.\n\nAll modified files are saved and can\nprobably be recovered on application restart." ; + Message [ portuguese ] = "Surgiu um erro irrecupervel. Contudo, todos os ficheiros \nmodificados foram guardados e podero provavelmente \nser recuperados ao reiniciar o programa." ; + Message [ english_us ] = "An unrecoverable error has occurred.\n\nAll modified files have been saved and can\nprobably be recovered at program restart." ; + Message [ portuguese_brazilian ] = "Es ist ein nicht behebbarer Fehler aufgetreten.\n\nAlle modifizierten Dateien wurden jedoch\ngesichert und k?nen voraussichtlich beim n?chsten\nProgrammstart wiederhergestellt werden." ; + Message [ swedish ] = "Ett irreparabelt fel har uppsttt.\n\nMen alla ndrade filer sparades\noch kan frmodligen terstllas\nvid nsta programstart." ; + Message [ danish ] = "Der opstod en irreparabel fejl.\n\nAlle ndrede filer er dog\nblevet gemt og kan sandsynligvis gendannes\nved nste programstart." ; + Message [ italian ] = "Si verificato un errore irrimediabile.\n\nTutti i file modificati sono stati \nsalvati e probabilmente verranno recuperati \nal prossimo avvio del programma." ; + Message [ spanish ] = "Ha ocurrido un error irreparable.\n\nSin embargo se guardaron todos los cambios realizados\nen los archivos y quizs podrn recuperarse\nal iniciar de nuevo el programa." ; + Message [ french ] = "Une erreur irrcuprable s'est produite.\n\nTous les fichiers dits ont t sauvegards\net devraient tre restaurs au\nredmarrage du programme." ; + Message [ dutch ] = "Er is een niet-corrigeerbare fout opgetreden.\n\nAlle gemodificeerde bestanden werden echter\nopgeslagen en kunnen waarschijnlijk bij de volgende\nprogrammastart opnieuw gemaakt worden." ; + Message[ chinese_simplified ] = "ǷdzǸIJһųĴ\nղĹļѾ档\nһʱܿ»ָЩļ"; + Message[ russian ] = " .\n\n \n \n ."; + Message[ polish ] = "Wystpi nieodwracalny bd.\n\nWszystkie zmodyfikowane pliki zostay jednak\nzabezpieczone i zostan prawdopodobnie przywrcone przy nastpnym rozpoczciu programu.\n."; + Message[ japanese ] = "łȂװ܂B\n\nύXׂĂ̧ق͕ۑĂ܂̂\n۸ъJnɕ錩݂łB"; + Message[ chinese_traditional ] = "uOD`pMzʧ@oF@ӵLkư~C\neקLɮפwgxsC\nbU@Ұʵ{ɫܥi୫s_oɮסC"; + Message[ arabic ] = " .\n\n ǡ \n \n ."; + Message[ dutch ] = "Er is een niet-corrigeerbare fout opgetreden.\n\nAlle gemodificeerde bestanden werden echter\nopgeslagen en kunnen waarschijnlijk bij de volgende\nprogrammastart opnieuw gemaakt worden."; + Message[ chinese_simplified ] = "ǷdzǸIJһųĴ\nղĹļѾ档\nһʱܿ»ָЩļ"; + Message[ greek ] = " .\n\n \n () \n "; + Message[ korean ] = " ߽ϴ.\n\n \nǾǷ, \nα ۽ÿ Դϴ."; + Message[ turkish ] = "Dzeltilemeyen bir hata olutu.\n\nDeitirilen tm dosyalar\nkaydedildi ve muhtemelen uygulama yeniden balatldnda\nkurtarlabilecek."; + Message[ language_user1 ] = " "; + Message[ catalan ] = "Ha ocurrido un error irreparable.\n\nSin embargo se guardaron todos los cambios realizados\nen los archivos y quizs podrn recuperarse\nal iniciar de nuevo el programa."; + Message[ finnish ] = "On ilmennyt peruuttamaton virhe.\n\nKaikki muokatut tiedostot on tallennettu\nja ne voidaan ehk palauttaa, kun kynnistt ohjelman uudelleen."; +}; + |