From 8c5c8d42d5cee83e00e3ecf00a55c8f42e0b169e Mon Sep 17 00:00:00 2001 From: Aditya Date: Sun, 30 Aug 2020 02:27:32 +0530 Subject: svx: Introduce createGalleryTheme() to GalleryThemeEntry MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Let GalleryThemeEntry initialize GalleryTheme. Change-Id: Ib81d95faf6561604a30a7d0a3d9dae808c83a398 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101655 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl --- svx/source/gallery2/gallery1.cxx | 21 ++++++++++++++++----- svx/source/gallery2/gallerybinaryengineentry.cxx | 7 +++++++ svx/source/gallery2/galtheme.cxx | 8 +------- 3 files changed, 24 insertions(+), 12 deletions(-) (limited to 'svx') diff --git a/svx/source/gallery2/gallery1.cxx b/svx/source/gallery2/gallery1.cxx index 7eee341227eb..750fd1491220 100644 --- a/svx/source/gallery2/gallery1.cxx +++ b/svx/source/gallery2/gallery1.cxx @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -162,11 +163,21 @@ GalleryThemeEntry::GalleryThemeEntry( bool bCreateUniqueURL, aName = rName; } -void GalleryThemeEntry::setStorageLocations(INetURLObject& rURL) +void GalleryThemeEntry::setStorageLocations(INetURLObject & rURL) { mpGalleryStorageEngineEntry->setStorageLocations(rURL); } +GalleryTheme* GalleryThemeEntry::createGalleryTheme(Gallery* pGallery) +{ + return new GalleryTheme(pGallery,this); +} + +std::unique_ptr GalleryThemeEntry::createGalleryStorageEngine(GalleryObjectCollection& mrGalleryObjectCollection) +{ + return mpGalleryStorageEngineEntry->createGalleryStorageEngine(mrGalleryObjectCollection, bReadOnly); +} + void GalleryTheme::InsertAllThemes(weld::ComboBox& rListBox) { for (size_t i = 0; i < SAL_N_ELEMENTS(aUnlocalized); ++i) @@ -574,7 +585,7 @@ bool Gallery::CreateTheme( const OUString& rThemeName ) false, true, 0, false ); aThemeList.emplace_back( pNewEntry ); - delete new GalleryTheme( this, pNewEntry ); + delete pNewEntry->createGalleryTheme( this ); Broadcast( GalleryHint( GalleryHintType::THEME_CREATED, rThemeName ) ); bRet = true; } @@ -636,15 +647,15 @@ bool Gallery::RemoveTheme( const OUString& rThemeName ) return bRet; } -std::unique_ptr GalleryThemeEntry::getCachedTheme(Gallery* pGallery) const +std::unique_ptr GalleryThemeEntry::getCachedTheme(Gallery* pGallery) { std::unique_ptr pNewTheme; - pNewTheme.reset(new GalleryTheme(pGallery, const_cast(this))); + pNewTheme.reset(createGalleryTheme(pGallery)); mpGalleryStorageEngineEntry->getCachedTheme(pNewTheme); return pNewTheme; } -GalleryTheme* Gallery::ImplGetCachedTheme(const GalleryThemeEntry* pThemeEntry) +GalleryTheme* Gallery::ImplGetCachedTheme(GalleryThemeEntry* pThemeEntry) { GalleryTheme* pTheme = nullptr; diff --git a/svx/source/gallery2/gallerybinaryengineentry.cxx b/svx/source/gallery2/gallerybinaryengineentry.cxx index 7750c9ae9bc0..0b0831169a4d 100644 --- a/svx/source/gallery2/gallerybinaryengineentry.cxx +++ b/svx/source/gallery2/gallerybinaryengineentry.cxx @@ -51,6 +51,13 @@ void GalleryBinaryEngineEntry::setStorageLocations(INetURLObject& rURL) mpGalleryStorageLocations->SetStorageLocations(rURL); } +std::unique_ptr GalleryBinaryEngineEntry::createGalleryStorageEngine( + GalleryObjectCollection& mrGalleryObjectCollection, bool& bReadOnly) +{ + return std::make_unique(*mpGalleryStorageLocations, + mrGalleryObjectCollection, bReadOnly); +} + void GalleryBinaryEngineEntry::CreateUniqueURL(const INetURLObject& rBaseURL, INetURLObject& aURL) { INetURLObject aBaseNoCase(GalleryBinaryStorageLocations::ImplGetURLIgnoreCase(rBaseURL)); diff --git a/svx/source/gallery2/galtheme.cxx b/svx/source/gallery2/galtheme.cxx index 69a09b84c2ee..e6dcf1acf75c 100644 --- a/svx/source/gallery2/galtheme.cxx +++ b/svx/source/gallery2/galtheme.cxx @@ -71,7 +71,7 @@ GalleryTheme::GalleryTheme( Gallery* pGallery, GalleryThemeEntry* pThemeEntry ) , bDragging(false) , bAbortActualize(false) { - mpGalleryStorageEngine = createGalleryStorageEngine(IsReadOnly()); + mpGalleryStorageEngine = pThm->createGalleryStorageEngine(maGalleryObjectCollection); } GalleryTheme::~GalleryTheme() @@ -94,12 +94,6 @@ void GalleryTheme::SetDestDir(const OUString& rDestDir, bool bRelative) mpGalleryStorageEngine->setDestDir(rDestDir, bRelative); } -std::unique_ptr GalleryTheme::createGalleryStorageEngine(bool bReadOnly) -{ - std::unique_ptr pGalleryBinaryEngine = std::make_unique(dynamic_cast(pThm->getGalleryStorageLocations()), maGalleryObjectCollection, bReadOnly); - return pGalleryBinaryEngine; -} - void GalleryTheme::ImplBroadcast(sal_uInt32 nUpdatePos) { if( !IsBroadcasterLocked() ) -- cgit