diff options
Diffstat (limited to 'dbaccess/source/ui/misc/defaultobjectnamecheck.cxx')
-rw-r--r-- | dbaccess/source/ui/misc/defaultobjectnamecheck.cxx | 47 |
1 files changed, 14 insertions, 33 deletions
diff --git a/dbaccess/source/ui/misc/defaultobjectnamecheck.cxx b/dbaccess/source/ui/misc/defaultobjectnamecheck.cxx index 34fac13d18d5..cc44de2bdee0 100644 --- a/dbaccess/source/ui/misc/defaultobjectnamecheck.cxx +++ b/dbaccess/source/ui/misc/defaultobjectnamecheck.cxx @@ -24,7 +24,6 @@ #include <com/sun/star/lang/IllegalArgumentException.hpp> #include <com/sun/star/sdb/CommandType.hpp> -#include <com/sun/star/sdb/tools/XConnectionTools.hpp> #include <com/sun/star/sdbc/SQLException.hpp> #include <connectivity/dbexception.hxx> @@ -32,10 +31,11 @@ #include <rtl/ustrbuf.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <cppuhelper/exc_hlp.hxx> #include <memory> +#include <string_view> namespace dbaui { @@ -46,7 +46,6 @@ namespace dbaui using ::com::sun::star::sdbc::SQLException; using ::com::sun::star::uno::Exception; using ::com::sun::star::sdbc::XConnection; - using ::com::sun::star::sdb::tools::XObjectNames; using ::com::sun::star::sdb::tools::XConnectionTools; using ::com::sun::star::uno::UNO_QUERY; @@ -57,31 +56,22 @@ namespace dbaui // helper namespace { - void lcl_fillNameExistsError( const OUString& _rObjectName, SQLExceptionInfo& _out_rErrorToDisplay ) + void lcl_fillNameExistsError( std::u16string_view _rObjectName, SQLExceptionInfo& _out_rErrorToDisplay ) { - SQLException aError; OUString sErrorMessage = DBA_RES(STR_NAMED_OBJECT_ALREADY_EXISTS); - aError.Message = sErrorMessage.replaceAll("$#$", _rObjectName); + SQLException aError(sErrorMessage.replaceAll("$#$", _rObjectName), {}, {}, 0, {}); _out_rErrorToDisplay = aError; } } - // HierarchicalNameCheck_Impl - struct HierarchicalNameCheck_Impl - { - Reference< XHierarchicalNameAccess > xHierarchicalNames; - OUString sRelativeRoot; - }; - // HierarchicalNameCheck HierarchicalNameCheck::HierarchicalNameCheck( const Reference< XHierarchicalNameAccess >& _rxNames, const OUString& _rRelativeRoot ) - :m_pImpl( new HierarchicalNameCheck_Impl ) { - m_pImpl->xHierarchicalNames = _rxNames; - m_pImpl->sRelativeRoot = _rRelativeRoot; + mxHierarchicalNames = _rxNames; + msRelativeRoot = _rRelativeRoot; - if ( !m_pImpl->xHierarchicalNames.is() ) + if ( !mxHierarchicalNames.is() ) throw IllegalArgumentException(); } @@ -94,15 +84,14 @@ namespace dbaui try { OUStringBuffer aCompleteName; - if ( !m_pImpl->sRelativeRoot.isEmpty() ) + if ( !msRelativeRoot.isEmpty() ) { - aCompleteName.append( m_pImpl->sRelativeRoot ); - aCompleteName.append( "/" ); + aCompleteName.append( msRelativeRoot + "/" ); } aCompleteName.append( _rObjectName ); OUString sCompleteName( aCompleteName.makeStringAndClear() ); - if ( !m_pImpl->xHierarchicalNames->hasByHierarchicalName( sCompleteName ) ) + if ( !mxHierarchicalNames->hasByHierarchicalName( sCompleteName ) ) return true; } catch( const Exception& ) @@ -114,26 +103,18 @@ namespace dbaui return false; } - // DynamicTableOrQueryNameCheck_Impl - struct DynamicTableOrQueryNameCheck_Impl - { - sal_Int32 nCommandType; - Reference< XObjectNames > xObjectNames; - }; - // DynamicTableOrQueryNameCheck DynamicTableOrQueryNameCheck::DynamicTableOrQueryNameCheck( const Reference< XConnection >& _rxSdbLevelConnection, sal_Int32 _nCommandType ) - :m_pImpl( new DynamicTableOrQueryNameCheck_Impl ) { Reference< XConnectionTools > xConnTools( _rxSdbLevelConnection, UNO_QUERY ); if ( xConnTools.is() ) - m_pImpl->xObjectNames.set( xConnTools->getObjectNames() ); - if ( !m_pImpl->xObjectNames.is() ) + mxObjectNames.set( xConnTools->getObjectNames() ); + if ( !mxObjectNames.is() ) throw IllegalArgumentException(); if ( ( _nCommandType != CommandType::QUERY ) && ( _nCommandType != CommandType::TABLE ) ) throw IllegalArgumentException(); - m_pImpl->nCommandType = _nCommandType; + mnCommandType = _nCommandType; } DynamicTableOrQueryNameCheck::~DynamicTableOrQueryNameCheck() @@ -144,7 +125,7 @@ namespace dbaui { try { - m_pImpl->xObjectNames->checkNameForCreate( m_pImpl->nCommandType, _rObjectName ); + mxObjectNames->checkNameForCreate( mnCommandType, _rObjectName ); return true; } catch( const SQLException& ) |