diff options
Diffstat (limited to 'connectivity/source/drivers/postgresql/pq_xkeys.cxx')
-rw-r--r-- | connectivity/source/drivers/postgresql/pq_xkeys.cxx | 41 |
1 files changed, 21 insertions, 20 deletions
diff --git a/connectivity/source/drivers/postgresql/pq_xkeys.cxx b/connectivity/source/drivers/postgresql/pq_xkeys.cxx index 969ce4dd398c..0758be630e04 100644 --- a/connectivity/source/drivers/postgresql/pq_xkeys.cxx +++ b/connectivity/source/drivers/postgresql/pq_xkeys.cxx @@ -39,6 +39,7 @@ #include <string_view> #include <sal/log.hxx> +#include <rtl/ref.hxx> #include <rtl/ustrbuf.hxx> #include <com/sun/star/lang/IndexOutOfBoundsException.hpp> #include <com/sun/star/lang/WrappedTargetRuntimeException.hpp> @@ -48,6 +49,8 @@ #include <com/sun/star/sdbc/KeyRule.hpp> #include <com/sun/star/sdbcx/KeyType.hpp> #include <cppuhelper/exc_hlp.hxx> +#include <o3tl/safeint.hxx> +#include <utility> #include "pq_xkeys.hxx" #include "pq_xkey.hxx" @@ -59,7 +62,7 @@ using osl::MutexGuard; using css::beans::XPropertySet; -using com::sun::star::uno::makeAny; +using com::sun::star::uno::Any; using com::sun::star::uno::UNO_QUERY; using com::sun::star::uno::Reference; @@ -77,11 +80,11 @@ Keys::Keys( const ::rtl::Reference< comphelper::RefCountedMutex > & refMutex, const css::uno::Reference< css::sdbc::XConnection > & origin, ConnectionSettings *pSettings, - const OUString &schemaName, - const OUString &tableName) + OUString schemaName, + OUString tableName) : Container( refMutex, origin, pSettings, getStatics().KEY ), - m_schemaName( schemaName ), - m_tableName( tableName ) + m_schemaName(std::move( schemaName )), + m_tableName(std::move( tableName )) {} Keys::~Keys() @@ -150,37 +153,36 @@ void Keys::refresh() int keyIndex = 0; while( rs->next() ) { - Key * pKey = + rtl::Reference<Key> pKey = new Key( m_xMutex, m_origin, m_pSettings , m_schemaName, m_tableName ); Reference< css::beans::XPropertySet > prop = pKey; pKey->setPropertyValue_NoBroadcast_public( - st.NAME, makeAny( xRow->getString( 1 ) ) ); + st.NAME, Any( xRow->getString( 1 ) ) ); sal_Int32 keyType = string2keytype( xRow->getString(2) ); - pKey->setPropertyValue_NoBroadcast_public( st.TYPE, makeAny( keyType ) ); + pKey->setPropertyValue_NoBroadcast_public( st.TYPE, Any( keyType ) ); pKey->setPropertyValue_NoBroadcast_public( - st.UPDATE_RULE, makeAny( string2keyrule( xRow->getString(3) ) ) ); + st.UPDATE_RULE, Any( string2keyrule( xRow->getString(3) ) ) ); pKey->setPropertyValue_NoBroadcast_public( - st.DELETE_RULE, makeAny( string2keyrule( xRow->getString(4) ) ) ); + st.DELETE_RULE, Any( string2keyrule( xRow->getString(4) ) ) ); pKey->setPropertyValue_NoBroadcast_public( st.PRIVATE_COLUMNS, - makeAny( + Any( convertMappedIntArray2StringArray( mainMap, string2intarray( xRow->getString( 7 ) ) ) ) ); if( css::sdbcx::KeyType::FOREIGN == keyType ) { - OUStringBuffer buf( 128 ); - buf.append( xRow->getString( 6 ) ).append( "." ).append( xRow->getString( 5 ) ); + OUString buf = xRow->getString( 6 ) + "." + xRow->getString( 5 ); pKey->setPropertyValue_NoBroadcast_public( - st.REFERENCED_TABLE, makeAny( buf.makeStringAndClear() ) ); + st.REFERENCED_TABLE, Any( buf ) ); Int2StringMap foreignMap; fillAttnum2attnameMap( foreignMap, m_origin, xRow->getString(6), xRow->getString(5)); pKey->setPropertyValue_NoBroadcast_public( st.PRIVATE_FOREIGN_COLUMNS, - makeAny( + Any( convertMappedIntArray2StringArray( foreignMap, string2intarray( xRow->getString(8) ) ) ) ); @@ -189,7 +191,7 @@ void Keys::refresh() { map[ xRow->getString( 1 ) ] = keyIndex; - m_values.push_back( makeAny( prop ) ); + m_values.push_back( Any( prop ) ); ++keyIndex; } } @@ -226,7 +228,7 @@ void Keys::appendByDescriptor( void Keys::dropByIndex( sal_Int32 index ) { osl::MutexGuard guard( m_xMutex->GetMutex() ); - if( index < 0 || index >= static_cast<sal_Int32>(m_values.size()) ) + if( index < 0 || o3tl::make_unsigned(index) >= m_values.size() ) { throw css::lang::IndexOutOfBoundsException( "TABLES: Index out of range (allowed 0 to " + OUString::number(m_values.size() -1) @@ -262,11 +264,10 @@ Reference< css::container::XIndexAccess > Keys::create( const OUString & schemaName, const OUString & tableName) { - Keys *pKeys = new Keys( refMutex, origin, pSettings, schemaName, tableName ); - Reference< css::container::XIndexAccess > ret = pKeys; + rtl::Reference<Keys> pKeys = new Keys( refMutex, origin, pSettings, schemaName, tableName ); pKeys->refresh(); - return ret; + return pKeys; } KeyDescriptors::KeyDescriptors( |