bump product version to 4.1.6.2
[LibreOffice.git] / xmloff / source / style / xmlbahdl.cxx
blob9a7c0ed582bdfa088374a60cb9d5dbc85f44d2a7
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
21 #include <xmlbahdl.hxx>
23 #include <tools/debug.hxx>
24 #include <sax/tools/converter.hxx>
25 #include <xmloff/xmluconv.hxx>
26 #include <com/sun/star/uno/Any.hxx>
27 #include <xmloff/xmltoken.hxx>
30 using namespace ::com::sun::star::uno;
31 using namespace ::xmloff::token;
33 static void lcl_xmloff_setAny( Any& rValue, sal_Int32 nValue, sal_Int8 nBytes )
35 switch( nBytes )
37 case 1:
38 if( nValue < SCHAR_MIN )
39 nValue = SCHAR_MIN;
40 else if( nValue > SCHAR_MAX )
41 nValue = SCHAR_MAX;
42 rValue <<= (sal_Int8)nValue;
43 break;
44 case 2:
45 if( nValue < SHRT_MIN )
46 nValue = SHRT_MIN;
47 else if( nValue > SHRT_MAX )
48 nValue = SHRT_MAX;
49 rValue <<= (sal_Int16)nValue;
50 break;
51 case 4:
52 rValue <<= nValue;
53 break;
57 static sal_Bool lcl_xmloff_getAny( const Any& rValue, sal_Int32& nValue,
58 sal_Int8 nBytes )
60 sal_Bool bRet = sal_False;
62 switch( nBytes )
64 case 1:
66 sal_Int8 nValue8 = 0;
67 bRet = rValue >>= nValue8;
68 nValue = nValue8;
70 break;
71 case 2:
73 sal_Int16 nValue16 = 0;
74 bRet = rValue >>= nValue16;
75 nValue = nValue16;
77 break;
78 case 4:
79 bRet = rValue >>= nValue;
80 break;
83 return bRet;
86 ///////////////////////////////////////////////////////////////////////////////
88 // class XMLNumberPropHdl
91 XMLNumberPropHdl::~XMLNumberPropHdl()
93 // nothing to do
96 sal_Bool XMLNumberPropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
98 sal_Int32 nValue = 0;
99 bool bRet = ::sax::Converter::convertNumber( nValue, rStrImpValue );
100 lcl_xmloff_setAny( rValue, nValue, nBytes );
102 return bRet;
105 sal_Bool XMLNumberPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
107 sal_Bool bRet = sal_False;
108 sal_Int32 nValue;
109 OUStringBuffer aOut;
111 if( lcl_xmloff_getAny( rValue, nValue, nBytes ) )
113 ::sax::Converter::convertNumber( aOut, nValue );
114 rStrExpValue = aOut.makeStringAndClear();
116 bRet = sal_True;
119 return bRet;
122 ///////////////////////////////////////////////////////////////////////////////
123 // class XMLNumberNonePropHdl
126 XMLNumberNonePropHdl::XMLNumberNonePropHdl( sal_Int8 nB ) :
127 sZeroStr( GetXMLToken(XML_NO_LIMIT) ),
128 nBytes( nB )
132 XMLNumberNonePropHdl::XMLNumberNonePropHdl( enum XMLTokenEnum eZeroString, sal_Int8 nB ) :
133 sZeroStr( GetXMLToken( eZeroString ) ),
134 nBytes( nB )
138 XMLNumberNonePropHdl::~XMLNumberNonePropHdl()
140 // nothing to do
143 sal_Bool XMLNumberNonePropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
145 sal_Bool bRet = sal_False;
147 sal_Int32 nValue = 0;
148 if( rStrImpValue == sZeroStr )
150 bRet = sal_True;
152 else
154 bRet = ::sax::Converter::convertNumber( nValue, rStrImpValue );
156 lcl_xmloff_setAny( rValue, nValue, nBytes );
158 return bRet;
161 sal_Bool XMLNumberNonePropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
163 sal_Bool bRet = sal_False;
164 sal_Int32 nValue;
166 if( lcl_xmloff_getAny( rValue, nValue, nBytes ) )
168 OUStringBuffer aOut;
170 if( nValue == 0 )
172 aOut.append( sZeroStr );
174 else
176 ::sax::Converter::convertNumber( aOut, nValue );
179 rStrExpValue = aOut.makeStringAndClear();
181 bRet = sal_True;
184 return bRet;
187 ///////////////////////////////////////////////////////////////////////////////
189 // class XMLMeasurePropHdl
192 XMLMeasurePropHdl::~XMLMeasurePropHdl()
194 // nothing to do
197 sal_Bool XMLMeasurePropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const
199 sal_Bool bRet = sal_False;
201 sal_Int32 nValue = 0;
202 bRet = rUnitConverter.convertMeasureToCore( nValue, rStrImpValue );
203 lcl_xmloff_setAny( rValue, nValue, nBytes );
205 return bRet;
208 sal_Bool XMLMeasurePropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const
210 sal_Bool bRet = sal_False;
211 sal_Int32 nValue;
212 OUStringBuffer aOut;
214 if( lcl_xmloff_getAny( rValue, nValue, nBytes ) )
216 rUnitConverter.convertMeasureToXML( aOut, nValue );
217 rStrExpValue = aOut.makeStringAndClear();
219 bRet = sal_True;
222 return bRet;
225 ///////////////////////////////////////////////////////////////////////////////
227 // class XMLBoolFalsePropHdl
230 XMLBoolFalsePropHdl::~XMLBoolFalsePropHdl()
232 // nothing to do
235 sal_Bool XMLBoolFalsePropHdl::importXML( const OUString&, Any&, const SvXMLUnitConverter& ) const
237 return sal_False;
240 sal_Bool XMLBoolFalsePropHdl::exportXML( OUString& rStrExpValue, const Any& /*rValue*/, const SvXMLUnitConverter& rCnv) const
242 return XMLBoolPropHdl::exportXML( rStrExpValue, makeAny( sal_False ), rCnv );
245 ///////////////////////////////////////////////////////////////////////////////
247 // class XMLBoolPropHdl
250 XMLBoolPropHdl::~XMLBoolPropHdl()
252 // nothing to do
255 sal_Bool XMLBoolPropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
257 bool bValue(false);
258 bool const bRet = ::sax::Converter::convertBool( bValue, rStrImpValue );
259 rValue <<= sal_Bool(bValue);
261 return bRet;
264 sal_Bool XMLBoolPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
266 sal_Bool bRet = sal_False;
267 OUStringBuffer aOut;
268 sal_Bool bValue = sal_Bool();
270 if (rValue >>= bValue)
272 ::sax::Converter::convertBool( aOut, bValue );
273 rStrExpValue = aOut.makeStringAndClear();
275 bRet = sal_True;
278 return bRet;
281 ///////////////////////////////////////////////////////////////////////////////
283 // class XMLNBoolPropHdl
286 XMLNBoolPropHdl::~XMLNBoolPropHdl()
288 // nothing to do
291 sal_Bool XMLNBoolPropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
293 bool bValue(false);
294 bool const bRet = ::sax::Converter::convertBool( bValue, rStrImpValue );
295 rValue <<= sal_Bool(!bValue);
297 return bRet;
300 sal_Bool XMLNBoolPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
302 sal_Bool bRet = sal_False;
303 OUStringBuffer aOut;
304 sal_Bool bValue = sal_Bool();
306 if (rValue >>= bValue)
308 ::sax::Converter::convertBool( aOut, !bValue );
309 rStrExpValue = aOut.makeStringAndClear();
311 bRet = sal_True;
314 return bRet;
317 ///////////////////////////////////////////////////////////////////////////////
319 // class XMLPercentPropHdl
322 XMLPercentPropHdl::~XMLPercentPropHdl()
324 // nothing to do
327 sal_Bool XMLPercentPropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
329 sal_Int32 nValue = 0;
330 bool const bRet = ::sax::Converter::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 ::sax::Converter::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 = ::sax::Converter::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 ::sax::Converter::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_Int32 nValue = 0;
415 bool const bRet = ::sax::Converter::convertPercent( nValue, rStrImpValue );
416 lcl_xmloff_setAny( rValue, 100-nValue, nBytes );
418 return bRet;
421 sal_Bool XMLNegPercentPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
423 sal_Bool bRet = sal_False;
424 sal_Int32 nValue;
425 OUStringBuffer aOut;
427 if( lcl_xmloff_getAny( rValue, nValue, nBytes ) )
429 ::sax::Converter::convertPercent( aOut, 100-nValue );
430 rStrExpValue = aOut.makeStringAndClear();
432 bRet = sal_True;
435 return bRet;
439 ///////////////////////////////////////////////////////////////////////////////
441 // class XMLMeasurePxPropHdl
444 XMLMeasurePxPropHdl::~XMLMeasurePxPropHdl()
446 // nothing to do
449 sal_Bool XMLMeasurePxPropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
451 sal_Bool bRet = sal_False;
453 sal_Int32 nValue = 0;
454 bRet = ::sax::Converter::convertMeasurePx( nValue, rStrImpValue );
455 lcl_xmloff_setAny( rValue, nValue, nBytes );
457 return bRet;
460 sal_Bool XMLMeasurePxPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
462 sal_Bool bRet = sal_False;
463 sal_Int32 nValue;
464 OUStringBuffer aOut;
466 if( lcl_xmloff_getAny( rValue, nValue, nBytes ) )
468 ::sax::Converter::convertMeasurePx( aOut, nValue );
469 rStrExpValue = aOut.makeStringAndClear();
471 bRet = sal_True;
474 return bRet;
477 ///////////////////////////////////////////////////////////////////////////////
479 // class XMLColorPropHdl
482 XMLColorPropHdl::~XMLColorPropHdl()
484 // Nothing to do
487 sal_Bool XMLColorPropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
489 sal_Bool bRet = sal_False;
491 const OUString astrHSL( "hsl" );
492 if( rStrImpValue.matchIgnoreAsciiCase( astrHSL ) )
494 sal_Int32 nOpen = rStrImpValue.indexOf( '(' );
495 sal_Int32 nClose = rStrImpValue.lastIndexOf( ')' );
497 if( (nOpen != -1) && (nClose > nOpen) )
499 const OUString aTmp( rStrImpValue.copy( nOpen+1, nClose - nOpen-1) );
501 sal_Int32 nIndex = 0;
503 Sequence< double > aHSL(3);
504 aHSL[0] = aTmp.getToken( 0, ',', nIndex ).toDouble();
505 aHSL[1] = aTmp.getToken( 0, ',', nIndex ).toDouble() / 100.0;
506 aHSL[2] = aTmp.getToken( 0, ',', nIndex ).toDouble() / 100.0;
507 rValue <<= aHSL;
508 bRet = true;
511 else
513 sal_Int32 nColor(0);
514 bRet = ::sax::Converter::convertColor( nColor, rStrImpValue );
515 rValue <<= nColor;
518 return bRet;
521 sal_Bool XMLColorPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
523 sal_Bool bRet = sal_False;
524 sal_Int32 nColor = 0;
526 OUStringBuffer aOut;
527 if( rValue >>= nColor )
529 ::sax::Converter::convertColor( aOut, nColor );
530 rStrExpValue = aOut.makeStringAndClear();
532 bRet = sal_True;
534 else
536 Sequence< double > aHSL;
537 if( (rValue >>= aHSL) && (aHSL.getLength() == 3) )
539 aOut.append( OUString("hsl(") );
540 aOut.append( aHSL[0] );
541 aOut.append( OUString(",") );
542 aOut.append( aHSL[1] * 100.0 );
543 aOut.append( OUString("%,") );
544 aOut.append( aHSL[2] * 100.0 );
545 aOut.append( OUString("%)") );
546 rStrExpValue = aOut.makeStringAndClear();
548 bRet = sal_True;
552 return bRet;
555 ///////////////////////////////////////////////////////////////////////////////
557 // class XMLHexPropHdl
560 XMLHexPropHdl::~XMLHexPropHdl()
562 // Nothing to do
565 sal_Bool XMLHexPropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
567 sal_Bool bRet = sal_False;
568 sal_uInt32 nRsid;
570 bRet = SvXMLUnitConverter::convertHex( nRsid, rStrImpValue );
571 rValue <<= nRsid;
573 return bRet;
576 sal_Bool XMLHexPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
578 sal_Bool bRet = sal_False;
579 sal_uInt32 nRsid = 0;
581 OUStringBuffer aOut;
582 if( rValue >>= nRsid )
584 SvXMLUnitConverter::convertHex( aOut, nRsid );
585 rStrExpValue = aOut.makeStringAndClear();
587 bRet = sal_True;
589 else
591 bRet = sal_False;
594 return bRet;
597 ///////////////////////////////////////////////////////////////////////////////
599 // class XMLStringPropHdl
602 XMLStringPropHdl::~XMLStringPropHdl()
604 // Nothing to do
607 sal_Bool XMLStringPropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
609 sal_Bool bRet = sal_False;
611 rValue <<= rStrImpValue;
612 bRet = sal_True;
614 return bRet;
617 sal_Bool XMLStringPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
619 sal_Bool bRet = sal_False;
621 if( rValue >>= rStrExpValue )
622 bRet = sal_True;
624 return bRet;
627 ///////////////////////////////////////////////////////////////////////////////
629 // class XMLStyleNamePropHdl
632 XMLStyleNamePropHdl::~XMLStyleNamePropHdl()
634 // Nothing to do
637 sal_Bool XMLStyleNamePropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const
639 sal_Bool bRet = sal_False;
641 if( rValue >>= rStrExpValue )
643 rStrExpValue = rUnitConverter.encodeStyleName( rStrExpValue );
644 bRet = sal_True;
647 return bRet;
651 ///////////////////////////////////////////////////////////////////////////////
653 // class XMLDoublePropHdl
656 XMLDoublePropHdl::~XMLDoublePropHdl()
658 // Nothing to do
661 sal_Bool XMLDoublePropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
663 double fDblValue(0.0);
664 bool const bRet = ::sax::Converter::convertDouble(fDblValue, rStrImpValue);
665 rValue <<= fDblValue;
666 return bRet;
669 sal_Bool XMLDoublePropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
671 sal_Bool bRet = sal_False;
673 double fValue = 0;
675 if( rValue >>= fValue )
677 OUStringBuffer aOut;
678 ::sax::Converter::convertDouble( aOut, fValue );
679 rStrExpValue = aOut.makeStringAndClear();
680 bRet = sal_True;
683 return bRet;
686 ///////////////////////////////////////////////////////////////////////////////
688 // class XMLColorTransparentPropHdl
691 XMLColorTransparentPropHdl::XMLColorTransparentPropHdl(
692 enum XMLTokenEnum eTransparent ) :
693 sTransparent( GetXMLToken(
694 eTransparent != XML_TOKEN_INVALID ? eTransparent : XML_TRANSPARENT ) )
696 // Nothing to do
699 XMLColorTransparentPropHdl::~XMLColorTransparentPropHdl()
701 // Nothing to do
704 sal_Bool XMLColorTransparentPropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
706 sal_Bool bRet = sal_False;
708 if( rStrImpValue != sTransparent )
710 sal_Int32 nColor(0);
711 bRet = ::sax::Converter::convertColor( nColor, rStrImpValue );
712 rValue <<= nColor;
715 return bRet;
718 sal_Bool XMLColorTransparentPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
720 sal_Bool bRet = sal_False;
721 sal_Int32 nColor = 0;
723 if( rStrExpValue == sTransparent )
724 bRet = sal_False;
725 else if( rValue >>= nColor )
727 OUStringBuffer aOut;
728 ::sax::Converter::convertColor( aOut, nColor );
729 rStrExpValue = aOut.makeStringAndClear();
731 bRet = sal_True;
734 return bRet;
738 ///////////////////////////////////////////////////////////////////////////////
740 // class XMLIsTransparentPropHdl
743 XMLIsTransparentPropHdl::XMLIsTransparentPropHdl(
744 enum XMLTokenEnum eTransparent, sal_Bool bTransPropVal ) :
745 sTransparent( GetXMLToken(
746 eTransparent != XML_TOKEN_INVALID ? eTransparent : XML_TRANSPARENT ) ),
747 bTransPropValue( bTransPropVal )
751 XMLIsTransparentPropHdl::~XMLIsTransparentPropHdl()
753 // Nothing to do
756 sal_Bool XMLIsTransparentPropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
758 sal_Bool bValue = ( (rStrImpValue == sTransparent) == bTransPropValue);
759 rValue.setValue( &bValue, ::getBooleanCppuType() );
761 return sal_True;
764 sal_Bool XMLIsTransparentPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
766 sal_Bool bRet = sal_False;
768 // MIB: This looks a bit strange, because bTransPropValue == bValue should
769 // do the same, but this only applies if 'true' is represented by the same
770 // 8 bit value in bValue and bTransPropValue. Who will ensure this?
771 sal_Bool bValue = *(sal_Bool *)rValue.getValue();
772 sal_Bool bIsTrans = bTransPropValue ? bValue : !bValue;
774 if( bIsTrans )
776 rStrExpValue = sTransparent;
777 bRet = sal_True;
780 return bRet;
783 ///////////////////////////////////////////////////////////////////////////////
785 // class XMLColorAutoPropHdl
788 XMLColorAutoPropHdl::XMLColorAutoPropHdl()
790 // Nothing to do
793 XMLColorAutoPropHdl::~XMLColorAutoPropHdl()
795 // Nothing to do
798 sal_Bool XMLColorAutoPropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
800 sal_Bool bRet = sal_False;
802 // This is a multi property: the value might be set to AUTO_COLOR
803 // already by the XMLIsAutoColorPropHdl!
804 sal_Int32 nColor = 0;
805 if( !(rValue >>= nColor) || -1 != nColor )
807 bRet = ::sax::Converter::convertColor( nColor, rStrImpValue );
808 if( bRet )
809 rValue <<= nColor;
812 return bRet;
815 sal_Bool XMLColorAutoPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
817 sal_Bool bRet = sal_False;
819 sal_Int32 nColor = 0;
820 if( (rValue >>= nColor) && -1 != nColor )
822 OUStringBuffer aOut;
823 ::sax::Converter::convertColor( aOut, nColor );
824 rStrExpValue = aOut.makeStringAndClear();
826 bRet = sal_True;
829 return bRet;
832 ///////////////////////////////////////////////////////////////////////////////
834 // class XMLIsAutoColorPropHdl
837 XMLIsAutoColorPropHdl::XMLIsAutoColorPropHdl()
841 XMLIsAutoColorPropHdl::~XMLIsAutoColorPropHdl()
843 // Nothing to do
846 sal_Bool XMLIsAutoColorPropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
848 // An auto color overrides any other color set!
849 bool bValue;
850 bool const bRet = ::sax::Converter::convertBool( bValue, rStrImpValue );
851 if( bRet && bValue )
852 rValue <<= (sal_Int32)-1;
854 return sal_True;
857 sal_Bool XMLIsAutoColorPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
859 sal_Bool bRet = sal_False;
860 sal_Int32 nColor = 0;
862 if( (rValue >>= nColor) && -1 == nColor )
864 OUStringBuffer aOut;
865 ::sax::Converter::convertBool( aOut, true );
866 rStrExpValue = aOut.makeStringAndClear();
868 bRet = sal_True;
871 return bRet;
874 ///////////////////////////////////////////////////////////////////////////////
876 // class XMLCompareOnlyPropHdl
879 XMLCompareOnlyPropHdl::~XMLCompareOnlyPropHdl()
881 // Nothing to do
884 sal_Bool XMLCompareOnlyPropHdl::importXML( const OUString&, Any&, const SvXMLUnitConverter& ) const
886 DBG_ASSERT( !this, "importXML called for compare-only-property" );
887 return sal_False;
890 sal_Bool XMLCompareOnlyPropHdl::exportXML( OUString&, const Any&, const SvXMLUnitConverter& ) const
892 DBG_ASSERT( !this, "exportXML called for compare-only-property" );
893 return sal_False;
896 ///////////////////////////////////////////////////////////////////////////////
897 // class XMLNumberWithoutZeroPropHdl
900 XMLNumberWithoutZeroPropHdl::XMLNumberWithoutZeroPropHdl( sal_Int8 nB ) :
901 nBytes( nB )
905 XMLNumberWithoutZeroPropHdl::~XMLNumberWithoutZeroPropHdl()
909 sal_Bool XMLNumberWithoutZeroPropHdl::importXML(
910 const OUString& rStrImpValue,
911 Any& rValue,
912 const SvXMLUnitConverter& ) const
914 sal_Int32 nValue = 0;
915 bool const bRet = ::sax::Converter::convertNumber( nValue, rStrImpValue );
916 if( bRet )
917 lcl_xmloff_setAny( rValue, nValue, nBytes );
918 return bRet;
921 sal_Bool XMLNumberWithoutZeroPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
924 sal_Int32 nValue = 0;
925 sal_Bool bRet = lcl_xmloff_getAny( rValue, nValue, nBytes );
926 bRet &= nValue != 0;
928 if( bRet )
930 OUStringBuffer aBuffer;
931 ::sax::Converter::convertNumber( aBuffer, nValue );
932 rStrExpValue = aBuffer.makeStringAndClear();
935 return bRet;
938 ///////////////////////////////////////////////////////////////////////////////
939 // class XMLNumberWithAutoInsteadZeroPropHdl
942 XMLNumberWithAutoInsteadZeroPropHdl::~XMLNumberWithAutoInsteadZeroPropHdl()
946 sal_Bool XMLNumberWithAutoInsteadZeroPropHdl::importXML(
947 const OUString& rStrImpValue,
948 Any& rValue,
949 const SvXMLUnitConverter& ) const
951 sal_Int32 nValue = 0;
952 bool bRet = ::sax::Converter::convertNumber( nValue, rStrImpValue );
953 if( bRet )
954 lcl_xmloff_setAny( rValue, nValue, 2 );
955 else if( rStrImpValue == GetXMLToken( XML_AUTO ) )
957 rValue <<= (sal_Int16)nValue;
958 bRet = sal_True;
960 return bRet;
963 sal_Bool XMLNumberWithAutoInsteadZeroPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
966 sal_Int32 nValue = 0;
967 lcl_xmloff_getAny( rValue, nValue, 2 );
969 if( 0 == nValue )
970 rStrExpValue = GetXMLToken( XML_AUTO );
971 else
973 OUStringBuffer aBuffer;
974 ::sax::Converter::convertNumber( aBuffer, nValue );
975 rStrExpValue = aBuffer.makeStringAndClear();
978 return sal_True;
981 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */