LibreOffice Module xmloff (master)  1
TransformerContext.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_XMLOFF_SOURCE_TRANSFORM_TRANSFORMERCONTEXT_HXX
21 #define INCLUDED_XMLOFF_SOURCE_TRANSFORM_TRANSFORMERCONTEXT_HXX
22 
23 #include <com/sun/star/xml/sax/XAttributeList.hpp>
25 #include <rtl/ref.hxx>
26 #include <rtl/ustring.hxx>
27 #include <xmloff/namespacemap.hxx>
28 #include <xmloff/xmltoken.hxx>
29 #include <memory>
30 
31 class SvXMLNamespaceMap;
32 class XMLTransformerBase;
33 
35 {
36  friend class XMLTransformerBase;
37 
39 
40  OUString m_aQName;
41 
42  std::unique_ptr<SvXMLNamespaceMap> m_xRewindMap;
43 
44  std::unique_ptr<SvXMLNamespaceMap> TakeRewindMap() { return std::move(m_xRewindMap); }
45  void PutRewindMap( std::unique_ptr<SvXMLNamespaceMap> p ) { m_xRewindMap = std::move(p); }
46 
47 protected:
48 
51 
52  void SetQName( const OUString& rQName ) { m_aQName = rQName; }
53 
54 public:
55  const OUString& GetQName() const { return m_aQName; }
56  bool HasQName( sal_uInt16 nPrefix,
58  bool HasNamespace( sal_uInt16 nPrefix ) const;
59 
60  // A contexts constructor does anything that is required if an element
61  // starts. Namespace processing has been done already.
62  // Note that virtual methods cannot be used inside constructors. Use
63  // StartElement instead if this is required.
65  const OUString& rQName );
66 
67  // Create a children element context. By default, the import's
68  // CreateContext method is called to create a new default context.
70  const OUString& rLocalName,
71  const OUString& rQName,
72  const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList );
73 
74  // StartElement is called after a context has been constructed and
75  // before an elements context is parsed. It may be used for actions that
76  // require virtual methods. The default is to do nothing.
77  virtual void StartElement( const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList );
78 
79  // EndElement is called before a context will be destructed, but
80  // after an elements context has been parsed. It may be used for actions
81  // that require virtual methods. The default is to do nothing.
82  virtual void EndElement();
83 
84  // This method is called for all characters that are contained in the
85  // current element. The default is to ignore them.
86  virtual void Characters( const OUString& rChars );
87 
88  // Is the current context a persistent one (i.e. one that saves is content
89  // rather than exporting it directly?
90  virtual bool IsPersistent() const;
91 
92  // Export the whole element. By default, nothing is done here
93  virtual void Export();
94 
95  // Export the element content. By default, nothing is done here
96  virtual void ExportContent();
97 };
98 
99 
100 #endif // INCLUDED_XMLOFF_SOURCE_TRANSFORM_TRANSFORMERCONTEXT_HXX
101 
102 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const XMLTransformerBase & GetTransformer() const
XMLTransformerBase & m_rTransformer
std::unique_ptr< SvXMLNamespaceMap > TakeRewindMap()
XMLTokenEnum
The enumeration of all XML tokens.
Definition: xmltoken.hxx:49
bool HasQName(sal_uInt16 nPrefix,::xmloff::token::XMLTokenEnum eToken) const
bool HasNamespace(sal_uInt16 nPrefix) const
void SetQName(const OUString &rQName)
virtual void Characters(const OUString &rChars)
XMLTransformerContext(XMLTransformerBase &rTransformer, const OUString &rQName)
virtual void StartElement(const css::uno::Reference< css::xml::sax::XAttributeList > &xAttrList)
XMLTransformerBase & GetTransformer()
std::unique_ptr< SvXMLNamespaceMap > m_xRewindMap
void PutRewindMap(std::unique_ptr< SvXMLNamespaceMap > p)
virtual bool IsPersistent() const
XMLTokenEnum eToken
Definition: xmltoken.cxx:40
const OUString & GetQName() const
virtual rtl::Reference< XMLTransformerContext > CreateChildContext(sal_uInt16 nPrefix, const OUString &rLocalName, const OUString &rQName, const css::uno::Reference< css::xml::sax::XAttributeList > &xAttrList)