LCOV - code coverage report
Current view: top level - writerfilter/inc/ooxml - OOXMLDocument.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 4 4 100.0 %
Date: 2012-08-25 Functions: 4 6 66.7 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 2 4 50.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                 :            : #ifndef INCLUDED_OOXML_DOCUMENT_HXX
      20                 :            : #define INCLUDED_OOXML_DOCUMENT_HXX
      21                 :            : 
      22                 :            : #include <sal/types.h>
      23                 :            : #include <com/sun/star/uno/Reference.hxx>
      24                 :            : #include <com/sun/star/io/XInputStream.hpp>
      25                 :            : #include <com/sun/star/uno/XComponentContext.hpp>
      26                 :            : #include <resourcemodel/WW8ResourceModel.hxx>
      27                 :            : #include <com/sun/star/xml/sax/XParser.hpp>
      28                 :            : #include <com/sun/star/xml/sax/XFastParser.hpp>
      29                 :            : #include <com/sun/star/xml/sax/XFastTokenHandler.hpp>
      30                 :            : #include <com/sun/star/xml/sax/XFastShapeContextHandler.hpp>
      31                 :            : #include <com/sun/star/frame/XModel.hpp>
      32                 :            : #include <com/sun/star/drawing/XDrawPage.hpp>
      33                 :            : 
      34                 :            : /**
      35                 :            :    @file OOXMLDocument.hxx
      36                 :            : 
      37                 :            :    <h1>Import of OOXML WordprocessingML Documents</h1>
      38                 :            : 
      39                 :            :    The following picture shows the classes involved in importing OOXML
      40                 :            :    WordprocessingML documents.
      41                 :            : 
      42                 :            :    @image html ooxmlimportchain.png
      43                 :            : 
      44                 :            :    The DOCX consists of parts. Each part is an XML document.  The
      45                 :            :    OOXMLDocument opens the DOCX and creates a SAX parser for the part
      46                 :            :    containing the main document content. The OOXMLDocument creates a
      47                 :            :    SAX handler, too. This handler is set as the handler for the events
      48                 :            :    created by the parser. Finally the OOXMLDocument initiates the
      49                 :            :    parsing process.
      50                 :            : 
      51                 :            :    The SAX handler hosts a stack of contexts. Each context is an
      52                 :            :    instance of a class derived from OOXMLContext. There is a context
      53                 :            :    class for each <define> in the model.xml.
      54                 :            : 
      55                 :            :    For a detailed information about how the contexts are handled see
      56                 :            :    the documentation for OOXMLContext.
      57                 :            : 
      58                 :            :    The contexts know how to convert an element in OOXML to the
      59                 :            :    intermediate format that the domain mapper understands. They
      60                 :            :    enumerate the according entity in OOXML by sending the according
      61                 :            :    events to the domain mapper.
      62                 :            : 
      63                 :            :    The domain mapper knows how to convert the intermediate format to
      64                 :            :    API calls. It takes the events sent by the contexts and uses the
      65                 :            :    core API to insert the according elements to the core.
      66                 :            :  */
      67                 :            : 
      68                 :            : namespace writerfilter {
      69                 :            : namespace ooxml
      70                 :            : {
      71                 :            : 
      72                 :            : using namespace com::sun::star;
      73                 :            : 
      74                 :       1553 : class WRITERFILTER_OOXML_DLLPUBLIC OOXMLStream
      75                 :            : {
      76                 :            : public:
      77                 :            :     enum StreamType_t { UNKNOWN, DOCUMENT, STYLES, FONTTABLE, NUMBERING,
      78                 :            :         FOOTNOTES, ENDNOTES, COMMENTS, THEME, SETTINGS, VBAPROJECT };
      79                 :            :     typedef boost::shared_ptr<OOXMLStream> Pointer_t;
      80                 :            : 
      81         [ -  + ]:       1553 :     virtual ~OOXMLStream() {}
      82                 :            : 
      83                 :            :     /**
      84                 :            :        Returns parser for this stream.
      85                 :            :      */
      86                 :            :     virtual uno::Reference<xml::sax::XParser> getParser() = 0;
      87                 :            : 
      88                 :            :     /**
      89                 :            :        Returns fast parser for this stream.
      90                 :            :      */
      91                 :            :     virtual uno::Reference<xml::sax::XFastParser> getFastParser() = 0;
      92                 :            : 
      93                 :            :     virtual uno::Reference<io::XInputStream> getDocumentStream() = 0;
      94                 :            : 
      95                 :            :     virtual uno::Reference<io::XInputStream> getStorageStream() = 0;
      96                 :            : 
      97                 :            :     /**
      98                 :            :        Returns component context for this stream.
      99                 :            :      */
     100                 :            :     virtual uno::Reference<uno::XComponentContext> getContext() = 0;
     101                 :            : 
     102                 :            :     /**
     103                 :            :        Returns target URL from relationships for a given id.
     104                 :            : 
     105                 :            :        @param rId           the id to look for
     106                 :            : 
     107                 :            :        @return the URL found or an empty string
     108                 :            :      */
     109                 :            :     virtual OUString getTargetForId(const OUString & rId) = 0;
     110                 :            : 
     111                 :            :     virtual const OUString & getTarget() const = 0;
     112                 :            : 
     113                 :            :     virtual uno::Reference<xml::sax::XFastTokenHandler>
     114                 :            :     getFastTokenHandler(uno::Reference<uno::XComponentContext> rContext) = 0;
     115                 :            : 
     116                 :            : };
     117                 :            : 
     118                 :        227 : class WRITERFILTER_OOXML_DLLPUBLIC OOXMLDocument : public writerfilter::Reference<Stream>
     119                 :            : {
     120                 :            : public:
     121                 :            :     /**
     122                 :            :        Pointer to this stream.
     123                 :            :     */
     124                 :            :     typedef boost::shared_ptr<OOXMLDocument> Pointer_t;
     125                 :            : 
     126         [ -  + ]:        227 :     virtual ~OOXMLDocument() {}
     127                 :            : 
     128                 :            :     /**
     129                 :            :        Resolves this document to a stream handler.
     130                 :            : 
     131                 :            :        @param rStream     stream handler to resolve this document to
     132                 :            :      */
     133                 :            :     virtual void resolve(Stream & rStream) = 0;
     134                 :            : 
     135                 :            :     /**
     136                 :            :        Returns string representation of the type of this reference.
     137                 :            : 
     138                 :            :        DEBUGGING PURPOSE ONLY.
     139                 :            :      */
     140                 :            :     virtual string getType() const = 0;
     141                 :            : 
     142                 :            :     /**
     143                 :            :        Resolves a footnote to a stream handler.
     144                 :            : 
     145                 :            :        A footnote is resolved if either the note type or
     146                 :            :        note id matches.
     147                 :            : 
     148                 :            :        @param rStream       stream handler to resolve to
     149                 :            :        @param rNoteType     type of footnote to resolve
     150                 :            :        @param rNoteId       id of the footnote to resolve
     151                 :            :      */
     152                 :            :     virtual void resolveFootnote(Stream & rStream,
     153                 :            :                                  const Id & rNoteType,
     154                 :            :                                  const sal_Int32 nNoteId) = 0;
     155                 :            :     /**
     156                 :            :        Resolves an endnote to a stream handler.
     157                 :            : 
     158                 :            :        An endnote is resolved if either the note type or
     159                 :            :        note id matches.
     160                 :            : 
     161                 :            :        @param rStream       stream handler to resolve to
     162                 :            :        @param rNoteType     type of footnote to resolve
     163                 :            :        @param rNoteId       id of the endnote to resolve
     164                 :            :      */
     165                 :            :     virtual void resolveEndnote(Stream & rStream,
     166                 :            :                                 const Id & rNoteType,
     167                 :            :                                 const sal_Int32 NoteId) = 0;
     168                 :            : 
     169                 :            :     /**
     170                 :            :        Resolves a comment to a stream handler.
     171                 :            : 
     172                 :            :        @param rStream       stream handler to resolve to
     173                 :            :        @param rComment      id of the comment to resolve
     174                 :            :      */
     175                 :            :     virtual void resolveComment(Stream & rStream,
     176                 :            :                                 const sal_Int32 nCommentId) = 0;
     177                 :            : 
     178                 :            :     /**
     179                 :            :        Resolves a picture to a stream handler.
     180                 :            : 
     181                 :            :        @param rStream       stream handler to resolve to
     182                 :            :        @param rPictureId    id of the picture to resolve
     183                 :            :      */
     184                 :            :     virtual void resolvePicture(Stream & rStream,
     185                 :            :                                 const OUString & rPictureId) = 0;
     186                 :            : 
     187                 :            :     /**
     188                 :            :        Resolves a header to a stream handler.
     189                 :            : 
     190                 :            :        @param rStream       stream handler to resolve to
     191                 :            :        @param type          type of header to resolve:
     192                 :            :                             NS_ooxml::LN_Value_ST_HrdFtr_even     header on even page
     193                 :            :                             NS_ooxml::LN_Value_ST_HrdFtr_default  header on right page
     194                 :            :                             NS_ooxml::LN_Value_ST_HrdFtr_first    header on first page
     195                 :            : 
     196                 :            :        @param rId           id of the header
     197                 :            :      */
     198                 :            :     virtual void resolveHeader(Stream & rStream,
     199                 :            :                                const sal_Int32 type,
     200                 :            :                                const OUString & rId) = 0;
     201                 :            : 
     202                 :            :     /**
     203                 :            :        Resolves a footer to a stream handler.
     204                 :            : 
     205                 :            :        @param rStream       stream handler to resolve to
     206                 :            :        @param type          type of footer to resolve:
     207                 :            :                             NS_ooxml::LN_Value_ST_HrdFtr_even     header on even page
     208                 :            :                             NS_ooxml::LN_Value_ST_HrdFtr_default  header on right page
     209                 :            :                             NS_ooxml::LN_Value_ST_HrdFtr_first    header on first page
     210                 :            : 
     211                 :            :        @param rId           id of the header
     212                 :            :     */
     213                 :            :     virtual void resolveFooter(Stream & rStream,
     214                 :            :                                const sal_Int32 type,
     215                 :            :                                const OUString & rId) = 0;
     216                 :            : 
     217                 :            : 
     218                 :            :     /**
     219                 :            :        Returns target URL from relationships for a given id.
     220                 :            : 
     221                 :            :        @param rId           the id to look for
     222                 :            : 
     223                 :            :        @return the URL found or an empty string
     224                 :            :      */
     225                 :            :     virtual OUString getTargetForId(const OUString & rId) = 0;
     226                 :            : 
     227                 :            :     virtual void setModel(uno::Reference<frame::XModel> xModel) = 0;
     228                 :            :     virtual uno::Reference<frame::XModel> getModel() = 0;
     229                 :            :     virtual void setDrawPage(uno::Reference<drawing::XDrawPage> xDrawPage) = 0;
     230                 :            :     virtual uno::Reference<drawing::XDrawPage> getDrawPage() = 0;
     231                 :            :     virtual uno::Reference<io::XInputStream> getInputStream() = 0;
     232                 :            :     virtual uno::Reference<io::XInputStream> getStorageStream() = 0;
     233                 :            :     virtual uno::Reference<io::XInputStream> getInputStreamForId
     234                 :            :     (const OUString & rId) = 0;
     235                 :            :     virtual void setXNoteId(const sal_Int32 nId) = 0;
     236                 :            :     virtual sal_Int32 getXNoteId() const = 0;
     237                 :            :     virtual void setXNoteType(const Id & nId) = 0;
     238                 :            :     virtual const Id & getXNoteType() const = 0;
     239                 :            :     virtual const OUString & getTarget() const = 0;
     240                 :            :     virtual uno::Reference<xml::sax::XFastShapeContextHandler> getShapeContext( ) = 0;
     241                 :            :     virtual void setShapeContext( uno::Reference<xml::sax::XFastShapeContextHandler> xContext ) = 0;
     242                 :            : };
     243                 :            : 
     244                 :            : 
     245                 :            : class WRITERFILTER_OOXML_DLLPUBLIC OOXMLDocumentFactory
     246                 :            : {
     247                 :            : public:
     248                 :            :     static OOXMLStream::Pointer_t
     249                 :            :     createStream(uno::Reference<uno::XComponentContext> rContext,
     250                 :            :                  uno::Reference<io::XInputStream> rStream,
     251                 :            :                  OOXMLStream::StreamType_t nStreamType = OOXMLStream::DOCUMENT);
     252                 :            : 
     253                 :            :     static OOXMLStream::Pointer_t
     254                 :            :     createStream(OOXMLStream::Pointer_t pStream,
     255                 :            :                  OOXMLStream::StreamType_t nStreamType = OOXMLStream::DOCUMENT);
     256                 :            : 
     257                 :            :     static OOXMLStream::Pointer_t
     258                 :            :     createStream(OOXMLStream::Pointer_t pStream, const OUString & rId);
     259                 :            : 
     260                 :            :     static OOXMLDocument *
     261                 :            :     createDocument(OOXMLStream::Pointer_t pStream);
     262                 :            : 
     263                 :            : };
     264                 :            : 
     265                 :            : void ooxmlidsToXML(::std::iostream & out);
     266                 :            : 
     267                 :            : }}
     268                 :            : #endif // INCLUDED_OOXML_DOCUMENT_HXX
     269                 :            : 
     270                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10