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 : #include <connectivity/CommonTools.hxx>
21 : #include "diagnose_ex.h"
22 : #include "TConnection.hxx"
23 : #include <connectivity/ParameterCont.hxx>
24 :
25 : #include <com/sun/star/awt/XWindow.hpp>
26 : #include <com/sun/star/beans/PropertyAttribute.hpp>
27 : #include <com/sun/star/container/XChild.hpp>
28 : #include <com/sun/star/form/FormComponentType.hpp>
29 : #include <com/sun/star/io/XInputStream.hpp>
30 : #include <com/sun/star/lang/DisposedException.hpp>
31 : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
32 : #include <com/sun/star/sdb/DatabaseContext.hpp>
33 : #include <com/sun/star/sdb/BooleanComparisonMode.hpp>
34 : #include <com/sun/star/sdb/CommandType.hpp>
35 : #include <com/sun/star/sdb/ErrorMessageDialog.hpp>
36 : #include <com/sun/star/sdb/ParametersRequest.hpp>
37 : #include <com/sun/star/sdb/RowSetVetoException.hpp>
38 : #include <com/sun/star/sdb/SQLContext.hpp>
39 : #include <com/sun/star/sdb/XCompletedConnection.hpp>
40 : #include <com/sun/star/sdb/XInteractionSupplyParameters.hpp>
41 : #include <com/sun/star/sdb/XOfficeDatabaseDocument.hpp>
42 : #include <com/sun/star/sdb/XParametersSupplier.hpp>
43 : #include <com/sun/star/sdb/XQueriesSupplier.hpp>
44 : #include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp>
45 : #include <com/sun/star/sdbc/ConnectionPool.hpp>
46 : #include <com/sun/star/sdbc/DataType.hpp>
47 : #include <com/sun/star/sdbc/XConnection.hpp>
48 : #include <com/sun/star/sdbc/XDataSource.hpp>
49 : #include <com/sun/star/sdbc/XDriverManager.hpp>
50 : #include <com/sun/star/sdbc/XParameters.hpp>
51 : #include <com/sun/star/sdbc/XRow.hpp>
52 : #include <com/sun/star/sdbc/XRowSet.hpp>
53 : #include <com/sun/star/sdbc/XRowUpdate.hpp>
54 : #include <com/sun/star/sdbcx/KeyType.hpp>
55 : #include <com/sun/star/sdbcx/Privilege.hpp>
56 : #include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
57 : #include <com/sun/star/sdbcx/XKeysSupplier.hpp>
58 : #include <com/sun/star/sdbcx/XTablesSupplier.hpp>
59 : #include <com/sun/star/task/InteractionHandler.hpp>
60 : #include <com/sun/star/task/XInteractionRequest.hpp>
61 : #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
62 : #include <com/sun/star/uno/XNamingService.hpp>
63 : #include <com/sun/star/util/NumberFormat.hpp>
64 : #include <com/sun/star/util/NumberFormatsSupplier.hpp>
65 : #include <com/sun/star/util/XNumberFormatTypes.hpp>
66 :
67 : #include <comphelper/extract.hxx>
68 : #include <comphelper/interaction.hxx>
69 : #include <comphelper/processfactory.hxx>
70 : #include <comphelper/property.hxx>
71 : #include <comphelper/propertysequence.hxx>
72 : #include <connectivity/conncleanup.hxx>
73 : #include <connectivity/dbconversion.hxx>
74 : #include <connectivity/dbexception.hxx>
75 : #include <connectivity/dbtools.hxx>
76 : #include <connectivity/statementcomposer.hxx>
77 : #include <osl/diagnose.h>
78 : #include <rtl/ustrbuf.hxx>
79 : #include <tools/diagnose_ex.h>
80 :
81 : #include "resource/common_res.hrc"
82 : #include "resource/sharedresources.hxx"
83 : #include <connectivity/OSubComponent.hxx>
84 :
85 : #include <algorithm>
86 : #include <iterator>
87 : #include <set>
88 :
89 : using namespace ::comphelper;
90 : using namespace ::com::sun::star::uno;
91 : using namespace ::com::sun::star::io;
92 : using namespace ::com::sun::star::awt;
93 : using namespace ::com::sun::star::ui::dialogs;
94 : using namespace ::com::sun::star::util;
95 : using namespace ::com::sun::star::lang;
96 : using namespace ::com::sun::star::beans;
97 : using namespace ::com::sun::star::container;
98 : using namespace ::com::sun::star::sdb;
99 : using namespace ::com::sun::star::sdbc;
100 : using namespace ::com::sun::star::sdbcx;
101 : using namespace ::com::sun::star::form;
102 : using namespace connectivity;
103 :
104 : namespace dbtools
105 : {
106 : using namespace ::com::sun::star::uno;
107 : using namespace ::com::sun::star::beans;
108 : using namespace ::com::sun::star::util;
109 : using namespace ::com::sun::star::lang;
110 : using namespace ::com::sun::star::sdbc;
111 : using namespace ::com::sun::star::task;
112 :
113 : namespace
114 : {
115 : typedef sal_Bool (SAL_CALL XDatabaseMetaData::*FMetaDataSupport)();
116 : }
117 :
118 875 : sal_Int32 getDefaultNumberFormat(const Reference< XPropertySet >& _xColumn,
119 : const Reference< XNumberFormatTypes >& _xTypes,
120 : const Locale& _rLocale)
121 : {
122 : OSL_ENSURE(_xTypes.is() && _xColumn.is(), "dbtools::getDefaultNumberFormat: invalid arg !");
123 875 : if (!_xTypes.is() || !_xColumn.is())
124 0 : return NumberFormat::UNDEFINED;
125 :
126 875 : sal_Int32 nDataType = 0;
127 875 : sal_Int32 nScale = 0;
128 : try
129 : {
130 : // determine the datatype of the column
131 875 : _xColumn->getPropertyValue("Type") >>= nDataType;
132 :
133 875 : if (DataType::NUMERIC == nDataType || DataType::DECIMAL == nDataType)
134 91 : _xColumn->getPropertyValue("Scale") >>= nScale;
135 : }
136 0 : catch (Exception&)
137 : {
138 0 : return NumberFormat::UNDEFINED;
139 : }
140 : return getDefaultNumberFormat(nDataType,
141 : nScale,
142 1750 : ::cppu::any2bool(_xColumn->getPropertyValue("IsCurrency")),
143 : _xTypes,
144 875 : _rLocale);
145 : }
146 :
147 875 : sal_Int32 getDefaultNumberFormat(sal_Int32 _nDataType,
148 : sal_Int32 _nScale,
149 : bool _bIsCurrency,
150 : const Reference< XNumberFormatTypes >& _xTypes,
151 : const Locale& _rLocale)
152 : {
153 : OSL_ENSURE(_xTypes.is() , "dbtools::getDefaultNumberFormat: invalid arg !");
154 875 : if (!_xTypes.is())
155 0 : return NumberFormat::UNDEFINED;
156 :
157 875 : sal_Int32 nFormat = 0;
158 875 : sal_Int32 nNumberType = _bIsCurrency ? NumberFormat::CURRENCY : NumberFormat::NUMBER;
159 875 : switch (_nDataType)
160 : {
161 : case DataType::BIT:
162 : case DataType::BOOLEAN:
163 16 : nFormat = _xTypes->getStandardFormat(NumberFormat::LOGICAL, _rLocale);
164 16 : break;
165 : case DataType::TINYINT:
166 : case DataType::SMALLINT:
167 : case DataType::INTEGER:
168 : case DataType::BIGINT:
169 : case DataType::FLOAT:
170 : case DataType::REAL:
171 : case DataType::DOUBLE:
172 : case DataType::NUMERIC:
173 : case DataType::DECIMAL:
174 : {
175 : try
176 : {
177 239 : nFormat = _xTypes->getStandardFormat((sal_Int16)nNumberType, _rLocale);
178 239 : if(_nScale > 0)
179 : {
180 : // generate a new format if necessary
181 80 : Reference< XNumberFormats > xFormats(_xTypes, UNO_QUERY);
182 160 : OUString sNewFormat = xFormats->generateFormat( 0L, _rLocale, sal_False, sal_False, (sal_Int16)_nScale, 1);
183 :
184 : // and add it to the formatter if necessary
185 80 : nFormat = xFormats->queryKey(sNewFormat, _rLocale, sal_False);
186 80 : if (nFormat == (sal_Int32)-1)
187 88 : nFormat = xFormats->addNew(sNewFormat, _rLocale);
188 : }
189 : }
190 0 : catch (Exception&)
191 : {
192 0 : nFormat = _xTypes->getStandardFormat((sal_Int16)nNumberType, _rLocale);
193 : }
194 239 : } break;
195 : case DataType::CHAR:
196 : case DataType::VARCHAR:
197 : case DataType::LONGVARCHAR:
198 : case DataType::CLOB:
199 582 : nFormat = _xTypes->getStandardFormat(NumberFormat::TEXT, _rLocale);
200 582 : break;
201 : case DataType::DATE:
202 38 : nFormat = _xTypes->getStandardFormat(NumberFormat::DATE, _rLocale);
203 38 : break;
204 : case DataType::TIME:
205 0 : nFormat = _xTypes->getStandardFormat(NumberFormat::TIME, _rLocale);
206 0 : break;
207 : case DataType::TIMESTAMP:
208 0 : nFormat = _xTypes->getStandardFormat(NumberFormat::DATETIME, _rLocale);
209 0 : break;
210 : case DataType::BINARY:
211 : case DataType::VARBINARY:
212 : case DataType::LONGVARBINARY:
213 : case DataType::SQLNULL:
214 : case DataType::OTHER:
215 : case DataType::OBJECT:
216 : case DataType::DISTINCT:
217 : case DataType::STRUCT:
218 : case DataType::ARRAY:
219 : case DataType::BLOB:
220 : case DataType::REF:
221 : default:
222 0 : nFormat = _xTypes->getStandardFormat(NumberFormat::UNDEFINED, _rLocale);
223 : }
224 875 : return nFormat;
225 : }
226 :
227 46 : Reference< XConnection> findConnection(const Reference< XInterface >& xParent)
228 : {
229 46 : Reference< XConnection> xConnection(xParent, UNO_QUERY);
230 46 : if (!xConnection.is())
231 : {
232 46 : Reference< XChild> xChild(xParent, UNO_QUERY);
233 46 : if (xChild.is())
234 34 : xConnection = findConnection(xChild->getParent());
235 : }
236 46 : return xConnection;
237 : }
238 :
239 37 : Reference< XDataSource> getDataSource_allowException(
240 : const OUString& _rsTitleOrPath,
241 : const Reference< XComponentContext >& _rxContext )
242 : {
243 37 : ENSURE_OR_RETURN( !_rsTitleOrPath.isEmpty(), "getDataSource_allowException: invalid arg !", NULL );
244 :
245 37 : Reference< XDatabaseContext> xDatabaseContext = DatabaseContext::create(_rxContext);
246 :
247 37 : return Reference< XDataSource >( xDatabaseContext->getByName( _rsTitleOrPath ), UNO_QUERY );
248 : }
249 :
250 26 : Reference< XDataSource > getDataSource(
251 : const OUString& _rsTitleOrPath,
252 : const Reference< XComponentContext >& _rxContext )
253 : {
254 26 : Reference< XDataSource > xDS;
255 : try
256 : {
257 26 : xDS = getDataSource_allowException( _rsTitleOrPath, _rxContext );
258 : }
259 0 : catch( const Exception& )
260 : {
261 : DBG_UNHANDLED_EXCEPTION();
262 : }
263 :
264 26 : return xDS;
265 : }
266 :
267 11 : Reference< XConnection > getConnection_allowException(
268 : const OUString& _rsTitleOrPath,
269 : const OUString& _rsUser,
270 : const OUString& _rsPwd,
271 : const Reference< XComponentContext>& _rxContext)
272 : {
273 11 : Reference< XDataSource> xDataSource( getDataSource_allowException(_rsTitleOrPath, _rxContext) );
274 11 : Reference<XConnection> xConnection;
275 11 : if (xDataSource.is())
276 : {
277 : // do it with interaction handler
278 11 : if(_rsUser.isEmpty() || _rsPwd.isEmpty())
279 : {
280 11 : Reference<XPropertySet> xProp(xDataSource,UNO_QUERY);
281 22 : OUString sPwd, sUser;
282 11 : bool bPwdReq = false;
283 : try
284 : {
285 11 : xProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PASSWORD)) >>= sPwd;
286 11 : bPwdReq = ::cppu::any2bool(xProp->getPropertyValue("IsPasswordRequired"));
287 11 : xProp->getPropertyValue("User") >>= sUser;
288 : }
289 0 : catch(Exception&)
290 : {
291 : OSL_FAIL("dbtools::getConnection: error while retrieving data source properties!");
292 : }
293 11 : if(bPwdReq && sPwd.isEmpty())
294 : { // password required, but empty -> connect using an interaction handler
295 0 : Reference<XCompletedConnection> xConnectionCompletion(xProp, UNO_QUERY);
296 0 : if (xConnectionCompletion.is())
297 : { // instantiate the default SDB interaction handler
298 : Reference< XInteractionHandler > xHandler(
299 0 : InteractionHandler::createWithParent(_rxContext, 0), UNO_QUERY );
300 0 : xConnection = xConnectionCompletion->connectWithCompletion(xHandler);
301 0 : }
302 : }
303 : else
304 22 : xConnection = xDataSource->getConnection(sUser, sPwd);
305 : }
306 11 : if(!xConnection.is()) // try to get one if not already have one, just to make sure
307 0 : xConnection = xDataSource->getConnection(_rsUser, _rsPwd);
308 : }
309 11 : return xConnection;
310 : }
311 :
312 0 : Reference< XConnection> getConnection_withFeedback(const OUString& _rDataSourceName,
313 : const OUString& _rUser, const OUString& _rPwd, const Reference< XComponentContext>& _rxContext)
314 : {
315 0 : Reference< XConnection > xReturn;
316 : try
317 : {
318 0 : xReturn = getConnection_allowException(_rDataSourceName, _rUser, _rPwd, _rxContext);
319 : }
320 0 : catch(SQLException&)
321 : {
322 : // allowed to pass
323 0 : throw;
324 : }
325 0 : catch(Exception&)
326 : {
327 : OSL_FAIL("::dbtools::getConnection_withFeedback: unexpected (non-SQL) exception caught!");
328 : }
329 0 : return xReturn;
330 : }
331 :
332 104 : Reference< XConnection> getConnection(const Reference< XRowSet>& _rxRowSet) throw (RuntimeException)
333 : {
334 104 : Reference< XConnection> xReturn;
335 208 : Reference< XPropertySet> xRowSetProps(_rxRowSet, UNO_QUERY);
336 104 : if (xRowSetProps.is())
337 104 : xRowSetProps->getPropertyValue("ActiveConnection") >>= xReturn;
338 208 : return xReturn;
339 : }
340 :
341 : // helper function which allows to implement both the connectRowset and the ensureRowSetConnection semantics
342 : // if connectRowset (which is deprecated) is removed, this function and one of its parameters are
343 : // not needed anymore, the whole implementation can be moved into ensureRowSetConnection then)
344 29 : SharedConnection lcl_connectRowSet(const Reference< XRowSet>& _rxRowSet, const Reference< XComponentContext >& _rxContext,
345 : bool _bSetAsActiveConnection, bool _bAttachAutoDisposer )
346 : {
347 29 : SharedConnection xConnection;
348 :
349 : do
350 : {
351 29 : Reference< XPropertySet> xRowSetProps(_rxRowSet, UNO_QUERY);
352 29 : if ( !xRowSetProps.is() )
353 0 : break;
354 :
355 : // 1. already connected?
356 : Reference< XConnection > xExistingConn(
357 29 : xRowSetProps->getPropertyValue("ActiveConnection"),
358 41 : UNO_QUERY );
359 :
360 104 : if ( xExistingConn.is()
361 : // 2. embedded in a database?
362 12 : || isEmbeddedInDatabase( _rxRowSet, xExistingConn )
363 : // 3. is there a connection in the parent hierarchy?
364 111 : || ( xExistingConn = findConnection( _rxRowSet ) ).is()
365 : )
366 : {
367 17 : if ( _bSetAsActiveConnection )
368 : {
369 17 : xRowSetProps->setPropertyValue("ActiveConnection", makeAny( xExistingConn ) );
370 : // no auto disposer needed, since we did not create the connection
371 : }
372 :
373 17 : xConnection.reset( xExistingConn, SharedConnection::NoTakeOwnership );
374 17 : break;
375 : }
376 :
377 : // build a connection with its current settings (4. data source name, or 5. URL)
378 :
379 24 : const OUString sUserProp( "User" );
380 24 : OUString sDataSourceName;
381 12 : xRowSetProps->getPropertyValue("DataSourceName") >>= sDataSourceName;
382 24 : OUString sURL;
383 12 : xRowSetProps->getPropertyValue("URL") >>= sURL;
384 :
385 24 : Reference< XConnection > xPureConnection;
386 12 : if (!sDataSourceName.isEmpty())
387 : { // the row set's data source property is set
388 : // -> try to connect, get user and pwd setting for that
389 22 : OUString sUser, sPwd;
390 :
391 11 : if (hasProperty(sUserProp, xRowSetProps))
392 11 : xRowSetProps->getPropertyValue(sUserProp) >>= sUser;
393 11 : if (hasProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PASSWORD), xRowSetProps))
394 11 : xRowSetProps->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PASSWORD)) >>= sPwd;
395 :
396 22 : xPureConnection = getConnection_allowException( sDataSourceName, sUser, sPwd, _rxContext );
397 : }
398 1 : else if (!sURL.isEmpty())
399 : { // the row set has no data source, but a connection url set
400 : // -> try to connection with that url
401 0 : Reference< XConnectionPool > xDriverManager;
402 : try {
403 0 : xDriverManager = ConnectionPool::create( _rxContext );
404 0 : } catch( const Exception& ) { }
405 0 : if (xDriverManager.is())
406 : {
407 0 : OUString sUser, sPwd;
408 0 : if (hasProperty(sUserProp, xRowSetProps))
409 0 : xRowSetProps->getPropertyValue(sUserProp) >>= sUser;
410 0 : if (hasProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PASSWORD), xRowSetProps))
411 0 : xRowSetProps->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PASSWORD)) >>= sPwd;
412 0 : if (!sUser.isEmpty())
413 : { // use user and pwd together with the url
414 : auto aInfo(::comphelper::InitPropertySequence({
415 : { "user", makeAny(sUser) },
416 : { "password", makeAny(sPwd) }
417 0 : }));
418 0 : xPureConnection = xDriverManager->getConnectionWithInfo( sURL, aInfo );
419 : }
420 : else
421 : // just use the url
422 0 : xPureConnection = xDriverManager->getConnection( sURL );
423 0 : }
424 : }
425 : xConnection.reset(
426 : xPureConnection,
427 : _bAttachAutoDisposer ? SharedConnection::NoTakeOwnership : SharedConnection::TakeOwnership
428 : /* take ownership if and only if we're *not* going to auto-dispose the connection */
429 12 : );
430 :
431 : // now if we created a connection, forward it to the row set
432 12 : if ( xConnection.is() && _bSetAsActiveConnection )
433 : {
434 : try
435 : {
436 11 : if ( _bAttachAutoDisposer )
437 : {
438 11 : OAutoConnectionDisposer* pAutoDispose = new OAutoConnectionDisposer( _rxRowSet, xConnection );
439 11 : Reference< XPropertyChangeListener > xEnsureDelete(pAutoDispose);
440 : }
441 : else
442 0 : xRowSetProps->setPropertyValue(
443 : OUString( "ActiveConnection" ),
444 0 : makeAny( xConnection.getTyped() )
445 0 : );
446 : }
447 0 : catch(Exception&)
448 : {
449 : OSL_FAIL("EXception when we set the new active connection!");
450 : }
451 12 : }
452 : }
453 : while ( false );
454 :
455 29 : return xConnection;
456 : }
457 :
458 29 : Reference< XConnection> connectRowset(const Reference< XRowSet>& _rxRowSet, const Reference< XComponentContext >& _rxContext,
459 : bool _bSetAsActiveConnection )
460 : {
461 29 : SharedConnection xConnection = lcl_connectRowSet( _rxRowSet, _rxContext, _bSetAsActiveConnection, true );
462 29 : return xConnection.getTyped();
463 : }
464 :
465 0 : SharedConnection ensureRowSetConnection(const Reference< XRowSet>& _rxRowSet, const Reference< XComponentContext>& _rxContext,
466 : bool _bUseAutoConnectionDisposer )
467 : {
468 0 : return lcl_connectRowSet( _rxRowSet, _rxContext, true, _bUseAutoConnectionDisposer );
469 : }
470 :
471 0 : Reference< XNameAccess> getTableFields(const Reference< XConnection>& _rxConn,const OUString& _rName)
472 : {
473 0 : Reference< XComponent > xDummy;
474 0 : return getFieldsByCommandDescriptor( _rxConn, CommandType::TABLE, _rName, xDummy );
475 : }
476 :
477 9 : Reference< XNameAccess> getPrimaryKeyColumns_throw(const Any& i_aTable)
478 : {
479 9 : const Reference< XPropertySet > xTable(i_aTable,UNO_QUERY_THROW);
480 9 : return getPrimaryKeyColumns_throw(xTable);
481 : }
482 :
483 90 : Reference< XNameAccess> getPrimaryKeyColumns_throw(const Reference< XPropertySet >& i_xTable)
484 : {
485 90 : Reference<XNameAccess> xKeyColumns;
486 180 : const Reference<XKeysSupplier> xKeySup(i_xTable,UNO_QUERY);
487 90 : if ( xKeySup.is() )
488 : {
489 82 : const Reference<XIndexAccess> xKeys = xKeySup->getKeys();
490 82 : if ( xKeys.is() )
491 : {
492 82 : ::dbtools::OPropertyMap& rPropMap = OMetaConnection::getPropMap();
493 82 : const OUString sPropName = rPropMap.getNameByIndex(PROPERTY_ID_TYPE);
494 164 : Reference<XPropertySet> xProp;
495 82 : const sal_Int32 nCount = xKeys->getCount();
496 82 : for(sal_Int32 i = 0;i< nCount;++i)
497 : {
498 82 : xProp.set(xKeys->getByIndex(i),UNO_QUERY_THROW);
499 82 : if ( xProp.is() )
500 : {
501 82 : sal_Int32 nKeyType = 0;
502 82 : xProp->getPropertyValue(sPropName) >>= nKeyType;
503 82 : if(KeyType::PRIMARY == nKeyType)
504 : {
505 82 : const Reference<XColumnsSupplier> xKeyColsSup(xProp,UNO_QUERY_THROW);
506 82 : xKeyColumns = xKeyColsSup->getColumns();
507 82 : break;
508 : }
509 : }
510 82 : }
511 82 : }
512 : }
513 :
514 180 : return xKeyColumns;
515 : }
516 :
517 : namespace
518 : {
519 : enum FieldLookupState
520 : {
521 : HANDLE_TABLE, HANDLE_QUERY, HANDLE_SQL, RETRIEVE_OBJECT, RETRIEVE_COLUMNS, DONE, FAILED
522 : };
523 : }
524 :
525 0 : Reference< XNameAccess > getFieldsByCommandDescriptor( const Reference< XConnection >& _rxConnection,
526 : const sal_Int32 _nCommandType, const OUString& _rCommand,
527 : Reference< XComponent >& _rxKeepFieldsAlive, SQLExceptionInfo* _pErrorInfo )
528 : {
529 : OSL_PRECOND( _rxConnection.is(), "::dbtools::getFieldsByCommandDescriptor: invalid connection!" );
530 : OSL_PRECOND( ( CommandType::TABLE == _nCommandType ) || ( CommandType::QUERY == _nCommandType ) || ( CommandType::COMMAND == _nCommandType ),
531 : "::dbtools::getFieldsByCommandDescriptor: invalid command type!" );
532 : OSL_PRECOND( !_rCommand.isEmpty(), "::dbtools::getFieldsByCommandDescriptor: invalid command (empty)!" );
533 :
534 0 : Reference< XNameAccess > xFields;
535 :
536 : // reset the error
537 0 : if ( _pErrorInfo )
538 0 : *_pErrorInfo = SQLExceptionInfo();
539 : // reset the ownership holder
540 0 : _rxKeepFieldsAlive.clear();
541 :
542 : // go for the fields
543 : try
544 : {
545 : // some kind of state machine to ease the sharing of code
546 0 : FieldLookupState eState = FAILED;
547 0 : switch ( _nCommandType )
548 : {
549 : case CommandType::TABLE:
550 0 : eState = HANDLE_TABLE;
551 0 : break;
552 : case CommandType::QUERY:
553 0 : eState = HANDLE_QUERY;
554 0 : break;
555 : case CommandType::COMMAND:
556 0 : eState = HANDLE_SQL;
557 0 : break;
558 : }
559 :
560 : // needed in various states:
561 0 : Reference< XNameAccess > xObjectCollection;
562 0 : Reference< XColumnsSupplier > xSupplyColumns;
563 :
564 : // go!
565 0 : while ( ( DONE != eState ) && ( FAILED != eState ) )
566 : {
567 0 : switch ( eState )
568 : {
569 : case HANDLE_TABLE:
570 : {
571 : // initial state for handling the tables
572 :
573 : // get the table objects
574 0 : Reference< XTablesSupplier > xSupplyTables( _rxConnection, UNO_QUERY );
575 0 : if ( xSupplyTables.is() )
576 0 : xObjectCollection = xSupplyTables->getTables();
577 : // if something went wrong 'til here, then this will be handled in the next state
578 :
579 : // next state: get the object
580 0 : eState = RETRIEVE_OBJECT;
581 : }
582 0 : break;
583 :
584 : case HANDLE_QUERY:
585 : {
586 : // initial state for handling the tables
587 :
588 : // get the table objects
589 0 : Reference< XQueriesSupplier > xSupplyQueries( _rxConnection, UNO_QUERY );
590 0 : if ( xSupplyQueries.is() )
591 0 : xObjectCollection = xSupplyQueries->getQueries();
592 : // if something went wrong 'til here, then this will be handled in the next state
593 :
594 : // next state: get the object
595 0 : eState = RETRIEVE_OBJECT;
596 : }
597 0 : break;
598 :
599 : case RETRIEVE_OBJECT:
600 : // here we should have an object (aka query or table) collection, and are going
601 : // to retrieve the desired object
602 :
603 : // next state: default to FAILED
604 0 : eState = FAILED;
605 :
606 : OSL_ENSURE( xObjectCollection.is(), "::dbtools::getFieldsByCommandDescriptor: invalid connection (no sdb.Connection, or no Tables-/QueriesSupplier)!");
607 0 : if ( xObjectCollection.is() )
608 : {
609 0 : if ( xObjectCollection.is() && xObjectCollection->hasByName( _rCommand ) )
610 : {
611 0 : xObjectCollection->getByName( _rCommand ) >>= xSupplyColumns;
612 : // (xSupplyColumns being NULL will be handled in the next state)
613 :
614 : // next: go for the columns
615 0 : eState = RETRIEVE_COLUMNS;
616 : }
617 : }
618 0 : break;
619 :
620 : case RETRIEVE_COLUMNS:
621 : OSL_ENSURE( xSupplyColumns.is(), "::dbtools::getFieldsByCommandDescriptor: could not retrieve the columns supplier!" );
622 :
623 : // next state: default to FAILED
624 0 : eState = FAILED;
625 :
626 0 : if ( xSupplyColumns.is() )
627 : {
628 0 : xFields = xSupplyColumns->getColumns();
629 : // that's it
630 0 : eState = DONE;
631 : }
632 0 : break;
633 :
634 : case HANDLE_SQL:
635 : {
636 0 : OUString sStatementToExecute( _rCommand );
637 :
638 : // well, the main problem here is to handle statements which contain a parameter
639 : // If we would simply execute a parametrized statement, then this will fail because
640 : // we cannot supply any parameter values.
641 : // Thus, we try to analyze the statement, and to append a WHERE 0=1 filter criterion
642 : // This should cause every driver to not really execute the statement, but to return
643 : // an empty result set with the proper structure. We then can use this result set
644 : // to retrieve the columns.
645 :
646 : try
647 : {
648 0 : Reference< XMultiServiceFactory > xComposerFac( _rxConnection, UNO_QUERY );
649 :
650 0 : if ( xComposerFac.is() )
651 : {
652 0 : Reference< XSingleSelectQueryComposer > xComposer(xComposerFac->createInstance("com.sun.star.sdb.SingleSelectQueryComposer"),UNO_QUERY);
653 0 : if ( xComposer.is() )
654 : {
655 0 : xComposer->setQuery( sStatementToExecute );
656 :
657 : // Now set the filter to a dummy restriction which will result in an empty
658 : // result set.
659 0 : xComposer->setFilter( OUString( "0=1" ) );
660 0 : sStatementToExecute = xComposer->getQuery( );
661 0 : }
662 0 : }
663 : }
664 0 : catch( const Exception& )
665 : {
666 : // silent this error, this was just a try. If we're here, we did not change sStatementToExecute,
667 : // so it will still be _rCommand, which then will be executed without being touched
668 : }
669 :
670 : // now execute
671 0 : Reference< XPreparedStatement > xStatement = _rxConnection->prepareStatement( sStatementToExecute );
672 : // transfer ownership of this temporary object to the caller
673 0 : _rxKeepFieldsAlive.set(xStatement, css::uno::UNO_QUERY);
674 :
675 : // set the "MaxRows" to 0. This is just in case our attempt to append a 0=1 filter
676 : // failed - in this case, the MaxRows restriction should at least ensure that there
677 : // is no data returned (which would be potentially expensive)
678 0 : Reference< XPropertySet > xStatementProps( xStatement,UNO_QUERY );
679 : try
680 : {
681 0 : if ( xStatementProps.is() )
682 0 : xStatementProps->setPropertyValue(
683 : OUString( "MaxRows" ),
684 : makeAny( sal_Int32( 0 ) )
685 0 : );
686 : }
687 0 : catch( const Exception& )
688 : {
689 : OSL_FAIL( "::dbtools::getFieldsByCommandDescriptor: could not set the MaxRows!" );
690 : // oh damn. Not much of a chance to recover, we will no retrieve the complete
691 : // full blown result set
692 : }
693 :
694 0 : xSupplyColumns.set(xStatement->executeQuery(), css::uno::UNO_QUERY);
695 : // this should have given us a result set which does not contain any data, but
696 : // the structural information we need
697 :
698 : // so the next state is to get the columns
699 0 : eState = RETRIEVE_COLUMNS;
700 : }
701 0 : break;
702 :
703 : default:
704 : OSL_FAIL( "::dbtools::getFieldsByCommandDescriptor: oops! unhandled state here!" );
705 0 : eState = FAILED;
706 : }
707 0 : }
708 : }
709 0 : catch( const SQLContext& e ) { if ( _pErrorInfo ) *_pErrorInfo = SQLExceptionInfo( e ); }
710 0 : catch( const SQLWarning& e ) { if ( _pErrorInfo ) *_pErrorInfo = SQLExceptionInfo( e ); }
711 0 : catch( const SQLException& e ) { if ( _pErrorInfo ) *_pErrorInfo = SQLExceptionInfo( e ); }
712 0 : catch( const Exception& )
713 : {
714 : OSL_FAIL( "::dbtools::getFieldsByCommandDescriptor: caught an exception while retrieving the fields!" );
715 : }
716 :
717 0 : return xFields;
718 : }
719 :
720 0 : Sequence< OUString > getFieldNamesByCommandDescriptor( const Reference< XConnection >& _rxConnection,
721 : const sal_Int32 _nCommandType, const OUString& _rCommand,
722 : SQLExceptionInfo* _pErrorInfo )
723 : {
724 : // get the container for the fields
725 0 : Reference< XComponent > xKeepFieldsAlive;
726 0 : Reference< XNameAccess > xFieldContainer = getFieldsByCommandDescriptor( _rxConnection, _nCommandType, _rCommand, xKeepFieldsAlive, _pErrorInfo );
727 :
728 : // get the names of the fields
729 0 : Sequence< OUString > aNames;
730 0 : if ( xFieldContainer.is() )
731 0 : aNames = xFieldContainer->getElementNames();
732 :
733 : // clean up any temporary objects which have been created
734 0 : disposeComponent( xKeepFieldsAlive );
735 :
736 : // outta here
737 0 : return aNames;
738 : }
739 :
740 0 : SQLException prependErrorInfo( const SQLException& _rChainedException, const Reference< XInterface >& _rxContext,
741 : const OUString& _rAdditionalError, const StandardSQLState _eSQLState, const sal_Int32 _nErrorCode )
742 : {
743 : return SQLException( _rAdditionalError, _rxContext,
744 : _eSQLState == SQL_ERROR_UNSPECIFIED ? OUString() : getStandardSQLState( _eSQLState ),
745 0 : _nErrorCode, makeAny( _rChainedException ) );
746 : }
747 :
748 : namespace
749 : {
750 : struct NameComponentSupport
751 : {
752 : const bool bCatalogs;
753 : const bool bSchemas;
754 :
755 1087 : NameComponentSupport( const bool _bCatalogs, const bool _bSchemas )
756 : :bCatalogs( _bCatalogs )
757 1087 : ,bSchemas( _bSchemas )
758 : {
759 1087 : }
760 : };
761 :
762 1087 : NameComponentSupport lcl_getNameComponentSupport( const Reference< XDatabaseMetaData >& _rxMetaData, EComposeRule _eComposeRule )
763 : {
764 : OSL_PRECOND( _rxMetaData.is(), "lcl_getNameComponentSupport: invalid meta data!" );
765 :
766 1087 : FMetaDataSupport pCatalogCall = &XDatabaseMetaData::supportsCatalogsInDataManipulation;
767 1087 : FMetaDataSupport pSchemaCall = &XDatabaseMetaData::supportsSchemasInDataManipulation;
768 1087 : bool bIgnoreMetaData = false;
769 :
770 1087 : switch ( _eComposeRule )
771 : {
772 : case eInTableDefinitions:
773 0 : pCatalogCall = &XDatabaseMetaData::supportsCatalogsInTableDefinitions;
774 0 : pSchemaCall = &XDatabaseMetaData::supportsSchemasInTableDefinitions;
775 0 : break;
776 : case eInIndexDefinitions:
777 0 : pCatalogCall = &XDatabaseMetaData::supportsCatalogsInIndexDefinitions;
778 0 : pSchemaCall = &XDatabaseMetaData::supportsSchemasInIndexDefinitions;
779 0 : break;
780 : case eInProcedureCalls:
781 0 : pCatalogCall = &XDatabaseMetaData::supportsCatalogsInProcedureCalls;
782 0 : pSchemaCall = &XDatabaseMetaData::supportsSchemasInProcedureCalls;
783 0 : break;
784 : case eInPrivilegeDefinitions:
785 0 : pCatalogCall = &XDatabaseMetaData::supportsCatalogsInPrivilegeDefinitions;
786 0 : pSchemaCall = &XDatabaseMetaData::supportsSchemasInPrivilegeDefinitions;
787 0 : break;
788 : case eComplete:
789 3 : bIgnoreMetaData = true;
790 3 : break;
791 : case eInDataManipulation:
792 : // already properly set above
793 1084 : break;
794 : }
795 : return NameComponentSupport(
796 1087 : bIgnoreMetaData || (_rxMetaData.get()->*pCatalogCall)(),
797 1087 : bIgnoreMetaData || (_rxMetaData.get()->*pSchemaCall)()
798 2174 : );
799 : }
800 : }
801 :
802 646 : static OUString impl_doComposeTableName( const Reference< XDatabaseMetaData >& _rxMetaData,
803 : const OUString& _rCatalog, const OUString& _rSchema, const OUString& _rName,
804 : bool _bQuote, EComposeRule _eComposeRule )
805 : {
806 : OSL_ENSURE(_rxMetaData.is(), "impl_doComposeTableName : invalid meta data !");
807 646 : if ( !_rxMetaData.is() )
808 0 : return OUString();
809 : OSL_ENSURE(!_rName.isEmpty(), "impl_doComposeTableName : at least the name should be non-empty !");
810 :
811 646 : const OUString sQuoteString = _rxMetaData->getIdentifierQuoteString();
812 646 : const NameComponentSupport aNameComps( lcl_getNameComponentSupport( _rxMetaData, _eComposeRule ) );
813 :
814 1292 : OUStringBuffer aComposedName;
815 :
816 1292 : OUString sCatalogSep;
817 646 : bool bCatlogAtStart = true;
818 646 : if ( !_rCatalog.isEmpty() && aNameComps.bCatalogs )
819 : {
820 0 : sCatalogSep = _rxMetaData->getCatalogSeparator();
821 0 : bCatlogAtStart = _rxMetaData->isCatalogAtStart();
822 :
823 0 : if ( bCatlogAtStart && !sCatalogSep.isEmpty())
824 : {
825 0 : aComposedName.append( _bQuote ? quoteName( sQuoteString, _rCatalog ) : _rCatalog );
826 0 : aComposedName.append( sCatalogSep );
827 : }
828 : }
829 :
830 646 : if ( !_rSchema.isEmpty() && aNameComps.bSchemas )
831 : {
832 0 : aComposedName.append( _bQuote ? quoteName( sQuoteString, _rSchema ) : _rSchema );
833 0 : aComposedName.appendAscii( "." );
834 : }
835 :
836 646 : aComposedName.append( _bQuote ? quoteName( sQuoteString, _rName ) : _rName );
837 :
838 1292 : if ( !_rCatalog.isEmpty()
839 0 : && !bCatlogAtStart
840 0 : && !sCatalogSep.isEmpty()
841 646 : && aNameComps.bCatalogs
842 : )
843 : {
844 0 : aComposedName.append( sCatalogSep );
845 0 : aComposedName.append( _bQuote ? quoteName( sQuoteString, _rCatalog ) : _rCatalog );
846 : }
847 :
848 1292 : return aComposedName.makeStringAndClear();
849 : }
850 :
851 5 : OUString quoteTableName(const Reference< XDatabaseMetaData>& _rxMeta
852 : , const OUString& _rName
853 : , EComposeRule _eComposeRule)
854 : {
855 10 : OUString sCatalog, sSchema, sTable;
856 5 : qualifiedNameComponents(_rxMeta,_rName,sCatalog,sSchema,sTable,_eComposeRule);
857 10 : return impl_doComposeTableName( _rxMeta, sCatalog, sSchema, sTable, true, _eComposeRule );
858 : }
859 :
860 441 : void qualifiedNameComponents(const Reference< XDatabaseMetaData >& _rxConnMetaData, const OUString& _rQualifiedName, OUString& _rCatalog, OUString& _rSchema, OUString& _rName,EComposeRule _eComposeRule)
861 : {
862 : OSL_ENSURE(_rxConnMetaData.is(), "QualifiedNameComponents : invalid meta data!");
863 :
864 441 : NameComponentSupport aNameComps( lcl_getNameComponentSupport( _rxConnMetaData, _eComposeRule ) );
865 :
866 441 : OUString sSeparator = _rxConnMetaData->getCatalogSeparator();
867 :
868 882 : OUString sName(_rQualifiedName);
869 : // do we have catalogs ?
870 441 : if ( aNameComps.bCatalogs )
871 : {
872 0 : if (_rxConnMetaData->isCatalogAtStart())
873 : {
874 : // search for the catalog name at the beginning
875 0 : sal_Int32 nIndex = sName.indexOf(sSeparator);
876 0 : if (-1 != nIndex)
877 : {
878 0 : _rCatalog = sName.copy(0, nIndex);
879 0 : sName = sName.copy(nIndex + 1);
880 : }
881 : }
882 : else
883 : {
884 : // Catalogue name at the end
885 0 : sal_Int32 nIndex = sName.lastIndexOf(sSeparator);
886 0 : if (-1 != nIndex)
887 : {
888 0 : _rCatalog = sName.copy(nIndex + 1);
889 0 : sName = sName.copy(0, nIndex);
890 : }
891 : }
892 : }
893 :
894 441 : if ( aNameComps.bSchemas )
895 : {
896 0 : sal_Int32 nIndex = sName.indexOf((sal_Unicode)'.');
897 : // OSL_ENSURE(-1 != nIndex, "QualifiedNameComponents : no schema separator!");
898 0 : if ( nIndex != -1 )
899 0 : _rSchema = sName.copy(0, nIndex);
900 0 : sName = sName.copy(nIndex + 1);
901 : }
902 :
903 882 : _rName = sName;
904 441 : }
905 :
906 338 : Reference< XNumberFormatsSupplier> getNumberFormats(
907 : const Reference< XConnection>& _rxConn,
908 : bool _bAlloweDefault,
909 : const Reference< XComponentContext>& _rxContext)
910 : {
911 : // ask the parent of the connection (should be an DatabaseAccess)
912 338 : Reference< XNumberFormatsSupplier> xReturn;
913 676 : Reference< XChild> xConnAsChild(_rxConn, UNO_QUERY);
914 676 : OUString sPropFormatsSupplier( "NumberFormatsSupplier" );
915 338 : if (xConnAsChild.is())
916 : {
917 337 : Reference< XPropertySet> xConnParentProps(xConnAsChild->getParent(), UNO_QUERY);
918 337 : if (xConnParentProps.is() && hasProperty(sPropFormatsSupplier, xConnParentProps))
919 337 : xConnParentProps->getPropertyValue(sPropFormatsSupplier) >>= xReturn;
920 : }
921 1 : else if(_bAlloweDefault && _rxContext.is())
922 : {
923 1 : xReturn = NumberFormatsSupplier::createWithDefaultLocale( _rxContext );
924 : }
925 676 : return xReturn;
926 : }
927 :
928 0 : void TransferFormComponentProperties(
929 : const Reference< XPropertySet>& xOldProps,
930 : const Reference< XPropertySet>& xNewProps,
931 : const Locale& _rLocale)
932 : {
933 : try
934 : {
935 : OSL_ENSURE( xOldProps.is() && xNewProps.is(), "TransferFormComponentProperties: invalid source/dest!" );
936 0 : if ( !xOldProps.is() || !xNewProps.is() )
937 0 : return;
938 :
939 : // First we copy all the Props, that are available in source and target and have the same description
940 0 : Reference< XPropertySetInfo> xOldInfo( xOldProps->getPropertySetInfo());
941 0 : Reference< XPropertySetInfo> xNewInfo( xNewProps->getPropertySetInfo());
942 :
943 0 : Sequence< Property> aOldProperties = xOldInfo->getProperties();
944 0 : Sequence< Property> aNewProperties = xNewInfo->getProperties();
945 0 : int nNewLen = aNewProperties.getLength();
946 :
947 0 : Property* pOldProps = aOldProperties.getArray();
948 0 : Property* pNewProps = aNewProperties.getArray();
949 :
950 0 : OUString sPropDefaultControl("DefaultControl");
951 0 : OUString sPropLabelControl("LabelControl");
952 0 : OUString sPropFormatsSupplier("FormatsSupplier");
953 0 : OUString sPropCurrencySymbol("CurrencySymbol");
954 0 : OUString sPropDecimals("Decimals");
955 0 : OUString sPropEffectiveMin("EffectiveMin");
956 0 : OUString sPropEffectiveMax("EffectiveMax");
957 0 : OUString sPropEffectiveDefault("EffectiveDefault");
958 0 : OUString sPropDefaultText("DefaultText");
959 0 : OUString sPropDefaultDate("DefaultDate");
960 0 : OUString sPropDefaultTime("DefaultTime");
961 0 : OUString sPropValueMin("ValueMin");
962 0 : OUString sPropValueMax("ValueMax");
963 0 : OUString sPropDecimalAccuracy("DecimalAccuracy");
964 0 : OUString sPropClassId("ClassId");
965 0 : OUString sFormattedServiceName( "com.sun.star.form.component.FormattedField" );
966 :
967 0 : for (sal_Int32 i=0; i<aOldProperties.getLength(); ++i)
968 : {
969 0 : if ( (!pOldProps[i].Name.equals(sPropDefaultControl))
970 0 : && (!pOldProps[i].Name.equals(sPropLabelControl))
971 : )
972 : {
973 : // binary search
974 : Property* pResult = ::std::lower_bound(
975 0 : pNewProps, pNewProps + nNewLen, pOldProps[i], ::comphelper::PropertyCompareByName());
976 :
977 0 : if ( pResult
978 0 : && ( pResult != pNewProps + nNewLen && pResult->Name == pOldProps[i].Name )
979 0 : && ( (pResult->Attributes & PropertyAttribute::READONLY) == 0 )
980 0 : && ( pResult->Type.equals(pOldProps[i].Type)) )
981 : { // Attributes match and the property is not read-only
982 : try
983 : {
984 0 : xNewProps->setPropertyValue(pResult->Name, xOldProps->getPropertyValue(pResult->Name));
985 : }
986 0 : catch(IllegalArgumentException& e)
987 : {
988 : OSL_UNUSED( e );
989 : #ifdef DBG_UTIL
990 : OUString sMessage = "TransferFormComponentProperties : could not transfer the value for property \"" +
991 : pResult->Name +
992 : "\"";
993 : OSL_FAIL(OUStringToOString(sMessage, RTL_TEXTENCODING_ASCII_US).getStr());
994 : #endif
995 : }
996 : }
997 : }
998 : }
999 :
1000 : // for formatted fields (either old or new) we have some special treatments
1001 0 : Reference< XServiceInfo > xSI( xOldProps, UNO_QUERY );
1002 0 : bool bOldIsFormatted = xSI.is() && xSI->supportsService( sFormattedServiceName );
1003 0 : xSI = Reference< XServiceInfo >( xNewProps, UNO_QUERY );
1004 0 : bool bNewIsFormatted = xSI.is() && xSI->supportsService( sFormattedServiceName );
1005 :
1006 0 : if (!bOldIsFormatted && !bNewIsFormatted)
1007 0 : return; // nothing to do
1008 :
1009 0 : if (bOldIsFormatted && bNewIsFormatted)
1010 : // if both fields are formatted we do no conversions
1011 0 : return;
1012 :
1013 0 : if (bOldIsFormatted)
1014 : {
1015 : // get some properties from the selected format and put them in the new Set
1016 0 : Any aFormatKey( xOldProps->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FORMATKEY)) );
1017 0 : if (aFormatKey.hasValue())
1018 : {
1019 0 : Reference< XNumberFormatsSupplier> xSupplier;
1020 0 : xOldProps->getPropertyValue(sPropFormatsSupplier) >>= xSupplier;
1021 0 : if (xSupplier.is())
1022 : {
1023 0 : Reference< XNumberFormats> xFormats(xSupplier->getNumberFormats());
1024 0 : Reference< XPropertySet> xFormat(xFormats->getByKey(getINT32(aFormatKey)));
1025 0 : if (hasProperty(sPropCurrencySymbol, xFormat))
1026 : {
1027 0 : Any aVal( xFormat->getPropertyValue(sPropCurrencySymbol) );
1028 0 : if (aVal.hasValue() && hasProperty(sPropCurrencySymbol, xNewProps))
1029 : // If the source value hasn't been set then don't copy it
1030 : // so we don't overwrite the default value
1031 0 : xNewProps->setPropertyValue(sPropCurrencySymbol, aVal);
1032 : }
1033 0 : if (hasProperty(sPropDecimals, xFormat) && hasProperty(sPropDecimals, xNewProps))
1034 0 : xNewProps->setPropertyValue(sPropDecimals, xFormat->getPropertyValue(sPropDecimals));
1035 0 : }
1036 : }
1037 :
1038 : // a potential Min-Max-Conversion
1039 0 : Any aEffectiveMin( xOldProps->getPropertyValue(sPropEffectiveMin) );
1040 0 : if (aEffectiveMin.hasValue())
1041 : { // Unlike the ValueMin the EffectiveMin can be void
1042 0 : if (hasProperty(sPropValueMin, xNewProps))
1043 : {
1044 : OSL_ENSURE(aEffectiveMin.getValueType().getTypeClass() == TypeClass_DOUBLE,
1045 : "TransferFormComponentProperties : invalid property type !");
1046 0 : xNewProps->setPropertyValue(sPropValueMin, aEffectiveMin);
1047 : }
1048 : }
1049 0 : Any aEffectiveMax( xOldProps->getPropertyValue(sPropEffectiveMax) );
1050 0 : if (aEffectiveMax.hasValue())
1051 : { // analog
1052 0 : if (hasProperty(sPropValueMax, xNewProps))
1053 : {
1054 : OSL_ENSURE(aEffectiveMax.getValueType().getTypeClass() == TypeClass_DOUBLE,
1055 : "TransferFormComponentProperties : invalid property type !");
1056 0 : xNewProps->setPropertyValue(sPropValueMax, aEffectiveMax);
1057 : }
1058 : }
1059 :
1060 : // then we can still convert and copy the default values
1061 0 : Any aEffectiveDefault( xOldProps->getPropertyValue(sPropEffectiveDefault) );
1062 0 : if (aEffectiveDefault.hasValue())
1063 : {
1064 0 : bool bIsString = aEffectiveDefault.getValueType().getTypeClass() == TypeClass_STRING;
1065 : OSL_ENSURE(bIsString || aEffectiveDefault.getValueType().getTypeClass() == TypeClass_DOUBLE,
1066 : "TransferFormComponentProperties : invalid property type !");
1067 : // The Effective-Properties should always be void or string or double ....
1068 :
1069 0 : if (hasProperty(sPropDefaultDate, xNewProps) && !bIsString)
1070 : { // (to convert a OUString into a date will not always succeed, because it might be bound to a text-column,
1071 : // but we can work with a double)
1072 0 : Date aDate = DBTypeConversion::toDate(getDouble(aEffectiveDefault));
1073 0 : xNewProps->setPropertyValue(sPropDefaultDate, makeAny(aDate));
1074 : }
1075 :
1076 0 : if (hasProperty(sPropDefaultTime, xNewProps) && !bIsString)
1077 : { // Completely analogous to time
1078 0 : css::util::Time aTime = DBTypeConversion::toTime(getDouble(aEffectiveDefault));
1079 0 : xNewProps->setPropertyValue(sPropDefaultTime, makeAny(aTime));
1080 : }
1081 :
1082 0 : if (hasProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DEFAULTVALUE), xNewProps) && !bIsString)
1083 : { // Here we can simply pass the double
1084 0 : xNewProps->setPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DEFAULTVALUE), aEffectiveDefault);
1085 : }
1086 :
1087 0 : if (hasProperty(sPropDefaultText, xNewProps) && bIsString)
1088 : { // and here the OUString
1089 0 : xNewProps->setPropertyValue(sPropDefaultText, aEffectiveDefault);
1090 : }
1091 :
1092 : // nyi: The translation between doubles and OUString would offer more alternatives
1093 0 : }
1094 : }
1095 :
1096 : // The other direction: the new Control shall be formatted
1097 0 : if (bNewIsFormatted)
1098 : {
1099 : // first the formatting
1100 : // we can't set a Supplier, so the new Set must bring one in
1101 0 : Reference< XNumberFormatsSupplier> xSupplier;
1102 0 : xNewProps->getPropertyValue(sPropFormatsSupplier) >>= xSupplier;
1103 0 : if (xSupplier.is())
1104 : {
1105 0 : Reference< XNumberFormats> xFormats(xSupplier->getNumberFormats());
1106 :
1107 : // Set number of decimals
1108 0 : sal_Int16 nDecimals = 2;
1109 0 : if (hasProperty(sPropDecimalAccuracy, xOldProps))
1110 0 : xOldProps->getPropertyValue(sPropDecimalAccuracy) >>= nDecimals;
1111 :
1112 : // base format (depending on the ClassId of the old Set)
1113 0 : sal_Int32 nBaseKey = 0;
1114 0 : if (hasProperty(sPropClassId, xOldProps))
1115 : {
1116 0 : Reference< XNumberFormatTypes> xTypeList(xFormats, UNO_QUERY);
1117 0 : if (xTypeList.is())
1118 : {
1119 0 : sal_Int16 nClassId = 0;
1120 0 : xOldProps->getPropertyValue(sPropClassId) >>= nClassId;
1121 0 : switch (nClassId)
1122 : {
1123 : case FormComponentType::DATEFIELD :
1124 0 : nBaseKey = xTypeList->getStandardFormat(NumberFormat::DATE, _rLocale);
1125 0 : break;
1126 :
1127 : case FormComponentType::TIMEFIELD :
1128 0 : nBaseKey = xTypeList->getStandardFormat(NumberFormat::TIME, _rLocale);
1129 0 : break;
1130 :
1131 : case FormComponentType::CURRENCYFIELD :
1132 0 : nBaseKey = xTypeList->getStandardFormat(NumberFormat::CURRENCY, _rLocale);
1133 0 : break;
1134 : }
1135 0 : }
1136 : }
1137 :
1138 : // With this we can generate a new format ...
1139 0 : OUString sNewFormat = xFormats->generateFormat(nBaseKey, _rLocale, sal_False, sal_False, nDecimals, 0);
1140 : // No thousands separator, negative numbers are not in red, no leading zeros
1141 :
1142 : // ... and add at FormatsSupplier (if needed)
1143 0 : sal_Int32 nKey = xFormats->queryKey(sNewFormat, _rLocale, sal_False);
1144 0 : if (nKey == (sal_Int32)-1)
1145 : { // not added yet in my formatter ...
1146 0 : nKey = xFormats->addNew(sNewFormat, _rLocale);
1147 : }
1148 :
1149 0 : xNewProps->setPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FORMATKEY), makeAny((sal_Int32)nKey));
1150 : }
1151 :
1152 : // min-/max-Value
1153 0 : Any aNewMin, aNewMax;
1154 0 : if (hasProperty(sPropValueMin, xOldProps))
1155 0 : aNewMin = xOldProps->getPropertyValue(sPropValueMin);
1156 0 : if (hasProperty(sPropValueMax, xOldProps))
1157 0 : aNewMax = xOldProps->getPropertyValue(sPropValueMax);
1158 0 : xNewProps->setPropertyValue(sPropEffectiveMin, aNewMin);
1159 0 : xNewProps->setPropertyValue(sPropEffectiveMax, aNewMax);
1160 :
1161 : // Default-Value
1162 0 : Any aNewDefault;
1163 0 : if (hasProperty(sPropDefaultDate, xOldProps))
1164 : {
1165 0 : Any aDate( xOldProps->getPropertyValue(sPropDefaultDate) );
1166 0 : if (aDate.hasValue())
1167 0 : aNewDefault <<= DBTypeConversion::toDouble(*static_cast<Date const *>(aDate.getValue()));
1168 : }
1169 :
1170 0 : if (hasProperty(sPropDefaultTime, xOldProps))
1171 : {
1172 0 : Any aTime( xOldProps->getPropertyValue(sPropDefaultTime) );
1173 0 : if (aTime.hasValue())
1174 0 : aNewDefault <<= DBTypeConversion::toDouble(*static_cast<Time const *>(aTime.getValue()));
1175 : }
1176 :
1177 : // double or OUString will be copied directly
1178 0 : if (hasProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DEFAULTVALUE), xOldProps))
1179 0 : aNewDefault = xOldProps->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DEFAULTVALUE));
1180 0 : if (hasProperty(sPropDefaultText, xOldProps))
1181 0 : aNewDefault = xOldProps->getPropertyValue(sPropDefaultText);
1182 :
1183 0 : if (aNewDefault.hasValue())
1184 0 : xNewProps->setPropertyValue(sPropEffectiveDefault, aNewDefault);
1185 0 : }
1186 : }
1187 0 : catch(const Exception&)
1188 : {
1189 : OSL_FAIL( "TransferFormComponentProperties: caught an exception!" );
1190 : }
1191 : }
1192 :
1193 0 : bool canInsert(const Reference< XPropertySet>& _rxCursorSet)
1194 : {
1195 0 : return ((_rxCursorSet.is() && (getINT32(_rxCursorSet->getPropertyValue("Privileges")) & Privilege::INSERT) != 0));
1196 : }
1197 :
1198 0 : bool canUpdate(const Reference< XPropertySet>& _rxCursorSet)
1199 : {
1200 0 : return ((_rxCursorSet.is() && (getINT32(_rxCursorSet->getPropertyValue("Privileges")) & Privilege::UPDATE) != 0));
1201 : }
1202 :
1203 0 : bool canDelete(const Reference< XPropertySet>& _rxCursorSet)
1204 : {
1205 0 : return ((_rxCursorSet.is() && (getINT32(_rxCursorSet->getPropertyValue("Privileges")) & Privilege::DELETE) != 0));
1206 : }
1207 :
1208 1378 : Reference< XDataSource> findDataSource(const Reference< XInterface >& _xParent)
1209 : {
1210 1378 : Reference< XOfficeDatabaseDocument> xDatabaseDocument(_xParent, UNO_QUERY);
1211 1378 : Reference< XDataSource> xDataSource;
1212 1378 : if ( xDatabaseDocument.is() )
1213 196 : xDataSource = xDatabaseDocument->getDataSource();
1214 1378 : if ( !xDataSource.is() )
1215 1182 : xDataSource.set(_xParent, UNO_QUERY);
1216 1378 : if (!xDataSource.is())
1217 : {
1218 96 : Reference< XChild> xChild(_xParent, UNO_QUERY);
1219 96 : if ( xChild.is() )
1220 78 : xDataSource = findDataSource(xChild->getParent());
1221 : }
1222 1378 : return xDataSource;
1223 : }
1224 :
1225 17 : Reference< XSingleSelectQueryComposer > getComposedRowSetStatement( const Reference< XPropertySet >& _rxRowSet, const Reference< XComponentContext >& _rxContext )
1226 : {
1227 17 : Reference< XSingleSelectQueryComposer > xComposer;
1228 : try
1229 : {
1230 17 : Reference< XConnection> xConn = connectRowset( Reference< XRowSet >( _rxRowSet, UNO_QUERY ), _rxContext, true );
1231 17 : if ( xConn.is() ) // implies _rxRowSet.is()
1232 : {
1233 : // build the statement the row set is based on (can't use the ActiveCommand property of the set
1234 : // as this reflects the status after the last execute, not the currently set properties)
1235 :
1236 17 : sal_Int32 nCommandType = CommandType::COMMAND;
1237 17 : OUString sCommand;
1238 17 : bool bEscapeProcessing = false;
1239 :
1240 17 : OSL_VERIFY( _rxRowSet->getPropertyValue("CommandType") >>= nCommandType );
1241 17 : OSL_VERIFY( _rxRowSet->getPropertyValue("Command") >>= sCommand );
1242 17 : OSL_VERIFY( _rxRowSet->getPropertyValue("EscapeProcessing") >>= bEscapeProcessing );
1243 :
1244 34 : StatementComposer aComposer( xConn, sCommand, nCommandType, bEscapeProcessing );
1245 : // append sort
1246 17 : aComposer.setOrder( getString( _rxRowSet->getPropertyValue("Order") ) );
1247 :
1248 : // append filter
1249 17 : bool bApplyFilter = true;
1250 17 : _rxRowSet->getPropertyValue("ApplyFilter") >>= bApplyFilter;
1251 17 : if ( bApplyFilter )
1252 11 : aComposer.setFilter( getString( _rxRowSet->getPropertyValue("Filter") ) );
1253 :
1254 17 : aComposer.getQuery();
1255 :
1256 17 : xComposer = aComposer.getComposer();
1257 34 : aComposer.setDisposeComposer( false );
1258 17 : }
1259 : }
1260 0 : catch( const SQLException& )
1261 : {
1262 0 : throw;
1263 : }
1264 0 : catch( const Exception& )
1265 : {
1266 : DBG_UNHANDLED_EXCEPTION();
1267 : }
1268 :
1269 17 : return xComposer;
1270 : }
1271 :
1272 17 : Reference< XSingleSelectQueryComposer > getCurrentSettingsComposer(
1273 : const Reference< XPropertySet>& _rxRowSetProps,
1274 : const Reference< XComponentContext>& _rxContext)
1275 : {
1276 17 : Reference< XSingleSelectQueryComposer > xReturn;
1277 : try
1278 : {
1279 17 : xReturn = getComposedRowSetStatement( _rxRowSetProps, _rxContext );
1280 : }
1281 0 : catch( const SQLException& )
1282 : {
1283 0 : throw;
1284 : }
1285 0 : catch( const Exception& )
1286 : {
1287 : OSL_FAIL( "::getCurrentSettingsComposer : caught an exception !" );
1288 : }
1289 :
1290 17 : return xReturn;
1291 : }
1292 :
1293 593 : OUString composeTableName( const Reference< XDatabaseMetaData >& _rxMetaData,
1294 : const OUString& _rCatalog,
1295 : const OUString& _rSchema,
1296 : const OUString& _rName,
1297 : bool _bQuote,
1298 : EComposeRule _eComposeRule)
1299 : {
1300 593 : return impl_doComposeTableName( _rxMetaData, _rCatalog, _rSchema, _rName, _bQuote, _eComposeRule );
1301 : }
1302 :
1303 48 : OUString composeTableNameForSelect( const Reference< XConnection >& _rxConnection,
1304 : const OUString& _rCatalog, const OUString& _rSchema, const OUString& _rName )
1305 : {
1306 48 : bool bUseCatalogInSelect = isDataSourcePropertyEnabled( _rxConnection, OUString( "UseCatalogInSelect" ), true );
1307 48 : bool bUseSchemaInSelect = isDataSourcePropertyEnabled( _rxConnection, OUString( "UseSchemaInSelect" ), true );
1308 :
1309 : return impl_doComposeTableName(
1310 48 : _rxConnection->getMetaData(),
1311 : bUseCatalogInSelect ? _rCatalog : OUString(),
1312 : bUseSchemaInSelect ? _rSchema : OUString(),
1313 : _rName,
1314 : true,
1315 : eInDataManipulation
1316 96 : );
1317 : }
1318 :
1319 : namespace
1320 : {
1321 35 : static void lcl_getTableNameComponents( const Reference<XPropertySet>& _xTable,
1322 : OUString& _out_rCatalog, OUString& _out_rSchema, OUString& _out_rName )
1323 : {
1324 35 : ::dbtools::OPropertyMap& rPropMap = OMetaConnection::getPropMap();
1325 35 : Reference< XPropertySetInfo > xInfo;
1326 35 : if (_xTable.is())
1327 35 : xInfo = _xTable->getPropertySetInfo();
1328 70 : if ( xInfo.is()
1329 35 : && xInfo->hasPropertyByName(rPropMap.getNameByIndex(PROPERTY_ID_NAME)) )
1330 : {
1331 70 : if ( xInfo->hasPropertyByName(rPropMap.getNameByIndex(PROPERTY_ID_CATALOGNAME))
1332 35 : && xInfo->hasPropertyByName(rPropMap.getNameByIndex(PROPERTY_ID_SCHEMANAME)) )
1333 : {
1334 35 : _xTable->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_CATALOGNAME)) >>= _out_rCatalog;
1335 35 : _xTable->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_SCHEMANAME)) >>= _out_rSchema;
1336 : }
1337 35 : _xTable->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_NAME)) >>= _out_rName;
1338 : }
1339 : else
1340 35 : OSL_FAIL( "::dbtools::lcl_getTableNameComponents: this is no table object!" );
1341 35 : }
1342 : }
1343 :
1344 35 : OUString composeTableNameForSelect( const Reference< XConnection >& _rxConnection, const Reference<XPropertySet>& _xTable )
1345 : {
1346 70 : OUString sCatalog, sSchema, sName;
1347 35 : lcl_getTableNameComponents( _xTable, sCatalog, sSchema, sName );
1348 :
1349 70 : return composeTableNameForSelect( _rxConnection, sCatalog, sSchema, sName );
1350 : }
1351 :
1352 0 : OUString composeTableName(const Reference<XDatabaseMetaData>& _xMetaData,
1353 : const Reference<XPropertySet>& _xTable,
1354 : EComposeRule _eComposeRule,
1355 : bool _bSuppressCatalog,
1356 : bool _bSuppressSchema,
1357 : bool _bQuote )
1358 : {
1359 0 : OUString sCatalog, sSchema, sName;
1360 0 : lcl_getTableNameComponents( _xTable, sCatalog, sSchema, sName );
1361 :
1362 : return impl_doComposeTableName(
1363 : _xMetaData,
1364 : _bSuppressCatalog ? OUString() : sCatalog,
1365 : _bSuppressSchema ? OUString() : sSchema,
1366 : sName,
1367 : _bQuote,
1368 : _eComposeRule
1369 0 : );
1370 : }
1371 :
1372 5 : sal_Int32 getSearchColumnFlag( const Reference< XConnection>& _rxConn,sal_Int32 _nDataType)
1373 : {
1374 5 : sal_Int32 nSearchFlag = 0;
1375 5 : Reference<XResultSet> xSet = _rxConn->getMetaData()->getTypeInfo();
1376 5 : if(xSet.is())
1377 : {
1378 5 : Reference<XRow> xRow(xSet,UNO_QUERY);
1379 10 : while(xSet->next())
1380 : {
1381 5 : if(xRow->getInt(2) == _nDataType)
1382 : {
1383 5 : nSearchFlag = xRow->getInt(9);
1384 5 : break;
1385 : }
1386 5 : }
1387 : }
1388 5 : return nSearchFlag;
1389 : }
1390 :
1391 0 : OUString createUniqueName( const Sequence< OUString >& _rNames, const OUString& _rBaseName, bool _bStartWithNumber )
1392 : {
1393 0 : ::std::set< OUString > aUsedNames;
1394 : ::std::copy(
1395 : _rNames.getConstArray(),
1396 0 : _rNames.getConstArray() + _rNames.getLength(),
1397 : ::std::insert_iterator< ::std::set< OUString > >( aUsedNames, aUsedNames.end() )
1398 0 : );
1399 :
1400 0 : OUString sName( _rBaseName );
1401 0 : sal_Int32 nPos = 1;
1402 0 : if ( _bStartWithNumber )
1403 0 : sName += OUString::number( nPos );
1404 :
1405 0 : while ( aUsedNames.find( sName ) != aUsedNames.end() )
1406 : {
1407 0 : sName = _rBaseName;
1408 0 : sName += OUString::number( ++nPos );
1409 : }
1410 0 : return sName;
1411 : }
1412 :
1413 0 : OUString createUniqueName(const Reference<XNameAccess>& _rxContainer,const OUString& _rBaseName, bool _bStartWithNumber)
1414 : {
1415 0 : Sequence< OUString > aElementNames;
1416 :
1417 : OSL_ENSURE( _rxContainer.is(), "createUniqueName: invalid container!" );
1418 0 : if ( _rxContainer.is() )
1419 0 : aElementNames = _rxContainer->getElementNames();
1420 :
1421 0 : return createUniqueName( aElementNames, _rBaseName, _bStartWithNumber );
1422 : }
1423 :
1424 0 : void showError(const SQLExceptionInfo& _rInfo,
1425 : const Reference< XWindow>& _xParent,
1426 : const Reference< XComponentContext >& _rxContext)
1427 : {
1428 0 : if (_rInfo.isValid())
1429 : {
1430 : try
1431 : {
1432 0 : Reference< XExecutableDialog > xErrorDialog = ErrorMessageDialog::create( _rxContext, "", _xParent, _rInfo.get() );
1433 0 : xErrorDialog->execute();
1434 : }
1435 0 : catch(const Exception&)
1436 : {
1437 : OSL_FAIL("showError: could not display the error message!");
1438 : }
1439 : }
1440 0 : }
1441 :
1442 0 : bool implUpdateObject(const Reference< XRowUpdate >& _rxUpdatedObject,
1443 : const sal_Int32 _nColumnIndex, const Any& _rValue)
1444 : {
1445 0 : bool bSuccessfullyReRouted = true;
1446 0 : switch (_rValue.getValueTypeClass())
1447 : {
1448 : case TypeClass_ANY:
1449 : {
1450 0 : Any aInnerValue;
1451 0 : _rValue >>= aInnerValue;
1452 0 : bSuccessfullyReRouted = implUpdateObject(_rxUpdatedObject, _nColumnIndex, aInnerValue);
1453 : }
1454 0 : break;
1455 :
1456 : case TypeClass_VOID:
1457 0 : _rxUpdatedObject->updateNull(_nColumnIndex);
1458 0 : break;
1459 :
1460 : case TypeClass_STRING:
1461 0 : _rxUpdatedObject->updateString(_nColumnIndex, *static_cast<OUString const *>(_rValue.getValue()));
1462 0 : break;
1463 :
1464 : case TypeClass_BOOLEAN:
1465 0 : _rxUpdatedObject->updateBoolean(_nColumnIndex, *static_cast<sal_Bool const *>(_rValue.getValue()));
1466 0 : break;
1467 :
1468 : case TypeClass_BYTE:
1469 0 : _rxUpdatedObject->updateByte(_nColumnIndex, *static_cast<sal_Int8 const *>(_rValue.getValue()));
1470 0 : break;
1471 :
1472 : case TypeClass_UNSIGNED_SHORT:
1473 : case TypeClass_SHORT:
1474 0 : _rxUpdatedObject->updateShort(_nColumnIndex, *static_cast<sal_Int16 const *>(_rValue.getValue()));
1475 0 : break;
1476 :
1477 : case TypeClass_CHAR:
1478 0 : _rxUpdatedObject->updateString(_nColumnIndex,OUString(static_cast<sal_Unicode const *>(_rValue.getValue()),1));
1479 0 : break;
1480 :
1481 : case TypeClass_UNSIGNED_LONG:
1482 : case TypeClass_LONG:
1483 0 : _rxUpdatedObject->updateInt(_nColumnIndex, *static_cast<sal_Int32 const *>(_rValue.getValue()));
1484 0 : break;
1485 :
1486 : case TypeClass_HYPER:
1487 : {
1488 0 : sal_Int64 nValue = 0;
1489 0 : OSL_VERIFY( _rValue >>= nValue );
1490 0 : _rxUpdatedObject->updateLong( _nColumnIndex, nValue );
1491 : }
1492 0 : break;
1493 :
1494 : case TypeClass_FLOAT:
1495 0 : _rxUpdatedObject->updateFloat(_nColumnIndex, *static_cast<float const *>(_rValue.getValue()));
1496 0 : break;
1497 :
1498 : case TypeClass_DOUBLE:
1499 0 : _rxUpdatedObject->updateDouble(_nColumnIndex, *static_cast<double const *>(_rValue.getValue()));
1500 0 : break;
1501 :
1502 : case TypeClass_SEQUENCE:
1503 0 : if (_rValue.getValueType() == cppu::UnoType< Sequence< sal_Int8 > >::get())
1504 0 : _rxUpdatedObject->updateBytes(_nColumnIndex, *static_cast<Sequence<sal_Int8> const *>(_rValue.getValue()));
1505 : else
1506 0 : bSuccessfullyReRouted = false;
1507 0 : break;
1508 : case TypeClass_STRUCT:
1509 0 : if (_rValue.getValueType() == cppu::UnoType<DateTime>::get())
1510 0 : _rxUpdatedObject->updateTimestamp(_nColumnIndex, *static_cast<DateTime const *>(_rValue.getValue()));
1511 0 : else if (_rValue.getValueType() == cppu::UnoType<Date>::get())
1512 0 : _rxUpdatedObject->updateDate(_nColumnIndex, *static_cast<Date const *>(_rValue.getValue()));
1513 0 : else if (_rValue.getValueType() == cppu::UnoType<Time>::get())
1514 0 : _rxUpdatedObject->updateTime(_nColumnIndex, *static_cast<Time const *>(_rValue.getValue()));
1515 : else
1516 0 : bSuccessfullyReRouted = false;
1517 0 : break;
1518 :
1519 : case TypeClass_INTERFACE:
1520 0 : if (_rValue.getValueType() == cppu::UnoType<XInputStream>::get())
1521 : {
1522 0 : Reference< XInputStream > xStream;
1523 0 : _rValue >>= xStream;
1524 0 : _rxUpdatedObject->updateBinaryStream(_nColumnIndex, xStream, xStream->available());
1525 0 : break;
1526 : }
1527 : // run through
1528 : default:
1529 0 : bSuccessfullyReRouted = false;
1530 : }
1531 :
1532 0 : return bSuccessfullyReRouted;
1533 : }
1534 :
1535 1 : bool implSetObject( const Reference< XParameters >& _rxParameters,
1536 : const sal_Int32 _nColumnIndex, const Any& _rValue)
1537 : {
1538 1 : bool bSuccessfullyReRouted = true;
1539 1 : switch (_rValue.getValueTypeClass())
1540 : {
1541 : case TypeClass_UNSIGNED_HYPER:
1542 : {
1543 0 : sal_uInt64 nValue = 0;
1544 0 : OSL_VERIFY( _rValue >>= nValue );
1545 0 : _rxParameters->setString(_nColumnIndex, OUString::number(nValue));
1546 : }
1547 0 : break;
1548 :
1549 : case TypeClass_UNSIGNED_LONG:
1550 : case TypeClass_HYPER:
1551 : {
1552 0 : sal_Int64 nValue = 0;
1553 0 : OSL_VERIFY( _rValue >>= nValue );
1554 0 : _rxParameters->setLong( _nColumnIndex, nValue );
1555 : }
1556 0 : break;
1557 :
1558 : case TypeClass_ANY:
1559 : {
1560 0 : Any aInnerValue;
1561 0 : _rValue >>= aInnerValue;
1562 0 : bSuccessfullyReRouted = implSetObject(_rxParameters, _nColumnIndex, aInnerValue);
1563 : }
1564 0 : break;
1565 :
1566 : case TypeClass_VOID:
1567 0 : _rxParameters->setNull(_nColumnIndex,DataType::VARCHAR);
1568 0 : break;
1569 :
1570 : case TypeClass_STRING:
1571 1 : _rxParameters->setString(_nColumnIndex, *static_cast<OUString const *>(_rValue.getValue()));
1572 1 : break;
1573 :
1574 : case TypeClass_BOOLEAN:
1575 0 : _rxParameters->setBoolean(_nColumnIndex, *static_cast<sal_Bool const *>(_rValue.getValue()));
1576 0 : break;
1577 :
1578 : case TypeClass_BYTE:
1579 0 : _rxParameters->setByte(_nColumnIndex, *static_cast<sal_Int8 const *>(_rValue.getValue()));
1580 0 : break;
1581 :
1582 : case TypeClass_SHORT:
1583 0 : _rxParameters->setShort(_nColumnIndex, *static_cast<sal_Int16 const *>(_rValue.getValue()));
1584 0 : break;
1585 :
1586 : case TypeClass_CHAR:
1587 0 : _rxParameters->setString(_nColumnIndex, OUString(static_cast<sal_Unicode const *>(_rValue.getValue()),1));
1588 0 : break;
1589 :
1590 : case TypeClass_UNSIGNED_SHORT:
1591 : case TypeClass_LONG:
1592 : {
1593 0 : sal_Int32 nValue = 0;
1594 0 : OSL_VERIFY( _rValue >>= nValue );
1595 0 : _rxParameters->setInt(_nColumnIndex, nValue);
1596 0 : break;
1597 : }
1598 :
1599 : case TypeClass_FLOAT:
1600 0 : _rxParameters->setFloat(_nColumnIndex, *static_cast<float const *>(_rValue.getValue()));
1601 0 : break;
1602 :
1603 : case TypeClass_DOUBLE:
1604 0 : _rxParameters->setDouble(_nColumnIndex, *static_cast<double const *>(_rValue.getValue()));
1605 0 : break;
1606 :
1607 : case TypeClass_SEQUENCE:
1608 0 : if (_rValue.getValueType() == cppu::UnoType< Sequence< sal_Int8 > >::get())
1609 : {
1610 0 : _rxParameters->setBytes(_nColumnIndex, *static_cast<Sequence<sal_Int8> const *>(_rValue.getValue()));
1611 : }
1612 : else
1613 0 : bSuccessfullyReRouted = false;
1614 0 : break;
1615 : case TypeClass_STRUCT:
1616 0 : if (_rValue.getValueType() == cppu::UnoType<DateTime>::get())
1617 0 : _rxParameters->setTimestamp(_nColumnIndex, *static_cast<DateTime const *>(_rValue.getValue()));
1618 0 : else if (_rValue.getValueType() == cppu::UnoType<Date>::get())
1619 0 : _rxParameters->setDate(_nColumnIndex, *static_cast<Date const *>(_rValue.getValue()));
1620 0 : else if (_rValue.getValueType() == cppu::UnoType<Time>::get())
1621 0 : _rxParameters->setTime(_nColumnIndex, *static_cast<Time const *>(_rValue.getValue()));
1622 : else
1623 0 : bSuccessfullyReRouted = false;
1624 0 : break;
1625 :
1626 : case TypeClass_INTERFACE:
1627 0 : if (_rValue.getValueType() == cppu::UnoType<XInputStream>::get())
1628 : {
1629 0 : Reference< XInputStream > xStream;
1630 0 : _rValue >>= xStream;
1631 0 : _rxParameters->setBinaryStream(_nColumnIndex, xStream, xStream->available());
1632 0 : break;
1633 : }
1634 : // run through
1635 : default:
1636 0 : bSuccessfullyReRouted = false;
1637 :
1638 : }
1639 :
1640 1 : return bSuccessfullyReRouted;
1641 : }
1642 :
1643 : namespace
1644 : {
1645 2 : class OParameterWrapper : public ::cppu::WeakImplHelper1< XIndexAccess >
1646 : {
1647 : ::std::vector<bool, std::allocator<bool> > m_aSet;
1648 : Reference<XIndexAccess> m_xSource;
1649 : public:
1650 1 : OParameterWrapper(const ::std::vector<bool, std::allocator<bool> >& _aSet,const Reference<XIndexAccess>& _xSource) : m_aSet(_aSet),m_xSource(_xSource){}
1651 : private:
1652 : // ::com::sun::star::container::XElementAccess
1653 0 : virtual Type SAL_CALL getElementType() throw(RuntimeException, std::exception) SAL_OVERRIDE
1654 : {
1655 0 : return m_xSource->getElementType();
1656 : }
1657 0 : virtual sal_Bool SAL_CALL hasElements( ) throw(RuntimeException, std::exception) SAL_OVERRIDE
1658 : {
1659 0 : if ( m_aSet.empty() )
1660 0 : return m_xSource->hasElements();
1661 0 : return ::std::count(m_aSet.begin(),m_aSet.end(),false) != 0;
1662 : }
1663 : // ::com::sun::star::container::XIndexAccess
1664 0 : virtual sal_Int32 SAL_CALL getCount( ) throw(RuntimeException, std::exception) SAL_OVERRIDE
1665 : {
1666 0 : if ( m_aSet.empty() )
1667 0 : return m_xSource->getCount();
1668 0 : return ::std::count(m_aSet.begin(),m_aSet.end(),false);
1669 : }
1670 1 : virtual Any SAL_CALL getByIndex( sal_Int32 Index ) throw(IndexOutOfBoundsException, WrappedTargetException, RuntimeException, std::exception) SAL_OVERRIDE
1671 : {
1672 1 : if ( m_aSet.empty() )
1673 0 : return m_xSource->getByIndex(Index);
1674 1 : if ( m_aSet.size() < (size_t)Index )
1675 0 : throw IndexOutOfBoundsException();
1676 :
1677 1 : ::std::vector<bool, std::allocator<bool> >::iterator aIter = m_aSet.begin();
1678 1 : ::std::vector<bool, std::allocator<bool> >::iterator aEnd = m_aSet.end();
1679 1 : sal_Int32 i = 0;
1680 1 : sal_Int32 nParamPos = -1;
1681 2 : for(; aIter != aEnd && i <= Index; ++aIter)
1682 : {
1683 1 : ++nParamPos;
1684 1 : if ( !*aIter )
1685 : {
1686 1 : ++i;
1687 : }
1688 : }
1689 1 : return m_xSource->getByIndex(nParamPos);
1690 : }
1691 : };
1692 : }
1693 :
1694 5 : void askForParameters(const Reference< XSingleSelectQueryComposer >& _xComposer,
1695 : const Reference<XParameters>& _xParameters,
1696 : const Reference< XConnection>& _xConnection,
1697 : const Reference< XInteractionHandler >& _rxHandler,
1698 : const ::std::vector<bool, std::allocator<bool> >& _aParametersSet)
1699 : {
1700 : OSL_ENSURE(_xComposer.is(),"dbtools::askForParameters XSQLQueryComposer is null!");
1701 : OSL_ENSURE(_xParameters.is(),"dbtools::askForParameters XParameters is null!");
1702 : OSL_ENSURE(_xConnection.is(),"dbtools::askForParameters XConnection is null!");
1703 : OSL_ENSURE(_rxHandler.is(),"dbtools::askForParameters XInteractionHandler is null!");
1704 :
1705 : // we have to set this here again because getCurrentSettingsComposer can force a setpropertyvalue
1706 5 : Reference<XParametersSupplier> xParameters = Reference<XParametersSupplier> (_xComposer, UNO_QUERY);
1707 :
1708 10 : Reference<XIndexAccess> xParamsAsIndicies = xParameters.is() ? xParameters->getParameters() : Reference<XIndexAccess>();
1709 5 : sal_Int32 nParamCount = xParamsAsIndicies.is() ? xParamsAsIndicies->getCount() : 0;
1710 10 : ::std::vector<bool, std::allocator<bool> > aNewParameterSet( _aParametersSet );
1711 5 : if ( nParamCount && ::std::count(aNewParameterSet.begin(),aNewParameterSet.end(),true) != nParamCount )
1712 : {
1713 1 : static const OUString PROPERTY_NAME(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME));
1714 1 : aNewParameterSet.resize(nParamCount ,false);
1715 : typedef ::std::map< OUString, ::std::vector<sal_Int32> > TParameterPositions;
1716 1 : TParameterPositions aParameterNames;
1717 2 : for(sal_Int32 i = 0; i < nParamCount; ++i)
1718 : {
1719 1 : Reference<XPropertySet> xParam(xParamsAsIndicies->getByIndex(i),UNO_QUERY);
1720 2 : OUString sName;
1721 1 : xParam->getPropertyValue(PROPERTY_NAME) >>= sName;
1722 :
1723 1 : TParameterPositions::iterator aFind = aParameterNames.find(sName);
1724 1 : if ( aFind != aParameterNames.end() )
1725 0 : aNewParameterSet[i] = true;
1726 1 : aParameterNames[sName].push_back(i+1);
1727 1 : }
1728 : // build an interaction request
1729 : // two continuations (Ok and Cancel)
1730 1 : OInteractionAbort* pAbort = new OInteractionAbort;
1731 1 : OParameterContinuation* pParams = new OParameterContinuation;
1732 : // the request
1733 2 : ParametersRequest aRequest;
1734 2 : Reference<XIndexAccess> xWrappedParameters = new OParameterWrapper(aNewParameterSet,xParamsAsIndicies);
1735 1 : aRequest.Parameters = xWrappedParameters;
1736 1 : aRequest.Connection = _xConnection;
1737 1 : OInteractionRequest* pRequest = new OInteractionRequest(makeAny(aRequest));
1738 2 : Reference< XInteractionRequest > xRequest(pRequest);
1739 : // some knittings
1740 1 : pRequest->addContinuation(pAbort);
1741 1 : pRequest->addContinuation(pParams);
1742 :
1743 : // execute the request
1744 1 : _rxHandler->handle(xRequest);
1745 :
1746 1 : if (!pParams->wasSelected())
1747 : {
1748 : // canceled by the user (i.e. (s)he canceled the dialog)
1749 0 : RowSetVetoException e;
1750 0 : e.ErrorCode = ParameterInteractionCancelled;
1751 0 : throw e;
1752 : }
1753 :
1754 : // now transfer the values from the continuation object to the parameter columns
1755 2 : Sequence< PropertyValue > aFinalValues = pParams->getValues();
1756 1 : const PropertyValue* pFinalValues = aFinalValues.getConstArray();
1757 2 : for (sal_Int32 i=0; i<aFinalValues.getLength(); ++i, ++pFinalValues)
1758 : {
1759 1 : Reference< XPropertySet > xParamColumn(xWrappedParameters->getByIndex(i),UNO_QUERY);
1760 1 : if (xParamColumn.is())
1761 : {
1762 1 : OUString sName;
1763 1 : xParamColumn->getPropertyValue(PROPERTY_NAME) >>= sName;
1764 : OSL_ENSURE(sName.equals(pFinalValues->Name), "::dbaui::askForParameters: inconsistent parameter names!");
1765 :
1766 : // determine the field type and ...
1767 1 : sal_Int32 nParamType = 0;
1768 1 : xParamColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE)) >>= nParamType;
1769 : // ... the scale of the parameter column
1770 1 : sal_Int32 nScale = 0;
1771 1 : if (hasProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE), xParamColumn))
1772 1 : xParamColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE)) >>= nScale;
1773 : // (the index of the parameters is one-based)
1774 1 : TParameterPositions::iterator aFind = aParameterNames.find(pFinalValues->Name);
1775 1 : ::std::vector<sal_Int32>::iterator aIterPos = aFind->second.begin();
1776 1 : ::std::vector<sal_Int32>::iterator aEndPos = aFind->second.end();
1777 2 : for(;aIterPos != aEndPos;++aIterPos)
1778 : {
1779 1 : if ( _aParametersSet.empty() || !_aParametersSet[(*aIterPos)-1] )
1780 : {
1781 1 : _xParameters->setObjectWithInfo(*aIterPos, pFinalValues->Value, nParamType, nScale);
1782 : }
1783 1 : }
1784 : }
1785 2 : }
1786 5 : }
1787 5 : }
1788 :
1789 7 : void setObjectWithInfo(const Reference<XParameters>& _xParams,
1790 : sal_Int32 parameterIndex,
1791 : const Any& x,
1792 : sal_Int32 sqlType,
1793 : sal_Int32 scale) throw(SQLException, RuntimeException)
1794 : {
1795 7 : ORowSetValue aVal;
1796 7 : aVal.fill(x);
1797 7 : setObjectWithInfo(_xParams,parameterIndex,aVal,sqlType,scale);
1798 7 : }
1799 :
1800 13510 : void setObjectWithInfo(const Reference<XParameters>& _xParams,
1801 : sal_Int32 parameterIndex,
1802 : const ::connectivity::ORowSetValue& _rValue,
1803 : sal_Int32 sqlType,
1804 : sal_Int32 scale) throw(SQLException, RuntimeException)
1805 : {
1806 13510 : if ( _rValue.isNull() )
1807 0 : _xParams->setNull(parameterIndex,sqlType);
1808 : else
1809 : {
1810 13510 : switch(sqlType)
1811 : {
1812 : case DataType::DECIMAL:
1813 : case DataType::NUMERIC:
1814 0 : _xParams->setObjectWithInfo(parameterIndex,_rValue.makeAny(),sqlType,scale);
1815 0 : break;
1816 : case DataType::CHAR:
1817 : case DataType::VARCHAR:
1818 : case DataType::LONGVARCHAR:
1819 9 : _xParams->setString(parameterIndex,_rValue);
1820 9 : break;
1821 : case DataType::CLOB:
1822 : {
1823 0 : Any x(_rValue.makeAny());
1824 0 : OUString sValue;
1825 0 : if ( x >>= sValue )
1826 0 : _xParams->setString(parameterIndex,sValue);
1827 : else
1828 : {
1829 0 : Reference< XClob > xClob;
1830 0 : if(x >>= xClob)
1831 0 : _xParams->setClob(parameterIndex,xClob);
1832 : else
1833 : {
1834 0 : Reference< ::com::sun::star::io::XInputStream > xStream;
1835 0 : if(x >>= xStream)
1836 0 : _xParams->setCharacterStream(parameterIndex,xStream,xStream->available());
1837 0 : }
1838 0 : }
1839 : }
1840 0 : break;
1841 : case DataType::BIGINT:
1842 0 : if ( _rValue.isSigned() )
1843 0 : _xParams->setLong(parameterIndex,_rValue);
1844 : else
1845 0 : _xParams->setString(parameterIndex,_rValue);
1846 0 : break;
1847 :
1848 : case DataType::FLOAT:
1849 0 : _xParams->setFloat(parameterIndex,_rValue);
1850 0 : break;
1851 : case DataType::REAL:
1852 : case DataType::DOUBLE:
1853 0 : _xParams->setDouble(parameterIndex,_rValue);
1854 0 : break;
1855 : case DataType::DATE:
1856 0 : _xParams->setDate(parameterIndex,_rValue);
1857 0 : break;
1858 : case DataType::TIME:
1859 0 : _xParams->setTime(parameterIndex,_rValue);
1860 0 : break;
1861 : case DataType::TIMESTAMP:
1862 0 : _xParams->setTimestamp(parameterIndex,_rValue);
1863 0 : break;
1864 : case DataType::BINARY:
1865 : case DataType::VARBINARY:
1866 : case DataType::LONGVARBINARY:
1867 : case DataType::BLOB:
1868 : {
1869 0 : Any x(_rValue.makeAny());
1870 0 : Sequence< sal_Int8> aBytes;
1871 0 : if(x >>= aBytes)
1872 0 : _xParams->setBytes(parameterIndex,aBytes);
1873 : else
1874 : {
1875 0 : Reference< XBlob > xBlob;
1876 0 : if(x >>= xBlob)
1877 0 : _xParams->setBlob(parameterIndex,xBlob);
1878 : else
1879 : {
1880 0 : Reference< XClob > xClob;
1881 0 : if(x >>= xClob)
1882 0 : _xParams->setClob(parameterIndex,xClob);
1883 : else
1884 : {
1885 0 : Reference< ::com::sun::star::io::XInputStream > xBinStream;
1886 0 : if(x >>= xBinStream)
1887 0 : _xParams->setBinaryStream(parameterIndex,xBinStream,xBinStream->available());
1888 0 : }
1889 0 : }
1890 0 : }
1891 : }
1892 0 : break;
1893 : case DataType::BIT:
1894 : case DataType::BOOLEAN:
1895 0 : _xParams->setBoolean(parameterIndex,static_cast<bool>(_rValue));
1896 0 : break;
1897 : case DataType::TINYINT:
1898 0 : if ( _rValue.isSigned() )
1899 0 : _xParams->setByte(parameterIndex,_rValue);
1900 : else
1901 0 : _xParams->setShort(parameterIndex,_rValue);
1902 0 : break;
1903 : case DataType::SMALLINT:
1904 0 : if ( _rValue.isSigned() )
1905 0 : _xParams->setShort(parameterIndex,_rValue);
1906 : else
1907 0 : _xParams->setInt(parameterIndex,_rValue);
1908 0 : break;
1909 : case DataType::INTEGER:
1910 13501 : if ( _rValue.isSigned() )
1911 13501 : _xParams->setInt(parameterIndex,_rValue);
1912 : else
1913 0 : _xParams->setLong(parameterIndex,_rValue);
1914 13501 : break;
1915 : default:
1916 : {
1917 0 : ::connectivity::SharedResources aResources;
1918 : const OUString sError( aResources.getResourceStringWithSubstitution(
1919 : STR_UNKNOWN_PARA_TYPE,
1920 : "$position$", OUString::number(parameterIndex)
1921 0 : ) );
1922 0 : ::dbtools::throwGenericSQLException(sError,NULL);
1923 : }
1924 : }
1925 : }
1926 13510 : }
1927 :
1928 0 : void getBooleanComparisonPredicate( const OUString& _rExpression, const bool _bValue, const sal_Int32 _nBooleanComparisonMode,
1929 : OUStringBuffer& _out_rSQLPredicate )
1930 : {
1931 0 : switch ( _nBooleanComparisonMode )
1932 : {
1933 : case BooleanComparisonMode::IS_LITERAL:
1934 0 : _out_rSQLPredicate.append( _rExpression );
1935 0 : if ( _bValue )
1936 0 : _out_rSQLPredicate.appendAscii( " IS TRUE" );
1937 : else
1938 0 : _out_rSQLPredicate.appendAscii( " IS FALSE" );
1939 0 : break;
1940 :
1941 : case BooleanComparisonMode::EQUAL_LITERAL:
1942 0 : _out_rSQLPredicate.append( _rExpression );
1943 0 : _out_rSQLPredicate.appendAscii( _bValue ? " = TRUE" : " = FALSE" );
1944 0 : break;
1945 :
1946 : case BooleanComparisonMode::ACCESS_COMPAT:
1947 0 : if ( _bValue )
1948 : {
1949 0 : _out_rSQLPredicate.appendAscii( " NOT ( ( " );
1950 0 : _out_rSQLPredicate.append( _rExpression );
1951 0 : _out_rSQLPredicate.appendAscii( " = 0 ) OR ( " );
1952 0 : _out_rSQLPredicate.append( _rExpression );
1953 0 : _out_rSQLPredicate.appendAscii( " IS NULL ) )" );
1954 : }
1955 : else
1956 : {
1957 0 : _out_rSQLPredicate.append( _rExpression );
1958 0 : _out_rSQLPredicate.appendAscii( " = 0" );
1959 : }
1960 0 : break;
1961 :
1962 : case BooleanComparisonMode::EQUAL_INTEGER:
1963 : // fall through
1964 : default:
1965 0 : _out_rSQLPredicate.append( _rExpression );
1966 0 : _out_rSQLPredicate.appendAscii( _bValue ? " = 1" : " = 0" );
1967 0 : break;
1968 : }
1969 0 : }
1970 :
1971 : } // namespace dbtools
1972 :
1973 : namespace connectivity
1974 : {
1975 47012 : void release(oslInterlockedCount& _refCount,
1976 : ::cppu::OBroadcastHelper& rBHelper,
1977 : Reference< XInterface >& _xInterface,
1978 : ::com::sun::star::lang::XComponent* _pObject)
1979 : {
1980 47012 : if (osl_atomic_decrement( &_refCount ) == 0)
1981 : {
1982 446 : osl_atomic_increment( &_refCount );
1983 :
1984 446 : if (!rBHelper.bDisposed && !rBHelper.bInDispose)
1985 : {
1986 : // remember the parent
1987 144 : Reference< XInterface > xParent;
1988 : {
1989 144 : ::osl::MutexGuard aGuard( rBHelper.rMutex );
1990 144 : xParent = _xInterface;
1991 144 : _xInterface = NULL;
1992 : }
1993 :
1994 : // First dispose
1995 144 : _pObject->dispose();
1996 :
1997 : // only the alive ref holds the object
1998 : OSL_ASSERT( _refCount == 1 );
1999 :
2000 : // release the parent in the ~
2001 144 : if (xParent.is())
2002 : {
2003 144 : ::osl::MutexGuard aGuard( rBHelper.rMutex );
2004 144 : _xInterface = xParent;
2005 144 : }
2006 : }
2007 : }
2008 : else
2009 46566 : osl_atomic_increment( &_refCount );
2010 47012 : }
2011 :
2012 283256 : void checkDisposed(bool _bThrow) throw ( DisposedException )
2013 : {
2014 283256 : if (_bThrow)
2015 8 : throw DisposedException();
2016 :
2017 283248 : }
2018 :
2019 4046 : OSQLColumns::Vector::const_iterator find(OSQLColumns::Vector::const_iterator __first,
2020 : OSQLColumns::Vector::const_iterator __last,
2021 : const OUString& _rVal,
2022 : const ::comphelper::UStringMixEqual& _rCase)
2023 : {
2024 4046 : OUString sName = OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME);
2025 4046 : return find(__first,__last,sName,_rVal,_rCase);
2026 : }
2027 :
2028 0 : OSQLColumns::Vector::const_iterator findRealName(OSQLColumns::Vector::const_iterator __first,
2029 : OSQLColumns::Vector::const_iterator __last,
2030 : const OUString& _rVal,
2031 : const ::comphelper::UStringMixEqual& _rCase)
2032 : {
2033 0 : OUString sRealName = OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_REALNAME);
2034 0 : return find(__first,__last,sRealName,_rVal,_rCase);
2035 : }
2036 :
2037 4046 : OSQLColumns::Vector::const_iterator find(OSQLColumns::Vector::const_iterator __first,
2038 : OSQLColumns::Vector::const_iterator __last,
2039 : const OUString& _rProp,
2040 : const OUString& _rVal,
2041 : const ::comphelper::UStringMixEqual& _rCase)
2042 : {
2043 46298 : while (__first != __last && !_rCase(getString((*__first)->getPropertyValue(_rProp)),_rVal))
2044 38206 : ++__first;
2045 4046 : return __first;
2046 : }
2047 : } //namespace connectivity
2048 :
2049 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|