Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include <xmlbahdl.hxx>
31 : :
32 : : #include <tools/debug.hxx>
33 : : #include <sax/tools/converter.hxx>
34 : : #include <xmloff/xmluconv.hxx>
35 : : #include <com/sun/star/uno/Any.hxx>
36 : : #include <xmloff/xmltoken.hxx>
37 : :
38 : : using ::rtl::OUString;
39 : : using ::rtl::OUStringBuffer;
40 : :
41 : : using namespace ::com::sun::star::uno;
42 : : using namespace ::xmloff::token;
43 : :
44 : 7536 : void lcl_xmloff_setAny( Any& rValue, sal_Int32 nValue, sal_Int8 nBytes )
45 : : {
46 [ + + + - ]: 7536 : switch( nBytes )
47 : : {
48 : : case 1:
49 [ - + ]: 33 : if( nValue < SCHAR_MIN )
50 : 0 : nValue = SCHAR_MIN;
51 [ - + ]: 33 : else if( nValue > SCHAR_MAX )
52 : 0 : nValue = SCHAR_MAX;
53 [ + - ]: 33 : rValue <<= (sal_Int8)nValue;
54 : 33 : break;
55 : : case 2:
56 [ - + ]: 1527 : if( nValue < SHRT_MIN )
57 : 0 : nValue = SHRT_MIN;
58 [ - + ]: 1527 : else if( nValue > SHRT_MAX )
59 : 0 : nValue = SHRT_MAX;
60 [ + - ]: 1527 : rValue <<= (sal_Int16)nValue;
61 : 1527 : break;
62 : : case 4:
63 : 5976 : rValue <<= nValue;
64 : 5976 : break;
65 : : }
66 : 7536 : }
67 : :
68 : 1409 : sal_Bool lcl_xmloff_getAny( const Any& rValue, sal_Int32& nValue,
69 : : sal_Int8 nBytes )
70 : : {
71 : 1409 : sal_Bool bRet = sal_False;
72 : :
73 [ + + + - ]: 1409 : switch( nBytes )
74 : : {
75 : : case 1:
76 : : {
77 : 6 : sal_Int8 nValue8 = 0;
78 : 6 : bRet = rValue >>= nValue8;
79 : 6 : nValue = nValue8;
80 : : }
81 : 6 : break;
82 : : case 2:
83 : : {
84 : 90 : sal_Int16 nValue16 = 0;
85 : 90 : bRet = rValue >>= nValue16;
86 : 90 : nValue = nValue16;
87 : : }
88 : 90 : break;
89 : : case 4:
90 : 1313 : bRet = rValue >>= nValue;
91 : 1313 : break;
92 : : }
93 : :
94 : 1409 : return bRet;
95 : : }
96 : :
97 : : ///////////////////////////////////////////////////////////////////////////////
98 : : //
99 : : // class XMLNumberPropHdl
100 : : //
101 : :
102 : 7939 : XMLNumberPropHdl::~XMLNumberPropHdl()
103 : : {
104 : : // nothing to do
105 [ - + ]: 15878 : }
106 : :
107 : 272 : sal_Bool XMLNumberPropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
108 : : {
109 : 272 : sal_Int32 nValue = 0;
110 [ + - ]: 272 : bool bRet = ::sax::Converter::convertNumber( nValue, rStrImpValue );
111 [ + - ]: 272 : lcl_xmloff_setAny( rValue, nValue, nBytes );
112 : :
113 : 272 : return bRet;
114 : : }
115 : :
116 : 86 : sal_Bool XMLNumberPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
117 : : {
118 : 86 : sal_Bool bRet = sal_False;
119 : : sal_Int32 nValue;
120 : 86 : OUStringBuffer aOut;
121 : :
122 [ + + ]: 86 : if( lcl_xmloff_getAny( rValue, nValue, nBytes ) )
123 : : {
124 [ + - ]: 64 : ::sax::Converter::convertNumber( aOut, nValue );
125 [ + - ]: 64 : rStrExpValue = aOut.makeStringAndClear();
126 : :
127 : 64 : bRet = sal_True;
128 : : }
129 : :
130 : 86 : return bRet;
131 : : }
132 : :
133 : : ///////////////////////////////////////////////////////////////////////////////
134 : : // class XMLNumberNonePropHdl
135 : : //
136 : :
137 : 1732 : XMLNumberNonePropHdl::XMLNumberNonePropHdl( sal_Int8 nB ) :
138 [ + - ]: 1732 : sZeroStr( GetXMLToken(XML_NO_LIMIT) ),
139 : 3464 : nBytes( nB )
140 : : {
141 : 1732 : }
142 : :
143 : 187 : XMLNumberNonePropHdl::XMLNumberNonePropHdl( enum XMLTokenEnum eZeroString, sal_Int8 nB ) :
144 [ + - ]: 187 : sZeroStr( GetXMLToken( eZeroString ) ),
145 : 374 : nBytes( nB )
146 : : {
147 : 187 : }
148 : :
149 : 1909 : XMLNumberNonePropHdl::~XMLNumberNonePropHdl()
150 : : {
151 : : // nothing to do
152 [ - + ]: 3818 : }
153 : :
154 : 79 : sal_Bool XMLNumberNonePropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
155 : : {
156 : 79 : sal_Bool bRet = sal_False;
157 : :
158 : 79 : sal_Int32 nValue = 0;
159 [ + + ]: 79 : if( rStrImpValue == sZeroStr )
160 : : {
161 : 76 : bRet = sal_True;
162 : : }
163 : : else
164 : : {
165 [ + - ]: 3 : bRet = ::sax::Converter::convertNumber( nValue, rStrImpValue );
166 : : }
167 [ + - ]: 79 : lcl_xmloff_setAny( rValue, nValue, nBytes );
168 : :
169 : 79 : return bRet;
170 : : }
171 : :
172 : 21 : sal_Bool XMLNumberNonePropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
173 : : {
174 : 21 : sal_Bool bRet = sal_False;
175 : : sal_Int32 nValue;
176 : :
177 [ + - ]: 21 : if( lcl_xmloff_getAny( rValue, nValue, nBytes ) )
178 : : {
179 : 21 : OUStringBuffer aOut;
180 : :
181 [ + - ]: 21 : if( nValue == 0 )
182 : : {
183 [ + - ]: 21 : aOut.append( sZeroStr );
184 : : }
185 : : else
186 : : {
187 [ # # ]: 0 : ::sax::Converter::convertNumber( aOut, nValue );
188 : : }
189 : :
190 [ + - ]: 21 : rStrExpValue = aOut.makeStringAndClear();
191 : :
192 : 21 : bRet = sal_True;
193 : : }
194 : :
195 : 21 : return bRet;
196 : : }
197 : :
198 : : ///////////////////////////////////////////////////////////////////////////////
199 : : //
200 : : // class XMLMeasurePropHdl
201 : : //
202 : :
203 : 6657 : XMLMeasurePropHdl::~XMLMeasurePropHdl()
204 : : {
205 : : // nothing to do
206 [ - + ]: 13314 : }
207 : :
208 : 5652 : sal_Bool XMLMeasurePropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const
209 : : {
210 : 5652 : sal_Bool bRet = sal_False;
211 : :
212 : 5652 : sal_Int32 nValue = 0;
213 [ + - ]: 5652 : bRet = rUnitConverter.convertMeasureToCore( nValue, rStrImpValue );
214 [ + - ]: 5652 : lcl_xmloff_setAny( rValue, nValue, nBytes );
215 : :
216 : 5652 : return bRet;
217 : : }
218 : :
219 : 1216 : sal_Bool XMLMeasurePropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const
220 : : {
221 : 1216 : sal_Bool bRet = sal_False;
222 : : sal_Int32 nValue;
223 : 1216 : OUStringBuffer aOut;
224 : :
225 [ + - ]: 1216 : if( lcl_xmloff_getAny( rValue, nValue, nBytes ) )
226 : : {
227 [ + - ]: 1216 : rUnitConverter.convertMeasureToXML( aOut, nValue );
228 [ + - ]: 1216 : rStrExpValue = aOut.makeStringAndClear();
229 : :
230 : 1216 : bRet = sal_True;
231 : : }
232 : :
233 : 1216 : return bRet;
234 : : }
235 : :
236 : : ///////////////////////////////////////////////////////////////////////////////
237 : : //
238 : : // class XMLBoolFalsePropHdl
239 : : //
240 : :
241 : 0 : XMLBoolFalsePropHdl::~XMLBoolFalsePropHdl()
242 : : {
243 : : // nothing to do
244 [ # # ]: 0 : }
245 : :
246 : 0 : sal_Bool XMLBoolFalsePropHdl::importXML( const OUString&, Any&, const SvXMLUnitConverter& ) const
247 : : {
248 : 0 : return sal_False;
249 : : }
250 : :
251 : 0 : sal_Bool XMLBoolFalsePropHdl::exportXML( OUString& rStrExpValue, const Any& /*rValue*/, const SvXMLUnitConverter& rCnv) const
252 : : {
253 [ # # ][ # # ]: 0 : return XMLBoolPropHdl::exportXML( rStrExpValue, makeAny( sal_False ), rCnv );
254 : : }
255 : :
256 : : ///////////////////////////////////////////////////////////////////////////////
257 : : //
258 : : // class XMLBoolPropHdl
259 : : //
260 : :
261 : 5826 : XMLBoolPropHdl::~XMLBoolPropHdl()
262 : : {
263 : : // nothing to do
264 [ - + ]: 11652 : }
265 : :
266 : 1650 : sal_Bool XMLBoolPropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
267 : : {
268 : 1650 : bool bValue(false);
269 [ + - ]: 1650 : bool const bRet = ::sax::Converter::convertBool( bValue, rStrImpValue );
270 [ + - ]: 1650 : rValue <<= sal_Bool(bValue);
271 : :
272 : 1650 : return bRet;
273 : : }
274 : :
275 : 541 : sal_Bool XMLBoolPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
276 : : {
277 : 541 : sal_Bool bRet = sal_False;
278 : 541 : OUStringBuffer aOut;
279 : 541 : sal_Bool bValue = sal_Bool();
280 : :
281 [ + - ]: 541 : if (rValue >>= bValue)
282 : : {
283 [ + - ]: 541 : ::sax::Converter::convertBool( aOut, bValue );
284 [ + - ]: 541 : rStrExpValue = aOut.makeStringAndClear();
285 : :
286 : 541 : bRet = sal_True;
287 : : }
288 : :
289 : 541 : return bRet;
290 : : }
291 : :
292 : : ///////////////////////////////////////////////////////////////////////////////
293 : : //
294 : : // class XMLNBoolPropHdl
295 : : //
296 : :
297 : 43 : XMLNBoolPropHdl::~XMLNBoolPropHdl()
298 : : {
299 : : // nothing to do
300 [ - + ]: 86 : }
301 : :
302 : 0 : sal_Bool XMLNBoolPropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
303 : : {
304 : 0 : bool bValue(false);
305 [ # # ]: 0 : bool const bRet = ::sax::Converter::convertBool( bValue, rStrImpValue );
306 [ # # ]: 0 : rValue <<= sal_Bool(!bValue);
307 : :
308 : 0 : return bRet;
309 : : }
310 : :
311 : 0 : sal_Bool XMLNBoolPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
312 : : {
313 : 0 : sal_Bool bRet = sal_False;
314 : 0 : OUStringBuffer aOut;
315 : 0 : sal_Bool bValue = sal_Bool();
316 : :
317 [ # # ]: 0 : if (rValue >>= bValue)
318 : : {
319 [ # # ]: 0 : ::sax::Converter::convertBool( aOut, !bValue );
320 [ # # ]: 0 : rStrExpValue = aOut.makeStringAndClear();
321 : :
322 : 0 : bRet = sal_True;
323 : : }
324 : :
325 : 0 : return bRet;
326 : : }
327 : :
328 : : ///////////////////////////////////////////////////////////////////////////////
329 : : //
330 : : // class XMLPercentPropHdl
331 : : //
332 : :
333 : 7373 : XMLPercentPropHdl::~XMLPercentPropHdl()
334 : : {
335 : : // nothing to do
336 [ - + ]: 14746 : }
337 : :
338 : 1359 : sal_Bool XMLPercentPropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
339 : : {
340 : 1359 : sal_Int32 nValue = 0;
341 [ + - ]: 1359 : bool const bRet = ::sax::Converter::convertPercent( nValue, rStrImpValue );
342 [ + - ]: 1359 : lcl_xmloff_setAny( rValue, nValue, nBytes );
343 : :
344 : 1359 : return bRet;
345 : : }
346 : :
347 : 41 : sal_Bool XMLPercentPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
348 : : {
349 : 41 : sal_Bool bRet = sal_False;
350 : : sal_Int32 nValue;
351 : 41 : OUStringBuffer aOut;
352 : :
353 [ + - ]: 41 : if( lcl_xmloff_getAny( rValue, nValue, nBytes ) )
354 : : {
355 [ + - ]: 41 : ::sax::Converter::convertPercent( aOut, nValue );
356 [ + - ]: 41 : rStrExpValue = aOut.makeStringAndClear();
357 : :
358 : 41 : bRet = sal_True;
359 : : }
360 : :
361 : 41 : return bRet;
362 : : }
363 : :
364 : : ///////////////////////////////////////////////////////////////////////////////
365 : : //
366 : : // class XMLDoublePercentPropHdl
367 : : //
368 : :
369 : 12 : sal_Bool XMLDoublePercentPropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
370 : : {
371 : 12 : sal_Bool bRet = sal_False;
372 : :
373 : 12 : double fValue = 1.0;
374 : :
375 [ - + ]: 12 : if( rStrImpValue.indexOf( (sal_Unicode)'%' ) == -1 )
376 : : {
377 : 0 : fValue = rStrImpValue.toDouble();
378 : : }
379 : : else
380 : : {
381 : 12 : sal_Int32 nValue = 0;
382 [ + - ]: 12 : bRet = ::sax::Converter::convertPercent( nValue, rStrImpValue );
383 : 12 : fValue = ((double)nValue) / 100.0;
384 : : }
385 [ + - ]: 12 : rValue <<= fValue;
386 : :
387 : 12 : return bRet;
388 : : }
389 : :
390 : 0 : sal_Bool XMLDoublePercentPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
391 : : {
392 : 0 : sal_Bool bRet = sal_False;
393 : 0 : double fValue = 0;
394 : :
395 [ # # ]: 0 : if( rValue >>= fValue )
396 : : {
397 : 0 : fValue *= 100.0;
398 [ # # ]: 0 : if( fValue > 0 ) fValue += 0.5; else fValue -= 0.5;
399 : :
400 : 0 : sal_Int32 nValue = (sal_Int32)fValue;
401 : :
402 : 0 : OUStringBuffer aOut;
403 [ # # ]: 0 : ::sax::Converter::convertPercent( aOut, nValue );
404 [ # # ]: 0 : rStrExpValue = aOut.makeStringAndClear();
405 : :
406 : 0 : bRet = sal_True;
407 : : }
408 : :
409 : 0 : return bRet;
410 : : }
411 : :
412 : :
413 : : ///////////////////////////////////////////////////////////////////////////////
414 : : //
415 : : // class XMLNegPercentPropHdl
416 : : //
417 : :
418 : 2230 : XMLNegPercentPropHdl::~XMLNegPercentPropHdl()
419 : : {
420 : : // nothing to do
421 [ - + ]: 4460 : }
422 : :
423 : 21 : sal_Bool XMLNegPercentPropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
424 : : {
425 : 21 : sal_Int32 nValue = 0;
426 [ + - ]: 21 : bool const bRet = ::sax::Converter::convertPercent( nValue, rStrImpValue );
427 [ + - ]: 21 : lcl_xmloff_setAny( rValue, 100-nValue, nBytes );
428 : :
429 : 21 : return bRet;
430 : : }
431 : :
432 : 0 : sal_Bool XMLNegPercentPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
433 : : {
434 : 0 : sal_Bool bRet = sal_False;
435 : : sal_Int32 nValue;
436 : 0 : OUStringBuffer aOut;
437 : :
438 [ # # ]: 0 : if( lcl_xmloff_getAny( rValue, nValue, nBytes ) )
439 : : {
440 [ # # ]: 0 : ::sax::Converter::convertPercent( aOut, 100-nValue );
441 [ # # ]: 0 : rStrExpValue = aOut.makeStringAndClear();
442 : :
443 : 0 : bRet = sal_True;
444 : : }
445 : :
446 : 0 : return bRet;
447 : : }
448 : :
449 : :
450 : : ///////////////////////////////////////////////////////////////////////////////
451 : : //
452 : : // class XMLMeasurePxPropHdl
453 : : //
454 : :
455 : 1496 : XMLMeasurePxPropHdl::~XMLMeasurePxPropHdl()
456 : : {
457 : : // nothing to do
458 [ - + ]: 2992 : }
459 : :
460 : 0 : sal_Bool XMLMeasurePxPropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
461 : : {
462 : 0 : sal_Bool bRet = sal_False;
463 : :
464 : 0 : sal_Int32 nValue = 0;
465 [ # # ]: 0 : bRet = ::sax::Converter::convertMeasurePx( nValue, rStrImpValue );
466 [ # # ]: 0 : lcl_xmloff_setAny( rValue, nValue, nBytes );
467 : :
468 : 0 : return bRet;
469 : : }
470 : :
471 : 0 : sal_Bool XMLMeasurePxPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
472 : : {
473 : 0 : sal_Bool bRet = sal_False;
474 : : sal_Int32 nValue;
475 : 0 : OUStringBuffer aOut;
476 : :
477 [ # # ]: 0 : if( lcl_xmloff_getAny( rValue, nValue, nBytes ) )
478 : : {
479 [ # # ]: 0 : ::sax::Converter::convertMeasurePx( aOut, nValue );
480 [ # # ]: 0 : rStrExpValue = aOut.makeStringAndClear();
481 : :
482 : 0 : bRet = sal_True;
483 : : }
484 : :
485 : 0 : return bRet;
486 : : }
487 : :
488 : : ///////////////////////////////////////////////////////////////////////////////
489 : : //
490 : : // class XMLColorPropHdl
491 : : //
492 : :
493 : 3609 : XMLColorPropHdl::~XMLColorPropHdl()
494 : : {
495 : : // Nothing to do
496 [ - + ]: 7218 : }
497 : :
498 : 435 : sal_Bool XMLColorPropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
499 : : {
500 : 435 : sal_Bool bRet = sal_False;
501 : :
502 : 435 : const OUString astrHSL( "hsl" );
503 [ - + ]: 435 : if( rStrImpValue.matchIgnoreAsciiCase( astrHSL ) )
504 : : {
505 : 0 : sal_Int32 nOpen = rStrImpValue.indexOf( '(' );
506 : 0 : sal_Int32 nClose = rStrImpValue.lastIndexOf( ')' );
507 : :
508 [ # # ][ # # ]: 0 : if( (nOpen != -1) && (nClose > nOpen) )
509 : : {
510 : 0 : const OUString aTmp( rStrImpValue.copy( nOpen+1, nClose - nOpen-1) );
511 : :
512 : 0 : sal_Int32 nIndex = 0;
513 : :
514 [ # # ]: 0 : Sequence< double > aHSL(3);
515 [ # # ]: 0 : aHSL[0] = aTmp.getToken( 0, ',', nIndex ).toDouble();
516 [ # # ]: 0 : aHSL[1] = aTmp.getToken( 0, ',', nIndex ).toDouble() / 100.0;
517 [ # # ]: 0 : aHSL[2] = aTmp.getToken( 0, ',', nIndex ).toDouble() / 100.0;
518 [ # # ]: 0 : rValue <<= aHSL;
519 [ # # ]: 0 : bRet = true;
520 : : }
521 : : }
522 : : else
523 : : {
524 : 435 : sal_Int32 nColor(0);
525 [ + - ]: 435 : bRet = ::sax::Converter::convertColor( nColor, rStrImpValue );
526 [ + - ]: 435 : rValue <<= nColor;
527 : : }
528 : :
529 : 435 : return bRet;
530 : : }
531 : :
532 : 342 : sal_Bool XMLColorPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
533 : : {
534 : 342 : sal_Bool bRet = sal_False;
535 : 342 : sal_Int32 nColor = 0;
536 : :
537 : 342 : OUStringBuffer aOut;
538 [ + - ]: 342 : if( rValue >>= nColor )
539 : : {
540 [ + - ]: 342 : ::sax::Converter::convertColor( aOut, nColor );
541 [ + - ]: 342 : rStrExpValue = aOut.makeStringAndClear();
542 : :
543 : 342 : bRet = sal_True;
544 : : }
545 : : else
546 : : {
547 [ # # ]: 0 : Sequence< double > aHSL;
548 [ # # ][ # # ]: 0 : if( (rValue >>= aHSL) && (aHSL.getLength() == 3) )
[ # # ][ # # ]
549 : : {
550 [ # # ]: 0 : aOut.append( OUString("hsl(") );
551 [ # # ][ # # ]: 0 : aOut.append( aHSL[0] );
552 [ # # ]: 0 : aOut.append( OUString(",") );
553 [ # # ][ # # ]: 0 : aOut.append( aHSL[1] * 100.0 );
554 [ # # ]: 0 : aOut.append( OUString("%,") );
555 [ # # ][ # # ]: 0 : aOut.append( aHSL[2] * 100.0 );
556 [ # # ]: 0 : aOut.append( OUString("%)") );
557 [ # # ]: 0 : rStrExpValue = aOut.makeStringAndClear();
558 : :
559 : 0 : bRet = sal_True;
560 [ # # ]: 0 : }
561 : : }
562 : :
563 : 342 : return bRet;
564 : : }
565 : :
566 : : ///////////////////////////////////////////////////////////////////////////////
567 : : //
568 : : // class XMLHexPropHdl
569 : : //
570 : :
571 : 2285 : XMLHexPropHdl::~XMLHexPropHdl()
572 : : {
573 : : // Nothing to do
574 [ - + ]: 4570 : }
575 : :
576 : 12 : sal_Bool XMLHexPropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
577 : : {
578 : 12 : sal_Bool bRet = sal_False;
579 : : sal_uInt32 nRsid;
580 : :
581 [ + - ]: 12 : bRet = SvXMLUnitConverter::convertHex( nRsid, rStrImpValue );
582 [ + - ]: 12 : rValue <<= nRsid;
583 : :
584 : 12 : return bRet;
585 : : }
586 : :
587 : 4 : sal_Bool XMLHexPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
588 : : {
589 : 4 : sal_Bool bRet = sal_False;
590 : 4 : sal_uInt32 nRsid = 0;
591 : :
592 : 4 : OUStringBuffer aOut;
593 [ + - ]: 4 : if( rValue >>= nRsid )
594 : : {
595 [ + - ]: 4 : SvXMLUnitConverter::convertHex( aOut, nRsid );
596 [ + - ]: 4 : rStrExpValue = aOut.makeStringAndClear();
597 : :
598 : 4 : bRet = sal_True;
599 : : }
600 : : else
601 : : {
602 : 0 : bRet = sal_False;
603 : : }
604 : :
605 : 4 : return bRet;
606 : : }
607 : :
608 : : ///////////////////////////////////////////////////////////////////////////////
609 : : //
610 : : // class XMLStringPropHdl
611 : : //
612 : :
613 : 8006 : XMLStringPropHdl::~XMLStringPropHdl()
614 : : {
615 : : // Nothing to do
616 [ - + ]: 13369 : }
617 : :
618 : 143 : sal_Bool XMLStringPropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
619 : : {
620 : 143 : sal_Bool bRet = sal_False;
621 : :
622 : 143 : rValue <<= rStrImpValue;
623 : 143 : bRet = sal_True;
624 : :
625 : 143 : return bRet;
626 : : }
627 : :
628 : 209 : sal_Bool XMLStringPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
629 : : {
630 : 209 : sal_Bool bRet = sal_False;
631 : :
632 [ + - ]: 209 : if( rValue >>= rStrExpValue )
633 : 209 : bRet = sal_True;
634 : :
635 : 209 : return bRet;
636 : : }
637 : :
638 : : ///////////////////////////////////////////////////////////////////////////////
639 : : //
640 : : // class XMLStyleNamePropHdl
641 : : //
642 : :
643 : 2643 : XMLStyleNamePropHdl::~XMLStyleNamePropHdl()
644 : : {
645 : : // Nothing to do
646 [ - + ]: 5286 : }
647 : :
648 : 36 : sal_Bool XMLStyleNamePropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const
649 : : {
650 : 36 : sal_Bool bRet = sal_False;
651 : :
652 [ + - ]: 36 : if( rValue >>= rStrExpValue )
653 : : {
654 : 36 : rStrExpValue = rUnitConverter.encodeStyleName( rStrExpValue );
655 : 36 : bRet = sal_True;
656 : : }
657 : :
658 : 36 : return bRet;
659 : : }
660 : :
661 : :
662 : : ///////////////////////////////////////////////////////////////////////////////
663 : : //
664 : : // class XMLDoublePropHdl
665 : : //
666 : :
667 : 33 : XMLDoublePropHdl::~XMLDoublePropHdl()
668 : : {
669 : : // Nothing to do
670 [ - + ]: 66 : }
671 : :
672 : 102 : sal_Bool XMLDoublePropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
673 : : {
674 : 102 : double fDblValue(0.0);
675 [ + - ]: 102 : bool const bRet = ::sax::Converter::convertDouble(fDblValue, rStrImpValue);
676 [ + - ]: 102 : rValue <<= fDblValue;
677 : 102 : return bRet;
678 : : }
679 : :
680 : 0 : sal_Bool XMLDoublePropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
681 : : {
682 : 0 : sal_Bool bRet = sal_False;
683 : :
684 : 0 : double fValue = 0;
685 : :
686 [ # # ]: 0 : if( rValue >>= fValue )
687 : : {
688 : 0 : OUStringBuffer aOut;
689 [ # # ]: 0 : ::sax::Converter::convertDouble( aOut, fValue );
690 [ # # ]: 0 : rStrExpValue = aOut.makeStringAndClear();
691 : 0 : bRet = sal_True;
692 : : }
693 : :
694 : 0 : return bRet;
695 : : }
696 : :
697 : : ///////////////////////////////////////////////////////////////////////////////
698 : : //
699 : : // class XMLColorTransparentPropHdl
700 : : //
701 : :
702 : 9196 : XMLColorTransparentPropHdl::XMLColorTransparentPropHdl(
703 : : enum XMLTokenEnum eTransparent ) :
704 : : sTransparent( GetXMLToken(
705 [ + + ][ + - ]: 9196 : eTransparent != XML_TOKEN_INVALID ? eTransparent : XML_TRANSPARENT ) )
706 : : {
707 : : // Nothing to do
708 : 9196 : }
709 : :
710 : 9166 : XMLColorTransparentPropHdl::~XMLColorTransparentPropHdl()
711 : : {
712 : : // Nothing to do
713 [ - + ]: 18332 : }
714 : :
715 : 368 : sal_Bool XMLColorTransparentPropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
716 : : {
717 : 368 : sal_Bool bRet = sal_False;
718 : :
719 [ + + ]: 368 : if( rStrImpValue != sTransparent )
720 : : {
721 : 213 : sal_Int32 nColor(0);
722 [ + - ]: 213 : bRet = ::sax::Converter::convertColor( nColor, rStrImpValue );
723 [ + - ]: 213 : rValue <<= nColor;
724 : : }
725 : :
726 : 368 : return bRet;
727 : : }
728 : :
729 : 42 : sal_Bool XMLColorTransparentPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
730 : : {
731 : 42 : sal_Bool bRet = sal_False;
732 : 42 : sal_Int32 nColor = 0;
733 : :
734 [ - + ]: 42 : if( rStrExpValue == sTransparent )
735 : 0 : bRet = sal_False;
736 [ + - ]: 42 : else if( rValue >>= nColor )
737 : : {
738 : 42 : OUStringBuffer aOut;
739 [ + - ]: 42 : ::sax::Converter::convertColor( aOut, nColor );
740 [ + - ]: 42 : rStrExpValue = aOut.makeStringAndClear();
741 : :
742 : 42 : bRet = sal_True;
743 : : }
744 : :
745 : 42 : return bRet;
746 : : }
747 : :
748 : :
749 : : ///////////////////////////////////////////////////////////////////////////////
750 : : //
751 : : // class XMLIsTransparentPropHdl
752 : : //
753 : :
754 : 9153 : XMLIsTransparentPropHdl::XMLIsTransparentPropHdl(
755 : : enum XMLTokenEnum eTransparent, sal_Bool bTransPropVal ) :
756 : : sTransparent( GetXMLToken(
757 [ + - ][ + + ]: 9153 : eTransparent != XML_TOKEN_INVALID ? eTransparent : XML_TRANSPARENT ) ),
758 : 18306 : bTransPropValue( bTransPropVal )
759 : : {
760 : 9153 : }
761 : :
762 : 9123 : XMLIsTransparentPropHdl::~XMLIsTransparentPropHdl()
763 : : {
764 : : // Nothing to do
765 [ - + ]: 18246 : }
766 : :
767 : 368 : sal_Bool XMLIsTransparentPropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
768 : : {
769 : 368 : sal_Bool bValue = ( (rStrImpValue == sTransparent) == bTransPropValue);
770 [ + - ]: 368 : rValue.setValue( &bValue, ::getBooleanCppuType() );
771 : :
772 : 368 : return sal_True;
773 : : }
774 : :
775 : 42 : sal_Bool XMLIsTransparentPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
776 : : {
777 : 42 : sal_Bool bRet = sal_False;
778 : :
779 : : // MIB: This looks a bit strange, because bTransPropValue == bValue should
780 : : // do the same, but this only applies if 'true' is represented by the same
781 : : // 8 bit value in bValue and bTransPropValue. Who will ensure this?
782 : 42 : sal_Bool bValue = *(sal_Bool *)rValue.getValue();
783 [ + + ]: 42 : sal_Bool bIsTrans = bTransPropValue ? bValue : !bValue;
784 : :
785 [ + + ]: 42 : if( bIsTrans )
786 : : {
787 : 34 : rStrExpValue = sTransparent;
788 : 34 : bRet = sal_True;
789 : : }
790 : :
791 : 42 : return bRet;
792 : : }
793 : :
794 : : ///////////////////////////////////////////////////////////////////////////////
795 : : //
796 : : // class XMLColorAutoPropHdl
797 : : //
798 : :
799 : 2695 : XMLColorAutoPropHdl::XMLColorAutoPropHdl()
800 : : {
801 : : // Nothing to do
802 : 2695 : }
803 : :
804 : 2685 : XMLColorAutoPropHdl::~XMLColorAutoPropHdl()
805 : : {
806 : : // Nothing to do
807 [ - + ]: 5370 : }
808 : :
809 : 125 : sal_Bool XMLColorAutoPropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
810 : : {
811 : 125 : sal_Bool bRet = sal_False;
812 : :
813 : : // This is a multi property: the value might be set to AUTO_COLOR
814 : : // already by the XMLIsAutoColorPropHdl!
815 : 125 : sal_Int32 nColor = 0;
816 [ - + ][ # # ]: 125 : if( !(rValue >>= nColor) || -1 != nColor )
[ + - ]
817 : : {
818 [ + - ]: 125 : bRet = ::sax::Converter::convertColor( nColor, rStrImpValue );
819 [ + - ]: 125 : if( bRet )
820 [ + - ]: 125 : rValue <<= nColor;
821 : : }
822 : :
823 : 125 : return bRet;
824 : : }
825 : :
826 : 89 : sal_Bool XMLColorAutoPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
827 : : {
828 : 89 : sal_Bool bRet = sal_False;
829 : :
830 : 89 : sal_Int32 nColor = 0;
831 [ + - ][ - + ]: 89 : if( (rValue >>= nColor) && -1 != nColor )
[ - + ]
832 : : {
833 : 0 : OUStringBuffer aOut;
834 [ # # ]: 0 : ::sax::Converter::convertColor( aOut, nColor );
835 [ # # ]: 0 : rStrExpValue = aOut.makeStringAndClear();
836 : :
837 : 0 : bRet = sal_True;
838 : : }
839 : :
840 : 89 : return bRet;
841 : : }
842 : :
843 : : ///////////////////////////////////////////////////////////////////////////////
844 : : //
845 : : // class XMLIsAutoColorPropHdl
846 : : //
847 : :
848 : 2295 : XMLIsAutoColorPropHdl::XMLIsAutoColorPropHdl()
849 : : {
850 : 2295 : }
851 : :
852 : 2285 : XMLIsAutoColorPropHdl::~XMLIsAutoColorPropHdl()
853 : : {
854 : : // Nothing to do
855 [ - + ]: 4570 : }
856 : :
857 : 198 : sal_Bool XMLIsAutoColorPropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
858 : : {
859 : : // An auto color overrides any other color set!
860 : : bool bValue;
861 [ + - ]: 198 : bool const bRet = ::sax::Converter::convertBool( bValue, rStrImpValue );
862 [ + - ][ + - ]: 198 : if( bRet && bValue )
863 [ + - ]: 198 : rValue <<= (sal_Int32)-1;
864 : :
865 : 198 : return sal_True;
866 : : }
867 : :
868 : 85 : sal_Bool XMLIsAutoColorPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
869 : : {
870 : 85 : sal_Bool bRet = sal_False;
871 : 85 : sal_Int32 nColor = 0;
872 : :
873 [ + - ][ + - ]: 85 : if( (rValue >>= nColor) && -1 == nColor )
[ + - ]
874 : : {
875 : 85 : OUStringBuffer aOut;
876 [ + - ]: 85 : ::sax::Converter::convertBool( aOut, true );
877 [ + - ]: 85 : rStrExpValue = aOut.makeStringAndClear();
878 : :
879 : 85 : bRet = sal_True;
880 : : }
881 : :
882 : 85 : return bRet;
883 : : }
884 : :
885 : : ///////////////////////////////////////////////////////////////////////////////
886 : : //
887 : : // class XMLCompareOnlyPropHdl
888 : : //
889 : :
890 : 4364 : XMLCompareOnlyPropHdl::~XMLCompareOnlyPropHdl()
891 : : {
892 : : // Nothing to do
893 [ - + ]: 8728 : }
894 : :
895 : 0 : sal_Bool XMLCompareOnlyPropHdl::importXML( const OUString&, Any&, const SvXMLUnitConverter& ) const
896 : : {
897 : : DBG_ASSERT( !this, "importXML called for compare-only-property" );
898 : 0 : return sal_False;
899 : : }
900 : :
901 : 0 : sal_Bool XMLCompareOnlyPropHdl::exportXML( OUString&, const Any&, const SvXMLUnitConverter& ) const
902 : : {
903 : : DBG_ASSERT( !this, "exportXML called for compare-only-property" );
904 : 0 : return sal_False;
905 : : }
906 : :
907 : : ///////////////////////////////////////////////////////////////////////////////
908 : : // class XMLNumberWithoutZeroPropHdl
909 : : //
910 : :
911 : 3464 : XMLNumberWithoutZeroPropHdl::XMLNumberWithoutZeroPropHdl( sal_Int8 nB ) :
912 : 3464 : nBytes( nB )
913 : : {
914 : 3464 : }
915 : :
916 : 3444 : XMLNumberWithoutZeroPropHdl::~XMLNumberWithoutZeroPropHdl()
917 : : {
918 [ - + ]: 5166 : }
919 : :
920 : 150 : sal_Bool XMLNumberWithoutZeroPropHdl::importXML(
921 : : const OUString& rStrImpValue,
922 : : Any& rValue,
923 : : const SvXMLUnitConverter& ) const
924 : : {
925 : 150 : sal_Int32 nValue = 0;
926 [ + - ]: 150 : bool const bRet = ::sax::Converter::convertNumber( nValue, rStrImpValue );
927 [ + - ]: 150 : if( bRet )
928 [ + - ]: 150 : lcl_xmloff_setAny( rValue, nValue, nBytes );
929 : 150 : return bRet;
930 : : }
931 : :
932 : 42 : sal_Bool XMLNumberWithoutZeroPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
933 : : {
934 : :
935 : 42 : sal_Int32 nValue = 0;
936 : 42 : sal_Bool bRet = lcl_xmloff_getAny( rValue, nValue, nBytes );
937 : 42 : bRet &= nValue != 0;
938 : :
939 [ + - ]: 42 : if( bRet )
940 : : {
941 : 42 : OUStringBuffer aBuffer;
942 [ + - ]: 42 : ::sax::Converter::convertNumber( aBuffer, nValue );
943 [ + - ]: 42 : rStrExpValue = aBuffer.makeStringAndClear();
944 : : }
945 : :
946 : 42 : return bRet;
947 : : }
948 : :
949 : : ///////////////////////////////////////////////////////////////////////////////
950 : : // class XMLNumberWithAutoInsteadZeroPropHdl
951 : : //
952 : :
953 : 1722 : XMLNumberWithAutoInsteadZeroPropHdl::~XMLNumberWithAutoInsteadZeroPropHdl()
954 : : {
955 [ - + ]: 3444 : }
956 : :
957 : 48 : sal_Bool XMLNumberWithAutoInsteadZeroPropHdl::importXML(
958 : : const OUString& rStrImpValue,
959 : : Any& rValue,
960 : : const SvXMLUnitConverter& ) const
961 : : {
962 : 48 : sal_Int32 nValue = 0;
963 [ + - ]: 48 : bool bRet = ::sax::Converter::convertNumber( nValue, rStrImpValue );
964 [ + + ]: 48 : if( bRet )
965 [ + - ]: 3 : lcl_xmloff_setAny( rValue, nValue, 2 );
966 [ + - ][ + - ]: 45 : else if( rStrImpValue == GetXMLToken( XML_AUTO ) )
967 : : {
968 [ + - ]: 45 : rValue <<= (sal_Int16)nValue;
969 : 45 : bRet = sal_True;
970 : : }
971 : 48 : return bRet;
972 : : }
973 : :
974 : 3 : sal_Bool XMLNumberWithAutoInsteadZeroPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
975 : : {
976 : :
977 : 3 : sal_Int32 nValue = 0;
978 : 3 : lcl_xmloff_getAny( rValue, nValue, 2 );
979 : :
980 [ + - ]: 3 : if( 0 == nValue )
981 [ + - ]: 3 : rStrExpValue = GetXMLToken( XML_AUTO );
982 : : else
983 : : {
984 : 0 : OUStringBuffer aBuffer;
985 [ # # ]: 0 : ::sax::Converter::convertNumber( aBuffer, nValue );
986 [ # # ]: 0 : rStrExpValue = aBuffer.makeStringAndClear();
987 : : }
988 : :
989 : 3 : return sal_True;
990 : : }
991 : :
992 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|