diff options
author | Aditya <adityasahu1511@gmail.com> | 2020-08-28 02:16:09 +0530 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2020-09-04 21:57:52 +0200 |
commit | b1a8b0e5327d823da34050e382f7a2838c262881 (patch) | |
tree | 373ec8e73b77a04bb395eaf4d84e06a0e802b2c6 /svx/source | |
parent | 125fbbe6cc1956d370a01f83f47c637d39f5e596 (diff) |
svx: Refactor Gallery::ImplGetCachedTheme
Introduce GalleryBinaryEngineEntry::getCachedTheme() to refactor
Gallery::ImplGetCachedTheme.
Change-Id: Ic27a325af0975298143d4746de363edd1d148a42
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101508
Tested-by: Tomaž Vajngerl <quikee@gmail.com>
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'svx/source')
-rw-r--r-- | svx/source/gallery2/gallery1.cxx | 34 | ||||
-rw-r--r-- | svx/source/gallery2/gallerybinaryengineentry.cxx | 34 | ||||
-rw-r--r-- | svx/source/gallery2/galtheme.cxx | 5 |
3 files changed, 43 insertions, 30 deletions
diff --git a/svx/source/gallery2/gallery1.cxx b/svx/source/gallery2/gallery1.cxx index 5e1182c46a4d..78f517f63868 100644 --- a/svx/source/gallery2/gallery1.cxx +++ b/svx/source/gallery2/gallery1.cxx @@ -636,6 +636,14 @@ bool Gallery::RemoveTheme( const OUString& rThemeName ) return bRet; } +std::unique_ptr<GalleryTheme> GalleryThemeEntry::getCachedTheme(Gallery* pGallery) const +{ + std::unique_ptr<GalleryTheme> pNewTheme; + pNewTheme.reset(new GalleryTheme(pGallery, const_cast<GalleryThemeEntry*>(this))); + mpGalleryStorageEngineEntry->getCachedTheme(pNewTheme); + return pNewTheme; +} + GalleryTheme* Gallery::ImplGetCachedTheme(const GalleryThemeEntry* pThemeEntry) { GalleryTheme* pTheme = nullptr; @@ -649,31 +657,7 @@ GalleryTheme* Gallery::ImplGetCachedTheme(const GalleryThemeEntry* pThemeEntry) if( !pTheme ) { - INetURLObject aURL = pThemeEntry->GetThmURL(); - - DBG_ASSERT( aURL.GetProtocol() != INetProtocol::NotValid, "invalid URL" ); - - std::unique_ptr<GalleryTheme> pNewTheme; - if( FileExists( aURL ) ) - { - std::unique_ptr<SvStream> pIStm(::utl::UcbStreamHelper::CreateStream( aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ), StreamMode::READ )); - - if( pIStm ) - { - try - { - pNewTheme.reset( new GalleryTheme( this, const_cast<GalleryThemeEntry*>(pThemeEntry) ) ); - ReadGalleryTheme( *pIStm, *pNewTheme ); - - if( pIStm->GetError() ) - pNewTheme.reset(); - } - catch (const css::ucb::ContentCreationException&) - { - } - } - } - + std::unique_ptr<GalleryTheme> pNewTheme = pThemeEntry->getCachedTheme(this); if (pNewTheme) { aThemeCache.push_back( new GalleryThemeCacheEntry( pThemeEntry, std::move(pNewTheme) )); diff --git a/svx/source/gallery2/gallerybinaryengineentry.cxx b/svx/source/gallery2/gallerybinaryengineentry.cxx index 56c836677c3a..8255b2b8a276 100644 --- a/svx/source/gallery2/gallerybinaryengineentry.cxx +++ b/svx/source/gallery2/gallerybinaryengineentry.cxx @@ -32,6 +32,8 @@ #include <tools/urlobj.hxx> #include <tools/vcompat.hxx> +#include <com/sun/star/ucb/ContentCreationException.hpp> + static bool FileExists(const INetURLObject& rURL, const OUString& rExt) { INetURLObject aURL(rURL); @@ -140,4 +142,36 @@ void GalleryBinaryEngineEntry::removeTheme() KillFile(aSdvURL); KillFile(aStrURL); } + +std::unique_ptr<GalleryTheme>& +GalleryBinaryEngineEntry::getCachedTheme(std::unique_ptr<GalleryTheme>& pNewTheme) +{ + INetURLObject aURL = GetThmURL(); + + DBG_ASSERT(aURL.GetProtocol() != INetProtocol::NotValid, "invalid URL"); + + if (FileExists(aURL)) + { + std::unique_ptr<SvStream> pIStm(::utl::UcbStreamHelper::CreateStream( + aURL.GetMainURL(INetURLObject::DecodeMechanism::NONE), StreamMode::READ)); + + if (pIStm) + { + try + { + ReadGalleryTheme(*pIStm, *pNewTheme); + + if (pIStm->GetError()) + pNewTheme.reset(); + } + catch (const css::ucb::ContentCreationException&) + { + } + } + } + return pNewTheme; +} + +SvStream& ReadGalleryTheme(SvStream& rIn, GalleryTheme& rTheme) { return rTheme.ReadData(rIn); } + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/gallery2/galtheme.cxx b/svx/source/gallery2/galtheme.cxx index fd395eeb0601..a25964afa1f3 100644 --- a/svx/source/gallery2/galtheme.cxx +++ b/svx/source/gallery2/galtheme.cxx @@ -784,11 +784,6 @@ SvStream& GalleryTheme::ReadData( SvStream& rIStm ) return rIStm; } -SvStream& ReadGalleryTheme( SvStream& rIn, GalleryTheme& rTheme ) -{ - return rTheme.ReadData( rIn ); -} - void GalleryTheme::ImplSetModified( bool bModified ) { pThm->SetModified(bModified); |