diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2020-07-04 09:05:51 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-07-05 10:20:16 +0200 |
commit | a2d844ca71fa013001b291d42dc5f00b0c1124c0 (patch) | |
tree | 1d295dab3372f1932ce24552747c056a38f8255d /basctl/source | |
parent | 99d4bf9446c392c3cf2877219c78917ca4d5dd87 (diff) |
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>
Diffstat (limited to 'basctl/source')
-rw-r--r-- | basctl/source/basicide/register.cxx | 76 | ||||
-rw-r--r-- | basctl/source/basicide/unomodel.cxx | 32 | ||||
-rw-r--r-- | basctl/source/basicide/unomodel.hxx | 7 |
3 files changed, 13 insertions, 102 deletions
diff --git a/basctl/source/basicide/register.cxx b/basctl/source/basicide/register.cxx deleted file mode 100644 index c73c97eeadf8..000000000000 --- a/basctl/source/basicide/register.cxx +++ /dev/null @@ -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: */ diff --git a/basctl/source/basicide/unomodel.cxx b/basctl/source/basicide/unomodel.cxx index 8c559cccb5b2..f22634935fcc 100644 --- a/basctl/source/basicide/unomodel.cxx +++ b/basctl/source/basicide/unomodel.cxx @@ -80,11 +80,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() +uno::Sequence< OUString > SIDEModel::getSupportedServiceNames() { 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: */ diff --git a/basctl/source/basicide/unomodel.hxx b/basctl/source/basicide/unomodel.hxx index aab2481c2b36..47094fa2a854 100644 --- a/basctl/source/basicide/unomodel.hxx +++ b/basctl/source/basicide/unomodel.hxx @@ -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: */ |