svt: Use constructor feature for SvFilterOptionsDialog.

Also fix the implementation name.

Change-Id: Ic7c8c77b819c0368cfbc95f16f6cce09a6a3de16
This commit is contained in:
Matúš Kukan 2014-01-08 17:08:26 +01:00
parent 9e5e7c9b55
commit 22c91244d4
4 changed files with 90 additions and 153 deletions

View File

@ -18,62 +18,100 @@
*/
#include "SvFilterOptionsDialog.hxx"
#include <vcl/FilterConfigItem.hxx>
#include <vcl/graphicfilter.hxx>
#include <vcl/svapp.hxx>
#include <osl/file.hxx>
#include <osl/module.hxx>
#include <rtl/ref.hxx>
#include <svl/solar.hrc>
#include <vcl/fltcall.hxx>
#include "exportdialog.hxx"
#include <uno/mapping.hxx>
#include <tools/fldunit.hxx>
#include <com/sun/star/frame/XModel.hpp>
#include <com/sun/star/beans/XPropertyAccess.hpp>
#include <com/sun/star/document/XExporter.hpp>
#include <com/sun/star/document/XViewDataSupplier.hpp>
#include <com/sun/star/container/XIndexAccess.hpp>
#include <com/sun/star/lang/XInitialization.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/uno/Sequence.h>
#include <com/sun/star/uno/Any.h>
#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
#include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
#include <unotools/syslocale.hxx>
#include <comphelper/processfactory.hxx>
#include "vcl/svapp.hxx"
#include <cppuhelper/implbase5.hxx>
#include <cppuhelper/supportsservice.hxx>
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 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;
}
OUString maDialogTitle;
FieldUnit meFieldUnit;
sal_Bool mbExportSelection;
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
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 );
// XExecuteDialog
virtual sal_Int16 SAL_CALL execute()
throw ( uno::RuntimeException );
virtual void SAL_CALL setTitle( const OUString& aTitle )
throw ( uno::RuntimeException );
// 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,16 @@ 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,
css::uno::Sequence<css::uno::Any> const &)
{
rtl::Reference<SvFilterOptionsDialog> x(new SvFilterOptionsDialog(context));
x->acquire();
return static_cast<cppu::OWeakObject *>(x.get());
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@ -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 <tools/fldunit.hxx>
#include <cppuhelper/implbase5.hxx>
#include <com/sun/star/beans/XPropertyAccess.hpp>
#include <com/sun/star/document/XExporter.hpp>
#include <com/sun/star/lang/XInitialization.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
#include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
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: */

View File

@ -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(

View File

@ -36,7 +36,8 @@
<implementation name="com.sun.star.graphic.GraphicObject">
<service name="com.sun.star.graphic.GraphicObject"/>
</implementation>
<implementation name="com.sun.star.svtools.SvFilterOptionsDialog">
<implementation name="com.sun.star.svtools.SvFilterOptionsDialog"
constructor="com_sun_star_svtools_SvFilterOptionsDialog_get_implementation">
<service name="com.sun.star.ui.dialogs.FilterOptionsDialog"/>
</implementation>
<implementation name="com.sun.star.comp.svt.FilePicker"