From c855a3ff35e8ad562161e0088c66daf945bb6a33 Mon Sep 17 00:00:00 2001 From: Xisco Fauli Date: Tue, 16 Jun 2026 17:47:02 +0200 Subject: [PATCH] Revert "remove css::embed::XLinkFactory" This reverts commit 26305f046f48dea9d7f88337ad9dc613f8e6a12d. it removes a published API without deprecating it first Change-Id: I174320a675e9fe6f9a7de475491ca7984ac30d9f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/206709 Reviewed-by: Xisco Fauli Tested-by: Jenkins --- .../source/commonembedding/xfactory.cxx | 57 +++++++++++++ .../source/commonembedding/xfactory.hxx | 5 ++ offapi/UnoApi_offapi.mk | 1 + .../sun/star/embed/XEmbeddedObjectCreator.idl | 1 + offapi/com/sun/star/embed/XLinkFactory.idl | 80 +++++++++++++++++++ offapi/type_reference/offapi.idl | 4 + 6 files changed, 148 insertions(+) create mode 100644 offapi/com/sun/star/embed/XLinkFactory.idl diff --git a/embeddedobj/source/commonembedding/xfactory.cxx b/embeddedobj/source/commonembedding/xfactory.cxx index cc4d51fc172c..3b5765a91cec 100644 --- a/embeddedobj/source/commonembedding/xfactory.cxx +++ b/embeddedobj/source/commonembedding/xfactory.cxx @@ -306,6 +306,63 @@ uno::Reference< uno::XInterface > SAL_CALL OOoEmbeddedObjectFactory::createInsta return xResult; } +uno::Reference< uno::XInterface > SAL_CALL OOoEmbeddedObjectFactory::createInstanceLinkUserInit( + const uno::Sequence< sal_Int8 >& aClassID, + const OUString& /*aClassName*/, + const uno::Reference< embed::XStorage >& xStorage, + const OUString& sEntName, + const uno::Sequence< beans::PropertyValue >& lArguments, + const uno::Sequence< beans::PropertyValue >& lObjArgs ) +{ + if ( officecfg::Office::Common::Security::Scripting::DisableActiveContent::get() ) + throw lang::NoSupportException(u"Active embedded content is disabled!"_ustr); + uno::Reference< uno::XInterface > xResult; + + // the initialization is completely controlled by user + if ( !xStorage.is() ) + throw lang::IllegalArgumentException( u"No parent storage is provided!"_ustr, + uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ), + 1 ); + + if ( sEntName.isEmpty() ) + throw lang::IllegalArgumentException( u"Empty element name is provided!"_ustr, + uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ), + 2 ); + + uno::Sequence< beans::PropertyValue > aTempMedDescr( lArguments ); + + OUString aURL; + for (beans::PropertyValue const& prop : aTempMedDescr) + if ( prop.Name == "URL" ) + prop.Value >>= aURL; + + if ( aURL.isEmpty() ) + throw lang::IllegalArgumentException( u"No URL for the link is provided!"_ustr, + uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ), + 3 ); + + uno::Sequence< beans::NamedValue > aObject = m_aConfigHelper.GetObjectPropsByClassID( aClassID ); + if ( !aObject.hasElements() ) + throw io::IOException(); // unexpected mimetype of the storage + + OUString aFilterName = m_aConfigHelper.UpdateMediaDescriptorWithFilterName( aTempMedDescr, aObject ); + + if ( aFilterName.isEmpty() ) + { + // the object must be OOo embedded object, if it is not an exception must be thrown + throw io::IOException(); // TODO: + } + + xResult.set(static_cast< ::cppu::OWeakObject* > ( new OCommonEmbeddedObject( + m_xContext, + aObject, + aTempMedDescr, + lObjArgs ) ), + uno::UNO_QUERY ); + + return xResult; +} + OUString SAL_CALL OOoEmbeddedObjectFactory::getImplementationName() { return u"com.sun.star.comp.embed.OOoEmbeddedObjectFactory"_ustr; diff --git a/embeddedobj/source/commonembedding/xfactory.hxx b/embeddedobj/source/commonembedding/xfactory.hxx index 8b5d92a2c131..056f50705ef9 100644 --- a/embeddedobj/source/commonembedding/xfactory.hxx +++ b/embeddedobj/source/commonembedding/xfactory.hxx @@ -20,6 +20,7 @@ #pragma once #include +#include #include #include #include @@ -27,6 +28,7 @@ class OOoEmbeddedObjectFactory : public ::cppu::WeakImplHelper< css::embed::XEmbeddedObjectCreator, + css::embed::XLinkFactory, css::lang::XServiceInfo > { css::uno::Reference< css::uno::XComponentContext > m_xContext; @@ -53,6 +55,9 @@ public: // XLinkCreator virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstanceLink( const css::uno::Reference< css::embed::XStorage >& xStorage, const OUString& sEntName, const css::uno::Sequence< css::beans::PropertyValue >& aMediaDescr, const css::uno::Sequence< css::beans::PropertyValue >& lObjArgs ) override; + // XLinkFactory + virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstanceLinkUserInit( const css::uno::Sequence< sal_Int8 >& aClassID, const OUString& aClassName, const css::uno::Reference< css::embed::XStorage >& xStorage, const OUString& sEntName, const css::uno::Sequence< css::beans::PropertyValue >& lArguments, const css::uno::Sequence< css::beans::PropertyValue >& lObjArgs ) override; + // XServiceInfo virtual OUString SAL_CALL getImplementationName() override; virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override; diff --git a/offapi/UnoApi_offapi.mk b/offapi/UnoApi_offapi.mk index 4ff27e052a80..c607450d542d 100644 --- a/offapi/UnoApi_offapi.mk +++ b/offapi/UnoApi_offapi.mk @@ -2405,6 +2405,7 @@ $(eval $(call gb_UnoApi_add_idlfiles,offapi,com/sun/star/embed,\ XInplaceObject \ XInsertObjectDialog \ XLinkCreator \ + XLinkFactory \ XLinkageSupport \ XOLESimpleStorage \ XOptimizedStorage \ diff --git a/offapi/com/sun/star/embed/XEmbeddedObjectCreator.idl b/offapi/com/sun/star/embed/XEmbeddedObjectCreator.idl index 67f0e852f67f..f0354b78a5de 100644 --- a/offapi/com/sun/star/embed/XEmbeddedObjectCreator.idl +++ b/offapi/com/sun/star/embed/XEmbeddedObjectCreator.idl @@ -27,6 +27,7 @@ interface XEmbeddedObjectCreator interface XEmbedObjectCreator; interface XEmbedObjectFactory; interface XLinkCreator; + [optional] interface XLinkFactory; }; diff --git a/offapi/com/sun/star/embed/XLinkFactory.idl b/offapi/com/sun/star/embed/XLinkFactory.idl new file mode 100644 index 000000000000..70ec24053cba --- /dev/null +++ b/offapi/com/sun/star/embed/XLinkFactory.idl @@ -0,0 +1,80 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * 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 . + */ + + + module com { module sun { module star { module embed { + +/** allows to create and initialize a new link of specified type. + */ +published interface XLinkFactory: com::sun::star::uno::XInterface +{ + /** creates a new link and transport parameters for persistent + initialization. + +

+ This method can be used to have a full control over persistence + initialization of a link. +

+ + @param aClassID + the class id of the new object + + @param ClassName + the class name of the new object + + @param xStorage + a parent storage the entry should be created in + + @param sEntryName + a name for the entry + + @param aArgs + com::sun::star::document::MediaDescriptor + that contains source for the link + + @param aObjectArgs + optional parameters for the object persistence initialization + see also + com::sun::star::embed::EmbeddedObjectDescriptor + + @throws ::com::sun::star::lang::IllegalArgumentException + one of arguments is illegal + + @throws com::sun::star::io::IOException + in case of io problems during opening or creation + + @throws com::sun::star::uno::Exception + in case of other problems + */ + ::com::sun::star::uno::XInterface createInstanceLinkUserInit( + [in] sequence< byte > aClassID, + [in] string ClassName, + [in] ::com::sun::star::embed::XStorage xStorage, + [in] string sEntryName, + [in] sequence< ::com::sun::star::beans::PropertyValue > aArgs, + [in] sequence< ::com::sun::star::beans::PropertyValue > aObjectArgs ) + raises( ::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::io::IOException, + ::com::sun::star::uno::Exception ); +}; + + +}; }; }; }; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/offapi/type_reference/offapi.idl b/offapi/type_reference/offapi.idl index 538044e2cdef..3e1952f37f30 100644 --- a/offapi/type_reference/offapi.idl +++ b/offapi/type_reference/offapi.idl @@ -6069,6 +6069,10 @@ module com { interface ::com::sun::star::uno::XInterface; ::com::sun::star::uno::XInterface createInstanceLink([in] ::com::sun::star::embed::XStorage xStorage, [in] string sEntryName, [in] sequence< ::com::sun::star::beans::PropertyValue > aArgs, [in] sequence< ::com::sun::star::beans::PropertyValue > aObjectArgs) raises (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::io::IOException, ::com::sun::star::uno::Exception); }; + published interface XLinkFactory { + interface ::com::sun::star::uno::XInterface; + ::com::sun::star::uno::XInterface createInstanceLinkUserInit([in] sequence< byte > aClassID, [in] string ClassName, [in] ::com::sun::star::embed::XStorage xStorage, [in] string sEntryName, [in] sequence< ::com::sun::star::beans::PropertyValue > aArgs, [in] sequence< ::com::sun::star::beans::PropertyValue > aObjectArgs) raises (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::io::IOException, ::com::sun::star::uno::Exception); + }; }; module frame { published interface XDispatchProviderInterceptor;