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

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


The following commit(s) were added to refs/heads/trunk by this push:
     new 671443b420 New method sfx2::LinkManager::urlIsVendor()
671443b420 is described below

commit 671443b4207afb76ae0124904a5e265c890dbb3d
Author: Arrigo Marchiori <[email protected]>
AuthorDate: Thu Jun 26 21:51:50 2025 +0200

    New method sfx2::LinkManager::urlIsVendor()
    
    This new method is invoked before all occurrences of
    sfx2::LinkManager::GetUserAllowsLinkUpdate()
---
 main/sc/source/ui/docshell/arealink.cxx |  2 ++
 main/sc/source/ui/unoobj/docuno.cxx     |  4 +++-
 main/sd/source/ui/unoidl/unomodel.cxx   |  4 +++-
 main/sfx2/inc/sfx2/linkmgr.hxx          |  3 +++
 main/sfx2/source/appl/linkmgr2.cxx      | 12 ++++++++++++
 main/svx/source/svdraw/svdograf.cxx     | 10 ++++++++--
 main/svx/source/unodraw/unoshap2.cxx    |  3 ++-
 main/sw/source/core/doc/notxtfrm.cxx    |  9 ++++++---
 main/sw/source/core/graphic/ndgrf.cxx   |  3 +++
 main/sw/source/core/unocore/unosett.cxx |  3 +++
 main/sw/source/ui/uno/unotxdoc.cxx      |  4 +++-
 11 files changed, 48 insertions(+), 9 deletions(-)

diff --git a/main/sc/source/ui/docshell/arealink.cxx 
b/main/sc/source/ui/docshell/arealink.cxx
index 71dbe17d3a..16d8dfd0df 100644
--- a/main/sc/source/ui/docshell/arealink.cxx
+++ b/main/sc/source/ui/docshell/arealink.cxx
@@ -247,6 +247,8 @@ sal_Bool ScAreaLink::Refresh( const String& rNewFile, const 
String& rNewFilter,
        // Request for authorization
        sfx2::LinkManager* pLinkMgr = 
pImpl->m_pDocSh->GetDocument()->GetLinkManager();
        if ( pLinkMgr ) {
+               if ( pLinkMgr->urlIsVendor( rNewFile ) )
+                       return sal_False;
                SfxViewFrame* pFrame = SfxViewFrame::GetFirst( pImpl->m_pDocSh 
);
                if ( pFrame ) {
                        Window* pWindow = &pFrame->GetWindow();
diff --git a/main/sc/source/ui/unoobj/docuno.cxx 
b/main/sc/source/ui/unoobj/docuno.cxx
index b2607a315d..0dd88a7234 100644
--- a/main/sc/source/ui/unoobj/docuno.cxx
+++ b/main/sc/source/ui/unoobj/docuno.cxx
@@ -1316,7 +1316,9 @@ sal_Bool ScModelObj::authorizeLinks( const 
::rtl::OUString& rURL ) throw( uno::R
                SfxMedium* pMedium = pDocShell->GetMedium();
                SfxFrame* pFrm = pMedium ? pMedium->GetLoadTargetFrame() : 0;
                sfx2::LinkManager *pLinkMgr = doc->GetLinkManager();
-               if ( pLinkMgr->urlIsSafe( rURL ) ) {
+               if ( pLinkMgr->urlIsVendor( rURL ) ) {
+                       return sal_False;
+               } else if ( pLinkMgr->urlIsSafe( rURL ) ) {
                        return sal_True;
                }
                Window* pDlgParent = 0;
diff --git a/main/sd/source/ui/unoidl/unomodel.cxx 
b/main/sd/source/ui/unoidl/unomodel.cxx
index 57b2243c57..877729b351 100644
--- a/main/sd/source/ui/unoidl/unomodel.cxx
+++ b/main/sd/source/ui/unoidl/unomodel.cxx
@@ -1438,7 +1438,9 @@ sal_Bool SAL_CALL SdXImpressDocument::authorizeLinks( 
const ::rtl::OUString &url
                SfxMedium* pMedium = mpDocShell->GetMedium();
                SfxFrame* pFrm = pMedium ? pMedium->GetLoadTargetFrame() : 0;
                sfx2::LinkManager *pLinkMgr = mpDoc->GetLinkManager();
-               if ( pLinkMgr->urlIsSafe( url ) ) {
+               if ( pLinkMgr->urlIsVendor( url ) ) {
+                       return sal_False;
+               } else if ( pLinkMgr->urlIsSafe( url ) ) {
                        return sal_True;
                }
                Window* pDlgParent = 0;
diff --git a/main/sfx2/inc/sfx2/linkmgr.hxx b/main/sfx2/inc/sfx2/linkmgr.hxx
index 8f08395040..7792b96fe1 100644
--- a/main/sfx2/inc/sfx2/linkmgr.hxx
+++ b/main/sfx2/inc/sfx2/linkmgr.hxx
@@ -170,6 +170,9 @@ public:
     // Check whether a link URL must be subject to authorization
     sal_Bool urlIsSafe( const ::com::sun::star::util::URL &url );
 
+    // Check whether a link URL is using a ``strange'' scheme
+    sal_Bool urlIsVendor( const ::rtl::OUString &url );
+
 private:
                                LinkManager( const LinkManager& );
                                LinkManager& operator=( const LinkManager& );
diff --git a/main/sfx2/source/appl/linkmgr2.cxx 
b/main/sfx2/source/appl/linkmgr2.cxx
index 6a6c3414a2..7d7fed13f0 100644
--- a/main/sfx2/source/appl/linkmgr2.cxx
+++ b/main/sfx2/source/appl/linkmgr2.cxx
@@ -575,6 +575,18 @@ sal_Bool LinkManager::urlIsSafe( const 
::com::sun::star::util::URL &url )
 }
 
 
+sal_Bool LinkManager::urlIsVendor( const ::rtl::OUString &url )
+{
+       if ( url.matchIgnoreAsciiCaseAsciiL( "vnd.sun.star.", 13, 0 ) ) {
+               return url.matchIgnoreAsciiCaseAsciiL ( "expand", 6, 13 ) ||
+                       url.matchIgnoreAsciiCaseAsciiL ( "script", 6, 13 ) ||
+                       url.matchIgnoreAsciiCaseAsciiL ( "tdoc", 4, 13 ) ||
+                       url.matchIgnoreAsciiCaseAsciiL ( "uno", 3, 13 );
+       }
+       return sal_False;
+}
+
+
 // ----------------------------------------------------------------------
 String lcl_DDE_RelToAbs( const String& rTopic, const String& rBaseURL )
 {
diff --git a/main/svx/source/svdraw/svdograf.cxx 
b/main/svx/source/svdraw/svdograf.cxx
index d1210cca44..be46b5a160 100644
--- a/main/svx/source/svdraw/svdograf.cxx
+++ b/main/svx/source/svdraw/svdograf.cxx
@@ -232,7 +232,12 @@ void SAL_CALL SdrGraphicUpdater::onTerminated(void)
 
 void SAL_CALL SdrGraphicUpdater::run(void)
 {
-       Graphic aGraphic( ImpLoadLinkedGraphic( maFileName, maFilterName ) );
+       sfx2::LinkManager *linkMgr = mrGraphicLink.GetLinkManager();
+       Graphic aGraphic;
+       if ( (linkMgr == NULL) ||
+                ( !linkMgr->urlIsVendor( maFileName ) && ( 
linkMgr->GetUserAllowsLinkUpdate(NULL) ) ) ) {
+               aGraphic = ImpLoadLinkedGraphic( maFileName, maFilterName );
+       }
        vos::OGuard aSolarGuard( Application::GetSolarMutex() );
        if ( !mbIsTerminated )
        {
@@ -820,7 +825,8 @@ sal_Bool SdrGrafObj::ImpUpdateGraphicLink( sal_Bool 
bAsynchron ) const
     if( pGraphicLink )
        {
         sfx2::LinkManager *linkMgr = pGraphicLink->GetLinkManager();
-        if ((linkMgr == NULL) || (linkMgr->GetUserAllowsLinkUpdate(NULL))) {
+        if ( (linkMgr == NULL) ||
+             ( !linkMgr->urlIsVendor( aFileName ) && ( 
linkMgr->GetUserAllowsLinkUpdate(NULL) ) ) ) {
             if ( bAsynchron )
                 pGraphicLink->UpdateAsynchron();
             else
diff --git a/main/svx/source/unodraw/unoshap2.cxx 
b/main/svx/source/unodraw/unoshap2.cxx
index d3c17aa52b..172abb9514 100644
--- a/main/svx/source/unodraw/unoshap2.cxx
+++ b/main/svx/source/unodraw/unoshap2.cxx
@@ -1724,7 +1724,8 @@ bool SvxGraphicObject::setPropertyValueImpl( const 
::rtl::OUString& rName, const
                 if (mpModel) {
                     linkManager = mpModel->GetLinkManager();
                 }
-                if ((linkManager == NULL) || 
(linkManager->GetUserAllowsLinkUpdate(SFX_APP()->GetTopWindow()))) {
+                if ( ( linkManager == NULL ) ||
+                     ( !linkManager->urlIsVendor( aURL ) && 
linkManager->GetUserAllowsLinkUpdate( SFX_APP()->GetTopWindow() ) ) ) {
                     SFX_APP()->GetFilterMatcher().GuessFilter( aSfxMedium, 
&pSfxFilter, SFX_FILTER_IMPORT, SFX_FILTER_NOTINSTALLED | SFX_FILTER_EXECUTABLE 
);
                 }
 
diff --git a/main/sw/source/core/doc/notxtfrm.cxx 
b/main/sw/source/core/doc/notxtfrm.cxx
index 8d5b38e879..354850f16d 100644
--- a/main/sw/source/core/doc/notxtfrm.cxx
+++ b/main/sw/source/core/doc/notxtfrm.cxx
@@ -945,13 +945,16 @@ void SwNoTxtFrm::PaintPicture( OutputDevice* pOut, const 
SwRect &rGrfArea ) cons
             // <--
                        {
                                Size aTmpSz;
-                ::sfx2::SvLinkSource* pGrfObj = pGrfNd->GetLink()->GetObj();
+                               ::sfx2::SvLinkSource* pGrfObj = 
pGrfNd->GetLink()->GetObj();
+                               String aUrl;
+                               GetRealURL( *pGrfNd, aUrl );
                                if( !pGrfObj ||
                                        !pGrfObj->IsDataComplete() ||
                                        !(aTmpSz = 
pGrfNd->GetTwipSize()).Width() ||
                                        !aTmpSz.Height() || 
!pGrfNd->GetAutoFmtLvl() )
                                {
-                    if 
(pShell->GetDoc()->GetLinkManager().GetUserAllowsLinkUpdate(pShell->GetWin())) {
+                    ::sfx2::LinkManager& linkMgr = 
pShell->GetDoc()->GetLinkManager();
+                    if ( !linkMgr.urlIsVendor( aUrl ) && 
linkMgr.GetUserAllowsLinkUpdate( pShell->GetWin() ) ) {
                         // --> OD 2006-12-22 #i73788#
                         pGrfNd->TriggerAsyncRetrieveInputStream();
                         // <--
@@ -959,7 +962,7 @@ void SwNoTxtFrm::PaintPicture( OutputDevice* pOut, const 
SwRect &rGrfArea ) cons
                                }
                 String aTxt( pGrfNd->GetTitle() );
                                if ( !aTxt.Len() )
-                                       GetRealURL( *pGrfNd, aTxt );
+                                       aTxt = aUrl;
                 ::lcl_PaintReplacement( aAlignedGrfArea, aTxt, *pShell, this, 
sal_False );
                                bContinue = sal_False;
                        }
diff --git a/main/sw/source/core/graphic/ndgrf.cxx 
b/main/sw/source/core/graphic/ndgrf.cxx
index 562886aebd..bcdd936241 100644
--- a/main/sw/source/core/graphic/ndgrf.cxx
+++ b/main/sw/source/core/graphic/ndgrf.cxx
@@ -184,6 +184,9 @@ sal_Bool SwGrfNode::ReRead(
     ASSERT( pGraphic || pGrfObj || rGrfName.Len(),
         "GraphicNode without a name, Graphic or GraphicObject" );
 
+    if ( GetDoc()->GetLinkManager().urlIsVendor( rGrfName ) )
+        return sal_False;
+
     // ReadRead mit Namen
     if ( refLink.Is() )
     {
diff --git a/main/sw/source/core/unocore/unosett.cxx 
b/main/sw/source/core/unocore/unosett.cxx
index 5d62969d6f..e111288396 100644
--- a/main/sw/source/core/unocore/unosett.cxx
+++ b/main/sw/source/core/unocore/unosett.cxx
@@ -2113,6 +2113,9 @@ void SwXNumberingRules::SetNumberingRuleByIndex(
                                                SfxMedium* pMedium = 
myDocShell->GetMedium();
                                                SfxFrame* pFrm = pMedium ? 
pMedium->GetLoadTargetFrame() : 0;
                                                sfx2::LinkManager& pLinkMgr = 
myDoc->GetLinkManager();
+                                               if ( pLinkMgr.urlIsVendor( 
sBrushURL ) ) {
+                                                       break; // Stop here
+                                               }
                                                if ( !pLinkMgr.urlIsSafe( 
sBrushURL ) ) {
                                                        Window* pDlgParent = 0;
                                                        if ( pFrm )
diff --git a/main/sw/source/ui/uno/unotxdoc.cxx 
b/main/sw/source/ui/uno/unotxdoc.cxx
index c56766b0b3..56730ddd6a 100644
--- a/main/sw/source/ui/uno/unotxdoc.cxx
+++ b/main/sw/source/ui/uno/unotxdoc.cxx
@@ -2383,7 +2383,9 @@ sal_Bool SwXTextDocument::authorizeLinks( const 
::rtl::OUString& rURL ) throw( R
                SfxMedium* pMedium = pDocShell->GetMedium();
                SfxFrame* pFrm = pMedium ? pMedium->GetLoadTargetFrame() : 0;
                sfx2::LinkManager &pLinkMgr = doc->GetLinkManager();
-               if ( pLinkMgr.urlIsSafe( rURL ) ) {
+               if ( pLinkMgr.urlIsVendor( rURL ) ) {
+                       return sal_False;
+               } else if ( pLinkMgr.urlIsSafe( rURL ) ) {
                        return sal_True;
                }
                Window* pDlgParent = 0;

Reply via email to