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 INCLUDED_unotools_XMLACCELCFG_HXX
21 : #define INCLUDED_unotools_XMLACCELCFG_HXX
22 :
23 : #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
24 : #include <cppuhelper/weak.hxx>
25 :
26 0 : struct SvtAcceleratorConfigItem
27 : {
28 : sal_uInt16 nCode;
29 : sal_uInt16 nModifier;
30 : OUString aCommand;
31 : };
32 :
33 : #include <list>
34 : typedef ::std::list < SvtAcceleratorConfigItem > SvtAcceleratorItemList;
35 :
36 :
37 : class OReadAccelatorDocumentHandler : public ::com::sun::star::xml::sax::XDocumentHandler,
38 : public ::cppu::OWeakObject
39 : {
40 : public:
41 : OReadAccelatorDocumentHandler( SvtAcceleratorItemList& aNewAcceleratorItemList ) :
42 : m_nElementDepth( 0 ),
43 : m_bAcceleratorMode( sal_False ),
44 : m_bItemCloseExpected( sal_False ),
45 : m_xLocator( 0 ),
46 : m_aReadAcceleratorList( aNewAcceleratorItemList ) {}
47 0 : virtual ~OReadAccelatorDocumentHandler() {}
48 :
49 : // XInterface
50 0 : virtual void SAL_CALL acquire() throw()
51 0 : { OWeakObject::acquire(); }
52 0 : virtual void SAL_CALL release() throw()
53 0 : { OWeakObject::release(); }
54 : virtual ::com::sun::star::uno::Any SAL_CALL queryInterface(
55 : const ::com::sun::star::uno::Type & rType ) throw( ::com::sun::star::uno::RuntimeException );
56 :
57 : // XDocumentHandler
58 : virtual void SAL_CALL startDocument(void)
59 : throw ( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException );
60 : virtual void SAL_CALL endDocument(void)
61 : throw ( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException );
62 : virtual void SAL_CALL startElement(
63 : const OUString& aName,
64 : const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > &xAttribs )
65 : throw( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException );
66 : virtual void SAL_CALL endElement(const OUString& aName) throw
67 : ( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException );
68 : virtual void SAL_CALL characters(const OUString& aChars)
69 : throw( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException );
70 : virtual void SAL_CALL ignorableWhitespace(const OUString& aWhitespaces)
71 : throw( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException );
72 : virtual void SAL_CALL processingInstruction( const OUString& aTarget, const OUString& aData )
73 : throw( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException );
74 : virtual void SAL_CALL setDocumentLocator(
75 : const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XLocator > &xLocator)
76 : throw( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException );
77 :
78 : private:
79 : OUString getErrorLineString();
80 :
81 : int m_nElementDepth;
82 : sal_Bool m_bAcceleratorMode;
83 : sal_Bool m_bItemCloseExpected;
84 : ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XLocator > m_xLocator;
85 : SvtAcceleratorItemList& m_aReadAcceleratorList;
86 : };
87 :
88 :
89 : class OWriteAccelatorDocumentHandler
90 : {
91 : public:
92 : OWriteAccelatorDocumentHandler(
93 : const SvtAcceleratorItemList& aWriteAcceleratorList,
94 : ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > );
95 : virtual ~OWriteAccelatorDocumentHandler();
96 :
97 : void WriteAcceleratorDocument() throw ( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException );
98 :
99 : private:
100 : void WriteAcceleratorItem( const SvtAcceleratorConfigItem& aAcceleratorItem ) throw( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException );
101 :
102 : ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > m_xWriteDocumentHandler;
103 : ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > m_xEmptyList;
104 : OUString m_aAttributeType;
105 : const SvtAcceleratorItemList& m_aWriteAcceleratorList;
106 : };
107 :
108 : #endif // INCLUDED_unotools_XMLACCELCFG_HXX
109 :
110 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|