tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / xmloff / source / style / xmlbahdl.cxx
bloba59abbdeed04b309b35ccbec206d80596c6e8056
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 <com/sun/star/beans/Pair.hpp>
31 #include <xmloff/xmltoken.hxx>
33 #include <limits.h>
35 using namespace ::com::sun::star::uno;
36 using namespace ::xmloff::token;
38 static void lcl_xmloff_setAny( Any& rValue, sal_Int32 nValue, sal_Int8 nBytes )
40 switch( nBytes )
42 case 1:
43 if( nValue < SCHAR_MIN )
44 nValue = SCHAR_MIN;
45 else if( nValue > SCHAR_MAX )
46 nValue = SCHAR_MAX;
47 rValue <<= static_cast<sal_Int8>(nValue);
48 break;
49 case 2:
50 if( nValue < SHRT_MIN )
51 nValue = SHRT_MIN;
52 else if( nValue > SHRT_MAX )
53 nValue = SHRT_MAX;
54 rValue <<= static_cast<sal_Int16>(nValue);
55 break;
56 case 4:
57 rValue <<= nValue;
58 break;
62 static bool lcl_xmloff_getAny( const Any& rValue, sal_Int32& nValue,
63 sal_Int8 nBytes )
65 bool bRet = false;
67 switch( nBytes )
69 case 1:
71 sal_Int8 nValue8 = 0;
72 bRet = rValue >>= nValue8;
73 nValue = nValue8;
75 break;
76 case 2:
78 sal_Int16 nValue16 = 0;
79 bRet = rValue >>= nValue16;
80 nValue = nValue16;
82 break;
83 case 4:
84 bRet = rValue >>= nValue;
85 break;
88 return bRet;
92 XMLNumberPropHdl::~XMLNumberPropHdl()
94 // nothing to do
97 bool XMLNumberPropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
99 sal_Int32 nValue = 0;
100 bool bRet = ::sax::Converter::convertNumber( nValue, rStrImpValue );
101 lcl_xmloff_setAny( rValue, nValue, nBytes );
103 return bRet;
106 bool XMLNumberPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
108 bool bRet = false;
109 sal_Int32 nValue;
111 if( lcl_xmloff_getAny( rValue, nValue, nBytes ) )
113 rStrExpValue = OUString::number( nValue );
115 bRet = true;
118 return bRet;
122 XMLNumberNonePropHdl::XMLNumberNonePropHdl( sal_Int8 nB ) :
123 sZeroStr( GetXMLToken(XML_NO_LIMIT) ),
124 nBytes( nB )
128 XMLNumberNonePropHdl::XMLNumberNonePropHdl( enum XMLTokenEnum eZeroString, sal_Int8 nB ) :
129 sZeroStr( GetXMLToken( eZeroString ) ),
130 nBytes( nB )
134 XMLNumberNonePropHdl::~XMLNumberNonePropHdl()
136 // nothing to do
139 bool XMLNumberNonePropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
141 bool bRet = false;
143 sal_Int32 nValue = 0;
144 if( rStrImpValue == sZeroStr )
146 bRet = true;
148 else
150 bRet = ::sax::Converter::convertNumber( nValue, rStrImpValue );
152 lcl_xmloff_setAny( rValue, nValue, nBytes );
154 return bRet;
157 bool XMLNumberNonePropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
159 bool bRet = false;
160 sal_Int32 nValue;
162 if( lcl_xmloff_getAny( rValue, nValue, nBytes ) )
164 if( nValue == 0 )
166 rStrExpValue = sZeroStr;
168 else
170 rStrExpValue = OUString::number( nValue );
173 bRet = true;
176 return bRet;
180 XMLMeasurePropHdl::~XMLMeasurePropHdl()
182 // nothing to do
185 bool XMLMeasurePropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const
187 sal_Int32 nValue = 0;
188 bool bRet = rUnitConverter.convertMeasureToCore( nValue, rStrImpValue );
189 lcl_xmloff_setAny( rValue, nValue, nBytes );
190 return bRet;
193 bool XMLMeasurePropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const
195 bool bRet = false;
196 sal_Int32 nValue;
198 if( lcl_xmloff_getAny( rValue, nValue, nBytes ) )
200 OUStringBuffer aOut;
201 rUnitConverter.convertMeasureToXML( aOut, nValue );
202 rStrExpValue = aOut.makeStringAndClear();
204 bRet = true;
207 return bRet;
211 bool XMLUnitMeasurePropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
213 double fValue = 0.0;
214 std::optional<sal_Int16> nValueUnit;
216 auto bRet = ::sax::Converter::convertMeasureUnit( fValue, nValueUnit, rStrImpValue );
218 if(bRet)
220 // This importer may only accept font-relative units.
221 // Discard all other units to allow fall-through to other attributes.
222 if (css::util::MeasureUnit::FONT_EM != nValueUnit
223 && css::util::MeasureUnit::FONT_CJK_ADVANCE != nValueUnit)
225 return false;
228 css::beans::Pair<double, sal_Int16> stValue{fValue, nValueUnit.value()};
229 rValue <<= stValue;
232 return bRet;
235 bool XMLUnitMeasurePropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
237 bool bRet = false;
238 css::beans::Pair<double, sal_Int16> stValue{0.0, css::util::MeasureUnit::MM_100TH};
240 if( rValue >>= stValue )
242 auto [fValue, nValueUnit] = stValue;
244 // This exporter may only produce font-relative units.
245 // Discard all other units to allow fall-through to other attributes.
246 if (css::util::MeasureUnit::FONT_EM != nValueUnit
247 && css::util::MeasureUnit::FONT_CJK_ADVANCE != nValueUnit)
249 return false;
252 OUStringBuffer aOut;
253 ::sax::Converter::convertMeasureUnit( aOut, fValue, nValueUnit );
254 rStrExpValue = aOut.makeStringAndClear();
256 bRet = true;
259 return bRet;
263 XMLBoolFalsePropHdl::~XMLBoolFalsePropHdl()
265 // nothing to do
268 bool XMLBoolFalsePropHdl::importXML( const OUString&, Any&, const SvXMLUnitConverter& ) const
270 return false;
273 bool XMLBoolFalsePropHdl::exportXML( OUString& rStrExpValue, const Any& /*rValue*/, const SvXMLUnitConverter& rCnv) const
275 return XMLBoolPropHdl::exportXML( rStrExpValue, Any( false ), rCnv );
279 XMLBoolPropHdl::~XMLBoolPropHdl()
281 // nothing to do
284 bool XMLBoolPropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
286 bool bValue(false);
287 bool const bRet = ::sax::Converter::convertBool( bValue, rStrImpValue );
288 rValue <<= bValue;
290 return bRet;
293 bool XMLBoolPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
295 bool bRet = false;
296 bool bValue;
298 if (rValue >>= bValue)
300 OUStringBuffer aOut;
301 ::sax::Converter::convertBool( aOut, bValue );
302 rStrExpValue = aOut.makeStringAndClear();
304 bRet = true;
307 return bRet;
311 XMLNBoolPropHdl::~XMLNBoolPropHdl()
313 // nothing to do
316 bool XMLNBoolPropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
318 bool bValue(false);
319 bool const bRet = ::sax::Converter::convertBool( bValue, rStrImpValue );
320 rValue <<= !bValue;
322 return bRet;
325 bool XMLNBoolPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
327 bool bRet = false;
328 bool bValue;
330 if (rValue >>= bValue)
332 OUStringBuffer aOut;
333 ::sax::Converter::convertBool( aOut, !bValue );
334 rStrExpValue = aOut.makeStringAndClear();
336 bRet = true;
339 return bRet;
343 XMLPercentPropHdl::~XMLPercentPropHdl()
345 // nothing to do
348 bool XMLPercentPropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
350 sal_Int32 nValue = 0;
351 bool const bRet = ::sax::Converter::convertPercent( nValue, rStrImpValue );
352 lcl_xmloff_setAny( rValue, nValue, nBytes );
354 return bRet;
357 bool XMLPercentPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
359 bool bRet = false;
360 sal_Int32 nValue;
362 if( lcl_xmloff_getAny( rValue, nValue, nBytes ) )
364 OUStringBuffer aOut;
365 ::sax::Converter::convertPercent( aOut, nValue );
366 rStrExpValue = aOut.makeStringAndClear();
368 bRet = true;
371 return bRet;
375 bool XMLDoublePercentPropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
377 bool bRet = false;
379 double fValue = 1.0;
381 if( rStrImpValue.indexOf( '%' ) == -1 )
383 fValue = rStrImpValue.toDouble();
385 else
387 sal_Int32 nValue = 0;
388 bRet = ::sax::Converter::convertPercent( nValue, rStrImpValue );
389 fValue = static_cast<double>(nValue) / 100.0;
391 rValue <<= fValue;
393 return bRet;
396 bool XMLDoublePercentPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
398 bool bRet = false;
399 double fValue = 0;
401 if( rValue >>= fValue )
403 fValue *= 100.0;
404 if( fValue > 0 ) fValue += 0.5; else fValue -= 0.5;
406 sal_Int32 nValue = static_cast<sal_Int32>(fValue);
408 OUStringBuffer aOut;
409 ::sax::Converter::convertPercent( aOut, nValue );
410 rStrExpValue = aOut.makeStringAndClear();
412 bRet = true;
415 return bRet;
418 bool XML100thPercentPropHdl::importXML(const OUString& rStrImpValue, Any& rValue,
419 const SvXMLUnitConverter&) const
421 bool bRet = false;
423 sal_Int32 nValue = 0;
424 bRet = sax::Converter::convertPercent(nValue, rStrImpValue);
425 rValue <<= static_cast<sal_Int16>(nValue * 100);
427 return bRet;
430 bool XML100thPercentPropHdl::exportXML(OUString& rStrExpValue, const Any& rValue,
431 const SvXMLUnitConverter&) const
433 bool bRet = false;
434 sal_Int16 nValue = 0;
436 if (rValue >>= nValue)
438 nValue = std::round(static_cast<double>(nValue) / 100);
439 OUStringBuffer aOut;
440 sax::Converter::convertPercent(aOut, nValue);
441 rStrExpValue = aOut.makeStringAndClear();
442 bRet = true;
445 return bRet;
449 XMLNegPercentPropHdl::~XMLNegPercentPropHdl()
451 // nothing to do
454 bool XMLNegPercentPropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
456 sal_Int32 nValue = 0;
457 bool bRet = ::sax::Converter::convertPercent( nValue, rStrImpValue );
458 if (bRet)
459 bRet = !o3tl::checked_sub<sal_Int32>(100, nValue, nValue);
460 if (bRet)
461 lcl_xmloff_setAny( rValue, nValue, nBytes );
462 return bRet;
465 bool XMLNegPercentPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
467 bool bRet = false;
468 sal_Int32 nValue;
470 if( lcl_xmloff_getAny( rValue, nValue, nBytes ) )
472 OUStringBuffer aOut;
473 ::sax::Converter::convertPercent( aOut, 100-nValue );
474 rStrExpValue = aOut.makeStringAndClear();
476 bRet = true;
479 return bRet;
482 XMLMeasurePxPropHdl::~XMLMeasurePxPropHdl()
484 // nothing to do
487 bool XMLMeasurePxPropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
489 sal_Int32 nValue = 0;
490 bool bRet = ::sax::Converter::convertMeasurePx( nValue, rStrImpValue );
491 lcl_xmloff_setAny( rValue, nValue, nBytes );
492 return bRet;
495 bool XMLMeasurePxPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
497 bool bRet = false;
498 sal_Int32 nValue;
500 if( lcl_xmloff_getAny( rValue, nValue, nBytes ) )
502 OUStringBuffer aOut;
503 ::sax::Converter::convertMeasurePx( aOut, nValue );
504 rStrExpValue = aOut.makeStringAndClear();
506 bRet = true;
509 return bRet;
513 XMLColorPropHdl::~XMLColorPropHdl()
515 // Nothing to do
518 bool XMLColorPropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
520 bool bRet = false;
522 if( rStrImpValue.matchIgnoreAsciiCase( "hsl" ) )
524 sal_Int32 nOpen = rStrImpValue.indexOf( '(' );
525 sal_Int32 nClose = rStrImpValue.lastIndexOf( ')' );
527 if( (nOpen != -1) && (nClose > nOpen) )
529 const std::u16string_view aTmp( rStrImpValue.subView( nOpen+1, nClose - nOpen-1) );
531 sal_Int32 nIndex = 0;
533 Sequence< double > aHSL
535 o3tl::toDouble(o3tl::getToken(aTmp, 0, ',', nIndex )),
536 o3tl::toDouble(o3tl::getToken(aTmp, 0, ',', nIndex )) / 100.0,
537 o3tl::toDouble(o3tl::getToken(aTmp, 0, ',', nIndex )) / 100.0
539 rValue <<= aHSL;
540 bRet = true;
543 else
545 sal_Int32 nColor(0);
546 bRet = ::sax::Converter::convertColor( nColor, rStrImpValue );
547 rValue <<= nColor;
550 return bRet;
553 bool XMLColorPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
555 bool bRet = false;
556 sal_Int32 nColor = 0;
558 OUStringBuffer aOut;
559 if( rValue >>= nColor )
561 ::sax::Converter::convertColor( aOut, nColor );
562 rStrExpValue = aOut.makeStringAndClear();
564 bRet = true;
566 else
568 Sequence< double > aHSL;
569 if( (rValue >>= aHSL) && (aHSL.getLength() == 3) )
571 rStrExpValue = "hsl(" + OUString::number(aHSL[0]) + "," +
572 OUString::number(aHSL[1] * 100.0) + "%," +
573 OUString::number(aHSL[2] * 100.0) + "%)";
575 bRet = true;
579 return bRet;
583 XMLHexPropHdl::~XMLHexPropHdl()
585 // Nothing to do
588 bool XMLHexPropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
590 sal_uInt32 nRsid;
591 bool bRet = SvXMLUnitConverter::convertHex( nRsid, rStrImpValue );
592 rValue <<= nRsid;
594 return bRet;
597 bool XMLHexPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
599 bool bRet = false;
600 sal_uInt32 nRsid = 0;
602 if( rValue >>= nRsid )
604 OUStringBuffer aOut;
605 SvXMLUnitConverter::convertHex( aOut, nRsid );
606 rStrExpValue = aOut.makeStringAndClear();
608 bRet = true;
610 else
612 bRet = false;
615 return bRet;
619 XMLStringPropHdl::~XMLStringPropHdl()
621 // Nothing to do
624 bool XMLStringPropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
626 rValue <<= rStrImpValue;
627 return true;
630 bool XMLStringPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
632 bool bRet = false;
634 if( rValue >>= rStrExpValue )
635 bRet = true;
637 return bRet;
641 XMLStyleNamePropHdl::~XMLStyleNamePropHdl()
643 // Nothing to do
646 bool XMLStyleNamePropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const
648 bool bRet = false;
650 if( rValue >>= rStrExpValue )
652 rStrExpValue = rUnitConverter.encodeStyleName( rStrExpValue );
653 bRet = true;
656 return bRet;
660 XMLDoublePropHdl::~XMLDoublePropHdl()
662 // Nothing to do
665 bool XMLDoublePropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
667 double fDblValue(0.0);
668 bool const bRet = ::sax::Converter::convertDouble(fDblValue, rStrImpValue);
669 rValue <<= fDblValue;
670 return bRet;
673 bool XMLDoublePropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
675 bool bRet = false;
677 double fValue = 0;
679 if( rValue >>= fValue )
681 OUStringBuffer aOut;
682 ::sax::Converter::convertDouble( aOut, fValue );
683 rStrExpValue = aOut.makeStringAndClear();
684 bRet = true;
687 return bRet;
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 bool XMLColorTransparentPropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
706 bool bRet = false;
708 if( rStrImpValue != sTransparent )
710 sal_Int32 nColor(0);
711 bRet = ::sax::Converter::convertColor( nColor, rStrImpValue );
712 rValue <<= nColor;
715 return bRet;
718 bool XMLColorTransparentPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
720 bool bRet = false;
721 sal_Int32 nColor = 0;
723 if( rStrExpValue == sTransparent )
724 bRet = false;
725 else if( rValue >>= nColor )
727 OUStringBuffer aOut;
728 ::sax::Converter::convertColor( aOut, nColor );
729 rStrExpValue = aOut.makeStringAndClear();
731 bRet = true;
734 return bRet;
738 XMLIsTransparentPropHdl::XMLIsTransparentPropHdl(
739 enum XMLTokenEnum eTransparent, bool bTransPropVal ) :
740 sTransparent( GetXMLToken(
741 eTransparent != XML_TOKEN_INVALID ? eTransparent : XML_TRANSPARENT ) ),
742 bTransPropValue( bTransPropVal )
746 XMLIsTransparentPropHdl::~XMLIsTransparentPropHdl()
748 // Nothing to do
751 bool XMLIsTransparentPropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
753 bool bValue = ( (rStrImpValue == sTransparent) == bTransPropValue);
754 rValue <<= bValue;
756 return true;
759 bool XMLIsTransparentPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
761 bool bRet = false;
763 // MIB: This looks a bit strange, because bTransPropValue == bValue should
764 // do the same, but this only applies if 'true' is represented by the same
765 // 8 bit value in bValue and bTransPropValue. Who will ensure this?
766 bool bValue = *o3tl::doAccess<bool>(rValue);
767 bool bIsTrans = bTransPropValue ? bValue : !bValue;
769 if( bIsTrans )
771 rStrExpValue = sTransparent;
772 bRet = true;
775 return bRet;
779 XMLColorAutoPropHdl::XMLColorAutoPropHdl()
781 // Nothing to do
784 XMLColorAutoPropHdl::~XMLColorAutoPropHdl()
786 // Nothing to do
789 bool XMLColorAutoPropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
791 bool bRet = false;
793 // This is a multi property: the value might be set to AUTO_COLOR
794 // already by the XMLIsAutoColorPropHdl!
795 sal_Int32 nColor = 0;
796 if( !(rValue >>= nColor) || -1 != nColor )
798 bRet = ::sax::Converter::convertColor( nColor, rStrImpValue );
799 if( bRet )
800 rValue <<= nColor;
803 return bRet;
806 bool XMLColorAutoPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
808 bool bRet = false;
810 sal_Int32 nColor = 0;
811 if( (rValue >>= nColor) && -1 != nColor )
813 OUStringBuffer aOut;
814 ::sax::Converter::convertColor( aOut, nColor );
815 rStrExpValue = aOut.makeStringAndClear();
817 bRet = true;
820 return bRet;
824 XMLIsAutoColorPropHdl::XMLIsAutoColorPropHdl()
828 XMLIsAutoColorPropHdl::~XMLIsAutoColorPropHdl()
830 // Nothing to do
833 bool XMLIsAutoColorPropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
835 // An auto color overrides any other color set!
836 bool bValue;
837 bool const bRet = ::sax::Converter::convertBool( bValue, rStrImpValue );
838 if( bRet && bValue )
839 rValue <<= sal_Int32(-1);
841 return true;
844 bool XMLIsAutoColorPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
846 bool bRet = false;
847 sal_Int32 nColor = 0;
849 if( (rValue >>= nColor) && -1 == nColor )
851 OUStringBuffer aOut;
852 ::sax::Converter::convertBool( aOut, true );
853 rStrExpValue = aOut.makeStringAndClear();
855 bRet = true;
858 return bRet;
862 XMLCompareOnlyPropHdl::~XMLCompareOnlyPropHdl()
864 // Nothing to do
867 bool XMLCompareOnlyPropHdl::importXML( const OUString&, Any&, const SvXMLUnitConverter& ) const
869 SAL_WARN( "xmloff", "importXML called for compare-only-property" );
870 return false;
873 bool XMLCompareOnlyPropHdl::exportXML( OUString&, const Any&, const SvXMLUnitConverter& ) const
875 SAL_WARN( "xmloff", "exportXML called for compare-only-property" );
876 return false;
880 XMLNumberWithoutZeroPropHdl::XMLNumberWithoutZeroPropHdl( sal_Int8 nB ) :
881 nBytes( nB )
885 XMLNumberWithoutZeroPropHdl::~XMLNumberWithoutZeroPropHdl()
889 bool XMLNumberWithoutZeroPropHdl::importXML(
890 const OUString& rStrImpValue,
891 Any& rValue,
892 const SvXMLUnitConverter& ) const
894 sal_Int32 nValue = 0;
895 bool const bRet = ::sax::Converter::convertNumber( nValue, rStrImpValue );
896 if( bRet )
897 lcl_xmloff_setAny( rValue, nValue, nBytes );
898 return bRet;
901 bool XMLNumberWithoutZeroPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
904 sal_Int32 nValue = 0;
905 bool bRet = lcl_xmloff_getAny( rValue, nValue, nBytes );
906 bRet &= nValue != 0;
908 if( bRet )
910 rStrExpValue = OUString::number(nValue);
913 return bRet;
917 XMLNumberWithAutoForVoidPropHdl::~XMLNumberWithAutoForVoidPropHdl()
921 bool XMLNumberWithAutoForVoidPropHdl::importXML(
922 const OUString& rStrImpValue,
923 Any& rValue,
924 const SvXMLUnitConverter& ) const
926 sal_Int32 nValue = 0;
927 bool bRet = ::sax::Converter::convertNumber( nValue, rStrImpValue );
928 if( bRet )
929 lcl_xmloff_setAny( rValue, nValue, 2 );
930 else if( rStrImpValue == GetXMLToken( XML_AUTO ) )
932 rValue.clear(); // void
933 bRet = true;
935 return bRet;
938 bool XMLNumberWithAutoForVoidPropHdl::exportXML(
939 OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter&) const
942 sal_Int32 nValue = 0;
943 bool bRet = lcl_xmloff_getAny( rValue, nValue, 2 );
945 // note: 0 is a valid value here, see CTF_PAGENUMBEROFFSET for when it isn't
947 if (!bRet)
948 rStrExpValue = GetXMLToken( XML_AUTO );
949 else
951 rStrExpValue = OUString::number(nValue);
954 return true;
957 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */