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