summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAditya <adityasahu1511@gmail.com>2020-08-30 02:27:32 +0530
committerTomaž Vajngerl <quikee@gmail.com>2020-09-06 22:41:52 +0200
commit8c5c8d42d5cee83e00e3ecf00a55c8f42e0b169e (patch)
tree352ac074ac01fa5fcd8f8f31c2f0c6a950226a65
parent7b4b1cb7c753fadbc20892ef8cc961b7a61e8d19 (diff)
svx: Introduce createGalleryTheme() to GalleryThemeEntry
Let GalleryThemeEntry initialize GalleryTheme. Change-Id: Ib81d95faf6561604a30a7d0a3d9dae808c83a398 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101655 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
-rw-r--r--include/svx/gallery1.hxx9
-rw-r--r--include/svx/gallerybinaryengineentry.hxx6
-rw-r--r--include/svx/galtheme.hxx1
-rw-r--r--svx/source/gallery2/gallery1.cxx21
-rw-r--r--svx/source/gallery2/gallerybinaryengineentry.cxx7
-rw-r--r--svx/source/gallery2/galtheme.cxx8
6 files changed, 36 insertions, 16 deletions
diff --git a/include/svx/gallery1.hxx b/include/svx/gallery1.hxx
index f9b83afe606e..69ec2728a6df 100644
--- a/include/svx/gallery1.hxx
+++ b/include/svx/gallery1.hxx
@@ -33,6 +33,7 @@
class GalleryBinaryEngineEntry;
class GalleryStorageLocations;
+class GalleryTheme;
class GalleryThemeEntry
{
@@ -56,6 +57,10 @@ public:
GalleryStorageLocations& getGalleryStorageLocations() const { return *mpGalleryStorageEngineEntry->getGalleryStorageLocations(); }
+ GalleryTheme* createGalleryTheme(Gallery* pGallery);
+
+ std::unique_ptr<GalleryBinaryEngine> createGalleryStorageEngine(GalleryObjectCollection& mrGalleryObjectCollection);
+
const OUString& GetThemeName() const { return aName; }
bool IsReadOnly() const { return bReadOnly; }
@@ -75,7 +80,7 @@ public:
void removeTheme();
- std::unique_ptr<GalleryTheme> getCachedTheme(Gallery* pGallery) const;
+ std::unique_ptr<GalleryTheme> getCachedTheme(Gallery* pGallery);
void setStorageLocations(INetURLObject& rURL);
};
@@ -102,7 +107,7 @@ private:
GalleryThemeEntry* ImplGetThemeEntry( const OUString& rThemeName );
- SAL_DLLPRIVATE GalleryTheme* ImplGetCachedTheme( const GalleryThemeEntry* pThemeEntry );
+ SAL_DLLPRIVATE GalleryTheme* ImplGetCachedTheme( GalleryThemeEntry* pThemeEntry );
SAL_DLLPRIVATE void ImplDeleteCachedTheme( GalleryTheme const * pTheme );
Gallery& operator=( Gallery const & ) = delete; // MSVC2015 workaround
diff --git a/include/svx/gallerybinaryengineentry.hxx b/include/svx/gallerybinaryengineentry.hxx
index eeb989257e3b..b1130127765c 100644
--- a/include/svx/gallerybinaryengineentry.hxx
+++ b/include/svx/gallerybinaryengineentry.hxx
@@ -28,6 +28,8 @@
#include <svx/galleryfilestorageentry.hxx>
class GalleryBinaryStorageLocations;
+class GalleryObjectCollection;
+class GalleryBinaryEngine;
class GalleryBinaryEngineEntry : public GalleryFileStorageEntry
{
@@ -46,7 +48,6 @@ public:
const INetURLObject& GetStrURL() const { return mpGalleryStorageLocations->GetStrURL(); }
const std::unique_ptr<GalleryBinaryStorageLocations>& getGalleryStorageLocations() const
-
{
return mpGalleryStorageLocations;
}
@@ -58,6 +59,9 @@ public:
std::unique_ptr<GalleryTheme>& getCachedTheme(std::unique_ptr<GalleryTheme>& pNewTheme);
void setStorageLocations(INetURLObject& rURL);
+
+ std::unique_ptr<GalleryBinaryEngine>
+ createGalleryStorageEngine(GalleryObjectCollection& mrGalleryObjectCollection, bool& bReadOnly);
};
SvStream& ReadGalleryTheme(SvStream& rIn, GalleryTheme& rTheme);
diff --git a/include/svx/galtheme.hxx b/include/svx/galtheme.hxx
index dcf5e7f198e4..61d360158847 100644
--- a/include/svx/galtheme.hxx
+++ b/include/svx/galtheme.hxx
@@ -68,7 +68,6 @@ private:
bool bDragging;
bool bAbortActualize;
- std::unique_ptr<GalleryBinaryEngine> createGalleryStorageEngine(bool bReadOnly);
const std::unique_ptr<GalleryBinaryEngine>& getGalleryStorageEngine() const { return mpGalleryStorageEngine; }
SAL_DLLPRIVATE void ImplSetModified( bool bModified );
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 <unotools/pathoptions.hxx>
#include <svx/dialmgr.hxx>
#include <svx/gallery.hxx>
+#include <svx/galleryobjectcollection.hxx>
#include <svx/strings.hrc>
#include <strings.hxx>
#include <svx/galmisc.hxx>
@@ -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<GalleryBinaryEngine> 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<GalleryTheme> GalleryThemeEntry::getCachedTheme(Gallery* pGallery) const
+std::unique_ptr<GalleryTheme> GalleryThemeEntry::getCachedTheme(Gallery* pGallery)
{
std::unique_ptr<GalleryTheme> pNewTheme;
- pNewTheme.reset(new GalleryTheme(pGallery, const_cast<GalleryThemeEntry*>(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<GalleryBinaryEngine> GalleryBinaryEngineEntry::createGalleryStorageEngine(
+ GalleryObjectCollection& mrGalleryObjectCollection, bool& bReadOnly)
+{
+ return std::make_unique<GalleryBinaryEngine>(*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<GalleryBinaryEngine> GalleryTheme::createGalleryStorageEngine(bool bReadOnly)
-{
- std::unique_ptr<GalleryBinaryEngine> pGalleryBinaryEngine = std::make_unique<GalleryBinaryEngine>(dynamic_cast<GalleryBinaryStorageLocations&>(pThm->getGalleryStorageLocations()), maGalleryObjectCollection, bReadOnly);
- return pGalleryBinaryEngine;
-}
-
void GalleryTheme::ImplBroadcast(sal_uInt32 nUpdatePos)
{
if( !IsBroadcasterLocked() )