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 #ifndef __FRAMEWORK_XML_STATUSBARDOCUMENTHANDLER_HXX_ 29 #define __FRAMEWORK_XML_STATUSBARDOCUMENTHANDLER_HXX_ 30 31 #ifndef __FRAMEWORK_XML_STATUSBARCONFIGURATION_HXX_ 32 #include <framework/statusbarconfiguration.hxx> 33 #endif 34 35 //_________________________________________________________________________________________________________________ 36 // interface includes 37 //_________________________________________________________________________________________________________________ 38 39 #ifndef __COM_SUN_STAR_XML_SAX_XDOCUMENTHANDLER_HPP_ 40 #include <com/sun/star/xml/sax/XDocumentHandler.hpp> 41 #endif 42 43 //_________________________________________________________________________________________________________________ 44 // other includes 45 //_________________________________________________________________________________________________________________ 46 #include <threadhelp/threadhelpbase.hxx> 47 #include <rtl/ustring.hxx> 48 #include <cppuhelper/implbase1.hxx> 49 50 #include <hash_map> 51 #include <stdtypes.h> 52 #include <framework/fwedllapi.h> 53 54 //_________________________________________________________________________________________________________________ 55 // namespace 56 //_________________________________________________________________________________________________________________ 57 58 namespace framework{ 59 60 //***************************************************************************************************************** 61 // Hash code function for using in all hash maps of follow implementation. 62 63 class FWE_DLLPUBLIC OReadStatusBarDocumentHandler : private ThreadHelpBase, // Struct for right initalization of lock member! Must be first of baseclasses. 64 public ::cppu::WeakImplHelper1< ::com::sun::star::xml::sax::XDocumentHandler > 65 { 66 public: 67 enum StatusBar_XML_Entry 68 { 69 SB_ELEMENT_STATUSBAR, 70 SB_ELEMENT_STATUSBARITEM, 71 SB_ATTRIBUTE_URL, 72 SB_ATTRIBUTE_ALIGN, 73 SB_ATTRIBUTE_STYLE, 74 SB_ATTRIBUTE_AUTOSIZE, 75 SB_ATTRIBUTE_OWNERDRAW, 76 SB_ATTRIBUTE_WIDTH, 77 SB_ATTRIBUTE_OFFSET, 78 SB_ATTRIBUTE_HELPURL, 79 SB_XML_ENTRY_COUNT 80 }; 81 82 enum StatusBar_XML_Namespace 83 { 84 SB_NS_STATUSBAR, 85 SB_NS_XLINK, 86 SB_XML_NAMESPACES_COUNT 87 }; 88 89 OReadStatusBarDocumentHandler( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer >& aStatusBarItems ); 90 virtual ~OReadStatusBarDocumentHandler(); 91 92 // XDocumentHandler 93 virtual void SAL_CALL startDocument(void) 94 throw ( ::com::sun::star::xml::sax::SAXException, 95 ::com::sun::star::uno::RuntimeException ); 96 97 virtual void SAL_CALL endDocument(void) 98 throw( ::com::sun::star::xml::sax::SAXException, 99 ::com::sun::star::uno::RuntimeException ); 100 101 virtual void SAL_CALL startElement( 102 const rtl::OUString& aName, 103 const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > &xAttribs) 104 throw( ::com::sun::star::xml::sax::SAXException, 105 ::com::sun::star::uno::RuntimeException ); 106 107 virtual void SAL_CALL endElement(const rtl::OUString& aName) 108 throw( ::com::sun::star::xml::sax::SAXException, 109 ::com::sun::star::uno::RuntimeException ); 110 111 virtual void SAL_CALL characters(const rtl::OUString& aChars) 112 throw( ::com::sun::star::xml::sax::SAXException, 113 ::com::sun::star::uno::RuntimeException ); 114 115 virtual void SAL_CALL ignorableWhitespace(const rtl::OUString& aWhitespaces) 116 throw( ::com::sun::star::xml::sax::SAXException, 117 ::com::sun::star::uno::RuntimeException ); 118 119 virtual void SAL_CALL processingInstruction(const rtl::OUString& aTarget, 120 const rtl::OUString& aData) 121 throw( ::com::sun::star::xml::sax::SAXException, 122 ::com::sun::star::uno::RuntimeException ); 123 124 virtual void SAL_CALL setDocumentLocator( 125 const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XLocator > &xLocator) 126 throw( ::com::sun::star::xml::sax::SAXException, 127 ::com::sun::star::uno::RuntimeException ); 128 129 private: 130 ::rtl::OUString getErrorLineString(); 131 132 class StatusBarHashMap : public ::std::hash_map< ::rtl::OUString , 133 StatusBar_XML_Entry , 134 OUStringHashCode , 135 ::std::equal_to< ::rtl::OUString > > 136 { 137 public: 138 inline void free() 139 { 140 StatusBarHashMap().swap( *this ); 141 } 142 }; 143 144 sal_Bool m_bStatusBarStartFound; 145 sal_Bool m_bStatusBarEndFound; 146 sal_Bool m_bStatusBarItemStartFound; 147 StatusBarHashMap m_aStatusBarMap; 148 ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer > m_aStatusBarItems; 149 ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XLocator > m_xLocator; 150 }; 151 152 class FWE_DLLPUBLIC OWriteStatusBarDocumentHandler : private ThreadHelpBase // Struct for right initalization of lock member! Must be first of baseclasses. 153 { 154 public: 155 OWriteStatusBarDocumentHandler( 156 const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess >& rStatusBarItems, 157 const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler >& rWriteDocHandler ); 158 virtual ~OWriteStatusBarDocumentHandler(); 159 160 void WriteStatusBarDocument() throw 161 ( ::com::sun::star::xml::sax::SAXException, 162 ::com::sun::star::uno::RuntimeException ); 163 164 protected: 165 virtual void WriteStatusBarItem( 166 const rtl::OUString& rCommandURL, 167 const rtl::OUString& rHelpURL, 168 sal_Int16 nOffset, 169 sal_Int16 nStyle, 170 sal_Int16 nWidth ) throw 171 ( ::com::sun::star::xml::sax::SAXException, 172 ::com::sun::star::uno::RuntimeException ); 173 174 ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > m_aStatusBarItems; 175 ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > m_xWriteDocumentHandler; 176 ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > m_xEmptyList; 177 ::rtl::OUString m_aXMLStatusBarNS; 178 ::rtl::OUString m_aXMLXlinkNS; 179 ::rtl::OUString m_aAttributeType; 180 ::rtl::OUString m_aAttributeURL; 181 }; 182 183 } // namespace framework 184 185 #endif 186