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/string.hxx> 31*cdf0e10cSrcweir #include <rtl/ustrbuf.hxx> 32*cdf0e10cSrcweir #include "propimp0.hxx" 33*cdf0e10cSrcweir #include <com/sun/star/drawing/LineDash.hpp> 34*cdf0e10cSrcweir #include <com/sun/star/util/DateTime.hpp> 35*cdf0e10cSrcweir #include <com/sun/star/uno/Any.hxx> 36*cdf0e10cSrcweir #include <xmloff/xmluconv.hxx> 37*cdf0e10cSrcweir #include <xmloff/xmlimp.hxx> 38*cdf0e10cSrcweir 39*cdf0e10cSrcweir using ::rtl::OUString; 40*cdf0e10cSrcweir using ::rtl::OUStringBuffer; 41*cdf0e10cSrcweir 42*cdf0e10cSrcweir using namespace ::com::sun::star; 43*cdf0e10cSrcweir 44*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 45*cdf0e10cSrcweir // implementation of graphic property Stroke 46*cdf0e10cSrcweir 47*cdf0e10cSrcweir 48*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 49*cdf0e10cSrcweir // implementation of presentation page property Change 50*cdf0e10cSrcweir 51*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 52*cdf0e10cSrcweir // implementation of an effect duration property handler 53*cdf0e10cSrcweir 54*cdf0e10cSrcweir 55*cdf0e10cSrcweir XMLDurationPropertyHdl::~XMLDurationPropertyHdl() 56*cdf0e10cSrcweir { 57*cdf0e10cSrcweir } 58*cdf0e10cSrcweir 59*cdf0e10cSrcweir sal_Bool XMLDurationPropertyHdl::importXML( 60*cdf0e10cSrcweir const OUString& rStrImpValue, 61*cdf0e10cSrcweir ::com::sun::star::uno::Any& rValue, 62*cdf0e10cSrcweir const SvXMLUnitConverter& ) const 63*cdf0e10cSrcweir { 64*cdf0e10cSrcweir util::DateTime aTime; 65*cdf0e10cSrcweir SvXMLUnitConverter::convertTime( aTime, rStrImpValue ); 66*cdf0e10cSrcweir 67*cdf0e10cSrcweir const sal_Int32 nSeconds = ( aTime.Hours * 60 + aTime.Minutes ) * 60 + aTime.Seconds; 68*cdf0e10cSrcweir rValue <<= nSeconds; 69*cdf0e10cSrcweir 70*cdf0e10cSrcweir return sal_True; 71*cdf0e10cSrcweir } 72*cdf0e10cSrcweir 73*cdf0e10cSrcweir sal_Bool XMLDurationPropertyHdl::exportXML( 74*cdf0e10cSrcweir OUString& rStrExpValue, 75*cdf0e10cSrcweir const ::com::sun::star::uno::Any& rValue, 76*cdf0e10cSrcweir const SvXMLUnitConverter& ) const 77*cdf0e10cSrcweir { 78*cdf0e10cSrcweir sal_Int32 nVal = 0; 79*cdf0e10cSrcweir 80*cdf0e10cSrcweir if(rValue >>= nVal) 81*cdf0e10cSrcweir { 82*cdf0e10cSrcweir util::DateTime aTime( 0, (sal_uInt16)nVal, 0, 0, 0, 0, 0 ); 83*cdf0e10cSrcweir 84*cdf0e10cSrcweir OUStringBuffer aOut; 85*cdf0e10cSrcweir SvXMLUnitConverter::convertTime( aOut, aTime ); 86*cdf0e10cSrcweir rStrExpValue = aOut.makeStringAndClear(); 87*cdf0e10cSrcweir return sal_True; 88*cdf0e10cSrcweir } 89*cdf0e10cSrcweir 90*cdf0e10cSrcweir return sal_False; 91*cdf0e10cSrcweir } 92*cdf0e10cSrcweir 93*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 94*cdf0e10cSrcweir // implementation of an opacity property handler 95*cdf0e10cSrcweir 96*cdf0e10cSrcweir 97*cdf0e10cSrcweir XMLOpacityPropertyHdl::XMLOpacityPropertyHdl( SvXMLImport* pImport ) 98*cdf0e10cSrcweir : mpImport( pImport ) 99*cdf0e10cSrcweir { 100*cdf0e10cSrcweir } 101*cdf0e10cSrcweir 102*cdf0e10cSrcweir XMLOpacityPropertyHdl::~XMLOpacityPropertyHdl() 103*cdf0e10cSrcweir { 104*cdf0e10cSrcweir } 105*cdf0e10cSrcweir 106*cdf0e10cSrcweir sal_Bool XMLOpacityPropertyHdl::importXML( 107*cdf0e10cSrcweir const OUString& rStrImpValue, 108*cdf0e10cSrcweir ::com::sun::star::uno::Any& rValue, 109*cdf0e10cSrcweir const SvXMLUnitConverter& ) const 110*cdf0e10cSrcweir { 111*cdf0e10cSrcweir sal_Bool bRet = sal_False; 112*cdf0e10cSrcweir sal_Int32 nValue = 0; 113*cdf0e10cSrcweir 114*cdf0e10cSrcweir if( rStrImpValue.indexOf( sal_Unicode('%') ) != -1 ) 115*cdf0e10cSrcweir { 116*cdf0e10cSrcweir if( SvXMLUnitConverter::convertPercent( nValue, rStrImpValue ) ) 117*cdf0e10cSrcweir bRet = sal_True; 118*cdf0e10cSrcweir } 119*cdf0e10cSrcweir else 120*cdf0e10cSrcweir { 121*cdf0e10cSrcweir nValue = sal_Int32( rStrImpValue.toDouble() * 100.0 ); 122*cdf0e10cSrcweir bRet = sal_True; 123*cdf0e10cSrcweir } 124*cdf0e10cSrcweir 125*cdf0e10cSrcweir if( bRet ) 126*cdf0e10cSrcweir { 127*cdf0e10cSrcweir // check ranges 128*cdf0e10cSrcweir if( nValue < 0 ) 129*cdf0e10cSrcweir nValue = 0; 130*cdf0e10cSrcweir if( nValue > 100 ) 131*cdf0e10cSrcweir nValue = 100; 132*cdf0e10cSrcweir 133*cdf0e10cSrcweir // convert xml opacity to api transparency 134*cdf0e10cSrcweir nValue = 100 - nValue; 135*cdf0e10cSrcweir 136*cdf0e10cSrcweir // #i42959# 137*cdf0e10cSrcweir if( mpImport ) 138*cdf0e10cSrcweir { 139*cdf0e10cSrcweir sal_Int32 nUPD, nBuild; 140*cdf0e10cSrcweir if( mpImport->getBuildIds( nUPD, nBuild ) ) 141*cdf0e10cSrcweir { 142*cdf0e10cSrcweir // correct import of documents written prior to StarOffice 8/OOO 2.0 final 143*cdf0e10cSrcweir if( (nUPD == 680) && (nBuild < 8951) ) 144*cdf0e10cSrcweir nValue = 100 - nValue; 145*cdf0e10cSrcweir } 146*cdf0e10cSrcweir } 147*cdf0e10cSrcweir 148*cdf0e10cSrcweir rValue <<= sal_uInt16(nValue); 149*cdf0e10cSrcweir } 150*cdf0e10cSrcweir 151*cdf0e10cSrcweir return bRet; 152*cdf0e10cSrcweir } 153*cdf0e10cSrcweir 154*cdf0e10cSrcweir sal_Bool XMLOpacityPropertyHdl::exportXML( 155*cdf0e10cSrcweir OUString& rStrExpValue, 156*cdf0e10cSrcweir const ::com::sun::star::uno::Any& rValue, 157*cdf0e10cSrcweir const SvXMLUnitConverter& ) const 158*cdf0e10cSrcweir { 159*cdf0e10cSrcweir sal_Bool bRet = sal_False; 160*cdf0e10cSrcweir sal_uInt16 nVal = sal_uInt16(); 161*cdf0e10cSrcweir 162*cdf0e10cSrcweir if( rValue >>= nVal ) 163*cdf0e10cSrcweir { 164*cdf0e10cSrcweir OUStringBuffer aOut; 165*cdf0e10cSrcweir 166*cdf0e10cSrcweir nVal = 100 - nVal; 167*cdf0e10cSrcweir SvXMLUnitConverter::convertPercent( aOut, nVal ); 168*cdf0e10cSrcweir rStrExpValue = aOut.makeStringAndClear(); 169*cdf0e10cSrcweir bRet = sal_True; 170*cdf0e10cSrcweir } 171*cdf0e10cSrcweir 172*cdf0e10cSrcweir return bRet; 173*cdf0e10cSrcweir } 174*cdf0e10cSrcweir 175*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 176*cdf0e10cSrcweir // implementation of an text animation step amount 177*cdf0e10cSrcweir 178*cdf0e10cSrcweir XMLTextAnimationStepPropertyHdl::~XMLTextAnimationStepPropertyHdl() 179*cdf0e10cSrcweir { 180*cdf0e10cSrcweir } 181*cdf0e10cSrcweir 182*cdf0e10cSrcweir sal_Bool XMLTextAnimationStepPropertyHdl::importXML( 183*cdf0e10cSrcweir const OUString& rStrImpValue, 184*cdf0e10cSrcweir ::com::sun::star::uno::Any& rValue, 185*cdf0e10cSrcweir const SvXMLUnitConverter& rUnitConverter ) const 186*cdf0e10cSrcweir { 187*cdf0e10cSrcweir sal_Bool bRet = sal_False; 188*cdf0e10cSrcweir sal_Int32 nValue = 0; 189*cdf0e10cSrcweir 190*cdf0e10cSrcweir const OUString aPX( RTL_CONSTASCII_USTRINGPARAM( "px" ) ); 191*cdf0e10cSrcweir sal_Int32 nPos = rStrImpValue.indexOf( aPX ); 192*cdf0e10cSrcweir if( nPos != -1 ) 193*cdf0e10cSrcweir { 194*cdf0e10cSrcweir if( rUnitConverter.convertNumber( nValue, rStrImpValue.copy( 0, nPos ) ) ) 195*cdf0e10cSrcweir { 196*cdf0e10cSrcweir rValue <<= sal_Int16( -nValue ); 197*cdf0e10cSrcweir bRet = sal_True; 198*cdf0e10cSrcweir } 199*cdf0e10cSrcweir } 200*cdf0e10cSrcweir else 201*cdf0e10cSrcweir { 202*cdf0e10cSrcweir if( rUnitConverter.convertMeasure( nValue, rStrImpValue ) ) 203*cdf0e10cSrcweir { 204*cdf0e10cSrcweir rValue <<= sal_Int16( nValue ); 205*cdf0e10cSrcweir bRet = sal_True; 206*cdf0e10cSrcweir } 207*cdf0e10cSrcweir } 208*cdf0e10cSrcweir 209*cdf0e10cSrcweir return bRet; 210*cdf0e10cSrcweir } 211*cdf0e10cSrcweir 212*cdf0e10cSrcweir sal_Bool XMLTextAnimationStepPropertyHdl::exportXML( 213*cdf0e10cSrcweir OUString& rStrExpValue, 214*cdf0e10cSrcweir const ::com::sun::star::uno::Any& rValue, 215*cdf0e10cSrcweir const SvXMLUnitConverter& rUnitConverter ) const 216*cdf0e10cSrcweir { 217*cdf0e10cSrcweir sal_Bool bRet = sal_False; 218*cdf0e10cSrcweir sal_Int16 nVal = sal_Int16(); 219*cdf0e10cSrcweir 220*cdf0e10cSrcweir if( rValue >>= nVal ) 221*cdf0e10cSrcweir { 222*cdf0e10cSrcweir OUStringBuffer aOut; 223*cdf0e10cSrcweir 224*cdf0e10cSrcweir if( nVal < 0 ) 225*cdf0e10cSrcweir { 226*cdf0e10cSrcweir const OUString aPX( RTL_CONSTASCII_USTRINGPARAM( "px" ) ); 227*cdf0e10cSrcweir rUnitConverter.convertNumber( aOut, (sal_Int32)-nVal ); 228*cdf0e10cSrcweir aOut.append( aPX ); 229*cdf0e10cSrcweir } 230*cdf0e10cSrcweir else 231*cdf0e10cSrcweir { 232*cdf0e10cSrcweir rUnitConverter.convertMeasure( aOut, nVal ); 233*cdf0e10cSrcweir } 234*cdf0e10cSrcweir 235*cdf0e10cSrcweir rStrExpValue = aOut.makeStringAndClear(); 236*cdf0e10cSrcweir bRet = sal_True; 237*cdf0e10cSrcweir } 238*cdf0e10cSrcweir 239*cdf0e10cSrcweir return bRet; 240*cdf0e10cSrcweir } 241*cdf0e10cSrcweir 242*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 243*cdf0e10cSrcweir 244*cdf0e10cSrcweir #include "sdxmlexp_impl.hxx" 245*cdf0e10cSrcweir 246*cdf0e10cSrcweir XMLDateTimeFormatHdl::XMLDateTimeFormatHdl( SvXMLExport* pExport ) 247*cdf0e10cSrcweir : mpExport( pExport ) 248*cdf0e10cSrcweir { 249*cdf0e10cSrcweir } 250*cdf0e10cSrcweir 251*cdf0e10cSrcweir XMLDateTimeFormatHdl::~XMLDateTimeFormatHdl() 252*cdf0e10cSrcweir { 253*cdf0e10cSrcweir } 254*cdf0e10cSrcweir 255*cdf0e10cSrcweir sal_Bool XMLDateTimeFormatHdl::importXML( const rtl::OUString& rStrImpValue, ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& ) const 256*cdf0e10cSrcweir { 257*cdf0e10cSrcweir rValue <<= rStrImpValue; 258*cdf0e10cSrcweir return true; 259*cdf0e10cSrcweir } 260*cdf0e10cSrcweir 261*cdf0e10cSrcweir sal_Bool XMLDateTimeFormatHdl::exportXML( rtl::OUString& rStrExpValue, const ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& ) const 262*cdf0e10cSrcweir { 263*cdf0e10cSrcweir sal_Int32 nNumberFormat = 0; 264*cdf0e10cSrcweir if( mpExport && (rValue >>= nNumberFormat) ) 265*cdf0e10cSrcweir { 266*cdf0e10cSrcweir mpExport->addDataStyle( nNumberFormat ); 267*cdf0e10cSrcweir rStrExpValue = mpExport->getDataStyleName( nNumberFormat ); 268*cdf0e10cSrcweir return sal_True; 269*cdf0e10cSrcweir } 270*cdf0e10cSrcweir 271*cdf0e10cSrcweir return sal_False; 272*cdf0e10cSrcweir } 273