bump product version to 7.6.3.2-android
[LibreOffice.git] / xmloff / source / style / xmlbahdl.cxx
blob36bc1037cbaa702a0eb2decd2c8ca8a04ead2ce5
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 .
20 #include "xmlbahdl.hxx"
22 #include <XMLNumberWithAutoForVoidPropHdl.hxx>
23 #include <sal/log.hxx>
24 #include <o3tl/any.hxx>
25 #include <o3tl/safeint.hxx>
26 #include <o3tl/string_view.hxx>
27 #include <sax/tools/converter.hxx>
28 #include <xmloff/xmluconv.hxx>
29 #include <com/sun/star/uno/Any.hxx>
30 #include <xmloff/xmltoken.hxx>
32 #include <limits.h>
34 using namespace ::com::sun::star::uno;
35 using namespace ::xmloff::token;
37 static void lcl_xmloff_setAny( Any& rValue, sal_Int32 nValue, sal_Int8 nBytes )
39 switch( nBytes )
41 case 1:
42 if( nValue < SCHAR_MIN )
43 nValue = SCHAR_MIN;
44 else if( nValue > SCHAR_MAX )
45 nValue = SCHAR_MAX;
46 rValue <<= static_cast<sal_Int8>(nValue);
47 break;
48 case 2:
49 if( nValue < SHRT_MIN )
50 nValue = SHRT_MIN;
51 else if( nValue > SHRT_MAX )
52 nValue = SHRT_MAX;
53 rValue <<= static_cast<sal_Int16>(nValue);
54 break;
55 case 4:
56 rValue <<= nValue;
57 break;
61 static bool lcl_xmloff_getAny( const Any& rValue, sal_Int32& nValue,
62 sal_Int8 nBytes )
64 bool bRet = false;
66 switch( nBytes )
68 case 1:
70 sal_Int8 nValue8 = 0;
71 bRet = rValue >>= nValue8;
72 nValue = nValue8;
74 break;
75 case 2:
77 sal_Int16 nValue16 = 0;
78 bRet = rValue >>= nValue16;
79 nValue = nValue16;
81 break;
82 case 4:
83 bRet = rValue >>= nValue;
84 break;
87 return bRet;
91 XMLNumberPropHdl::~XMLNumberPropHdl()
93 // nothing to do
96 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 bool XMLNumberPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
107 bool bRet = false;
108 sal_Int32 nValue;
110 if( lcl_xmloff_getAny( rValue, nValue, nBytes ) )
112 rStrExpValue = OUString::number( nValue );
114 bRet = true;
117 return bRet;
121 XMLNumberNonePropHdl::XMLNumberNonePropHdl( sal_Int8 nB ) :
122 sZeroStr( GetXMLToken(XML_NO_LIMIT) ),
123 nBytes( nB )
127 XMLNumberNonePropHdl::XMLNumberNonePropHdl( enum XMLTokenEnum eZeroString, sal_Int8 nB ) :
128 sZeroStr( GetXMLToken( eZeroString ) ),
129 nBytes( nB )
133 XMLNumberNonePropHdl::~XMLNumberNonePropHdl()
135 // nothing to do
138 bool XMLNumberNonePropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
140 bool bRet = false;
142 sal_Int32 nValue = 0;
143 if( rStrImpValue == sZeroStr )
145 bRet = true;
147 else
149 bRet = ::sax::Converter::convertNumber( nValue, rStrImpValue );
151 lcl_xmloff_setAny( rValue, nValue, nBytes );
153 return bRet;
156 bool XMLNumberNonePropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
158 bool bRet = false;
159 sal_Int32 nValue;
161 if( lcl_xmloff_getAny( rValue, nValue, nBytes ) )
163 if( nValue == 0 )
165 rStrExpValue = sZeroStr;
167 else
169 rStrExpValue = OUString::number( nValue );
172 bRet = true;
175 return bRet;
179 XMLMeasurePropHdl::~XMLMeasurePropHdl()
181 // nothing to do
184 bool XMLMeasurePropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const
186 sal_Int32 nValue = 0;
187 bool bRet = rUnitConverter.convertMeasureToCore( nValue, rStrImpValue );
188 lcl_xmloff_setAny( rValue, nValue, nBytes );
189 return bRet;
192 bool XMLMeasurePropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const
194 bool bRet = false;
195 sal_Int32 nValue;
197 if( lcl_xmloff_getAny( rValue, nValue, nBytes ) )
199 OUStringBuffer aOut;
200 rUnitConverter.convertMeasureToXML( aOut, nValue );
201 rStrExpValue = aOut.makeStringAndClear();
203 bRet = true;
206 return bRet;
210 XMLBoolFalsePropHdl::~XMLBoolFalsePropHdl()
212 // nothing to do
215 bool XMLBoolFalsePropHdl::importXML( const OUString&, Any&, const SvXMLUnitConverter& ) const
217 return false;
220 bool XMLBoolFalsePropHdl::exportXML( OUString& rStrExpValue, const Any& /*rValue*/, const SvXMLUnitConverter& rCnv) const
222 return XMLBoolPropHdl::exportXML( rStrExpValue, Any( false ), rCnv );
226 XMLBoolPropHdl::~XMLBoolPropHdl()
228 // nothing to do
231 bool XMLBoolPropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
233 bool bValue(false);
234 bool const bRet = ::sax::Converter::convertBool( bValue, rStrImpValue );
235 rValue <<= bValue;
237 return bRet;
240 bool XMLBoolPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
242 bool bRet = false;
243 bool bValue;
245 if (rValue >>= bValue)
247 OUStringBuffer aOut;
248 ::sax::Converter::convertBool( aOut, bValue );
249 rStrExpValue = aOut.makeStringAndClear();
251 bRet = true;
254 return bRet;
258 XMLNBoolPropHdl::~XMLNBoolPropHdl()
260 // nothing to do
263 bool XMLNBoolPropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
265 bool bValue(false);
266 bool const bRet = ::sax::Converter::convertBool( bValue, rStrImpValue );
267 rValue <<= !bValue;
269 return bRet;
272 bool XMLNBoolPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
274 bool bRet = false;
275 bool bValue;
277 if (rValue >>= bValue)
279 OUStringBuffer aOut;
280 ::sax::Converter::convertBool( aOut, !bValue );
281 rStrExpValue = aOut.makeStringAndClear();
283 bRet = true;
286 return bRet;
290 XMLPercentPropHdl::~XMLPercentPropHdl()
292 // nothing to do
295 bool XMLPercentPropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
297 sal_Int32 nValue = 0;
298 bool const bRet = ::sax::Converter::convertPercent( nValue, rStrImpValue );
299 lcl_xmloff_setAny( rValue, nValue, nBytes );
301 return bRet;
304 bool XMLPercentPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
306 bool bRet = false;
307 sal_Int32 nValue;
309 if( lcl_xmloff_getAny( rValue, nValue, nBytes ) )
311 OUStringBuffer aOut;
312 ::sax::Converter::convertPercent( aOut, nValue );
313 rStrExpValue = aOut.makeStringAndClear();
315 bRet = true;
318 return bRet;
322 bool XMLDoublePercentPropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
324 bool bRet = false;
326 double fValue = 1.0;
328 if( rStrImpValue.indexOf( '%' ) == -1 )
330 fValue = rStrImpValue.toDouble();
332 else
334 sal_Int32 nValue = 0;
335 bRet = ::sax::Converter::convertPercent( nValue, rStrImpValue );
336 fValue = static_cast<double>(nValue) / 100.0;
338 rValue <<= fValue;
340 return bRet;
343 bool XMLDoublePercentPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
345 bool bRet = false;
346 double fValue = 0;
348 if( rValue >>= fValue )
350 fValue *= 100.0;
351 if( fValue > 0 ) fValue += 0.5; else fValue -= 0.5;
353 sal_Int32 nValue = static_cast<sal_Int32>(fValue);
355 OUStringBuffer aOut;
356 ::sax::Converter::convertPercent( aOut, nValue );
357 rStrExpValue = aOut.makeStringAndClear();
359 bRet = true;
362 return bRet;
365 bool XML100thPercentPropHdl::importXML(const OUString& rStrImpValue, Any& rValue,
366 const SvXMLUnitConverter&) const
368 bool bRet = false;
370 sal_Int32 nValue = 0;
371 bRet = sax::Converter::convertPercent(nValue, rStrImpValue);
372 rValue <<= static_cast<sal_Int16>(nValue * 100);
374 return bRet;
377 bool XML100thPercentPropHdl::exportXML(OUString& rStrExpValue, const Any& rValue,
378 const SvXMLUnitConverter&) const
380 bool bRet = false;
381 sal_Int16 nValue = 0;
383 if (rValue >>= nValue)
385 nValue = std::round(static_cast<double>(nValue) / 100);
386 OUStringBuffer aOut;
387 sax::Converter::convertPercent(aOut, nValue);
388 rStrExpValue = aOut.makeStringAndClear();
389 bRet = true;
392 return bRet;
396 XMLNegPercentPropHdl::~XMLNegPercentPropHdl()
398 // nothing to do
401 bool XMLNegPercentPropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
403 sal_Int32 nValue = 0;
404 bool bRet = ::sax::Converter::convertPercent( nValue, rStrImpValue );
405 if (bRet)
406 bRet = !o3tl::checked_sub<sal_Int32>(100, nValue, nValue);
407 if (bRet)
408 lcl_xmloff_setAny( rValue, nValue, nBytes );
409 return bRet;
412 bool XMLNegPercentPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
414 bool bRet = false;
415 sal_Int32 nValue;
417 if( lcl_xmloff_getAny( rValue, nValue, nBytes ) )
419 OUStringBuffer aOut;
420 ::sax::Converter::convertPercent( aOut, 100-nValue );
421 rStrExpValue = aOut.makeStringAndClear();
423 bRet = true;
426 return bRet;
429 XMLMeasurePxPropHdl::~XMLMeasurePxPropHdl()
431 // nothing to do
434 bool XMLMeasurePxPropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
436 sal_Int32 nValue = 0;
437 bool bRet = ::sax::Converter::convertMeasurePx( nValue, rStrImpValue );
438 lcl_xmloff_setAny( rValue, nValue, nBytes );
439 return bRet;
442 bool XMLMeasurePxPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
444 bool bRet = false;
445 sal_Int32 nValue;
447 if( lcl_xmloff_getAny( rValue, nValue, nBytes ) )
449 OUStringBuffer aOut;
450 ::sax::Converter::convertMeasurePx( aOut, nValue );
451 rStrExpValue = aOut.makeStringAndClear();
453 bRet = true;
456 return bRet;
460 XMLColorPropHdl::~XMLColorPropHdl()
462 // Nothing to do
465 bool XMLColorPropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
467 bool bRet = false;
469 if( rStrImpValue.matchIgnoreAsciiCase( "hsl" ) )
471 sal_Int32 nOpen = rStrImpValue.indexOf( '(' );
472 sal_Int32 nClose = rStrImpValue.lastIndexOf( ')' );
474 if( (nOpen != -1) && (nClose > nOpen) )
476 const std::u16string_view aTmp( rStrImpValue.subView( nOpen+1, nClose - nOpen-1) );
478 sal_Int32 nIndex = 0;
480 Sequence< double > aHSL
482 o3tl::toDouble(o3tl::getToken(aTmp, 0, ',', nIndex )),
483 o3tl::toDouble(o3tl::getToken(aTmp, 0, ',', nIndex )) / 100.0,
484 o3tl::toDouble(o3tl::getToken(aTmp, 0, ',', nIndex )) / 100.0
486 rValue <<= aHSL;
487 bRet = true;
490 else
492 sal_Int32 nColor(0);
493 bRet = ::sax::Converter::convertColor( nColor, rStrImpValue );
494 rValue <<= nColor;
497 return bRet;
500 bool XMLColorPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
502 bool bRet = false;
503 sal_Int32 nColor = 0;
505 OUStringBuffer aOut;
506 if( rValue >>= nColor )
508 ::sax::Converter::convertColor( aOut, nColor );
509 rStrExpValue = aOut.makeStringAndClear();
511 bRet = true;
513 else
515 Sequence< double > aHSL;
516 if( (rValue >>= aHSL) && (aHSL.getLength() == 3) )
518 rStrExpValue = "hsl(" + OUString::number(aHSL[0]) + "," +
519 OUString::number(aHSL[1] * 100.0) + "%," +
520 OUString::number(aHSL[2] * 100.0) + "%)";
522 bRet = true;
526 return bRet;
530 XMLHexPropHdl::~XMLHexPropHdl()
532 // Nothing to do
535 bool XMLHexPropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
537 sal_uInt32 nRsid;
538 bool bRet = SvXMLUnitConverter::convertHex( nRsid, rStrImpValue );
539 rValue <<= nRsid;
541 return bRet;
544 bool XMLHexPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
546 bool bRet = false;
547 sal_uInt32 nRsid = 0;
549 if( rValue >>= nRsid )
551 OUStringBuffer aOut;
552 SvXMLUnitConverter::convertHex( aOut, nRsid );
553 rStrExpValue = aOut.makeStringAndClear();
555 bRet = true;
557 else
559 bRet = false;
562 return bRet;
566 XMLStringPropHdl::~XMLStringPropHdl()
568 // Nothing to do
571 bool XMLStringPropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
573 rValue <<= rStrImpValue;
574 return true;
577 bool XMLStringPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
579 bool bRet = false;
581 if( rValue >>= rStrExpValue )
582 bRet = true;
584 return bRet;
588 XMLStyleNamePropHdl::~XMLStyleNamePropHdl()
590 // Nothing to do
593 bool XMLStyleNamePropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const
595 bool bRet = false;
597 if( rValue >>= rStrExpValue )
599 rStrExpValue = rUnitConverter.encodeStyleName( rStrExpValue );
600 bRet = true;
603 return bRet;
607 XMLDoublePropHdl::~XMLDoublePropHdl()
609 // Nothing to do
612 bool XMLDoublePropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
614 double fDblValue(0.0);
615 bool const bRet = ::sax::Converter::convertDouble(fDblValue, rStrImpValue);
616 rValue <<= fDblValue;
617 return bRet;
620 bool XMLDoublePropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
622 bool bRet = false;
624 double fValue = 0;
626 if( rValue >>= fValue )
628 OUStringBuffer aOut;
629 ::sax::Converter::convertDouble( aOut, fValue );
630 rStrExpValue = aOut.makeStringAndClear();
631 bRet = true;
634 return bRet;
638 XMLColorTransparentPropHdl::XMLColorTransparentPropHdl(
639 enum XMLTokenEnum eTransparent ) :
640 sTransparent( GetXMLToken(
641 eTransparent != XML_TOKEN_INVALID ? eTransparent : XML_TRANSPARENT ) )
643 // Nothing to do
646 XMLColorTransparentPropHdl::~XMLColorTransparentPropHdl()
648 // Nothing to do
651 bool XMLColorTransparentPropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
653 bool bRet = false;
655 if( rStrImpValue != sTransparent )
657 sal_Int32 nColor(0);
658 bRet = ::sax::Converter::convertColor( nColor, rStrImpValue );
659 rValue <<= nColor;
662 return bRet;
665 bool XMLColorTransparentPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
667 bool bRet = false;
668 sal_Int32 nColor = 0;
670 if( rStrExpValue == sTransparent )
671 bRet = false;
672 else if( rValue >>= nColor )
674 OUStringBuffer aOut;
675 ::sax::Converter::convertColor( aOut, nColor );
676 rStrExpValue = aOut.makeStringAndClear();
678 bRet = true;
681 return bRet;
685 XMLIsTransparentPropHdl::XMLIsTransparentPropHdl(
686 enum XMLTokenEnum eTransparent, bool bTransPropVal ) :
687 sTransparent( GetXMLToken(
688 eTransparent != XML_TOKEN_INVALID ? eTransparent : XML_TRANSPARENT ) ),
689 bTransPropValue( bTransPropVal )
693 XMLIsTransparentPropHdl::~XMLIsTransparentPropHdl()
695 // Nothing to do
698 bool XMLIsTransparentPropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
700 bool bValue = ( (rStrImpValue == sTransparent) == bTransPropValue);
701 rValue <<= bValue;
703 return true;
706 bool XMLIsTransparentPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
708 bool bRet = false;
710 // MIB: This looks a bit strange, because bTransPropValue == bValue should
711 // do the same, but this only applies if 'true' is represented by the same
712 // 8 bit value in bValue and bTransPropValue. Who will ensure this?
713 bool bValue = *o3tl::doAccess<bool>(rValue);
714 bool bIsTrans = bTransPropValue ? bValue : !bValue;
716 if( bIsTrans )
718 rStrExpValue = sTransparent;
719 bRet = true;
722 return bRet;
726 XMLColorAutoPropHdl::XMLColorAutoPropHdl()
728 // Nothing to do
731 XMLColorAutoPropHdl::~XMLColorAutoPropHdl()
733 // Nothing to do
736 bool XMLColorAutoPropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
738 bool bRet = false;
740 // This is a multi property: the value might be set to AUTO_COLOR
741 // already by the XMLIsAutoColorPropHdl!
742 sal_Int32 nColor = 0;
743 if( !(rValue >>= nColor) || -1 != nColor )
745 bRet = ::sax::Converter::convertColor( nColor, rStrImpValue );
746 if( bRet )
747 rValue <<= nColor;
750 return bRet;
753 bool XMLColorAutoPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
755 bool bRet = false;
757 sal_Int32 nColor = 0;
758 if( (rValue >>= nColor) && -1 != nColor )
760 OUStringBuffer aOut;
761 ::sax::Converter::convertColor( aOut, nColor );
762 rStrExpValue = aOut.makeStringAndClear();
764 bRet = true;
767 return bRet;
771 XMLIsAutoColorPropHdl::XMLIsAutoColorPropHdl()
775 XMLIsAutoColorPropHdl::~XMLIsAutoColorPropHdl()
777 // Nothing to do
780 bool XMLIsAutoColorPropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
782 // An auto color overrides any other color set!
783 bool bValue;
784 bool const bRet = ::sax::Converter::convertBool( bValue, rStrImpValue );
785 if( bRet && bValue )
786 rValue <<= sal_Int32(-1);
788 return true;
791 bool XMLIsAutoColorPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
793 bool bRet = false;
794 sal_Int32 nColor = 0;
796 if( (rValue >>= nColor) && -1 == nColor )
798 OUStringBuffer aOut;
799 ::sax::Converter::convertBool( aOut, true );
800 rStrExpValue = aOut.makeStringAndClear();
802 bRet = true;
805 return bRet;
809 XMLCompareOnlyPropHdl::~XMLCompareOnlyPropHdl()
811 // Nothing to do
814 bool XMLCompareOnlyPropHdl::importXML( const OUString&, Any&, const SvXMLUnitConverter& ) const
816 SAL_WARN( "xmloff", "importXML called for compare-only-property" );
817 return false;
820 bool XMLCompareOnlyPropHdl::exportXML( OUString&, const Any&, const SvXMLUnitConverter& ) const
822 SAL_WARN( "xmloff", "exportXML called for compare-only-property" );
823 return false;
827 XMLNumberWithoutZeroPropHdl::XMLNumberWithoutZeroPropHdl( sal_Int8 nB ) :
828 nBytes( nB )
832 XMLNumberWithoutZeroPropHdl::~XMLNumberWithoutZeroPropHdl()
836 bool XMLNumberWithoutZeroPropHdl::importXML(
837 const OUString& rStrImpValue,
838 Any& rValue,
839 const SvXMLUnitConverter& ) const
841 sal_Int32 nValue = 0;
842 bool const bRet = ::sax::Converter::convertNumber( nValue, rStrImpValue );
843 if( bRet )
844 lcl_xmloff_setAny( rValue, nValue, nBytes );
845 return bRet;
848 bool XMLNumberWithoutZeroPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
851 sal_Int32 nValue = 0;
852 bool bRet = lcl_xmloff_getAny( rValue, nValue, nBytes );
853 bRet &= nValue != 0;
855 if( bRet )
857 rStrExpValue = OUString::number(nValue);
860 return bRet;
864 XMLNumberWithAutoForVoidPropHdl::~XMLNumberWithAutoForVoidPropHdl()
868 bool XMLNumberWithAutoForVoidPropHdl::importXML(
869 const OUString& rStrImpValue,
870 Any& rValue,
871 const SvXMLUnitConverter& ) const
873 sal_Int32 nValue = 0;
874 bool bRet = ::sax::Converter::convertNumber( nValue, rStrImpValue );
875 if( bRet )
876 lcl_xmloff_setAny( rValue, nValue, 2 );
877 else if( rStrImpValue == GetXMLToken( XML_AUTO ) )
879 rValue.clear(); // void
880 bRet = true;
882 return bRet;
885 bool XMLNumberWithAutoForVoidPropHdl::exportXML(
886 OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter&) const
889 sal_Int32 nValue = 0;
890 bool bRet = lcl_xmloff_getAny( rValue, nValue, 2 );
892 // note: 0 is a valid value here, see CTF_PAGENUMBEROFFSET for when it isn't
894 if (!bRet)
895 rStrExpValue = GetXMLToken( XML_AUTO );
896 else
898 rStrExpValue = OUString::number(nValue);
901 return true;
904 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */