1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_dbaccess.hxx" 30 31 #include "textconnectionsettings.hxx" 32 #include "dbu_reghelper.hxx" 33 #include "moduledbu.hxx" 34 #include "apitools.hxx" 35 #include "unoadmin.hxx" 36 #include "dbustrings.hrc" 37 #include "propertystorage.hxx" 38 39 /** === begin UNO includes === **/ 40 #include <com/sun/star/beans/XPropertySetInfo.hpp> 41 #include <com/sun/star/beans/PropertyAttribute.hpp> 42 /** === end UNO includes === **/ 43 44 #include <comphelper/componentcontext.hxx> 45 #include <svtools/genericunodialog.hxx> 46 47 //........................................................................ 48 namespace dbaui 49 { 50 //........................................................................ 51 52 /** === begin UNO using === **/ 53 using ::com::sun::star::uno::Reference; 54 using ::com::sun::star::uno::XInterface; 55 using ::com::sun::star::uno::UNO_QUERY; 56 using ::com::sun::star::uno::UNO_QUERY_THROW; 57 using ::com::sun::star::uno::Exception; 58 using ::com::sun::star::uno::RuntimeException; 59 using ::com::sun::star::uno::Any; 60 using ::com::sun::star::uno::makeAny; 61 using ::com::sun::star::beans::XPropertySetInfo; 62 using ::com::sun::star::uno::Sequence; 63 using ::com::sun::star::beans::Property; 64 using ::com::sun::star::lang::IllegalArgumentException; 65 /** === end UNO using === **/ 66 namespace PropertyAttribute = ::com::sun::star::beans::PropertyAttribute; 67 68 //==================================================================== 69 //= OTextConnectionSettingsDialog 70 //==================================================================== 71 72 class OTextConnectionSettingsDialog; 73 typedef ODatabaseAdministrationDialog OTextConnectionSettingsDialog_BASE; 74 typedef ::comphelper::OPropertyArrayUsageHelper< OTextConnectionSettingsDialog > OTextConnectionSettingsDialog_PBASE; 75 76 class OTextConnectionSettingsDialog 77 :public OTextConnectionSettingsDialog_BASE 78 ,public OTextConnectionSettingsDialog_PBASE 79 { 80 OModuleClient m_aModuleClient; 81 PropertyValues m_aPropertyValues; 82 83 protected: 84 OTextConnectionSettingsDialog( const ::comphelper::ComponentContext& _rContext ); 85 virtual ~OTextConnectionSettingsDialog(); 86 87 public: 88 DECLARE_IMPLEMENTATION_ID( ); 89 DECLARE_SERVICE_INFO_STATIC( ); 90 DECLARE_PROPERTYCONTAINER_DEFAULTS( ); 91 92 virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const Any& rValue ) throw(Exception); 93 virtual sal_Bool SAL_CALL convertFastPropertyValue( Any& rConvertedValue, Any& rOldValue, sal_Int32 nHandle, const Any& rValue) throw(IllegalArgumentException); 94 virtual void SAL_CALL getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const; 95 96 protected: 97 // OGenericUnoDialog overridables 98 virtual Dialog* createDialog( Window* _pParent ); 99 virtual void implInitialize( const com::sun::star::uno::Any& _rValue ); 100 protected: 101 using OTextConnectionSettingsDialog_BASE::getFastPropertyValue; 102 }; 103 104 //==================================================================== 105 //= OTextConnectionSettingsDialog 106 //==================================================================== 107 //-------------------------------------------------------------------- 108 OTextConnectionSettingsDialog::OTextConnectionSettingsDialog( const ::comphelper::ComponentContext& _rContext ) 109 :OTextConnectionSettingsDialog_BASE( _rContext.getLegacyServiceFactory() ) 110 { 111 TextConnectionSettingsDialog::bindItemStorages( *m_pDatasourceItems, m_aPropertyValues ); 112 } 113 114 //--------------------------------------------------------------------- 115 OTextConnectionSettingsDialog::~OTextConnectionSettingsDialog() 116 { 117 } 118 119 //--------------------------------------------------------------------- 120 IMPLEMENT_IMPLEMENTATION_ID( OTextConnectionSettingsDialog ) 121 122 //--------------------------------------------------------------------- 123 IMPLEMENT_SERVICE_INFO1_STATIC( OTextConnectionSettingsDialog, "com.sun.star.comp.dbaccess.OTextConnectionSettingsDialog", "com.sun.star.sdb.TextConnectionSettings" ) 124 125 //--------------------------------------------------------------------- 126 Reference< XPropertySetInfo > SAL_CALL OTextConnectionSettingsDialog::getPropertySetInfo() throw(RuntimeException) 127 { 128 return createPropertySetInfo( getInfoHelper() ); 129 } 130 131 //--------------------------------------------------------------------- 132 ::cppu::IPropertyArrayHelper& OTextConnectionSettingsDialog::getInfoHelper() 133 { 134 return *getArrayHelper(); 135 } 136 137 //--------------------------------------------------------------------- 138 ::cppu::IPropertyArrayHelper* OTextConnectionSettingsDialog::createArrayHelper( ) const 139 { 140 Sequence< Property > aProps; 141 describeProperties( aProps ); 142 143 // in addition to the properties registered by the base class, we have 144 // more properties which are not even handled by the PropertyContainer implementation, 145 // but whose values are stored in our item set 146 sal_Int32 nProp = aProps.getLength(); 147 aProps.realloc( nProp + 6 ); 148 149 aProps[ nProp++ ] = Property( 150 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "HeaderLine" ) ), 151 PROPERTY_ID_HEADER_LINE, 152 ::cppu::UnoType< sal_Bool >::get(), 153 PropertyAttribute::TRANSIENT 154 ); 155 156 aProps[ nProp++ ] = Property( 157 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FieldDelimiter" ) ), 158 PROPERTY_ID_FIELD_DELIMITER, 159 ::cppu::UnoType< ::rtl::OUString >::get(), 160 PropertyAttribute::TRANSIENT 161 ); 162 163 aProps[ nProp++ ] = Property( 164 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "StringDelimiter" ) ), 165 PROPERTY_ID_STRING_DELIMITER, 166 ::cppu::UnoType< ::rtl::OUString >::get(), 167 PropertyAttribute::TRANSIENT 168 ); 169 170 aProps[ nProp++ ] = Property( 171 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DecimalDelimiter" ) ), 172 PROPERTY_ID_DECIMAL_DELIMITER, 173 ::cppu::UnoType< ::rtl::OUString >::get(), 174 PropertyAttribute::TRANSIENT 175 ); 176 177 aProps[ nProp++ ] = Property( 178 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ThousandDelimiter" ) ), 179 PROPERTY_ID_THOUSAND_DELIMITER, 180 ::cppu::UnoType< ::rtl::OUString >::get(), 181 PropertyAttribute::TRANSIENT 182 ); 183 184 aProps[ nProp++ ] = Property( 185 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharSet" ) ), 186 PROPERTY_ID_ENCODING, 187 ::cppu::UnoType< ::rtl::OUString >::get(), 188 PropertyAttribute::TRANSIENT 189 ); 190 191 return new ::cppu::OPropertyArrayHelper( aProps ); 192 } 193 194 //--------------------------------------------------------------------- 195 Dialog* OTextConnectionSettingsDialog::createDialog(Window* _pParent) 196 { 197 return new TextConnectionSettingsDialog( _pParent, *m_pDatasourceItems ); 198 } 199 200 //--------------------------------------------------------------------- 201 void OTextConnectionSettingsDialog::implInitialize(const Any& _rValue) 202 { 203 OTextConnectionSettingsDialog_BASE::implInitialize( _rValue ); 204 } 205 206 //-------------------------------------------------------------------- 207 void SAL_CALL OTextConnectionSettingsDialog::setFastPropertyValue_NoBroadcast( sal_Int32 _nHandle, const Any& _rValue ) throw(Exception) 208 { 209 PropertyValues::const_iterator pos = m_aPropertyValues.find( _nHandle ); 210 if ( pos != m_aPropertyValues.end() ) 211 { 212 pos->second->setPropertyValue( _rValue ); 213 } 214 else 215 { 216 OTextConnectionSettingsDialog::setFastPropertyValue_NoBroadcast( _nHandle, _rValue ); 217 } 218 } 219 220 //-------------------------------------------------------------------- 221 sal_Bool SAL_CALL OTextConnectionSettingsDialog::convertFastPropertyValue( Any& _rConvertedValue, Any& _rOldValue, sal_Int32 _nHandle, const Any& _rValue) throw(IllegalArgumentException) 222 { 223 sal_Bool bModified = sal_False; 224 225 PropertyValues::const_iterator pos = m_aPropertyValues.find( _nHandle ); 226 if ( pos != m_aPropertyValues.end() ) 227 { 228 // we're lazy here ... 229 _rConvertedValue = _rValue; 230 pos->second->getPropertyValue( _rOldValue ); 231 bModified = sal_True; 232 } 233 else 234 { 235 bModified = OTextConnectionSettingsDialog::convertFastPropertyValue( _rConvertedValue, _rOldValue, _nHandle, _rValue ); 236 } 237 238 return bModified; 239 } 240 241 //-------------------------------------------------------------------- 242 void SAL_CALL OTextConnectionSettingsDialog::getFastPropertyValue( Any& _rValue, sal_Int32 _nHandle ) const 243 { 244 PropertyValues::const_iterator pos = m_aPropertyValues.find( _nHandle ); 245 if ( pos != m_aPropertyValues.end() ) 246 { 247 pos->second->getPropertyValue( _rValue ); 248 } 249 else 250 { 251 OTextConnectionSettingsDialog::getFastPropertyValue( _rValue, _nHandle ); 252 } 253 } 254 255 //........................................................................ 256 } // namespace dbaui 257 //........................................................................ 258 259 extern "C" void SAL_CALL createRegistryInfo_OTextConnectionSettingsDialog() 260 { 261 static ::dbaui::OMultiInstanceAutoRegistration< ::dbaui::OTextConnectionSettingsDialog > aAutoRegistration; 262 } 263 264