xref: /trunk/main/unotools/inc/unotools/xmlaccelcfg.hxx (revision 91144cd0085a7583d2099b982122deb2184ab956)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef INCLUDED_unotools_XMLACCELCFG_HXX
25 #define INCLUDED_unotools_XMLACCELCFG_HXX
26 
27 #ifndef __COM_SUN_STAR_XML_SAX_XDOCUMENTHANDLER_HPP_
28 #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
29 #endif
30 #include <cppuhelper/weak.hxx>
31 
32 #include <unotools/accelcfg.hxx>
33 
34 class OReadAccelatorDocumentHandler : public ::com::sun::star::xml::sax::XDocumentHandler,
35                                       public ::cppu::OWeakObject
36 {
37     public:
OReadAccelatorDocumentHandler(SvtAcceleratorItemList & aNewAcceleratorItemList)38         OReadAccelatorDocumentHandler( SvtAcceleratorItemList& aNewAcceleratorItemList ) :
39             m_nElementDepth( 0 ),
40             m_bAcceleratorMode( sal_False ),
41             m_bItemCloseExpected( sal_False ),
42             m_xLocator( 0 ),
43             m_aReadAcceleratorList( aNewAcceleratorItemList ) {}
~OReadAccelatorDocumentHandler()44         virtual ~OReadAccelatorDocumentHandler() {}
45 
46         // XInterface
acquire()47         virtual void SAL_CALL acquire() throw()
48             { OWeakObject::acquire(); }
release()49         virtual void SAL_CALL release() throw()
50             { OWeakObject::release(); }
51         virtual ::com::sun::star::uno::Any SAL_CALL queryInterface(
52             const ::com::sun::star::uno::Type & rType );
53 
54         // XDocumentHandler
55         virtual void SAL_CALL startDocument(void);
56         virtual void SAL_CALL endDocument(void);
57         virtual void SAL_CALL startElement(
58             const ::rtl::OUString& aName,
59             const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > &xAttribs );
60         virtual void SAL_CALL endElement(const ::rtl::OUString& aName);
61         virtual void SAL_CALL characters(const ::rtl::OUString& aChars);
62         virtual void SAL_CALL ignorableWhitespace(const ::rtl::OUString& aWhitespaces);
63         virtual void SAL_CALL processingInstruction( const ::rtl::OUString& aTarget, const ::rtl::OUString& aData );
64         virtual void SAL_CALL setDocumentLocator(
65             const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XLocator > &xLocator);
66 
67     private:
68         ::rtl::OUString getErrorLineString();
69 
70         int                     m_nElementDepth;
71         sal_Bool                m_bAcceleratorMode;
72         sal_Bool                m_bItemCloseExpected;
73         ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XLocator >    m_xLocator;
74         SvtAcceleratorItemList& m_aReadAcceleratorList;
75 };
76 
77 
78 class OWriteAccelatorDocumentHandler
79 {
80     public:
81         OWriteAccelatorDocumentHandler(
82             const SvtAcceleratorItemList& aWriteAcceleratorList,
83             ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > );
84         virtual ~OWriteAccelatorDocumentHandler();
85 
86         void WriteAcceleratorDocument();
87 
88     private:
89         void WriteAcceleratorItem( const SvtAcceleratorConfigItem& aAcceleratorItem );
90 
91         ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > m_xWriteDocumentHandler;
92         ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > m_xEmptyList;
93         ::rtl::OUString                                         m_aAttributeType;
94         const SvtAcceleratorItemList&                           m_aWriteAcceleratorList;
95 };
96 
97 #endif // INCLUDED_unotools_XMLACCELCFG_HXX
98