1f8e07b45SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3f8e07b45SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4f8e07b45SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5f8e07b45SAndrew Rist  * distributed with this work for additional information
6f8e07b45SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7f8e07b45SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8f8e07b45SAndrew Rist  * "License"); you may not use this file except in compliance
9f8e07b45SAndrew Rist  * with the License.  You may obtain a copy of the License at
10f8e07b45SAndrew Rist  *
11f8e07b45SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12f8e07b45SAndrew Rist  *
13f8e07b45SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14f8e07b45SAndrew Rist  * software distributed under the License is distributed on an
15f8e07b45SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16f8e07b45SAndrew Rist  * KIND, either express or implied.  See the License for the
17f8e07b45SAndrew Rist  * specific language governing permissions and limitations
18f8e07b45SAndrew Rist  * under the License.
19f8e07b45SAndrew Rist  *
20f8e07b45SAndrew Rist  *************************************************************/
21f8e07b45SAndrew Rist 
22f8e07b45SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef __FRAMEWORK_XML_EVENTSDOCUMENTHANDLER_HXX_
25cdf0e10cSrcweir #define __FRAMEWORK_XML_EVENTSDOCUMENTHANDLER_HXX_
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #ifndef __FRAMEWORK_XML_TOOLBOXCONFIGURATION_HXX_
28cdf0e10cSrcweir #include <framework/eventsconfiguration.hxx>
29cdf0e10cSrcweir #endif
30cdf0e10cSrcweir 
31cdf0e10cSrcweir //_________________________________________________________________________________________________________________
32cdf0e10cSrcweir //	interface includes
33cdf0e10cSrcweir //_________________________________________________________________________________________________________________
34cdf0e10cSrcweir 
35cdf0e10cSrcweir #ifndef __COM_SUN_STAR_XML_SAX_XDOCUMENTHANDLER_HPP_
36cdf0e10cSrcweir #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
37cdf0e10cSrcweir #endif
38cdf0e10cSrcweir 
39cdf0e10cSrcweir //_________________________________________________________________________________________________________________
40cdf0e10cSrcweir //	other includes
41cdf0e10cSrcweir //_________________________________________________________________________________________________________________
42cdf0e10cSrcweir #include <threadhelp/threadhelpbase.hxx>
43cdf0e10cSrcweir #include <rtl/ustring.hxx>
44cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx>
45cdf0e10cSrcweir 
46cdf0e10cSrcweir #include <hash_map>
47cdf0e10cSrcweir #include <stdtypes.h>
48cdf0e10cSrcweir 
49cdf0e10cSrcweir #include <framework/fwedllapi.h>
50cdf0e10cSrcweir //_________________________________________________________________________________________________________________
51cdf0e10cSrcweir //	namespace
52cdf0e10cSrcweir //_________________________________________________________________________________________________________________
53cdf0e10cSrcweir 
54cdf0e10cSrcweir namespace framework{
55cdf0e10cSrcweir 
56cdf0e10cSrcweir //*****************************************************************************************************************
57cdf0e10cSrcweir // Hash code function for using in all hash maps of follow implementation.
58cdf0e10cSrcweir 
59*30acf5e8Spfg class FWE_DLLPUBLIC OReadEventsDocumentHandler :	private ThreadHelpBase,	// Struct for right initialization of lock member! Must be first of baseclasses.
60cdf0e10cSrcweir 									public ::cppu::WeakImplHelper1< ::com::sun::star::xml::sax::XDocumentHandler >
61cdf0e10cSrcweir {
62cdf0e10cSrcweir 	public:
63cdf0e10cSrcweir 		enum Events_XML_Entry
64cdf0e10cSrcweir 		{
65cdf0e10cSrcweir 			EV_ELEMENT_EVENTS,
66cdf0e10cSrcweir 			EV_ELEMENT_EVENT,
67cdf0e10cSrcweir 			EV_ATTRIBUTE_TYPE,
68cdf0e10cSrcweir 			EV_ATTRIBUTE_NAME,
69cdf0e10cSrcweir 			XL_ATTRIBUTE_HREF,
70cdf0e10cSrcweir 			XL_ATTRIBUTE_TYPE,
71cdf0e10cSrcweir 			EV_ATTRIBUTE_MACRONAME,
72cdf0e10cSrcweir 			EV_ATTRIBUTE_LIBRARY,
73cdf0e10cSrcweir 			EV_XML_ENTRY_COUNT
74cdf0e10cSrcweir 		};
75cdf0e10cSrcweir 
76cdf0e10cSrcweir 		enum Event_XML_Namespace
77cdf0e10cSrcweir 		{
78cdf0e10cSrcweir 			EV_NS_EVENT,
79cdf0e10cSrcweir 			EV_NS_XLINK,
80cdf0e10cSrcweir 			EV_XML_NAMESPACES_COUNT
81cdf0e10cSrcweir 		};
82cdf0e10cSrcweir 
83cdf0e10cSrcweir 		OReadEventsDocumentHandler( EventsConfig& aItems );
84cdf0e10cSrcweir 
85cdf0e10cSrcweir 
86cdf0e10cSrcweir 		// XDocumentHandler
87cdf0e10cSrcweir 		virtual void SAL_CALL startDocument(void)
88cdf0e10cSrcweir 		throw (	::com::sun::star::xml::sax::SAXException,
89cdf0e10cSrcweir 				::com::sun::star::uno::RuntimeException );
90cdf0e10cSrcweir 
91cdf0e10cSrcweir 		virtual void SAL_CALL endDocument(void)
92cdf0e10cSrcweir 		throw(	::com::sun::star::xml::sax::SAXException,
93cdf0e10cSrcweir 				::com::sun::star::uno::RuntimeException );
94cdf0e10cSrcweir 
95cdf0e10cSrcweir 		virtual void SAL_CALL startElement(
96cdf0e10cSrcweir 			const rtl::OUString& aName,
97cdf0e10cSrcweir 			const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > &xAttribs)
98cdf0e10cSrcweir 		throw(	::com::sun::star::xml::sax::SAXException,
99cdf0e10cSrcweir 				::com::sun::star::uno::RuntimeException );
100cdf0e10cSrcweir 
101cdf0e10cSrcweir 		virtual void SAL_CALL endElement(const rtl::OUString& aName)
102cdf0e10cSrcweir 		throw(	::com::sun::star::xml::sax::SAXException,
103cdf0e10cSrcweir 				::com::sun::star::uno::RuntimeException );
104cdf0e10cSrcweir 
105cdf0e10cSrcweir 		virtual void SAL_CALL characters(const rtl::OUString& aChars)
106cdf0e10cSrcweir 		throw(	::com::sun::star::xml::sax::SAXException,
107cdf0e10cSrcweir 				::com::sun::star::uno::RuntimeException );
108cdf0e10cSrcweir 
109cdf0e10cSrcweir 		virtual void SAL_CALL ignorableWhitespace(const rtl::OUString& aWhitespaces)
110cdf0e10cSrcweir 		throw(	::com::sun::star::xml::sax::SAXException,
111cdf0e10cSrcweir 				::com::sun::star::uno::RuntimeException );
112cdf0e10cSrcweir 
113cdf0e10cSrcweir 		virtual void SAL_CALL processingInstruction(const rtl::OUString& aTarget,
114cdf0e10cSrcweir 													const rtl::OUString& aData)
115cdf0e10cSrcweir 		throw(	::com::sun::star::xml::sax::SAXException,
116cdf0e10cSrcweir 				::com::sun::star::uno::RuntimeException );
117cdf0e10cSrcweir 
118cdf0e10cSrcweir 		virtual void SAL_CALL setDocumentLocator(
119cdf0e10cSrcweir 			const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XLocator > &xLocator)
120cdf0e10cSrcweir 		throw(	::com::sun::star::xml::sax::SAXException,
121cdf0e10cSrcweir 				::com::sun::star::uno::RuntimeException );
122cdf0e10cSrcweir 
123cdf0e10cSrcweir     protected:
124cdf0e10cSrcweir         virtual ~OReadEventsDocumentHandler();
125cdf0e10cSrcweir 
126cdf0e10cSrcweir 	private:
127cdf0e10cSrcweir 		::rtl::OUString getErrorLineString();
128cdf0e10cSrcweir 
129cdf0e10cSrcweir 		class EventsHashMap : public ::std::hash_map<	::rtl::OUString					,
130cdf0e10cSrcweir 														Events_XML_Entry				,
1315758ad8cSAriel Constenla-Haile 														rtl::OUStringHash,
132cdf0e10cSrcweir 														::std::equal_to< ::rtl::OUString >	>
133cdf0e10cSrcweir 		{
134cdf0e10cSrcweir 			public:
free()135cdf0e10cSrcweir 				inline void free()
136cdf0e10cSrcweir 				{
137cdf0e10cSrcweir 					EventsHashMap().swap( *this );
138cdf0e10cSrcweir 				}
139cdf0e10cSrcweir 		};
140cdf0e10cSrcweir 
141cdf0e10cSrcweir 		sal_Bool																	m_bEventsStartFound;
142cdf0e10cSrcweir 		sal_Bool																	m_bEventsEndFound;
143cdf0e10cSrcweir 		sal_Bool																	m_bEventStartFound;
144cdf0e10cSrcweir 		EventsHashMap																m_aEventsMap;
145cdf0e10cSrcweir 		EventsConfig&																m_aEventItems;
146cdf0e10cSrcweir 		::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XLocator >	m_xLocator;
147cdf0e10cSrcweir };
148cdf0e10cSrcweir 
149*30acf5e8Spfg class FWE_DLLPUBLIC OWriteEventsDocumentHandler : private ThreadHelpBase // Struct for right initialization of lock member! Must be first of baseclasses.
150cdf0e10cSrcweir {
151cdf0e10cSrcweir 	public:
152cdf0e10cSrcweir 		OWriteEventsDocumentHandler(
153cdf0e10cSrcweir 			const EventsConfig& aItems,
154cdf0e10cSrcweir 			::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > );
155cdf0e10cSrcweir 		virtual ~OWriteEventsDocumentHandler();
156cdf0e10cSrcweir 
157cdf0e10cSrcweir 		void WriteEventsDocument() throw
158cdf0e10cSrcweir 			( ::com::sun::star::xml::sax::SAXException,
159cdf0e10cSrcweir 			  ::com::sun::star::uno::RuntimeException );
160cdf0e10cSrcweir 
161cdf0e10cSrcweir 	protected:
162cdf0e10cSrcweir 		virtual void WriteEvent(
163cdf0e10cSrcweir 				const ::rtl::OUString& aEventName,
164cdf0e10cSrcweir 				const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aPropertyValue ) throw
165cdf0e10cSrcweir 			( ::com::sun::star::xml::sax::SAXException,
166cdf0e10cSrcweir 			  ::com::sun::star::uno::RuntimeException );
167cdf0e10cSrcweir 
168cdf0e10cSrcweir 		const EventsConfig&																	m_aItems;
169cdf0e10cSrcweir 		::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler >	m_xWriteDocumentHandler;
170cdf0e10cSrcweir 		::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >		m_xEmptyList;
171cdf0e10cSrcweir 		::rtl::OUString																		m_aXMLEventNS;
172cdf0e10cSrcweir 		::rtl::OUString																		m_aXMLXlinkNS;
173cdf0e10cSrcweir 		::rtl::OUString																		m_aAttributeType;
174cdf0e10cSrcweir 		::rtl::OUString																		m_aAttributeURL;
175cdf0e10cSrcweir 		::rtl::OUString																		m_aAttributeLanguage;
176cdf0e10cSrcweir 		::rtl::OUString																		m_aAttributeLinkType;
177cdf0e10cSrcweir 		::rtl::OUString																		m_aAttributeMacroName;
178cdf0e10cSrcweir 		::rtl::OUString																		m_aAttributeLibrary;
179cdf0e10cSrcweir 		::rtl::OUString																		m_aAttributeName;
180cdf0e10cSrcweir };
181cdf0e10cSrcweir 
182cdf0e10cSrcweir } // namespace framework
183cdf0e10cSrcweir 
184cdf0e10cSrcweir #endif
185