update dev300-m57
[ooovba.git] / framework / inc / classes / statusbardocumenthandler.hxx
blob5dce26dec2e4ea89d03a8d48f8e6d0e48ce1ec2e
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: statusbardocumenthandler.hxx,v $
10 * $Revision: 1.4 $
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_STATUSBARDOCUMENTHANDLER_HXX_
32 #define __FRAMEWORK_CLASSES_STATUSBARDOCUMENTHANDLER_HXX_
34 #include <classes/statusbarconfiguration.hxx>
36 //_________________________________________________________________________________________________________________
37 // interface includes
38 //_________________________________________________________________________________________________________________
40 #ifndef __COM_SUN_STAR_XML_SAX_XDOCUMENTHANDLER_HPP_
41 #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
42 #endif
44 //_________________________________________________________________________________________________________________
45 // other includes
46 //_________________________________________________________________________________________________________________
47 #include <threadhelp/threadhelpbase.hxx>
48 #include <rtl/ustring.hxx>
49 #include <cppuhelper/weak.hxx>
51 #ifndef __SGI_STL_HASH_MAP
52 #include <hash_map>
53 #endif
54 #include <stdtypes.h>
56 //_________________________________________________________________________________________________________________
57 // namespace
58 //_________________________________________________________________________________________________________________
60 namespace framework{
62 //*****************************************************************************************************************
63 // Hash code function for using in all hash maps of follow implementation.
65 class OReadStatusBarDocumentHandler : public ::com::sun::star::xml::sax::XDocumentHandler,
66 private ThreadHelpBase, // Struct for right initalization of lock member! Must be first of baseclasses.
67 public ::cppu::OWeakObject
69 public:
70 enum StatusBar_XML_Entry
72 SB_ELEMENT_STATUSBAR,
73 SB_ELEMENT_STATUSBARITEM,
74 SB_ATTRIBUTE_URL,
75 SB_ATTRIBUTE_ALIGN,
76 SB_ATTRIBUTE_STYLE,
77 SB_ATTRIBUTE_AUTOSIZE,
78 SB_ATTRIBUTE_OWNERDRAW,
79 SB_ATTRIBUTE_WIDTH,
80 SB_ATTRIBUTE_OFFSET,
81 SB_XML_ENTRY_COUNT
84 enum StatusBar_XML_Namespace
86 SB_NS_STATUSBAR,
87 SB_NS_XLINK,
88 SB_XML_NAMESPACES_COUNT
91 OReadStatusBarDocumentHandler( StatusBarDescriptor& aStatusBarItems );
92 virtual ~OReadStatusBarDocumentHandler();
94 // XInterface
95 virtual void SAL_CALL acquire() throw()
96 { OWeakObject::acquire(); }
97 virtual void SAL_CALL release() throw()
98 { OWeakObject::release(); }
99 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface(
100 const ::com::sun::star::uno::Type & rType ) throw( ::com::sun::star::uno::RuntimeException );
102 // XDocumentHandler
103 virtual void SAL_CALL startDocument(void)
104 throw ( ::com::sun::star::xml::sax::SAXException,
105 ::com::sun::star::uno::RuntimeException );
107 virtual void SAL_CALL endDocument(void)
108 throw( ::com::sun::star::xml::sax::SAXException,
109 ::com::sun::star::uno::RuntimeException );
111 virtual void SAL_CALL startElement(
112 const rtl::OUString& aName,
113 const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > &xAttribs)
114 throw( ::com::sun::star::xml::sax::SAXException,
115 ::com::sun::star::uno::RuntimeException );
117 virtual void SAL_CALL endElement(const rtl::OUString& aName)
118 throw( ::com::sun::star::xml::sax::SAXException,
119 ::com::sun::star::uno::RuntimeException );
121 virtual void SAL_CALL characters(const rtl::OUString& aChars)
122 throw( ::com::sun::star::xml::sax::SAXException,
123 ::com::sun::star::uno::RuntimeException );
125 virtual void SAL_CALL ignorableWhitespace(const rtl::OUString& aWhitespaces)
126 throw( ::com::sun::star::xml::sax::SAXException,
127 ::com::sun::star::uno::RuntimeException );
129 virtual void SAL_CALL processingInstruction(const rtl::OUString& aTarget,
130 const rtl::OUString& aData)
131 throw( ::com::sun::star::xml::sax::SAXException,
132 ::com::sun::star::uno::RuntimeException );
134 virtual void SAL_CALL setDocumentLocator(
135 const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XLocator > &xLocator)
136 throw( ::com::sun::star::xml::sax::SAXException,
137 ::com::sun::star::uno::RuntimeException );
139 private:
140 ::rtl::OUString getErrorLineString();
142 class StatusBarHashMap : public ::std::hash_map< ::rtl::OUString ,
143 StatusBar_XML_Entry ,
144 OUStringHashCode ,
145 ::std::equal_to< ::rtl::OUString > >
147 public:
148 inline void free()
150 StatusBarHashMap().swap( *this );
154 sal_Bool m_bStatusBarStartFound;
155 sal_Bool m_bStatusBarEndFound;
156 sal_Bool m_bStatusBarItemStartFound;
157 StatusBarHashMap m_aStatusBarMap;
158 StatusBarDescriptor& m_aStatusBarItems;
159 ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XLocator > m_xLocator;
162 class OWriteStatusBarDocumentHandler : private ThreadHelpBase // Struct for right initalization of lock member! Must be first of baseclasses.
164 public:
165 OWriteStatusBarDocumentHandler(
166 const StatusBarDescriptor& aStatusBarItems,
167 ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > );
168 virtual ~OWriteStatusBarDocumentHandler();
170 void WriteStatusBarDocument() throw
171 ( ::com::sun::star::xml::sax::SAXException,
172 ::com::sun::star::uno::RuntimeException );
174 protected:
175 virtual void WriteStatusBarItem( const StatusBarItemDescriptor* ) throw
176 ( ::com::sun::star::xml::sax::SAXException,
177 ::com::sun::star::uno::RuntimeException );
179 const StatusBarDescriptor& m_aStatusBarItems;
180 ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > m_xWriteDocumentHandler;
181 ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > m_xEmptyList;
182 ::rtl::OUString m_aXMLStatusBarNS;
183 ::rtl::OUString m_aXMLXlinkNS;
184 ::rtl::OUString m_aAttributeType;
185 ::rtl::OUString m_aAttributeURL;
188 } // namespace framework
190 #endif