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

Generated by: LCOV version 1.10