1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_framework.hxx"
26 
27 #include <framework/fwedllapi.h>
28 #include <stdio.h>
29 
30 //_________________________________________________________________________________________________________________
31 //	my own includes
32 //_________________________________________________________________________________________________________________
33 
34 #include <threadhelp/resetableguard.hxx>
35 #include <xml/eventsdocumenthandler.hxx>
36 #include <macros/debug.hxx>
37 
38 //_________________________________________________________________________________________________________________
39 //	interface includes
40 //_________________________________________________________________________________________________________________
41 
42 #ifndef __COM_SUN_STAR_XML_SAX_XEXTENDEDDOCUMENTHANDLER_HPP_
43 #include <com/sun/star/xml/sax/XExtendedDocumentHandler.hpp>
44 #endif
45 
46 //_________________________________________________________________________________________________________________
47 //	other includes
48 //_________________________________________________________________________________________________________________
49 
50 #include <sal/config.h>
51 #include <vcl/svapp.hxx>
52 #include <vcl/toolbox.hxx>
53 
54 #include <comphelper/attributelist.hxx>
55 
56 //_________________________________________________________________________________________________________________
57 //	namespace
58 //_________________________________________________________________________________________________________________
59 
60 using namespace ::com::sun::star::uno;
61 using namespace ::com::sun::star::beans;
62 using namespace ::com::sun::star::xml::sax;
63 
64 
65 #define XMLNS_EVENT				"http://openoffice.org/2001/event"
66 #define XMLNS_XLINK				"http://www.w3.org/1999/xlink"
67 #define XMLNS_EVENT_PREFIX		"event:"
68 #define XMLNS_XLINK_PREFIX		"xlink:"
69 
70 #define ATTRIBUTE_XMLNS_EVENT	"xmlns:event"
71 #define ATTRIBUTE_XMLNS_XLINK	"xmlns:xlink"
72 
73 #define XMLNS_FILTER_SEPARATOR	"^"
74 
75 #define ELEMENT_EVENTS			"events"
76 #define ELEMENT_EVENT			"event"
77 
78 #define ATTRIBUTE_LANGUAGE		"language"
79 #define ATTRIBUTE_LIBRARY		"library"
80 #define ATTRIBUTE_NAME			"name"
81 #define ATTRIBUTE_HREF			"href"
82 #define ATTRIBUTE_TYPE			"type"
83 #define ATTRIBUTE_MACRONAME		"macro-name"
84 
85 #define ELEMENT_NS_EVENTS		"event:events"
86 #define ELEMENT_NS_EVENT		"event:event"
87 
88 #define ATTRIBUTE_TYPE_CDATA	"CDATA"
89 
90 #define EVENTS_DOCTYPE			"<!DOCTYPE event:events PUBLIC \"-//OpenOffice.org//DTD OfficeDocument 1.0//EN\" \"event.dtd\">"
91 
92 // Property names for events
93 #define	PROP_EVENT_TYPE		"EventType"
94 #define PROP_LIBRARY		"Library"
95 #define PROP_SCRIPT			"Script"
96 #define PROP_MACRO_NAME		"MacroName"
97 #define STAR_BASIC			"StarBasic"
98 #define JAVA_SCRIPT			"JavaScript"
99 
100 
101 namespace framework
102 {
103 
104 struct EventEntryProperty
105 {
106 	OReadEventsDocumentHandler::Event_XML_Namespace	nNamespace;
107 	char											aEntryName[20];
108 };
109 
110 static EventEntryProperty EventEntries[OReadEventsDocumentHandler::EV_XML_ENTRY_COUNT] =
111 {
112 	{ OReadEventsDocumentHandler::EV_NS_EVENT,	ELEMENT_EVENTS			},
113 	{ OReadEventsDocumentHandler::EV_NS_EVENT,	ELEMENT_EVENT			},
114 	{ OReadEventsDocumentHandler::EV_NS_EVENT,	ATTRIBUTE_LANGUAGE		},
115 	{ OReadEventsDocumentHandler::EV_NS_EVENT,	ATTRIBUTE_NAME			},
116 	{ OReadEventsDocumentHandler::EV_NS_XLINK,	ATTRIBUTE_HREF			},
117 	{ OReadEventsDocumentHandler::EV_NS_XLINK,	ATTRIBUTE_TYPE			},
118 	{ OReadEventsDocumentHandler::EV_NS_EVENT,	ATTRIBUTE_MACRONAME		},
119 	{ OReadEventsDocumentHandler::EV_NS_EVENT,	ATTRIBUTE_LIBRARY		}
120 };
121 
122 
OReadEventsDocumentHandler(EventsConfig & aItems)123 OReadEventsDocumentHandler::OReadEventsDocumentHandler( EventsConfig& aItems ) :
124 	ThreadHelpBase( &Application::GetSolarMutex() ),
125 	m_aEventItems( aItems )
126 {
127 	::rtl::OUString aNamespaceEvent( RTL_CONSTASCII_USTRINGPARAM( XMLNS_EVENT ));
128 	::rtl::OUString aNamespaceXLink( RTL_CONSTASCII_USTRINGPARAM( XMLNS_XLINK ));
129 	::rtl::OUString aSeparator( RTL_CONSTASCII_USTRINGPARAM( XMLNS_FILTER_SEPARATOR ));
130 
131 	// create hash map
132 	for ( int i = 0; i < (int)EV_XML_ENTRY_COUNT; i++ )
133 	{
134 		if ( EventEntries[i].nNamespace == EV_NS_EVENT )
135 		{
136 			::rtl::OUString temp( aNamespaceEvent );
137 			temp += aSeparator;
138 			temp += ::rtl::OUString::createFromAscii( EventEntries[i].aEntryName );
139 			m_aEventsMap.insert( EventsHashMap::value_type( temp, (Events_XML_Entry)i ) );
140 		}
141 		else
142 		{
143 			::rtl::OUString temp( aNamespaceXLink );
144 			temp += aSeparator;
145 			temp += ::rtl::OUString::createFromAscii( EventEntries[i].aEntryName );
146 			m_aEventsMap.insert( EventsHashMap::value_type( temp, (Events_XML_Entry)i ) );
147 		}
148 	}
149 
150 	m_bEventsStartFound				= sal_False;
151 	m_bEventsEndFound				= sal_False;
152 	m_bEventStartFound				= sal_False;
153 }
154 
~OReadEventsDocumentHandler()155 OReadEventsDocumentHandler::~OReadEventsDocumentHandler()
156 {
157 }
158 
159 // XDocumentHandler
startDocument(void)160 void SAL_CALL OReadEventsDocumentHandler::startDocument(void)
161 throw (	SAXException, RuntimeException )
162 {
163 }
164 
endDocument(void)165 void SAL_CALL OReadEventsDocumentHandler::endDocument(void)
166 throw(	SAXException, RuntimeException )
167 {
168 	ResetableGuard aGuard( m_aLock );
169 
170 	if (( m_bEventsStartFound && !m_bEventsEndFound ) ||
171 		( !m_bEventsStartFound && m_bEventsEndFound )		)
172 	{
173 		::rtl::OUString aErrorMessage = getErrorLineString();
174 		aErrorMessage += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "No matching start or end element 'event:events' found!" ));
175 		throw SAXException( aErrorMessage, Reference< XInterface >(), Any() );
176 	}
177 }
178 
startElement(const::rtl::OUString & aName,const Reference<XAttributeList> & xAttribs)179 void SAL_CALL OReadEventsDocumentHandler::startElement(
180 	const ::rtl::OUString& aName, const Reference< XAttributeList > &xAttribs )
181 throw(	SAXException, RuntimeException )
182 {
183 	ResetableGuard aGuard( m_aLock );
184 
185 	EventsHashMap::const_iterator pEventEntry = m_aEventsMap.find( aName );
186 	if ( pEventEntry != m_aEventsMap.end() )
187 	{
188 		switch ( pEventEntry->second )
189 		{
190 			case EV_ELEMENT_EVENTS:
191 			{
192 				if ( m_bEventsStartFound )
193 				{
194 					::rtl::OUString aErrorMessage = getErrorLineString();
195 					aErrorMessage += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Element 'event:events' cannot be embeded into 'event:events'!" ));
196 					throw SAXException( aErrorMessage, Reference< XInterface >(), Any() );
197 				}
198 
199 				m_bEventsStartFound = sal_True;
200 			}
201 			break;
202 
203 			case EV_ELEMENT_EVENT:
204 			{
205 				if ( !m_bEventsStartFound )
206 				{
207 					::rtl::OUString aErrorMessage = getErrorLineString();
208 					aErrorMessage += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Element 'event:event' must be embeded into element 'event:events'!" ));
209 					throw SAXException( aErrorMessage, Reference< XInterface >(), Any() );
210 				}
211 
212 				if ( m_bEventStartFound )
213 				{
214 					::rtl::OUString aErrorMessage = getErrorLineString();
215 					aErrorMessage += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Element event:event is not a container!" ));
216 					throw SAXException( aErrorMessage, Reference< XInterface >(), Any() );
217 				}
218 
219 				::rtl::OUString aLanguage;
220 				::rtl::OUString aURL;
221 				::rtl::OUString aMacroName;
222 				::rtl::OUString aLibrary;
223 				::rtl::OUString aEventName;
224 
225 				m_bEventStartFound = sal_True;
226 
227 				long					  nIndex = m_aEventItems.aEventNames.getLength();
228 				long					  nPropCount = 2; // every event config entry needs at least 2 properties
229 				Sequence< PropertyValue > aEventProperties( nPropCount );
230 
231 				m_aEventItems.aEventNames.realloc(  nIndex + 1 );
232 
233 				for ( sal_Int16 n = 0; n < xAttribs->getLength(); n++ )
234 				{
235 					pEventEntry = m_aEventsMap.find( xAttribs->getNameByIndex( n ) );
236 					if ( pEventEntry != m_aEventsMap.end() )
237 					{
238 						switch ( pEventEntry->second )
239 						{
240 							case EV_ATTRIBUTE_TYPE:
241 							{
242 								aLanguage = xAttribs->getValueByIndex( n );
243 							}
244 							break;
245 
246 							case EV_ATTRIBUTE_NAME:
247 							{
248 								aEventName = xAttribs->getValueByIndex( n );
249 							}
250 							break;
251 
252 							case XL_ATTRIBUTE_HREF:
253 							{
254 								aURL = xAttribs->getValueByIndex( n );
255 							}
256 							break;
257 
258 							case EV_ATTRIBUTE_MACRONAME:
259 							{
260 								aMacroName = xAttribs->getValueByIndex( n );
261 							}
262 							break;
263 
264 							case EV_ATTRIBUTE_LIBRARY:
265 							{
266 								aLibrary = xAttribs->getValueByIndex( n );
267 							}
268 							break;
269 
270                                           default:
271                                               break; // nothing to do
272 						}
273 					}
274 				} // for
275 
276 				::rtl::OUString aRequiredAttributeName;
277 				if ( aLanguage.getLength() == 0 )
278 					aRequiredAttributeName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_TYPE ));
279 				else if ( aEventName.getLength() == 0 )
280 					aRequiredAttributeName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_NAME ));
281 
282 				// check for missing attribute values
283 				if ( aRequiredAttributeName.getLength() > 0 )
284 				{
285 					::rtl::OUString aErrorMessage = getErrorLineString();
286 					aErrorMessage += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Required attribute "));
287 					aErrorMessage += aRequiredAttributeName;
288 					aErrorMessage += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( " must have a value!" ));
289 					throw SAXException( aErrorMessage, Reference< XInterface >(), Any() );
290 				}
291 
292 				Any a;
293 
294 				// set properties
295 				a <<= aLanguage;
296 				aEventProperties[0].Value <<= a;
297 				aEventProperties[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( PROP_EVENT_TYPE ));
298 
299 				a <<= aMacroName;
300 				aEventProperties[1].Value <<= a;
301 				aEventProperties[1].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( PROP_MACRO_NAME ));
302 
303 				if ( aLibrary.getLength() > 0 )
304 				{
305 					++nPropCount;
306 					aEventProperties.realloc( nPropCount );
307 					a <<= aLibrary;
308 					aEventProperties[nPropCount-1].Value <<= a;
309 					aEventProperties[nPropCount-1].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( PROP_LIBRARY ));
310 				}
311 
312 				if ( aURL.getLength() > 0 )
313 				{
314 					++nPropCount;
315 					aEventProperties.realloc( nPropCount );
316 					a <<= aURL;
317 					aEventProperties[nPropCount-1].Value <<= a;
318 					aEventProperties[nPropCount-1].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( PROP_SCRIPT ));
319 				}
320 
321 				// set event name
322 				m_aEventItems.aEventNames[ nIndex ] = aEventName;
323 
324 				m_aEventItems.aEventsProperties.realloc( nIndex + 1 );
325 				a <<= aEventProperties;
326 				m_aEventItems.aEventsProperties[ nIndex ] = a;
327 			}
328 			break;
329 
330                   default:
331                       break;
332 		}
333 	}
334 }
335 
endElement(const::rtl::OUString & aName)336 void SAL_CALL OReadEventsDocumentHandler::endElement(const ::rtl::OUString& aName)
337 throw(	SAXException, RuntimeException )
338 {
339 	ResetableGuard aGuard( m_aLock );
340 
341 	EventsHashMap::const_iterator pEventEntry = m_aEventsMap.find( aName );
342 	if ( pEventEntry != m_aEventsMap.end() )
343 	{
344 		switch ( pEventEntry->second )
345 		{
346 			case EV_ELEMENT_EVENTS:
347 			{
348 				if ( !m_bEventsStartFound )
349 				{
350 					::rtl::OUString aErrorMessage = getErrorLineString();
351 					aErrorMessage += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "End element 'event:events' found, but no start element" ));
352 					throw SAXException( aErrorMessage, Reference< XInterface >(), Any() );
353 				}
354 
355 				m_bEventsStartFound = sal_False;
356 			}
357 			break;
358 
359 			case EV_ELEMENT_EVENT:
360 			{
361 				if ( !m_bEventStartFound )
362 				{
363 					::rtl::OUString aErrorMessage = getErrorLineString();
364 					aErrorMessage += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "End element 'event:event' found, but no start element" ));
365 					throw SAXException( aErrorMessage, Reference< XInterface >(), Any() );
366 				}
367 
368 				m_bEventStartFound = sal_False;
369 			}
370 			break;
371 
372                   default:
373                       break; // impossible case
374 		}
375 	}
376 }
377 
characters(const::rtl::OUString &)378 void SAL_CALL OReadEventsDocumentHandler::characters(const ::rtl::OUString&)
379 throw(	SAXException, RuntimeException )
380 {
381 }
382 
ignorableWhitespace(const::rtl::OUString &)383 void SAL_CALL OReadEventsDocumentHandler::ignorableWhitespace(const ::rtl::OUString&)
384 throw(	SAXException, RuntimeException )
385 {
386 }
387 
processingInstruction(const::rtl::OUString &,const::rtl::OUString &)388 void SAL_CALL OReadEventsDocumentHandler::processingInstruction(
389 	const ::rtl::OUString& /*aTarget*/, const ::rtl::OUString& /*aData*/ )
390 throw(	SAXException, RuntimeException )
391 {
392 }
393 
setDocumentLocator(const Reference<XLocator> & xLocator)394 void SAL_CALL OReadEventsDocumentHandler::setDocumentLocator(
395 	const Reference< XLocator > &xLocator)
396 throw(	SAXException, RuntimeException )
397 {
398 	ResetableGuard aGuard( m_aLock );
399 
400 	m_xLocator = xLocator;
401 }
402 
getErrorLineString()403 ::rtl::OUString OReadEventsDocumentHandler::getErrorLineString()
404 {
405 	ResetableGuard aGuard( m_aLock );
406 
407 	char buffer[32];
408 
409 	if ( m_xLocator.is() )
410 	{
411 		snprintf( buffer, sizeof(buffer), "Line: %ld - ", static_cast<long>(m_xLocator->getLineNumber() ));
412 		return ::rtl::OUString::createFromAscii( buffer );
413 	}
414 	else
415 		return ::rtl::OUString();
416 }
417 
418 
419 //_________________________________________________________________________________________________________________
420 //	OWriteEventsDocumentHandler
421 //_________________________________________________________________________________________________________________
422 
OWriteEventsDocumentHandler(const EventsConfig & aItems,Reference<XDocumentHandler> rWriteDocumentHandler)423 OWriteEventsDocumentHandler::OWriteEventsDocumentHandler(
424 	const EventsConfig& aItems,
425 	Reference< XDocumentHandler > rWriteDocumentHandler ) :
426     ThreadHelpBase( &Application::GetSolarMutex() ),
427 	m_aItems( aItems ),
428 	m_xWriteDocumentHandler( rWriteDocumentHandler )
429 {
430     ::comphelper::AttributeList* pList = new ::comphelper::AttributeList;
431 	m_xEmptyList		= Reference< XAttributeList >( (XAttributeList *) pList, UNO_QUERY );
432 	m_aAttributeType	= ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_TYPE_CDATA ));
433 	m_aXMLXlinkNS		= ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( XMLNS_XLINK_PREFIX ));
434 	m_aXMLEventNS		= ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( XMLNS_EVENT_PREFIX ));
435 }
436 
~OWriteEventsDocumentHandler()437 OWriteEventsDocumentHandler::~OWriteEventsDocumentHandler()
438 {
439 }
440 
WriteEventsDocument()441 void OWriteEventsDocumentHandler::WriteEventsDocument() throw
442 ( SAXException, RuntimeException )
443 {
444 	ResetableGuard aGuard( m_aLock );
445 
446 	m_xWriteDocumentHandler->startDocument();
447 
448 	// write DOCTYPE line!
449 	Reference< XExtendedDocumentHandler > xExtendedDocHandler( m_xWriteDocumentHandler, UNO_QUERY );
450 	if ( xExtendedDocHandler.is() )
451 	{
452 		xExtendedDocHandler->unknown( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( EVENTS_DOCTYPE )) );
453 		m_xWriteDocumentHandler->ignorableWhitespace( ::rtl::OUString() );
454 	}
455 
456 	::comphelper::AttributeList* pList = new ::comphelper::AttributeList;
457 	Reference< XAttributeList > xList( (XAttributeList *) pList , UNO_QUERY );
458 
459 	pList->AddAttribute( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_XMLNS_EVENT )),
460 						 m_aAttributeType,
461 						 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( XMLNS_EVENT )) );
462 	pList->AddAttribute( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_XMLNS_XLINK )),
463 						 m_aAttributeType,
464 						 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( XMLNS_XLINK )) );
465 
466 	m_xWriteDocumentHandler->startElement( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ELEMENT_NS_EVENTS )), pList );
467 	m_xWriteDocumentHandler->ignorableWhitespace( ::rtl::OUString() );
468 
469 	Sequence< PropertyValue > aEventProperties;
470 
471 	for ( int i = 0; i < m_aItems.aEventNames.getLength(); i++ )
472 	{
473 		if ( m_aItems.aEventsProperties[i] >>= aEventProperties )
474 			WriteEvent( m_aItems.aEventNames[i], aEventProperties );
475 	}
476 
477 	m_xWriteDocumentHandler->ignorableWhitespace( ::rtl::OUString() );
478 	m_xWriteDocumentHandler->endElement( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ELEMENT_NS_EVENTS )) );
479 
480 	m_xWriteDocumentHandler->ignorableWhitespace( ::rtl::OUString() );
481 	m_xWriteDocumentHandler->endDocument();
482 }
483 
484 //_________________________________________________________________________________________________________________
485 //	protected member functions
486 //_________________________________________________________________________________________________________________
487 
WriteEvent(const::rtl::OUString & aEventName,const Sequence<PropertyValue> & aPropertyValues)488 void OWriteEventsDocumentHandler::WriteEvent( const ::rtl::OUString& aEventName, const Sequence< PropertyValue >& aPropertyValues ) throw
489 ( SAXException, RuntimeException )
490 {
491 	if ( aPropertyValues.getLength() > 0 )
492 	{
493 		::comphelper::AttributeList* pList = new ::comphelper::AttributeList;
494 		Reference< XAttributeList > xList( (XAttributeList *) pList , UNO_QUERY );
495 
496 		if ( m_aAttributeURL.getLength() == 0 )
497 		{
498 			m_aAttributeURL = m_aXMLXlinkNS;
499 			m_aAttributeURL += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_HREF ));
500 			m_aAttributeLinkType = m_aXMLXlinkNS;
501 			m_aAttributeLinkType += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_TYPE ));
502 			m_aAttributeLanguage = m_aXMLEventNS;
503 			m_aAttributeLanguage += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_LANGUAGE ));
504 			m_aAttributeMacroName = m_aXMLEventNS;
505 			m_aAttributeMacroName += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_MACRONAME ));
506 			m_aAttributeLibrary = m_aXMLEventNS;
507 			m_aAttributeLibrary += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_LIBRARY ));
508 			m_aAttributeName = m_aXMLEventNS;
509 			m_aAttributeName += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_NAME ));
510 		}
511 
512 		pList->AddAttribute( m_aAttributeName, m_aAttributeType, aEventName );
513 
514 		sal_Bool	bURLSet = sal_False;
515 		::rtl::OUString	aValue;
516 		::rtl::OUString	aName;
517 
518 		// save attributes
519 		for ( int i = 0; i < aPropertyValues.getLength(); i++ )
520 		{
521 			aPropertyValues[i].Value >>= aValue;
522 			if ( aPropertyValues[i].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( PROP_EVENT_TYPE )))
523 				pList->AddAttribute( m_aAttributeLanguage, m_aAttributeType, aValue );
524 			else if ( aPropertyValues[i].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( PROP_MACRO_NAME )) &&
525 					  aValue.getLength() > 0 )
526 				pList->AddAttribute( m_aAttributeMacroName, m_aAttributeType, aValue );
527 			else if ( aPropertyValues[i].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( PROP_LIBRARY )) &&
528 					  aValue.getLength() > 0 )
529 				pList->AddAttribute( m_aAttributeLibrary, m_aAttributeType, aValue );
530 			else if ( aPropertyValues[i].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( PROP_SCRIPT )))
531 			{
532 				pList->AddAttribute( m_aAttributeURL, m_aAttributeType, aValue );
533 				bURLSet = sal_True;
534 			}
535 		}
536 
537 		if ( bURLSet )
538 			pList->AddAttribute( m_aAttributeLinkType, m_aAttributeType, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "simple" )) );
539 
540 		m_xWriteDocumentHandler->startElement( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ELEMENT_NS_EVENT )), xList );
541 		m_xWriteDocumentHandler->ignorableWhitespace( ::rtl::OUString() );
542 
543 		m_xWriteDocumentHandler->endElement( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ELEMENT_NS_EVENT )) );
544 		m_xWriteDocumentHandler->ignorableWhitespace( ::rtl::OUString() );
545 	}
546 }
547 
548 } // namespace framework
549 
550