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