Line data Source code
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 :
21 : #include "TransformerBase.hxx"
22 : #include "PersMixedContentTContext.hxx"
23 :
24 : using namespace ::com::sun::star::uno;
25 : using namespace ::com::sun::star::xml::sax;
26 :
27 : //------------------------------------------------------------------------------
28 : class XMLPersTextTContext_Impl : public XMLTransformerContext
29 : {
30 : OUString m_aCharacters;
31 :
32 : public:
33 : TYPEINFO();
34 :
35 : XMLPersTextTContext_Impl( XMLTransformerBase& rTransformer,
36 : const OUString& rChars );
37 : virtual ~XMLPersTextTContext_Impl();
38 :
39 : virtual XMLTransformerContext *CreateChildContext( sal_uInt16 nPrefix,
40 : const OUString& rLocalName,
41 : const OUString& rQName,
42 : const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList );
43 : virtual void StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList );
44 : virtual void EndElement();
45 : virtual void Characters( const OUString& rChars );
46 :
47 : virtual sal_Bool IsPersistent() const;
48 : virtual void Export();
49 : const OUString& GetText() const { return m_aCharacters; }
50 : };
51 :
52 0 : TYPEINIT1( XMLPersTextTContext_Impl, XMLTransformerContext );
53 :
54 0 : XMLPersTextTContext_Impl::XMLPersTextTContext_Impl(
55 : XMLTransformerBase& rImp,
56 : const OUString& rChars ) :
57 : XMLTransformerContext( rImp, OUString() ),
58 0 : m_aCharacters( rChars )
59 : {
60 0 : }
61 :
62 0 : XMLPersTextTContext_Impl::~XMLPersTextTContext_Impl()
63 : {
64 0 : }
65 :
66 0 : XMLTransformerContext *XMLPersTextTContext_Impl::CreateChildContext(
67 : sal_uInt16,
68 : const OUString&,
69 : const OUString&,
70 : const Reference< XAttributeList >& )
71 : {
72 : OSL_ENSURE( !this, "illegal call to CreateChildContext" );
73 0 : return 0;
74 : }
75 :
76 0 : void XMLPersTextTContext_Impl::StartElement(
77 : const Reference< XAttributeList >& )
78 : {
79 : OSL_ENSURE( !this, "illegal call to StartElement" );
80 0 : }
81 :
82 0 : void XMLPersTextTContext_Impl::EndElement()
83 : {
84 : OSL_ENSURE( !this, "illegal call to EndElement" );
85 0 : }
86 :
87 0 : sal_Bool XMLPersTextTContext_Impl::IsPersistent() const
88 : {
89 0 : return sal_True;
90 : }
91 :
92 0 : void XMLPersTextTContext_Impl::Characters( const OUString& rChars )
93 : {
94 0 : m_aCharacters += rChars;
95 0 : }
96 :
97 0 : void XMLPersTextTContext_Impl::Export()
98 : {
99 0 : GetTransformer().GetDocHandler()->characters( m_aCharacters );
100 0 : }
101 :
102 : //------------------------------------------------------------------------------
103 :
104 0 : TYPEINIT1( XMLPersMixedContentTContext, XMLPersElemContentTContext );
105 :
106 58 : XMLPersMixedContentTContext::XMLPersMixedContentTContext(
107 : XMLTransformerBase& rImp,
108 : const OUString& rQName ) :
109 58 : XMLPersElemContentTContext( rImp, rQName )
110 : {
111 58 : }
112 :
113 29 : XMLPersMixedContentTContext::XMLPersMixedContentTContext(
114 : XMLTransformerBase& rImp,
115 : const OUString& rQName,
116 : sal_uInt16 nActionMap ) :
117 29 : XMLPersElemContentTContext( rImp, rQName, nActionMap )
118 : {
119 29 : }
120 :
121 0 : XMLPersMixedContentTContext::XMLPersMixedContentTContext(
122 : XMLTransformerBase& rImp,
123 : const OUString& rQName,
124 : sal_uInt16 nPrefix,
125 : ::xmloff::token::XMLTokenEnum eToken ) :
126 0 : XMLPersElemContentTContext( rImp, rQName, nPrefix, eToken )
127 : {
128 0 : }
129 :
130 0 : XMLPersMixedContentTContext::XMLPersMixedContentTContext(
131 : XMLTransformerBase& rImp,
132 : const OUString& rQName,
133 : sal_uInt16 nPrefix,
134 : ::xmloff::token::XMLTokenEnum eToken,
135 : sal_uInt16 nActionMap ) :
136 0 : XMLPersElemContentTContext( rImp, rQName, nPrefix, eToken, nActionMap )
137 : {
138 0 : }
139 :
140 174 : XMLPersMixedContentTContext::~XMLPersMixedContentTContext()
141 : {
142 174 : }
143 :
144 0 : void XMLPersMixedContentTContext::Characters( const OUString& rChars )
145 : {
146 0 : AddContent( new XMLPersTextTContext_Impl( GetTransformer(), rChars ) );
147 0 : }
148 :
149 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|