From 42adbfccad151a29e56ea1ed8eeb323cd4b7dae4 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Wed, 2 Jan 2013 14:43:43 +0200 Subject: fdo#46808, Adapt embed::HatchWindowFactory UNO service to new style The service already existed, it just did not have an IDL file. Change-Id: If00396effd92ed72ea942da5eb1fe60b6380c665 --- embeddedobj/source/commonembedding/miscobj.cxx | 3 +- embeddedobj/source/general/docholder.cxx | 32 ++++++++------------ embeddedobj/source/inc/docholder.hxx | 5 ++-- offapi/UnoApi_offapi.mk | 1 + offapi/com/sun/star/embed/HatchWindowFactory.idl | 38 ++++++++++++++++++++++++ 5 files changed, 57 insertions(+), 22 deletions(-) create mode 100644 offapi/com/sun/star/embed/HatchWindowFactory.idl diff --git a/embeddedobj/source/commonembedding/miscobj.cxx b/embeddedobj/source/commonembedding/miscobj.cxx index 2946d7fc3537..508883d333f0 100644 --- a/embeddedobj/source/commonembedding/miscobj.cxx +++ b/embeddedobj/source/commonembedding/miscobj.cxx @@ -29,6 +29,7 @@ #include #include #include +#include #include "closepreventer.hxx" #include "intercept.hxx" @@ -98,7 +99,7 @@ void OCommonEmbeddedObject::CommonInit_Impl( const uno::Sequence< beans::NamedVa if ( !m_xFactory.is() ) throw uno::RuntimeException(); - m_pDocHolder = new DocumentHolder( m_xFactory, this ); + m_pDocHolder = new DocumentHolder( comphelper::getComponentContext(m_xFactory), this ); m_pDocHolder->acquire(); // parse configuration entries diff --git a/embeddedobj/source/general/docholder.cxx b/embeddedobj/source/general/docholder.cxx index 47367f7cfa74..76bb6499f471 100644 --- a/embeddedobj/source/general/docholder.cxx +++ b/embeddedobj/source/general/docholder.cxx @@ -47,7 +47,7 @@ #include #include #include -#include +#include #include #include #include @@ -150,11 +150,11 @@ static void InsertMenu_Impl( const uno::Reference< container::XIndexContainer >& } //=========================================================================== -DocumentHolder::DocumentHolder( const uno::Reference< lang::XMultiServiceFactory >& xFactory, +DocumentHolder::DocumentHolder( const uno::Reference< uno::XComponentContext >& xContext, OCommonEmbeddedObject* pEmbObj ) : m_pEmbedObj( pEmbObj ), m_pInterceptor( NULL ), - m_xFactory( xFactory ), + m_xContext( xContext ), m_bReadOnly( sal_False ), m_bWaitForClose( sal_False ), m_bAllowClosing( sal_False ), @@ -173,7 +173,7 @@ DocumentHolder::DocumentHolder( const uno::Reference< lang::XMultiServiceFactory aArg.Value <<= sal_False; m_aOutplaceFrameProps[1] <<= aArg; - uno::Reference< frame::XDesktop2 > xDesktop = frame::Desktop::create( comphelper::getComponentContext(m_xFactory) ); + uno::Reference< frame::XDesktop2 > xDesktop = frame::Desktop::create( m_xContext ); m_refCount++; try { @@ -247,7 +247,7 @@ void DocumentHolder::CloseFrame() //--------------------------------------------------------------------------- void DocumentHolder::FreeOffice() { - uno::Reference< frame::XDesktop2 > xDesktop = frame::Desktop::create( comphelper::getComponentContext(m_xFactory) ); + uno::Reference< frame::XDesktop2 > xDesktop = frame::Desktop::create( m_xContext ); xDesktop->removeTerminateListener( this ); // the following code is commented out since for now there is still no completely correct way to detect @@ -410,13 +410,8 @@ sal_Bool DocumentHolder::ShowInplace( const uno::Reference< awt::XWindowPeer >& if ( xModel.is() ) { - uno::Reference< embed::XHatchWindowFactory > xHatchFactory( - m_xFactory->createInstance( - ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.embed.HatchWindowFactory" )) ), - uno::UNO_QUERY ); - - if ( !xHatchFactory.is() ) - throw uno::RuntimeException(); + uno::Reference< embed::XHatchWindowFactory > xHatchFactory = + embed::HatchWindowFactory::create(m_xContext); uno::Reference< embed::XHatchWindow > xHatchWindow = xHatchFactory->createHatchWindowInstance( xParent, @@ -446,8 +441,7 @@ sal_Bool DocumentHolder::ShowInplace( const uno::Reference< awt::XWindowPeer >& awt::Rectangle(),//aOwnRectangle, awt::WindowAttribute::SHOW | awt::VclWindowPeerAttribute::CLIPCHILDREN ); - uno::Reference< awt::XToolkit2 > xToolkit = - awt::Toolkit::create(comphelper::getComponentContext(m_xFactory)); + uno::Reference< awt::XToolkit2 > xToolkit = awt::Toolkit::create(m_xContext); uno::Reference< awt::XWindowPeer > xNewWinPeer = xToolkit->createWindow( aOwnWinDescriptor ); uno::Reference< awt::XWindow > xOwnWindow( xNewWinPeer, uno::UNO_QUERY ); @@ -456,7 +450,7 @@ sal_Bool DocumentHolder::ShowInplace( const uno::Reference< awt::XWindowPeer >& // create a frame based on the specified window uno::Reference< lang::XSingleServiceFactory > xFrameFact( - m_xFactory->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.TaskCreator" )) ), + m_xContext->getServiceManager()->createInstanceWithContext( "com.sun.star.frame.TaskCreator", m_xContext ), uno::UNO_QUERY_THROW ); uno::Sequence< uno::Any > aArgs( 2 ); @@ -554,14 +548,14 @@ uno::Reference< container::XIndexAccess > DocumentHolder::RetrieveOwnMenu_Impl() if ( !xResult.is() ) { // no internal document configuration, use the one from the module - uno::Reference< frame::XModuleManager2 > xModuleMan( frame::ModuleManager::create(comphelper::getComponentContext(m_xFactory)) ); + uno::Reference< frame::XModuleManager2 > xModuleMan = frame::ModuleManager::create(m_xContext); ::rtl::OUString aModuleIdent = xModuleMan->identify( uno::Reference< uno::XInterface >( m_xComponent, uno::UNO_QUERY ) ); if ( !aModuleIdent.isEmpty() ) { - uno::Reference< ui::XModuleUIConfigurationManagerSupplier > xModConfSupplier( - ui::ModuleUIConfigurationManagerSupplier::create(comphelper::getComponentContext(m_xFactory)) ); + uno::Reference< ui::XModuleUIConfigurationManagerSupplier > xModConfSupplier = + ui::ModuleUIConfigurationManagerSupplier::create(m_xContext); uno::Reference< ::com::sun::star::ui::XUIConfigurationManager > xModUIConfMan( xModConfSupplier->getUIConfigurationManager( aModuleIdent ), uno::UNO_QUERY_THROW ); @@ -836,7 +830,7 @@ uno::Reference< frame::XFrame > DocumentHolder::GetDocFrame() if ( !m_xFrame.is() ) { uno::Reference< lang::XSingleServiceFactory > xFrameFact( - m_xFactory->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.TaskCreator" ) )), + m_xContext->getServiceManager()->createInstanceWithContext( "com.sun.star.frame.TaskCreator", m_xContext ), uno::UNO_QUERY_THROW ); m_xFrame.set(xFrameFact->createInstanceWithArguments( m_aOutplaceFrameProps ), uno::UNO_QUERY_THROW); diff --git a/embeddedobj/source/inc/docholder.hxx b/embeddedobj/source/inc/docholder.hxx index 7c8f1057f3de..a76faae55597 100644 --- a/embeddedobj/source/inc/docholder.hxx +++ b/embeddedobj/source/inc/docholder.hxx @@ -34,6 +34,7 @@ #include #include #include +#include #include class OCommonEmbeddedObject; @@ -55,7 +56,7 @@ private: Interceptor* m_pInterceptor; ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProviderInterceptor > m_xOutplaceInterceptor; - ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xFactory; + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext; ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloseable > m_xComponent; @@ -114,7 +115,7 @@ public: throw ( ::com::sun::star::uno::Exception ); - DocumentHolder( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xFactory, + DocumentHolder( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext, OCommonEmbeddedObject* pEmbObj ); ~DocumentHolder(); diff --git a/offapi/UnoApi_offapi.mk b/offapi/UnoApi_offapi.mk index 56e5f4811ba8..a887de2d9381 100644 --- a/offapi/UnoApi_offapi.mk +++ b/offapi/UnoApi_offapi.mk @@ -111,6 +111,7 @@ $(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,offapi/com/sun/star/drawing/fr $(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,offapi/com/sun/star/embed,\ DocumentCloser \ FileSystemStorageFactory \ + HatchWindowFactory \ InstanceLocker \ OLESimpleStorage \ StorageFactory \ diff --git a/offapi/com/sun/star/embed/HatchWindowFactory.idl b/offapi/com/sun/star/embed/HatchWindowFactory.idl new file mode 100644 index 000000000000..2456ce5892d1 --- /dev/null +++ b/offapi/com/sun/star/embed/HatchWindowFactory.idl @@ -0,0 +1,38 @@ +/* -*- 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 . + */ +#ifndef __com_sun_star_embed_HatchWindowFactory_idl__ +#define __com_sun_star_embed_HatchWindowFactory_idl__ + +#include + + +module com { module sun { module star { module embed { + + +/** + @since LibreOffice 4.1 + */ +service HatchWindowFactory : XHatchWindowFactory; + + +}; }; }; }; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit v1.2.3