[Libreoffice-commits] core.git: include/svx svx/source

Aditya (via logerrit) logerrit at kemper.freedesktop.org
Fri Sep 4 19:58:39 UTC 2020


 include/svx/gallery1.hxx                         |    3 ++
 include/svx/gallerybinaryengineentry.hxx         |    4 ++
 include/svx/galtheme.hxx                         |    5 ---
 svx/source/gallery2/gallery1.cxx                 |   34 ++++++-----------------
 svx/source/gallery2/gallerybinaryengineentry.cxx |   34 +++++++++++++++++++++++
 svx/source/gallery2/galtheme.cxx                 |    5 ---
 6 files changed, 51 insertions(+), 34 deletions(-)

New commits:
commit b1a8b0e5327d823da34050e382f7a2838c262881
Author:     Aditya <adityasahu1511 at gmail.com>
AuthorDate: Fri Aug 28 02:16:09 2020 +0530
Commit:     Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Fri Sep 4 21:57:52 2020 +0200

    svx: Refactor Gallery::ImplGetCachedTheme
    
    Introduce GalleryBinaryEngineEntry::getCachedTheme() to refactor
     Gallery::ImplGetCachedTheme.
    
    Change-Id: Ic27a325af0975298143d4746de363edd1d148a42
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101508
    Tested-by: Tomaž Vajngerl <quikee at gmail.com>
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>

diff --git a/include/svx/gallery1.hxx b/include/svx/gallery1.hxx
index 3aa89cc4211d..6d3e7bbd105d 100644
--- a/include/svx/gallery1.hxx
+++ b/include/svx/gallery1.hxx
@@ -79,7 +79,10 @@ public:
     sal_uInt32              GetId() const { return nId; }
     void                    SetId( sal_uInt32 nNewId, bool bResetThemeName );
 
+
     void removeTheme();
+
+    std::unique_ptr<GalleryTheme> getCachedTheme(Gallery* pGallery) const;
 };
 
 class SfxListener;
diff --git a/include/svx/gallerybinaryengineentry.hxx b/include/svx/gallerybinaryengineentry.hxx
index 9b1f25a5b6b4..e2561ce764dd 100644
--- a/include/svx/gallerybinaryengineentry.hxx
+++ b/include/svx/gallerybinaryengineentry.hxx
@@ -47,6 +47,10 @@ public:
     static GalleryThemeEntry* CreateThemeEntry(const INetURLObject& rURL, bool bReadOnly);
 
     void removeTheme();
+
+    std::unique_ptr<GalleryTheme>& getCachedTheme(std::unique_ptr<GalleryTheme>& pNewTheme);
 };
 
+SvStream& ReadGalleryTheme(SvStream& rIn, GalleryTheme& rTheme);
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/svx/galtheme.hxx b/include/svx/galtheme.hxx
index c15d03d14b02..dcf5e7f198e4 100644
--- a/include/svx/galtheme.hxx
+++ b/include/svx/galtheme.hxx
@@ -74,12 +74,11 @@ private:
     SAL_DLLPRIVATE void         ImplSetModified( bool bModified );
     SAL_DLLPRIVATE void         ImplBroadcast(sal_uInt32 nUpdatePos);
 
-    SAL_DLLPRIVATE              GalleryTheme( Gallery* pGallery, GalleryThemeEntry* pThemeEntry );
-
     GalleryTheme(GalleryTheme const &) = delete;
     void operator =(GalleryTheme const &) = delete;
 
 public:
+    SAL_DLLPRIVATE              GalleryTheme(Gallery* pGallery, GalleryThemeEntry* pThemeEntry);
 
     SAL_DLLPRIVATE              virtual ~GalleryTheme() override;
 
@@ -168,8 +167,6 @@ public:
     SAL_DLLPRIVATE void SetPreviewBitmapExAndStrings(sal_uInt32 nPos, const BitmapEx& rBitmapEx, const Size& rSize, const OUString& rTitle, const OUString& rPath);
 };
 
-SvStream& ReadGalleryTheme( SvStream& rIn, GalleryTheme& rTheme );
-
 #endif // INCLUDED_SVX_GALTHEME_HXX
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/gallery2/gallery1.cxx b/svx/source/gallery2/gallery1.cxx
index 5e1182c46a4d..78f517f63868 100644
--- a/svx/source/gallery2/gallery1.cxx
+++ b/svx/source/gallery2/gallery1.cxx
@@ -636,6 +636,14 @@ bool Gallery::RemoveTheme( const OUString& rThemeName )
     return bRet;
 }
 
+std::unique_ptr<GalleryTheme> GalleryThemeEntry::getCachedTheme(Gallery* pGallery) const
+{
+    std::unique_ptr<GalleryTheme> pNewTheme;
+    pNewTheme.reset(new GalleryTheme(pGallery, const_cast<GalleryThemeEntry*>(this)));
+    mpGalleryStorageEngineEntry->getCachedTheme(pNewTheme);
+    return pNewTheme;
+}
+
 GalleryTheme* Gallery::ImplGetCachedTheme(const GalleryThemeEntry* pThemeEntry)
 {
     GalleryTheme* pTheme = nullptr;
@@ -649,31 +657,7 @@ GalleryTheme* Gallery::ImplGetCachedTheme(const GalleryThemeEntry* pThemeEntry)
 
         if( !pTheme )
         {
-            INetURLObject aURL = pThemeEntry->GetThmURL();
-
-            DBG_ASSERT( aURL.GetProtocol() != INetProtocol::NotValid, "invalid URL" );
-
-            std::unique_ptr<GalleryTheme> pNewTheme;
-            if( FileExists( aURL ) )
-            {
-                std::unique_ptr<SvStream> pIStm(::utl::UcbStreamHelper::CreateStream( aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ), StreamMode::READ ));
-
-                if( pIStm )
-                {
-                    try
-                    {
-                        pNewTheme.reset( new GalleryTheme( this, const_cast<GalleryThemeEntry*>(pThemeEntry) ) );
-                        ReadGalleryTheme( *pIStm, *pNewTheme );
-
-                        if( pIStm->GetError() )
-                            pNewTheme.reset();
-                    }
-                    catch (const css::ucb::ContentCreationException&)
-                    {
-                    }
-                }
-            }
-
+            std::unique_ptr<GalleryTheme> pNewTheme = pThemeEntry->getCachedTheme(this);
             if (pNewTheme)
             {
                 aThemeCache.push_back( new GalleryThemeCacheEntry( pThemeEntry, std::move(pNewTheme) ));
diff --git a/svx/source/gallery2/gallerybinaryengineentry.cxx b/svx/source/gallery2/gallerybinaryengineentry.cxx
index 56c836677c3a..8255b2b8a276 100644
--- a/svx/source/gallery2/gallerybinaryengineentry.cxx
+++ b/svx/source/gallery2/gallerybinaryengineentry.cxx
@@ -32,6 +32,8 @@
 #include <tools/urlobj.hxx>
 #include <tools/vcompat.hxx>
 
+#include <com/sun/star/ucb/ContentCreationException.hpp>
+
 static bool FileExists(const INetURLObject& rURL, const OUString& rExt)
 {
     INetURLObject aURL(rURL);
@@ -140,4 +142,36 @@ void GalleryBinaryEngineEntry::removeTheme()
     KillFile(aSdvURL);
     KillFile(aStrURL);
 }
+
+std::unique_ptr<GalleryTheme>&
+GalleryBinaryEngineEntry::getCachedTheme(std::unique_ptr<GalleryTheme>& pNewTheme)
+{
+    INetURLObject aURL = GetThmURL();
+
+    DBG_ASSERT(aURL.GetProtocol() != INetProtocol::NotValid, "invalid URL");
+
+    if (FileExists(aURL))
+    {
+        std::unique_ptr<SvStream> pIStm(::utl::UcbStreamHelper::CreateStream(
+            aURL.GetMainURL(INetURLObject::DecodeMechanism::NONE), StreamMode::READ));
+
+        if (pIStm)
+        {
+            try
+            {
+                ReadGalleryTheme(*pIStm, *pNewTheme);
+
+                if (pIStm->GetError())
+                    pNewTheme.reset();
+            }
+            catch (const css::ucb::ContentCreationException&)
+            {
+            }
+        }
+    }
+    return pNewTheme;
+}
+
+SvStream& ReadGalleryTheme(SvStream& rIn, GalleryTheme& rTheme) { return rTheme.ReadData(rIn); }
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/gallery2/galtheme.cxx b/svx/source/gallery2/galtheme.cxx
index fd395eeb0601..a25964afa1f3 100644
--- a/svx/source/gallery2/galtheme.cxx
+++ b/svx/source/gallery2/galtheme.cxx
@@ -784,11 +784,6 @@ SvStream& GalleryTheme::ReadData( SvStream& rIStm )
     return rIStm;
 }
 
-SvStream& ReadGalleryTheme( SvStream& rIn, GalleryTheme& rTheme )
-{
-    return rTheme.ReadData( rIn );
-}
-
 void GalleryTheme::ImplSetModified( bool bModified )
 {
     pThm->SetModified(bModified);


More information about the Libreoffice-commits mailing list