diff options
author | Aditya <adityasahu1511@gmail.com> | 2020-08-28 20:39:41 +0530 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2020-09-06 12:44:41 +0200 |
commit | 0e3b72ac75d9f9c70fe6e74e83a43ffa2635c777 (patch) | |
tree | 1cbe0822c688fcf6d8fd60384c970f987c727da3 | |
parent | d17b80d8a0c540a5add6e675a3b42f97c4737f98 (diff) |
svx refactoring: Remove GalleryStorageLocations from GalleryThemeEntry
Change-Id: I3955a66b7ec4f463264dbb5db6209bbb667bf2b8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101557
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
-rw-r--r-- | include/svx/gallery1.hxx | 8 | ||||
-rw-r--r-- | include/svx/gallerybinaryengineentry.hxx | 20 | ||||
-rw-r--r-- | svx/qa/unit/gallery/test_gallery.cxx | 2 | ||||
-rw-r--r-- | svx/source/gallery2/gallery1.cxx | 10 | ||||
-rw-r--r-- | svx/source/gallery2/gallerybinaryengineentry.cxx | 18 | ||||
-rw-r--r-- | svx/source/gallery2/gallerybinarystoragelocations.cxx | 10 | ||||
-rw-r--r-- | svx/source/gallery2/galtheme.cxx | 2 |
7 files changed, 44 insertions, 26 deletions
diff --git a/include/svx/gallery1.hxx b/include/svx/gallery1.hxx index 81d22ac1e5ae..36f25a292877 100644 --- a/include/svx/gallery1.hxx +++ b/include/svx/gallery1.hxx @@ -39,7 +39,6 @@ class GalleryThemeEntry private: std::unique_ptr<GalleryBinaryEngineEntry> mpGalleryStorageEngineEntry; - std::unique_ptr<GalleryStorageLocations> mpGalleryStorageLocations; OUString aName; sal_uInt32 nId; bool bReadOnly; @@ -53,11 +52,10 @@ public: bool bReadOnly, bool bNewFile, sal_uInt32 nId, bool bThemeNameFromResource ); - std::unique_ptr<GalleryBinaryEngineEntry> createGalleryStorageEngineEntry(); + static std::unique_ptr<GalleryBinaryEngineEntry> createGalleryStorageEngineEntry(); const std::unique_ptr<GalleryBinaryEngineEntry>& getGalleryStorageEngineEntry() const { return mpGalleryStorageEngineEntry; } - static std::unique_ptr<GalleryStorageLocations> createGalleryStorageLocations(); - const std::unique_ptr<GalleryStorageLocations>& getGalleryStorageLocations() const { return mpGalleryStorageLocations; } + GalleryStorageLocations& getGalleryStorageLocations() const { return *mpGalleryStorageEngineEntry->getGalleryStorageLocations(); } const OUString& GetThemeName() const { return aName; } @@ -79,6 +77,8 @@ public: void removeTheme(); std::unique_ptr<GalleryTheme> getCachedTheme(Gallery* pGallery) const; + + void setStorageLocations(INetURLObject& rURL); }; class SfxListener; diff --git a/include/svx/gallerybinaryengineentry.hxx b/include/svx/gallerybinaryengineentry.hxx index 8039661e4dec..b0f8d7a447b3 100644 --- a/include/svx/gallerybinaryengineentry.hxx +++ b/include/svx/gallerybinaryengineentry.hxx @@ -32,24 +32,32 @@ class GalleryBinaryStorageLocations; class GalleryBinaryEngineEntry : public GalleryFileStorageEntry { private: - GalleryBinaryStorageLocations& m_rGalleryStorageLocations; + std::unique_ptr<GalleryBinaryStorageLocations> mpGalleryStorageLocations; public: - GalleryBinaryEngineEntry(GalleryBinaryStorageLocations& rGalleryStorageLocations); + GalleryBinaryEngineEntry(); static void CreateUniqueURL(const INetURLObject& rBaseURL, INetURLObject& aURL); OUString ReadStrFromIni(const OUString& aKeyName); - const INetURLObject& GetThmURL() const { return m_rGalleryStorageLocations.GetThmURL(); } - const INetURLObject& GetSdgURL() const { return m_rGalleryStorageLocations.GetSdgURL(); } - const INetURLObject& GetSdvURL() const { return m_rGalleryStorageLocations.GetSdvURL(); } - const INetURLObject& GetStrURL() const { return m_rGalleryStorageLocations.GetStrURL(); } + const INetURLObject& GetThmURL() const { return mpGalleryStorageLocations->GetThmURL(); } + const INetURLObject& GetSdgURL() const { return mpGalleryStorageLocations->GetSdgURL(); } + const INetURLObject& GetSdvURL() const { return mpGalleryStorageLocations->GetSdvURL(); } + const INetURLObject& GetStrURL() const { return mpGalleryStorageLocations->GetStrURL(); } + + static std::unique_ptr<GalleryBinaryStorageLocations> createGalleryStorageLocations(); + const std::unique_ptr<GalleryBinaryStorageLocations>& getGalleryStorageLocations() const + { + return mpGalleryStorageLocations; + } static GalleryThemeEntry* CreateThemeEntry(const INetURLObject& rURL, bool bReadOnly); void removeTheme(); std::unique_ptr<GalleryTheme>& getCachedTheme(std::unique_ptr<GalleryTheme>& pNewTheme); + + void setStorageLocations(INetURLObject& rURL); }; SvStream& ReadGalleryTheme(SvStream& rIn, GalleryTheme& rTheme); diff --git a/svx/qa/unit/gallery/test_gallery.cxx b/svx/qa/unit/gallery/test_gallery.cxx index 83ccf600ed36..d9ae9150ceb1 100644 --- a/svx/qa/unit/gallery/test_gallery.cxx +++ b/svx/qa/unit/gallery/test_gallery.cxx @@ -258,7 +258,7 @@ void GalleryObjTest::TestGalleryThemeEntry() // Check URLs GalleryBinaryStorageLocations& aGalleryBinaryStorageLocations - = dynamic_cast<GalleryBinaryStorageLocations&>(*mpThemeEntry->getGalleryStorageLocations()); + = dynamic_cast<GalleryBinaryStorageLocations&>(mpThemeEntry->getGalleryStorageLocations()); INetURLObject aURL(aGalleryURL); aURL.Append(myThemeName); INetURLObject aThemeURL(aURL), aSdvURL(aURL), aSdgURL(aURL), aStrURL(aURL); diff --git a/svx/source/gallery2/gallery1.cxx b/svx/source/gallery2/gallery1.cxx index aaa6b47ed918..d0a2da1836d7 100644 --- a/svx/source/gallery2/gallery1.cxx +++ b/svx/source/gallery2/gallery1.cxx @@ -122,9 +122,8 @@ GalleryThemeEntry::GalleryThemeEntry( bool bCreateUniqueURL, { GalleryBinaryEngineEntry::CreateUniqueURL(rBaseURL,aURL); } - mpGalleryStorageLocations = createGalleryStorageLocations(); mpGalleryStorageEngineEntry = createGalleryStorageEngineEntry(); - mpGalleryStorageLocations->SetStorageLocations(aURL); + setStorageLocations(aURL); SetModified( _bNewFile ); @@ -164,14 +163,13 @@ GalleryThemeEntry::GalleryThemeEntry( bool bCreateUniqueURL, std::unique_ptr<GalleryBinaryEngineEntry> GalleryThemeEntry::createGalleryStorageEngineEntry() { - std::unique_ptr<GalleryBinaryEngineEntry> pGalleryBinaryEngineEntry = std::make_unique<GalleryBinaryEngineEntry>(dynamic_cast<GalleryBinaryStorageLocations&>(*mpGalleryStorageLocations)); + std::unique_ptr<GalleryBinaryEngineEntry> pGalleryBinaryEngineEntry = std::make_unique<GalleryBinaryEngineEntry>(); return pGalleryBinaryEngineEntry; } -std::unique_ptr<GalleryStorageLocations> GalleryThemeEntry::createGalleryStorageLocations() +void GalleryThemeEntry::setStorageLocations(INetURLObject& rURL) { - std::unique_ptr<GalleryStorageLocations> pGalleryStorageLocations = std::make_unique<GalleryBinaryStorageLocations>(); - return pGalleryStorageLocations; + mpGalleryStorageEngineEntry->setStorageLocations(rURL); } void GalleryTheme::InsertAllThemes(weld::ComboBox& rListBox) diff --git a/svx/source/gallery2/gallerybinaryengineentry.cxx b/svx/source/gallery2/gallerybinaryengineentry.cxx index 1d669576dc98..5c7c81fb5790 100644 --- a/svx/source/gallery2/gallerybinaryengineentry.cxx +++ b/svx/source/gallery2/gallerybinaryengineentry.cxx @@ -41,10 +41,22 @@ static bool FileExists(const INetURLObject& rURL, const OUString& rExt) return FileExists(aURL); } -GalleryBinaryEngineEntry::GalleryBinaryEngineEntry( - GalleryBinaryStorageLocations& rGalleryStorageLocations) - : m_rGalleryStorageLocations(rGalleryStorageLocations) +GalleryBinaryEngineEntry::GalleryBinaryEngineEntry() { + mpGalleryStorageLocations = createGalleryStorageLocations(); +} + +std::unique_ptr<GalleryBinaryStorageLocations> +GalleryBinaryEngineEntry::createGalleryStorageLocations() +{ + std::unique_ptr<GalleryBinaryStorageLocations> pGalleryStorageLocations + = std::make_unique<GalleryBinaryStorageLocations>(); + return pGalleryStorageLocations; +} + +void GalleryBinaryEngineEntry::setStorageLocations(INetURLObject& rURL) +{ + mpGalleryStorageLocations->SetStorageLocations(rURL); } void GalleryBinaryEngineEntry::CreateUniqueURL(const INetURLObject& rBaseURL, INetURLObject& aURL) diff --git a/svx/source/gallery2/gallerybinarystoragelocations.cxx b/svx/source/gallery2/gallerybinarystoragelocations.cxx index cefb79d543a9..e8aaf88b1fee 100644 --- a/svx/source/gallery2/gallerybinarystoragelocations.cxx +++ b/svx/source/gallery2/gallerybinarystoragelocations.cxx @@ -64,12 +64,12 @@ void GalleryBinaryStorageLocations::SetStrExtension(INetURLObject& aURL) maStrURL = ImplGetURLIgnoreCase(aURL); } -void GalleryBinaryStorageLocations::SetStorageLocations(INetURLObject& aURL) +void GalleryBinaryStorageLocations::SetStorageLocations(INetURLObject& rURL) { - SetThmExtension(aURL); - SetSdgExtension(aURL); - SetSdvExtension(aURL); - SetStrExtension(aURL); + SetThmExtension(rURL); + SetSdgExtension(rURL); + SetSdvExtension(rURL); + SetStrExtension(rURL); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/gallery2/galtheme.cxx b/svx/source/gallery2/galtheme.cxx index c0fb25b430ce..69a09b84c2ee 100644 --- a/svx/source/gallery2/galtheme.cxx +++ b/svx/source/gallery2/galtheme.cxx @@ -96,7 +96,7 @@ void GalleryTheme::SetDestDir(const OUString& rDestDir, bool bRelative) std::unique_ptr<GalleryBinaryEngine> GalleryTheme::createGalleryStorageEngine(bool bReadOnly) { - std::unique_ptr<GalleryBinaryEngine> pGalleryBinaryEngine = std::make_unique<GalleryBinaryEngine>(dynamic_cast<GalleryBinaryStorageLocations&>(*pThm->getGalleryStorageLocations()), maGalleryObjectCollection, bReadOnly); + std::unique_ptr<GalleryBinaryEngine> pGalleryBinaryEngine = std::make_unique<GalleryBinaryEngine>(dynamic_cast<GalleryBinaryStorageLocations&>(pThm->getGalleryStorageLocations()), maGalleryObjectCollection, bReadOnly); return pGalleryBinaryEngine; } |