You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by ms...@apache.org on 2025/06/05 20:59:02 UTC

(openoffice) 04/04: Port main/basctl component_getFactory() to the component context API.

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

commit 4fc7055894010c22a4b7ceef3df35d7656156509
Author: Damjan Jovanovic <da...@apache.org>
AuthorDate: Thu Jun 5 21:02:12 2025 +0200

    Port main/basctl component_getFactory() to the component context API.
    
    Patch by: me
    
    (cherry picked from commit b504c543a5c0014f61d361c52d736b627c675f94)
---
 main/basctl/source/basicide/register.cxx | 47 ++++++++++----------------------
 main/basctl/source/basicide/unomodel.cxx |  2 +-
 main/basctl/source/basicide/unomodel.hxx |  4 +--
 3 files changed, 18 insertions(+), 35 deletions(-)

diff --git a/main/basctl/source/basicide/register.cxx b/main/basctl/source/basicide/register.cxx
index 7de865a51b..1acafb0c76 100644
--- a/main/basctl/source/basicide/register.cxx
+++ b/main/basctl/source/basicide/register.cxx
@@ -29,6 +29,7 @@
 #include <rtl/ustring.hxx>
 
 #include <cppuhelper/factory.hxx>
+#include <cppuhelper/implementationentry.hxx>
 
 #include "unomodel.hxx"
 
@@ -37,6 +38,18 @@ using namespace ::com::sun::star;
 using namespace ::com::sun::star::uno;
 using namespace ::com::sun::star::lang;
 
+static struct ::cppu::ImplementationEntry g_component_entries[] =
+{
+     {
+         SIDEModel_createInstance,
+         SIDEModel::getImplementationName_Static,
+         SIDEModel::getSupportedServiceNames_Static,
+         ::cppu::createSingleComponentFactory,
+         0,
+         0
+     },
+     { 0, 0, 0, 0, 0, 0 }
+};
 
 extern "C" {
 
@@ -53,37 +66,7 @@ void* SAL_CALL component_getFactory( const sal_Char* pImplementationName,
                                      void* pServiceManager,
                                      void* pRegistryKey )
 {
-	(void)pRegistryKey;
-
-	// Set default return value for this operation - if it failed.
-	void* pReturn = NULL ;
-
-	if	(
-			( pImplementationName	!=	NULL ) &&
-			( pServiceManager		!=	NULL )
-		)
-	{
-		// Define variables which are used in following macros.
-        Reference< XSingleServiceFactory >   xFactory                                                                                                ;
-        Reference< XMultiServiceFactory >    xServiceManager( reinterpret_cast< XMultiServiceFactory* >( pServiceManager ) ) ;
-
-		if( SIDEModel::getImplementationName_Static().equalsAscii( pImplementationName ) )
-		{
-			xFactory = ::cppu::createSingleFactory( xServiceManager,
-			SIDEModel::getImplementationName_Static(),
-			SIDEModel_createInstance,
-			SIDEModel::getSupportedServiceNames_Static() );
-		}
-
-		// Factory is valid - service was found.
-		if ( xFactory.is() )
-		{
-			xFactory->acquire();
-			pReturn = xFactory.get();
-		}
-	}
-
-	// Return with result of this operation.
-	return pReturn ;
+    return ::cppu::component_getFactoryHelper( pImplementationName, pServiceManager, pRegistryKey, g_component_entries );
 }
+
 } // extern "C"
diff --git a/main/basctl/source/basicide/unomodel.cxx b/main/basctl/source/basicide/unomodel.cxx
index 4d70a1aea8..868d32c85b 100644
--- a/main/basctl/source/basicide/unomodel.cxx
+++ b/main/basctl/source/basicide/unomodel.cxx
@@ -114,7 +114,7 @@ uno::Sequence< OUString > SIDEModel::getSupportedServiceNames_Static(void)
 }
 
 uno::Reference< uno::XInterface > SAL_CALL SIDEModel_createInstance(
-				const uno::Reference< lang::XMultiServiceFactory > & ) throw( uno::Exception )
+				const uno::Reference< uno::XComponentContext > & ) throw( uno::Exception )
 {
     ::vos::OGuard aGuard( Application::GetSolarMutex() );
 	BasicIDEDLL::Init();
diff --git a/main/basctl/source/basicide/unomodel.hxx b/main/basctl/source/basicide/unomodel.hxx
index 86c07c8f09..692b407bb0 100644
--- a/main/basctl/source/basicide/unomodel.hxx
+++ b/main/basctl/source/basicide/unomodel.hxx
@@ -24,7 +24,7 @@
 #define UNOMODEL_HXX
 
 #include <com/sun/star/lang/XServiceInfo.hpp>
-#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
 #include <sfx2/sfxbasemodel.hxx>
 
 //-----------------------------------------------------------------------------
@@ -56,7 +56,7 @@ public:
 };
 
 com::sun::star::uno::Reference< com::sun::star::uno::XInterface > SAL_CALL SIDEModel_createInstance(
-				const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > & rSMgr )
+				const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > & rContext )
 					throw( com::sun::star::uno::Exception );
 
 #endif