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 #ifndef _XMLOFF_PERSATTRLISTTCONTEXT_HXX
25 #define _XMLOFF_PERSATTRLISTTCONTEXT_HXX
26 
27 #include <xmloff/xmltoken.hxx>
28 #include "TransformerContext.hxx"
29 
30 
31 class XMLPersAttrListTContext : public XMLTransformerContext
32 {
33 
34 	::com::sun::star::uno::Reference<
35 		::com::sun::star::xml::sax::XAttributeList > m_xAttrList;
36 	::rtl::OUString m_aElemQName;
37 	sal_uInt16 m_nActionMap;
38 
39 protected:
40 
SetExportQName(const::rtl::OUString & r)41 	void SetExportQName( const ::rtl::OUString& r ) { m_aElemQName = r; }
42 
43 public:
44 	TYPEINFO();
45 
46 	// A contexts constructor does anything that is required if an element
47 	// starts. Namespace processing has been done already.
48 	// Note that virtual methods cannot be used inside constructors. Use
49 	// StartElement instead if this is required.
50 	XMLPersAttrListTContext( XMLTransformerBase& rTransformer,
51 						   const ::rtl::OUString& rQName );
52 
53 	// attr list persistence + attribute processing
54 	XMLPersAttrListTContext( XMLTransformerBase& rTransformer,
55 						   const ::rtl::OUString& rQName,
56 		   				   sal_uInt16 nActionMap );
57 
58 	// attr list persistence + renaming
59 	XMLPersAttrListTContext( XMLTransformerBase& rTransformer,
60 						   const ::rtl::OUString& rQName,
61 		   				   sal_uInt16 nPrefix,
62 		   				   ::xmloff::token::XMLTokenEnum eToken );
63 
64 	// attr list persistence + renaming + attribute processing
65 	XMLPersAttrListTContext( XMLTransformerBase& rTransformer,
66 						   const ::rtl::OUString& rQName,
67 		   				   sal_uInt16 nPrefix,
68 		   				   ::xmloff::token::XMLTokenEnum eToken,
69 		   				   sal_uInt16 nActionMap );
70 
71 	// A contexts destructor does anything that is required if an element
72 	// ends. By default, nothing is done.
73 	// Note that virtual methods cannot be used inside destructors. Use
74 	// EndElement instead if this is required.
75 	virtual ~XMLPersAttrListTContext();
76 
77 	// Create a childs element context. By default, the import's
78 	// CreateContext method is called to create a new default context.
79 	virtual XMLTransformerContext *CreateChildContext( sal_uInt16 nPrefix,
80 								   const ::rtl::OUString& rLocalName,
81 								   const ::rtl::OUString& rQName,
82 								   const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList );
83 
84 	// StartElement is called after a context has been constructed and
85 	// before a elements context is parsed. It may be used for actions that
86 	// require virtual methods. The default is to do nothing.
87 	virtual void StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList );
88 
89 	// EndElement is called before a context will be destructed, but
90 	// after a elements context has been parsed. It may be used for actions
91 	// that require virtual methods. The default is to do nothing.
92 	virtual void EndElement();
93 
94 	// This method is called for all characters that are contained in the
95 	// current element.
96 	virtual void Characters( const ::rtl::OUString& rChars );
97 
98 	virtual sal_Bool IsPersistent() const;
99 	virtual void Export();
100 	virtual void ExportContent();
101 
GetExportQName() const102 	const ::rtl::OUString& GetExportQName() const { return m_aElemQName; }
103 
104 	void AddAttribute( sal_uInt16 nAPrefix,
105 		::xmloff::token::XMLTokenEnum eAToken,
106 	   	::xmloff::token::XMLTokenEnum eVToken );
107 
108 	void AddAttribute( sal_uInt16 nAPrefix,
109 		::xmloff::token::XMLTokenEnum eAToken,
110         const ::rtl::OUString & rValue );
111 
112 	::com::sun::star::uno::Reference<
113 		::com::sun::star::xml::sax::XAttributeList >
114         GetAttrList() const;
115 };
116 
117 #endif	//  _XMLOFF_PERSATTRLISTTCONTEXT_HXX
118 
119