summaryrefslogtreecommitdiff
path: root/svx/source/gallery2/galtheme.cxx
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-11-21 15:49:27 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-11-22 12:15:38 +0100
commit3fbbd74b7bc6aef4af5f0c4b23a73a6726b9afbf (patch)
treeb3a0df75c42a93645f5342863a7291c871e520eb /svx/source/gallery2/galtheme.cxx
parent4b7490fe49bb93f895e974602a2616fa80b74019 (diff)
loplugin:flatten in svx
Change-Id: Idc4d0186ecc6f0722c2b1358486a2430f037ae29 Reviewed-on: https://gerrit.libreoffice.org/45036 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svx/source/gallery2/galtheme.cxx')
-rw-r--r--svx/source/gallery2/galtheme.cxx264
1 files changed, 132 insertions, 132 deletions
diff --git a/svx/source/gallery2/galtheme.cxx b/svx/source/gallery2/galtheme.cxx
index 1e2342f2b429..0a64e17f8bc2 100644
--- a/svx/source/gallery2/galtheme.cxx
+++ b/svx/source/gallery2/galtheme.cxx
@@ -509,178 +509,178 @@ bool GalleryTheme::ChangeObjectPos( size_t nOldPos, size_t nNewPos )
void GalleryTheme::Actualize( const Link<const INetURLObject&, void>& rActualizeLink, GalleryProgress* pProgress )
{
- if( !IsReadOnly() )
- {
- Graphic aGraphic;
- OUString aFormat;
- GalleryObject* pEntry;
- const size_t nCount = aObjectList.size();
+ if( IsReadOnly() )
+ return;
- LockBroadcaster();
- bAbortActualize = false;
+ Graphic aGraphic;
+ OUString aFormat;
+ GalleryObject* pEntry;
+ const size_t nCount = aObjectList.size();
- // reset delete flag
- for (size_t i = 0; i < nCount; i++)
- aObjectList[ i ]->mbDelete = false;
+ LockBroadcaster();
+ bAbortActualize = false;
- for(size_t i = 0; ( i < nCount ) && !bAbortActualize; i++)
- {
- if( pProgress )
- pProgress->Update( i, nCount - 1 );
+ // reset delete flag
+ for (size_t i = 0; i < nCount; i++)
+ aObjectList[ i ]->mbDelete = false;
- pEntry = aObjectList[ i ];
+ for(size_t i = 0; ( i < nCount ) && !bAbortActualize; i++)
+ {
+ if( pProgress )
+ pProgress->Update( i, nCount - 1 );
- const INetURLObject aURL( pEntry->aURL );
+ pEntry = aObjectList[ i ];
- rActualizeLink.Call( aURL );
+ const INetURLObject aURL( pEntry->aURL );
- // SvDraw objects will be updated later
- if( pEntry->eObjKind != SgaObjKind::SvDraw )
- {
- // Still a function should be implemented,
- // which assigns files to the relevant entry.
- // insert graphics as graphic objects into the gallery
- if( pEntry->eObjKind == SgaObjKind::Sound )
- {
- SgaObjectSound aObjSound( aURL );
- if( !InsertObject( aObjSound ) )
- pEntry->mbDelete = true;
- }
- else
- {
- aGraphic.Clear();
+ rActualizeLink.Call( aURL );
- if ( GalleryGraphicImport( aURL, aGraphic, aFormat ) != GalleryGraphicImportRet::IMPORT_NONE )
- {
- std::unique_ptr<SgaObject> pNewObj;
+ // SvDraw objects will be updated later
+ if( pEntry->eObjKind != SgaObjKind::SvDraw )
+ {
+ // Still a function should be implemented,
+ // which assigns files to the relevant entry.
+ // insert graphics as graphic objects into the gallery
+ if( pEntry->eObjKind == SgaObjKind::Sound )
+ {
+ SgaObjectSound aObjSound( aURL );
+ if( !InsertObject( aObjSound ) )
+ pEntry->mbDelete = true;
+ }
+ else
+ {
+ aGraphic.Clear();
- if ( SgaObjKind::Inet == pEntry->eObjKind )
- pNewObj.reset(static_cast<SgaObject*>(new SgaObjectINet( aGraphic, aURL )));
- else if ( aGraphic.IsAnimated() )
- pNewObj.reset(static_cast<SgaObject*>(new SgaObjectAnim( aGraphic, aURL )));
- else
- pNewObj.reset(static_cast<SgaObject*>(new SgaObjectBmp( aGraphic, aURL )));
+ if ( GalleryGraphicImport( aURL, aGraphic, aFormat ) != GalleryGraphicImportRet::IMPORT_NONE )
+ {
+ std::unique_ptr<SgaObject> pNewObj;
- if( !InsertObject( *pNewObj ) )
- pEntry->mbDelete = true;
- }
+ if ( SgaObjKind::Inet == pEntry->eObjKind )
+ pNewObj.reset(static_cast<SgaObject*>(new SgaObjectINet( aGraphic, aURL )));
+ else if ( aGraphic.IsAnimated() )
+ pNewObj.reset(static_cast<SgaObject*>(new SgaObjectAnim( aGraphic, aURL )));
else
- pEntry->mbDelete = true; // set delete flag
+ pNewObj.reset(static_cast<SgaObject*>(new SgaObjectBmp( aGraphic, aURL )));
+
+ if( !InsertObject( *pNewObj ) )
+ pEntry->mbDelete = true;
}
+ else
+ pEntry->mbDelete = true; // set delete flag
}
- else
+ }
+ else
+ {
+ if ( aSvDrawStorageRef.is() )
{
- if ( aSvDrawStorageRef.is() )
- {
- const OUString aStmName( GetSvDrawStreamNameFromURL( pEntry->aURL ) );
- tools::SvRef<SotStorageStream> pIStm = aSvDrawStorageRef->OpenSotStream( aStmName, StreamMode::READ );
+ const OUString aStmName( GetSvDrawStreamNameFromURL( pEntry->aURL ) );
+ tools::SvRef<SotStorageStream> pIStm = aSvDrawStorageRef->OpenSotStream( aStmName, StreamMode::READ );
- if( pIStm.is() && !pIStm->GetError() )
- {
- pIStm->SetBufferSize( 16384 );
+ if( pIStm.is() && !pIStm->GetError() )
+ {
+ pIStm->SetBufferSize( 16384 );
- SgaObjectSvDraw aNewObj( *pIStm, pEntry->aURL );
+ SgaObjectSvDraw aNewObj( *pIStm, pEntry->aURL );
- if( !InsertObject( aNewObj ) )
- pEntry->mbDelete = true;
+ if( !InsertObject( aNewObj ) )
+ pEntry->mbDelete = true;
- pIStm->SetBufferSize( 0 );
- }
+ pIStm->SetBufferSize( 0 );
}
}
}
+ }
- // remove all entries with set flag
- for ( GalleryObjectList::iterator it = aObjectList.begin(); it != aObjectList.end(); /* increment is in the body of loop */)
+ // remove all entries with set flag
+ for ( GalleryObjectList::iterator it = aObjectList.begin(); it != aObjectList.end(); /* increment is in the body of loop */)
+ {
+ if( (*it)->mbDelete )
{
- if( (*it)->mbDelete )
- {
- Broadcast( GalleryHint( GalleryHintType::CLOSE_OBJECT, GetName(), reinterpret_cast< sal_uIntPtr >( *it ) ) );
- Broadcast( GalleryHint( GalleryHintType::OBJECT_REMOVED, GetName(), reinterpret_cast< sal_uLong >( *it ) ) );
- delete *it;
- it = aObjectList.erase( it );
- }
- else ++it;
+ Broadcast( GalleryHint( GalleryHintType::CLOSE_OBJECT, GetName(), reinterpret_cast< sal_uIntPtr >( *it ) ) );
+ Broadcast( GalleryHint( GalleryHintType::OBJECT_REMOVED, GetName(), reinterpret_cast< sal_uLong >( *it ) ) );
+ delete *it;
+ it = aObjectList.erase( it );
}
+ else ++it;
+ }
- // update theme
- ::utl::TempFile aTmp;
- INetURLObject aInURL( GetSdgURL() );
- INetURLObject aTmpURL( aTmp.GetURL() );
+ // update theme
+ ::utl::TempFile aTmp;
+ INetURLObject aInURL( GetSdgURL() );
+ INetURLObject aTmpURL( aTmp.GetURL() );
- DBG_ASSERT( aInURL.GetProtocol() != INetProtocol::NotValid, "invalid URL" );
- DBG_ASSERT( aTmpURL.GetProtocol() != INetProtocol::NotValid, "invalid URL" );
+ DBG_ASSERT( aInURL.GetProtocol() != INetProtocol::NotValid, "invalid URL" );
+ DBG_ASSERT( aTmpURL.GetProtocol() != INetProtocol::NotValid, "invalid URL" );
- std::unique_ptr<SvStream> pIStm(::utl::UcbStreamHelper::CreateStream( aInURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ), StreamMode::READ ));
- std::unique_ptr<SvStream> pTmpStm(::utl::UcbStreamHelper::CreateStream( aTmpURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ), StreamMode::WRITE | StreamMode::TRUNC ));
+ std::unique_ptr<SvStream> pIStm(::utl::UcbStreamHelper::CreateStream( aInURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ), StreamMode::READ ));
+ std::unique_ptr<SvStream> pTmpStm(::utl::UcbStreamHelper::CreateStream( aTmpURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ), StreamMode::WRITE | StreamMode::TRUNC ));
- if( pIStm && pTmpStm )
+ if( pIStm && pTmpStm )
+ {
+ for (GalleryObject* i : aObjectList)
{
- for (GalleryObject* i : aObjectList)
- {
- pEntry = i;
- std::unique_ptr<SgaObject> pObj;
+ pEntry = i;
+ std::unique_ptr<SgaObject> pObj;
- switch( pEntry->eObjKind )
- {
- case SgaObjKind::Bitmap: pObj.reset(new SgaObjectBmp()); break;
- case SgaObjKind::Animation: pObj.reset(new SgaObjectAnim()); break;
- case SgaObjKind::Inet: pObj.reset(new SgaObjectINet()); break;
- case SgaObjKind::SvDraw: pObj.reset(new SgaObjectSvDraw()); break;
- case SgaObjKind::Sound: pObj.reset(new SgaObjectSound()); break;
+ switch( pEntry->eObjKind )
+ {
+ case SgaObjKind::Bitmap: pObj.reset(new SgaObjectBmp()); break;
+ case SgaObjKind::Animation: pObj.reset(new SgaObjectAnim()); break;
+ case SgaObjKind::Inet: pObj.reset(new SgaObjectINet()); break;
+ case SgaObjKind::SvDraw: pObj.reset(new SgaObjectSvDraw()); break;
+ case SgaObjKind::Sound: pObj.reset(new SgaObjectSound()); break;
- default:
- break;
- }
+ default:
+ break;
+ }
- if( pObj )
- {
- pIStm->Seek( pEntry->nOffset );
- ReadSgaObject( *pIStm, *pObj);
- pEntry->nOffset = pTmpStm->Tell();
- WriteSgaObject( *pTmpStm, *pObj );
- }
+ if( pObj )
+ {
+ pIStm->Seek( pEntry->nOffset );
+ ReadSgaObject( *pIStm, *pObj);
+ pEntry->nOffset = pTmpStm->Tell();
+ WriteSgaObject( *pTmpStm, *pObj );
}
}
- else
- {
- OSL_FAIL( "File(s) could not be opened" );
- }
-
- pIStm.reset();
- pTmpStm.reset();
+ }
+ else
+ {
+ OSL_FAIL( "File(s) could not be opened" );
+ }
- CopyFile( aTmpURL, aInURL );
- KillFile( aTmpURL );
+ pIStm.reset();
+ pTmpStm.reset();
- ErrCode nStorErr = ERRCODE_NONE;
+ CopyFile( aTmpURL, aInURL );
+ KillFile( aTmpURL );
- try
- {
- tools::SvRef<SotStorage> aTempStorageRef( new SotStorage( false, aTmpURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ), StreamMode::STD_READWRITE ) );
- aSvDrawStorageRef->CopyTo( aTempStorageRef.get() );
- nStorErr = aSvDrawStorageRef->GetError();
- }
- catch (const css::ucb::ContentCreationException& e)
- {
- SAL_WARN("svx", "failed to open: "
- << aTmpURL.GetMainURL(INetURLObject::DecodeMechanism::NONE)
- << "due to : " << e);
- nStorErr = ERRCODE_IO_GENERAL;
- }
+ ErrCode nStorErr = ERRCODE_NONE;
- if( nStorErr == ERRCODE_NONE )
- {
- aSvDrawStorageRef.clear();
- CopyFile( aTmpURL, GetSdvURL() );
- ImplCreateSvDrawStorage();
- }
+ try
+ {
+ tools::SvRef<SotStorage> aTempStorageRef( new SotStorage( false, aTmpURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ), StreamMode::STD_READWRITE ) );
+ aSvDrawStorageRef->CopyTo( aTempStorageRef.get() );
+ nStorErr = aSvDrawStorageRef->GetError();
+ }
+ catch (const css::ucb::ContentCreationException& e)
+ {
+ SAL_WARN("svx", "failed to open: "
+ << aTmpURL.GetMainURL(INetURLObject::DecodeMechanism::NONE)
+ << "due to : " << e);
+ nStorErr = ERRCODE_IO_GENERAL;
+ }
- KillFile( aTmpURL );
- ImplSetModified( true );
- ImplWrite();
- UnlockBroadcaster();
+ if( nStorErr == ERRCODE_NONE )
+ {
+ aSvDrawStorageRef.clear();
+ CopyFile( aTmpURL, GetSdvURL() );
+ ImplCreateSvDrawStorage();
}
+
+ KillFile( aTmpURL );
+ ImplSetModified( true );
+ ImplWrite();
+ UnlockBroadcaster();
}
GalleryThemeEntry* GalleryTheme::CreateThemeEntry( const INetURLObject& rURL, bool bReadOnly )