diff options
-rw-r--r-- | include/svx/gallery1.hxx | 3 | ||||
-rw-r--r-- | include/svx/gallerybinaryengineentry.hxx | 4 | ||||
-rw-r--r-- | include/svx/galtheme.hxx | 5 | ||||
-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 |
6 files changed, 51 insertions, 34 deletions
diff --git a/include/svx/gallery1.hxx b/include/svx/gallery1.hxx index 3aa89cc4211d..6d3e7bbd105d 100644 --- a/include/svx/gallery1.hxx +++ b/include/svx/gallery1.hxx @@ -79,7 +79,10 @@ public: sal_uInt32 GetId() const { return nId; } void SetId( sal_uInt32 nNewId, bool bResetThemeName ); + void removeTheme(); + + std::unique_ptr<GalleryTheme> getCachedTheme(Gallery* pGallery) const; }; class SfxListener; diff --git a/include/svx/gallerybinaryengineentry.hxx b/include/svx/gallerybinaryengineentry.hxx index 9b1f25a5b6b4..e2561ce764dd 100644 --- a/include/svx/gallerybinaryengineentry.hxx +++ b/include/svx/gallerybinaryengineentry.hxx @@ -47,6 +47,10 @@ public: static GalleryThemeEntry* CreateThemeEntry(const INetURLObject& rURL, bool bReadOnly); void removeTheme(); + + std::unique_ptr<GalleryTheme>& getCachedTheme(std::unique_ptr<GalleryTheme>& pNewTheme); }; +SvStream& ReadGalleryTheme(SvStream& rIn, GalleryTheme& rTheme); + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svx/galtheme.hxx b/include/svx/galtheme.hxx index c15d03d14b02..dcf5e7f198e4 100644 --- a/include/svx/galtheme.hxx +++ b/include/svx/galtheme.hxx @@ -74,12 +74,11 @@ private: SAL_DLLPRIVATE void ImplSetModified( bool bModified ); SAL_DLLPRIVATE void ImplBroadcast(sal_uInt32 nUpdatePos); - SAL_DLLPRIVATE GalleryTheme( Gallery* pGallery, GalleryThemeEntry* pThemeEntry ); - GalleryTheme(GalleryTheme const &) = delete; void operator =(GalleryTheme const &) = delete; public: + SAL_DLLPRIVATE GalleryTheme(Gallery* pGallery, GalleryThemeEntry* pThemeEntry); SAL_DLLPRIVATE virtual ~GalleryTheme() override; @@ -168,8 +167,6 @@ public: SAL_DLLPRIVATE void SetPreviewBitmapExAndStrings(sal_uInt32 nPos, const BitmapEx& rBitmapEx, const Size& rSize, const OUString& rTitle, const OUString& rPath); }; -SvStream& ReadGalleryTheme( SvStream& rIn, GalleryTheme& rTheme ); - #endif // INCLUDED_SVX_GALTHEME_HXX /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 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); |