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