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 #pragma once
21 
22 #include <xmloff/xmlimp.hxx>
23 #include <xmloff/xmlnamespace.hxx>
24 #include <xmloff/xmltkmap.hxx>
25 #include <com/sun/star/xml/sax/FastToken.hpp>
26 #include <sax/fastattribs.hxx>
27 
28 namespace com::sun::star::xml::sax { class XFastTokenHandler; }
29 
30 using namespace css::xml::sax;
31 using namespace xmloff::token;
32 
33 class SwXMLTextBlocks;
34 class SwXMLBlockListImport final : public SvXMLImport
35 {
36 private:
38 
39  // This method is called after the namespace map has been updated, but
40  // before a context for the current element has been pushed.
41  virtual SvXMLImportContext* CreateFastContext( sal_Int32 Element,
42  const css::uno::Reference< css::xml::sax::XFastAttributeList > & xAttrList ) override;
43 
44 public:
46  const css::uno::Reference< css::uno::XComponentContext >& rContext,
47  SwXMLTextBlocks &rBlocks );
48 
50  {
51  return m_rBlockList;
52  }
53  virtual ~SwXMLBlockListImport()
54  noexcept override;
55 };
56 
57 class SwXMLTextBlockImport final : public SvXMLImport
58 {
59  // This method is called after the namespace map has been updated, but
60  // before a context for the current element has been pushed.
61  virtual SvXMLImportContext* CreateFastContext( sal_Int32 Element,
62  const css::uno::Reference< css::xml::sax::XFastAttributeList > & xAttrList ) override;
63 
64 public:
66  OUString &m_rText;
68  const css::uno::Reference< css::uno::XComponentContext >& rContext,
69  OUString &rNewText, bool bNewTextOnly );
70 
71  virtual ~SwXMLTextBlockImport()
72  noexcept override;
73  virtual void SAL_CALL endDocument() override;
74 };
75 
76 enum SwXMLTextBlockToken : sal_Int32
77 {
78  OFFICE_BODY = FastToken::NAMESPACE | XML_NAMESPACE_OFFICE | XML_BODY,
79  OFFICE_TEXT = FastToken::NAMESPACE | XML_NAMESPACE_OFFICE | XML_TEXT,
82  TEXT_P = FastToken::NAMESPACE | XML_NAMESPACE_TEXT | XML_P
83 };
84 
87 {
88 public:
90  virtual ~SwXMLTextBlockTokenHandler() override;
91 
92  //XFastTokenHandler
93  sal_Int32 SAL_CALL getTokenFromUTF8( const css::uno::Sequence< sal_Int8 >& Identifier ) override;
94  css::uno::Sequence< sal_Int8 > SAL_CALL getUTF8Identifier( sal_Int32 Token ) override;
95 
96  //Much fast direct C++ shortcut to the method that matters
97  virtual sal_Int32 getTokenDirect( const char *pTag, sal_Int32 nLength ) const override;
98 };
99 
100 enum SwXMLBlockListToken : sal_Int32
101 {
103  BLOCK = FastToken::NAMESPACE | XML_NAMESPACE_BLOCKLIST | XML_BLOCK,
105  LIST_NAME = FastToken::NAMESPACE | XML_NAMESPACE_BLOCKLIST | XML_LIST_NAME,
106  NAME = FastToken::NAMESPACE | XML_NAMESPACE_BLOCKLIST | XML_NAME,
109 };
110 
113 {
114 public:
116  virtual ~SwXMLBlockListTokenHandler() override;
117 
118  //XFastTokenHandler
119  sal_Int32 SAL_CALL getTokenFromUTF8( const css::uno::Sequence< sal_Int8 >& Identifier ) override;
120  css::uno::Sequence< sal_Int8 > SAL_CALL getUTF8Identifier( sal_Int32 Token ) override;
121 
122  //Much fast direct C++ shortcut to the method that matters
123  virtual sal_Int32 getTokenDirect( const char *pTag, sal_Int32 nLength ) const override;
124 };
125 
126 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
NAME
XML_DOCUMENT_CONTENT
constexpr sal_uInt16 XML_NAMESPACE_OFFICE
XML_DOCUMENT
XML_BLOCK_LIST
XML_TEXT
XML_PACKAGE_NAME
XML_BODY
SwXMLTextBlocks & m_rBlockList
constexpr sal_uInt16 XML_NAMESPACE_BLOCKLIST
XML_P
XML_LIST_NAME
constexpr sal_uInt16 XML_NAMESPACE_TEXT
SwXMLTextBlockToken
SwXMLTextBlocks & getBlockList()
SwXMLBlockListToken
XML_ABBREVIATED_NAME
XML_UNFORMATTED_TEXT
sal_Int32 nLength
XML_NAME
BLOCK
XML_BLOCK