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