From b8a403467e6209437c3c113ff2df95df6ffec61a Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Mon, 3 Dec 2012 13:10:01 +0200 Subject: fdo#46808, Create new-style sdb::ReportDesign service The service already existed, it just did not have an IDL file. Change-Id: I681754040e1de8d96fe5bdc1b442bfc4de76c7c7 --- dbaccess/source/ui/browser/dbloader.cxx | 32 ++++++++++++-------------- offapi/UnoApi_offapi.mk | 1 + offapi/com/sun/star/sdb/ReportDesign.idl | 39 ++++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+), 18 deletions(-) create mode 100644 offapi/com/sun/star/sdb/ReportDesign.idl diff --git a/dbaccess/source/ui/browser/dbloader.cxx b/dbaccess/source/ui/browser/dbloader.cxx index 60b4b0a13479..1f4a3be7b3e2 100644 --- a/dbaccess/source/ui/browser/dbloader.cxx +++ b/dbaccess/source/ui/browser/dbloader.cxx @@ -35,6 +35,7 @@ #include #include #include +#include #include #include @@ -53,11 +54,11 @@ using namespace ::com::sun::star; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::frame; using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::sdb; using namespace ::com::sun::star::sdbc; using namespace ::com::sun::star::container; using namespace ::com::sun::star::lang; using namespace ::com::sun::star::registry; -using ::com::sun::star::sdbc::XDataSource; using namespace dbaui; class DBContentLoader : public ::cppu::WeakImplHelper2< XFrameLoader, XServiceInfo> @@ -67,9 +68,9 @@ private: Sequence< PropertyValue> m_aArgs; Reference< XLoadEventListener > m_xListener; Reference< XFrame > m_xFrame; - Reference< XMultiServiceFactory > m_xServiceFactory; + Reference< XComponentContext > m_xContext; public: - DBContentLoader(const Reference< XMultiServiceFactory >&); + DBContentLoader(const Reference< XComponentContext >&); ~DBContentLoader(); // XServiceInfo @@ -94,8 +95,8 @@ public: }; DBG_NAME(DBContentLoader) -DBContentLoader::DBContentLoader(const Reference< XMultiServiceFactory >& _rxFactory) - :m_xServiceFactory(_rxFactory) +DBContentLoader::DBContentLoader(const Reference< XComponentContext >& _rxContext) + :m_xContext(_rxContext) { DBG_CTOR(DBContentLoader,NULL); @@ -116,7 +117,7 @@ extern "C" void SAL_CALL createRegistryInfo_DBContentLoader() // ------------------------------------------------------------------------- Reference< XInterface > SAL_CALL DBContentLoader::Create( const Reference< XMultiServiceFactory > & rSMgr ) { - return *(new DBContentLoader(rSMgr)); + return *(new DBContentLoader(comphelper::getComponentContext(rSMgr))); } // ------------------------------------------------------------------------- // XServiceInfo @@ -181,8 +182,6 @@ void SAL_CALL DBContentLoader::load(const Reference< XFrame > & rFrame, const :: m_aURL = rURL; m_aArgs = rArgs; - ::comphelper::ComponentContext aContext( m_xServiceFactory ); - struct ServiceNameToImplName { const sal_Char* pAsciiServiceName; @@ -209,7 +208,8 @@ void SAL_CALL DBContentLoader::load(const Reference< XFrame > & rFrame, const :: { if ( sComponentURL.equalsAscii( aImplementations[i].pAsciiServiceName ) ) { - aContext.createComponent( aImplementations[i].pAsciiImplementationName, xController ); + xController.set( m_xContext->getServiceManager()-> + createInstanceWithContext( ::rtl::OUString::createFromAscii( aImplementations[i].pAsciiImplementationName ), m_xContext), UNO_QUERY_THROW ); break; } } @@ -250,14 +250,10 @@ void SAL_CALL DBContentLoader::load(const Reference< XFrame > & rFrame, const :: Reference< XModel > xReportModel( aLoadArgs.getOrDefault( "Model", Reference< XModel >() ) ); if ( xReportModel.is() ) { - xController.set( m_xServiceFactory->createInstance( - ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sdb.ReportDesign" ) ) ), UNO_QUERY ); - if ( xController.is() ) - { - xController->attachModel( xReportModel ); - xReportModel->connectController( xController.get() ); - xReportModel->setCurrentController( xController.get() ); - } + xController.set( ReportDesign::create( m_xContext ) ); + xController->attachModel( xReportModel ); + xReportModel->connectController( xController.get() ); + xReportModel->setCurrentController( xController.get() ); } } @@ -275,7 +271,7 @@ void SAL_CALL DBContentLoader::load(const Reference< XFrame > & rFrame, const :: else if ( !sDataSourceName.isEmpty() ) { ::dbtools::SQLExceptionInfo aError; - xDataSource.set( getDataSourceByName( sDataSourceName, NULL, comphelper::getComponentContext(m_xServiceFactory), &aError ) ); + xDataSource.set( getDataSourceByName( sDataSourceName, NULL, m_xContext, &aError ) ); xDatabaseDocument.set( getDataSourceOrModel( xDataSource ), UNO_QUERY ); } else if ( xConnection.is() ) diff --git a/offapi/UnoApi_offapi.mk b/offapi/UnoApi_offapi.mk index c4b467dd8761..295cc9042caa 100644 --- a/offapi/UnoApi_offapi.mk +++ b/offapi/UnoApi_offapi.mk @@ -244,6 +244,7 @@ $(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,offapi/com/sun/star/sdb,\ DatabaseInteractionHandler \ ErrorMessageDialog \ InteractionHandler \ + ReportDesign \ )) $(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,offapi/com/sun/star/sdb/application,\ CopyTableWizard \ diff --git a/offapi/com/sun/star/sdb/ReportDesign.idl b/offapi/com/sun/star/sdb/ReportDesign.idl new file mode 100644 index 000000000000..832c3824512e --- /dev/null +++ b/offapi/com/sun/star/sdb/ReportDesign.idl @@ -0,0 +1,39 @@ +/* -*- 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_sdb_ReportDesign_idl__ +#define __com_sun_star_sdb_ReportDesign_idl__ + +#include + + +module com { module sun { module star { module sdb { + + +/** + This interface could be imcomplete since I derived it from it's sole place of use. + + @since LibreOffice 4.1 +*/ +service ReportDesign : com::sun::star::frame::XController2; + + +}; }; }; }; + +#endif +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit v1.2.3