1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: eventsdocumenthandler.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef __FRAMEWORK_CLASSES_EVENTSDOCUMENTHANDLER_HXX_
32 #define __FRAMEWORK_CLASSES_EVENTSDOCUMENTHANDLER_HXX_
34 #ifndef __FRAMEWORK_CLASSES_TOOLBOXCONFIGURATION_HXX_
35 #include <classes/eventsconfiguration.hxx>
38 //_________________________________________________________________________________________________________________
40 //_________________________________________________________________________________________________________________
42 #ifndef __COM_SUN_STAR_XML_SAX_XDOCUMENTHANDLER_HPP_
43 #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
46 //_________________________________________________________________________________________________________________
48 //_________________________________________________________________________________________________________________
49 #include <threadhelp/threadhelpbase.hxx>
50 #include <rtl/ustring.hxx>
51 #include <cppuhelper/weak.hxx>
53 #ifndef __SGI_STL_HASH_MAP
58 //_________________________________________________________________________________________________________________
60 //_________________________________________________________________________________________________________________
64 //*****************************************************************************************************************
65 // Hash code function for using in all hash maps of follow implementation.
67 class OReadEventsDocumentHandler
: public ::com::sun::star::xml::sax::XDocumentHandler
,
68 private ThreadHelpBase
, // Struct for right initalization of lock member! Must be first of baseclasses.
69 public ::cppu::OWeakObject
80 EV_ATTRIBUTE_MACRONAME
,
85 enum Event_XML_Namespace
89 EV_XML_NAMESPACES_COUNT
92 OReadEventsDocumentHandler( EventsConfig
& aItems
);
93 virtual ~OReadEventsDocumentHandler();
96 virtual void SAL_CALL
acquire() throw()
97 { OWeakObject::acquire(); }
98 virtual void SAL_CALL
release() throw()
99 { OWeakObject::release(); }
100 virtual ::com::sun::star::uno::Any SAL_CALL
queryInterface(
101 const ::com::sun::star::uno::Type
& rType
) throw( ::com::sun::star::uno::RuntimeException
);
104 virtual void SAL_CALL
startDocument(void)
105 throw ( ::com::sun::star::xml::sax::SAXException
,
106 ::com::sun::star::uno::RuntimeException
);
108 virtual void SAL_CALL
endDocument(void)
109 throw( ::com::sun::star::xml::sax::SAXException
,
110 ::com::sun::star::uno::RuntimeException
);
112 virtual void SAL_CALL
startElement(
113 const rtl::OUString
& aName
,
114 const ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XAttributeList
> &xAttribs
)
115 throw( ::com::sun::star::xml::sax::SAXException
,
116 ::com::sun::star::uno::RuntimeException
);
118 virtual void SAL_CALL
endElement(const rtl::OUString
& aName
)
119 throw( ::com::sun::star::xml::sax::SAXException
,
120 ::com::sun::star::uno::RuntimeException
);
122 virtual void SAL_CALL
characters(const rtl::OUString
& aChars
)
123 throw( ::com::sun::star::xml::sax::SAXException
,
124 ::com::sun::star::uno::RuntimeException
);
126 virtual void SAL_CALL
ignorableWhitespace(const rtl::OUString
& aWhitespaces
)
127 throw( ::com::sun::star::xml::sax::SAXException
,
128 ::com::sun::star::uno::RuntimeException
);
130 virtual void SAL_CALL
processingInstruction(const rtl::OUString
& aTarget
,
131 const rtl::OUString
& aData
)
132 throw( ::com::sun::star::xml::sax::SAXException
,
133 ::com::sun::star::uno::RuntimeException
);
135 virtual void SAL_CALL
setDocumentLocator(
136 const ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XLocator
> &xLocator
)
137 throw( ::com::sun::star::xml::sax::SAXException
,
138 ::com::sun::star::uno::RuntimeException
);
141 ::rtl::OUString
getErrorLineString();
143 class EventsHashMap
: public ::std::hash_map
< ::rtl::OUString
,
146 ::std::equal_to
< ::rtl::OUString
> >
151 EventsHashMap().swap( *this );
155 sal_Bool m_bEventsStartFound
;
156 sal_Bool m_bEventsEndFound
;
157 sal_Bool m_bEventStartFound
;
158 EventsHashMap m_aEventsMap
;
159 EventsConfig
& m_aEventItems
;
160 ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XLocator
> m_xLocator
;
163 class OWriteEventsDocumentHandler
: private ThreadHelpBase
// Struct for right initalization of lock member! Must be first of baseclasses.
166 OWriteEventsDocumentHandler(
167 const EventsConfig
& aItems
,
168 ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XDocumentHandler
> );
169 virtual ~OWriteEventsDocumentHandler();
171 void WriteEventsDocument() throw
172 ( ::com::sun::star::xml::sax::SAXException
,
173 ::com::sun::star::uno::RuntimeException
);
176 virtual void WriteEvent(
177 const ::rtl::OUString
& aEventName
,
178 const ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
>& aPropertyValue
) throw
179 ( ::com::sun::star::xml::sax::SAXException
,
180 ::com::sun::star::uno::RuntimeException
);
182 const EventsConfig
& m_aItems
;
183 ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XDocumentHandler
> m_xWriteDocumentHandler
;
184 ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XAttributeList
> m_xEmptyList
;
185 ::rtl::OUString m_aXMLEventNS
;
186 ::rtl::OUString m_aXMLXlinkNS
;
187 ::rtl::OUString m_aAttributeType
;
188 ::rtl::OUString m_aAttributeURL
;
189 ::rtl::OUString m_aAttributeLanguage
;
190 ::rtl::OUString m_aAttributeLinkType
;
191 ::rtl::OUString m_aAttributeMacroName
;
192 ::rtl::OUString m_aAttributeLibrary
;
193 ::rtl::OUString m_aAttributeName
;
196 } // namespace framework