diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-10-31 12:57:08 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-11-01 07:12:36 +0100 |
commit | 8c9b5a901dcbb430bbf225ed0a2d7a286b1d5185 (patch) | |
tree | edf76ea7647609264260d20d86dca9357aa662db | |
parent | c45a3488af6455a3b307f9e64bed41d23b3bae53 (diff) |
loplugin:constantparam in connectivity
Change-Id: Ia13d0931bbdf642fe04119ea1112788fb143eba8
Reviewed-on: https://gerrit.libreoffice.org/44110
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
35 files changed, 85 insertions, 115 deletions
diff --git a/connectivity/source/commontools/DateConversion.cxx b/connectivity/source/commontools/DateConversion.cxx index e51339378526..39acab5c1092 100644 --- a/connectivity/source/commontools/DateConversion.cxx +++ b/connectivity/source/commontools/DateConversion.cxx @@ -44,7 +44,7 @@ using namespace ::com::sun::star::beans; using namespace ::com::sun::star::util; using namespace ::com::sun::star::uno; -OUString DBTypeConversion::toSQLString(sal_Int32 eType, const Any& _rVal, bool bQuote, +OUString DBTypeConversion::toSQLString(sal_Int32 eType, const Any& _rVal, const Reference< XTypeConverter >& _rxTypeConverter) { OUStringBuffer aRet; @@ -76,8 +76,7 @@ OUString DBTypeConversion::toSQLString(sal_Int32 eType, const Any& _rVal, bool b case DataType::CHAR: case DataType::VARCHAR: case DataType::LONGVARCHAR: - if (bQuote) - aRet.append("'"); + aRet.append("'"); { OUString aTemp; _rxTypeConverter->convertToSimpleType(_rVal, TypeClass_STRING) >>= aTemp; @@ -93,8 +92,7 @@ OUString DBTypeConversion::toSQLString(sal_Int32 eType, const Any& _rVal, bool b aRet.append(aTemp); } - if (bQuote) - aRet.append("'"); + aRet.append("'"); break; case DataType::REAL: case DataType::DOUBLE: @@ -133,11 +131,9 @@ OUString DBTypeConversion::toSQLString(sal_Int32 eType, const Any& _rVal, bool b // check if this is really a timestamp or only a date if ( bOk ) { - if (bQuote) - aRet.append("{ts '"); + aRet.append("{ts '"); aRet.append(DBTypeConversion::toDateTimeString(aDateTime)); - if (bQuote) - aRet.append("'}"); + aRet.append("'}"); break; } break; @@ -163,11 +159,9 @@ OUString DBTypeConversion::toSQLString(sal_Int32 eType, const Any& _rVal, bool b else bOk = _rVal >>= aDate; OSL_ENSURE( bOk, "DBTypeConversion::toSQLString: _rVal is not date!"); - if (bQuote) - aRet.append("{d '"); + aRet.append("{d '"); aRet.append(DBTypeConversion::toDateString(aDate)); - if (bQuote) - aRet.append("'}"); + aRet.append("'}"); } break; case DataType::TIME: { @@ -190,11 +184,9 @@ OUString DBTypeConversion::toSQLString(sal_Int32 eType, const Any& _rVal, bool b else bOk = _rVal >>= aTime; OSL_ENSURE( bOk,"DBTypeConversion::toSQLString: _rVal is not time!"); - if (bQuote) - aRet.append("{t '"); + aRet.append("{t '"); aRet.append(DBTypeConversion::toTimeString(aTime)); - if (bQuote) - aRet.append("'}"); + aRet.append("'}"); } break; } } diff --git a/connectivity/source/commontools/TColumnsHelper.cxx b/connectivity/source/commontools/TColumnsHelper.cxx index 2f347da63946..ff585a6e4993 100644 --- a/connectivity/source/commontools/TColumnsHelper.cxx +++ b/connectivity/source/commontools/TColumnsHelper.cxx @@ -175,7 +175,7 @@ sdbcx::ObjectType OColumnsHelper::appendObject( const OUString& _rForName, const Reference<XDatabaseMetaData> xMetaData = m_pTable->getConnection()->getMetaData(); OUString aSql = "ALTER TABLE " + - ::dbtools::composeTableName( xMetaData, m_pTable, ::dbtools::EComposeRule::InTableDefinitions, false, false, true ) + + ::dbtools::composeTableName( xMetaData, m_pTable, ::dbtools::EComposeRule::InTableDefinitions, true ) + " ADD " + ::dbtools::createStandardColumnPart(descriptor,m_pTable->getConnection(),nullptr,m_pTable->getTypeCreatePattern()); @@ -197,7 +197,7 @@ void OColumnsHelper::dropObject(sal_Int32 /*_nPos*/, const OUString& _sElementNa Reference<XDatabaseMetaData> xMetaData = m_pTable->getConnection()->getMetaData(); OUString aQuote = xMetaData->getIdentifierQuoteString( ); OUString aSql = "ALTER TABLE " + - ::dbtools::composeTableName( xMetaData, m_pTable, ::dbtools::EComposeRule::InTableDefinitions, false, false, true ) + + ::dbtools::composeTableName( xMetaData, m_pTable, ::dbtools::EComposeRule::InTableDefinitions, true ) + " DROP " + ::dbtools::quoteName( aQuote,_sElementName); diff --git a/connectivity/source/commontools/TIndexes.cxx b/connectivity/source/commontools/TIndexes.cxx index 85e90bd94ddc..33dabdd76a23 100644 --- a/connectivity/source/commontools/TIndexes.cxx +++ b/connectivity/source/commontools/TIndexes.cxx @@ -227,7 +227,7 @@ void OIndexesHelper::dropObject(sal_Int32 /*_nPos*/,const OUString& _sElementNam OUString aSql( "DROP INDEX " ); - OUString aComposedName = dbtools::composeTableName( m_pTable->getMetaData(), m_pTable, ::dbtools::EComposeRule::InIndexDefinitions, false, false, true ); + OUString aComposedName = dbtools::composeTableName( m_pTable->getMetaData(), m_pTable, ::dbtools::EComposeRule::InIndexDefinitions, true ); OUString sIndexName; sIndexName = dbtools::composeTableName( m_pTable->getMetaData(), OUString(), aSchema, aName, true, ::dbtools::EComposeRule::InIndexDefinitions ); diff --git a/connectivity/source/commontools/TKeys.cxx b/connectivity/source/commontools/TKeys.cxx index c7419c47c7cf..6b3b8dae0e7a 100644 --- a/connectivity/source/commontools/TKeys.cxx +++ b/connectivity/source/commontools/TKeys.cxx @@ -159,7 +159,7 @@ sdbcx::ObjectType OKeysHelper::appendObject( const OUString& _rForName, const Re aSql.append("ALTER TABLE "); OUString aQuote = m_pTable->getConnection()->getMetaData()->getIdentifierQuoteString( ); - aSql.append(composeTableName( m_pTable->getConnection()->getMetaData(), m_pTable, ::dbtools::EComposeRule::InTableDefinitions, false, false, true )); + aSql.append(composeTableName( m_pTable->getConnection()->getMetaData(), m_pTable, ::dbtools::EComposeRule::InTableDefinitions, true )); aSql.append(" ADD "); if ( nKeyType == KeyType::PRIMARY ) @@ -274,7 +274,7 @@ void OKeysHelper::dropObject(sal_Int32 _nPos, const OUString& _sElementName) OUStringBuffer aSql; aSql.append("ALTER TABLE "); - aSql.append( composeTableName( m_pTable->getConnection()->getMetaData(), m_pTable,::dbtools::EComposeRule::InTableDefinitions, false, false, true )); + aSql.append( composeTableName( m_pTable->getConnection()->getMetaData(), m_pTable,::dbtools::EComposeRule::InTableDefinitions, true )); sal_Int32 nKeyType = KeyType::PRIMARY; if ( xKey.is() ) diff --git a/connectivity/source/commontools/dbexception.cxx b/connectivity/source/commontools/dbexception.cxx index da88206cc7d8..961720f4bc59 100644 --- a/connectivity/source/commontools/dbexception.cxx +++ b/connectivity/source/commontools/dbexception.cxx @@ -446,14 +446,14 @@ void throwInvalidColumnException( const OUString& _rColumnName, const Reference< } void throwSQLException( const OUString& _rMessage, const OUString& _rSQLState, - const Reference< XInterface >& _rxContext, const sal_Int32 _nErrorCode, const Any* _pNextException ) + const Reference< XInterface >& _rxContext, const sal_Int32 _nErrorCode ) { throw SQLException( _rMessage, _rxContext, _rSQLState, _nErrorCode, - _pNextException ? *_pNextException : Any() + Any() ); } diff --git a/connectivity/source/commontools/dbtools.cxx b/connectivity/source/commontools/dbtools.cxx index 547aea048041..861419a5c283 100644 --- a/connectivity/source/commontools/dbtools.cxx +++ b/connectivity/source/commontools/dbtools.cxx @@ -450,17 +450,15 @@ SharedConnection lcl_connectRowSet(const Reference< XRowSet>& _rxRowSet, const R return xConnection; } -Reference< XConnection> connectRowset(const Reference< XRowSet>& _rxRowSet, const Reference< XComponentContext >& _rxContext, - bool _bSetAsActiveConnection ) +Reference< XConnection> connectRowset(const Reference< XRowSet>& _rxRowSet, const Reference< XComponentContext >& _rxContext ) { - SharedConnection xConnection = lcl_connectRowSet( _rxRowSet, _rxContext, _bSetAsActiveConnection, true ); + SharedConnection xConnection = lcl_connectRowSet( _rxRowSet, _rxContext, true/*bSetAsActiveConnection*/, true ); return xConnection.getTyped(); } -SharedConnection ensureRowSetConnection(const Reference< XRowSet>& _rxRowSet, const Reference< XComponentContext>& _rxContext, - bool _bUseAutoConnectionDisposer ) +SharedConnection ensureRowSetConnection(const Reference< XRowSet>& _rxRowSet, const Reference< XComponentContext>& _rxContext ) { - return lcl_connectRowSet( _rxRowSet, _rxContext, true, _bUseAutoConnectionDisposer ); + return lcl_connectRowSet( _rxRowSet, _rxContext, true, false/*bUseAutoConnectionDisposer*/ ); } Reference< XNameAccess> getTableFields(const Reference< XConnection>& _rxConn,const OUString& _rName) @@ -1210,7 +1208,7 @@ Reference< XSingleSelectQueryComposer > getComposedRowSetStatement( const Refere Reference< XSingleSelectQueryComposer > xComposer; try { - Reference< XConnection> xConn = connectRowset( Reference< XRowSet >( _rxRowSet, UNO_QUERY ), _rxContext, true ); + Reference< XConnection> xConn = connectRowset( Reference< XRowSet >( _rxRowSet, UNO_QUERY ), _rxContext ); if ( xConn.is() ) // implies _rxRowSet.is() { // build the statement the row set is based on (can't use the ActiveCommand property of the set @@ -1335,8 +1333,6 @@ OUString composeTableNameForSelect( const Reference< XConnection >& _rxConnectio OUString composeTableName(const Reference<XDatabaseMetaData>& _xMetaData, const Reference<XPropertySet>& _xTable, EComposeRule _eComposeRule, - bool _bSuppressCatalog, - bool _bSuppressSchema, bool _bQuote ) { OUString sCatalog, sSchema, sName; @@ -1344,8 +1340,8 @@ OUString composeTableName(const Reference<XDatabaseMetaData>& _xMetaData, return impl_doComposeTableName( _xMetaData, - _bSuppressCatalog ? OUString() : sCatalog, - _bSuppressSchema ? OUString() : sSchema, + sCatalog, + sSchema, sName, _bQuote, _eComposeRule diff --git a/connectivity/source/commontools/dbtools2.cxx b/connectivity/source/commontools/dbtools2.cxx index 942d9ac60278..efff523d800d 100644 --- a/connectivity/source/commontools/dbtools2.cxx +++ b/connectivity/source/commontools/dbtools2.cxx @@ -987,7 +987,7 @@ OUString getDefaultReportEngineServiceName(const Reference< XComponentContext >& return OUString(); } -bool isAggregateColumn(const Reference< XSingleSelectQueryComposer > &_xParser, const Reference< XPropertySet > &_xField, bool whenNotFound) +bool isAggregateColumn(const Reference< XSingleSelectQueryComposer > &_xParser, const Reference< XPropertySet > &_xField) { OUString sName; _xField->getPropertyValue("Name") >>= sName; @@ -996,7 +996,7 @@ bool isAggregateColumn(const Reference< XSingleSelectQueryComposer > &_xParser, if (xColumnsSupplier.is()) xCols = xColumnsSupplier->getColumns(); - return isAggregateColumn(xCols, sName, whenNotFound); + return isAggregateColumn(xCols, sName, false/*whenNotFound*/); } bool isAggregateColumn(const Reference< XNameAccess > &_xColumns, const OUString &_sName, bool whenNotFound) diff --git a/connectivity/source/drivers/hsqldb/HTables.cxx b/connectivity/source/drivers/hsqldb/HTables.cxx index c3b76a8355a9..bde5866b9d92 100644 --- a/connectivity/source/drivers/hsqldb/HTables.cxx +++ b/connectivity/source/drivers/hsqldb/HTables.cxx @@ -179,7 +179,7 @@ void OTables::appendNew(const OUString& _rsNewTable) OUString OTables::getNameForObject(const sdbcx::ObjectType& _xObject) { OSL_ENSURE(_xObject.is(),"OTables::getNameForObject: Object is NULL!"); - return ::dbtools::composeTableName( m_xMetaData, _xObject, ::dbtools::EComposeRule::InDataManipulation, false, false, false ); + return ::dbtools::composeTableName( m_xMetaData, _xObject, ::dbtools::EComposeRule::InDataManipulation, false ); } diff --git a/connectivity/source/drivers/hsqldb/HViews.cxx b/connectivity/source/drivers/hsqldb/HViews.cxx index e7ff80db0038..d254ed16f541 100644 --- a/connectivity/source/drivers/hsqldb/HViews.cxx +++ b/connectivity/source/drivers/hsqldb/HViews.cxx @@ -111,7 +111,7 @@ void HViews::dropObject(sal_Int32 _nPos,const OUString& /*_sElementName*/) OUString aSql( "DROP VIEW" ); Reference<XPropertySet> xProp(xObject,UNO_QUERY); - aSql += ::dbtools::composeTableName( m_xMetaData, xProp, ::dbtools::EComposeRule::InTableDefinitions, false, false, true ); + aSql += ::dbtools::composeTableName( m_xMetaData, xProp, ::dbtools::EComposeRule::InTableDefinitions, true ); Reference<XConnection> xConnection = static_cast<OHCatalog&>(m_rParent).getConnection(); Reference< XStatement > xStmt = xConnection->createStatement( ); @@ -135,7 +135,7 @@ void HViews::createView( const Reference< XPropertySet >& descriptor ) descriptor->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_COMMAND)) >>= sCommand; OUString aSql = "CREATE VIEW " + - ::dbtools::composeTableName( m_xMetaData, descriptor, ::dbtools::EComposeRule::InTableDefinitions, false, false, true ) + + ::dbtools::composeTableName( m_xMetaData, descriptor, ::dbtools::EComposeRule::InTableDefinitions, true ) + " AS " + sCommand; Reference< XStatement > xStmt = xConnection->createStatement( ); @@ -149,7 +149,7 @@ void HViews::createView( const Reference< XPropertySet >& descriptor ) OTables* pTables = static_cast<OTables*>(static_cast<OHCatalog&>(m_rParent).getPrivateTables()); if ( pTables ) { - OUString sName = ::dbtools::composeTableName( m_xMetaData, descriptor, ::dbtools::EComposeRule::InDataManipulation, false, false, false ); + OUString sName = ::dbtools::composeTableName( m_xMetaData, descriptor, ::dbtools::EComposeRule::InDataManipulation, false ); pTables->appendNew(sName); } } diff --git a/connectivity/source/drivers/jdbc/DatabaseMetaData.cxx b/connectivity/source/drivers/jdbc/DatabaseMetaData.cxx index fb13acb5e534..ccef2260e8b0 100644 --- a/connectivity/source/drivers/jdbc/DatabaseMetaData.cxx +++ b/connectivity/source/drivers/jdbc/DatabaseMetaData.cxx @@ -117,7 +117,7 @@ Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getTables( // execute Java-Call static jmethodID mID(nullptr); obtainMethodId_throwSQL(t.pEnv, cMethodName,cSignature, mID); - OSL_VERIFY( !isExceptionOccurred(t.pEnv, true) ); + OSL_VERIFY( !isExceptionOccurred(t.pEnv) ); jvalue args[4]; args[3].l = nullptr; @@ -125,7 +125,7 @@ Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getTables( if ( typeFilterCount ) { jobjectArray pObjArray = t.pEnv->NewObjectArray( (jsize)typeFilterCount, java_lang_String::st_getMyClass(), nullptr ); - OSL_VERIFY( !isExceptionOccurred( t.pEnv, true ) ); + OSL_VERIFY( !isExceptionOccurred( t.pEnv ) ); const OUString* typeFilter = _types.getConstArray(); bool bIncludeAllTypes = false; for ( sal_Int32 i=0; i<typeFilterCount; ++i, ++typeFilter ) @@ -137,7 +137,7 @@ Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getTables( } jstring aT = convertwchar_tToJavaString( t.pEnv, *typeFilter ); t.pEnv->SetObjectArrayElement( pObjArray, (jsize)i, aT ); - OSL_VERIFY( !isExceptionOccurred( t.pEnv, true ) ); + OSL_VERIFY( !isExceptionOccurred( t.pEnv ) ); } if ( bIncludeAllTypes ) @@ -145,7 +145,7 @@ Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getTables( // the SDBC API allows to pass "%" as table type filter, but in JDBC, "all table types" // is represented by the table type being <null/> t.pEnv->DeleteLocalRef( pObjArray ); - OSL_VERIFY( !isExceptionOccurred( t.pEnv, true ) ); + OSL_VERIFY( !isExceptionOccurred( t.pEnv ) ); } else { @@ -173,23 +173,23 @@ Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getTables( if ( aCatalogFilter.hasValue() ) { t.pEnv->DeleteLocalRef(static_cast<jstring>(args[0].l)); - OSL_VERIFY( !isExceptionOccurred( t.pEnv, true ) ); + OSL_VERIFY( !isExceptionOccurred( t.pEnv ) ); } if(args[1].l) { t.pEnv->DeleteLocalRef(static_cast<jstring>(args[1].l)); - OSL_VERIFY( !isExceptionOccurred( t.pEnv, true ) ); + OSL_VERIFY( !isExceptionOccurred( t.pEnv ) ); } if(!tableNamePattern.isEmpty()) { t.pEnv->DeleteLocalRef(static_cast<jstring>(args[2].l)); - OSL_VERIFY( !isExceptionOccurred( t.pEnv, true ) ); + OSL_VERIFY( !isExceptionOccurred( t.pEnv ) ); } //for(INT16 i=0;i<len;i++) if ( args[3].l ) { t.pEnv->DeleteLocalRef( static_cast<jobjectArray>(args[3].l) ); - OSL_VERIFY( !isExceptionOccurred( t.pEnv, true ) ); + OSL_VERIFY( !isExceptionOccurred( t.pEnv ) ); } if ( jThrow ) diff --git a/connectivity/source/drivers/jdbc/tools.cxx b/connectivity/source/drivers/jdbc/tools.cxx index 7625f3eb5a1e..7b651b68fe72 100644 --- a/connectivity/source/drivers/jdbc/tools.cxx +++ b/connectivity/source/drivers/jdbc/tools.cxx @@ -184,7 +184,7 @@ jobject connectivity::convertTypeMapToJavaMap(const Reference< css::container::X return nullptr; } -bool connectivity::isExceptionOccurred(JNIEnv *pEnv,bool _bClear) +bool connectivity::isExceptionOccurred(JNIEnv *pEnv) { if ( !pEnv ) return false; @@ -193,8 +193,7 @@ bool connectivity::isExceptionOccurred(JNIEnv *pEnv,bool _bClear) bool bRet = pThrowable != nullptr; if ( pThrowable ) { - if ( _bClear ) - pEnv->ExceptionClear(); + pEnv->ExceptionClear(); pEnv->DeleteLocalRef(pThrowable); } diff --git a/connectivity/source/drivers/mysql/YTables.cxx b/connectivity/source/drivers/mysql/YTables.cxx index 988016796b7c..be47c7c7a116 100644 --- a/connectivity/source/drivers/mysql/YTables.cxx +++ b/connectivity/source/drivers/mysql/YTables.cxx @@ -199,7 +199,7 @@ void OTables::appendNew(const OUString& _rsNewTable) OUString OTables::getNameForObject(const sdbcx::ObjectType& _xObject) { OSL_ENSURE(_xObject.is(),"OTables::getNameForObject: Object is NULL!"); - return ::dbtools::composeTableName( m_xMetaData, _xObject, ::dbtools::EComposeRule::InDataManipulation, false, false, false ); + return ::dbtools::composeTableName( m_xMetaData, _xObject, ::dbtools::EComposeRule::InDataManipulation, false ); } void OTables::addComment(const Reference< XPropertySet >& descriptor,OUStringBuffer& _rOut) diff --git a/connectivity/source/drivers/mysql/YViews.cxx b/connectivity/source/drivers/mysql/YViews.cxx index 874f8ce33ee8..2f4f123285b3 100644 --- a/connectivity/source/drivers/mysql/YViews.cxx +++ b/connectivity/source/drivers/mysql/YViews.cxx @@ -104,7 +104,7 @@ void OViews::dropObject(sal_Int32 _nPos,const OUString& /*_sElementName*/) OUString aSql( "DROP VIEW" ); Reference<XPropertySet> xProp(xObject,UNO_QUERY); - aSql += ::dbtools::composeTableName( m_xMetaData, xProp, ::dbtools::EComposeRule::InTableDefinitions, false, false, true ); + aSql += ::dbtools::composeTableName( m_xMetaData, xProp, ::dbtools::EComposeRule::InTableDefinitions, true ); Reference<XConnection> xConnection = static_cast<OMySQLCatalog&>(m_rParent).getConnection(); Reference< XStatement > xStmt = xConnection->createStatement( ); @@ -127,7 +127,7 @@ void OViews::createView( const Reference< XPropertySet >& descriptor ) OUString aSql( "CREATE VIEW " ); OUString sCommand; - aSql += ::dbtools::composeTableName( m_xMetaData, descriptor, ::dbtools::EComposeRule::InTableDefinitions, false, false, true ); + aSql += ::dbtools::composeTableName( m_xMetaData, descriptor, ::dbtools::EComposeRule::InTableDefinitions, true ); aSql += " AS "; descriptor->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_COMMAND)) >>= sCommand; @@ -144,7 +144,7 @@ void OViews::createView( const Reference< XPropertySet >& descriptor ) OTables* pTables = static_cast<OTables*>(static_cast<OMySQLCatalog&>(m_rParent).getPrivateTables()); if ( pTables ) { - OUString sName = ::dbtools::composeTableName( m_xMetaData, descriptor, ::dbtools::EComposeRule::InDataManipulation, false, false, false ); + OUString sName = ::dbtools::composeTableName( m_xMetaData, descriptor, ::dbtools::EComposeRule::InDataManipulation, false ); pTables->appendNew(sName); } } diff --git a/connectivity/source/inc/java/tools.hxx b/connectivity/source/inc/java/tools.hxx index 31647fe57fc8..c181a1b2f940 100644 --- a/connectivity/source/inc/java/tools.hxx +++ b/connectivity/source/inc/java/tools.hxx @@ -48,14 +48,11 @@ namespace connectivity jobject convertTypeMapToJavaMap(const css::uno::Reference< css::container::XNameAccess > & _rMap); /** return if a exception occurred + the exception will be cleared. @param pEnv The native java env - @param _bClear - <TRUE/> if the exception should be cleared - @return - <TRUE/> if an exception is occurred */ - bool isExceptionOccurred(JNIEnv *pEnv,bool _bClear); + bool isExceptionOccurred(JNIEnv *pEnv); jobject createByteInputStream(const css::uno::Reference< css::io::XInputStream >& x,sal_Int32 length); jobject createCharArrayReader(const css::uno::Reference< css::io::XInputStream >& x,sal_Int32 length); diff --git a/dbaccess/source/core/api/FilteredContainer.cxx b/dbaccess/source/core/api/FilteredContainer.cxx index ab3894ff3b11..b9d734e4c242 100644 --- a/dbaccess/source/core/api/FilteredContainer.cxx +++ b/dbaccess/source/core/api/FilteredContainer.cxx @@ -403,7 +403,7 @@ sal_Int32 createWildCardVector(Sequence< OUString >& _rTableFilter, std::vector< OUString OFilteredContainer::getNameForObject(const ObjectType& _xObject) { OSL_ENSURE( _xObject.is(), "OFilteredContainer::getNameForObject: Object is NULL!" ); - return ::dbtools::composeTableName( m_xMetaData, _xObject, ::dbtools::EComposeRule::InDataManipulation, false, false, false ); + return ::dbtools::composeTableName( m_xMetaData, _xObject, ::dbtools::EComposeRule::InDataManipulation, false ); } // multiple to obtain all tables from XDatabaseMetaData::getTables, via passing a particular diff --git a/dbaccess/source/core/api/KeySet.cxx b/dbaccess/source/core/api/KeySet.cxx index 69c5ca5b1a2c..6c9bc6964d45 100644 --- a/dbaccess/source/core/api/KeySet.cxx +++ b/dbaccess/source/core/api/KeySet.cxx @@ -310,7 +310,7 @@ void OKeySet::construct(const Reference< XResultSet>& _xDriverSet, const OUStrin { connectivity::OSQLTable xSelColSup(xSelectTables->getByName(*pIter),uno::UNO_QUERY); Reference<XPropertySet> xProp(xSelColSup,uno::UNO_QUERY); - OUString sSelectTableName = ::dbtools::composeTableName( xMeta, xProp, ::dbtools::EComposeRule::InDataManipulation, false, false, false ); + OUString sSelectTableName = ::dbtools::composeTableName( xMeta, xProp, ::dbtools::EComposeRule::InDataManipulation, false ); ::dbaccess::getColumnPositions(xQueryColumns, xSelColSup->getColumns()->getElementNames(), sSelectTableName, (*m_pForeignColumnNames), true); diff --git a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx index 915c13e75808..61859ffd1cca 100644 --- a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx +++ b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx @@ -1607,7 +1607,7 @@ void OSingleSelectQueryComposer::setConditionByColumn( const Reference< XPropert case DataType::VARCHAR: case DataType::CHAR: case DataType::LONGVARCHAR: - aSQL.append( DBTypeConversion::toSQLString( nType, aValue, true, m_xTypeConverter ) ); + aSQL.append( DBTypeConversion::toSQLString( nType, aValue, m_xTypeConverter ) ); break; case DataType::CLOB: { @@ -1622,7 +1622,7 @@ void OSingleSelectQueryComposer::setConditionByColumn( const Reference< XPropert } else { - aSQL.append( DBTypeConversion::toSQLString( nType, aValue, true, m_xTypeConverter ) ); + aSQL.append( DBTypeConversion::toSQLString( nType, aValue, m_xTypeConverter ) ); } } break; @@ -1659,7 +1659,7 @@ void OSingleSelectQueryComposer::setConditionByColumn( const Reference< XPropert } break; default: - aSQL.append( DBTypeConversion::toSQLString( nType, aValue, true, m_xTypeConverter ) ); + aSQL.append( DBTypeConversion::toSQLString( nType, aValue, m_xTypeConverter ) ); break; } } diff --git a/dbaccess/source/core/api/viewcontainer.cxx b/dbaccess/source/core/api/viewcontainer.cxx index 4e64e1aa0d61..d14de81b1a19 100644 --- a/dbaccess/source/core/api/viewcontainer.cxx +++ b/dbaccess/source/core/api/viewcontainer.cxx @@ -133,7 +133,7 @@ ObjectType OViewContainer::appendObject( const OUString& _rForName, const Refere } else { - OUString sComposedName = ::dbtools::composeTableName( m_xMetaData, descriptor, ::dbtools::EComposeRule::InTableDefinitions, false, false, true ); + OUString sComposedName = ::dbtools::composeTableName( m_xMetaData, descriptor, ::dbtools::EComposeRule::InTableDefinitions, true ); if(sComposedName.isEmpty()) ::dbtools::throwFunctionSequenceException(static_cast<XTypeProvider*>(static_cast<OFilteredContainer*>(this))); diff --git a/dbaccess/source/ui/app/AppController.cxx b/dbaccess/source/ui/app/AppController.cxx index c30874a66fb6..951664a736d6 100644 --- a/dbaccess/source/ui/app/AppController.cxx +++ b/dbaccess/source/ui/app/AppController.cxx @@ -1590,7 +1590,7 @@ void SAL_CALL OApplicationController::elementReplaced( const ContainerEvent& _rE { ensureConnection(); if ( xProp.is() && m_xMetaData.is() ) - sNewName = ::dbaui::composeTableName( m_xMetaData, xProp, ::dbtools::EComposeRule::InDataManipulation, false, false, false ); + sNewName = ::dbaui::composeTableName( m_xMetaData, xProp, ::dbtools::EComposeRule::InDataManipulation, false ); } break; case E_FORM: @@ -2122,7 +2122,7 @@ void OApplicationController::renameEntry() if ( eType == E_TABLE ) { Reference<XPropertySet> xProp(xRename,UNO_QUERY); - sNewName = ::dbaui::composeTableName( m_xMetaData, xProp, ::dbtools::EComposeRule::InDataManipulation, false, false, false ); + sNewName = ::dbaui::composeTableName( m_xMetaData, xProp, ::dbtools::EComposeRule::InDataManipulation, false ); } getContainer()->elementReplaced( eType , sOldName, sNewName ); diff --git a/dbaccess/source/ui/browser/sbagrid.cxx b/dbaccess/source/ui/browser/sbagrid.cxx index b2920d018d68..b97bcaa239fd 100644 --- a/dbaccess/source/ui/browser/sbagrid.cxx +++ b/dbaccess/source/ui/browser/sbagrid.cxx @@ -982,7 +982,7 @@ bool SbaGridControl::IsReadOnlyDB() const if (xColumns.is()) { Reference< XRowSet > xDataSource(xColumns->getParent(), UNO_QUERY); - ::dbtools::ensureRowSetConnection( xDataSource, getContext(), false ); // NOT SURE ABOUT FALSE + ::dbtools::ensureRowSetConnection( xDataSource, getContext() ); Reference< XChild > xConn(::dbtools::getConnection(xDataSource),UNO_QUERY); if (xConn.is()) { diff --git a/dbaccess/source/ui/misc/DExport.cxx b/dbaccess/source/ui/misc/DExport.cxx index 6b5493a39ec1..d83f0f74ff85 100644 --- a/dbaccess/source/ui/misc/DExport.cxx +++ b/dbaccess/source/ui/misc/DExport.cxx @@ -803,7 +803,7 @@ Reference< XPreparedStatement > ODatabaseExport::createPreparedStatment( const R ,const Reference<XPropertySet>& _xDestTable ,const TPositions& _rvColumns) { - OUString sComposedTableName = ::dbtools::composeTableName( _xMetaData, _xDestTable, ::dbtools::EComposeRule::InDataManipulation, false, false, true ); + OUString sComposedTableName = ::dbtools::composeTableName( _xMetaData, _xDestTable, ::dbtools::EComposeRule::InDataManipulation, true ); OUString aSql = "INSERT INTO " + sComposedTableName diff --git a/dbaccess/source/ui/misc/WCopyTable.cxx b/dbaccess/source/ui/misc/WCopyTable.cxx index 355c19bbd40d..abc1205d998b 100644 --- a/dbaccess/source/ui/misc/WCopyTable.cxx +++ b/dbaccess/source/ui/misc/WCopyTable.cxx @@ -114,7 +114,7 @@ OUString ObjectCopySource::getQualifiedObjectName() const OUString sName; if ( !m_xObjectPSI->hasPropertyByName( PROPERTY_COMMAND ) ) - sName = ::dbtools::composeTableName( m_xMetaData, m_xObject, ::dbtools::EComposeRule::InDataManipulation, false, false, false ); + sName = ::dbtools::composeTableName( m_xMetaData, m_xObject, ::dbtools::EComposeRule::InDataManipulation, false ); else m_xObject->getPropertyValue( PROPERTY_NAME ) >>= sName; return sName; @@ -1239,7 +1239,7 @@ Reference< XPropertySet > OCopyTableWizard::createTable() else { OUString sComposedName( - ::dbtools::composeTableName( m_xDestConnection->getMetaData(), xTable, ::dbtools::EComposeRule::InDataManipulation, false, false, false ) ); + ::dbtools::composeTableName( m_xDestConnection->getMetaData(), xTable, ::dbtools::EComposeRule::InDataManipulation, false ) ); if(xTables->hasByName(sComposedName)) { xTables->getByName(sComposedName) >>= xTable; diff --git a/dbaccess/source/ui/querydesign/QueryDesignView.cxx b/dbaccess/source/ui/querydesign/QueryDesignView.cxx index 87e18ae5d924..b3e71892e671 100644 --- a/dbaccess/source/ui/querydesign/QueryDesignView.cxx +++ b/dbaccess/source/ui/querydesign/QueryDesignView.cxx @@ -1973,7 +1973,7 @@ namespace OSL_VERIFY( xTableProps->getPropertyValue( PROPERTY_NAME ) >>= sComposedName ); else { - sComposedName = ::dbtools::composeTableName( xMetaData, xTableProps, ::dbtools::EComposeRule::InDataManipulation, false, false, false ); + sComposedName = ::dbtools::composeTableName( xMetaData, xTableProps, ::dbtools::EComposeRule::InDataManipulation, false ); // if the alias is the complete (composed) table, then shorten it if ( aKeyComp( sComposedName, aIter->first ) ) diff --git a/dbaccess/source/ui/querydesign/querycontroller.cxx b/dbaccess/source/ui/querydesign/querycontroller.cxx index 1375ac8ba17a..ea6e5777297f 100644 --- a/dbaccess/source/ui/querydesign/querycontroller.cxx +++ b/dbaccess/source/ui/querydesign/querycontroller.cxx @@ -1489,7 +1489,7 @@ bool OQueryController::doSaveAsDoc(bool _bSaveAs) xViewProps.set( xElements->getByName( m_sName ), UNO_QUERY ); if ( !xViewProps.is() ) // correct name and try again - m_sName = ::dbtools::composeTableName( getMetaData(), xQuery, ::dbtools::EComposeRule::InDataManipulation, false, false, false ); + m_sName = ::dbtools::composeTableName( getMetaData(), xQuery, ::dbtools::EComposeRule::InDataManipulation, false ); OSL_ENSURE( xElements->hasByName( m_sName ), "OQueryController::doSaveAsDoc: newly created view does not exist!" ); diff --git a/dbaccess/source/ui/relationdesign/RelationController.cxx b/dbaccess/source/ui/relationdesign/RelationController.cxx index 2197c4654bc8..bfba6567223a 100644 --- a/dbaccess/source/ui/relationdesign/RelationController.cxx +++ b/dbaccess/source/ui/relationdesign/RelationController.cxx @@ -353,7 +353,7 @@ namespace void RelationLoader::loadTableData(const Any& _aTable) { Reference<XPropertySet> xTableProp(_aTable,UNO_QUERY); - const OUString sSourceName = ::dbtools::composeTableName( m_xMetaData, xTableProp, ::dbtools::EComposeRule::InTableDefinitions, false, false, false ); + const OUString sSourceName = ::dbtools::composeTableName( m_xMetaData, xTableProp, ::dbtools::EComposeRule::InTableDefinitions, false ); TTableDataHelper::const_iterator aFind = m_aTableData.find(sSourceName); if ( aFind == m_aTableData.end() ) { diff --git a/dbaccess/source/ui/tabledesign/TableController.cxx b/dbaccess/source/ui/tabledesign/TableController.cxx index 3fd564ab50bf..6f0ec5edb670 100644 --- a/dbaccess/source/ui/tabledesign/TableController.cxx +++ b/dbaccess/source/ui/tabledesign/TableController.cxx @@ -367,7 +367,7 @@ bool OTableController::doSaveDoc(bool _bSaveAs) if(!m_xTable.is()) // correct name and try again { // it can be that someone inserted new data for us - m_sName = ::dbtools::composeTableName( getConnection()->getMetaData(), xTable, ::dbtools::EComposeRule::InDataManipulation, false, false, false ); + m_sName = ::dbtools::composeTableName( getConnection()->getMetaData(), xTable, ::dbtools::EComposeRule::InDataManipulation, false ); assignTable(); } // now check if our datasource has set a tablefilter and if append the new table name to it @@ -1483,7 +1483,7 @@ OUString OTableController::getPrivateTitle() const if ( !m_sName.isEmpty() && getConnection().is() ) { if ( m_xTable.is() ) - sTitle = ::dbtools::composeTableName( getConnection()->getMetaData(), m_xTable, ::dbtools::EComposeRule::InDataManipulation, false, false, false ); + sTitle = ::dbtools::composeTableName( getConnection()->getMetaData(), m_xTable, ::dbtools::EComposeRule::InDataManipulation, false ); else sTitle = m_sName; } diff --git a/dbaccess/source/ui/uno/copytablewizard.cxx b/dbaccess/source/ui/uno/copytablewizard.cxx index d95deabafc01..a1b141a919ba 100644 --- a/dbaccess/source/ui/uno/copytablewizard.cxx +++ b/dbaccess/source/ui/uno/copytablewizard.cxx @@ -1444,7 +1444,7 @@ OUString CopyTableWizard::impl_getServerSideCopyStatement_throw(const Reference< sColumns.append(sQuote + aDestColumnNames[aPosIter->second - 1] + sQuote); } } - const OUString sComposedTableName = ::dbtools::composeTableName( xDestMetaData, _xTable, ::dbtools::EComposeRule::InDataManipulation, false, false, true ); + const OUString sComposedTableName = ::dbtools::composeTableName( xDestMetaData, _xTable, ::dbtools::EComposeRule::InDataManipulation, true ); OUString sSql("INSERT INTO " + sComposedTableName + " ( " + sColumns.makeStringAndClear() + " ) ( " + m_pSourceObject->getSelectStatement() + " )"); return sSql; diff --git a/extensions/source/dbpilots/controlwizard.cxx b/extensions/source/dbpilots/controlwizard.cxx index 5f14c6760b39..496b52dd0e58 100644 --- a/extensions/source/dbpilots/controlwizard.cxx +++ b/extensions/source/dbpilots/controlwizard.cxx @@ -522,7 +522,7 @@ namespace dbp Reference< XConnection > xConnection; m_aContext.bEmbedded = ::dbtools::isEmbeddedInDatabase( m_aContext.xForm, xConnection ); if ( !m_aContext.bEmbedded ) - xConnection = ::dbtools::connectRowset( m_aContext.xRowSet, m_xContext, true ); + xConnection = ::dbtools::connectRowset( m_aContext.xRowSet, m_xContext ); // get the fields if (xConnection.is()) diff --git a/extensions/source/propctrlr/formcomponenthandler.cxx b/extensions/source/propctrlr/formcomponenthandler.cxx index 799a1d5545d7..da9ad725451d 100644 --- a/extensions/source/propctrlr/formcomponenthandler.cxx +++ b/extensions/source/propctrlr/formcomponenthandler.cxx @@ -2359,7 +2359,7 @@ namespace pcr if ( xRowSetProps.is() ) { WaitCursor aWaitCursor( impl_getDefaultDialogParent_nothrow() ); - m_xRowSetConnection = ::dbtools::ensureRowSetConnection( xRowSet, m_xContext, false ); + m_xRowSetConnection = ::dbtools::ensureRowSetConnection( xRowSet, m_xContext ); } } catch ( const SQLException& ) { aError = SQLExceptionInfo( ::cppu::getCaughtException() ); } diff --git a/extensions/source/propctrlr/formlinkdialog.cxx b/extensions/source/propctrlr/formlinkdialog.cxx index 7ee0a03ed111..2d332470449f 100644 --- a/extensions/source/propctrlr/formlinkdialog.cxx +++ b/extensions/source/propctrlr/formlinkdialog.cxx @@ -471,7 +471,7 @@ namespace pcr _rxConnection.set(_rxFormProps->getPropertyValue(PROPERTY_ACTIVE_CONNECTION),UNO_QUERY); if ( !_rxConnection.is() ) - _rxConnection = ::dbtools::connectRowset( Reference< XRowSet >( _rxFormProps, UNO_QUERY ), m_xContext, true ); + _rxConnection = ::dbtools::connectRowset( Reference< XRowSet >( _rxFormProps, UNO_QUERY ), m_xContext ); } diff --git a/forms/source/component/DatabaseForm.cxx b/forms/source/component/DatabaseForm.cxx index 9112c9e3ad40..5f8fe4d15c88 100644 --- a/forms/source/component/DatabaseForm.cxx +++ b/forms/source/component/DatabaseForm.cxx @@ -2788,8 +2788,7 @@ bool ODatabaseForm::implEnsureConnection() { Reference< XConnection > xConnection = connectRowset( Reference<XRowSet> (m_xAggregate, UNO_QUERY), - m_xContext, - true // set a calculated connection as ActiveConnection + m_xContext ); return xConnection.is(); } diff --git a/include/connectivity/dbconversion.hxx b/include/connectivity/dbconversion.hxx index 2e67931cb3ad..270aea7b86da 100644 --- a/include/connectivity/dbconversion.hxx +++ b/include/connectivity/dbconversion.hxx @@ -135,7 +135,7 @@ namespace dbtools // return the DateTime in the format %04d-%02d-%02d %02d:%02d:%02d.%09d OOO_DLLPUBLIC_DBTOOLS OUString toDateTimeString(const css::util::DateTime& _rDateTime); // return the any in an sql standard format - OOO_DLLPUBLIC_DBTOOLS OUString toSQLString(sal_Int32 eType, const css::uno::Any& _rVal, bool bQuote, + OOO_DLLPUBLIC_DBTOOLS OUString toSQLString(sal_Int32 eType, const css::uno::Any& _rVal, const css::uno::Reference< css::script::XTypeConverter >& _rxTypeConverter); /** converts a Unicode string into a 8-bit string, using the given encoding diff --git a/include/connectivity/dbexception.hxx b/include/connectivity/dbexception.hxx index 0742d5b69224..16c499954ad2 100644 --- a/include/connectivity/dbexception.hxx +++ b/include/connectivity/dbexception.hxx @@ -310,8 +310,7 @@ OOO_DLLPUBLIC_DBTOOLS void throwSQLException( const OUString& _rMessage, const OUString& _rSQLState, const css::uno::Reference< css::uno::XInterface >& _rxContext, - const sal_Int32 _nErrorCode = 0, - const css::uno::Any* _pNextException = nullptr + const sal_Int32 _nErrorCode = 0 ); diff --git a/include/connectivity/dbtools.hxx b/include/connectivity/dbtools.hxx index e0bf5ca8f022..885cf82e50b9 100644 --- a/include/connectivity/dbtools.hxx +++ b/include/connectivity/dbtools.hxx @@ -127,28 +127,27 @@ namespace dbtools retrieved from the driver manager. </nl> + The calculated connection is set as ActiveConnection property on the rowset. + + If the connection was newly created by the method, then + the ownership of the connection is delivered to a temporary object, which observes the + row set: As soon as a connection-relevant property of the row set changes, or as soon + as somebody else sets another ActiveConnection at the row set, the original + connection (the one which this function calculated) is disposed and discarded. At this + very moment, also the temporary observer object dies. This way, it is ensured that + there's no resource leak from an un-owned connection object. + @param _rxRowSet the row set @param _rxFactory a service factory, which can be used to create data sources, interaction handler etc (the usual stuff) - @param _bSetAsActiveConnection - If <TRUE/>, the calculated connection is set as ActiveConnection property on the rowset. - - If the connection was newly created by the method, and this parameter is <TRUE/>, then - the ownership of the connection is delivered to a temporary object, which observes the - row set: As soon as a connection-relevant property of the row set changes, or as soon - as somebody else sets another ActiveConnection at the row set, the original - connection (the one which this function calculated) is disposed and discarded. At this - very moment, also the temporary observer object dies. This way, it is ensured that - there's no resource leak from an un-owned connection object. */ OOO_DLLPUBLIC_DBTOOLS css::uno::Reference< css::sdbc::XConnection> connectRowset( const css::uno::Reference< css::sdbc::XRowSet>& _rxRowSet, - const css::uno::Reference< css::uno::XComponentContext>& _rxContext, - bool _bSetAsActiveConnection + const css::uno::Reference< css::uno::XComponentContext>& _rxContext ); /** ensures that a row set has a valid ActiveConnection, if possible @@ -163,21 +162,15 @@ namespace dbtools <ul><li>If the connection was not newly created, the returned ->SharedConnection instance will not have the ownership, since in this case it's assumed that there already is an instance which has the ownership.</li> - <li>If the connection was newly created, and ->_bUseAutoConnectionDisposer - is <TRUE/>, then the returned SharedConnection instance will <em>not</em> - be the owner of the connection. Instead, the ownership will be delivered - to a temporary object as described for connectRowset.</li> - <li>If the connection was newly created, and ->_bUseAutoConnectionDisposer - is <FALSE/>, then the returned SharedConnection instance will have the - ownership of the XConnection.</li> + <li>If the connection was newly created, then the returned SharedConnection + instance will have the ownership of the XConnection.</li> </ul> </li> </ul> */ OOO_DLLPUBLIC_DBTOOLS SharedConnection ensureRowSetConnection( const css::uno::Reference< css::sdbc::XRowSet>& _rxRowSet, - const css::uno::Reference< css::uno::XComponentContext>& _rxContext, - bool _bUseAutoConnectionDisposer + const css::uno::Reference< css::uno::XComponentContext>& _rxContext ); /** returns the connection the RowSet is currently working with (which is the ActiveConnection property) @@ -482,8 +475,6 @@ namespace dbtools const css::uno::Reference< css::sdbc::XDatabaseMetaData>& _xMetaData, const css::uno::Reference< css::beans::XPropertySet>& _xTable, EComposeRule _eComposeRule, - bool _bSuppressCatalogName, - bool _bSuppressSchemaName, bool _bQuote); @@ -794,13 +785,10 @@ namespace dbtools a query composer that knows the field by name @param _xField the field - @param whenNotFound - value returned when _sName is not known by _xComposer */ OOO_DLLPUBLIC_DBTOOLS bool isAggregateColumn( const css::uno::Reference< css::sdb::XSingleSelectQueryComposer > &_xComposer, - const css::uno::Reference< css::beans::XPropertySet > &_xField, - bool whenNotFound = false + const css::uno::Reference< css::beans::XPropertySet > &_xField ); /** is this column an aggregate? diff --git a/svx/source/form/tabwin.cxx b/svx/source/form/tabwin.cxx index a7258b6bd459..3f3a99fc0efb 100644 --- a/svx/source/form/tabwin.cxx +++ b/svx/source/form/tabwin.cxx @@ -313,7 +313,7 @@ void FmFieldWin::UpdateContent(const css::uno::Reference< css::form::XForm > & x // get the connection of the form m_aConnection.reset( - connectRowset( Reference< XRowSet >( xForm, UNO_QUERY ), ::comphelper::getProcessComponentContext(), true ), + connectRowset( Reference< XRowSet >( xForm, UNO_QUERY ), ::comphelper::getProcessComponentContext() ), SharedConnection::NoTakeOwnership ); // TODO: When incompatible changes (such as extending the "virtualdbtools" interface by ensureRowSetConnection) |