2010-10-12 15:59:03 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-06-14 17:39:53 +01:00
|
|
|
/*
|
|
|
|
* 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 .
|
|
|
|
*/
|
2005-01-05 11:37:55 +00:00
|
|
|
|
|
|
|
#include "composerdialogs.hxx"
|
2017-10-23 22:42:52 +02:00
|
|
|
#include <uiservices.hxx>
|
2005-01-05 11:37:55 +00:00
|
|
|
|
2017-10-23 22:42:52 +02:00
|
|
|
#include <dbu_reghelper.hxx>
|
2019-01-30 00:10:38 +01:00
|
|
|
#include <com/sun/star/awt/XWindow.hpp>
|
|
|
|
#include <com/sun/star/beans/PropertyAttribute.hpp>
|
2005-01-05 11:37:55 +00:00
|
|
|
#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
|
2017-10-23 22:42:52 +02:00
|
|
|
#include <stringconstants.hxx>
|
|
|
|
#include <queryfilter.hxx>
|
|
|
|
#include <queryorder.hxx>
|
2013-03-19 13:08:47 +02:00
|
|
|
#include <comphelper/processfactory.hxx>
|
2005-01-05 11:37:55 +00:00
|
|
|
#include <connectivity/dbtools.hxx>
|
2018-10-06 15:54:11 +01:00
|
|
|
#include <toolkit/helper/vclunohelper.hxx>
|
2008-05-05 15:10:15 +00:00
|
|
|
#include <tools/diagnose_ex.h>
|
2011-02-03 00:33:36 +01:00
|
|
|
#include <osl/diagnose.h>
|
2018-10-11 17:06:02 +01:00
|
|
|
#include <vcl/svapp.hxx>
|
2005-01-05 11:37:55 +00:00
|
|
|
|
2017-12-08 15:58:41 +02:00
|
|
|
extern "C" void createRegistryInfo_ComposerDialogs()
|
2005-01-05 11:37:55 +00:00
|
|
|
{
|
|
|
|
static ::dbaui::OMultiInstanceAutoRegistration< ::dbaui::RowsetOrderDialog > aOrderDialogRegistration;
|
|
|
|
static ::dbaui::OMultiInstanceAutoRegistration< ::dbaui::RowsetFilterDialog > aFilterDialogRegistration;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace dbaui
|
|
|
|
{
|
|
|
|
|
|
|
|
#define PROPERTY_ID_QUERYCOMPOSER 100
|
|
|
|
#define PROPERTY_ID_ROWSET 101
|
|
|
|
|
2013-04-25 10:56:02 +02:00
|
|
|
#define PROPERTY_QUERYCOMPOSER "QueryComposer"
|
|
|
|
#define PROPERTY_ROWSET "RowSet"
|
2005-01-05 11:37:55 +00:00
|
|
|
|
|
|
|
using namespace ::com::sun::star::uno;
|
|
|
|
using namespace ::com::sun::star::lang;
|
|
|
|
using namespace ::com::sun::star::beans;
|
|
|
|
using namespace ::com::sun::star::container;
|
|
|
|
using namespace ::com::sun::star::sdbcx;
|
|
|
|
using namespace ::com::sun::star::sdbc;
|
|
|
|
using namespace ::com::sun::star::sdb;
|
|
|
|
|
2013-08-17 23:43:14 +02:00
|
|
|
// ComposerDialog
|
2013-03-19 13:08:47 +02:00
|
|
|
ComposerDialog::ComposerDialog(const Reference< XComponentContext >& _rxORB)
|
2012-12-20 16:13:33 +01:00
|
|
|
:OGenericUnoDialog( _rxORB )
|
2005-01-05 11:37:55 +00:00
|
|
|
{
|
2005-09-23 11:47:12 +00:00
|
|
|
|
2005-01-05 11:37:55 +00:00
|
|
|
registerProperty( PROPERTY_QUERYCOMPOSER, PROPERTY_ID_QUERYCOMPOSER, PropertyAttribute::TRANSIENT,
|
2015-04-01 08:38:29 +02:00
|
|
|
&m_xComposer, cppu::UnoType<decltype(m_xComposer)>::get() );
|
2005-01-05 11:37:55 +00:00
|
|
|
registerProperty( PROPERTY_ROWSET, PROPERTY_ID_ROWSET, PropertyAttribute::TRANSIENT,
|
2015-04-01 08:38:29 +02:00
|
|
|
&m_xRowSet, cppu::UnoType<decltype(m_xRowSet)>::get() );
|
2005-01-05 11:37:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ComposerDialog::~ComposerDialog()
|
|
|
|
{
|
2005-09-23 11:47:12 +00:00
|
|
|
|
2005-01-05 11:37:55 +00:00
|
|
|
}
|
|
|
|
|
2014-03-11 13:02:59 +01:00
|
|
|
css::uno::Sequence<sal_Int8> ComposerDialog::getImplementationId()
|
|
|
|
{
|
|
|
|
return css::uno::Sequence<sal_Int8>();
|
|
|
|
}
|
2005-01-05 11:37:55 +00:00
|
|
|
|
|
|
|
IMPLEMENT_PROPERTYCONTAINER_DEFAULTS( ComposerDialog )
|
|
|
|
|
2019-09-15 20:41:25 +01:00
|
|
|
std::unique_ptr<weld::DialogController> ComposerDialog::createDialog(const css::uno::Reference<css::awt::XWindow>& rParent)
|
2005-01-05 11:37:55 +00:00
|
|
|
{
|
|
|
|
// obtain all the objects needed for the dialog
|
|
|
|
Reference< XConnection > xConnection;
|
|
|
|
Reference< XNameAccess > xColumns;
|
|
|
|
try
|
|
|
|
{
|
|
|
|
// the connection the row set is working with
|
2005-03-10 15:55:16 +00:00
|
|
|
if ( !::dbtools::isEmbeddedInDatabase( m_xRowSet, xConnection ) )
|
|
|
|
{
|
|
|
|
Reference< XPropertySet > xRowsetProps( m_xRowSet, UNO_QUERY );
|
|
|
|
if ( xRowsetProps.is() )
|
2008-01-30 07:56:26 +00:00
|
|
|
xRowsetProps->getPropertyValue( PROPERTY_ACTIVE_CONNECTION ) >>= xConnection;
|
2005-03-10 15:55:16 +00:00
|
|
|
}
|
2005-01-05 11:37:55 +00:00
|
|
|
|
|
|
|
// fallback: if there is a connection and thus a row set, but no composer, create one
|
|
|
|
if ( xConnection.is() && !m_xComposer.is() )
|
2019-08-16 20:23:50 +01:00
|
|
|
m_xComposer = ::dbtools::getCurrentSettingsComposer( Reference< XPropertySet >( m_xRowSet, UNO_QUERY ), m_aContext, rParent );
|
2005-01-05 11:37:55 +00:00
|
|
|
|
|
|
|
// the columns of the row set
|
|
|
|
Reference< XColumnsSupplier > xSuppColumns( m_xRowSet, UNO_QUERY );
|
|
|
|
if ( xSuppColumns.is() )
|
|
|
|
xColumns = xSuppColumns->getColumns();
|
|
|
|
|
|
|
|
if ( !xColumns.is() || !xColumns->hasElements() )
|
|
|
|
{ // perhaps the composer can supply us with columns? This is necessary for cases
|
|
|
|
// where the dialog is invoked for a rowset which is not yet loaded
|
2011-02-27 22:55:22 +01:00
|
|
|
// #i22878#
|
2014-06-13 17:49:30 +02:00
|
|
|
xSuppColumns.set(m_xComposer, css::uno::UNO_QUERY);
|
2005-01-05 11:37:55 +00:00
|
|
|
if ( xSuppColumns.is() )
|
|
|
|
xColumns = xSuppColumns->getColumns();
|
|
|
|
}
|
|
|
|
|
2011-02-03 00:33:36 +01:00
|
|
|
OSL_ENSURE( xColumns.is() && xColumns->hasElements(), "ComposerDialog::createDialog: not much fun without any columns!" );
|
2005-01-05 11:37:55 +00:00
|
|
|
}
|
|
|
|
catch( const Exception& )
|
|
|
|
{
|
2018-04-02 08:58:19 +02:00
|
|
|
DBG_UNHANDLED_EXCEPTION("dbaccess");
|
2005-01-05 11:37:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( !xConnection.is() || !xColumns.is() || !m_xComposer.is() )
|
2018-03-21 10:33:23 +00:00
|
|
|
{
|
2005-01-05 11:37:55 +00:00
|
|
|
// can't create the dialog if I have improper settings
|
2019-09-15 20:41:25 +01:00
|
|
|
return nullptr;
|
2018-03-21 10:33:23 +00:00
|
|
|
}
|
2005-01-05 11:37:55 +00:00
|
|
|
|
2019-09-15 20:41:25 +01:00
|
|
|
return createComposerDialog(Application::GetFrameWeld(rParent), xConnection, xColumns);
|
2005-01-05 11:37:55 +00:00
|
|
|
}
|
|
|
|
|
2013-08-17 23:43:14 +02:00
|
|
|
// RowsetFilterDialog
|
2013-03-19 13:08:47 +02:00
|
|
|
RowsetFilterDialog::RowsetFilterDialog( const Reference< XComponentContext >& _rxORB )
|
2005-01-05 11:37:55 +00:00
|
|
|
:ComposerDialog( _rxORB )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-03-19 13:08:47 +02:00
|
|
|
IMPLEMENT_SERVICE_INFO_IMPLNAME_STATIC(RowsetFilterDialog, "com.sun.star.uno.comp.sdb.RowsetFilterDialog")
|
|
|
|
IMPLEMENT_SERVICE_INFO_SUPPORTS(RowsetFilterDialog)
|
|
|
|
IMPLEMENT_SERVICE_INFO_GETSUPPORTED1_STATIC(RowsetFilterDialog, "com.sun.star.sdb.FilterDialog")
|
|
|
|
|
2015-08-03 09:14:58 +02:00
|
|
|
css::uno::Reference< css::uno::XInterface >
|
No need to keep these whitelisted functions decorated with SAL_CALL
The only effect SAL_CALL effectively has on LO-internal code is to change non-
static member functions from __thiscall to __cdecl in MSVC (where all other
functions are __cdecl by default, anyway). (For 3rd-party code, it could be
argued that SAL_CALL is useful on function declarations in the URE stable
interface other than non-static member functions, too, in case 3rd-party code
uses a compiler switch to change the default calling convention to something
other than __cdecl. But loplugin:salcall exempts the URE stable interface,
anyway.)
One could argue that SAL_CALL, even if today it effectively only affects non-
static member functions in MSVC, could be extended in the future to affect more
functions on more platforms. However, the current code would already not
support that. For example, 3af500580b1c82eabd60335c9ebc458a3f68850c
"loplugin:salcall fix functions" changed FrameControl_createInstance in
UnoControls/source/base/registercontrols.cxx to no longer be SAL_CALL, even
though its address (in ctl_component_getFacrory, in the same file) is passed to
cppuhelper::createSingleFactory as an argument of type
cppu::ComponentInstantiation, which is a pointer to SAL_CALL function.
Change-Id: I3acbf7314a3d7868ed70e35bb5c47bc11a0b7ff6
Reviewed-on: https://gerrit.libreoffice.org/46436
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2017-12-14 08:45:02 +01:00
|
|
|
RowsetFilterDialog::Create(const css::uno::Reference< css::lang::XMultiServiceFactory >& _rxORB)
|
2013-03-19 13:08:47 +02:00
|
|
|
{
|
|
|
|
return static_cast< XServiceInfo* >(new RowsetFilterDialog( comphelper::getComponentContext(_rxORB)));
|
|
|
|
}
|
|
|
|
|
2018-10-11 17:06:02 +01:00
|
|
|
std::unique_ptr<weld::GenericDialogController> RowsetFilterDialog::createComposerDialog(weld::Window* _pParent, const Reference< XConnection >& _rxConnection, const Reference< XNameAccess >& _rxColumns )
|
2005-01-05 11:37:55 +00:00
|
|
|
{
|
2019-01-17 18:35:37 +01:00
|
|
|
return std::make_unique<DlgFilterCrit>(_pParent, m_aContext, _rxConnection, m_xComposer, _rxColumns);
|
2005-01-05 11:37:55 +00:00
|
|
|
}
|
|
|
|
|
2017-01-26 12:28:58 +01:00
|
|
|
void SAL_CALL RowsetFilterDialog::initialize( const Sequence< Any >& aArguments )
|
2012-12-12 17:18:33 +02:00
|
|
|
{
|
|
|
|
if( aArguments.getLength() == 3 )
|
|
|
|
{
|
2013-01-03 14:39:09 +02:00
|
|
|
// this is the FilterDialog::createWithQuery method
|
2015-08-03 09:14:58 +02:00
|
|
|
Reference<css::sdb::XSingleSelectQueryComposer> xQueryComposer;
|
2012-12-12 17:18:33 +02:00
|
|
|
aArguments[0] >>= xQueryComposer;
|
2015-08-03 09:14:58 +02:00
|
|
|
Reference<css::sdbc::XRowSet> xRowSet;
|
2012-12-12 17:18:33 +02:00
|
|
|
aArguments[1] >>= xRowSet;
|
2015-08-03 09:14:58 +02:00
|
|
|
Reference<css::awt::XWindow> xParentWindow;
|
2012-12-12 17:18:33 +02:00
|
|
|
aArguments[2] >>= xParentWindow;
|
2013-01-15 22:40:04 -02:00
|
|
|
setPropertyValue( "QueryComposer", makeAny( xQueryComposer ) );
|
|
|
|
setPropertyValue( "RowSet", makeAny( xRowSet ) );
|
|
|
|
setPropertyValue( "ParentWindow", makeAny( xParentWindow ) );
|
2012-12-12 17:18:33 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
ComposerDialog::initialize(aArguments);
|
|
|
|
}
|
|
|
|
|
2005-01-05 11:37:55 +00:00
|
|
|
void RowsetFilterDialog::executedDialog( sal_Int16 _nExecutionResult )
|
|
|
|
{
|
|
|
|
ComposerDialog::executedDialog( _nExecutionResult );
|
|
|
|
|
2019-09-15 20:41:25 +01:00
|
|
|
if ( _nExecutionResult && m_xDialog )
|
|
|
|
static_cast<DlgFilterCrit*>(m_xDialog.get())->BuildWherePart();
|
2005-01-05 11:37:55 +00:00
|
|
|
}
|
|
|
|
|
2013-08-17 23:43:14 +02:00
|
|
|
// RowsetOrderDialog
|
2013-03-19 13:08:47 +02:00
|
|
|
RowsetOrderDialog::RowsetOrderDialog( const Reference< XComponentContext >& _rxORB )
|
2005-01-05 11:37:55 +00:00
|
|
|
:ComposerDialog( _rxORB )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-03-19 13:08:47 +02:00
|
|
|
IMPLEMENT_SERVICE_INFO_IMPLNAME_STATIC(RowsetOrderDialog, "com.sun.star.uno.comp.sdb.RowsetOrderDialog")
|
|
|
|
IMPLEMENT_SERVICE_INFO_SUPPORTS(RowsetOrderDialog)
|
|
|
|
IMPLEMENT_SERVICE_INFO_GETSUPPORTED1_STATIC(RowsetOrderDialog, "com.sun.star.sdb.OrderDialog")
|
|
|
|
|
2015-08-03 09:14:58 +02:00
|
|
|
css::uno::Reference< css::uno::XInterface >
|
No need to keep these whitelisted functions decorated with SAL_CALL
The only effect SAL_CALL effectively has on LO-internal code is to change non-
static member functions from __thiscall to __cdecl in MSVC (where all other
functions are __cdecl by default, anyway). (For 3rd-party code, it could be
argued that SAL_CALL is useful on function declarations in the URE stable
interface other than non-static member functions, too, in case 3rd-party code
uses a compiler switch to change the default calling convention to something
other than __cdecl. But loplugin:salcall exempts the URE stable interface,
anyway.)
One could argue that SAL_CALL, even if today it effectively only affects non-
static member functions in MSVC, could be extended in the future to affect more
functions on more platforms. However, the current code would already not
support that. For example, 3af500580b1c82eabd60335c9ebc458a3f68850c
"loplugin:salcall fix functions" changed FrameControl_createInstance in
UnoControls/source/base/registercontrols.cxx to no longer be SAL_CALL, even
though its address (in ctl_component_getFacrory, in the same file) is passed to
cppuhelper::createSingleFactory as an argument of type
cppu::ComponentInstantiation, which is a pointer to SAL_CALL function.
Change-Id: I3acbf7314a3d7868ed70e35bb5c47bc11a0b7ff6
Reviewed-on: https://gerrit.libreoffice.org/46436
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2017-12-14 08:45:02 +01:00
|
|
|
RowsetOrderDialog::Create(const css::uno::Reference< css::lang::XMultiServiceFactory >& _rxORB)
|
2013-03-19 13:08:47 +02:00
|
|
|
{
|
|
|
|
return static_cast< XServiceInfo* >(new RowsetOrderDialog( comphelper::getComponentContext(_rxORB)));
|
|
|
|
}
|
2005-01-05 11:37:55 +00:00
|
|
|
|
2018-10-11 17:06:02 +01:00
|
|
|
std::unique_ptr<weld::GenericDialogController> RowsetOrderDialog::createComposerDialog(weld::Window* pParent, const Reference< XConnection >& rxConnection, const Reference< XNameAccess >& rxColumns)
|
2005-01-05 11:37:55 +00:00
|
|
|
{
|
2019-01-17 18:35:37 +01:00
|
|
|
return std::make_unique<DlgOrderCrit>(pParent, rxConnection, m_xComposer, rxColumns);
|
2005-01-05 11:37:55 +00:00
|
|
|
}
|
|
|
|
|
2017-01-26 12:28:58 +01:00
|
|
|
void SAL_CALL RowsetOrderDialog::initialize( const Sequence< Any >& aArguments )
|
2013-01-03 14:39:09 +02:00
|
|
|
{
|
2018-12-17 15:19:07 +00:00
|
|
|
if (aArguments.getLength() == 2 || aArguments.getLength() == 3)
|
2013-01-03 14:39:09 +02:00
|
|
|
{
|
2015-08-03 09:14:58 +02:00
|
|
|
Reference<css::sdb::XSingleSelectQueryComposer> xQueryComposer;
|
2013-01-03 14:39:09 +02:00
|
|
|
aArguments[0] >>= xQueryComposer;
|
2015-08-03 09:14:58 +02:00
|
|
|
Reference<css::beans::XPropertySet> xRowSet;
|
2013-01-03 14:39:09 +02:00
|
|
|
aArguments[1] >>= xRowSet;
|
2013-01-15 22:40:04 -02:00
|
|
|
setPropertyValue( "QueryComposer", makeAny( xQueryComposer ) );
|
|
|
|
setPropertyValue( "RowSet", makeAny( xRowSet ) );
|
2018-12-17 15:19:07 +00:00
|
|
|
if (aArguments.getLength() == 3)
|
|
|
|
{
|
|
|
|
Reference<css::awt::XWindow> xParentWindow;
|
|
|
|
aArguments[2] >>= xParentWindow;
|
|
|
|
setPropertyValue("ParentWindow", makeAny(xParentWindow));
|
|
|
|
}
|
2013-01-03 14:39:09 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
ComposerDialog::initialize(aArguments);
|
|
|
|
}
|
|
|
|
|
2005-01-05 11:37:55 +00:00
|
|
|
void RowsetOrderDialog::executedDialog( sal_Int16 _nExecutionResult )
|
|
|
|
{
|
|
|
|
ComposerDialog::executedDialog( _nExecutionResult );
|
|
|
|
|
2019-09-15 20:41:25 +01:00
|
|
|
if ( !m_xDialog )
|
2006-01-19 14:45:45 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
if ( _nExecutionResult )
|
2019-09-15 20:41:25 +01:00
|
|
|
static_cast<DlgOrderCrit*>(m_xDialog.get())->BuildOrderPart();
|
2005-01-05 11:37:55 +00:00
|
|
|
else if ( m_xComposer.is() )
|
2019-09-15 20:41:25 +01:00
|
|
|
m_xComposer->setOrder(static_cast<DlgOrderCrit*>(m_xDialog.get())->GetOriginalOrder());
|
2005-01-05 11:37:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace dbaui
|
|
|
|
|
2010-10-12 15:59:03 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|