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_ACCELERATORCONFIGURATIONREADER_HXX_
25cdf0e10cSrcweir #define _FRAMEWORK_XML_ACCELERATORCONFIGURATIONREADER_HXX_
26cdf0e10cSrcweir 
27cdf0e10cSrcweir //_______________________________________________
28cdf0e10cSrcweir // own includes
29cdf0e10cSrcweir 
30cdf0e10cSrcweir #include <accelerators/acceleratorcache.hxx>
31cdf0e10cSrcweir #include <accelerators/keymapping.hxx>
32cdf0e10cSrcweir #include <macros/xinterface.hxx>
33cdf0e10cSrcweir #include <threadhelp/threadhelpbase.hxx>
34cdf0e10cSrcweir #include <general.h>
35cdf0e10cSrcweir 
36cdf0e10cSrcweir //_______________________________________________
37cdf0e10cSrcweir // interface includes
38cdf0e10cSrcweir 
39cdf0e10cSrcweir #ifndef __COM_SUN_STAR_XML_SAX_XDOCUMENTHANDLER_HPP_
40cdf0e10cSrcweir #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
41cdf0e10cSrcweir #endif
42cdf0e10cSrcweir 
43cdf0e10cSrcweir #ifndef __COM_SUN_STAR_XML_SAX_XLOCATOR_HPP_
44cdf0e10cSrcweir #include <com/sun/star/xml/sax/XLocator.hpp>
45cdf0e10cSrcweir #endif
46cdf0e10cSrcweir 
47cdf0e10cSrcweir //_______________________________________________
48cdf0e10cSrcweir // other includes
49cdf0e10cSrcweir #include <salhelper/singletonref.hxx>
50cdf0e10cSrcweir #include <cppuhelper/weak.hxx>
51cdf0e10cSrcweir #include <rtl/ustring.hxx>
52cdf0e10cSrcweir 
53cdf0e10cSrcweir namespace framework{
54cdf0e10cSrcweir 
55cdf0e10cSrcweir class AcceleratorConfigurationReader : public  css::xml::sax::XDocumentHandler
56cdf0e10cSrcweir                                      , private ThreadHelpBase
57cdf0e10cSrcweir                                      , public  ::cppu::OWeakObject
58cdf0e10cSrcweir {
59cdf0e10cSrcweir     //-------------------------------------------
60cdf0e10cSrcweir     // const, types
61cdf0e10cSrcweir 
62cdf0e10cSrcweir     private:
63cdf0e10cSrcweir 
64cdf0e10cSrcweir         //---------------------------------------
65cdf0e10cSrcweir         /** @short  classification of XML elements. */
66cdf0e10cSrcweir 		enum EXMLElement
67cdf0e10cSrcweir 		{
68cdf0e10cSrcweir 			E_ELEMENT_ACCELERATORLIST,
69cdf0e10cSrcweir 			E_ELEMENT_ITEM
70cdf0e10cSrcweir         };
71cdf0e10cSrcweir 
72cdf0e10cSrcweir         //---------------------------------------
73cdf0e10cSrcweir         /** @short  classification of XML attributes. */
74cdf0e10cSrcweir         enum EXMLAttribute
75cdf0e10cSrcweir         {
76cdf0e10cSrcweir 			E_ATTRIBUTE_KEYCODE,
77cdf0e10cSrcweir 			E_ATTRIBUTE_MOD_SHIFT,
78cdf0e10cSrcweir 			E_ATTRIBUTE_MOD_MOD1,
79cdf0e10cSrcweir 			E_ATTRIBUTE_MOD_MOD2,
80cdf0e10cSrcweir                         E_ATTRIBUTE_MOD_MOD3,
81cdf0e10cSrcweir 			E_ATTRIBUTE_URL
82cdf0e10cSrcweir 		};
83cdf0e10cSrcweir 
84cdf0e10cSrcweir         //---------------------------------------
85cdf0e10cSrcweir         /** @short  some namespace defines */
86cdf0e10cSrcweir 		enum EAcceleratorXMLNamespace
87cdf0e10cSrcweir 		{
88cdf0e10cSrcweir 			E_NAMESPACE_ACCEL,
89cdf0e10cSrcweir 			E_NAMESPACE_XLINK
90cdf0e10cSrcweir 		};
91cdf0e10cSrcweir 
92cdf0e10cSrcweir     //-------------------------------------------
93cdf0e10cSrcweir     // member
94cdf0e10cSrcweir 
95cdf0e10cSrcweir     private:
96cdf0e10cSrcweir 
97cdf0e10cSrcweir         //---------------------------------------
98cdf0e10cSrcweir         /** @short  needed to read the xml configuration. */
99cdf0e10cSrcweir         css::uno::Reference< css::xml::sax::XDocumentHandler > m_xReader;
100cdf0e10cSrcweir 
101cdf0e10cSrcweir         //---------------------------------------
102cdf0e10cSrcweir         /** @short  reference to the outside container, where this
103cdf0e10cSrcweir                     reader/writer must work on. */
104cdf0e10cSrcweir         AcceleratorCache& m_rContainer;
105cdf0e10cSrcweir 
106cdf0e10cSrcweir         //---------------------------------------
107cdf0e10cSrcweir         /** @short  used to detect if an accelerator list
108*30acf5e8Spfg                     occurs recursive inside xml. */
109cdf0e10cSrcweir 		sal_Bool m_bInsideAcceleratorList;
110cdf0e10cSrcweir 
111cdf0e10cSrcweir         //---------------------------------------
112cdf0e10cSrcweir         /** @short  used to detect if an accelerator item
113*30acf5e8Spfg                     occurs recursive inside xml. */
114cdf0e10cSrcweir 		sal_Bool m_bInsideAcceleratorItem;
115cdf0e10cSrcweir 
116cdf0e10cSrcweir         //---------------------------------------
117cdf0e10cSrcweir         /** @short  is used to map key codes to its
118cdf0e10cSrcweir                     string representation.
119cdf0e10cSrcweir 
120cdf0e10cSrcweir             @descr  To perform this operatio is
121cdf0e10cSrcweir                     created only one times and holded
122cdf0e10cSrcweir                     alive forever ...*/
123cdf0e10cSrcweir         ::salhelper::SingletonRef< KeyMapping > m_rKeyMapping;
124cdf0e10cSrcweir 
125cdf0e10cSrcweir         //---------------------------------------
126cdf0e10cSrcweir         /** @short  provide informations abou the parsing state.
127cdf0e10cSrcweir 
128cdf0e10cSrcweir             @descr  We use it to find out the line and column, where
12907a3d7f1SPedro Giffuni                     an error occur.
130cdf0e10cSrcweir           */
131cdf0e10cSrcweir 		css::uno::Reference< css::xml::sax::XLocator > m_xLocator;
132cdf0e10cSrcweir 
133cdf0e10cSrcweir /*        SfxAcceleratorItemList& m_aReadAcceleratorList;
134cdf0e10cSrcweir */
135cdf0e10cSrcweir 
136cdf0e10cSrcweir     //-------------------------------------------
137cdf0e10cSrcweir     // interface
138cdf0e10cSrcweir 
139cdf0e10cSrcweir 	public:
140cdf0e10cSrcweir 
141cdf0e10cSrcweir         //---------------------------------------
142cdf0e10cSrcweir         /** @short  connect this new reader/writer instance
143cdf0e10cSrcweir                     to an outside container, which should be used
144cdf0e10cSrcweir                     flushed to the underlying XML configuration or
145cdf0e10cSrcweir                     filled from there.
146cdf0e10cSrcweir 
147cdf0e10cSrcweir             @param  rContainer
148cdf0e10cSrcweir                     a reference to the outside container.
149cdf0e10cSrcweir           */
150cdf0e10cSrcweir         AcceleratorConfigurationReader(AcceleratorCache& rContainer);
151cdf0e10cSrcweir 
152cdf0e10cSrcweir         //---------------------------------------
153cdf0e10cSrcweir         /** @short  does nothing real ... */
154cdf0e10cSrcweir 		virtual ~AcceleratorConfigurationReader();
155cdf0e10cSrcweir 
156cdf0e10cSrcweir         //---------------------------------------
157cdf0e10cSrcweir         // XInterface
158cdf0e10cSrcweir         FWK_DECLARE_XINTERFACE
159cdf0e10cSrcweir 
160cdf0e10cSrcweir         //---------------------------------------
161cdf0e10cSrcweir 		// XDocumentHandler
162cdf0e10cSrcweir 		virtual void SAL_CALL startDocument()
163cdf0e10cSrcweir 			throw(css::xml::sax::SAXException,
164cdf0e10cSrcweir                   css::uno::RuntimeException );
165cdf0e10cSrcweir 
166cdf0e10cSrcweir 		virtual void SAL_CALL endDocument()
167cdf0e10cSrcweir 			throw(css::xml::sax::SAXException,
168cdf0e10cSrcweir                   css::uno::RuntimeException );
169cdf0e10cSrcweir 
170cdf0e10cSrcweir 		virtual void SAL_CALL startElement(const ::rtl::OUString&                                      sElement      ,
171cdf0e10cSrcweir 			                               const css::uno::Reference< css::xml::sax::XAttributeList >& xAttributeList)
172cdf0e10cSrcweir 			throw(css::xml::sax::SAXException,
173cdf0e10cSrcweir                   css::uno::RuntimeException );
174cdf0e10cSrcweir 
175cdf0e10cSrcweir 		virtual void SAL_CALL endElement(const ::rtl::OUString& sElement)
176cdf0e10cSrcweir             throw(css::xml::sax::SAXException,
177cdf0e10cSrcweir                   css::uno::RuntimeException );
178cdf0e10cSrcweir 
179cdf0e10cSrcweir 		virtual void SAL_CALL characters(const ::rtl::OUString& sChars)
180cdf0e10cSrcweir 			throw(css::xml::sax::SAXException,
181cdf0e10cSrcweir                   css::uno::RuntimeException );
182cdf0e10cSrcweir 
183cdf0e10cSrcweir 		virtual void SAL_CALL ignorableWhitespace(const ::rtl::OUString& sWhitespaces)
184cdf0e10cSrcweir 			throw(css::xml::sax::SAXException,
185cdf0e10cSrcweir                   css::uno::RuntimeException );
186cdf0e10cSrcweir 
187cdf0e10cSrcweir 		virtual void SAL_CALL processingInstruction(const ::rtl::OUString& sTarget,
188cdf0e10cSrcweir                                                     const ::rtl::OUString& sData  )
189cdf0e10cSrcweir 			throw(css::xml::sax::SAXException,
190cdf0e10cSrcweir                   css::uno::RuntimeException );
191cdf0e10cSrcweir 
192cdf0e10cSrcweir 		virtual void SAL_CALL setDocumentLocator(const css::uno::Reference< css::xml::sax::XLocator >& xLocator)
193cdf0e10cSrcweir 			throw(css::xml::sax::SAXException,
194cdf0e10cSrcweir                   css::uno::RuntimeException );
195cdf0e10cSrcweir 
196cdf0e10cSrcweir     //-------------------------------------------
197cdf0e10cSrcweir     // helper
198cdf0e10cSrcweir 
199cdf0e10cSrcweir     private:
200cdf0e10cSrcweir 
201cdf0e10cSrcweir         //---------------------------------------
202cdf0e10cSrcweir         /** TODO document me */
203cdf0e10cSrcweir 		static EXMLElement implst_classifyElement(const ::rtl::OUString& sElement);
204cdf0e10cSrcweir 
205cdf0e10cSrcweir         //---------------------------------------
206cdf0e10cSrcweir         /** TODO document me */
207cdf0e10cSrcweir 		static EXMLAttribute implst_classifyAttribute(const ::rtl::OUString& sAttribute);
208cdf0e10cSrcweir 
209cdf0e10cSrcweir         //---------------------------------------
210cdf0e10cSrcweir         /** TODO document me */
211cdf0e10cSrcweir 		::rtl::OUString implts_getErrorLineString();
212cdf0e10cSrcweir };
213cdf0e10cSrcweir 
214cdf0e10cSrcweir } // namespace framework
215cdf0e10cSrcweir 
216cdf0e10cSrcweir #endif // _FRAMEWORK_XML_ACCELERATORCONFIGURATIONREADER_HXX_
217