You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by ar...@apache.org on 2025/06/12 16:27:07 UTC

(openoffice) 01/07: UNO interface com::sun::star::document::XLinkAuthorizer

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

commit 68281b3f07af4696861c62e9efad368fb5607c0d
Author: Arrigo Marchiori <ar...@yahoo.it>
AuthorDate: Mon Apr 7 23:11:02 2025 +0200

    UNO interface com::sun::star::document::XLinkAuthorizer
    
    sfx2::LinkManager improve URL categorization
    
    Writer, Calc and Draw/Impress XModel implementations also implement
    XLinkAuthorizer
---
 main/offapi/UnoApi_offapi.mk                       |  1 +
 .../com/sun/star/document/XLinkAuthorizer.idl      | 51 ++++++++++++++++++++++
 main/sc/inc/docuno.hxx                             |  4 ++
 main/sc/source/ui/unoobj/docuno.cxx                | 41 ++++++++++++++---
 main/sd/source/ui/inc/unomodel.hxx                 |  5 +++
 main/sd/source/ui/unoidl/unomodel.cxx              | 30 ++++++++++++-
 main/sfx2/inc/sfx2/linkmgr.hxx                     | 15 +++++++
 main/sfx2/source/appl/linkmgr2.cxx                 | 36 +++++++++++++++
 main/sw/inc/unotxdoc.hxx                           | 26 ++++++-----
 main/sw/source/ui/uno/unotxdoc.cxx                 | 22 ++++++++++
 10 files changed, 214 insertions(+), 17 deletions(-)

diff --git a/main/offapi/UnoApi_offapi.mk b/main/offapi/UnoApi_offapi.mk
index 3bdbf22e65..4ceb959c56 100644
--- a/main/offapi/UnoApi_offapi.mk
+++ b/main/offapi/UnoApi_offapi.mk
@@ -1818,6 +1818,7 @@ $(eval $(call gb_UnoApiTarget_add_idlfiles,offapi,\
 	offapi/com/sun/star/document/XImporter \
 	offapi/com/sun/star/document/XInteractionFilterOptions \
 	offapi/com/sun/star/document/XInteractionFilterSelect \
+	offapi/com/sun/star/document/XLinkAuthorizer \
 	offapi/com/sun/star/document/XLinkTargetSupplier \
 	offapi/com/sun/star/document/XMimeTypeInfo \
 	offapi/com/sun/star/document/XOOXMLDocumentPropertiesImporter \
diff --git a/main/offapi/com/sun/star/document/XLinkAuthorizer.idl b/main/offapi/com/sun/star/document/XLinkAuthorizer.idl
new file mode 100644
index 0000000000..a8a4298598
--- /dev/null
+++ b/main/offapi/com/sun/star/document/XLinkAuthorizer.idl
@@ -0,0 +1,51 @@
+/**************************************************************
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * 
+ *************************************************************/
+
+
+#ifndef __com_sun_star_document_XLinkAuthorizer_idl__
+#define __com_sun_star_document_XLinkAuthorizer_idl__
+
+//=============================================================================
+
+module com { module sun { module star { module document {
+
+//=============================================================================
+/** gives the authorization to follow links and update them.
+
+ */
+published interface XLinkAuthorizer: com::sun::star::uno::XInterface
+{
+    /** request for authorization to follow or update links.
+
+        @param url if empty, means any link. If indicated, the URL is checked
+        against "private" protocols that it makes no sense to disallow.
+
+        @returns true if links can be followed or updated.
+	 */
+    boolean authorizeLinks( [in] string url );
+
+};
+
+//=============================================================================
+
+}; }; }; };
+
+#endif
diff --git a/main/sc/inc/docuno.hxx b/main/sc/inc/docuno.hxx
index 2d4ac4e1a9..f9dee234d0 100644
--- a/main/sc/inc/docuno.hxx
+++ b/main/sc/inc/docuno.hxx
@@ -31,6 +31,7 @@
 #include <com/sun/star/view/XRenderable.hpp>
 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
 #include <com/sun/star/document/XActionLockable.hpp>
+#include <com/sun/star/document/XLinkAuthorizer.hpp>
 #include <com/sun/star/document/XLinkTargetSupplier.hpp>
 #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
 #include <com/sun/star/drawing/XDrawPages.hpp>
@@ -82,6 +83,7 @@ class SC_DLLPUBLIC ScModelObj : public SfxBaseModel,
 					public com::sun::star::sheet::XDocumentAuditing,
 					public com::sun::star::style::XStyleFamiliesSupplier,
 					public com::sun::star::view::XRenderable,
+					public com::sun::star::document::XLinkAuthorizer,
 					public com::sun::star::document::XLinkTargetSupplier,
 					public com::sun::star::beans::XPropertySet,
 					public SvxFmMSFactory,	// derived from XMultiServiceFactory
@@ -175,6 +177,8 @@ public:
 								throw (::com::sun::star::lang::IllegalArgumentException,
 										::com::sun::star::uno::RuntimeException);
 
+							//XLinkAuthorizer
+	virtual sal_Bool SAL_CALL authorizeLinks( const ::rtl::OUString& rURL ) throw( ::com::sun::star::uno::RuntimeException );
 							// XLinkTargetSupplier
 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL
 							getLinks() throw(::com::sun::star::uno::RuntimeException);
diff --git a/main/sc/source/ui/unoobj/docuno.cxx b/main/sc/source/ui/unoobj/docuno.cxx
index ef1b1481a4..b2607a315d 100644
--- a/main/sc/source/ui/unoobj/docuno.cxx
+++ b/main/sc/source/ui/unoobj/docuno.cxx
@@ -34,6 +34,8 @@
 #include <svl/smplhint.hxx>
 #include <unotools/undoopt.hxx>
 #include <unotools/moduleoptions.hxx>
+#include <sfx2/docfile.hxx>
+#include <sfx2/linkmgr.hxx>
 #include <sfx2/printer.hxx>
 #include <sfx2/bindings.hxx>
 #include <vcl/pdfextoutdevdata.hxx>
@@ -460,6 +462,7 @@ uno::Any SAL_CALL ScModelObj::queryInterface( const uno::Type& rType )
 	SC_QUERYINTERFACE( sheet::XDocumentAuditing )
 	SC_QUERYINTERFACE( style::XStyleFamiliesSupplier )
 	SC_QUERYINTERFACE( view::XRenderable )
+	SC_QUERYINTERFACE( document::XLinkAuthorizer )
 	SC_QUERYINTERFACE( document::XLinkTargetSupplier )
 	SC_QUERYINTERFACE( beans::XPropertySet )
 	SC_QUERYINTERFACE( lang::XMultiServiceFactory )
@@ -518,7 +521,7 @@ uno::Sequence<uno::Type> SAL_CALL ScModelObj::getTypes() throw(uno::RuntimeExcep
 		long nAggLen = aAggTypes.getLength();
 		const uno::Type* pAggPtr = aAggTypes.getConstArray();
 
-		const long nThisLen = 15;
+		const long nThisLen = 16;
 		aTypes.realloc( nParentLen + nAggLen + nThisLen );
 		uno::Type* pPtr = aTypes.getArray();
 		pPtr[nParentLen + 0] = getCppuType((const uno::Reference<sheet::XSpreadsheetDocument>*)0);
@@ -531,11 +534,12 @@ uno::Sequence<uno::Type> SAL_CALL ScModelObj::getTypes() throw(uno::RuntimeExcep
 		pPtr[nParentLen + 7] = getCppuType((const uno::Reference<sheet::XDocumentAuditing>*)0);
 		pPtr[nParentLen + 8] = getCppuType((const uno::Reference<style::XStyleFamiliesSupplier>*)0);
 		pPtr[nParentLen + 9] = getCppuType((const uno::Reference<view::XRenderable>*)0);
-		pPtr[nParentLen +10] = getCppuType((const uno::Reference<document::XLinkTargetSupplier>*)0);
-		pPtr[nParentLen +11] = getCppuType((const uno::Reference<beans::XPropertySet>*)0);
-		pPtr[nParentLen +12] = getCppuType((const uno::Reference<lang::XMultiServiceFactory>*)0);
-		pPtr[nParentLen +13] = getCppuType((const uno::Reference<lang::XServiceInfo>*)0);
-		pPtr[nParentLen +14] = getCppuType((const uno::Reference<util::XChangesNotifier>*)0);
+		pPtr[nParentLen +10] = getCppuType((const uno::Reference<document::XLinkAuthorizer>*)0);
+		pPtr[nParentLen +11] = getCppuType((const uno::Reference<document::XLinkTargetSupplier>*)0);
+		pPtr[nParentLen +12] = getCppuType((const uno::Reference<beans::XPropertySet>*)0);
+		pPtr[nParentLen +13] = getCppuType((const uno::Reference<lang::XMultiServiceFactory>*)0);
+		pPtr[nParentLen +14] = getCppuType((const uno::Reference<lang::XServiceInfo>*)0);
+		pPtr[nParentLen +15] = getCppuType((const uno::Reference<util::XChangesNotifier>*)0);
 
 		long i;
 		for (i=0; i<nParentLen; i++)
@@ -1301,6 +1305,31 @@ void SAL_CALL ScModelObj::render( sal_Int32 nSelRenderer, const uno::Any& aSelec
 	delete pDrawView;
 }
 
+// XLinkAuthorizer
+
+sal_Bool ScModelObj::authorizeLinks( const ::rtl::OUString& rURL ) throw( uno::RuntimeException )
+{
+	ScUnoGuard aGuard;
+	ScDocument *doc = pDocShell->GetDocument();
+	if ( doc ) {
+		// The following access to the window is copied from SwDoc::UpdateLinks()
+		SfxMedium* pMedium = pDocShell->GetMedium();
+		SfxFrame* pFrm = pMedium ? pMedium->GetLoadTargetFrame() : 0;
+		sfx2::LinkManager *pLinkMgr = doc->GetLinkManager();
+		if ( pLinkMgr->urlIsSafe( rURL ) ) {
+			return sal_True;
+		}
+		Window* pDlgParent = 0;
+		if ( pFrm )
+			pDlgParent = &pFrm->GetWindow();
+		if ( !pDlgParent )
+			pDlgParent = pDocShell->GetDialogParent( pMedium );
+		if ( pDlgParent )
+			return pLinkMgr->GetUserAllowsLinkUpdate( pDlgParent );
+	}
+	return sal_False;
+}
+
 // XLinkTargetSupplier
 
 uno::Reference<container::XNameAccess> SAL_CALL ScModelObj::getLinks() throw(uno::RuntimeException)
diff --git a/main/sd/source/ui/inc/unomodel.hxx b/main/sd/source/ui/inc/unomodel.hxx
index 759df49ab1..6fa5ef2d53 100644
--- a/main/sd/source/ui/inc/unomodel.hxx
+++ b/main/sd/source/ui/inc/unomodel.hxx
@@ -24,6 +24,7 @@
 #define SD_UNO_MODEL_HXX
 
 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
+#include <com/sun/star/document/XLinkAuthorizer.hpp>
 #include <com/sun/star/document/XLinkTargetSupplier.hpp>
 #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
 #include <com/sun/star/drawing/XDrawPageSummarizer.hpp>
@@ -76,6 +77,7 @@ class SdXImpressDocument : public SfxBaseModel, // implements SfxListener, OWEAK
 						   public ::com::sun::star::drawing::XDrawPagesSupplier,
 						   public ::com::sun::star::presentation::XPresentationSupplier,
 						   public ::com::sun::star::presentation::XCustomPresentationSupplier,
+						   public ::com::sun::star::document::XLinkAuthorizer,
 						   public ::com::sun::star::document::XLinkTargetSupplier,
 						   public ::com::sun::star::beans::XPropertySet,
 						   public ::com::sun::star::style::XStyleFamiliesSupplier,
@@ -201,6 +203,9 @@ public:
     virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
     virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
 
+	// XLinkAuthorizer
+    virtual sal_Bool SAL_CALL authorizeLinks( const ::rtl::OUString &url ) throw(::com::sun::star::uno::RuntimeException);
+
 	// XLinkTargetSupplier
     virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getLinks(  ) throw(::com::sun::star::uno::RuntimeException);
 
diff --git a/main/sd/source/ui/unoidl/unomodel.cxx b/main/sd/source/ui/unoidl/unomodel.cxx
index f92359c80c..57b2243c57 100644
--- a/main/sd/source/ui/unoidl/unomodel.cxx
+++ b/main/sd/source/ui/unoidl/unomodel.cxx
@@ -45,7 +45,9 @@
 #include <editeng/unofield.hxx>
 #include <unomodel.hxx>
 #include <sfx2/dispatch.hxx>
+#include <sfx2/docfile.hxx>
 #include <sfx2/bindings.hxx>
+#include <sfx2/linkmgr.hxx>
 #include <vcl/svapp.hxx>
 #include <editeng/UnoForbiddenCharsTable.hxx>
 #include <svx/svdoutl.hxx>
@@ -301,6 +303,7 @@ uno::Any SAL_CALL SdXImpressDocument::queryInterface( const uno::Type & rType )
 	else QUERYINT(drawing::XMasterPagesSupplier);
 	else QUERYINT(drawing::XDrawPagesSupplier);
 	else QUERYINT(presentation::XHandoutMasterSupplier);
+	else QUERYINT(document::XLinkAuthorizer);
 	else QUERYINT(document::XLinkTargetSupplier);
 	else QUERYINT(style::XStyleFamiliesSupplier);
 	else QUERYINT(com::sun::star::ucb::XAnyCompareFactory);
@@ -395,7 +398,7 @@ uno::Sequence< uno::Type > SAL_CALL SdXImpressDocument::getTypes(  ) throw(uno::
 		const sal_Int32 nBaseTypes = aBaseTypes.getLength();
 		const uno::Type* pBaseTypes = aBaseTypes.getConstArray();
 
-		const sal_Int32 nOwnTypes = mbImpressDoc ? 14 : 11;		// !DANGER! Keep this updated!
+		const sal_Int32 nOwnTypes = mbImpressDoc ? 15 : 12;		// !DANGER! Keep this updated!
 
 		maTypeSequence.realloc(  nBaseTypes + nOwnTypes );
 		uno::Type* pTypes = maTypeSequence.getArray();
@@ -407,6 +410,7 @@ uno::Sequence< uno::Type > SAL_CALL SdXImpressDocument::getTypes(  ) throw(uno::
 		*pTypes++ = ITYPE(drawing::XLayerSupplier);
 		*pTypes++ = ITYPE(drawing::XMasterPagesSupplier);
 		*pTypes++ = ITYPE(drawing::XDrawPagesSupplier);
+		*pTypes++ = ITYPE(document::XLinkAuthorizer);
 		*pTypes++ = ITYPE(document::XLinkTargetSupplier);
 		*pTypes++ = ITYPE(style::XStyleFamiliesSupplier);
 		*pTypes++ = ITYPE(com::sun::star::ucb::XAnyCompareFactory);
@@ -1424,6 +1428,30 @@ void SAL_CALL SdXImpressDocument::removePropertyChangeListener( const OUString&
 void SAL_CALL SdXImpressDocument::addVetoableChangeListener( const OUString& , const uno::Reference< beans::XVetoableChangeListener >&  ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) {}
 void SAL_CALL SdXImpressDocument::removeVetoableChangeListener( const OUString& , const uno::Reference< beans::XVetoableChangeListener >&  ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) {}
 
+// XLinkAuthorizer
+sal_Bool SAL_CALL SdXImpressDocument::authorizeLinks( const ::rtl::OUString &url )
+	throw(uno::RuntimeException)
+{
+	OGuard aGuard( Application::GetSolarMutex() );
+	if ( mpDoc ) {
+		// The following access to the window is copied from SwDoc::UpdateLinks()
+		SfxMedium* pMedium = mpDocShell->GetMedium();
+		SfxFrame* pFrm = pMedium ? pMedium->GetLoadTargetFrame() : 0;
+		sfx2::LinkManager *pLinkMgr = mpDoc->GetLinkManager();
+		if ( pLinkMgr->urlIsSafe( url ) ) {
+			return sal_True;
+		}
+		Window* pDlgParent = 0;
+		if ( pFrm )
+			pDlgParent = &pFrm->GetWindow();
+		if ( !pDlgParent )
+			pDlgParent = mpDocShell->GetDialogParent( pMedium );
+		if ( pDlgParent )
+			return pLinkMgr->GetUserAllowsLinkUpdate( pDlgParent );
+	}
+	return sal_False;
+}
+
 // XLinkTargetSupplier
 uno::Reference< container::XNameAccess > SAL_CALL SdXImpressDocument::getLinks()
 	throw(uno::RuntimeException)
diff --git a/main/sfx2/inc/sfx2/linkmgr.hxx b/main/sfx2/inc/sfx2/linkmgr.hxx
index 85634051a5..8f08395040 100644
--- a/main/sfx2/inc/sfx2/linkmgr.hxx
+++ b/main/sfx2/inc/sfx2/linkmgr.hxx
@@ -33,6 +33,11 @@ class SfxObjectShell;
 class Graphic;
 class Size;
 
+namespace com { namespace sun { namespace star { namespace util {
+    class URL;
+    class XURLTransformer;
+} } } }
+
 namespace sfx2
 {
     // The FileObject sends a SvData with the FormatId to notify the link about
@@ -59,6 +64,8 @@ class SFX2_DLLPUBLIC LinkManager
 	sal_Bool mUpdateAsked;
 	sal_Bool mAllowUpdate;
 
+    com::sun::star::uno::Reference< com::sun::star::util::XURLTransformer > xURLTransformer;
+
 	void SetUserAllowsLinkUpdate(SvBaseLink *pLink, sal_Bool allows);
 protected:
 	sal_Bool 		InsertLink( SvBaseLink* pLink, sal_uInt16 nObjType, sal_uInt16 nUpdateType,
@@ -155,6 +162,14 @@ public:
 								const ::com::sun::star::uno::Any & rValue,
 								Graphic& rGrf );
 
+    // Check whether a link URL must be subject to authorization
+    //
+    // An empty url is considered unsafe
+    sal_Bool urlIsSafe( const ::rtl::OUString &url );
+
+    // Check whether a link URL must be subject to authorization
+    sal_Bool urlIsSafe( const ::com::sun::star::util::URL &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 a2aebb0558..6a6c3414a2 100644
--- a/main/sfx2/source/appl/linkmgr2.cxx
+++ b/main/sfx2/source/appl/linkmgr2.cxx
@@ -24,6 +24,9 @@
 
 #include <sfx2/linkmgr.hxx>
 #include <com/sun/star/document/UpdateDocMode.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/util/XURLTransformer.hpp>
+
 #include <sfx2/objsh.hxx>
 #include <svl/urihelper.hxx>
 #include <sot/formats.hxx>
@@ -38,6 +41,7 @@
 #include <svl/eitem.hxx>
 #include <svl/intitem.hxx>
 #include <unotools/localfilehelper.hxx>
+#include <comphelper/processfactory.hxx>
 #include <i18npool/mslangid.hxx>
 #include <sfx2/request.hxx>
 #include <vcl/dibtools.hxx>
@@ -538,6 +542,38 @@ sal_Bool LinkManager::GetGraphicFromAny( const String& rMimeType,
 	return bRet;
 }
 
+sal_Bool LinkManager::urlIsSafe( const ::rtl::OUString &url )
+{
+	if ( url.getLength() == 0 ) {
+		return sal_False;
+	}
+	if ( !xURLTransformer.is() ) {
+		const com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > xContext ( ::comphelper::getProcessComponentContext() );
+		com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiComponentFactory > xFactory ( xContext->getServiceManager(), ::com::sun::star::uno::UNO_QUERY );
+		if ( !xFactory.is() ) {
+			return sal_False;
+		}
+		xURLTransformer.set( xFactory->createInstanceWithContext( rtl::OUString::createFromAscii( "com.sun.star.util.URLTransformer" ), xContext), com::sun::star::uno::UNO_QUERY );
+		if ( !xURLTransformer.is() ) {
+			return sal_False;
+		}
+	}
+	com::sun::star::util::URL aURL;
+	aURL.Complete = url;
+	sal_Bool b = xURLTransformer->parseSmart( aURL, ::rtl::OUString() );
+	if ( !b ) {
+		return sal_False;
+	}
+	return urlIsSafe( aURL );
+}
+
+sal_Bool LinkManager::urlIsSafe( const ::com::sun::star::util::URL &url )
+{
+	sal_Bool result = ( url.Path.getLength() == 0 ) &&
+		( url.Server.getLength() == 0);
+	return result;
+}
+
 
 // ----------------------------------------------------------------------
 String lcl_DDE_RelToAbs( const String& rTopic, const String& rBaseURL )
diff --git a/main/sw/inc/unotxdoc.hxx b/main/sw/inc/unotxdoc.hxx
index 321c0c563a..2b784165b3 100644
--- a/main/sw/inc/unotxdoc.hxx
+++ b/main/sw/inc/unotxdoc.hxx
@@ -30,6 +30,7 @@
 #include <com/sun/star/beans/PropertyValues.hpp>
 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
 #include <com/sun/star/style/XAutoStylesSupplier.hpp>
+#include <com/sun/star/document/XLinkAuthorizer.hpp>
 #include <com/sun/star/document/XLinkTargetSupplier.hpp>
 #include <com/sun/star/document/XRedlinesSupplier.hpp>
 #include <com/sun/star/text/XNumberingRulesSupplier.hpp>
@@ -76,22 +77,22 @@
 
 #include <viewopt.hxx>
 
-#define __IFC32 Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11, Ifc12, Ifc13, Ifc14, Ifc15, Ifc16, \
-Ifc17, Ifc18, Ifc19, Ifc20, Ifc21, Ifc22, Ifc23, Ifc24, Ifc25, Ifc26, Ifc27, Ifc28, Ifc29, Ifc30, Ifc31, Ifc32
+#define __IFC33 Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11, Ifc12, Ifc13, Ifc14, Ifc15, Ifc16, \
+Ifc17, Ifc18, Ifc19, Ifc20, Ifc21, Ifc22, Ifc23, Ifc24, Ifc25, Ifc26, Ifc27, Ifc28, Ifc29, Ifc30, Ifc31, Ifc32, Ifc33
 
-#define __CLASS_IFC32 class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, \
+#define __CLASS_IFC33 class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, \
 class Ifc8, class Ifc9, class Ifc10, class Ifc11, class Ifc12, class Ifc13, class Ifc14, class Ifc15, class Ifc16, \
 class Ifc17, class Ifc18, class Ifc19, class Ifc20, class Ifc21, class Ifc22, class Ifc23, class Ifc24,\
-class Ifc25, class Ifc26, class Ifc27, class Ifc28, class Ifc29, class Ifc30, class Ifc31 , class Ifc32
+class Ifc25, class Ifc26, class Ifc27, class Ifc28, class Ifc29, class Ifc30, class Ifc31 , class Ifc32, class Ifc33
 
-#define __PUBLIC_IFC32 public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8, public Ifc9, public Ifc10, public Ifc11, public Ifc12, \
+#define __PUBLIC_IFC33 public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8, public Ifc9, public Ifc10, public Ifc11, public Ifc12, \
 public Ifc13, public Ifc14, public Ifc15, public Ifc16, public Ifc17, public Ifc18, \
 public Ifc19, public Ifc20, public Ifc21, public Ifc22, public Ifc23, public Ifc24, \
 public Ifc25, public Ifc26, public Ifc27, public Ifc28, public Ifc29, public Ifc30, \
-public Ifc31, public Ifc32
+public Ifc31, public Ifc32, public Ifc33
 #include <cppuhelper/implbase_ex.hxx>
 #include <cppuhelper/implbase_ex_pre.hxx>
-#define __IFC_EX_TYPE_INIT32( class_cast ) \
+#define __IFC_EX_TYPE_INIT33( class_cast ) \
     __IFC_EX_TYPE_INIT( class_cast, 1 ), __IFC_EX_TYPE_INIT( class_cast, 2 ), \
     __IFC_EX_TYPE_INIT( class_cast, 3 ), __IFC_EX_TYPE_INIT( class_cast, 4 ), \
     __IFC_EX_TYPE_INIT( class_cast, 5 ), __IFC_EX_TYPE_INIT( class_cast, 6 ), \
@@ -107,10 +108,11 @@ public Ifc31, public Ifc32
     __IFC_EX_TYPE_INIT( class_cast, 25 ), __IFC_EX_TYPE_INIT( class_cast, 26 ), \
     __IFC_EX_TYPE_INIT( class_cast, 27 ), __IFC_EX_TYPE_INIT( class_cast, 28 ), \
     __IFC_EX_TYPE_INIT( class_cast, 29 ), __IFC_EX_TYPE_INIT( class_cast, 30 ), \
-    __IFC_EX_TYPE_INIT( class_cast, 31 ), __IFC_EX_TYPE_INIT( class_cast, 32)
+    __IFC_EX_TYPE_INIT( class_cast, 31 ), __IFC_EX_TYPE_INIT( class_cast, 32 ), \
+    __IFC_EX_TYPE_INIT( class_cast, 33 )
 #include <cppuhelper/implbase_ex_post.hxx>
 
-__DEF_IMPLHELPER_EX( 32 )
+__DEF_IMPLHELPER_EX( 33 )
 
 namespace css = ::com::sun::star;
 
@@ -136,7 +138,7 @@ SV_DECL_PTRARR(ActionContextArr, UnoActionContextPtr, 4, 4)
  ******************************************************************************/
 
 
-typedef cppu::WeakImplHelper32
+typedef cppu::WeakImplHelper33
 <
 	css::text::XTextDocument,
 	css::text::XLineNumberingProperties,
@@ -161,6 +163,7 @@ typedef cppu::WeakImplHelper32
 	css::text::XDocumentIndexesSupplier,
 	css::beans::XPropertySet,
 	css::beans::XPropertyState,
+	css::document::XLinkAuthorizer,
 	css::document::XLinkTargetSupplier,
 	css::document::XRedlinesSupplier,
 	css::util::XRefreshable,
@@ -391,6 +394,9 @@ public:
     virtual void SAL_CALL setPropertyToDefault( const ::rtl::OUString& rPropertyName ) throw (css::beans::UnknownPropertyException, css::uno::RuntimeException);
     virtual css::uno::Any SAL_CALL getPropertyDefault( const ::rtl::OUString& rPropertyName ) throw (css::beans::UnknownPropertyException, css::lang::WrappedTargetException, css::uno::RuntimeException);
 
+	//XLinkAuthorizer
+	virtual sal_Bool SAL_CALL authorizeLinks( const ::rtl::OUString& rURL ) throw( css::uno::RuntimeException );
+
 	//XLinkTargetSupplier
 	virtual css::uno::Reference< css::container::XNameAccess >  SAL_CALL getLinks(void) throw( css::uno::RuntimeException );
 
diff --git a/main/sw/source/ui/uno/unotxdoc.cxx b/main/sw/source/ui/uno/unotxdoc.cxx
index 12fdadcf07..c56766b0b3 100644
--- a/main/sw/source/ui/uno/unotxdoc.cxx
+++ b/main/sw/source/ui/uno/unotxdoc.cxx
@@ -2374,6 +2374,28 @@ void SwXTextDocument::removeVetoableChangeListener(const OUString& /*PropertyNam
 {
 	DBG_WARNING("not implemented");
 }
+
+sal_Bool SwXTextDocument::authorizeLinks( const ::rtl::OUString& rURL ) throw( RuntimeException )
+{
+	SwDoc *doc = pDocShell->GetDoc();
+	if ( doc ) {
+		// The following access to the window is copied from SwDoc::UpdateLinks()
+		SfxMedium* pMedium = pDocShell->GetMedium();
+		SfxFrame* pFrm = pMedium ? pMedium->GetLoadTargetFrame() : 0;
+		sfx2::LinkManager &pLinkMgr = doc->GetLinkManager();
+		if ( pLinkMgr.urlIsSafe( rURL ) ) {
+			return sal_True;
+		}
+		Window* pDlgParent = 0;
+		if ( pFrm )
+			pDlgParent = &pFrm->GetWindow();
+		if ( !pDlgParent )
+			pDlgParent = pDocShell->GetDialogParent( pMedium );
+		if ( pDlgParent )
+			return pLinkMgr.GetUserAllowsLinkUpdate( pDlgParent );
+	}
+	return sal_False;
+}
 /* -----------------25.10.99 10:42-------------------
 
  --------------------------------------------------*/