Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
5 : : * This Source Code Form is subject to the terms of the Mozilla Public
6 : : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : : *
9 : : * This file incorporates work covered by the following license notice:
10 : : *
11 : : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : : * contributor license agreements. See the NOTICE file distributed
13 : : * with this work for additional information regarding copyright
14 : : * ownership. The ASF licenses this file to you under the Apache
15 : : * License, Version 2.0 (the "License"); you may not use this file
16 : : * except in compliance with the License. You may obtain a copy of
17 : : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : : */
19 : :
20 : :
21 : : #include "DriverSettings.hxx"
22 : : #include "dsmeta.hxx"
23 : :
24 : : #include <com/sun/star/uno/Sequence.hxx>
25 : : #include <com/sun/star/beans/NamedValue.hpp>
26 : :
27 : : #include <connectivity/DriversConfig.hxx>
28 : :
29 : : using ::com::sun::star::uno::Sequence;
30 : : using ::com::sun::star::beans::NamedValue;
31 : :
32 : : using namespace dbaui;
33 : 0 : 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 )
34 : : {
35 : : // for a number of settings, we do not need to use hard-coded here, but can ask a
36 : : // central DataSourceUI instance.
37 [ # # ]: 0 : DataSourceMetaData aMeta( _sURLPrefix );
38 [ # # ]: 0 : const FeatureSet& rFeatures( aMeta.getFeatureSet() );
39 [ # # # # ]: 0 : for ( FeatureSet::const_iterator feature = rFeatures.begin();
[ # # ]
40 : 0 : feature != rFeatures.end();
41 : : ++feature
42 : : )
43 : : {
44 [ # # ][ # # ]: 0 : _out_rDetailsIds.push_back( *feature );
45 : : }
46 : :
47 : : // the rest is configuration-based
48 : : // TODO: that's not really true: *everything* is configuration-based nowadays, even the FeatureSet obtained
49 : : // from the DataSourceMetaData has been initialized from the configuration. So in fact, we could consolidate
50 : : // the two blocks.
51 : : // The best approach would be to extend the FeatureSet to contain *all* known data source features, not only
52 : : // the ones from the "Advanced settings" UI.
53 : :
54 [ # # ]: 0 : ::connectivity::DriversConfig aDriverConfig(_xFactory);
55 [ # # ]: 0 : const ::comphelper::NamedValueCollection& aProperties = aDriverConfig.getProperties(_sURLPrefix);
56 : : #if OSL_DEBUG_LEVEL > 0
57 : : {
58 : : Sequence< NamedValue > aNamedValues;
59 : : aProperties >>= aNamedValues;
60 : : for ( const NamedValue* loop = aNamedValues.getConstArray();
61 : : loop != aNamedValues.getConstArray() + aNamedValues.getLength();
62 : : ++loop
63 : : )
64 : : {
65 : : int dummy = 0;
66 : : (void)dummy;
67 : : }
68 : : }
69 : : #endif
70 : : typedef ::std::pair<sal_uInt16, ::rtl::OUString> TProperties;
71 : : TProperties aProps[] = { TProperties(DSID_SHOWDELETEDROWS,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ShowDeleted")))
72 : : ,TProperties(DSID_CHARSET,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CharSet")))
73 : : ,TProperties(DSID_FIELDDELIMITER,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FieldDelimiter")))
74 : : ,TProperties(DSID_TEXTDELIMITER,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("StringDelimiter")))
75 : : ,TProperties(DSID_DECIMALDELIMITER,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DecimalDelimiter")))
76 : : ,TProperties(DSID_THOUSANDSDELIMITER,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ThousandDelimiter")))
77 : : ,TProperties(DSID_TEXTFILEEXTENSION,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Extension")))
78 : : ,TProperties(DSID_TEXTFILEHEADER,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("HeaderLine")))
79 : : ,TProperties(DSID_ADDITIONALOPTIONS,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SystemDriverSettings")))
80 : : ,TProperties(DSID_CONN_SHUTSERVICE,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ShutdownDatabase")))
81 : : ,TProperties(DSID_CONN_DATAINC,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DataCacheSizeIncrement")))
82 : : ,TProperties(DSID_CONN_CACHESIZE,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DataCacheSize")))
83 : : ,TProperties(DSID_CONN_CTRLUSER,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ControlUser")))
84 : : ,TProperties(DSID_CONN_CTRLPWD,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ControlPassword")))
85 : : ,TProperties(DSID_USECATALOG,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("UseCatalog")))
86 : : ,TProperties(DSID_CONN_SOCKET,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("LocalSocket")))
87 : : ,TProperties(DSID_NAMED_PIPE,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("NamedPipe")))
88 : : ,TProperties(DSID_JDBCDRIVERCLASS,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JavaDriverClass")))
89 : : ,TProperties(DSID_CONN_LDAP_BASEDN,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("BaseDN")))
90 : : ,TProperties(DSID_CONN_LDAP_ROWCOUNT,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MaxRowCount")))
91 : : ,TProperties(DSID_CONN_LDAP_USESSL,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("UseSSL")))
92 : : ,TProperties(DSID_IGNORECURRENCY,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IgnoreCurrency")))
93 : : ,TProperties(0,::rtl::OUString())
94 [ # # ][ # # ]: 0 : };
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # # # ]
95 : : // TODO: This mapping between IDs and property names already exists - in ODbDataSourceAdministrationHelper::ODbDataSourceAdministrationHelper.
96 : : // Another mapping (which is also duplicated in ODbDataSourceAdministrationHelper) exists in dsmeta.cxx. We should
97 : : // consolidate those three places into one.
98 : : // However, care has to be taken: We need to distinguish between "features" and "properties" of a data source (resp. driver).
99 : : // That is, a driver can support a certain property, but not allow to change it in the UI, which means it would
100 : : // not have the respective "feature".
101 [ # # ]: 0 : for ( TProperties* pProps = aProps; pProps->first; ++pProps )
102 : : {
103 [ # # ][ # # ]: 0 : if ( aProperties.has(pProps->second) )
104 [ # # ]: 0 : _out_rDetailsIds.push_back(pProps->first);
105 [ # # ][ # # ]: 0 : }
[ # # # # ]
106 : 0 : }
107 : :
108 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|