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