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_DBACCESS_SOURCE_CORE_RECOVERY_SETTINGSIMPORT_HXX
21 : #define INCLUDED_DBACCESS_SOURCE_CORE_RECOVERY_SETTINGSIMPORT_HXX
22 :
23 : #include <com/sun/star/xml/sax/XAttributeList.hpp>
24 :
25 : #include <comphelper/namedvaluecollection.hxx>
26 : #include <rtl/ref.hxx>
27 : #include <rtl/ustrbuf.hxx>
28 : #include <salhelper/simplereferenceobject.hxx>
29 :
30 : namespace dbaccess
31 : {
32 :
33 : // SettingsImport
34 : /** a simplified version of xmloff/DocumentSettingsContext
35 :
36 : It would be nice if the DocumentSettingsContext would not be that tightly interwoven with the SvXMLImport
37 : class, so we could re-use it here ...
38 : */
39 : class SettingsImport : public salhelper::SimpleReferenceObject
40 : {
41 : public:
42 : SettingsImport();
43 :
44 : // own overridables
45 : virtual ::rtl::Reference< SettingsImport > nextState(
46 : const OUString& i_rElementName
47 : ) = 0;
48 : virtual void startElement(
49 : const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& i_rAttributes
50 : );
51 : virtual void endElement();
52 : virtual void characters( const OUString& i_rCharacters );
53 :
54 : protected:
55 : virtual ~SettingsImport();
56 :
57 : protected:
58 : static void split( const OUString& i_rElementName, OUString& o_rNamespace, OUString& o_rLocalName );
59 :
60 : protected:
61 0 : const OUString& getItemName() const { return m_sItemName; }
62 0 : const OUString& getItemType() const { return m_sItemType; }
63 0 : const OUStringBuffer& getAccumulatedCharacters() const { return m_aCharacters; }
64 :
65 : private:
66 : // value of the config:name attribute, if any
67 : OUString m_sItemName;
68 : // value of the config:type attribute, if any
69 : OUString m_sItemType;
70 : // accumulated characters, if any
71 : OUStringBuffer m_aCharacters;
72 : };
73 :
74 : // IgnoringSettingsImport
75 : class IgnoringSettingsImport : public SettingsImport
76 : {
77 : public:
78 0 : IgnoringSettingsImport()
79 0 : {
80 0 : }
81 :
82 : // SettingsImport overridables
83 : virtual ::rtl::Reference< SettingsImport > nextState(
84 : const OUString& i_rElementName
85 : ) SAL_OVERRIDE;
86 :
87 : private:
88 0 : virtual ~IgnoringSettingsImport()
89 0 : {
90 0 : }
91 : };
92 :
93 : // OfficeSettingsImport
94 : class OfficeSettingsImport : public SettingsImport
95 : {
96 : public:
97 : OfficeSettingsImport( ::comphelper::NamedValueCollection& o_rSettings );
98 :
99 : // SettingsImport overridables
100 : virtual ::rtl::Reference< SettingsImport > nextState(
101 : const OUString& i_rElementName
102 : ) SAL_OVERRIDE;
103 :
104 : protected:
105 : virtual ~OfficeSettingsImport();
106 :
107 : private:
108 : // the settings collection to which |this| will contribute a single setting
109 : ::comphelper::NamedValueCollection& m_rSettings;
110 : };
111 :
112 : // ConfigItemSetImport
113 : class ConfigItemImport : public SettingsImport
114 : {
115 : public:
116 : ConfigItemImport( ::comphelper::NamedValueCollection& o_rSettings );
117 :
118 : protected:
119 : virtual ~ConfigItemImport();
120 :
121 : public:
122 : // SettingsImport overridables
123 : virtual ::rtl::Reference< SettingsImport > nextState(
124 : const OUString& i_rElementName
125 : ) SAL_OVERRIDE;
126 : virtual void endElement() SAL_OVERRIDE;
127 :
128 : protected:
129 : // own overridables
130 : /// retrieves the value represented by the element
131 : virtual void getItemValue( ::com::sun::star::uno::Any& o_rValue ) const;
132 :
133 : private:
134 : // the settings collection to which |this| will contribute a single setting
135 : ::comphelper::NamedValueCollection& m_rSettings;
136 : };
137 :
138 : // ConfigItemSetImport
139 : class ConfigItemSetImport : public ConfigItemImport
140 : {
141 : public:
142 : ConfigItemSetImport( ::comphelper::NamedValueCollection& o_rSettings );
143 :
144 : protected:
145 : virtual ~ConfigItemSetImport();
146 :
147 : public:
148 : // SettingsImport overridables
149 : virtual ::rtl::Reference< SettingsImport > nextState(
150 : const OUString& i_rElementName
151 : ) SAL_OVERRIDE;
152 :
153 : protected:
154 : // ConfigItemImport overridables
155 : virtual void getItemValue( ::com::sun::star::uno::Any& o_rValue ) const SAL_OVERRIDE;
156 :
157 : private:
158 : /// the settings represented by our child elements
159 : ::comphelper::NamedValueCollection m_aChildSettings;
160 : };
161 :
162 : } // namespace dbaccess
163 :
164 : #endif // INCLUDED_DBACCESS_SOURCE_CORE_RECOVERY_SETTINGSIMPORT_HXX
165 :
166 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|