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

Generated by: LCOV version 1.10