LCOV - code coverage report
Current view: top level - starmath/source - mathmlimport.hxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 13 13 100.0 %
Date: 2014-04-11 Functions: 7 7 100.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_STARMATH_SOURCE_MATHMLIMPORT_HXX
      21             : #define INCLUDED_STARMATH_SOURCE_MATHMLIMPORT_HXX
      22             : 
      23             : #include <xmloff/xmlimp.hxx>
      24             : #include <xmloff/xmlexp.hxx>
      25             : #include <xmloff/DocumentSettingsContext.hxx>
      26             : #include <xmloff/xmltoken.hxx>
      27             : 
      28             : #include <node.hxx>
      29             : 
      30             : class SfxMedium;
      31             : namespace com { namespace sun { namespace star {
      32             :     namespace io {
      33             :         class XIutputStream; }
      34             :     namespace beans {
      35             :         class XPropertySet; }
      36             : } } }
      37             : 
      38             : 
      39             : 
      40           2 : class SmXMLImportWrapper
      41             : {
      42             :     com::sun::star::uno::Reference<com::sun::star::frame::XModel> xModel;
      43             : 
      44             : public:
      45           2 :     SmXMLImportWrapper(com::sun::star::uno::Reference<com::sun::star::frame::XModel> &rRef)
      46           2 :         : xModel(rRef) {}
      47             : 
      48             :     sal_uLong Import(SfxMedium &rMedium);
      49             : 
      50             :     sal_uLong ReadThroughComponent(
      51             :         ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > xInputStream,
      52             :         ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > xModelComponent,
      53             :         ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > & rxContext,
      54             :         ::com::sun::star::uno::Reference<
      55             :             ::com::sun::star::beans::XPropertySet > & rPropSet,
      56             :         const sal_Char* pFilterName,
      57             :         sal_Bool bEncrypted );
      58             : 
      59             :     sal_uLong ReadThroughComponent(
      60             :          const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage,
      61             :                 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > xModelComponent,
      62             :         const sal_Char* pStreamName,
      63             :         const sal_Char* pCompatibilityStreamName,
      64             :         ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > & rxContext,
      65             :         ::com::sun::star::uno::Reference<
      66             :             ::com::sun::star::beans::XPropertySet > & rPropSet,
      67             :         const sal_Char* pFilterName );
      68             : };
      69             : 
      70             : 
      71             : 
      72             : class SmXMLImport : public SvXMLImport
      73             : {
      74             :         SvXMLTokenMap *pPresLayoutElemTokenMap;
      75             :         SvXMLTokenMap *pPresLayoutAttrTokenMap;
      76             :         SvXMLTokenMap *pFencedAttrTokenMap;
      77             :         SvXMLTokenMap *pOperatorAttrTokenMap;
      78             :         SvXMLTokenMap *pAnnotationAttrTokenMap;
      79             :         SvXMLTokenMap *pPresElemTokenMap;
      80             :         SvXMLTokenMap *pPresScriptEmptyElemTokenMap;
      81             :         SvXMLTokenMap *pPresTableElemTokenMap;
      82             :         SvXMLTokenMap *pColorTokenMap;
      83             : 
      84             :         SmNodeStack aNodeStack;
      85             :         sal_Bool bSuccess;
      86             :         OUString aText;
      87             : 
      88             : public:
      89             :     SmXMLImport(
      90             :         const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > xContext,
      91             :         OUString const & implementationName, sal_uInt16 nImportFlags);
      92             :     virtual ~SmXMLImport() throw ();
      93             : 
      94             :     // XUnoTunnel
      95             :     sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& rId ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      96             :     static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId() throw();
      97             : 
      98             :     void SAL_CALL endDocument(void)
      99             :         throw( ::com::sun::star::xml::sax::SAXException,
     100             :         ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     101             : 
     102             :     SvXMLImportContext *CreateContext(sal_uInt16 nPrefix,
     103             :         const OUString &rLocalName,
     104             :         const com::sun::star::uno::Reference <
     105             :         com::sun::star::xml::sax::XAttributeList> &xAttrList) SAL_OVERRIDE;
     106             :     SvXMLImportContext *CreateMathContext(sal_uInt16 nPrefix,
     107             :         const OUString &rLocalName,
     108             :         const com::sun::star::uno::Reference <
     109             :         com::sun::star::xml::sax::XAttributeList> &xAttrList);
     110             :     SvXMLImportContext *CreateRowContext(sal_uInt16 nPrefix,
     111             :         const OUString &rLocalName,
     112             :         const com::sun::star::uno::Reference <
     113             :         com::sun::star::xml::sax::XAttributeList> &xAttrList);
     114             :     SvXMLImportContext *CreateEncloseContext(sal_uInt16 nPrefix,
     115             :         const OUString &rLocalName,
     116             :         const com::sun::star::uno::Reference <
     117             :         com::sun::star::xml::sax::XAttributeList> &xAttrList);
     118             :     SvXMLImportContext *CreateFracContext(sal_uInt16 nPrefix,
     119             :         const OUString &rLocalName,
     120             :         const com::sun::star::uno::Reference <
     121             :         com::sun::star::xml::sax::XAttributeList> &xAttrList);
     122             :     SvXMLImportContext *CreateNumberContext(sal_uInt16 nPrefix,
     123             :         const OUString &rLocalName,
     124             :         const com::sun::star::uno::Reference <
     125             :         com::sun::star::xml::sax::XAttributeList> &xAttrList);
     126             :     SvXMLImportContext *CreateTextContext(sal_uInt16 nPrefix,
     127             :         const OUString &rLocalName,
     128             :         const com::sun::star::uno::Reference <
     129             :         com::sun::star::xml::sax::XAttributeList> &xAttrList);
     130             :     SvXMLImportContext *CreateAnnotationContext(sal_uInt16 nPrefix,
     131             :         const OUString &rLocalName,
     132             :         const com::sun::star::uno::Reference <
     133             :         com::sun::star::xml::sax::XAttributeList> &xAttrList);
     134             :     SvXMLImportContext *CreateStringContext(sal_uInt16 nPrefix,
     135             :         const OUString &rLocalName,
     136             :         const com::sun::star::uno::Reference <
     137             :         com::sun::star::xml::sax::XAttributeList> &xAttrList);
     138             :     SvXMLImportContext *CreateIdentifierContext(sal_uInt16 nPrefix,
     139             :         const OUString &rLocalName,
     140             :         const com::sun::star::uno::Reference <
     141             :         com::sun::star::xml::sax::XAttributeList> &xAttrList);
     142             :     SvXMLImportContext *CreateOperatorContext(sal_uInt16 nPrefix,
     143             :         const OUString &rLocalName,
     144             :         const com::sun::star::uno::Reference <
     145             :         com::sun::star::xml::sax::XAttributeList> &xAttrList);
     146             :     SvXMLImportContext *CreateSpaceContext(sal_uInt16 nPrefix,
     147             :         const OUString &rLocalName,
     148             :         const com::sun::star::uno::Reference <
     149             :         com::sun::star::xml::sax::XAttributeList> &xAttrList);
     150             :     SvXMLImportContext *CreateSqrtContext(sal_uInt16 nPrefix,
     151             :         const OUString &rLocalName,
     152             :         const com::sun::star::uno::Reference <
     153             :         com::sun::star::xml::sax::XAttributeList> &xAttrList);
     154             :     SvXMLImportContext *CreateRootContext(sal_uInt16 nPrefix,
     155             :         const OUString &rLocalName,
     156             :         const com::sun::star::uno::Reference <
     157             :         com::sun::star::xml::sax::XAttributeList> &xAttrList);
     158             :     SvXMLImportContext *CreateStyleContext(sal_uInt16 nPrefix,
     159             :         const OUString &rLocalName,
     160             :         const com::sun::star::uno::Reference <
     161             :         com::sun::star::xml::sax::XAttributeList> &xAttrList);
     162             :     SvXMLImportContext *CreatePaddedContext(sal_uInt16 nPrefix,
     163             :         const OUString &rLocalName,
     164             :         const com::sun::star::uno::Reference <
     165             :         com::sun::star::xml::sax::XAttributeList> &xAttrList);
     166             :     SvXMLImportContext *CreatePhantomContext(sal_uInt16 nPrefix,
     167             :         const OUString &rLocalName,
     168             :         const com::sun::star::uno::Reference <
     169             :         com::sun::star::xml::sax::XAttributeList> &xAttrList);
     170             :     SvXMLImportContext *CreateFencedContext(sal_uInt16 nPrefix,
     171             :         const OUString &rLocalName,
     172             :         const com::sun::star::uno::Reference <
     173             :         com::sun::star::xml::sax::XAttributeList> &xAttrList);
     174             :     SvXMLImportContext *CreateErrorContext(sal_uInt16 nPrefix,
     175             :         const OUString &rLocalName,
     176             :         const com::sun::star::uno::Reference <
     177             :         com::sun::star::xml::sax::XAttributeList> &xAttrList);
     178             :     SvXMLImportContext *CreateSubContext(sal_uInt16 nPrefix,
     179             :         const OUString &rLocalName,
     180             :         const com::sun::star::uno::Reference <
     181             :         com::sun::star::xml::sax::XAttributeList> &xAttrList);
     182             :     SvXMLImportContext *CreateSupContext(sal_uInt16 nPrefix,
     183             :         const OUString &rLocalName,
     184             :         const com::sun::star::uno::Reference <
     185             :         com::sun::star::xml::sax::XAttributeList> &xAttrList);
     186             :     SvXMLImportContext *CreateSubSupContext(sal_uInt16 nPrefix,
     187             :         const OUString &rLocalName,
     188             :         const com::sun::star::uno::Reference <
     189             :         com::sun::star::xml::sax::XAttributeList> &xAttrList);
     190             :     SvXMLImportContext *CreateUnderContext(sal_uInt16 nPrefix,
     191             :         const OUString &rLocalName,
     192             :         const com::sun::star::uno::Reference <
     193             :         com::sun::star::xml::sax::XAttributeList> &xAttrList);
     194             :     SvXMLImportContext *CreateOverContext(sal_uInt16 nPrefix,
     195             :         const OUString &rLocalName,
     196             :         const com::sun::star::uno::Reference <
     197             :         com::sun::star::xml::sax::XAttributeList> &xAttrList);
     198             :     SvXMLImportContext *CreateUnderOverContext(sal_uInt16 nPrefix,
     199             :         const OUString &rLocalName,
     200             :         const com::sun::star::uno::Reference <
     201             :         com::sun::star::xml::sax::XAttributeList> &xAttrList);
     202             :     SvXMLImportContext *CreateMultiScriptsContext(sal_uInt16 nPrefix,
     203             :         const OUString &rLocalName,
     204             :         const com::sun::star::uno::Reference <
     205             :         com::sun::star::xml::sax::XAttributeList> &xAttrList);
     206             :     SvXMLImportContext *CreateNoneContext(sal_uInt16 nPrefix,
     207             :         const OUString &rLocalName,
     208             :         const com::sun::star::uno::Reference <
     209             :         com::sun::star::xml::sax::XAttributeList> &xAttrList);
     210             :     SvXMLImportContext *CreatePrescriptsContext(sal_uInt16 nPrefix,
     211             :         const OUString &rLocalName,
     212             :         const com::sun::star::uno::Reference <
     213             :         com::sun::star::xml::sax::XAttributeList> &xAttrList);
     214             :     SvXMLImportContext *CreateTableContext(sal_uInt16 nPrefix,
     215             :         const OUString &rLocalName,
     216             :         const com::sun::star::uno::Reference <
     217             :         com::sun::star::xml::sax::XAttributeList> &xAttrList);
     218             :     SvXMLImportContext *CreateTableRowContext(sal_uInt16 nPrefix,
     219             :         const OUString &rLocalName,
     220             :         const com::sun::star::uno::Reference <
     221             :         com::sun::star::xml::sax::XAttributeList> &xAttrList);
     222             :     SvXMLImportContext *CreateTableCellContext(sal_uInt16 nPrefix,
     223             :         const OUString &rLocalName,
     224             :         const com::sun::star::uno::Reference <
     225             :         com::sun::star::xml::sax::XAttributeList> &xAttrList);
     226             :     SvXMLImportContext *CreateAlignGroupContext(sal_uInt16 nPrefix,
     227             :         const OUString &rLocalName,
     228             :         const com::sun::star::uno::Reference <
     229             :         com::sun::star::xml::sax::XAttributeList> &xAttrList);
     230             :     SvXMLImportContext *CreateActionContext(sal_uInt16 nPrefix,
     231             :         const OUString &rLocalName,
     232             :         const com::sun::star::uno::Reference <
     233             :         com::sun::star::xml::sax::XAttributeList> &xAttrList);
     234             : 
     235             :     const SvXMLTokenMap &GetPresLayoutElemTokenMap();
     236             :     const SvXMLTokenMap &GetPresLayoutAttrTokenMap();
     237             :     const SvXMLTokenMap &GetFencedAttrTokenMap();
     238             :     const SvXMLTokenMap &GetOperatorAttrTokenMap();
     239             :     const SvXMLTokenMap &GetAnnotationAttrTokenMap();
     240             :     const SvXMLTokenMap &GetPresElemTokenMap();
     241             :     const SvXMLTokenMap &GetPresScriptEmptyElemTokenMap();
     242             :     const SvXMLTokenMap &GetPresTableElemTokenMap();
     243             :     const SvXMLTokenMap &GetColorTokenMap();
     244             : 
     245          28 :     SmNodeStack & GetNodeStack()    { return aNodeStack; }
     246           4 :     SmNode *GetTree()
     247             :     {
     248           4 :         if (aNodeStack.empty())
     249           2 :             return 0;
     250           2 :         SmNode* result = aNodeStack.top();
     251           2 :         aNodeStack.pop();
     252           2 :         return result;
     253             :     }
     254             : 
     255           4 :     sal_Bool GetSuccess()              { return bSuccess; }
     256           2 :     SAL_WARN_UNUSED_RESULT OUString GetText() { return aText; }
     257           2 :     void SetText(const OUString &rStr) { aText = rStr; }
     258             : 
     259             :     virtual void SetViewSettings(const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& aViewProps) SAL_OVERRIDE;
     260             :     virtual void SetConfigurationSettings(const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& aViewProps) SAL_OVERRIDE;
     261             : };
     262             : 
     263             : 
     264             : 
     265             : enum SmXMLMathElemTokenMap
     266             : {
     267             :     XML_TOK_MATH
     268             : };
     269             : 
     270             : enum SmXMLPresLayoutElemTokenMap
     271             : {
     272             :     XML_TOK_SEMANTICS,
     273             :     XML_TOK_MSTYLE,
     274             :     XML_TOK_MERROR,
     275             :     XML_TOK_MPHANTOM,
     276             :     XML_TOK_MROW,
     277             :     XML_TOK_MENCLOSE,
     278             :     XML_TOK_MFRAC,
     279             :     XML_TOK_MSQRT,
     280             :     XML_TOK_MROOT,
     281             :     XML_TOK_MSUB,
     282             :     XML_TOK_MSUP,
     283             :     XML_TOK_MSUBSUP,
     284             :     XML_TOK_MMULTISCRIPTS,
     285             :     XML_TOK_MUNDER,
     286             :     XML_TOK_MOVER,
     287             :     XML_TOK_MUNDEROVER,
     288             :     XML_TOK_MTABLE,
     289             :     XML_TOK_MACTION,
     290             :     XML_TOK_MFENCED,
     291             :     XML_TOK_MPADDED
     292             : };
     293             : 
     294             : enum SmXMLPresLayoutAttrTokenMap
     295             : {
     296             :     XML_TOK_FONTWEIGHT,
     297             :     XML_TOK_FONTSTYLE,
     298             :     XML_TOK_FONTSIZE,
     299             :     XML_TOK_FONTFAMILY,
     300             :     XML_TOK_COLOR
     301             : };
     302             : 
     303             : 
     304             : enum SmXMLFencedAttrTokenMap
     305             : {
     306             :     XML_TOK_OPEN,
     307             :     XML_TOK_CLOSE
     308             : };
     309             : 
     310             : 
     311             : enum SmXMLPresTableElemTokenMap
     312             : {
     313             :     XML_TOK_MTR,
     314             :     XML_TOK_MTD
     315             : };
     316             : 
     317             : enum SmXMLPresElemTokenMap
     318             : {
     319             :     XML_TOK_ANNOTATION,
     320             :     XML_TOK_MI,
     321             :     XML_TOK_MN,
     322             :     XML_TOK_MO,
     323             :     XML_TOK_MTEXT,
     324             :     XML_TOK_MSPACE,
     325             :     XML_TOK_MS,
     326             :     XML_TOK_MALIGNGROUP
     327             : };
     328             : 
     329             : enum SmXMLPresScriptEmptyElemTokenMap
     330             : {
     331             :     XML_TOK_MPRESCRIPTS,
     332             :     XML_TOK_NONE
     333             : };
     334             : 
     335             : enum SmXMLOperatorAttrTokenMap
     336             : {
     337             :     XML_TOK_STRETCHY
     338             : };
     339             : 
     340             : enum SmXMLAnnotationAttrTokenMap
     341             : {
     342             :     XML_TOK_ENCODING
     343             : };
     344             : 
     345             : 
     346             : 
     347             : #endif
     348             : 
     349             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10