basctl: create instances with uno constructors
See tdf#74608 for motivation Change-Id: Ibada6b9b7e6c754487c90ce1a37c17019db55370 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97932 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
committed by
Noel Grandin
parent
99d4bf9446
commit
a2d844ca71
@@ -94,7 +94,6 @@ $(eval $(call gb_Library_add_exception_objects,basctl,\
|
||||
basctl/source/basicide/moduldl2 \
|
||||
basctl/source/basicide/moduldlg \
|
||||
basctl/source/basicide/ObjectCatalog \
|
||||
basctl/source/basicide/register \
|
||||
basctl/source/basicide/sbxitem \
|
||||
basctl/source/basicide/scriptdocument \
|
||||
basctl/source/basicide/uiobject \
|
||||
|
||||
@@ -1,76 +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/XServiceInfo.hpp>
|
||||
#include <com/sun/star/lang/XSingleServiceFactory.hpp>
|
||||
|
||||
#include <cppuhelper/factory.hxx>
|
||||
|
||||
#include "unomodel.hxx"
|
||||
|
||||
namespace basctl
|
||||
{
|
||||
|
||||
using namespace ::com::sun::star;
|
||||
using namespace ::com::sun::star::uno;
|
||||
using namespace ::com::sun::star::lang;
|
||||
|
||||
extern "C" {
|
||||
|
||||
SAL_DLLPUBLIC_EXPORT void* basctl_component_getFactory( const char* pImplementationName,
|
||||
void* pServiceManager,
|
||||
void* )
|
||||
{
|
||||
// Set default return value for this operation - if it failed.
|
||||
void* pReturn = nullptr ;
|
||||
|
||||
if (
|
||||
( pImplementationName != nullptr ) &&
|
||||
( pServiceManager != nullptr )
|
||||
)
|
||||
{
|
||||
// Define variables which are used in following macros.
|
||||
Reference< XSingleServiceFactory > xFactory ;
|
||||
Reference< XMultiServiceFactory > xServiceManager( static_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 ;
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
|
||||
} // namespace basctl
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
@@ -79,11 +79,6 @@ uno::Sequence< uno::Type > SAL_CALL SIDEModel::getTypes( )
|
||||
}
|
||||
|
||||
OUString SIDEModel::getImplementationName()
|
||||
{
|
||||
return getImplementationName_Static();
|
||||
}
|
||||
|
||||
OUString SIDEModel::getImplementationName_Static()
|
||||
{
|
||||
return "com.sun.star.comp.basic.BasicIDE";
|
||||
}
|
||||
@@ -92,25 +87,12 @@ sal_Bool SIDEModel::supportsService(const OUString& rServiceName)
|
||||
{
|
||||
return cppu::supportsService(this, rServiceName);
|
||||
}
|
||||
|
||||
uno::Sequence< OUString > SIDEModel::getSupportedServiceNames()
|
||||
{
|
||||
return getSupportedServiceNames_Static();
|
||||
}
|
||||
|
||||
uno::Sequence< OUString > SIDEModel::getSupportedServiceNames_Static()
|
||||
{
|
||||
return { "com.sun.star.script.BasicIDE" };
|
||||
}
|
||||
|
||||
uno::Reference< uno::XInterface > SIDEModel_createInstance(
|
||||
const uno::Reference< lang::XMultiServiceFactory > & )
|
||||
{
|
||||
SolarMutexGuard aGuard;
|
||||
EnsureIde();
|
||||
SfxObjectShell* pShell = new DocShell();
|
||||
return uno::Reference< uno::XInterface >( pShell->GetModel() );
|
||||
}
|
||||
|
||||
// XStorable
|
||||
void SAL_CALL SIDEModel::store()
|
||||
{
|
||||
@@ -135,4 +117,16 @@ void SIDEModel::notImplemented()
|
||||
|
||||
} // namespace basctl
|
||||
|
||||
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
|
||||
com_sun_star_comp_basic_BasicID_get_implementation(
|
||||
css::uno::XComponentContext* , css::uno::Sequence<css::uno::Any> const&)
|
||||
{
|
||||
SolarMutexGuard aGuard;
|
||||
basctl::EnsureIde();
|
||||
SfxObjectShell* pShell = new basctl::DocShell();
|
||||
auto pModel = pShell->GetModel();
|
||||
pModel->acquire();
|
||||
return pModel.get();
|
||||
}
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
|
||||
@@ -54,15 +54,8 @@ public:
|
||||
const css::uno::Sequence< css::beans::PropertyValue >& seqArguments ) override;
|
||||
virtual void SAL_CALL storeToURL( const OUString& sURL,
|
||||
const css::uno::Sequence< css::beans::PropertyValue >& seqArguments ) override;
|
||||
|
||||
static css::uno::Sequence< OUString > getSupportedServiceNames_Static();
|
||||
static OUString getImplementationName_Static();
|
||||
};
|
||||
|
||||
/// @throws com::sun::star::uno::Exception
|
||||
css::uno::Reference< css::uno::XInterface > SIDEModel_createInstance(
|
||||
const css::uno::Reference< css::lang::XMultiServiceFactory > & rSMgr );
|
||||
|
||||
} // namespace basctl
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
|
||||
@@ -18,8 +18,9 @@
|
||||
-->
|
||||
|
||||
<component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@"
|
||||
prefix="basctl" xmlns="http://openoffice.org/2010/uno-components">
|
||||
<implementation name="com.sun.star.comp.basic.BasicIDE">
|
||||
xmlns="http://openoffice.org/2010/uno-components">
|
||||
<implementation name="com.sun.star.comp.basic.BasicIDE"
|
||||
constructor="com_sun_star_comp_basic_BasicID_get_implementation">
|
||||
<service name="com.sun.star.script.BasicIDE"/>
|
||||
</implementation>
|
||||
</component>
|
||||
|
||||
Reference in New Issue
Block a user