tdf#120703 PVS: V547 Expression is always false
Let FSStorage::GetContent() return reference.
Change-Id: I6595f48d56f7eb9256600eb6ee1a569077fef92f
Reviewed-on: https://gerrit.libreoffice.org/62823
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
diff --git a/svl/source/fsstor/fsstorage.cxx b/svl/source/fsstor/fsstorage.cxx
index 360083c..32f88f6 100644
--- a/svl/source/fsstor/fsstorage.cxx
+++ b/svl/source/fsstor/fsstorage.cxx
@@ -132,10 +132,10 @@
return false;
}
::ucbhelper::Content* FSStorage::GetContent()
ucbhelper::Content& FSStorage::GetContent()
{
::osl::MutexGuard aGuard( m_aMutex );
return &m_pImpl->m_aContent;
return m_pImpl->m_aContent;
}
void FSStorage::CopyStreamToSubStream( const OUString& aSourceURL,
@@ -166,11 +166,9 @@
xDestOutput->closeOutput();
}
void FSStorage::CopyContentToStorage_Impl( ::ucbhelper::Content* pContent, const uno::Reference< embed::XStorage >& xDest )
void FSStorage::CopyContentToStorage_Impl(ucbhelper::Content& rContent,
const uno::Reference<embed::XStorage>& xDest)
{
if ( !pContent )
throw uno::RuntimeException();
// get list of contents of the Content
// create cursor for access to children
uno::Sequence< OUString > aProps( 2 );
@@ -180,7 +178,8 @@
try
{
uno::Reference< sdbc::XResultSet > xResultSet = pContent->createCursor( aProps, ::ucbhelper::INCLUDE_FOLDERS_AND_DOCUMENTS );
uno::Reference<sdbc::XResultSet> xResultSet
= rContent.createCursor(aProps, ::ucbhelper::INCLUDE_FOLDERS_AND_DOCUMENTS);
uno::Reference< sdbc::XRow > xRow( xResultSet, uno::UNO_QUERY );
if ( xResultSet.is() )
{
@@ -203,7 +202,7 @@
uno::Reference< ucb::XCommandEnvironment > xDummyEnv;
::ucbhelper::Content aSourceContent( aSourceURL, xDummyEnv, comphelper::getProcessComponentContext() );
CopyContentToStorage_Impl( &aSourceContent, xSubStorage );
CopyContentToStorage_Impl( aSourceContent, xSubStorage );
}
else
{
@@ -294,9 +293,6 @@
if ( !xDest.is() || xDest == uno::Reference< uno::XInterface >( static_cast< OWeakObject*> ( this ), uno::UNO_QUERY ) )
throw lang::IllegalArgumentException(); // TODO:
if ( !GetContent() )
throw io::IOException(); // TODO: error handling
try
{
CopyContentToStorage_Impl( GetContent(), xDest );
@@ -338,9 +334,6 @@
if ( !m_pImpl )
throw lang::DisposedException();
if ( !GetContent() )
throw io::IOException(); // TODO: error handling
// TODO/LATER: may need possibility to create folder if it was removed, since the folder can not be locked
INetURLObject aFileURL( m_pImpl->m_aURL );
aFileURL.Append( aStreamName );
@@ -445,9 +438,6 @@
if ( !m_pImpl )
throw lang::DisposedException();
if ( !GetContent() )
throw io::IOException(); // TODO: error handling
if ( ( nStorageMode & embed::ElementModes::WRITE )
&& !( m_pImpl->m_nMode & embed::ElementModes::WRITE ) )
throw io::IOException(); // TODO: error handling
@@ -531,9 +521,6 @@
if ( !m_pImpl )
throw lang::DisposedException();
if ( !GetContent() )
throw io::IOException(); // TODO: error handling
// TODO/LATER: may need possibility to create folder if it was removed, since the folder can not be locked
INetURLObject aFileURL( m_pImpl->m_aURL );
aFileURL.Append( aStreamName );
@@ -624,9 +611,6 @@
if ( !m_pImpl )
throw lang::DisposedException();
if ( !GetContent() )
throw embed::InvalidStorageException(); // TODO: error handling
INetURLObject aURL( m_pImpl->m_aURL );
aURL.Append( aElementName );
@@ -640,9 +624,6 @@
if ( !m_pImpl )
throw lang::DisposedException();
if ( !GetContent() )
throw embed::InvalidStorageException(); // TODO: error handling
INetURLObject aURL( m_pImpl->m_aURL );
aURL.Append( aElementName );
@@ -656,9 +637,6 @@
if ( !m_pImpl )
throw lang::DisposedException();
if ( !GetContent() )
throw io::IOException(); // TODO: error handling
INetURLObject aURL( m_pImpl->m_aURL );
aURL.Append( aElementName );
@@ -676,9 +654,6 @@
if ( !m_pImpl )
throw lang::DisposedException();
if ( !GetContent() )
throw io::IOException(); // TODO: error handling
INetURLObject aOldURL( m_pImpl->m_aURL );
aOldURL.Append( aElementName );
@@ -698,10 +673,8 @@
uno::Reference< ucb::XCommandEnvironment > xDummyEnv;
::ucbhelper::Content aSourceContent( aOldURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ), xDummyEnv, comphelper::getProcessComponentContext() );
GetContent()->transferContent( aSourceContent,
::ucbhelper::InsertOperation::Move,
aNewName,
ucb::NameClash::ERROR );
GetContent().transferContent(aSourceContent, ::ucbhelper::InsertOperation::Move, aNewName,
ucb::NameClash::ERROR);
}
catch( embed::InvalidStorageException& )
{
@@ -752,9 +725,6 @@
if ( !xDest.is() )
throw uno::RuntimeException();
if ( !GetContent() )
throw io::IOException(); // TODO: error handling
INetURLObject aOwnURL( m_pImpl->m_aURL );
aOwnURL.Append( aElementName );
@@ -771,7 +741,7 @@
xDest->openStorageElement( aNewName, embed::ElementModes::READWRITE ),
uno::UNO_QUERY_THROW );
CopyContentToStorage_Impl( &aSourceContent, xDestSubStor );
CopyContentToStorage_Impl( aSourceContent, xDestSubStor );
}
else if ( ::utl::UCBContentHelper::IsDocument( aOwnURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ) ) )
{
@@ -845,9 +815,6 @@
uno::Any aResult;
try
{
if ( !GetContent() )
throw io::IOException(); // TODO: error handling
INetURLObject aURL( m_pImpl->m_aURL );
aURL.Append( aName );
@@ -898,13 +865,11 @@
try
{
if ( !GetContent() )
throw io::IOException(); // TODO: error handling
uno::Sequence<OUString> aProps { "Title" };
sal_Int32 nSize = 0;
uno::Reference< sdbc::XResultSet > xResultSet = GetContent()->createCursor( aProps, ::ucbhelper::INCLUDE_FOLDERS_AND_DOCUMENTS );
uno::Reference<sdbc::XResultSet> xResultSet
= GetContent().createCursor(aProps, ::ucbhelper::INCLUDE_FOLDERS_AND_DOCUMENTS);
uno::Reference< sdbc::XRow > xRow( xResultSet, uno::UNO_QUERY );
if ( xResultSet.is() )
{
@@ -951,25 +916,8 @@
if ( !m_pImpl )
throw lang::DisposedException();
try
{
if ( !GetContent() )
throw io::IOException(); // TODO: error handling
if ( aName.isEmpty() )
throw lang::IllegalArgumentException();
}
catch( uno::RuntimeException& )
{
throw;
}
catch ( uno::Exception& )
{
uno::Any aCaught( ::cppu::getCaughtException() );
throw lang::WrappedTargetRuntimeException( "Can not open storage!",
static_cast< OWeakObject* >( this ),
aCaught );
}
if ( aName.isEmpty() )
throw lang::IllegalArgumentException();
INetURLObject aURL( m_pImpl->m_aURL );
aURL.Append( aName );
@@ -998,12 +946,10 @@
try
{
if ( !GetContent() )
throw io::IOException(); // TODO: error handling
uno::Sequence<OUString> aProps { "TargetURL" };
uno::Reference< sdbc::XResultSet > xResultSet = GetContent()->createCursor( aProps, ::ucbhelper::INCLUDE_FOLDERS_AND_DOCUMENTS );
uno::Reference<sdbc::XResultSet> xResultSet
= GetContent().createCursor(aProps, ::ucbhelper::INCLUDE_FOLDERS_AND_DOCUMENTS);
return ( xResultSet.is() && xResultSet->next() );
}
catch (const uno::RuntimeException&)
@@ -1167,9 +1113,6 @@
if ( sStreamPath.toChar() == '/' )
throw lang::IllegalArgumentException();
if ( !GetContent() )
throw io::IOException(); // TODO: error handling
INetURLObject aBaseURL( m_pImpl->m_aURL );
if ( !aBaseURL.setFinalSlash() )
throw uno::RuntimeException();
@@ -1283,9 +1226,6 @@
if ( !m_pImpl )
throw lang::DisposedException();
if ( !GetContent() )
throw io::IOException(); // TODO: error handling
// TODO/LATER: may need possibility to create folder if it was removed, since the folder can not be locked
INetURLObject aBaseURL( m_pImpl->m_aURL );
if ( !aBaseURL.setFinalSlash() )
diff --git a/svl/source/fsstor/fsstorage.hxx b/svl/source/fsstor/fsstorage.hxx
index 18574f2..4db99c0 100644
--- a/svl/source/fsstor/fsstorage.hxx
+++ b/svl/source/fsstor/fsstorage.hxx
@@ -55,14 +55,14 @@
virtual ~FSStorage() override;
::ucbhelper::Content* GetContent();
ucbhelper::Content& GetContent();
static void CopyStreamToSubStream( const OUString& aSourceURL,
const css::uno::Reference< css::embed::XStorage >& xDest,
const OUString& aNewEntryName );
void CopyContentToStorage_Impl( ::ucbhelper::Content* pContent,
const css::uno::Reference< css::embed::XStorage >& xDest );
void CopyContentToStorage_Impl(ucbhelper::Content& rContent,
const css::uno::Reference<css::embed::XStorage>& xDest);
static bool MakeFolderNoUI( const OUString& rFolder );