Kaydet (Commit) 30caf94d authored tarafından Noel Grandin's avatar Noel Grandin

fdo#46808, Convert ui::dialogs::AddressBookSourceDialog to new style

The service already existed, it just needed an IDL file.

Change-Id: I6b9a5a5fd02985bfdd29bb42f032265d0b5498c7
üst c98a1fa0
......@@ -34,6 +34,7 @@ namespace abp
{
//.........................................................................
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::beans;
......@@ -147,6 +148,18 @@ namespace abp
return new ::cppu::OPropertyArrayHelper(aProps);
}
void SAL_CALL OABSPilotUno::initialize( const Sequence< Any >& aArguments ) throw(Exception, RuntimeException)
{
Reference<awt::XWindow> xParentWindow;
if (aArguments.getLength() == 1 && (aArguments[0] >>= xParentWindow) ) {
Sequence< Any > aNewArgs(1);
aNewArgs[0] <<= PropertyValue( ::rtl::OUString("ParentWindow"), 0, makeAny(xParentWindow), PropertyState_DIRECT_VALUE );
OGenericUnoDialog::initialize(aNewArgs);
} else {
OGenericUnoDialog::initialize(aArguments);
}
}
//--------------------------------------------------------------------------
Dialog* OABSPilotUno::createDialog(Window* _pParent)
{
......
......@@ -78,6 +78,9 @@ namespace abp
// XJob
virtual ::com::sun::star::uno::Any SAL_CALL execute( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& lArgs ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
// XInitialisation
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);
using OABSPilotUno_DBase::execute;
protected:
// OGenericUnoDialog overridables
......
......@@ -357,6 +357,7 @@ $(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,offapi/com/sun/star/ui,\
WindowStateConfiguration \
))
$(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,offapi/com/sun/star/ui/dialogs,\
AddressBookSourcePilot \
FilePicker \
FolderPicker \
Wizard \
......
/* -*- 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_dialogs_AddressBookSourcePilot_idl__
#define __com_sun_star_ui_dialogs_AddressBookSourcePilot_idl__
#include <com/sun/star/awt/XWindow.idl>
#include <com/sun/star/ui/dialogs/XExecutableDialog.idl>
module com { module sun { module star { module ui { module dialogs {
/**
@since LibreOffice 4.1
*/
service AddressBookSourcePilot : XExecutableDialog
{
createWithParent([in] com::sun::star::awt::XWindow ParentWindow);
};
}; }; }; }; };
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -17,27 +17,27 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <com/sun/star/uno/Reference.hxx>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/lang/IllegalArgumentException.hpp>
#include <com/sun/star/document/XEmbeddedScripts.hpp>
#include <com/sun/star/embed/XStorage.hpp>
#include <com/sun/star/embed/ElementModes.hpp>
#include <com/sun/star/frame/Desktop.hpp>
#include <com/sun/star/frame/DispatchResultEvent.hpp>
#include <com/sun/star/frame/DispatchResultState.hpp>
#include <com/sun/star/task/XJobExecutor.hpp>
#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
#include <com/sun/star/frame/DispatchHelper.hpp>
#include <com/sun/star/frame/XDesktop.hpp>
#include <com/sun/star/frame/XFramesSupplier.hpp>
#include <com/sun/star/util/XCloseable.hpp>
#include <com/sun/star/util/CloseVetoException.hpp>
#include <com/sun/star/frame/XLayoutManager.hpp>
#include <com/sun/star/document/XEmbeddedScripts.hpp>
#include <com/sun/star/embed/XStorage.hpp>
#include <com/sun/star/embed/ElementModes.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/lang/IllegalArgumentException.hpp>
#include <com/sun/star/sdbc/DriverManager.hpp>
#include <com/sun/star/system/SystemShellExecute.hpp>
#include <com/sun/star/system/SystemShellExecuteFlags.hpp>
#include <com/sun/star/system/SystemShellExecuteException.hpp>
#include <com/sun/star/sdbc/DriverManager.hpp>
#include <com/sun/star/task/XJobExecutor.hpp>
#include <com/sun/star/ui/dialogs/AddressBookSourcePilot.hpp>
#include <com/sun/star/uno/Reference.hxx>
#include <com/sun/star/util/XCloseable.hpp>
#include <com/sun/star/util/CloseVetoException.hpp>
#include <org/freedesktop/PackageKit/SyncDbusSessionHelper.hpp>
#include <com/sun/star/frame/XComponentLoader.hpp>
......@@ -602,7 +602,7 @@ void SfxApplication::MiscExec_Impl( SfxRequest& rReq )
case SID_TEMPLATE_ADDRESSBOKSOURCE:
{
svt::AddressBookSourceDialog aDialog(GetTopWindow(), ::comphelper::getProcessServiceFactory());
svt::AddressBookSourceDialog aDialog(GetTopWindow(), ::comphelper::getProcessComponentContext());
aDialog.Execute();
bDone = true;
break;
......@@ -1428,20 +1428,16 @@ void SfxApplication::OfaExec_Impl( SfxRequest& rReq )
case SID_ADDRESS_DATA_SOURCE:
{
::rtl::OUString sDialogServiceName( "com.sun.star.ui.dialogs.AddressBookSourcePilot" );
try
{
Reference< com::sun::star::lang::XMultiServiceFactory > xORB = ::comphelper::getProcessServiceFactory();
Reference< com::sun::star::ui::dialogs::XExecutableDialog > xDialog;
if (xORB.is())
xDialog = Reference< com::sun::star::ui::dialogs::XExecutableDialog >(xORB->createInstance(sDialogServiceName), UNO_QUERY);
if (xDialog.is())
xDialog->execute();
else
ShowServiceNotAvailableError(NULL, sDialogServiceName, sal_True);
Reference< uno::XComponentContext > xORB = ::comphelper::getProcessComponentContext();
Reference< ui::dialogs::XExecutableDialog > xDialog;
xDialog = ui::dialogs::AddressBookSourcePilot::createWithParent(xORB, 0);
xDialog->execute();
}
catch(::com::sun::star::uno::Exception&)
catch(const ::com::sun::star::uno::Exception&)
{
DBG_UNHANDLED_EXCEPTION();
}
}
break;
......
......@@ -29,7 +29,6 @@
#include <vcl/lstbox.hxx>
#include <vcl/scrbar.hxx>
#include <com/sun/star/container/XNameAccess.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/util/AliasProgrammaticPair.hpp>
#include <com/sun/star/sdb/XDatabaseContext.hpp>
#include <com/sun/star/sdbc/XDataSource.hpp>
......@@ -70,7 +69,7 @@ namespace svt
::com::sun::star::uno::Reference< ::com::sun::star::sdb::XDatabaseContext >
m_xDatabaseContext;
// the ORB for creating objects
::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >
m_xORB;
::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >
m_xCurrentDatasourceTables;
......@@ -80,7 +79,7 @@ namespace svt
public:
AddressBookSourceDialog( Window* _pParent,
const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB );
const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxORB );
/** if you use this ctor, the dialog
<ul><li>will not store it's data in the configuration (nor initially retrieve it from there)</li>
......@@ -102,7 +101,7 @@ namespace svt
obtained from <arg>_rxTransientDS</arg>
*/
AddressBookSourceDialog( Window* _pParent,
const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB,
const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxORB,
const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDataSource >& _rxTransientDS,
const ::rtl::OUString& _rDataSourceName,
const ::rtl::OUString& _rTable,
......
......@@ -34,7 +34,7 @@
#include <vcl/waitobj.hxx>
#include <vcl/msgbox.hxx>
#include <toolkit/helper/vclunohelper.hxx>
#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
#include <com/sun/star/ui/dialogs/AddressBookSourcePilot.hpp>
#include <com/sun/star/awt/XWindow.hpp>
#include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
......@@ -562,7 +562,7 @@ void AssignmentPersistentData::Commit()
// -------------------------------------------------------------------
AddressBookSourceDialog::AddressBookSourceDialog(Window* _pParent,
const Reference< XMultiServiceFactory >& _rxORB )
const Reference< XComponentContext >& _rxORB )
:INIT_FIELDS()
,m_pImpl( new AddressBookSourceDialogData )
{
......@@ -570,7 +570,7 @@ void AssignmentPersistentData::Commit()
}
// -------------------------------------------------------------------
AddressBookSourceDialog::AddressBookSourceDialog( Window* _pParent, const Reference< XMultiServiceFactory >& _rxORB,
AddressBookSourceDialog::AddressBookSourceDialog( Window* _pParent, const Reference< XComponentContext >& _rxORB,
const Reference< XDataSource >& _rxTransientDS, const ::rtl::OUString& _rDataSourceName,
const ::rtl::OUString& _rTable, const Sequence< AliasProgrammaticPair >& _rMapping )
:INIT_FIELDS()
......@@ -791,9 +791,9 @@ void AssignmentPersistentData::Commit()
try
{
m_xDatabaseContext = DatabaseContext::create(comphelper::getComponentContext(m_xORB));
m_xDatabaseContext = DatabaseContext::create(m_xORB);
}
catch(Exception&) { }
catch(const Exception&) { }
if (!m_xDatabaseContext.is())
{
const rtl::OUString sContextServiceName("com.sun.star.sdb.DatabaseContext");
......@@ -842,10 +842,10 @@ void AssignmentPersistentData::Commit()
try
{
xHandler.set(
InteractionHandler::createWithParent(comphelper::getComponentContext(m_xORB), 0),
InteractionHandler::createWithParent(m_xORB, 0),
UNO_QUERY_THROW );
}
catch(Exception&) { }
catch(const Exception&) { }
if (!xHandler.is())
{
const rtl::OUString sInteractionHandlerServiceName("com.sun.star.task.InteractionHandler");
......@@ -1212,21 +1212,16 @@ void AssignmentPersistentData::Commit()
// -------------------------------------------------------------------
IMPL_LINK_NOARG(AddressBookSourceDialog, OnAdministrateDatasources)
{
// collect some initial arguments for the dialog
Sequence< Any > aArgs(1);
aArgs[0] <<= PropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ParentWindow")), 0, makeAny(VCLUnoHelper::GetInterface(this)), PropertyState_DIRECT_VALUE);
// create the dialog object
const rtl::OUString sDialogServiceName("com.sun.star.ui.dialogs.AddressBookSourcePilot");
Reference< XExecutableDialog > xAdminDialog;
try
{
xAdminDialog = Reference< XExecutableDialog >(m_xORB->createInstanceWithArguments(sDialogServiceName, aArgs), UNO_QUERY);
xAdminDialog = AddressBookSourcePilot::createWithParent( m_xORB, VCLUnoHelper::GetInterface(this) );
}
catch(Exception&) { }
catch(const Exception&) { }
if (!xAdminDialog.is())
{
ShowServiceNotAvailableError(this, sDialogServiceName, sal_True);
ShowServiceNotAvailableError(this, rtl::OUString("com.sun.star.ui.dialogs.AddressBookSourcePilot"), sal_True);
return 1L;
}
......@@ -1256,7 +1251,7 @@ void AssignmentPersistentData::Commit()
}
}
}
catch(Exception&)
catch(const Exception&)
{
OSL_FAIL("AddressBookSourceDialog::OnAdministrateDatasources: an error occurred while executing the administration dialog!");
}
......
......@@ -252,9 +252,9 @@ namespace svt
Dialog* OAddressBookSourceDialogUno::createDialog(Window* _pParent)
{
if ( m_xDataSource.is() && !m_sTable.isEmpty() )
return new AddressBookSourceDialog(_pParent, m_aContext.getLegacyServiceFactory(), m_xDataSource, m_sDataSourceName, m_sTable, m_aAliases );
return new AddressBookSourceDialog(_pParent, m_aContext.getUNOContext(), m_xDataSource, m_sDataSourceName, m_sTable, m_aAliases );
else
return new AddressBookSourceDialog( _pParent, m_aContext.getLegacyServiceFactory() );
return new AddressBookSourceDialog( _pParent, m_aContext.getUNOContext() );
}
// .......................................................................
......
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