summaryrefslogtreecommitdiffstats
path: root/offapi/com/sun/star/document/XDocumentRecovery.idl
blob: 914a091b672b9af67bc5194fb4221ae1722fd1c6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * This file incorporates work covered by the following license notice:
 *
 *   Licensed to the Apache Software Foundation (ASF) under one or more
 *   contributor license agreements. See the NOTICE file distributed
 *   with this work for additional information regarding copyright
 *   ownership. The ASF licenses this file to you under the Apache
 *   License, Version 2.0 (the "License"); you may not use this file
 *   except in compliance with the License. You may obtain a copy of
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
 */

#ifndef __com_sun_star_document_XDocumentRecovery_idl__
#define __com_sun_star_document_XDocumentRecovery_idl__

#include <com/sun/star/beans/PropertyValue.idl>
#include <com/sun/star/io/IOException.idl>
#include <com/sun/star/lang/WrappedTargetException.idl>


module com { module sun { module star { module document {


/** is the interface to be implemented by documents who wish to participate in
    the document emergency-save / recovery process.
 */
interface XDocumentRecovery
{
    /** determines whether the document has been modified since the last call to storeToRecoveryFile().

        <p>If <code>storeToRecoveryFile</code> has not been called before, this method returns whether the document
        has been modified since it has been loaded respectively created.</p>

        <p>When saving a session, either in case of an emergency (when OpenOffice.org crashed), or during a
        periodic session save as configured by the user, storeToRecoveryFile() is called for every
        document where <code>wasModifiedSinceLastSave</code> returns `TRUE`.</p>

        <p>It's allowed to implement this method sloppy, by returning `TRUE` in cases where it is not sure whether
        the document actually has been modified. So, the most simple implementation could simply delegate this call
        to com::sun::star::util::XModifiable::isModified(). (Well, actually that's the
        second simple implementation, the <em>most</em> simple one would, still legitimately, always return `TRUE`.)</p>

        <p>However, in such a case, the document might be saved more often than needed. In particular during the
        periodic session save, this might become a problem when saving is expensive, for a single document
        or the sum of all open documents.</p>
    */
    boolean wasModifiedSinceLastSave();

    /** does an emergency save of the document

        <p>A default implementation of this method could simply delegate this call to
        com::sun::star::frame::XStorable::storeToURL().</p>

        @param TargetLocation
            specifies the URL of the location to which the document should be emergency-saved.

        @param MediaDescriptor
            contains additional arguments for the save process, for instance a StatusIndicator.

        @see MediaDescriptor
    */
    void    storeToRecoveryFile(
                [in] string TargetLocation,
                [in] sequence< ::com::sun::star::beans::PropertyValue > MediaDescriptor
            )
            raises  (   ::com::sun::star::io::IOException,
                        ::com::sun::star::lang::WrappedTargetException
                    );

    /** recovers the document after a previous emergency or session save.

        <p>The document itself has previously been created, but <em>not</em> loaded
        (via com::sun::star::frame::XLoadable::load()) or initialized (via
        com::sun::star::frame::XLoadable::initNew()).</p>

        <p>Upon successful return, the document must be fully initialized. In particular, the
        caller is not responsible for calling com::sun::star::frame::XModel::attachResource().
        Instead, the implementation is responsible to do so, if required.</p>

        <p>A default implementation of this method could simply delegate this call to
        ::com::sun::star::frame::XLoadable::load(), followed by
        com::sun::star::frame::XModel::attachResource().</p>

        @param SourceLocation
            specifies the URL of the location to which the document was previously emergency-saved.

        @param SalvagedFile
            specifies the original URL of the file which had been emergency-saved. If this is empty,
            then the file should be recovered from its original location.

        @param MediaDescriptor
            contains additional arguments for the load process, for instance a StatusIndicator.

        @see MediaDescriptor
    */
    void    recoverFromFile(
                [in] string SourceLocation,
                [in] string SalvagedFile,
                [in] sequence< ::com::sun::star::beans::PropertyValue > MediaDescriptor
            )
            raises  (   ::com::sun::star::io::IOException,
                        ::com::sun::star::lang::WrappedTargetException
                    );
};


}; }; }; };


#endif

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */