This is an automated email from the ASF dual-hosted git repository.

ardovm pushed a commit to branch links
in repository https://gitbox.apache.org/repos/asf/openoffice.git

commit 1b9d1397d93e567a9042ac64832efcc85d3fed81
Author: Arrigo Marchiori <ard...@yahoo.it>
AuthorDate: Sun Jun 4 21:36:22 2023 +0200

    Use sfx2::LinkManager::GetUserAllowsLinkUpdate()
---
 main/sd/source/core/drawdoc.cxx      |  4 +++-
 main/svx/source/svdraw/svdograf.cxx  | 11 +++++++----
 main/svx/source/unodraw/unoshap2.cxx | 10 +++++++++-
 main/sw/source/core/doc/docnew.cxx   |  1 +
 main/sw/source/core/doc/notxtfrm.cxx |  9 ++++++---
 5 files changed, 26 insertions(+), 9 deletions(-)

diff --git a/main/sd/source/core/drawdoc.cxx b/main/sd/source/core/drawdoc.cxx
index 41d74eb08f..30146c9b82 100644
--- a/main/sd/source/core/drawdoc.cxx
+++ b/main/sd/source/core/drawdoc.cxx
@@ -276,7 +276,9 @@ SdDrawDocument::SdDrawDocument(DocumentType eType, 
SfxObjectShell* pDrDocSh)
 
        if (mpDocSh)
        {
-               SetLinkManager( new sfx2::LinkManager(mpDocSh) );
+        sfx2::LinkManager *linkMgr = new sfx2::LinkManager(mpDocSh);
+        linkMgr->SetAutoAskUpdateAllLinks();
+               SetLinkManager( linkMgr );
        }
 
        sal_uLong nCntrl = rOutliner.GetControlWord();
diff --git a/main/svx/source/svdraw/svdograf.cxx 
b/main/svx/source/svdraw/svdograf.cxx
index d21a1420c0..988ae37c5d 100644
--- a/main/svx/source/svdraw/svdograf.cxx
+++ b/main/svx/source/svdraw/svdograf.cxx
@@ -819,10 +819,13 @@ sal_Bool SdrGrafObj::ImpUpdateGraphicLink( sal_Bool 
bAsynchron ) const
     sal_Bool bRet = sal_False;
     if( pGraphicLink )
        {
-               if ( bAsynchron )
-                       pGraphicLink->UpdateAsynchron();
-               else
-                       pGraphicLink->DataChanged( ImpLoadLinkedGraphic( 
aFileName, aFilterName ) );
+        sfx2::LinkManager *linkMgr = pGraphicLink->GetLinkManager();
+        if ((linkMgr == NULL) || (linkMgr->GetUserAllowsLinkUpdate(NULL))) {
+            if ( bAsynchron )
+                pGraphicLink->UpdateAsynchron();
+            else
+                pGraphicLink->DataChanged( ImpLoadLinkedGraphic( aFileName, 
aFilterName ) );
+        } // else links shall not be updated
         bRet = sal_True;
     }
        return bRet;
diff --git a/main/svx/source/unodraw/unoshap2.cxx 
b/main/svx/source/unodraw/unoshap2.cxx
index 011c20879e..d3c17aa52b 100644
--- a/main/svx/source/unodraw/unoshap2.cxx
+++ b/main/svx/source/unodraw/unoshap2.cxx
@@ -1623,6 +1623,7 @@ uno::Sequence< OUString > SAL_CALL 
SvxShapePolyPolygonBezier::getSupportedServic
 #ifndef _SFXDOCFILE_HXX
 #include <sfx2/docfile.hxx>
 #endif
+#include <sfx2/linkmgr.hxx>
 #include <sfx2/app.hxx>
 #include <sfx2/fcontnr.hxx>
 #endif
@@ -1718,7 +1719,14 @@ bool SvxGraphicObject::setPropertyValueImpl( const 
::rtl::OUString& rName, const
                                const SfxFilter*        pSfxFilter = NULL;
                                SfxMedium                       aSfxMedium( 
aURL, STREAM_READ | STREAM_SHARE_DENYNONE, sal_False );
 
-                               SFX_APP()->GetFilterMatcher().GuessFilter( 
aSfxMedium, &pSfxFilter, SFX_FILTER_IMPORT, SFX_FILTER_NOTINSTALLED | 
SFX_FILTER_EXECUTABLE );
+                // SfxFilterMatcher::GuessFilter() may ``taste'' linked files, 
so we must be sure we are authorized to access them
+                sfx2::LinkManager *linkManager = NULL;
+                if (mpModel) {
+                    linkManager = mpModel->GetLinkManager();
+                }
+                if ((linkManager == NULL) || 
(linkManager->GetUserAllowsLinkUpdate(SFX_APP()->GetTopWindow()))) {
+                    SFX_APP()->GetFilterMatcher().GuessFilter( aSfxMedium, 
&pSfxFilter, SFX_FILTER_IMPORT, SFX_FILTER_NOTINSTALLED | SFX_FILTER_EXECUTABLE 
);
+                }
 
                                if( !pSfxFilter )
                                {
diff --git a/main/sw/source/core/doc/docnew.cxx 
b/main/sw/source/core/doc/docnew.cxx
index f8312e56d0..0b3589f66c 100644
--- a/main/sw/source/core/doc/docnew.cxx
+++ b/main/sw/source/core/doc/docnew.cxx
@@ -358,6 +358,7 @@ SwDoc::SwDoc()
     mbPurgeOLE =
                             true;
 
+    pLinkMgr->SetAutoAskUpdateAllLinks();
     //
     // COMPATIBILITY FLAGS START
     //
diff --git a/main/sw/source/core/doc/notxtfrm.cxx 
b/main/sw/source/core/doc/notxtfrm.cxx
index 8754d214dd..b96b6b3b7f 100644
--- a/main/sw/source/core/doc/notxtfrm.cxx
+++ b/main/sw/source/core/doc/notxtfrm.cxx
@@ -33,6 +33,7 @@
 #include <svtools/soerr.hxx>
 #include <sfx2/progress.hxx>
 #include <sfx2/docfile.hxx>
+#include <sfx2/linkmgr.hxx>
 #include <sfx2/printer.hxx>
 #include <editeng/udlnitem.hxx>
 #include <editeng/colritem.hxx>
@@ -950,9 +951,11 @@ void SwNoTxtFrm::PaintPicture( OutputDevice* pOut, const 
SwRect &rGrfArea ) cons
                                        !(aTmpSz = 
pGrfNd->GetTwipSize()).Width() ||
                                        !aTmpSz.Height() || 
!pGrfNd->GetAutoFmtLvl() )
                                {
-                    // --> OD 2006-12-22 #i73788#
-                    pGrfNd->TriggerAsyncRetrieveInputStream();
-                    // <--
+                    if 
(pShell->GetDoc()->GetLinkManager().GetUserAllowsLinkUpdate(pShell->GetWin())) {
+                        // --> OD 2006-12-22 #i73788#
+                        pGrfNd->TriggerAsyncRetrieveInputStream();
+                        // <--
+                    }
                                }
                 String aTxt( pGrfNd->GetTitle() );
                                if ( !aTxt.Len() )

Reply via email to