Update ooo320-m1
[ooovba.git] / framework / inc / xml / statusbardocumenthandler.hxx
blobc27c4e6c4bc29ad3015e271d9c19232ea12c595c
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.6 $
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_XML_STATUSBARDOCUMENTHANDLER_HXX_
32 #define __FRAMEWORK_XML_STATUSBARDOCUMENTHANDLER_HXX_
34 #ifndef __FRAMEWORK_XML_STATUSBARCONFIGURATION_HXX_
35 #include <xml/statusbarconfiguration.hxx>
36 #endif
38 //_________________________________________________________________________________________________________________
39 // interface includes
40 //_________________________________________________________________________________________________________________
42 #ifndef __COM_SUN_STAR_XML_SAX_XDOCUMENTHANDLER_HPP_
43 #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
44 #endif
46 //_________________________________________________________________________________________________________________
47 // other includes
48 //_________________________________________________________________________________________________________________
49 #include <threadhelp/threadhelpbase.hxx>
50 #include <rtl/ustring.hxx>
51 #include <cppuhelper/implbase1.hxx>
53 #include <hash_map>
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 : private ThreadHelpBase, // Struct for right initalization of lock member! Must be first of baseclasses.
66 public ::cppu::WeakImplHelper1< ::com::sun::star::xml::sax::XDocumentHandler >
68 public:
69 enum StatusBar_XML_Entry
71 SB_ELEMENT_STATUSBAR,
72 SB_ELEMENT_STATUSBARITEM,
73 SB_ATTRIBUTE_URL,
74 SB_ATTRIBUTE_ALIGN,
75 SB_ATTRIBUTE_STYLE,
76 SB_ATTRIBUTE_AUTOSIZE,
77 SB_ATTRIBUTE_OWNERDRAW,
78 SB_ATTRIBUTE_WIDTH,
79 SB_ATTRIBUTE_OFFSET,
80 SB_ATTRIBUTE_HELPURL,
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( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer >& aStatusBarItems );
92 virtual ~OReadStatusBarDocumentHandler();
94 // XDocumentHandler
95 virtual void SAL_CALL startDocument(void)
96 throw ( ::com::sun::star::xml::sax::SAXException,
97 ::com::sun::star::uno::RuntimeException );
99 virtual void SAL_CALL endDocument(void)
100 throw( ::com::sun::star::xml::sax::SAXException,
101 ::com::sun::star::uno::RuntimeException );
103 virtual void SAL_CALL startElement(
104 const rtl::OUString& aName,
105 const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > &xAttribs)
106 throw( ::com::sun::star::xml::sax::SAXException,
107 ::com::sun::star::uno::RuntimeException );
109 virtual void SAL_CALL endElement(const rtl::OUString& aName)
110 throw( ::com::sun::star::xml::sax::SAXException,
111 ::com::sun::star::uno::RuntimeException );
113 virtual void SAL_CALL characters(const rtl::OUString& aChars)
114 throw( ::com::sun::star::xml::sax::SAXException,
115 ::com::sun::star::uno::RuntimeException );
117 virtual void SAL_CALL ignorableWhitespace(const rtl::OUString& aWhitespaces)
118 throw( ::com::sun::star::xml::sax::SAXException,
119 ::com::sun::star::uno::RuntimeException );
121 virtual void SAL_CALL processingInstruction(const rtl::OUString& aTarget,
122 const rtl::OUString& aData)
123 throw( ::com::sun::star::xml::sax::SAXException,
124 ::com::sun::star::uno::RuntimeException );
126 virtual void SAL_CALL setDocumentLocator(
127 const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XLocator > &xLocator)
128 throw( ::com::sun::star::xml::sax::SAXException,
129 ::com::sun::star::uno::RuntimeException );
131 private:
132 ::rtl::OUString getErrorLineString();
134 class StatusBarHashMap : public ::std::hash_map< ::rtl::OUString ,
135 StatusBar_XML_Entry ,
136 OUStringHashCode ,
137 ::std::equal_to< ::rtl::OUString > >
139 public:
140 inline void free()
142 StatusBarHashMap().swap( *this );
146 sal_Bool m_bStatusBarStartFound;
147 sal_Bool m_bStatusBarEndFound;
148 sal_Bool m_bStatusBarItemStartFound;
149 StatusBarHashMap m_aStatusBarMap;
150 ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer > m_aStatusBarItems;
151 ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XLocator > m_xLocator;
154 class OWriteStatusBarDocumentHandler : private ThreadHelpBase // Struct for right initalization of lock member! Must be first of baseclasses.
156 public:
157 OWriteStatusBarDocumentHandler(
158 const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess >& rStatusBarItems,
159 const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler >& rWriteDocHandler );
160 virtual ~OWriteStatusBarDocumentHandler();
162 void WriteStatusBarDocument() throw
163 ( ::com::sun::star::xml::sax::SAXException,
164 ::com::sun::star::uno::RuntimeException );
166 protected:
167 virtual void WriteStatusBarItem(
168 const rtl::OUString& rCommandURL,
169 const rtl::OUString& rHelpURL,
170 sal_Int16 nOffset,
171 sal_Int16 nStyle,
172 sal_Int16 nWidth ) throw
173 ( ::com::sun::star::xml::sax::SAXException,
174 ::com::sun::star::uno::RuntimeException );
176 ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > m_aStatusBarItems;
177 ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > m_xWriteDocumentHandler;
178 ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > m_xEmptyList;
179 ::rtl::OUString m_aXMLStatusBarNS;
180 ::rtl::OUString m_aXMLXlinkNS;
181 ::rtl::OUString m_aAttributeType;
182 ::rtl::OUString m_aAttributeURL;
185 } // namespace framework
187 #endif