xref: /aoo42x/main/sw/source/filter/xml/xmlexpit.hxx (revision 1d2dbeb0)
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 _XMLITMPR_HXX
25 #define _XMLITMPR_HXX
26 
27 #include <tools/solar.h>
28 #include <tools/ref.hxx>
29 #include "xmlitmap.hxx"
30 
31 #define XML_EXPORT_FLAG_DEFAULTS	0x0001		// export also default items
32 #define XML_EXPORT_FLAG_DEEP		0x0002		// export also items from
33 												// parent item sets
34 #define XML_EXPORT_FLAG_EMPTY		0x0004		// export attribs element
35 												// even if its empty
36 #define XML_EXPORT_FLAG_IGN_WS		0x0008
37 
38 namespace rtl { class OUString; }
39 class SvXMLUnitConverter;
40 class SfxPoolItem;
41 class SfxItemSet;
42 class SvXMLAttributeList;
43 class SvXMLNamespaceMap;
44 class SvUShorts;
45 class SvXMLExport;
46 
47 
48 class SvXMLExportItemMapper
49 {
50 protected:
51 	SvXMLItemMapEntriesRef mrMapEntries;
52 
53 	/** fills the given attribute list with the items in the given set */
54 	void exportXML( const SvXMLExport& rExport,
55 					SvXMLAttributeList& rAttrList,
56 					const SfxItemSet& rSet,
57 					const SvXMLUnitConverter& rUnitConverter,
58 					const SvXMLNamespaceMap& rNamespaceMap,
59 					sal_uInt16 nFlags,
60 					SvUShorts* pIndexArray ) const;
61 
62 	void exportXML( const SvXMLExport& rExport,
63 					SvXMLAttributeList& rAttrList,
64 					const SfxPoolItem& rItem,
65 					const SvXMLItemMapEntry &rEntry,
66 					const SvXMLUnitConverter& rUnitConverter,
67 					const SvXMLNamespaceMap& rNamespaceMap,
68 					sal_uInt16 nFlags,
69 				    const SfxItemSet *pSet ) const;
70 
71 
72 	void exportElementItems(  SvXMLExport& rExport,
73 							  const SvXMLUnitConverter& rUnitConverter,
74 							  const SfxItemSet &rSet,
75 							  sal_uInt16 nFlags,
76 							  const SvUShorts& rIndexArray ) const;
77 
78 	static const SfxPoolItem* GetItem( const SfxItemSet &rSet,
79 									   sal_uInt16 nWhichId,
80 									   sal_uInt16 nFlags );
81 
82 public:
83 	SvXMLExportItemMapper( SvXMLItemMapEntriesRef rMapEntries );
84 	virtual ~SvXMLExportItemMapper();
85 
86 	void exportXML( SvXMLExport& rExport,
87 					const SfxItemSet& rSet,
88 					const SvXMLUnitConverter& rUnitConverter,
89 					::xmloff::token::XMLTokenEnum ePropToken,
90 					sal_uInt16 nFlags = 0 ) const;
91 
92 	/** this method is called for every item that has the
93 		MID_SW_FLAG_SPECIAL_ITEM_EXPORT flag set */
94 	virtual void handleSpecialItem( SvXMLAttributeList& rAttrList,
95 									const SvXMLItemMapEntry& rEntry,
96 									const SfxPoolItem& rItem,
97 									const SvXMLUnitConverter& rUnitConverter,
98 									const SvXMLNamespaceMap& rNamespaceMap,
99 									const SfxItemSet *pSet = NULL ) const;
100 
101 
102 	/** this method is called for every item that has the
103 		MID_SW_FLAG_NO_ITEM_EXPORT flag set */
104 	virtual void handleNoItem( SvXMLAttributeList& rAttrList,
105 							   const SvXMLItemMapEntry& rEntry,
106 							   const SvXMLUnitConverter& rUnitConverter,
107 							   const SvXMLNamespaceMap& rNamespaceMap,
108 							   const SfxItemSet& rSet ) const;
109 
110 	/** this method is called for every item that has the
111 		MID_SW_FLAG_ELEMENT_EXPORT flag set */
112 	virtual void handleElementItem( SvXMLExport& rExport,
113 									const SvXMLItemMapEntry& rEntry,
114 									const SfxPoolItem& rItem,
115 									const SvXMLUnitConverter& rUnitConverter,
116 									const SfxItemSet& rSet,
117 									sal_uInt16 nFlags ) const;
118 
119 	inline void setMapEntries( SvXMLItemMapEntriesRef rMapEntries );
120 
121     static sal_Bool QueryXMLValue( const SfxPoolItem& rItem,
122                                  ::rtl::OUString& rValue, sal_uInt16 nMemberId,
123                                  const SvXMLUnitConverter& rUnitConverter );
124 };
125 
126 inline void
setMapEntries(SvXMLItemMapEntriesRef rMapEntries)127 SvXMLExportItemMapper::setMapEntries( SvXMLItemMapEntriesRef rMapEntries )
128 {
129 	mrMapEntries = rMapEntries;
130 }
131 
132 #endif	//  _XMLITMPR_HXX
133