xref: /aoo41x/main/xmloff/source/style/xmlbahdl.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef _XMLOFF_PROPERTYHANDLER_BASICTYPES_HXX
29 #define _XMLOFF_PROPERTYHANDLER_BASICTYPES_HXX
30 
31 #include <xmloff/xmlprhdl.hxx>
32 #include <rtl/ustrbuf.hxx>
33 #include <xmloff/xmltoken.hxx>
34 
35 
36 /**
37     PropertyHandler for the XML-data-type: XML_TYPE_NUMBER
38 */
39 class XMLNumberPropHdl : public XMLPropertyHandler
40 {
41 	sal_Int8 nBytes;
42 
43 public:
44 	XMLNumberPropHdl( sal_Int8 nB=4 ) : nBytes( nB ) {}
45 	virtual ~XMLNumberPropHdl();
46 
47 	virtual sal_Bool importXML( const ::rtl::OUString& rStrImpValue, ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const;
48 	virtual sal_Bool exportXML( ::rtl::OUString& rStrExpValue, const ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const;
49 };
50 
51 /**
52     PropertyHandler for the XML-data-type: XML_TYPE_NUMBER_NONE
53 */
54 class XMLNumberNonePropHdl : public XMLPropertyHandler
55 {
56 	::rtl::OUString	sZeroStr;
57 	sal_Int8		nBytes;
58 public:
59 	XMLNumberNonePropHdl( sal_Int8 nB = 4 );
60 	XMLNumberNonePropHdl( enum ::xmloff::token::XMLTokenEnum eZeroString, sal_Int8 nB = 4 );
61 	virtual ~XMLNumberNonePropHdl();
62 
63 	virtual sal_Bool importXML( const ::rtl::OUString& rStrImpValue, ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const;
64 	virtual sal_Bool exportXML( ::rtl::OUString& rStrExpValue, const ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const;
65 };
66 
67 /**
68     PropertyHandler for the XML-data-type: XML_TYPE_MEASURE
69 */
70 class XMLMeasurePropHdl : public XMLPropertyHandler
71 {
72 	sal_Int8 nBytes;
73 public:
74 	XMLMeasurePropHdl( sal_Int8 nB=4 ) : nBytes( nB ) {}
75 	virtual ~XMLMeasurePropHdl();
76 
77 	virtual sal_Bool importXML( const ::rtl::OUString& rStrImpValue, ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const;
78 	virtual sal_Bool exportXML( ::rtl::OUString& rStrExpValue, const ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const;
79 };
80 
81 /**
82     PropertyHandler for the XML-data-type: XML_TYPE_PERCENT
83 */
84 class XMLPercentPropHdl : public XMLPropertyHandler
85 {
86 	sal_Int8 nBytes;
87 public:
88 	XMLPercentPropHdl( sal_Int8 nB=4 ) : nBytes( nB ) {}
89 	virtual ~XMLPercentPropHdl();
90 
91 	virtual sal_Bool importXML( const ::rtl::OUString& rStrImpValue, ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const;
92 	virtual sal_Bool exportXML( ::rtl::OUString& rStrExpValue, const ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const;
93 };
94 
95 /**
96     PropertyHandler for the XML-data-type: XML_TYPE_PERCENT
97 	that is mapped on a double from 0.0 to 1.0
98 */
99 class XMLDoublePercentPropHdl : public XMLPropertyHandler
100 {
101 	virtual sal_Bool importXML( const ::rtl::OUString& rStrImpValue, ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const;
102 	virtual sal_Bool exportXML( ::rtl::OUString& rStrExpValue, const ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const;
103 };
104 
105 /**
106     PropertyHandler for the XML-data-type: XML_TYPE_NEG_PERCENT
107 */
108 class XMLNegPercentPropHdl : public XMLPropertyHandler
109 {
110 	sal_Int8 nBytes;
111 public:
112 	XMLNegPercentPropHdl( sal_Int8 nB=4 ) : nBytes( nB ) {}
113 	virtual ~XMLNegPercentPropHdl();
114 
115 	virtual sal_Bool importXML( const ::rtl::OUString& rStrImpValue, ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const;
116 	virtual sal_Bool exportXML( ::rtl::OUString& rStrExpValue, const ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const;
117 };
118 
119 /**
120     PropertyHandler for the XML-data-type: XML_TYPE_PERCENT
121 */
122 class XMLMeasurePxPropHdl : public XMLPropertyHandler
123 {
124 	sal_Int8 nBytes;
125 public:
126 	XMLMeasurePxPropHdl( sal_Int8 nB=4 ) : nBytes( nB ) {}
127 	virtual ~XMLMeasurePxPropHdl();
128 
129 	virtual sal_Bool importXML( const ::rtl::OUString& rStrImpValue, ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const;
130 	virtual sal_Bool exportXML( ::rtl::OUString& rStrExpValue, const ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const;
131 };
132 
133 /**
134     PropertyHandler for the XML-data-type: XML_TYPE_BOOL
135 */
136 class XMLBoolPropHdl : public XMLPropertyHandler
137 {
138 public:
139 	virtual ~XMLBoolPropHdl();
140 
141 	virtual sal_Bool importXML( const ::rtl::OUString& rStrImpValue, ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const;
142 	virtual sal_Bool exportXML( ::rtl::OUString& rStrExpValue, const ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const;
143 };
144 
145 /**
146     PropertyHandler for the XML-data-type: XML_TYPE_COLOR
147 */
148 class XMLColorPropHdl : public XMLPropertyHandler
149 {
150 public:
151 	virtual ~XMLColorPropHdl();
152 
153 	virtual sal_Bool importXML( const ::rtl::OUString& rStrImpValue, ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const;
154 	virtual sal_Bool exportXML( ::rtl::OUString& rStrExpValue, const ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const;
155 };
156 
157 /**
158     PropertyHandler for the XML-data-type: XML_TYPE_STRING
159 */
160 class XMLStringPropHdl : public XMLPropertyHandler
161 {
162 public:
163 	virtual ~XMLStringPropHdl();
164 
165 	virtual sal_Bool importXML( const ::rtl::OUString& rStrImpValue, ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const;
166 	virtual sal_Bool exportXML( ::rtl::OUString& rStrExpValue, const ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const;
167 };
168 
169 /**
170     PropertyHandler for the XML-data-type: XML_TYPE_STYLENAME
171 */
172 class XMLStyleNamePropHdl : public XMLStringPropHdl
173 {
174 public:
175 	virtual ~XMLStyleNamePropHdl();
176 
177 	virtual sal_Bool exportXML( ::rtl::OUString& rStrExpValue, const ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const;
178 };
179 
180 
181 /**
182 	PropertyHandler for the XML-data-type: XML_TYPE_DOUBLE
183 */
184 class XMLDoublePropHdl : public XMLPropertyHandler
185 {
186 public:
187 	virtual ~XMLDoublePropHdl();
188 
189 	virtual sal_Bool importXML( const ::rtl::OUString& rStrImpValue, ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const;
190 	virtual sal_Bool exportXML( ::rtl::OUString& rStrExpValue, const ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const;
191 };
192 
193 /**
194     PropertyHandler for the XML-data-type: XML_TYPE_NBOOL
195 */
196 class XMLNBoolPropHdl : public XMLPropertyHandler
197 {
198 public:
199 	virtual ~XMLNBoolPropHdl();
200 
201 	virtual sal_Bool importXML( const ::rtl::OUString& rStrImpValue, ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const;
202 	virtual sal_Bool exportXML( ::rtl::OUString& rStrExpValue, const ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const;
203 };
204 
205 /**
206     PropertyHandler for the XML-data-type: XML_TYPE_COLORTRANSPARENT
207 */
208 class XMLColorTransparentPropHdl : public XMLPropertyHandler
209 {
210 	const ::rtl::OUString sTransparent;
211 
212 public:
213 	XMLColorTransparentPropHdl( enum ::xmloff::token::XMLTokenEnum eTransparent = xmloff::token::XML_TOKEN_INVALID );
214 	virtual ~XMLColorTransparentPropHdl();
215 
216 	virtual sal_Bool importXML( const ::rtl::OUString& rStrImpValue, ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const;
217 	virtual sal_Bool exportXML( ::rtl::OUString& rStrExpValue, const ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const;
218 };
219 
220 /**
221     PropertyHandler for the XML-data-type: XML_TYPE_ISTRANSPARENT
222 */
223 class XMLIsTransparentPropHdl : public XMLPropertyHandler
224 {
225 	const ::rtl::OUString sTransparent;
226 	sal_Bool bTransPropValue;
227 
228 public:
229 	XMLIsTransparentPropHdl( enum ::xmloff::token::XMLTokenEnum eTransparent = xmloff::token::XML_TOKEN_INVALID,
230 						     sal_Bool bTransPropValue = sal_True );
231 	virtual ~XMLIsTransparentPropHdl();
232 
233 	virtual sal_Bool importXML( const ::rtl::OUString& rStrImpValue, ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const;
234 	virtual sal_Bool exportXML( ::rtl::OUString& rStrExpValue, const ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const;
235 };
236 
237 /**
238     PropertyHandler for the XML-data-type: XML_TYPE_COLORAUTO
239 */
240 class XMLColorAutoPropHdl : public XMLPropertyHandler
241 {
242 public:
243 	XMLColorAutoPropHdl();
244 	virtual ~XMLColorAutoPropHdl();
245 
246 	virtual sal_Bool importXML( const ::rtl::OUString& rStrImpValue, ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const;
247 	virtual sal_Bool exportXML( ::rtl::OUString& rStrExpValue, const ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const;
248 };
249 
250 /**
251     PropertyHandler for the XML-data-type: XML_TYPE_COLORISAUTO
252 */
253 class XMLIsAutoColorPropHdl : public XMLPropertyHandler
254 {
255 public:
256 	XMLIsAutoColorPropHdl();
257 	virtual ~XMLIsAutoColorPropHdl();
258 
259 	virtual sal_Bool importXML( const ::rtl::OUString& rStrImpValue, ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const;
260 	virtual sal_Bool exportXML( ::rtl::OUString& rStrExpValue, const ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const;
261 };
262 
263 
264 /**
265     PropertyHandler for properties that cannot make use of importXML
266 	and exportXML methods, but can make use of the default comparison
267 */
268 class XMLCompareOnlyPropHdl : public XMLPropertyHandler
269 {
270 public:
271 	virtual ~XMLCompareOnlyPropHdl();
272 
273 	virtual sal_Bool importXML( const ::rtl::OUString& rStrImpValue, ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const;
274 	virtual sal_Bool exportXML( ::rtl::OUString& rStrExpValue, const ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const;
275 };
276 
277 /**
278     PropertyHandler for the XML-data-type: XML_TYPE_NUMBER_NO_ZERO
279     Reads/writes numeric properties, but fails for the value zero
280     (i.e., a value 0 property will not be written)
281 */
282 class XMLNumberWithoutZeroPropHdl : public XMLPropertyHandler
283 {
284 	sal_Int8		nBytes;
285 public:
286 	XMLNumberWithoutZeroPropHdl( sal_Int8 nB = 4 );
287 	virtual ~XMLNumberWithoutZeroPropHdl();
288 
289 	virtual sal_Bool importXML( const ::rtl::OUString& rStrImpValue, ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const;
290 	virtual sal_Bool exportXML( ::rtl::OUString& rStrExpValue, const ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const;
291 };
292 
293 /**
294     PropertyHandler for the XML-data-type: XML_TYPE_NUMBER16_AUTO
295     Reads/writes numeric properties with special handling for the value zero
296     (i.e., a value 0 property will be written as "auto")
297 */
298 class XMLNumberWithAutoInsteadZeroPropHdl : public XMLNumberWithoutZeroPropHdl
299 {
300 public:
301 	virtual ~XMLNumberWithAutoInsteadZeroPropHdl();
302 
303 	virtual sal_Bool importXML( const ::rtl::OUString& rStrImpValue, ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const;
304 	virtual sal_Bool exportXML( ::rtl::OUString& rStrExpValue, const ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const;
305 };
306 
307 #endif		// _XMLOFF_PROPERTYHANDLER_BASICTYPES_HXX
308