framework/inc/services.h | 1 framework/inc/services/taskcreatorsrv.hxx | 87 +++++++++++++++++++++++++++ framework/source/classes/taskcreator.cxx | 17 ----- framework/source/services/taskcreatorsrv.cxx | 67 -------------------- 4 files changed, 90 insertions(+), 82 deletions(-)
New commits: commit 536b947123e65e8a7587ff74c5ea69c5880fd96d Author: Noel Grandin <noelgran...@gmail.com> AuthorDate: Sat Jun 14 12:59:00 2025 +0200 Commit: Noel Grandin <noelgran...@gmail.com> CommitDate: Sat Jun 14 15:11:43 2025 +0200 use more concrete UNO Change-Id: Ib306444628f145ee35d0a019e8589c374fe2016a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/186493 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/framework/inc/services.h b/framework/inc/services.h index c87008f8eb7b..d758c5225c8d 100644 --- a/framework/inc/services.h +++ b/framework/inc/services.h @@ -35,7 +35,6 @@ inline constexpr OUString SERVICENAME_POPUPMENUCONTROLLER = u"com.sun.star.frame // used implementationnames by framework #define IMPLEMENTATIONNAME_QUICKLAUNCHER "com.sun.star.comp.desktop.QuickstartWrapper" -inline constexpr OUString IMPLEMENTATIONNAME_FWK_TASKCREATOR = u"com.sun.star.comp.framework.TaskCreator"_ustr; } // namespace framework diff --git a/framework/inc/services/taskcreatorsrv.hxx b/framework/inc/services/taskcreatorsrv.hxx new file mode 100644 index 000000000000..e66cda211378 --- /dev/null +++ b/framework/inc/services/taskcreatorsrv.hxx @@ -0,0 +1,87 @@ +/* -*- 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 . + */ + +#pragma once + +#include <comphelper/compbase.hxx> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/lang/XSingleServiceFactory.hpp> +#include <com/sun/star/frame/XFrame2.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> +#include <cppuhelper/supportsservice.hxx> + +typedef comphelper::WeakComponentImplHelper<css::lang::XServiceInfo, + css::lang::XSingleServiceFactory> + TaskCreatorService_BASE; + +class TaskCreatorService : public TaskCreatorService_BASE +{ +private: + /** @short the global uno service manager. + @descr Must be used to create own needed services. + */ + css::uno::Reference<css::uno::XComponentContext> m_xContext; + +public: + explicit TaskCreatorService(css::uno::Reference<css::uno::XComponentContext> xContext); + + virtual OUString SAL_CALL getImplementationName() override + { + return u"com.sun.star.comp.framework.TaskCreator"_ustr; + } + + virtual sal_Bool SAL_CALL supportsService(OUString const& ServiceName) override + { + return cppu::supportsService(this, ServiceName); + } + + virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override + { + return { u"com.sun.star.frame.TaskCreator"_ustr }; + } + + // XSingleServiceFactory + virtual css::uno::Reference<css::uno::XInterface> SAL_CALL createInstance() override; + + virtual css::uno::Reference<css::uno::XInterface> SAL_CALL + createInstanceWithArguments(const css::uno::Sequence<css::uno::Any>& lArguments) override; + +private: + css::uno::Reference<css::awt::XWindow> + implts_createContainerWindow(const css::uno::Reference<css::awt::XWindow>& xParentWindow, + const css::awt::Rectangle& aPosSize, bool bTopWindow); + + static void implts_applyDocStyleToWindow(const css::uno::Reference<css::awt::XWindow>& xWindow); + + css::uno::Reference<css::frame::XFrame2> + implts_createFrame(const css::uno::Reference<css::frame::XFrame>& xParentFrame, + const css::uno::Reference<css::awt::XWindow>& xContainerWindow, + const OUString& sName); + + void + implts_establishWindowStateListener(const css::uno::Reference<css::frame::XFrame2>& xFrame); + void implts_establishTitleBarUpdate(const css::uno::Reference<css::frame::XFrame2>& xFrame); + + static void + implts_establishDocModifyListener(const css::uno::Reference<css::frame::XFrame2>& xFrame); + + static OUString impl_filterNames(const OUString& sName); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/source/classes/taskcreator.cxx b/framework/source/classes/taskcreator.cxx index f84bcb711467..167e345e051e 100644 --- a/framework/source/classes/taskcreator.cxx +++ b/framework/source/classes/taskcreator.cxx @@ -18,6 +18,7 @@ */ #include <classes/taskcreator.hxx> +#include <services/taskcreatorsrv.hxx> #include <services.h> #include <taskcreatordefs.hxx> @@ -55,21 +56,7 @@ TaskCreator::~TaskCreator() *//*-*****************************************************************************************************/ css::uno::Reference< css::frame::XFrame > TaskCreator::createTask( const OUString& sName, const utl::MediaDescriptor& rDescriptor ) { - css::uno::Reference< css::lang::XSingleServiceFactory > xCreator; - - try - { - xCreator.set( m_xContext->getServiceManager()->createInstanceWithContext(IMPLEMENTATIONNAME_FWK_TASKCREATOR, m_xContext), css::uno::UNO_QUERY_THROW); - } - catch(const css::uno::Exception&) - {} - - // no catch here ... without a task creator service we can't open ANY document window within the office. - // That's IMHO not a good idea. Then we should accept the stacktrace showing us the real problem. - // BTW: The used fallback creator service (IMPLEMENTATIONNAME_FWK_TASKCREATOR) is implemented in the same - // library then these class here ... Why we should not be able to create it ? - if ( ! xCreator.is()) - xCreator = css::frame::TaskCreator::create(m_xContext); + rtl::Reference< TaskCreatorService > xCreator = new TaskCreatorService(m_xContext); css::uno::Sequence< css::uno::Any > lArgs { diff --git a/framework/source/services/taskcreatorsrv.cxx b/framework/source/services/taskcreatorsrv.cxx index 1af36d0c0754..2cd7519d0b73 100644 --- a/framework/source/services/taskcreatorsrv.cxx +++ b/framework/source/services/taskcreatorsrv.cxx @@ -17,6 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <services/taskcreatorsrv.hxx> #include <helper/persistentwindowstate.hxx> #include <helper/tagwindowasmodified.hxx> #include <helper/titlebarupdate.hxx> @@ -24,19 +25,14 @@ #include <taskcreatordefs.hxx> #include <com/sun/star/frame/Frame.hpp> -#include <com/sun/star/frame/XFrame2.hpp> #include <com/sun/star/frame/XDesktop.hpp> #include <com/sun/star/awt/Rectangle.hpp> #include <com/sun/star/awt/Toolkit.hpp> #include <com/sun/star/awt/WindowDescriptor.hpp> #include <com/sun/star/awt/WindowAttribute.hpp> #include <com/sun/star/awt/VclWindowPeerAttribute.hpp> -#include <com/sun/star/lang/XServiceInfo.hpp> -#include <com/sun/star/lang/XSingleServiceFactory.hpp> #include <comphelper/sequenceashashmap.hxx> -#include <comphelper/compbase.hxx> -#include <cppuhelper/supportsservice.hxx> #include <svtools/colorcfg.hxx> #include <toolkit/helper/vclunohelper.hxx> #include <utility> @@ -45,65 +41,6 @@ using namespace framework; -namespace { - -typedef comphelper::WeakComponentImplHelper< - css::lang::XServiceInfo, - css::lang::XSingleServiceFactory> TaskCreatorService_BASE; - -class TaskCreatorService : public TaskCreatorService_BASE -{ -private: - - /** @short the global uno service manager. - @descr Must be used to create own needed services. - */ - css::uno::Reference< css::uno::XComponentContext > m_xContext; - -public: - - explicit TaskCreatorService(css::uno::Reference< css::uno::XComponentContext > xContext); - - virtual OUString SAL_CALL getImplementationName() override - { - return u"com.sun.star.comp.framework.TaskCreator"_ustr; - } - - virtual sal_Bool SAL_CALL supportsService(OUString const & ServiceName) override - { - return cppu::supportsService(this, ServiceName); - } - - virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override - { - return {u"com.sun.star.frame.TaskCreator"_ustr}; - } - - // XSingleServiceFactory - virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstance() override; - - virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstanceWithArguments(const css::uno::Sequence< css::uno::Any >& lArguments) override; - -private: - - css::uno::Reference< css::awt::XWindow > implts_createContainerWindow( const css::uno::Reference< css::awt::XWindow >& xParentWindow , - const css::awt::Rectangle& aPosSize , - bool bTopWindow ); - - static void implts_applyDocStyleToWindow(const css::uno::Reference< css::awt::XWindow >& xWindow); - - css::uno::Reference< css::frame::XFrame2 > implts_createFrame( const css::uno::Reference< css::frame::XFrame >& xParentFrame , - const css::uno::Reference< css::awt::XWindow >& xContainerWindow , - const OUString& sName ); - - void implts_establishWindowStateListener( const css::uno::Reference< css::frame::XFrame2 >& xFrame ); - void implts_establishTitleBarUpdate( const css::uno::Reference< css::frame::XFrame2 >& xFrame ); - - static void implts_establishDocModifyListener( const css::uno::Reference< css::frame::XFrame2 >& xFrame ); - - static OUString impl_filterNames( const OUString& sName ); -}; - TaskCreatorService::TaskCreatorService(css::uno::Reference< css::uno::XComponentContext > xContext) : m_xContext (std::move(xContext )) { @@ -347,8 +284,6 @@ OUString TaskCreatorService::impl_filterNames( const OUString& sName ) return sFiltered; } -} - extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_comp_framework_TaskCreator_get_implementation( css::uno::XComponentContext *context,