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_STATUSBARDOCUMENTHANDLER_HXX_ 25 #define __FRAMEWORK_XML_STATUSBARDOCUMENTHANDLER_HXX_ 26 27 #ifndef __FRAMEWORK_XML_STATUSBARCONFIGURATION_HXX_ 28 #include <framework/statusbarconfiguration.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 #include <framework/fwedllapi.h> 49 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 OReadStatusBarDocumentHandler : 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 StatusBar_XML_Entry 64 { 65 SB_ELEMENT_STATUSBAR, 66 SB_ELEMENT_STATUSBARITEM, 67 SB_ATTRIBUTE_URL, 68 SB_ATTRIBUTE_ALIGN, 69 SB_ATTRIBUTE_STYLE, 70 SB_ATTRIBUTE_AUTOSIZE, 71 SB_ATTRIBUTE_OWNERDRAW, 72 SB_ATTRIBUTE_WIDTH, 73 SB_ATTRIBUTE_OFFSET, 74 SB_ATTRIBUTE_HELPURL, 75 SB_XML_ENTRY_COUNT 76 }; 77 78 enum StatusBar_XML_Namespace 79 { 80 SB_NS_STATUSBAR, 81 SB_NS_XLINK, 82 SB_XML_NAMESPACES_COUNT 83 }; 84 85 OReadStatusBarDocumentHandler( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer >& aStatusBarItems ); 86 virtual ~OReadStatusBarDocumentHandler(); 87 88 // XDocumentHandler 89 virtual void SAL_CALL startDocument(void); 90 91 virtual void SAL_CALL endDocument(void); 92 93 virtual void SAL_CALL startElement( 94 const rtl::OUString& aName, 95 const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > &xAttribs); 96 97 virtual void SAL_CALL endElement(const rtl::OUString& aName); 98 99 virtual void SAL_CALL characters(const rtl::OUString& aChars); 100 101 virtual void SAL_CALL ignorableWhitespace(const rtl::OUString& aWhitespaces); 102 103 virtual void SAL_CALL processingInstruction(const rtl::OUString& aTarget, 104 const rtl::OUString& aData); 105 106 virtual void SAL_CALL setDocumentLocator( 107 const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XLocator > &xLocator); 108 109 private: 110 ::rtl::OUString getErrorLineString(); 111 112 class StatusBarHashMap : public ::std::hash_map< ::rtl::OUString , 113 StatusBar_XML_Entry , 114 rtl::OUStringHash, 115 ::std::equal_to< ::rtl::OUString > > 116 { 117 public: free()118 inline void free() 119 { 120 StatusBarHashMap().swap( *this ); 121 } 122 }; 123 124 sal_Bool m_bStatusBarStartFound; 125 sal_Bool m_bStatusBarEndFound; 126 sal_Bool m_bStatusBarItemStartFound; 127 StatusBarHashMap m_aStatusBarMap; 128 ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer > m_aStatusBarItems; 129 ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XLocator > m_xLocator; 130 }; 131 132 class FWE_DLLPUBLIC OWriteStatusBarDocumentHandler : private ThreadHelpBase // Struct for right initialization of lock member! Must be first of baseclasses. 133 { 134 public: 135 OWriteStatusBarDocumentHandler( 136 const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess >& rStatusBarItems, 137 const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler >& rWriteDocHandler ); 138 virtual ~OWriteStatusBarDocumentHandler(); 139 140 void WriteStatusBarDocument(); 141 142 protected: 143 virtual void WriteStatusBarItem( 144 const rtl::OUString& rCommandURL, 145 const rtl::OUString& rHelpURL, 146 sal_Int16 nOffset, 147 sal_Int16 nStyle, 148 sal_Int16 nWidth ); 149 150 ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > m_aStatusBarItems; 151 ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > m_xWriteDocumentHandler; 152 ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > m_xEmptyList; 153 ::rtl::OUString m_aXMLStatusBarNS; 154 ::rtl::OUString m_aXMLXlinkNS; 155 ::rtl::OUString m_aAttributeType; 156 ::rtl::OUString m_aAttributeURL; 157 }; 158 159 } // namespace framework 160 161 #endif 162