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