update credits
[LibreOffice.git] / writerfilter / inc / doctok / WW8Document.hxx
blobb624ce710dc268d69651bce2d31a8e4ff0fcbeff
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_WW8_DOCUMENT_HXX
21 #define INCLUDED_WW8_DOCUMENT_HXX
23 #include <boost/shared_ptr.hpp>
24 #include <sal/types.h>
25 #include <com/sun/star/uno/Reference.hxx>
26 #include <resourcemodel/SubSequence.hxx>
27 #include <com/sun/star/io/XInputStream.hpp>
28 #include <com/sun/star/uno/XComponentContext.hpp>
30 #include <resourcemodel/WW8ResourceModel.hxx>
31 #include <resourcemodel/OutputWithDepth.hxx>
33 #include <WriterFilterDllApi.hxx>
35 namespace writerfilter {
36 namespace doctok {
38 using namespace ::com::sun::star;
40 /**
41 A stream containing a WW8 document.
43 The content of the stream is a sequence of unsigned bytes. The
44 stream consists of substreams that are identified by string
45 identifiers.
47 class WRITERFILTER_DOCTOK_DLLPUBLIC WW8Stream
49 public:
50 /**
51 Pointer to a WW8Stream.
53 typedef boost::shared_ptr<WW8Stream> Pointer_t;
55 /**
56 Type for the content of the stream
58 typedef SubSequence<sal_uInt8> Sequence;
60 virtual ~WW8Stream();
62 /**
63 Returns pointer to a substream.
65 @param rSid identifier of substream to return
67 @return the substream
69 virtual Pointer_t getSubStream(const OUString & rSid) = 0;
71 /**
72 Return a continious part of the stream.
74 @param nOffset offset in the stream where the part starts
75 @param nCount length of the part (number of bytes)
77 @return sequence of unsigned bytes
79 virtual Sequence get(sal_uInt32 nOffset, sal_uInt32 nCount)
80 const = 0;
82 // Returns the names of substreams contained in the stream
83 virtual string getSubStreamNames() const = 0;
85 virtual uno::Sequence<OUString> getSubStreamUNames() const = 0;
87 /**
88 Dumps content of stream to output.
90 @param o the target output
92 virtual void dump(OutputWithDepth<string> & o) const = 0;
94 //virtual bool put(sal_uInt32 nOffset, const Sequence & rSeq) = 0;
97 /**
98 A property.
101 class WRITERFILTER_DOCTOK_DLLPUBLIC WW8Property
103 public:
105 Ponter to a property.
107 typedef boost::shared_ptr<WW8Property> Pointer_t;
109 virtual ~WW8Property();
111 virtual sal_uInt32 getId() const = 0;
112 virtual sal_uInt32 getParam() const = 0;
113 virtual WW8Stream::Sequence getParams() const = 0;
115 virtual string toString() const = 0;
118 Dumps this object to an output.
121 virtual void dump(OutputWithDepth<string> & o) const = 0;
125 An iterator for traversal of a set of properties.
127 Sample code for use of iterator:
129 \code
130 Return_t function(WW8PropertySet::tPointer pSet)
132 do_something;
134 WW8PropertySetIterator::tPointer pIt = pSet->begin();
135 WW8PropertySetIterator::tPointer pItEnd = pSet->end();
137 while ((*pIt) != (*pItEnd))
139 do_something();
141 ++(*pIt);
144 do_something;
146 \endcode
148 class WRITERFILTER_DOCTOK_DLLPUBLIC WW8PropertySetIterator
150 public:
151 typedef boost::shared_ptr<WW8PropertySetIterator> Pointer_t;
153 virtual ~WW8PropertySetIterator();
156 Advance iterator to the next property.
158 virtual WW8PropertySetIterator & operator++() = 0;
161 Returns a pointer to the property the iterator references.
163 virtual WW8Property::Pointer_t get() const = 0;
166 Checks if the iterator is equal to another one.
168 virtual bool equal(const WW8PropertySetIterator & rIt) const = 0;
171 Returns string representation of iterator.
173 virtual string toString() const = 0;
177 Checks if two property set iterators are not equal.
179 bool operator != (const WW8PropertySetIterator & rA,
180 const WW8PropertySetIterator & rB);
183 A set of properties.
185 class WRITERFILTER_DOCTOK_DLLPUBLIC WW8PropertySet
187 public:
188 typedef boost::shared_ptr<WW8PropertySet> Pointer_t;
190 virtual ~WW8PropertySet();
193 Returns iterator to the start of the set.
195 virtual WW8PropertySetIterator::Pointer_t begin() = 0;
198 Returns iterator to the end of the set.
200 virtual WW8PropertySetIterator::Pointer_t end() = 0;
203 Dumps property set to output stream.
205 @param o output stream to dump property set to
207 virtual void dump(OutputWithDepth<string> & o) const = 0;
210 Iterate through property set and for each element dump a dot
211 output stream.
213 @param o output stream to dump dots to
215 virtual void dots(ostream & o) = 0;
217 virtual bool isPap() const = 0;
218 virtual sal_uInt32 get_istd() const = 0;
221 Insert another property set into this property set.
223 @param pSet the set to insert
225 virtual void insert(const WW8PropertySet::Pointer_t pSet) = 0;
228 enum PropertyType {
229 /** Auxiliary type for character positions defined in piece table */
230 PROP_DOC,
232 /** properties are section properies */
233 PROP_SEC,
235 /** properties are paragraph properties */
236 PROP_PAP,
238 /** properties are character properties */
239 PROP_CHP,
241 /** a footnote reference */
242 PROP_FOOTNOTE,
244 /** an endnote reference */
245 PROP_ENDNOTE,
247 /** an annotaion reference */
248 PROP_ANNOTATION,
250 /** the start of a bookmark */
251 PROP_BOOKMARKSTART,
253 /** the end of a bookmark */
254 PROP_BOOKMARKEND,
256 /** a field character (start, separator or end) */
257 PROP_FLD,
259 /** a shape character */
260 PROP_SHP,
262 /** a break character */
263 PROP_BRK
267 An iterator for traversal of the character positions of a Word
268 document.
270 The use of the iterator is analogous to WW8PropertySetIterator.
272 class WRITERFILTER_DOCTOK_DLLPUBLIC WW8DocumentIterator
274 public:
275 typedef boost::shared_ptr<WW8DocumentIterator> Pointer_t;
277 virtual ~WW8DocumentIterator();
280 Advance iterator to next character position of the document.
282 virtual WW8DocumentIterator & operator++() = 0;
285 Recedes iterator to previous character postion of the document.
287 virtual WW8DocumentIterator & operator--() = 0;
290 Returns properties set at the character position the iterator
291 points to.
293 @return pointer to set of properties
295 virtual writerfilter::Reference<Properties>::Pointer_t getProperties()
296 const = 0;
298 virtual writerfilter::Reference<Stream>::Pointer_t getSubDocument()
299 const = 0;
302 Returns text run at the character position the iterator points
305 virtual WW8Stream::Sequence getText() = 0;
308 Return pointer to the shape at character position the iterator
309 is pointing to.
311 virtual writerfilter::Reference<Properties>::Pointer_t getShape() const = 0;
314 Checks if the characters of the entity the iterator points to
315 are complex.
317 Complex characters in a Word document are byte size
318 characters. Non-complex characters are word size characters.
320 @retval true The characters are complex.
321 @retval false The characters are non-complex.
323 virtual bool isComplex() const = 0;
326 Returns the property type of the entity the iterator points to.
328 virtual PropertyType getPropertyType() const = 0;
331 Checks is the iterator is equal to another one.
333 @param rIt iterator to check against
335 @retval true the iterators are equal
336 @retval false else
338 virtual bool equal(const WW8DocumentIterator & rIt) const = 0;
341 Returns string representation of the iterator.
343 virtual string toString() const = 0;
346 Dumps the iterator to an output stream.
348 @param o the output stream to dump the iterator to
350 virtual void dump(ostream & o) const = 0;
354 Checks if two document iterators are equal.
356 @param rA first iterator
357 @param rB second iterator
359 @retval true the document iterators are equal
360 @retval false else
362 bool operator == (const WW8DocumentIterator & rA,
363 const WW8DocumentIterator & rB);
365 class SubDocumentId
367 public:
368 enum eType { FOOTNOTES, HEADERS, FOOTERS };
370 private:
371 eType mnType;
372 sal_uInt8 mnIndex;
374 public:
375 SubDocumentId(eType nType, sal_uInt8 nIndex)
376 : mnType(nType), mnIndex(nIndex)
380 eType getType() const { return mnType; }
381 sal_uInt8 getIndex() const { return mnIndex; }
385 A Word 8 document.
387 class WRITERFILTER_DOCTOK_DLLPUBLIC WW8Document :
388 public writerfilter::Reference<Stream>
390 public:
391 typedef boost::shared_ptr<WW8Document> Pointer_t;
393 virtual ~WW8Document();
396 Get a subdocument.
398 A subdocument can be
400 - a header
401 - a footer
402 - a footnode
404 @param nId identifier of the subdocumen
406 virtual Pointer_t getSubDocument(SubDocumentId nId) = 0;
409 Returns iterator to beginning of document.
411 virtual WW8DocumentIterator::Pointer_t begin() = 0;
414 Returns iterator to end of document.
416 virtual WW8DocumentIterator::Pointer_t end() = 0;
419 class WRITERFILTER_DOCTOK_DLLPUBLIC WW8DocumentFactory
421 public:
422 static WW8Stream::Pointer_t
423 createStream(uno::Reference<uno::XComponentContext> rContext,
424 uno::Reference<io::XInputStream> rStream);
426 static WW8Document *
427 createDocument(WW8Stream::Pointer_t rpStream);
432 #endif // INCLUDED_WW8_DOCUMENT_HXX
434 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */