Kaydet (Commit) 1e618a8d authored tarafından Noel Grandin's avatar Noel Grandin

fdo#46808, Adapt ui::AddressBookSourceDialog UNO service to new style

The service already existed, it just did not have an IDL file.

Change-Id: I34f9c29b7d5c91735cf1763b74d02516466bc78c
üst b920a2a8
......@@ -22,6 +22,7 @@
#include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
#include <com/sun/star/ui/AddressBookSourceDialog.hpp>
#include <com/sun/star/awt/XWindow.hpp>
#include <com/sun/star/sdb/CommandType.hpp>
#include <tools/debug.hxx>
......@@ -45,6 +46,7 @@ namespace abp
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::sdb;
using namespace ::com::sun::star::ui;
using namespace ::com::sun::star::ui::dialogs;
//---------------------------------------------------------------------
......@@ -67,7 +69,7 @@ namespace abp
//.....................................................................
//-----------------------------------------------------------------
sal_Bool invokeDialog( const Reference< XMultiServiceFactory >& _rxORB, class Window* _pParent,
sal_Bool invokeDialog( const Reference< XComponentContext >& _rxORB, class Window* _pParent,
const Reference< XPropertySet >& _rxDataSource, AddressSettings& _rSettings ) SAL_THROW ( ( ) )
{
_rSettings.aFieldMapping.clear();
......@@ -80,37 +82,17 @@ namespace abp
try
{
// ........................................................
// the parameters for creating the dialog
Sequence< Any > aArguments(5);
Any* pArguments = aArguments.getArray();
// the parent window
// create an instance of the dialog service
Reference< XWindow > xDialogParent = VCLUnoHelper::GetInterface( _pParent );
*pArguments++ <<= PropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ParentWindow" )), -1, makeAny( xDialogParent ), PropertyState_DIRECT_VALUE);
// the data source to use
*pArguments++ <<= PropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "DataSource" )), -1, makeAny( _rxDataSource ), PropertyState_DIRECT_VALUE);
*pArguments++ <<= PropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "DataSourceName" )), -1, makeAny( (sal_Bool)_rSettings.bRegisterDataSource ? _rSettings.sRegisteredDataSourceName : _rSettings.sDataSourceName ), PropertyState_DIRECT_VALUE);
// the table to use
*pArguments++ <<= PropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Command" )), -1, makeAny( _rSettings.sSelectedTable ), PropertyState_DIRECT_VALUE);
// the title
::rtl::OUString sTitle = String( ModuleRes( RID_STR_FIELDDIALOGTITLE ) );
*pArguments++ <<= PropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Title" )), -1, makeAny( sTitle ), PropertyState_DIRECT_VALUE);
// ........................................................
// create an instance of the dialog service
static ::rtl::OUString s_sAdressBookFieldAssignmentServiceName(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ui.AddressBookSourceDialog" ));
Reference< XExecutableDialog > xDialog(
_rxORB->createInstanceWithArguments( s_sAdressBookFieldAssignmentServiceName, aArguments ),
UNO_QUERY
);
if ( !xDialog.is( ) )
{
ShowServiceNotAvailableError( _pParent, s_sAdressBookFieldAssignmentServiceName, sal_True );
return sal_False;
}
Reference< XExecutableDialog > xDialog = AddressBookSourceDialog::createWithDataSource(_rxORB,
// the parent window
xDialogParent,
_rxDataSource,
(sal_Bool)_rSettings.bRegisterDataSource ? _rSettings.sRegisteredDataSourceName : _rSettings.sDataSourceName,
// the table to use
_rSettings.sSelectedTable,
sTitle);
// execute the dialog
if ( xDialog->execute() )
......
......@@ -60,7 +60,7 @@ namespace abp
field mapping dialog.
*/
sal_Bool invokeDialog(
const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB,
const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxORB,
class Window* _pParent,
const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxDataSource,
AddressSettings& _rSettings
......
......@@ -21,6 +21,7 @@
#include "fieldmappingimpl.hxx"
#include "addresssettings.hxx"
#include "abspilot.hxx"
#include <comphelper/processfactory.hxx>
//.........................................................................
namespace abp
......@@ -91,7 +92,7 @@ namespace abp
AddressSettings& rSettings = getSettings();
// invoke the dialog doing the mapping
if ( fieldmapping::invokeDialog( getORB(), this, getDialog()->getDataSource().getDataSource(), rSettings ) )
if ( fieldmapping::invokeDialog( comphelper::getComponentContext(getORB()), this, getDialog()->getDataSource().getDataSource(), rSettings ) )
{
if ( rSettings.aFieldMapping.size() )
getDialog()->travelNext();
......
......@@ -309,6 +309,7 @@ $(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,offapi/com/sun/star/ucb,\
UniversalContentBroker \
))
$(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,offapi/com/sun/star/ui,\
AddressBookSourceDialog \
GlobalAcceleratorConfiguration \
ModuleUIConfigurationManagerSupplier \
UIElementFactoryManager \
......
/* -*- 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_ui_AddressBookSourceDialog_idl__
#define __com_sun_star_ui_AddressBookSourceDialog_idl__
#include <com/sun/star/ui/dialogs/XExecutableDialog.idl>
#include <com/sun/star/awt/XWindow.idl>
#include <com/sun/star/beans/XPropertySet.idl>
module com { module sun { module star { module ui {
/** This interface could be incomplete since I derived it from its places of use.
@since LibreOffice 4.1
*/
service AddressBookSourceDialog : com::sun::star::ui::dialogs::XExecutableDialog
{
createWithDataSource([in] com::sun::star::awt::XWindow ParentWindow,
[in] com::sun::star::beans::XPropertySet DataSource,
[in] string DataSourceName,
[in] string Command,
[in] string Title);
};
}; }; }; };
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -76,6 +76,8 @@ namespace svt
// OPropertyArrayUsageHelper
virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
void initialize(const Sequence< Any >& aArguments) throw(RuntimeException);
protected:
// OGenericUnoDialog overridables
virtual Dialog* createDialog(Window* _pParent);
......@@ -171,7 +173,32 @@ namespace svt
if ( m_pDialog )
static_cast< AddressBookSourceDialog* >( m_pDialog )->getFieldMapping( m_aAliases );
}
//------------------------------------------------------------------------------
void OAddressBookSourceDialogUno::initialize(const Sequence< Any >& aArguments) throw(RuntimeException)
{
if( aArguments.getLength() == 5 )
{
Reference<com::sun::star::awt::XWindow> xParentWindow;
Reference<com::sun::star::beans::XPropertySet> xDataSource;
rtl::OUString sDataSourceName;
rtl::OUString sCommand;
rtl::OUString sTitle;
if ( (aArguments[0] >>= xParentWindow)
&& (aArguments[1] >>= xDataSource)
&& (aArguments[2] >>= sDataSourceName)
&& (aArguments[3] >>= sCommand)
&& (aArguments[4] >>= sTitle) )
{
setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ParentWindow" ) ), makeAny( xParentWindow ) );
setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DataSource" ) ), makeAny( xDataSource ) );
setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DataSourceName" ) ), makeAny( sDataSourceName ) );
setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Command" ) ), makeAny( sCommand ) );
setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Title" ) ), makeAny( sTitle ) );
return;
}
}
OGenericUnoDialog::initialize(aArguments);
}
//------------------------------------------------------------------------------
void OAddressBookSourceDialogUno::implInitialize(const com::sun::star::uno::Any& _rValue)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment