[Libreoffice-commits] core.git: include/svx svx/inc svx/source
Aditya (via logerrit)
logerrit at kemper.freedesktop.org
Wed Jun 17 13:36:47 UTC 2020
include/svx/gallery1.hxx | 13 +++++---
include/svx/gallerybinaryengine.hxx | 7 ++++
include/svx/galtheme.hxx | 1
svx/inc/galobj.hxx | 2 +
svx/source/gallery2/gallery1.cxx | 18 +++++++----
svx/source/gallery2/gallerybinaryengine.cxx | 43 ++++++++++++++++++++++++++++
svx/source/gallery2/galtheme.cxx | 42 +--------------------------
7 files changed, 74 insertions(+), 52 deletions(-)
New commits:
commit f9383f75af46efbb319110921158dcd6b5e91913
Author: Aditya <adityasahu1511 at gmail.com>
AuthorDate: Wed Jun 17 16:43:49 2020 +0530
Commit: Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Wed Jun 17 15:36:06 2020 +0200
svx: Refactor GalleryTheme class
Change-Id: I60ce3b5a9ca5a28e499015c3ac118d2f6a091f16
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96527
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
diff --git a/include/svx/gallery1.hxx b/include/svx/gallery1.hxx
index 0cb9700f5462..f34a707cd712 100644
--- a/include/svx/gallery1.hxx
+++ b/include/svx/gallery1.hxx
@@ -36,7 +36,7 @@ class GalleryThemeEntry
{
private:
- GalleryBinaryEngine maGalleryBinaryEngine;
+ std::unique_ptr<GalleryBinaryEngine> mpGalleryBinaryEngine;
OUString aName;
sal_uInt32 nId;
bool bReadOnly;
@@ -50,12 +50,15 @@ public:
bool bReadOnly, bool bNewFile,
sal_uInt32 nId, bool bThemeNameFromResource );
+ static std::unique_ptr<GalleryBinaryEngine> createGalleryBinaryEngine();
+ const std::unique_ptr<GalleryBinaryEngine>& getGalleryBinaryEngine() const { return mpGalleryBinaryEngine; }
+
const OUString& GetThemeName() const { return aName; }
- const INetURLObject& GetThmURL() const { return maGalleryBinaryEngine.GetThmURL(); }
- const INetURLObject& GetSdgURL() const { return maGalleryBinaryEngine.GetSdgURL(); }
- const INetURLObject& GetSdvURL() const { return maGalleryBinaryEngine.GetSdvURL(); }
- const INetURLObject& GetStrURL() const { return maGalleryBinaryEngine.GetStrURL(); }
+ const INetURLObject& GetThmURL() const { return mpGalleryBinaryEngine->GetThmURL(); }
+ const INetURLObject& GetSdgURL() const { return mpGalleryBinaryEngine->GetSdgURL(); }
+ const INetURLObject& GetSdvURL() const { return mpGalleryBinaryEngine->GetSdvURL(); }
+ const INetURLObject& GetStrURL() const { return mpGalleryBinaryEngine->GetStrURL(); }
bool IsReadOnly() const { return bReadOnly; }
bool IsDefault() const;
diff --git a/include/svx/gallerybinaryengine.hxx b/include/svx/gallerybinaryengine.hxx
index 15aa8957d510..f658b248735c 100644
--- a/include/svx/gallerybinaryengine.hxx
+++ b/include/svx/gallerybinaryengine.hxx
@@ -21,6 +21,9 @@
#include <tools/urlobj.hxx>
#include <svx/svxdllapi.h>
+#include <svx/galtheme.hxx>
+
+struct GalleryObject;
class SVXCORE_DLLPUBLIC GalleryBinaryEngine
{
@@ -46,6 +49,10 @@ public:
const INetURLObject& GetSdgURL() const { return aSdgURL; }
const INetURLObject& GetSdvURL() const { return aSdvURL; }
const INetURLObject& GetStrURL() const { return aStrURL; }
+
+ bool ImplWriteSgaObject(const SgaObject& rObj, sal_uInt32 nPos, GalleryObject* pExistentEntry,
+ OUString& aDestDir,
+ ::std::vector<std::unique_ptr<GalleryObject>>& aObjectList);
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/svx/galtheme.hxx b/include/svx/galtheme.hxx
index c7c248d22344..3af46ca2431e 100644
--- a/include/svx/galtheme.hxx
+++ b/include/svx/galtheme.hxx
@@ -87,7 +87,6 @@ private:
SAL_DLLPRIVATE void ImplCreateSvDrawStorage();
std::unique_ptr<SgaObject> ImplReadSgaObject( GalleryObject const * pEntry );
- SAL_DLLPRIVATE bool ImplWriteSgaObject(const SgaObject& rObj, sal_uInt32 nPos, GalleryObject* pExistentEntry);
SAL_DLLPRIVATE void ImplWrite();
SAL_DLLPRIVATE const GalleryObject* ImplGetGalleryObject(sal_uInt32 nPos) const
{
diff --git a/svx/inc/galobj.hxx b/svx/inc/galobj.hxx
index 77869d28a1f6..6501b49ff1c7 100644
--- a/svx/inc/galobj.hxx
+++ b/svx/inc/galobj.hxx
@@ -25,6 +25,7 @@
#include <vcl/graph.hxx>
#include <vcl/gdimtf.hxx>
#include <svx/galmisc.hxx>
+#include <svx/gallerybinaryengine.hxx>
#define S_THUMB 80
@@ -44,6 +45,7 @@ enum GalSoundType
class UNLESS_MERGELIBS(SVXCORE_DLLPUBLIC) SgaObject
{
friend class GalleryTheme;
+ friend class GalleryBinaryEngine;
private:
diff --git a/svx/source/gallery2/gallery1.cxx b/svx/source/gallery2/gallery1.cxx
index a7c86c3ef9a3..3bd04dbeb527 100644
--- a/svx/source/gallery2/gallery1.cxx
+++ b/svx/source/gallery2/gallery1.cxx
@@ -121,15 +121,15 @@ GalleryThemeEntry::GalleryThemeEntry( bool bCreateUniqueURL,
{
GalleryBinaryEngine::CreateUniqueURL(rBaseURL,aURL);
}
-
- maGalleryBinaryEngine.SetThmExtension(aURL);
- maGalleryBinaryEngine.SetSdgExtension(aURL);
- maGalleryBinaryEngine.SetSdvExtension(aURL);
- maGalleryBinaryEngine.SetStrExtension(aURL);
+ mpGalleryBinaryEngine = createGalleryBinaryEngine();
+ mpGalleryBinaryEngine->SetThmExtension(aURL);
+ mpGalleryBinaryEngine->SetSdgExtension(aURL);
+ mpGalleryBinaryEngine->SetSdvExtension(aURL);
+ mpGalleryBinaryEngine->SetStrExtension(aURL);
SetModified( _bNewFile );
- aName = maGalleryBinaryEngine.ReadStrFromIni( "name" );
+ aName = mpGalleryBinaryEngine->ReadStrFromIni( "name" );
// This is awful - we shouldn't use these resources if we
// possibly can avoid them
@@ -163,6 +163,12 @@ GalleryThemeEntry::GalleryThemeEntry( bool bCreateUniqueURL,
aName = rName;
}
+std::unique_ptr<GalleryBinaryEngine> GalleryThemeEntry::createGalleryBinaryEngine()
+{
+ std::unique_ptr<GalleryBinaryEngine> pGalleryBinaryEngine = std::make_unique<GalleryBinaryEngine>();
+ return pGalleryBinaryEngine;
+}
+
void GalleryTheme::InsertAllThemes(weld::ComboBox& rListBox)
{
for (size_t i = 0; i < SAL_N_ELEMENTS(aUnlocalized); ++i)
diff --git a/svx/source/gallery2/gallerybinaryengine.cxx b/svx/source/gallery2/gallerybinaryengine.cxx
index 0e08359909c2..c5d2f018e1d4 100644
--- a/svx/source/gallery2/gallerybinaryengine.cxx
+++ b/svx/source/gallery2/gallerybinaryengine.cxx
@@ -19,7 +19,9 @@
#include <svx/gallerybinaryengine.hxx>
#include <svx/galmisc.hxx>
+#include <galobj.hxx>
+#include <unotools/ucbstreamhelper.hxx>
#include <tools/urlobj.hxx>
static bool FileExists(const INetURLObject& rURL, const OUString& rExt)
@@ -85,3 +87,44 @@ void GalleryBinaryEngine::SetStrExtension(INetURLObject aURL)
aURL.setExtension("str");
aStrURL = ImplGetURLIgnoreCase(aURL);
}
+
+bool GalleryBinaryEngine::ImplWriteSgaObject(
+ const SgaObject& rObj, sal_uInt32 nPos, GalleryObject* pExistentEntry, OUString& aDestDir,
+ ::std::vector<std::unique_ptr<GalleryObject>>& aObjectList)
+{
+ std::unique_ptr<SvStream> pOStm(::utl::UcbStreamHelper::CreateStream(
+ GetSdgURL().GetMainURL(INetURLObject::DecodeMechanism::NONE), StreamMode::WRITE));
+ bool bRet = false;
+
+ if (pOStm)
+ {
+ const sal_uInt32 nOffset = pOStm->Seek(STREAM_SEEK_TO_END);
+
+ rObj.WriteData(*pOStm, aDestDir);
+
+ if (!pOStm->GetError())
+ {
+ GalleryObject* pEntry;
+
+ if (!pExistentEntry)
+ {
+ pEntry = new GalleryObject;
+ if (nPos < aObjectList.size())
+ {
+ aObjectList.emplace(aObjectList.begin() + nPos, pEntry);
+ }
+ else
+ aObjectList.emplace_back(pEntry);
+ }
+ else
+ pEntry = pExistentEntry;
+
+ pEntry->aURL = rObj.GetURL();
+ pEntry->nOffset = nOffset;
+ pEntry->eObjKind = rObj.GetObjKind();
+ bRet = true;
+ }
+ }
+
+ return bRet;
+}
diff --git a/svx/source/gallery2/galtheme.cxx b/svx/source/gallery2/galtheme.cxx
index a5b60f572817..e849542e4ef2 100644
--- a/svx/source/gallery2/galtheme.cxx
+++ b/svx/source/gallery2/galtheme.cxx
@@ -103,44 +103,6 @@ void GalleryTheme::ImplCreateSvDrawStorage()
}
}
-bool GalleryTheme::ImplWriteSgaObject(const SgaObject& rObj, sal_uInt32 nPos, GalleryObject* pExistentEntry)
-{
- std::unique_ptr<SvStream> pOStm(::utl::UcbStreamHelper::CreateStream( GetSdgURL().GetMainURL( INetURLObject::DecodeMechanism::NONE ), StreamMode::WRITE ));
- bool bRet = false;
-
- if( pOStm )
- {
- const sal_uInt32 nOffset = pOStm->Seek( STREAM_SEEK_TO_END );
-
- rObj.WriteData( *pOStm, m_aDestDir );
-
- if( !pOStm->GetError() )
- {
- GalleryObject* pEntry;
-
- if( !pExistentEntry )
- {
- pEntry = new GalleryObject;
- if ( nPos < aObjectList.size() )
- {
- aObjectList.emplace( aObjectList.begin() + nPos, pEntry );
- }
- else
- aObjectList.emplace_back( pEntry );
- }
- else
- pEntry = pExistentEntry;
-
- pEntry->aURL = rObj.GetURL();
- pEntry->nOffset = nOffset;
- pEntry->eObjKind = rObj.GetObjKind();
- bRet = true;
- }
- }
-
- return bRet;
-}
-
std::unique_ptr<SgaObject> GalleryTheme::ImplReadSgaObject( GalleryObject const * pEntry )
{
std::unique_ptr<SgaObject> pSgaObj;
@@ -390,11 +352,11 @@ bool GalleryTheme::InsertObject(const SgaObject& rObj, sal_uInt32 nInsertPos)
else if (rObj.GetTitle() == "__<empty>__")
const_cast<SgaObject&>(rObj).SetTitle("");
- ImplWriteSgaObject(rObj, nInsertPos, &aNewEntry);
+ pThm->getGalleryBinaryEngine()->ImplWriteSgaObject(rObj, nInsertPos, &aNewEntry, m_aDestDir, aObjectList);
pFoundEntry->nOffset = aNewEntry.nOffset;
}
else
- ImplWriteSgaObject(rObj, nInsertPos, nullptr);
+ pThm->getGalleryBinaryEngine()->ImplWriteSgaObject(rObj, nInsertPos, nullptr, m_aDestDir, aObjectList);
ImplSetModified(true);
ImplBroadcast(pFoundEntry? iFoundPos: nInsertPos);
More information about the Libreoffice-commits
mailing list