1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: xmlbahdl.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _XMLOFF_PROPERTYHANDLER_BASICTYPES_HXX
32 #define _XMLOFF_PROPERTYHANDLER_BASICTYPES_HXX
34 #include <xmloff/xmlprhdl.hxx>
35 #include <rtl/ustrbuf.hxx>
36 #include <xmloff/xmltoken.hxx>
40 PropertyHandler for the XML-data-type: XML_TYPE_NUMBER
42 class XMLNumberPropHdl
: public XMLPropertyHandler
47 XMLNumberPropHdl( sal_Int8 nB
=4 ) : nBytes( nB
) {}
48 virtual ~XMLNumberPropHdl();
50 virtual sal_Bool
importXML( const ::rtl::OUString
& rStrImpValue
, ::com::sun::star::uno::Any
& rValue
, const SvXMLUnitConverter
& rUnitConverter
) const;
51 virtual sal_Bool
exportXML( ::rtl::OUString
& rStrExpValue
, const ::com::sun::star::uno::Any
& rValue
, const SvXMLUnitConverter
& rUnitConverter
) const;
55 PropertyHandler for the XML-data-type: XML_TYPE_NUMBER_NONE
57 class XMLNumberNonePropHdl
: public XMLPropertyHandler
59 ::rtl::OUString sZeroStr
;
62 XMLNumberNonePropHdl( sal_Int8 nB
= 4 );
63 XMLNumberNonePropHdl( enum ::xmloff::token::XMLTokenEnum eZeroString
, sal_Int8 nB
= 4 );
64 virtual ~XMLNumberNonePropHdl();
66 virtual sal_Bool
importXML( const ::rtl::OUString
& rStrImpValue
, ::com::sun::star::uno::Any
& rValue
, const SvXMLUnitConverter
& rUnitConverter
) const;
67 virtual sal_Bool
exportXML( ::rtl::OUString
& rStrExpValue
, const ::com::sun::star::uno::Any
& rValue
, const SvXMLUnitConverter
& rUnitConverter
) const;
71 PropertyHandler for the XML-data-type: XML_TYPE_MEASURE
73 class XMLMeasurePropHdl
: public XMLPropertyHandler
77 XMLMeasurePropHdl( sal_Int8 nB
=4 ) : nBytes( nB
) {}
78 virtual ~XMLMeasurePropHdl();
80 virtual sal_Bool
importXML( const ::rtl::OUString
& rStrImpValue
, ::com::sun::star::uno::Any
& rValue
, const SvXMLUnitConverter
& rUnitConverter
) const;
81 virtual sal_Bool
exportXML( ::rtl::OUString
& rStrExpValue
, const ::com::sun::star::uno::Any
& rValue
, const SvXMLUnitConverter
& rUnitConverter
) const;
85 PropertyHandler for the XML-data-type: XML_TYPE_PERCENT
87 class XMLPercentPropHdl
: public XMLPropertyHandler
91 XMLPercentPropHdl( sal_Int8 nB
=4 ) : nBytes( nB
) {}
92 virtual ~XMLPercentPropHdl();
94 virtual sal_Bool
importXML( const ::rtl::OUString
& rStrImpValue
, ::com::sun::star::uno::Any
& rValue
, const SvXMLUnitConverter
& rUnitConverter
) const;
95 virtual sal_Bool
exportXML( ::rtl::OUString
& rStrExpValue
, const ::com::sun::star::uno::Any
& rValue
, const SvXMLUnitConverter
& rUnitConverter
) const;
99 PropertyHandler for the XML-data-type: XML_TYPE_PERCENT
100 that is mapped on a double from 0.0 to 1.0
102 class XMLDoublePercentPropHdl
: public XMLPropertyHandler
104 virtual sal_Bool
importXML( const ::rtl::OUString
& rStrImpValue
, ::com::sun::star::uno::Any
& rValue
, const SvXMLUnitConverter
& rUnitConverter
) const;
105 virtual sal_Bool
exportXML( ::rtl::OUString
& rStrExpValue
, const ::com::sun::star::uno::Any
& rValue
, const SvXMLUnitConverter
& rUnitConverter
) const;
109 PropertyHandler for the XML-data-type: XML_TYPE_NEG_PERCENT
111 class XMLNegPercentPropHdl
: public XMLPropertyHandler
115 XMLNegPercentPropHdl( sal_Int8 nB
=4 ) : nBytes( nB
) {}
116 virtual ~XMLNegPercentPropHdl();
118 virtual sal_Bool
importXML( const ::rtl::OUString
& rStrImpValue
, ::com::sun::star::uno::Any
& rValue
, const SvXMLUnitConverter
& rUnitConverter
) const;
119 virtual sal_Bool
exportXML( ::rtl::OUString
& rStrExpValue
, const ::com::sun::star::uno::Any
& rValue
, const SvXMLUnitConverter
& rUnitConverter
) const;
123 PropertyHandler for the XML-data-type: XML_TYPE_PERCENT
125 class XMLMeasurePxPropHdl
: public XMLPropertyHandler
129 XMLMeasurePxPropHdl( sal_Int8 nB
=4 ) : nBytes( nB
) {}
130 virtual ~XMLMeasurePxPropHdl();
132 virtual sal_Bool
importXML( const ::rtl::OUString
& rStrImpValue
, ::com::sun::star::uno::Any
& rValue
, const SvXMLUnitConverter
& rUnitConverter
) const;
133 virtual sal_Bool
exportXML( ::rtl::OUString
& rStrExpValue
, const ::com::sun::star::uno::Any
& rValue
, const SvXMLUnitConverter
& rUnitConverter
) const;
137 PropertyHandler for the XML-data-type: XML_TYPE_BOOL
139 class XMLBoolPropHdl
: public XMLPropertyHandler
142 virtual ~XMLBoolPropHdl();
144 virtual sal_Bool
importXML( const ::rtl::OUString
& rStrImpValue
, ::com::sun::star::uno::Any
& rValue
, const SvXMLUnitConverter
& rUnitConverter
) const;
145 virtual sal_Bool
exportXML( ::rtl::OUString
& rStrExpValue
, const ::com::sun::star::uno::Any
& rValue
, const SvXMLUnitConverter
& rUnitConverter
) const;
149 PropertyHandler for the XML-data-type: XML_TYPE_COLOR
151 class XMLColorPropHdl
: public XMLPropertyHandler
154 virtual ~XMLColorPropHdl();
156 virtual sal_Bool
importXML( const ::rtl::OUString
& rStrImpValue
, ::com::sun::star::uno::Any
& rValue
, const SvXMLUnitConverter
& rUnitConverter
) const;
157 virtual sal_Bool
exportXML( ::rtl::OUString
& rStrExpValue
, const ::com::sun::star::uno::Any
& rValue
, const SvXMLUnitConverter
& rUnitConverter
) const;
161 PropertyHandler for the XML-data-type: XML_TYPE_STRING
163 class XMLStringPropHdl
: public XMLPropertyHandler
166 virtual ~XMLStringPropHdl();
168 virtual sal_Bool
importXML( const ::rtl::OUString
& rStrImpValue
, ::com::sun::star::uno::Any
& rValue
, const SvXMLUnitConverter
& rUnitConverter
) const;
169 virtual sal_Bool
exportXML( ::rtl::OUString
& rStrExpValue
, const ::com::sun::star::uno::Any
& rValue
, const SvXMLUnitConverter
& rUnitConverter
) const;
173 PropertyHandler for the XML-data-type: XML_TYPE_STYLENAME
175 class XMLStyleNamePropHdl
: public XMLStringPropHdl
178 virtual ~XMLStyleNamePropHdl();
180 virtual sal_Bool
exportXML( ::rtl::OUString
& rStrExpValue
, const ::com::sun::star::uno::Any
& rValue
, const SvXMLUnitConverter
& rUnitConverter
) const;
185 PropertyHandler for the XML-data-type: XML_TYPE_DOUBLE
187 class XMLDoublePropHdl
: public XMLPropertyHandler
190 virtual ~XMLDoublePropHdl();
192 virtual sal_Bool
importXML( const ::rtl::OUString
& rStrImpValue
, ::com::sun::star::uno::Any
& rValue
, const SvXMLUnitConverter
& rUnitConverter
) const;
193 virtual sal_Bool
exportXML( ::rtl::OUString
& rStrExpValue
, const ::com::sun::star::uno::Any
& rValue
, const SvXMLUnitConverter
& rUnitConverter
) const;
197 PropertyHandler for the XML-data-type: XML_TYPE_NBOOL
199 class XMLNBoolPropHdl
: public XMLPropertyHandler
202 virtual ~XMLNBoolPropHdl();
204 virtual sal_Bool
importXML( const ::rtl::OUString
& rStrImpValue
, ::com::sun::star::uno::Any
& rValue
, const SvXMLUnitConverter
& rUnitConverter
) const;
205 virtual sal_Bool
exportXML( ::rtl::OUString
& rStrExpValue
, const ::com::sun::star::uno::Any
& rValue
, const SvXMLUnitConverter
& rUnitConverter
) const;
209 PropertyHandler for the XML-data-type: XML_TYPE_COLORTRANSPARENT
211 class XMLColorTransparentPropHdl
: public XMLPropertyHandler
213 const ::rtl::OUString sTransparent
;
216 XMLColorTransparentPropHdl( enum ::xmloff::token::XMLTokenEnum eTransparent
= xmloff::token::XML_TOKEN_INVALID
);
217 virtual ~XMLColorTransparentPropHdl();
219 virtual sal_Bool
importXML( const ::rtl::OUString
& rStrImpValue
, ::com::sun::star::uno::Any
& rValue
, const SvXMLUnitConverter
& rUnitConverter
) const;
220 virtual sal_Bool
exportXML( ::rtl::OUString
& rStrExpValue
, const ::com::sun::star::uno::Any
& rValue
, const SvXMLUnitConverter
& rUnitConverter
) const;
224 PropertyHandler for the XML-data-type: XML_TYPE_ISTRANSPARENT
226 class XMLIsTransparentPropHdl
: public XMLPropertyHandler
228 const ::rtl::OUString sTransparent
;
229 sal_Bool bTransPropValue
;
232 XMLIsTransparentPropHdl( enum ::xmloff::token::XMLTokenEnum eTransparent
= xmloff::token::XML_TOKEN_INVALID
,
233 sal_Bool bTransPropValue
= sal_True
);
234 virtual ~XMLIsTransparentPropHdl();
236 virtual sal_Bool
importXML( const ::rtl::OUString
& rStrImpValue
, ::com::sun::star::uno::Any
& rValue
, const SvXMLUnitConverter
& rUnitConverter
) const;
237 virtual sal_Bool
exportXML( ::rtl::OUString
& rStrExpValue
, const ::com::sun::star::uno::Any
& rValue
, const SvXMLUnitConverter
& rUnitConverter
) const;
241 PropertyHandler for the XML-data-type: XML_TYPE_COLORAUTO
243 class XMLColorAutoPropHdl
: public XMLPropertyHandler
246 XMLColorAutoPropHdl();
247 virtual ~XMLColorAutoPropHdl();
249 virtual sal_Bool
importXML( const ::rtl::OUString
& rStrImpValue
, ::com::sun::star::uno::Any
& rValue
, const SvXMLUnitConverter
& rUnitConverter
) const;
250 virtual sal_Bool
exportXML( ::rtl::OUString
& rStrExpValue
, const ::com::sun::star::uno::Any
& rValue
, const SvXMLUnitConverter
& rUnitConverter
) const;
254 PropertyHandler for the XML-data-type: XML_TYPE_COLORISAUTO
256 class XMLIsAutoColorPropHdl
: public XMLPropertyHandler
259 XMLIsAutoColorPropHdl();
260 virtual ~XMLIsAutoColorPropHdl();
262 virtual sal_Bool
importXML( const ::rtl::OUString
& rStrImpValue
, ::com::sun::star::uno::Any
& rValue
, const SvXMLUnitConverter
& rUnitConverter
) const;
263 virtual sal_Bool
exportXML( ::rtl::OUString
& rStrExpValue
, const ::com::sun::star::uno::Any
& rValue
, const SvXMLUnitConverter
& rUnitConverter
) const;
268 PropertyHandler for properties that cannot make use of importXML
269 and exportXML methods, but can make use of the default comparison
271 class XMLCompareOnlyPropHdl
: public XMLPropertyHandler
274 virtual ~XMLCompareOnlyPropHdl();
276 virtual sal_Bool
importXML( const ::rtl::OUString
& rStrImpValue
, ::com::sun::star::uno::Any
& rValue
, const SvXMLUnitConverter
& rUnitConverter
) const;
277 virtual sal_Bool
exportXML( ::rtl::OUString
& rStrExpValue
, const ::com::sun::star::uno::Any
& rValue
, const SvXMLUnitConverter
& rUnitConverter
) const;
281 PropertyHandler for the XML-data-type: XML_TYPE_NUMBER_NO_ZERO
282 Reads/writes numeric properties, but fails for the value zero
283 (i.e., a value 0 property will not be written)
285 class XMLNumberWithoutZeroPropHdl
: public XMLPropertyHandler
289 XMLNumberWithoutZeroPropHdl( sal_Int8 nB
= 4 );
290 virtual ~XMLNumberWithoutZeroPropHdl();
292 virtual sal_Bool
importXML( const ::rtl::OUString
& rStrImpValue
, ::com::sun::star::uno::Any
& rValue
, const SvXMLUnitConverter
& rUnitConverter
) const;
293 virtual sal_Bool
exportXML( ::rtl::OUString
& rStrExpValue
, const ::com::sun::star::uno::Any
& rValue
, const SvXMLUnitConverter
& rUnitConverter
) const;
297 PropertyHandler for the XML-data-type: XML_TYPE_NUMBER16_AUTO
298 Reads/writes numeric properties with special handling for the value zero
299 (i.e., a value 0 property will be written as "auto")
301 class XMLNumberWithAutoInsteadZeroPropHdl
: public XMLNumberWithoutZeroPropHdl
304 virtual ~XMLNumberWithAutoInsteadZeroPropHdl();
306 virtual sal_Bool
importXML( const ::rtl::OUString
& rStrImpValue
, ::com::sun::star::uno::Any
& rValue
, const SvXMLUnitConverter
& rUnitConverter
) const;
307 virtual sal_Bool
exportXML( ::rtl::OUString
& rStrExpValue
, const ::com::sun::star::uno::Any
& rValue
, const SvXMLUnitConverter
& rUnitConverter
) const;
310 #endif // _XMLOFF_PROPERTYHANDLER_BASICTYPES_HXX