Author: alg
Date: Thu Aug  7 09:59:26 2014
New Revision: 1616457

URL: http://svn.apache.org/r1616457
Log:
i125386 secured user request and changed some bools to bitfield

Modified:
    openoffice/trunk/main/comphelper/inc/comphelper/embeddedobjectcontainer.hxx
    
openoffice/trunk/main/comphelper/source/container/embeddedobjectcontainer.cxx
    openoffice/trunk/main/sfx2/source/appl/linkmgr2.cxx
    openoffice/trunk/main/svtools/source/misc/embedhlp.cxx

Modified: 
openoffice/trunk/main/comphelper/inc/comphelper/embeddedobjectcontainer.hxx
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/comphelper/inc/comphelper/embeddedobjectcontainer.hxx?rev=1616457&r1=1616456&r2=1616457&view=diff
==============================================================================
--- openoffice/trunk/main/comphelper/inc/comphelper/embeddedobjectcontainer.hxx 
(original)
+++ openoffice/trunk/main/comphelper/inc/comphelper/embeddedobjectcontainer.hxx 
Thu Aug  7 09:59:26 2014
@@ -178,6 +178,9 @@ sal_Bool            RemoveEmbeddedObject
     * \return <FALSE/> if no error occurred, otherwise <TRUE/>.
     */
     sal_Bool             SetPersistentEntries(const 
com::sun::star::uno::Reference< com::sun::star::embed::XStorage >& 
_xStorage,bool _bClearModifedFlag = true);
+
+    bool getUserAllowsLinkUpdate() const;
+    void setUserAllowsLinkUpdate(bool bNew);
 };
 
 }

Modified: 
openoffice/trunk/main/comphelper/source/container/embeddedobjectcontainer.cxx
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/comphelper/source/container/embeddedobjectcontainer.cxx?rev=1616457&r1=1616456&r2=1616457&view=diff
==============================================================================
--- 
openoffice/trunk/main/comphelper/source/container/embeddedobjectcontainer.cxx 
(original)
+++ 
openoffice/trunk/main/comphelper/source/container/embeddedobjectcontainer.cxx 
Thu Aug  7 09:59:26 2014
@@ -92,7 +92,10 @@ struct EmbedImpl
     uno::WeakReference < uno::XInterface > m_xModel;
     //EmbeddedObjectContainerNameMap maTempObjectContainer;
     //uno::Reference < embed::XStorage > mxTempStorage;
-    sal_Bool bOwnsStorage;
+
+    /// bitfield
+    bool mbOwnsStorage : 1;
+    bool mbUserAllowsLinkUpdate : 1;
 
     const uno::Reference < embed::XStorage >& GetReplacements();
 };
@@ -123,7 +126,8 @@ EmbeddedObjectContainer::EmbeddedObjectC
 {
     pImpl = new EmbedImpl;
     pImpl->mxStorage = ::comphelper::OStorageHelper::GetTemporaryStorage();
-    pImpl->bOwnsStorage = sal_True;
+    pImpl->mbOwnsStorage = true;
+    pImpl->mbUserAllowsLinkUpdate = true;
     pImpl->mpTempObjectContainer = 0;
 }
 
@@ -131,7 +135,8 @@ EmbeddedObjectContainer::EmbeddedObjectC
 {
     pImpl = new EmbedImpl;
     pImpl->mxStorage = rStor;
-    pImpl->bOwnsStorage = sal_False;
+    pImpl->mbOwnsStorage = false;
+    pImpl->mbUserAllowsLinkUpdate = true;
     pImpl->mpTempObjectContainer = 0;
 }
 
@@ -139,7 +144,8 @@ EmbeddedObjectContainer::EmbeddedObjectC
 {
     pImpl = new EmbedImpl;
     pImpl->mxStorage = rStor;
-    pImpl->bOwnsStorage = sal_False;
+    pImpl->mbOwnsStorage = false;
+    pImpl->mbUserAllowsLinkUpdate = true;
     pImpl->mpTempObjectContainer = 0;
     pImpl->m_xModel = xModel;
 }
@@ -148,11 +154,11 @@ void EmbeddedObjectContainer::SwitchPers
 {
        ReleaseImageSubStorage();
 
-    if ( pImpl->bOwnsStorage )
+    if ( pImpl->mbOwnsStorage )
         pImpl->mxStorage->dispose();
 
     pImpl->mxStorage = rStor;
-    pImpl->bOwnsStorage = sal_False;
+    pImpl->mbOwnsStorage = false;
 }
 
 sal_Bool EmbeddedObjectContainer::CommitImageSubStorage()
@@ -208,7 +214,7 @@ EmbeddedObjectContainer::~EmbeddedObject
 {
        ReleaseImageSubStorage();
 
-    if ( pImpl->bOwnsStorage )
+    if ( pImpl->mbOwnsStorage )
         pImpl->mxStorage->dispose();
 
     delete pImpl->mpTempObjectContainer;
@@ -1401,7 +1407,7 @@ sal_Bool EmbeddedObjectContainer::StoreA
                     xStream = GetGraphicStream( xObj, &aMediaType );
                 }
 
-                if ( !xStream.is() )
+                if ( !xStream.is() && getUserAllowsLinkUpdate() )
                 {
                     // the image must be regenerated
                     // TODO/LATER: another aspect could be used
@@ -1685,4 +1691,18 @@ sal_Bool EmbeddedObjectContainer::SetPer
        }
     return bError;
 }
+
+bool EmbeddedObjectContainer::getUserAllowsLinkUpdate() const
+{
+    return pImpl->mbUserAllowsLinkUpdate;
+}
+
+void EmbeddedObjectContainer::setUserAllowsLinkUpdate(bool bNew)
+{
+    if(pImpl->mbUserAllowsLinkUpdate != bNew)
+    {
+        pImpl->mbUserAllowsLinkUpdate = bNew;
+    }
+}
+
 }

Modified: openoffice/trunk/main/sfx2/source/appl/linkmgr2.cxx
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/sfx2/source/appl/linkmgr2.cxx?rev=1616457&r1=1616456&r2=1616457&view=diff
==============================================================================
--- openoffice/trunk/main/sfx2/source/appl/linkmgr2.cxx (original)
+++ openoffice/trunk/main/sfx2/source/appl/linkmgr2.cxx Thu Aug  7 09:59:26 2014
@@ -318,7 +318,17 @@ void LinkManager::UpdateAllLinks( 
                {
             int nRet = QueryBox( pParentWin, WB_YES_NO | WB_DEF_YES, SfxResId( 
STR_QUERY_UPDATE_LINKS ) ).Execute();
                        if( RET_YES != nRet )
+            {
+                SfxObjectShell* pShell = pLink->GetLinkManager()->GetPersist();
+
+                if(pShell)
+                {
+                    comphelper::EmbeddedObjectContainer& 
rEmbeddedObjectContainer = pShell->getEmbeddedObjectContainer();
+                    rEmbeddedObjectContainer.setUserAllowsLinkUpdate(false);
+                }
+
                                return ;                // es soll nichts 
geupdatet werden
+            }
                        bAskUpdate = sal_False;         // einmal reicht
                }
 

Modified: openoffice/trunk/main/svtools/source/misc/embedhlp.cxx
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/svtools/source/misc/embedhlp.cxx?rev=1616457&r1=1616456&r2=1616457&view=diff
==============================================================================
--- openoffice/trunk/main/svtools/source/misc/embedhlp.cxx (original)
+++ openoffice/trunk/main/svtools/source/misc/embedhlp.cxx Thu Aug  7 09:59:26 
2014
@@ -709,19 +709,30 @@ SvStream* EmbeddedObjectRef::GetGraphicS
     if ( !xStream.is() )
     {
                RTL_LOGFILE_CONTEXT_TRACE( aLog, "getting stream from object" );
-        // update wanted or no stream in container storage available
-               xStream = GetGraphicReplacementStream( mpImp->nViewAspect, 
mxObj, &mpImp->aMediaType );
+        bool bUserAllowsLinkUpdate(true);
+        const comphelper::EmbeddedObjectContainer* pContainer = GetContainer();
 
-               if ( xStream.is() )
-               {
-                       if ( mpImp->pContainer )
-               mpImp->pContainer->InsertGraphicStream( xStream, 
mpImp->aPersistName, mpImp->aMediaType );
+        if(pContainer)
+        {
+            bUserAllowsLinkUpdate = pContainer->getUserAllowsLinkUpdate();
+        }
 
-            SvStream* pResult = ::utl::UcbStreamHelper::CreateStream( xStream 
);
-            if ( pResult && bUpdate )
-                mpImp->bNeedUpdate = sal_False;
+        if(bUserAllowsLinkUpdate)
+        {
+            // update wanted or no stream in container storage available
+            xStream = 
GetGraphicReplacementStream(mpImp->nViewAspect,mxObj,&mpImp->aMediaType);
+
+            if(xStream.is())
+            {
+                if(mpImp->pContainer)
+                    
mpImp->pContainer->InsertGraphicStream(xStream,mpImp->aPersistName,mpImp->aMediaType);
+
+                SvStream* pResult = ::utl::UcbStreamHelper::CreateStream( 
xStream );
+                if ( pResult && bUpdate )
+                    mpImp->bNeedUpdate = sal_False;
 
-            return pResult;
+                return pResult;
+            }
         }
     }
 


Reply via email to