From 489a152aea904cf82101d13c4bd82cd6acd041b0 Mon Sep 17 00:00:00 2001 From: Matúš Kukan Date: Wed, 8 Jan 2014 17:08:26 +0100 Subject: svt: Use constructor feature for SvFilterOptionsDialog. Also fix the implementation name. Change-Id: Ic7c8c77b819c0368cfbc95f16f6cce09a6a3de16 --- svtools/source/filter/SvFilterOptionsDialog.cxx | 129 +++++++++++++++++------- svtools/source/filter/SvFilterOptionsDialog.hxx | 99 ------------------ svtools/source/uno/miscservices.cxx | 17 ---- svtools/util/svt.component | 3 +- 4 files changed, 95 insertions(+), 153 deletions(-) delete mode 100644 svtools/source/filter/SvFilterOptionsDialog.hxx diff --git a/svtools/source/filter/SvFilterOptionsDialog.cxx b/svtools/source/filter/SvFilterOptionsDialog.cxx index 108020c446f1..714ca5ba146f 100644 --- a/svtools/source/filter/SvFilterOptionsDialog.cxx +++ b/svtools/source/filter/SvFilterOptionsDialog.cxx @@ -18,62 +18,100 @@ */ -#include "SvFilterOptionsDialog.hxx" #include #include +#include #include #include +#include #include #include #include "exportdialog.hxx" #include +#include #include +#include +#include #include #include +#include #include #include #include +#include +#include +#include #include #include -#include "vcl/svapp.hxx" +#include +#include -using namespace ::rtl; using namespace ::com::sun::star; -// ------------------------- -// - SvFilterOptionsDialog - -// ------------------------- +namespace { -uno::Reference< uno::XInterface > - SAL_CALL SvFilterOptionsDialog_CreateInstance( - const uno::Reference< lang::XMultiServiceFactory > & _rxFactory ) +class SvFilterOptionsDialog : public cppu::WeakImplHelper5 +< + document::XExporter, + ui::dialogs::XExecutableDialog, + beans::XPropertyAccess, + lang::XInitialization, + lang::XServiceInfo +> { - return static_cast< ::cppu::OWeakObject* > ( new SvFilterOptionsDialog( comphelper::getComponentContext(_rxFactory) ) ); -} + const uno::Reference< uno::XComponentContext > + mxContext; + uno::Sequence< beans::PropertyValue > + maMediaDescriptor; + uno::Sequence< beans::PropertyValue > + maFilterDataSequence; + uno::Reference< lang::XComponent > + mxSourceDocument; + + OUString maDialogTitle; + FieldUnit meFieldUnit; + sal_Bool mbExportSelection; + +public: + + SvFilterOptionsDialog( const uno::Reference< uno::XComponentContext >& _rxORB ); + ~SvFilterOptionsDialog(); + + // XInterface + virtual void SAL_CALL acquire() throw(); + virtual void SAL_CALL release() throw(); + + // XInitialization + virtual void SAL_CALL initialize( const uno::Sequence< uno::Any > & aArguments ) + throw ( uno::Exception, uno::RuntimeException ); + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName() + throw ( uno::RuntimeException ); + virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) + throw ( uno::RuntimeException ); + virtual uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() + throw ( uno::RuntimeException ); + + // XPropertyAccess + virtual uno::Sequence< beans::PropertyValue > SAL_CALL getPropertyValues() + throw ( uno::RuntimeException ); + virtual void SAL_CALL setPropertyValues( const uno::Sequence< beans::PropertyValue > & aProps ) + throw ( beans::UnknownPropertyException, beans::PropertyVetoException, + lang::IllegalArgumentException, lang::WrappedTargetException, + uno::RuntimeException ); -OUString SvFilterOptionsDialog_getImplementationName() - throw( uno::RuntimeException ) -{ - return OUString( "com.sun.star.comp.svtools.SvFilterOptionsDialog" ); -} -#define SERVICE_NAME "com.sun.star.ui.dialog.FilterOptionsDialog" -sal_Bool SAL_CALL SvFilterOptionsDialog_supportsService( const OUString& ServiceName ) - throw( uno::RuntimeException ) -{ - return ServiceName == SERVICE_NAME; -} + // XExecuteDialog + virtual sal_Int16 SAL_CALL execute() + throw ( uno::RuntimeException ); + virtual void SAL_CALL setTitle( const OUString& aTitle ) + throw ( uno::RuntimeException ); -uno::Sequence< OUString > SAL_CALL SvFilterOptionsDialog_getSupportedServiceNames() - throw( uno::RuntimeException ) -{ - uno::Sequence< OUString > aRet(1); - OUString* pArray = aRet.getArray(); - pArray[0] = OUString( SERVICE_NAME ); - return aRet; -} -#undef SERVICE_NAME + // XExporter + virtual void SAL_CALL setSourceDocument( const uno::Reference< lang::XComponent >& xDoc ) + throw ( lang::IllegalArgumentException, uno::RuntimeException ); -// ----------------------------------------------------------------------------- +}; SvFilterOptionsDialog::SvFilterOptionsDialog( const uno::Reference< uno::XComponentContext >& rxContext ) : mxContext ( rxContext ), @@ -112,20 +150,22 @@ void SAL_CALL SvFilterOptionsDialog::initialize( const uno::Sequence< uno::Any > OUString SAL_CALL SvFilterOptionsDialog::getImplementationName() throw( uno::RuntimeException ) { - return SvFilterOptionsDialog_getImplementationName(); + return OUString( "com.sun.star.svtools.SvFilterOptionsDialog" ); } sal_Bool SAL_CALL SvFilterOptionsDialog::supportsService( const OUString& rServiceName ) throw( uno::RuntimeException ) { - return SvFilterOptionsDialog_supportsService( rServiceName ); + return cppu::supportsService(this, rServiceName); } uno::Sequence< OUString > SAL_CALL SvFilterOptionsDialog::getSupportedServiceNames() throw ( uno::RuntimeException ) { - return SvFilterOptionsDialog_getSupportedServiceNames(); + uno::Sequence< OUString > aRet(1); + OUString* pArray = aRet.getArray(); + pArray[0] = OUString("com.sun.star.ui.dialog.FilterOptionsDialog"); + return aRet; } - // XPropertyAccess uno::Sequence< beans::PropertyValue > SvFilterOptionsDialog::getPropertyValues() throw ( uno::RuntimeException ) @@ -257,4 +297,21 @@ void SvFilterOptionsDialog::setSourceDocument( const uno::Reference< lang::XComp } } +} + +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL +com_sun_star_svtools_SvFilterOptionsDialog_get_implementation( + css::uno::XComponentContext * context, + uno_Sequence * arguments) +{ + assert(arguments != 0); + rtl::Reference x(new SvFilterOptionsDialog(context)); + css::uno::Sequence aArgs( + reinterpret_cast(arguments->elements), + arguments->nElements); + x->initialize(aArgs); + x->acquire(); + return static_cast(x.get()); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svtools/source/filter/SvFilterOptionsDialog.hxx b/svtools/source/filter/SvFilterOptionsDialog.hxx deleted file mode 100644 index 7e0767731664..000000000000 --- a/svtools/source/filter/SvFilterOptionsDialog.hxx +++ /dev/null @@ -1,99 +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 . - */ - -#ifndef INCLUDED_SVTOOLS_SOURCE_FILTER_SVFILTEROPTIONSDIALOG_HXX -#define INCLUDED_SVTOOLS_SOURCE_FILTER_SVFILTEROPTIONSDIALOG_HXX - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -class SvFilterOptionsDialog : public cppu::WeakImplHelper5 -< - com::sun::star::document::XExporter, - com::sun::star::ui::dialogs::XExecutableDialog, - com::sun::star::beans::XPropertyAccess, - com::sun::star::lang::XInitialization, - com::sun::star::lang::XServiceInfo -> -{ - const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > - mxContext; - com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > - maMediaDescriptor; - com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > - maFilterDataSequence; - com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > - mxSourceDocument; - - OUString maDialogTitle; - FieldUnit meFieldUnit; - sal_Bool mbExportSelection; - -public: - - SvFilterOptionsDialog( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxORB ); - ~SvFilterOptionsDialog(); - - // XInterface - virtual void SAL_CALL acquire() throw(); - virtual void SAL_CALL release() throw(); - - // XInitialization - virtual void SAL_CALL initialize( const com::sun::star::uno::Sequence< com::sun::star::uno::Any > & aArguments ) - throw ( com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException ); - - // XServiceInfo - virtual OUString SAL_CALL getImplementationName() - throw ( com::sun::star::uno::RuntimeException ); - virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) - throw ( com::sun::star::uno::RuntimeException ); - virtual com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() - throw ( com::sun::star::uno::RuntimeException ); - - // XPropertyAccess - virtual com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > SAL_CALL getPropertyValues() - throw ( com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL setPropertyValues( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > & aProps ) - throw ( ::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, - ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, - ::com::sun::star::uno::RuntimeException ); - - // XExecuteDialog - virtual sal_Int16 SAL_CALL execute() - throw ( com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL setTitle( const OUString& aTitle ) - throw ( ::com::sun::star::uno::RuntimeException ); - - // XExporter - virtual void SAL_CALL setSourceDocument( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& xDoc ) - throw ( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException ); - -}; - - -#endif // INCLUDED_SVTOOLS_SOURCE_FILTER_SVFILTEROPTIONSDIALOG_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svtools/source/uno/miscservices.cxx b/svtools/source/uno/miscservices.cxx index e12db4529cbf..184146522470 100644 --- a/svtools/source/uno/miscservices.cxx +++ b/svtools/source/uno/miscservices.cxx @@ -45,10 +45,6 @@ namespace unographic { extern sdecl::ServiceDecl const serviceDecl; } -// for CreateInstance functions implemented elsewhere -#define DECLARE_CREATEINSTANCE( ImplName ) \ - Reference< XInterface > SAL_CALL ImplName##_CreateInstance( const Reference< XMultiServiceFactory >& ); - // for CreateInstance functions implemented elsewhere, while the function is within a namespace #define DECLARE_CREATEINSTANCE_NAMESPACE( nmspe, ImplName ) \ namespace nmspe { \ @@ -70,7 +66,6 @@ namespace } DECLARE_CREATEINSTANCE_NAMESPACE( svt, OAddressBookSourceDialogUno ) -DECLARE_CREATEINSTANCE( SvFilterOptionsDialog ) extern "C" { @@ -96,18 +91,6 @@ SAL_DLLPUBLIC_EXPORT void * SAL_CALL svt_component_getFactory ( svt::OAddressBookSourceDialogUno_CreateInstance, aServiceNames); } - else if (rtl_str_compare ( - pImplementationName, "com.sun.star.svtools.SvFilterOptionsDialog") == 0) - { - Sequence< OUString > aServiceNames(1); - aServiceNames.getArray()[0] = - OUString( "com.sun.star.ui.dialogs.FilterOptionsDialog" ); - - xFactory = ::cppu::createSingleFactory (xSMgr, - OUString::createFromAscii( pImplementationName ), - SvFilterOptionsDialog_CreateInstance, - aServiceNames); - } else { pResult = comphelper::service_decl::component_getFactoryHelper( diff --git a/svtools/util/svt.component b/svtools/util/svt.component index 6d3bb3fea30b..a4028c6a979d 100644 --- a/svtools/util/svt.component +++ b/svtools/util/svt.component @@ -36,7 +36,8 @@ - +