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