[Libreoffice-commits] core.git: Branch 'libreoffice-4-3' - comphelper/source include/comphelper sfx2/source svtools/source

Armin Le Grand alg at apache.org
Tue Aug 12 01:07:29 PDT 2014


 comphelper/source/container/embeddedobjectcontainer.cxx |   36 ++++++++++++----
 include/comphelper/embeddedobjectcontainer.hxx          |    3 +
 sfx2/source/appl/linkmgr2.cxx                           |   12 ++++-
 svtools/source/misc/embedhlp.cxx                        |   29 ++++++++----
 4 files changed, 62 insertions(+), 18 deletions(-)

New commits:
commit b6b84b972fc9b997a586ca2e5496eb0617544a1a
Author: Armin Le Grand <alg at apache.org>
Date:   Thu Aug 7 09:59:26 2014 +0000

    Resolves: #i125386# secured user request and changed some bools to bitfield
    
    (cherry picked from commit 5e3cbe056c19bea5018dbf1fd4b2bc8f8b030ff3)
    
    Conflicts:
    	comphelper/inc/comphelper/embeddedobjectcontainer.hxx
    	comphelper/source/container/embeddedobjectcontainer.cxx
    	sfx2/source/appl/linkmgr2.cxx
    	svtools/source/misc/embedhlp.cxx
    
    Change-Id: I7e9b20a87ca6afe8cb91c577860a6c6b72368ee9
    (cherry picked from commit d005acae3aa315921f2c331612131626c470bd22)

diff --git a/comphelper/source/container/embeddedobjectcontainer.cxx b/comphelper/source/container/embeddedobjectcontainer.cxx
index 9437893..d7813d7 100644
--- a/comphelper/source/container/embeddedobjectcontainer.cxx
+++ b/comphelper/source/container/embeddedobjectcontainer.cxx
@@ -85,7 +85,10 @@ struct EmbedImpl
     uno::WeakReference < uno::XInterface > m_xModel;
     //EmbeddedObjectContainerNameMap maTempObjectContainer;
     //uno::Reference < embed::XStorage > mxTempStorage;
-    bool bOwnsStorage;
+
+    /// bitfield
+    bool mbOwnsStorage : 1;
+    bool mbUserAllowsLinkUpdate : 1;
 
     const uno::Reference < embed::XStorage >& GetReplacements();
 };
@@ -116,7 +119,8 @@ EmbeddedObjectContainer::EmbeddedObjectContainer()
 {
     pImpl = new EmbedImpl;
     pImpl->mxStorage = ::comphelper::OStorageHelper::GetTemporaryStorage();
-    pImpl->bOwnsStorage = true;
+    pImpl->mbOwnsStorage = true;
+    pImpl->mbUserAllowsLinkUpdate = true;
     pImpl->mpTempObjectContainer = 0;
 }
 
@@ -124,7 +128,8 @@ EmbeddedObjectContainer::EmbeddedObjectContainer( const uno::Reference < embed::
 {
     pImpl = new EmbedImpl;
     pImpl->mxStorage = rStor;
-    pImpl->bOwnsStorage = false;
+    pImpl->mbOwnsStorage = false;
+    pImpl->mbUserAllowsLinkUpdate = true;
     pImpl->mpTempObjectContainer = 0;
 }
 
@@ -132,7 +137,8 @@ EmbeddedObjectContainer::EmbeddedObjectContainer( const uno::Reference < embed::
 {
     pImpl = new EmbedImpl;
     pImpl->mxStorage = rStor;
-    pImpl->bOwnsStorage = false;
+    pImpl->mbOwnsStorage = false;
+    pImpl->mbUserAllowsLinkUpdate = true;
     pImpl->mpTempObjectContainer = 0;
     pImpl->m_xModel = xModel;
 }
@@ -141,11 +147,11 @@ void EmbeddedObjectContainer::SwitchPersistence( const uno::Reference < embed::X
 {
     ReleaseImageSubStorage();
 
-    if ( pImpl->bOwnsStorage )
+    if ( pImpl->mbOwnsStorage )
         pImpl->mxStorage->dispose();
 
     pImpl->mxStorage = rStor;
-    pImpl->bOwnsStorage = false;
+    pImpl->mbOwnsStorage = false;
 }
 
 bool EmbeddedObjectContainer::CommitImageSubStorage()
@@ -201,7 +207,7 @@ EmbeddedObjectContainer::~EmbeddedObjectContainer()
 {
     ReleaseImageSubStorage();
 
-    if ( pImpl->bOwnsStorage )
+    if ( pImpl->mbOwnsStorage )
         pImpl->mxStorage->dispose();
 
     delete pImpl->mpTempObjectContainer;
@@ -1360,7 +1366,7 @@ bool EmbeddedObjectContainer::StoreAsChildren(bool _bOasisFormat,bool _bCreateEm
                     xStream = GetGraphicStream( xObj, &aMediaType );
                 }
 
-                if ( !xStream.is() )
+                if ( !xStream.is() && getUserAllowsLinkUpdate() )
                 {
                     // the image must be regenerated
                     // TODO/LATER: another aspect could be used
@@ -1649,6 +1655,20 @@ bool EmbeddedObjectContainer::SetPersistentEntries(const uno::Reference< embed::
     }
     return bError;
 }
+
+bool EmbeddedObjectContainer::getUserAllowsLinkUpdate() const
+{
+    return pImpl->mbUserAllowsLinkUpdate;
+}
+
+void EmbeddedObjectContainer::setUserAllowsLinkUpdate(bool bNew)
+{
+    if(pImpl->mbUserAllowsLinkUpdate != bNew)
+    {
+        pImpl->mbUserAllowsLinkUpdate = bNew;
+    }
+}
+
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/comphelper/embeddedobjectcontainer.hxx b/include/comphelper/embeddedobjectcontainer.hxx
index 8895a8d..2c8e25f 100644
--- a/include/comphelper/embeddedobjectcontainer.hxx
+++ b/include/comphelper/embeddedobjectcontainer.hxx
@@ -181,6 +181,9 @@ public:
     * \return <FALSE/> if no error occurred, otherwise <TRUE/>.
     */
     bool             SetPersistentEntries(const com::sun::star::uno::Reference< com::sun::star::embed::XStorage >& _xStorage,bool _bClearModifedFlag = true);
+
+    bool getUserAllowsLinkUpdate() const;
+    void setUserAllowsLinkUpdate(bool bNew);
 };
 
 }
diff --git a/sfx2/source/appl/linkmgr2.cxx b/sfx2/source/appl/linkmgr2.cxx
index 2916713..906914d 100644
--- a/sfx2/source/appl/linkmgr2.cxx
+++ b/sfx2/source/appl/linkmgr2.cxx
@@ -329,7 +329,17 @@ void LinkManager::UpdateAllLinks(
         {
             int nRet = QueryBox( pParentWin, WB_YES_NO | WB_DEF_YES, SfxResId( STR_QUERY_UPDATE_LINKS ).toString() ).Execute();
             if( RET_YES != nRet )
-                return ;         // nothing should be updated
+            {
+                SfxObjectShell* pShell = pLink->GetLinkManager()->GetPersist();
+
+                if(pShell)
+                {
+                    comphelper::EmbeddedObjectContainer& rEmbeddedObjectContainer = pShell->getEmbeddedObjectContainer();
+                    rEmbeddedObjectContainer.setUserAllowsLinkUpdate(false);
+                }
+
+                return ;        // nothing should be updated
+            }
             bAskUpdate = false;  // once is enough
         }
 
diff --git a/svtools/source/misc/embedhlp.cxx b/svtools/source/misc/embedhlp.cxx
index 9c1c51d..faa3131 100644
--- a/svtools/source/misc/embedhlp.cxx
+++ b/svtools/source/misc/embedhlp.cxx
@@ -606,19 +606,30 @@ SvStream* EmbeddedObjectRef::GetGraphicStream( bool bUpdate ) const
     if ( !xStream.is() )
     {
         SAL_INFO( "svtools.misc", "getting stream from object" );
-        // update wanted or no stream in container storage available
-        xStream = GetGraphicReplacementStream(mpImpl->nViewAspect, mpImpl->mxObj, &mpImpl->aMediaType);
+        bool bUserAllowsLinkUpdate(true);
+        const comphelper::EmbeddedObjectContainer* pContainer = GetContainer();
 
-        if ( xStream.is() )
+        if(pContainer)
         {
-            if ( mpImpl->pContainer )
-                mpImpl->pContainer->InsertGraphicStream( xStream, mpImpl->aPersistName, mpImpl->aMediaType );
+            bUserAllowsLinkUpdate = pContainer->getUserAllowsLinkUpdate();
+        }
 
-            SvStream* pResult = ::utl::UcbStreamHelper::CreateStream( xStream );
-            if ( pResult && bUpdate )
-                mpImpl->bNeedUpdate = false;
+        if(bUserAllowsLinkUpdate)
+        {
+            // update wanted or no stream in container storage available
+            xStream = GetGraphicReplacementStream(mpImpl->nViewAspect, mpImpl->mxObj, &mpImpl->aMediaType);
 
-            return pResult;
+            if(xStream.is())
+            {
+                if (mpImpl->pContainer)
+                    mpImpl->pContainer->InsertGraphicStream(xStream,mpImpl->aPersistName,mpImpl->aMediaType);
+
+                SvStream* pResult = ::utl::UcbStreamHelper::CreateStream( xStream );
+                if (pResult && bUpdate)
+                    mpImpl->bNeedUpdate = false;
+
+                return pResult;
+            }
         }
     }
 


More information about the Libreoffice-commits mailing list