LCOV - code coverage report
Current view: top level - writerfilter/inc/doctok - WW8Document.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 6 0.0 %
Date: 2012-08-25 Functions: 0 7 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     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_WW8_DOCUMENT_HXX
      21                 :            : #define INCLUDED_WW8_DOCUMENT_HXX
      22                 :            : 
      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>
      29                 :            : 
      30                 :            : #include <resourcemodel/WW8ResourceModel.hxx>
      31                 :            : #include <resourcemodel/OutputWithDepth.hxx>
      32                 :            : 
      33                 :            : #include <WriterFilterDllApi.hxx>
      34                 :            : 
      35                 :            : namespace writerfilter {
      36                 :            : namespace doctok {
      37                 :            : 
      38                 :            : using namespace ::com::sun::star;
      39                 :            : 
      40                 :            : /**
      41                 :            :    A stream containing a WW8 document.
      42                 :            : 
      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.
      46                 :            : */
      47                 :          0 : class WRITERFILTER_DOCTOK_DLLPUBLIC WW8Stream
      48                 :            : {
      49                 :            : public:
      50                 :            :     /**
      51                 :            :        Pointer to a WW8Stream.
      52                 :            :     */
      53                 :            :     typedef boost::shared_ptr<WW8Stream> Pointer_t;
      54                 :            : 
      55                 :            :     /**
      56                 :            :        Type for the content of the stream
      57                 :            :      */
      58                 :            :     typedef SubSequence<sal_uInt8> Sequence;
      59                 :            : 
      60                 :            :     virtual ~WW8Stream();
      61                 :            : 
      62                 :            :     /**
      63                 :            :        Returns pointer to a substream.
      64                 :            : 
      65                 :            :        @param rSid     identifier of substream to return
      66                 :            : 
      67                 :            :        @return    the substream
      68                 :            :      */
      69                 :            :     virtual Pointer_t getSubStream(const OUString & rSid) = 0;
      70                 :            : 
      71                 :            :     /**
      72                 :            :        Return a continious part of the stream.
      73                 :            : 
      74                 :            :        @param nOffset     offset in the stream where the part starts
      75                 :            :        @param nCount      length of the part (number of bytes)
      76                 :            : 
      77                 :            :        @return    sequence of unsigned bytes
      78                 :            :      */
      79                 :            :     virtual Sequence get(sal_uInt32 nOffset, sal_uInt32 nCount)
      80                 :            :         const = 0;
      81                 :            : 
      82                 :            :     // Returns the names of substreams contained in the stream
      83                 :            :     virtual string getSubStreamNames() const = 0;
      84                 :            : 
      85                 :            :     virtual uno::Sequence<OUString> getSubStreamUNames() const = 0;
      86                 :            : 
      87                 :            :     /**
      88                 :            :        Dumps content of stream to output.
      89                 :            : 
      90                 :            :        @param o     the target output
      91                 :            :     */
      92                 :            :     virtual void dump(OutputWithDepth<string> & o) const = 0;
      93                 :            : 
      94                 :            :     //virtual bool put(sal_uInt32 nOffset, const Sequence & rSeq) = 0;
      95                 :            : };
      96                 :            : 
      97                 :            : /**
      98                 :            :    A property.
      99                 :            : 
     100                 :            : */
     101                 :          0 : class WRITERFILTER_DOCTOK_DLLPUBLIC WW8Property
     102                 :            : {
     103                 :            : public:
     104                 :            :     /**
     105                 :            :        Ponter to a property.
     106                 :            :     */
     107                 :            :     typedef boost::shared_ptr<WW8Property> Pointer_t;
     108                 :            : 
     109                 :            :     virtual ~WW8Property();
     110                 :            : 
     111                 :            :     virtual sal_uInt32 getId() const = 0;
     112                 :            :     virtual sal_uInt32 getParam() const = 0;
     113                 :            :     virtual WW8Stream::Sequence getParams() const = 0;
     114                 :            : 
     115                 :            :     virtual string toString() const = 0;
     116                 :            : 
     117                 :            :     /**
     118                 :            :        Dumps this object to an output.
     119                 :            : 
     120                 :            :     */
     121                 :            :     virtual void dump(OutputWithDepth<string> & o) const = 0;
     122                 :            : };
     123                 :            : 
     124                 :            : /**
     125                 :            :    An iterator for traversal of a set of properties.
     126                 :            : 
     127                 :            :    Sample code for use of iterator:
     128                 :            : 
     129                 :            :    \code
     130                 :            :    Return_t function(WW8PropertySet::tPointer pSet)
     131                 :            :    {
     132                 :            :        do_something;
     133                 :            : 
     134                 :            :        WW8PropertySetIterator::tPointer pIt = pSet->begin();
     135                 :            :        WW8PropertySetIterator::tPointer pItEnd = pSet->end();
     136                 :            : 
     137                 :            :        while ((*pIt) != (*pItEnd))
     138                 :            :        {
     139                 :            :            do_something();
     140                 :            : 
     141                 :            :            ++(*pIt);
     142                 :            :        }
     143                 :            : 
     144                 :            :        do_something;
     145                 :            :    }
     146                 :            :    \endcode
     147                 :            : */
     148                 :          0 : class WRITERFILTER_DOCTOK_DLLPUBLIC WW8PropertySetIterator
     149                 :            : {
     150                 :            : public:
     151                 :            :     typedef boost::shared_ptr<WW8PropertySetIterator> Pointer_t;
     152                 :            : 
     153                 :            :     virtual ~WW8PropertySetIterator();
     154                 :            : 
     155                 :            :     /**
     156                 :            :        Advance iterator to the next property.
     157                 :            :     */
     158                 :            :     virtual WW8PropertySetIterator & operator++() = 0;
     159                 :            : 
     160                 :            :     /**
     161                 :            :        Returns a pointer to the property the iterator references.
     162                 :            :     */
     163                 :            :     virtual WW8Property::Pointer_t get() const = 0;
     164                 :            : 
     165                 :            :     /**
     166                 :            :        Checks if the iterator is equal to another one.
     167                 :            :     */
     168                 :            :     virtual bool equal(const WW8PropertySetIterator & rIt) const = 0;
     169                 :            : 
     170                 :            :     /**
     171                 :            :        Returns string representation of iterator.
     172                 :            :      */
     173                 :            :     virtual string toString() const = 0;
     174                 :            : };
     175                 :            : 
     176                 :            : /**
     177                 :            :    Checks if two property set iterators are not equal.
     178                 :            : */
     179                 :            : bool operator != (const WW8PropertySetIterator & rA,
     180                 :            :                   const WW8PropertySetIterator & rB);
     181                 :            : 
     182                 :            : /**
     183                 :            :    A set of properties.
     184                 :            : */
     185                 :          0 : class WRITERFILTER_DOCTOK_DLLPUBLIC WW8PropertySet
     186                 :            : {
     187                 :            : public:
     188                 :            :     typedef boost::shared_ptr<WW8PropertySet> Pointer_t;
     189                 :            : 
     190                 :            :     virtual ~WW8PropertySet();
     191                 :            : 
     192                 :            :     /**
     193                 :            :        Returns iterator to the start of the set.
     194                 :            :      */
     195                 :            :     virtual WW8PropertySetIterator::Pointer_t begin() = 0;
     196                 :            : 
     197                 :            :     /**
     198                 :            :        Returns iterator to the end of the set.
     199                 :            :     */
     200                 :            :     virtual WW8PropertySetIterator::Pointer_t end() = 0;
     201                 :            : 
     202                 :            :     /**
     203                 :            :        Dumps property set to output stream.
     204                 :            : 
     205                 :            :        @param o    output stream to dump property set to
     206                 :            :     */
     207                 :            :     virtual void dump(OutputWithDepth<string> & o) const = 0;
     208                 :            : 
     209                 :            :     /**
     210                 :            :        Iterate through property set and for each element dump a dot
     211                 :            :        output stream.
     212                 :            : 
     213                 :            :        @param o      output stream to dump dots to
     214                 :            :      */
     215                 :            :     virtual void dots(ostream & o) = 0;
     216                 :            : 
     217                 :            :     virtual bool isPap() const = 0;
     218                 :            :     virtual sal_uInt32 get_istd() const = 0;
     219                 :            : 
     220                 :            :     /**
     221                 :            :        Insert another property set into this property set.
     222                 :            : 
     223                 :            :        @param pSet   the set to insert
     224                 :            :      */
     225                 :            :     virtual void insert(const WW8PropertySet::Pointer_t pSet) = 0;
     226                 :            : };
     227                 :            : 
     228                 :            : enum PropertyType {
     229                 :            :     /** Auxiliary type for character positions defined in piece table */
     230                 :            :     PROP_DOC,
     231                 :            : 
     232                 :            :     /** properties are section properies */
     233                 :            :     PROP_SEC,
     234                 :            : 
     235                 :            :     /** properties are paragraph properties */
     236                 :            :     PROP_PAP,
     237                 :            : 
     238                 :            :     /** properties are character properties */
     239                 :            :     PROP_CHP,
     240                 :            : 
     241                 :            :     /** a footnote reference */
     242                 :            :     PROP_FOOTNOTE,
     243                 :            : 
     244                 :            :     /** an endnote reference */
     245                 :            :     PROP_ENDNOTE,
     246                 :            : 
     247                 :            :     /** an annotaion reference */
     248                 :            :     PROP_ANNOTATION,
     249                 :            : 
     250                 :            :     /** the start of a bookmark */
     251                 :            :     PROP_BOOKMARKSTART,
     252                 :            : 
     253                 :            :     /** the end of a bookmark */
     254                 :            :     PROP_BOOKMARKEND,
     255                 :            : 
     256                 :            :     /** a field character (start, separator or end) */
     257                 :            :     PROP_FLD,
     258                 :            : 
     259                 :            :     /** a shape character */
     260                 :            :     PROP_SHP,
     261                 :            : 
     262                 :            :     /** a break character */
     263                 :            :     PROP_BRK
     264                 :            : };
     265                 :            : 
     266                 :            : /**
     267                 :            :    An iterator for traversal of the character positions of a Word
     268                 :            :    document.
     269                 :            : 
     270                 :            :    The use of the iterator is analogous to WW8PropertySetIterator.
     271                 :            : */
     272                 :          0 : class WRITERFILTER_DOCTOK_DLLPUBLIC WW8DocumentIterator
     273                 :            : {
     274                 :            : public:
     275                 :            :     typedef boost::shared_ptr<WW8DocumentIterator> Pointer_t;
     276                 :            : 
     277                 :            :     virtual ~WW8DocumentIterator();
     278                 :            : 
     279                 :            :     /**
     280                 :            :        Advance iterator to next character position of the document.
     281                 :            :     */
     282                 :            :     virtual WW8DocumentIterator & operator++() = 0;
     283                 :            : 
     284                 :            :     /**
     285                 :            :        Recedes iterator to previous character postion of the document.
     286                 :            :      */
     287                 :            :     virtual WW8DocumentIterator & operator--() = 0;
     288                 :            : 
     289                 :            :     /**
     290                 :            :        Returns properties set at the character position the iterator
     291                 :            :        points to.
     292                 :            : 
     293                 :            :        @return pointer to set of properties
     294                 :            :      */
     295                 :            :     virtual writerfilter::Reference<Properties>::Pointer_t getProperties()
     296                 :            :         const = 0;
     297                 :            : 
     298                 :            :     virtual writerfilter::Reference<Stream>::Pointer_t getSubDocument()
     299                 :            :         const = 0;
     300                 :            : 
     301                 :            :     /**
     302                 :            :        Returns text run at the character position the iterator points
     303                 :            :        to.
     304                 :            :      */
     305                 :            :     virtual WW8Stream::Sequence getText() = 0;
     306                 :            : 
     307                 :            :     /**
     308                 :            :        Return pointer to the shape at character position the iterator
     309                 :            :        is pointing to.
     310                 :            :      */
     311                 :            :     virtual writerfilter::Reference<Properties>::Pointer_t getShape() const = 0;
     312                 :            : 
     313                 :            :     /**
     314                 :            :        Checks if the characters of the entity the iterator points to
     315                 :            :        are complex.
     316                 :            : 
     317                 :            :        Complex characters in a Word document are byte size
     318                 :            :        characters. Non-complex characters are word size characters.
     319                 :            : 
     320                 :            :        @retval true      The characters are complex.
     321                 :            :        @retval false     The characters are non-complex.
     322                 :            :      */
     323                 :            :     virtual bool isComplex() const = 0;
     324                 :            : 
     325                 :            :     /**
     326                 :            :        Returns the property type of the entity the iterator points to.
     327                 :            :      */
     328                 :            :     virtual PropertyType getPropertyType() const = 0;
     329                 :            : 
     330                 :            :     /**
     331                 :            :        Checks is the iterator is equal to another one.
     332                 :            : 
     333                 :            :        @param rIt    iterator to check against
     334                 :            : 
     335                 :            :        @retval true    the iterators are equal
     336                 :            :        @retval false   else
     337                 :            :     */
     338                 :            :     virtual bool equal(const WW8DocumentIterator & rIt) const = 0;
     339                 :            : 
     340                 :            :     /**
     341                 :            :        Returns string representation of the iterator.
     342                 :            :     */
     343                 :            :     virtual string toString() const = 0;
     344                 :            : 
     345                 :            :     /**
     346                 :            :        Dumps the iterator to an output stream.
     347                 :            : 
     348                 :            :        @param o    the output stream to dump the iterator to
     349                 :            :      */
     350                 :            :     virtual void dump(ostream & o) const = 0;
     351                 :            : };
     352                 :            : 
     353                 :            : /**
     354                 :            :    Checks if two document iterators are equal.
     355                 :            : 
     356                 :            :    @param rA     first iterator
     357                 :            :    @param rB     second iterator
     358                 :            : 
     359                 :            :    @retval true    the document iterators are equal
     360                 :            :    @retval false   else
     361                 :            :  */
     362                 :            : bool operator == (const WW8DocumentIterator & rA,
     363                 :            :                   const WW8DocumentIterator & rB);
     364                 :            : 
     365                 :            : class SubDocumentId
     366                 :            : {
     367                 :            : public:
     368                 :            :     enum eType { FOOTNOTES, HEADERS, FOOTERS };
     369                 :            : 
     370                 :            : private:
     371                 :            :     eType mnType;
     372                 :            :     sal_uInt8 mnIndex;
     373                 :            : 
     374                 :            : public:
     375                 :            :     SubDocumentId(eType nType, sal_uInt8 nIndex)
     376                 :            :     : mnType(nType), mnIndex(nIndex)
     377                 :            :     {
     378                 :            :     }
     379                 :            : 
     380                 :            :     eType getType() const { return mnType; }
     381                 :            :     sal_uInt8 getIndex() const { return mnIndex; }
     382                 :            : };
     383                 :            : 
     384                 :            : /**
     385                 :            :    A Word 8 document.
     386                 :            : */
     387                 :          0 : class WRITERFILTER_DOCTOK_DLLPUBLIC WW8Document :
     388                 :            :     public writerfilter::Reference<Stream>
     389                 :            : {
     390                 :            : public:
     391                 :            :     typedef boost::shared_ptr<WW8Document> Pointer_t;
     392                 :            : 
     393                 :            :     virtual ~WW8Document();
     394                 :            : 
     395                 :            :     /**
     396                 :            :        Get a subdocument.
     397                 :            : 
     398                 :            :        A subdocument can be
     399                 :            : 
     400                 :            :        - a header
     401                 :            :        - a footer
     402                 :            :        - a footnode
     403                 :            : 
     404                 :            :        @param nId identifier of the subdocumen
     405                 :            :     */
     406                 :            :     virtual Pointer_t getSubDocument(SubDocumentId nId) = 0;
     407                 :            : 
     408                 :            :     /**
     409                 :            :        Returns iterator to beginning of document.
     410                 :            :      */
     411                 :            :     virtual WW8DocumentIterator::Pointer_t begin() = 0;
     412                 :            : 
     413                 :            :     /**
     414                 :            :        Returns iterator to end of document.
     415                 :            :      */
     416                 :            :     virtual WW8DocumentIterator::Pointer_t end() = 0;
     417                 :            : };
     418                 :            : 
     419                 :            : class WRITERFILTER_DOCTOK_DLLPUBLIC WW8DocumentFactory
     420                 :            : {
     421                 :            : public:
     422                 :            :     static WW8Stream::Pointer_t
     423                 :            :     createStream(uno::Reference<uno::XComponentContext> rContext,
     424                 :            :                  uno::Reference<io::XInputStream> rStream);
     425                 :            : 
     426                 :            :     static WW8Document *
     427                 :            :     createDocument(WW8Stream::Pointer_t rpStream);
     428                 :            : };
     429                 :            : 
     430                 :            : void sprmidsToXML(::std::iostream & out);
     431                 :            : 
     432                 :            : void doctokidsToXML(::std::iostream & out);
     433                 :            : 
     434                 :            : }}
     435                 :            : 
     436                 :            : #endif // INCLUDED_WW8_DOCUMENT_HXX
     437                 :            : 
     438                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10