[Libreoffice-commits] core.git: include/svx svx/source
Aditya (via logerrit)
logerrit at kemper.freedesktop.org
Fri Jul 10 07:08:03 UTC 2020
include/svx/gallery1.hxx | 2 +
include/svx/gallerybinaryengine.hxx | 9 +++++
include/svx/galtheme.hxx | 4 --
svx/source/gallery2/gallery1.cxx | 5 ++
svx/source/gallery2/gallerybinaryengine.cxx | 38 +++++++++++++++++++++
svx/source/gallery2/galtheme.cxx | 49 ++++++++--------------------
6 files changed, 68 insertions(+), 39 deletions(-)
New commits:
commit dd4c68b02578618d861a2df687823eaaa8ab35f8
Author: Aditya <adityasahu1511 at gmail.com>
AuthorDate: Mon Jun 29 15:39:19 2020 +0530
Commit: Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Fri Jul 10 09:07:40 2020 +0200
svx:Refactoring of GalleryTheme members to GalleryBinaryEngine
Moving of aSvDrawStorageRef into the binary engine and consequent changes
Change-Id: I7262c77ec8730fbbe516f9fb205c25c4e1f15ff5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96764
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
diff --git a/include/svx/gallery1.hxx b/include/svx/gallery1.hxx
index f34a707cd712..15fa6e1d6629 100644
--- a/include/svx/gallery1.hxx
+++ b/include/svx/gallery1.hxx
@@ -53,6 +53,8 @@ public:
static std::unique_ptr<GalleryBinaryEngine> createGalleryBinaryEngine();
const std::unique_ptr<GalleryBinaryEngine>& getGalleryBinaryEngine() const { return mpGalleryBinaryEngine; }
+ void callGalleryThemeInit();
+
const OUString& GetThemeName() const { return aName; }
const INetURLObject& GetThmURL() const { return mpGalleryBinaryEngine->GetThmURL(); }
diff --git a/include/svx/gallerybinaryengine.hxx b/include/svx/gallerybinaryengine.hxx
index 5b655cfc49fc..20be0b6cdfe0 100644
--- a/include/svx/gallerybinaryengine.hxx
+++ b/include/svx/gallerybinaryengine.hxx
@@ -22,7 +22,9 @@
#include <tools/urlobj.hxx>
#include <svx/svxdllapi.h>
#include <svx/galtheme.hxx>
+#include <sot/storage.hxx>
+class SotStorage;
struct GalleryObject;
class SVXCORE_DLLPUBLIC GalleryBinaryEngine
@@ -32,10 +34,14 @@ private:
INetURLObject aSdgURL;
INetURLObject aSdvURL;
INetURLObject aStrURL;
+ tools::SvRef<SotStorage> aSvDrawStorageRef;
static INetURLObject ImplGetURLIgnoreCase(const INetURLObject& rURL);
public:
+ void galleryThemeInit(bool bReadOnly);
+ void galleryThemeDestroy();
+
static void CreateUniqueURL(const INetURLObject& rBaseURL, INetURLObject& aURL);
OUString ReadStrFromIni(const OUString& aKeyName);
@@ -50,6 +56,9 @@ public:
const INetURLObject& GetSdvURL() const { return aSdvURL; }
const INetURLObject& GetStrURL() const { return aStrURL; }
+ SAL_DLLPRIVATE void ImplCreateSvDrawStorage(bool bReadOnly);
+ SAL_DLLPRIVATE const tools::SvRef<SotStorage>& GetSvDrawStorage() const;
+
std::unique_ptr<SgaObject> implReadSgaObject(GalleryObject const* pEntry);
bool implWriteSgaObject(const SgaObject& rObj, sal_uInt32 nPos, GalleryObject* pExistentEntry,
OUString& aDestDir,
diff --git a/include/svx/galtheme.hxx b/include/svx/galtheme.hxx
index 44b13f0fd539..b262805a0744 100644
--- a/include/svx/galtheme.hxx
+++ b/include/svx/galtheme.hxx
@@ -32,7 +32,6 @@
namespace weld { class ComboBox; }
-class SotStorage;
class SotStorageStream;
@@ -76,7 +75,6 @@ private:
::std::vector< std::unique_ptr<GalleryObject> > aObjectList;
OUString m_aDestDir;
bool m_bDestDirRelative;
- tools::SvRef<SotStorage> aSvDrawStorageRef;
Gallery* pParent;
GalleryThemeEntry* pThm;
sal_uInt32 mnThemeLockCount;
@@ -85,7 +83,6 @@ private:
bool bDragging;
bool bAbortActualize;
- SAL_DLLPRIVATE void ImplCreateSvDrawStorage();
SAL_DLLPRIVATE const GalleryObject* ImplGetGalleryObject(sal_uInt32 nPos) const
{
if (nPos < aObjectList.size())
@@ -158,7 +155,6 @@ public:
SAL_DLLPRIVATE void AbortActualize() { bAbortActualize = true; }
SAL_DLLPRIVATE Gallery* GetParent() const { return pParent; }
- SAL_DLLPRIVATE const tools::SvRef<SotStorage>& GetSvDrawStorage() const;
public:
diff --git a/svx/source/gallery2/gallery1.cxx b/svx/source/gallery2/gallery1.cxx
index 7f0c524fda65..73b623a1ce1f 100644
--- a/svx/source/gallery2/gallery1.cxx
+++ b/svx/source/gallery2/gallery1.cxx
@@ -169,6 +169,11 @@ std::unique_ptr<GalleryBinaryEngine> GalleryThemeEntry::createGalleryBinaryEngin
return pGalleryBinaryEngine;
}
+void GalleryThemeEntry::callGalleryThemeInit()
+{
+ getGalleryBinaryEngine()->galleryThemeInit(IsReadOnly());
+}
+
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 f72247ba038b..57ebc07feff8 100644
--- a/svx/source/gallery2/gallerybinaryengine.cxx
+++ b/svx/source/gallery2/gallerybinaryengine.cxx
@@ -22,9 +22,13 @@
#include <vcl/salctype.hxx>
#include <galobj.hxx>
+#include <sal/log.hxx>
+
#include <unotools/ucbstreamhelper.hxx>
+#include <com/sun/star/ucb/ContentCreationException.hpp>
#include <tools/urlobj.hxx>
#include <tools/vcompat.hxx>
+#include <tools/diagnose_ex.h>
static bool FileExists(const INetURLObject& rURL, const OUString& rExt)
{
@@ -33,6 +37,14 @@ static bool FileExists(const INetURLObject& rURL, const OUString& rExt)
return FileExists(aURL);
}
+void GalleryBinaryEngine::galleryThemeInit(bool bReadOnly)
+{
+ SAL_WARN_IF(aSvDrawStorageRef.is(), "svx", "SotStorage is already initialized");
+ ImplCreateSvDrawStorage(bReadOnly);
+}
+
+void GalleryBinaryEngine::galleryThemeDestroy() { aSvDrawStorageRef.clear(); }
+
INetURLObject GalleryBinaryEngine::ImplGetURLIgnoreCase(const INetURLObject& rURL)
{
INetURLObject aURL(rURL);
@@ -333,6 +345,32 @@ GalleryBinaryEngine::implCreateUniqueURL(SgaObjKind eObjKind, const INetURLObjec
return aNewURL;
}
+void GalleryBinaryEngine::ImplCreateSvDrawStorage(bool bReadOnly)
+{
+ try
+ {
+ aSvDrawStorageRef
+ = new SotStorage(false, GetSdvURL().GetMainURL(INetURLObject::DecodeMechanism::NONE),
+ bReadOnly ? StreamMode::READ : StreamMode::STD_READWRITE);
+ // #i50423# ReadOnly may not been set though the file can't be written (because of security reasons)
+ if ((aSvDrawStorageRef->GetError() != ERRCODE_NONE) && !bReadOnly)
+ aSvDrawStorageRef = new SotStorage(
+ false, GetSdvURL().GetMainURL(INetURLObject::DecodeMechanism::NONE),
+ StreamMode::READ);
+ }
+ catch (const css::ucb::ContentCreationException&)
+ {
+ TOOLS_WARN_EXCEPTION("svx", "failed to open: " << GetSdvURL().GetMainURL(
+ INetURLObject::DecodeMechanism::NONE)
+ << "due to");
+ }
+}
+
+const tools::SvRef<SotStorage>& GalleryBinaryEngine::GetSvDrawStorage() const
+{
+ return aSvDrawStorageRef;
+}
+
SvStream& WriteGalleryTheme(SvStream& rOut, const GalleryTheme& rTheme)
{
return rTheme.WriteData(rOut);
diff --git a/svx/source/gallery2/galtheme.cxx b/svx/source/gallery2/galtheme.cxx
index ec52c09b56e5..d53d59d424b0 100644
--- a/svx/source/gallery2/galtheme.cxx
+++ b/svx/source/gallery2/galtheme.cxx
@@ -70,7 +70,7 @@ GalleryTheme::GalleryTheme( Gallery* pGallery, GalleryThemeEntry* pThemeEntry )
, bDragging(false)
, bAbortActualize(false)
{
- ImplCreateSvDrawStorage();
+ pThm->callGalleryThemeInit();
}
GalleryTheme::~GalleryTheme()
@@ -85,24 +85,7 @@ GalleryTheme::~GalleryTheme()
pEntry.reset();
}
aObjectList.clear();
-
-}
-
-void GalleryTheme::ImplCreateSvDrawStorage()
-{
- try
- {
- aSvDrawStorageRef = new SotStorage( false, GetSdvURL().GetMainURL( INetURLObject::DecodeMechanism::NONE ), pThm->IsReadOnly() ? StreamMode::READ : StreamMode::STD_READWRITE );
- // #i50423# ReadOnly may not been set though the file can't be written (because of security reasons)
- if ( ( aSvDrawStorageRef->GetError() != ERRCODE_NONE ) && !pThm->IsReadOnly() )
- aSvDrawStorageRef = new SotStorage( false, GetSdvURL().GetMainURL( INetURLObject::DecodeMechanism::NONE ), StreamMode::READ );
- }
- catch (const css::ucb::ContentCreationException&)
- {
- TOOLS_WARN_EXCEPTION("svx", "failed to open: "
- << GetSdvURL().GetMainURL(INetURLObject::DecodeMechanism::NONE)
- << "due to");
- }
+ pThm->getGalleryBinaryEngine()->galleryThemeDestroy();
}
const GalleryObject* GalleryTheme::ImplGetGalleryObject( const INetURLObject& rURL )
@@ -237,7 +220,7 @@ void GalleryTheme::RemoveObject(sal_uInt32 nPos)
KillFile( GetSdgURL() );
if( SgaObjKind::SvDraw == pEntry->eObjKind )
- aSvDrawStorageRef->Remove( pEntry->aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ) );
+ pThm->getGalleryBinaryEngine()->GetSvDrawStorage()->Remove( pEntry->aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ) );
Broadcast( GalleryHint( GalleryHintType::CLOSE_OBJECT, GetName(), pEntry.get() ) );
pEntry.reset();
@@ -330,10 +313,10 @@ void GalleryTheme::Actualize( const Link<const INetURLObject&, void>& rActualize
}
else
{
- if ( aSvDrawStorageRef.is() )
+ if ( pThm->getGalleryBinaryEngine()->GetSvDrawStorage().is() )
{
const OUString aStmName( GetSvDrawStreamNameFromURL( pEntry->aURL ) );
- tools::SvRef<SotStorageStream> pIStm = aSvDrawStorageRef->OpenSotStream( aStmName, StreamMode::READ );
+ tools::SvRef<SotStorageStream> pIStm = pThm->getGalleryBinaryEngine()->GetSvDrawStorage()->OpenSotStream( aStmName, StreamMode::READ );
if( pIStm.is() && !pIStm->GetError() )
{
@@ -417,8 +400,8 @@ void GalleryTheme::Actualize( const Link<const INetURLObject&, void>& rActualize
try
{
tools::SvRef<SotStorage> aTempStorageRef( new SotStorage( false, aTmpURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ), StreamMode::STD_READWRITE ) );
- aSvDrawStorageRef->CopyTo( aTempStorageRef.get() );
- nStorErr = aSvDrawStorageRef->GetError();
+ pThm->getGalleryBinaryEngine()->GetSvDrawStorage()->CopyTo( aTempStorageRef.get() );
+ nStorErr = pThm->getGalleryBinaryEngine()->GetSvDrawStorage()->GetError();
}
catch (const css::ucb::ContentCreationException&)
{
@@ -430,9 +413,10 @@ void GalleryTheme::Actualize( const Link<const INetURLObject&, void>& rActualize
if( nStorErr == ERRCODE_NONE )
{
- aSvDrawStorageRef.clear();
+ auto aSvDrawStorage = pThm->getGalleryBinaryEngine()->GetSvDrawStorage();
+ aSvDrawStorage.clear();
CopyFile( aTmpURL, GetSdvURL() );
- ImplCreateSvDrawStorage();
+ pThm->callGalleryThemeInit();
}
KillFile( aTmpURL );
@@ -688,7 +672,7 @@ bool GalleryTheme::GetModel(sal_uInt32 nPos, SdrModel& rModel)
if( pObject && ( SgaObjKind::SvDraw == pObject->eObjKind ) )
{
const INetURLObject aURL( ImplGetURL( pObject ) );
- tools::SvRef<SotStorage> xStor( GetSvDrawStorage() );
+ tools::SvRef<SotStorage> xStor( pThm->getGalleryBinaryEngine()->GetSvDrawStorage() );
if( xStor.is() )
{
@@ -710,7 +694,7 @@ bool GalleryTheme::GetModel(sal_uInt32 nPos, SdrModel& rModel)
bool GalleryTheme::InsertModel(const FmFormModel& rModel, sal_uInt32 nInsertPos)
{
INetURLObject aURL( GalleryBinaryEngine::implCreateUniqueURL( SgaObjKind::SvDraw, GetParent()->GetUserURL(), aObjectList) );
- tools::SvRef<SotStorage> xStor( GetSvDrawStorage() );
+ tools::SvRef<SotStorage> xStor(pThm->getGalleryBinaryEngine()->GetSvDrawStorage() );
bool bRet = false;
if( xStor.is() )
@@ -760,7 +744,7 @@ bool GalleryTheme::GetModelStream(sal_uInt32 nPos, tools::SvRef<SotStorageStream
if( pObject && ( SgaObjKind::SvDraw == pObject->eObjKind ) )
{
const INetURLObject aURL( ImplGetURL( pObject ) );
- tools::SvRef<SotStorage> xStor( GetSvDrawStorage() );
+ tools::SvRef<SotStorage> xStor( pThm->getGalleryBinaryEngine()->GetSvDrawStorage() );
if( xStor.is() )
{
@@ -806,7 +790,7 @@ bool GalleryTheme::GetModelStream(sal_uInt32 nPos, tools::SvRef<SotStorageStream
bool GalleryTheme::InsertModelStream(const tools::SvRef<SotStorageStream>& rxModelStream, sal_uInt32 nInsertPos)
{
INetURLObject aURL( GalleryBinaryEngine::implCreateUniqueURL( SgaObjKind::SvDraw, GetParent()->GetUserURL(), aObjectList ) );
- tools::SvRef<SotStorage> xStor( GetSvDrawStorage() );
+ tools::SvRef<SotStorage> xStor( pThm->getGalleryBinaryEngine()->GetSvDrawStorage() );
bool bRet = false;
if( xStor.is() )
@@ -1255,11 +1239,6 @@ void GalleryTheme::SetId( sal_uInt32 nNewId, bool bResetThemeName ) { pThm->SetI
bool GalleryTheme::IsReadOnly() const { return pThm->IsReadOnly(); }
bool GalleryTheme::IsDefault() const { return pThm->IsDefault(); }
-const tools::SvRef<SotStorage>& GalleryTheme::GetSvDrawStorage() const
-{
- return aSvDrawStorageRef;
-}
-
const OUString& GalleryTheme::GetName() const { return pThm->GetThemeName(); }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
More information about the Libreoffice-commits
mailing list