merge the formfield patch from ooo-build
[ooovba.git] / writerfilter / inc / ooxml / OOXMLDocument.hxx
blob803ebec94ce6a9f489910e6a896b59a76cf2a11f
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: OOXMLDocument.hxx,v $
10 * $Revision: 1.17 $
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 ************************************************************************/
30 #ifndef INCLUDED_OOXML_DOCUMENT_HXX
31 #define INCLUDED_OOXML_DOCUMENT_HXX
33 #include <sal/types.h>
34 #include <com/sun/star/uno/Reference.hxx>
35 #include <com/sun/star/io/XInputStream.hpp>
36 #ifndef _COM_SUN_STAR_UNO_XCOMPONENTCONTEX_HPP_
37 #include <com/sun/star/uno/XComponentContext.hpp>
38 #endif
39 #ifndef INCLUDED_WW8_RESOURCE_MODEL_HXX
40 #include <resourcemodel/WW8ResourceModel.hxx>
41 #endif
42 #ifndef _COM_SUN_STAR_XML_SAX_XPARSER_HOO_
43 #include <com/sun/star/xml/sax/XParser.hpp>
44 #endif
45 #include <com/sun/star/xml/sax/XFastParser.hpp>
46 #include <com/sun/star/xml/sax/XFastTokenHandler.hpp>
47 #include <com/sun/star/frame/XModel.hpp>
48 #include <com/sun/star/drawing/XDrawPage.hpp>
50 /**
51 @file OOXMLDocument.hxx
53 <h1>Import of OOXML WordprocessingML Documents</h1>
55 The following picture shows the classes involved in importing OOXML
56 WordprocessingML documents.
58 @image html ooxmlimportchain.png
60 The DOCX consists of parts. Each part is an XML document. The
61 OOXMLDocument opens the DOCX and creates a SAX parser for the part
62 containing the main document content. The OOXMLDocument creates a
63 SAX handler, too. This handler is set as the handler for the events
64 created by the parser. Finally the OOXMLDocument initiates the
65 parsing process.
67 The SAX handler hosts a stack of contexts. Each context is an
68 instance of a class derived from OOXMLContext. There is a context
69 class for each <define> in the model.xml.
71 For a detailed information about how the contexts are handled see
72 the documentation for OOXMLContext.
74 The contexts know how to convert an element in OOXML to the
75 intermediate format that the domain mapper understands. They
76 enumerate the according entity in OOXML by sending the according
77 events to the domain mapper.
79 The domain mapper knows how to convert the intermediate format to
80 API calls. It takes the events sent by the contexts and uses the
81 core API to insert the according elements to the core.
84 namespace writerfilter {
85 namespace ooxml
88 using namespace com::sun::star;
90 class WRITERFILTER_DLLPUBLIC OOXMLStream
92 public:
93 enum StreamType_t { UNKNOWN, DOCUMENT, STYLES, FONTTABLE, NUMBERING,
94 FOOTNOTES, ENDNOTES, COMMENTS, THEME, SETTINGS };
95 typedef boost::shared_ptr<OOXMLStream> Pointer_t;
97 virtual ~OOXMLStream() {}
99 /**
100 Returns parser for this stream.
102 virtual uno::Reference<xml::sax::XParser> getParser() = 0;
105 Returns fast parser for this stream.
107 virtual uno::Reference<xml::sax::XFastParser> getFastParser() = 0;
109 virtual uno::Reference<io::XInputStream> getDocumentStream() = 0;
111 virtual uno::Reference<io::XInputStream> getStorageStream() = 0;
114 Returns component context for this stream.
116 virtual uno::Reference<uno::XComponentContext> getContext() = 0;
119 Returns target URL from relationships for a given id.
121 @param rId the id to look for
123 @return the URL found or an empty string
125 virtual ::rtl::OUString getTargetForId(const ::rtl::OUString & rId) = 0;
127 virtual const ::rtl::OUString & getTarget() const = 0;
129 virtual uno::Reference<xml::sax::XFastTokenHandler>
130 getFastTokenHandler(uno::Reference<uno::XComponentContext> rContext) = 0;
134 class WRITERFILTER_DLLPUBLIC OOXMLDocument : public writerfilter::Reference<Stream>
136 public:
138 Pointer to this stream.
140 typedef boost::shared_ptr<OOXMLDocument> Pointer_t;
142 virtual ~OOXMLDocument() {}
145 Resolves this document to a stream handler.
147 @param rStream stream handler to resolve this document to
149 virtual void resolve(Stream & rStream) = 0;
152 Returns string representation of the type of this reference.
154 DEBUGGING PURPOSE ONLY.
156 virtual string getType() const = 0;
159 Resolves a footnote to a stream handler.
161 A footnote is resolved if either the note type or
162 note id matches.
164 @param rStream stream handler to resolve to
165 @param rNoteType type of footnote to resolve
166 @param rNoteId id of the footnote to resolve
168 virtual void resolveFootnote(Stream & rStream,
169 const Id & rNoteType,
170 const rtl::OUString & rNoteId) = 0;
172 Resolves an endnote to a stream handler.
174 An endnote is resolved if either the note type or
175 note id matches.
177 @param rStream stream handler to resolve to
178 @param rNoteType type of footnote to resolve
179 @param rNoteId id of the endnote to resolve
181 virtual void resolveEndnote(Stream & rStream,
182 const Id & rNoteType,
183 const rtl::OUString & rNoteId) = 0;
186 Resolves a comment to a stream handler.
188 @param rStream stream handler to resolve to
189 @param rComment id of the comment to resolve
191 virtual void resolveComment(Stream & rStream,
192 const rtl::OUString & rCommentId) = 0;
195 Resolves a picture to a stream handler.
197 @param rStream stream handler to resolve to
198 @param rPictureId id of the picture to resolve
200 virtual void resolvePicture(Stream & rStream,
201 const rtl::OUString & rPictureId) = 0;
204 Resolves a header to a stream handler.
206 @param rStream stream handler to resolve to
207 @param type type of header to resolve:
208 NS_ooxml::LN_Value_ST_HrdFtr_even header on even page
209 NS_ooxml::LN_Value_ST_HrdFtr_default header on right page
210 NS_ooxml::LN_Value_ST_HrdFtr_first header on first page
212 @param rId id of the header
214 virtual void resolveHeader(Stream & rStream,
215 const sal_Int32 type,
216 const rtl::OUString & rId) = 0;
219 Resolves a footer to a stream handler.
221 @param rStream stream handler to resolve to
222 @param type type of footer to resolve:
223 NS_ooxml::LN_Value_ST_HrdFtr_even header on even page
224 NS_ooxml::LN_Value_ST_HrdFtr_default header on right page
225 NS_ooxml::LN_Value_ST_HrdFtr_first header on first page
227 @param rId id of the header
229 virtual void resolveFooter(Stream & rStream,
230 const sal_Int32 type,
231 const rtl::OUString & rId) = 0;
235 Returns target URL from relationships for a given id.
237 @param rId the id to look for
239 @return the URL found or an empty string
241 virtual ::rtl::OUString getTargetForId(const ::rtl::OUString & rId) = 0;
243 virtual void setModel(uno::Reference<frame::XModel> xModel) = 0;
244 virtual uno::Reference<frame::XModel> getModel() = 0;
245 virtual void setDrawPage(uno::Reference<drawing::XDrawPage> xDrawPage) = 0;
246 virtual uno::Reference<drawing::XDrawPage> getDrawPage() = 0;
247 virtual uno::Reference<io::XInputStream> getInputStream() = 0;
248 virtual uno::Reference<io::XInputStream> getStorageStream() = 0;
249 virtual uno::Reference<io::XInputStream> getInputStreamForId
250 (const ::rtl::OUString & rId) = 0;
251 virtual void setXNoteId(const rtl::OUString & rId) = 0;
252 virtual const ::rtl::OUString & getXNoteId() const = 0;
253 virtual void setXNoteType(const Id & nId) = 0;
254 virtual const Id & getXNoteType() const = 0;
255 virtual const ::rtl::OUString & getTarget() const = 0;
259 class WRITERFILTER_DLLPUBLIC OOXMLDocumentFactory
261 public:
262 static OOXMLStream::Pointer_t
263 createStream(uno::Reference<uno::XComponentContext> rContext,
264 uno::Reference<io::XInputStream> rStream,
265 OOXMLStream::StreamType_t nStreamType = OOXMLStream::DOCUMENT);
267 static OOXMLStream::Pointer_t
268 createStream(OOXMLStream::Pointer_t pStream,
269 OOXMLStream::StreamType_t nStreamType = OOXMLStream::DOCUMENT);
271 static OOXMLStream::Pointer_t
272 createStream(OOXMLStream::Pointer_t pStream, const rtl::OUString & rId);
274 static OOXMLDocument *
275 createDocument(OOXMLStream::Pointer_t pStream);
279 void ooxmlidsToXML(::std::iostream & out);
282 #endif // INCLUDED_OOXML_DOCUMENT_HXX