1*cdf0e10cSrcweir/************************************************************************* 2*cdf0e10cSrcweir* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3*cdf0e10cSrcweir* 4*cdf0e10cSrcweir* Copyright 2009 by Sun Microsystems, Inc. 5*cdf0e10cSrcweir* 6*cdf0e10cSrcweir* OpenOffice.org - a multi-platform office productivity suite 7*cdf0e10cSrcweir* 8*cdf0e10cSrcweir* This file is part of OpenOffice.org. 9*cdf0e10cSrcweir* 10*cdf0e10cSrcweir* OpenOffice.org is free software: you can redistribute it and/or modify 11*cdf0e10cSrcweir* it under the terms of the GNU Lesser General Public License version 3 12*cdf0e10cSrcweir* only, as published by the Free Software Foundation. 13*cdf0e10cSrcweir* 14*cdf0e10cSrcweir* OpenOffice.org is distributed in the hope that it will be useful, 15*cdf0e10cSrcweir* but WITHOUT ANY WARRANTY; without even the implied warranty of 16*cdf0e10cSrcweir* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17*cdf0e10cSrcweir* GNU Lesser General Public License version 3 for more details 18*cdf0e10cSrcweir* (a copy is included in the LICENSE file that accompanied this code). 19*cdf0e10cSrcweir* 20*cdf0e10cSrcweir* You should have received a copy of the GNU Lesser General Public License 21*cdf0e10cSrcweir* version 3 along with OpenOffice.org. If not, see 22*cdf0e10cSrcweir* <http://www.openoffice.org/license.html> 23*cdf0e10cSrcweir* for a copy of the LGPLv3 License. 24*cdf0e10cSrcweir************************************************************************/ 25*cdf0e10cSrcweir 26*cdf0e10cSrcweir#ifndef __offapcom_sun_star_document_XDocumentRecovery_idl__ 27*cdf0e10cSrcweir#define __offapcom_sun_star_document_XDocumentRecovery_idl__ 28*cdf0e10cSrcweir 29*cdf0e10cSrcweir#include <com/sun/star/beans/PropertyValue.idl> 30*cdf0e10cSrcweir#include <com/sun/star/io/IOException.idl> 31*cdf0e10cSrcweir#include <com/sun/star/lang/WrappedTargetException.idl> 32*cdf0e10cSrcweir 33*cdf0e10cSrcweir//============================================================================= 34*cdf0e10cSrcweir 35*cdf0e10cSrcweirmodule com { module sun { module star { module document { 36*cdf0e10cSrcweir 37*cdf0e10cSrcweir//============================================================================= 38*cdf0e10cSrcweir 39*cdf0e10cSrcweir/** is the interface to be implemented by documents who wish to participate in 40*cdf0e10cSrcweir the document emergency-save / recovery process. 41*cdf0e10cSrcweir */ 42*cdf0e10cSrcweirinterface XDocumentRecovery 43*cdf0e10cSrcweir{ 44*cdf0e10cSrcweir /** determines whether the document has been modified since the last call to <member>storeToRecoveryFile</member>. 45*cdf0e10cSrcweir 46*cdf0e10cSrcweir <p>If <code>storeToRecoveryFile</code> has not been called before, this method returns whether the document 47*cdf0e10cSrcweir has been modified since it has been loaded respectively created.</p> 48*cdf0e10cSrcweir 49*cdf0e10cSrcweir <p>When saving a session, either in case of a emergency (when OpenOffice.org crashed), or during a 50*cdf0e10cSrcweir periodic session save as configured by the user, <member>storeToRecoveryFile</member> is called for every 51*cdf0e10cSrcweir document where <code>wasModifiedSinceLastSave</code> returns <TRUE/>.</p> 52*cdf0e10cSrcweir 53*cdf0e10cSrcweir <p>It's allowed to implement this method sloppy, by returning <TRUE/> in cases where it is not sure whether 54*cdf0e10cSrcweir the document actually has been modified. So, the most simple implementation could simply delegate this call 55*cdf0e10cSrcweir to <member scope="com::sun::star::util">XModifiable::isModified</member>. (Well, actually that's the 56*cdf0e10cSrcweir second simple implementation, the <em>most</em> simple one would, still egitimately, always return <TRUE/>.)</p> 57*cdf0e10cSrcweir 58*cdf0e10cSrcweir <p>However, in such a case, the document might be saved more often than needed. In particular during the 59*cdf0e10cSrcweir periodic session save, this might become a problem when saving is expensive, for a single document 60*cdf0e10cSrcweir or the sum of all open documents.</p> 61*cdf0e10cSrcweir */ 62*cdf0e10cSrcweir boolean wasModifiedSinceLastSave(); 63*cdf0e10cSrcweir 64*cdf0e10cSrcweir /** does an emergency save of the document 65*cdf0e10cSrcweir 66*cdf0e10cSrcweir <p>A default implementation of this method could simply delegate this call to 67*cdf0e10cSrcweir <member scope="com::sun::star::frame">XStorable::storeToURL</member>.</p> 68*cdf0e10cSrcweir 69*cdf0e10cSrcweir @param TargetLocation 70*cdf0e10cSrcweir specifies the URL of the location to which the document should be emergency-saved. 71*cdf0e10cSrcweir 72*cdf0e10cSrcweir @param MediaDescriptor 73*cdf0e10cSrcweir contains additional arguments for the save process, for instance an StatusIndicator. 74*cdf0e10cSrcweir 75*cdf0e10cSrcweir @see MediaDescriptor 76*cdf0e10cSrcweir */ 77*cdf0e10cSrcweir void storeToRecoveryFile( 78*cdf0e10cSrcweir [in] string TargetLocation, 79*cdf0e10cSrcweir [in] sequence< ::com::sun::star::beans::PropertyValue > MediaDescriptor 80*cdf0e10cSrcweir ) 81*cdf0e10cSrcweir raises ( ::com::sun::star::io::IOException, 82*cdf0e10cSrcweir ::com::sun::star::lang::WrappedTargetException 83*cdf0e10cSrcweir ); 84*cdf0e10cSrcweir 85*cdf0e10cSrcweir /** recovers the document after a previous emergency or session save. 86*cdf0e10cSrcweir 87*cdf0e10cSrcweir <p>The document itself has previously been created, but <em>not</em> loaded 88*cdf0e10cSrcweir (via <member scope="com::sun::star::frame">XLoadable::load</member>) or initialized (via 89*cdf0e10cSrcweir <member scope="com::sun::star::frame">XLoadable::initNew</member>).</p> 90*cdf0e10cSrcweir 91*cdf0e10cSrcweir <p>Upon successful return, the document must be fully initialized. In particular, the 92*cdf0e10cSrcweir caller is not responsible for calling <member scope="com::sun::star::frame">XModel::attachResource</member>. 93*cdf0e10cSrcweir Instead, the implementation is responsible to do so, if required.</p> 94*cdf0e10cSrcweir 95*cdf0e10cSrcweir <p>A default implementation of this method could simply delegate this call to 96*cdf0e10cSrcweir <member scope="::com::sun::star::frame:">XLodable::load</member>, followed by 97*cdf0e10cSrcweir <member scope="com::sun::star::frame">XModel::attachResource</member>.</p> 98*cdf0e10cSrcweir 99*cdf0e10cSrcweir @param SourceLocation 100*cdf0e10cSrcweir specifies the URL of the location to which the document was previously emergency-saved. 101*cdf0e10cSrcweir 102*cdf0e10cSrcweir @param SalvagedFile 103*cdf0e10cSrcweir specifies the original URL of the file which had been emergency-saved. If this is empty, 104*cdf0e10cSrcweir then the file should be recovered from its original location. 105*cdf0e10cSrcweir 106*cdf0e10cSrcweir @param MediaDescriptor 107*cdf0e10cSrcweir contains additional arguments for the load process, for instance an StatusIndicator. 108*cdf0e10cSrcweir 109*cdf0e10cSrcweir @see MediaDescriptor 110*cdf0e10cSrcweir */ 111*cdf0e10cSrcweir void recoverFromFile( 112*cdf0e10cSrcweir [in] string SourceLocation, 113*cdf0e10cSrcweir [in] string SalvagedFile, 114*cdf0e10cSrcweir [in] sequence< ::com::sun::star::beans::PropertyValue > MediaDescriptor 115*cdf0e10cSrcweir ) 116*cdf0e10cSrcweir raises ( ::com::sun::star::io::IOException, 117*cdf0e10cSrcweir ::com::sun::star::lang::WrappedTargetException 118*cdf0e10cSrcweir ); 119*cdf0e10cSrcweir}; 120*cdf0e10cSrcweir 121*cdf0e10cSrcweir//============================================================================= 122*cdf0e10cSrcweir 123*cdf0e10cSrcweir}; }; }; }; 124*cdf0e10cSrcweir 125*cdf0e10cSrcweir//============================================================================= 126*cdf0e10cSrcweir 127*cdf0e10cSrcweir#endif 128