1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: autorecovery.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef __FRAMEWORK_SERVICES_AUTORECOVERY_HXX_
32 #define __FRAMEWORK_SERVICES_AUTORECOVERY_HXX_
34 //_______________________________________________
37 #include <threadhelp/threadhelpbase.hxx>
38 #include <macros/xinterface.hxx>
39 #include <macros/xtypeprovider.hxx>
40 #include <macros/xserviceinfo.hxx>
44 //_______________________________________________
46 #include <com/sun/star/uno/XInterface.hpp>
47 #include <com/sun/star/lang/XTypeProvider.hpp>
48 #include <com/sun/star/lang/XServiceInfo.hpp>
49 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
50 #include <com/sun/star/frame/XDispatch.hpp>
51 #include <com/sun/star/container/XNameAccess.hpp>
52 #include <com/sun/star/document/XEventListener.hpp>
53 #include <com/sun/star/document/XEventBroadcaster.hpp>
54 #include <com/sun/star/frame/XModel.hpp>
55 #include <com/sun/star/util/XChangesListener.hpp>
56 #include <com/sun/star/task/XStatusIndicator.hpp>
57 #include <com/sun/star/util/XModifyListener.hpp>
59 //_______________________________________________
61 #include <comphelper/mediadescriptor.hxx>
62 #include <vcl/timer.hxx>
63 #include <vcl/evntpost.hxx>
64 #include <cppuhelper/interfacecontainer.hxx>
65 #include <cppuhelper/propshlp.hxx>
66 #include <cppuhelper/weak.hxx>
68 //_______________________________________________
72 namespace css
= ::com::sun::star
;
78 //---------------------------------------
79 /** @short hold all needed informations for an asynchronous dispatch alive.
81 @descr Because some operations are forced to be executed asynchronously
82 (e.g. requested by our CreashSave/Recovery dialog) ... we must make sure
83 that these informations wont be set as "normal" members of our AtoRecovery
84 instance. Otherwise they can disturb our normal AutoSave-timer handling.
85 e.g. it can be unclear then, which progress has to be used for storing documents ...
91 DispatchParams(const ::comphelper::SequenceAsHashMap
& lArgs
,
92 const css::uno::Reference
< css::uno::XInterface
>& xOwner
);
93 DispatchParams(const DispatchParams
& rCopy
);
96 DispatchParams
& operator=(const DispatchParams
& rCopy
);
101 //---------------------------------------
102 /** @short can be set from outside and is provided to
103 our internal started operations.
105 @descr Normaly we use the normal status indicator
106 of the document windows to show a progress.
107 But in case we are used by any special UI,
108 it can provide its own status indicator object
109 to us - so we use it instead of the normal one.
111 css::uno::Reference
< css::task::XStatusIndicator
> m_xProgress
;
113 //---------------------------------------
114 /** TODO document me */
115 ::rtl::OUString m_sSavePath
;
117 //---------------------------------------
118 /** @short define the current cache entry, which should be used for current
119 backup or cleanUp operation ... which is may be done asynchronous */
120 sal_Int32 m_nWorkingEntryID
;
122 //---------------------------------------
123 /** @short used for asyncoperations, to prevent us from dying.
125 @descr If our dispatch() method was forced to start the
126 internal operation asynchronous ... we send an event
127 to start and return immediatly. But we must be shure that
128 our instance live if the event callback reach us.
129 So we hold an uno reference to ourself.
131 css::uno::Reference
< css::uno::XInterface
> m_xHoldRefForAsyncOpAlive
;
134 //_______________________________________________
136 implements the functionality of AutoSave and AutoRecovery
137 of documents - including features of an EmergencySave in
140 class AutoRecovery
: public css::lang::XTypeProvider
141 , public css::lang::XServiceInfo
142 , public css::frame::XDispatch
143 , public css::document::XEventListener
// => css.lang.XEventListener
144 , public css::util::XChangesListener
// => css.lang.XEventListener
145 , public css::util::XModifyListener
// => css.lang.XEventListener
146 // attention! Must be the first base class to guarentee right initialize lock ...
147 , private ThreadHelpBase
148 , public ::cppu::OBroadcastHelper
149 , public ::cppu::OPropertySetHelper
// => XPropertySet, XFastPropertySet, XMultiPropertySet
150 , public ::cppu::OWeakObject
152 //___________________________________________
157 /** These values are used as flags and represent the current state of a document.
158 Every state of the life time of a document has to be recognized here.
160 @attention Do not change (means reorganize) already used numbers.
161 There exists some code inside SVX, which uses the same numbers,
162 to analyze such document states.
163 Not the best design ... but may be it will be changed later .-)
169 /// default state, if a document was new created or loaded
171 /// modified against the original file
173 /** We differe between the states: "modified in general" and "modified after last AutoSave".
174 The first state will be interesting in case the crashed document will be restored. Then we have
175 set the right modify state after loading the document. But the second state let us optimize the
176 AutoSave itself. see member ListenForModify too ...
178 E_MODIFIED_SINCE_LAST_AUTOSAVE
= 1024,
179 /// an active document can be postponed to be saved later.
181 /// was already handled during one AutoSave/Recovery session.
183 /** an action was started (saving/loading) ... Can be interesting later if the process may be was interrupted by an exception. */
185 E_TRY_LOAD_BACKUP
= 16,
186 E_TRY_LOAD_ORIGINAL
= 32,
190 /// the Auto/Emergency saved document isnt useable any longer
192 /// the Auto/Emergency saved document isnt realy up-to-date (some changes can be missing)
194 /// the Auto/Emergency saved document was processed successfully
198 /** @short indicates the results of a FAILURE_SAFE operation
200 @descr We must know, which reason was the real one in case
201 we couldnt copy a "failure document" to a user specified path.
202 We must know, if we can forget our cache entry or not.
204 enum EFailureSafeResult
207 E_ORIGINAL_FILE_MISSING
,
214 /** the timer shouldnt be used next time */
216 /** timer (was/must be) started with normal AutoSaveTimeIntervall */
217 E_NORMAL_AUTOSAVE_INTERVALL
,
218 /** timer must be started with special short time intervall,
219 to poll for an user idle period */
220 E_POLL_FOR_USER_IDLE
,
221 /** timer mst be started with a very(!) short time intervall,
222 to poll for the end of an user action, which does not allow saving documents in general */
223 E_POLL_TILL_AUTOSAVE_IS_ALLOWED
,
224 /** dont start the timer - but calls the same action then before immediatly again! */
228 // TODO document me ... flag field
229 // Emergency_Save and Recovery overwrites Auto_Save!
234 E_EMERGENCY_SAVE
= 2,
237 E_ENTRY_CLEANUP
= 16,
238 E_PREPARE_EMERGENCY_SAVE
= 32,
240 E_SESSION_RESTORE
= 128,
241 E_DISABLE_AUTORECOVERY
= 256,
242 E_SET_AUTOSAVE_STATE
= 512
245 //---------------------------------------
246 /** @short combine different informations about one office document. */
251 //-------------------------------
253 : DocumentState (E_UNKNOWN
)
254 , UsedForSaving (sal_False
)
255 , ListenForModify (sal_False
)
256 , IgnoreClosing (sal_False
)
260 //-------------------------------
261 /** @short points to the document. */
262 css::uno::Reference
< css::frame::XModel
> Document
;
264 //-------------------------------
265 /** @short knows, if the document is realy modified since the last autosave,
266 or was postponed, because it was an active one etcpp...
268 @descr Because we have no CHANGE TRACKING mechanism, based on office document,
269 we implements it by ourself. We listen for MODIFIED events
270 of each document and update this state flag here.
272 Further we postpone saving of active documents, e.g. if the user
273 works currently on it. We wait for an idle period then ...
275 sal_Int32 DocumentState
;
277 //-------------------------------
278 /** Because our applications not ready for concurrent save requests at the same time,
279 we have supress our own AutoSave for the moment, a document will be already saved
282 sal_Bool UsedForSaving
;
284 //-------------------------------
285 /** For every user action, which modifies a document (e.g. key input) we get
286 a notification as XModifyListener. That seams to be a "performance issue" .-)
287 So we decided to listen for such modify events only for the time in which the document
288 was stored as temp. file and was not modified again by the user.
290 sal_Bool ListenForModify
;
292 //-------------------------------
293 /** For SessionSave we must close all open documents by ourself.
294 But because we are listen for documents events, we get some ...
295 and deregister these documents from our configuration.
296 That's why we mark these documents as "Closed by ourself" so we can
297 ignore these "OnUnload" or disposing() events .-)
299 sal_Bool IgnoreClosing
;
301 //-------------------------------
302 /** TODO: document me */
303 ::rtl::OUString OrgURL
;
304 ::rtl::OUString FactoryURL
;
305 ::rtl::OUString TemplateURL
;
307 ::rtl::OUString OldTempURL
;
308 ::rtl::OUString NewTempURL
;
310 ::rtl::OUString AppModule
; // e.g. com.sun.star.text.TextDocument - used to identify app module
311 ::rtl::OUString RealFilter
; // real filter, which was used at loading time
312 ::rtl::OUString DefaultFilter
; // supports saving of the default format without loosing data
313 ::rtl::OUString Extension
; // file extension of the default filter
314 ::rtl::OUString Title
; // can be used as "DisplayName" on every recovery UI!
319 //---------------------------------------
320 /** @short used to know every currently open document. */
321 typedef ::std::vector
< TDocumentInfo
> TDocumentList
;
323 //___________________________________________
328 //---------------------------------------
329 /** @short the global uno service manager.
330 @descr Must be used to create own needed services.
332 css::uno::Reference
< css::lang::XMultiServiceFactory
> m_xSMGR
;
334 //---------------------------------------
335 /** @short points to the underlying recovery configuration.
336 @descr This instance does not cache - it calls directly the
339 css::uno::Reference
< css::container::XNameAccess
> m_xRecoveryCFG
;
341 //---------------------------------------
342 /** @short points to the used configuration package or.openoffice.Setup
343 @descr This instance does not cache - it calls directly the
346 css::uno::Reference
< css::container::XNameAccess
> m_xModuleCFG
;
348 //---------------------------------------
349 /** @short holds the global event broadcaster alive,
350 where we listen for new created documents.
352 css::uno::Reference
< css::document::XEventBroadcaster
> m_xNewDocBroadcaster
;
354 //---------------------------------------
355 /** @short because we stop/restart listening sometimes, it's a good idea to know
356 if we already registered as listener .-)
358 sal_Bool m_bListenForDocEvents
;
359 sal_Bool m_bListenForConfigChanges
;
361 //---------------------------------------
362 /** @short specify the time intervall between two save actions.
363 @descr Time is measured in [min].
365 sal_Int32 m_nAutoSaveTimeIntervall
;
367 //---------------------------------------
368 /** @short for an asynchronous operation we must know, if there is
369 at least one running job (may be asynchronous!).
373 //---------------------------------------
374 /** @short the timer, which is used to be informed about the next
379 //---------------------------------------
380 /** @short make our dispatch asynchronous ... if required to do so! */
381 ::vcl::EventPoster m_aAsyncDispatcher
;
383 //---------------------------------------
384 /** @see DispatchParams
386 DispatchParams m_aDispatchParams
;
388 //---------------------------------------
389 /** @short indicates, which time period is currently used by the
392 ETimerType m_eTimerType
;
394 //---------------------------------------
395 /** @short this cache is used to hold all informations about
396 recovery/emergency save documents alive.
398 TDocumentList m_lDocCache
;
400 //---------------------------------------
404 //---------------------------------------
405 /** @short contains all status listener registered at this instance.
407 ListenerHash m_lListener
;
409 /** @descr This member is used to prevent us against re-entrance problems.
410 A mutex cant help to prevent us from concurrent using of members
411 inside the same thread. But e.g. our internaly used stl structures
412 are not threadsafe ... and furthermore they cant be used at the same time
413 for iteration and add/remove requests!
414 So we have to detect such states and ... show a warning.
415 May be there will be a better solution next time ... (copying the cache temp.
418 And further it's not possible to use a simple boolean value here.
419 Because if more then one operation iterates over the same stl container ...
420 (only to modify it's elements but dont add new or removing existing ones!)
421 it should be possible doing so. But we must guarantee that the last operation reset
422 this lock ... not the first one ! So we use a "ref count" mechanism for that."
424 sal_Int32 m_nDocCacheLock
;
426 /** @descr These members are used to check the minimum disc space, which must exists
427 to start the corresponding operation.
429 sal_Int32 m_nMinSpaceDocSave
;
430 sal_Int32 m_nMinSpaceConfigSave
;
432 //---------------------------------------
433 /** @short special debug option to make testing faster.
435 @descr We dont interpret the timer unit as [min] ...
436 we use [ms] instead of that. Further we dont
437 wait 10 s for user idle ...
439 #if OSL_DEBUG_LEVEL > 1
440 sal_Bool m_dbg_bMakeItFaster
;
443 //---------------------------------------
445 css::uno::Reference
< css::task::XStatusIndicator
> m_xExternalProgress
;
447 //___________________________________________
452 AutoRecovery(const css::uno::Reference
< css::lang::XMultiServiceFactory
>& xSMGR
);
453 virtual ~AutoRecovery( );
455 // XInterface, XTypeProvider, XServiceInfo
456 FWK_DECLARE_XINTERFACE
457 FWK_DECLARE_XTYPEPROVIDER
460 //---------------------------------------
461 // css.frame.XDispatch
462 virtual void SAL_CALL
dispatch(const css::util::URL
& aURL
,
463 const css::uno::Sequence
< css::beans::PropertyValue
>& lArguments
)
464 throw(css::uno::RuntimeException
);
466 virtual void SAL_CALL
addStatusListener(const css::uno::Reference
< css::frame::XStatusListener
>& xListener
,
467 const css::util::URL
& aURL
)
468 throw(css::uno::RuntimeException
);
470 virtual void SAL_CALL
removeStatusListener(const css::uno::Reference
< css::frame::XStatusListener
>& xListener
,
471 const css::util::URL
& aURL
)
472 throw(css::uno::RuntimeException
);
474 //---------------------------------------
475 // css.document.XEventListener
476 /** @short informs about created/opened documents.
478 @descr Every new opened/created document will be saved internaly
479 so it can be checked if its modified. This modified state
480 is used later to decide, if it must be saved or not.
483 points to the new created/opened document.
485 virtual void SAL_CALL
notifyEvent(const css::document::EventObject
& aEvent
)
486 throw(css::uno::RuntimeException
);
488 //---------------------------------------
489 // css.util.XChangesListener
490 virtual void SAL_CALL
changesOccurred(const css::util::ChangesEvent
& aEvent
)
491 throw(css::uno::RuntimeException
);
493 //---------------------------------------
494 // css.util.XModifyListener
495 virtual void SAL_CALL
modified(const css::lang::EventObject
& aEvent
)
496 throw(css::uno::RuntimeException
);
498 //---------------------------------------
499 // css.lang.XEventListener
500 using cppu::OPropertySetHelper::disposing
;
501 virtual void SAL_CALL
disposing(const css::lang::EventObject
& aEvent
)
502 throw(css::uno::RuntimeException
);
504 //___________________________________________
509 //---------------------------------------
510 // OPropertySetHelper
512 virtual sal_Bool SAL_CALL
convertFastPropertyValue( css::uno::Any
& aConvertedValue
,
513 css::uno::Any
& aOldValue
,
515 const css::uno::Any
& aValue
)
516 throw(css::lang::IllegalArgumentException
);
518 virtual void SAL_CALL
setFastPropertyValue_NoBroadcast( sal_Int32 nHandle
,
519 const css::uno::Any
& aValue
)
520 throw(css::uno::Exception
);
521 using cppu::OPropertySetHelper::getFastPropertyValue
;
522 virtual void SAL_CALL
getFastPropertyValue(css::uno::Any
& aValue
,
523 sal_Int32 nHandle
) const;
525 virtual ::cppu::IPropertyArrayHelper
& SAL_CALL
getInfoHelper();
527 virtual css::uno::Reference
< css::beans::XPropertySetInfo
> SAL_CALL
getPropertySetInfo()
528 throw(css::uno::RuntimeException
);
529 //___________________________________________
534 //---------------------------------------
535 /** @short open the underlying configuration.
537 @descr This method must be called everytimes
538 a configuartion call is needed. Because
539 method works together with the member
540 m_xCFG, open it on demand and cache it
543 @return [com.sun.star.container.XNameAccess]
544 the configuration object
546 @throw [com.sun.star.uno.RuntimeException]
547 if config could not be opened successfully!
551 css::uno::Reference
< css::container::XNameAccess
> implts_openConfig();
553 //---------------------------------------
554 /** @short read the underlying configuration.
556 @descr After that we know the initial state - means:
557 - if AutoSave was enabled by the user
558 - which time intervall has to be used
559 - which recovery entries may already exists
561 @throw [com.sun.star.uno.RuntimeException]
562 if config could not be opened or readed successfully!
566 void implts_readConfig();
568 //---------------------------------------
569 /** @short read the underlying configuration...
571 @descr ... but only keys related to the AutoSave mechanism.
572 Means: State and Timer intervall.
573 E.g. the recovery list isnt adressed here.
575 @throw [com.sun.star.uno.RuntimeException]
576 if config could not be opened or readed successfully!
580 void implts_readAutoSaveConfig();
582 //---------------------------------------
584 void implts_flushConfigItem(const AutoRecovery::TDocumentInfo
& rInfo
,
585 sal_Bool bRemoveIt
= sal_False
);
587 //---------------------------------------
589 void implts_startListening();
590 void implts_startModifyListeningOnDoc(AutoRecovery::TDocumentInfo
& rInfo
);
592 //---------------------------------------
594 void implts_stopListening();
595 void implts_stopModifyListeningOnDoc(AutoRecovery::TDocumentInfo
& rInfo
);
597 //---------------------------------------
598 /** @short stops and may be(!) restarts the timer.
600 @descr A running timer is stopped everytimes here.
601 But starting depends from the different internal
602 timer variables (e.g. AutoSaveEnabled, AutoSaveTimeIntervall,
605 @throw [com.sun.star.uno.RuntimeException]
606 if timer could not be stopped or started!
610 void implts_actualizeTimer();
612 //---------------------------------------
613 /** @short stop the timer.
615 @descr Double calls will be ignored - means we do
616 nothing here, if the timer is already disabled.
618 @throw [com.sun.star.uno.RuntimeException]
619 if timer could not be stopped!
623 void implts_stopTimer();
625 //---------------------------------------
626 /** @short callback of our internal timer.
628 DECL_LINK(implts_timerExpired
, void*);
630 //---------------------------------------
631 /** @short makes our dispatch() method asynchronous!
633 DECL_LINK(implts_asyncDispatch
, void*);
635 //---------------------------------------
636 /** @short implements the dispatch real. */
637 void implts_dispatch(const DispatchParams
& aParams
);
639 //---------------------------------------
640 /** @short validate new detected document and add it into the internal
643 @descr This method should be called only, if its clear that a new
644 document was opened/created during office runtime.
645 This method checks, if its a top level document (means not an embedded one).
646 Only such top level documents can be recognized by this auto save mechanism.
649 the new document, which should be checked and registered.
653 void implts_registerDocument(const css::uno::Reference
< css::frame::XModel
>& xDocument
);
655 //---------------------------------------
656 /** @short remove the specified document from our internal document list.
659 the new document, which should be deregistered.
661 @param bStopListening
662 FALSE: must be used in case this method is called withion disposing() of the document,
663 where it make no sense to deregister our listener. The container dies ...
664 TRUE : must be used in case this method is used on "dergistration" of this document, where
665 we must deregister our listener .-)
669 void implts_deregisterDocument(const css::uno::Reference
< css::frame::XModel
>& xDocument
,
670 sal_Bool bStopListening
= sal_True
);
672 //---------------------------------------
674 void implts_markDocumentModifiedAgainstLastBackup(const css::uno::Reference
< css::frame::XModel
>& xDocument
);
676 //---------------------------------------
678 void implts_actualizeModifiedState(const css::uno::Reference
< css::frame::XModel
>& xDocument
);
680 //---------------------------------------
682 void implts_updateDocumentUsedForSavingState(const css::uno::Reference
< css::frame::XModel
>& xDocument
,
683 sal_Bool bSaveInProgress
);
685 //---------------------------------------
687 void implts_markDocumentAsSaved(const css::uno::Reference
< css::frame::XModel
>& xDocument
);
689 //---------------------------------------
690 /** @short search a document inside given list.
693 reference to a vector, which can contain such
697 the document, which should be located inside the
700 @return [TDocumentList::iterator]
701 which points to the located document.
702 If document does not exists - its set to
705 static TDocumentList::iterator
impl_searchDocument( AutoRecovery::TDocumentList
& rList
,
706 const css::uno::Reference
< css::frame::XModel
>& xDocument
);
708 //---------------------------------------
709 /** TODO document me */
710 void implts_changeAllDocVisibility(sal_Bool bVisible
);
711 void implts_prepareSessionShutdown();
713 //---------------------------------------
714 /** @short save all current opened documents to a specific
717 @descr Only realy changed documents will be saved here.
719 Further this method returns a suggestion, if and how it should
720 be called again. May be some documents was not saved yet
721 and must wait for an user idle period ...
723 @param bAllowUserIdleLoop
724 Because this method is used for different uses cases, it must
725 know, which actions are allowed or not.
727 If a document is the most active one, saving it
728 will be postponed if there exists other unsaved
729 documents. This feature was implemented, because
730 we dont wish to disturb the user on it's work.
731 ... bAllowUserIdleLoop should be set to TRUE
732 EMERGENCY_SAVE / SESSION_SAVE =>
733 Here we must finish our work ASAP! It's not allowed
734 to postpone any document.
735 ... bAllowUserIdleLoop must(!) be set to FALSE
738 sometimes this method is required inside an external dispatch request.
739 The it contains some special environment variables, which overwrites
740 our normal environment.
741 AutoSave => pParams == 0
742 SessionSave/CrashSave => pParams != 0
744 @return A suggestion, how the timer (if its not already disabled!)
745 should be restarted to full fill the requirements.
749 AutoRecovery::ETimerType
implts_saveDocs( sal_Bool bAllowUserIdleLoop
,
750 sal_Bool bRemoveLockFiles
,
751 const DispatchParams
* pParams
= 0);
753 //---------------------------------------
754 /** @short save one of the current documents to a specific
758 - defines a new(!) unique temp file name
759 - save the new temp file
760 - remove the old temp file
761 - patch the given info struct
765 - patch the configuration.
767 Note further: It paches the info struct
768 more then ones. E.g. the new temp URL is set
769 before the file is saved. And the old URL is removed
770 only if removing oft he old file was successfully.
771 If this method returns without an exception - everything
772 was OK. Otherwhise the info struct can be analyzed to
773 get more information, e.g. when the problem occures.
776 the base path for saving such temp files.
779 points to an informations structure, where
780 e.g. the document, its modified state, the count
781 of autosave-retries etcpp. exists.
782 Its used also to return the new temp file name
783 and some other state values!
787 void implts_saveOneDoc(const ::rtl::OUString
& sBackupPath
,
788 AutoRecovery::TDocumentInfo
& rInfo
,
789 const css::uno::Reference
< css::task::XStatusIndicator
>& xExternalProgress
);
791 //---------------------------------------
792 /** @short recovery all documents, which was saved during
795 @return A suggestion, how this method must be called back!
799 AutoRecovery::ETimerType
implts_openDocs(const DispatchParams
& aParams
);
801 //---------------------------------------
803 void implts_openOneDoc(const ::rtl::OUString
& sURL
,
804 ::comphelper::MediaDescriptor
& lDescriptor
,
805 AutoRecovery::TDocumentInfo
& rInfo
);
807 //---------------------------------------
809 void implts_generateNewTempURL(const ::rtl::OUString
& sBackupPath
,
810 ::comphelper::MediaDescriptor
& rMediaDescriptor
,
811 AutoRecovery::TDocumentInfo
& rInfo
);
813 //---------------------------------------
814 /** @short notifies all interested listener about the current state
815 of the currently running operation.
817 @descr We support different set's of functions. AUTO_SAVE, EMERGENCY_SAVE,
818 AUTO_RECOVERY, FAILURE_SAVE ... etcpp.
819 Listener can register itself for any type of supported
820 functionality ... but not for document URL's in special.
823 is used to know, which set of listener we must notify.
826 describe the event more in detail.
830 void implts_informListener( sal_Int32 eJob
,
831 const css::frame::FeatureStateEvent
& aEvent
);
833 //---------------------------------------
834 /** short create a feature event struct, which can be send
835 to any interested listener.
838 describe the current running operation
839 AUTOSAVE, EMERGENCYSAVE, RECOVERY
842 describe the type of this event
846 if sOperation is an update, this parameter must be different from NULL
847 and is used to send informations regarding the current handled document.
849 @return [css::frame::FeatureStateEvent]
850 the event structure for sending.
852 static css::frame::FeatureStateEvent
implst_createFeatureStateEvent( sal_Int32 eJob
,
853 const ::rtl::OUString
& sEventType
,
854 AutoRecovery::TDocumentInfo
* pInfo
);
856 //---------------------------------------
859 void implts_resetHandleStates(sal_Bool bLoadCache
);
861 //---------------------------------------
863 void implts_specifyDefaultFilterAndExtension(AutoRecovery::TDocumentInfo
& rInfo
);
865 //---------------------------------------
867 void implts_specifyAppModuleAndFactoryURL(AutoRecovery::TDocumentInfo
& rInfo
);
869 //---------------------------------------
871 void implts_prepareEmergencySave();
873 //---------------------------------------
875 void implts_doEmergencySave(const DispatchParams
& aParams
);
877 //---------------------------------------
879 void implts_doRecovery(const DispatchParams
& aParams
);
881 //---------------------------------------
883 void implts_doSessionSave(const DispatchParams
& aParams
);
885 //---------------------------------------
887 void implts_doSessionRestore(const DispatchParams
& aParams
);
889 //---------------------------------------
891 void implts_backupWorkingEntry(const DispatchParams
& aParams
);
893 //---------------------------------------
895 void implts_cleanUpWorkingEntry(const DispatchParams
& aParams
);
897 //---------------------------------------
898 /** try to make sure that all changed config items (not our used
899 config access only) will be flushed back to disc.
901 E.g. our svtools::ConfigItems() has to be flushed explicitly .-(
903 Note: This method cant fail. Flushing of config entries is an
904 optional feature. Errors can be ignored.
906 void impl_flushALLConfigChanges();
908 //---------------------------------------
910 AutoRecovery::EFailureSafeResult
implts_copyFile(const ::rtl::OUString
& sSource
,
911 const ::rtl::OUString
& sTargetPath
,
912 const ::rtl::OUString
& sTargetName
);
914 //---------------------------------------
915 /** @short converts m_eJob into a job description, which
916 can be used to inform an outside listener
917 about the current running operation
920 describe the current running operation
921 AUTOSAVE, EMERGENCYSAVE, RECOVERY
924 a suitable job description of form:
925 vnd.sun.star.autorecovery:/do...
927 static ::rtl::OUString
implst_getJobDescription(sal_Int32 eJob
);
929 //---------------------------------------
930 /** @short mape the given URL to an internal int representation.
933 the url, which describe the next starting or may be already running
937 the internal int representation
940 static sal_Int32
implst_classifyJob(const css::util::URL
& aURL
);
943 void implts_verifyCacheAgainstDesktopDocumentList();
946 sal_Bool
impl_enoughDiscSpace(sal_Int32 nRequiredSpace
);
949 static void impl_showFullDiscError();
951 //---------------------------------------
952 /** @short try to create/use a progress and set it inside the
955 @descr The problem behind: There exists different use case of this method.
956 a) An external progress is provided by our CrashSave or Recovery dialog.
957 b) We must create our own progress e.g. for an AutoSave
958 c) Sometimes our application filters dont use the progress
959 provided by the MediaDescriptor. They uses the Frame everytime to create
960 it's own progress. So we implemented a HACK for these and now we set
961 an InterceptedProgress there for the time WE use this frame for loading/storing documents .-)
964 must be set only in case WE create a new frame (e.g. for loading documents
965 on session restore or recovery). Then search for a frame using rInfo.Document must
966 be supressed and xFrame must be preferred instead .-)
969 used e.g. to find the frame corresponding to a document.
970 This frame must be used to create a new progress e.g. for an AutoSave.
973 is used to set the new created progress as parameter on these set.
975 void impl_establishProgress(const AutoRecovery::TDocumentInfo
& rInfo
,
976 ::comphelper::MediaDescriptor
& rArgs
,
977 const css::uno::Reference
< css::frame::XFrame
>& xNewFrame
);
979 void impl_forgetProgress(const AutoRecovery::TDocumentInfo
& rInfo
,
980 ::comphelper::MediaDescriptor
& rArgs
,
981 const css::uno::Reference
< css::frame::XFrame
>& xNewFrame
);
983 //---------------------------------------
984 /** try to remove the specified file from disc.
986 Every URL supported by our UCB component can be used here.
987 Further it doesnt matter if the file realy exists or not.
988 Because removing a non exsistent file will have the same
989 result at the end ... a non existing file .-)
991 On the other side removing of files from disc is an optional
992 feature. If we are not able doing so ... its not a real problem.
993 Ok - users disc place will be samller then ... but we should produce
994 a crash during crash save because we cant delete a temporary file only !
997 the url of the file, which should be removed.
999 static void st_impl_removeFile(const ::rtl::OUString
& sURL
);
1001 //---------------------------------------
1002 /** try to remove ".lock" file from disc if office will be terminated
1003 not using the offical way .-)
1005 This method has to be handled "optional". So every error inside
1006 has to be ignored ! This method CANT FAIL ... it can forget something only .-)
1008 static void st_impl_removeLockFile();
1011 } // namespace framework
1013 #endif // __FRAMEWORK_SERVICES_AUTORECOVERY_HXX_