LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/writerfilter/inc/resourcemodel - WW8ResourceModel.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 14 15 93.3 %
Date: 2013-07-09 Functions: 21 28 75.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       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/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      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 .
      18             :  */
      19             : 
      20             : #ifndef INCLUDED_WW8RESOURCEMODEL_HXX
      21             : #define INCLUDED_WW8RESOURCEMODEL_HXX
      22             : 
      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
      33             : 
      34             :    The classes in this file define the interfaces for the resource
      35             :    model of the DocTokenizer:
      36             : 
      37             :    @image html doctok.png
      38             : 
      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.
      41             : 
      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.
      45             : 
      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.
      49             : 
      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.
      54             : */
      55             : 
      56             : 
      57             : typedef sal_uInt32 Id;
      58             : 
      59             : namespace writerfilter {
      60             : using namespace ::com::sun::star;
      61             : using namespace ::std;
      62             : 
      63             : /**
      64             :     Reference to an resource that generates events and sends them to a
      65             :     handler.
      66             : 
      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.
      70             : 
      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!
      73             : 
      74             :     Example:
      75             : 
      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.
      81             : */
      82             : 
      83             : template <class T>
      84       75805 : class SAL_DLLPUBLIC_TEMPLATE Reference
      85             : {
      86             : public:
      87             :     /**
      88             :         Pointer to reference
      89             : 
      90             :         @attention The ownership of a reference is transfered when
      91             :         the reference is passed.
      92             :     */
      93             :     typedef boost::shared_ptr< Reference<T> > Pointer_t;
      94             : 
      95             :     /**
      96             :        Resolves the reference.
      97             : 
      98             :        The events of the references target resource are generated and
      99             :        send to a handler.
     100             : 
     101             :        @param rHandler         handler which receives the events
     102             :      */
     103             :     virtual void resolve(T & rHandler) = 0;
     104             : 
     105             :     /**
     106             :        Returns the type of the reference aka the name of the access class.
     107             :      */
     108             :     virtual string getType() const = 0;
     109             : 
     110             : protected:
     111       75805 :     ~Reference() {}
     112             : };
     113             : 
     114             : class Value;
     115             : class Sprm;
     116             : 
     117             : /**
     118             :    Handler for properties.
     119             :  */
     120        4398 : class WRITERFILTER_RESOURCEMODEL_DLLPUBLIC Properties
     121             : {
     122             : public:
     123             :     /**
     124             :        Receives an attribute.
     125             : 
     126             :        @param name     name of the attribute
     127             :        @param val      value of the attribute
     128             :      */
     129             :     virtual void attribute(Id name, Value & val) = 0;
     130             : 
     131             :     /**
     132             :        Receives a SPRM.
     133             : 
     134             :        @param  sprm      the SPRM received
     135             :     */
     136             :     virtual void sprm(Sprm & sprm) = 0;
     137             : 
     138             : protected:
     139        4398 :     ~Properties() {}
     140             : };
     141             : 
     142             : /**
     143             :    Handler for tables.
     144             :  */
     145        1489 : class WRITERFILTER_RESOURCEMODEL_DLLPUBLIC Table
     146             : {
     147             : public:
     148             :     typedef boost::shared_ptr<Table> Pointer_t;
     149             : 
     150             :     /**
     151             :        Receives an entry of the table.
     152             : 
     153             :        @param pos     position of the entry in the table
     154             :        @param ref     reference to properties of the entry
     155             :      */
     156             :     virtual void entry(int pos, writerfilter::Reference<Properties>::Pointer_t ref) = 0;
     157             : 
     158             : protected:
     159        1489 :     ~Table() {}
     160             : };
     161             : 
     162             : /**
     163             :    Handler for binary objects.
     164             :  */
     165         385 : class WRITERFILTER_RESOURCEMODEL_DLLPUBLIC BinaryObj
     166             : {
     167             : public:
     168             :     /**
     169             :        Receives binary data of the object.
     170             : 
     171             :        @param buf     pointer to buffer containing the data
     172             :        @param len     size of buffer
     173             :        @param ref     reference to properties of binary object
     174             :      */
     175             :     virtual void data(const sal_uInt8* buf, size_t len,
     176             :                       writerfilter::Reference<Properties>::Pointer_t ref) = 0;
     177             : 
     178             : protected:
     179         385 :     ~BinaryObj() {}
     180             : };
     181             : 
     182             : /**
     183             :    Handler for a stream.
     184             :  */
     185         659 : class WRITERFILTER_RESOURCEMODEL_DLLPUBLIC Stream
     186             : {
     187             : public:
     188             : 
     189             :     /**
     190             :        Pointer to this stream.
     191             :      */
     192             :     typedef boost::shared_ptr<Stream> Pointer_t;
     193             : 
     194             :     /**
     195             :        Receives start mark for group with the same section properties.
     196             :      */
     197             :     virtual void startSectionGroup() = 0;
     198             : 
     199             :     /**
     200             :        Receives end mark for group with the same section properties.
     201             :     */
     202             :     virtual void endSectionGroup() = 0;
     203             : 
     204             :     /**
     205             :        Receives start mark for group with the same paragraph properties.
     206             :      */
     207             :     virtual void startParagraphGroup() = 0;
     208             : 
     209             :     /**
     210             :        Receives end mark for group with the same paragraph properties.
     211             :      */
     212             :     virtual void endParagraphGroup() = 0;
     213             : 
     214           0 :     virtual void markLastParagraphInSection( ) { };
     215             : 
     216             :     /**
     217             :        Receives start mark for group with the same character properties.
     218             :      */
     219             :     virtual void startCharacterGroup() = 0;
     220             : 
     221             :     /**
     222             :        Receives end mark for group with the same character properties.
     223             :      */
     224             :     virtual void endCharacterGroup() = 0;
     225             : 
     226             :     /**
     227             :       Receives a shape.
     228             :      */
     229             :     virtual void startShape( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape ) = 0;
     230             : 
     231             :     virtual void endShape( ) = 0;
     232             : 
     233             :     /**
     234             :        Receives 8-bit per character text.
     235             : 
     236             :        @param data  buffer containing the text
     237             :        @param len   number of characters in the text
     238             :      */
     239             :     virtual void text(const sal_uInt8 * data, size_t len) = 0;
     240             : 
     241             :     /**
     242             :        Receives 16-bit per character text.
     243             : 
     244             :        @param data    buffer containing the text
     245             :        @param len     number of characters in the text.
     246             :      */
     247             :     virtual void utext(const sal_uInt8 * data, size_t len) = 0;
     248             : 
     249             :     /**
     250             :        Receives properties of the current run of text.
     251             : 
     252             :        @param ref    reference to the properties
     253             :      */
     254             :     virtual void props(writerfilter::Reference<Properties>::Pointer_t ref) = 0;
     255             : 
     256             :     /**
     257             :        Receives table.
     258             : 
     259             :        @param name     name of the table
     260             :        @param ref      referecne to the table
     261             :      */
     262             :     virtual void table(Id name,
     263             :                        writerfilter::Reference<Table>::Pointer_t ref) = 0;
     264             : 
     265             :     /**
     266             :         Receives a substream.
     267             : 
     268             :         @param name    name of the substream
     269             :         @param ref     reference to the substream
     270             :     */
     271             :     virtual void substream(Id name,
     272             :                            writerfilter::Reference<Stream>::Pointer_t ref) = 0;
     273             : 
     274             : 
     275             :     /**
     276             :        Debugging: Receives information about current point in stream.
     277             : 
     278             :        @param info     the information
     279             :      */
     280             :     virtual void info(const string & info) = 0;
     281             : 
     282             : protected:
     283         659 :     ~Stream() {}
     284             : };
     285             : 
     286             : /**
     287             :    A value.
     288             : 
     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.
     292             :  */
     293      377637 : class WRITERFILTER_RESOURCEMODEL_DLLPUBLIC Value
     294             : {
     295             : public:
     296             :     /**
     297             :        Pointer to a value.
     298             :      */
     299             :     SAL_WNODEPRECATED_DECLARATIONS_PUSH
     300             :     typedef auto_ptr<Value> Pointer_t;
     301             :     SAL_WNODEPRECATED_DECLARATIONS_POP
     302             : 
     303      377637 :     virtual ~Value() {}
     304             : 
     305             :     /**
     306             :        Returns integer representation of the value.
     307             :      */
     308             :     virtual int getInt() const = 0;
     309             : 
     310             :     /**
     311             :        Returns string representation of the value.
     312             :      */
     313             :     virtual OUString getString() const = 0;
     314             : 
     315             :     /**
     316             :        Returns representation of the value as uno::Any.
     317             :      */
     318             :     virtual uno::Any getAny() const = 0;
     319             : 
     320             :     /**
     321             :        Returns properties of this value.
     322             :      */
     323             :     virtual writerfilter::Reference<Properties>::Pointer_t getProperties() = 0;
     324             : 
     325             :     /**
     326             :        Returns stream of this value.
     327             :      */
     328             :     virtual writerfilter::Reference<Stream>::Pointer_t getStream() = 0;
     329             : 
     330             :     /**
     331             :        Returns binary object  of this value.
     332             :      */
     333             :     virtual writerfilter::Reference<BinaryObj>::Pointer_t getBinary() = 0;
     334             : 
     335             :     /**
     336             :        Returns string representation of this value.
     337             :      */
     338             :     virtual string toString() const = 0;
     339             : };
     340             : 
     341             : /**
     342             :    An SPRM.
     343             : 
     344             :  */
     345      121505 : class WRITERFILTER_RESOURCEMODEL_DLLPUBLIC Sprm
     346             : {
     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 };
     352             : 
     353             :     /**
     354             :        Returns id of the SPRM.
     355             :      */
     356             :     virtual sal_uInt32 getId() const = 0;
     357             : 
     358             :     /**
     359             :        Returns value of the SPRM.
     360             :      */
     361             :     virtual Value::Pointer_t getValue() = 0;
     362             : 
     363             :     /**
     364             :        Returns reference to binary object contained in the SPRM.
     365             :      */
     366             :     virtual writerfilter::Reference<BinaryObj>::Pointer_t getBinary() = 0;
     367             : 
     368             :     /**
     369             :        Returns reference to stream associated with the SPRM.
     370             :      */
     371             :     virtual writerfilter::Reference<Stream>::Pointer_t getStream() = 0;
     372             : 
     373             :     /**
     374             :        Returns reference to properties contained in the SPRM.
     375             : 
     376             :      */
     377             :     virtual writerfilter::Reference<Properties>::Pointer_t getProps() = 0;
     378             : 
     379             :     /**
     380             :        Returns the kind of this SPRM.
     381             :     */
     382             :     virtual Kind getKind() = 0;
     383             : 
     384             :     /**
     385             :        Returns name of sprm.
     386             :     */
     387             :     virtual string getName() const = 0;
     388             : 
     389             :     /**
     390             :        Returns string repesentation of sprm.
     391             :      */
     392             :     virtual string toString() const = 0;
     393             : 
     394             : protected:
     395      121505 :     ~Sprm() {}
     396             : };
     397             : 
     398             : /**
     399             :    Creates handler for a stream.
     400             : */
     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);
     406             : 
     407             : }
     408             : 
     409             : #endif // INCLUDED_WW8RESOURCEMODEL_HXX
     410             : 
     411             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10