LCOV - code coverage report
Current view: top level - writerfilter/inc/resourcemodel - WW8ResourceModel.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 14 16 87.5 %
Date: 2014-11-03 Functions: 21 26 80.8 %
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_WRITERFILTER_INC_RESOURCEMODEL_WW8RESOURCEMODEL_HXX
      21             : #define INCLUDED_WRITERFILTER_INC_RESOURCEMODEL_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             : /**
      30             :    @file WW8ResourceModel.hxx
      31             : 
      32             :    The classes in this file define the interfaces for the resource
      33             :    model of the DocTokenizer:
      34             : 
      35             :    @image html doctok.png
      36             : 
      37             :    A resource is a set of events that describe an object. A resource
      38             :    is only an abstract concept. It is not instantiated to a class.
      39             : 
      40             :    A reference to a resource represents the object that the resource
      41             :    describes. The reference can be resolved thereby generating the
      42             :    events of the resource.
      43             : 
      44             :    A handler receives the events generated by resolving a
      45             :    reference. There are several types of handlers each accepting their
      46             :    specific set of events.
      47             : 
      48             :    References always have a parameter determining the kind of handler
      49             :    they send the events they generate to. The set of events generated
      50             :    by resolving the reference is a subset of the events received by
      51             :    the handler.
      52             : */
      53             : 
      54             : 
      55             : typedef sal_uInt32 Id;
      56             : 
      57             : namespace writerfilter {
      58             : 
      59             : /**
      60             :     Reference to an resource that generates events and sends them to a
      61             :     handler.
      62             : 
      63             :     The reference can be resolved, i.e. the resource generates its
      64             :     events. The events must be suitable for the handler type given by
      65             :     the template parameter.
      66             : 
      67             :     @attention The parameter of the template does not determine the
      68             :     type of the reference's target. It determines the type of the handler!
      69             : 
      70             :     Example:
      71             : 
      72             :     A Word document can be represented as a stream of events. Event
      73             :     types in a Word document are text, properties, tables, starts and
      74             :     ends of groups. These can be handled by a stream handler (@see
      75             :     Stream). Thus a reference to a Word document is resolved by
      76             :     sending these events to a stream handler.
      77             : */
      78             : 
      79             : template <class T>
      80     4329946 : class SAL_DLLPUBLIC_TEMPLATE Reference
      81             : {
      82             : public:
      83             :     /**
      84             :         Pointer to reference
      85             : 
      86             :         @attention The ownership of a reference is transferred when
      87             :         the reference is passed.
      88             :     */
      89             :     typedef boost::shared_ptr< Reference<T> > Pointer_t;
      90             : 
      91             :     /**
      92             :        Resolves the reference.
      93             : 
      94             :        The events of the references target resource are generated and
      95             :        send to a handler.
      96             : 
      97             :        @param rHandler         handler which receives the events
      98             :      */
      99             :     virtual void resolve(T & rHandler) = 0;
     100             : 
     101             : protected:
     102     4329946 :     ~Reference() {}
     103             : };
     104             : 
     105             : class Value;
     106             : class Sprm;
     107             : 
     108             : /**
     109             :    Handler for properties.
     110             :  */
     111      571230 : class Properties
     112             : {
     113             : public:
     114             :     /**
     115             :        Receives an attribute.
     116             : 
     117             :        @param name     name of the attribute
     118             :        @param val      value of the attribute
     119             :      */
     120             :     virtual void attribute(Id name, Value & val) = 0;
     121             : 
     122             :     /**
     123             :        Receives a SPRM.
     124             : 
     125             :        @param  sprm      the SPRM received
     126             :     */
     127             :     virtual void sprm(Sprm & sprm) = 0;
     128             : 
     129             : protected:
     130      571230 :     ~Properties() {}
     131             : };
     132             : 
     133             : /**
     134             :    Handler for tables.
     135             :  */
     136       19618 : class Table
     137             : {
     138             : public:
     139             :     typedef boost::shared_ptr<Table> Pointer_t;
     140             : 
     141             :     /**
     142             :        Receives an entry of the table.
     143             : 
     144             :        @param pos     position of the entry in the table
     145             :        @param ref     reference to properties of the entry
     146             :      */
     147             :     virtual void entry(int pos, writerfilter::Reference<Properties>::Pointer_t ref) = 0;
     148             : 
     149             : protected:
     150       19618 :     ~Table() {}
     151             : };
     152             : 
     153             : /**
     154             :    Handler for binary objects.
     155             :  */
     156        6072 : class BinaryObj
     157             : {
     158             : public:
     159             :     /**
     160             :        Receives binary data of the object.
     161             : 
     162             :        @param buf     pointer to buffer containing the data
     163             :        @param len     size of buffer
     164             :        @param ref     reference to properties of binary object
     165             :      */
     166             :     virtual void data(const sal_uInt8* buf, size_t len,
     167             :                       writerfilter::Reference<Properties>::Pointer_t ref) = 0;
     168             : 
     169             : protected:
     170        6072 :     ~BinaryObj() {}
     171             : };
     172             : 
     173             : /**
     174             :    Handler for a stream.
     175             :  */
     176        9190 : class Stream
     177             : {
     178             : public:
     179             : 
     180             :     /**
     181             :        Pointer to this stream.
     182             :      */
     183             :     typedef boost::shared_ptr<Stream> Pointer_t;
     184             : 
     185             :     /**
     186             :        Receives start mark for group with the same section properties.
     187             :      */
     188             :     virtual void startSectionGroup() = 0;
     189             : 
     190             :     /**
     191             :        Receives end mark for group with the same section properties.
     192             :     */
     193             :     virtual void endSectionGroup() = 0;
     194             : 
     195             :     /// The current section is the last one in this body text.
     196           0 :     virtual void markLastSectionGroup( ) { };
     197             : 
     198             :     /**
     199             :        Receives start mark for group with the same paragraph properties.
     200             :      */
     201             :     virtual void startParagraphGroup() = 0;
     202             : 
     203             :     /**
     204             :        Receives end mark for group with the same paragraph properties.
     205             :      */
     206             :     virtual void endParagraphGroup() = 0;
     207             : 
     208           0 :     virtual void markLastParagraphInSection( ) { };
     209             : 
     210             :     /**
     211             :        Receives start mark for group with the same character properties.
     212             :      */
     213             :     virtual void startCharacterGroup() = 0;
     214             : 
     215             :     /**
     216             :        Receives end mark for group with the same character properties.
     217             :      */
     218             :     virtual void endCharacterGroup() = 0;
     219             : 
     220             :     /**
     221             :       Receives a shape.
     222             :      */
     223             :     virtual void startShape( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > const& xShape ) = 0;
     224             : 
     225             :     virtual void endShape( ) = 0;
     226             : 
     227             :     /**
     228             :        Receives 8-bit per character text.
     229             : 
     230             :        @param data  buffer containing the text
     231             :        @param len   number of characters in the text
     232             :      */
     233             :     virtual void text(const sal_uInt8 * data, size_t len) = 0;
     234             : 
     235             :     /**
     236             :        Receives 16-bit per character text.
     237             : 
     238             :        @param data    buffer containing the text
     239             :        @param len     number of characters in the text.
     240             :      */
     241             :     virtual void utext(const sal_uInt8 * data, size_t len) = 0;
     242             : 
     243             :     virtual void positivePercentage(const OUString& rText) = 0;
     244             : 
     245             :     /**
     246             :        Receives properties of the current run of text.
     247             : 
     248             :        @param ref    reference to the properties
     249             :      */
     250             :     virtual void props(writerfilter::Reference<Properties>::Pointer_t ref) = 0;
     251             : 
     252             :     /**
     253             :        Receives table.
     254             : 
     255             :        @param name     name of the table
     256             :        @param ref      referecne to the table
     257             :      */
     258             :     virtual void table(Id name,
     259             :                        writerfilter::Reference<Table>::Pointer_t ref) = 0;
     260             : 
     261             :     /**
     262             :         Receives a substream.
     263             : 
     264             :         @param name    name of the substream
     265             :         @param ref     reference to the substream
     266             :     */
     267             :     virtual void substream(Id name,
     268             :                            writerfilter::Reference<Stream>::Pointer_t ref) = 0;
     269             : 
     270             : 
     271             :     /**
     272             :        Debugging: Receives information about current point in stream.
     273             : 
     274             :        @param info     the information
     275             :      */
     276             :     virtual void info(const std::string & info) = 0;
     277             : 
     278             : protected:
     279        9190 :     ~Stream() {}
     280             : };
     281             : 
     282             : /**
     283             :    A value.
     284             : 
     285             :    The methods of this class may throw exceptions if a certain aspect
     286             :    makes no sense for a certain value, e.g. the integer value of a
     287             :    string.
     288             :  */
     289    14772588 : class Value
     290             : {
     291             : public:
     292             :     /**
     293             :        Pointer to a value.
     294             :      */
     295             :     typedef std::unique_ptr<Value> Pointer_t;
     296             : 
     297    14772588 :     virtual ~Value() {}
     298             : 
     299             :     /**
     300             :        Returns integer representation of the value.
     301             :      */
     302             :     virtual int getInt() const = 0;
     303             : 
     304             :     /**
     305             :        Returns string representation of the value.
     306             :      */
     307             :     virtual OUString getString() const = 0;
     308             : 
     309             :     /**
     310             :        Returns representation of the value as uno::Any.
     311             :      */
     312             :     virtual css::uno::Any getAny() const = 0;
     313             : 
     314             :     /**
     315             :        Returns properties of this value.
     316             :      */
     317             :     virtual writerfilter::Reference<Properties>::Pointer_t getProperties() = 0;
     318             : 
     319             :     /**
     320             :        Returns stream of this value.
     321             :      */
     322             :     virtual writerfilter::Reference<Stream>::Pointer_t getStream() = 0;
     323             : 
     324             :     /**
     325             :        Returns binary object  of this value.
     326             :      */
     327             :     virtual writerfilter::Reference<BinaryObj>::Pointer_t getBinary() = 0;
     328             : 
     329             :     /**
     330             :        Returns string representation of this value.
     331             :      */
     332             : #ifdef DEBUG_WRITERFILTER
     333             :     virtual std::string toString() const = 0;
     334             : #endif
     335             : };
     336             : 
     337             : /**
     338             :    An SPRM.
     339             : 
     340             :  */
     341     7059580 : class Sprm
     342             : {
     343             : public:
     344             :     typedef std::unique_ptr<Sprm> Pointer_t;
     345             : 
     346             :     /**
     347             :        Returns id of the SPRM.
     348             :      */
     349             :     virtual sal_uInt32 getId() const = 0;
     350             : 
     351             :     /**
     352             :        Returns value of the SPRM.
     353             :      */
     354             :     virtual Value::Pointer_t getValue() = 0;
     355             : 
     356             :     /**
     357             :        Returns reference to binary object contained in the SPRM.
     358             :      */
     359             :     virtual writerfilter::Reference<BinaryObj>::Pointer_t getBinary() = 0;
     360             : 
     361             :     /**
     362             :        Returns reference to stream associated with the SPRM.
     363             :      */
     364             :     virtual writerfilter::Reference<Stream>::Pointer_t getStream() = 0;
     365             : 
     366             :     /**
     367             :        Returns reference to properties contained in the SPRM.
     368             : 
     369             :      */
     370             :     virtual writerfilter::Reference<Properties>::Pointer_t getProps() = 0;
     371             : 
     372             :     /**
     373             :        Returns name of sprm.
     374             :     */
     375             : #ifdef DEBUG_WRITERFILTER
     376             :     virtual std::string getName() const = 0;
     377             : #endif
     378             : 
     379             :     /**
     380             :        Returns string repesentation of sprm.
     381             :      */
     382             : #ifdef DEBUG_WRITERFILTER
     383             :     virtual std::string toString() const = 0;
     384             : #endif
     385             : 
     386             : protected:
     387     7059580 :     ~Sprm() {}
     388             : };
     389             : 
     390             : typedef sal_Int32 Token_t;
     391             : 
     392             : }
     393             : 
     394             : #endif // INCLUDED_WRITERFILTER_INC_RESOURCEMODEL_WW8RESOURCEMODEL_HXX
     395             : 
     396             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10