Debian Codegraph @

xmloff/source/transform/PersMixedContentTContext.cxx

raw
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"
21 #include "PersMixedContentTContext.hxx"
22
23 #include <osl/diagnose.h>
24
25 #include <utility>
26
27 using namespace ::com::sun::star::uno;
28 using namespace ::com::sun::star::xml::sax;
29
30 namespace {
31
32 class XMLPersTextTContext_Impl : public XMLTransformerContext
33 {
34 OUString m_aCharacters;
35
36 public:
37 XMLPersTextTContext_Impl( XMLTransformerBase& rTransformer,
38 OUString aChars );
39
40 virtual rtl::Reference<XMLTransformerContext> CreateChildContext( sal_uInt16 nPrefix,
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
54 XMLPersTextTContext_Impl::XMLPersTextTContext_Impl(
55 XMLTransformerBase& rImp,
56 OUString aChars ) :
57 XMLTransformerContext( rImp, OUString() ),
58 m_aCharacters(std::move( aChars ))
59 {
60 }
61
62 rtl::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
72 void XMLPersTextTContext_Impl::StartElement(
73 const Reference< XAttributeList >& )
74 {
75 OSL_ENSURE( false, "illegal call to StartElement" );
76 }
77
78 void XMLPersTextTContext_Impl::EndElement()
79 {
80 OSL_ENSURE( false, "illegal call to EndElement" );
81 }
82
83 bool XMLPersTextTContext_Impl::IsPersistent() const
84 {
85 return true;
86 }
87
88 void XMLPersTextTContext_Impl::Characters( const OUString& rChars )
89 {
90 m_aCharacters += rChars;
91 }
92
93 void XMLPersTextTContext_Impl::Export()
94 {
95 GetTransformer().GetDocHandler()->characters( m_aCharacters );
96 }
97
98 XMLPersMixedContentTContext::XMLPersMixedContentTContext(
99 XMLTransformerBase& rImp,
100 const OUString& rQName ) :
101 XMLPersElemContentTContext( rImp, rQName )
102 {
103 }
104
105 XMLPersMixedContentTContext::XMLPersMixedContentTContext(
106 XMLTransformerBase& rImp,
107 const OUString& rQName,
108 sal_uInt16 nActionMap ) :
109 XMLPersElemContentTContext( rImp, rQName, nActionMap )
110 {
111 }
112
113 XMLPersMixedContentTContext::XMLPersMixedContentTContext(
114 XMLTransformerBase& rImp,
115 const OUString& rQName,
116 sal_uInt16 nPrefix,
117 ::xmloff::token::XMLTokenEnum eToken ) :
118 XMLPersElemContentTContext( rImp, rQName, nPrefix, eToken )
119 {
120 }
121
122 XMLPersMixedContentTContext::XMLPersMixedContentTContext(
123 XMLTransformerBase& rImp,
124 const OUString& rQName,
125 sal_uInt16 nPrefix,
126 ::xmloff::token::XMLTokenEnum eToken,
127 sal_uInt16 nActionMap ) :
128 XMLPersElemContentTContext( rImp, rQName, nPrefix, eToken, nActionMap )
129 {
130 }
131
132 XMLPersMixedContentTContext::~XMLPersMixedContentTContext()
133 {
134 }
135
136 void XMLPersMixedContentTContext::Characters( const OUString& rChars )
137 {
138 AddContent( new XMLPersTextTContext_Impl( GetTransformer(), rChars ) );
139 }
140
141 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */