1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "TransformerBase.hxx"
21 #include "PersMixedContentTContext.hxx"
23 #include <osl/diagnose.h>
25 using namespace ::com::sun::star::uno
;
26 using namespace ::com::sun::star::xml::sax
;
28 class XMLPersTextTContext_Impl
: public XMLTransformerContext
30 OUString m_aCharacters
;
33 XMLPersTextTContext_Impl( XMLTransformerBase
& rTransformer
,
34 const OUString
& rChars
);
35 virtual ~XMLPersTextTContext_Impl() override
;
37 virtual rtl::Reference
<XMLTransformerContext
> CreateChildContext( sal_uInt16 nPrefix
,
38 const OUString
& rLocalName
,
39 const OUString
& rQName
,
40 const css::uno::Reference
< css::xml::sax::XAttributeList
>& xAttrList
) override
;
41 virtual void StartElement( const css::uno::Reference
< css::xml::sax::XAttributeList
>& xAttrList
) override
;
42 virtual void EndElement() override
;
43 virtual void Characters( const OUString
& rChars
) override
;
45 virtual bool IsPersistent() const override
;
46 virtual void Export() override
;
49 XMLPersTextTContext_Impl::XMLPersTextTContext_Impl(
50 XMLTransformerBase
& rImp
,
51 const OUString
& rChars
) :
52 XMLTransformerContext( rImp
, OUString() ),
53 m_aCharacters( rChars
)
57 XMLPersTextTContext_Impl::~XMLPersTextTContext_Impl()
61 rtl::Reference
<XMLTransformerContext
> XMLPersTextTContext_Impl::CreateChildContext(
65 const Reference
< XAttributeList
>& )
67 OSL_ENSURE( false, "illegal call to CreateChildContext" );
71 void XMLPersTextTContext_Impl::StartElement(
72 const Reference
< XAttributeList
>& )
74 OSL_ENSURE( false, "illegal call to StartElement" );
77 void XMLPersTextTContext_Impl::EndElement()
79 OSL_ENSURE( false, "illegal call to EndElement" );
82 bool XMLPersTextTContext_Impl::IsPersistent() const
87 void XMLPersTextTContext_Impl::Characters( const OUString
& rChars
)
89 m_aCharacters
+= rChars
;
92 void XMLPersTextTContext_Impl::Export()
94 GetTransformer().GetDocHandler()->characters( m_aCharacters
);
97 XMLPersMixedContentTContext::XMLPersMixedContentTContext(
98 XMLTransformerBase
& rImp
,
99 const OUString
& rQName
) :
100 XMLPersElemContentTContext( rImp
, rQName
)
104 XMLPersMixedContentTContext::XMLPersMixedContentTContext(
105 XMLTransformerBase
& rImp
,
106 const OUString
& rQName
,
107 sal_uInt16 nActionMap
) :
108 XMLPersElemContentTContext( rImp
, rQName
, nActionMap
)
112 XMLPersMixedContentTContext::XMLPersMixedContentTContext(
113 XMLTransformerBase
& rImp
,
114 const OUString
& rQName
,
116 ::xmloff::token::XMLTokenEnum eToken
) :
117 XMLPersElemContentTContext( rImp
, rQName
, nPrefix
, eToken
)
121 XMLPersMixedContentTContext::XMLPersMixedContentTContext(
122 XMLTransformerBase
& rImp
,
123 const OUString
& rQName
,
125 ::xmloff::token::XMLTokenEnum eToken
,
126 sal_uInt16 nActionMap
) :
127 XMLPersElemContentTContext( rImp
, rQName
, nPrefix
, eToken
, nActionMap
)
131 XMLPersMixedContentTContext::~XMLPersMixedContentTContext()
135 void XMLPersMixedContentTContext::Characters( const OUString
& rChars
)
137 AddContent( new XMLPersTextTContext_Impl( GetTransformer(), rChars
) );
140 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */