This is an automated email from the ASF dual-hosted git repository.
mseidel pushed a commit to branch AOO42X
in repository https://gitbox.apache.org/repos/asf/openoffice.git
The following commit(s) were added to refs/heads/AOO42X by this push:
new 59e160c3f8 Port main/sot to the component context API.
59e160c3f8 is described below
commit 59e160c3f8455cd51e66847bb26b2919fcc39e89
Author: Damjan Jovanovic <[email protected]>
AuthorDate: Fri Jun 6 06:21:42 2025 +0200
Port main/sot to the component context API.
Patch by: me
(cherry picked from commit 641497ea435a3bb77c7987883e7df05d6864a13a)
---
main/sot/source/unoolestorage/register.cxx | 37 ++++++++++------------
.../sot/source/unoolestorage/xolesimplestorage.cxx | 21 ++++++------
.../sot/source/unoolestorage/xolesimplestorage.hxx | 7 ++--
3 files changed, 31 insertions(+), 34 deletions(-)
diff --git a/main/sot/source/unoolestorage/register.cxx
b/main/sot/source/unoolestorage/register.cxx
index f072716b93..394ab31a64 100644
--- a/main/sot/source/unoolestorage/register.cxx
+++ b/main/sot/source/unoolestorage/register.cxx
@@ -28,11 +28,25 @@
#include <com/sun/star/registry/XRegistryKey.hpp>
#include <com/sun/star/registry/InvalidRegistryException.hpp>
#include <cppuhelper/factory.hxx>
+#include <cppuhelper/implementationentry.hxx>
#include "xolesimplestorage.hxx"
using namespace ::com::sun::star;
+static struct ::cppu::ImplementationEntry g_component_entries[] =
+{
+ {
+ OLESimpleStorage::impl_staticCreateSelfInstance,
+ OLESimpleStorage::impl_staticGetImplementationName,
+ OLESimpleStorage::impl_staticGetSupportedServiceNames,
+ ::cppu::createSingleComponentFactory,
+ 0,
+ 0
+ },
+ { 0, 0, 0, 0, 0, 0 }
+};
+
extern "C" {
@@ -41,28 +55,9 @@ SAL_DLLPUBLIC_EXPORT void SAL_CALL
component_getImplementationEnvironment( const
*ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
}
-SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory( const sal_Char *
pImplName, void * pServiceManager, void * /*pRegistryKey*/ )
+SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory( const sal_Char *
pImplName, void * pServiceManager, void * pRegistryKey )
{
- void * pRet = 0;
-
- ::rtl::OUString aImplName( ::rtl::OUString::createFromAscii( pImplName
) );
- uno::Reference< lang::XSingleServiceFactory > xFactory;
-
- if ( pServiceManager && aImplName.equals(
OLESimpleStorage::impl_staticGetImplementationName() ) )
- {
- xFactory= ::cppu::createSingleFactory( reinterpret_cast<
lang::XMultiServiceFactory*>( pServiceManager ),
-
OLESimpleStorage::impl_staticGetImplementationName(),
-
OLESimpleStorage::impl_staticCreateSelfInstance,
-
OLESimpleStorage::impl_staticGetSupportedServiceNames() );
- }
-
- if ( xFactory.is() )
- {
- xFactory->acquire();
- pRet = xFactory.get();
- }
-
- return pRet;
+ return ::cppu::component_getFactoryHelper( pImplName, pServiceManager,
pRegistryKey, g_component_entries );
}
} // extern "C"
diff --git a/main/sot/source/unoolestorage/xolesimplestorage.cxx
b/main/sot/source/unoolestorage/xolesimplestorage.cxx
index fc15dc39cd..c47c0559a2 100644
--- a/main/sot/source/unoolestorage/xolesimplestorage.cxx
+++ b/main/sot/source/unoolestorage/xolesimplestorage.cxx
@@ -46,16 +46,16 @@ const sal_Int32 nBytesCount = 32000;
//
--------------------------------------------------------------------------------
-OLESimpleStorage::OLESimpleStorage( uno::Reference< lang::XMultiServiceFactory
> xFactory )
+OLESimpleStorage::OLESimpleStorage( uno::Reference< uno::XComponentContext >
xContext )
: m_bDisposed( sal_False )
, m_pStream( NULL )
, m_pStorage( NULL )
, m_pListenersContainer( NULL )
-, m_xFactory( xFactory )
+, m_xContext( xContext )
, m_bNoTemporaryCopy( sal_False )
{
- OSL_ENSURE( m_xFactory.is(), "No factory is provided on creation!\n" );
- if ( !m_xFactory.is() )
+ OSL_ENSURE( m_xContext.is(), "No component context is provided on
creation!\n" );
+ if ( !m_xContext.is() )
throw uno::RuntimeException();
}
@@ -91,9 +91,9 @@ uno::Sequence< ::rtl::OUString > SAL_CALL
OLESimpleStorage::impl_staticGetSuppor
//-------------------------------------------------------------------------
uno::Reference< uno::XInterface > SAL_CALL
OLESimpleStorage::impl_staticCreateSelfInstance(
- const uno::Reference< lang::XMultiServiceFactory >&
xServiceManager )
+ const uno::Reference< uno::XComponentContext >&
xComponentContext )
{
- return uno::Reference< uno::XInterface >( *new OLESimpleStorage(
xServiceManager ) );
+ return uno::Reference< uno::XInterface >( *new OLESimpleStorage(
xComponentContext ) );
}
//-------------------------------------------------------------------------
@@ -262,7 +262,7 @@ void SAL_CALL OLESimpleStorage::initialize( const
uno::Sequence< uno::Any >& aAr
else
{
uno::Reference < io::XStream > xTempFile(
- m_xFactory->createInstance(
::rtl::OUString::createFromAscii( "com.sun.star.io.TempFile" ) ),
+
m_xContext->getServiceManager()->createInstanceWithContext(
::rtl::OUString::createFromAscii( "com.sun.star.io.TempFile" ), m_xContext ),
uno::UNO_QUERY_THROW );
uno::Reference < io::XSeekable > xTempSeek( xTempFile,
uno::UNO_QUERY_THROW );
uno::Reference< io::XOutputStream > xTempOut =
xTempFile->getOutputStream();
@@ -447,7 +447,7 @@ uno::Any SAL_CALL OLESimpleStorage::getByName( const
::rtl::OUString& aName )
uno::Any aResult;
uno::Reference< io::XStream > xTempFile(
- m_xFactory->createInstance( ::rtl::OUString::createFromAscii(
"com.sun.star.io.TempFile" ) ),
+ m_xContext->getServiceManager()->createInstanceWithContext(
::rtl::OUString::createFromAscii( "com.sun.star.io.TempFile" ), m_xContext ),
uno::UNO_QUERY );
uno::Reference< io::XSeekable > xSeekable( xTempFile,
uno::UNO_QUERY_THROW );
uno::Reference< io::XOutputStream > xOutputStream =
xTempFile->getOutputStream();
@@ -482,9 +482,10 @@ uno::Any SAL_CALL OLESimpleStorage::getByName( const
::rtl::OUString& aName )
aArgs[1] <<= (sal_Bool)sal_True; // do not create copy
uno::Reference< container::XNameContainer >
xResultNameContainer(
- m_xFactory->createInstanceWithArguments(
+
m_xContext->getServiceManager()->createInstanceWithArgumentsAndContext(
::rtl::OUString::createFromAscii(
"com.sun.star.embed.OLESimpleStorage" ),
- aArgs ),
+ aArgs,
+ m_xContext ),
uno::UNO_QUERY_THROW );
aResult <<= xResultNameContainer;
diff --git a/main/sot/source/unoolestorage/xolesimplestorage.hxx
b/main/sot/source/unoolestorage/xolesimplestorage.hxx
index a65a1d5cf0..2e56f67923 100644
--- a/main/sot/source/unoolestorage/xolesimplestorage.hxx
+++ b/main/sot/source/unoolestorage/xolesimplestorage.hxx
@@ -31,6 +31,7 @@
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/embed/XTransactedObject.hpp>
#include <com/sun/star/embed/XClassifiedObject.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
#include <com/sun/star/io/XOutputStream.hpp>
@@ -57,7 +58,7 @@ class OLESimpleStorage : public ::cppu::WeakImplHelper3
BaseStorage* m_pStorage;
::cppu::OInterfaceContainerHelper* m_pListenersContainer; // list of
listeners
- ::com::sun::star::uno::Reference<
::com::sun::star::lang::XMultiServiceFactory > m_xFactory;
+ ::com::sun::star::uno::Reference<
::com::sun::star::uno::XComponentContext > m_xContext;
sal_Bool m_bNoTemporaryCopy;
@@ -71,7 +72,7 @@ class OLESimpleStorage : public ::cppu::WeakImplHelper3
public:
- OLESimpleStorage( ::com::sun::star::uno::Reference<
::com::sun::star::lang::XMultiServiceFactory > xFactory );
+ OLESimpleStorage( ::com::sun::star::uno::Reference<
::com::sun::star::uno::XComponentContext > xContext );
virtual ~OLESimpleStorage();
@@ -79,7 +80,7 @@ public:
static ::rtl::OUString SAL_CALL impl_staticGetImplementationName();
static ::com::sun::star::uno::Reference<
::com::sun::star::uno::XInterface > SAL_CALL
impl_staticCreateSelfInstance(
- const ::com::sun::star::uno::Reference<
::com::sun::star::lang::XMultiServiceFactory >& xServiceManager );
+ const ::com::sun::star::uno::Reference<
::com::sun::star::uno::XComponentContext >& xContext );
//____________________________________________________________________________________________________