LibreOffice Module xmloff (master) 1
PersMixedContentTContext.cxx
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#include "TransformerBase.hxx"
22
23#include <osl/diagnose.h>
24
25#include <utility>
26
27using namespace ::com::sun::star::uno;
28using namespace ::com::sun::star::xml::sax;
29
30namespace {
31
32class XMLPersTextTContext_Impl : public XMLTransformerContext
33{
34 OUString m_aCharacters;
35
36public:
37 XMLPersTextTContext_Impl( XMLTransformerBase& rTransformer,
38 OUString aChars );
39
41 const OUString& rLocalName,
42 const OUString& rQName,
43 const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList ) override;
44 virtual void StartElement( const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList ) override;
45 virtual void EndElement() override;
46 virtual void Characters( const OUString& rChars ) override;
47
48 virtual bool IsPersistent() const override;
49 virtual void Export() override;
50};
51
52}
53
54XMLPersTextTContext_Impl::XMLPersTextTContext_Impl(
56 OUString aChars ) :
57 XMLTransformerContext( rImp, OUString() ),
58 m_aCharacters(std::move( aChars ))
59{
60}
61
62rtl::Reference<XMLTransformerContext> XMLPersTextTContext_Impl::CreateChildContext(
63 sal_uInt16,
64 const OUString&,
65 const OUString&,
66 const Reference< XAttributeList >& )
67{
68 OSL_ENSURE( false, "illegal call to CreateChildContext" );
69 return {};
70}
71
72void XMLPersTextTContext_Impl::StartElement(
73 const Reference< XAttributeList >& )
74{
75 OSL_ENSURE( false, "illegal call to StartElement" );
76}
77
78void XMLPersTextTContext_Impl::EndElement()
79{
80 OSL_ENSURE( false, "illegal call to EndElement" );
81}
82
83bool XMLPersTextTContext_Impl::IsPersistent() const
84{
85 return true;
86}
87
88void XMLPersTextTContext_Impl::Characters( const OUString& rChars )
89{
90 m_aCharacters += rChars;
91}
92
93void XMLPersTextTContext_Impl::Export()
94{
95 GetTransformer().GetDocHandler()->characters( m_aCharacters );
96}
97
100 const OUString& rQName ) :
101 XMLPersElemContentTContext( rImp, rQName )
102{
103}
104
106 XMLTransformerBase& rImp,
107 const OUString& rQName,
108 sal_uInt16 nActionMap ) :
109 XMLPersElemContentTContext( rImp, rQName, nActionMap )
110{
111}
112
114 XMLTransformerBase& rImp,
115 const OUString& rQName,
116 sal_uInt16 nPrefix,
118 XMLPersElemContentTContext( rImp, rQName, nPrefix, eToken )
119{
120}
121
123 XMLTransformerBase& rImp,
124 const OUString& rQName,
125 sal_uInt16 nPrefix,
127 sal_uInt16 nActionMap ) :
128 XMLPersElemContentTContext( rImp, rQName, nPrefix, eToken, nActionMap )
129{
130}
131
133{
134}
135
136void XMLPersMixedContentTContext::Characters( const OUString& rChars )
137{
138 AddContent( new XMLPersTextTContext_Impl( GetTransformer(), rChars ) );
139}
140
141/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OUString m_aCharacters
void AddContent(rtl::Reference< XMLTransformerContext > const &pContent)
virtual void Characters(const OUString &rChars) override
XMLPersMixedContentTContext(XMLTransformerBase &rTransformer, const OUString &rQName)
virtual rtl::Reference< XMLTransformerContext > CreateChildContext(sal_uInt16 nPrefix, const OUString &rLocalName, const OUString &rQName, const css::uno::Reference< css::xml::sax::XAttributeList > &xAttrList)
virtual void Characters(const OUString &rChars)
XMLTransformerBase & GetTransformer()
virtual void StartElement(const css::uno::Reference< css::xml::sax::XAttributeList > &xAttrList)
virtual bool IsPersistent() const
XMLTokenEnum
The enumeration of all XML tokens.
Definition: xmltoken.hxx:50
XMLTokenEnum eToken
Definition: xmltoken.cxx:40