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