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