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