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