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

Aditya (via logerrit) logerrit at kemper.freedesktop.org
Mon Jun 22 22:20:33 UTC 2020


 include/svx/gallerybinaryengine.hxx         |    8 -
 include/svx/galtheme.hxx                    |    3 
 svx/source/gallery2/gallery1.cxx            |    4 
 svx/source/gallery2/gallerybinaryengine.cxx |  219 +++++++++++++++++++++++++++-
 svx/source/gallery2/galtheme.cxx            |  191 +-----------------------
 svx/source/unogallery/unogalitem.cxx        |    3 
 6 files changed, 239 insertions(+), 189 deletions(-)

New commits:
commit aadcd6f90916bd2b9734ae793141d0c77cc5b46c
Author:     Aditya <adityasahu1511 at gmail.com>
AuthorDate: Wed Jun 17 19:41:59 2020 +0530
Commit:     Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Tue Jun 23 00:19:56 2020 +0200

    svx:Refactor members of GalleryTheme class to GalleryBinaryEngine
    
    Move those data members and functions in GalleryTheme that deal with reading
     and writing of binary files to the new class GalleryBinaryEngine. These
     internal changes must not reflect any change in the behaviour.
    Functions moved in this patch: ImplReadSgaObject(), ImplWrite(),
     ImplCreateUniqueURL()
    
    Change-Id: Ifd30bc7920f31007dfe7fe2ffdc539dfc43976ac
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96541
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>

diff --git a/include/svx/gallerybinaryengine.hxx b/include/svx/gallerybinaryengine.hxx
index f658b248735c..5b655cfc49fc 100644
--- a/include/svx/gallerybinaryengine.hxx
+++ b/include/svx/gallerybinaryengine.hxx
@@ -50,9 +50,15 @@ public:
     const INetURLObject& GetSdvURL() const { return aSdvURL; }
     const INetURLObject& GetStrURL() const { return aStrURL; }
 
-    bool ImplWriteSgaObject(const SgaObject& rObj, sal_uInt32 nPos, GalleryObject* pExistentEntry,
+    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);
+    SAL_DLLPRIVATE static INetURLObject
+    implCreateUniqueURL(SgaObjKind eObjKind, const INetURLObject& rUserURL,
+                        ::std::vector<std::unique_ptr<GalleryObject>>& rObjectList,
+                        ConvertDataFormat nFormat = ConvertDataFormat::Unknown);
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/svx/galtheme.hxx b/include/svx/galtheme.hxx
index 3af46ca2431e..44b13f0fd539 100644
--- a/include/svx/galtheme.hxx
+++ b/include/svx/galtheme.hxx
@@ -86,8 +86,6 @@ private:
     bool                        bAbortActualize;
 
     SAL_DLLPRIVATE void         ImplCreateSvDrawStorage();
-    std::unique_ptr<SgaObject>  ImplReadSgaObject( GalleryObject const * pEntry );
-    SAL_DLLPRIVATE void         ImplWrite();
     SAL_DLLPRIVATE const GalleryObject* ImplGetGalleryObject(sal_uInt32 nPos) const
     {
         if (nPos < aObjectList.size())
@@ -104,7 +102,6 @@ private:
                                     return SAL_MAX_UINT32;
                                 }
     SAL_DLLPRIVATE static INetURLObject ImplGetURL( const GalleryObject* pObject );
-    SAL_DLLPRIVATE INetURLObject ImplCreateUniqueURL( SgaObjKind eObjKind, ConvertDataFormat nFormat = ConvertDataFormat::Unknown );
     SAL_DLLPRIVATE void         ImplSetModified( bool bModified );
     SAL_DLLPRIVATE void         ImplBroadcast(sal_uInt32 nUpdatePos);
 
diff --git a/svx/source/gallery2/gallery1.cxx b/svx/source/gallery2/gallery1.cxx
index 3bd04dbeb527..7f0c524fda65 100644
--- a/svx/source/gallery2/gallery1.cxx
+++ b/svx/source/gallery2/gallery1.cxx
@@ -593,7 +593,9 @@ void Gallery::RenameTheme( const OUString& rOldName, const OUString& rNewName )
         if( pThm )
         {
             pThemeEntry->SetName( rNewName );
-            pThm->ImplWrite();
+            if (pThm->pThm->IsModified())
+                if (!pThm->pThm->getGalleryBinaryEngine()->implWrite(*pThm))
+                    pThm->ImplSetModified(false);
 
             Broadcast( GalleryHint( GalleryHintType::THEME_RENAMED, rOldName, pThm->GetName() ) );
             ReleaseTheme( pThm, aListener );
diff --git a/svx/source/gallery2/gallerybinaryengine.cxx b/svx/source/gallery2/gallerybinaryengine.cxx
index c5d2f018e1d4..f72247ba038b 100644
--- a/svx/source/gallery2/gallerybinaryengine.cxx
+++ b/svx/source/gallery2/gallerybinaryengine.cxx
@@ -19,10 +19,12 @@
 
 #include <svx/gallerybinaryengine.hxx>
 #include <svx/galmisc.hxx>
+#include <vcl/salctype.hxx>
 #include <galobj.hxx>
 
 #include <unotools/ucbstreamhelper.hxx>
 #include <tools/urlobj.hxx>
+#include <tools/vcompat.hxx>
 
 static bool FileExists(const INetURLObject& rURL, const OUString& rExt)
 {
@@ -88,9 +90,64 @@ void GalleryBinaryEngine::SetStrExtension(INetURLObject aURL)
     aStrURL = ImplGetURLIgnoreCase(aURL);
 }
 
-bool GalleryBinaryEngine::ImplWriteSgaObject(
+std::unique_ptr<SgaObject> GalleryBinaryEngine::implReadSgaObject(GalleryObject const* pEntry)
+{
+    std::unique_ptr<SgaObject> pSgaObj;
+
+    if (pEntry)
+    {
+        std::unique_ptr<SvStream> pIStm(::utl::UcbStreamHelper::CreateStream(
+            GetSdgURL().GetMainURL(INetURLObject::DecodeMechanism::NONE), StreamMode::READ));
+
+        if (pIStm)
+        {
+            sal_uInt32 nInventor;
+
+            // Check to ensure that the file is a valid SGA file
+            pIStm->Seek(pEntry->nOffset);
+            pIStm->ReadUInt32(nInventor);
+
+            if (nInventor == COMPAT_FORMAT('S', 'G', 'A', '3'))
+            {
+                pIStm->Seek(pEntry->nOffset);
+
+                switch (pEntry->eObjKind)
+                {
+                    case SgaObjKind::Bitmap:
+                        pSgaObj.reset(new SgaObjectBmp());
+                        break;
+                    case SgaObjKind::Animation:
+                        pSgaObj.reset(new SgaObjectAnim());
+                        break;
+                    case SgaObjKind::Inet:
+                        pSgaObj.reset(new SgaObjectINet());
+                        break;
+                    case SgaObjKind::SvDraw:
+                        pSgaObj.reset(new SgaObjectSvDraw());
+                        break;
+                    case SgaObjKind::Sound:
+                        pSgaObj.reset(new SgaObjectSound());
+                        break;
+
+                    default:
+                        break;
+                }
+
+                if (pSgaObj)
+                {
+                    ReadSgaObject(*pIStm, *pSgaObj);
+                    pSgaObj->ImplUpdateURL(pEntry->aURL);
+                }
+            }
+        }
+    }
+
+    return pSgaObj;
+}
+
+bool GalleryBinaryEngine::implWriteSgaObject(
     const SgaObject& rObj, sal_uInt32 nPos, GalleryObject* pExistentEntry, OUString& aDestDir,
-    ::std::vector<std::unique_ptr<GalleryObject>>& aObjectList)
+    ::std::vector<std::unique_ptr<GalleryObject>>& rObjectList)
 {
     std::unique_ptr<SvStream> pOStm(::utl::UcbStreamHelper::CreateStream(
         GetSdgURL().GetMainURL(INetURLObject::DecodeMechanism::NONE), StreamMode::WRITE));
@@ -109,12 +166,12 @@ bool GalleryBinaryEngine::ImplWriteSgaObject(
             if (!pExistentEntry)
             {
                 pEntry = new GalleryObject;
-                if (nPos < aObjectList.size())
+                if (nPos < rObjectList.size())
                 {
-                    aObjectList.emplace(aObjectList.begin() + nPos, pEntry);
+                    rObjectList.emplace(rObjectList.begin() + nPos, pEntry);
                 }
                 else
-                    aObjectList.emplace_back(pEntry);
+                    rObjectList.emplace_back(pEntry);
             }
             else
                 pEntry = pExistentEntry;
@@ -128,3 +185,155 @@ bool GalleryBinaryEngine::ImplWriteSgaObject(
 
     return bRet;
 }
+
+bool GalleryBinaryEngine::implWrite(const GalleryTheme& rTheme)
+{
+    INetURLObject aPathURL(GetThmURL());
+
+    aPathURL.removeSegment();
+    aPathURL.removeFinalSlash();
+
+    DBG_ASSERT(aPathURL.GetProtocol() != INetProtocol::NotValid, "invalid URL");
+
+    if (FileExists(aPathURL) || CreateDir(aPathURL))
+    {
+#ifdef UNX
+        std::unique_ptr<SvStream> pOStm(::utl::UcbStreamHelper::CreateStream(
+            GetThmURL().GetMainURL(INetURLObject::DecodeMechanism::NONE),
+            StreamMode::WRITE | StreamMode::COPY_ON_SYMLINK | StreamMode::TRUNC));
+#else
+        std::unique_ptr<SvStream> pOStm(::utl::UcbStreamHelper::CreateStream(
+            GetThmURL().GetMainURL(INetURLObject::DecodeMechanism::NONE),
+            StreamMode::WRITE | StreamMode::TRUNC));
+#endif
+
+        if (pOStm)
+        {
+            WriteGalleryTheme(*pOStm, rTheme);
+            pOStm.reset();
+            return true;
+        }
+
+        return false;
+    }
+    return true;
+}
+
+INetURLObject
+GalleryBinaryEngine::implCreateUniqueURL(SgaObjKind eObjKind, const INetURLObject& rUserURL,
+                                         ::std::vector<std::unique_ptr<GalleryObject>>& rObjectList,
+                                         ConvertDataFormat nFormat)
+{
+    INetURLObject aDir(rUserURL);
+    INetURLObject aInfoFileURL(rUserURL);
+    INetURLObject aNewURL;
+    sal_uInt32 nNextNumber = 1999;
+    char const* pExt = nullptr;
+    bool bExists;
+
+    aDir.Append("dragdrop");
+    CreateDir(aDir);
+
+    aInfoFileURL.Append("sdddndx1");
+
+    // read next possible number
+    if (FileExists(aInfoFileURL))
+    {
+        std::unique_ptr<SvStream> pIStm(::utl::UcbStreamHelper::CreateStream(
+            aInfoFileURL.GetMainURL(INetURLObject::DecodeMechanism::NONE), StreamMode::READ));
+
+        if (pIStm)
+        {
+            pIStm->ReadUInt32(nNextNumber);
+        }
+    }
+
+    // create extension
+    if (nFormat != ConvertDataFormat::Unknown)
+    {
+        switch (nFormat)
+        {
+            case ConvertDataFormat::BMP:
+                pExt = ".bmp";
+                break;
+            case ConvertDataFormat::GIF:
+                pExt = ".gif";
+                break;
+            case ConvertDataFormat::JPG:
+                pExt = ".jpg";
+                break;
+            case ConvertDataFormat::MET:
+                pExt = ".met";
+                break;
+            case ConvertDataFormat::PCT:
+                pExt = ".pct";
+                break;
+            case ConvertDataFormat::PNG:
+                pExt = ".png";
+                break;
+            case ConvertDataFormat::SVM:
+                pExt = ".svm";
+                break;
+            case ConvertDataFormat::TIF:
+                pExt = ".tif";
+                break;
+            case ConvertDataFormat::WMF:
+                pExt = ".wmf";
+                break;
+            case ConvertDataFormat::EMF:
+                pExt = ".emf";
+                break;
+
+            default:
+                pExt = ".grf";
+                break;
+        }
+    }
+
+    do
+    {
+        // get URL
+        if (SgaObjKind::SvDraw == eObjKind)
+        {
+            OUString aFileName = "gallery/svdraw/dd" + OUString::number(++nNextNumber % 99999999);
+            aNewURL = INetURLObject(aFileName, INetProtocol::PrivSoffice);
+
+            bExists = false;
+
+            for (auto const& p : rObjectList)
+                if (p->aURL == aNewURL)
+                {
+                    bExists = true;
+                    break;
+                }
+        }
+        else
+        {
+            OUString aFileName = "dd" + OUString::number(++nNextNumber % 999999);
+
+            if (pExt)
+                aFileName += OUString(pExt, strlen(pExt), RTL_TEXTENCODING_ASCII_US);
+
+            aNewURL = aDir;
+            aNewURL.Append(aFileName);
+
+            bExists = FileExists(aNewURL);
+        }
+    } while (bExists);
+
+    // write updated number
+    std::unique_ptr<SvStream> pOStm(::utl::UcbStreamHelper::CreateStream(
+        aInfoFileURL.GetMainURL(INetURLObject::DecodeMechanism::NONE), StreamMode::WRITE));
+
+    if (pOStm)
+    {
+        pOStm->WriteUInt32(nNextNumber);
+    }
+
+    return aNewURL;
+}
+
+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 e849542e4ef2..ec52c09b56e5 100644
--- a/svx/source/gallery2/galtheme.cxx
+++ b/svx/source/gallery2/galtheme.cxx
@@ -75,7 +75,9 @@ GalleryTheme::GalleryTheme( Gallery* pGallery, GalleryThemeEntry* pThemeEntry )
 
 GalleryTheme::~GalleryTheme()
 {
-    ImplWrite();
+    if(pThm->IsModified())
+        if(!pThm->getGalleryBinaryEngine()->implWrite(*this))
+            ImplSetModified(false);
 
     for (auto & pEntry : aObjectList)
     {
@@ -103,80 +105,6 @@ void GalleryTheme::ImplCreateSvDrawStorage()
     }
 }
 
-std::unique_ptr<SgaObject> GalleryTheme::ImplReadSgaObject( GalleryObject const * pEntry )
-{
-    std::unique_ptr<SgaObject> pSgaObj;
-
-    if( pEntry )
-    {
-        std::unique_ptr<SvStream> pIStm(::utl::UcbStreamHelper::CreateStream( GetSdgURL().GetMainURL( INetURLObject::DecodeMechanism::NONE ), StreamMode::READ ));
-
-        if( pIStm )
-        {
-            sal_uInt32 nInventor;
-
-            // Check to ensure that the file is a valid SGA file
-            pIStm->Seek( pEntry->nOffset );
-            pIStm->ReadUInt32( nInventor );
-
-            if( nInventor == COMPAT_FORMAT( 'S', 'G', 'A', '3' ) )
-            {
-                pIStm->Seek( pEntry->nOffset );
-
-                switch( pEntry->eObjKind )
-                {
-                    case SgaObjKind::Bitmap:    pSgaObj.reset(new SgaObjectBmp()); break;
-                    case SgaObjKind::Animation:   pSgaObj.reset(new SgaObjectAnim()); break;
-                    case SgaObjKind::Inet:   pSgaObj.reset(new SgaObjectINet()); break;
-                    case SgaObjKind::SvDraw: pSgaObj.reset(new SgaObjectSvDraw()); break;
-                    case SgaObjKind::Sound:  pSgaObj.reset(new SgaObjectSound()); break;
-
-                    default:
-                    break;
-                }
-
-                if( pSgaObj )
-                {
-                    ReadSgaObject( *pIStm, *pSgaObj );
-                    pSgaObj->ImplUpdateURL( pEntry->aURL );
-                }
-            }
-        }
-    }
-
-    return pSgaObj;
-}
-
-void GalleryTheme::ImplWrite()
-{
-    if( pThm->IsModified() )
-    {
-        INetURLObject aPathURL( GetThmURL() );
-
-        aPathURL.removeSegment();
-        aPathURL.removeFinalSlash();
-
-        DBG_ASSERT( aPathURL.GetProtocol() != INetProtocol::NotValid, "invalid URL" );
-
-        if( FileExists( aPathURL ) || CreateDir( aPathURL ) )
-        {
-#ifdef UNX
-            std::unique_ptr<SvStream> pOStm(::utl::UcbStreamHelper::CreateStream( GetThmURL().GetMainURL( INetURLObject::DecodeMechanism::NONE ), StreamMode::WRITE | StreamMode::COPY_ON_SYMLINK | StreamMode::TRUNC ));
-#else
-            std::unique_ptr<SvStream> pOStm(::utl::UcbStreamHelper::CreateStream( GetThmURL().GetMainURL( INetURLObject::DecodeMechanism::NONE ), StreamMode::WRITE | StreamMode::TRUNC ));
-#endif
-
-            if( pOStm )
-            {
-                WriteGalleryTheme( *pOStm, *this );
-                pOStm.reset();
-            }
-
-            ImplSetModified( false );
-        }
-    }
-}
-
 const GalleryObject* GalleryTheme::ImplGetGalleryObject( const INetURLObject& rURL )
 {
     for (auto const & i : aObjectList)
@@ -195,96 +123,6 @@ INetURLObject GalleryTheme::ImplGetURL( const GalleryObject* pObject )
     return aURL;
 }
 
-INetURLObject GalleryTheme::ImplCreateUniqueURL( SgaObjKind eObjKind, ConvertDataFormat nFormat )
-{
-    INetURLObject   aDir( GetParent()->GetUserURL() );
-    INetURLObject   aInfoFileURL( GetParent()->GetUserURL() );
-    INetURLObject   aNewURL;
-    sal_uInt32      nNextNumber = 1999;
-    char const*     pExt = nullptr;
-    bool            bExists;
-
-    aDir.Append( "dragdrop" );
-    CreateDir( aDir );
-
-    aInfoFileURL.Append( "sdddndx1" );
-
-    // read next possible number
-    if( FileExists( aInfoFileURL ) )
-    {
-        std::unique_ptr<SvStream> pIStm(::utl::UcbStreamHelper::CreateStream( aInfoFileURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ), StreamMode::READ ));
-
-        if( pIStm )
-        {
-            pIStm->ReadUInt32( nNextNumber );
-        }
-    }
-
-    // create extension
-    if( nFormat != ConvertDataFormat::Unknown )
-    {
-        switch( nFormat )
-        {
-            case ConvertDataFormat::BMP: pExt = ".bmp"; break;
-            case ConvertDataFormat::GIF: pExt = ".gif"; break;
-            case ConvertDataFormat::JPG: pExt = ".jpg"; break;
-            case ConvertDataFormat::MET: pExt = ".met"; break;
-            case ConvertDataFormat::PCT: pExt = ".pct"; break;
-            case ConvertDataFormat::PNG: pExt = ".png"; break;
-            case ConvertDataFormat::SVM: pExt = ".svm"; break;
-            case ConvertDataFormat::TIF: pExt = ".tif"; break;
-            case ConvertDataFormat::WMF: pExt = ".wmf"; break;
-            case ConvertDataFormat::EMF: pExt = ".emf"; break;
-
-            default:
-                pExt = ".grf";
-            break;
-        }
-    }
-
-    do
-    {
-        // get URL
-        if( SgaObjKind::SvDraw == eObjKind )
-        {
-            OUString aFileName = "gallery/svdraw/dd" + OUString::number( ++nNextNumber % 99999999 );
-            aNewURL = INetURLObject( aFileName, INetProtocol::PrivSoffice );
-
-            bExists = false;
-
-            for (auto const & p : aObjectList)
-                if ( p->aURL == aNewURL )
-                {
-                    bExists = true;
-                    break;
-                }
-        }
-        else
-        {
-            OUString aFileName = "dd" + OUString::number( ++nNextNumber % 999999 );
-
-            if (pExt)
-                aFileName += OUString( pExt, strlen(pExt), RTL_TEXTENCODING_ASCII_US );
-
-            aNewURL = aDir;
-            aNewURL.Append( aFileName );
-
-            bExists = FileExists( aNewURL );
-        }
-    }
-    while( bExists );
-
-    // write updated number
-    std::unique_ptr<SvStream> pOStm(::utl::UcbStreamHelper::CreateStream( aInfoFileURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ), StreamMode::WRITE ));
-
-    if( pOStm )
-    {
-        pOStm->WriteUInt32( nNextNumber );
-    }
-
-    return aNewURL;
-}
-
 void GalleryTheme::ImplBroadcast(sal_uInt32 nUpdatePos)
 {
     if( !IsBroadcasterLocked() )
@@ -342,7 +180,7 @@ bool GalleryTheme::InsertObject(const SgaObject& rObj, sal_uInt32 nInsertPos)
         // update title of new object if necessary
         if (rObj.GetTitle().isEmpty())
         {
-            std::unique_ptr<SgaObject> pOldObj(ImplReadSgaObject(pFoundEntry));
+            std::unique_ptr<SgaObject> pOldObj(pThm->getGalleryBinaryEngine()->implReadSgaObject(pFoundEntry));
 
             if (pOldObj)
             {
@@ -352,11 +190,11 @@ bool GalleryTheme::InsertObject(const SgaObject& rObj, sal_uInt32 nInsertPos)
         else if (rObj.GetTitle() == "__<empty>__")
             const_cast<SgaObject&>(rObj).SetTitle("");
 
-        pThm->getGalleryBinaryEngine()->ImplWriteSgaObject(rObj, nInsertPos, &aNewEntry, m_aDestDir, aObjectList);
+        pThm->getGalleryBinaryEngine()->implWriteSgaObject(rObj, nInsertPos, &aNewEntry, m_aDestDir, aObjectList);
         pFoundEntry->nOffset = aNewEntry.nOffset;
     }
     else
-        pThm->getGalleryBinaryEngine()->ImplWriteSgaObject(rObj, nInsertPos, nullptr, m_aDestDir, aObjectList);
+        pThm->getGalleryBinaryEngine()->implWriteSgaObject(rObj, nInsertPos, nullptr, m_aDestDir, aObjectList);
 
     ImplSetModified(true);
     ImplBroadcast(pFoundEntry? iFoundPos: nInsertPos);
@@ -366,7 +204,7 @@ bool GalleryTheme::InsertObject(const SgaObject& rObj, sal_uInt32 nInsertPos)
 
 std::unique_ptr<SgaObject> GalleryTheme::AcquireObject(sal_uInt32 nPos)
 {
-    return ImplReadSgaObject(ImplGetGalleryObject(nPos));
+    return pThm->getGalleryBinaryEngine()->implReadSgaObject(ImplGetGalleryObject(nPos));
 }
 
 void GalleryTheme::GetPreviewBitmapExAndStrings(sal_uInt32 nPos, BitmapEx& rBitmapEx, Size& rSize, OUString& rTitle, OUString& rPath) const
@@ -599,7 +437,9 @@ void GalleryTheme::Actualize( const Link<const INetURLObject&, void>& rActualize
 
     KillFile( aTmpURL );
     ImplSetModified( true );
-    ImplWrite();
+    if (pThm->IsModified())
+        if (!pThm->getGalleryBinaryEngine()->implWrite(*this))
+            ImplSetModified(false);
     UnlockBroadcaster();
 }
 
@@ -802,7 +642,7 @@ bool GalleryTheme::InsertGraphic(const Graphic& rGraphic, sal_uInt32 nInsertPos)
                 nExportFormat = ConvertDataFormat::SVM;
         }
 
-        const INetURLObject aURL( ImplCreateUniqueURL( SgaObjKind::Bitmap, nExportFormat ) );
+        const INetURLObject aURL( GalleryBinaryEngine::implCreateUniqueURL( SgaObjKind::Bitmap, GetParent()->GetUserURL(), aObjectList, nExportFormat ) );
         std::unique_ptr<SvStream> pOStm(::utl::UcbStreamHelper::CreateStream( aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ), StreamMode::WRITE | StreamMode::TRUNC ));
 
         if( pOStm )
@@ -869,7 +709,7 @@ bool GalleryTheme::GetModel(sal_uInt32 nPos, SdrModel& rModel)
 
 bool GalleryTheme::InsertModel(const FmFormModel& rModel, sal_uInt32 nInsertPos)
 {
-    INetURLObject   aURL( ImplCreateUniqueURL( SgaObjKind::SvDraw ) );
+    INetURLObject   aURL( GalleryBinaryEngine::implCreateUniqueURL( SgaObjKind::SvDraw, GetParent()->GetUserURL(), aObjectList) );
     tools::SvRef<SotStorage>    xStor( GetSvDrawStorage() );
     bool            bRet = false;
 
@@ -965,7 +805,7 @@ bool GalleryTheme::GetModelStream(sal_uInt32 nPos, tools::SvRef<SotStorageStream
 
 bool GalleryTheme::InsertModelStream(const tools::SvRef<SotStorageStream>& rxModelStream, sal_uInt32 nInsertPos)
 {
-    INetURLObject   aURL( ImplCreateUniqueURL( SgaObjKind::SvDraw ) );
+    INetURLObject   aURL( GalleryBinaryEngine::implCreateUniqueURL( SgaObjKind::SvDraw, GetParent()->GetUserURL(), aObjectList ) );
     tools::SvRef<SotStorage>    xStor( GetSvDrawStorage() );
     bool            bRet = false;
 
@@ -1396,11 +1236,6 @@ SvStream& GalleryTheme::ReadData( SvStream& rIStm )
     return rIStm;
 }
 
-SvStream& WriteGalleryTheme( SvStream& rOut, const GalleryTheme& rTheme )
-{
-    return rTheme.WriteData( rOut );
-}
-
 SvStream& ReadGalleryTheme( SvStream& rIn, GalleryTheme& rTheme )
 {
     return rTheme.ReadData( rIn );
diff --git a/svx/source/unogallery/unogalitem.cxx b/svx/source/unogallery/unogalitem.cxx
index 5ddf5611ebe4..b94ec657561f 100644
--- a/svx/source/unogallery/unogalitem.cxx
+++ b/svx/source/unogallery/unogalitem.cxx
@@ -22,6 +22,7 @@
 #include "unogaltheme.hxx"
 #include <svx/galtheme.hxx>
 #include <svx/galmisc.hxx>
+#include <svx/gallery1.hxx>
 #include <svx/fmmodel.hxx>
 #include <vcl/svapp.hxx>
 #include <vcl/graph.hxx>
@@ -219,7 +220,7 @@ void GalleryItem::_setPropertyValues( const comphelper::PropertyMapEntry** ppEnt
 
             if( pGalTheme )
             {
-                std::unique_ptr<SgaObject> pObj(pGalTheme->ImplReadSgaObject( implGetObject() ));
+                std::unique_ptr<SgaObject> pObj(pGalTheme->pThm->getGalleryBinaryEngine()->implReadSgaObject( implGetObject() ));
 
                 if( pObj )
                 {


More information about the Libreoffice-commits mailing list