CopyTo is never passed a null argument
Change-Id: Ie25e61d6795819a9c432d71fdf478b1a4430c06f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166940 Tested-by: Caolán McNamara <caolan.mcnamara@collabora.com> Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
This commit is contained in:
parent
4742808bf2
commit
fe72e20f86
5 changed files with 25 additions and 25 deletions
|
@ -86,7 +86,7 @@ public:
|
|||
virtual SotClipboardFormatId GetFormat() = 0;
|
||||
virtual OUString GetUserName() = 0;
|
||||
virtual void FillInfoList( SvStorageInfoList* ) const = 0;
|
||||
virtual bool CopyTo( BaseStorage* pDestStg ) const = 0;
|
||||
virtual bool CopyTo( BaseStorage& rDestStg ) const = 0;
|
||||
virtual bool Commit() = 0;
|
||||
virtual bool Revert() = 0;
|
||||
virtual BaseStorageStream* OpenStream( const OUString & rEleName,
|
||||
|
@ -173,7 +173,7 @@ public:
|
|||
virtual SotClipboardFormatId GetFormat() override;
|
||||
virtual OUString GetUserName() override;
|
||||
virtual void FillInfoList( SvStorageInfoList* ) const override;
|
||||
virtual bool CopyTo( BaseStorage* pDestStg ) const override;
|
||||
virtual bool CopyTo( BaseStorage& rDestStg ) const override;
|
||||
virtual bool Commit() final override;
|
||||
virtual bool Revert() override;
|
||||
virtual BaseStorageStream* OpenStream( const OUString & rEleName,
|
||||
|
@ -279,7 +279,7 @@ public:
|
|||
virtual SotClipboardFormatId GetFormat() override;
|
||||
virtual OUString GetUserName() override;
|
||||
virtual void FillInfoList( SvStorageInfoList* ) const override;
|
||||
virtual bool CopyTo( BaseStorage* pDestStg ) const override;
|
||||
virtual bool CopyTo( BaseStorage& rDestStg ) const override;
|
||||
virtual bool Commit() final override;
|
||||
virtual bool Revert() override;
|
||||
virtual BaseStorageStream* OpenStream( const OUString & rEleName,
|
||||
|
|
|
@ -684,7 +684,7 @@ bool Storage::CopyTo( const OUString& rElem, BaseStorage* pDest, const OUString&
|
|||
if( !nTmpErr )
|
||||
{
|
||||
p2->SetClassId( p1->GetClassId() );
|
||||
p1->CopyTo( p2.get() );
|
||||
p1->CopyTo( *p2 );
|
||||
SetError( p1->GetError() );
|
||||
|
||||
nTmpErr = p2->GetError();
|
||||
|
@ -730,27 +730,27 @@ bool Storage::CopyTo( const OUString& rElem, BaseStorage* pDest, const OUString&
|
|||
return false;
|
||||
}
|
||||
|
||||
bool Storage::CopyTo( BaseStorage* pDest ) const
|
||||
bool Storage::CopyTo( BaseStorage& rDest ) const
|
||||
{
|
||||
if( !Validate() || !pDest || !pDest->Validate( true ) || Equals( *pDest ) )
|
||||
if( !Validate() || !rDest.Validate( true ) || Equals( rDest ) )
|
||||
{
|
||||
SetError( SVSTREAM_ACCESS_DENIED );
|
||||
return false;
|
||||
}
|
||||
Storage* pThis = const_cast<Storage*>(this);
|
||||
pDest->SetClassId( GetClassId() );
|
||||
pDest->SetDirty();
|
||||
rDest.SetClassId( GetClassId() );
|
||||
rDest.SetDirty();
|
||||
SvStorageInfoList aList;
|
||||
FillInfoList( &aList );
|
||||
bool bRes = true;
|
||||
for( size_t i = 0; i < aList.size() && bRes; i++ )
|
||||
{
|
||||
SvStorageInfo& rInfo = aList[ i ];
|
||||
bRes = pThis->CopyTo( rInfo.GetName(), pDest, rInfo.GetName() );
|
||||
bRes = pThis->CopyTo( rInfo.GetName(), &rDest, rInfo.GetName() );
|
||||
}
|
||||
if( !bRes )
|
||||
SetError( pDest->GetError() );
|
||||
return Good() && pDest->Good();
|
||||
SetError( rDest.GetError() );
|
||||
return Good() && rDest.Good();
|
||||
}
|
||||
|
||||
bool Storage::IsStorage( const OUString& rName ) const
|
||||
|
|
|
@ -461,7 +461,7 @@ bool SotStorage::CopyTo( SotStorage * pDestStg )
|
|||
{
|
||||
if( m_pOwnStg && pDestStg->m_pOwnStg )
|
||||
{
|
||||
m_pOwnStg->CopyTo( pDestStg->m_pOwnStg );
|
||||
m_pOwnStg->CopyTo( *pDestStg->m_pOwnStg );
|
||||
SetError( m_pOwnStg->GetError() );
|
||||
pDestStg->m_aKey = m_aKey;
|
||||
pDestStg->m_nVersion = m_nVersion;
|
||||
|
|
|
@ -2398,7 +2398,7 @@ bool UCBStorage::CopyStorageElement_Impl( UCBStorageElement_Impl const & rElemen
|
|||
pUCBCopy->pImp->m_aUserTypeName );
|
||||
else
|
||||
pOtherStorage->SetClassId( pStorage->GetClassId() );
|
||||
pStorage->CopyTo( pOtherStorage.get() );
|
||||
pStorage->CopyTo( *pOtherStorage );
|
||||
SetError( pStorage->GetError() );
|
||||
if( pOtherStorage->GetError() )
|
||||
pDest->SetError( pOtherStorage->GetError() );
|
||||
|
@ -2423,10 +2423,10 @@ UCBStorageElement_Impl* UCBStorage::FindElement_Impl( std::u16string_view rName
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
bool UCBStorage::CopyTo( BaseStorage* pDestStg ) const
|
||||
bool UCBStorage::CopyTo( BaseStorage& rDestStg ) const
|
||||
{
|
||||
DBG_ASSERT( pDestStg != static_cast<BaseStorage const *>(this), "Self-Copying is not possible!" );
|
||||
if ( pDestStg == static_cast<BaseStorage const *>(this) )
|
||||
DBG_ASSERT( &rDestStg != static_cast<BaseStorage const *>(this), "Self-Copying is not possible!" );
|
||||
if ( &rDestStg == static_cast<BaseStorage const *>(this) )
|
||||
return false;
|
||||
|
||||
// perhaps it's also a problem if one storage is a parent of the other ?!
|
||||
|
@ -2434,24 +2434,24 @@ bool UCBStorage::CopyTo( BaseStorage* pDestStg ) const
|
|||
|
||||
// For UCB storages, the class id and the format id may differ,
|
||||
// do passing the class id is not sufficient.
|
||||
if( dynamic_cast<const UCBStorage *>(pDestStg) != nullptr )
|
||||
pDestStg->SetClass( pImp->m_aClassId, pImp->m_nFormat,
|
||||
pImp->m_aUserTypeName );
|
||||
if( dynamic_cast<const UCBStorage *>(&rDestStg) != nullptr )
|
||||
rDestStg.SetClass( pImp->m_aClassId, pImp->m_nFormat,
|
||||
pImp->m_aUserTypeName );
|
||||
else
|
||||
pDestStg->SetClassId( GetClassId() );
|
||||
pDestStg->SetDirty();
|
||||
rDestStg.SetClassId( GetClassId() );
|
||||
rDestStg.SetDirty();
|
||||
|
||||
bool bRet = true;
|
||||
for ( size_t i = 0; i < pImp->GetChildrenList().size() && bRet; ++i )
|
||||
{
|
||||
auto& pElement = pImp->GetChildrenList()[ i ];
|
||||
if ( !pElement->m_bIsRemoved )
|
||||
bRet = CopyStorageElement_Impl( *pElement, pDestStg, pElement->m_aName );
|
||||
bRet = CopyStorageElement_Impl( *pElement, &rDestStg, pElement->m_aName );
|
||||
}
|
||||
|
||||
if( !bRet )
|
||||
SetError( pDestStg->GetError() );
|
||||
return Good() && pDestStg->Good();
|
||||
SetError( rDestStg.GetError() );
|
||||
return Good() && rDestStg.Good();
|
||||
}
|
||||
|
||||
bool UCBStorage::CopyTo( const OUString& rElemName, BaseStorage* pDest, const OUString& rNew )
|
||||
|
|
|
@ -387,7 +387,7 @@ uno::Any SAL_CALL OLESimpleStorage::getByName( const OUString& aName )
|
|||
throw uno::RuntimeException();
|
||||
|
||||
std::unique_ptr<BaseStorage> pNewStor(new Storage( *pStream, false ));
|
||||
bool bSuccess = ( pStrg->CopyTo( pNewStor.get() ) && pNewStor->Commit() &&
|
||||
bool bSuccess = ( pStrg->CopyTo( *pNewStor ) && pNewStor->Commit() &&
|
||||
!pNewStor->GetError() && !pStrg->GetError() );
|
||||
|
||||
pNewStor.reset();
|
||||
|
|
Loading…
Reference in a new issue