1 /************************************************************************* 2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * 4 * Copyright 2009 by Sun Microsystems, Inc. 5 * 6 * OpenOffice.org - a multi-platform office productivity suite 7 * 8 * This file is part of OpenOffice.org. 9 * 10 * OpenOffice.org is free software: you can redistribute it and/or modify 11 * it under the terms of the GNU Lesser General Public License version 3 12 * only, as published by the Free Software Foundation. 13 * 14 * OpenOffice.org is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * GNU Lesser General Public License version 3 for more details 18 * (a copy is included in the LICENSE file that accompanied this code). 19 * 20 * You should have received a copy of the GNU Lesser General Public License 21 * version 3 along with OpenOffice.org. If not, see 22 * <http://www.openoffice.org/license.html> 23 * for a copy of the LGPLv3 License. 24 ************************************************************************/ 25 26 #ifndef SETTINGSIMPORT_HXX 27 #define SETTINGSIMPORT_HXX 28 29 /** === begin UNO includes === **/ 30 #include <com/sun/star/xml/sax/XAttributeList.hpp> 31 /** === end UNO includes === **/ 32 33 #include <comphelper/namedvaluecollection.hxx> 34 #include <rtl/ref.hxx> 35 #include <rtl/ustrbuf.hxx> 36 37 //........................................................................ 38 namespace dbaccess 39 { 40 //........................................................................ 41 42 //==================================================================== 43 //= SettingsImport 44 //==================================================================== 45 /** a simplified version of xmloff/DocumentSettingsContext 46 47 It would be nice if the DocumentSettingsContext would not be that tightly interwoven with the SvXMLImport 48 class, so we could re-use it here ... 49 */ 50 class SettingsImport : public ::rtl::IReference 51 { 52 public: 53 SettingsImport(); 54 55 // IReference 56 virtual oslInterlockedCount SAL_CALL acquire(); 57 virtual oslInterlockedCount SAL_CALL release(); 58 59 // own overriables 60 virtual ::rtl::Reference< SettingsImport > nextState( 61 const ::rtl::OUString& i_rElementName 62 ) = 0; 63 virtual void startElement( 64 const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& i_rAttributes 65 ); 66 virtual void endElement(); 67 virtual void characters( const ::rtl::OUString& i_rCharacters ); 68 69 protected: 70 virtual ~SettingsImport(); 71 72 protected: 73 static void split( const ::rtl::OUString& i_rElementName, ::rtl::OUString& o_rNamespace, ::rtl::OUString& o_rLocalName ); 74 75 protected: 76 const ::rtl::OUString& getItemName() const { return m_sItemName; } 77 const ::rtl::OUString& getItemType() const { return m_sItemType; } 78 const ::rtl::OUStringBuffer& getAccumulatedCharacters() const { return m_aCharacters; } 79 80 private: 81 oslInterlockedCount m_refCount; 82 // value of the config:name attribute, if any 83 ::rtl::OUString m_sItemName; 84 // value of the config:type attribute, if any 85 ::rtl::OUString m_sItemType; 86 // accumulated characters, if any 87 ::rtl::OUStringBuffer m_aCharacters; 88 }; 89 90 //==================================================================== 91 //= IgnoringSettingsImport 92 //==================================================================== 93 class IgnoringSettingsImport : public SettingsImport 94 { 95 public: 96 IgnoringSettingsImport() 97 { 98 } 99 100 // SettingsImport overridables 101 virtual ::rtl::Reference< SettingsImport > nextState( 102 const ::rtl::OUString& i_rElementName 103 ); 104 105 private: 106 ~IgnoringSettingsImport() 107 { 108 } 109 }; 110 111 //==================================================================== 112 //= OfficeSettingsImport 113 //==================================================================== 114 class OfficeSettingsImport : public SettingsImport 115 { 116 public: 117 OfficeSettingsImport( ::comphelper::NamedValueCollection& o_rSettings ); 118 119 // SettingsImport overridables 120 virtual ::rtl::Reference< SettingsImport > nextState( 121 const ::rtl::OUString& i_rElementName 122 ); 123 124 protected: 125 ~OfficeSettingsImport(); 126 127 private: 128 // the settings collection to which |this| will contribute a single setting 129 ::comphelper::NamedValueCollection& m_rSettings; 130 }; 131 132 //==================================================================== 133 //= ConfigItemSetImport 134 //==================================================================== 135 class ConfigItemImport : public SettingsImport 136 { 137 public: 138 ConfigItemImport( ::comphelper::NamedValueCollection& o_rSettings ); 139 140 protected: 141 ~ConfigItemImport(); 142 143 public: 144 // SettingsImport overridables 145 virtual ::rtl::Reference< SettingsImport > nextState( 146 const ::rtl::OUString& i_rElementName 147 ); 148 virtual void endElement(); 149 150 protected: 151 // own overridables 152 /// retrieves the value represented by the element 153 virtual void getItemValue( ::com::sun::star::uno::Any& o_rValue ) const; 154 155 private: 156 // the settings collection to which |this| will contribute a single setting 157 ::comphelper::NamedValueCollection& m_rSettings; 158 }; 159 160 //==================================================================== 161 //= ConfigItemSetImport 162 //==================================================================== 163 class ConfigItemSetImport : public ConfigItemImport 164 { 165 public: 166 ConfigItemSetImport( ::comphelper::NamedValueCollection& o_rSettings ); 167 168 protected: 169 ~ConfigItemSetImport(); 170 171 public: 172 // SettingsImport overridables 173 virtual ::rtl::Reference< SettingsImport > nextState( 174 const ::rtl::OUString& i_rElementName 175 ); 176 177 protected: 178 // ConfigItemImport overridables 179 virtual void getItemValue( ::com::sun::star::uno::Any& o_rValue ) const; 180 181 private: 182 /// the settings represented by our child elements 183 ::comphelper::NamedValueCollection m_aChildSettings; 184 }; 185 186 //........................................................................ 187 } // namespace dbaccess 188 //........................................................................ 189 190 #endif // SETTINGSIMPORT_HXX 191