1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_xmloff.hxx"
26 
27 #ifndef _XMLOFF_TRANSFORMERBASE_HXX
28 #include "TransformerBase.hxx"
29 #endif
30 #include "PersMixedContentTContext.hxx"
31 
32 using ::rtl::OUString;
33 using namespace ::com::sun::star::uno;
34 using namespace ::com::sun::star::xml::sax;
35 
36 //------------------------------------------------------------------------------
37 class XMLPersTextTContext_Impl : public XMLTransformerContext
38 {
39 	::rtl::OUString m_aCharacters;
40 
41 public:
42 	TYPEINFO();
43 
44 	XMLPersTextTContext_Impl( XMLTransformerBase& rTransformer,
45 						   const ::rtl::OUString& rChars );
46 	virtual ~XMLPersTextTContext_Impl();
47 
48 	virtual XMLTransformerContext *CreateChildContext( sal_uInt16 nPrefix,
49 								   const ::rtl::OUString& rLocalName,
50 								   const ::rtl::OUString& rQName,
51 								   const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList );
52 	virtual void StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList );
53 	virtual void EndElement();
54 	virtual void Characters( const ::rtl::OUString& rChars );
55 
56 	virtual sal_Bool IsPersistent() const;
57 	virtual void Export();
58 	const ::rtl::OUString& GetText() const { return m_aCharacters; }
59 };
60 
61 TYPEINIT1( XMLPersTextTContext_Impl, XMLTransformerContext );
62 
63 XMLPersTextTContext_Impl::XMLPersTextTContext_Impl(
64 		XMLTransformerBase& rImp,
65 		const OUString& rChars ) :
66 	XMLTransformerContext( rImp, OUString() ),
67 	m_aCharacters( rChars )
68 {
69 }
70 
71 XMLPersTextTContext_Impl::~XMLPersTextTContext_Impl()
72 {
73 }
74 
75 XMLTransformerContext *XMLPersTextTContext_Impl::CreateChildContext(
76 		sal_uInt16,
77 		const OUString&,
78 		const OUString&,
79 		const Reference< XAttributeList >& )
80 {
81 	OSL_ENSURE( !this, "illegal call to CreateChildContext" );
82 	return 0;
83 }
84 
85 void XMLPersTextTContext_Impl::StartElement(
86 	const Reference< XAttributeList >& )
87 {
88 	OSL_ENSURE( !this, "illegal call to StartElement" );
89 }
90 
91 void XMLPersTextTContext_Impl::EndElement()
92 {
93 	OSL_ENSURE( !this, "illegal call to EndElement" );
94 }
95 
96 sal_Bool XMLPersTextTContext_Impl::IsPersistent() const
97 {
98 	return sal_True;
99 }
100 
101 void XMLPersTextTContext_Impl::Characters( const OUString& rChars )
102 {
103 	m_aCharacters += rChars;
104 }
105 
106 void XMLPersTextTContext_Impl::Export()
107 {
108 	GetTransformer().GetDocHandler()->characters( m_aCharacters );
109 }
110 
111 //------------------------------------------------------------------------------
112 
113 TYPEINIT1( XMLPersMixedContentTContext, XMLPersElemContentTContext );
114 
115 XMLPersMixedContentTContext::XMLPersMixedContentTContext(
116 		XMLTransformerBase& rImp,
117 		const OUString& rQName ) :
118 	XMLPersElemContentTContext( rImp, rQName )
119 {
120 }
121 
122 XMLPersMixedContentTContext::XMLPersMixedContentTContext(
123 		XMLTransformerBase& rImp,
124 		const OUString& rQName,
125 	   sal_uInt16 nActionMap ) :
126 	XMLPersElemContentTContext( rImp, rQName, nActionMap )
127 {
128 }
129 
130 XMLPersMixedContentTContext::XMLPersMixedContentTContext(
131 		XMLTransformerBase& rImp,
132 		const OUString& rQName,
133 	    sal_uInt16 nPrefix,
134 		::xmloff::token::XMLTokenEnum eToken ) :
135 	XMLPersElemContentTContext( rImp, rQName, nPrefix, eToken )
136 {
137 }
138 
139 XMLPersMixedContentTContext::XMLPersMixedContentTContext(
140 		XMLTransformerBase& rImp,
141 		const OUString& rQName,
142 	    sal_uInt16 nPrefix,
143 		::xmloff::token::XMLTokenEnum eToken,
144 	   sal_uInt16 nActionMap ) :
145 	XMLPersElemContentTContext( rImp, rQName, nPrefix, eToken, nActionMap )
146 {
147 }
148 
149 XMLPersMixedContentTContext::~XMLPersMixedContentTContext()
150 {
151 }
152 
153 void XMLPersMixedContentTContext::Characters( const OUString& rChars )
154 {
155 	AddContent( new XMLPersTextTContext_Impl( GetTransformer(), rChars ) );
156 }
157