xref: /aoo42x/main/xmloff/source/style/xmlbahdl.hxx (revision ecfe53c5)
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_PROPERTYHANDLER_BASICTYPES_HXX
25 #define _XMLOFF_PROPERTYHANDLER_BASICTYPES_HXX
26 
27 #include <xmloff/xmlprhdl.hxx>
28 #include <rtl/ustrbuf.hxx>
29 #include <xmloff/xmltoken.hxx>
30 
31 
32 /**
33     PropertyHandler for the XML-data-type: XML_TYPE_NUMBER
34 */
35 class XMLNumberPropHdl : public XMLPropertyHandler
36 {
37 	sal_Int8 nBytes;
38 
39 public:
XMLNumberPropHdl(sal_Int8 nB=4)40 	XMLNumberPropHdl( sal_Int8 nB=4 ) : nBytes( nB ) {}
41 	virtual ~XMLNumberPropHdl();
42 
43 	virtual sal_Bool importXML( const ::rtl::OUString& rStrImpValue, ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const;
44 	virtual sal_Bool exportXML( ::rtl::OUString& rStrExpValue, const ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const;
45 };
46 
47 /**
48     PropertyHandler for the XML-data-type: XML_TYPE_NUMBER_NONE
49 */
50 class XMLNumberNonePropHdl : public XMLPropertyHandler
51 {
52 	::rtl::OUString	sZeroStr;
53 	sal_Int8		nBytes;
54 public:
55 	XMLNumberNonePropHdl( sal_Int8 nB = 4 );
56 	XMLNumberNonePropHdl( enum ::xmloff::token::XMLTokenEnum eZeroString, sal_Int8 nB = 4 );
57 	virtual ~XMLNumberNonePropHdl();
58 
59 	virtual sal_Bool importXML( const ::rtl::OUString& rStrImpValue, ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const;
60 	virtual sal_Bool exportXML( ::rtl::OUString& rStrExpValue, const ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const;
61 };
62 
63 /**
64     PropertyHandler for the XML-data-type: XML_TYPE_MEASURE
65 */
66 class XMLMeasurePropHdl : public XMLPropertyHandler
67 {
68 	sal_Int8 nBytes;
69 public:
XMLMeasurePropHdl(sal_Int8 nB=4)70 	XMLMeasurePropHdl( sal_Int8 nB=4 ) : nBytes( nB ) {}
71 	virtual ~XMLMeasurePropHdl();
72 
73 	virtual sal_Bool importXML( const ::rtl::OUString& rStrImpValue, ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const;
74 	virtual sal_Bool exportXML( ::rtl::OUString& rStrExpValue, const ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const;
75 };
76 
77 /**
78     PropertyHandler for the XML-data-type: XML_TYPE_PERCENT
79 */
80 class XMLPercentPropHdl : public XMLPropertyHandler
81 {
82 	sal_Int8 nBytes;
83 public:
XMLPercentPropHdl(sal_Int8 nB=4)84 	XMLPercentPropHdl( sal_Int8 nB=4 ) : nBytes( nB ) {}
85 	virtual ~XMLPercentPropHdl();
86 
87 	virtual sal_Bool importXML( const ::rtl::OUString& rStrImpValue, ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const;
88 	virtual sal_Bool exportXML( ::rtl::OUString& rStrExpValue, const ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const;
89 };
90 
91 /**
92     PropertyHandler for the XML-data-type: XML_TYPE_PERCENT
93 	that is mapped on a double from 0.0 to 1.0
94 */
95 class XMLDoublePercentPropHdl : public XMLPropertyHandler
96 {
97 	virtual sal_Bool importXML( const ::rtl::OUString& rStrImpValue, ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const;
98 	virtual sal_Bool exportXML( ::rtl::OUString& rStrExpValue, const ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const;
99 };
100 
101 /**
102     PropertyHandler for the XML-data-type: XML_TYPE_NEG_PERCENT
103 */
104 class XMLNegPercentPropHdl : public XMLPropertyHandler
105 {
106 	sal_Int8 nBytes;
107 public:
XMLNegPercentPropHdl(sal_Int8 nB=4)108 	XMLNegPercentPropHdl( sal_Int8 nB=4 ) : nBytes( nB ) {}
109 	virtual ~XMLNegPercentPropHdl();
110 
111 	virtual sal_Bool importXML( const ::rtl::OUString& rStrImpValue, ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const;
112 	virtual sal_Bool exportXML( ::rtl::OUString& rStrExpValue, const ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const;
113 };
114 
115 /**
116     PropertyHandler for the XML-data-type: XML_TYPE_PERCENT
117 */
118 class XMLMeasurePxPropHdl : public XMLPropertyHandler
119 {
120 	sal_Int8 nBytes;
121 public:
XMLMeasurePxPropHdl(sal_Int8 nB=4)122 	XMLMeasurePxPropHdl( sal_Int8 nB=4 ) : nBytes( nB ) {}
123 	virtual ~XMLMeasurePxPropHdl();
124 
125 	virtual sal_Bool importXML( const ::rtl::OUString& rStrImpValue, ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const;
126 	virtual sal_Bool exportXML( ::rtl::OUString& rStrExpValue, const ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const;
127 };
128 
129 /**
130     PropertyHandler for the XML-data-type: XML_TYPE_BOOL
131 */
132 class XMLBoolPropHdl : public XMLPropertyHandler
133 {
134 public:
135 	virtual ~XMLBoolPropHdl();
136 
137 	virtual sal_Bool importXML( const ::rtl::OUString& rStrImpValue, ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const;
138 	virtual sal_Bool exportXML( ::rtl::OUString& rStrExpValue, const ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const;
139 };
140 
141 /**
142     PropertyHandler for the XML-data-type: XML_TYPE_COLOR
143 */
144 class XMLColorPropHdl : public XMLPropertyHandler
145 {
146 public:
147 	virtual ~XMLColorPropHdl();
148 
149 	virtual sal_Bool importXML( const ::rtl::OUString& rStrImpValue, ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const;
150 	virtual sal_Bool exportXML( ::rtl::OUString& rStrExpValue, const ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const;
151 };
152 
153 /**
154     PropertyHandler for the XML-data-type: XML_TYPE_STRING
155 */
156 class XMLStringPropHdl : public XMLPropertyHandler
157 {
158 public:
159 	virtual ~XMLStringPropHdl();
160 
161 	virtual sal_Bool importXML( const ::rtl::OUString& rStrImpValue, ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const;
162 	virtual sal_Bool exportXML( ::rtl::OUString& rStrExpValue, const ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const;
163 };
164 
165 /**
166     PropertyHandler for the XML-data-type: XML_TYPE_STYLENAME
167 */
168 class XMLStyleNamePropHdl : public XMLStringPropHdl
169 {
170 public:
171 	virtual ~XMLStyleNamePropHdl();
172 
173 	virtual sal_Bool exportXML( ::rtl::OUString& rStrExpValue, const ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const;
174 };
175 
176 
177 /**
178 	PropertyHandler for the XML-data-type: XML_TYPE_DOUBLE
179 */
180 class XMLDoublePropHdl : public XMLPropertyHandler
181 {
182 public:
183 	virtual ~XMLDoublePropHdl();
184 
185 	virtual sal_Bool importXML( const ::rtl::OUString& rStrImpValue, ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const;
186 	virtual sal_Bool exportXML( ::rtl::OUString& rStrExpValue, const ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const;
187 };
188 
189 /**
190     PropertyHandler for the XML-data-type: XML_TYPE_NBOOL
191 */
192 class XMLNBoolPropHdl : public XMLPropertyHandler
193 {
194 public:
195 	virtual ~XMLNBoolPropHdl();
196 
197 	virtual sal_Bool importXML( const ::rtl::OUString& rStrImpValue, ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const;
198 	virtual sal_Bool exportXML( ::rtl::OUString& rStrExpValue, const ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const;
199 };
200 
201 /**
202     PropertyHandler for the XML-data-type: XML_TYPE_COLORTRANSPARENT
203 */
204 class XMLColorTransparentPropHdl : public XMLPropertyHandler
205 {
206 	const ::rtl::OUString sTransparent;
207 
208 public:
209 	XMLColorTransparentPropHdl( enum ::xmloff::token::XMLTokenEnum eTransparent = xmloff::token::XML_TOKEN_INVALID );
210 	virtual ~XMLColorTransparentPropHdl();
211 
212 	virtual sal_Bool importXML( const ::rtl::OUString& rStrImpValue, ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const;
213 	virtual sal_Bool exportXML( ::rtl::OUString& rStrExpValue, const ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const;
214 };
215 
216 /**
217     PropertyHandler for the XML-data-type: XML_TYPE_ISTRANSPARENT
218 */
219 class XMLIsTransparentPropHdl : public XMLPropertyHandler
220 {
221 	const ::rtl::OUString sTransparent;
222 	sal_Bool bTransPropValue;
223 
224 public:
225 	XMLIsTransparentPropHdl( enum ::xmloff::token::XMLTokenEnum eTransparent = xmloff::token::XML_TOKEN_INVALID,
226 						     sal_Bool bTransPropValue = sal_True );
227 	virtual ~XMLIsTransparentPropHdl();
228 
229 	virtual sal_Bool importXML( const ::rtl::OUString& rStrImpValue, ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const;
230 	virtual sal_Bool exportXML( ::rtl::OUString& rStrExpValue, const ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const;
231 };
232 
233 /**
234     PropertyHandler for the XML-data-type: XML_TYPE_COLORAUTO
235 */
236 class XMLColorAutoPropHdl : public XMLPropertyHandler
237 {
238 public:
239 	XMLColorAutoPropHdl();
240 	virtual ~XMLColorAutoPropHdl();
241 
242 	virtual sal_Bool importXML( const ::rtl::OUString& rStrImpValue, ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const;
243 	virtual sal_Bool exportXML( ::rtl::OUString& rStrExpValue, const ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const;
244 };
245 
246 /**
247     PropertyHandler for the XML-data-type: XML_TYPE_COLORISAUTO
248 */
249 class XMLIsAutoColorPropHdl : public XMLPropertyHandler
250 {
251 public:
252 	XMLIsAutoColorPropHdl();
253 	virtual ~XMLIsAutoColorPropHdl();
254 
255 	virtual sal_Bool importXML( const ::rtl::OUString& rStrImpValue, ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const;
256 	virtual sal_Bool exportXML( ::rtl::OUString& rStrExpValue, const ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const;
257 };
258 
259 
260 /**
261     PropertyHandler for properties that cannot make use of importXML
262 	and exportXML methods, but can make use of the default comparison
263 */
264 class XMLCompareOnlyPropHdl : public XMLPropertyHandler
265 {
266 public:
267 	virtual ~XMLCompareOnlyPropHdl();
268 
269 	virtual sal_Bool importXML( const ::rtl::OUString& rStrImpValue, ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const;
270 	virtual sal_Bool exportXML( ::rtl::OUString& rStrExpValue, const ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const;
271 };
272 
273 /**
274     PropertyHandler for the XML-data-type: XML_TYPE_NUMBER_NO_ZERO
275     Reads/writes numeric properties, but fails for the value zero
276     (i.e., a value 0 property will not be written)
277 */
278 class XMLNumberWithoutZeroPropHdl : public XMLPropertyHandler
279 {
280 	sal_Int8		nBytes;
281 public:
282 	XMLNumberWithoutZeroPropHdl( sal_Int8 nB = 4 );
283 	virtual ~XMLNumberWithoutZeroPropHdl();
284 
285 	virtual sal_Bool importXML( const ::rtl::OUString& rStrImpValue, ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const;
286 	virtual sal_Bool exportXML( ::rtl::OUString& rStrExpValue, const ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const;
287 };
288 
289 /**
290     PropertyHandler for the XML-data-type: XML_TYPE_NUMBER16_AUTO
291     Reads/writes numeric properties with special handling for the value zero
292     (i.e., a value 0 property will be written as "auto")
293 */
294 class XMLNumberWithAutoInsteadZeroPropHdl : public XMLNumberWithoutZeroPropHdl
295 {
296 public:
297 	virtual ~XMLNumberWithAutoInsteadZeroPropHdl();
298 
299 	virtual sal_Bool importXML( const ::rtl::OUString& rStrImpValue, ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const;
300 	virtual sal_Bool exportXML( ::rtl::OUString& rStrExpValue, const ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const;
301 };
302 
303 #endif		// _XMLOFF_PROPERTYHANDLER_BASICTYPES_HXX
304