summaryrefslogtreecommitdiff
path: root/framework/source/services/autorecovery.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'framework/source/services/autorecovery.cxx')
-rw-r--r--framework/source/services/autorecovery.cxx147
1 files changed, 93 insertions, 54 deletions
diff --git a/framework/source/services/autorecovery.cxx b/framework/source/services/autorecovery.cxx
index 9328ed9d9a5c..9b19503f887e 100644
--- a/framework/source/services/autorecovery.cxx
+++ b/framework/source/services/autorecovery.cxx
@@ -80,7 +80,7 @@
#include <comphelper/configurationhelper.hxx>
#include <comphelper/mediadescriptor.hxx>
#include <vcl/svapp.hxx>
-#include <svtools/pathoptions.hxx>
+#include <unotools/pathoptions.hxx>
#include <tools/link.hxx>
#include <tools/string.hxx>
#include <unotools/tempfile.hxx>
@@ -91,7 +91,7 @@
#include <osl/file.hxx>
#include <unotools/bootstrap.hxx>
#include <unotools/configmgr.hxx>
-#include <svtools/documentlockfile.hxx>
+#include <svl/documentlockfile.hxx>
#include <tools/urlobj.hxx>
@@ -170,6 +170,7 @@ static const ::rtl::OUString CMD_DO_RECOVERY = ::rtl::OUString::
static const ::rtl::OUString CMD_DO_ENTRY_BACKUP = ::rtl::OUString::createFromAscii("/doEntryBackup" ); // try to store a temp or original file to a user defined location
static const ::rtl::OUString CMD_DO_ENTRY_CLEANUP = ::rtl::OUString::createFromAscii("/doEntryCleanUp" ); // remove the specified entry from the recovery cache
static const ::rtl::OUString CMD_DO_SESSION_SAVE = ::rtl::OUString::createFromAscii("/doSessionSave" ); // save all open documents if e.g. a window manager closes an user session
+static const ::rtl::OUString CMD_DO_SESSION_QUIET_QUIT = ::rtl::OUString::createFromAscii("/doSessionQuietQuit" ); // let the current session be quietly closed ( the saving should be done using doSessionSave previously ) if e.g. a window manager closes an user session
static const ::rtl::OUString CMD_DO_SESSION_RESTORE = ::rtl::OUString::createFromAscii("/doSessionRestore" ); // restore a saved user session from disc
static const ::rtl::OUString CMD_DO_DISABLE_RECOVERY = ::rtl::OUString::createFromAscii("/disableRecovery" ); // disable recovery and auto save (!) temp. for this office session
static const ::rtl::OUString CMD_DO_SET_AUTOSAVE_STATE = ::rtl::OUString::createFromAscii("/setAutoSaveState" ); // disable/enable auto save (not crash save) for this office session
@@ -725,6 +726,16 @@ void AutoRecovery::implts_dispatch(const DispatchParams& aParams)
}
else
if (
+ ((eJob & AutoRecovery::E_SESSION_QUIET_QUIT ) == AutoRecovery::E_SESSION_QUIET_QUIT ) &&
+ ((eJob & AutoRecovery::E_DISABLE_AUTORECOVERY) != AutoRecovery::E_DISABLE_AUTORECOVERY)
+ )
+ {
+ LOG_RECOVERY("... do session quiet quit ...")
+ bAllowAutoSaveReactivation = sal_False;
+ implts_doSessionQuietQuit(aParams);
+ }
+ else
+ if (
((eJob & AutoRecovery::E_SESSION_RESTORE ) == AutoRecovery::E_SESSION_RESTORE ) &&
((eJob & AutoRecovery::E_DISABLE_AUTORECOVERY) != AutoRecovery::E_DISABLE_AUTORECOVERY)
)
@@ -1987,6 +1998,30 @@ void AutoRecovery::implts_changeAllDocVisibility(sal_Bool bVisible)
}
//-----------------------------------------------
+/* Currently the document is not closed in case of crash,
+ so the lock file must be removed explicitly
+*/
+void lc_removeLockFile(AutoRecovery::TDocumentInfo& rInfo)
+{
+ if ( rInfo.Document.is() )
+ {
+ try
+ {
+ css::uno::Reference< css::frame::XStorable > xStore(rInfo.Document, css::uno::UNO_QUERY_THROW);
+ ::rtl::OUString aURL = xStore->getLocation();
+ if ( aURL.getLength() )
+ {
+ ::svt::DocumentLockFile aLockFile( aURL );
+ aLockFile.RemoveFile();
+ }
+ }
+ catch( const css::uno::Exception& )
+ {}
+ }
+}
+
+
+//-----------------------------------------------
void AutoRecovery::implts_prepareSessionShutdown()
{
LOG_RECOVERY("AutoRecovery::implts_prepareSessionShutdown() starts ...")
@@ -2004,6 +2039,10 @@ void AutoRecovery::implts_prepareSessionShutdown()
{
AutoRecovery::TDocumentInfo& rInfo = *pIt;
+ // WORKAROUND... Since the documents are not closed the lock file must be removed explicitly
+ // it is not done on documents saving since shutdown can be cancelled
+ lc_removeLockFile( rInfo );
+
// Prevent us from deregistration of these documents.
// Because we close these documents by ourself (see XClosable below) ...
// it's fact, that we reach our deregistration method. There we
@@ -2014,31 +2053,38 @@ void AutoRecovery::implts_prepareSessionShutdown()
// reset modified flag of these documents (ignoring the notification about it!)
// Otherwise a message box is shown on closing these models.
implts_stopModifyListeningOnDoc(rInfo);
- css::uno::Reference< css::util::XModifiable > xModify(rInfo.Document, css::uno::UNO_QUERY);
- if (xModify.is())
- xModify->setModified(sal_False);
- // close the model.
- css::uno::Reference< css::util::XCloseable > xClose(rInfo.Document, css::uno::UNO_QUERY);
- if (xClose.is())
+ // if the session save is still running the documents should not be thrown away,
+ // actually that would be a bad sign, that means that the SessionManager tryes
+ // to kill the session before the saving is ready
+ if ((m_eJob & AutoRecovery::E_SESSION_SAVE) != AutoRecovery::E_SESSION_SAVE)
{
- try
+ css::uno::Reference< css::util::XModifiable > xModify(rInfo.Document, css::uno::UNO_QUERY);
+ if (xModify.is())
+ xModify->setModified(sal_False);
+
+ // close the model.
+ css::uno::Reference< css::util::XCloseable > xClose(rInfo.Document, css::uno::UNO_QUERY);
+ if (xClose.is())
{
- xClose->close(sal_False);
- }
- /*
- catch(const css::lang::DisposedException&)
- {
- // closed ... disposed ... always the same .-)
- }
- */
- catch(const css::uno::Exception&)
+ try
{
- // At least it's only a try to close these documents before anybody else it does.
- // So it seams to be possible to ignore any error here .-)
+ xClose->close(sal_False);
}
+ /*
+ catch(const css::lang::DisposedException&)
+ {
+ // closed ... disposed ... always the same .-)
+ }
+ */
+ catch(const css::uno::Exception&)
+ {
+ // At least it's only a try to close these documents before anybody else it does.
+ // So it seams to be possible to ignore any error here .-)
+ }
- rInfo.Document.clear();
+ rInfo.Document.clear();
+ }
}
}
@@ -2047,30 +2093,6 @@ void AutoRecovery::implts_prepareSessionShutdown()
}
//-----------------------------------------------
-/* Currently the document is not closed in case of crash,
- so the lock file must be removed explicitly
-*/
-void lc_removeLockFile(AutoRecovery::TDocumentInfo& rInfo)
-{
- if ( rInfo.Document.is() )
- {
- try
- {
- css::uno::Reference< css::frame::XStorable > xStore(rInfo.Document, css::uno::UNO_QUERY_THROW);
- ::rtl::OUString aURL = xStore->getLocation();
- if ( aURL.getLength() )
- {
- ::svt::DocumentLockFile aLockFile( aURL );
- aLockFile.RemoveFile();
- }
- }
- catch( const css::uno::Exception& )
- {}
- }
-}
-
-
-//-----------------------------------------------
/* TODO WORKAROUND:
#i64599#
@@ -2750,6 +2772,9 @@ void AutoRecovery::implts_informListener( sal_Int32 eJ
if ((eJob & AutoRecovery::E_SESSION_SAVE) == AutoRecovery::E_SESSION_SAVE)
sFeature.append(CMD_DO_SESSION_SAVE);
else
+ if ((eJob & AutoRecovery::E_SESSION_QUIET_QUIT) == AutoRecovery::E_SESSION_QUIET_QUIT)
+ sFeature.append(CMD_DO_SESSION_QUIET_QUIT);
+ else
if ((eJob & AutoRecovery::E_SESSION_RESTORE) == AutoRecovery::E_SESSION_RESTORE)
sFeature.append(CMD_DO_SESSION_RESTORE);
else
@@ -2792,6 +2817,9 @@ sal_Int32 AutoRecovery::implst_classifyJob(const css::util::URL& aURL)
if (aURL.Path.equals(CMD_DO_SESSION_SAVE))
return AutoRecovery::E_SESSION_SAVE;
else
+ if (aURL.Path.equals(CMD_DO_SESSION_QUIET_QUIT))
+ return AutoRecovery::E_SESSION_QUIET_QUIT;
+ else
if (aURL.Path.equals(CMD_DO_SESSION_RESTORE))
return AutoRecovery::E_SESSION_RESTORE;
else
@@ -2968,14 +2996,6 @@ void AutoRecovery::implts_doSessionSave(const DispatchParams& aParams)
{
LOG_RECOVERY("AutoRecovery::implts_doSessionSave()")
- // try to make sure next time office will be started user wont be
- // notified about any other might be running office instance
- // remove ".lock" file from disc !
- // it is done as a first action for session save since Gnome sessions
- // do not provide enough time for shutdown, and the dialog looks to be
- // confusing for the user
- AutoRecovery::st_impl_removeLockFile();
-
// Be sure to know all open documents realy .-)
implts_verifyCacheAgainstDesktopDocumentList();
@@ -2991,7 +3011,8 @@ void AutoRecovery::implts_doSessionSave(const DispatchParams& aParams)
AutoRecovery::ETimerType eSuggestedTimer = AutoRecovery::E_DONT_START_TIMER;
do
{
- eSuggestedTimer = implts_saveDocs(bAllowUserIdleLoop, sal_True, &aParams);
+ // do not remove lock files of the documents, it will be done on session quit
+ eSuggestedTimer = implts_saveDocs(bAllowUserIdleLoop, sal_False, &aParams);
}
while(eSuggestedTimer == AutoRecovery::E_CALL_ME_BACK);
@@ -3002,6 +3023,23 @@ void AutoRecovery::implts_doSessionSave(const DispatchParams& aParams)
// any "handle" state ...
implts_resetHandleStates(sal_False);
+ // flush config cached back to disc.
+ impl_flushALLConfigChanges();
+}
+
+//-----------------------------------------------
+void AutoRecovery::implts_doSessionQuietQuit(const DispatchParams& /*aParams*/)
+{
+ LOG_RECOVERY("AutoRecovery::implts_doSessionQuietQuit()")
+
+ // try to make sure next time office will be started user wont be
+ // notified about any other might be running office instance
+ // remove ".lock" file from disc !
+ // it is done as a first action for session save since Gnome sessions
+ // do not provide enough time for shutdown, and the dialog looks to be
+ // confusing for the user
+ AutoRecovery::st_impl_removeLockFile();
+
// reset all modified documents, so the dont show any UI on closing ...
// and close all documents, so we can shutdown the OS!
implts_prepareSessionShutdown();
@@ -3020,6 +3058,7 @@ void AutoRecovery::implts_doSessionSave(const DispatchParams& aParams)
impl_flushALLConfigChanges();
}
+
//-----------------------------------------------
void AutoRecovery::implts_doSessionRestore(const DispatchParams& aParams)
{