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