xref: /AOO41X/main/unotools/inc/unotools/xmlaccelcfg.hxx (revision bae3752ec30c258ca902793e4eea3c818b0bcaad)
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 ) throw( ::com::sun::star::uno::RuntimeException );
53 
54         // XDocumentHandler
55         virtual void SAL_CALL startDocument(void)
56             throw ( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException );
57         virtual void SAL_CALL endDocument(void)
58             throw ( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException );
59         virtual void SAL_CALL startElement(
60             const ::rtl::OUString& aName,
61             const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > &xAttribs )
62             throw( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException );
63         virtual void SAL_CALL endElement(const ::rtl::OUString& aName) throw
64             ( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException );
65         virtual void SAL_CALL characters(const ::rtl::OUString& aChars)
66             throw( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException );
67         virtual void SAL_CALL ignorableWhitespace(const ::rtl::OUString& aWhitespaces)
68             throw( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException );
69         virtual void SAL_CALL processingInstruction( const ::rtl::OUString& aTarget, const ::rtl::OUString& aData )
70             throw( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException );
71         virtual void SAL_CALL setDocumentLocator(
72             const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XLocator > &xLocator)
73             throw( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException );
74 
75     private:
76         ::rtl::OUString getErrorLineString();
77 
78         int                     m_nElementDepth;
79         sal_Bool                m_bAcceleratorMode;
80         sal_Bool                m_bItemCloseExpected;
81         ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XLocator >    m_xLocator;
82         SvtAcceleratorItemList& m_aReadAcceleratorList;
83 };
84 
85 
86 class OWriteAccelatorDocumentHandler
87 {
88     public:
89         OWriteAccelatorDocumentHandler(
90             const SvtAcceleratorItemList& aWriteAcceleratorList,
91             ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > );
92         virtual ~OWriteAccelatorDocumentHandler();
93 
94         void WriteAcceleratorDocument() throw ( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException );
95 
96     private:
97         void WriteAcceleratorItem( const SvtAcceleratorConfigItem& aAcceleratorItem ) throw( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException );
98 
99         ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > m_xWriteDocumentHandler;
100         ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > m_xEmptyList;
101         ::rtl::OUString                                         m_aAttributeType;
102         const SvtAcceleratorItemList&                           m_aWriteAcceleratorList;
103 };
104 
105 #endif // INCLUDED_unotools_XMLACCELCFG_HXX
106