1*2e2212a7SAndrew Rist /************************************************************** 2*2e2212a7SAndrew Rist * 3*2e2212a7SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*2e2212a7SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*2e2212a7SAndrew Rist * distributed with this work for additional information 6*2e2212a7SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*2e2212a7SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*2e2212a7SAndrew Rist * "License"); you may not use this file except in compliance 9*2e2212a7SAndrew Rist * with the License. You may obtain a copy of the License at 10*2e2212a7SAndrew Rist * 11*2e2212a7SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*2e2212a7SAndrew Rist * 13*2e2212a7SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*2e2212a7SAndrew Rist * software distributed under the License is distributed on an 15*2e2212a7SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*2e2212a7SAndrew Rist * KIND, either express or implied. See the License for the 17*2e2212a7SAndrew Rist * specific language governing permissions and limitations 18*2e2212a7SAndrew Rist * under the License. 19*2e2212a7SAndrew Rist * 20*2e2212a7SAndrew Rist *************************************************************/ 21*2e2212a7SAndrew Rist 22*2e2212a7SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef SETTINGSIMPORT_HXX 25cdf0e10cSrcweir #define SETTINGSIMPORT_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir /** === begin UNO includes === **/ 28cdf0e10cSrcweir #include <com/sun/star/xml/sax/XAttributeList.hpp> 29cdf0e10cSrcweir /** === end UNO includes === **/ 30cdf0e10cSrcweir 31cdf0e10cSrcweir #include <comphelper/namedvaluecollection.hxx> 32cdf0e10cSrcweir #include <rtl/ref.hxx> 33cdf0e10cSrcweir #include <rtl/ustrbuf.hxx> 34cdf0e10cSrcweir 35cdf0e10cSrcweir //........................................................................ 36cdf0e10cSrcweir namespace dbaccess 37cdf0e10cSrcweir { 38cdf0e10cSrcweir //........................................................................ 39cdf0e10cSrcweir 40cdf0e10cSrcweir //==================================================================== 41cdf0e10cSrcweir //= SettingsImport 42cdf0e10cSrcweir //==================================================================== 43cdf0e10cSrcweir /** a simplified version of xmloff/DocumentSettingsContext 44cdf0e10cSrcweir 45cdf0e10cSrcweir It would be nice if the DocumentSettingsContext would not be that tightly interwoven with the SvXMLImport 46cdf0e10cSrcweir class, so we could re-use it here ... 47cdf0e10cSrcweir */ 48cdf0e10cSrcweir class SettingsImport : public ::rtl::IReference 49cdf0e10cSrcweir { 50cdf0e10cSrcweir public: 51cdf0e10cSrcweir SettingsImport(); 52cdf0e10cSrcweir 53cdf0e10cSrcweir // IReference 54cdf0e10cSrcweir virtual oslInterlockedCount SAL_CALL acquire(); 55cdf0e10cSrcweir virtual oslInterlockedCount SAL_CALL release(); 56cdf0e10cSrcweir 57cdf0e10cSrcweir // own overriables 58cdf0e10cSrcweir virtual ::rtl::Reference< SettingsImport > nextState( 59cdf0e10cSrcweir const ::rtl::OUString& i_rElementName 60cdf0e10cSrcweir ) = 0; 61cdf0e10cSrcweir virtual void startElement( 62cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& i_rAttributes 63cdf0e10cSrcweir ); 64cdf0e10cSrcweir virtual void endElement(); 65cdf0e10cSrcweir virtual void characters( const ::rtl::OUString& i_rCharacters ); 66cdf0e10cSrcweir 67cdf0e10cSrcweir protected: 68cdf0e10cSrcweir virtual ~SettingsImport(); 69cdf0e10cSrcweir 70cdf0e10cSrcweir protected: 71cdf0e10cSrcweir static void split( const ::rtl::OUString& i_rElementName, ::rtl::OUString& o_rNamespace, ::rtl::OUString& o_rLocalName ); 72cdf0e10cSrcweir 73cdf0e10cSrcweir protected: getItemName() const74cdf0e10cSrcweir const ::rtl::OUString& getItemName() const { return m_sItemName; } getItemType() const75cdf0e10cSrcweir const ::rtl::OUString& getItemType() const { return m_sItemType; } getAccumulatedCharacters() const76cdf0e10cSrcweir const ::rtl::OUStringBuffer& getAccumulatedCharacters() const { return m_aCharacters; } 77cdf0e10cSrcweir 78cdf0e10cSrcweir private: 79cdf0e10cSrcweir oslInterlockedCount m_refCount; 80cdf0e10cSrcweir // value of the config:name attribute, if any 81cdf0e10cSrcweir ::rtl::OUString m_sItemName; 82cdf0e10cSrcweir // value of the config:type attribute, if any 83cdf0e10cSrcweir ::rtl::OUString m_sItemType; 84cdf0e10cSrcweir // accumulated characters, if any 85cdf0e10cSrcweir ::rtl::OUStringBuffer m_aCharacters; 86cdf0e10cSrcweir }; 87cdf0e10cSrcweir 88cdf0e10cSrcweir //==================================================================== 89cdf0e10cSrcweir //= IgnoringSettingsImport 90cdf0e10cSrcweir //==================================================================== 91cdf0e10cSrcweir class IgnoringSettingsImport : public SettingsImport 92cdf0e10cSrcweir { 93cdf0e10cSrcweir public: IgnoringSettingsImport()94cdf0e10cSrcweir IgnoringSettingsImport() 95cdf0e10cSrcweir { 96cdf0e10cSrcweir } 97cdf0e10cSrcweir 98cdf0e10cSrcweir // SettingsImport overridables 99cdf0e10cSrcweir virtual ::rtl::Reference< SettingsImport > nextState( 100cdf0e10cSrcweir const ::rtl::OUString& i_rElementName 101cdf0e10cSrcweir ); 102cdf0e10cSrcweir 103cdf0e10cSrcweir private: ~IgnoringSettingsImport()104cdf0e10cSrcweir ~IgnoringSettingsImport() 105cdf0e10cSrcweir { 106cdf0e10cSrcweir } 107cdf0e10cSrcweir }; 108cdf0e10cSrcweir 109cdf0e10cSrcweir //==================================================================== 110cdf0e10cSrcweir //= OfficeSettingsImport 111cdf0e10cSrcweir //==================================================================== 112cdf0e10cSrcweir class OfficeSettingsImport : public SettingsImport 113cdf0e10cSrcweir { 114cdf0e10cSrcweir public: 115cdf0e10cSrcweir OfficeSettingsImport( ::comphelper::NamedValueCollection& o_rSettings ); 116cdf0e10cSrcweir 117cdf0e10cSrcweir // SettingsImport overridables 118cdf0e10cSrcweir virtual ::rtl::Reference< SettingsImport > nextState( 119cdf0e10cSrcweir const ::rtl::OUString& i_rElementName 120cdf0e10cSrcweir ); 121cdf0e10cSrcweir 122cdf0e10cSrcweir protected: 123cdf0e10cSrcweir ~OfficeSettingsImport(); 124cdf0e10cSrcweir 125cdf0e10cSrcweir private: 126cdf0e10cSrcweir // the settings collection to which |this| will contribute a single setting 127cdf0e10cSrcweir ::comphelper::NamedValueCollection& m_rSettings; 128cdf0e10cSrcweir }; 129cdf0e10cSrcweir 130cdf0e10cSrcweir //==================================================================== 131cdf0e10cSrcweir //= ConfigItemSetImport 132cdf0e10cSrcweir //==================================================================== 133cdf0e10cSrcweir class ConfigItemImport : public SettingsImport 134cdf0e10cSrcweir { 135cdf0e10cSrcweir public: 136cdf0e10cSrcweir ConfigItemImport( ::comphelper::NamedValueCollection& o_rSettings ); 137cdf0e10cSrcweir 138cdf0e10cSrcweir protected: 139cdf0e10cSrcweir ~ConfigItemImport(); 140cdf0e10cSrcweir 141cdf0e10cSrcweir public: 142cdf0e10cSrcweir // SettingsImport overridables 143cdf0e10cSrcweir virtual ::rtl::Reference< SettingsImport > nextState( 144cdf0e10cSrcweir const ::rtl::OUString& i_rElementName 145cdf0e10cSrcweir ); 146cdf0e10cSrcweir virtual void endElement(); 147cdf0e10cSrcweir 148cdf0e10cSrcweir protected: 149cdf0e10cSrcweir // own overridables 150cdf0e10cSrcweir /// retrieves the value represented by the element 151cdf0e10cSrcweir virtual void getItemValue( ::com::sun::star::uno::Any& o_rValue ) const; 152cdf0e10cSrcweir 153cdf0e10cSrcweir private: 154cdf0e10cSrcweir // the settings collection to which |this| will contribute a single setting 155cdf0e10cSrcweir ::comphelper::NamedValueCollection& m_rSettings; 156cdf0e10cSrcweir }; 157cdf0e10cSrcweir 158cdf0e10cSrcweir //==================================================================== 159cdf0e10cSrcweir //= ConfigItemSetImport 160cdf0e10cSrcweir //==================================================================== 161cdf0e10cSrcweir class ConfigItemSetImport : public ConfigItemImport 162cdf0e10cSrcweir { 163cdf0e10cSrcweir public: 164cdf0e10cSrcweir ConfigItemSetImport( ::comphelper::NamedValueCollection& o_rSettings ); 165cdf0e10cSrcweir 166cdf0e10cSrcweir protected: 167cdf0e10cSrcweir ~ConfigItemSetImport(); 168cdf0e10cSrcweir 169cdf0e10cSrcweir public: 170cdf0e10cSrcweir // SettingsImport overridables 171cdf0e10cSrcweir virtual ::rtl::Reference< SettingsImport > nextState( 172cdf0e10cSrcweir const ::rtl::OUString& i_rElementName 173cdf0e10cSrcweir ); 174cdf0e10cSrcweir 175cdf0e10cSrcweir protected: 176cdf0e10cSrcweir // ConfigItemImport overridables 177cdf0e10cSrcweir virtual void getItemValue( ::com::sun::star::uno::Any& o_rValue ) const; 178cdf0e10cSrcweir 179cdf0e10cSrcweir private: 180cdf0e10cSrcweir /// the settings represented by our child elements 181cdf0e10cSrcweir ::comphelper::NamedValueCollection m_aChildSettings; 182cdf0e10cSrcweir }; 183cdf0e10cSrcweir 184cdf0e10cSrcweir //........................................................................ 185cdf0e10cSrcweir } // namespace dbaccess 186cdf0e10cSrcweir //........................................................................ 187cdf0e10cSrcweir 188cdf0e10cSrcweir #endif // SETTINGSIMPORT_HXX 189