1*ecfe53c5SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*ecfe53c5SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*ecfe53c5SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*ecfe53c5SAndrew Rist  * distributed with this work for additional information
6*ecfe53c5SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*ecfe53c5SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*ecfe53c5SAndrew Rist  * "License"); you may not use this file except in compliance
9*ecfe53c5SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*ecfe53c5SAndrew Rist  *
11*ecfe53c5SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*ecfe53c5SAndrew Rist  *
13*ecfe53c5SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*ecfe53c5SAndrew Rist  * software distributed under the License is distributed on an
15*ecfe53c5SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*ecfe53c5SAndrew Rist  * KIND, either express or implied.  See the License for the
17*ecfe53c5SAndrew Rist  * specific language governing permissions and limitations
18*ecfe53c5SAndrew Rist  * under the License.
19*ecfe53c5SAndrew Rist  *
20*ecfe53c5SAndrew Rist  *************************************************************/
21*ecfe53c5SAndrew Rist 
22*ecfe53c5SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef _XMLOFF_TRANSFORMERCONTEXT_HXX
25cdf0e10cSrcweir #define _XMLOFF_TRANSFORMERCONTEXT_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <com/sun/star/xml/sax/XAttributeList.hpp>
28cdf0e10cSrcweir #include <tools/solar.h>
29cdf0e10cSrcweir #include <salhelper/simplereferenceobject.hxx>
30cdf0e10cSrcweir #include <rtl/ustring.hxx>
31cdf0e10cSrcweir #include <tools/rtti.hxx>
32cdf0e10cSrcweir #include <xmloff/xmltoken.hxx>
33cdf0e10cSrcweir 
34cdf0e10cSrcweir class SvXMLNamespaceMap;
35cdf0e10cSrcweir class XMLTransformerBase;
36cdf0e10cSrcweir 
37cdf0e10cSrcweir class XMLTransformerContext : public ::salhelper::SimpleReferenceObject
38cdf0e10cSrcweir {
39cdf0e10cSrcweir 	friend class XMLTransformerBase;
40cdf0e10cSrcweir 
41cdf0e10cSrcweir 	XMLTransformerBase& m_rTransformer;
42cdf0e10cSrcweir 
43cdf0e10cSrcweir 	::rtl::OUString m_aQName;
44cdf0e10cSrcweir 
45cdf0e10cSrcweir 	SvXMLNamespaceMap	*m_pRewindMap;
46cdf0e10cSrcweir 
GetRewindMap() const47cdf0e10cSrcweir 	SvXMLNamespaceMap  *GetRewindMap() const { return m_pRewindMap; }
SetRewindMap(SvXMLNamespaceMap * p)48cdf0e10cSrcweir 	void SetRewindMap( SvXMLNamespaceMap *p ) { m_pRewindMap = p; }
49cdf0e10cSrcweir 
50cdf0e10cSrcweir protected:
51cdf0e10cSrcweir 
GetTransformer()52cdf0e10cSrcweir 	XMLTransformerBase& GetTransformer() { return m_rTransformer; }
GetTransformer() const53cdf0e10cSrcweir 	const XMLTransformerBase& GetTransformer() const { return m_rTransformer; }
54cdf0e10cSrcweir 
SetQName(const::rtl::OUString & rQName)55cdf0e10cSrcweir 	void SetQName( const ::rtl::OUString& rQName ) { m_aQName = rQName; }
56cdf0e10cSrcweir 
57cdf0e10cSrcweir public:
58cdf0e10cSrcweir 	TYPEINFO();
59cdf0e10cSrcweir 
GetQName() const60cdf0e10cSrcweir 	const ::rtl::OUString& GetQName() const { return m_aQName; }
61cdf0e10cSrcweir 	sal_Bool HasQName( sal_uInt16 nPrefix,
62cdf0e10cSrcweir 					   ::xmloff::token::XMLTokenEnum eToken ) const;
63cdf0e10cSrcweir 	sal_Bool HasNamespace( sal_uInt16 nPrefix ) const;
64cdf0e10cSrcweir 
65cdf0e10cSrcweir 	// A contexts constructor does anything that is required if an element
66cdf0e10cSrcweir 	// starts. Namespace processing has been done already.
67cdf0e10cSrcweir 	// Note that virtual methods cannot be used inside constructors. Use
68cdf0e10cSrcweir 	// StartElement instead if this is required.
69cdf0e10cSrcweir 	XMLTransformerContext( XMLTransformerBase& rTransformer,
70cdf0e10cSrcweir 						const ::rtl::OUString& rQName );
71cdf0e10cSrcweir 
72cdf0e10cSrcweir 	// A contexts destructor does anything that is required if an element
73cdf0e10cSrcweir 	// ends. By default, nothing is done.
74cdf0e10cSrcweir 	// Note that virtual methods cannot be used inside destructors. Use
75cdf0e10cSrcweir 	// EndElement instead if this is required.
76cdf0e10cSrcweir 	virtual ~XMLTransformerContext();
77cdf0e10cSrcweir 
78cdf0e10cSrcweir 	// Create a childs element context. By default, the import's
79cdf0e10cSrcweir 	// CreateContext method is called to create a new default context.
80cdf0e10cSrcweir 	virtual XMLTransformerContext *CreateChildContext( sal_uInt16 nPrefix,
81cdf0e10cSrcweir 								   const ::rtl::OUString& rLocalName,
82cdf0e10cSrcweir 								   const ::rtl::OUString& rQName,
83cdf0e10cSrcweir 								   const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList );
84cdf0e10cSrcweir 
85cdf0e10cSrcweir 	// StartElement is called after a context has been constructed and
86cdf0e10cSrcweir 	// before a elements context is parsed. It may be used for actions that
87cdf0e10cSrcweir 	// require virtual methods. The default is to do nothing.
88cdf0e10cSrcweir 	virtual void StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList );
89cdf0e10cSrcweir 
90cdf0e10cSrcweir 	// EndElement is called before a context will be destructed, but
91cdf0e10cSrcweir 	// after a elements context has been parsed. It may be used for actions
92cdf0e10cSrcweir 	// that require virtual methods. The default is to do nothing.
93cdf0e10cSrcweir 	virtual void EndElement();
94cdf0e10cSrcweir 
95cdf0e10cSrcweir 	// This method is called for all characters that are contained in the
96cdf0e10cSrcweir 	// current element. The default is to ignore them.
97cdf0e10cSrcweir 	virtual void Characters( const ::rtl::OUString& rChars );
98cdf0e10cSrcweir 
99cdf0e10cSrcweir 	// Is the current context a persistent one (i.e. one that saves is content
100cdf0e10cSrcweir 	// rather than exporting it directly?
101cdf0e10cSrcweir 	virtual sal_Bool IsPersistent() const;
102cdf0e10cSrcweir 
103cdf0e10cSrcweir 	// Export the whole element. By default, nothing is done here
104cdf0e10cSrcweir 	virtual void Export();
105cdf0e10cSrcweir 
106cdf0e10cSrcweir 	// Export the element content. By default, nothing is done here
107cdf0e10cSrcweir 	virtual void ExportContent();
108cdf0e10cSrcweir };
109cdf0e10cSrcweir 
110cdf0e10cSrcweir 
111cdf0e10cSrcweir #endif	//  _XMLOFF_TRANSFORMERCONTEXT_HXX
112cdf0e10cSrcweir 
113