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

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.

f8e1d243 "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
üst 9e8957de
...@@ -191,6 +191,8 @@ class Desktop : public Application ...@@ -191,6 +191,8 @@ class Desktop : public Application
/// does initializations which are necessary for the first run of the office /// does initializations which are necessary for the first run of the office
void DoFirstRunInitializations(); void DoFirstRunInitializations();
static void ShowBackingComponent(Desktop * progress);
static sal_Bool SaveTasks(); static sal_Bool SaveTasks();
static void retrieveCrashReporterState(); static void retrieveCrashReporterState();
......
...@@ -1203,24 +1203,19 @@ sal_Bool impl_callRecoveryUI(sal_Bool bEmergencySave , ...@@ -1203,24 +1203,19 @@ sal_Bool impl_callRecoveryUI(sal_Bool bEmergencySave ,
css::util::URL aURL; css::util::URL aURL;
if (bEmergencySave) if (bEmergencySave)
aURL.Complete = COMMAND_EMERGENCYSAVE; aURL.Complete = COMMAND_EMERGENCYSAVE;
else if (bExistsRecoveryData)
aURL.Complete = COMMAND_RECOVERY;
else if (bCrashed && Desktop::isCrashReporterEnabled() )
aURL.Complete = COMMAND_CRASHREPORT;
else else
{ return false;
if (bExistsRecoveryData)
aURL.Complete = COMMAND_RECOVERY;
else
if (bCrashed && Desktop::isCrashReporterEnabled() )
aURL.Complete = COMMAND_CRASHREPORT;
}
sal_Bool bRet = sal_False; xURLParser->parseStrict(aURL);
if ( !aURL.Complete.isEmpty() )
{
xURLParser->parseStrict(aURL);
css::uno::Any aRet = xRecoveryUI->dispatchWithReturnValue(aURL, css::uno::Sequence< css::beans::PropertyValue >()); css::uno::Any aRet = xRecoveryUI->dispatchWithReturnValue(aURL, css::uno::Sequence< css::beans::PropertyValue >());
aRet >>= bRet; sal_Bool bRet = sal_False;
} aRet >>= bRet;
return bRet; return !bEmergencySave || bRet;
} }
/* /*
...@@ -1674,40 +1669,8 @@ int Desktop::Main() ...@@ -1674,40 +1669,8 @@ int Desktop::Main()
(!Application::AnyInput( VCL_INPUT_APPEVENT ) )) (!Application::AnyInput( VCL_INPUT_APPEVENT ) ))
{ {
RTL_LOGFILE_CONTEXT_TRACE( aLog, "{ create BackingComponent" ); RTL_LOGFILE_CONTEXT_TRACE( aLog, "{ create BackingComponent" );
Reference< XFrame > xDesktopFrame( xDesktop, UNO_QUERY ); ShowBackingComponent(this);
if (xDesktopFrame.is()) RTL_LOGFILE_CONTEXT_TRACE( aLog, "} create BackingComponent" );
{
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" );
} }
} }
} }
...@@ -2355,7 +2318,7 @@ void Desktop::OpenClients() ...@@ -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 // 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 // should be created
Reference < XComponent > xFirst; Reference < XComponent > xFirst;
sal_Bool bLoaded = sal_False; bool bRecovery = false;
const CommandLineArgs& rArgs = GetCommandLineArgs(); const CommandLineArgs& rArgs = GetCommandLineArgs();
SvtInternalOptions aInternalOptions; SvtInternalOptions aInternalOptions;
...@@ -2482,7 +2445,6 @@ void Desktop::OpenClients() ...@@ -2482,7 +2445,6 @@ void Desktop::OpenClients()
impl_checkRecoveryState(bCrashed, bExistsRecoveryData, bExistsSessionData); impl_checkRecoveryState(bCrashed, bExistsRecoveryData, bExistsSessionData);
if ( !getenv ("OOO_DISABLE_RECOVERY") && if ( !getenv ("OOO_DISABLE_RECOVERY") &&
( ! bLoaded ) &&
( (
( bExistsRecoveryData ) || // => crash with files => recovery ( bExistsRecoveryData ) || // => crash with files => recovery
( bCrashed ) // => crash without files => error report ( bCrashed ) // => crash without files => error report
...@@ -2491,22 +2453,10 @@ void Desktop::OpenClients() ...@@ -2491,22 +2453,10 @@ void Desktop::OpenClients()
{ {
try try
{ {
impl_callRecoveryUI( bRecovery = impl_callRecoveryUI(
sal_False , // false => force recovery instead of emergency save sal_False , // false => force recovery instead of emergency save
bCrashed , bCrashed ,
bExistsRecoveryData); 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) catch(const css::uno::Exception& e)
{ {
...@@ -2538,16 +2488,13 @@ void Desktop::OpenClients() ...@@ -2538,16 +2488,13 @@ void Desktop::OpenClients()
OSL_FAIL(OUStringToOString(aMessage, RTL_TEXTENCODING_ASCII_US).getStr()); OSL_FAIL(OUStringToOString(aMessage, RTL_TEXTENCODING_ASCII_US).getStr());
} }
if ( if ( bExistsSessionData )
( ! bLoaded ) &&
( bExistsSessionData )
)
{ {
// session management // session management
try try
{ {
Reference< XSessionManagerListener > r(xSessionListener, UNO_QUERY_THROW); Reference< XSessionManagerListener > r(xSessionListener, UNO_QUERY_THROW);
bLoaded = r->doRestore(); r->doRestore();
} }
catch(const com::sun::star::uno::Exception& e) catch(const com::sun::star::uno::Exception& e)
{ {
...@@ -2585,8 +2532,6 @@ void Desktop::OpenClients() ...@@ -2585,8 +2532,6 @@ void Desktop::OpenClients()
( !aRequest.aPrintToList.empty() && !aRequest.aPrinterName.isEmpty() ) || ( !aRequest.aPrintToList.empty() && !aRequest.aPrinterName.isEmpty() ) ||
!aRequest.aConversionList.empty() ) !aRequest.aConversionList.empty() )
{ {
bLoaded = sal_True;
if ( rArgs.HasModuleParam() ) if ( rArgs.HasModuleParam() )
{ {
SvtModuleOptions aOpt; SvtModuleOptions aOpt;
...@@ -2635,6 +2580,12 @@ void Desktop::OpenClients() ...@@ -2635,6 +2580,12 @@ void Desktop::OpenClients()
if ( rArgs.IsQuickstart() || rArgs.IsInvisible() || Application::AnyInput( VCL_INPUT_APPEVENT ) ) if ( rArgs.IsQuickstart() || rArgs.IsInvisible() || Application::AnyInput( VCL_INPUT_APPEVENT ) )
// soffice was started as tray icon ... // soffice was started as tray icon ...
return; return;
if ( bRecovery )
{
ShowBackingComponent(0);
}
else
{ {
OpenDefault(); OpenDefault();
} }
...@@ -3014,6 +2965,58 @@ void Desktop::DoFirstRunInitializations() ...@@ -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( ) void Desktop::CheckFirstRun( )
{ {
......
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