1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
22 #include <xmloff/xmlprhdl.hxx>
23 #include <xmloff/xmltoken.hxx>
27 PropertyHandler for the XML-data-type: XML_TYPE_NUMBER
29 class XMLNumberPropHdl
: public XMLPropertyHandler
34 explicit XMLNumberPropHdl( sal_Int8 nB
) : nBytes( nB
) {}
35 virtual ~XMLNumberPropHdl() override
;
37 virtual bool importXML( const OUString
& rStrImpValue
, css::uno::Any
& rValue
, const SvXMLUnitConverter
& rUnitConverter
) const override
;
38 virtual bool exportXML( OUString
& rStrExpValue
, const css::uno::Any
& rValue
, const SvXMLUnitConverter
& rUnitConverter
) const override
;
42 PropertyHandler for the XML-data-type: XML_TYPE_NUMBER_NONE
44 class XMLNumberNonePropHdl
: public XMLPropertyHandler
49 explicit XMLNumberNonePropHdl( sal_Int8 nB
= 4 );
50 XMLNumberNonePropHdl( enum ::xmloff::token::XMLTokenEnum eZeroString
, sal_Int8 nB
);
51 virtual ~XMLNumberNonePropHdl() override
;
53 virtual bool importXML( const OUString
& rStrImpValue
, css::uno::Any
& rValue
, const SvXMLUnitConverter
& rUnitConverter
) const override
;
54 virtual bool exportXML( OUString
& rStrExpValue
, const css::uno::Any
& rValue
, const SvXMLUnitConverter
& rUnitConverter
) const override
;
58 PropertyHandler for the XML-data-type: XML_TYPE_MEASURE
60 class XMLMeasurePropHdl
: public XMLPropertyHandler
64 explicit XMLMeasurePropHdl( sal_Int8 nB
) : nBytes( nB
) {}
65 virtual ~XMLMeasurePropHdl() override
;
67 virtual bool importXML( const OUString
& rStrImpValue
, css::uno::Any
& rValue
, const SvXMLUnitConverter
& rUnitConverter
) const override
;
68 virtual bool exportXML( OUString
& rStrExpValue
, const css::uno::Any
& rValue
, const SvXMLUnitConverter
& rUnitConverter
) const override
;
72 PropertyHandler for the XML-data-type: XML_TYPE_UNIT_MEASURE
74 class XMLUnitMeasurePropHdl
: public XMLPropertyHandler
77 bool importXML( const OUString
& rStrImpValue
, css::uno::Any
& rValue
, const SvXMLUnitConverter
& rUnitConverter
) const override
;
78 bool exportXML( OUString
& rStrExpValue
, const css::uno::Any
& rValue
, const SvXMLUnitConverter
& rUnitConverter
) const override
;
82 PropertyHandler for the XML-data-type: XML_TYPE_PERCENT
84 class XMLPercentPropHdl
: public XMLPropertyHandler
88 explicit XMLPercentPropHdl( sal_Int8 nB
) : nBytes( nB
) {}
89 virtual ~XMLPercentPropHdl() override
;
91 virtual bool importXML( const OUString
& rStrImpValue
, css::uno::Any
& rValue
, const SvXMLUnitConverter
& rUnitConverter
) const override
;
92 virtual bool exportXML( OUString
& rStrExpValue
, const css::uno::Any
& rValue
, const SvXMLUnitConverter
& rUnitConverter
) const override
;
96 PropertyHandler for the XML-data-type: XML_TYPE_PERCENT
97 that is mapped on a double from 0.0 to 1.0
99 class XMLDoublePercentPropHdl
: public XMLPropertyHandler
101 virtual bool importXML( const OUString
& rStrImpValue
, css::uno::Any
& rValue
, const SvXMLUnitConverter
& rUnitConverter
) const override
;
102 virtual bool exportXML( OUString
& rStrExpValue
, const css::uno::Any
& rValue
, const SvXMLUnitConverter
& rUnitConverter
) const override
;
105 /// Maps between XML percentage and our 100th percent ints.
106 class XML100thPercentPropHdl
: public XMLPropertyHandler
108 virtual bool importXML(const OUString
& rStrImpValue
, css::uno::Any
& rValue
,
109 const SvXMLUnitConverter
& rUnitConverter
) const override
;
110 virtual bool exportXML(OUString
& rStrExpValue
, const css::uno::Any
& rValue
,
111 const SvXMLUnitConverter
& rUnitConverter
) const override
;
115 PropertyHandler for the XML-data-type: XML_TYPE_NEG_PERCENT
117 class XMLNegPercentPropHdl
: public XMLPropertyHandler
121 explicit XMLNegPercentPropHdl( sal_Int8 nB
) : nBytes( nB
) {}
122 virtual ~XMLNegPercentPropHdl() override
;
124 virtual bool importXML( const OUString
& rStrImpValue
, css::uno::Any
& rValue
, const SvXMLUnitConverter
& rUnitConverter
) const override
;
125 virtual bool exportXML( OUString
& rStrExpValue
, const css::uno::Any
& rValue
, const SvXMLUnitConverter
& rUnitConverter
) const override
;
129 PropertyHandler for the XML-data-type: XML_TYPE_PERCENT
131 class XMLMeasurePxPropHdl
: public XMLPropertyHandler
135 explicit XMLMeasurePxPropHdl( sal_Int8 nB
) : nBytes( nB
) {}
136 virtual ~XMLMeasurePxPropHdl() override
;
138 virtual bool importXML( const OUString
& rStrImpValue
, css::uno::Any
& rValue
, const SvXMLUnitConverter
& rUnitConverter
) const override
;
139 virtual bool exportXML( OUString
& rStrExpValue
, const css::uno::Any
& rValue
, const SvXMLUnitConverter
& rUnitConverter
) const override
;
143 PropertyHandler for the XML-data-type: XML_TYPE_BOOL
145 class XMLBoolPropHdl
: public XMLPropertyHandler
148 virtual ~XMLBoolPropHdl() override
;
150 virtual bool importXML( const OUString
& rStrImpValue
, css::uno::Any
& rValue
, const SvXMLUnitConverter
& rUnitConverter
) const override
;
151 virtual bool exportXML( OUString
& rStrExpValue
, const css::uno::Any
& rValue
, const SvXMLUnitConverter
& rUnitConverter
) const override
;
154 class XMLBoolFalsePropHdl
: public XMLBoolPropHdl
157 virtual ~XMLBoolFalsePropHdl() override
;
159 virtual bool importXML( const OUString
& rStrImpValue
, css::uno::Any
& rValue
, const SvXMLUnitConverter
& rUnitConverter
) const override
;
160 virtual bool exportXML( OUString
& rStrExpValue
, const css::uno::Any
& rValue
, const SvXMLUnitConverter
& rUnitConverter
) const override
;
165 PropertyHandler for the XML-data-type: XML_TYPE_COLOR
167 class XMLColorPropHdl
: public XMLPropertyHandler
170 virtual ~XMLColorPropHdl() override
;
172 virtual bool importXML( const OUString
& rStrImpValue
, css::uno::Any
& rValue
, const SvXMLUnitConverter
& rUnitConverter
) const override
;
173 virtual bool exportXML( OUString
& rStrExpValue
, const css::uno::Any
& rValue
, const SvXMLUnitConverter
& rUnitConverter
) const override
;
177 PropertyHandler for the XML-data-type: XML_TYPE_HEX
179 class XMLHexPropHdl
: public XMLPropertyHandler
182 virtual ~XMLHexPropHdl() override
;
184 virtual bool importXML( const OUString
& rStrImpValue
, css::uno::Any
& rValue
, const SvXMLUnitConverter
& rUnitConverter
) const override
;
185 virtual bool exportXML( OUString
& rStrExpValue
, const css::uno::Any
& rValue
, const SvXMLUnitConverter
& rUnitConverter
) const override
;
189 PropertyHandler for the XML-data-type: XML_TYPE_STRING
191 class XMLStringPropHdl
: public XMLPropertyHandler
194 virtual ~XMLStringPropHdl() override
;
196 virtual bool importXML( const OUString
& rStrImpValue
, css::uno::Any
& rValue
, const SvXMLUnitConverter
& rUnitConverter
) const override
;
197 virtual bool exportXML( OUString
& rStrExpValue
, const css::uno::Any
& rValue
, const SvXMLUnitConverter
& rUnitConverter
) const override
;
201 PropertyHandler for the XML-data-type: XML_TYPE_STYLENAME
203 class XMLStyleNamePropHdl
: public XMLStringPropHdl
206 virtual ~XMLStyleNamePropHdl() override
;
208 virtual bool exportXML( OUString
& rStrExpValue
, const css::uno::Any
& rValue
, const SvXMLUnitConverter
& rUnitConverter
) const override
;
213 PropertyHandler for the XML-data-type: XML_TYPE_DOUBLE
215 class XMLDoublePropHdl
: public XMLPropertyHandler
218 virtual ~XMLDoublePropHdl() override
;
220 virtual bool importXML( const OUString
& rStrImpValue
, css::uno::Any
& rValue
, const SvXMLUnitConverter
& rUnitConverter
) const override
;
221 virtual bool exportXML( OUString
& rStrExpValue
, const css::uno::Any
& rValue
, const SvXMLUnitConverter
& rUnitConverter
) const override
;
225 PropertyHandler for the XML-data-type: XML_TYPE_NBOOL
227 class XMLNBoolPropHdl
: public XMLPropertyHandler
230 virtual ~XMLNBoolPropHdl() override
;
232 virtual bool importXML( const OUString
& rStrImpValue
, css::uno::Any
& rValue
, const SvXMLUnitConverter
& rUnitConverter
) const override
;
233 virtual bool exportXML( OUString
& rStrExpValue
, const css::uno::Any
& rValue
, const SvXMLUnitConverter
& rUnitConverter
) const override
;
237 PropertyHandler for the XML-data-type: XML_TYPE_COLORTRANSPARENT
239 class XMLColorTransparentPropHdl
: public XMLPropertyHandler
241 const OUString sTransparent
;
244 explicit XMLColorTransparentPropHdl( enum ::xmloff::token::XMLTokenEnum eTransparent
= xmloff::token::XML_TOKEN_INVALID
);
245 virtual ~XMLColorTransparentPropHdl() override
;
247 virtual bool importXML( const OUString
& rStrImpValue
, css::uno::Any
& rValue
, const SvXMLUnitConverter
& rUnitConverter
) const override
;
248 virtual bool exportXML( OUString
& rStrExpValue
, const css::uno::Any
& rValue
, const SvXMLUnitConverter
& rUnitConverter
) const override
;
252 PropertyHandler for the XML-data-type: XML_TYPE_ISTRANSPARENT
254 class XMLIsTransparentPropHdl
: public XMLPropertyHandler
256 const OUString sTransparent
;
257 bool bTransPropValue
;
260 XMLIsTransparentPropHdl( enum ::xmloff::token::XMLTokenEnum eTransparent
= xmloff::token::XML_TOKEN_INVALID
,
261 bool bTransPropValue
= true );
262 virtual ~XMLIsTransparentPropHdl() override
;
264 virtual bool importXML( const OUString
& rStrImpValue
, css::uno::Any
& rValue
, const SvXMLUnitConverter
& rUnitConverter
) const override
;
265 virtual bool exportXML( OUString
& rStrExpValue
, const css::uno::Any
& rValue
, const SvXMLUnitConverter
& rUnitConverter
) const override
;
269 PropertyHandler for the XML-data-type: XML_TYPE_COLORAUTO
271 class XMLColorAutoPropHdl
: public XMLPropertyHandler
274 XMLColorAutoPropHdl();
275 virtual ~XMLColorAutoPropHdl() override
;
277 virtual bool importXML( const OUString
& rStrImpValue
, css::uno::Any
& rValue
, const SvXMLUnitConverter
& rUnitConverter
) const override
;
278 virtual bool exportXML( OUString
& rStrExpValue
, const css::uno::Any
& rValue
, const SvXMLUnitConverter
& rUnitConverter
) const override
;
282 PropertyHandler for the XML-data-type: XML_TYPE_COLORISAUTO
284 class XMLIsAutoColorPropHdl
: public XMLPropertyHandler
287 XMLIsAutoColorPropHdl();
288 virtual ~XMLIsAutoColorPropHdl() override
;
290 virtual bool importXML( const OUString
& rStrImpValue
, css::uno::Any
& rValue
, const SvXMLUnitConverter
& rUnitConverter
) const override
;
291 virtual bool exportXML( OUString
& rStrExpValue
, const css::uno::Any
& rValue
, const SvXMLUnitConverter
& rUnitConverter
) const override
;
296 PropertyHandler for properties that cannot make use of importXML
297 and exportXML methods, but can make use of the default comparison
299 class XMLCompareOnlyPropHdl
: public XMLPropertyHandler
302 virtual ~XMLCompareOnlyPropHdl() override
;
304 virtual bool importXML( const OUString
& rStrImpValue
, css::uno::Any
& rValue
, const SvXMLUnitConverter
& rUnitConverter
) const override
;
305 virtual bool exportXML( OUString
& rStrExpValue
, const css::uno::Any
& rValue
, const SvXMLUnitConverter
& rUnitConverter
) const override
;
309 PropertyHandler for the XML-data-type: XML_TYPE_NUMBER_NO_ZERO
310 Reads/writes numeric properties, but fails for the value zero
311 (i.e., a value 0 property will not be written)
313 class XMLNumberWithoutZeroPropHdl
: public XMLPropertyHandler
317 explicit XMLNumberWithoutZeroPropHdl( sal_Int8 nB
);
318 virtual ~XMLNumberWithoutZeroPropHdl() override
;
320 virtual bool importXML( const OUString
& rStrImpValue
, css::uno::Any
& rValue
, const SvXMLUnitConverter
& rUnitConverter
) const override
;
321 virtual bool exportXML( OUString
& rStrExpValue
, const css::uno::Any
& rValue
, const SvXMLUnitConverter
& rUnitConverter
) const override
;
324 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */