diff options
author | Aditya <adityasahu1511@gmail.com> | 2020-07-17 13:55:11 +0530 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2020-07-23 22:07:32 +0200 |
commit | 2157185ce15d99f7a234abe46c50f3c6f83a2651 (patch) | |
tree | a9104b7c70a073f133727815d9fbb02fce11ef28 /include | |
parent | 09a3b52f883783a2047d77b058d085a3b14e4c9b (diff) |
svx:Introduce GalleryBinaryEngineEntry and GalleryStorageLocations
Change GalleryBinaryEngine to GalleryBinaryEngineEntry and create
GalleryBinaryEngine class that is instantiated at when GalleryEngine is
instantiated.
Implement GalleryStorageLocations, a shared class which contains locations
to binary files like aThmURL, aSdgURL, aSdvURL and aStrURL. The class shares
the members between GalleryBinaryEngine and GalleryBinaryEngineEntry.
Change-Id: I22da487fbc2a500252196f9ff8dcfa9c4df6abbf
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98979
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/svx/gallery1.hxx | 31 | ||||
-rw-r--r-- | include/svx/gallerybinaryengine.hxx | 59 | ||||
-rw-r--r-- | include/svx/gallerybinaryengineentry.hxx | 50 | ||||
-rw-r--r-- | include/svx/gallerystoragelocations.hxx | 49 | ||||
-rw-r--r-- | include/svx/galtheme.hxx | 7 |
5 files changed, 144 insertions, 52 deletions
diff --git a/include/svx/gallery1.hxx b/include/svx/gallery1.hxx index 013245d91da0..28ba3fe72eb4 100644 --- a/include/svx/gallery1.hxx +++ b/include/svx/gallery1.hxx @@ -24,21 +24,23 @@ #include <svl/SfxBroadcaster.hxx> #include <svx/svxdllapi.h> #include <tools/urlobj.hxx> +#include <svx/gallerybinaryengineentry.hxx> #include <svx/gallerybinaryengine.hxx> #include <cstdio> #include <memory> #include <vector> -class SgaObjectSvDraw; struct GalleryObject; -class GalleryBinaryEngine; +class GalleryBinaryEngineEntry; +class GalleryStorageLocations; class GalleryThemeEntry { private: - std::unique_ptr<GalleryBinaryEngine> mpGalleryBinaryEngine; + std::unique_ptr<GalleryBinaryEngineEntry> mpGalleryBinaryEngineEntry; + GalleryStorageLocations maGalleryStorageLocations; OUString aName; sal_uInt32 nId; bool bReadOnly; @@ -52,26 +54,17 @@ 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; } + std::unique_ptr<GalleryBinaryEngineEntry> createGalleryBinaryEngineEntry(); + const std::unique_ptr<GalleryBinaryEngineEntry>& getGalleryBinaryEngineEntry() const { return mpGalleryBinaryEngineEntry; } - void callGalleryThemeInit(); - - bool readModel(const GalleryObject* pObject, SdrModel& rModel); - bool insertModel(const FmFormModel& rModel, INetURLObject& aURL); - - bool readModelStream(const GalleryObject* pObject, tools::SvRef<SotStorageStream> const& rxModelStream); - SgaObjectSvDraw insertModelStream(const tools::SvRef<SotStorageStream>& rxModelStream, INetURLObject& rURL); - - void insertObject(const SgaObject& rObj, GalleryObject* pFoundEntry, OUString& rDestDir, - ::std::vector<std::unique_ptr<GalleryObject>>& rObjectList, sal_uInt32& rInsertPos); + const GalleryStorageLocations& getGalleryStorageLocations() const { return maGalleryStorageLocations; } const OUString& GetThemeName() const { return aName; } - 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(); } + const INetURLObject& GetThmURL() const { return mpGalleryBinaryEngineEntry->GetThmURL(); } + const INetURLObject& GetSdgURL() const { return mpGalleryBinaryEngineEntry->GetSdgURL(); } + const INetURLObject& GetSdvURL() const { return mpGalleryBinaryEngineEntry->GetSdvURL(); } + const INetURLObject& GetStrURL() const { return mpGalleryBinaryEngineEntry->GetStrURL(); } bool IsReadOnly() const { return bReadOnly; } bool IsDefault() const; diff --git a/include/svx/gallerybinaryengine.hxx b/include/svx/gallerybinaryengine.hxx index 4582bd1d4b8d..b40f9c2b11bb 100644 --- a/include/svx/gallerybinaryengine.hxx +++ b/include/svx/gallerybinaryengine.hxx @@ -19,52 +19,54 @@ #pragma once -#include <tools/urlobj.hxx> -#include <svx/svxdllapi.h> #include <svx/galtheme.hxx> +#include <svx/gallerybinaryengine.hxx> +#include <svx/gallerystoragelocations.hxx> +#include <svx/svxdllapi.h> +#include <svx/fmmodel.hxx> +#include <tools/urlobj.hxx> #include <sot/storage.hxx> +#include <cstdio> +#include <memory> +#include <vector> + +class GalleryStorageLocations; class SgaObjectSvDraw; +class SgaObject; class SotStorage; struct GalleryObject; +class FmFormModel; +class GalleryTheme; class SVXCORE_DLLPUBLIC GalleryBinaryEngine { private: - INetURLObject aThmURL; - INetURLObject aSdgURL; - INetURLObject aSdvURL; - INetURLObject aStrURL; - tools::SvRef<SotStorage> aSvDrawStorageRef; - - static INetURLObject ImplGetURLIgnoreCase(const INetURLObject& rURL); + tools::SvRef<SotStorage> m_aSvDrawStorageRef; + const GalleryStorageLocations& maGalleryStorageLocations; public: - void galleryThemeInit(bool bReadOnly); - void galleryThemeDestroy(); + GalleryBinaryEngine(const GalleryStorageLocations& rGalleryStorageLocations); + void clearSotStorage(); - static void CreateUniqueURL(const INetURLObject& rBaseURL, INetURLObject& aURL); - - OUString ReadStrFromIni(const OUString& aKeyName); + SAL_DLLPRIVATE void ImplCreateSvDrawStorage(bool bReadOnly); + SAL_DLLPRIVATE const tools::SvRef<SotStorage>& GetSvDrawStorage() const; - void SetThmExtension(INetURLObject aURL); - void SetSdgExtension(INetURLObject aURL); - void SetSdvExtension(INetURLObject aURL); - void SetStrExtension(INetURLObject aURL); + const INetURLObject& GetThmURL() const { return maGalleryStorageLocations.GetThmURL(); } + const INetURLObject& GetSdgURL() const { return maGalleryStorageLocations.GetSdgURL(); } + const INetURLObject& GetSdvURL() const { return maGalleryStorageLocations.GetSdvURL(); } + const INetURLObject& GetStrURL() const { return maGalleryStorageLocations.GetStrURL(); } - const INetURLObject& GetThmURL() const { return aThmURL; } - const INetURLObject& GetSdgURL() const { return aSdgURL; } - const INetURLObject& GetSdvURL() const { return aSdvURL; } - const INetURLObject& GetStrURL() const { return aStrURL; } + SAL_DLLPRIVATE bool implWrite(const GalleryTheme& rTheme); - SAL_DLLPRIVATE void ImplCreateSvDrawStorage(bool bReadOnly); - SAL_DLLPRIVATE const tools::SvRef<SotStorage>& GetSvDrawStorage() const; + void insertObject(const SgaObject& rObj, GalleryObject* pFoundEntry, OUString& rDestDir, + ::std::vector<std::unique_ptr<GalleryObject>>& rObjectList, + sal_uInt32& rInsertPos); std::unique_ptr<SgaObject> implReadSgaObject(GalleryObject const* pEntry); bool implWriteSgaObject(const SgaObject& rObj, sal_uInt32 nPos, GalleryObject* pExistentEntry, OUString& aDestDir, ::std::vector<std::unique_ptr<GalleryObject>>& aObjectList); - SAL_DLLPRIVATE bool implWrite(const GalleryTheme& rTheme); bool readModel(const GalleryObject* pObject, SdrModel& rModel); bool insertModel(const FmFormModel& rModel, INetURLObject& rURL); @@ -73,13 +75,6 @@ public: tools::SvRef<SotStorageStream> const& rxModelStream); SgaObjectSvDraw insertModelStream(const tools::SvRef<SotStorageStream>& rxModelStream, INetURLObject& rURL); - - void insertObject(const SgaObject& rObj, GalleryObject* pFoundEntry, OUString& rDestDir, - ::std::vector<std::unique_ptr<GalleryObject>>& rObjectList, - sal_uInt32& rInsertPos); - - SAL_DLLPRIVATE static GalleryThemeEntry* CreateThemeEntry(const INetURLObject& rURL, - bool bReadOnly); }; SvStream& WriteGalleryTheme(SvStream& rOut, const GalleryTheme& rTheme); diff --git a/include/svx/gallerybinaryengineentry.hxx b/include/svx/gallerybinaryengineentry.hxx new file mode 100644 index 000000000000..a310f085df03 --- /dev/null +++ b/include/svx/gallerybinaryengineentry.hxx @@ -0,0 +1,50 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <tools/urlobj.hxx> +#include <svx/svxdllapi.h> +#include <svx/galtheme.hxx> +#include <svx/gallerybinaryengine.hxx> +#include <svx/gallerystoragelocations.hxx> + +class GalleryStorageLocations; + +class SVXCORE_DLLPUBLIC GalleryBinaryEngineEntry +{ +private: + GalleryStorageLocations& maGalleryStorageLocations; + +public: + GalleryBinaryEngineEntry(GalleryStorageLocations& rGalleryStorageLocations); + static void CreateUniqueURL(const INetURLObject& rBaseURL, INetURLObject& aURL); + + OUString ReadStrFromIni(const OUString& aKeyName); + + const INetURLObject& GetThmURL() const { return maGalleryStorageLocations.GetThmURL(); } + const INetURLObject& GetSdgURL() const { return maGalleryStorageLocations.GetSdgURL(); } + const INetURLObject& GetSdvURL() const { return maGalleryStorageLocations.GetSdvURL(); } + const INetURLObject& GetStrURL() const { return maGalleryStorageLocations.GetStrURL(); } + + SAL_DLLPRIVATE static GalleryThemeEntry* CreateThemeEntry(const INetURLObject& rURL, + bool bReadOnly); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svx/gallerystoragelocations.hxx b/include/svx/gallerystoragelocations.hxx new file mode 100644 index 000000000000..77ce6b69c232 --- /dev/null +++ b/include/svx/gallerystoragelocations.hxx @@ -0,0 +1,49 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <tools/urlobj.hxx> +#include <svx/svxdllapi.h> + +class SVXCORE_DLLPUBLIC GalleryStorageLocations +{ +private: + INetURLObject maThmURL; + INetURLObject maSdgURL; + INetURLObject maSdvURL; + INetURLObject maStrURL; + +public: + static INetURLObject ImplGetURLIgnoreCase(const INetURLObject& rURL); + + const INetURLObject& GetThmURL() const { return maThmURL; } + const INetURLObject& GetSdgURL() const { return maSdgURL; } + const INetURLObject& GetSdvURL() const { return maSdvURL; } + const INetURLObject& GetStrURL() const { return maStrURL; } + + void SetThmExtension(INetURLObject& aURL); + void SetSdgExtension(INetURLObject& aURL); + void SetSdvExtension(INetURLObject& aURL); + void SetStrExtension(INetURLObject& aURL); + + void SetStorageLocations(INetURLObject& aURL); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svx/galtheme.hxx b/include/svx/galtheme.hxx index 7d67fe6f3488..1da9eac44a7a 100644 --- a/include/svx/galtheme.hxx +++ b/include/svx/galtheme.hxx @@ -21,6 +21,7 @@ #define INCLUDED_SVX_GALTHEME_HXX #include <svx/svxdllapi.h> +#include <svx/gallerybinaryengine.hxx> #include <tools/debug.hxx> #include <tools/urlobj.hxx> @@ -34,7 +35,6 @@ namespace weld { class ComboBox; } class SotStorageStream; - struct GalleryObject { INetURLObject aURL; @@ -62,6 +62,7 @@ namespace unogallery class GalleryItem; } +class GalleryBinaryEngine; class SVXCORE_DLLPUBLIC GalleryTheme : public SfxBroadcaster { @@ -72,6 +73,7 @@ class SVXCORE_DLLPUBLIC GalleryTheme : public SfxBroadcaster private: + std::unique_ptr<GalleryBinaryEngine> mpGalleryBinaryEngine; ::std::vector< std::unique_ptr<GalleryObject> > aObjectList; OUString m_aDestDir; bool m_bDestDirRelative; @@ -83,6 +85,9 @@ private: bool bDragging; bool bAbortActualize; + std::unique_ptr<GalleryBinaryEngine> createGalleryBinaryEngine(); + const std::unique_ptr<GalleryBinaryEngine>& getGalleryBinaryEngine() const { return mpGalleryBinaryEngine; } + SAL_DLLPRIVATE const GalleryObject* ImplGetGalleryObject(sal_uInt32 nPos) const { if (nPos < aObjectList.size()) |