update dev300-m58
[ooovba.git] / xmloff / source / style / xmlbahdl.cxx
blob152b1adbbdb9eca585c24c66e2eb8f89121d5609
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: xmlbahdl.cxx,v $
10 * $Revision: 1.28 $
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 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_xmloff.hxx"
33 #include <tools/debug.hxx>
34 #include <xmlbahdl.hxx>
35 #include <xmloff/xmluconv.hxx>
36 #include <com/sun/star/uno/Any.hxx>
37 #include <xmloff/xmltoken.hxx>
39 using ::rtl::OUString;
40 using ::rtl::OUStringBuffer;
42 using namespace ::com::sun::star::uno;
43 using namespace ::xmloff::token;
45 void lcl_xmloff_setAny( Any& rValue, sal_Int32 nValue, sal_Int8 nBytes )
47 switch( nBytes )
49 case 1:
50 if( nValue < SCHAR_MIN )
51 nValue = SCHAR_MIN;
52 else if( nValue > SCHAR_MAX )
53 nValue = SCHAR_MAX;
54 rValue <<= (sal_Int8)nValue;
55 break;
56 case 2:
57 if( nValue < SHRT_MIN )
58 nValue = SHRT_MIN;
59 else if( nValue > SHRT_MAX )
60 nValue = SHRT_MAX;
61 rValue <<= (sal_Int16)nValue;
62 break;
63 case 4:
64 rValue <<= nValue;
65 break;
69 sal_Bool lcl_xmloff_getAny( const Any& rValue, sal_Int32& nValue,
70 sal_Int8 nBytes )
72 sal_Bool bRet = sal_False;
74 switch( nBytes )
76 case 1:
78 sal_Int8 nValue8 = 0;
79 bRet = rValue >>= nValue8;
80 nValue = nValue8;
82 break;
83 case 2:
85 sal_Int16 nValue16 = 0;
86 bRet = rValue >>= nValue16;
87 nValue = nValue16;
89 break;
90 case 4:
91 bRet = rValue >>= nValue;
92 break;
95 return bRet;
98 ///////////////////////////////////////////////////////////////////////////////
100 // class XMLNumberPropHdl
103 XMLNumberPropHdl::~XMLNumberPropHdl()
105 // nothing to do
108 sal_Bool XMLNumberPropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
110 sal_Bool bRet = sal_False;
112 sal_Int32 nValue = 0;
113 bRet = SvXMLUnitConverter::convertNumber( nValue, rStrImpValue );
114 lcl_xmloff_setAny( rValue, nValue, nBytes );
116 return bRet;
119 sal_Bool XMLNumberPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
121 sal_Bool bRet = sal_False;
122 sal_Int32 nValue;
123 OUStringBuffer aOut;
125 if( lcl_xmloff_getAny( rValue, nValue, nBytes ) )
127 SvXMLUnitConverter::convertNumber( aOut, nValue );
128 rStrExpValue = aOut.makeStringAndClear();
130 bRet = sal_True;
133 return bRet;
136 ///////////////////////////////////////////////////////////////////////////////
137 // class XMLNumberNonePropHdl
140 XMLNumberNonePropHdl::XMLNumberNonePropHdl( sal_Int8 nB ) :
141 sZeroStr( GetXMLToken(XML_NO_LIMIT) ),
142 nBytes( nB )
146 XMLNumberNonePropHdl::XMLNumberNonePropHdl( enum XMLTokenEnum eZeroString, sal_Int8 nB ) :
147 sZeroStr( GetXMLToken( eZeroString ) ),
148 nBytes( nB )
152 XMLNumberNonePropHdl::~XMLNumberNonePropHdl()
154 // nothing to do
157 sal_Bool XMLNumberNonePropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
159 sal_Bool bRet = sal_False;
161 sal_Int32 nValue = 0;
162 if( rStrImpValue == sZeroStr )
164 bRet = sal_True;
166 else
168 bRet = SvXMLUnitConverter::convertNumber( nValue, rStrImpValue );
170 lcl_xmloff_setAny( rValue, nValue, nBytes );
172 return bRet;
175 sal_Bool XMLNumberNonePropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
177 sal_Bool bRet = sal_False;
178 sal_Int32 nValue;
180 if( lcl_xmloff_getAny( rValue, nValue, nBytes ) )
182 OUStringBuffer aOut;
184 if( nValue == 0 )
186 aOut.append( sZeroStr );
188 else
190 SvXMLUnitConverter::convertNumber( aOut, nValue );
193 rStrExpValue = aOut.makeStringAndClear();
195 bRet = sal_True;
198 return bRet;
201 ///////////////////////////////////////////////////////////////////////////////
203 // class XMLMeasurePropHdl
206 XMLMeasurePropHdl::~XMLMeasurePropHdl()
208 // nothing to do
211 sal_Bool XMLMeasurePropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const
213 sal_Bool bRet = sal_False;
215 sal_Int32 nValue = 0;
216 bRet = rUnitConverter.convertMeasure( nValue, rStrImpValue );
217 lcl_xmloff_setAny( rValue, nValue, nBytes );
219 return bRet;
222 sal_Bool XMLMeasurePropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const
224 sal_Bool bRet = sal_False;
225 sal_Int32 nValue;
226 OUStringBuffer aOut;
228 if( lcl_xmloff_getAny( rValue, nValue, nBytes ) )
230 rUnitConverter.convertMeasure( aOut, nValue );
231 rStrExpValue = aOut.makeStringAndClear();
233 bRet = sal_True;
236 return bRet;
239 ///////////////////////////////////////////////////////////////////////////////
241 // class XMLBoolPropHdl
244 XMLBoolPropHdl::~XMLBoolPropHdl()
246 // nothing to do
249 sal_Bool XMLBoolPropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
251 sal_Bool bRet = sal_False;
253 sal_Bool bValue;
254 bRet = SvXMLUnitConverter::convertBool( bValue, rStrImpValue );
255 rValue <<= sal_Bool(bValue);
257 return bRet;
260 sal_Bool XMLBoolPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
262 sal_Bool bRet = sal_False;
263 OUStringBuffer aOut;
264 sal_Bool bValue = sal_Bool();
266 if (rValue >>= bValue)
268 SvXMLUnitConverter::convertBool( aOut, bValue );
269 rStrExpValue = aOut.makeStringAndClear();
271 bRet = sal_True;
274 return bRet;
277 ///////////////////////////////////////////////////////////////////////////////
279 // class XMLNBoolPropHdl
282 XMLNBoolPropHdl::~XMLNBoolPropHdl()
284 // nothing to do
287 sal_Bool XMLNBoolPropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
289 sal_Bool bRet = sal_False;
291 sal_Bool bValue;
292 bRet = SvXMLUnitConverter::convertBool( bValue, rStrImpValue );
293 rValue <<= sal_Bool(!bValue);
295 return bRet;
298 sal_Bool XMLNBoolPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
300 sal_Bool bRet = sal_False;
301 OUStringBuffer aOut;
302 sal_Bool bValue = sal_Bool();
304 if (rValue >>= bValue)
306 SvXMLUnitConverter::convertBool( aOut, !bValue );
307 rStrExpValue = aOut.makeStringAndClear();
309 bRet = sal_True;
312 return bRet;
315 ///////////////////////////////////////////////////////////////////////////////
317 // class XMLPercentPropHdl
320 XMLPercentPropHdl::~XMLPercentPropHdl()
322 // nothing to do
325 sal_Bool XMLPercentPropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
327 sal_Bool bRet = sal_False;
329 sal_Int32 nValue = 0;
330 bRet = SvXMLUnitConverter::convertPercent( nValue, rStrImpValue );
331 lcl_xmloff_setAny( rValue, nValue, nBytes );
333 return bRet;
336 sal_Bool XMLPercentPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
338 sal_Bool bRet = sal_False;
339 sal_Int32 nValue;
340 OUStringBuffer aOut;
342 if( lcl_xmloff_getAny( rValue, nValue, nBytes ) )
344 SvXMLUnitConverter::convertPercent( aOut, nValue );
345 rStrExpValue = aOut.makeStringAndClear();
347 bRet = sal_True;
350 return bRet;
353 ///////////////////////////////////////////////////////////////////////////////
355 // class XMLDoublePercentPropHdl
358 sal_Bool XMLDoublePercentPropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
360 sal_Bool bRet = sal_False;
362 double fValue = 1.0;
364 if( rStrImpValue.indexOf( (sal_Unicode)'%' ) == -1 )
366 fValue = rStrImpValue.toDouble();
368 else
370 sal_Int32 nValue = 0;
371 bRet = SvXMLUnitConverter::convertPercent( nValue, rStrImpValue );
372 fValue = ((double)nValue) / 100.0;
374 rValue <<= fValue;
376 return bRet;
379 sal_Bool XMLDoublePercentPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
381 sal_Bool bRet = sal_False;
382 double fValue = 0;
384 if( rValue >>= fValue )
386 fValue *= 100.0;
387 if( fValue > 0 ) fValue += 0.5; else fValue -= 0.5;
389 sal_Int32 nValue = (sal_Int32)fValue;
391 OUStringBuffer aOut;
392 SvXMLUnitConverter::convertPercent( aOut, nValue );
393 rStrExpValue = aOut.makeStringAndClear();
395 bRet = sal_True;
398 return bRet;
402 ///////////////////////////////////////////////////////////////////////////////
404 // class XMLNegPercentPropHdl
407 XMLNegPercentPropHdl::~XMLNegPercentPropHdl()
409 // nothing to do
412 sal_Bool XMLNegPercentPropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
414 sal_Bool bRet = sal_False;
416 sal_Int32 nValue = 0;
417 bRet = SvXMLUnitConverter::convertPercent( nValue, rStrImpValue );
418 lcl_xmloff_setAny( rValue, 100-nValue, nBytes );
420 return bRet;
423 sal_Bool XMLNegPercentPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
425 sal_Bool bRet = sal_False;
426 sal_Int32 nValue;
427 OUStringBuffer aOut;
429 if( lcl_xmloff_getAny( rValue, nValue, nBytes ) )
431 SvXMLUnitConverter::convertPercent( aOut, 100-nValue );
432 rStrExpValue = aOut.makeStringAndClear();
434 bRet = sal_True;
437 return bRet;
441 ///////////////////////////////////////////////////////////////////////////////
443 // class XMLMeasurePxPropHdl
446 XMLMeasurePxPropHdl::~XMLMeasurePxPropHdl()
448 // nothing to do
451 sal_Bool XMLMeasurePxPropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
453 sal_Bool bRet = sal_False;
455 sal_Int32 nValue = 0;
456 bRet = SvXMLUnitConverter::convertMeasurePx( nValue, rStrImpValue );
457 lcl_xmloff_setAny( rValue, nValue, nBytes );
459 return bRet;
462 sal_Bool XMLMeasurePxPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
464 sal_Bool bRet = sal_False;
465 sal_Int32 nValue;
466 OUStringBuffer aOut;
468 if( lcl_xmloff_getAny( rValue, nValue, nBytes ) )
470 SvXMLUnitConverter::convertMeasurePx( aOut, nValue );
471 rStrExpValue = aOut.makeStringAndClear();
473 bRet = sal_True;
476 return bRet;
479 ///////////////////////////////////////////////////////////////////////////////
481 // class XMLColorPropHdl
484 XMLColorPropHdl::~XMLColorPropHdl()
486 // Nothing to do
489 sal_Bool XMLColorPropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
491 sal_Bool bRet = sal_False;
492 Color aColor;
494 const OUString astrHSL( RTL_CONSTASCII_USTRINGPARAM( "hsl" ) );
495 if( rStrImpValue.matchIgnoreAsciiCase( astrHSL ) )
497 sal_Int32 nOpen = rStrImpValue.indexOf( '(' );
498 sal_Int32 nClose = rStrImpValue.lastIndexOf( ')' );
500 if( (nOpen != -1) && (nClose > nOpen) )
502 const OUString aTmp( rStrImpValue.copy( nOpen+1, nClose - nOpen-1) );
504 sal_Int32 nIndex = 0;
506 Sequence< double > aHSL(3);
507 aHSL[0] = aTmp.getToken( 0, ',', nIndex ).toDouble();
508 aHSL[1] = aTmp.getToken( 0, ',', nIndex ).toDouble() / 100.0;
509 aHSL[2] = aTmp.getToken( 0, ',', nIndex ).toDouble() / 100.0;
510 rValue <<= aHSL;
511 bRet = true;
514 else
516 bRet = SvXMLUnitConverter::convertColor( aColor, rStrImpValue );
517 rValue <<= (sal_Int32)( aColor.GetColor() );
520 return bRet;
523 sal_Bool XMLColorPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
525 sal_Bool bRet = sal_False;
526 Color aColor;
527 sal_Int32 nColor = 0;
529 OUStringBuffer aOut;
530 if( rValue >>= nColor )
532 aColor.SetColor( nColor );
534 SvXMLUnitConverter::convertColor( aOut, aColor );
535 rStrExpValue = aOut.makeStringAndClear();
537 bRet = sal_True;
539 else
541 Sequence< double > aHSL;
542 if( (rValue >>= aHSL) && (aHSL.getLength() == 3) )
544 aOut.append( OUString::createFromAscii("hsl(") );
545 aOut.append( aHSL[0] );
546 aOut.append( OUString::createFromAscii(",") );
547 aOut.append( aHSL[1] * 100.0 );
548 aOut.append( OUString::createFromAscii("%,") );
549 aOut.append( aHSL[2] * 100.0 );
550 aOut.append( OUString::createFromAscii("%)") );
551 rStrExpValue = aOut.makeStringAndClear();
553 bRet = sal_True;
557 return bRet;
560 ///////////////////////////////////////////////////////////////////////////////
562 // class XMLStringPropHdl
565 XMLStringPropHdl::~XMLStringPropHdl()
567 // Nothing to do
570 sal_Bool XMLStringPropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
572 sal_Bool bRet = sal_False;
574 rValue <<= rStrImpValue;
575 bRet = sal_True;
577 return bRet;
580 sal_Bool XMLStringPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
582 sal_Bool bRet = sal_False;
584 if( rValue >>= rStrExpValue )
585 bRet = sal_True;
587 return bRet;
590 ///////////////////////////////////////////////////////////////////////////////
592 // class XMLStyleNamePropHdl
595 XMLStyleNamePropHdl::~XMLStyleNamePropHdl()
597 // Nothing to do
600 sal_Bool XMLStyleNamePropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const
602 sal_Bool bRet = sal_False;
604 if( rValue >>= rStrExpValue )
606 rStrExpValue = rUnitConverter.encodeStyleName( rStrExpValue );
607 bRet = sal_True;
610 return bRet;
614 ///////////////////////////////////////////////////////////////////////////////
616 // class XMLDoublePropHdl
619 XMLDoublePropHdl::~XMLDoublePropHdl()
621 // Nothing to do
624 sal_Bool XMLDoublePropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
626 double fDblValue;
627 sal_Bool bRet = SvXMLUnitConverter::convertDouble( fDblValue, rStrImpValue );
628 rValue <<= fDblValue;
629 return bRet;
632 sal_Bool XMLDoublePropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
634 sal_Bool bRet = sal_False;
636 double fValue = 0;
638 if( rValue >>= fValue )
640 OUStringBuffer aOut;
641 SvXMLUnitConverter::convertDouble( aOut, fValue );
642 rStrExpValue = aOut.makeStringAndClear();
643 bRet = sal_True;
646 return bRet;
649 ///////////////////////////////////////////////////////////////////////////////
651 // class XMLColorTransparentPropHdl
654 XMLColorTransparentPropHdl::XMLColorTransparentPropHdl(
655 enum XMLTokenEnum eTransparent ) :
656 sTransparent( GetXMLToken(
657 eTransparent != XML_TOKEN_INVALID ? eTransparent : XML_TRANSPARENT ) )
659 // Nothing to do
662 XMLColorTransparentPropHdl::~XMLColorTransparentPropHdl()
664 // Nothing to do
667 sal_Bool XMLColorTransparentPropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
669 sal_Bool bRet = sal_False;
671 if( rStrImpValue != sTransparent )
673 Color aColor;
674 bRet = SvXMLUnitConverter::convertColor( aColor, rStrImpValue );
675 rValue <<= (sal_Int32)( aColor.GetColor() );
678 return bRet;
681 sal_Bool XMLColorTransparentPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
683 sal_Bool bRet = sal_False;
684 sal_Int32 nColor = 0;
686 if( rStrExpValue == sTransparent )
687 bRet = sal_False;
688 else if( rValue >>= nColor )
690 Color aColor( nColor );
691 OUStringBuffer aOut;
692 SvXMLUnitConverter::convertColor( aOut, aColor );
693 rStrExpValue = aOut.makeStringAndClear();
695 bRet = sal_True;
698 return bRet;
702 ///////////////////////////////////////////////////////////////////////////////
704 // class XMLIsTransparentPropHdl
707 XMLIsTransparentPropHdl::XMLIsTransparentPropHdl(
708 enum XMLTokenEnum eTransparent, sal_Bool bTransPropVal ) :
709 sTransparent( GetXMLToken(
710 eTransparent != XML_TOKEN_INVALID ? eTransparent : XML_TRANSPARENT ) ),
711 bTransPropValue( bTransPropVal )
715 XMLIsTransparentPropHdl::~XMLIsTransparentPropHdl()
717 // Nothing to do
720 sal_Bool XMLIsTransparentPropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
722 sal_Bool bValue = ( (rStrImpValue == sTransparent) == bTransPropValue);
723 rValue.setValue( &bValue, ::getBooleanCppuType() );
725 return sal_True;
728 sal_Bool XMLIsTransparentPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
730 sal_Bool bRet = sal_False;
732 // MIB: This looks a bit strange, because bTransPropValue == bValue should
733 // do the same, but this only applies if 'true' is represented by the same
734 // 8 bit value in bValue and bTransPropValue. Who will ensure this?
735 sal_Bool bValue = *(sal_Bool *)rValue.getValue();
736 sal_Bool bIsTrans = bTransPropValue ? bValue : !bValue;
738 if( bIsTrans )
740 rStrExpValue = sTransparent;
741 bRet = sal_True;
744 return bRet;
747 ///////////////////////////////////////////////////////////////////////////////
749 // class XMLColorAutoPropHdl
752 XMLColorAutoPropHdl::XMLColorAutoPropHdl()
754 // Nothing to do
757 XMLColorAutoPropHdl::~XMLColorAutoPropHdl()
759 // Nothing to do
762 sal_Bool XMLColorAutoPropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
764 sal_Bool bRet = sal_False;
766 // This is a multi property: the value might be set to AUTO_COLOR
767 // already by the XMLIsAutoColorPropHdl!
768 sal_Int32 nColor = 0;
769 if( !(rValue >>= nColor) || -1 != nColor )
771 Color aColor;
772 bRet = SvXMLUnitConverter::convertColor( aColor, rStrImpValue );
773 if( bRet )
774 rValue <<= (sal_Int32)( aColor.GetColor() );
777 return bRet;
780 sal_Bool XMLColorAutoPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
782 sal_Bool bRet = sal_False;
784 sal_Int32 nColor = 0;
785 if( (rValue >>= nColor) && -1 != nColor )
787 Color aColor( nColor );
788 OUStringBuffer aOut;
789 SvXMLUnitConverter::convertColor( aOut, aColor );
790 rStrExpValue = aOut.makeStringAndClear();
792 bRet = sal_True;
795 return bRet;
798 ///////////////////////////////////////////////////////////////////////////////
800 // class XMLIsAutoColorPropHdl
803 XMLIsAutoColorPropHdl::XMLIsAutoColorPropHdl()
807 XMLIsAutoColorPropHdl::~XMLIsAutoColorPropHdl()
809 // Nothing to do
812 sal_Bool XMLIsAutoColorPropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
814 sal_Bool bValue;
816 // An auto color overrides any other color set!
817 sal_Bool bRet = SvXMLUnitConverter::convertBool( bValue, rStrImpValue );
818 if( bRet && bValue )
819 rValue <<= (sal_Int32)-1;
821 return sal_True;
824 sal_Bool XMLIsAutoColorPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
826 sal_Bool bRet = sal_False;
827 sal_Int32 nColor = 0;
829 if( (rValue >>= nColor) && -1 == nColor )
831 OUStringBuffer aOut;
832 SvXMLUnitConverter::convertBool( aOut, sal_True );
833 rStrExpValue = aOut.makeStringAndClear();
835 bRet = sal_True;
838 return bRet;
841 ///////////////////////////////////////////////////////////////////////////////
843 // class XMLCompareOnlyPropHdl
846 XMLCompareOnlyPropHdl::~XMLCompareOnlyPropHdl()
848 // Nothing to do
851 sal_Bool XMLCompareOnlyPropHdl::importXML( const OUString&, Any&, const SvXMLUnitConverter& ) const
853 DBG_ASSERT( !this, "importXML called for compare-only-property" );
854 return sal_False;
857 sal_Bool XMLCompareOnlyPropHdl::exportXML( OUString&, const Any&, const SvXMLUnitConverter& ) const
859 DBG_ASSERT( !this, "exportXML called for compare-only-property" );
860 return sal_False;
863 ///////////////////////////////////////////////////////////////////////////////
864 // class XMLNumberWithoutZeroPropHdl
867 XMLNumberWithoutZeroPropHdl::XMLNumberWithoutZeroPropHdl( sal_Int8 nB ) :
868 nBytes( nB )
872 XMLNumberWithoutZeroPropHdl::~XMLNumberWithoutZeroPropHdl()
876 sal_Bool XMLNumberWithoutZeroPropHdl::importXML(
877 const OUString& rStrImpValue,
878 Any& rValue,
879 const SvXMLUnitConverter& ) const
881 sal_Int32 nValue = 0;
882 sal_Bool bRet = SvXMLUnitConverter::convertNumber( nValue, rStrImpValue );
883 if( bRet )
884 lcl_xmloff_setAny( rValue, nValue, nBytes );
885 return bRet;
888 sal_Bool XMLNumberWithoutZeroPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
891 sal_Int32 nValue = 0;
892 sal_Bool bRet = lcl_xmloff_getAny( rValue, nValue, nBytes );
893 bRet &= nValue != 0;
895 if( bRet )
897 OUStringBuffer aBuffer;
898 SvXMLUnitConverter::convertNumber( aBuffer, nValue );
899 rStrExpValue = aBuffer.makeStringAndClear();
902 return bRet;
905 ///////////////////////////////////////////////////////////////////////////////
906 // class XMLNumberWithAutoInsteadZeroPropHdl
909 XMLNumberWithAutoInsteadZeroPropHdl::~XMLNumberWithAutoInsteadZeroPropHdl()
913 sal_Bool XMLNumberWithAutoInsteadZeroPropHdl::importXML(
914 const OUString& rStrImpValue,
915 Any& rValue,
916 const SvXMLUnitConverter& ) const
918 sal_Int32 nValue = 0;
919 sal_Bool bRet = SvXMLUnitConverter::convertNumber( nValue, rStrImpValue );
920 if( bRet )
921 lcl_xmloff_setAny( rValue, nValue, 2 );
922 else if( rStrImpValue == GetXMLToken( XML_AUTO ) )
924 rValue <<= (sal_Int16)nValue;
925 bRet = sal_True;
927 return bRet;
930 sal_Bool XMLNumberWithAutoInsteadZeroPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
933 sal_Int32 nValue = 0;
934 lcl_xmloff_getAny( rValue, nValue, 2 );
936 if( 0 == nValue )
937 rStrExpValue = GetXMLToken( XML_AUTO );
938 else
940 OUStringBuffer aBuffer;
941 SvXMLUnitConverter::convertNumber( aBuffer, nValue );
942 rStrExpValue = aBuffer.makeStringAndClear();
945 return sal_True;