LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/writerfilter/source/ooxml - OOXMLFastContextHandler.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 9 19 47.4 %
Date: 2013-07-09 Functions: 10 21 47.6 %
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_OOXML_FAST_CONTEXT_HANDLER_HXX
      21             : #define INCLUDED_OOXML_FAST_CONTEXT_HANDLER_HXX
      22             : 
      23             : #include <com/sun/star/xml/sax/XFastShapeContextHandler.hpp>
      24             : 
      25             : #include <string>
      26             : #include <set>
      27             : #include "sal/config.h"
      28             : #include "com/sun/star/uno/XComponentContext.hpp"
      29             : #include "cppuhelper/implbase1.hxx"
      30             : #include "com/sun/star/xml/sax/XFastContextHandler.hpp"
      31             : #include "OOXMLParserState.hxx"
      32             : #include "OOXMLPropertySetImpl.hxx"
      33             : #include "OOXMLDocumentImpl.hxx"
      34             : #include "RefAndPointer.hxx"
      35             : #include <ooxml/OOXMLFastTokens.hxx>
      36             : #include <svtools/embedhlp.hxx>
      37             : 
      38             : #include <oox/mathml/import.hxx>
      39             : #include <oox/mathml/importutils.hxx>
      40             : 
      41             : namespace writerfilter {
      42             : namespace ooxml
      43             : {
      44             : using namespace ::std;
      45             : using namespace ::com::sun::star;
      46             : using namespace ::com::sun::star::xml::sax;
      47             : 
      48             : typedef boost::shared_ptr<Stream> StreamPointer_t;
      49             : 
      50          17 : class OOXMLFastContextHandler:
      51             :     public ::cppu::WeakImplHelper1<
      52             :         xml::sax::XFastContextHandler>
      53             : {
      54             : public:
      55             :     typedef RefAndPointer<XFastContextHandler, OOXMLFastContextHandler>
      56             :     RefAndPointer_t;
      57             :     typedef boost::shared_ptr<OOXMLFastContextHandler> Pointer_t;
      58             : 
      59             :     enum ResourceEnum_t { UNKNOWN, STREAM, PROPERTIES, TABLE, SHAPE };
      60             : 
      61             :     OOXMLFastContextHandler();
      62             :     explicit OOXMLFastContextHandler
      63             :     (uno::Reference< uno::XComponentContext > const & context);
      64             : 
      65             :     explicit OOXMLFastContextHandler
      66             :     (OOXMLFastContextHandler * pContext);
      67             : 
      68             :     virtual ~OOXMLFastContextHandler();
      69             : 
      70             :     // ::com::sun::star::xml::sax::XFastContextHandler:
      71             :     virtual void SAL_CALL startFastElement
      72             :     (Token_t Element,
      73             :      const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
      74             :         throw (uno::RuntimeException, xml::sax::SAXException);
      75             : 
      76             :     virtual void SAL_CALL startUnknownElement
      77             :     (const OUString & Namespace,
      78             :      const OUString & Name,
      79             :      const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
      80             :         throw (uno::RuntimeException, xml::sax::SAXException);
      81             : 
      82             :     virtual void SAL_CALL endFastElement(Token_t Element)
      83             :         throw (uno::RuntimeException, xml::sax::SAXException);
      84             : 
      85             :     virtual void SAL_CALL endUnknownElement
      86             :     (const OUString & Namespace, const OUString & Name)
      87             :         throw (uno::RuntimeException, xml::sax::SAXException);
      88             : 
      89             :     virtual uno::Reference< xml::sax::XFastContextHandler > SAL_CALL
      90             :     createFastChildContext
      91             :     (Token_t Element,
      92             :      const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
      93             :         throw (uno::RuntimeException, xml::sax::SAXException);
      94             : 
      95             :     virtual uno::Reference< xml::sax::XFastContextHandler > SAL_CALL
      96             :     createUnknownChildContext
      97             :     (const OUString & Namespace,
      98             :      const OUString & Name,
      99             :      const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
     100             :         throw (uno::RuntimeException, xml::sax::SAXException);
     101             : 
     102             :     virtual void SAL_CALL characters(const OUString & aChars)
     103             :         throw (uno::RuntimeException, xml::sax::SAXException);
     104             : 
     105             :     static const uno::Sequence< sal_Int8 > & getUnoTunnelId();
     106             :     virtual sal_Int64 SAL_CALL getSomething(const uno::Sequence<sal_Int8> & rId)
     107             :         throw (uno::RuntimeException);
     108             : 
     109             :     // local
     110             : 
     111             :     void setStream(Stream * pStream);
     112             : 
     113             :     /**
     114             :        Return value of this context(element).
     115             : 
     116             :        @return  the value
     117             :      */
     118             :     virtual OOXMLValue::Pointer_t getValue() const;
     119             : 
     120             :     /**
     121             :        Returns a string describing the type of the context.
     122             : 
     123             :        This is the name of the define normally.
     124             : 
     125             :        @return type string
     126             :      */
     127           0 :     virtual string getType() const { return "??"; }
     128             : 
     129         923 :     virtual ResourceEnum_t getResource() const { return STREAM; }
     130             : 
     131             :     virtual void attributes
     132             :     (const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
     133             :         throw (uno::RuntimeException, xml::sax::SAXException);
     134             : 
     135             :     virtual void newProperty(const Id & rId, OOXMLValue::Pointer_t pVal);
     136             :     virtual void setPropertySet(OOXMLPropertySet::Pointer_t pPropertySet);
     137             :     virtual OOXMLPropertySet::Pointer_t getPropertySet() const;
     138             : 
     139             :     virtual void setToken(Token_t nToken);
     140             :     virtual Token_t getToken() const;
     141             : 
     142             :     void mark(const Id & rId, OOXMLValue::Pointer_t pVal);
     143             : 
     144             :     void resolveFootnote(const sal_Int32 nId);
     145             :     void resolveEndnote(const sal_Int32 nId);
     146             :     void resolveComment(const sal_Int32 nId);
     147             :     void resolvePicture(const OUString & rId);
     148             :     void resolveHeader(const sal_Int32 type,
     149             :                                 const OUString & rId);
     150             :     void resolveFooter(const sal_Int32 type,
     151             :                                 const OUString & rId);
     152             :     void resolveData(const OUString & rId);
     153             : 
     154             :     OUString getTargetForId(const OUString & rId);
     155             : 
     156             :     uno::Reference < xml::sax::XFastContextHandler >
     157             :     createFromStart
     158             :     (Token_t Element,
     159             :      const uno::Reference< xml::sax::XFastAttributeList > & Attribs);
     160             : 
     161             :     void setDocument(OOXMLDocument * pDocument);
     162             :     OOXMLDocument * getDocument();
     163             :     void setXNoteId(OOXMLValue::Pointer_t pValue);
     164             :     void setXNoteId(const sal_Int32 nId);
     165             :     sal_Int32 getXNoteId() const;
     166             :     void setForwardEvents(bool bForwardEvents);
     167             :     bool isForwardEvents() const;
     168             :     virtual void setParent(OOXMLFastContextHandler * pParent);
     169             :     virtual void setId(Id nId);
     170             :     virtual Id getId() const;
     171             : 
     172             :     void setDefine(Id nDefine);
     173             :     Id getDefine() const;
     174             : 
     175             :     OOXMLParserState::Pointer_t getParserState() const;
     176             : 
     177             :     void sendTableDepth() const;
     178             :     void setHandle();
     179             : 
     180             :     void startSectionGroup();
     181             :     void setLastParagraphInSection();
     182             :     void endSectionGroup();
     183             :     void startParagraphGroup();
     184             :     void endParagraphGroup();
     185             :     void startCharacterGroup();
     186             :     void endCharacterGroup();
     187             :     void startSdt();
     188             :     void endSdt();
     189             : 
     190             :     void startField();
     191             :     void fieldSeparator();
     192             :     void endField();
     193             :     void ftnednref();
     194             :     void ftnedncont();
     195             :     void ftnednsep();
     196             :     void pgNum();
     197             :     void tab();
     198             :     void cr();
     199             :     void noBreakHyphen();
     200             :     void softHyphen();
     201             :     void handleLastParagraphInSection();
     202             :     void endOfParagraph();
     203             :     void text(const OUString & sText);
     204             :     void positionOffset(const OUString & sText);
     205             :     void alignH(const OUString & sText);
     206             :     void alignV(const OUString & sText);
     207             :     void startTxbxContent();
     208             :     void endTxbxContent();
     209             :     virtual void propagateCharacterProperties();
     210             :     virtual void propagateCharacterPropertiesAsSet(const Id & rId);
     211             :     virtual void propagateTableProperties();
     212             :     virtual void propagateRowProperties();
     213             :     virtual void propagateCellProperties();
     214             :     virtual bool propagatesProperties() const;
     215             :     void sendPropertiesWithId(const Id & rId);
     216             :     void sendPropertiesToParent();
     217             :     void sendCellProperties();
     218             :     void sendRowProperties();
     219             :     void sendTableProperties();
     220             :     void clearTableProps();
     221             :     void clearProps();
     222             : 
     223             :     virtual void setDefaultBooleanValue();
     224             :     virtual void setDefaultIntegerValue();
     225             :     virtual void setDefaultHexValue();
     226             :     virtual void setDefaultStringValue();
     227             : 
     228             :     void sendPropertyToParent();
     229             : 
     230             : #if OSL_DEBUG_LEVEL > 1
     231             :     virtual void dumpXml( const TagLogger::Pointer_t pLogger ) const;
     232             : #endif
     233             : 
     234             :     sal_uInt32 getInstanceNumber() { return mnInstanceNumber; }
     235             : protected:
     236             :     OOXMLFastContextHandler * mpParent;
     237             :     Id mId;
     238             :     Id mnDefine;
     239             :     Token_t mnToken;
     240             : 
     241             : #ifdef DEBUG_CONTEXT_HANDLER
     242             :     string msTokenString;
     243             : #endif
     244             : 
     245             :     // the stream to send the stream events to.
     246             :     Stream * mpStream;
     247             : 
     248             :     // the current global parser state
     249             :     OOXMLParserState::Pointer_t mpParserState;
     250             : 
     251             :     // the table depth of this context
     252             :     unsigned int mnTableDepth;
     253             : 
     254             :     virtual void lcl_startFastElement
     255             :     (Token_t Element,
     256             :      const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
     257             :         throw (uno::RuntimeException, xml::sax::SAXException);
     258             : 
     259             :     virtual void lcl_endFastElement(Token_t Element)
     260             :         throw (uno::RuntimeException, xml::sax::SAXException);
     261             : 
     262             :     virtual uno::Reference< xml::sax::XFastContextHandler >
     263             :     lcl_createFastChildContext
     264             :     (Token_t Element,
     265             :      const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
     266             :         throw (uno::RuntimeException, xml::sax::SAXException);
     267             : 
     268             :     virtual void lcl_characters(const OUString & aChars)
     269             :         throw (uno::RuntimeException, xml::sax::SAXException);
     270             : 
     271             :     void startAction(Token_t Element);
     272             :     virtual void lcl_startAction(Token_t Element);
     273             :     void endAction(Token_t Element);
     274             :     virtual void lcl_endAction(Token_t Element);
     275             : 
     276             : 
     277             :     virtual OOXMLPropertySet * getPicturePropSet
     278             :     (const OUString & rId);
     279             :     virtual void resolvePropertySetAttrs();
     280             : 
     281             :     uno::Reference< uno::XComponentContext > getComponentContext();
     282             : 
     283             :     sal_uInt32 mnInstanceNumber;
     284             :     sal_uInt32 mnRefCount;
     285             : 
     286             :     bool inPositionV;
     287             : 
     288             : private:
     289             :     void operator =(OOXMLFastContextHandler &); // not defined
     290             : 
     291             :     uno::Reference< uno::XComponentContext > m_xContext;
     292             :     bool m_bDiscardChildren;
     293             : 
     294             :     static sal_uInt32 mnInstanceCount;
     295             : 
     296             : };
     297             : 
     298             : class OOXMLFastContextHandlerStream : public OOXMLFastContextHandler
     299             : {
     300             : public:
     301             :     OOXMLFastContextHandlerStream(OOXMLFastContextHandler * pContext);
     302             :     virtual ~OOXMLFastContextHandlerStream();
     303             : 
     304        1926 :     virtual ResourceEnum_t getResource() const { return STREAM; }
     305             : 
     306             :     OOXMLPropertySet::Pointer_t getPropertySetAttrs() const;
     307             : 
     308             :     virtual void newProperty(const Id & rId, OOXMLValue::Pointer_t pVal);
     309             :     virtual void sendProperty(Id nId);
     310             :     virtual OOXMLPropertySet::Pointer_t getPropertySet() const;
     311             : 
     312             :     void handleHyperlink();
     313             : 
     314             : protected:
     315             :     virtual void resolvePropertySetAttrs();
     316             : 
     317             : private:
     318             :     mutable OOXMLPropertySet::Pointer_t mpPropertySetAttrs;
     319             : };
     320             : 
     321             : class OOXMLFastContextHandlerProperties : public OOXMLFastContextHandler
     322             : {
     323             : public:
     324             :     OOXMLFastContextHandlerProperties(OOXMLFastContextHandler * pContext);
     325             :     virtual ~OOXMLFastContextHandlerProperties();
     326             : 
     327             :     virtual OOXMLValue::Pointer_t getValue() const;
     328       29022 :     virtual ResourceEnum_t getResource() const { return PROPERTIES; }
     329             : 
     330             :     virtual void newProperty(const Id & nId, OOXMLValue::Pointer_t pVal);
     331             : 
     332             :     void handleXNotes();
     333             :     void handleHdrFtr();
     334             :     void handleComment();
     335             :     void handlePicture();
     336             :     void handleBreak();
     337             :     void handleOLE();
     338             :     void handleFontRel();
     339             : 
     340             :     virtual void setPropertySet(OOXMLPropertySet::Pointer_t pPropertySet);
     341             :     virtual OOXMLPropertySet::Pointer_t getPropertySet() const;
     342             : 
     343             : #if OSL_DEBUG_LEVEL > 1
     344             :     virtual void dumpXml( const TagLogger::Pointer_t pLogger ) const;
     345             : #endif
     346             : 
     347             : protected:
     348             :     /// the properties
     349             :     OOXMLPropertySet::Pointer_t mpPropertySet;
     350             : 
     351             :     virtual void lcl_endFastElement(Token_t Element)
     352             :         throw (uno::RuntimeException, xml::sax::SAXException);
     353             :     virtual void setParent(OOXMLFastContextHandler * pParent);
     354             : 
     355             : private:
     356             : 
     357             :     bool mbResolve;
     358             : };
     359             : 
     360             : class OOXMLFastContextHandlerPropertyTable :
     361             :     public OOXMLFastContextHandlerProperties
     362             : {
     363             : public:
     364             :     OOXMLFastContextHandlerPropertyTable(OOXMLFastContextHandler * pContext);
     365             :     virtual ~OOXMLFastContextHandlerPropertyTable();
     366             : 
     367             : protected:
     368             :     OOXMLTableImpl mTable;
     369             : 
     370             :     virtual void lcl_endFastElement(Token_t Element)
     371             :         throw (uno::RuntimeException, xml::sax::SAXException);
     372             :  };
     373             : 
     374             : class OOXMLFastContextHandlerValue :
     375             :     public OOXMLFastContextHandler
     376             : {
     377             : public:
     378             :     OOXMLFastContextHandlerValue
     379             :     (OOXMLFastContextHandler * pContext);
     380             :     virtual ~OOXMLFastContextHandlerValue();
     381             : 
     382             :     virtual void setValue(OOXMLValue::Pointer_t pValue);
     383             :     virtual OOXMLValue::Pointer_t getValue() const;
     384             : 
     385             :     virtual void lcl_endFastElement(Token_t Element)
     386             :     throw (uno::RuntimeException, xml::sax::SAXException);
     387             : 
     388           0 :     virtual string getType() const { return "Value"; }
     389             : 
     390             :     virtual void setDefaultBooleanValue();
     391             :     virtual void setDefaultIntegerValue();
     392             :     virtual void setDefaultHexValue();
     393             :     virtual void setDefaultStringValue();
     394             : 
     395             : protected:
     396             :     OOXMLValue::Pointer_t mpValue;
     397             : };
     398             : 
     399             : class OOXMLFastContextHandlerTable : public OOXMLFastContextHandler
     400             : {
     401             : public:
     402             :     OOXMLFastContextHandlerTable(OOXMLFastContextHandler * pContext);
     403             :     virtual ~OOXMLFastContextHandlerTable();
     404             : 
     405             :     virtual uno::Reference< xml::sax::XFastContextHandler > SAL_CALL
     406             :     createFastChildContext
     407             :     (Token_t Element,
     408             :      const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
     409             :         throw (uno::RuntimeException, xml::sax::SAXException);
     410             : 
     411             :     virtual void newPropertySet(OOXMLPropertySet::Pointer_t pPropertySet);
     412             : protected:
     413             :     OOXMLTableImpl mTable;
     414             : 
     415             :     RefAndPointer_t mCurrentChild;
     416             : 
     417             :     virtual void lcl_endFastElement(Token_t Element)
     418             :         throw (uno::RuntimeException, xml::sax::SAXException);
     419             : 
     420        2577 :     virtual ResourceEnum_t getResource() const { return TABLE; }
     421             : 
     422           0 :     virtual string getType() const { return "Table"; }
     423             : 
     424             :     void addCurrentChild();
     425             : };
     426             : 
     427             : class OOXMLFastContextHandlerXNote : public OOXMLFastContextHandlerProperties
     428             : {
     429             : public:
     430             :     OOXMLFastContextHandlerXNote(OOXMLFastContextHandler * pContext);
     431             :     virtual ~OOXMLFastContextHandlerXNote();
     432             : 
     433             :     void checkId(OOXMLValue::Pointer_t pValue);
     434             : 
     435           0 :     virtual string getType() const { return "XNote"; }
     436             : 
     437             : private:
     438             :     bool mbForwardEventsSaved;
     439             :     sal_Int32 mnMyXNoteId;
     440             : 
     441             :     virtual void lcl_startFastElement
     442             :     (Token_t Element,
     443             :      const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
     444             :         throw (uno::RuntimeException, xml::sax::SAXException);
     445             : 
     446             :     virtual void lcl_endFastElement(Token_t Element)
     447             :         throw (uno::RuntimeException, xml::sax::SAXException);
     448             : 
     449           0 :     virtual ResourceEnum_t getResource() const { return STREAM; }
     450             : };
     451             : 
     452             : class OOXMLFastContextHandlerTextTableCell : public OOXMLFastContextHandler
     453             : {
     454             : public:
     455             :     OOXMLFastContextHandlerTextTableCell
     456             :     (OOXMLFastContextHandler * pContext);
     457             :     virtual ~OOXMLFastContextHandlerTextTableCell();
     458             : 
     459           0 :     virtual string getType() const { return "TextTableCell"; }
     460             : 
     461             :     void startCell();
     462             :     void endCell();
     463             : };
     464             : 
     465             : class OOXMLFastContextHandlerTextTableRow : public OOXMLFastContextHandler
     466             : {
     467             : public:
     468             :     OOXMLFastContextHandlerTextTableRow
     469             :     (OOXMLFastContextHandler * pContext);
     470             :     virtual ~OOXMLFastContextHandlerTextTableRow();
     471             : 
     472           0 :     virtual string getType() const { return "TextTableRow"; }
     473             : 
     474             :     void startRow();
     475             :     void endRow();
     476             : };
     477             : 
     478             : class OOXMLFastContextHandlerTextTable : public OOXMLFastContextHandler
     479             : {
     480             : public:
     481             :     OOXMLFastContextHandlerTextTable
     482             :     (OOXMLFastContextHandler * pContext);
     483             : 
     484             :     virtual ~OOXMLFastContextHandlerTextTable();
     485             : 
     486           0 :     virtual string getType() const { return "TextTable"; }
     487             : 
     488             : protected:
     489             :     virtual void lcl_startFastElement
     490             :     (Token_t Element,
     491             :      const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
     492             :         throw (uno::RuntimeException, xml::sax::SAXException);
     493             : 
     494             :     virtual void lcl_endFastElement(Token_t Element)
     495             :         throw (uno::RuntimeException, xml::sax::SAXException);
     496             : };
     497             : 
     498             : class OOXMLFastContextHandlerShape: public OOXMLFastContextHandlerProperties
     499             : {
     500             : private:
     501             :     bool m_bShapeSent;
     502             :     bool m_bShapeStarted;
     503             : 
     504             : public:
     505             :     explicit OOXMLFastContextHandlerShape
     506             :     (OOXMLFastContextHandler * pContext);
     507             :     virtual ~OOXMLFastContextHandlerShape();
     508             : 
     509           0 :     virtual string getType() const { return "Shape"; }
     510             : 
     511             :     // ::com::sun::star::xml::sax::XFastContextHandler:
     512             :     virtual void SAL_CALL startUnknownElement
     513             :     (const OUString & Namespace,
     514             :      const OUString & Name,
     515             :      const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
     516             :         throw (uno::RuntimeException, xml::sax::SAXException);
     517             : 
     518             :     virtual void SAL_CALL endUnknownElement
     519             :     (const OUString & Namespace,
     520             :      const OUString & Name)
     521             :         throw (uno::RuntimeException, xml::sax::SAXException);
     522             : 
     523             :     virtual uno::Reference< xml::sax::XFastContextHandler > SAL_CALL
     524             :     createUnknownChildContext
     525             :     (const OUString & Namespace,
     526             :      const OUString & Name,
     527             :      const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
     528             :         throw (uno::RuntimeException, xml::sax::SAXException);
     529             : 
     530             :     virtual void setToken(Token_t nToken);
     531             : 
     532           5 :     virtual ResourceEnum_t getResource() const { return SHAPE; }
     533             : 
     534             :     void sendShape( Token_t Element );
     535          51 :     bool isShapeSent( ) { return m_bShapeSent; }
     536             : 
     537             : protected:
     538             :     typedef uno::Reference<XFastShapeContextHandler> ShapeContextRef;
     539             :     ShapeContextRef mrShapeContext;
     540             : 
     541             :     virtual void lcl_startFastElement
     542             :     (Token_t Element,
     543             :      const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
     544             :         throw (uno::RuntimeException, xml::sax::SAXException);
     545             : 
     546             :     virtual void lcl_endFastElement(Token_t Element)
     547             :         throw (uno::RuntimeException, xml::sax::SAXException);
     548             : 
     549             :     virtual uno::Reference< xml::sax::XFastContextHandler >
     550             :     lcl_createFastChildContext
     551             :     (Token_t Element,
     552             :      const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
     553             :         throw (uno::RuntimeException, xml::sax::SAXException);
     554             : 
     555             :     virtual void lcl_characters(const OUString & aChars)
     556             :                 throw (uno::RuntimeException, xml::sax::SAXException);
     557             : 
     558             : };
     559             : 
     560             : /**
     561             :    OOXMLFastContextHandlerWrapper wraps an OOXMLFastContextHandler.
     562             : 
     563             :    The method calls for the interface
     564             :    ::com::sun::star::xml::sax::XFastContextHandler are forwarded to the wrapped
     565             :    OOXMLFastContextHandler.
     566             :  */
     567             : class OOXMLFastContextHandlerWrapper : public OOXMLFastContextHandler
     568             : {
     569             : public:
     570             :     explicit OOXMLFastContextHandlerWrapper
     571             :     (OOXMLFastContextHandler * pParent,
     572             :      uno::Reference<XFastContextHandler>  xContext);
     573             :     virtual ~OOXMLFastContextHandlerWrapper();
     574             : 
     575             :     // ::com::sun::star::xml::sax::XFastContextHandler:
     576             :     virtual void SAL_CALL startUnknownElement
     577             :     (const OUString & Namespace,
     578             :      const OUString & Name,
     579             :      const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
     580             :         throw (uno::RuntimeException, xml::sax::SAXException);
     581             : 
     582             :     virtual void SAL_CALL endUnknownElement
     583             :     (const OUString & Namespace,
     584             :      const OUString & Name)
     585             :         throw (uno::RuntimeException, xml::sax::SAXException);
     586             : 
     587             :     virtual uno::Reference< xml::sax::XFastContextHandler > SAL_CALL
     588             :     createUnknownChildContext
     589             :     (const OUString & Namespace,
     590             :      const OUString & Name,
     591             :      const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
     592             :         throw (uno::RuntimeException, xml::sax::SAXException);
     593             : 
     594             :     virtual void attributes
     595             :     (const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
     596             :     throw (uno::RuntimeException, xml::sax::SAXException);
     597             : 
     598             :     virtual ResourceEnum_t getResource() const;
     599             : 
     600             :     void addNamespace(const Id & nId);
     601             :     void addToken( Token_t Element );
     602             : 
     603             :     virtual void newProperty(const Id & rId, OOXMLValue::Pointer_t pVal);
     604             :     virtual void setPropertySet(OOXMLPropertySet::Pointer_t pPropertySet);
     605             :     virtual OOXMLPropertySet::Pointer_t getPropertySet() const;
     606             : 
     607             :     virtual string getType() const;
     608             : 
     609             : protected:
     610             :     virtual void lcl_startFastElement
     611             :     (Token_t Element,
     612             :      const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
     613             :         throw (uno::RuntimeException, xml::sax::SAXException);
     614             : 
     615             :     virtual void lcl_endFastElement(Token_t Element)
     616             :         throw (uno::RuntimeException, xml::sax::SAXException);
     617             : 
     618             :     virtual uno::Reference< xml::sax::XFastContextHandler >
     619             :     lcl_createFastChildContext
     620             :     (Token_t Element,
     621             :      const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
     622             :         throw (uno::RuntimeException, xml::sax::SAXException);
     623             : 
     624             :     virtual void lcl_characters(const OUString & aChars)
     625             :                 throw (uno::RuntimeException, xml::sax::SAXException);
     626             : 
     627             :     virtual void setId(Id nId);
     628             :     virtual Id getId() const;
     629             : 
     630             :     virtual void setToken(Token_t nToken);
     631             :     virtual Token_t getToken() const;
     632             : 
     633             : private:
     634             :     uno::Reference<XFastContextHandler> mxContext;
     635             :     set<Id> mMyNamespaces;
     636             :     set<Token_t> mMyTokens;
     637             :     OOXMLPropertySet::Pointer_t mpPropertySet;
     638             : 
     639             :     OOXMLFastContextHandler * getFastContextHandler() const;
     640             : };
     641             : 
     642             : /**
     643             :  A class that converts from XFastParser/XFastContextHandler usage to a liner XML stream of data.
     644             : 
     645             :  The purpose of this class is to convert the rather complex XFastContextHandler-based XML
     646             :  processing that requires context subclasses, callbacks, etc. into a linear stream of XML tokens
     647             :  that can be handled simply by reading the tokens one by one and directly processing them.
     648             :  See the oox::formulaimport::XmlStream class documentation for more information.
     649             : 
     650             :  Usage: Create a subclass of OOXMLFastContextHandlerLinear, reimplemented getType() to provide
     651             :  type of the subclass and process() to actually process the XML stream. Also make sure to
     652             :  add a line like the following to model.xml (for class OOXMLFastContextHandlerMath):
     653             : 
     654             :  <resource name="CT_OMath" resource="Math"/>
     655             : 
     656             :  @since 3.5
     657             : */
     658          88 : class OOXMLFastContextHandlerLinear: public OOXMLFastContextHandlerProperties
     659             : {
     660             : public:
     661             :     explicit OOXMLFastContextHandlerLinear(OOXMLFastContextHandler * pContext);
     662             :     /**
     663             :      Return the type of the class, as written in model.xml .
     664             :      */
     665             :     virtual string getType() const = 0;
     666             : 
     667             : protected:
     668             :     /**
     669             :      Called when the tokens for the element, its content and sub-elements have been linearized
     670             :      and should be processed. The data member @ref buffer contains the converted data.
     671             :     */
     672             :     virtual void process() = 0;
     673             : 
     674             :     virtual void lcl_startFastElement(Token_t Element, const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
     675             :         throw (uno::RuntimeException, xml::sax::SAXException);
     676             : 
     677             :     virtual void lcl_endFastElement(Token_t Element) throw (uno::RuntimeException, xml::sax::SAXException);
     678             : 
     679             :     virtual uno::Reference< xml::sax::XFastContextHandler > lcl_createFastChildContext(Token_t Element,
     680             :         const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
     681             :         throw (uno::RuntimeException, xml::sax::SAXException);
     682             : 
     683             :     virtual void lcl_characters(const OUString & aChars) throw (uno::RuntimeException, xml::sax::SAXException);
     684             : 
     685             :     // should be private, but not much point in making deep copies of it
     686             :     oox::formulaimport::XmlStreamBuilder buffer;
     687             : 
     688             : private:
     689             :     int depthCount;
     690             : };
     691             : 
     692         176 : class OOXMLFastContextHandlerMath: public OOXMLFastContextHandlerLinear
     693             : {
     694             : public:
     695             :     explicit OOXMLFastContextHandlerMath(OOXMLFastContextHandler * pContext);
     696           0 :     virtual string getType() const { return "Math"; }
     697             : protected:
     698             :     virtual void process();
     699             : };
     700             : 
     701             : }}
     702             : #endif // INCLUDED_OOXML_FAST_CONTEXT_HANDLER_HXX
     703             : 
     704             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10