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