diff options
author | Noel Grandin <noel@peralex.com> | 2020-07-21 17:02:32 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-07-22 17:48:12 +0200 |
commit | 7405145605923123a09738829ead507fe6078e0c (patch) | |
tree | b85add1a367166cb53bcb90d08e7d0327e9e6f2f /embeddedobj/source | |
parent | 950d7d4d51e68cfae3a5d0d23a3d39e84e548357 (diff) |
embeddedobj/msole: create instances with uno constructors
See tdf#74608 for motivation.
Change-Id: I11ad7cf96d65332e418f1854803d62a30bacc7e4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99163
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'embeddedobj/source')
-rw-r--r-- | embeddedobj/source/inc/oleembobj.hxx | 9 | ||||
-rw-r--r-- | embeddedobj/source/msole/emboleobj.component | 5 | ||||
-rw-r--r-- | embeddedobj/source/msole/emboleobj.windows.component | 8 | ||||
-rw-r--r-- | embeddedobj/source/msole/olecomponent.cxx | 12 | ||||
-rw-r--r-- | embeddedobj/source/msole/olecomponent.hxx | 5 | ||||
-rw-r--r-- | embeddedobj/source/msole/oleembed.cxx | 38 | ||||
-rw-r--r-- | embeddedobj/source/msole/olemisc.cxx | 16 | ||||
-rw-r--r-- | embeddedobj/source/msole/olepersist.cxx | 78 | ||||
-rw-r--r-- | embeddedobj/source/msole/olepersist.hxx | 8 | ||||
-rw-r--r-- | embeddedobj/source/msole/oleregister.cxx | 75 | ||||
-rw-r--r-- | embeddedobj/source/msole/ownview.cxx | 32 | ||||
-rw-r--r-- | embeddedobj/source/msole/ownview.hxx | 7 | ||||
-rw-r--r-- | embeddedobj/source/msole/xdialogcreator.cxx | 46 | ||||
-rw-r--r-- | embeddedobj/source/msole/xdialogcreator.hxx | 18 | ||||
-rw-r--r-- | embeddedobj/source/msole/xolefactory.cxx | 46 | ||||
-rw-r--r-- | embeddedobj/source/msole/xolefactory.hxx | 18 |
16 files changed, 156 insertions, 265 deletions
diff --git a/embeddedobj/source/inc/oleembobj.hxx b/embeddedobj/source/inc/oleembobj.hxx index 051d63294af4..9739402c6a27 100644 --- a/embeddedobj/source/inc/oleembobj.hxx +++ b/embeddedobj/source/inc/oleembobj.hxx @@ -34,6 +34,7 @@ #include <com/sun/star/util/XCloseListener.hpp> #include <com/sun/star/io/XActiveDataStreamer.hpp> #include <com/sun/star/lang/XInitialization.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> #include <cppuhelper/implbase.hxx> #include <rtl/ref.hxx> @@ -132,7 +133,7 @@ class OleEmbeddedObject : public ::cppu::WeakImplHelper sal_Int32 m_nTargetState; sal_Int32 m_nUpdateMode; - css::uno::Reference< css::lang::XMultiServiceFactory > m_xFactory; + css::uno::Reference< css::uno::XComponentContext > m_xContext; css::uno::Sequence< sal_Int8 > m_aClassID; OUString m_aClassName; @@ -291,17 +292,17 @@ protected: public: // in case a new object must be created the class ID must be specified - OleEmbeddedObject( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory, + OleEmbeddedObject( const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Sequence< sal_Int8 >& aClassID, const OUString& aClassName ); // in case object will be loaded from a persistent entry or from a file the class ID will be detected on loading // factory can do it for OOo objects, but for OLE objects OS dependent code is required - OleEmbeddedObject( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory, + OleEmbeddedObject( const css::uno::Reference< css::uno::XComponentContext >& xContext, bool bLink ); #ifdef _WIN32 // this constructor let object be initialized from clipboard - OleEmbeddedObject( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory ); + OleEmbeddedObject( const css::uno::Reference< css::uno::XComponentContext >& xContext ); #endif virtual ~OleEmbeddedObject() override; diff --git a/embeddedobj/source/msole/emboleobj.component b/embeddedobj/source/msole/emboleobj.component index 5b588b2c30ac..bf7e128f04e5 100644 --- a/embeddedobj/source/msole/emboleobj.component +++ b/embeddedobj/source/msole/emboleobj.component @@ -18,8 +18,9 @@ --> <component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@" - prefix="emboleobj" xmlns="http://openoffice.org/2010/uno-components"> - <implementation name="com.sun.star.comp.embed.OLEEmbeddedObjectFactory"> + xmlns="http://openoffice.org/2010/uno-components"> + <implementation name="com.sun.star.comp.embed.OLEEmbeddedObjectFactory" + constructor="embeddedobj_OleEmbeddedObjectFactory_get_implementation"> <service name="com.sun.star.comp.embed.OLEEmbeddedObjectFactory"/> <service name="com.sun.star.embed.OLEEmbeddedObjectFactory"/> </implementation> diff --git a/embeddedobj/source/msole/emboleobj.windows.component b/embeddedobj/source/msole/emboleobj.windows.component index 7faee94cc84d..e41c81d33048 100644 --- a/embeddedobj/source/msole/emboleobj.windows.component +++ b/embeddedobj/source/msole/emboleobj.windows.component @@ -18,12 +18,14 @@ --> <component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@" - prefix="emboleobj" xmlns="http://openoffice.org/2010/uno-components"> - <implementation name="com.sun.star.comp.embed.MSOLEObjectSystemCreator"> + xmlns="http://openoffice.org/2010/uno-components"> + <implementation name="com.sun.star.comp.embed.MSOLEObjectSystemCreator" + constructor="embeddedobj_MSOLEDialogObjectCreator_get_implementation"> <service name="com.sun.star.comp.embed.MSOLEObjectSystemCreator"/> <service name="com.sun.star.embed.MSOLEObjectSystemCreator"/> </implementation> - <implementation name="com.sun.star.comp.embed.OLEEmbeddedObjectFactory"> + <implementation name="com.sun.star.comp.embed.OLEEmbeddedObjectFactory" + constructor="embeddedobj_OleEmbeddedObjectFactory_get_implementation"> <service name="com.sun.star.comp.embed.OLEEmbeddedObjectFactory"/> <service name="com.sun.star.embed.OLEEmbeddedObjectFactory"/> </implementation> diff --git a/embeddedobj/source/msole/olecomponent.cxx b/embeddedobj/source/msole/olecomponent.cxx index 7e8cfdb1809e..ea5bb265aa2c 100644 --- a/embeddedobj/source/msole/olecomponent.cxx +++ b/embeddedobj/source/msole/olecomponent.cxx @@ -427,7 +427,7 @@ static OUString WinAccToVcl_Impl( const sal_Unicode* pStr ) } -OleComponent::OleComponent( const uno::Reference< lang::XMultiServiceFactory >& xFactory, OleEmbeddedObject* pUnoOleObject ) +OleComponent::OleComponent( const uno::Reference< uno::XComponentContext >& xContext, OleEmbeddedObject* pUnoOleObject ) : m_pInterfaceContainer( nullptr ) , m_bDisposed( false ) , m_bModified( false ) @@ -437,7 +437,7 @@ OleComponent::OleComponent( const uno::Reference< lang::XMultiServiceFactory >& , m_pImplAdviseSink( nullptr ) , m_nOLEMiscFlags( 0 ) , m_nAdvConn( 0 ) -, m_xFactory( xFactory ) +, m_xContext( xContext ) , m_bOleInitialized( false ) , m_bWorkaroundActive( false ) { @@ -545,7 +545,7 @@ void OleComponent::CreateNewIStorage_Impl() if ( m_pUnoOleObject ) aTempURL = m_pUnoOleObject->CreateTempURLEmpty_Impl(); else - aTempURL = GetNewTempFileURL_Impl( m_xFactory ); + aTempURL = GetNewTempFileURL_Impl( m_xContext ); if ( !aTempURL.getLength() ) throw uno::RuntimeException(); // TODO @@ -1390,7 +1390,7 @@ void OleComponent::OnViewChange_Impl( sal_uInt32 dwAspect ) if ( xLockObject.is() ) { uno::Reference < awt::XRequestCallback > xRequestCallback( - m_xFactory->createInstance("com.sun.star.awt.AsyncCallback"), + m_xContext->getServiceManager()->createInstanceWithContext("com.sun.star.awt.AsyncCallback", m_xContext), uno::UNO_QUERY ); xRequestCallback->addCallback( new MainThreadNotificationRequest( xLockObject, OLECOMP_ONVIEWCHANGE, dwAspect ), uno::Any() ); } @@ -1410,7 +1410,7 @@ void OleComponent::OnClose_Impl() if ( xLockObject.is() ) { uno::Reference < awt::XRequestCallback > xRequestCallback( - m_xFactory->createInstance("com.sun.star.awt.AsyncCallback"), + m_xContext->getServiceManager()->createInstanceWithContext("com.sun.star.awt.AsyncCallback", m_xContext), uno::UNO_QUERY ); xRequestCallback->addCallback( new MainThreadNotificationRequest( xLockObject, OLECOMP_ONCLOSE ), uno::Any() ); } @@ -1572,7 +1572,7 @@ uno::Any SAL_CALL OleComponent::getTransferData( const datatransfer::DataFlavor& // allow to retrieve stream-representation of the object persistence bSupportedFlavor = true; uno::Reference < io::XStream > xTempFileStream( - io::TempFile::create(comphelper::getComponentContext(m_xFactory)), + io::TempFile::create(m_xContext), uno::UNO_QUERY_THROW ); uno::Reference< io::XOutputStream > xTempOutStream = xTempFileStream->getOutputStream(); diff --git a/embeddedobj/source/msole/olecomponent.hxx b/embeddedobj/source/msole/olecomponent.hxx index ffcf3e920162..9b0ca8038f85 100644 --- a/embeddedobj/source/msole/olecomponent.hxx +++ b/embeddedobj/source/msole/olecomponent.hxx @@ -33,6 +33,7 @@ #include <cppuhelper/implbase.hxx> #include <com/sun/star/util/XModifiable.hpp> #include <com/sun/star/util/XModifyListener.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> namespace cppu { @@ -65,7 +66,7 @@ class OleComponent : public ::cppu::WeakImplHelper< css::util::XCloseable, css:: css::uno::Sequence< css::embed::VerbDescriptor > m_aVerbList; css::uno::Sequence< css::datatransfer::DataFlavor > m_aDataFlavors; - css::uno::Reference< css::lang::XMultiServiceFactory > m_xFactory; + css::uno::Reference< css::uno::XComponentContext > m_xContext; bool m_bOleInitialized; @@ -81,7 +82,7 @@ class OleComponent : public ::cppu::WeakImplHelper< css::util::XCloseable, css:: public: - OleComponent( const css::uno::Reference< css::lang::XMultiServiceFactory >& m_xFactory, + OleComponent( const css::uno::Reference< css::uno::XComponentContext >& xContext, OleEmbeddedObject* pOleObj ); virtual ~OleComponent() override; diff --git a/embeddedobj/source/msole/oleembed.cxx b/embeddedobj/source/msole/oleembed.cxx index 5997fba7ca22..92cddf7cbcb2 100644 --- a/embeddedobj/source/msole/oleembed.cxx +++ b/embeddedobj/source/msole/oleembed.cxx @@ -260,14 +260,14 @@ bool OleEmbeddedObject::TryToConvertToOOo( const uno::Reference< io::XStream >& // the stream must be seekable uno::Reference< io::XSeekable > xSeekable( xStream, uno::UNO_QUERY_THROW ); xSeekable->seek( 0 ); - m_aFilterName = OwnView_Impl::GetFilterNameFromExtentionAndInStream( m_xFactory, OUString(), xStream->getInputStream() ); + m_aFilterName = OwnView_Impl::GetFilterNameFromExtentionAndInStream( m_xContext, OUString(), xStream->getInputStream() ); if ( !m_aFilterName.isEmpty() && ( m_aFilterName == "Calc MS Excel 2007 XML" || m_aFilterName == "Impress MS PowerPoint 2007 XML" || m_aFilterName == "MS Word 2007 XML" || m_aFilterName == "MS Excel 97 Vorlage/Template" || m_aFilterName == "MS Word 97 Vorlage" ) ) { uno::Reference< container::XNameAccess > xFilterFactory( - m_xFactory->createInstance("com.sun.star.document.FilterFactory"), + m_xContext->getServiceManager()->createInstanceWithContext("com.sun.star.document.FilterFactory", m_xContext), uno::UNO_QUERY_THROW ); OUString aDocServiceName; @@ -286,7 +286,7 @@ bool OleEmbeddedObject::TryToConvertToOOo( const uno::Reference< io::XStream >& uno::Sequence< uno::Any > aArguments(1); aArguments[0] <<= beans::NamedValue( "EmbeddedObject", uno::makeAny( true )); - uno::Reference< util::XCloseable > xDocument( m_xFactory->createInstanceWithArguments( aDocServiceName, aArguments ), uno::UNO_QUERY_THROW ); + uno::Reference< util::XCloseable > xDocument( m_xContext->getServiceManager()->createInstanceWithArgumentsAndContext( aDocServiceName, aArguments, m_xContext ), uno::UNO_QUERY_THROW ); uno::Reference< frame::XLoadable > xLoadable( xDocument, uno::UNO_QUERY_THROW ); uno::Reference< document::XStorageBasedDocument > xStorDoc( xDocument, uno::UNO_QUERY_THROW ); @@ -323,7 +323,7 @@ bool OleEmbeddedObject::TryToConvertToOOo( const uno::Reference< io::XStream >& xTmpStorage->dispose(); // look for the related embedded object factory - ::comphelper::MimeConfigurationHelper aConfigHelper( comphelper::getComponentContext(m_xFactory) ); + ::comphelper::MimeConfigurationHelper aConfigHelper( m_xContext ); OUString aEmbedFactory; if ( !aMediaType.isEmpty() ) aEmbedFactory = aConfigHelper.GetFactoryNameByMediaType( aMediaType ); @@ -331,7 +331,7 @@ bool OleEmbeddedObject::TryToConvertToOOo( const uno::Reference< io::XStream >& if ( aEmbedFactory.isEmpty() ) throw uno::RuntimeException(); - uno::Reference< uno::XInterface > xFact = m_xFactory->createInstance( aEmbedFactory ); + uno::Reference< uno::XInterface > xFact = m_xContext->getServiceManager()->createInstanceWithContext( aEmbedFactory, m_xContext ); uno::Reference< embed::XEmbedObjectCreator > xEmbCreator( xFact, uno::UNO_QUERY_THROW ); @@ -681,11 +681,11 @@ namespace } uno::Reference < io::XStream > lcl_GetExtractedStream( OUString& rUrl, - const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory, + const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::io::XStream >& xObjectStream ) { uno::Reference <beans::XPropertySet> xNativeTempFile( - io::TempFile::create(comphelper::getComponentContext(xFactory)), + io::TempFile::create(xContext), uno::UNO_QUERY_THROW); uno::Reference < io::XStream > xStream(xNativeTempFile, uno::UNO_QUERY_THROW); @@ -693,9 +693,9 @@ namespace aArgs[0] <<= xObjectStream; aArgs[1] <<= true; // do not create copy uno::Reference< container::XNameContainer > xNameContainer( - xFactory->createInstanceWithArguments( + xContext->getServiceManager()->createInstanceWithArgumentsAndContext( "com.sun.star.embed.OLESimpleStorage", - aArgs ), uno::UNO_QUERY_THROW ); + aArgs, xContext ), uno::UNO_QUERY_THROW ); //various stream names that can contain the real document contents for //this object in a straightforward direct way @@ -787,7 +787,7 @@ namespace xNativeTempFile.clear(); uno::Reference < ucb::XSimpleFileAccess3 > xSimpleFileAccess( - ucb::SimpleFileAccess::create( comphelper::getComponentContext(xFactory) ) ); + ucb::SimpleFileAccess::create( xContext ) ); xSimpleFileAccess->setReadOnly(rUrl, true); } @@ -803,26 +803,26 @@ namespace //Dump the objects content to a tempfile, just the "CONTENTS" stream if //there is one for non-compound documents, otherwise the whole content. //On success a file is returned which must be removed by the caller - OUString lcl_ExtractObject(const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory, + OUString lcl_ExtractObject(const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::io::XStream >& xObjectStream) { OUString sUrl; // the solution is only active for Unix systems #ifndef _WIN32 - lcl_GetExtractedStream(sUrl, xFactory, xObjectStream); + lcl_GetExtractedStream(sUrl, xContext, xObjectStream); #else - (void) xFactory; + (void) xContext; (void) xObjectStream; #endif return sUrl; } - uno::Reference < io::XStream > lcl_ExtractObjectStream( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory, + uno::Reference < io::XStream > lcl_ExtractObjectStream( const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::io::XStream >& xObjectStream ) { OUString sUrl; - return lcl_GetExtractedStream( sUrl, xFactory, xObjectStream ); + return lcl_GetExtractedStream( sUrl, xContext, xObjectStream ); } } @@ -924,7 +924,7 @@ void SAL_CALL OleEmbeddedObject::doVerb( sal_Int32 nVerbID ) if ( xSeekable.is() ) xSeekable->seek( 0 ); - m_xOwnView = new OwnView_Impl( m_xFactory, m_xObjectStream->getInputStream() ); + m_xOwnView = new OwnView_Impl( m_xContext, m_xObjectStream->getInputStream() ); } catch( uno::RuntimeException& ) { @@ -939,7 +939,7 @@ void SAL_CALL OleEmbeddedObject::doVerb( sal_Int32 nVerbID ) // it may be the OLE Storage, try to extract stream if ( !m_xOwnView.is() && m_xObjectStream.is() && m_aFilterName == "Text" ) { - uno::Reference< io::XStream > xStream = lcl_ExtractObjectStream( m_xFactory, m_xObjectStream ); + uno::Reference< io::XStream > xStream = lcl_ExtractObjectStream( m_xContext, m_xObjectStream ); if ( TryToConvertToOOo( xStream ) ) { @@ -953,13 +953,13 @@ void SAL_CALL OleEmbeddedObject::doVerb( sal_Int32 nVerbID ) //Make a RO copy and see if the OS can find something to at //least display the content for us if (m_aTempDumpURL.isEmpty()) - m_aTempDumpURL = lcl_ExtractObject(m_xFactory, m_xObjectStream); + m_aTempDumpURL = lcl_ExtractObject(m_xContext, m_xObjectStream); if (m_aTempDumpURL.isEmpty()) throw embed::UnreachableStateException(); uno::Reference< css::system::XSystemShellExecute > xSystemShellExecute( - css::system::SystemShellExecute::create(comphelper::getComponentContext(m_xFactory)) ); + css::system::SystemShellExecute::create( m_xContext ) ); xSystemShellExecute->execute(m_aTempDumpURL, OUString(), css::system::SystemShellExecuteFlags::URIS_ONLY); } diff --git a/embeddedobj/source/msole/olemisc.cxx b/embeddedobj/source/msole/olemisc.cxx index 6de6a9cdca75..90041729d03d 100644 --- a/embeddedobj/source/msole/olemisc.cxx +++ b/embeddedobj/source/msole/olemisc.cxx @@ -43,7 +43,7 @@ using namespace ::com::sun::star; -OleEmbeddedObject::OleEmbeddedObject( const uno::Reference< lang::XMultiServiceFactory >& xFactory, +OleEmbeddedObject::OleEmbeddedObject( const uno::Reference< uno::XComponentContext >& xContext, const uno::Sequence< sal_Int8 >& aClassID, const OUString& aClassName ) : m_pOleComponent( nullptr ) @@ -52,7 +52,7 @@ OleEmbeddedObject::OleEmbeddedObject( const uno::Reference< lang::XMultiServiceF , m_nObjectState( -1 ) , m_nTargetState( -1 ) , m_nUpdateMode ( embed::EmbedUpdateModes::ALWAYS_UPDATE ) -, m_xFactory( xFactory ) +, m_xContext( xContext ) , m_aClassID( aClassID ) , m_aClassName( aClassName ) , m_bWaitSaveCompleted( false ) @@ -77,14 +77,14 @@ OleEmbeddedObject::OleEmbeddedObject( const uno::Reference< lang::XMultiServiceF // In case of loading from persistent entry the classID of the object // will be retrieved from the entry, during construction it is unknown -OleEmbeddedObject::OleEmbeddedObject( const uno::Reference< lang::XMultiServiceFactory >& xFactory, bool bLink ) +OleEmbeddedObject::OleEmbeddedObject( const uno::Reference< uno::XComponentContext >& xContext, bool bLink ) : m_pOleComponent( nullptr ) , m_bReadOnly( false ) , m_bDisposed( false ) , m_nObjectState( -1 ) , m_nTargetState( -1 ) , m_nUpdateMode( embed::EmbedUpdateModes::ALWAYS_UPDATE ) -, m_xFactory( xFactory ) +, m_xContext( xContext ) , m_bWaitSaveCompleted( false ) , m_bNewVisReplInStream( true ) , m_bStoreLoaded( false ) @@ -106,14 +106,14 @@ OleEmbeddedObject::OleEmbeddedObject( const uno::Reference< lang::XMultiServiceF #ifdef _WIN32 // this constructor let object be initialized from clipboard -OleEmbeddedObject::OleEmbeddedObject( const uno::Reference< lang::XMultiServiceFactory >& xFactory ) +OleEmbeddedObject::OleEmbeddedObject( const uno::Reference< uno::XComponentContext >& xContext ) : m_pOleComponent( nullptr ) , m_bReadOnly( false ) , m_bDisposed( false ) , m_nObjectState( -1 ) , m_nTargetState( -1 ) , m_nUpdateMode( embed::EmbedUpdateModes::ALWAYS_UPDATE ) -, m_xFactory( xFactory ) +, m_xContext( xContext ) , m_bWaitSaveCompleted( false ) , m_bNewVisReplInStream( true ) , m_bStoreLoaded( false ) @@ -149,10 +149,10 @@ OleEmbeddedObject::~OleEmbeddedObject() } if ( !m_aTempURL.isEmpty() ) - KillFile_Impl( m_aTempURL, m_xFactory ); + KillFile_Impl( m_aTempURL, m_xContext ); if ( !m_aTempDumpURL.isEmpty() ) - KillFile_Impl( m_aTempDumpURL, m_xFactory ); + KillFile_Impl( m_aTempDumpURL, m_xContext ); } diff --git a/embeddedobj/source/msole/olepersist.cxx b/embeddedobj/source/msole/olepersist.cxx index c4c8760b549b..2d5dfbf59a4d 100644 --- a/embeddedobj/source/msole/olepersist.cxx +++ b/embeddedobj/source/msole/olepersist.cxx @@ -59,9 +59,9 @@ using namespace ::com::sun::star; using namespace ::comphelper; -bool KillFile_Impl( const OUString& aURL, const uno::Reference< lang::XMultiServiceFactory >& xFactory ) +bool KillFile_Impl( const OUString& aURL, const uno::Reference< uno::XComponentContext >& xContext ) { - if ( !xFactory.is() ) + if ( !xContext.is() ) return false; bool bRet = false; @@ -69,7 +69,7 @@ bool KillFile_Impl( const OUString& aURL, const uno::Reference< lang::XMultiServ try { uno::Reference < ucb::XSimpleFileAccess3 > xAccess( - ucb::SimpleFileAccess::create( comphelper::getComponentContext(xFactory) ) ); + ucb::SimpleFileAccess::create( xContext ) ); xAccess->kill( aURL ); bRet = true; @@ -82,14 +82,14 @@ bool KillFile_Impl( const OUString& aURL, const uno::Reference< lang::XMultiServ } -OUString GetNewTempFileURL_Impl( const uno::Reference< lang::XMultiServiceFactory >& xFactory ) +OUString GetNewTempFileURL_Impl( const uno::Reference< uno::XComponentContext >& xContext ) { - SAL_WARN_IF( !xFactory.is(), "embeddedobj.ole", "No factory is provided!" ); + SAL_WARN_IF( !xContext.is(), "embeddedobj.ole", "No factory is provided!" ); OUString aResult; uno::Reference < beans::XPropertySet > xTempFile( - io::TempFile::create(comphelper::getComponentContext(xFactory)), + io::TempFile::create(xContext), uno::UNO_QUERY_THROW ); try { @@ -109,17 +109,17 @@ OUString GetNewTempFileURL_Impl( const uno::Reference< lang::XMultiServiceFactor OUString GetNewFilledTempFile_Impl( const uno::Reference< io::XInputStream >& xInStream, - const uno::Reference< lang::XMultiServiceFactory >& xFactory ) + const uno::Reference< uno::XComponentContext >& xContext ) { - OSL_ENSURE( xInStream.is() && xFactory.is(), "Wrong parameters are provided!" ); + OSL_ENSURE( xInStream.is() && xContext.is(), "Wrong parameters are provided!" ); - OUString aResult = GetNewTempFileURL_Impl( xFactory ); + OUString aResult = GetNewTempFileURL_Impl( xContext ); if ( !aResult.isEmpty() ) { try { uno::Reference < ucb::XSimpleFileAccess3 > xTempAccess( - ucb::SimpleFileAccess::create( comphelper::getComponentContext(xFactory) ) ); + ucb::SimpleFileAccess::create( xContext ) ); uno::Reference< io::XOutputStream > xTempOutStream = xTempAccess->openFileWrite( aResult ); if ( !xTempOutStream.is() ) @@ -131,22 +131,22 @@ OUString GetNewFilledTempFile_Impl( const uno::Reference< io::XInputStream >& xI } catch( const packages::WrongPasswordException& ) { - KillFile_Impl( aResult, xFactory ); + KillFile_Impl( aResult, xContext ); throw io::IOException(); //TODO: } catch( const io::IOException& ) { - KillFile_Impl( aResult, xFactory ); + KillFile_Impl( aResult, xContext ); throw; } catch( const uno::RuntimeException& ) { - KillFile_Impl( aResult, xFactory ); + KillFile_Impl( aResult, xContext ); throw; } catch( const uno::Exception& ) { - KillFile_Impl( aResult, xFactory ); + KillFile_Impl( aResult, xContext ); aResult.clear(); } } @@ -156,14 +156,14 @@ OUString GetNewFilledTempFile_Impl( const uno::Reference< io::XInputStream >& xI #ifdef _WIN32 /// @throws io::IOException /// @throws uno::RuntimeException -static OUString GetNewFilledTempFile_Impl( const uno::Reference< embed::XOptimizedStorage >& xParentStorage, const OUString& aEntryName, const uno::Reference< lang::XMultiServiceFactory >& xFactory ) +static OUString GetNewFilledTempFile_Impl( const uno::Reference< embed::XOptimizedStorage >& xParentStorage, const OUString& aEntryName, const uno::Reference< uno::XComponentContext >& xContext ) { OUString aResult; try { uno::Reference < beans::XPropertySet > xTempFile( - io::TempFile::create(comphelper::getComponentContext(xFactory)), + io::TempFile::create(xContext), uno::UNO_QUERY ); uno::Reference < io::XStream > xTempStream( xTempFile, uno::UNO_QUERY_THROW ); @@ -262,7 +262,7 @@ uno::Reference< io::XStream > OleEmbeddedObject::GetNewFilledTempStream_Impl( co SAL_WARN_IF( !xInStream.is(), "embeddedobj.ole", "Wrong parameter is provided!" ); uno::Reference < io::XStream > xTempFile( - io::TempFile::create(comphelper::getComponentContext(m_xFactory)), + io::TempFile::create(m_xContext), uno::UNO_QUERY_THROW ); uno::Reference< io::XOutputStream > xTempOutStream = xTempFile->getOutputStream(); @@ -277,7 +277,7 @@ uno::Reference< io::XStream > OleEmbeddedObject::GetNewFilledTempStream_Impl( co uno::Reference< io::XStream > OleEmbeddedObject::TryToGetAcceptableFormat_Impl( const uno::Reference< io::XStream >& xStream ) { // TODO/LATER: Actually this should be done by a centralized component ( may be a graphical filter ) - if ( !m_xFactory.is() ) + if ( !m_xContext.is() ) throw uno::RuntimeException(); uno::Reference< io::XInputStream > xInStream = xStream->getInputStream(); @@ -334,7 +334,7 @@ uno::Reference< io::XStream > OleEmbeddedObject::TryToGetAcceptableFormat_Impl( { // this is either a bitmap or a metafile clipboard format, retrieve the pure stream uno::Reference < io::XStream > xResult( - io::TempFile::create(comphelper::getComponentContext(m_xFactory)), + io::TempFile::create(m_xContext), uno::UNO_QUERY_THROW ); uno::Reference < io::XSeekable > xResultSeek( xResult, uno::UNO_QUERY_THROW ); uno::Reference < io::XOutputStream > xResultOut = xResult->getOutputStream(); @@ -368,16 +368,16 @@ void OleEmbeddedObject::InsertVisualCache_Impl( const uno::Reference< io::XStrea aArgs[1] <<= true; // do not create copy uno::Reference< container::XNameContainer > xNameContainer( - m_xFactory->createInstanceWithArguments( + m_xContext->getServiceManager()->createInstanceWithArgumentsAndContext( "com.sun.star.embed.OLESimpleStorage", - aArgs ), + aArgs, m_xContext ), uno::UNO_QUERY_THROW ); uno::Reference< io::XSeekable > xCachedSeek( xCachedVisualRepresentation, uno::UNO_QUERY_THROW ); xCachedSeek->seek( 0 ); uno::Reference < io::XStream > xTempFile( - io::TempFile::create(comphelper::getComponentContext(m_xFactory)), + io::TempFile::create(m_xContext), uno::UNO_QUERY_THROW ); uno::Reference< io::XSeekable > xTempSeek( xTempFile, uno::UNO_QUERY_THROW ); @@ -507,9 +507,9 @@ void OleEmbeddedObject::RemoveVisualCache_Impl( const uno::Reference< io::XStrea aArgs[0] <<= xTargetStream; aArgs[1] <<= true; // do not create copy uno::Reference< container::XNameContainer > xNameContainer( - m_xFactory->createInstanceWithArguments( + m_xContext->getServiceManager()->createInstanceWithArgumentsAndContext( "com.sun.star.embed.OLESimpleStorage", - aArgs ), + aArgs, m_xContext ), uno::UNO_QUERY_THROW ); for ( sal_uInt8 nInd = 0; nInd < 10; nInd++ ) @@ -550,7 +550,7 @@ bool OleEmbeddedObject::HasVisReplInStream() { // open temporary file for reading uno::Reference < ucb::XSimpleFileAccess3 > xTempAccess( - ucb::SimpleFileAccess::create( comphelper::getComponentContext(m_xFactory) ) ); + ucb::SimpleFileAccess::create( m_xContext ) ); xStream = xTempAccess->openFileRead( m_aTempURL ); } @@ -569,9 +569,9 @@ bool OleEmbeddedObject::HasVisReplInStream() aArgs[0] <<= xStream; aArgs[1] <<= true; // do not create copy uno::Reference< container::XNameContainer > xNameContainer( - m_xFactory->createInstanceWithArguments( + m_xContext->getServiceManager()->createInstanceWithArgumentsAndContext( "com.sun.star.embed.OLESimpleStorage", - aArgs ), + aArgs, m_xContext ), uno::UNO_QUERY ); if ( xNameContainer.is() ) @@ -615,9 +615,9 @@ uno::Reference< io::XStream > OleEmbeddedObject::TryToRetrieveCachedVisualRepres try { xNameContainer.set( - m_xFactory->createInstanceWithArguments( + m_xContext->getServiceManager()->createInstanceWithArgumentsAndContext( "com.sun.star.embed.OLESimpleStorage", - aArgs ), + aArgs, m_xContext ), uno::UNO_QUERY ); } catch( const uno::Exception& ) @@ -697,7 +697,7 @@ uno::Reference< io::XStream > OleEmbeddedObject::TryToRetrieveCachedVisualRepres if ( !m_aTempURL.isEmpty() ) { // this is the own stream, so the temporary URL must be cleaned if it exists - KillFile_Impl( m_aTempURL, m_xFactory ); + KillFile_Impl( m_aTempURL, m_xContext ); m_aTempURL.clear(); } @@ -893,7 +893,7 @@ void OleEmbeddedObject::OnClosed_Impl() OUString OleEmbeddedObject::CreateTempURLEmpty_Impl() { SAL_WARN_IF( !m_aTempURL.isEmpty(), "embeddedobj.ole", "The object has already the temporary file!" ); - m_aTempURL = GetNewTempFileURL_Impl( m_xFactory ); + m_aTempURL = GetNewTempFileURL_Impl( m_xContext ); return m_aTempURL; } @@ -909,7 +909,7 @@ OUString OleEmbeddedObject::GetTempURL_Impl() uno::Reference< embed::XOptimizedStorage > xOptParStorage( m_xParentStorage, uno::UNO_QUERY ); if ( xOptParStorage.is() ) { - m_aTempURL = GetNewFilledTempFile_Impl( xOptParStorage, m_aEntryName, m_xFactory ); + m_aTempURL = GetNewFilledTempFile_Impl( xOptParStorage, m_aEntryName, m_xContext ); } else if ( m_xObjectStream.is() ) { @@ -918,7 +918,7 @@ OUString OleEmbeddedObject::GetTempURL_Impl() if ( !xInStream.is() ) throw io::IOException(); // TODO: access denied - m_aTempURL = GetNewFilledTempFile_Impl( xInStream, m_xFactory ); + m_aTempURL = GetNewFilledTempFile_Impl( xInStream, m_xContext ); } } @@ -930,7 +930,7 @@ void OleEmbeddedObject::CreateOleComponent_Impl( OleComponent* pOleComponent ) { if ( !m_pOleComponent ) { - m_pOleComponent = pOleComponent ? pOleComponent : new OleComponent( m_xFactory, this ); + m_pOleComponent = pOleComponent ? pOleComponent : new OleComponent( m_xContext, this ); m_pOleComponent->acquire(); // TODO: needs holder? if ( !m_xClosePreventer.is() ) @@ -1007,7 +1007,7 @@ void OleEmbeddedObject::StoreObjectToStream( uno::Reference< io::XOutputStream > // open temporary file for reading uno::Reference < ucb::XSimpleFileAccess3 > xTempAccess( - ucb::SimpleFileAccess::create( comphelper::getComponentContext(m_xFactory) ) ); + ucb::SimpleFileAccess::create( m_xContext ) ); uno::Reference< io::XInputStream > xTempInStream = xTempAccess->openFileRead( m_aTempURL ); SAL_WARN_IF( !xTempInStream.is(), "embeddedobj.ole", "The object's temporary file can not be reopened for reading!" ); @@ -1886,7 +1886,7 @@ void SAL_CALL OleEmbeddedObject::breakLink( const uno::Reference< embed::XStorag OUString aOldTempURL = m_aTempURL; m_aTempURL.clear(); - OleComponent* pNewOleComponent = new OleComponent(m_xFactory, this); + OleComponent* pNewOleComponent = new OleComponent(m_xContext, this); try { pNewOleComponent->InitEmbeddedCopyOfLink(m_pOleComponent); } @@ -1894,7 +1894,7 @@ void SAL_CALL OleEmbeddedObject::breakLink( const uno::Reference< embed::XStorag { delete pNewOleComponent; if (!m_aTempURL.isEmpty()) - KillFile_Impl(m_aTempURL, m_xFactory); + KillFile_Impl(m_aTempURL, m_xContext); m_aTempURL = aOldTempURL; throw; } @@ -1906,12 +1906,12 @@ void SAL_CALL OleEmbeddedObject::breakLink( const uno::Reference< embed::XStorag { delete pNewOleComponent; if (!m_aTempURL.isEmpty()) - KillFile_Impl(m_aTempURL, m_xFactory); + KillFile_Impl(m_aTempURL, m_xContext); m_aTempURL = aOldTempURL; throw; } - KillFile_Impl(aOldTempURL, m_xFactory); + KillFile_Impl(aOldTempURL, m_xContext); CreateOleComponent_Impl(pNewOleComponent); diff --git a/embeddedobj/source/msole/olepersist.hxx b/embeddedobj/source/msole/olepersist.hxx index 111e34e31004..16e2fc7275b9 100644 --- a/embeddedobj/source/msole/olepersist.hxx +++ b/embeddedobj/source/msole/olepersist.hxx @@ -27,18 +27,18 @@ namespace com::sun::star { namespace io { class XInputStream; } - namespace lang { class XMultiServiceFactory; } + namespace uno { class XComponentContext; } } -OUString GetNewTempFileURL_Impl( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory ); +OUString GetNewTempFileURL_Impl( const css::uno::Reference< css::uno::XComponentContext >& xContext ); /// @throws css::io::IOException /// @throws css::uno::RuntimeException OUString GetNewFilledTempFile_Impl( css::uno::Reference<css::io::XInputStream > const & xInStream, - css::uno::Reference<css::lang::XMultiServiceFactory> const & xFactory); + css::uno::Reference<css::uno::XComponentContext> const & xContext); -bool KillFile_Impl( const OUString& aURL, const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory ); +bool KillFile_Impl( const OUString& aURL, const css::uno::Reference< css::uno::XComponentContext >& xContext ); #endif diff --git a/embeddedobj/source/msole/oleregister.cxx b/embeddedobj/source/msole/oleregister.cxx deleted file mode 100644 index cd3f5915807a..000000000000 --- a/embeddedobj/source/msole/oleregister.cxx +++ /dev/null @@ -1,75 +0,0 @@ -/* -*- 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 . - */ - -#include <com/sun/star/lang/XSingleServiceFactory.hpp> -#include <cppuhelper/factory.hxx> - -#include "xolefactory.hxx" - -#if defined(_WIN32) -#include "xdialogcreator.hxx" -#endif - -using namespace ::com::sun::star; - - -extern "C" { - -SAL_DLLPUBLIC_EXPORT void * emboleobj_component_getFactory( - const char * pImplName, void * pServiceManager, - SAL_UNUSED_PARAMETER void * /*pRegistryKey*/ ) -{ - void * pRet = nullptr; - - OUString aImplName( OUString::createFromAscii( pImplName ) ); - uno::Reference< lang::XSingleServiceFactory > xFactory; - - if ( pServiceManager ) - { - if ( aImplName == OleEmbeddedObjectFactory::impl_staticGetImplementationName() ) - { - xFactory= ::cppu::createOneInstanceFactory( static_cast< lang::XMultiServiceFactory*>( pServiceManager ), - OleEmbeddedObjectFactory::impl_staticGetImplementationName(), - OleEmbeddedObjectFactory::impl_staticCreateSelfInstance, - OleEmbeddedObjectFactory::impl_staticGetSupportedServiceNames() ); - } -#ifdef _WIN32 - // the following service makes sense only on windows - else if ( aImplName.equals( MSOLEDialogObjectCreator::impl_staticGetImplementationName() ) ) - { - xFactory= ::cppu::createOneInstanceFactory( static_cast< lang::XMultiServiceFactory*>( pServiceManager ), - MSOLEDialogObjectCreator::impl_staticGetImplementationName(), - MSOLEDialogObjectCreator::impl_staticCreateSelfInstance, - MSOLEDialogObjectCreator::impl_staticGetSupportedServiceNames() ); - } -#endif - } - - if ( xFactory.is() ) - { - xFactory->acquire(); - pRet = xFactory.get(); - } - - return pRet; -} - -} // extern "C" - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/embeddedobj/source/msole/ownview.cxx b/embeddedobj/source/msole/ownview.cxx index 474439194dee..8abb7f9d2acf 100644 --- a/embeddedobj/source/msole/ownview.cxx +++ b/embeddedobj/source/msole/ownview.cxx @@ -69,28 +69,28 @@ void SAL_CALL DummyHandler_Impl::handle( const uno::Reference< task::XInteractio // Object viewer -OwnView_Impl::OwnView_Impl( const uno::Reference< lang::XMultiServiceFactory >& xFactory, +OwnView_Impl::OwnView_Impl( const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< io::XInputStream >& xInputStream ) -: m_xFactory( xFactory ) +: m_xContext( xContext ) , m_bBusy( false ) , m_bUseNative( false ) { - if ( !xFactory.is() || !xInputStream.is() ) + if ( !xContext.is() || !xInputStream.is() ) throw uno::RuntimeException(); - m_aTempFileURL = GetNewFilledTempFile_Impl( xInputStream, m_xFactory ); + m_aTempFileURL = GetNewFilledTempFile_Impl( xInputStream, m_xContext ); } OwnView_Impl::~OwnView_Impl() { try { - KillFile_Impl( m_aTempFileURL, m_xFactory ); + KillFile_Impl( m_aTempFileURL, m_xContext ); } catch( uno::Exception& ) {} try { if ( !m_aNativeTempURL.isEmpty() ) - KillFile_Impl( m_aNativeTempURL, m_xFactory ); + KillFile_Impl( m_aNativeTempURL, m_xContext ); } catch( uno::Exception& ) {} } @@ -102,7 +102,7 @@ bool OwnView_Impl::CreateModelFromURL( const OUString& aFileURL ) if ( !aFileURL.isEmpty() ) { try { - uno::Reference < frame::XDesktop2 > xDocumentLoader = frame::Desktop::create(comphelper::getComponentContext(m_xFactory)); + uno::Reference < frame::XDesktop2 > xDocumentLoader = frame::Desktop::create(m_xContext); uno::Sequence< beans::PropertyValue > aArgs( m_aFilterName.isEmpty() ? 4 : 5 ); @@ -179,7 +179,7 @@ bool OwnView_Impl::CreateModel( bool bUseNative ) OUString OwnView_Impl::GetFilterNameFromExtentionAndInStream( - const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory, + const css::uno::Reference< css::uno::XComponentContext >& xContext, const OUString& aNameWithExtention, const uno::Reference< io::XInputStream >& xInputStream ) { @@ -187,7 +187,7 @@ OUString OwnView_Impl::GetFilterNameFromExtentionAndInStream( throw uno::RuntimeException(); uno::Reference< document::XTypeDetection > xTypeDetection( - xFactory->createInstance("com.sun.star.document.TypeDetection"), + xContext->getServiceManager()->createInstanceWithContext("com.sun.star.document.TypeDetection", xContext), uno::UNO_QUERY_THROW ); OUString aTypeName; @@ -248,7 +248,7 @@ bool OwnView_Impl::ReadContentsAndGenerateTempFile( const uno::Reference< io::XI // create m_aNativeTempURL OUString aNativeTempURL; uno::Reference < beans::XPropertySet > xNativeTempFile( - io::TempFile::create(comphelper::getComponentContext(m_xFactory)), + io::TempFile::create(m_xContext), uno::UNO_QUERY_THROW ); uno::Reference < io::XStream > xNativeTempStream( xNativeTempFile, uno::UNO_QUERY_THROW ); uno::Reference < io::XOutputStream > xNativeOutTemp = xNativeTempStream->getOutputStream(); @@ -379,7 +379,7 @@ bool OwnView_Impl::ReadContentsAndGenerateTempFile( const uno::Reference< io::XI // The temporary native file is created, now the filter must be detected if ( !bFailed ) { - m_aFilterName = GetFilterNameFromExtentionAndInStream( m_xFactory, aFileSuffix, xNativeInTemp ); + m_aFilterName = GetFilterNameFromExtentionAndInStream( m_xContext, aFileSuffix, xNativeInTemp ); m_aNativeTempURL = aNativeTempURL; } @@ -395,7 +395,7 @@ void OwnView_Impl::CreateNative() try { uno::Reference < ucb::XSimpleFileAccess3 > xAccess( - ucb::SimpleFileAccess::create( comphelper::getComponentContext(m_xFactory) ) ); + ucb::SimpleFileAccess::create( m_xContext ) ); uno::Reference< io::XInputStream > xInStream = xAccess->openFileRead( m_aTempFileURL ); if ( !xInStream.is() ) @@ -404,9 +404,9 @@ void OwnView_Impl::CreateNative() uno::Sequence< uno::Any > aArgs( 1 ); aArgs[0] <<= xInStream; uno::Reference< container::XNameAccess > xNameAccess( - m_xFactory->createInstanceWithArguments( + m_xContext->getServiceManager()->createInstanceWithArgumentsAndContext( "com.sun.star.embed.OLESimpleStorage", - aArgs ), + aArgs, m_xContext ), uno::UNO_QUERY_THROW ); OUString aSubStreamName = "\1Ole10Native"; @@ -433,7 +433,7 @@ void OwnView_Impl::CreateNative() if ( !bOk && !m_aNativeTempURL.isEmpty() ) { - KillFile_Impl( m_aNativeTempURL, m_xFactory ); + KillFile_Impl( m_aNativeTempURL, m_xContext ); m_aNativeTempURL.clear(); } } @@ -444,7 +444,7 @@ void OwnView_Impl::CreateNative() if ( !bOk && !m_aNativeTempURL.isEmpty() ) { - KillFile_Impl( m_aNativeTempURL, m_xFactory ); + KillFile_Impl( m_aNativeTempURL, m_xContext ); m_aNativeTempURL.clear(); } } diff --git a/embeddedobj/source/msole/ownview.hxx b/embeddedobj/source/msole/ownview.hxx index 4afcb9e80b17..b2f580a84d24 100644 --- a/embeddedobj/source/msole/ownview.hxx +++ b/embeddedobj/source/msole/ownview.hxx @@ -25,6 +25,7 @@ #include <com/sun/star/document/XEventListener.hpp> #include <com/sun/star/frame/XModel.hpp> #include <com/sun/star/io/XInputStream.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> #include <cppuhelper/implbase.hxx> #include <osl/mutex.hxx> @@ -34,7 +35,7 @@ class OwnView_Impl : public ::cppu::WeakImplHelper < css::util::XCloseListener, { ::osl::Mutex m_aMutex; - css::uno::Reference< css::lang::XMultiServiceFactory > m_xFactory; + css::uno::Reference< css::uno::XComponentContext > m_xContext; css::uno::Reference< css::frame::XModel > m_xModel; OUString m_aTempFileURL; @@ -57,11 +58,11 @@ private: public: static OUString GetFilterNameFromExtentionAndInStream( - const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory, + const css::uno::Reference< css::uno::XComponentContext >& xContext, const OUString& aNameWithExtention, const css::uno::Reference< css::io::XInputStream >& xInputStream ); - OwnView_Impl( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory, + OwnView_Impl( const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::io::XInputStream >& xStream ); virtual ~OwnView_Impl() override; diff --git a/embeddedobj/source/msole/xdialogcreator.cxx b/embeddedobj/source/msole/xdialogcreator.cxx index 819168567a6f..49e9c0c925e4 100644 --- a/embeddedobj/source/msole/xdialogcreator.cxx +++ b/embeddedobj/source/msole/xdialogcreator.cxx @@ -110,28 +110,6 @@ static uno::Sequence< sal_Int8 > GetRelatedInternalID_Impl( const uno::Sequence< } -uno::Sequence< OUString > MSOLEDialogObjectCreator::impl_staticGetSupportedServiceNames() -{ - uno::Sequence< OUString > aRet(2); - aRet[0] = "com.sun.star.embed.MSOLEObjectSystemCreator"; - aRet[1] = "com.sun.star.comp.embed.MSOLEObjectSystemCreator"; - return aRet; -} - - -OUString MSOLEDialogObjectCreator::impl_staticGetImplementationName() -{ - return "com.sun.star.comp.embed.MSOLEObjectSystemCreator"; -} - - -uno::Reference< uno::XInterface > MSOLEDialogObjectCreator::impl_staticCreateSelfInstance( - const uno::Reference< lang::XMultiServiceFactory >& xServiceManager ) -{ - return uno::Reference< uno::XInterface >( *new MSOLEDialogObjectCreator( xServiceManager ) ); -} - - embed::InsertedObjectInfo SAL_CALL MSOLEDialogObjectCreator::createInstanceByDialog( const uno::Reference< embed::XStorage >& xStorage, const OUString& sEntName, @@ -188,7 +166,7 @@ embed::InsertedObjectInfo SAL_CALL MSOLEDialogObjectCreator::createInstanceByDia if (io.dwFlags & IOF_SELECTCREATENEW) { - uno::Reference< embed::XEmbeddedObjectCreator > xEmbCreator = embed::EmbeddedObjectCreator::create( comphelper::getComponentContext(m_xFactory) ); + uno::Reference< embed::XEmbeddedObjectCreator > xEmbCreator = embed::EmbeddedObjectCreator::create( m_xContext ); uno::Sequence< sal_Int8 > aClassID = MimeConfigurationHelper::GetSequenceClassID( io.clsid.Data1, io.clsid.Data2, @@ -221,12 +199,12 @@ embed::InsertedObjectInfo SAL_CALL MSOLEDialogObjectCreator::createInstanceByDia // TODO: use config helper for type detection uno::Reference< embed::XEmbeddedObjectCreator > xEmbCreator; - ::comphelper::MimeConfigurationHelper aHelper( comphelper::getComponentContext(m_xFactory) ); + ::comphelper::MimeConfigurationHelper aHelper( m_xContext ); if ( aHelper.AddFilterNameCheckOwnFile( aMediaDescr ) ) - xEmbCreator = embed::EmbeddedObjectCreator::create( comphelper::getComponentContext(m_xFactory) ); + xEmbCreator = embed::EmbeddedObjectCreator::create( m_xContext ); else - xEmbCreator = embed::OLEEmbeddedObjectFactory::create( comphelper::getComponentContext(m_xFactory) ); + xEmbCreator = embed::OLEEmbeddedObjectFactory::create( m_xContext ); if ( !xEmbCreator.is() ) throw uno::RuntimeException(); @@ -298,7 +276,7 @@ embed::InsertedObjectInfo SAL_CALL MSOLEDialogObjectCreator::createInstanceInitF 2 ); uno::Reference< embed::XEmbeddedObject > xResult( - static_cast< ::cppu::OWeakObject* > ( new OleEmbeddedObject( m_xFactory ) ), + static_cast< ::cppu::OWeakObject* > ( new OleEmbeddedObject( m_xContext ) ), uno::UNO_QUERY ); uno::Reference< embed::XEmbedPersist > xPersist( xResult, uno::UNO_QUERY_THROW ); @@ -325,7 +303,7 @@ embed::InsertedObjectInfo SAL_CALL MSOLEDialogObjectCreator::createInstanceInitF OUString SAL_CALL MSOLEDialogObjectCreator::getImplementationName() { - return impl_staticGetImplementationName(); + return "com.sun.star.comp.embed.MSOLEObjectSystemCreator"; } @@ -337,7 +315,17 @@ sal_Bool SAL_CALL MSOLEDialogObjectCreator::supportsService( const OUString& Ser uno::Sequence< OUString > SAL_CALL MSOLEDialogObjectCreator::getSupportedServiceNames() { - return impl_staticGetSupportedServiceNames(); + return { "com.sun.star.embed.MSOLEObjectSystemCreator", + "com.sun.star.comp.embed.MSOLEObjectSystemCreator" }; +} + +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* +embeddedobj_MSOLEDialogObjectCreator_get_implementation( + css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const&) +{ + static rtl::Reference<MSOLEDialogObjectCreator> g_Instance(new MSOLEDialogObjectCreator(context)); + g_Instance->acquire(); + return static_cast<cppu::OWeakObject*>(g_Instance.get()); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/embeddedobj/source/msole/xdialogcreator.hxx b/embeddedobj/source/msole/xdialogcreator.hxx index 128c099d23aa..f1f96287956c 100644 --- a/embeddedobj/source/msole/xdialogcreator.hxx +++ b/embeddedobj/source/msole/xdialogcreator.hxx @@ -24,6 +24,7 @@ #include <com/sun/star/embed/XEmbedObjectClipboardCreator.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> #include <cppuhelper/implbase.hxx> #include <osl/diagnose.h> @@ -34,25 +35,16 @@ class MSOLEDialogObjectCreator : public ::cppu::WeakImplHelper< css::embed::XEmbedObjectClipboardCreator, css::lang::XServiceInfo > { - css::uno::Reference< css::lang::XMultiServiceFactory > m_xFactory; + css::uno::Reference< css::uno::XComponentContext > m_xContext; public: explicit MSOLEDialogObjectCreator( - const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory ) - : m_xFactory( xFactory ) + const css::uno::Reference< css::uno::XComponentContext >& xContext ) + : m_xContext( xContext ) { - OSL_ENSURE( xFactory.is(), "No service manager is provided!" ); + OSL_ENSURE( xContext.is(), "No service manager is provided!" ); } - static css::uno::Sequence< OUString > impl_staticGetSupportedServiceNames(); - - static OUString impl_staticGetImplementationName(); - - static css::uno::Reference< css::uno::XInterface > - impl_staticCreateSelfInstance( - const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager ); - - // XInsertObjectDialog virtual css::embed::InsertedObjectInfo SAL_CALL createInstanceByDialog( const css::uno::Reference< css::embed::XStorage >& xStorage, const OUString& sEntName, const css::uno::Sequence< css::beans::PropertyValue >& lObjArgs ) override; diff --git a/embeddedobj/source/msole/xolefactory.cxx b/embeddedobj/source/msole/xolefactory.cxx index f162af865c05..9ecd2c690bf5 100644 --- a/embeddedobj/source/msole/xolefactory.cxx +++ b/embeddedobj/source/msole/xolefactory.cxx @@ -34,28 +34,6 @@ using namespace ::com::sun::star; // TODO: do not create OLE objects that represent OOo documents -uno::Sequence< OUString > OleEmbeddedObjectFactory::impl_staticGetSupportedServiceNames() -{ - uno::Sequence< OUString > aRet(2); - aRet[0] = "com.sun.star.embed.OLEEmbeddedObjectFactory"; - aRet[1] = "com.sun.star.comp.embed.OLEEmbeddedObjectFactory"; - return aRet; -} - - -OUString OleEmbeddedObjectFactory::impl_staticGetImplementationName() -{ - return "com.sun.star.comp.embed.OLEEmbeddedObjectFactory"; -} - - -uno::Reference< uno::XInterface > OleEmbeddedObjectFactory::impl_staticCreateSelfInstance( - const uno::Reference< lang::XMultiServiceFactory >& xServiceManager ) -{ - return uno::Reference< uno::XInterface >( *new OleEmbeddedObjectFactory( xServiceManager ) ); -} - - uno::Reference< uno::XInterface > SAL_CALL OleEmbeddedObjectFactory::createInstanceInitFromEntry( const uno::Reference< embed::XStorage >& xStorage, const OUString& sEntName, @@ -85,7 +63,7 @@ uno::Reference< uno::XInterface > SAL_CALL OleEmbeddedObjectFactory::createInsta } uno::Reference< uno::XInterface > xResult( - static_cast< ::cppu::OWeakObject* > ( new OleEmbeddedObject( m_xFactory, false ) ), + static_cast< ::cppu::OWeakObject* > ( new OleEmbeddedObject( m_xContext, false ) ), uno::UNO_QUERY ); uno::Reference< embed::XEmbedPersist > xPersist( xResult, uno::UNO_QUERY_THROW ); @@ -133,7 +111,7 @@ uno::Reference< uno::XInterface > SAL_CALL OleEmbeddedObjectFactory::createInsta 2 ); uno::Reference< uno::XInterface > xResult( - static_cast< ::cppu::OWeakObject* > ( new OleEmbeddedObject( m_xFactory, false ) ), + static_cast< ::cppu::OWeakObject* > ( new OleEmbeddedObject( m_xContext, false ) ), uno::UNO_QUERY ); uno::Reference< embed::XEmbedPersist > xPersist( xResult, uno::UNO_QUERY_THROW ); @@ -165,7 +143,7 @@ uno::Reference< uno::XInterface > SAL_CALL OleEmbeddedObjectFactory::createInsta 4 ); uno::Reference< uno::XInterface > xResult( - static_cast< ::cppu::OWeakObject* > ( new OleEmbeddedObject( m_xFactory, aClassID, aClassName ) ), + static_cast< ::cppu::OWeakObject* > ( new OleEmbeddedObject( m_xContext, aClassID, aClassName ) ), uno::UNO_QUERY ); uno::Reference< embed::XEmbedPersist > xPersist( xResult, uno::UNO_QUERY_THROW ); @@ -196,7 +174,7 @@ uno::Reference< uno::XInterface > SAL_CALL OleEmbeddedObjectFactory::createInsta 2 ); uno::Reference< uno::XInterface > xResult( - static_cast< ::cppu::OWeakObject* > ( new OleEmbeddedObject( m_xFactory, true ) ), + static_cast< ::cppu::OWeakObject* > ( new OleEmbeddedObject( m_xContext, true ) ), uno::UNO_QUERY ); uno::Reference< embed::XEmbedPersist > xPersist( xResult, uno::UNO_QUERY_THROW ); @@ -231,7 +209,7 @@ uno::Reference< uno::XInterface > SAL_CALL OleEmbeddedObjectFactory::createInsta 2 ); uno::Reference< uno::XInterface > xResult( - static_cast< ::cppu::OWeakObject* > ( new OleEmbeddedObject( m_xFactory, aClassID, aClassName ) ), + static_cast< ::cppu::OWeakObject* > ( new OleEmbeddedObject( m_xContext, aClassID, aClassName ) ), uno::UNO_QUERY ); uno::Reference< embed::XEmbedPersist > xPersist( xResult, uno::UNO_QUERY_THROW ); @@ -247,7 +225,7 @@ uno::Reference< uno::XInterface > SAL_CALL OleEmbeddedObjectFactory::createInsta OUString SAL_CALL OleEmbeddedObjectFactory::getImplementationName() { - return impl_staticGetImplementationName(); + return "com.sun.star.comp.embed.OLEEmbeddedObjectFactory"; } sal_Bool SAL_CALL OleEmbeddedObjectFactory::supportsService( const OUString& ServiceName ) @@ -258,7 +236,17 @@ sal_Bool SAL_CALL OleEmbeddedObjectFactory::supportsService( const OUString& Ser uno::Sequence< OUString > SAL_CALL OleEmbeddedObjectFactory::getSupportedServiceNames() { - return impl_staticGetSupportedServiceNames(); + return { "com.sun.star.embed.OLEEmbeddedObjectFactory", + "com.sun.star.comp.embed.OLEEmbeddedObjectFactory" }; +} + +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* +embeddedobj_OleEmbeddedObjectFactory_get_implementation( + css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const&) +{ + static rtl::Reference<OleEmbeddedObjectFactory> g_Instance(new OleEmbeddedObjectFactory(context)); + g_Instance->acquire(); + return static_cast<cppu::OWeakObject*>(g_Instance.get()); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/embeddedobj/source/msole/xolefactory.hxx b/embeddedobj/source/msole/xolefactory.hxx index bd58f1080fc7..eda359fa6daf 100644 --- a/embeddedobj/source/msole/xolefactory.hxx +++ b/embeddedobj/source/msole/xolefactory.hxx @@ -23,6 +23,7 @@ #include <com/sun/star/embed/XEmbeddedObjectCreator.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> #include <cppuhelper/implbase.hxx> #include <osl/diagnose.h> @@ -32,25 +33,16 @@ class OleEmbeddedObjectFactory : public ::cppu::WeakImplHelper< css::embed::XEmbeddedObjectCreator, css::lang::XServiceInfo > { - css::uno::Reference< css::lang::XMultiServiceFactory > m_xFactory; + css::uno::Reference< css::uno::XComponentContext > m_xContext; public: explicit OleEmbeddedObjectFactory( - const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory ) - : m_xFactory( xFactory ) + const css::uno::Reference< css::uno::XComponentContext >& xContext ) + : m_xContext( xContext ) { - OSL_ENSURE( xFactory.is(), "No service manager is provided!" ); + OSL_ENSURE( xContext.is(), "No service manager is provided!" ); } - static css::uno::Sequence< OUString > impl_staticGetSupportedServiceNames(); - - static OUString impl_staticGetImplementationName(); - - static css::uno::Reference< css::uno::XInterface > - impl_staticCreateSelfInstance( - const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager ); - - // XEmbedObjectCreator virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstanceInitNew( 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 >& lObjArgs ) override; virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstanceInitFromEntry( const css::uno::Reference< css::embed::XStorage >& xStorage, const OUString& sEntName, const css::uno::Sequence< css::beans::PropertyValue >& aMedDescr, const css::uno::Sequence< css::beans::PropertyValue >& lObjArgs ) override; |