Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef __FRAMEWORK_XML_STATUSBARDOCUMENTHANDLER_HXX_
21 : #define __FRAMEWORK_XML_STATUSBARDOCUMENTHANDLER_HXX_
22 :
23 : #include <framework/statusbarconfiguration.hxx>
24 :
25 : #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
26 :
27 : #include <threadhelp/threadhelpbase.hxx>
28 : #include <rtl/ustring.hxx>
29 : #include <cppuhelper/implbase1.hxx>
30 :
31 : #include <boost/unordered_map.hpp>
32 : #include <stdtypes.h>
33 : #include <framework/fwedllapi.h>
34 :
35 : namespace framework{
36 :
37 : //*****************************************************************************************************************
38 : // Hash code function for using in all hash maps of follow implementation.
39 :
40 : class FWE_DLLPUBLIC OReadStatusBarDocumentHandler : private ThreadHelpBase, // Struct for right initalization of lock member! Must be first of baseclasses.
41 : public ::cppu::WeakImplHelper1< ::com::sun::star::xml::sax::XDocumentHandler >
42 : {
43 : public:
44 : enum StatusBar_XML_Entry
45 : {
46 : SB_ELEMENT_STATUSBAR,
47 : SB_ELEMENT_STATUSBARITEM,
48 : SB_ATTRIBUTE_URL,
49 : SB_ATTRIBUTE_ALIGN,
50 : SB_ATTRIBUTE_STYLE,
51 : SB_ATTRIBUTE_AUTOSIZE,
52 : SB_ATTRIBUTE_OWNERDRAW,
53 : SB_ATTRIBUTE_WIDTH,
54 : SB_ATTRIBUTE_OFFSET,
55 : SB_ATTRIBUTE_HELPURL,
56 : SB_XML_ENTRY_COUNT
57 : };
58 :
59 : enum StatusBar_XML_Namespace
60 : {
61 : SB_NS_STATUSBAR,
62 : SB_NS_XLINK,
63 : SB_XML_NAMESPACES_COUNT
64 : };
65 :
66 : OReadStatusBarDocumentHandler( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer >& aStatusBarItems );
67 : virtual ~OReadStatusBarDocumentHandler();
68 :
69 : // XDocumentHandler
70 : virtual void SAL_CALL startDocument(void)
71 : throw ( ::com::sun::star::xml::sax::SAXException,
72 : ::com::sun::star::uno::RuntimeException );
73 :
74 : virtual void SAL_CALL endDocument(void)
75 : throw( ::com::sun::star::xml::sax::SAXException,
76 : ::com::sun::star::uno::RuntimeException );
77 :
78 : virtual void SAL_CALL startElement(
79 : const rtl::OUString& aName,
80 : const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > &xAttribs)
81 : throw( ::com::sun::star::xml::sax::SAXException,
82 : ::com::sun::star::uno::RuntimeException );
83 :
84 : virtual void SAL_CALL endElement(const rtl::OUString& aName)
85 : throw( ::com::sun::star::xml::sax::SAXException,
86 : ::com::sun::star::uno::RuntimeException );
87 :
88 : virtual void SAL_CALL characters(const rtl::OUString& aChars)
89 : throw( ::com::sun::star::xml::sax::SAXException,
90 : ::com::sun::star::uno::RuntimeException );
91 :
92 : virtual void SAL_CALL ignorableWhitespace(const rtl::OUString& aWhitespaces)
93 : throw( ::com::sun::star::xml::sax::SAXException,
94 : ::com::sun::star::uno::RuntimeException );
95 :
96 : virtual void SAL_CALL processingInstruction(const rtl::OUString& aTarget,
97 : const rtl::OUString& aData)
98 : throw( ::com::sun::star::xml::sax::SAXException,
99 : ::com::sun::star::uno::RuntimeException );
100 :
101 : virtual void SAL_CALL setDocumentLocator(
102 : const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XLocator > &xLocator)
103 : throw( ::com::sun::star::xml::sax::SAXException,
104 : ::com::sun::star::uno::RuntimeException );
105 :
106 : private:
107 : ::rtl::OUString getErrorLineString();
108 :
109 0 : class StatusBarHashMap : public ::boost::unordered_map< ::rtl::OUString ,
110 : StatusBar_XML_Entry ,
111 : OUStringHashCode ,
112 : ::std::equal_to< ::rtl::OUString > >
113 : {
114 : public:
115 : inline void free()
116 : {
117 : StatusBarHashMap().swap( *this );
118 : }
119 : };
120 :
121 : sal_Bool m_bStatusBarStartFound;
122 : sal_Bool m_bStatusBarEndFound;
123 : sal_Bool m_bStatusBarItemStartFound;
124 : StatusBarHashMap m_aStatusBarMap;
125 : ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer > m_aStatusBarItems;
126 : ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XLocator > m_xLocator;
127 : };
128 :
129 : class FWE_DLLPUBLIC OWriteStatusBarDocumentHandler : private ThreadHelpBase // Struct for right initalization of lock member! Must be first of baseclasses.
130 : {
131 : public:
132 : OWriteStatusBarDocumentHandler(
133 : const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess >& rStatusBarItems,
134 : const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler >& rWriteDocHandler );
135 : virtual ~OWriteStatusBarDocumentHandler();
136 :
137 : void WriteStatusBarDocument() throw
138 : ( ::com::sun::star::xml::sax::SAXException,
139 : ::com::sun::star::uno::RuntimeException );
140 :
141 : protected:
142 : virtual void WriteStatusBarItem(
143 : const rtl::OUString& rCommandURL,
144 : const rtl::OUString& rHelpURL,
145 : sal_Int16 nOffset,
146 : sal_Int16 nStyle,
147 : sal_Int16 nWidth ) throw
148 : ( ::com::sun::star::xml::sax::SAXException,
149 : ::com::sun::star::uno::RuntimeException );
150 :
151 : ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > m_aStatusBarItems;
152 : ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > m_xWriteDocumentHandler;
153 : ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > m_xEmptyList;
154 : ::rtl::OUString m_aXMLStatusBarNS;
155 : ::rtl::OUString m_aXMLXlinkNS;
156 : ::rtl::OUString m_aAttributeType;
157 : ::rtl::OUString m_aAttributeURL;
158 : };
159 :
160 : } // namespace framework
161 :
162 : #endif
163 :
164 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|