xref: /AOO41X/main/dbaccess/source/ui/dlg/DriverSettings.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_dbaccess.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include "DriverSettings.hxx"
32*cdf0e10cSrcweir #include "dsmeta.hxx"
33*cdf0e10cSrcweir 
34*cdf0e10cSrcweir #include <com/sun/star/uno/Sequence.hxx>
35*cdf0e10cSrcweir #include <com/sun/star/beans/NamedValue.hpp>
36*cdf0e10cSrcweir 
37*cdf0e10cSrcweir #include <connectivity/DriversConfig.hxx>
38*cdf0e10cSrcweir 
39*cdf0e10cSrcweir using ::com::sun::star::uno::Sequence;
40*cdf0e10cSrcweir using ::com::sun::star::beans::NamedValue;
41*cdf0e10cSrcweir 
42*cdf0e10cSrcweir using namespace dbaui;
43*cdf0e10cSrcweir 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 )
44*cdf0e10cSrcweir {
45*cdf0e10cSrcweir     // for a number of settings, we do not need to use hard-coded here, but can ask a
46*cdf0e10cSrcweir     // central DataSourceUI instance.
47*cdf0e10cSrcweir     DataSourceMetaData aMeta( _sURLPrefix );
48*cdf0e10cSrcweir     const FeatureSet& rFeatures( aMeta.getFeatureSet() );
49*cdf0e10cSrcweir     for (   FeatureSet::const_iterator feature = rFeatures.begin();
50*cdf0e10cSrcweir             feature != rFeatures.end();
51*cdf0e10cSrcweir             ++feature
52*cdf0e10cSrcweir         )
53*cdf0e10cSrcweir     {
54*cdf0e10cSrcweir         _out_rDetailsIds.push_back( *feature );
55*cdf0e10cSrcweir     }
56*cdf0e10cSrcweir 
57*cdf0e10cSrcweir     // the rest is configuration-based
58*cdf0e10cSrcweir     // TODO: that's not really true: *everything* is configuration-based nowadays, even the FeatureSet obtained
59*cdf0e10cSrcweir     // from the DataSourceMetaData has been initialized from the configuration. So in fact, we could consolidate
60*cdf0e10cSrcweir     // the two blocks.
61*cdf0e10cSrcweir     // The best approach would be to extend the FeatureSet to contain *all* known data source features, not only
62*cdf0e10cSrcweir     // the ones from the "Advanced settings" UI.
63*cdf0e10cSrcweir 
64*cdf0e10cSrcweir     ::connectivity::DriversConfig aDriverConfig(_xFactory);
65*cdf0e10cSrcweir     const ::comphelper::NamedValueCollection& aProperties = aDriverConfig.getProperties(_sURLPrefix);
66*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0
67*cdf0e10cSrcweir     {
68*cdf0e10cSrcweir         Sequence< NamedValue > aNamedValues;
69*cdf0e10cSrcweir         aProperties >>= aNamedValues;
70*cdf0e10cSrcweir         for (   const NamedValue* loop = aNamedValues.getConstArray();
71*cdf0e10cSrcweir                 loop != aNamedValues.getConstArray() + aNamedValues.getLength();
72*cdf0e10cSrcweir                 ++loop
73*cdf0e10cSrcweir             )
74*cdf0e10cSrcweir         {
75*cdf0e10cSrcweir             int dummy = 0;
76*cdf0e10cSrcweir             (void)dummy;
77*cdf0e10cSrcweir         }
78*cdf0e10cSrcweir     }
79*cdf0e10cSrcweir #endif
80*cdf0e10cSrcweir     typedef ::std::pair<sal_uInt16, ::rtl::OUString> TProperties;
81*cdf0e10cSrcweir     TProperties aProps[] = { TProperties(DSID_SHOWDELETEDROWS,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ShowDeleted")))
82*cdf0e10cSrcweir                             ,TProperties(DSID_CHARSET,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CharSet")))
83*cdf0e10cSrcweir                             ,TProperties(DSID_FIELDDELIMITER,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FieldDelimiter")))
84*cdf0e10cSrcweir                             ,TProperties(DSID_TEXTDELIMITER,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("StringDelimiter")))
85*cdf0e10cSrcweir                             ,TProperties(DSID_DECIMALDELIMITER,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DecimalDelimiter")))
86*cdf0e10cSrcweir                             ,TProperties(DSID_THOUSANDSDELIMITER,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ThousandDelimiter")))
87*cdf0e10cSrcweir                             ,TProperties(DSID_TEXTFILEEXTENSION,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Extension")))
88*cdf0e10cSrcweir                             ,TProperties(DSID_TEXTFILEHEADER,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("HeaderLine")))
89*cdf0e10cSrcweir                             ,TProperties(DSID_ADDITIONALOPTIONS,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SystemDriverSettings")))
90*cdf0e10cSrcweir                             ,TProperties(DSID_CONN_SHUTSERVICE,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ShutdownDatabase")))
91*cdf0e10cSrcweir                             ,TProperties(DSID_CONN_DATAINC,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DataCacheSizeIncrement")))
92*cdf0e10cSrcweir                             ,TProperties(DSID_CONN_CACHESIZE,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DataCacheSize")))
93*cdf0e10cSrcweir                             ,TProperties(DSID_CONN_CTRLUSER,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ControlUser")))
94*cdf0e10cSrcweir                             ,TProperties(DSID_CONN_CTRLPWD,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ControlPassword")))
95*cdf0e10cSrcweir                             ,TProperties(DSID_USECATALOG,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("UseCatalog")))
96*cdf0e10cSrcweir                             ,TProperties(DSID_CONN_SOCKET,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("LocalSocket")))
97*cdf0e10cSrcweir                             ,TProperties(DSID_NAMED_PIPE,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("NamedPipe")))
98*cdf0e10cSrcweir                             ,TProperties(DSID_JDBCDRIVERCLASS,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JavaDriverClass")))
99*cdf0e10cSrcweir                             ,TProperties(DSID_CONN_LDAP_BASEDN,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("BaseDN")))
100*cdf0e10cSrcweir                             ,TProperties(DSID_CONN_LDAP_ROWCOUNT,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MaxRowCount")))
101*cdf0e10cSrcweir                             ,TProperties(DSID_CONN_LDAP_USESSL,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("UseSSL")))
102*cdf0e10cSrcweir                             ,TProperties(DSID_IGNORECURRENCY,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IgnoreCurrency")))
103*cdf0e10cSrcweir                             ,TProperties(0,::rtl::OUString())
104*cdf0e10cSrcweir     };
105*cdf0e10cSrcweir     // TODO: This mapping between IDs and property names already exists - in ODbDataSourceAdministrationHelper::ODbDataSourceAdministrationHelper.
106*cdf0e10cSrcweir     // Another mapping (which is also duplicated in ODbDataSourceAdministrationHelper) exists in dsmeta.cxx. We should
107*cdf0e10cSrcweir     // consolidate those three places into one.
108*cdf0e10cSrcweir     // However, care has to be taken: We need to distinguish between "features" and "properties" of a data source (resp. driver).
109*cdf0e10cSrcweir     // That is, a driver can support a certain property, but not allow to change it in the UI, which means it would
110*cdf0e10cSrcweir     // not have the respective "feature".
111*cdf0e10cSrcweir     for ( TProperties* pProps = aProps; pProps->first; ++pProps )
112*cdf0e10cSrcweir     {
113*cdf0e10cSrcweir         if ( aProperties.has(pProps->second) )
114*cdf0e10cSrcweir             _out_rDetailsIds.push_back(pProps->first);
115*cdf0e10cSrcweir     }
116*cdf0e10cSrcweir }
117