LCOV - code coverage report
Current view: top level - sw/source/core/inc - SwXMLBlockImport.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 2 2 100.0 %
Date: 2015-06-13 12:38:46 Functions: 1 1 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_SW_SOURCE_CORE_INC_SWXMLBLOCKIMPORT_HXX
      21             : #define INCLUDED_SW_SOURCE_CORE_INC_SWXMLBLOCKIMPORT_HXX
      22             : 
      23             : #include <xmloff/xmlimp.hxx>
      24             : #include <xmloff/nmspmap.hxx>
      25             : #include <xmloff/xmlnmspe.hxx>
      26             : #include <com/sun/star/xml/sax/XFastTokenHandler.hpp>
      27             : #include <com/sun/star/xml/sax/FastToken.hpp>
      28             : #include <sax/fastattribs.hxx>
      29             : #include <cppuhelper/implbase.hxx>
      30             : 
      31             : using namespace css::xml::sax;
      32             : using namespace xmloff::token;
      33             : 
      34             : class SwXMLTextBlocks;
      35             : class SwXMLBlockListImport : public SvXMLImport
      36             : {
      37             : private:
      38             :     SwXMLTextBlocks &rBlockList;
      39             : 
      40             : protected:
      41             :     // This method is called after the namespace map has been updated, but
      42             :     // before a context for the current element has been pushed.
      43             :     virtual SvXMLImportContext* CreateFastContext( sal_Int32 Element,
      44             :         const css::uno::Reference< css::xml::sax::XFastAttributeList > & xAttrList ) SAL_OVERRIDE;
      45             : 
      46             : public:
      47             :     SwXMLBlockListImport(
      48             :         const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rContext,
      49             :         SwXMLTextBlocks &rBlocks );
      50             : 
      51         100 :     SwXMLTextBlocks& getBlockList()
      52             :     {
      53         100 :         return rBlockList;
      54             :     }
      55             :     virtual ~SwXMLBlockListImport()
      56             :         throw();
      57             : };
      58             : 
      59             : class SwXMLTextBlockImport : public SvXMLImport
      60             : {
      61             : private:
      62             :     SwXMLTextBlocks &rBlockList;
      63             : 
      64             : protected:
      65             :     // This method is called after the namespace map has been updated, but
      66             :     // before a context for the current element has been pushed.
      67             :     virtual SvXMLImportContext* CreateFastContext( sal_Int32 Element,
      68             :         const css::uno::Reference< css::xml::sax::XFastAttributeList > & xAttrList ) SAL_OVERRIDE;
      69             : 
      70             : public:
      71             :     bool bTextOnly;
      72             :     OUString &m_rText;
      73             :     SwXMLTextBlockImport(
      74             :         const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rContext,
      75             :         SwXMLTextBlocks &rBlocks, OUString &rNewText, bool bNewTextOnly );
      76             : 
      77             :     SwXMLTextBlocks& getBlockList()
      78             :     {
      79             :         return rBlockList;
      80             :     }
      81             :     virtual ~SwXMLTextBlockImport()
      82             :         throw();
      83             :     virtual void SAL_CALL endDocument()
      84             :         throw( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
      85             : };
      86             : 
      87             : enum SwXMLTextBlockToken : sal_Int32
      88             : {
      89             :     OFFICE_BODY = FastToken::NAMESPACE | XML_NAMESPACE_OFFICE | XML_BODY,
      90             :     OFFICE_TEXT = FastToken::NAMESPACE | XML_NAMESPACE_OFFICE | XML_TEXT,
      91             :     OFFICE_DOCUMENT = FastToken::NAMESPACE | XML_NAMESPACE_OFFICE | XML_DOCUMENT,
      92             :     OFFICE_DOCUMENT_CONTENT = FastToken::NAMESPACE | XML_NAMESPACE_OFFICE | XML_DOCUMENT_CONTENT,
      93             :     TEXT_P = FastToken::NAMESPACE | XML_NAMESPACE_TEXT | XML_P
      94             : };
      95             : 
      96             : class SwXMLTextBlockTokenHandler : public
      97             :         cppu::WeakImplHelper< css::xml::sax::XFastTokenHandler >,
      98             :         public sax_fastparser::FastTokenHandlerBase
      99             : {
     100             : public:
     101             :     SwXMLTextBlockTokenHandler();
     102             :     virtual ~SwXMLTextBlockTokenHandler();
     103             : 
     104             :     //XFastTokenHandler
     105             :     sal_Int32 SAL_CALL getTokenFromUTF8( const css::uno::Sequence< sal_Int8 >& Identifier )
     106             :         throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     107             :     css::uno::Sequence< sal_Int8 > SAL_CALL getUTF8Identifier( sal_Int32 Token )
     108             :         throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     109             : 
     110             :     //Much fast direct C++ shortcut to the method that matters
     111             :     virtual sal_Int32 getTokenDirect( const char *pTag, sal_Int32 nLength ) const SAL_OVERRIDE;
     112             : };
     113             : 
     114             : enum SwXMLBlockListToken : sal_Int32
     115             : {
     116             :     ABBREVIATED_NAME = FastToken::NAMESPACE | XML_NAMESPACE_BLOCKLIST | XML_ABBREVIATED_NAME,
     117             :     BLOCK = FastToken::NAMESPACE | XML_NAMESPACE_BLOCKLIST | XML_BLOCK,
     118             :     BLOCK_LIST = FastToken::NAMESPACE | XML_NAMESPACE_BLOCKLIST | XML_BLOCK_LIST,
     119             :     LIST_NAME = FastToken::NAMESPACE | XML_NAMESPACE_BLOCKLIST | XML_LIST_NAME,
     120             :     NAME = FastToken::NAMESPACE | XML_NAMESPACE_BLOCKLIST | XML_NAME,
     121             :     PACKAGE_NAME = FastToken::NAMESPACE | XML_NAMESPACE_BLOCKLIST | XML_PACKAGE_NAME,
     122             :     UNFORMATTED_TEXT = FastToken::NAMESPACE | XML_NAMESPACE_BLOCKLIST | XML_UNFORMATTED_TEXT
     123             : };
     124             : 
     125             : class SwXMLBlockListTokenHandler : public
     126             :         cppu::WeakImplHelper< css::xml::sax::XFastTokenHandler >,
     127             :         public sax_fastparser::FastTokenHandlerBase
     128             : {
     129             : public:
     130             :     SwXMLBlockListTokenHandler();
     131             :     virtual ~SwXMLBlockListTokenHandler();
     132             : 
     133             :     //XFastTokenHandler
     134             :     sal_Int32 SAL_CALL getTokenFromUTF8( const css::uno::Sequence< sal_Int8 >& Identifier )
     135             :         throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     136             :     css::uno::Sequence< sal_Int8 > SAL_CALL getUTF8Identifier( sal_Int32 Token )
     137             :         throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     138             : 
     139             :     //Much fast direct C++ shortcut to the method that matters
     140             :     virtual sal_Int32 getTokenDirect( const char *pTag, sal_Int32 nLength ) const SAL_OVERRIDE;
     141             : };
     142             : 
     143             : #endif
     144             : 
     145             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11