1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 //........................................................................
32 //........................................................................
34 //====================================================================
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
48 virtual oslInterlockedCount SAL_CALL
acquire();
49 virtual oslInterlockedCount SAL_CALL
release();
52 virtual ::rtl::Reference
< SettingsImport
> nextState(
53 const ::rtl::OUString
& i_rElementName
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
);
62 virtual ~SettingsImport();
65 static void split( const ::rtl::OUString
& i_rElementName
, ::rtl::OUString
& o_rNamespace
, ::rtl::OUString
& o_rLocalName
);
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
; }
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
88 IgnoringSettingsImport()
92 // SettingsImport overridables
93 virtual ::rtl::Reference
< SettingsImport
> nextState(
94 const ::rtl::OUString
& i_rElementName
98 ~IgnoringSettingsImport()
103 //====================================================================
104 //= OfficeSettingsImport
105 //====================================================================
106 class OfficeSettingsImport
: public SettingsImport
109 OfficeSettingsImport( ::comphelper::NamedValueCollection
& o_rSettings
);
111 // SettingsImport overridables
112 virtual ::rtl::Reference
< SettingsImport
> nextState(
113 const ::rtl::OUString
& i_rElementName
117 ~OfficeSettingsImport();
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
130 ConfigItemImport( ::comphelper::NamedValueCollection
& o_rSettings
);
136 // SettingsImport overridables
137 virtual ::rtl::Reference
< SettingsImport
> nextState(
138 const ::rtl::OUString
& i_rElementName
140 virtual void endElement();
144 /// retrieves the value represented by the element
145 virtual void getItemValue( ::com::sun::star::uno::Any
& o_rValue
) const;
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
158 ConfigItemSetImport( ::comphelper::NamedValueCollection
& o_rSettings
);
161 ~ConfigItemSetImport();
164 // SettingsImport overridables
165 virtual ::rtl::Reference
< SettingsImport
> nextState(
166 const ::rtl::OUString
& i_rElementName
170 // ConfigItemImport overridables
171 virtual void getItemValue( ::com::sun::star::uno::Any
& o_rValue
) const;
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: */