1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "DbAdminImpl.hxx"
23 #include <svl/poolitem.hxx>
24 #include <svl/itempool.hxx>
25 #include <svl/stritem.hxx>
26 #include <svl/intitem.hxx>
27 #include <svl/eitem.hxx>
28 #include "DriverSettings.hxx"
29 #include "IItemSetHelper.hxx"
30 #include "UITools.hxx"
31 #include "dbu_dlg.hrc"
32 #include "dbustrings.hrc"
33 #include "dsitems.hxx"
34 #include "dsnItem.hxx"
35 #include "moduledbu.hxx"
36 #include "optionalboolitem.hxx"
37 #include "propertysetitem.hxx"
38 #include "stringlistitem.hxx"
39 #include "OAuthenticationContinuation.hxx"
41 #include <com/sun/star/beans/PropertyAttribute.hpp>
42 #include <com/sun/star/frame/XStorable.hpp>
43 #include <com/sun/star/sdb/DatabaseContext.hpp>
44 #include <com/sun/star/sdb/SQLContext.hpp>
45 #include <com/sun/star/sdbc/ConnectionPool.hpp>
46 #include <com/sun/star/sdbc/XDriver.hpp>
47 #include <com/sun/star/sdbc/XDriverAccess.hpp>
48 #include <com/sun/star/task/InteractionHandler.hpp>
49 #include <com/sun/star/task/XInteractionRequest.hpp>
50 #include <com/sun/star/ucb/XInteractionSupplyAuthentication2.hpp>
51 #include <com/sun/star/ucb/AuthenticationRequest.hpp>
53 #include <comphelper/guarding.hxx>
54 #include <comphelper/interaction.hxx>
55 #include <comphelper/processfactory.hxx>
56 #include <comphelper/property.hxx>
57 #include <comphelper/sequence.hxx>
58 #include <comphelper/string.hxx>
59 #include <connectivity/DriversConfig.hxx>
60 #include <connectivity/dbexception.hxx>
61 #include <osl/file.hxx>
62 #include <tools/diagnose_ex.h>
63 #include <osl/diagnose.h>
64 #include <typelib/typedescription.hxx>
65 #include <vcl/svapp.hxx>
66 #include <vcl/msgbox.hxx>
67 #include <vcl/stdtext.hxx>
68 #include <vcl/waitobj.hxx>
69 #include <osl/mutex.hxx>
73 #include <o3tl/compat_functional.hxx>
77 using namespace ::dbtools
;
78 using namespace com::sun::star::uno
;
79 using namespace com::sun::star
;
80 using namespace com::sun::star::ucb
;
81 using namespace com::sun::star::task
;
82 using namespace com::sun::star::sdbc
;
83 using namespace com::sun::star::sdb
;
84 using namespace com::sun::star::lang
;
85 using namespace com::sun::star::beans
;
86 using namespace com::sun::star::util
;
87 using namespace com::sun::star::container
;
88 using namespace com::sun::star::frame
;
92 bool implCheckItemType( SfxItemSet
& _rSet
, const sal_uInt16 _nId
, const TypeId _nExpectedItemType
)
94 bool bCorrectType
= false;
96 SfxItemPool
* pPool
= _rSet
.GetPool();
97 OSL_ENSURE( pPool
, "implCheckItemType: invalid item pool!" );
100 const SfxPoolItem
& rDefItem
= pPool
->GetDefaultItem( _nId
);
101 bCorrectType
= rDefItem
.IsA( _nExpectedItemType
);
106 void lcl_putProperty(const Reference
< XPropertySet
>& _rxSet
, const OUString
& _rName
, const Any
& _rValue
)
111 _rxSet
->setPropertyValue(_rName
, _rValue
);
115 #if OSL_DEBUG_LEVEL > 0
116 OString
sMessage("ODbAdminDialog::implTranslateProperty: could not set the property ");
117 sMessage
+= OString(_rName
.getStr(), _rName
.getLength(), RTL_TEXTENCODING_ASCII_US
);
118 sMessage
+= OString("!");
119 OSL_FAIL(sMessage
.getStr());
125 OUString
lcl_createHostWithPort(const SfxStringItem
* _pHostName
,const SfxInt32Item
* _pPortNumber
)
129 if ( _pHostName
&& _pHostName
->GetValue().getLength() )
130 sNewUrl
= _pHostName
->GetValue();
134 sNewUrl
= sNewUrl
+ ":" + OUString::number(_pPortNumber
->GetValue());
141 // ODbDataSourceAdministrationHelper
142 ODbDataSourceAdministrationHelper::ODbDataSourceAdministrationHelper(const Reference
< XComponentContext
>& _xORB
, vcl::Window
* _pParent
,IItemSetHelper
* _pItemSetHelper
)
144 , m_pParent(_pParent
)
145 , m_pItemSetHelper(_pItemSetHelper
)
147 /// initialize the property translation map
148 // direct properties of a data source
149 m_aDirectPropTranslator
.insert(MapInt2String::value_type(DSID_CONNECTURL
, PROPERTY_URL
));
150 m_aDirectPropTranslator
.insert(MapInt2String::value_type(DSID_NAME
, PROPERTY_NAME
));
151 m_aDirectPropTranslator
.insert(MapInt2String::value_type(DSID_USER
, PROPERTY_USER
));
152 m_aDirectPropTranslator
.insert(MapInt2String::value_type(DSID_PASSWORD
, PROPERTY_PASSWORD
));
153 m_aDirectPropTranslator
.insert(MapInt2String::value_type(DSID_PASSWORDREQUIRED
, PROPERTY_ISPASSWORDREQUIRED
));
154 m_aDirectPropTranslator
.insert(MapInt2String::value_type(DSID_TABLEFILTER
, PROPERTY_TABLEFILTER
));
155 m_aDirectPropTranslator
.insert(MapInt2String::value_type(DSID_READONLY
, PROPERTY_ISREADONLY
));
156 m_aDirectPropTranslator
.insert(MapInt2String::value_type(DSID_SUPPRESSVERSIONCL
, PROPERTY_SUPPRESSVERSIONCL
));
158 // implicit properties, to be found in the direct property "Info"
159 m_aIndirectPropTranslator
.insert(MapInt2String::value_type(DSID_JDBCDRIVERCLASS
, INFO_JDBCDRIVERCLASS
));
160 m_aIndirectPropTranslator
.insert(MapInt2String::value_type(DSID_TEXTFILEEXTENSION
, INFO_TEXTFILEEXTENSION
));
161 m_aIndirectPropTranslator
.insert(MapInt2String::value_type(DSID_CHARSET
, INFO_CHARSET
));
162 m_aIndirectPropTranslator
.insert(MapInt2String::value_type(DSID_TEXTFILEHEADER
, INFO_TEXTFILEHEADER
));
163 m_aIndirectPropTranslator
.insert(MapInt2String::value_type(DSID_FIELDDELIMITER
, INFO_FIELDDELIMITER
));
164 m_aIndirectPropTranslator
.insert(MapInt2String::value_type(DSID_TEXTDELIMITER
, INFO_TEXTDELIMITER
));
165 m_aIndirectPropTranslator
.insert(MapInt2String::value_type(DSID_DECIMALDELIMITER
, INFO_DECIMALDELIMITER
));
166 m_aIndirectPropTranslator
.insert(MapInt2String::value_type(DSID_THOUSANDSDELIMITER
, INFO_THOUSANDSDELIMITER
));
167 m_aIndirectPropTranslator
.insert(MapInt2String::value_type(DSID_SHOWDELETEDROWS
, INFO_SHOWDELETEDROWS
));
168 m_aIndirectPropTranslator
.insert(MapInt2String::value_type(DSID_ALLOWLONGTABLENAMES
, INFO_ALLOWLONGTABLENAMES
));
169 m_aIndirectPropTranslator
.insert(MapInt2String::value_type(DSID_ADDITIONALOPTIONS
, INFO_ADDITIONALOPTIONS
));
170 m_aIndirectPropTranslator
.insert(MapInt2String::value_type(DSID_SQL92CHECK
, PROPERTY_ENABLESQL92CHECK
));
171 m_aIndirectPropTranslator
.insert(MapInt2String::value_type(DSID_AUTOINCREMENTVALUE
, PROPERTY_AUTOINCREMENTCREATION
));
172 m_aIndirectPropTranslator
.insert(MapInt2String::value_type(DSID_AUTORETRIEVEVALUE
, INFO_AUTORETRIEVEVALUE
));
173 m_aIndirectPropTranslator
.insert(MapInt2String::value_type(DSID_AUTORETRIEVEENABLED
, INFO_AUTORETRIEVEENABLED
));
174 m_aIndirectPropTranslator
.insert(MapInt2String::value_type(DSID_APPEND_TABLE_ALIAS
, INFO_APPEND_TABLE_ALIAS
));
175 m_aIndirectPropTranslator
.insert(MapInt2String::value_type(DSID_AS_BEFORE_CORRNAME
, INFO_AS_BEFORE_CORRELATION_NAME
) );
176 m_aIndirectPropTranslator
.insert(MapInt2String::value_type(DSID_CHECK_REQUIRED_FIELDS
, INFO_FORMS_CHECK_REQUIRED_FIELDS
) );
177 m_aIndirectPropTranslator
.insert(MapInt2String::value_type(DSID_ESCAPE_DATETIME
, INFO_ESCAPE_DATETIME
) );
178 m_aIndirectPropTranslator
.insert(MapInt2String::value_type(DSID_PRIMARY_KEY_SUPPORT
, OUString("PrimaryKeySupport")));
179 m_aIndirectPropTranslator
.insert(MapInt2String::value_type(DSID_PARAMETERNAMESUBST
, INFO_PARAMETERNAMESUBST
));
180 m_aIndirectPropTranslator
.insert(MapInt2String::value_type(DSID_IGNOREDRIVER_PRIV
, INFO_IGNOREDRIVER_PRIV
));
181 m_aIndirectPropTranslator
.insert(MapInt2String::value_type(DSID_BOOLEANCOMPARISON
, PROPERTY_BOOLEANCOMPARISONMODE
));
182 m_aIndirectPropTranslator
.insert(MapInt2String::value_type(DSID_ENABLEOUTERJOIN
, PROPERTY_ENABLEOUTERJOIN
));
183 m_aIndirectPropTranslator
.insert(MapInt2String::value_type(DSID_CATALOG
, PROPERTY_USECATALOGINSELECT
));
184 m_aIndirectPropTranslator
.insert(MapInt2String::value_type(DSID_SCHEMA
, PROPERTY_USESCHEMAINSELECT
));
185 m_aIndirectPropTranslator
.insert(MapInt2String::value_type(DSID_INDEXAPPENDIX
, OUString("AddIndexAppendix")));
186 m_aIndirectPropTranslator
.insert(MapInt2String::value_type(DSID_DOSLINEENDS
, OUString("PreferDosLikeLineEnds")));
187 m_aIndirectPropTranslator
.insert(MapInt2String::value_type(DSID_CONN_SOCKET
, OUString("LocalSocket")));
188 m_aIndirectPropTranslator
.insert(MapInt2String::value_type(DSID_NAMED_PIPE
, OUString("NamedPipe")));
189 m_aIndirectPropTranslator
.insert(MapInt2String::value_type(DSID_RESPECTRESULTSETTYPE
, OUString("RespectDriverResultSetType")));
190 m_aIndirectPropTranslator
.insert(MapInt2String::value_type(DSID_MAX_ROW_SCAN
, OUString("MaxRowScan")));
192 // extra settings for odbc
193 m_aIndirectPropTranslator
.insert(MapInt2String::value_type(DSID_USECATALOG
, INFO_USECATALOG
));
194 // extra settings for a ldap address book
195 m_aIndirectPropTranslator
.insert(MapInt2String::value_type(DSID_CONN_LDAP_BASEDN
, INFO_CONN_LDAP_BASEDN
));
196 m_aIndirectPropTranslator
.insert(MapInt2String::value_type(DSID_CONN_LDAP_ROWCOUNT
, INFO_CONN_LDAP_ROWCOUNT
));
197 m_aIndirectPropTranslator
.insert(MapInt2String::value_type(DSID_CONN_LDAP_USESSL
, OUString("UseSSL")));
198 m_aIndirectPropTranslator
.insert(MapInt2String::value_type(DSID_DOCUMENT_URL
, PROPERTY_URL
));
201 m_aIndirectPropTranslator
.insert(MapInt2String::value_type(DSID_IGNORECURRENCY
, OUString("IgnoreCurrency")));
205 m_xDatabaseContext
= DatabaseContext::create(m_xContext
);
207 catch(const Exception
&)
209 ShowServiceNotAvailableError(_pParent
->GetParent(), OUString("com.sun.star.sdb.DatabaseContext"), true);
213 bool ODbDataSourceAdministrationHelper::getCurrentSettings(Sequence
< PropertyValue
>& _rDriverParam
)
215 OSL_ENSURE(m_pItemSetHelper
->getOutputSet(), "ODbDataSourceAdministrationHelper::getCurrentSettings : not to be called without an example set!");
216 if (!m_pItemSetHelper
->getOutputSet())
219 ::std::vector
< PropertyValue
> aReturn
;
220 // collecting this in a vector because it has a push_back, in opposite to sequences
222 // user: DSID_USER -> "user"
223 SFX_ITEMSET_GET(*m_pItemSetHelper
->getOutputSet(), pUser
, SfxStringItem
, DSID_USER
, true);
224 if (pUser
&& pUser
->GetValue().getLength())
226 PropertyValue( OUString("user"), 0,
227 makeAny(OUString(pUser
->GetValue())), PropertyState_DIRECT_VALUE
));
229 // check if the connection type requires a password
230 if (hasAuthentication(*m_pItemSetHelper
->getOutputSet()))
232 // password: DSID_PASSWORD -> password
233 SFX_ITEMSET_GET(*m_pItemSetHelper
->getOutputSet(), pPassword
, SfxStringItem
, DSID_PASSWORD
, true);
234 OUString sPassword
= pPassword
? pPassword
->GetValue() : OUString();
235 SFX_ITEMSET_GET(*m_pItemSetHelper
->getOutputSet(), pPasswordRequired
, SfxBoolItem
, DSID_PASSWORDREQUIRED
, true);
236 // if the set does not contain a password, but the item set says it requires one, ask the user
237 if ((!pPassword
|| !pPassword
->GetValue().getLength()) && (pPasswordRequired
&& pPasswordRequired
->GetValue()))
239 SFX_ITEMSET_GET(*m_pItemSetHelper
->getOutputSet(), pName
, SfxStringItem
, DSID_NAME
, true);
241 Reference
< XModel
> xModel( getDataSourceOrModel( m_xDatasource
), UNO_QUERY_THROW
);
242 ::comphelper::NamedValueCollection
aArgs( xModel
->getArgs() );
243 Reference
< XInteractionHandler
> xHandler( aArgs
.getOrDefault( "InteractionHandler", Reference
< XInteractionHandler
>() ) );
245 if ( !xHandler
.is() )
247 // instantiate the default SDB interaction handler
248 xHandler
= Reference
< XInteractionHandler
>( task::InteractionHandler::createWithParent(m_xContext
, 0), UNO_QUERY
);
251 OUString sName
= pName
? pName
->GetValue() : OUString();
252 OUString
sLoginRequest(ModuleRes(STR_ENTER_CONNECTION_PASSWORD
));
253 OUString sTemp
= sName
;
254 sName
= ::dbaui::getStrippedDatabaseName(NULL
,sTemp
);
255 if ( !sName
.isEmpty() )
256 sLoginRequest
= sLoginRequest
.replaceAll("$name$", sName
);
259 sLoginRequest
= sLoginRequest
.replaceAll("\"$name$\"", OUString());
260 // ensure that in other languages the string will be deleted
261 sLoginRequest
= sLoginRequest
.replaceAll("$name$", OUString());
265 AuthenticationRequest aRequest
;
266 aRequest
.ServerName
= sName
;
267 aRequest
.Diagnostic
= sLoginRequest
;
268 aRequest
.HasRealm
= aRequest
.HasAccount
= sal_False
;
270 aRequest
.HasUserName
= pUser
!= 0;
271 aRequest
.UserName
= pUser
? OUString(pUser
->GetValue()) : OUString();
272 aRequest
.HasPassword
= sal_True
;
274 aRequest
.HasAccount
= sal_False
;
277 comphelper::OInteractionRequest
* pRequest
= new comphelper::OInteractionRequest(makeAny(aRequest
));
278 uno::Reference
< XInteractionRequest
> xRequest(pRequest
);
280 // build an interaction request
281 // two continuations (Ok and Cancel)
282 ::rtl::Reference
< comphelper::OInteractionAbort
> pAbort
= new comphelper::OInteractionAbort
;
283 ::rtl::Reference
< dbaccess::OAuthenticationContinuation
> pAuthenticate
= new dbaccess::OAuthenticationContinuation
;
284 pAuthenticate
->setCanChangeUserName( false );
285 pAuthenticate
->setRememberPassword( RememberAuthentication_SESSION
);
288 pRequest
->addContinuation(pAbort
.get());
289 pRequest
->addContinuation(pAuthenticate
.get());
291 // handle the request
294 SolarMutexGuard aSolarGuard
;
295 // release the mutex when calling the handler, it may need to lock the SolarMutex
296 xHandler
->handle(xRequest
);
300 DBG_UNHANDLED_EXCEPTION();
302 if (!pAuthenticate
->wasSelected())
305 sPassword
= pAuthenticate
->getPassword();
306 if (pAuthenticate
->getRememberPassword())
307 m_pItemSetHelper
->getWriteOutputSet()->Put(SfxStringItem(DSID_PASSWORD
, sPassword
));
310 if (!sPassword
.isEmpty())
312 PropertyValue( OUString("password"), 0,
313 makeAny(OUString(sPassword
)), PropertyState_DIRECT_VALUE
));
316 if ( !aReturn
.empty() )
317 _rDriverParam
= Sequence
< PropertyValue
>(&(*aReturn
.begin()), aReturn
.size());
319 // append all the other stuff (charset etc.)
320 fillDatasourceInfo(*m_pItemSetHelper
->getOutputSet(), _rDriverParam
);
325 void ODbDataSourceAdministrationHelper::successfullyConnected()
327 OSL_ENSURE(m_pItemSetHelper
->getOutputSet(), "ODbDataSourceAdministrationHelper::successfullyConnected: not to be called without an example set!");
328 if (!m_pItemSetHelper
->getOutputSet())
331 if (hasAuthentication(*m_pItemSetHelper
->getOutputSet()))
333 SFX_ITEMSET_GET(*m_pItemSetHelper
->getOutputSet(), pPassword
, SfxStringItem
, DSID_PASSWORD
, true);
334 if (pPassword
&& (0 != pPassword
->GetValue().getLength()))
336 OUString sPassword
= pPassword
->GetValue();
338 Reference
< XPropertySet
> xCurrentDatasource
= getCurrentDataSource();
339 lcl_putProperty(xCurrentDatasource
,m_aDirectPropTranslator
[DSID_PASSWORD
], makeAny(sPassword
));
344 void ODbDataSourceAdministrationHelper::clearPassword()
346 if (m_pItemSetHelper
->getWriteOutputSet())
347 m_pItemSetHelper
->getWriteOutputSet()->ClearItem(DSID_PASSWORD
);
350 ::std::pair
< Reference
<XConnection
>,sal_Bool
> ODbDataSourceAdministrationHelper::createConnection()
352 ::std::pair
< Reference
<XConnection
>,sal_Bool
> aRet
;
353 aRet
.second
= sal_False
;
354 Sequence
< PropertyValue
> aConnectionParams
;
355 if ( getCurrentSettings(aConnectionParams
) )
358 // fill the table list with this connection information
359 SQLExceptionInfo aErrorInfo
;
362 WaitObject
aWaitCursor(m_pParent
);
363 aRet
.first
= getDriver()->connect(getConnectionURL(), aConnectionParams
);
364 aRet
.second
= sal_True
;
366 catch (const SQLContext
& e
) { aErrorInfo
= SQLExceptionInfo(e
); }
367 catch (const SQLWarning
& e
) { aErrorInfo
= SQLExceptionInfo(e
); }
368 catch (const SQLException
& e
) { aErrorInfo
= SQLExceptionInfo(e
); }
370 showError(aErrorInfo
,m_pParent
,getORB());
372 if ( aRet
.first
.is() )
373 successfullyConnected();// notify the admindlg to save the password
378 Reference
< XDriver
> ODbDataSourceAdministrationHelper::getDriver()
380 return getDriver(getConnectionURL());
383 Reference
< XDriver
> ODbDataSourceAdministrationHelper::getDriver(const OUString
& _sURL
)
385 // get the global DriverManager
386 Reference
< XConnectionPool
> xDriverManager
;
388 OUString sCurrentActionError
= ModuleRes(STR_COULDNOTCREATE_DRIVERMANAGER
);
389 sCurrentActionError
= sCurrentActionError
.replaceFirst("#servicename#", "com.sun.star.sdbc.ConnectionPool");
393 xDriverManager
.set( ConnectionPool::create( getORB() ) );
395 catch (const Exception
& e
)
397 // wrap the exception into an SQLException
398 SQLException
aSQLWrapper(e
.Message
, getORB(), OUString("S1000"), 0, Any());
399 throw SQLException(sCurrentActionError
, getORB(), OUString("S1000"), 0, makeAny(aSQLWrapper
));
402 Reference
< XDriver
> xDriver
= xDriverManager
->getDriverByURL(_sURL
);
405 sCurrentActionError
= ModuleRes(STR_NOREGISTEREDDRIVER
);
406 sCurrentActionError
= sCurrentActionError
.replaceFirst("#connurl#", _sURL
);
407 // will be caught and translated into an SQLContext exception
408 throw SQLException(sCurrentActionError
, getORB(), OUString("S1000"), 0, Any());
413 Reference
< XPropertySet
> ODbDataSourceAdministrationHelper::getCurrentDataSource()
415 if ( !m_xDatasource
.is() )
417 Reference
<XInterface
> xIn(m_aDataSourceOrName
,UNO_QUERY
);
420 OUString sCurrentDatasource
;
421 m_aDataSourceOrName
>>= sCurrentDatasource
;
422 OSL_ENSURE(!sCurrentDatasource
.isEmpty(),"No datasource name given!");
425 if ( m_xDatabaseContext
.is() )
426 m_xDatasource
.set(m_xDatabaseContext
->getByName(sCurrentDatasource
),UNO_QUERY
);
429 catch(const Exception
&)
433 m_xModel
.set(getDataSourceOrModel(xIn
),UNO_QUERY
);
435 m_xDatasource
.set(xIn
,UNO_QUERY
);
438 m_xDatasource
.set(getDataSourceOrModel(xIn
),UNO_QUERY
);
439 m_xModel
.set(xIn
,UNO_QUERY
);
443 OSL_ENSURE(m_xDatasource
.is(), "ODbDataSourceAdministrationHelper::getCurrentDataSource: no data source!");
444 return m_xDatasource
;
447 OUString
ODbDataSourceAdministrationHelper::getDatasourceType( const SfxItemSet
& _rSet
)
449 SFX_ITEMSET_GET( _rSet
, pConnectURL
, SfxStringItem
, DSID_CONNECTURL
, true );
450 OSL_ENSURE( pConnectURL
, "ODbDataSourceAdministrationHelper::getDatasourceType: invalid items in the source set!" );
451 SFX_ITEMSET_GET(_rSet
, pTypeCollection
, DbuTypeCollectionItem
, DSID_TYPECOLLECTION
, true);
452 OSL_ENSURE(pTypeCollection
, "ODbDataSourceAdministrationHelper::getDatasourceType: invalid items in the source set!");
453 ::dbaccess::ODsnTypeCollection
* pCollection
= pTypeCollection
->getCollection();
454 return pCollection
->getType(pConnectURL
->GetValue());
457 bool ODbDataSourceAdministrationHelper::hasAuthentication(const SfxItemSet
& _rSet
)
459 return DataSourceMetaData::getAuthentication( getDatasourceType( _rSet
) ) != AuthNone
;
462 OUString
ODbDataSourceAdministrationHelper::getConnectionURL() const
466 OUString eType
= getDatasourceType(*m_pItemSetHelper
->getOutputSet());
468 SFX_ITEMSET_GET(*m_pItemSetHelper
->getOutputSet(), pUrlItem
, SfxStringItem
, DSID_CONNECTURL
, true);
469 SFX_ITEMSET_GET(*m_pItemSetHelper
->getOutputSet(), pTypeCollection
, DbuTypeCollectionItem
, DSID_TYPECOLLECTION
, true);
471 OSL_ENSURE(pUrlItem
,"Connection URL is NULL. -> GPF!");
472 OSL_ENSURE(pTypeCollection
, "ODbDataSourceAdministrationHelper::getDatasourceType: invalid items in the source set!");
473 ::dbaccess::ODsnTypeCollection
* pCollection
= pTypeCollection
->getCollection();
474 OSL_ENSURE(pCollection
, "ODbDataSourceAdministrationHelper::getDatasourceType: invalid type collection!");
476 switch( pCollection
->determineType(eType
) )
478 case ::dbaccess::DST_DBASE
:
479 case ::dbaccess::DST_FLAT
:
480 case ::dbaccess::DST_CALC
:
482 case ::dbaccess::DST_MSACCESS
:
483 case ::dbaccess::DST_MSACCESS_2007
:
485 OUString sFileName
= pCollection
->cutPrefix(pUrlItem
->GetValue());
486 OUString sNewFileName
;
487 if ( ::osl::FileBase::getSystemPathFromFileURL( sFileName
, sNewFileName
) == ::osl::FileBase::E_None
)
489 sNewUrl
+= sNewFileName
;
493 case ::dbaccess::DST_MYSQL_NATIVE
:
494 case ::dbaccess::DST_MYSQL_JDBC
:
496 SFX_ITEMSET_GET(*m_pItemSetHelper
->getOutputSet(), pHostName
, SfxStringItem
, DSID_CONN_HOSTNAME
, true);
497 SFX_ITEMSET_GET(*m_pItemSetHelper
->getOutputSet(), pPortNumber
, SfxInt32Item
, DSID_MYSQL_PORTNUMBER
, true);
498 SFX_ITEMSET_GET(*m_pItemSetHelper
->getOutputSet(), pDatabaseName
, SfxStringItem
, DSID_DATABASENAME
, true);
499 sNewUrl
= lcl_createHostWithPort(pHostName
,pPortNumber
);
500 OUString sDatabaseName
= pDatabaseName
? pDatabaseName
->GetValue() : OUString();
501 if ( !sDatabaseName
.getLength() && pUrlItem
)
502 sDatabaseName
= pCollection
->cutPrefix( pUrlItem
->GetValue() );
503 // TODO: what's that? Why is the database name transported via the URL Item?
504 // Huh? Anybody there?
505 // OJ: It is needed when the connection properties are changed. There the URL is used for every type.
507 if ( !sDatabaseName
.isEmpty() )
509 sNewUrl
+= "/" + sDatabaseName
;
513 case ::dbaccess::DST_ORACLE_JDBC
:
515 SFX_ITEMSET_GET(*m_pItemSetHelper
->getOutputSet(), pHostName
, SfxStringItem
, DSID_CONN_HOSTNAME
, true);
516 SFX_ITEMSET_GET(*m_pItemSetHelper
->getOutputSet(), pPortNumber
, SfxInt32Item
, DSID_ORACLE_PORTNUMBER
, true);
517 SFX_ITEMSET_GET(*m_pItemSetHelper
->getOutputSet(), pDatabaseName
, SfxStringItem
, DSID_DATABASENAME
, true);
518 if ( pHostName
&& pHostName
->GetValue().getLength() )
520 sNewUrl
= "@" + lcl_createHostWithPort(pHostName
,pPortNumber
);
521 OUString sDatabaseName
= pDatabaseName
? pDatabaseName
->GetValue() : OUString();
522 if ( sDatabaseName
.isEmpty() && pUrlItem
)
523 sDatabaseName
= pCollection
->cutPrefix( pUrlItem
->GetValue() );
524 if ( !sDatabaseName
.isEmpty() )
526 sNewUrl
+= ":" + sDatabaseName
;
530 { // here someone entered a JDBC url which looks like oracle, so we have to use the url property
535 case ::dbaccess::DST_LDAP
:
537 SFX_ITEMSET_GET(*m_pItemSetHelper
->getOutputSet(), pPortNumber
, SfxInt32Item
, DSID_CONN_LDAP_PORTNUMBER
, true);
538 sNewUrl
= pCollection
->cutPrefix(pUrlItem
->GetValue()) + lcl_createHostWithPort(NULL
,pPortNumber
);
541 case ::dbaccess::DST_JDBC
:
546 if ( !sNewUrl
.isEmpty() )
547 sNewUrl
= pCollection
->getPrefix(eType
) + sNewUrl
;
549 sNewUrl
= pUrlItem
->GetValue();
554 struct PropertyValueLess
556 bool operator() (const PropertyValue
& x
, const PropertyValue
& y
) const
557 { return x
.Name
< y
.Name
; } // construct prevents a MSVC6 warning
560 typedef std::set
<PropertyValue
, PropertyValueLess
> PropertyValueSet
;
562 void ODbDataSourceAdministrationHelper::translateProperties(const Reference
< XPropertySet
>& _rxSource
, SfxItemSet
& _rDest
)
566 for ( MapInt2String::const_iterator aDirect
= m_aDirectPropTranslator
.begin();
567 aDirect
!= m_aDirectPropTranslator
.end();
571 // get the property value
575 aValue
= _rxSource
->getPropertyValue(aDirect
->second
);
579 #if OSL_DEBUG_LEVEL > 0
580 OString
aMessage("ODbDataSourceAdministrationHelper::translateProperties: could not extract the property ");
581 aMessage
+= OString(aDirect
->second
.getStr(), aDirect
->second
.getLength(), RTL_TEXTENCODING_ASCII_US
);
582 aMessage
+= OString("!");
583 OSL_FAIL(aMessage
.getStr());
586 // transfer it into an item
587 implTranslateProperty(_rDest
, aDirect
->first
, aValue
);
590 // get the additional information
591 Sequence
< PropertyValue
> aAdditionalInfo
;
594 _rxSource
->getPropertyValue(PROPERTY_INFO
) >>= aAdditionalInfo
;
596 catch(Exception
&) { }
598 // collect the names of the additional settings
599 const PropertyValue
* pAdditionalInfo
= aAdditionalInfo
.getConstArray();
600 PropertyValueSet aInfos
;
601 for (sal_Int32 i
=0; i
<aAdditionalInfo
.getLength(); ++i
, ++pAdditionalInfo
)
603 if( pAdditionalInfo
->Name
== "JDBCDRV" )
605 PropertyValue
aCompatibility(*pAdditionalInfo
);
606 aCompatibility
.Name
= "JavaDriverClass";
607 aInfos
.insert(aCompatibility
);
610 aInfos
.insert(*pAdditionalInfo
);
613 // go through all known translations and check if we have such a setting
614 if ( !aInfos
.empty() )
616 PropertyValue aSearchFor
;
617 MapInt2String::const_iterator aEnd
= m_aIndirectPropTranslator
.end();
618 for ( MapInt2String::const_iterator aIndirect
= m_aIndirectPropTranslator
.begin();
622 aSearchFor
.Name
= aIndirect
->second
;
623 PropertyValueSet::const_iterator aInfoPos
= aInfos
.find(aSearchFor
);
624 if (aInfos
.end() != aInfoPos
)
625 // the property is contained in the info sequence
626 // -> transfer it into an item
627 implTranslateProperty(_rDest
, aIndirect
->first
, aInfoPos
->Value
);
636 _rDest
.Put(OPropertySetItem(DSID_DATASOURCE_UNO
, _rxSource
));
637 Reference
<XStorable
> xStore(getDataSourceOrModel(_rxSource
),UNO_QUERY
);
638 _rDest
.Put(SfxBoolItem(DSID_READONLY
, !xStore
.is() || xStore
->isReadonly() ));
642 OSL_FAIL("IsReadOnly throws an exception!");
646 void ODbDataSourceAdministrationHelper::translateProperties(const SfxItemSet
& _rSource
, const Reference
< XPropertySet
>& _rxDest
)
648 OSL_ENSURE(_rxDest
.is(), "ODbDataSourceAdministrationHelper::translateProperties: invalid property set!");
652 // the property set info
653 Reference
< XPropertySetInfo
> xInfo
;
654 try { xInfo
= _rxDest
->getPropertySetInfo(); }
655 catch(Exception
&) { }
657 const OUString
sUrlProp("URL");
658 // transfer the direct properties
659 for ( MapInt2String::const_iterator aDirect
= m_aDirectPropTranslator
.begin();
660 aDirect
!= m_aDirectPropTranslator
.end();
664 const SfxPoolItem
* pCurrentItem
= _rSource
.GetItem((sal_uInt16
)aDirect
->first
);
667 sal_Int16 nAttributes
= PropertyAttribute::READONLY
;
670 try { nAttributes
= xInfo
->getPropertyByName(aDirect
->second
).Attributes
; }
671 catch(Exception
&) { }
673 if ((nAttributes
& PropertyAttribute::READONLY
) == 0)
675 if ( sUrlProp
== aDirect
->second
)
677 Any
aValue(makeAny(OUString(getConnectionURL())));
678 // aValue <<= OUString();
679 lcl_putProperty(_rxDest
, aDirect
->second
,aValue
);
682 implTranslateProperty(_rxDest
, aDirect
->second
, pCurrentItem
);
687 // now for the indirect properties
689 Sequence
< PropertyValue
> aInfo
;
690 // the original properties
693 _rxDest
->getPropertyValue(PROPERTY_INFO
) >>= aInfo
;
695 catch(Exception
&) { }
697 // overwrite and extend them
698 fillDatasourceInfo(_rSource
, aInfo
);
699 // and propagate the (newly composed) sequence to the set
700 lcl_putProperty(_rxDest
,PROPERTY_INFO
, makeAny(aInfo
));
703 void ODbDataSourceAdministrationHelper::fillDatasourceInfo(const SfxItemSet
& _rSource
, Sequence
< ::com::sun::star::beans::PropertyValue
>& _rInfo
)
705 // within the current "Info" sequence, replace the ones we can examine from the item set
706 // (we don't just fill a completely new sequence with our own items, but we preserve any properties unknown to
709 // first determine which of all the items are relevant for the data source (depends on the connection url)
710 OUString eType
= getDatasourceType(_rSource
);
711 ::std::vector
< sal_Int32
> aDetailIds
;
712 ODriversSettings::getSupportedIndirectSettings(eType
, getORB(), aDetailIds
);
714 // collect the translated property values for the relevant items
715 PropertyValueSet aRelevantSettings
;
716 MapInt2String::const_iterator aTranslation
;
717 ::std::vector
< sal_Int32
>::iterator aDetailsEnd
= aDetailIds
.end();
718 for (::std::vector
< sal_Int32
>::iterator aIter
= aDetailIds
.begin();aIter
!= aDetailsEnd
; ++aIter
)
720 const SfxPoolItem
* pCurrent
= _rSource
.GetItem((sal_uInt16
)*aIter
);
721 aTranslation
= m_aIndirectPropTranslator
.find(*aIter
);
722 if ( pCurrent
&& (m_aIndirectPropTranslator
.end() != aTranslation
) )
724 if ( aTranslation
->second
== INFO_CHARSET
)
727 implTranslateProperty(pCurrent
) >>= sCharSet
;
728 if ( !sCharSet
.isEmpty() )
729 aRelevantSettings
.insert(PropertyValue(aTranslation
->second
, 0, makeAny(sCharSet
), PropertyState_DIRECT_VALUE
));
732 aRelevantSettings
.insert(PropertyValue(aTranslation
->second
, 0, implTranslateProperty(pCurrent
), PropertyState_DIRECT_VALUE
));
736 // settings to preserve
737 MapInt2String aPreservedSettings
;
739 // now aRelevantSettings contains all the property values relevant for the current data source type,
740 // check the original sequence if it already contains any of these values (which have to be overwritten, then)
741 PropertyValue
* pInfo
= _rInfo
.getArray();
742 PropertyValue aSearchFor
;
743 sal_Int32 nObsoleteSetting
= -1;
744 sal_Int32 nCount
= _rInfo
.getLength();
745 for (sal_Int32 i
= 0; i
< nCount
; ++i
, ++pInfo
)
747 aSearchFor
.Name
= pInfo
->Name
;
748 PropertyValueSet::iterator aOverwrittenSetting
= aRelevantSettings
.find(aSearchFor
);
749 if (aRelevantSettings
.end() != aOverwrittenSetting
)
750 { // the setting was present in the original sequence, and it is to be overwritten -> replace it
751 if ( !::comphelper::compare(pInfo
->Value
,aOverwrittenSetting
->Value
) )
752 *pInfo
= *aOverwrittenSetting
;
753 aRelevantSettings
.erase(aOverwrittenSetting
);
755 else if( pInfo
->Name
== "JDBCDRV" )
756 { // this is a compatibility setting, remove it from the sequence (it's replaced by JavaDriverClass)
757 nObsoleteSetting
= i
;
760 aPreservedSettings
[i
] = pInfo
->Name
;
762 if (-1 != nObsoleteSetting
)
763 ::comphelper::removeElementAt(_rInfo
, nObsoleteSetting
);
765 if ( !aPreservedSettings
.empty() )
766 { // check if there are settings which
767 // * are known as indirect properties
768 // * but not relevant for the current data source type
769 // These settings have to be removed: If they're not relevant, we have no UI for changing them.
771 // for this, we need a string-controlled quick access to m_aIndirectPropTranslator
772 StringSet aIndirectProps
;
773 ::std::transform(m_aIndirectPropTranslator
.begin(),
774 m_aIndirectPropTranslator
.end(),
775 ::std::insert_iterator
<StringSet
>(aIndirectProps
,aIndirectProps
.begin()),
776 ::o3tl::select2nd
<MapInt2String::value_type
>());
778 // now check the to-be-preserved props
779 ::std::vector
< sal_Int32
> aRemoveIndexes
;
780 sal_Int32 nPositionCorrector
= 0;
781 MapInt2String::const_iterator aPreservedEnd
= aPreservedSettings
.end();
782 for ( MapInt2String::const_iterator aPreserved
= aPreservedSettings
.begin();
783 aPreserved
!= aPreservedEnd
;
787 if (aIndirectProps
.end() != aIndirectProps
.find(aPreserved
->second
))
789 aRemoveIndexes
.push_back(aPreserved
->first
- nPositionCorrector
);
790 ++nPositionCorrector
;
793 // now finally remove all such props
794 ::std::vector
< sal_Int32
>::const_iterator aRemoveEnd
= aRemoveIndexes
.end();
795 for ( ::std::vector
< sal_Int32
>::const_iterator aRemoveIndex
= aRemoveIndexes
.begin();
796 aRemoveIndex
!= aRemoveEnd
;
799 ::comphelper::removeElementAt(_rInfo
, *aRemoveIndex
);
802 ::connectivity::DriversConfig
aDriverConfig(getORB());
803 const ::comphelper::NamedValueCollection
& aProperties
= aDriverConfig
.getProperties(eType
);
804 Sequence
< Any
> aTypeSettings
;
805 aTypeSettings
= aProperties
.getOrDefault("TypeInfoSettings",aTypeSettings
);
806 // here we have a special entry for types from oracle
807 if ( aTypeSettings
.getLength() )
809 aRelevantSettings
.insert(PropertyValue(OUString("TypeInfoSettings"), 0, makeAny(aTypeSettings
), PropertyState_DIRECT_VALUE
));
812 // check which values are still left ('cause they were not present in the original sequence, but are to be set)
813 if ( !aRelevantSettings
.empty() )
815 sal_Int32 nOldLength
= _rInfo
.getLength();
816 _rInfo
.realloc(nOldLength
+ aRelevantSettings
.size());
817 PropertyValue
* pAppendValues
= _rInfo
.getArray() + nOldLength
;
818 PropertyValueSet::const_iterator aRelevantEnd
= aRelevantSettings
.end();
819 for ( PropertyValueSet::const_iterator aLoop
= aRelevantSettings
.begin();
820 aLoop
!= aRelevantEnd
;
821 ++aLoop
, ++pAppendValues
824 if ( aLoop
->Name
== INFO_CHARSET
)
827 aLoop
->Value
>>= sCharSet
;
828 if ( !sCharSet
.isEmpty() )
829 *pAppendValues
= *aLoop
;
832 *pAppendValues
= *aLoop
;
837 Any
ODbDataSourceAdministrationHelper::implTranslateProperty(const SfxPoolItem
* _pItem
)
839 // translate the SfxPoolItem
842 const SfxStringItem
* pStringItem
= PTR_CAST( SfxStringItem
, _pItem
);
843 const SfxBoolItem
* pBoolItem
= PTR_CAST( SfxBoolItem
, _pItem
);
844 const OptionalBoolItem
* pOptBoolItem
= PTR_CAST( OptionalBoolItem
, _pItem
);
845 const SfxInt32Item
* pInt32Item
= PTR_CAST( SfxInt32Item
, _pItem
);
846 const OStringListItem
* pStringListItem
= PTR_CAST( OStringListItem
, _pItem
);
850 aValue
<<= OUString( pStringItem
->GetValue().getStr() );
852 else if ( pBoolItem
)
854 aValue
<<= pBoolItem
->GetValue();
856 else if ( pOptBoolItem
)
858 if ( !pOptBoolItem
->HasValue() )
861 aValue
<<= pOptBoolItem
->GetValue();
863 else if ( pInt32Item
)
865 aValue
<<= pInt32Item
->GetValue();
867 else if ( pStringListItem
)
869 aValue
<<= pStringListItem
->getList();
873 OSL_FAIL("ODbDataSourceAdministrationHelper::implTranslateProperty: unsupported item type!");
880 void ODbDataSourceAdministrationHelper::implTranslateProperty(const Reference
< XPropertySet
>& _rxSet
, const OUString
& _rName
, const SfxPoolItem
* _pItem
)
882 Any aValue
= implTranslateProperty(_pItem
);
883 lcl_putProperty(_rxSet
, _rName
,aValue
);
886 #if OSL_DEBUG_LEVEL > 0
887 OString
ODbDataSourceAdministrationHelper::translatePropertyId( sal_Int32 _nId
)
891 MapInt2String::const_iterator aPos
= m_aDirectPropTranslator
.find( _nId
);
892 if ( m_aDirectPropTranslator
.end() != aPos
)
894 aString
= aPos
->second
;
898 MapInt2String::const_iterator indirectPos
= m_aIndirectPropTranslator
.find( _nId
);
899 if ( m_aIndirectPropTranslator
.end() != indirectPos
)
900 aString
= indirectPos
->second
;
903 OString
aReturn( aString
.getStr(), aString
.getLength(), RTL_TEXTENCODING_ASCII_US
);
909 void ODbDataSourceAdministrationHelper::implTranslateProperty( SfxItemSet
& _rSet
, sal_Int32 _nId
, const Any
& _rValue
)
911 switch ( _rValue
.getValueType().getTypeClass() )
913 case TypeClass_STRING
:
914 if ( implCheckItemType( _rSet
, _nId
, SfxStringItem::StaticType() ) )
918 _rSet
.Put(SfxStringItem(_nId
, sValue
));
922 ( OString( "ODbDataSourceAdministrationHelper::implTranslateProperty: invalid property value (" )
923 += OString( translatePropertyId( _nId
) )
924 += OString( " should be no string)!" )
930 case TypeClass_BOOLEAN
:
931 if ( implCheckItemType( _rSet
, _nId
, SfxBoolItem::StaticType() ) )
935 _rSet
.Put(SfxBoolItem(_nId
, bVal
));
937 else if ( implCheckItemType( _rSet
, _nId
, OptionalBoolItem::StaticType() ) )
939 OptionalBoolItem
aItem( _nId
);
940 if ( _rValue
.hasValue() )
944 aItem
.SetValue( bValue
);
952 ( OString( "ODbDataSourceAdministrationHelper::implTranslateProperty: invalid property value (" )
953 += OString( translatePropertyId( _nId
) )
954 += OString( " should be no boolean)!" )
961 if ( implCheckItemType( _rSet
, _nId
, SfxInt32Item::StaticType() ) )
963 sal_Int32 nValue
= 0;
965 _rSet
.Put( SfxInt32Item( _nId
, nValue
) );
969 ( OString( "ODbDataSourceAdministrationHelper::implTranslateProperty: invalid property value (" )
970 += OString( translatePropertyId( _nId
) )
971 += OString( " should be no int)!" )
977 case TypeClass_SEQUENCE
:
978 if ( implCheckItemType( _rSet
, _nId
, OStringListItem::StaticType() ) )
980 // determine the element type
981 TypeDescription
aTD(_rValue
.getValueType());
982 typelib_IndirectTypeDescription
* pSequenceTD
=
983 reinterpret_cast< typelib_IndirectTypeDescription
* >(aTD
.get());
984 OSL_ENSURE(pSequenceTD
&& pSequenceTD
->pType
, "ODbDataSourceAdministrationHelper::implTranslateProperty: invalid sequence type!");
986 Type
aElementType(pSequenceTD
->pType
);
987 switch (aElementType
.getTypeClass())
989 case TypeClass_STRING
:
991 Sequence
< OUString
> aStringList
;
992 _rValue
>>= aStringList
;
993 _rSet
.Put(OStringListItem(_nId
, aStringList
));
997 OSL_FAIL("ODbDataSourceAdministrationHelper::implTranslateProperty: unsupported property value type!");
1002 ( OString( "ODbDataSourceAdministrationHelper::implTranslateProperty: invalid property value (" )
1003 += OString( translatePropertyId( _nId
) )
1004 += OString( " should be no string sequence)!" )
1010 case TypeClass_VOID
:
1011 _rSet
.ClearItem(_nId
);
1015 OSL_FAIL("ODbDataSourceAdministrationHelper::implTranslateProperty: unsupported property value type!");
1019 OUString
ODbDataSourceAdministrationHelper::getDocumentUrl(SfxItemSet
& _rDest
)
1021 SFX_ITEMSET_GET(_rDest
, pUrlItem
, SfxStringItem
, DSID_DOCUMENT_URL
, true);
1022 OSL_ENSURE(pUrlItem
,"Document URL is NULL. -> GPF!");
1023 return pUrlItem
->GetValue();
1026 void ODbDataSourceAdministrationHelper::convertUrl(SfxItemSet
& _rDest
)
1028 OUString eType
= getDatasourceType(_rDest
);
1030 SFX_ITEMSET_GET(_rDest
, pUrlItem
, SfxStringItem
, DSID_CONNECTURL
, true);
1031 SFX_ITEMSET_GET(_rDest
, pTypeCollection
, DbuTypeCollectionItem
, DSID_TYPECOLLECTION
, true);
1033 OSL_ENSURE(pUrlItem
,"Connection URL is NULL. -> GPF!");
1034 OSL_ENSURE(pTypeCollection
, "ODbAdminDialog::getDatasourceType: invalid items in the source set!");
1035 ::dbaccess::ODsnTypeCollection
* pCollection
= pTypeCollection
->getCollection();
1036 OSL_ENSURE(pCollection
, "ODbAdminDialog::getDatasourceType: invalid type collection!");
1038 sal_uInt16 nPortNumberId
= 0;
1039 sal_Int32 nPortNumber
= -1;
1040 OUString sNewHostName
;
1043 pCollection
->extractHostNamePort(pUrlItem
->GetValue(),sUrlPart
,sNewHostName
,nPortNumber
);
1044 const ::dbaccess::DATASOURCE_TYPE eTy
= pCollection
->determineType(eType
);
1048 case ::dbaccess::DST_MYSQL_NATIVE
:
1049 case ::dbaccess::DST_MYSQL_JDBC
:
1050 nPortNumberId
= DSID_MYSQL_PORTNUMBER
;
1052 case ::dbaccess::DST_ORACLE_JDBC
:
1053 nPortNumberId
= DSID_ORACLE_PORTNUMBER
;
1055 case ::dbaccess::DST_LDAP
:
1056 nPortNumberId
= DSID_CONN_LDAP_PORTNUMBER
;
1062 if ( !sUrlPart
.isEmpty() )
1064 if ( eTy
== ::dbaccess::DST_MYSQL_NATIVE
)
1066 _rDest
.Put( SfxStringItem( DSID_DATABASENAME
, sUrlPart
) );
1070 OUString sNewUrl
= pCollection
->getPrefix(eType
);
1071 sNewUrl
+= sUrlPart
;
1072 _rDest
.Put( SfxStringItem( DSID_CONNECTURL
, sNewUrl
) );
1076 if ( !sNewHostName
.isEmpty() )
1077 _rDest
.Put(SfxStringItem(DSID_CONN_HOSTNAME
, sNewHostName
));
1079 if ( nPortNumber
!= -1 && nPortNumberId
!= 0 )
1080 _rDest
.Put(SfxInt32Item(nPortNumberId
, nPortNumber
));
1084 bool ODbDataSourceAdministrationHelper::saveChanges(const SfxItemSet
& _rSource
)
1086 // put the remembered settings into the property set
1087 Reference
<XPropertySet
> xDatasource
= getCurrentDataSource();
1088 if ( !xDatasource
.is() )
1091 translateProperties(_rSource
,xDatasource
);
1096 void ODbDataSourceAdministrationHelper::setDataSourceOrName( const Any
& _rDataSourceOrName
)
1098 OSL_ENSURE( !m_aDataSourceOrName
.hasValue(), "ODbDataSourceAdministrationHelper::setDataSourceOrName: already have one!" );
1099 // hmm. We could reset m_xDatasource/m_xModel, probably, and continue working
1100 m_aDataSourceOrName
= _rDataSourceOrName
;
1103 // DbuTypeCollectionItem
1104 TYPEINIT1(DbuTypeCollectionItem
, SfxPoolItem
);
1105 DbuTypeCollectionItem::DbuTypeCollectionItem(sal_Int16 _nWhich
, ::dbaccess::ODsnTypeCollection
* _pCollection
)
1106 :SfxPoolItem(_nWhich
)
1107 ,m_pCollection(_pCollection
)
1111 DbuTypeCollectionItem::DbuTypeCollectionItem(const DbuTypeCollectionItem
& _rSource
)
1112 :SfxPoolItem(_rSource
)
1113 ,m_pCollection(_rSource
.getCollection())
1117 bool DbuTypeCollectionItem::operator==(const SfxPoolItem
& _rItem
) const
1119 const DbuTypeCollectionItem
* pCompare
= PTR_CAST(DbuTypeCollectionItem
, &_rItem
);
1120 return pCompare
&& (pCompare
->getCollection() == getCollection());
1123 SfxPoolItem
* DbuTypeCollectionItem::Clone(SfxItemPool
* /*_pPool*/) const
1125 return new DbuTypeCollectionItem(*this);
1128 } // namespace dbaui
1130 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */