summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2012-06-07 10:50:18 +0200
committerStephan Bergmann <sbergman@redhat.com>2012-06-07 11:05:21 +0200
commitb5ad981518f4407243f89507b2561dd0b1ef28ee (patch)
tree6cd43135bc6d0044f63b2177e2b5451fc289209c
parent9e8957de203bb9abb208516ad32aee9527feb67b (diff)
bnc#524250: Show backing component after cancelled recovery
...instead of an empty Writer document, which is non-intuitive when the user had worked on something other than a Writer document before the crash. f8e1d2438199c4a76ceeb36352678c415e25272c "win32-dont-attempt-restart.diff: Don't attempt to restart OOo after crash" had previously attempted to fix this with a sledgehammer approach of not restarting at all after a crash on Windows, under the wrong assumption that there would be no restart after crash at all on Linux either (which was apparently rather a bug caused by the newly introduced oosplash at that time). Change-Id: If65d2e21640d56262c486d887c4a29137cabcd0a
-rw-r--r--desktop/inc/app.hxx2
-rw-r--r--desktop/source/app/app.cxx145
2 files changed, 76 insertions, 71 deletions
diff --git a/desktop/inc/app.hxx b/desktop/inc/app.hxx
index 0dfa7ca82ed2..ea107e801ff2 100644
--- a/desktop/inc/app.hxx
+++ b/desktop/inc/app.hxx
@@ -191,6 +191,8 @@ class Desktop : public Application
/// does initializations which are necessary for the first run of the office
void DoFirstRunInitializations();
+ static void ShowBackingComponent(Desktop * progress);
+
static sal_Bool SaveTasks();
static void retrieveCrashReporterState();
diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx
index 7374ea322f2e..7ddec0ee3ec5 100644
--- a/desktop/source/app/app.cxx
+++ b/desktop/source/app/app.cxx
@@ -1203,24 +1203,19 @@ sal_Bool impl_callRecoveryUI(sal_Bool bEmergencySave ,
css::util::URL aURL;
if (bEmergencySave)
aURL.Complete = COMMAND_EMERGENCYSAVE;
+ else if (bExistsRecoveryData)
+ aURL.Complete = COMMAND_RECOVERY;
+ else if (bCrashed && Desktop::isCrashReporterEnabled() )
+ aURL.Complete = COMMAND_CRASHREPORT;
else
- {
- if (bExistsRecoveryData)
- aURL.Complete = COMMAND_RECOVERY;
- else
- if (bCrashed && Desktop::isCrashReporterEnabled() )
- aURL.Complete = COMMAND_CRASHREPORT;
- }
+ return false;
- sal_Bool bRet = sal_False;
- if ( !aURL.Complete.isEmpty() )
- {
- xURLParser->parseStrict(aURL);
+ xURLParser->parseStrict(aURL);
- css::uno::Any aRet = xRecoveryUI->dispatchWithReturnValue(aURL, css::uno::Sequence< css::beans::PropertyValue >());
- aRet >>= bRet;
- }
- return bRet;
+ css::uno::Any aRet = xRecoveryUI->dispatchWithReturnValue(aURL, css::uno::Sequence< css::beans::PropertyValue >());
+ sal_Bool bRet = sal_False;
+ aRet >>= bRet;
+ return !bEmergencySave || bRet;
}
/*
@@ -1674,40 +1669,8 @@ int Desktop::Main()
(!Application::AnyInput( VCL_INPUT_APPEVENT ) ))
{
RTL_LOGFILE_CONTEXT_TRACE( aLog, "{ create BackingComponent" );
- Reference< XFrame > xDesktopFrame( xDesktop, UNO_QUERY );
- if (xDesktopFrame.is())
- {
- SetSplashScreenProgress(60);
- Reference< XFrame > xBackingFrame;
- Reference< ::com::sun::star::awt::XWindow > xContainerWindow;
-
- xBackingFrame = xDesktopFrame->findFrame(OUString( "_blank" ), 0);
- if (xBackingFrame.is())
- xContainerWindow = xBackingFrame->getContainerWindow();
- if (xContainerWindow.is())
- {
- SetDocumentExtendedStyle(xContainerWindow);
- SetSplashScreenProgress(75);
- Sequence< Any > lArgs(1);
- lArgs[0] <<= xContainerWindow;
-
- Reference< XController > xBackingComp(
- xSMgr->createInstanceWithArguments(OUString( "com.sun.star.frame.StartModule" ), lArgs), UNO_QUERY);
- if (xBackingComp.is())
- {
- Reference< ::com::sun::star::awt::XWindow > xBackingWin(xBackingComp, UNO_QUERY);
- // Attention: You MUST(!) call setComponent() before you call attachFrame().
- // Because the backing component set the property "IsBackingMode" of the frame
- // to true inside attachFrame(). But setComponent() reset this state everytimes ...
- xBackingFrame->setComponent(xBackingWin, xBackingComp);
- SetSplashScreenProgress(100);
- xBackingComp->attachFrame(xBackingFrame);
- CloseSplashScreen();
- xContainerWindow->setVisible(sal_True);
- }
- }
- }
- RTL_LOGFILE_CONTEXT_TRACE( aLog, "} create BackingComponent" );
+ ShowBackingComponent(this);
+ RTL_LOGFILE_CONTEXT_TRACE( aLog, "} create BackingComponent" );
}
}
}
@@ -2355,7 +2318,7 @@ void Desktop::OpenClients()
// check if a document has been recovered - if there is one of if a document was loaded by cmdline, no default document
// should be created
Reference < XComponent > xFirst;
- sal_Bool bLoaded = sal_False;
+ bool bRecovery = false;
const CommandLineArgs& rArgs = GetCommandLineArgs();
SvtInternalOptions aInternalOptions;
@@ -2482,7 +2445,6 @@ void Desktop::OpenClients()
impl_checkRecoveryState(bCrashed, bExistsRecoveryData, bExistsSessionData);
if ( !getenv ("OOO_DISABLE_RECOVERY") &&
- ( ! bLoaded ) &&
(
( bExistsRecoveryData ) || // => crash with files => recovery
( bCrashed ) // => crash without files => error report
@@ -2491,22 +2453,10 @@ void Desktop::OpenClients()
{
try
{
- impl_callRecoveryUI(
+ bRecovery = impl_callRecoveryUI(
sal_False , // false => force recovery instead of emergency save
bCrashed ,
bExistsRecoveryData);
- /* TODO we cant be shure, that at least one document could be recovered here successfully
- So we set bLoaded=sal_True to supress opening of the default document.
- But we should make it more safe. Otherwhise we have an office without an UI ...
- ...
- May be we can check the desktop if some documents are existing there.
- */
- Reference< XFramesSupplier > xTasksSupplier(
- ::comphelper::getProcessServiceFactory()->createInstance( OUString("com.sun.star.frame.Desktop") ),
- ::com::sun::star::uno::UNO_QUERY_THROW );
- Reference< XElementAccess > xList( xTasksSupplier->getFrames(), UNO_QUERY_THROW );
- if ( xList->hasElements() )
- bLoaded = sal_True;
}
catch(const css::uno::Exception& e)
{
@@ -2538,16 +2488,13 @@ void Desktop::OpenClients()
OSL_FAIL(OUStringToOString(aMessage, RTL_TEXTENCODING_ASCII_US).getStr());
}
- if (
- ( ! bLoaded ) &&
- ( bExistsSessionData )
- )
+ if ( bExistsSessionData )
{
// session management
try
{
Reference< XSessionManagerListener > r(xSessionListener, UNO_QUERY_THROW);
- bLoaded = r->doRestore();
+ r->doRestore();
}
catch(const com::sun::star::uno::Exception& e)
{
@@ -2585,8 +2532,6 @@ void Desktop::OpenClients()
( !aRequest.aPrintToList.empty() && !aRequest.aPrinterName.isEmpty() ) ||
!aRequest.aConversionList.empty() )
{
- bLoaded = sal_True;
-
if ( rArgs.HasModuleParam() )
{
SvtModuleOptions aOpt;
@@ -2635,6 +2580,12 @@ void Desktop::OpenClients()
if ( rArgs.IsQuickstart() || rArgs.IsInvisible() || Application::AnyInput( VCL_INPUT_APPEVENT ) )
// soffice was started as tray icon ...
return;
+
+ if ( bRecovery )
+ {
+ ShowBackingComponent(0);
+ }
+ else
{
OpenDefault();
}
@@ -3014,6 +2965,58 @@ void Desktop::DoFirstRunInitializations()
}
}
+void Desktop::ShowBackingComponent(Desktop * progress)
+{
+ Reference< XMultiServiceFactory > xSMgr(
+ comphelper::getProcessServiceFactory(), UNO_SET_THROW);
+ Reference< XFrame > xDesktopFrame(
+ xSMgr->createInstance("com.sun.star.frame.Desktop"), UNO_QUERY);
+ if (xDesktopFrame.is())
+ {
+ if (progress != 0)
+ {
+ progress->SetSplashScreenProgress(60);
+ }
+ Reference< XFrame > xBackingFrame;
+ Reference< ::com::sun::star::awt::XWindow > xContainerWindow;
+
+ xBackingFrame = xDesktopFrame->findFrame(OUString( "_blank" ), 0);
+ if (xBackingFrame.is())
+ xContainerWindow = xBackingFrame->getContainerWindow();
+ if (xContainerWindow.is())
+ {
+ SetDocumentExtendedStyle(xContainerWindow);
+ if (progress != 0)
+ {
+ progress->SetSplashScreenProgress(75);
+ }
+ Sequence< Any > lArgs(1);
+ lArgs[0] <<= xContainerWindow;
+
+ Reference< XController > xBackingComp(
+ xSMgr->createInstanceWithArguments(OUString( "com.sun.star.frame.StartModule" ), lArgs), UNO_QUERY);
+ if (xBackingComp.is())
+ {
+ Reference< ::com::sun::star::awt::XWindow > xBackingWin(xBackingComp, UNO_QUERY);
+ // Attention: You MUST(!) call setComponent() before you call attachFrame().
+ // Because the backing component set the property "IsBackingMode" of the frame
+ // to true inside attachFrame(). But setComponent() reset this state everytimes ...
+ xBackingFrame->setComponent(xBackingWin, xBackingComp);
+ if (progress != 0)
+ {
+ progress->SetSplashScreenProgress(100);
+ }
+ xBackingComp->attachFrame(xBackingFrame);
+ if (progress != 0)
+ {
+ progress->CloseSplashScreen();
+ }
+ xContainerWindow->setVisible(sal_True);
+ }
+ }
+ }
+}
+
// ========================================================================
void Desktop::CheckFirstRun( )
{