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 #ifndef __FRAMEWORK_XML_EVENTSDOCUMENTHANDLER_HXX_ 25 #define __FRAMEWORK_XML_EVENTSDOCUMENTHANDLER_HXX_ 26 27 #ifndef __FRAMEWORK_XML_TOOLBOXCONFIGURATION_HXX_ 28 #include <framework/eventsconfiguration.hxx> 29 #endif 30 31 //_________________________________________________________________________________________________________________ 32 // interface includes 33 //_________________________________________________________________________________________________________________ 34 35 #ifndef __COM_SUN_STAR_XML_SAX_XDOCUMENTHANDLER_HPP_ 36 #include <com/sun/star/xml/sax/XDocumentHandler.hpp> 37 #endif 38 39 //_________________________________________________________________________________________________________________ 40 // other includes 41 //_________________________________________________________________________________________________________________ 42 #include <threadhelp/threadhelpbase.hxx> 43 #include <rtl/ustring.hxx> 44 #include <cppuhelper/implbase1.hxx> 45 46 #include <hash_map> 47 #include <stdtypes.h> 48 49 #include <framework/fwedllapi.h> 50 //_________________________________________________________________________________________________________________ 51 // namespace 52 //_________________________________________________________________________________________________________________ 53 54 namespace framework{ 55 56 //***************************************************************************************************************** 57 // Hash code function for using in all hash maps of follow implementation. 58 59 class FWE_DLLPUBLIC OReadEventsDocumentHandler : private ThreadHelpBase, // Struct for right initialization of lock member! Must be first of baseclasses. 60 public ::cppu::WeakImplHelper1< ::com::sun::star::xml::sax::XDocumentHandler > 61 { 62 public: 63 enum Events_XML_Entry 64 { 65 EV_ELEMENT_EVENTS, 66 EV_ELEMENT_EVENT, 67 EV_ATTRIBUTE_TYPE, 68 EV_ATTRIBUTE_NAME, 69 XL_ATTRIBUTE_HREF, 70 XL_ATTRIBUTE_TYPE, 71 EV_ATTRIBUTE_MACRONAME, 72 EV_ATTRIBUTE_LIBRARY, 73 EV_XML_ENTRY_COUNT 74 }; 75 76 enum Event_XML_Namespace 77 { 78 EV_NS_EVENT, 79 EV_NS_XLINK, 80 EV_XML_NAMESPACES_COUNT 81 }; 82 83 OReadEventsDocumentHandler( EventsConfig& aItems ); 84 85 86 // XDocumentHandler 87 virtual void SAL_CALL startDocument(void); 88 89 virtual void SAL_CALL endDocument(void); 90 91 virtual void SAL_CALL startElement( 92 const rtl::OUString& aName, 93 const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > &xAttribs); 94 95 virtual void SAL_CALL endElement(const rtl::OUString& aName); 96 97 virtual void SAL_CALL characters(const rtl::OUString& aChars); 98 99 virtual void SAL_CALL ignorableWhitespace(const rtl::OUString& aWhitespaces); 100 101 virtual void SAL_CALL processingInstruction(const rtl::OUString& aTarget, 102 const rtl::OUString& aData); 103 104 virtual void SAL_CALL setDocumentLocator( 105 const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XLocator > &xLocator); 106 107 protected: 108 virtual ~OReadEventsDocumentHandler(); 109 110 private: 111 ::rtl::OUString getErrorLineString(); 112 113 class EventsHashMap : public ::std::hash_map< ::rtl::OUString , 114 Events_XML_Entry , 115 rtl::OUStringHash, 116 ::std::equal_to< ::rtl::OUString > > 117 { 118 public: free()119 inline void free() 120 { 121 EventsHashMap().swap( *this ); 122 } 123 }; 124 125 sal_Bool m_bEventsStartFound; 126 sal_Bool m_bEventsEndFound; 127 sal_Bool m_bEventStartFound; 128 EventsHashMap m_aEventsMap; 129 EventsConfig& m_aEventItems; 130 ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XLocator > m_xLocator; 131 }; 132 133 class FWE_DLLPUBLIC OWriteEventsDocumentHandler : private ThreadHelpBase // Struct for right initialization of lock member! Must be first of baseclasses. 134 { 135 public: 136 OWriteEventsDocumentHandler( 137 const EventsConfig& aItems, 138 ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > ); 139 virtual ~OWriteEventsDocumentHandler(); 140 141 void WriteEventsDocument(); 142 143 protected: 144 virtual void WriteEvent( 145 const ::rtl::OUString& aEventName, 146 const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aPropertyValue ); 147 148 const EventsConfig& m_aItems; 149 ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > m_xWriteDocumentHandler; 150 ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > m_xEmptyList; 151 ::rtl::OUString m_aXMLEventNS; 152 ::rtl::OUString m_aXMLXlinkNS; 153 ::rtl::OUString m_aAttributeType; 154 ::rtl::OUString m_aAttributeURL; 155 ::rtl::OUString m_aAttributeLanguage; 156 ::rtl::OUString m_aAttributeLinkType; 157 ::rtl::OUString m_aAttributeMacroName; 158 ::rtl::OUString m_aAttributeLibrary; 159 ::rtl::OUString m_aAttributeName; 160 }; 161 162 } // namespace framework 163 164 #endif 165