LibreOffice Module sw (master)  1
SwXMLBlockImport.hxx
Go to the documentation of this file.
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/xmlnmspe.hxx>
25 #include <com/sun/star/xml/sax/FastToken.hpp>
26 #include <sax/fastattribs.hxx>
27 #include <cppuhelper/implbase.hxx>
28 
29 namespace com::sun::star::xml::sax { class XFastTokenHandler; }
30 
31 using namespace css::xml::sax;
32 using namespace xmloff::token;
33 
34 class SwXMLTextBlocks;
36 {
37 private:
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 ) override;
45 
46 public:
48  const css::uno::Reference< css::uno::XComponentContext >& rContext,
49  SwXMLTextBlocks &rBlocks );
50 
52  {
53  return rBlockList;
54  }
55  virtual ~SwXMLBlockListImport()
56  throw() override;
57 };
58 
60 {
61 protected:
62  // This method is called after the namespace map has been updated, but
63  // before a context for the current element has been pushed.
64  virtual SvXMLImportContext* CreateFastContext( sal_Int32 Element,
65  const css::uno::Reference< css::xml::sax::XFastAttributeList > & xAttrList ) override;
66 
67 public:
68  bool const bTextOnly;
69  OUString &m_rText;
71  const css::uno::Reference< css::uno::XComponentContext >& rContext,
72  OUString &rNewText, bool bNewTextOnly );
73 
74  virtual ~SwXMLTextBlockImport()
75  throw() override;
76  virtual void SAL_CALL endDocument() override;
77 };
78 
79 enum SwXMLTextBlockToken : sal_Int32
80 {
81  OFFICE_BODY = FastToken::NAMESPACE | XML_NAMESPACE_OFFICE | XML_BODY,
82  OFFICE_TEXT = FastToken::NAMESPACE | XML_NAMESPACE_OFFICE | XML_TEXT,
83  OFFICE_DOCUMENT = FastToken::NAMESPACE | XML_NAMESPACE_OFFICE | XML_DOCUMENT,
84  OFFICE_DOCUMENT_CONTENT = FastToken::NAMESPACE | XML_NAMESPACE_OFFICE | XML_DOCUMENT_CONTENT,
85  TEXT_P = FastToken::NAMESPACE | XML_NAMESPACE_TEXT | XML_P
86 };
87 
89  cppu::WeakImplHelper< css::xml::sax::XFastTokenHandler >,
91 {
92 public:
94  virtual ~SwXMLTextBlockTokenHandler() override;
95 
96  //XFastTokenHandler
97  sal_Int32 SAL_CALL getTokenFromUTF8( const css::uno::Sequence< sal_Int8 >& Identifier ) override;
98  css::uno::Sequence< sal_Int8 > SAL_CALL getUTF8Identifier( sal_Int32 Token ) override;
99 
100  //Much fast direct C++ shortcut to the method that matters
101  virtual sal_Int32 getTokenDirect( const char *pTag, sal_Int32 nLength ) const override;
102 };
103 
104 enum SwXMLBlockListToken : sal_Int32
105 {
106  ABBREVIATED_NAME = FastToken::NAMESPACE | XML_NAMESPACE_BLOCKLIST | XML_ABBREVIATED_NAME,
107  BLOCK = FastToken::NAMESPACE | XML_NAMESPACE_BLOCKLIST | XML_BLOCK,
108  BLOCK_LIST = FastToken::NAMESPACE | XML_NAMESPACE_BLOCKLIST | XML_BLOCK_LIST,
109  LIST_NAME = FastToken::NAMESPACE | XML_NAMESPACE_BLOCKLIST | XML_LIST_NAME,
110  NAME = FastToken::NAMESPACE | XML_NAMESPACE_BLOCKLIST | XML_NAME,
111  PACKAGE_NAME = FastToken::NAMESPACE | XML_NAMESPACE_BLOCKLIST | XML_PACKAGE_NAME,
112  UNFORMATTED_TEXT = FastToken::NAMESPACE | XML_NAMESPACE_BLOCKLIST | XML_UNFORMATTED_TEXT
113 };
114 
116  cppu::WeakImplHelper< css::xml::sax::XFastTokenHandler >,
118 {
119 public:
121  virtual ~SwXMLBlockListTokenHandler() override;
122 
123  //XFastTokenHandler
124  sal_Int32 SAL_CALL getTokenFromUTF8( const css::uno::Sequence< sal_Int8 >& Identifier ) override;
125  css::uno::Sequence< sal_Int8 > SAL_CALL getUTF8Identifier( sal_Int32 Token ) override;
126 
127  //Much fast direct C++ shortcut to the method that matters
128  virtual sal_Int32 getTokenDirect( const char *pTag, sal_Int32 nLength ) const override;
129 };
130 
131 #endif
132 
133 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
NAME
XML_NAME
XML_UNFORMATTED_TEXT
XML_ABBREVIATED_NAME
XML_BODY
SwXMLTextBlocks & rBlockList
XML_PACKAGE_NAME
XML_LIST_NAME
SwXMLTextBlockToken
XML_TEXT
SwXMLTextBlocks & getBlockList()
SwXMLBlockListToken
XML_BLOCK_LIST
XML_DOCUMENT
XML_DOCUMENT_CONTENT
XML_BLOCK
XML_P
sal_Int32 const nLength
BLOCK