LibreOffice Module xmloff (master) 1
xmlbahdl.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#include "xmlbahdl.hxx"
21
23#include <sal/log.hxx>
24#include <o3tl/any.hxx>
25#include <o3tl/safeint.hxx>
26#include <o3tl/string_view.hxx>
28#include <xmloff/xmluconv.hxx>
29#include <com/sun/star/uno/Any.hxx>
30#include <xmloff/xmltoken.hxx>
31
32#include <limits.h>
33
34using namespace ::com::sun::star::uno;
35using namespace ::xmloff::token;
36
37static void lcl_xmloff_setAny( Any& rValue, sal_Int32 nValue, sal_Int8 nBytes )
38{
39 switch( nBytes )
40 {
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;
58 }
59}
60
61static bool lcl_xmloff_getAny( const Any& rValue, sal_Int32& nValue,
62 sal_Int8 nBytes )
63{
64 bool bRet = false;
65
66 switch( nBytes )
67 {
68 case 1:
69 {
70 sal_Int8 nValue8 = 0;
71 bRet = rValue >>= nValue8;
72 nValue = nValue8;
73 }
74 break;
75 case 2:
76 {
77 sal_Int16 nValue16 = 0;
78 bRet = rValue >>= nValue16;
79 nValue = nValue16;
80 }
81 break;
82 case 4:
83 bRet = rValue >>= nValue;
84 break;
85 }
86
87 return bRet;
88}
89
90
92{
93 // nothing to do
94}
95
96bool XMLNumberPropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
97{
98 sal_Int32 nValue = 0;
99 bool bRet = ::sax::Converter::convertNumber( nValue, rStrImpValue );
100 lcl_xmloff_setAny( rValue, nValue, nBytes );
101
102 return bRet;
103}
104
105bool XMLNumberPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
106{
107 bool bRet = false;
108 sal_Int32 nValue;
109
110 if( lcl_xmloff_getAny( rValue, nValue, nBytes ) )
111 {
112 rStrExpValue = OUString::number( nValue );
113
114 bRet = true;
115 }
116
117 return bRet;
118}
119
120
122 sZeroStr( GetXMLToken(XML_NO_LIMIT) ),
123 nBytes( nB )
124{
125}
126
128 sZeroStr( GetXMLToken( eZeroString ) ),
129 nBytes( nB )
130{
131}
132
134{
135 // nothing to do
136}
137
138bool XMLNumberNonePropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
139{
140 bool bRet = false;
141
142 sal_Int32 nValue = 0;
143 if( rStrImpValue == sZeroStr )
144 {
145 bRet = true;
146 }
147 else
148 {
149 bRet = ::sax::Converter::convertNumber( nValue, rStrImpValue );
150 }
151 lcl_xmloff_setAny( rValue, nValue, nBytes );
152
153 return bRet;
154}
155
156bool XMLNumberNonePropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
157{
158 bool bRet = false;
159 sal_Int32 nValue;
160
161 if( lcl_xmloff_getAny( rValue, nValue, nBytes ) )
162 {
163 if( nValue == 0 )
164 {
165 rStrExpValue = sZeroStr;
166 }
167 else
168 {
169 rStrExpValue = OUString::number( nValue );
170 }
171
172 bRet = true;
173 }
174
175 return bRet;
176}
177
178
180{
181 // nothing to do
182}
183
184bool XMLMeasurePropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const
185{
186 sal_Int32 nValue = 0;
187 bool bRet = rUnitConverter.convertMeasureToCore( nValue, rStrImpValue );
188 lcl_xmloff_setAny( rValue, nValue, nBytes );
189 return bRet;
190}
191
192bool XMLMeasurePropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const
193{
194 bool bRet = false;
195 sal_Int32 nValue;
196
197 if( lcl_xmloff_getAny( rValue, nValue, nBytes ) )
198 {
199 OUStringBuffer aOut;
200 rUnitConverter.convertMeasureToXML( aOut, nValue );
201 rStrExpValue = aOut.makeStringAndClear();
202
203 bRet = true;
204 }
205
206 return bRet;
207}
208
209
211{
212 // nothing to do
213}
214
215bool XMLBoolFalsePropHdl::importXML( const OUString&, Any&, const SvXMLUnitConverter& ) const
216{
217 return false;
218}
219
220bool XMLBoolFalsePropHdl::exportXML( OUString& rStrExpValue, const Any& /*rValue*/, const SvXMLUnitConverter& rCnv) const
221{
222 return XMLBoolPropHdl::exportXML( rStrExpValue, Any( false ), rCnv );
223}
224
225
227{
228 // nothing to do
229}
230
231bool XMLBoolPropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
232{
233 bool bValue(false);
234 bool const bRet = ::sax::Converter::convertBool( bValue, rStrImpValue );
235 rValue <<= bValue;
236
237 return bRet;
238}
239
240bool XMLBoolPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
241{
242 bool bRet = false;
243 bool bValue;
244
245 if (rValue >>= bValue)
246 {
247 OUStringBuffer aOut;
248 ::sax::Converter::convertBool( aOut, bValue );
249 rStrExpValue = aOut.makeStringAndClear();
250
251 bRet = true;
252 }
253
254 return bRet;
255}
256
257
259{
260 // nothing to do
261}
262
263bool XMLNBoolPropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
264{
265 bool bValue(false);
266 bool const bRet = ::sax::Converter::convertBool( bValue, rStrImpValue );
267 rValue <<= !bValue;
268
269 return bRet;
270}
271
272bool XMLNBoolPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
273{
274 bool bRet = false;
275 bool bValue;
276
277 if (rValue >>= bValue)
278 {
279 OUStringBuffer aOut;
280 ::sax::Converter::convertBool( aOut, !bValue );
281 rStrExpValue = aOut.makeStringAndClear();
282
283 bRet = true;
284 }
285
286 return bRet;
287}
288
289
291{
292 // nothing to do
293}
294
295bool XMLPercentPropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
296{
297 sal_Int32 nValue = 0;
298 bool const bRet = ::sax::Converter::convertPercent( nValue, rStrImpValue );
299 lcl_xmloff_setAny( rValue, nValue, nBytes );
300
301 return bRet;
302}
303
304bool XMLPercentPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
305{
306 bool bRet = false;
307 sal_Int32 nValue;
308
309 if( lcl_xmloff_getAny( rValue, nValue, nBytes ) )
310 {
311 OUStringBuffer aOut;
313 rStrExpValue = aOut.makeStringAndClear();
314
315 bRet = true;
316 }
317
318 return bRet;
319}
320
321
322bool XMLDoublePercentPropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
323{
324 bool bRet = false;
325
326 double fValue = 1.0;
327
328 if( rStrImpValue.indexOf( '%' ) == -1 )
329 {
330 fValue = rStrImpValue.toDouble();
331 }
332 else
333 {
334 sal_Int32 nValue = 0;
335 bRet = ::sax::Converter::convertPercent( nValue, rStrImpValue );
336 fValue = static_cast<double>(nValue) / 100.0;
337 }
338 rValue <<= fValue;
339
340 return bRet;
341}
342
343bool XMLDoublePercentPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
344{
345 bool bRet = false;
346 double fValue = 0;
347
348 if( rValue >>= fValue )
349 {
350 fValue *= 100.0;
351 if( fValue > 0 ) fValue += 0.5; else fValue -= 0.5;
352
353 sal_Int32 nValue = static_cast<sal_Int32>(fValue);
354
355 OUStringBuffer aOut;
357 rStrExpValue = aOut.makeStringAndClear();
358
359 bRet = true;
360 }
361
362 return bRet;
363}
364
365bool XML100thPercentPropHdl::importXML(const OUString& rStrImpValue, Any& rValue,
366 const SvXMLUnitConverter&) const
367{
368 bool bRet = false;
369
370 sal_Int32 nValue = 0;
371 bRet = sax::Converter::convertPercent(nValue, rStrImpValue);
372 rValue <<= static_cast<sal_Int16>(nValue * 100);
373
374 return bRet;
375}
376
377bool XML100thPercentPropHdl::exportXML(OUString& rStrExpValue, const Any& rValue,
378 const SvXMLUnitConverter&) const
379{
380 bool bRet = false;
381 sal_Int16 nValue = 0;
382
383 if (rValue >>= nValue)
384 {
385 nValue = std::round(static_cast<double>(nValue) / 100);
386 OUStringBuffer aOut;
388 rStrExpValue = aOut.makeStringAndClear();
389 bRet = true;
390 }
391
392 return bRet;
393}
394
395
397{
398 // nothing to do
399}
400
401bool XMLNegPercentPropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
402{
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;
410}
411
412bool XMLNegPercentPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
413{
414 bool bRet = false;
415 sal_Int32 nValue;
416
417 if( lcl_xmloff_getAny( rValue, nValue, nBytes ) )
418 {
419 OUStringBuffer aOut;
421 rStrExpValue = aOut.makeStringAndClear();
422
423 bRet = true;
424 }
425
426 return bRet;
427}
428
430{
431 // nothing to do
432}
433
434bool XMLMeasurePxPropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
435{
436 sal_Int32 nValue = 0;
437 bool bRet = ::sax::Converter::convertMeasurePx( nValue, rStrImpValue );
438 lcl_xmloff_setAny( rValue, nValue, nBytes );
439 return bRet;
440}
441
442bool XMLMeasurePxPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
443{
444 bool bRet = false;
445 sal_Int32 nValue;
446
447 if( lcl_xmloff_getAny( rValue, nValue, nBytes ) )
448 {
449 OUStringBuffer aOut;
451 rStrExpValue = aOut.makeStringAndClear();
452
453 bRet = true;
454 }
455
456 return bRet;
457}
458
459
461{
462 // Nothing to do
463}
464
465bool XMLColorPropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
466{
467 bool bRet = false;
468
469 if( rStrImpValue.matchIgnoreAsciiCase( "hsl" ) )
470 {
471 sal_Int32 nOpen = rStrImpValue.indexOf( '(' );
472 sal_Int32 nClose = rStrImpValue.lastIndexOf( ')' );
473
474 if( (nOpen != -1) && (nClose > nOpen) )
475 {
476 const std::u16string_view aTmp( rStrImpValue.subView( nOpen+1, nClose - nOpen-1) );
477
478 sal_Int32 nIndex = 0;
479
480 Sequence< double > aHSL
481 {
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
485 };
486 rValue <<= aHSL;
487 bRet = true;
488 }
489 }
490 else
491 {
492 sal_Int32 nColor(0);
493 bRet = ::sax::Converter::convertColor( nColor, rStrImpValue );
494 rValue <<= nColor;
495 }
496
497 return bRet;
498}
499
500bool XMLColorPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
501{
502 bool bRet = false;
503 sal_Int32 nColor = 0;
504
505 OUStringBuffer aOut;
506 if( rValue >>= nColor )
507 {
508 ::sax::Converter::convertColor( aOut, nColor );
509 rStrExpValue = aOut.makeStringAndClear();
510
511 bRet = true;
512 }
513 else
514 {
515 Sequence< double > aHSL;
516 if( (rValue >>= aHSL) && (aHSL.getLength() == 3) )
517 {
518 rStrExpValue = "hsl(" + OUString::number(aHSL[0]) + "," +
519 OUString::number(aHSL[1] * 100.0) + "%," +
520 OUString::number(aHSL[2] * 100.0) + "%)";
521
522 bRet = true;
523 }
524 }
525
526 return bRet;
527}
528
529
531{
532 // Nothing to do
533}
534
535bool XMLHexPropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
536{
537 sal_uInt32 nRsid;
538 bool bRet = SvXMLUnitConverter::convertHex( nRsid, rStrImpValue );
539 rValue <<= nRsid;
540
541 return bRet;
542}
543
544bool XMLHexPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
545{
546 bool bRet = false;
547 sal_uInt32 nRsid = 0;
548
549 if( rValue >>= nRsid )
550 {
551 OUStringBuffer aOut;
552 SvXMLUnitConverter::convertHex( aOut, nRsid );
553 rStrExpValue = aOut.makeStringAndClear();
554
555 bRet = true;
556 }
557 else
558 {
559 bRet = false;
560 }
561
562 return bRet;
563}
564
565
567{
568 // Nothing to do
569}
570
571bool XMLStringPropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
572{
573 rValue <<= rStrImpValue;
574 return true;
575}
576
577bool XMLStringPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
578{
579 bool bRet = false;
580
581 if( rValue >>= rStrExpValue )
582 bRet = true;
583
584 return bRet;
585}
586
587
589{
590 // Nothing to do
591}
592
593bool XMLStyleNamePropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const
594{
595 bool bRet = false;
596
597 if( rValue >>= rStrExpValue )
598 {
599 rStrExpValue = rUnitConverter.encodeStyleName( rStrExpValue );
600 bRet = true;
601 }
602
603 return bRet;
604}
605
606
608{
609 // Nothing to do
610}
611
612bool XMLDoublePropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
613{
614 double fDblValue(0.0);
615 bool const bRet = ::sax::Converter::convertDouble(fDblValue, rStrImpValue);
616 rValue <<= fDblValue;
617 return bRet;
618}
619
620bool XMLDoublePropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
621{
622 bool bRet = false;
623
624 double fValue = 0;
625
626 if( rValue >>= fValue )
627 {
628 OUStringBuffer aOut;
629 ::sax::Converter::convertDouble( aOut, fValue );
630 rStrExpValue = aOut.makeStringAndClear();
631 bRet = true;
632 }
633
634 return bRet;
635}
636
637
639 enum XMLTokenEnum eTransparent ) :
640 sTransparent( GetXMLToken(
641 eTransparent != XML_TOKEN_INVALID ? eTransparent : XML_TRANSPARENT ) )
642{
643 // Nothing to do
644}
645
647{
648 // Nothing to do
649}
650
651bool XMLColorTransparentPropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
652{
653 bool bRet = false;
654
655 if( rStrImpValue != sTransparent )
656 {
657 sal_Int32 nColor(0);
658 bRet = ::sax::Converter::convertColor( nColor, rStrImpValue );
659 rValue <<= nColor;
660 }
661
662 return bRet;
663}
664
665bool XMLColorTransparentPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
666{
667 bool bRet = false;
668 sal_Int32 nColor = 0;
669
670 if( rStrExpValue == sTransparent )
671 bRet = false;
672 else if( rValue >>= nColor )
673 {
674 OUStringBuffer aOut;
675 ::sax::Converter::convertColor( aOut, nColor );
676 rStrExpValue = aOut.makeStringAndClear();
677
678 bRet = true;
679 }
680
681 return bRet;
682}
683
684
686 enum XMLTokenEnum eTransparent, bool bTransPropVal ) :
687 sTransparent( GetXMLToken(
688 eTransparent != XML_TOKEN_INVALID ? eTransparent : XML_TRANSPARENT ) ),
689 bTransPropValue( bTransPropVal )
690{
691}
692
694{
695 // Nothing to do
696}
697
698bool XMLIsTransparentPropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
699{
700 bool bValue = ( (rStrImpValue == sTransparent) == bTransPropValue);
701 rValue <<= bValue;
702
703 return true;
704}
705
706bool XMLIsTransparentPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
707{
708 bool bRet = false;
709
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;
715
716 if( bIsTrans )
717 {
718 rStrExpValue = sTransparent;
719 bRet = true;
720 }
721
722 return bRet;
723}
724
725
727{
728 // Nothing to do
729}
730
732{
733 // Nothing to do
734}
735
736bool XMLColorAutoPropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
737{
738 bool bRet = false;
739
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 )
744 {
745 bRet = ::sax::Converter::convertColor( nColor, rStrImpValue );
746 if( bRet )
747 rValue <<= nColor;
748 }
749
750 return bRet;
751}
752
753bool XMLColorAutoPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
754{
755 bool bRet = false;
756
757 sal_Int32 nColor = 0;
758 if( (rValue >>= nColor) && -1 != nColor )
759 {
760 OUStringBuffer aOut;
761 ::sax::Converter::convertColor( aOut, nColor );
762 rStrExpValue = aOut.makeStringAndClear();
763
764 bRet = true;
765 }
766
767 return bRet;
768}
769
770
772{
773}
774
776{
777 // Nothing to do
778}
779
780bool XMLIsAutoColorPropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
781{
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);
787
788 return true;
789}
790
791bool XMLIsAutoColorPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
792{
793 bool bRet = false;
794 sal_Int32 nColor = 0;
795
796 if( (rValue >>= nColor) && -1 == nColor )
797 {
798 OUStringBuffer aOut;
799 ::sax::Converter::convertBool( aOut, true );
800 rStrExpValue = aOut.makeStringAndClear();
801
802 bRet = true;
803 }
804
805 return bRet;
806}
807
808
810{
811 // Nothing to do
812}
813
814bool XMLCompareOnlyPropHdl::importXML( const OUString&, Any&, const SvXMLUnitConverter& ) const
815{
816 SAL_WARN( "xmloff", "importXML called for compare-only-property" );
817 return false;
818}
819
820bool XMLCompareOnlyPropHdl::exportXML( OUString&, const Any&, const SvXMLUnitConverter& ) const
821{
822 SAL_WARN( "xmloff", "exportXML called for compare-only-property" );
823 return false;
824}
825
826
828 nBytes( nB )
829{
830}
831
833{
834}
835
837 const OUString& rStrImpValue,
838 Any& rValue,
839 const SvXMLUnitConverter& ) const
840{
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;
846}
847
848bool XMLNumberWithoutZeroPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
849{
850
851 sal_Int32 nValue = 0;
852 bool bRet = lcl_xmloff_getAny( rValue, nValue, nBytes );
853 bRet &= nValue != 0;
854
855 if( bRet )
856 {
857 rStrExpValue = OUString::number(nValue);
858 }
859
860 return bRet;
861}
862
863
865{
866}
867
869 const OUString& rStrImpValue,
870 Any& rValue,
871 const SvXMLUnitConverter& ) const
872{
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 ) )
878 {
879 rValue.clear(); // void
880 bRet = true;
881 }
882 return bRet;
883}
884
886 OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter&) const
887{
888
889 sal_Int32 nValue = 0;
890 bool bRet = lcl_xmloff_getAny( rValue, nValue, 2 );
891
892 // note: 0 is a valid value here, see CTF_PAGENUMBEROFFSET for when it isn't
893
894 if (!bRet)
895 rStrExpValue = GetXMLToken( XML_AUTO );
896 else
897 {
898 rStrExpValue = OUString::number(nValue);
899 }
900
901 return true;
902}
903
904/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
the SvXMLTypeConverter converts values of various types from their internal representation to the tex...
Definition: xmluconv.hxx:83
bool convertMeasureToCore(sal_Int32 &rValue, std::u16string_view rString, sal_Int32 nMin=SAL_MIN_INT32, sal_Int32 nMax=SAL_MAX_INT32) const
convert string to measure with meCoreMeasureUnit, using optional min and max values
Definition: xmluconv.cxx:188
OUString encodeStyleName(const OUString &rName, bool *pEncoded=nullptr) const
Definition: xmluconv.cxx:832
static bool convertHex(sal_uInt32 &nVal, std::u16string_view rValue)
convert string (hex) to number (sal_uInt32)
Definition: xmluconv.cxx:937
void convertMeasureToXML(OUStringBuffer &rBuffer, sal_Int32 nMeasure) const
convert measure to string: from meCoreMeasureUnit to meXMLMeasureUnit
Definition: xmluconv.cxx:208
virtual bool exportXML(OUString &rStrExpValue, const css::uno::Any &rValue, const SvXMLUnitConverter &rUnitConverter) const override
Exports the given value according to the XML-data-type corresponding to the derived class.
Definition: xmlbahdl.cxx:377
virtual bool importXML(const OUString &rStrImpValue, css::uno::Any &rValue, const SvXMLUnitConverter &rUnitConverter) const override
Imports the given value according to the XML-data-type corresponding to the derived class.
Definition: xmlbahdl.cxx:365
virtual ~XMLBoolFalsePropHdl() override
Definition: xmlbahdl.cxx:210
virtual bool exportXML(OUString &rStrExpValue, const css::uno::Any &rValue, const SvXMLUnitConverter &rUnitConverter) const override
Exports the given value according to the XML-data-type corresponding to the derived class.
Definition: xmlbahdl.cxx:220
virtual bool importXML(const OUString &rStrImpValue, css::uno::Any &rValue, const SvXMLUnitConverter &rUnitConverter) const override
Imports the given value according to the XML-data-type corresponding to the derived class.
Definition: xmlbahdl.cxx:215
virtual ~XMLBoolPropHdl() override
Definition: xmlbahdl.cxx:226
virtual bool exportXML(OUString &rStrExpValue, const css::uno::Any &rValue, const SvXMLUnitConverter &rUnitConverter) const override
Exports the given value according to the XML-data-type corresponding to the derived class.
Definition: xmlbahdl.cxx:240
virtual bool importXML(const OUString &rStrImpValue, css::uno::Any &rValue, const SvXMLUnitConverter &rUnitConverter) const override
Imports the given value according to the XML-data-type corresponding to the derived class.
Definition: xmlbahdl.cxx:231
virtual bool exportXML(OUString &rStrExpValue, const css::uno::Any &rValue, const SvXMLUnitConverter &rUnitConverter) const override
Exports the given value according to the XML-data-type corresponding to the derived class.
Definition: xmlbahdl.cxx:753
virtual ~XMLColorAutoPropHdl() override
Definition: xmlbahdl.cxx:731
virtual bool importXML(const OUString &rStrImpValue, css::uno::Any &rValue, const SvXMLUnitConverter &rUnitConverter) const override
Imports the given value according to the XML-data-type corresponding to the derived class.
Definition: xmlbahdl.cxx:736
virtual bool exportXML(OUString &rStrExpValue, const css::uno::Any &rValue, const SvXMLUnitConverter &rUnitConverter) const override
Exports the given value according to the XML-data-type corresponding to the derived class.
Definition: xmlbahdl.cxx:500
virtual ~XMLColorPropHdl() override
Definition: xmlbahdl.cxx:460
virtual bool importXML(const OUString &rStrImpValue, css::uno::Any &rValue, const SvXMLUnitConverter &rUnitConverter) const override
Imports the given value according to the XML-data-type corresponding to the derived class.
Definition: xmlbahdl.cxx:465
const OUString sTransparent
Definition: xmlbahdl.hxx:231
virtual bool importXML(const OUString &rStrImpValue, css::uno::Any &rValue, const SvXMLUnitConverter &rUnitConverter) const override
Imports the given value according to the XML-data-type corresponding to the derived class.
Definition: xmlbahdl.cxx:651
virtual bool exportXML(OUString &rStrExpValue, const css::uno::Any &rValue, const SvXMLUnitConverter &rUnitConverter) const override
Exports the given value according to the XML-data-type corresponding to the derived class.
Definition: xmlbahdl.cxx:665
XMLColorTransparentPropHdl(enum ::xmloff::token::XMLTokenEnum eTransparent=xmloff::token::XML_TOKEN_INVALID)
Definition: xmlbahdl.cxx:638
virtual ~XMLColorTransparentPropHdl() override
Definition: xmlbahdl.cxx:646
virtual bool exportXML(OUString &rStrExpValue, const css::uno::Any &rValue, const SvXMLUnitConverter &rUnitConverter) const override
Exports the given value according to the XML-data-type corresponding to the derived class.
Definition: xmlbahdl.cxx:820
virtual ~XMLCompareOnlyPropHdl() override
Definition: xmlbahdl.cxx:809
virtual bool importXML(const OUString &rStrImpValue, css::uno::Any &rValue, const SvXMLUnitConverter &rUnitConverter) const override
Imports the given value according to the XML-data-type corresponding to the derived class.
Definition: xmlbahdl.cxx:814
virtual bool exportXML(OUString &rStrExpValue, const css::uno::Any &rValue, const SvXMLUnitConverter &rUnitConverter) const override
Exports the given value according to the XML-data-type corresponding to the derived class.
Definition: xmlbahdl.cxx:343
virtual bool importXML(const OUString &rStrImpValue, css::uno::Any &rValue, const SvXMLUnitConverter &rUnitConverter) const override
Imports the given value according to the XML-data-type corresponding to the derived class.
Definition: xmlbahdl.cxx:322
virtual bool importXML(const OUString &rStrImpValue, css::uno::Any &rValue, const SvXMLUnitConverter &rUnitConverter) const override
Imports the given value according to the XML-data-type corresponding to the derived class.
Definition: xmlbahdl.cxx:612
virtual ~XMLDoublePropHdl() override
Definition: xmlbahdl.cxx:607
virtual bool exportXML(OUString &rStrExpValue, const css::uno::Any &rValue, const SvXMLUnitConverter &rUnitConverter) const override
Exports the given value according to the XML-data-type corresponding to the derived class.
Definition: xmlbahdl.cxx:620
virtual ~XMLHexPropHdl() override
Definition: xmlbahdl.cxx:530
virtual bool importXML(const OUString &rStrImpValue, css::uno::Any &rValue, const SvXMLUnitConverter &rUnitConverter) const override
Imports the given value according to the XML-data-type corresponding to the derived class.
Definition: xmlbahdl.cxx:535
virtual bool exportXML(OUString &rStrExpValue, const css::uno::Any &rValue, const SvXMLUnitConverter &rUnitConverter) const override
Exports the given value according to the XML-data-type corresponding to the derived class.
Definition: xmlbahdl.cxx:544
virtual ~XMLIsAutoColorPropHdl() override
Definition: xmlbahdl.cxx:775
virtual bool exportXML(OUString &rStrExpValue, const css::uno::Any &rValue, const SvXMLUnitConverter &rUnitConverter) const override
Exports the given value according to the XML-data-type corresponding to the derived class.
Definition: xmlbahdl.cxx:791
virtual bool importXML(const OUString &rStrImpValue, css::uno::Any &rValue, const SvXMLUnitConverter &rUnitConverter) const override
Imports the given value according to the XML-data-type corresponding to the derived class.
Definition: xmlbahdl.cxx:780
virtual bool importXML(const OUString &rStrImpValue, css::uno::Any &rValue, const SvXMLUnitConverter &rUnitConverter) const override
Imports the given value according to the XML-data-type corresponding to the derived class.
Definition: xmlbahdl.cxx:698
XMLIsTransparentPropHdl(enum ::xmloff::token::XMLTokenEnum eTransparent=xmloff::token::XML_TOKEN_INVALID, bool bTransPropValue=true)
Definition: xmlbahdl.cxx:685
virtual bool exportXML(OUString &rStrExpValue, const css::uno::Any &rValue, const SvXMLUnitConverter &rUnitConverter) const override
Exports the given value according to the XML-data-type corresponding to the derived class.
Definition: xmlbahdl.cxx:706
const OUString sTransparent
Definition: xmlbahdl.hxx:246
virtual ~XMLIsTransparentPropHdl() override
Definition: xmlbahdl.cxx:693
virtual bool importXML(const OUString &rStrImpValue, css::uno::Any &rValue, const SvXMLUnitConverter &rUnitConverter) const override
Imports the given value according to the XML-data-type corresponding to the derived class.
Definition: xmlbahdl.cxx:184
sal_Int8 nBytes
Definition: xmlbahdl.hxx:62
virtual bool exportXML(OUString &rStrExpValue, const css::uno::Any &rValue, const SvXMLUnitConverter &rUnitConverter) const override
Exports the given value according to the XML-data-type corresponding to the derived class.
Definition: xmlbahdl.cxx:192
virtual ~XMLMeasurePropHdl() override
Definition: xmlbahdl.cxx:179
virtual bool exportXML(OUString &rStrExpValue, const css::uno::Any &rValue, const SvXMLUnitConverter &rUnitConverter) const override
Exports the given value according to the XML-data-type corresponding to the derived class.
Definition: xmlbahdl.cxx:442
virtual ~XMLMeasurePxPropHdl() override
Definition: xmlbahdl.cxx:429
virtual bool importXML(const OUString &rStrImpValue, css::uno::Any &rValue, const SvXMLUnitConverter &rUnitConverter) const override
Imports the given value according to the XML-data-type corresponding to the derived class.
Definition: xmlbahdl.cxx:434
virtual ~XMLNBoolPropHdl() override
Definition: xmlbahdl.cxx:258
virtual bool importXML(const OUString &rStrImpValue, css::uno::Any &rValue, const SvXMLUnitConverter &rUnitConverter) const override
Imports the given value according to the XML-data-type corresponding to the derived class.
Definition: xmlbahdl.cxx:263
virtual bool exportXML(OUString &rStrExpValue, const css::uno::Any &rValue, const SvXMLUnitConverter &rUnitConverter) const override
Exports the given value according to the XML-data-type corresponding to the derived class.
Definition: xmlbahdl.cxx:272
virtual ~XMLNegPercentPropHdl() override
Definition: xmlbahdl.cxx:396
virtual bool exportXML(OUString &rStrExpValue, const css::uno::Any &rValue, const SvXMLUnitConverter &rUnitConverter) const override
Exports the given value according to the XML-data-type corresponding to the derived class.
Definition: xmlbahdl.cxx:412
virtual bool importXML(const OUString &rStrImpValue, css::uno::Any &rValue, const SvXMLUnitConverter &rUnitConverter) const override
Imports the given value according to the XML-data-type corresponding to the derived class.
Definition: xmlbahdl.cxx:401
virtual bool importXML(const OUString &rStrImpValue, css::uno::Any &rValue, const SvXMLUnitConverter &rUnitConverter) const override
Imports the given value according to the XML-data-type corresponding to the derived class.
Definition: xmlbahdl.cxx:138
virtual bool exportXML(OUString &rStrExpValue, const css::uno::Any &rValue, const SvXMLUnitConverter &rUnitConverter) const override
Exports the given value according to the XML-data-type corresponding to the derived class.
Definition: xmlbahdl.cxx:156
virtual ~XMLNumberNonePropHdl() override
Definition: xmlbahdl.cxx:133
XMLNumberNonePropHdl(sal_Int8 nB=4)
Definition: xmlbahdl.cxx:121
virtual bool importXML(const OUString &rStrImpValue, css::uno::Any &rValue, const SvXMLUnitConverter &rUnitConverter) const override
Imports the given value according to the XML-data-type corresponding to the derived class.
Definition: xmlbahdl.cxx:96
virtual ~XMLNumberPropHdl() override
Definition: xmlbahdl.cxx:91
virtual bool exportXML(OUString &rStrExpValue, const css::uno::Any &rValue, const SvXMLUnitConverter &rUnitConverter) const override
Exports the given value according to the XML-data-type corresponding to the derived class.
Definition: xmlbahdl.cxx:105
sal_Int8 nBytes
Definition: xmlbahdl.hxx:31
virtual bool exportXML(OUString &rStrExpValue, const css::uno::Any &rValue, const SvXMLUnitConverter &rUnitConverter) const override
Exports the given value according to the XML-data-type corresponding to the derived class.
Definition: xmlbahdl.cxx:885
virtual ~XMLNumberWithAutoForVoidPropHdl() override
Definition: xmlbahdl.cxx:864
virtual bool importXML(const OUString &rStrImpValue, css::uno::Any &rValue, const SvXMLUnitConverter &rUnitConverter) const override
Imports the given value according to the XML-data-type corresponding to the derived class.
Definition: xmlbahdl.cxx:868
XMLNumberWithoutZeroPropHdl(sal_Int8 nB)
Definition: xmlbahdl.cxx:827
virtual bool importXML(const OUString &rStrImpValue, css::uno::Any &rValue, const SvXMLUnitConverter &rUnitConverter) const override
Imports the given value according to the XML-data-type corresponding to the derived class.
Definition: xmlbahdl.cxx:836
virtual bool exportXML(OUString &rStrExpValue, const css::uno::Any &rValue, const SvXMLUnitConverter &rUnitConverter) const override
Exports the given value according to the XML-data-type corresponding to the derived class.
Definition: xmlbahdl.cxx:848
virtual ~XMLNumberWithoutZeroPropHdl() override
Definition: xmlbahdl.cxx:832
virtual ~XMLPercentPropHdl() override
Definition: xmlbahdl.cxx:290
virtual bool exportXML(OUString &rStrExpValue, const css::uno::Any &rValue, const SvXMLUnitConverter &rUnitConverter) const override
Exports the given value according to the XML-data-type corresponding to the derived class.
Definition: xmlbahdl.cxx:304
sal_Int8 nBytes
Definition: xmlbahdl.hxx:76
virtual bool importXML(const OUString &rStrImpValue, css::uno::Any &rValue, const SvXMLUnitConverter &rUnitConverter) const override
Imports the given value according to the XML-data-type corresponding to the derived class.
Definition: xmlbahdl.cxx:295
virtual bool importXML(const OUString &rStrImpValue, css::uno::Any &rValue, const SvXMLUnitConverter &rUnitConverter) const override
Imports the given value according to the XML-data-type corresponding to the derived class.
Definition: xmlbahdl.cxx:571
virtual bool exportXML(OUString &rStrExpValue, const css::uno::Any &rValue, const SvXMLUnitConverter &rUnitConverter) const override
Exports the given value according to the XML-data-type corresponding to the derived class.
Definition: xmlbahdl.cxx:577
virtual ~XMLStringPropHdl() override
Definition: xmlbahdl.cxx:566
virtual ~XMLStyleNamePropHdl() override
Definition: xmlbahdl.cxx:588
virtual bool exportXML(OUString &rStrExpValue, const css::uno::Any &rValue, const SvXMLUnitConverter &rUnitConverter) const override
Exports the given value according to the XML-data-type corresponding to the derived class.
Definition: xmlbahdl.cxx:593
static void convertDouble(OUStringBuffer &rBuffer, double fNumber, bool bWriteUnits, sal_Int16 nSourceUnit, sal_Int16 nTargetUnit)
static bool convertMeasurePx(sal_Int32 &rValue, std::u16string_view rString)
static bool convertPercent(sal_Int32 &rValue, std::u16string_view rString)
static bool convertColor(sal_Int32 &rColor, std::u16string_view rValue)
static bool convertNumber(sal_Int32 &rValue, std::u16string_view aString, sal_Int32 nMin=SAL_MIN_INT32, sal_Int32 nMax=SAL_MAX_INT32)
static bool convertBool(bool &rBool, std::u16string_view rString)
sal_Int16 nValue
sal_Int32 nIndex
#define SAL_WARN(area, stream)
std::basic_string_view< charT, traits > getToken(std::basic_string_view< charT, traits > sv, charT delimiter, std::size_t &position)
double toDouble(std::u16string_view str)
Handling of tokens in XML:
XMLTokenEnum
The enumeration of all XML tokens.
Definition: xmltoken.hxx:50
const OUString & GetXMLToken(enum XMLTokenEnum eToken)
return the OUString representation for eToken
Definition: xmltoken.cxx:3541
signed char sal_Int8
static bool lcl_xmloff_getAny(const Any &rValue, sal_Int32 &nValue, sal_Int8 nBytes)
Definition: xmlbahdl.cxx:61
static void lcl_xmloff_setAny(Any &rValue, sal_Int32 nValue, sal_Int8 nBytes)
Definition: xmlbahdl.cxx:37