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