1*cc385c9fSAndrew Rist/************************************************************** 2*cc385c9fSAndrew Rist * 3*cc385c9fSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*cc385c9fSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*cc385c9fSAndrew Rist * distributed with this work for additional information 6*cc385c9fSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*cc385c9fSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*cc385c9fSAndrew Rist * "License"); you may not use this file except in compliance 9*cc385c9fSAndrew Rist * with the License. You may obtain a copy of the License at 10*cc385c9fSAndrew Rist * 11*cc385c9fSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*cc385c9fSAndrew Rist * 13*cc385c9fSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*cc385c9fSAndrew Rist * software distributed under the License is distributed on an 15*cc385c9fSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*cc385c9fSAndrew Rist * KIND, either express or implied. See the License for the 17*cc385c9fSAndrew Rist * specific language governing permissions and limitations 18*cc385c9fSAndrew Rist * under the License. 19*cc385c9fSAndrew Rist * 20*cc385c9fSAndrew Rist *************************************************************/ 21*cc385c9fSAndrew Rist 22*cc385c9fSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir#ifndef __offapcom_sun_star_document_XDocumentRecovery_idl__ 25cdf0e10cSrcweir#define __offapcom_sun_star_document_XDocumentRecovery_idl__ 26cdf0e10cSrcweir 27cdf0e10cSrcweir#include <com/sun/star/beans/PropertyValue.idl> 28cdf0e10cSrcweir#include <com/sun/star/io/IOException.idl> 29cdf0e10cSrcweir#include <com/sun/star/lang/WrappedTargetException.idl> 30cdf0e10cSrcweir 31cdf0e10cSrcweir//============================================================================= 32cdf0e10cSrcweir 33cdf0e10cSrcweirmodule com { module sun { module star { module document { 34cdf0e10cSrcweir 35cdf0e10cSrcweir//============================================================================= 36cdf0e10cSrcweir 37cdf0e10cSrcweir/** is the interface to be implemented by documents who wish to participate in 38cdf0e10cSrcweir the document emergency-save / recovery process. 39cdf0e10cSrcweir */ 40cdf0e10cSrcweirinterface XDocumentRecovery 41cdf0e10cSrcweir{ 42cdf0e10cSrcweir /** determines whether the document has been modified since the last call to <member>storeToRecoveryFile</member>. 43cdf0e10cSrcweir 44cdf0e10cSrcweir <p>If <code>storeToRecoveryFile</code> has not been called before, this method returns whether the document 45cdf0e10cSrcweir has been modified since it has been loaded respectively created.</p> 46cdf0e10cSrcweir 47cdf0e10cSrcweir <p>When saving a session, either in case of a emergency (when OpenOffice.org crashed), or during a 48cdf0e10cSrcweir periodic session save as configured by the user, <member>storeToRecoveryFile</member> is called for every 49cdf0e10cSrcweir document where <code>wasModifiedSinceLastSave</code> returns <TRUE/>.</p> 50cdf0e10cSrcweir 51cdf0e10cSrcweir <p>It's allowed to implement this method sloppy, by returning <TRUE/> in cases where it is not sure whether 52cdf0e10cSrcweir the document actually has been modified. So, the most simple implementation could simply delegate this call 53cdf0e10cSrcweir to <member scope="com::sun::star::util">XModifiable::isModified</member>. (Well, actually that's the 54cdf0e10cSrcweir second simple implementation, the <em>most</em> simple one would, still egitimately, always return <TRUE/>.)</p> 55cdf0e10cSrcweir 56cdf0e10cSrcweir <p>However, in such a case, the document might be saved more often than needed. In particular during the 57cdf0e10cSrcweir periodic session save, this might become a problem when saving is expensive, for a single document 58cdf0e10cSrcweir or the sum of all open documents.</p> 59cdf0e10cSrcweir */ 60cdf0e10cSrcweir boolean wasModifiedSinceLastSave(); 61cdf0e10cSrcweir 62cdf0e10cSrcweir /** does an emergency save of the document 63cdf0e10cSrcweir 64cdf0e10cSrcweir <p>A default implementation of this method could simply delegate this call to 65cdf0e10cSrcweir <member scope="com::sun::star::frame">XStorable::storeToURL</member>.</p> 66cdf0e10cSrcweir 67cdf0e10cSrcweir @param TargetLocation 68cdf0e10cSrcweir specifies the URL of the location to which the document should be emergency-saved. 69cdf0e10cSrcweir 70cdf0e10cSrcweir @param MediaDescriptor 71cdf0e10cSrcweir contains additional arguments for the save process, for instance an StatusIndicator. 72cdf0e10cSrcweir 73cdf0e10cSrcweir @see MediaDescriptor 74cdf0e10cSrcweir */ 75cdf0e10cSrcweir void storeToRecoveryFile( 76cdf0e10cSrcweir [in] string TargetLocation, 77cdf0e10cSrcweir [in] sequence< ::com::sun::star::beans::PropertyValue > MediaDescriptor 78cdf0e10cSrcweir ) 79cdf0e10cSrcweir raises ( ::com::sun::star::io::IOException, 80cdf0e10cSrcweir ::com::sun::star::lang::WrappedTargetException 81cdf0e10cSrcweir ); 82cdf0e10cSrcweir 83cdf0e10cSrcweir /** recovers the document after a previous emergency or session save. 84cdf0e10cSrcweir 85cdf0e10cSrcweir <p>The document itself has previously been created, but <em>not</em> loaded 86cdf0e10cSrcweir (via <member scope="com::sun::star::frame">XLoadable::load</member>) or initialized (via 87cdf0e10cSrcweir <member scope="com::sun::star::frame">XLoadable::initNew</member>).</p> 88cdf0e10cSrcweir 89cdf0e10cSrcweir <p>Upon successful return, the document must be fully initialized. In particular, the 90cdf0e10cSrcweir caller is not responsible for calling <member scope="com::sun::star::frame">XModel::attachResource</member>. 91cdf0e10cSrcweir Instead, the implementation is responsible to do so, if required.</p> 92cdf0e10cSrcweir 93cdf0e10cSrcweir <p>A default implementation of this method could simply delegate this call to 94cdf0e10cSrcweir <member scope="::com::sun::star::frame:">XLodable::load</member>, followed by 95cdf0e10cSrcweir <member scope="com::sun::star::frame">XModel::attachResource</member>.</p> 96cdf0e10cSrcweir 97cdf0e10cSrcweir @param SourceLocation 98cdf0e10cSrcweir specifies the URL of the location to which the document was previously emergency-saved. 99cdf0e10cSrcweir 100cdf0e10cSrcweir @param SalvagedFile 101cdf0e10cSrcweir specifies the original URL of the file which had been emergency-saved. If this is empty, 102cdf0e10cSrcweir then the file should be recovered from its original location. 103cdf0e10cSrcweir 104cdf0e10cSrcweir @param MediaDescriptor 105cdf0e10cSrcweir contains additional arguments for the load process, for instance an StatusIndicator. 106cdf0e10cSrcweir 107cdf0e10cSrcweir @see MediaDescriptor 108cdf0e10cSrcweir */ 109cdf0e10cSrcweir void recoverFromFile( 110cdf0e10cSrcweir [in] string SourceLocation, 111cdf0e10cSrcweir [in] string SalvagedFile, 112cdf0e10cSrcweir [in] sequence< ::com::sun::star::beans::PropertyValue > MediaDescriptor 113cdf0e10cSrcweir ) 114cdf0e10cSrcweir raises ( ::com::sun::star::io::IOException, 115cdf0e10cSrcweir ::com::sun::star::lang::WrappedTargetException 116cdf0e10cSrcweir ); 117cdf0e10cSrcweir}; 118cdf0e10cSrcweir 119cdf0e10cSrcweir//============================================================================= 120cdf0e10cSrcweir 121cdf0e10cSrcweir}; }; }; }; 122cdf0e10cSrcweir 123cdf0e10cSrcweir//============================================================================= 124cdf0e10cSrcweir 125cdf0e10cSrcweir#endif 126