fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / writerfilter / inc / resourcemodel / WW8ResourceModel.hxx
blob886d2f637ea986b2f17acc136c82e633cb37914c
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_WW8RESOURCEMODEL_HXX
21 #define INCLUDED_WW8RESOURCEMODEL_HXX
23 #include <string>
24 #include <memory>
25 #include <boost/shared_ptr.hpp>
26 #include <sal/types.h>
27 #include <com/sun/star/drawing/XShape.hpp>
28 #include <com/sun/star/uno/Any.hxx>
29 #include <WriterFilterDllApi.hxx>
30 #include <resourcemodel/OutputWithDepth.hxx>
31 /**
32 @file WW8ResourceModel.hxx
34 The classes in this file define the interfaces for the resource
35 model of the DocTokenizer:
37 @image html doctok.png
39 A resource is a set of events that describe an object. A resource
40 is only an abstract concept. It is not instanciated to a class.
42 A reference to a resource represents the object that the resource
43 describes. The reference can be resolved thereby generating the
44 events of the resource.
46 A handler receives the events generated by resolving a
47 reference. There are several types of handlers each accepting their
48 specific set of events.
50 References always have a parameter determining the kind of handler
51 they send the events they generate to. The set of events generated
52 by resolving the reference is a subset of the events received by
53 the handler.
57 typedef sal_uInt32 Id;
59 namespace writerfilter {
60 using namespace ::com::sun::star;
61 using namespace ::std;
63 /**
64 Reference to an resource that generates events and sends them to a
65 handler.
67 The reference can be resolved, i.e. the resource generates its
68 events. The events must be suitable for the handler type given by
69 the template parameter.
71 @attention The parameter of the template does not determine the
72 type of the reference's target. It determines the type of the handler!
74 Example:
76 A Word document can be represented as a stream of events. Event
77 types in a Word document are text, properties, tables, starts and
78 ends of groups. These can be handled by a stream handler (@see
79 Stream). Thus a reference to a Word document is resolved by
80 sending these events to a stream handler.
83 template <class T>
84 class SAL_DLLPUBLIC_TEMPLATE Reference
86 public:
87 /**
88 Pointer to reference
90 @attention The ownership of a reference is transfered when
91 the reference is passed.
93 typedef boost::shared_ptr< Reference<T> > Pointer_t;
95 /**
96 Resolves the reference.
98 The events of the references target resource are generated and
99 send to a handler.
101 @param rHandler handler which receives the events
103 virtual void resolve(T & rHandler) = 0;
106 Returns the type of the reference aka the name of the access class.
108 virtual string getType() const = 0;
110 protected:
111 ~Reference() {}
114 class Value;
115 class Sprm;
118 Handler for properties.
120 class WRITERFILTER_RESOURCEMODEL_DLLPUBLIC Properties
122 public:
124 Receives an attribute.
126 @param name name of the attribute
127 @param val value of the attribute
129 virtual void attribute(Id name, Value & val) = 0;
132 Receives a SPRM.
134 @param sprm the SPRM received
136 virtual void sprm(Sprm & sprm) = 0;
138 protected:
139 ~Properties() {}
143 Handler for tables.
145 class WRITERFILTER_RESOURCEMODEL_DLLPUBLIC Table
147 public:
148 typedef boost::shared_ptr<Table> Pointer_t;
151 Receives an entry of the table.
153 @param pos position of the entry in the table
154 @param ref reference to properties of the entry
156 virtual void entry(int pos, writerfilter::Reference<Properties>::Pointer_t ref) = 0;
158 protected:
159 ~Table() {}
163 Handler for binary objects.
165 class WRITERFILTER_RESOURCEMODEL_DLLPUBLIC BinaryObj
167 public:
169 Receives binary data of the object.
171 @param buf pointer to buffer containing the data
172 @param len size of buffer
173 @param ref reference to properties of binary object
175 virtual void data(const sal_uInt8* buf, size_t len,
176 writerfilter::Reference<Properties>::Pointer_t ref) = 0;
178 protected:
179 ~BinaryObj() {}
183 Handler for a stream.
185 class WRITERFILTER_RESOURCEMODEL_DLLPUBLIC Stream
187 public:
190 Pointer to this stream.
192 typedef boost::shared_ptr<Stream> Pointer_t;
195 Receives start mark for group with the same section properties.
197 virtual void startSectionGroup() = 0;
200 Receives end mark for group with the same section properties.
202 virtual void endSectionGroup() = 0;
205 Receives start mark for group with the same paragraph properties.
207 virtual void startParagraphGroup() = 0;
210 Receives end mark for group with the same paragraph properties.
212 virtual void endParagraphGroup() = 0;
214 virtual void markLastParagraphInSection( ) { };
217 Receives start mark for group with the same character properties.
219 virtual void startCharacterGroup() = 0;
222 Receives end mark for group with the same character properties.
224 virtual void endCharacterGroup() = 0;
227 Receives a shape.
229 virtual void startShape( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape ) = 0;
231 virtual void endShape( ) = 0;
234 Receives 8-bit per character text.
236 @param data buffer containing the text
237 @param len number of characters in the text
239 virtual void text(const sal_uInt8 * data, size_t len) = 0;
242 Receives 16-bit per character text.
244 @param data buffer containing the text
245 @param len number of characters in the text.
247 virtual void utext(const sal_uInt8 * data, size_t len) = 0;
250 Receives properties of the current run of text.
252 @param ref reference to the properties
254 virtual void props(writerfilter::Reference<Properties>::Pointer_t ref) = 0;
257 Receives table.
259 @param name name of the table
260 @param ref referecne to the table
262 virtual void table(Id name,
263 writerfilter::Reference<Table>::Pointer_t ref) = 0;
266 Receives a substream.
268 @param name name of the substream
269 @param ref reference to the substream
271 virtual void substream(Id name,
272 writerfilter::Reference<Stream>::Pointer_t ref) = 0;
276 Debugging: Receives information about current point in stream.
278 @param info the information
280 virtual void info(const string & info) = 0;
282 protected:
283 ~Stream() {}
287 A value.
289 The methods of this class may throw exceptions if a certain aspect
290 makes no sense for a certain value, e.g. the integer value of a
291 string.
293 class WRITERFILTER_RESOURCEMODEL_DLLPUBLIC Value
295 public:
297 Pointer to a value.
299 SAL_WNODEPRECATED_DECLARATIONS_PUSH
300 typedef auto_ptr<Value> Pointer_t;
301 SAL_WNODEPRECATED_DECLARATIONS_POP
303 virtual ~Value() {}
306 Returns integer representation of the value.
308 virtual int getInt() const = 0;
311 Returns string representation of the value.
313 virtual OUString getString() const = 0;
316 Returns representation of the value as uno::Any.
318 virtual uno::Any getAny() const = 0;
321 Returns properties of this value.
323 virtual writerfilter::Reference<Properties>::Pointer_t getProperties() = 0;
326 Returns stream of this value.
328 virtual writerfilter::Reference<Stream>::Pointer_t getStream() = 0;
331 Returns binary object of this value.
333 virtual writerfilter::Reference<BinaryObj>::Pointer_t getBinary() = 0;
336 Returns string representation of this value.
338 virtual string toString() const = 0;
342 An SPRM.
345 class WRITERFILTER_RESOURCEMODEL_DLLPUBLIC Sprm
347 public:
348 SAL_WNODEPRECATED_DECLARATIONS_PUSH
349 typedef auto_ptr<Sprm> Pointer_t;
350 SAL_WNODEPRECATED_DECLARATIONS_POP
351 enum Kind { UNKNOWN, CHARACTER, PARAGRAPH, TABLE };
354 Returns id of the SPRM.
356 virtual sal_uInt32 getId() const = 0;
359 Returns value of the SPRM.
361 virtual Value::Pointer_t getValue() = 0;
364 Returns reference to binary object contained in the SPRM.
366 virtual writerfilter::Reference<BinaryObj>::Pointer_t getBinary() = 0;
369 Returns reference to stream associated with the SPRM.
371 virtual writerfilter::Reference<Stream>::Pointer_t getStream() = 0;
374 Returns reference to properties contained in the SPRM.
377 virtual writerfilter::Reference<Properties>::Pointer_t getProps() = 0;
380 Returns the kind of this SPRM.
382 virtual Kind getKind() = 0;
385 Returns name of sprm.
387 virtual string getName() const = 0;
390 Returns string repesentation of sprm.
392 virtual string toString() const = 0;
394 protected:
395 ~Sprm() {}
399 Creates handler for a stream.
401 void WRITERFILTER_RESOURCEMODEL_DLLPUBLIC dump(OutputWithDepth<string> & o, const char * name, writerfilter::Reference<Properties>::Pointer_t props);
402 void WRITERFILTER_RESOURCEMODEL_DLLPUBLIC dump(OutputWithDepth<string> & o, const char * name, sal_uInt32 n);
403 void WRITERFILTER_RESOURCEMODEL_DLLPUBLIC dump(OutputWithDepth<string> & /*o*/, const char * /*name*/,
404 const OUString & /*str*/);
405 void WRITERFILTER_RESOURCEMODEL_DLLPUBLIC dump(OutputWithDepth<string> & o, const char * name, writerfilter::Reference<BinaryObj>::Pointer_t binary);
409 #endif // INCLUDED_WW8RESOURCEMODEL_HXX
411 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */