xref: /aoo4110/main/xmloff/inc/xmloff/xmlexppr.hxx (revision b1cdbd2c)
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_XMLEXPPR_HXX
25 #define _XMLOFF_XMLEXPPR_HXX
26 
27 #include "sal/config.h"
28 #include "xmloff/dllapi.h"
29 #include <xmloff/xmlprmap.hxx>
30 #include <xmloff/uniref.hxx>
31 
32 namespace rtl { class OUString; }
33 
34 class SvXMLUnitConverter;
35 class SvXMLAttributeList;
36 class SvXMLNamespaceMap;
37 class SvUShorts;
38 class FilterPropertiesInfos_Impl;
39 class SvXMLExport;
40 
41 #define XML_EXPORT_FLAG_DEFAULTS	0x0001		// export also default items
42 #define XML_EXPORT_FLAG_DEEP		0x0002		// export also items from
43 												// parent item sets
44 #define XML_EXPORT_FLAG_EMPTY		0x0004		// export attribs element
45 												// even if its empty
46 #define XML_EXPORT_FLAG_IGN_WS		0x0008
47 
48 class XMLOFF_DLLPUBLIC SvXMLExportPropertyMapper : public UniRefBase
49 {
50 	UniReference< SvXMLExportPropertyMapper> mxNextMapper;
51 
52 	FilterPropertiesInfos_Impl *pCache;
53 
54 protected:
55 	UniReference< XMLPropertySetMapper > maPropMapper;
56 
57 	rtl::OUString maStyleName;
58 
59 	/** Filter all properties we don't want to export:
60 	    Take all properties of the XPropertySet which are also found in the
61         XMLPropertyMapEntry-array and which are not set directly (so, the value isn't
62 		default and isn't inherited, apart from bDefault is true)
63 		After this process It'll called 'Contextfilter' for application-specific
64 		filter-processes. */
65 	::std::vector< XMLPropertyState > _Filter(
66 			const ::com::sun::star::uno::Reference<
67 					::com::sun::star::beans::XPropertySet > rPropSet,
68 			const sal_Bool bDefault ) const;
69 
70 	/** Application-specific filter. By default do nothing. */
71 	virtual void ContextFilter(
72 			::std::vector< XMLPropertyState >& rProperties,
73 		    ::com::sun::star::uno::Reference<
74 					::com::sun::star::beans::XPropertySet > rPropSet ) const;
75 
76 	/** fills the given attribute list with the items in the given set */
77 	void _exportXML( sal_uInt16 nPropType, sal_uInt16& rPropTypeFlags,
78 					 SvXMLAttributeList& rAttrList,
79 		             const ::std::vector< XMLPropertyState >& rProperties,
80 					 const SvXMLUnitConverter& rUnitConverter,
81 					 const SvXMLNamespaceMap& rNamespaceMap,
82 					 sal_uInt16 nFlags,
83 					 SvUShorts* pIndexArray,
84 				  	 sal_Int32 nPropMapStartIdx, sal_Int32 nPropMapEndIdx ) const;
85 
86 	void _exportXML( SvXMLAttributeList& rAttrList,
87 		             const XMLPropertyState& rProperty,
88 					 const SvXMLUnitConverter& rUnitConverter,
89 					 const SvXMLNamespaceMap& rNamespaceMap,
90 					 sal_uInt16 nFlags,
91 					 const ::std::vector< XMLPropertyState > *pProperties = 0,
92 					 sal_uInt32 nIdx = 0 ) const;
93 
94 	void exportElementItems(
95             SvXMLExport& rExport,
96 			const ::std::vector< XMLPropertyState >& rProperties,
97 			sal_uInt16 nFlags,
98 			const SvUShorts& rIndexArray ) const;
99 
100 public:
101 
102 	SvXMLExportPropertyMapper(
103 			const UniReference< XMLPropertySetMapper >& rMapper );
104 	virtual ~SvXMLExportPropertyMapper();
105 
106 	// Add a ExportPropertyMapper at the end of the import mapper chain.
107 	// The added mapper MUST not be used outside the Mapper chain any longer,
108 	// because its PropertyMapper will be replaced.
109 	void ChainExportMapper(
110 		const UniReference< SvXMLExportPropertyMapper>& rMapper );
111 
112 	/** Filter all properties we don't want to export:
113 	    Take all properties of the XPropertySet which are also found in the
114         XMLPropertyMapEntry-array and which are not set directly (so, the value isn't
115 		default and isn't inherited)
116 		After this process It'll called 'Contextfilter' for application-specific
117 		filter-processes. */
Filter(const::com::sun::star::uno::Reference<::com::sun::star::beans::XPropertySet> rPropSet) const118 	::std::vector< XMLPropertyState > Filter(
119 			const ::com::sun::star::uno::Reference<
120 					::com::sun::star::beans::XPropertySet > rPropSet ) const
121 					{ return _Filter(rPropSet, sal_False); }
122 
123 	/** Like Filter(), excepti that:
124 	  * - only properties that have the map flag MID_FLAG_DEFAULT_ITEM_EXPORT
125 	  *   set are exported,
126 	  * - instead of the property's value, its defualt value is exported.
127 	  */
FilterDefaults(const::com::sun::star::uno::Reference<::com::sun::star::beans::XPropertySet> rPropSet) const128 	::std::vector< XMLPropertyState > FilterDefaults(
129 			const ::com::sun::star::uno::Reference<
130 					::com::sun::star::beans::XPropertySet > rPropSet ) const
131 					{ return _Filter(rPropSet, sal_True); }
132 
133 	/** Compare to arrays of XMLPropertyState */
134 	sal_Bool Equals( const ::std::vector< XMLPropertyState >& aProperties1,
135 		             const ::std::vector< XMLPropertyState >& aProperties2 ) const;
136 
137 	/** fills the given attribute list with the items in the given set */
138 	void exportXML(
139 		   SvXMLAttributeList& rAttrList,
140 		   const ::std::vector< XMLPropertyState >& rProperties,
141 		   const SvXMLUnitConverter& rUnitConverter,
142 		   const SvXMLNamespaceMap& rNamespaceMap,
143 		   sal_uInt16 nFlags = 0 ) const;
144 	/** like above but only properties whose property map index is within the
145 	    specified range are exported */
146 	void exportXML(
147 		   SvXMLAttributeList& rAttrList,
148 		   const ::std::vector< XMLPropertyState >& rProperties,
149 		   const SvXMLUnitConverter& rUnitConverter,
150 		   const SvXMLNamespaceMap& rNamespaceMap,
151 		   sal_Int32 nPropMapStartIdx, sal_Int32 nPropMapEndIdx,
152 		   sal_uInt16 nFlags = 0 ) const;
153 
154 	/** fills the given attribute list with the representation of one item */
155 	void exportXML(
156 		   SvXMLAttributeList& rAttrList,
157 		   const XMLPropertyState& rProperty,
158 		   const SvXMLUnitConverter& rUnitConverter,
159 		   const SvXMLNamespaceMap& rNamespaceMap,
160 		   sal_uInt16 nFlags = 0 ) const;
161 
162 	void exportXML(
163             SvXMLExport& rExport,
164 			const ::std::vector< XMLPropertyState >& rProperties,
165 			sal_uInt16 nFlags = 0 ) const;
166 
167 	/** like above but only properties whose property map index is within the
168 	    specified range are exported */
169 	void exportXML(
170             SvXMLExport& rExport,
171 			const ::std::vector< XMLPropertyState >& rProperties,
172 		    sal_Int32 nPropMapStartIdx, sal_Int32 nPropMapEndIdx,
173 			sal_uInt16 nFlags = 0 ) const;
174 
175 	/** this method is called for every item that has the
176 	    MID_FLAG_ELEMENT_EXPORT flag set */
177 	virtual void handleElementItem(
178             SvXMLExport& rExport,
179 			const XMLPropertyState& rProperty,
180 			sal_uInt16 nFlags,
181 			const ::std::vector< XMLPropertyState > *pProperties = 0,
182 			sal_uInt32 nIdx = 0 ) const;
183 
184 	/** this method is called for every item that has the
185 	    MID_FLAG_SPECIAL_ITEM_EXPORT flag set */
186 	virtual void handleSpecialItem(
187 			SvXMLAttributeList& rAttrList,
188 			const XMLPropertyState& rProperty,
189 			const SvXMLUnitConverter& rUnitConverter,
190 			const SvXMLNamespaceMap& rNamespaceMap,
191 			const ::std::vector< XMLPropertyState > *pProperties = 0,
192 			sal_uInt32 nIdx = 0 ) const;
193 
194 	inline const UniReference< XMLPropertySetMapper >&
getPropertySetMapper() const195 		getPropertySetMapper() const { return maPropMapper; }
196 
SetStyleName(const rtl::OUString & rStyleName)197 	void SetStyleName( const rtl::OUString& rStyleName ) { maStyleName = rStyleName; }
198 };
199 
200 #endif	//  _XMLOFF_XMLEXPPR_HXX
201