Kaydet (Commit) 53d6326b authored tarafından Noel Grandin's avatar Noel Grandin

loplugin:useuniqueptr in DataSupplier_Impl

Change-Id: Iaa25aee42d59b481a6b6edf015fe57dbd81cfa3e
Reviewed-on: https://gerrit.libreoffice.org/48706Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst af3bd4b7
...@@ -45,7 +45,7 @@ namespace tdoc_ucp ...@@ -45,7 +45,7 @@ namespace tdoc_ucp
struct ResultListEntry struct ResultListEntry
{ {
OUString aURL; OUString aURL;
uno::Reference< ucb::XContentIdentifier > xId; uno::Reference< ucb::XContentIdentifier > xId;
uno::Reference< ucb::XContent > xContent; uno::Reference< ucb::XContent > xContent;
uno::Reference< sdbc::XRow > xRow; uno::Reference< sdbc::XRow > xRow;
...@@ -54,22 +54,16 @@ struct ResultListEntry ...@@ -54,22 +54,16 @@ struct ResultListEntry
}; };
// ResultList.
typedef std::vector< ResultListEntry* > ResultList;
// struct DataSupplier_Impl. // struct DataSupplier_Impl.
struct DataSupplier_Impl struct DataSupplier_Impl
{ {
osl::Mutex m_aMutex; osl::Mutex m_aMutex;
ResultList m_aResults; std::vector< ResultListEntry > m_aResults;
rtl::Reference< Content > m_xContent; rtl::Reference< Content > m_xContent;
uno::Reference< uno::XComponentContext > m_xContext; uno::Reference< uno::XComponentContext > m_xContext;
uno::Sequence< OUString > * m_pNamesOfChildren; std::unique_ptr<uno::Sequence< OUString > > m_pNamesOfChildren;
bool m_bCountFinal; bool m_bCountFinal;
bool m_bThrowException; bool m_bThrowException;
...@@ -77,27 +71,11 @@ struct DataSupplier_Impl ...@@ -77,27 +71,11 @@ struct DataSupplier_Impl
const uno::Reference< uno::XComponentContext >& rxContext, const uno::Reference< uno::XComponentContext >& rxContext,
const rtl::Reference< Content >& rContent ) const rtl::Reference< Content >& rContent )
: m_xContent( rContent ), m_xContext( rxContext ), : m_xContent( rContent ), m_xContext( rxContext ),
m_pNamesOfChildren( nullptr ),
m_bCountFinal( false ), m_bThrowException( false ) m_bCountFinal( false ), m_bThrowException( false )
{} {}
~DataSupplier_Impl();
}; };
DataSupplier_Impl::~DataSupplier_Impl()
{
ResultList::const_iterator it = m_aResults.begin();
ResultList::const_iterator end = m_aResults.end();
while ( it != end )
{
delete *it;
++it;
}
delete m_pNamesOfChildren;
}
} }
// DataSupplier Implementation. // DataSupplier Implementation.
...@@ -121,7 +99,7 @@ ResultSetDataSupplier::queryContentIdentifierString( sal_uInt32 nIndex ) ...@@ -121,7 +99,7 @@ ResultSetDataSupplier::queryContentIdentifierString( sal_uInt32 nIndex )
if ( nIndex < m_pImpl->m_aResults.size() ) if ( nIndex < m_pImpl->m_aResults.size() )
{ {
OUString aId = m_pImpl->m_aResults[ nIndex ]->aURL; OUString aId = m_pImpl->m_aResults[ nIndex ].aURL;
if ( !aId.isEmpty() ) if ( !aId.isEmpty() )
{ {
// Already cached. // Already cached.
...@@ -132,7 +110,7 @@ ResultSetDataSupplier::queryContentIdentifierString( sal_uInt32 nIndex ) ...@@ -132,7 +110,7 @@ ResultSetDataSupplier::queryContentIdentifierString( sal_uInt32 nIndex )
if ( getResult( nIndex ) ) if ( getResult( nIndex ) )
{ {
// Note: getResult fills m_pImpl->m_aResults[ nIndex ]->aURL. // Note: getResult fills m_pImpl->m_aResults[ nIndex ]->aURL.
return m_pImpl->m_aResults[ nIndex ]->aURL; return m_pImpl->m_aResults[ nIndex ].aURL;
} }
return OUString(); return OUString();
} }
...@@ -146,7 +124,7 @@ ResultSetDataSupplier::queryContentIdentifier( sal_uInt32 nIndex ) ...@@ -146,7 +124,7 @@ ResultSetDataSupplier::queryContentIdentifier( sal_uInt32 nIndex )
if ( nIndex < m_pImpl->m_aResults.size() ) if ( nIndex < m_pImpl->m_aResults.size() )
{ {
uno::Reference< ucb::XContentIdentifier > xId uno::Reference< ucb::XContentIdentifier > xId
= m_pImpl->m_aResults[ nIndex ]->xId; = m_pImpl->m_aResults[ nIndex ].xId;
if ( xId.is() ) if ( xId.is() )
{ {
// Already cached. // Already cached.
...@@ -159,7 +137,7 @@ ResultSetDataSupplier::queryContentIdentifier( sal_uInt32 nIndex ) ...@@ -159,7 +137,7 @@ ResultSetDataSupplier::queryContentIdentifier( sal_uInt32 nIndex )
{ {
uno::Reference< ucb::XContentIdentifier > xId uno::Reference< ucb::XContentIdentifier > xId
= new ::ucbhelper::ContentIdentifier( aId ); = new ::ucbhelper::ContentIdentifier( aId );
m_pImpl->m_aResults[ nIndex ]->xId = xId; m_pImpl->m_aResults[ nIndex ].xId = xId;
return xId; return xId;
} }
return uno::Reference< ucb::XContentIdentifier >(); return uno::Reference< ucb::XContentIdentifier >();
...@@ -174,7 +152,7 @@ ResultSetDataSupplier::queryContent( sal_uInt32 nIndex ) ...@@ -174,7 +152,7 @@ ResultSetDataSupplier::queryContent( sal_uInt32 nIndex )
if ( nIndex < m_pImpl->m_aResults.size() ) if ( nIndex < m_pImpl->m_aResults.size() )
{ {
uno::Reference< ucb::XContent > xContent uno::Reference< ucb::XContent > xContent
= m_pImpl->m_aResults[ nIndex ]->xContent; = m_pImpl->m_aResults[ nIndex ].xContent;
if ( xContent.is() ) if ( xContent.is() )
{ {
// Already cached. // Already cached.
...@@ -190,7 +168,7 @@ ResultSetDataSupplier::queryContent( sal_uInt32 nIndex ) ...@@ -190,7 +168,7 @@ ResultSetDataSupplier::queryContent( sal_uInt32 nIndex )
{ {
uno::Reference< ucb::XContent > xContent uno::Reference< ucb::XContent > xContent
= m_pImpl->m_xContent->getProvider()->queryContent( xId ); = m_pImpl->m_xContent->getProvider()->queryContent( xId );
m_pImpl->m_aResults[ nIndex ]->xContent = xContent; m_pImpl->m_aResults[ nIndex ].xContent = xContent;
return xContent; return xContent;
} }
...@@ -241,7 +219,7 @@ bool ResultSetDataSupplier::getResult( sal_uInt32 nIndex ) ...@@ -241,7 +219,7 @@ bool ResultSetDataSupplier::getResult( sal_uInt32 nIndex )
// Assemble URL for child. // Assemble URL for child.
OUString aURL = assembleChildURL( rName ); OUString aURL = assembleChildURL( rName );
m_pImpl->m_aResults.push_back( new ResultListEntry( aURL ) ); m_pImpl->m_aResults.emplace_back( aURL );
if ( n == nIndex ) if ( n == nIndex )
{ {
...@@ -300,7 +278,7 @@ sal_uInt32 ResultSetDataSupplier::totalCount() ...@@ -300,7 +278,7 @@ sal_uInt32 ResultSetDataSupplier::totalCount()
// Assemble URL for child. // Assemble URL for child.
OUString aURL = assembleChildURL( rName ); OUString aURL = assembleChildURL( rName );
m_pImpl->m_aResults.push_back( new ResultListEntry( aURL ) ); m_pImpl->m_aResults.emplace_back( aURL );
} }
} }
...@@ -341,7 +319,7 @@ ResultSetDataSupplier::queryPropertyValues( sal_uInt32 nIndex ) ...@@ -341,7 +319,7 @@ ResultSetDataSupplier::queryPropertyValues( sal_uInt32 nIndex )
if ( nIndex < m_pImpl->m_aResults.size() ) if ( nIndex < m_pImpl->m_aResults.size() )
{ {
uno::Reference< sdbc::XRow > xRow = m_pImpl->m_aResults[ nIndex ]->xRow; uno::Reference< sdbc::XRow > xRow = m_pImpl->m_aResults[ nIndex ].xRow;
if ( xRow.is() ) if ( xRow.is() )
{ {
// Already cached. // Already cached.
...@@ -356,7 +334,7 @@ ResultSetDataSupplier::queryPropertyValues( sal_uInt32 nIndex ) ...@@ -356,7 +334,7 @@ ResultSetDataSupplier::queryPropertyValues( sal_uInt32 nIndex )
getResultSet()->getProperties(), getResultSet()->getProperties(),
m_pImpl->m_xContent->getContentProvider().get(), m_pImpl->m_xContent->getContentProvider().get(),
queryContentIdentifierString( nIndex ) ); queryContentIdentifierString( nIndex ) );
m_pImpl->m_aResults[ nIndex ]->xRow = xRow; m_pImpl->m_aResults[ nIndex ].xRow = xRow;
return xRow; return xRow;
} }
...@@ -369,7 +347,7 @@ void ResultSetDataSupplier::releasePropertyValues( sal_uInt32 nIndex ) ...@@ -369,7 +347,7 @@ void ResultSetDataSupplier::releasePropertyValues( sal_uInt32 nIndex )
osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex ); osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
if ( nIndex < m_pImpl->m_aResults.size() ) if ( nIndex < m_pImpl->m_aResults.size() )
m_pImpl->m_aResults[ nIndex ]->xRow.clear(); m_pImpl->m_aResults[ nIndex ].xRow.clear();
} }
// virtual // virtual
...@@ -390,21 +368,20 @@ bool ResultSetDataSupplier::queryNamesOfChildren() ...@@ -390,21 +368,20 @@ bool ResultSetDataSupplier::queryNamesOfChildren()
if ( m_pImpl->m_pNamesOfChildren == nullptr ) if ( m_pImpl->m_pNamesOfChildren == nullptr )
{ {
uno::Sequence< OUString > * pNamesOfChildren std::unique_ptr<uno::Sequence< OUString >> pNamesOfChildren(
= new uno::Sequence< OUString >(); new uno::Sequence< OUString >() );
if ( !m_pImpl->m_xContent->getContentProvider()->queryNamesOfChildren( if ( !m_pImpl->m_xContent->getContentProvider()->queryNamesOfChildren(
m_pImpl->m_xContent->getIdentifier()->getContentIdentifier(), m_pImpl->m_xContent->getIdentifier()->getContentIdentifier(),
*pNamesOfChildren ) ) *pNamesOfChildren ) )
{ {
OSL_FAIL( "Got no list of children!" ); OSL_FAIL( "Got no list of children!" );
delete pNamesOfChildren;
m_pImpl->m_bThrowException = true; m_pImpl->m_bThrowException = true;
return false; return false;
} }
else else
{ {
m_pImpl->m_pNamesOfChildren = pNamesOfChildren; m_pImpl->m_pNamesOfChildren = std::move( pNamesOfChildren );
} }
} }
return true; return true;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment