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 "DriverSettings.hxx" 28cdf0e10cSrcweir #include "dsmeta.hxx" 29cdf0e10cSrcweir 30cdf0e10cSrcweir #include <com/sun/star/uno/Sequence.hxx> 31cdf0e10cSrcweir #include <com/sun/star/beans/NamedValue.hpp> 32cdf0e10cSrcweir 33cdf0e10cSrcweir #include <connectivity/DriversConfig.hxx> 34cdf0e10cSrcweir 35cdf0e10cSrcweir using ::com::sun::star::uno::Sequence; 36cdf0e10cSrcweir using ::com::sun::star::beans::NamedValue; 37cdf0e10cSrcweir 38cdf0e10cSrcweir using namespace dbaui; 39cdf0e10cSrcweir void ODriversSettings::getSupportedIndirectSettings( const ::rtl::OUString& _sURLPrefix,const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xFactory, ::std::vector< sal_Int32>& _out_rDetailsIds ) 40cdf0e10cSrcweir { 41cdf0e10cSrcweir // for a number of settings, we do not need to use hard-coded here, but can ask a 42cdf0e10cSrcweir // central DataSourceUI instance. 43cdf0e10cSrcweir DataSourceMetaData aMeta( _sURLPrefix ); 44cdf0e10cSrcweir const FeatureSet& rFeatures( aMeta.getFeatureSet() ); 45cdf0e10cSrcweir for ( FeatureSet::const_iterator feature = rFeatures.begin(); 46cdf0e10cSrcweir feature != rFeatures.end(); 47cdf0e10cSrcweir ++feature 48cdf0e10cSrcweir ) 49cdf0e10cSrcweir { 50cdf0e10cSrcweir _out_rDetailsIds.push_back( *feature ); 51cdf0e10cSrcweir } 52cdf0e10cSrcweir 53cdf0e10cSrcweir // the rest is configuration-based 54cdf0e10cSrcweir // TODO: that's not really true: *everything* is configuration-based nowadays, even the FeatureSet obtained 55cdf0e10cSrcweir // from the DataSourceMetaData has been initialized from the configuration. So in fact, we could consolidate 56cdf0e10cSrcweir // the two blocks. 57cdf0e10cSrcweir // The best approach would be to extend the FeatureSet to contain *all* known data source features, not only 58cdf0e10cSrcweir // the ones from the "Advanced settings" UI. 59cdf0e10cSrcweir 60cdf0e10cSrcweir ::connectivity::DriversConfig aDriverConfig(_xFactory); 61cdf0e10cSrcweir const ::comphelper::NamedValueCollection& aProperties = aDriverConfig.getProperties(_sURLPrefix); 62cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0 63cdf0e10cSrcweir { 64cdf0e10cSrcweir Sequence< NamedValue > aNamedValues; 65cdf0e10cSrcweir aProperties >>= aNamedValues; 66cdf0e10cSrcweir for ( const NamedValue* loop = aNamedValues.getConstArray(); 67cdf0e10cSrcweir loop != aNamedValues.getConstArray() + aNamedValues.getLength(); 68cdf0e10cSrcweir ++loop 69cdf0e10cSrcweir ) 70cdf0e10cSrcweir { 71cdf0e10cSrcweir int dummy = 0; 72cdf0e10cSrcweir (void)dummy; 73cdf0e10cSrcweir } 74cdf0e10cSrcweir } 75cdf0e10cSrcweir #endif 76cdf0e10cSrcweir typedef ::std::pair<sal_uInt16, ::rtl::OUString> TProperties; 77cdf0e10cSrcweir TProperties aProps[] = { TProperties(DSID_SHOWDELETEDROWS,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ShowDeleted"))) 78cdf0e10cSrcweir ,TProperties(DSID_CHARSET,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CharSet"))) 79cdf0e10cSrcweir ,TProperties(DSID_FIELDDELIMITER,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FieldDelimiter"))) 80cdf0e10cSrcweir ,TProperties(DSID_TEXTDELIMITER,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("StringDelimiter"))) 81cdf0e10cSrcweir ,TProperties(DSID_DECIMALDELIMITER,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DecimalDelimiter"))) 82cdf0e10cSrcweir ,TProperties(DSID_THOUSANDSDELIMITER,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ThousandDelimiter"))) 83cdf0e10cSrcweir ,TProperties(DSID_TEXTFILEEXTENSION,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Extension"))) 84cdf0e10cSrcweir ,TProperties(DSID_TEXTFILEHEADER,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("HeaderLine"))) 85cdf0e10cSrcweir ,TProperties(DSID_ADDITIONALOPTIONS,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SystemDriverSettings"))) 86cdf0e10cSrcweir ,TProperties(DSID_CONN_SHUTSERVICE,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ShutdownDatabase"))) 87cdf0e10cSrcweir ,TProperties(DSID_CONN_DATAINC,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DataCacheSizeIncrement"))) 88cdf0e10cSrcweir ,TProperties(DSID_CONN_CACHESIZE,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DataCacheSize"))) 89cdf0e10cSrcweir ,TProperties(DSID_CONN_CTRLUSER,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ControlUser"))) 90cdf0e10cSrcweir ,TProperties(DSID_CONN_CTRLPWD,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ControlPassword"))) 91cdf0e10cSrcweir ,TProperties(DSID_USECATALOG,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("UseCatalog"))) 92cdf0e10cSrcweir ,TProperties(DSID_CONN_SOCKET,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("LocalSocket"))) 93cdf0e10cSrcweir ,TProperties(DSID_NAMED_PIPE,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("NamedPipe"))) 94cdf0e10cSrcweir ,TProperties(DSID_JDBCDRIVERCLASS,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JavaDriverClass"))) 95cdf0e10cSrcweir ,TProperties(DSID_CONN_LDAP_BASEDN,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("BaseDN"))) 96cdf0e10cSrcweir ,TProperties(DSID_CONN_LDAP_ROWCOUNT,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MaxRowCount"))) 97cdf0e10cSrcweir ,TProperties(DSID_CONN_LDAP_USESSL,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("UseSSL"))) 98cdf0e10cSrcweir ,TProperties(DSID_IGNORECURRENCY,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IgnoreCurrency"))) 99cdf0e10cSrcweir ,TProperties(0,::rtl::OUString()) 100cdf0e10cSrcweir }; 101cdf0e10cSrcweir // TODO: This mapping between IDs and property names already exists - in ODbDataSourceAdministrationHelper::ODbDataSourceAdministrationHelper. 102cdf0e10cSrcweir // Another mapping (which is also duplicated in ODbDataSourceAdministrationHelper) exists in dsmeta.cxx. We should 103cdf0e10cSrcweir // consolidate those three places into one. 104cdf0e10cSrcweir // However, care has to be taken: We need to distinguish between "features" and "properties" of a data source (resp. driver). 105cdf0e10cSrcweir // That is, a driver can support a certain property, but not allow to change it in the UI, which means it would 106cdf0e10cSrcweir // not have the respective "feature". 107cdf0e10cSrcweir for ( TProperties* pProps = aProps; pProps->first; ++pProps ) 108cdf0e10cSrcweir { 109cdf0e10cSrcweir if ( aProperties.has(pProps->second) ) 110cdf0e10cSrcweir _out_rDetailsIds.push_back(pProps->first); 111cdf0e10cSrcweir } 112cdf0e10cSrcweir } 113