Version 4.0.0.1, tag libreoffice-4.0.0.1
[LibreOffice.git] / dbaccess / source / core / recovery / settingsimport.hxx
blobe0daac2f929baa3ebe857855476eb853b63604ee
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef SETTINGSIMPORT_HXX
21 #define SETTINGSIMPORT_HXX
23 #include <com/sun/star/xml/sax/XAttributeList.hpp>
25 #include <comphelper/namedvaluecollection.hxx>
26 #include <rtl/ref.hxx>
27 #include <rtl/ustrbuf.hxx>
29 //........................................................................
30 namespace dbaccess
32 //........................................................................
34 //====================================================================
35 //= SettingsImport
36 //====================================================================
37 /** a simplified version of xmloff/DocumentSettingsContext
39 It would be nice if the DocumentSettingsContext would not be that tightly interwoven with the SvXMLImport
40 class, so we could re-use it here ...
42 class SettingsImport : public ::rtl::IReference
44 public:
45 SettingsImport();
47 // IReference
48 virtual oslInterlockedCount SAL_CALL acquire();
49 virtual oslInterlockedCount SAL_CALL release();
51 // own overriables
52 virtual ::rtl::Reference< SettingsImport > nextState(
53 const ::rtl::OUString& i_rElementName
54 ) = 0;
55 virtual void startElement(
56 const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& i_rAttributes
58 virtual void endElement();
59 virtual void characters( const ::rtl::OUString& i_rCharacters );
61 protected:
62 virtual ~SettingsImport();
64 protected:
65 static void split( const ::rtl::OUString& i_rElementName, ::rtl::OUString& o_rNamespace, ::rtl::OUString& o_rLocalName );
67 protected:
68 const ::rtl::OUString& getItemName() const { return m_sItemName; }
69 const ::rtl::OUString& getItemType() const { return m_sItemType; }
70 const ::rtl::OUStringBuffer& getAccumulatedCharacters() const { return m_aCharacters; }
72 private:
73 oslInterlockedCount m_refCount;
74 // value of the config:name attribute, if any
75 ::rtl::OUString m_sItemName;
76 // value of the config:type attribute, if any
77 ::rtl::OUString m_sItemType;
78 // accumulated characters, if any
79 ::rtl::OUStringBuffer m_aCharacters;
82 //====================================================================
83 //= IgnoringSettingsImport
84 //====================================================================
85 class IgnoringSettingsImport : public SettingsImport
87 public:
88 IgnoringSettingsImport()
92 // SettingsImport overridables
93 virtual ::rtl::Reference< SettingsImport > nextState(
94 const ::rtl::OUString& i_rElementName
97 private:
98 ~IgnoringSettingsImport()
103 //====================================================================
104 //= OfficeSettingsImport
105 //====================================================================
106 class OfficeSettingsImport : public SettingsImport
108 public:
109 OfficeSettingsImport( ::comphelper::NamedValueCollection& o_rSettings );
111 // SettingsImport overridables
112 virtual ::rtl::Reference< SettingsImport > nextState(
113 const ::rtl::OUString& i_rElementName
116 protected:
117 ~OfficeSettingsImport();
119 private:
120 // the settings collection to which |this| will contribute a single setting
121 ::comphelper::NamedValueCollection& m_rSettings;
124 //====================================================================
125 //= ConfigItemSetImport
126 //====================================================================
127 class ConfigItemImport : public SettingsImport
129 public:
130 ConfigItemImport( ::comphelper::NamedValueCollection& o_rSettings );
132 protected:
133 ~ConfigItemImport();
135 public:
136 // SettingsImport overridables
137 virtual ::rtl::Reference< SettingsImport > nextState(
138 const ::rtl::OUString& i_rElementName
140 virtual void endElement();
142 protected:
143 // own overridables
144 /// retrieves the value represented by the element
145 virtual void getItemValue( ::com::sun::star::uno::Any& o_rValue ) const;
147 private:
148 // the settings collection to which |this| will contribute a single setting
149 ::comphelper::NamedValueCollection& m_rSettings;
152 //====================================================================
153 //= ConfigItemSetImport
154 //====================================================================
155 class ConfigItemSetImport : public ConfigItemImport
157 public:
158 ConfigItemSetImport( ::comphelper::NamedValueCollection& o_rSettings );
160 protected:
161 ~ConfigItemSetImport();
163 public:
164 // SettingsImport overridables
165 virtual ::rtl::Reference< SettingsImport > nextState(
166 const ::rtl::OUString& i_rElementName
169 protected:
170 // ConfigItemImport overridables
171 virtual void getItemValue( ::com::sun::star::uno::Any& o_rValue ) const;
173 private:
174 /// the settings represented by our child elements
175 ::comphelper::NamedValueCollection m_aChildSettings;
178 //........................................................................
179 } // namespace dbaccess
180 //........................................................................
182 #endif // SETTINGSIMPORT_HXX
184 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */