1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #pragma once
21 
22 #include <xmloff/xmlprhdl.hxx>
23 #include <xmloff/xmltoken.hxx>
24 
25 
26 /**
27     PropertyHandler for the XML-data-type: XML_TYPE_NUMBER
28 */
29 class XMLNumberPropHdl : public XMLPropertyHandler
30 {
31     sal_Int8 nBytes;
32 
33 public:
XMLNumberPropHdl(sal_Int8 nB)34     explicit XMLNumberPropHdl( sal_Int8 nB ) : nBytes( nB ) {}
35     virtual ~XMLNumberPropHdl() override;
36 
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;
39 };
40 
41 /**
42     PropertyHandler for the XML-data-type: XML_TYPE_NUMBER_NONE
43 */
44 class XMLNumberNonePropHdl : public XMLPropertyHandler
45 {
46     OUString sZeroStr;
47     sal_Int8        nBytes;
48 public:
49     explicit XMLNumberNonePropHdl( sal_Int8 nB = 4 );
50     XMLNumberNonePropHdl( enum ::xmloff::token::XMLTokenEnum eZeroString, sal_Int8 nB );
51     virtual ~XMLNumberNonePropHdl() override;
52 
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;
55 };
56 
57 /**
58     PropertyHandler for the XML-data-type: XML_TYPE_MEASURE
59 */
60 class XMLMeasurePropHdl : public XMLPropertyHandler
61 {
62     sal_Int8 nBytes;
63 public:
XMLMeasurePropHdl(sal_Int8 nB)64     explicit XMLMeasurePropHdl( sal_Int8 nB ) : nBytes( nB ) {}
65     virtual ~XMLMeasurePropHdl() override;
66 
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;
69 };
70 
71 /**
72     PropertyHandler for the XML-data-type: XML_TYPE_PERCENT
73 */
74 class XMLPercentPropHdl : public XMLPropertyHandler
75 {
76     sal_Int8 nBytes;
77 public:
XMLPercentPropHdl(sal_Int8 nB)78     explicit XMLPercentPropHdl( sal_Int8 nB ) : nBytes( nB ) {}
79     virtual ~XMLPercentPropHdl() override;
80 
81     virtual bool importXML( const OUString& rStrImpValue, css::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const override;
82     virtual bool exportXML( OUString& rStrExpValue, const css::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const override;
83 };
84 
85 /**
86     PropertyHandler for the XML-data-type: XML_TYPE_PERCENT
87     that is mapped on a double from 0.0 to 1.0
88 */
89 class XMLDoublePercentPropHdl : public XMLPropertyHandler
90 {
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;
93 };
94 
95 /**
96     PropertyHandler for the XML-data-type: XML_TYPE_NEG_PERCENT
97 */
98 class XMLNegPercentPropHdl : public XMLPropertyHandler
99 {
100     sal_Int8 nBytes;
101 public:
XMLNegPercentPropHdl(sal_Int8 nB)102     explicit XMLNegPercentPropHdl( sal_Int8 nB ) : nBytes( nB ) {}
103     virtual ~XMLNegPercentPropHdl() override;
104 
105     virtual bool importXML( const OUString& rStrImpValue, css::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const override;
106     virtual bool exportXML( OUString& rStrExpValue, const css::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const override;
107 };
108 
109 /**
110     PropertyHandler for the XML-data-type: XML_TYPE_PERCENT
111 */
112 class XMLMeasurePxPropHdl : public XMLPropertyHandler
113 {
114     sal_Int8 nBytes;
115 public:
XMLMeasurePxPropHdl(sal_Int8 nB)116     explicit XMLMeasurePxPropHdl( sal_Int8 nB ) : nBytes( nB ) {}
117     virtual ~XMLMeasurePxPropHdl() override;
118 
119     virtual bool importXML( const OUString& rStrImpValue, css::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const override;
120     virtual bool exportXML( OUString& rStrExpValue, const css::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const override;
121 };
122 
123 /**
124     PropertyHandler for the XML-data-type: XML_TYPE_BOOL
125 */
126 class XMLBoolPropHdl : public XMLPropertyHandler
127 {
128 public:
129     virtual ~XMLBoolPropHdl() override;
130 
131     virtual bool importXML( const OUString& rStrImpValue, css::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const override;
132     virtual bool exportXML( OUString& rStrExpValue, const css::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const override;
133 };
134 
135 class XMLBoolFalsePropHdl : public XMLBoolPropHdl
136 {
137 public:
138     virtual ~XMLBoolFalsePropHdl() override;
139 
140     virtual bool importXML( const OUString& rStrImpValue, css::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const override;
141     virtual bool exportXML( OUString& rStrExpValue, const css::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const override;
142 
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() override;
152 
153     virtual bool importXML( const OUString& rStrImpValue, css::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const override;
154     virtual bool exportXML( OUString& rStrExpValue, const css::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const override;
155 };
156 
157 /**
158     PropertyHandler for the XML-data-type: XML_TYPE_HEX
159 */
160 class XMLHexPropHdl : public XMLPropertyHandler
161 {
162 public:
163     virtual ~XMLHexPropHdl() override;
164 
165     virtual bool importXML( const OUString& rStrImpValue, css::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const override;
166     virtual bool exportXML( OUString& rStrExpValue, const css::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const override;
167 };
168 
169 /**
170     PropertyHandler for the XML-data-type: XML_TYPE_STRING
171 */
172 class XMLStringPropHdl : public XMLPropertyHandler
173 {
174 public:
175     virtual ~XMLStringPropHdl() override;
176 
177     virtual bool importXML( const OUString& rStrImpValue, css::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const override;
178     virtual bool exportXML( OUString& rStrExpValue, const css::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const override;
179 };
180 
181 /**
182     PropertyHandler for the XML-data-type: XML_TYPE_STYLENAME
183 */
184 class XMLStyleNamePropHdl : public XMLStringPropHdl
185 {
186 public:
187     virtual ~XMLStyleNamePropHdl() override;
188 
189     virtual bool exportXML( OUString& rStrExpValue, const css::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const override;
190 };
191 
192 
193 /**
194     PropertyHandler for the XML-data-type: XML_TYPE_DOUBLE
195 */
196 class XMLDoublePropHdl : public XMLPropertyHandler
197 {
198 public:
199     virtual ~XMLDoublePropHdl() override;
200 
201     virtual bool importXML( const OUString& rStrImpValue, css::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const override;
202     virtual bool exportXML( OUString& rStrExpValue, const css::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const override;
203 };
204 
205 /**
206     PropertyHandler for the XML-data-type: XML_TYPE_NBOOL
207 */
208 class XMLNBoolPropHdl : public XMLPropertyHandler
209 {
210 public:
211     virtual ~XMLNBoolPropHdl() override;
212 
213     virtual bool importXML( const OUString& rStrImpValue, css::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const override;
214     virtual bool exportXML( OUString& rStrExpValue, const css::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const override;
215 };
216 
217 /**
218     PropertyHandler for the XML-data-type: XML_TYPE_COLORTRANSPARENT
219 */
220 class XMLColorTransparentPropHdl : public XMLPropertyHandler
221 {
222     const OUString sTransparent;
223 
224 public:
225     explicit XMLColorTransparentPropHdl( enum ::xmloff::token::XMLTokenEnum eTransparent = xmloff::token::XML_TOKEN_INVALID );
226     virtual ~XMLColorTransparentPropHdl() override;
227 
228     virtual bool importXML( const OUString& rStrImpValue, css::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const override;
229     virtual bool exportXML( OUString& rStrExpValue, const css::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const override;
230 };
231 
232 /**
233     PropertyHandler for the XML-data-type: XML_TYPE_ISTRANSPARENT
234 */
235 class XMLIsTransparentPropHdl : public XMLPropertyHandler
236 {
237     const OUString sTransparent;
238     bool bTransPropValue;
239 
240 public:
241     XMLIsTransparentPropHdl( enum ::xmloff::token::XMLTokenEnum eTransparent = xmloff::token::XML_TOKEN_INVALID,
242                              bool bTransPropValue = true );
243     virtual ~XMLIsTransparentPropHdl() override;
244 
245     virtual bool importXML( const OUString& rStrImpValue, css::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const override;
246     virtual bool exportXML( OUString& rStrExpValue, const css::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const override;
247 };
248 
249 /**
250     PropertyHandler for the XML-data-type: XML_TYPE_COLORAUTO
251 */
252 class XMLColorAutoPropHdl : public XMLPropertyHandler
253 {
254 public:
255     XMLColorAutoPropHdl();
256     virtual ~XMLColorAutoPropHdl() override;
257 
258     virtual bool importXML( const OUString& rStrImpValue, css::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const override;
259     virtual bool exportXML( OUString& rStrExpValue, const css::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const override;
260 };
261 
262 /**
263     PropertyHandler for the XML-data-type: XML_TYPE_COLORISAUTO
264 */
265 class XMLIsAutoColorPropHdl : public XMLPropertyHandler
266 {
267 public:
268     XMLIsAutoColorPropHdl();
269     virtual ~XMLIsAutoColorPropHdl() override;
270 
271     virtual bool importXML( const OUString& rStrImpValue, css::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const override;
272     virtual bool exportXML( OUString& rStrExpValue, const css::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const override;
273 };
274 
275 
276 /**
277     PropertyHandler for properties that cannot make use of importXML
278     and exportXML methods, but can make use of the default comparison
279 */
280 class XMLCompareOnlyPropHdl : public XMLPropertyHandler
281 {
282 public:
283     virtual ~XMLCompareOnlyPropHdl() override;
284 
285     virtual bool importXML( const OUString& rStrImpValue, css::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const override;
286     virtual bool exportXML( OUString& rStrExpValue, const css::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const override;
287 };
288 
289 /**
290     PropertyHandler for the XML-data-type: XML_TYPE_NUMBER_NO_ZERO
291     Reads/writes numeric properties, but fails for the value zero
292     (i.e., a value 0 property will not be written)
293 */
294 class XMLNumberWithoutZeroPropHdl : public XMLPropertyHandler
295 {
296     sal_Int8        nBytes;
297 public:
298     explicit XMLNumberWithoutZeroPropHdl( sal_Int8 nB );
299     virtual ~XMLNumberWithoutZeroPropHdl() override;
300 
301     virtual bool importXML( const OUString& rStrImpValue, css::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const override;
302     virtual bool exportXML( OUString& rStrExpValue, const css::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const override;
303 };
304 
305 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
306