1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: PersMixedContentTContext.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_xmloff.hxx"
34 #ifndef _XMLOFF_TRANSFORMERBASE_HXX
35 #include "TransformerBase.hxx"
37 #include "PersMixedContentTContext.hxx"
39 using ::rtl::OUString
;
40 using namespace ::com::sun::star::uno
;
41 using namespace ::com::sun::star::xml::sax
;
43 //------------------------------------------------------------------------------
44 class XMLPersTextTContext_Impl
: public XMLTransformerContext
46 ::rtl::OUString m_aCharacters
;
51 XMLPersTextTContext_Impl( XMLTransformerBase
& rTransformer
,
52 const ::rtl::OUString
& rChars
);
53 virtual ~XMLPersTextTContext_Impl();
55 virtual XMLTransformerContext
*CreateChildContext( sal_uInt16 nPrefix
,
56 const ::rtl::OUString
& rLocalName
,
57 const ::rtl::OUString
& rQName
,
58 const ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
);
59 virtual void StartElement( const ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
);
60 virtual void EndElement();
61 virtual void Characters( const ::rtl::OUString
& rChars
);
63 virtual sal_Bool
IsPersistent() const;
64 virtual void Export();
65 const ::rtl::OUString
& GetText() const { return m_aCharacters
; }
68 TYPEINIT1( XMLPersTextTContext_Impl
, XMLTransformerContext
);
70 XMLPersTextTContext_Impl::XMLPersTextTContext_Impl(
71 XMLTransformerBase
& rImp
,
72 const OUString
& rChars
) :
73 XMLTransformerContext( rImp
, OUString() ),
74 m_aCharacters( rChars
)
78 XMLPersTextTContext_Impl::~XMLPersTextTContext_Impl()
82 XMLTransformerContext
*XMLPersTextTContext_Impl::CreateChildContext(
86 const Reference
< XAttributeList
>& )
88 OSL_ENSURE( !this, "illegal call to CreateChildContext" );
92 void XMLPersTextTContext_Impl::StartElement(
93 const Reference
< XAttributeList
>& )
95 OSL_ENSURE( !this, "illegal call to StartElement" );
98 void XMLPersTextTContext_Impl::EndElement()
100 OSL_ENSURE( !this, "illegal call to EndElement" );
103 sal_Bool
XMLPersTextTContext_Impl::IsPersistent() const
108 void XMLPersTextTContext_Impl::Characters( const OUString
& rChars
)
110 m_aCharacters
+= rChars
;
113 void XMLPersTextTContext_Impl::Export()
115 GetTransformer().GetDocHandler()->characters( m_aCharacters
);
118 //------------------------------------------------------------------------------
120 TYPEINIT1( XMLPersMixedContentTContext
, XMLPersElemContentTContext
);
122 XMLPersMixedContentTContext::XMLPersMixedContentTContext(
123 XMLTransformerBase
& rImp
,
124 const OUString
& rQName
) :
125 XMLPersElemContentTContext( rImp
, rQName
)
129 XMLPersMixedContentTContext::XMLPersMixedContentTContext(
130 XMLTransformerBase
& rImp
,
131 const OUString
& rQName
,
132 sal_uInt16 nActionMap
) :
133 XMLPersElemContentTContext( rImp
, rQName
, nActionMap
)
137 XMLPersMixedContentTContext::XMLPersMixedContentTContext(
138 XMLTransformerBase
& rImp
,
139 const OUString
& rQName
,
141 ::xmloff::token::XMLTokenEnum eToken
) :
142 XMLPersElemContentTContext( rImp
, rQName
, nPrefix
, eToken
)
146 XMLPersMixedContentTContext::XMLPersMixedContentTContext(
147 XMLTransformerBase
& rImp
,
148 const OUString
& rQName
,
150 ::xmloff::token::XMLTokenEnum eToken
,
151 sal_uInt16 nActionMap
) :
152 XMLPersElemContentTContext( rImp
, rQName
, nPrefix
, eToken
, nActionMap
)
156 XMLPersMixedContentTContext::~XMLPersMixedContentTContext()
160 void XMLPersMixedContentTContext::Characters( const OUString
& rChars
)
162 AddContent( new XMLPersTextTContext_Impl( GetTransformer(), rChars
) );