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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
|
/* This file is part of the KDE project
Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __koDocumentChild_h__
#define __koDocumentChild_h__
#include <KoChild.h>
#include <koffice_export.h>
class TQDomDocument;
class TQDomElement;
class KURL;
class KoStore;
class KoDocument;
class KoDocumentChildPrivate;
class KoDocumentEntry;
class KoXmlWriter;
/**
* @brief Holds an embedded object.
*
* In addition to its base class @ref KoChild it cares about the content
* of an embedded document. That means it supports operations like
* loading and saving.
*
* If you need a representation for embedded documents in your KOffice
* component then you should inherit from this class.
*/
class KOFFICECORE_EXPORT KoDocumentChild : public KoChild
{
Q_OBJECT
TQ_OBJECT
public:
KoDocumentChild( KoDocument* tqparent, KoDocument* doc, const TQRect& tqgeometry );
/**
* When using this constructor you must call @ref #setDocument before
* you can call any other function of this class.
*/
KoDocumentChild( KoDocument* tqparent );
virtual ~KoDocumentChild();
/**
* Call this function only directly after calling the constructor
* that takes only a tqparent as argument.
*/
virtual void setDocument( KoDocument *doc, const TQRect &tqgeometry );
/**
* @return document contained in this child
*
* @see KoDocument
*/
KoDocument *document() const;
/**
* @return tqparent document of this child
*
* @see KoDocument
*/
virtual KoDocument *tqparentDocument() const; // TODO: remove virtual, makes no sense
virtual KoDocument* hitTest( const TQPoint& p, const TQWMatrix& _matrix = TQWMatrix() );
/**
* @note Can be empty (which is why it doesn't return a const KURL &)
*/
KURL url() const;
/**
* Writes the "object" tag, but does NOT write the content of the
* embedded documents. Saving the embedded documents themselves
* is done in @ref KoDocument::saveChildren. This function just stores information
* about the position and id of the embedded document and should be
* called from within KoDocument::saveXML.
*
* The "object" element is not added to the document. It is just created
* and returned.
*
* @return the element containing the "object" tag.
*/
virtual TQDomElement save( TQDomDocument& doc, bool uppercase=false );
/**
* Save an embedded object to OASIS.
* This method sets the attributes for the draw:object element in the tqparent XML document.
* It also prepares the embedded object for being saved into the store at
* the end of saving (see saveOasisToStore).
* Note that @p name is only used for "internal" documents (not extern).
*/
void saveOasisAttributes( KoXmlWriter &xmlWriter, const TQString& name );
/**
* Save an embedded object to an OASIS store.
* This is called automatically by the tqparent KoDocument's saveOasis
*/
virtual bool saveOasis( KoStore* store, KoXmlWriter* manifestWriter );
/**
* Parses the "object" tag. This does NOT mean creating the child documents.
* AFTER the 'parser' has finished parsing, you must use @ref #loadDocument
* to actually load the embedded documents.
*
* What you should have in mind is that this method is called from within
* @ref KoDocument::loadXML while @ref #loadDocument is called from within
* @ref KoDocument::loadChildren, respectively from your implementation
* of these methods.
*/
virtual bool load( const TQDomElement& element, bool uppercase=false );
void loadOasis( const TQDomElement &frameElement, const TQDomElement& objectElement );
/**
* Actually loads the document from the disk/net or from the store,
* depending on @ref #url
*/
virtual bool loadDocument( KoStore* );
/**
* Actually loads the document from the disk/net or from the store
* depending on the document's url
*/
virtual bool loadOasisDocument( KoStore* store, const TQDomDocument& manifestDoc );
virtual bool isStoredExtern() const;
/**
* This document (child) is deleted.
*/
bool isDeleted() const;
void setDeleted( bool on = true );
protected: // Should be private, but KWord needs access to the variables
// because it reimplements load/save (for uppercase tags)
/**
* Holds the source of this object, for example "file:/home/weis/image.gif"
* or "tar:/table1/2" if it is stored in a koffice store. This variable is
* set after parsing the OBJECT tag in @ref #load and is reset after
* calling @ref #loadDocument.
*/
TQString m_tmpURL;
/**
* This variable is
* set after parsing the OBJECT tag in @ref #load and is reset after
* calling @ref #loadDocument.
*/
TQRect m_tmpGeometry;
/**
* This variable is
* set after parsing the OBJECT tag in @ref #load and is reset after
* calling @ref #loadDocument.
*/
TQString m_tmpMimeType;
private:
bool createUnavailDocument( KoStore* store, bool doOpenURL, const TQString& mimeType );
bool loadDocumentInternal( KoStore* _store, const KoDocumentEntry& e, bool doOpenURL, bool oasis );
private:
KoDocumentChildPrivate *d;
};
#endif
|