LCOV - code coverage report
Current view: top level - libreoffice/xmloff/source/style - xmlbahdl.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 282 417 67.6 %
Date: 2012-12-17 Functions: 75 94 79.8 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10