Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef __FRAMEWORK_XML_STATUSBARDOCUMENTHANDLER_HXX_
30 : : #define __FRAMEWORK_XML_STATUSBARDOCUMENTHANDLER_HXX_
31 : :
32 : : #include <framework/statusbarconfiguration.hxx>
33 : :
34 : : #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
35 : :
36 : : #include <threadhelp/threadhelpbase.hxx>
37 : : #include <rtl/ustring.hxx>
38 : : #include <cppuhelper/implbase1.hxx>
39 : :
40 : : #include <boost/unordered_map.hpp>
41 : : #include <stdtypes.h>
42 : : #include <framework/fwedllapi.h>
43 : :
44 : : namespace framework{
45 : :
46 : : //*****************************************************************************************************************
47 : : // Hash code function for using in all hash maps of follow implementation.
48 : :
49 : : class FWE_DLLPUBLIC OReadStatusBarDocumentHandler : private ThreadHelpBase, // Struct for right initalization of lock member! Must be first of baseclasses.
50 : : public ::cppu::WeakImplHelper1< ::com::sun::star::xml::sax::XDocumentHandler >
51 : : {
52 : : public:
53 : : enum StatusBar_XML_Entry
54 : : {
55 : : SB_ELEMENT_STATUSBAR,
56 : : SB_ELEMENT_STATUSBARITEM,
57 : : SB_ATTRIBUTE_URL,
58 : : SB_ATTRIBUTE_ALIGN,
59 : : SB_ATTRIBUTE_STYLE,
60 : : SB_ATTRIBUTE_AUTOSIZE,
61 : : SB_ATTRIBUTE_OWNERDRAW,
62 : : SB_ATTRIBUTE_WIDTH,
63 : : SB_ATTRIBUTE_OFFSET,
64 : : SB_ATTRIBUTE_HELPURL,
65 : : SB_XML_ENTRY_COUNT
66 : : };
67 : :
68 : : enum StatusBar_XML_Namespace
69 : : {
70 : : SB_NS_STATUSBAR,
71 : : SB_NS_XLINK,
72 : : SB_XML_NAMESPACES_COUNT
73 : : };
74 : :
75 : : OReadStatusBarDocumentHandler( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer >& aStatusBarItems );
76 : : virtual ~OReadStatusBarDocumentHandler();
77 : :
78 : : // XDocumentHandler
79 : : virtual void SAL_CALL startDocument(void)
80 : : throw ( ::com::sun::star::xml::sax::SAXException,
81 : : ::com::sun::star::uno::RuntimeException );
82 : :
83 : : virtual void SAL_CALL endDocument(void)
84 : : throw( ::com::sun::star::xml::sax::SAXException,
85 : : ::com::sun::star::uno::RuntimeException );
86 : :
87 : : virtual void SAL_CALL startElement(
88 : : const rtl::OUString& aName,
89 : : const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > &xAttribs)
90 : : throw( ::com::sun::star::xml::sax::SAXException,
91 : : ::com::sun::star::uno::RuntimeException );
92 : :
93 : : virtual void SAL_CALL endElement(const rtl::OUString& aName)
94 : : throw( ::com::sun::star::xml::sax::SAXException,
95 : : ::com::sun::star::uno::RuntimeException );
96 : :
97 : : virtual void SAL_CALL characters(const rtl::OUString& aChars)
98 : : throw( ::com::sun::star::xml::sax::SAXException,
99 : : ::com::sun::star::uno::RuntimeException );
100 : :
101 : : virtual void SAL_CALL ignorableWhitespace(const rtl::OUString& aWhitespaces)
102 : : throw( ::com::sun::star::xml::sax::SAXException,
103 : : ::com::sun::star::uno::RuntimeException );
104 : :
105 : : virtual void SAL_CALL processingInstruction(const rtl::OUString& aTarget,
106 : : const rtl::OUString& aData)
107 : : throw( ::com::sun::star::xml::sax::SAXException,
108 : : ::com::sun::star::uno::RuntimeException );
109 : :
110 : : virtual void SAL_CALL setDocumentLocator(
111 : : const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XLocator > &xLocator)
112 : : throw( ::com::sun::star::xml::sax::SAXException,
113 : : ::com::sun::star::uno::RuntimeException );
114 : :
115 : : private:
116 : : ::rtl::OUString getErrorLineString();
117 : :
118 [ + - ]: 180 : class StatusBarHashMap : public ::boost::unordered_map< ::rtl::OUString ,
119 : : StatusBar_XML_Entry ,
120 : : OUStringHashCode ,
121 : : ::std::equal_to< ::rtl::OUString > >
122 : : {
123 : : public:
124 : : inline void free()
125 : : {
126 : : StatusBarHashMap().swap( *this );
127 : : }
128 : : };
129 : :
130 : : sal_Bool m_bStatusBarStartFound;
131 : : sal_Bool m_bStatusBarEndFound;
132 : : sal_Bool m_bStatusBarItemStartFound;
133 : : StatusBarHashMap m_aStatusBarMap;
134 : : ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer > m_aStatusBarItems;
135 : : ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XLocator > m_xLocator;
136 : : };
137 : :
138 : : class FWE_DLLPUBLIC OWriteStatusBarDocumentHandler : private ThreadHelpBase // Struct for right initalization of lock member! Must be first of baseclasses.
139 : : {
140 : : public:
141 : : OWriteStatusBarDocumentHandler(
142 : : const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess >& rStatusBarItems,
143 : : const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler >& rWriteDocHandler );
144 : : virtual ~OWriteStatusBarDocumentHandler();
145 : :
146 : : void WriteStatusBarDocument() throw
147 : : ( ::com::sun::star::xml::sax::SAXException,
148 : : ::com::sun::star::uno::RuntimeException );
149 : :
150 : : protected:
151 : : virtual void WriteStatusBarItem(
152 : : const rtl::OUString& rCommandURL,
153 : : const rtl::OUString& rHelpURL,
154 : : sal_Int16 nOffset,
155 : : sal_Int16 nStyle,
156 : : sal_Int16 nWidth ) throw
157 : : ( ::com::sun::star::xml::sax::SAXException,
158 : : ::com::sun::star::uno::RuntimeException );
159 : :
160 : : ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > m_aStatusBarItems;
161 : : ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > m_xWriteDocumentHandler;
162 : : ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > m_xEmptyList;
163 : : ::rtl::OUString m_aXMLStatusBarNS;
164 : : ::rtl::OUString m_aXMLXlinkNS;
165 : : ::rtl::OUString m_aAttributeType;
166 : : ::rtl::OUString m_aAttributeURL;
167 : : };
168 : :
169 : : } // namespace framework
170 : :
171 : : #endif
172 : :
173 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|