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 31*cdf0e10cSrcweir #include <tools/debug.hxx> 32*cdf0e10cSrcweir #include <com/sun/star/document/XEventsSupplier.hpp> 33*cdf0e10cSrcweir #include <com/sun/star/container/XNameReplace.hpp> 34*cdf0e10cSrcweir #include <com/sun/star/presentation/AnimationSpeed.hpp> 35*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp> 36*cdf0e10cSrcweir #include <com/sun/star/xml/sax/XAttributeList.hpp> 37*cdf0e10cSrcweir #include <com/sun/star/presentation/ClickAction.hpp> 38*cdf0e10cSrcweir #include <tools/urlobj.hxx> 39*cdf0e10cSrcweir #include <comphelper/extract.hxx> 40*cdf0e10cSrcweir #include <xmloff/xmltoken.hxx> 41*cdf0e10cSrcweir #include <xmloff/xmlimp.hxx> 42*cdf0e10cSrcweir #include "xmloff/xmlnmspe.hxx" 43*cdf0e10cSrcweir #include <xmloff/xmluconv.hxx> 44*cdf0e10cSrcweir #include <xmloff/nmspmap.hxx> 45*cdf0e10cSrcweir #include "eventimp.hxx" 46*cdf0e10cSrcweir #include "anim.hxx" 47*cdf0e10cSrcweir 48*cdf0e10cSrcweir using ::rtl::OUString; 49*cdf0e10cSrcweir using ::rtl::OUStringBuffer; 50*cdf0e10cSrcweir 51*cdf0e10cSrcweir using namespace ::std; 52*cdf0e10cSrcweir using namespace ::cppu; 53*cdf0e10cSrcweir using namespace ::com::sun::star; 54*cdf0e10cSrcweir using namespace ::com::sun::star::xml; 55*cdf0e10cSrcweir using namespace ::com::sun::star::xml::sax; 56*cdf0e10cSrcweir using namespace ::com::sun::star::uno; 57*cdf0e10cSrcweir using namespace ::com::sun::star::drawing; 58*cdf0e10cSrcweir using namespace ::com::sun::star::beans; 59*cdf0e10cSrcweir using namespace ::com::sun::star::lang; 60*cdf0e10cSrcweir using namespace ::com::sun::star::document; 61*cdf0e10cSrcweir using namespace ::com::sun::star::container; 62*cdf0e10cSrcweir using namespace ::com::sun::star::presentation; 63*cdf0e10cSrcweir using namespace ::xmloff::token; 64*cdf0e10cSrcweir 65*cdf0e10cSrcweir /////////////////////////////////////////////////////////////////////// 66*cdf0e10cSrcweir 67*cdf0e10cSrcweir SvXMLEnumMapEntry __READONLY_DATA aXML_EventActions_EnumMap[] = 68*cdf0e10cSrcweir { 69*cdf0e10cSrcweir { XML_NONE, ClickAction_NONE }, 70*cdf0e10cSrcweir { XML_PREVIOUS_PAGE, ClickAction_PREVPAGE }, 71*cdf0e10cSrcweir { XML_NEXT_PAGE, ClickAction_NEXTPAGE }, 72*cdf0e10cSrcweir { XML_FIRST_PAGE, ClickAction_FIRSTPAGE }, 73*cdf0e10cSrcweir { XML_LAST_PAGE, ClickAction_LASTPAGE }, 74*cdf0e10cSrcweir { XML_HIDE, ClickAction_INVISIBLE }, 75*cdf0e10cSrcweir { XML_STOP, ClickAction_STOPPRESENTATION }, 76*cdf0e10cSrcweir { XML_EXECUTE, ClickAction_PROGRAM }, 77*cdf0e10cSrcweir { XML_SHOW, ClickAction_BOOKMARK }, 78*cdf0e10cSrcweir { XML_SHOW, ClickAction_DOCUMENT }, 79*cdf0e10cSrcweir { XML_EXECUTE_MACRO, ClickAction_MACRO }, 80*cdf0e10cSrcweir { XML_VERB, ClickAction_VERB }, 81*cdf0e10cSrcweir { XML_FADE_OUT, ClickAction_VANISH }, 82*cdf0e10cSrcweir { XML_SOUND, ClickAction_SOUND }, 83*cdf0e10cSrcweir { XML_TOKEN_INVALID, 0 } 84*cdf0e10cSrcweir }; 85*cdf0e10cSrcweir 86*cdf0e10cSrcweir /////////////////////////////////////////////////////////////////////// 87*cdf0e10cSrcweir 88*cdf0e10cSrcweir class SdXMLEventContext : public SvXMLImportContext 89*cdf0e10cSrcweir { 90*cdf0e10cSrcweir private: 91*cdf0e10cSrcweir com::sun::star::uno::Reference< com::sun::star::drawing::XShape > mxShape; 92*cdf0e10cSrcweir 93*cdf0e10cSrcweir public: 94*cdf0e10cSrcweir TYPEINFO(); 95*cdf0e10cSrcweir 96*cdf0e10cSrcweir SdXMLEventContext( SvXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLocalName, const Reference< XAttributeList>& xAttrList, const Reference< XShape >& rxShape ); 97*cdf0e10cSrcweir virtual ~SdXMLEventContext(); 98*cdf0e10cSrcweir 99*cdf0e10cSrcweir virtual SvXMLImportContext * CreateChildContext( sal_uInt16 nPrefix, const OUString& rLocalName, const Reference< XAttributeList>& xAttrList ); 100*cdf0e10cSrcweir virtual void EndElement(); 101*cdf0e10cSrcweir 102*cdf0e10cSrcweir sal_Bool mbValid; 103*cdf0e10cSrcweir sal_Bool mbScript; 104*cdf0e10cSrcweir #ifdef ISSUE66550_HLINK_FOR_SHAPES 105*cdf0e10cSrcweir sal_Bool mbActionEvent; 106*cdf0e10cSrcweir #endif 107*cdf0e10cSrcweir ClickAction meClickAction; 108*cdf0e10cSrcweir XMLEffect meEffect; 109*cdf0e10cSrcweir XMLEffectDirection meDirection; 110*cdf0e10cSrcweir sal_Int16 mnStartScale; 111*cdf0e10cSrcweir AnimationSpeed meSpeed; 112*cdf0e10cSrcweir sal_Int32 mnVerb; 113*cdf0e10cSrcweir OUString msSoundURL; 114*cdf0e10cSrcweir sal_Bool mbPlayFull; 115*cdf0e10cSrcweir OUString msMacroName; 116*cdf0e10cSrcweir OUString msBookmark; 117*cdf0e10cSrcweir OUString msLanguage; 118*cdf0e10cSrcweir #ifdef ISSUE66550_HLINK_FOR_SHAPES 119*cdf0e10cSrcweir OUString msHyperURL; 120*cdf0e10cSrcweir #endif 121*cdf0e10cSrcweir }; 122*cdf0e10cSrcweir 123*cdf0e10cSrcweir /////////////////////////////////////////////////////////////////////// 124*cdf0e10cSrcweir 125*cdf0e10cSrcweir class XMLEventSoundContext : public SvXMLImportContext 126*cdf0e10cSrcweir { 127*cdf0e10cSrcweir SdXMLEventContext* mpParent; 128*cdf0e10cSrcweir 129*cdf0e10cSrcweir public: 130*cdf0e10cSrcweir TYPEINFO(); 131*cdf0e10cSrcweir 132*cdf0e10cSrcweir XMLEventSoundContext( SvXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLocalName, const Reference< XAttributeList >& xAttrList, SdXMLEventContext* pParent ); 133*cdf0e10cSrcweir virtual ~XMLEventSoundContext(); 134*cdf0e10cSrcweir }; 135*cdf0e10cSrcweir 136*cdf0e10cSrcweir TYPEINIT1( XMLEventSoundContext, SvXMLImportContext ); 137*cdf0e10cSrcweir 138*cdf0e10cSrcweir XMLEventSoundContext::XMLEventSoundContext( SvXMLImport& rImp, sal_uInt16 nPrfx, const OUString& rLocalName, const Reference< XAttributeList >& xAttrList, SdXMLEventContext* pParent ) 139*cdf0e10cSrcweir : SvXMLImportContext( rImp, nPrfx, rLocalName ), mpParent( pParent ) 140*cdf0e10cSrcweir { 141*cdf0e10cSrcweir if( mpParent && nPrfx == XML_NAMESPACE_PRESENTATION && IsXMLToken( rLocalName, XML_SOUND ) ) 142*cdf0e10cSrcweir { 143*cdf0e10cSrcweir const sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; 144*cdf0e10cSrcweir for(sal_Int16 i=0; i < nAttrCount; i++) 145*cdf0e10cSrcweir { 146*cdf0e10cSrcweir OUString sAttrName = xAttrList->getNameByIndex( i ); 147*cdf0e10cSrcweir OUString aAttrLocalName; 148*cdf0e10cSrcweir sal_uInt16 nAttrPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aAttrLocalName ); 149*cdf0e10cSrcweir OUString sValue = xAttrList->getValueByIndex( i ); 150*cdf0e10cSrcweir 151*cdf0e10cSrcweir switch( nAttrPrefix ) 152*cdf0e10cSrcweir { 153*cdf0e10cSrcweir case XML_NAMESPACE_XLINK: 154*cdf0e10cSrcweir if( IsXMLToken( aAttrLocalName, XML_HREF ) ) 155*cdf0e10cSrcweir { 156*cdf0e10cSrcweir mpParent->msSoundURL = rImp.GetAbsoluteReference(sValue); 157*cdf0e10cSrcweir } 158*cdf0e10cSrcweir break; 159*cdf0e10cSrcweir case XML_NAMESPACE_PRESENTATION: 160*cdf0e10cSrcweir if( IsXMLToken( aAttrLocalName, XML_PLAY_FULL ) ) 161*cdf0e10cSrcweir { 162*cdf0e10cSrcweir mpParent->mbPlayFull = IsXMLToken( sValue, XML_TRUE ); 163*cdf0e10cSrcweir } 164*cdf0e10cSrcweir } 165*cdf0e10cSrcweir } 166*cdf0e10cSrcweir } 167*cdf0e10cSrcweir } 168*cdf0e10cSrcweir 169*cdf0e10cSrcweir XMLEventSoundContext::~XMLEventSoundContext() 170*cdf0e10cSrcweir { 171*cdf0e10cSrcweir } 172*cdf0e10cSrcweir 173*cdf0e10cSrcweir /////////////////////////////////////////////////////////////////////// 174*cdf0e10cSrcweir 175*cdf0e10cSrcweir TYPEINIT1( SdXMLEventContext, SvXMLImportContext ); 176*cdf0e10cSrcweir 177*cdf0e10cSrcweir SdXMLEventContext::SdXMLEventContext( SvXMLImport& rImp, sal_uInt16 nPrfx, const OUString& rLocalName, const Reference< XAttributeList >& xAttrList, const Reference< XShape >& rxShape ) 178*cdf0e10cSrcweir : SvXMLImportContext(rImp, nPrfx, rLocalName), 179*cdf0e10cSrcweir #ifdef ISSUE66550_HLINK_FOR_SHAPES 180*cdf0e10cSrcweir mxShape( rxShape ), mbScript( sal_False ), mbActionEvent( sal_False ), meClickAction( ClickAction_NONE ), 181*cdf0e10cSrcweir #else 182*cdf0e10cSrcweir mxShape( rxShape ), mbScript( sal_False ), meClickAction( ClickAction_NONE ), 183*cdf0e10cSrcweir #endif 184*cdf0e10cSrcweir meEffect( EK_none ), meDirection( ED_none ), mnStartScale( 100 ), 185*cdf0e10cSrcweir meSpeed( AnimationSpeed_MEDIUM ), mnVerb(0), mbPlayFull( sal_False ) 186*cdf0e10cSrcweir { 187*cdf0e10cSrcweir static const OUString sXMLClickName( RTL_CONSTASCII_USTRINGPARAM( "click" ) ); 188*cdf0e10cSrcweir #ifdef ISSUE66550_HLINK_FOR_SHAPES 189*cdf0e10cSrcweir static const OUString sXMLActionName( RTL_CONSTASCII_USTRINGPARAM( "action" ) ); 190*cdf0e10cSrcweir #endif 191*cdf0e10cSrcweir 192*cdf0e10cSrcweir if( nPrfx == XML_NAMESPACE_PRESENTATION && IsXMLToken( rLocalName, XML_EVENT_LISTENER ) ) 193*cdf0e10cSrcweir { 194*cdf0e10cSrcweir mbValid = sal_True; 195*cdf0e10cSrcweir } 196*cdf0e10cSrcweir else if( nPrfx == XML_NAMESPACE_SCRIPT && IsXMLToken( rLocalName, XML_EVENT_LISTENER ) ) 197*cdf0e10cSrcweir { 198*cdf0e10cSrcweir mbScript = sal_True; 199*cdf0e10cSrcweir mbValid = sal_True; 200*cdf0e10cSrcweir } 201*cdf0e10cSrcweir else 202*cdf0e10cSrcweir { 203*cdf0e10cSrcweir return; 204*cdf0e10cSrcweir } 205*cdf0e10cSrcweir 206*cdf0e10cSrcweir // read attributes 207*cdf0e10cSrcweir OUString sEventName; 208*cdf0e10cSrcweir const sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; 209*cdf0e10cSrcweir for(sal_Int16 i=0; (i < nAttrCount) && mbValid; i++) 210*cdf0e10cSrcweir { 211*cdf0e10cSrcweir OUString sAttrName = xAttrList->getNameByIndex( i ); 212*cdf0e10cSrcweir OUString aAttrLocalName; 213*cdf0e10cSrcweir sal_uInt16 nAttrPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aAttrLocalName ); 214*cdf0e10cSrcweir OUString sValue = xAttrList->getValueByIndex( i ); 215*cdf0e10cSrcweir 216*cdf0e10cSrcweir switch( nAttrPrefix ) 217*cdf0e10cSrcweir { 218*cdf0e10cSrcweir case XML_NAMESPACE_PRESENTATION: 219*cdf0e10cSrcweir if( IsXMLToken( aAttrLocalName, XML_ACTION ) ) 220*cdf0e10cSrcweir { 221*cdf0e10cSrcweir sal_uInt16 eEnum; 222*cdf0e10cSrcweir if( SvXMLUnitConverter::convertEnum( eEnum, sValue, aXML_EventActions_EnumMap ) ) 223*cdf0e10cSrcweir meClickAction = (ClickAction)eEnum; 224*cdf0e10cSrcweir } 225*cdf0e10cSrcweir if( IsXMLToken( aAttrLocalName, XML_EFFECT ) ) 226*cdf0e10cSrcweir { 227*cdf0e10cSrcweir sal_uInt16 eEnum; 228*cdf0e10cSrcweir if( SvXMLUnitConverter::convertEnum( eEnum, sValue, aXML_AnimationEffect_EnumMap ) ) 229*cdf0e10cSrcweir meEffect = (XMLEffect)eEnum; 230*cdf0e10cSrcweir } 231*cdf0e10cSrcweir else if( IsXMLToken( aAttrLocalName, XML_DIRECTION ) ) 232*cdf0e10cSrcweir { 233*cdf0e10cSrcweir sal_uInt16 eEnum; 234*cdf0e10cSrcweir if( SvXMLUnitConverter::convertEnum( eEnum, sValue, aXML_AnimationDirection_EnumMap ) ) 235*cdf0e10cSrcweir meDirection = (XMLEffectDirection)eEnum; 236*cdf0e10cSrcweir } 237*cdf0e10cSrcweir else if( IsXMLToken( aAttrLocalName, XML_START_SCALE ) ) 238*cdf0e10cSrcweir { 239*cdf0e10cSrcweir sal_Int32 nScale; 240*cdf0e10cSrcweir if( SvXMLUnitConverter::convertPercent( nScale, sValue ) ) 241*cdf0e10cSrcweir mnStartScale = (sal_Int16)nScale; 242*cdf0e10cSrcweir } 243*cdf0e10cSrcweir else if( IsXMLToken( aAttrLocalName, XML_SPEED ) ) 244*cdf0e10cSrcweir { 245*cdf0e10cSrcweir sal_uInt16 eEnum; 246*cdf0e10cSrcweir if( SvXMLUnitConverter::convertEnum( eEnum, sValue, aXML_AnimationSpeed_EnumMap ) ) 247*cdf0e10cSrcweir meSpeed = (AnimationSpeed)eEnum; 248*cdf0e10cSrcweir } 249*cdf0e10cSrcweir else if( IsXMLToken( aAttrLocalName, XML_VERB ) ) 250*cdf0e10cSrcweir { 251*cdf0e10cSrcweir SvXMLUnitConverter::convertNumber( mnVerb, sValue ); 252*cdf0e10cSrcweir } 253*cdf0e10cSrcweir break; 254*cdf0e10cSrcweir 255*cdf0e10cSrcweir case XML_NAMESPACE_SCRIPT: 256*cdf0e10cSrcweir if( IsXMLToken( aAttrLocalName, XML_EVENT_NAME ) ) 257*cdf0e10cSrcweir { 258*cdf0e10cSrcweir sEventName = sValue; 259*cdf0e10cSrcweir sal_uInt16 nScriptPrefix = 260*cdf0e10cSrcweir GetImport().GetNamespaceMap().GetKeyByAttrName( sValue, &sEventName ); 261*cdf0e10cSrcweir #ifdef ISSUE66550_HLINK_FOR_SHAPES 262*cdf0e10cSrcweir mbValid = XML_NAMESPACE_DOM == nScriptPrefix && ( sEventName == sXMLClickName || sEventName == sXMLActionName ); 263*cdf0e10cSrcweir mbActionEvent = mbValid && (sEventName == sXMLActionName); 264*cdf0e10cSrcweir #else 265*cdf0e10cSrcweir mbValid = XML_NAMESPACE_DOM == nScriptPrefix && sEventName == sXMLClickName; 266*cdf0e10cSrcweir #endif 267*cdf0e10cSrcweir } 268*cdf0e10cSrcweir else if( IsXMLToken( aAttrLocalName, XML_LANGUAGE ) ) 269*cdf0e10cSrcweir { 270*cdf0e10cSrcweir // language is not evaluated! 271*cdf0e10cSrcweir OUString aScriptLanguage; 272*cdf0e10cSrcweir msLanguage = sValue; 273*cdf0e10cSrcweir sal_uInt16 nScriptPrefix = rImp.GetNamespaceMap(). 274*cdf0e10cSrcweir GetKeyByAttrName( msLanguage, &aScriptLanguage ); 275*cdf0e10cSrcweir if( XML_NAMESPACE_OOO == nScriptPrefix ) 276*cdf0e10cSrcweir msLanguage = aScriptLanguage; 277*cdf0e10cSrcweir } 278*cdf0e10cSrcweir else if( IsXMLToken( aAttrLocalName, XML_MACRO_NAME ) ) 279*cdf0e10cSrcweir { 280*cdf0e10cSrcweir msMacroName = sValue; 281*cdf0e10cSrcweir } 282*cdf0e10cSrcweir // else if( IsXMLToken( aLocalName, XML_LIBRARY ) ) 283*cdf0e10cSrcweir // { 284*cdf0e10cSrcweir // msLibrary = sValue; 285*cdf0e10cSrcweir // } 286*cdf0e10cSrcweir break; 287*cdf0e10cSrcweir 288*cdf0e10cSrcweir case XML_NAMESPACE_XLINK: 289*cdf0e10cSrcweir if( IsXMLToken( aAttrLocalName, XML_HREF ) ) 290*cdf0e10cSrcweir { 291*cdf0e10cSrcweir if ( mbScript ) 292*cdf0e10cSrcweir { 293*cdf0e10cSrcweir msMacroName = sValue; 294*cdf0e10cSrcweir } 295*cdf0e10cSrcweir #ifdef ISSUE66550_HLINK_FOR_SHAPES 296*cdf0e10cSrcweir else if ( mbActionEvent ) 297*cdf0e10cSrcweir { 298*cdf0e10cSrcweir msHyperURL = sValue; 299*cdf0e10cSrcweir } 300*cdf0e10cSrcweir #endif 301*cdf0e10cSrcweir else 302*cdf0e10cSrcweir { 303*cdf0e10cSrcweir const rtl::OUString &rTmp = 304*cdf0e10cSrcweir rImp.GetAbsoluteReference(sValue); 305*cdf0e10cSrcweir INetURLObject::translateToInternal( rTmp, msBookmark, 306*cdf0e10cSrcweir INetURLObject::DECODE_UNAMBIGUOUS, 307*cdf0e10cSrcweir RTL_TEXTENCODING_UTF8 ); 308*cdf0e10cSrcweir } 309*cdf0e10cSrcweir } 310*cdf0e10cSrcweir break; 311*cdf0e10cSrcweir } 312*cdf0e10cSrcweir } 313*cdf0e10cSrcweir 314*cdf0e10cSrcweir if( mbValid ) 315*cdf0e10cSrcweir mbValid = sEventName.getLength() != 0; 316*cdf0e10cSrcweir } 317*cdf0e10cSrcweir 318*cdf0e10cSrcweir SdXMLEventContext::~SdXMLEventContext() 319*cdf0e10cSrcweir { 320*cdf0e10cSrcweir } 321*cdf0e10cSrcweir 322*cdf0e10cSrcweir SvXMLImportContext * SdXMLEventContext::CreateChildContext( sal_uInt16 nPrefix, const OUString& rLocalName, const Reference< XAttributeList>& xAttrList ) 323*cdf0e10cSrcweir { 324*cdf0e10cSrcweir return new XMLEventSoundContext( GetImport(), nPrefix, rLocalName, xAttrList, this ); 325*cdf0e10cSrcweir } 326*cdf0e10cSrcweir 327*cdf0e10cSrcweir void SdXMLEventContext::EndElement() 328*cdf0e10cSrcweir { 329*cdf0e10cSrcweir if( !mbValid ) 330*cdf0e10cSrcweir return; 331*cdf0e10cSrcweir 332*cdf0e10cSrcweir do 333*cdf0e10cSrcweir { 334*cdf0e10cSrcweir Reference< XEventsSupplier > xEventsSupplier( mxShape, UNO_QUERY ); 335*cdf0e10cSrcweir if( !xEventsSupplier.is() ) 336*cdf0e10cSrcweir break; 337*cdf0e10cSrcweir 338*cdf0e10cSrcweir Reference< XNameReplace > xEvents( xEventsSupplier->getEvents() ); 339*cdf0e10cSrcweir DBG_ASSERT( xEvents.is(), "XEventsSupplier::getEvents() returned NULL" ); 340*cdf0e10cSrcweir if( !xEvents.is() ) 341*cdf0e10cSrcweir break; 342*cdf0e10cSrcweir 343*cdf0e10cSrcweir OUString sAPIEventName; 344*cdf0e10cSrcweir uno::Sequence< beans::PropertyValue > aProperties; 345*cdf0e10cSrcweir 346*cdf0e10cSrcweir #ifdef ISSUE66550_HLINK_FOR_SHAPES 347*cdf0e10cSrcweir if( mbActionEvent ) 348*cdf0e10cSrcweir { 349*cdf0e10cSrcweir sAPIEventName = OUString( RTL_CONSTASCII_USTRINGPARAM( "OnAction" ) ); 350*cdf0e10cSrcweir aProperties.realloc( 2 ); 351*cdf0e10cSrcweir beans::PropertyValue* pProperty = aProperties.getArray(); 352*cdf0e10cSrcweir 353*cdf0e10cSrcweir pProperty->Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "EventType" ) ); 354*cdf0e10cSrcweir pProperty->Handle = -1; 355*cdf0e10cSrcweir pProperty->Value <<= OUString( RTL_CONSTASCII_USTRINGPARAM( "Action" ) ); 356*cdf0e10cSrcweir pProperty->State = beans::PropertyState_DIRECT_VALUE; 357*cdf0e10cSrcweir ++pProperty; 358*cdf0e10cSrcweir pProperty->Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "URL" ) ); 359*cdf0e10cSrcweir pProperty->Handle = -1; 360*cdf0e10cSrcweir pProperty->Value <<= msHyperURL; 361*cdf0e10cSrcweir pProperty->State = beans::PropertyState_DIRECT_VALUE; 362*cdf0e10cSrcweir } 363*cdf0e10cSrcweir else 364*cdf0e10cSrcweir #endif 365*cdf0e10cSrcweir { 366*cdf0e10cSrcweir sAPIEventName = OUString( RTL_CONSTASCII_USTRINGPARAM( "OnClick" ) ); 367*cdf0e10cSrcweir 368*cdf0e10cSrcweir if( mbScript ) 369*cdf0e10cSrcweir meClickAction = ClickAction_MACRO; 370*cdf0e10cSrcweir 371*cdf0e10cSrcweir sal_Int32 nPropertyCount = 2; 372*cdf0e10cSrcweir switch( meClickAction ) 373*cdf0e10cSrcweir { 374*cdf0e10cSrcweir case ClickAction_NONE: 375*cdf0e10cSrcweir case ClickAction_PREVPAGE: 376*cdf0e10cSrcweir case ClickAction_NEXTPAGE: 377*cdf0e10cSrcweir case ClickAction_FIRSTPAGE: 378*cdf0e10cSrcweir case ClickAction_LASTPAGE: 379*cdf0e10cSrcweir case ClickAction_INVISIBLE: 380*cdf0e10cSrcweir case ClickAction_STOPPRESENTATION: 381*cdf0e10cSrcweir break; 382*cdf0e10cSrcweir case ClickAction_PROGRAM: 383*cdf0e10cSrcweir case ClickAction_VERB: 384*cdf0e10cSrcweir case ClickAction_BOOKMARK: 385*cdf0e10cSrcweir case ClickAction_DOCUMENT: 386*cdf0e10cSrcweir nPropertyCount += 1; 387*cdf0e10cSrcweir break; 388*cdf0e10cSrcweir case ClickAction_MACRO: 389*cdf0e10cSrcweir if ( msLanguage.equalsIgnoreAsciiCaseAscii("starbasic") ) 390*cdf0e10cSrcweir nPropertyCount += 1; 391*cdf0e10cSrcweir break; 392*cdf0e10cSrcweir 393*cdf0e10cSrcweir case ClickAction_SOUND: 394*cdf0e10cSrcweir nPropertyCount += 2; 395*cdf0e10cSrcweir break; 396*cdf0e10cSrcweir 397*cdf0e10cSrcweir case ClickAction_VANISH: 398*cdf0e10cSrcweir nPropertyCount += 4; 399*cdf0e10cSrcweir break; 400*cdf0e10cSrcweir default: 401*cdf0e10cSrcweir break; 402*cdf0e10cSrcweir } 403*cdf0e10cSrcweir 404*cdf0e10cSrcweir aProperties.realloc( nPropertyCount ); 405*cdf0e10cSrcweir beans::PropertyValue* pProperties = aProperties.getArray(); 406*cdf0e10cSrcweir 407*cdf0e10cSrcweir if( ClickAction_MACRO == meClickAction ) 408*cdf0e10cSrcweir { 409*cdf0e10cSrcweir if ( msLanguage.equalsIgnoreAsciiCaseAscii("starbasic") ) 410*cdf0e10cSrcweir { 411*cdf0e10cSrcweir OUString sLibrary; 412*cdf0e10cSrcweir const OUString& rApp = GetXMLToken( XML_APPLICATION ); 413*cdf0e10cSrcweir const OUString& rDoc = GetXMLToken( XML_DOCUMENT ); 414*cdf0e10cSrcweir if( msMacroName.getLength() > rApp.getLength()+1 && 415*cdf0e10cSrcweir msMacroName.copy(0,rApp.getLength()).equalsIgnoreAsciiCase( rApp ) && 416*cdf0e10cSrcweir ':' == msMacroName[rApp.getLength()] ) 417*cdf0e10cSrcweir { 418*cdf0e10cSrcweir sLibrary = OUString(RTL_CONSTASCII_USTRINGPARAM("StarOffice")); 419*cdf0e10cSrcweir msMacroName = msMacroName.copy( rApp.getLength()+1 ); 420*cdf0e10cSrcweir } 421*cdf0e10cSrcweir else if( msMacroName.getLength() > rDoc.getLength()+1 && 422*cdf0e10cSrcweir msMacroName.copy(0,rDoc.getLength()).equalsIgnoreAsciiCase( rDoc ) && 423*cdf0e10cSrcweir ':' == msMacroName[rDoc.getLength()] ) 424*cdf0e10cSrcweir { 425*cdf0e10cSrcweir sLibrary = rDoc; 426*cdf0e10cSrcweir msMacroName = msMacroName.copy( rDoc.getLength()+1 ); 427*cdf0e10cSrcweir } 428*cdf0e10cSrcweir 429*cdf0e10cSrcweir pProperties->Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "EventType" ) ); 430*cdf0e10cSrcweir pProperties->Handle = -1; 431*cdf0e10cSrcweir pProperties->Value <<= OUString( RTL_CONSTASCII_USTRINGPARAM("StarBasic") ); 432*cdf0e10cSrcweir pProperties->State = beans::PropertyState_DIRECT_VALUE; 433*cdf0e10cSrcweir pProperties++; 434*cdf0e10cSrcweir 435*cdf0e10cSrcweir pProperties->Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "MacroName" ) ); 436*cdf0e10cSrcweir pProperties->Handle = -1; 437*cdf0e10cSrcweir pProperties->Value <<= msMacroName; 438*cdf0e10cSrcweir pProperties->State = beans::PropertyState_DIRECT_VALUE; 439*cdf0e10cSrcweir pProperties++; 440*cdf0e10cSrcweir 441*cdf0e10cSrcweir pProperties->Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "Library" ) ); 442*cdf0e10cSrcweir pProperties->Handle = -1; 443*cdf0e10cSrcweir pProperties->Value <<= sLibrary; 444*cdf0e10cSrcweir pProperties->State = beans::PropertyState_DIRECT_VALUE; 445*cdf0e10cSrcweir } 446*cdf0e10cSrcweir else 447*cdf0e10cSrcweir { 448*cdf0e10cSrcweir pProperties->Name = 449*cdf0e10cSrcweir OUString( RTL_CONSTASCII_USTRINGPARAM( "EventType" ) ); 450*cdf0e10cSrcweir pProperties->Handle = -1; 451*cdf0e10cSrcweir pProperties->Value <<= OUString( 452*cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM("Script") ); 453*cdf0e10cSrcweir pProperties->State = beans::PropertyState_DIRECT_VALUE; 454*cdf0e10cSrcweir pProperties++; 455*cdf0e10cSrcweir 456*cdf0e10cSrcweir pProperties->Name = OUString( 457*cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM( "Script" ) ); 458*cdf0e10cSrcweir pProperties->Handle = -1; 459*cdf0e10cSrcweir pProperties->Value <<= msMacroName; 460*cdf0e10cSrcweir pProperties->State = beans::PropertyState_DIRECT_VALUE; 461*cdf0e10cSrcweir } 462*cdf0e10cSrcweir } 463*cdf0e10cSrcweir else 464*cdf0e10cSrcweir { 465*cdf0e10cSrcweir pProperties->Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "EventType" ) ); 466*cdf0e10cSrcweir pProperties->Handle = -1; 467*cdf0e10cSrcweir pProperties->Value <<= OUString( RTL_CONSTASCII_USTRINGPARAM("Presentation") ); 468*cdf0e10cSrcweir pProperties->State = beans::PropertyState_DIRECT_VALUE; 469*cdf0e10cSrcweir pProperties++; 470*cdf0e10cSrcweir 471*cdf0e10cSrcweir // ClickAction_BOOKMARK and ClickAction_DOCUMENT share the same xml event 472*cdf0e10cSrcweir // so check here if its realy a bookmark or maybe a document 473*cdf0e10cSrcweir if( meClickAction == ClickAction_BOOKMARK ) 474*cdf0e10cSrcweir { 475*cdf0e10cSrcweir if( msBookmark.compareToAscii( "#", 1 ) != 0 ) 476*cdf0e10cSrcweir meClickAction = ClickAction_DOCUMENT; 477*cdf0e10cSrcweir } 478*cdf0e10cSrcweir 479*cdf0e10cSrcweir pProperties->Name = OUString( RTL_CONSTASCII_USTRINGPARAM("ClickAction") ); 480*cdf0e10cSrcweir pProperties->Handle = -1; 481*cdf0e10cSrcweir pProperties->Value <<= meClickAction; 482*cdf0e10cSrcweir pProperties->State = beans::PropertyState_DIRECT_VALUE; 483*cdf0e10cSrcweir pProperties++; 484*cdf0e10cSrcweir 485*cdf0e10cSrcweir switch( meClickAction ) 486*cdf0e10cSrcweir { 487*cdf0e10cSrcweir case ClickAction_NONE: 488*cdf0e10cSrcweir case ClickAction_PREVPAGE: 489*cdf0e10cSrcweir case ClickAction_NEXTPAGE: 490*cdf0e10cSrcweir case ClickAction_FIRSTPAGE: 491*cdf0e10cSrcweir case ClickAction_LASTPAGE: 492*cdf0e10cSrcweir case ClickAction_INVISIBLE: 493*cdf0e10cSrcweir case ClickAction_STOPPRESENTATION: 494*cdf0e10cSrcweir break; 495*cdf0e10cSrcweir 496*cdf0e10cSrcweir case ClickAction_BOOKMARK: 497*cdf0e10cSrcweir msBookmark = msBookmark.copy(1); 498*cdf0e10cSrcweir 499*cdf0e10cSrcweir // Note: no break here!!! 500*cdf0e10cSrcweir 501*cdf0e10cSrcweir case ClickAction_DOCUMENT: 502*cdf0e10cSrcweir case ClickAction_PROGRAM: 503*cdf0e10cSrcweir pProperties->Name = OUString( RTL_CONSTASCII_USTRINGPARAM("Bookmark") ); 504*cdf0e10cSrcweir pProperties->Handle = -1; 505*cdf0e10cSrcweir pProperties->Value <<= msBookmark; 506*cdf0e10cSrcweir pProperties->State = beans::PropertyState_DIRECT_VALUE; 507*cdf0e10cSrcweir break; 508*cdf0e10cSrcweir 509*cdf0e10cSrcweir case ClickAction_VANISH: 510*cdf0e10cSrcweir pProperties->Name = OUString( RTL_CONSTASCII_USTRINGPARAM("Effect") ); 511*cdf0e10cSrcweir pProperties->Handle = -1; 512*cdf0e10cSrcweir pProperties->Value <<= ImplSdXMLgetEffect( meEffect, meDirection, mnStartScale, sal_True ); 513*cdf0e10cSrcweir pProperties->State = beans::PropertyState_DIRECT_VALUE; 514*cdf0e10cSrcweir pProperties++; 515*cdf0e10cSrcweir 516*cdf0e10cSrcweir pProperties->Name = OUString( RTL_CONSTASCII_USTRINGPARAM("Speed") ); 517*cdf0e10cSrcweir pProperties->Handle = -1; 518*cdf0e10cSrcweir pProperties->Value <<= meSpeed; 519*cdf0e10cSrcweir pProperties->State = beans::PropertyState_DIRECT_VALUE; 520*cdf0e10cSrcweir pProperties++; 521*cdf0e10cSrcweir 522*cdf0e10cSrcweir // NOTE: no break here!!! 523*cdf0e10cSrcweir 524*cdf0e10cSrcweir case ClickAction_SOUND: 525*cdf0e10cSrcweir pProperties->Name = OUString( RTL_CONSTASCII_USTRINGPARAM("SoundURL") ); 526*cdf0e10cSrcweir pProperties->Handle = -1; 527*cdf0e10cSrcweir pProperties->Value <<= msSoundURL; 528*cdf0e10cSrcweir pProperties->State = beans::PropertyState_DIRECT_VALUE; 529*cdf0e10cSrcweir pProperties++; 530*cdf0e10cSrcweir 531*cdf0e10cSrcweir pProperties->Name = OUString( RTL_CONSTASCII_USTRINGPARAM("PlayFull") ); 532*cdf0e10cSrcweir pProperties->Handle = -1; 533*cdf0e10cSrcweir pProperties->Value = ::cppu::bool2any(mbPlayFull); 534*cdf0e10cSrcweir pProperties->State = beans::PropertyState_DIRECT_VALUE; 535*cdf0e10cSrcweir break; 536*cdf0e10cSrcweir 537*cdf0e10cSrcweir case ClickAction_VERB: 538*cdf0e10cSrcweir pProperties->Name = OUString( RTL_CONSTASCII_USTRINGPARAM("Verb") ); 539*cdf0e10cSrcweir pProperties->Handle = -1; 540*cdf0e10cSrcweir pProperties->Value <<= mnVerb; 541*cdf0e10cSrcweir pProperties->State = beans::PropertyState_DIRECT_VALUE; 542*cdf0e10cSrcweir break; 543*cdf0e10cSrcweir case ClickAction_MACRO: 544*cdf0e10cSrcweir DBG_ERROR("xmloff::SdXMLEventContext::EndElement(), ClickAction_MACRO must be handled in different if case"); 545*cdf0e10cSrcweir break; 546*cdf0e10cSrcweir default: 547*cdf0e10cSrcweir break; 548*cdf0e10cSrcweir } 549*cdf0e10cSrcweir } 550*cdf0e10cSrcweir } 551*cdf0e10cSrcweir 552*cdf0e10cSrcweir xEvents->replaceByName( sAPIEventName, uno::Any( aProperties ) ); 553*cdf0e10cSrcweir 554*cdf0e10cSrcweir } while(0); 555*cdf0e10cSrcweir } 556*cdf0e10cSrcweir 557*cdf0e10cSrcweir /////////////////////////////////////////////////////////////////////// 558*cdf0e10cSrcweir 559*cdf0e10cSrcweir TYPEINIT1( SdXMLEventsContext, SvXMLImportContext ); 560*cdf0e10cSrcweir 561*cdf0e10cSrcweir SdXMLEventsContext::SdXMLEventsContext( SvXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLocalName, 562*cdf0e10cSrcweir const Reference< XAttributeList>&, const Reference< XShape >& rxShape) 563*cdf0e10cSrcweir : SvXMLImportContext(rImport, nPrfx, rLocalName), mxShape( rxShape ) 564*cdf0e10cSrcweir { 565*cdf0e10cSrcweir } 566*cdf0e10cSrcweir 567*cdf0e10cSrcweir SdXMLEventsContext::~SdXMLEventsContext() 568*cdf0e10cSrcweir { 569*cdf0e10cSrcweir } 570*cdf0e10cSrcweir 571*cdf0e10cSrcweir SvXMLImportContext * SdXMLEventsContext::CreateChildContext( sal_uInt16 nPrfx, const ::rtl::OUString& rLocalName, 572*cdf0e10cSrcweir const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList ) 573*cdf0e10cSrcweir { 574*cdf0e10cSrcweir return new SdXMLEventContext( GetImport(), nPrfx, rLocalName, xAttrList, mxShape ); 575*cdf0e10cSrcweir } 576