merge the formfield patch from ooo-build
[ooovba.git] / writerfilter / inc / doctok / WW8Document.hxx
blobe6c616ec23b5d602324b83e2abca69ec9a654001
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: WW8Document.hxx,v $
10 * $Revision: 1.8 $
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 ************************************************************************/
31 #ifndef INCLUDED_WW8_DOCUMENT_HXX
32 #define INCLUDED_WW8_DOCUMENT_HXX
34 #include <boost/shared_ptr.hpp>
35 #include <sal/types.h>
36 #include <com/sun/star/uno/Reference.hxx>
37 #include <resourcemodel/SubSequence.hxx>
38 #include <com/sun/star/io/XInputStream.hpp>
39 #ifndef _COM_SUN_STAR_UNO_XCOMPONENTCONTEX_HPP_
40 #include <com/sun/star/uno/XComponentContext.hpp>
41 #endif
43 #ifndef INCLUDED_WW8_RESOURCE_MODEL_HXX
44 #include <resourcemodel/WW8ResourceModel.hxx>
45 #endif
46 #include <resourcemodel/OutputWithDepth.hxx>
48 #include <WriterFilterDllApi.hxx>
50 namespace writerfilter {
51 namespace doctok {
53 using namespace ::com::sun::star;
55 /**
56 A stream containing a WW8 document.
58 The content of the stream is a sequence of unsigned bytes. The
59 stream consists of substreams that are identified by string
60 identifiers.
62 class WRITERFILTER_DLLPUBLIC WW8Stream
64 public:
65 /**
66 Pointer to a WW8Stream.
68 typedef boost::shared_ptr<WW8Stream> Pointer_t;
70 /**
71 Type for the content of the stream
73 typedef SubSequence<sal_uInt8> Sequence;
75 virtual ~WW8Stream();
77 /**
78 Returns pointer to a substream.
80 @param rSid identifier of substream to return
82 @return the substream
84 virtual Pointer_t getSubStream(const ::rtl::OUString & rSid) = 0;
86 /**
87 Return a continious part of the stream.
89 @param nOffset offset in the stream where the part starts
90 @param nCount length of the part (number of bytes)
92 @return sequence of unsigned bytes
94 virtual Sequence get(sal_uInt32 nOffset, sal_uInt32 nCount)
95 const = 0;
97 // Returns the names of substreams contained in the stream
98 virtual string getSubStreamNames() const = 0;
100 virtual uno::Sequence<rtl::OUString> getSubStreamUNames() const = 0;
103 Dumps content of stream to output.
105 @param o the target output
107 virtual void dump(OutputWithDepth<string> & o) const = 0;
109 //virtual bool put(sal_uInt32 nOffset, const Sequence & rSeq) = 0;
113 A property.
116 class WRITERFILTER_DLLPUBLIC WW8Property
118 public:
120 Ponter to a property.
122 typedef boost::shared_ptr<WW8Property> Pointer_t;
124 virtual ~WW8Property();
126 virtual sal_uInt32 getId() const = 0;
127 virtual sal_uInt32 getParam() const = 0;
128 virtual WW8Stream::Sequence getParams() const = 0;
130 virtual string toString() const = 0;
133 Dumps this object to an output.
136 virtual void dump(OutputWithDepth<string> & o) const = 0;
140 An iterator for traversal of a set of properties.
142 Sample code for use of iterator:
144 \code
145 Return_t function(WW8PropertySet::tPointer pSet)
147 do_something;
149 WW8PropertySetIterator::tPointer pIt = pSet->begin();
150 WW8PropertySetIterator::tPointer pItEnd = pSet->end();
152 while ((*pIt) != (*pItEnd))
154 do_something();
156 ++(*pIt);
159 do_something;
161 \endcode
163 class WRITERFILTER_DLLPUBLIC WW8PropertySetIterator
165 public:
166 typedef boost::shared_ptr<WW8PropertySetIterator> Pointer_t;
168 virtual ~WW8PropertySetIterator();
171 Advance iterator to the next property.
173 virtual WW8PropertySetIterator & operator++() = 0;
176 Returns a pointer to the property the iterator references.
178 virtual WW8Property::Pointer_t get() const = 0;
181 Checks if the iterator is equal to another one.
183 virtual bool equal(const WW8PropertySetIterator & rIt) const = 0;
186 Returns string representation of iterator.
188 virtual string toString() const = 0;
192 Checks if two property set iterators are not equal.
194 bool operator != (const WW8PropertySetIterator & rA,
195 const WW8PropertySetIterator & rB);
198 A set of properties.
200 class WRITERFILTER_DLLPUBLIC WW8PropertySet
202 public:
203 typedef boost::shared_ptr<WW8PropertySet> Pointer_t;
205 virtual ~WW8PropertySet();
208 Returns iterator to the start of the set.
210 virtual WW8PropertySetIterator::Pointer_t begin() = 0;
213 Returns iterator to the end of the set.
215 virtual WW8PropertySetIterator::Pointer_t end() = 0;
218 Dumps property set to output stream.
220 @param o output stream to dump property set to
222 virtual void dump(OutputWithDepth<string> & o) const = 0;
225 Iterate through property set and for each element dump a dot
226 output stream.
228 @param o output stream to dump dots to
230 virtual void dots(ostream & o) = 0;
232 virtual bool isPap() const = 0;
233 virtual sal_uInt32 get_istd() const = 0;
236 Insert another property set into this property set.
238 @param pSet the set to insert
240 virtual void insert(const WW8PropertySet::Pointer_t pSet) = 0;
243 enum PropertyType {
244 /** Auxiliary type for character positions defined in piece table */
245 PROP_DOC,
247 /** properties are section properies */
248 PROP_SEC,
250 /** properties are paragraph properties */
251 PROP_PAP,
253 /** properties are character properties */
254 PROP_CHP,
256 /** a footnote reference */
257 PROP_FOOTNOTE,
259 /** an endnote reference */
260 PROP_ENDNOTE,
262 /** an annotaion reference */
263 PROP_ANNOTATION,
265 /** the start of a bookmark */
266 PROP_BOOKMARKSTART,
268 /** the end of a bookmark */
269 PROP_BOOKMARKEND,
271 /** a field character (start, separator or end) */
272 PROP_FLD,
274 /** a shape character */
275 PROP_SHP,
277 /** a break character */
278 PROP_BRK
282 An iterator for traversal of the character positions of a Word
283 document.
285 The use of the iterator is analogous to WW8PropertySetIterator.
287 class WRITERFILTER_DLLPUBLIC WW8DocumentIterator
289 public:
290 typedef boost::shared_ptr<WW8DocumentIterator> Pointer_t;
292 virtual ~WW8DocumentIterator();
295 Advance iterator to next character position of the document.
297 virtual WW8DocumentIterator & operator++() = 0;
300 Recedes iterator to previous character postion of the document.
302 virtual WW8DocumentIterator & operator--() = 0;
305 Returns properties set at the character position the iterator
306 points to.
308 @return pointer to set of properties
310 virtual writerfilter::Reference<Properties>::Pointer_t getProperties()
311 const = 0;
313 virtual writerfilter::Reference<Stream>::Pointer_t getSubDocument()
314 const = 0;
317 Returns text run at the character position the iterator points
320 virtual WW8Stream::Sequence getText() = 0;
323 Return pointer to the shape at character position the iterator
324 is pointing to.
326 virtual writerfilter::Reference<Properties>::Pointer_t getShape() const = 0;
329 Checks if the characters of the entity the iterator points to
330 are complex.
332 Complex characters in a Word document are byte size
333 characters. Non-complex characters are word size characters.
335 @retval true The characters are complex.
336 @retval false The characters are non-complex.
338 virtual bool isComplex() const = 0;
341 Returns the property type of the entity the iterator points to.
343 virtual PropertyType getPropertyType() const = 0;
346 Checks is the iterator is equal to another one.
348 @param rIt iterator to check against
350 @retval true the iterators are equal
351 @retval false else
353 virtual bool equal(const WW8DocumentIterator & rIt) const = 0;
356 Returns string representation of the iterator.
358 virtual string toString() const = 0;
361 Dumps the iterator to an output stream.
363 @param o the output stream to dump the iterator to
365 virtual void dump(ostream & o) const = 0;
369 Checks if two document iterators are equal.
371 @param rA first iterator
372 @param rB second iterator
374 @retval true the document iterators are equal
375 @retval false else
377 bool operator == (const WW8DocumentIterator & rA,
378 const WW8DocumentIterator & rB);
380 class WRITERFILTER_DLLPUBLIC SubDocumentId
382 public:
383 enum eType { FOOTNOTES, HEADERS, FOOTERS };
385 private:
386 eType mnType;
387 sal_uInt8 mnIndex;
389 public:
390 SubDocumentId(eType nType, sal_uInt8 nIndex)
391 : mnType(nType), mnIndex(nIndex)
395 eType getType() const { return mnType; }
396 sal_uInt8 getIndex() const { return mnIndex; }
400 A Word 8 document.
402 class WRITERFILTER_DLLPUBLIC WW8Document :
403 public writerfilter::Reference<Stream>
405 public:
406 typedef boost::shared_ptr<WW8Document> Pointer_t;
408 virtual ~WW8Document();
411 Get a subdocument.
413 A subdocument can be
415 - a header
416 - a footer
417 - a footnode
419 @param nId identifier of the subdocumen
421 virtual Pointer_t getSubDocument(SubDocumentId nId) = 0;
424 Returns iterator to beginning of document.
426 virtual WW8DocumentIterator::Pointer_t begin() = 0;
429 Returns iterator to end of document.
431 virtual WW8DocumentIterator::Pointer_t end() = 0;
434 class WRITERFILTER_DLLPUBLIC WW8DocumentFactory
436 public:
437 static WW8Stream::Pointer_t
438 createStream(uno::Reference<uno::XComponentContext> rContext,
439 uno::Reference<io::XInputStream> rStream);
441 static WW8Document *
442 createDocument(WW8Stream::Pointer_t rpStream);
445 void sprmidsToXML(::std::iostream & out);
447 void doctokidsToXML(::std::iostream & out);
451 #endif // INCLUDED_WW8_DOCUMENT_HXX