You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by pa...@apache.org on 2017/10/30 23:02:26 UTC

svn commit: r1813837 - in /openoffice/trunk/main: sc/source/core/data/documen2.cxx sfx2/inc/sfx2/linkmgr.hxx sfx2/source/appl/linkmgr2.cxx

Author: pats
Date: Mon Oct 30 23:02:26 2017
New Revision: 1813837

URL: http://svn.apache.org/viewvc?rev=1813837&view=rev
Log:
Make spreadsheets ask to update links. CVE CVE-2017-3157

Modified:
    openoffice/trunk/main/sc/source/core/data/documen2.cxx
    openoffice/trunk/main/sfx2/inc/sfx2/linkmgr.hxx
    openoffice/trunk/main/sfx2/source/appl/linkmgr2.cxx

Modified: openoffice/trunk/main/sc/source/core/data/documen2.cxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/sc/source/core/data/documen2.cxx?rev=1813837&r1=1813836&r2=1813837&view=diff
==============================================================================
--- openoffice/trunk/main/sc/source/core/data/documen2.cxx (original)
+++ openoffice/trunk/main/sc/source/core/data/documen2.cxx Mon Oct 30 23:02:26 2017
@@ -229,7 +229,10 @@ ScDocument::ScDocument( ScDocumentMode	e
 	if ( eMode == SCDOCMODE_DOCUMENT )
 	{
 		if ( pDocShell )
-			pLinkManager = new sfx2::LinkManager( pDocShell );
+		{
+			pLinkManager = new sfx2::LinkManager(pDocShell);
+			pLinkManager->SetAutoAskUpdateAllLinks();
+		}
 
 		xPoolHelper = new ScPoolHelper( this );
 
@@ -269,6 +272,7 @@ sfx2::LinkManager*	ScDocument::GetLinkMa
     if ( bAutoCalc && !pLinkManager && pShell)
 	{
 		pLinkManager = new sfx2::LinkManager( pShell );
+		pLinkManager->SetAutoAskUpdateAllLinks();
     }
     return pLinkManager; 
 }

Modified: openoffice/trunk/main/sfx2/inc/sfx2/linkmgr.hxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/sfx2/inc/sfx2/linkmgr.hxx?rev=1813837&r1=1813836&r2=1813837&view=diff
==============================================================================
--- openoffice/trunk/main/sfx2/inc/sfx2/linkmgr.hxx (original)
+++ openoffice/trunk/main/sfx2/inc/sfx2/linkmgr.hxx Mon Oct 30 23:02:26 2017
@@ -54,6 +54,13 @@ class SFX2_DLLPUBLIC LinkManager
 	SvLinkSources aServerTbl;
 
     SfxObjectShell *pPersist; // LinkMgr has to be deallocated before SfxObjectShell
+
+	sal_Bool mAutoAskUpdateAllLinks;
+	sal_Bool mUpdateAsked;
+	sal_Bool mAllowUpdate;
+
+	sal_Bool GetUserAllowsLinkUpdate(Window *pParent);
+	void SetUserAllowsLinkUpdate(SvBaseLink *pLink, sal_Bool allows);
 protected:
 	sal_Bool 		InsertLink( SvBaseLink* pLink, sal_uInt16 nObjType, sal_uInt16 nUpdateType,
 							const String* pName = 0 );
@@ -138,7 +145,10 @@ public:
 	// graphic from the Any. Return says no errors
 	static sal_Bool GetGraphicFromAny( const String& rMimeType,
 								const ::com::sun::star::uno::Any & rValue,
-								Graphic& rGrf );				
+								Graphic& rGrf );
+
+	// Automatically ask user about update all links, on first insert
+	void SetAutoAskUpdateAllLinks();
 
 private:
 				LinkManager( const LinkManager& );

Modified: openoffice/trunk/main/sfx2/source/appl/linkmgr2.cxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/sfx2/source/appl/linkmgr2.cxx?rev=1813837&r1=1813836&r2=1813837&view=diff
==============================================================================
--- openoffice/trunk/main/sfx2/source/appl/linkmgr2.cxx (original)
+++ openoffice/trunk/main/sfx2/source/appl/linkmgr2.cxx Mon Oct 30 23:02:26 2017
@@ -65,11 +65,12 @@ public:
 SV_IMPL_PTRARR( SvBaseLinks, SvBaseLinkRefPtr )
 
 LinkManager::LinkManager(SfxObjectShell* p)
-	: pPersist( p )
+	: pPersist(p),
+	mUpdateAsked(sal_False),
+	mAutoAskUpdateAllLinks(sal_False)
 {
 }
 
-
 LinkManager::~LinkManager()
 {
 	SvBaseLinkRef** ppRef = (SvBaseLinkRef**)aLinkTbl.GetData();
@@ -143,6 +144,7 @@ void LinkManager::Remove( sal_uInt16 nPo
 
 sal_Bool LinkManager::Insert( SvBaseLink* pLink )
 {
+
 	// do not insert links double
 	for( sal_uInt16 n = 0; n < aLinkTbl.Count(); ++n )
 	{
@@ -157,6 +159,12 @@ sal_Bool LinkManager::Insert( SvBaseLink
 	SvBaseLinkRef* pTmp = new SvBaseLinkRef( pLink );
     pLink->SetLinkManager( this );
 	aLinkTbl.Insert( pTmp, aLinkTbl.Count() );
+	Window *parent = GetPersist()->GetDialogParent();
+	if (mAutoAskUpdateAllLinks)
+	{
+		SetUserAllowsLinkUpdate(pLink, GetUserAllowsLinkUpdate(parent));
+	}
+
 	return sal_True;
 }
 
@@ -268,6 +276,35 @@ sal_Bool LinkManager::GetDisplayNames( c
 	return bRet;
 }
 
+void LinkManager::SetAutoAskUpdateAllLinks()
+{
+	mAutoAskUpdateAllLinks = sal_True;
+}
+
+sal_Bool LinkManager::GetUserAllowsLinkUpdate(Window *pParentWin)
+{
+	if (!mUpdateAsked)
+	{
+		if (QueryBox(pParentWin, WB_YES_NO | WB_DEF_NO, SfxResId(STR_QUERY_UPDATE_LINKS)).Execute() == RET_YES)
+			mAllowUpdate = sal_True;
+		else
+			mAllowUpdate = sal_False;
+		mUpdateAsked = sal_True;
+	}
+	return mAllowUpdate;
+}
+
+void LinkManager::SetUserAllowsLinkUpdate(SvBaseLink *pLink, sal_Bool allows)
+{
+	SfxObjectShell* pShell = pLink->GetLinkManager()->GetPersist();
+
+	if (pShell)
+	{
+		comphelper::EmbeddedObjectContainer& rEmbeddedObjectContainer = pShell->getEmbeddedObjectContainer();
+		rEmbeddedObjectContainer.setUserAllowsLinkUpdate(allows);
+	}
+}
+
 
 void LinkManager::UpdateAllLinks( 
     sal_Bool bAskUpdate, 
@@ -313,25 +350,18 @@ void LinkManager::UpdateAllLinks(
 			( !bUpdateGrfLinks && OBJECT_CLIENT_GRF == pLink->GetObjType() ))
 			continue;
 
-		if( bAskUpdate )
+		sal_Bool allows = sal_True;
+			
+		if (bAskUpdate)
 		{
-            int nRet = QueryBox( pParentWin, WB_YES_NO | WB_DEF_NO, SfxResId( STR_QUERY_UPDATE_LINKS ) ).Execute();
-            SfxObjectShell* pShell = pLink->GetLinkManager()->GetPersist();
-
-            if(pShell)
-            {
-                comphelper::EmbeddedObjectContainer& rEmbeddedObjectContainer = pShell->getEmbeddedObjectContainer();
-                rEmbeddedObjectContainer.setUserAllowsLinkUpdate(RET_YES == nRet);
-            }
-
-		    if (RET_YES != nRet)
-			{
-				return;		// nothing should be updated
-            }
-			bAskUpdate = sal_False;		// one time is OK
+			allows = GetUserAllowsLinkUpdate(pParentWin);
 		}
 
-		pLink->Update();
+		SetUserAllowsLinkUpdate(pLink, allows);
+	    bAskUpdate = sal_False;		// one time is OK
+
+		if (allows)
+			pLink->Update();
 	}
 }