fdo#46808, Adapt form::control::FilterControl UNO service to new style
The service already existed, it just did not have an IDL file Change-Id: I1ca7ab09491057c1e9c91b5bb6763b84be10b47b
This commit is contained in:
@@ -763,8 +763,16 @@ namespace frm
|
|||||||
NamedValue aValue;
|
NamedValue aValue;
|
||||||
const ::rtl::OUString* pName = NULL;
|
const ::rtl::OUString* pName = NULL;
|
||||||
const Any* pValue = NULL;
|
const Any* pValue = NULL;
|
||||||
|
Reference< XPropertySet > xControlModel;
|
||||||
|
|
||||||
for ( ; pArguments != pArgumentsEnd; ++pArguments )
|
if (aArguments.getLength() == 3
|
||||||
|
&& (aArguments[0] >>= m_xMessageParent)
|
||||||
|
&& (aArguments[1] >>= m_xFormatter)
|
||||||
|
&& (aArguments[2] >>= xControlModel))
|
||||||
|
{
|
||||||
|
initControlModel(xControlModel);
|
||||||
|
}
|
||||||
|
else for ( ; pArguments != pArgumentsEnd; ++pArguments )
|
||||||
{
|
{
|
||||||
// we recognize PropertyValues and NamedValues
|
// we recognize PropertyValues and NamedValues
|
||||||
if ( *pArguments >>= aProp )
|
if ( *pArguments >>= aProp )
|
||||||
@@ -798,65 +806,73 @@ namespace frm
|
|||||||
else if ( 0 == pName->compareToAscii( "ControlModel" ) )
|
else if ( 0 == pName->compareToAscii( "ControlModel" ) )
|
||||||
{
|
{
|
||||||
// the control model for which we act as filter control
|
// the control model for which we act as filter control
|
||||||
Reference< XPropertySet > xControlModel;
|
if ( !(*pValue >>= xControlModel ) )
|
||||||
if ( !(*pValue >>= xControlModel ) || !xControlModel.is() )
|
|
||||||
{
|
{
|
||||||
OSL_FAIL( "OFilterControl::initialize: invalid control model argument!" );
|
OSL_FAIL( "OFilterControl::initialize: invalid control model argument!" );
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
initControlModel(xControlModel);
|
||||||
// some properties which are "derived" from the control model we're working for
|
|
||||||
// ...................................................
|
|
||||||
// the field
|
|
||||||
m_xField.clear();
|
|
||||||
OSL_ENSURE( ::comphelper::hasProperty( PROPERTY_BOUNDFIELD, xControlModel ), "OFilterControl::initialize: control model needs a bound field property!" );
|
|
||||||
xControlModel->getPropertyValue( PROPERTY_BOUNDFIELD ) >>= m_xField;
|
|
||||||
|
|
||||||
// ...................................................
|
|
||||||
// filter list and control class
|
|
||||||
m_bFilterList = ::comphelper::hasProperty( PROPERTY_FILTERPROPOSAL, xControlModel ) && ::comphelper::getBOOL( xControlModel->getPropertyValue( PROPERTY_FILTERPROPOSAL ) );
|
|
||||||
if ( m_bFilterList )
|
|
||||||
m_nControlClass = FormComponentType::COMBOBOX;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sal_Int16 nClassId = ::comphelper::getINT16( xControlModel->getPropertyValue( PROPERTY_CLASSID ) );
|
|
||||||
switch (nClassId)
|
|
||||||
{
|
|
||||||
case FormComponentType::CHECKBOX:
|
|
||||||
case FormComponentType::RADIOBUTTON:
|
|
||||||
case FormComponentType::LISTBOX:
|
|
||||||
case FormComponentType::COMBOBOX:
|
|
||||||
m_nControlClass = nClassId;
|
|
||||||
if ( FormComponentType::LISTBOX == nClassId )
|
|
||||||
{
|
|
||||||
Sequence< ::rtl::OUString > aDisplayItems;
|
|
||||||
OSL_VERIFY( xControlModel->getPropertyValue( PROPERTY_STRINGITEMLIST ) >>= aDisplayItems );
|
|
||||||
Sequence< ::rtl::OUString > aValueItems;
|
|
||||||
OSL_VERIFY( xControlModel->getPropertyValue( PROPERTY_VALUE_SEQ ) >>= aValueItems );
|
|
||||||
OSL_ENSURE( aDisplayItems.getLength() == aValueItems.getLength(), "OFilterControl::initialize: inconsistent item lists!" );
|
|
||||||
for ( sal_Int32 i=0; i < ::std::min( aDisplayItems.getLength(), aValueItems.getLength() ); ++i )
|
|
||||||
m_aDisplayItemToValueItem[ aDisplayItems[i] ] = aValueItems[i];
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
m_bMultiLine = ::comphelper::hasProperty( PROPERTY_MULTILINE, xControlModel ) && ::comphelper::getBOOL( xControlModel->getPropertyValue( PROPERTY_MULTILINE ) );
|
|
||||||
m_nControlClass = FormComponentType::TEXTFIELD;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ...................................................
|
|
||||||
// the connection meta data for the form which we're working for
|
|
||||||
Reference< XChild > xModel( xControlModel, UNO_QUERY );
|
|
||||||
Reference< XRowSet > xForm;
|
|
||||||
if ( xModel.is() )
|
|
||||||
xForm = xForm.query( xModel->getParent() );
|
|
||||||
m_xConnection = ::dbtools::getConnection( xForm );
|
|
||||||
OSL_ENSURE( m_xConnection.is(), "OFilterControl::initialize: unable to determine the form's connection!" );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OFilterControl::initControlModel(Reference< XPropertySet >& xControlModel)
|
||||||
|
{
|
||||||
|
if ( !xControlModel.is() )
|
||||||
|
{
|
||||||
|
OSL_FAIL( "OFilterControl::initialize: invalid control model argument!" );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// some properties which are "derived" from the control model we're working for
|
||||||
|
// ...................................................
|
||||||
|
// the field
|
||||||
|
m_xField.clear();
|
||||||
|
OSL_ENSURE( ::comphelper::hasProperty( PROPERTY_BOUNDFIELD, xControlModel ), "OFilterControl::initialize: control model needs a bound field property!" );
|
||||||
|
xControlModel->getPropertyValue( PROPERTY_BOUNDFIELD ) >>= m_xField;
|
||||||
|
|
||||||
|
// ...................................................
|
||||||
|
// filter list and control class
|
||||||
|
m_bFilterList = ::comphelper::hasProperty( PROPERTY_FILTERPROPOSAL, xControlModel ) && ::comphelper::getBOOL( xControlModel->getPropertyValue( PROPERTY_FILTERPROPOSAL ) );
|
||||||
|
if ( m_bFilterList )
|
||||||
|
m_nControlClass = FormComponentType::COMBOBOX;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sal_Int16 nClassId = ::comphelper::getINT16( xControlModel->getPropertyValue( PROPERTY_CLASSID ) );
|
||||||
|
switch (nClassId)
|
||||||
|
{
|
||||||
|
case FormComponentType::CHECKBOX:
|
||||||
|
case FormComponentType::RADIOBUTTON:
|
||||||
|
case FormComponentType::LISTBOX:
|
||||||
|
case FormComponentType::COMBOBOX:
|
||||||
|
m_nControlClass = nClassId;
|
||||||
|
if ( FormComponentType::LISTBOX == nClassId )
|
||||||
|
{
|
||||||
|
Sequence< ::rtl::OUString > aDisplayItems;
|
||||||
|
OSL_VERIFY( xControlModel->getPropertyValue( PROPERTY_STRINGITEMLIST ) >>= aDisplayItems );
|
||||||
|
Sequence< ::rtl::OUString > aValueItems;
|
||||||
|
OSL_VERIFY( xControlModel->getPropertyValue( PROPERTY_VALUE_SEQ ) >>= aValueItems );
|
||||||
|
OSL_ENSURE( aDisplayItems.getLength() == aValueItems.getLength(), "OFilterControl::initialize: inconsistent item lists!" );
|
||||||
|
for ( sal_Int32 i=0; i < ::std::min( aDisplayItems.getLength(), aValueItems.getLength() ); ++i )
|
||||||
|
m_aDisplayItemToValueItem[ aDisplayItems[i] ] = aValueItems[i];
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
m_bMultiLine = ::comphelper::hasProperty( PROPERTY_MULTILINE, xControlModel ) && ::comphelper::getBOOL( xControlModel->getPropertyValue( PROPERTY_MULTILINE ) );
|
||||||
|
m_nControlClass = FormComponentType::TEXTFIELD;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ...................................................
|
||||||
|
// the connection meta data for the form which we're working for
|
||||||
|
Reference< XChild > xModel( xControlModel, UNO_QUERY );
|
||||||
|
Reference< XRowSet > xForm;
|
||||||
|
if ( xModel.is() )
|
||||||
|
xForm = xForm.query( xModel->getParent() );
|
||||||
|
m_xConnection = ::dbtools::getConnection( xForm );
|
||||||
|
OSL_ENSURE( m_xConnection.is(), "OFilterControl::initialize: unable to determine the form's connection!" );
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------
|
//---------------------------------------------------------------------
|
||||||
::rtl::OUString SAL_CALL OFilterControl::getImplementationName( ) throw (RuntimeException)
|
::rtl::OUString SAL_CALL OFilterControl::getImplementationName( ) throw (RuntimeException)
|
||||||
{
|
{
|
||||||
|
@@ -79,6 +79,7 @@ namespace frm
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void implInitFilterList();
|
void implInitFilterList();
|
||||||
|
void initControlModel(::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xControlModel);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
OFilterControl( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxORB );
|
OFilterControl( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxORB );
|
||||||
|
@@ -129,6 +129,9 @@ $(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,offapi/com/sun/star/embed,\
|
|||||||
OOoEmbeddedObjectFactory \
|
OOoEmbeddedObjectFactory \
|
||||||
StorageFactory \
|
StorageFactory \
|
||||||
))
|
))
|
||||||
|
$(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,offapi/com/sun/star/form/control,\
|
||||||
|
FilterControl \
|
||||||
|
))
|
||||||
$(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,offapi/com/sun/star/form/inspection,\
|
$(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,offapi/com/sun/star/form/inspection,\
|
||||||
DefaultFormComponentInspectorModel \
|
DefaultFormComponentInspectorModel \
|
||||||
))
|
))
|
||||||
|
53
offapi/com/sun/star/form/control/FilterControl.idl
Normal file
53
offapi/com/sun/star/form/control/FilterControl.idl
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
/* -*- 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_form_control_FilterControl_idl__
|
||||||
|
#define __com_sun_star_form_control_FilterControl_idl__
|
||||||
|
|
||||||
|
#include <com/sun/star/awt/XControl.idl>
|
||||||
|
#include <com/sun/star/awt/XWindow.idl>
|
||||||
|
#include <com/sun/star/util/XNumberFormatter.idl>
|
||||||
|
#include <com/sun/star/beans/XPropertySet.idl>
|
||||||
|
|
||||||
|
|
||||||
|
module com { module sun { module star { module form { module control {
|
||||||
|
|
||||||
|
|
||||||
|
/** describes a check box control which can (but not necessarily has to) be bound to a database field.
|
||||||
|
|
||||||
|
<p>The model of the control has to support the <type scope="com::sun::star::form::component">CheckBox</type>
|
||||||
|
service.</p>
|
||||||
|
|
||||||
|
@see com::sun::star::awt::UnoControl
|
||||||
|
@see com::sun::star::awt::UnoControlModel
|
||||||
|
*/
|
||||||
|
service FilterControl : com::sun::star::awt::XControl
|
||||||
|
{
|
||||||
|
createWithFormat([in] com::sun::star::awt::XWindow MessageParent,
|
||||||
|
[in] com::sun::star::util::XNumberFormatter NumberFormatter,
|
||||||
|
[in] com::sun::star::beans::XPropertySet ControlModel);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
}; }; }; }; };
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
@@ -47,6 +47,7 @@
|
|||||||
#include <com/sun/star/form/XGridControl.hpp>
|
#include <com/sun/star/form/XGridControl.hpp>
|
||||||
#include <com/sun/star/form/XLoadable.hpp>
|
#include <com/sun/star/form/XLoadable.hpp>
|
||||||
#include <com/sun/star/form/XReset.hpp>
|
#include <com/sun/star/form/XReset.hpp>
|
||||||
|
#include <com/sun/star/form/control/FilterControl.hpp>
|
||||||
#include <com/sun/star/frame/XController.hpp>
|
#include <com/sun/star/frame/XController.hpp>
|
||||||
#include <com/sun/star/sdb/ParametersRequest.hpp>
|
#include <com/sun/star/sdb/ParametersRequest.hpp>
|
||||||
#include <com/sun/star/sdb/RowChangeAction.hpp>
|
#include <com/sun/star/sdb/RowChangeAction.hpp>
|
||||||
@@ -3377,15 +3378,11 @@ void FormController::startFiltering()
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
// create a filter control
|
// create a filter control
|
||||||
Sequence< Any > aCreationArgs( 3 );
|
Reference< XControl > xFilterControl = form::control::FilterControl::createWithFormat(
|
||||||
aCreationArgs[ 0 ] <<= NamedValue( ::rtl::OUString("MessageParent"), makeAny( VCLUnoHelper::GetInterface( getDialogParentWindow() ) ) );
|
m_aContext.getUNOContext(),
|
||||||
aCreationArgs[ 1 ] <<= NamedValue( ::rtl::OUString("NumberFormatter"), makeAny( xFormatter ) );
|
VCLUnoHelper::GetInterface( getDialogParentWindow() ),
|
||||||
aCreationArgs[ 2 ] <<= NamedValue( ::rtl::OUString("ControlModel"), makeAny( xModel ) );
|
xFormatter,
|
||||||
Reference< XControl > xFilterControl(
|
xModel);
|
||||||
m_aContext.createComponentWithArguments( "com.sun.star.form.control.FilterControl", aCreationArgs ),
|
|
||||||
UNO_QUERY
|
|
||||||
);
|
|
||||||
DBG_ASSERT( xFilterControl.is(), "FormController::startFiltering: could not create a filter control!" );
|
|
||||||
|
|
||||||
if ( replaceControl( xControl, xFilterControl ) )
|
if ( replaceControl( xControl, xFilterControl ) )
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user