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(3);
450  aHSL[0] = aTmp.getToken( 0, ',', nIndex ).toDouble();
451  aHSL[1] = aTmp.getToken( 0, ',', nIndex ).toDouble() / 100.0;
452  aHSL[2] = aTmp.getToken( 0, ',', nIndex ).toDouble() / 100.0;
453  rValue <<= aHSL;
454  bRet = true;
455  }
456  }
457  else
458  {
459  sal_Int32 nColor(0);
460  bRet = ::sax::Converter::convertColor( nColor, rStrImpValue );
461  rValue <<= nColor;
462  }
463 
464  return bRet;
465 }
466 
467 bool XMLColorPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
468 {
469  bool bRet = false;
470  sal_Int32 nColor = 0;
471 
472  OUStringBuffer aOut;
473  if( rValue >>= nColor )
474  {
475  ::sax::Converter::convertColor( aOut, nColor );
476  rStrExpValue = aOut.makeStringAndClear();
477 
478  bRet = true;
479  }
480  else
481  {
482  Sequence< double > aHSL;
483  if( (rValue >>= aHSL) && (aHSL.getLength() == 3) )
484  {
485  aOut.append( "hsl(" ).append( OUString::number(aHSL[0]) ).append( "," )
486  .append( OUString::number(aHSL[1] * 100.0) ).append( "%," )
487  .append( OUString::number(aHSL[2] * 100.0) ).append( "%)" );
488  rStrExpValue = aOut.makeStringAndClear();
489 
490  bRet = true;
491  }
492  }
493 
494  return bRet;
495 }
496 
497 
499 {
500  // Nothing to do
501 }
502 
503 bool XMLHexPropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
504 {
505  sal_uInt32 nRsid;
506  bool bRet = SvXMLUnitConverter::convertHex( nRsid, rStrImpValue );
507  rValue <<= nRsid;
508 
509  return bRet;
510 }
511 
512 bool XMLHexPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
513 {
514  bool bRet = false;
515  sal_uInt32 nRsid = 0;
516 
517  if( rValue >>= nRsid )
518  {
519  OUStringBuffer aOut;
520  SvXMLUnitConverter::convertHex( aOut, nRsid );
521  rStrExpValue = aOut.makeStringAndClear();
522 
523  bRet = true;
524  }
525  else
526  {
527  bRet = false;
528  }
529 
530  return bRet;
531 }
532 
533 
535 {
536  // Nothing to do
537 }
538 
539 bool XMLStringPropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
540 {
541  rValue <<= rStrImpValue;
542  return true;
543 }
544 
545 bool XMLStringPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
546 {
547  bool bRet = false;
548 
549  if( rValue >>= rStrExpValue )
550  bRet = true;
551 
552  return bRet;
553 }
554 
555 
557 {
558  // Nothing to do
559 }
560 
561 bool XMLStyleNamePropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const
562 {
563  bool bRet = false;
564 
565  if( rValue >>= rStrExpValue )
566  {
567  rStrExpValue = rUnitConverter.encodeStyleName( rStrExpValue );
568  bRet = true;
569  }
570 
571  return bRet;
572 }
573 
574 
576 {
577  // Nothing to do
578 }
579 
580 bool XMLDoublePropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
581 {
582  double fDblValue(0.0);
583  bool const bRet = ::sax::Converter::convertDouble(fDblValue, rStrImpValue);
584  rValue <<= fDblValue;
585  return bRet;
586 }
587 
588 bool XMLDoublePropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
589 {
590  bool bRet = false;
591 
592  double fValue = 0;
593 
594  if( rValue >>= fValue )
595  {
596  OUStringBuffer aOut;
597  ::sax::Converter::convertDouble( aOut, fValue );
598  rStrExpValue = aOut.makeStringAndClear();
599  bRet = true;
600  }
601 
602  return bRet;
603 }
604 
605 
607  enum XMLTokenEnum eTransparent ) :
608  sTransparent( GetXMLToken(
609  eTransparent != XML_TOKEN_INVALID ? eTransparent : XML_TRANSPARENT ) )
610 {
611  // Nothing to do
612 }
613 
615 {
616  // Nothing to do
617 }
618 
619 bool XMLColorTransparentPropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
620 {
621  bool bRet = false;
622 
623  if( rStrImpValue != sTransparent )
624  {
625  sal_Int32 nColor(0);
626  bRet = ::sax::Converter::convertColor( nColor, rStrImpValue );
627  rValue <<= nColor;
628  }
629 
630  return bRet;
631 }
632 
633 bool XMLColorTransparentPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
634 {
635  bool bRet = false;
636  sal_Int32 nColor = 0;
637 
638  if( rStrExpValue == sTransparent )
639  bRet = false;
640  else if( rValue >>= nColor )
641  {
642  OUStringBuffer aOut;
643  ::sax::Converter::convertColor( aOut, nColor );
644  rStrExpValue = aOut.makeStringAndClear();
645 
646  bRet = true;
647  }
648 
649  return bRet;
650 }
651 
652 
654  enum XMLTokenEnum eTransparent, bool bTransPropVal ) :
655  sTransparent( GetXMLToken(
656  eTransparent != XML_TOKEN_INVALID ? eTransparent : XML_TRANSPARENT ) ),
657  bTransPropValue( bTransPropVal )
658 {
659 }
660 
662 {
663  // Nothing to do
664 }
665 
666 bool XMLIsTransparentPropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
667 {
668  bool bValue = ( (rStrImpValue == sTransparent) == bTransPropValue);
669  rValue <<= bValue;
670 
671  return true;
672 }
673 
674 bool XMLIsTransparentPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
675 {
676  bool bRet = false;
677 
678  // MIB: This looks a bit strange, because bTransPropValue == bValue should
679  // do the same, but this only applies if 'true' is represented by the same
680  // 8 bit value in bValue and bTransPropValue. Who will ensure this?
681  bool bValue = *o3tl::doAccess<bool>(rValue);
682  bool bIsTrans = bTransPropValue ? bValue : !bValue;
683 
684  if( bIsTrans )
685  {
686  rStrExpValue = sTransparent;
687  bRet = true;
688  }
689 
690  return bRet;
691 }
692 
693 
695 {
696  // Nothing to do
697 }
698 
700 {
701  // Nothing to do
702 }
703 
704 bool XMLColorAutoPropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
705 {
706  bool bRet = false;
707 
708  // This is a multi property: the value might be set to AUTO_COLOR
709  // already by the XMLIsAutoColorPropHdl!
710  sal_Int32 nColor = 0;
711  if( !(rValue >>= nColor) || -1 != nColor )
712  {
713  bRet = ::sax::Converter::convertColor( nColor, rStrImpValue );
714  if( bRet )
715  rValue <<= nColor;
716  }
717 
718  return bRet;
719 }
720 
721 bool XMLColorAutoPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
722 {
723  bool bRet = false;
724 
725  sal_Int32 nColor = 0;
726  if( (rValue >>= nColor) && -1 != nColor )
727  {
728  OUStringBuffer aOut;
729  ::sax::Converter::convertColor( aOut, nColor );
730  rStrExpValue = aOut.makeStringAndClear();
731 
732  bRet = true;
733  }
734 
735  return bRet;
736 }
737 
738 
740 {
741 }
742 
744 {
745  // Nothing to do
746 }
747 
748 bool XMLIsAutoColorPropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
749 {
750  // An auto color overrides any other color set!
751  bool bValue;
752  bool const bRet = ::sax::Converter::convertBool( bValue, rStrImpValue );
753  if( bRet && bValue )
754  rValue <<= sal_Int32(-1);
755 
756  return true;
757 }
758 
759 bool XMLIsAutoColorPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
760 {
761  bool bRet = false;
762  sal_Int32 nColor = 0;
763 
764  if( (rValue >>= nColor) && -1 == nColor )
765  {
766  OUStringBuffer aOut;
767  ::sax::Converter::convertBool( aOut, true );
768  rStrExpValue = aOut.makeStringAndClear();
769 
770  bRet = true;
771  }
772 
773  return bRet;
774 }
775 
776 
778 {
779  // Nothing to do
780 }
781 
782 bool XMLCompareOnlyPropHdl::importXML( const OUString&, Any&, const SvXMLUnitConverter& ) const
783 {
784  SAL_WARN( "xmloff", "importXML called for compare-only-property" );
785  return false;
786 }
787 
788 bool XMLCompareOnlyPropHdl::exportXML( OUString&, const Any&, const SvXMLUnitConverter& ) const
789 {
790  SAL_WARN( "xmloff", "exportXML called for compare-only-property" );
791  return false;
792 }
793 
794 
796  nBytes( nB )
797 {
798 }
799 
801 {
802 }
803 
805  const OUString& rStrImpValue,
806  Any& rValue,
807  const SvXMLUnitConverter& ) const
808 {
809  sal_Int32 nValue = 0;
810  bool const bRet = ::sax::Converter::convertNumber( nValue, rStrImpValue );
811  if( bRet )
812  lcl_xmloff_setAny( rValue, nValue, nBytes );
813  return bRet;
814 }
815 
816 bool XMLNumberWithoutZeroPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
817 {
818 
819  sal_Int32 nValue = 0;
820  bool bRet = lcl_xmloff_getAny( rValue, nValue, nBytes );
821  bRet &= nValue != 0;
822 
823  if( bRet )
824  {
825  rStrExpValue = OUString::number(nValue);
826  }
827 
828  return bRet;
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 bRet = ::sax::Converter::convertNumber( nValue, rStrImpValue );
843  if( bRet )
844  lcl_xmloff_setAny( rValue, nValue, 2 );
845  else if( rStrImpValue == GetXMLToken( XML_AUTO ) )
846  {
847  rValue.clear(); // void
848  bRet = true;
849  }
850  return bRet;
851 }
852 
854  OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter&) const
855 {
856 
857  sal_Int32 nValue = 0;
858  bool bRet = lcl_xmloff_getAny( rValue, nValue, 2 );
859 
860  // note: 0 is a valid value here, see CTF_PAGENUMBEROFFSET for when it isn't
861 
862  if (!bRet)
863  rStrExpValue = GetXMLToken( XML_AUTO );
864  else
865  {
866  rStrExpValue = OUString::number(nValue);
867  }
868 
869  return true;
870 }
871 
872 /* 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:800
sal_Int32 nIndex
sal_Int8 nBytes
Definition: xmlbahdl.hxx:32
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:816
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:743
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
static bool convertBool(bool &rBool, const OUString &rString)
the SvXMLTypeConverter converts values of various types from their internal representation to the tex...
Definition: xmluconv.hxx:77
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:614
virtual ~XMLBoolFalsePropHdl() override
Definition: xmlbahdl.cxx:209
XMLIsTransparentPropHdl(enum::xmloff::token::XMLTokenEnum eTransparent=xmloff::token::XML_TOKEN_INVALID, bool bTransPropValue=true)
Definition: xmlbahdl.cxx:653
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:606
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
virtual ~XMLNumberWithAutoForVoidPropHdl() override
Definition: xmlbahdl.cxx:832
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:556
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:748
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:580
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
bool convertMeasureToCore(sal_Int32 &rValue, const OUString &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:171
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:782
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:666
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:223
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 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:759
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:853
virtual ~XMLColorAutoPropHdl() override
Definition: xmlbahdl.cxx:699
virtual ~XMLNumberNonePropHdl() override
Definition: xmlbahdl.cxx:132
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:503
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:795
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:721
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
sal_Int8 nBytes
Definition: xmlbahdl.hxx:77
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:804
virtual ~XMLHexPropHdl() override
Definition: xmlbahdl.cxx:498
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:777
virtual ~XMLColorPropHdl() override
Definition: xmlbahdl.cxx:429
const OUString & GetXMLToken(enum XMLTokenEnum eToken)
return the OUString representation for eToken
Definition: xmltoken.cxx:3378
static bool convertColor(sal_Int32 &rColor, const OUString &rValue)
static bool convertHex(sal_uInt32 &nVal, const OUString &rValue)
convert string (hex) to number (sal_uInt32)
Definition: xmluconv.cxx:844
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:467
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:561
sal_Int8 nBytes
Definition: xmlbahdl.hxx:63
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:512
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:619
virtual ~XMLMeasurePropHdl() override
Definition: xmlbahdl.cxx:178
virtual ~XMLDoublePropHdl() override
Definition: xmlbahdl.cxx:575
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:633
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:704
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:674
static bool convertMeasurePx(sal_Int32 &rValue, const OUString &rString)
virtual ~XMLIsTransparentPropHdl() override
Definition: xmlbahdl.cxx:661
OUString encodeStyleName(const OUString &rName, bool *pEncoded=nullptr) const
Definition: xmluconv.cxx:739
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:539
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:788
virtual ~XMLStringPropHdl() override
Definition: xmlbahdl.cxx:534
#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:588
const OUString sTransparent
Definition: xmlbahdl.hxx:238
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:181
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:545
sal_Int16 nValue
static bool convertPercent(sal_Int32 &rValue, const OUString &rString)
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)