weld DlgFilterCrit and DlgOrderCrit

Change-Id: Icb96b47cb20a1a80877f693156a3395aba4c70d5
Reviewed-on: https://gerrit.libreoffice.org/61685
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
diff --git a/dbaccess/source/ui/browser/brwctrlr.cxx b/dbaccess/source/ui/browser/brwctrlr.cxx
index 73b9997..4fab483 100644
--- a/dbaccess/source/ui/browser/brwctrlr.cxx
+++ b/dbaccess/source/ui/browser/brwctrlr.cxx
@@ -1751,19 +1751,19 @@ void SbaXDataBrowserController::ExecuteFilterSortCrit(bool bFilter)
        Reference< XConnection> xCon(xFormSet->getPropertyValue(PROPERTY_ACTIVE_CONNECTION),UNO_QUERY);
        if(bFilter)
        {
            ScopedVclPtrInstance< DlgFilterCrit > aDlg( getBrowserView(), getORB(), xCon, xParser, m_xColumnsSupplier->getColumns() );
            if ( !aDlg->Execute() )
            DlgFilterCrit aDlg(getFrameWeld(), getORB(), xCon, xParser, m_xColumnsSupplier->getColumns());
            if (!aDlg.run())
                return; // if so we don't need to update the grid
            aDlg->BuildWherePart();
            aDlg.BuildWherePart();
        }
        else
        {
            ScopedVclPtrInstance< DlgOrderCrit > aDlg( getBrowserView(),xCon,xParser, m_xColumnsSupplier->getColumns() );
            if(!aDlg->Execute())
            DlgOrderCrit aDlg(getFrameWeld(), xCon, xParser, m_xColumnsSupplier->getColumns());
            if (!aDlg.run())
            {
                return; // if so we don't need to actualize the grid
            }
            aDlg->BuildOrderPart();
            aDlg.BuildOrderPart();
        }
    }
    catch(const SQLException& )
diff --git a/dbaccess/source/ui/dlg/queryfilter.cxx b/dbaccess/source/ui/dlg/queryfilter.cxx
index 8b98159..3c1d780 100644
--- a/dbaccess/source/ui/dlg/queryfilter.cxx
+++ b/dbaccess/source/ui/dlg/queryfilter.cxx
@@ -61,49 +61,42 @@ static void Replace_SQL_PlaceHolder(OUString& aString)
    aString = aString.replaceAll( "_", "?" );
}


DlgFilterCrit::DlgFilterCrit(vcl::Window * pParent,
DlgFilterCrit::DlgFilterCrit(weld::Window * pParent,
                             const Reference< XComponentContext >& rxContext,
                             const Reference< XConnection>& _rxConnection,
                             const Reference< XSingleSelectQueryComposer >& _rxComposer,
                             const Reference< XNameAccess>& _rxCols
                             )
    : ModalDialog(pParent, "QueryFilterDialog",
        "dbaccess/ui/queryfilterdialog.ui")

    ,m_xQueryComposer(_rxComposer)
    ,m_xColumns( _rxCols )
    ,m_xConnection( _rxConnection )
    ,m_xMetaData( _rxConnection->getMetaData() )
    ,m_aPredicateInput( rxContext, _rxConnection, getParseContext() )
                             const Reference< XNameAccess>& _rxCols)
    : GenericDialogController(pParent, "dbaccess/ui/queryfilterdialog.ui", "QueryFilterDialog")
    , m_xQueryComposer(_rxComposer)
    , m_xColumns( _rxCols )
    , m_xConnection( _rxConnection )
    , m_xMetaData( _rxConnection->getMetaData() )
    , m_aPredicateInput( rxContext, _rxConnection, getParseContext() )
    , m_xLB_WHEREFIELD1(m_xBuilder->weld_combo_box("field1"))
    , m_xLB_WHERECOMP1(m_xBuilder->weld_combo_box("cond1"))
    , m_xET_WHEREVALUE1(m_xBuilder->weld_entry("value1"))
    , m_xLB_WHERECOND2(m_xBuilder->weld_combo_box("op2"))
    , m_xLB_WHEREFIELD2(m_xBuilder->weld_combo_box("field2"))
    , m_xLB_WHERECOMP2(m_xBuilder->weld_combo_box("cond2"))
    , m_xET_WHEREVALUE2(m_xBuilder->weld_entry("value2"))
    , m_xLB_WHERECOND3(m_xBuilder->weld_combo_box("op3"))
    , m_xLB_WHEREFIELD3(m_xBuilder->weld_combo_box("field3"))
    , m_xLB_WHERECOMP3(m_xBuilder->weld_combo_box("cond3"))
    , m_xET_WHEREVALUE3(m_xBuilder->weld_entry("value3"))
{
    get(m_pLB_WHEREFIELD1, "field1");
    get(m_pLB_WHERECOMP1, "cond1");
    get(m_pET_WHEREVALUE1, "value1");

    get(m_pLB_WHERECOND2, "op2");
    get(m_pLB_WHEREFIELD2, "field2");
    get(m_pLB_WHERECOMP2, "cond2");
    get(m_pET_WHEREVALUE2, "value2");

    get(m_pLB_WHERECOND3, "op3");
    get(m_pLB_WHEREFIELD3, "field3");
    get(m_pLB_WHERECOMP3, "cond3");
    get(m_pET_WHEREVALUE3, "value3");

    //set all condition preferred width to max width
    //if all entries exist
    Size aSize(m_pLB_WHERECOMP1->get_preferred_size());
    m_pLB_WHERECOMP1->set_width_request(aSize.Width());
    m_pLB_WHERECOMP2->set_width_request(aSize.Width());
    m_pLB_WHERECOMP3->set_width_request(aSize.Width());
    const sal_Int32 nEntryCount =  m_pLB_WHERECOMP1->GetEntryCount();
    Size aSize(m_xLB_WHERECOMP1->get_preferred_size());
    m_xLB_WHERECOMP1->set_size_request(aSize.Width(), -1);
    m_xLB_WHERECOMP2->set_size_request(aSize.Width(), -1);
    m_xLB_WHERECOMP3->set_size_request(aSize.Width(), -1);
    const sal_Int32 nEntryCount =  m_xLB_WHERECOMP1->get_count();
    m_aSTR_COMPARE_OPERATORS.resize(nEntryCount);
    for (sal_Int32 i = 0; i < nEntryCount; ++i)
    {
        m_aSTR_COMPARE_OPERATORS[i] = m_pLB_WHERECOMP1->GetEntry(i);
        m_aSTR_COMPARE_OPERATORS[i] = m_xLB_WHERECOMP1->get_text(i);
    }
    m_pLB_WHERECOMP1->Clear();
    m_xLB_WHERECOMP1->clear();

    // ... also write it into the remaining fields
    Sequence< OUString> aNames = m_xColumns->getElementNames();
@@ -131,9 +124,9 @@ DlgFilterCrit::DlgFilterCrit(vcl::Window * pParent,
        {
            DBG_UNHANDLED_EXCEPTION("dbaccess");
        }
        m_pLB_WHEREFIELD1->InsertEntry( *pIter );
        m_pLB_WHEREFIELD2->InsertEntry( *pIter );
        m_pLB_WHEREFIELD3->InsertEntry( *pIter );
        m_xLB_WHEREFIELD1->append_text( *pIter );
        m_xLB_WHEREFIELD2->append_text( *pIter );
        m_xLB_WHEREFIELD3->append_text( *pIter );
    }

    Reference<XNameAccess> xSelectColumns = Reference<XColumnsSupplier>(m_xQueryComposer,UNO_QUERY)->getColumns();
@@ -154,16 +147,16 @@ DlgFilterCrit::DlgFilterCrit(vcl::Window * pParent,
            // !pColumn->IsFunction()
            if(eColumnSearch != ColumnSearch::NONE)
            {
                m_pLB_WHEREFIELD1->InsertEntry( *pIter );
                m_pLB_WHEREFIELD2->InsertEntry( *pIter );
                m_pLB_WHEREFIELD3->InsertEntry( *pIter );
                m_xLB_WHEREFIELD1->append_text( *pIter );
                m_xLB_WHEREFIELD2->append_text( *pIter );
                m_xLB_WHEREFIELD3->append_text( *pIter );
            }
        }
    }
    // initialize the listboxes with noEntry
    m_pLB_WHEREFIELD1->SelectEntryPos(0);
    m_pLB_WHEREFIELD2->SelectEntryPos(0);
    m_pLB_WHEREFIELD3->SelectEntryPos(0);
    m_xLB_WHEREFIELD1->set_active(0);
    m_xLB_WHEREFIELD2->set_active(0);
    m_xLB_WHEREFIELD3->set_active(0);

    // insert the criteria into the dialog
    Sequence<Sequence<PropertyValue > > aValues = m_xQueryComposer->getStructuredFilter();
@@ -174,45 +167,28 @@ DlgFilterCrit::DlgFilterCrit(vcl::Window * pParent,

    EnableLines();

    m_pLB_WHEREFIELD1->SetSelectHdl(LINK(this,DlgFilterCrit,ListSelectHdl));
    m_pLB_WHEREFIELD2->SetSelectHdl(LINK(this,DlgFilterCrit,ListSelectHdl));
    m_pLB_WHEREFIELD3->SetSelectHdl(LINK(this,DlgFilterCrit,ListSelectHdl));
    m_xLB_WHEREFIELD1->connect_changed(LINK(this,DlgFilterCrit,ListSelectHdl));
    m_xLB_WHEREFIELD2->connect_changed(LINK(this,DlgFilterCrit,ListSelectHdl));
    m_xLB_WHEREFIELD3->connect_changed(LINK(this,DlgFilterCrit,ListSelectHdl));

    m_pLB_WHERECOMP1->SetSelectHdl(LINK(this,DlgFilterCrit,ListSelectCompHdl));
    m_pLB_WHERECOMP2->SetSelectHdl(LINK(this,DlgFilterCrit,ListSelectCompHdl));
    m_pLB_WHERECOMP3->SetSelectHdl(LINK(this,DlgFilterCrit,ListSelectCompHdl));
    m_xLB_WHERECOMP1->connect_changed(LINK(this,DlgFilterCrit,ListSelectCompHdl));
    m_xLB_WHERECOMP2->connect_changed(LINK(this,DlgFilterCrit,ListSelectCompHdl));
    m_xLB_WHERECOMP3->connect_changed(LINK(this,DlgFilterCrit,ListSelectCompHdl));

    m_pET_WHEREVALUE1->SetLoseFocusHdl( LINK( this, DlgFilterCrit, PredicateLoseFocus ) );
    m_pET_WHEREVALUE2->SetLoseFocusHdl( LINK( this, DlgFilterCrit, PredicateLoseFocus ) );
    m_pET_WHEREVALUE3->SetLoseFocusHdl( LINK( this, DlgFilterCrit, PredicateLoseFocus ) );
    m_xET_WHEREVALUE1->connect_focus_out( LINK( this, DlgFilterCrit, PredicateLoseFocus ) );
    m_xET_WHEREVALUE2->connect_focus_out( LINK( this, DlgFilterCrit, PredicateLoseFocus ) );
    m_xET_WHEREVALUE3->connect_focus_out( LINK( this, DlgFilterCrit, PredicateLoseFocus ) );

    if ( m_pET_WHEREVALUE1->IsEnabled() )
        m_pET_WHEREVALUE1->GrabFocus();
    if (m_xET_WHEREVALUE1->get_sensitive())
        m_xET_WHEREVALUE1->grab_focus();
}

DlgFilterCrit::~DlgFilterCrit()
{
    disposeOnce();
}

void DlgFilterCrit::dispose()
{
    m_pLB_WHEREFIELD1.clear();
    m_pLB_WHERECOMP1.clear();
    m_pET_WHEREVALUE1.clear();
    m_pLB_WHERECOND2.clear();
    m_pLB_WHEREFIELD2.clear();
    m_pLB_WHERECOMP2.clear();
    m_pET_WHEREVALUE2.clear();
    m_pLB_WHERECOND3.clear();
    m_pLB_WHEREFIELD3.clear();
    m_pLB_WHERECOMP3.clear();
    m_pET_WHEREVALUE3.clear();
    ModalDialog::dispose();
}

#define LbText(x)       ((x).GetSelectedEntry())
#define LbPos(x)        ((x).GetSelectedEntryPos())
#define LbText(x)       ((x).get_active_text())
#define LbPos(x)        ((x).get_active())

sal_Int32 DlgFilterCrit::GetOSQLPredicateType( const OUString& _rSelectedPredicate ) const
{
@@ -265,7 +241,7 @@ sal_Int32 DlgFilterCrit::GetOSQLPredicateType( const OUString& _rSelectedPredica
    return nPredicateType;
}

sal_Int32 DlgFilterCrit::GetSelectionPos(sal_Int32 eType, const ListBox& rListBox)
sal_Int32 DlgFilterCrit::GetSelectionPos(sal_Int32 eType, const weld::ComboBox& rListBox)
{
    sal_Int32 nPos;
    switch(eType)
@@ -289,16 +265,16 @@ sal_Int32 DlgFilterCrit::GetSelectionPos(sal_Int32 eType, const ListBox& rListBo
            nPos = 5;
            break;
        case SQLFilterOperator::NOT_LIKE:
            nPos = rListBox.GetEntryCount() > 2 ? rListBox.GetEntryCount()-3 : 0;
            nPos = rListBox.get_count() > 2 ? rListBox.get_count()-3 : 0;
            break;
        case SQLFilterOperator::LIKE:
            nPos = rListBox.GetEntryCount() > 2 ? rListBox.GetEntryCount()-4 : 1;
            nPos = rListBox.get_count() > 2 ? rListBox.get_count()-4 : 1;
            break;
        case SQLFilterOperator::SQLNULL:
            nPos = rListBox.GetEntryCount()-2;
            nPos = rListBox.get_count()-2;
            break;
        case SQLFilterOperator::NOT_SQLNULL:
            nPos = rListBox.GetEntryCount()-1;
            nPos = rListBox.get_count()-1;
            break;
        default:
            //  TODO  What value should this be?
@@ -308,13 +284,13 @@ sal_Int32 DlgFilterCrit::GetSelectionPos(sal_Int32 eType, const ListBox& rListBo
    return nPos;
}

bool DlgFilterCrit::getCondition(const ListBox& _rField,const ListBox& _rComp,const Edit& _rValue,PropertyValue& _rFilter) const
bool DlgFilterCrit::getCondition(const weld::ComboBox& _rField,const weld::ComboBox& _rComp,const weld::Entry& _rValue,PropertyValue& _rFilter) const
{
    bool bHaving = false;
    try
    {
        OUString sTableName;
        _rFilter.Name = _rField.GetSelectedEntry();
        _rFilter.Name = _rField.get_active_text();
        Reference< XPropertySet > xColumn = getQueryColumn(_rFilter.Name);
        if ( xColumn.is() )
        {
@@ -359,11 +335,11 @@ bool DlgFilterCrit::getCondition(const ListBox& _rField,const ListBox& _rComp,co
    {
    }

    _rFilter.Handle = GetOSQLPredicateType( _rComp.GetSelectedEntry() );
    _rFilter.Handle = GetOSQLPredicateType( _rComp.get_active_text() );
    if ( SQLFilterOperator::SQLNULL != _rFilter.Handle && _rFilter.Handle != SQLFilterOperator::NOT_SQLNULL )
    {
        OUString sPredicateValue;
        m_aPredicateInput.getPredicateValue( _rValue.GetText(), getMatchingColumn( _rValue ) ) >>= sPredicateValue;
        m_aPredicateInput.getPredicateValue( _rValue.get_text(), getMatchingColumn( _rValue ) ) >>= sPredicateValue;
        if ( _rFilter.Handle == SQLFilterOperator::LIKE ||
             _rFilter.Handle == SQLFilterOperator::NOT_LIKE )
            ::Replace_OS_PlaceHolder( sPredicateValue );
@@ -428,21 +404,21 @@ Reference< XPropertySet > DlgFilterCrit::getQueryColumn( const OUString& _rField
    return xColumn;
}

Reference< XPropertySet > DlgFilterCrit::getMatchingColumn( const Edit& _rValueInput ) const
Reference< XPropertySet > DlgFilterCrit::getMatchingColumn( const weld::Entry& _rValueInput ) const
{
    // the name
    OUString sField;
    if ( &_rValueInput == m_pET_WHEREVALUE1 )
    if ( &_rValueInput == m_xET_WHEREVALUE1.get() )
    {
        sField = m_pLB_WHEREFIELD1->GetSelectedEntry();
        sField = m_xLB_WHEREFIELD1->get_active_text();
    }
    else if ( &_rValueInput == m_pET_WHEREVALUE2 )
    else if ( &_rValueInput == m_xET_WHEREVALUE2.get() )
    {
        sField = m_pLB_WHEREFIELD2->GetSelectedEntry();
        sField = m_xLB_WHEREFIELD2->get_active_text();
    }
    else if ( &_rValueInput == m_pET_WHEREVALUE3 )
    else if ( &_rValueInput == m_xET_WHEREVALUE3.get() )
    {
        sField = m_pLB_WHEREFIELD3->GetSelectedEntry();
        sField = m_xLB_WHEREFIELD3->get_active_text();
    }
    else {
        OSL_FAIL( "DlgFilterCrit::getMatchingColumn: invalid event source!" );
@@ -452,17 +428,17 @@ Reference< XPropertySet > DlgFilterCrit::getMatchingColumn( const Edit& _rValueI
    return getColumn( sField );
}

IMPL_LINK( DlgFilterCrit, PredicateLoseFocus, Control&, rControl, void )
IMPL_LINK( DlgFilterCrit, PredicateLoseFocus, weld::Widget&, rControl, void )
{
    Edit* _pField = static_cast<Edit*>(&rControl);
    weld::Entry& rField = dynamic_cast<weld::Entry&>(rControl);
    // retrieve the field affected
    Reference< XPropertySet> xColumn( getMatchingColumn( *_pField ) );
    Reference< XPropertySet> xColumn(getMatchingColumn(rField));
    // and normalize its content
    if ( xColumn.is() )
    {
        OUString sText( _pField->GetText() );
        m_aPredicateInput.normalizePredicateString( sText, xColumn );
        _pField->SetText( sText );
        OUString sText(rField.get_text());
        m_aPredicateInput.normalizePredicateString(sText, xColumn);
        rField.set_text(sText);
    }
}

@@ -478,29 +454,29 @@ void DlgFilterCrit::SetLine( int nIdx, const PropertyValue& _rItem, bool _bOr )
    Reference< XPropertySet > xColumn = getColumn( _rItem.Name );

    // to make sure that we only set first three
    ListBox* pColumnListControl =  nullptr;
    ListBox* pPredicateListControl = nullptr;
    Edit* pPredicateValueControl = nullptr;
    weld::ComboBox* pColumnListControl =  nullptr;
    weld::ComboBox* pPredicateListControl = nullptr;
    weld::Entry* pPredicateValueControl = nullptr;
    switch( nIdx )
    {
        case 0:
            pColumnListControl = m_pLB_WHEREFIELD1;
            pPredicateListControl = m_pLB_WHERECOMP1;
            pPredicateValueControl = m_pET_WHEREVALUE1;
            pColumnListControl = m_xLB_WHEREFIELD1.get();
            pPredicateListControl = m_xLB_WHERECOMP1.get();
            pPredicateValueControl = m_xET_WHEREVALUE1.get();
            break;
        case 1:
            m_pLB_WHERECOND2->SelectEntryPos( _bOr ? 1 : 0 );
            m_xLB_WHERECOND2->set_active( _bOr ? 1 : 0 );

            pColumnListControl = m_pLB_WHEREFIELD2;
            pPredicateListControl = m_pLB_WHERECOMP2;
            pPredicateValueControl = m_pET_WHEREVALUE2;
            pColumnListControl = m_xLB_WHEREFIELD2.get();
            pPredicateListControl = m_xLB_WHERECOMP2.get();
            pPredicateValueControl = m_xET_WHEREVALUE2.get();
            break;
        case 2:
            m_pLB_WHERECOND3->SelectEntryPos( _bOr ? 1 : 0 );
            m_xLB_WHERECOND3->set_active( _bOr ? 1 : 0 );

            pColumnListControl = m_pLB_WHEREFIELD3;
            pPredicateListControl = m_pLB_WHERECOMP3;
            pPredicateValueControl = m_pET_WHEREVALUE3;
            pColumnListControl = m_xLB_WHEREFIELD3.get();
            pPredicateListControl = m_xLB_WHERECOMP3.get();
            pPredicateValueControl = m_xET_WHEREVALUE3.get();
            break;
    }

@@ -516,154 +492,154 @@ void DlgFilterCrit::SetLine( int nIdx, const PropertyValue& _rItem, bool _bOr )
        ListSelectHdl( *pColumnListControl );

        // select the appropriate condition
        pPredicateListControl->SelectEntryPos( GetSelectionPos( static_cast<sal_Int32>(_rItem.Handle), *pPredicateListControl ) );
        pPredicateListControl->set_active( GetSelectionPos( static_cast<sal_Int32>(_rItem.Handle), *pPredicateListControl ) );

        // initially normalize this value
        OUString aString( aStr );
        m_aPredicateInput.normalizePredicateString( aString, xColumn );
        pPredicateValueControl->SetText( aString );
        pPredicateValueControl->set_text( aString );
    }
}

void DlgFilterCrit::SelectField( ListBox& rBox, const OUString& rField )
void DlgFilterCrit::SelectField(weld::ComboBox& rBox, const OUString& rField)
{
    const sal_Int32 nCnt = rBox.GetEntryCount();
    const sal_Int32 nCnt = rBox.get_count();

    for( sal_Int32 i=0 ; i<nCnt ; i++ )
    {
        if(rBox.GetEntry(i) == rField)
        if (rBox.get_text(i) == rField)
        {
            rBox.SelectEntryPos(i);
            rBox.set_active(i);
            return;
        }
    }

    rBox.SelectEntryPos(0);
    rBox.set_active(0);
}

void DlgFilterCrit::EnableLines()
{
    // enabling/disabling of whole lines
    if( LbPos(*m_pLB_WHEREFIELD1) == 0 )
    if( LbPos(*m_xLB_WHEREFIELD1) == 0 )
    {
        m_pLB_WHEREFIELD2->Disable();
        m_pLB_WHERECOND2->Disable();
        m_pLB_WHERECOMP2->Disable();
        m_pET_WHEREVALUE2->Disable();
        m_xLB_WHEREFIELD2->set_sensitive(false);
        m_xLB_WHERECOND2->set_sensitive(false);
        m_xLB_WHERECOMP2->set_sensitive(false);
        m_xET_WHEREVALUE2->set_sensitive(false);

        m_pLB_WHEREFIELD3->Disable();
        m_pLB_WHERECOND3->Disable();
        m_pLB_WHERECOMP3->Disable();
        m_pET_WHEREVALUE3->Disable();
        m_xLB_WHEREFIELD3->set_sensitive(false);
        m_xLB_WHERECOND3->set_sensitive(false);
        m_xLB_WHERECOMP3->set_sensitive(false);
        m_xET_WHEREVALUE3->set_sensitive(false);
    }
    else
    {
        m_pLB_WHEREFIELD2->Enable();
        m_pLB_WHERECOND2->Enable();
        m_pLB_WHERECOMP2->Enable();
        m_pET_WHEREVALUE2->Enable();
        m_xLB_WHEREFIELD2->set_sensitive(true);
        m_xLB_WHERECOND2->set_sensitive(true);
        m_xLB_WHERECOMP2->set_sensitive(true);
        m_xET_WHEREVALUE2->set_sensitive(true);

        m_pLB_WHEREFIELD3->Enable();
        m_pLB_WHERECOND3->Enable();
        m_pLB_WHERECOMP3->Enable();
        m_pET_WHEREVALUE3->Enable();
        m_xLB_WHEREFIELD3->set_sensitive(true);
        m_xLB_WHERECOND3->set_sensitive(true);
        m_xLB_WHERECOMP3->set_sensitive(true);
        m_xET_WHEREVALUE3->set_sensitive(true);
    }

    if( LbPos(*m_pLB_WHEREFIELD2) == 0 )
    if( LbPos(*m_xLB_WHEREFIELD2) == 0 )
    {
        m_pLB_WHEREFIELD3->Disable();
        m_pLB_WHERECOND3->Disable();
        m_pLB_WHERECOMP3->Disable();
        m_pET_WHEREVALUE3->Disable();
        m_xLB_WHEREFIELD3->set_sensitive(false);
        m_xLB_WHERECOND3->set_sensitive(false);
        m_xLB_WHERECOMP3->set_sensitive(false);
        m_xET_WHEREVALUE3->set_sensitive(false);
    }
    else
    {
        m_pLB_WHEREFIELD3->Enable();
        m_pLB_WHERECOND3->Enable();
        m_pLB_WHERECOMP3->Enable();
        m_pET_WHEREVALUE3->Enable();
        m_xLB_WHEREFIELD3->set_sensitive(true);
        m_xLB_WHERECOND3->set_sensitive(true);
        m_xLB_WHERECOMP3->set_sensitive(true);
        m_xET_WHEREVALUE3->set_sensitive(true);
    }

    // comparison field equal to NOENTRY
    if( LbPos(*m_pLB_WHEREFIELD1) == 0 )
    if( LbPos(*m_xLB_WHEREFIELD1) == 0 )
    {
        m_pLB_WHERECOMP1->Disable();
        m_pET_WHEREVALUE1->Disable();
        m_xLB_WHERECOMP1->set_sensitive(false);
        m_xET_WHEREVALUE1->set_sensitive(false);
    }
    else
    {
        m_pLB_WHEREFIELD1->Enable();
        m_pLB_WHERECOMP1->Enable();
        m_pET_WHEREVALUE1->Enable();
        m_xLB_WHEREFIELD1->set_sensitive(true);
        m_xLB_WHERECOMP1->set_sensitive(true);
        m_xET_WHEREVALUE1->set_sensitive(true);
    }

    if( LbPos(*m_pLB_WHEREFIELD2) == 0 )
    if( LbPos(*m_xLB_WHEREFIELD2) == 0 )
    {
        m_pLB_WHERECOND2->Disable();
        m_pLB_WHERECOMP2->Disable();
        m_pET_WHEREVALUE2->Disable();
        m_xLB_WHERECOND2->set_sensitive(false);
        m_xLB_WHERECOMP2->set_sensitive(false);
        m_xET_WHEREVALUE2->set_sensitive(false);
    }
    else
    {
        m_pLB_WHERECOND2->Enable();
        m_pLB_WHEREFIELD2->Enable();
        m_pLB_WHERECOMP2->Enable();
        m_pET_WHEREVALUE2->Enable();
        m_xLB_WHERECOND2->set_sensitive(true);
        m_xLB_WHEREFIELD2->set_sensitive(true);
        m_xLB_WHERECOMP2->set_sensitive(true);
        m_xET_WHEREVALUE2->set_sensitive(true);
    }

    if( LbPos(*m_pLB_WHEREFIELD3) == 0 )
    if( LbPos(*m_xLB_WHEREFIELD3) == 0 )
    {
        m_pLB_WHERECOND3->Disable();
        m_pLB_WHERECOMP3->Disable();
        m_pET_WHEREVALUE3->Disable();
        m_xLB_WHERECOND3->set_sensitive(false);
        m_xLB_WHERECOMP3->set_sensitive(false);
        m_xET_WHEREVALUE3->set_sensitive(false);
    }
    else
    {
        m_pLB_WHERECOND3->Enable();
        m_pLB_WHERECOND3->Enable();
        m_pLB_WHEREFIELD3->Enable();
        m_pLB_WHERECOMP3->Enable();
        m_pET_WHEREVALUE3->Enable();
        m_xLB_WHERECOND3->set_sensitive(true);
        m_xLB_WHERECOND3->set_sensitive(true);
        m_xLB_WHEREFIELD3->set_sensitive(true);
        m_xLB_WHERECOMP3->set_sensitive(true);
        m_xET_WHEREVALUE3->set_sensitive(true);
    }

    // comparison operator equal to ISNULL or ISNOTNULL
    if(m_pLB_WHERECOMP1->GetEntryCount() > 2 &&
        ((LbPos(*m_pLB_WHERECOMP1) == m_pLB_WHERECOMP1->GetEntryCount()-1) ||
         (LbPos(*m_pLB_WHERECOMP1) == m_pLB_WHERECOMP1->GetEntryCount()-2)) )
        m_pET_WHEREVALUE1->Disable();
    if(m_xLB_WHERECOMP1->get_count() > 2 &&
        ((LbPos(*m_xLB_WHERECOMP1) == m_xLB_WHERECOMP1->get_count()-1) ||
         (LbPos(*m_xLB_WHERECOMP1) == m_xLB_WHERECOMP1->get_count()-2)) )
        m_xET_WHEREVALUE1->set_sensitive(false);

    if(m_pLB_WHERECOMP2->GetEntryCount() > 2 &&
        ((LbPos(*m_pLB_WHERECOMP2) == m_pLB_WHERECOMP2->GetEntryCount()-1) ||
         (LbPos(*m_pLB_WHERECOMP2) == m_pLB_WHERECOMP2->GetEntryCount()-2)) )
        m_pET_WHEREVALUE2->Disable();
    if(m_xLB_WHERECOMP2->get_count() > 2 &&
        ((LbPos(*m_xLB_WHERECOMP2) == m_xLB_WHERECOMP2->get_count()-1) ||
         (LbPos(*m_xLB_WHERECOMP2) == m_xLB_WHERECOMP2->get_count()-2)) )
        m_xET_WHEREVALUE2->set_sensitive(false);

    if(m_pLB_WHERECOMP3->GetEntryCount() > 2 &&
        ((LbPos(*m_pLB_WHERECOMP3) == m_pLB_WHERECOMP3->GetEntryCount()-1) ||
         (LbPos(*m_pLB_WHERECOMP3) == m_pLB_WHERECOMP3->GetEntryCount()-2)) )
        m_pET_WHEREVALUE3->Disable();
    if(m_xLB_WHERECOMP3->get_count() > 2 &&
        ((LbPos(*m_xLB_WHERECOMP3) == m_xLB_WHERECOMP3->get_count()-1) ||
         (LbPos(*m_xLB_WHERECOMP3) == m_xLB_WHERECOMP3->get_count()-2)) )
        m_xET_WHEREVALUE3->set_sensitive(false);
}

IMPL_LINK( DlgFilterCrit, ListSelectHdl, ListBox&, rListBox, void )
IMPL_LINK( DlgFilterCrit, ListSelectHdl, weld::ComboBox&, rListBox, void )
{
    OUString aName;
    ListBox* pComp;
    if(&rListBox == m_pLB_WHEREFIELD1)
    weld::ComboBox* pComp;
    if(&rListBox == m_xLB_WHEREFIELD1.get())
    {
        aName = LbText(*m_pLB_WHEREFIELD1);
        pComp = m_pLB_WHERECOMP1;
        aName = LbText(*m_xLB_WHEREFIELD1);
        pComp = m_xLB_WHERECOMP1.get();
    }
    else if(&rListBox == m_pLB_WHEREFIELD2)
    else if(&rListBox == m_xLB_WHEREFIELD2.get())
    {
        aName = LbText(*m_pLB_WHEREFIELD2);
        pComp = m_pLB_WHERECOMP2;
        aName = LbText(*m_xLB_WHEREFIELD2);
        pComp = m_xLB_WHERECOMP2.get();
    }
    else
    {
        aName = LbText(*m_pLB_WHEREFIELD3);
        pComp = m_pLB_WHERECOMP3;
        aName = LbText(*m_xLB_WHEREFIELD3);
        pComp = m_xLB_WHERECOMP3.get();
    }

    pComp->Clear();
    pComp->clear();

    Reference<XPropertySet> xColumn = getColumn(aName);
    if ( xColumn.is() )
@@ -675,32 +651,32 @@ IMPL_LINK( DlgFilterCrit, ListSelectHdl, ListBox&, rListBox, void )
        if(eColumnSearch  == ColumnSearch::FULL)
        {
            for(size_t i=0;i < m_aSTR_COMPARE_OPERATORS.size(); i++)
                pComp->InsertEntry(m_aSTR_COMPARE_OPERATORS[i]);
                pComp->append_text(m_aSTR_COMPARE_OPERATORS[i]);
        }
        else if(eColumnSearch == ColumnSearch::CHAR)
        {
            for(sal_Int32 i=6; i<10; i++)
                pComp->InsertEntry(m_aSTR_COMPARE_OPERATORS[i]);
                pComp->append_text(m_aSTR_COMPARE_OPERATORS[i]);
        }
        else if(eColumnSearch == ColumnSearch::BASIC)
        {
            size_t i;
            for( i = 0; i < 6; i++ )
                pComp->InsertEntry(m_aSTR_COMPARE_OPERATORS[i]);
                pComp->append_text(m_aSTR_COMPARE_OPERATORS[i]);
            for(i=8; i < m_aSTR_COMPARE_OPERATORS.size(); ++i)
                pComp->InsertEntry(m_aSTR_COMPARE_OPERATORS[i]);
                pComp->append_text(m_aSTR_COMPARE_OPERATORS[i]);
        }
        else
        {
            OSL_FAIL("DlgFilterCrit::ListSelectHdl: This column should not exist at all.");
        }
    }
    pComp->SelectEntryPos(0);
    pComp->set_active(0);

    EnableLines();
}

IMPL_LINK_NOARG( DlgFilterCrit, ListSelectCompHdl, ListBox&, void )
IMPL_LINK_NOARG(DlgFilterCrit, ListSelectCompHdl, weld::ComboBox&, void)
{
    EnableLines();
}
@@ -711,10 +687,10 @@ void DlgFilterCrit::BuildWherePart()
    aFilter.realloc(1);
    aHaving.realloc(1);

    if( LbPos(*m_pLB_WHEREFIELD1) != 0 )
    if( LbPos(*m_xLB_WHEREFIELD1) != 0 )
    {
        PropertyValue aValue;
        if ( getCondition(*m_pLB_WHEREFIELD1,*m_pLB_WHERECOMP1,*m_pET_WHEREVALUE1,aValue) )
        if ( getCondition(*m_xLB_WHEREFIELD1,*m_xLB_WHERECOMP1,*m_xET_WHEREVALUE1,aValue) )
        {
            aHaving[0].realloc(1);
            aHaving[0][0] = aValue;
@@ -726,14 +702,14 @@ void DlgFilterCrit::BuildWherePart()
        }
    }

    if( LbPos(*m_pLB_WHEREFIELD2) != 0 )
    if( LbPos(*m_xLB_WHEREFIELD2) != 0 )
    {
        PropertyValue aValue;
        Sequence<Sequence<PropertyValue> >& _rValues = aFilter;
        if ( getCondition(*m_pLB_WHEREFIELD2,*m_pLB_WHERECOMP2,*m_pET_WHEREVALUE2,aValue) )
        if ( getCondition(*m_xLB_WHEREFIELD2,*m_xLB_WHERECOMP2,*m_xET_WHEREVALUE2,aValue) )
            _rValues = aHaving;
        PropertyValue* pPos = nullptr;
        if ( m_pLB_WHERECOND2->GetSelectedEntryPos() )
        if ( m_xLB_WHERECOND2->get_active() )
        {
            sal_Int32 nPos = _rValues.getLength();
            _rValues.realloc( nPos + 1);
@@ -750,14 +726,14 @@ void DlgFilterCrit::BuildWherePart()
        *pPos = aValue;
    }

    if( LbPos(*m_pLB_WHEREFIELD3) != 0 )
    if( LbPos(*m_xLB_WHEREFIELD3) != 0 )
    {
        PropertyValue aValue;
        Sequence<Sequence<PropertyValue> >& _rValues = aFilter;
        if ( getCondition(*m_pLB_WHEREFIELD3,*m_pLB_WHERECOMP3,*m_pET_WHEREVALUE3,aValue) )
        if ( getCondition(*m_xLB_WHEREFIELD3,*m_xLB_WHERECOMP3,*m_xET_WHEREVALUE3,aValue) )
            _rValues = aHaving;
        PropertyValue* pPos = nullptr;
        if ( m_pLB_WHERECOND3->GetSelectedEntryPos() )
        if (m_xLB_WHERECOND3->get_active())
        {
            sal_Int32 nPos = _rValues.getLength();
            _rValues.realloc( nPos + 1);
diff --git a/dbaccess/source/ui/dlg/queryorder.cxx b/dbaccess/source/ui/dlg/queryorder.cxx
index a5d0237..9ee58ca 100644
--- a/dbaccess/source/ui/dlg/queryorder.cxx
+++ b/dbaccess/source/ui/dlg/queryorder.cxx
@@ -44,47 +44,39 @@ using namespace ::com::sun::star::sdbcx;
using namespace ::com::sun::star::beans;


DlgOrderCrit::DlgOrderCrit(vcl::Window * pParent,
DlgOrderCrit::DlgOrderCrit(weld::Window * pParent,
    const Reference< XConnection>& _rxConnection,
    const Reference< XSingleSelectQueryComposer >& _rxComposer,
    const Reference< XNameAccess>& _rxCols)
    : ModalDialog(pParent, "SortDialog", "dbaccess/ui/sortdialog.ui")
    : GenericDialogController(pParent, "dbaccess/ui/sortdialog.ui", "SortDialog")
    , m_xQueryComposer(_rxComposer)
    , m_xColumns(_rxCols)
    , m_xConnection(_rxConnection)
    , m_xLB_ORDERFIELD1(m_xBuilder->weld_combo_box("field1"))
    , m_xLB_ORDERVALUE1(m_xBuilder->weld_combo_box("value1"))
    , m_xLB_ORDERFIELD2(m_xBuilder->weld_combo_box("field2"))
    , m_xLB_ORDERVALUE2(m_xBuilder->weld_combo_box("value2"))
    , m_xLB_ORDERFIELD3(m_xBuilder->weld_combo_box("field3"))
    , m_xLB_ORDERVALUE3(m_xBuilder->weld_combo_box("value3"))
{
    m_aColumnList[0] = m_xLB_ORDERFIELD1.get();
    m_aColumnList[1] = m_xLB_ORDERFIELD2.get();
    m_aColumnList[2] = m_xLB_ORDERFIELD3.get();

    get(m_pLB_ORDERFIELD1, "field1");
    get(m_pLB_ORDERVALUE1, "value1");
    get(m_pLB_ORDERFIELD2, "field2");
    get(m_pLB_ORDERVALUE2, "value2");
    get(m_pLB_ORDERFIELD3, "field3");
    get(m_pLB_ORDERVALUE3, "value3");

    AllSettings aSettings( GetSettings() );
    StyleSettings aStyle( aSettings.GetStyleSettings() );
    aStyle.SetAutoMnemonic( false );
    aSettings.SetStyleSettings( aStyle );
    SetSettings( aSettings );

    m_aColumnList[0] = m_pLB_ORDERFIELD1;
    m_aColumnList[1] = m_pLB_ORDERFIELD2;
    m_aColumnList[2] = m_pLB_ORDERFIELD3;

    m_aValueList[0] = m_pLB_ORDERVALUE1;
    m_aValueList[1] = m_pLB_ORDERVALUE2;
    m_aValueList[2] = m_pLB_ORDERVALUE3;
    m_aValueList[0] = m_xLB_ORDERVALUE1.get();
    m_aValueList[1] = m_xLB_ORDERVALUE2.get();
    m_aValueList[2] = m_xLB_ORDERVALUE3.get();

    OUString aSTR_NOENTRY(DBA_RES(STR_VALUE_NONE));
    for (VclPtr<ListBox> & j : m_aColumnList)
    for (auto j : m_aColumnList)
    {
        j->InsertEntry( aSTR_NOENTRY );
        j->append_text(aSTR_NOENTRY);
    }

    for (int j=0; j < DOG_ROWS; ++j)
    {
        m_aColumnList[j]->SelectEntryPos(0);
        m_aValueList[j]->SelectEntryPos(0);
        m_aColumnList[j]->set_active(0);
        m_aValueList[j]->set_active(0);
    }
    try
    {
@@ -104,9 +96,9 @@ DlgOrderCrit::DlgOrderCrit(vcl::Window * pParent,
                sal_Int32 eColumnSearch = dbtools::getSearchColumnFlag(m_xConnection,nDataType);
                if(eColumnSearch != ColumnSearch::NONE)
                {
                    for (VclPtr<ListBox> & j : m_aColumnList)
                    for (auto j : m_aColumnList)
                    {
                        j->InsertEntry(*pIter);
                        j->append_text(*pIter);
                    }
                }
            }
@@ -121,29 +113,15 @@ DlgOrderCrit::DlgOrderCrit(vcl::Window * pParent,
    }
    EnableLines();

    m_pLB_ORDERFIELD1->SetSelectHdl(LINK(this,DlgOrderCrit,FieldListSelectHdl));
    m_pLB_ORDERFIELD2->SetSelectHdl(LINK(this,DlgOrderCrit,FieldListSelectHdl));
    m_xLB_ORDERFIELD1->connect_changed(LINK(this,DlgOrderCrit,FieldListSelectHdl));
    m_xLB_ORDERFIELD2->connect_changed(LINK(this,DlgOrderCrit,FieldListSelectHdl));
}

DlgOrderCrit::~DlgOrderCrit()
{
    disposeOnce();
}

void DlgOrderCrit::dispose()
{
    m_pLB_ORDERFIELD1.clear();
    m_pLB_ORDERVALUE1.clear();
    m_pLB_ORDERFIELD2.clear();
    m_pLB_ORDERVALUE2.clear();
    m_pLB_ORDERFIELD3.clear();
    m_pLB_ORDERVALUE3.clear();
    for (auto& a : m_aColumnList) a.clear();
    for (auto& a : m_aValueList) a.clear();
    ModalDialog::dispose();
}

IMPL_LINK_NOARG( DlgOrderCrit, FieldListSelectHdl, ListBox&, void )
IMPL_LINK_NOARG( DlgOrderCrit, FieldListSelectHdl, weld::ComboBox&, void )
{
    EnableLines();
}
@@ -170,8 +148,8 @@ void DlgOrderCrit::impl_initializeOrderList_nothrow()
            xColumn->getPropertyValue( sNameProperty ) >>= sColumnName;
            xColumn->getPropertyValue( sAscendingProperty ) >>= bIsAscending;

            m_aColumnList[i]->SelectEntry( sColumnName );
            m_aValueList[i]->SelectEntryPos( bIsAscending ? 0 : 1 );
            m_aColumnList[i]->set_active_text(sColumnName);
            m_aValueList[i]->set_active(bIsAscending ? 0 : 1);
        }
    }
    catch( const Exception& )
@@ -183,32 +161,32 @@ void DlgOrderCrit::impl_initializeOrderList_nothrow()
void DlgOrderCrit::EnableLines()
{

    if ( m_pLB_ORDERFIELD1->GetSelectedEntryPos() == 0 )
    if ( m_xLB_ORDERFIELD1->get_active() == 0 )
    {
        m_pLB_ORDERFIELD2->Disable();
        m_pLB_ORDERVALUE2->Disable();
        m_xLB_ORDERFIELD2->set_sensitive(false);
        m_xLB_ORDERVALUE2->set_sensitive(false);

        m_pLB_ORDERFIELD2->SelectEntryPos( 0 );
        m_pLB_ORDERVALUE2->SelectEntryPos( 0 );
        m_xLB_ORDERFIELD2->set_active( 0 );
        m_xLB_ORDERVALUE2->set_active( 0 );
    }
    else
    {
        m_pLB_ORDERFIELD2->Enable();
        m_pLB_ORDERVALUE2->Enable();
        m_xLB_ORDERFIELD2->set_sensitive(true);
        m_xLB_ORDERVALUE2->set_sensitive(true);
    }

    if ( m_pLB_ORDERFIELD2->GetSelectedEntryPos() == 0 )
    if ( m_xLB_ORDERFIELD2->get_active() == 0 )
    {
        m_pLB_ORDERFIELD3->Disable();
        m_pLB_ORDERVALUE3->Disable();
        m_xLB_ORDERFIELD3->set_sensitive(false);
        m_xLB_ORDERVALUE3->set_sensitive(false);

        m_pLB_ORDERFIELD3->SelectEntryPos( 0 );
        m_pLB_ORDERVALUE3->SelectEntryPos( 0 );
        m_xLB_ORDERFIELD3->set_active( 0 );
        m_xLB_ORDERVALUE3->set_active( 0 );
    }
    else
    {
        m_pLB_ORDERFIELD3->Enable();
        m_pLB_ORDERVALUE3->Enable();
        m_xLB_ORDERFIELD3->set_sensitive(true);
        m_xLB_ORDERVALUE3->set_sensitive(true);
    }
}

@@ -222,14 +200,14 @@ OUString DlgOrderCrit::GetOrderList( ) const
    OUStringBuffer sOrder;
    for( sal_uInt16 i=0 ; i<DOG_ROWS; i++ )
    {
        if(m_aColumnList[i]->GetSelectedEntryPos() != 0)
        if (m_aColumnList[i]->get_active() != 0)
        {
            if(!sOrder.isEmpty())
                sOrder.append(",");

            OUString sName = m_aColumnList[i]->GetSelectedEntry();
            OUString sName = m_aColumnList[i]->get_active_text();
            sOrder.append(::dbtools::quoteName(sQuote,sName));
            if(m_aValueList[i]->GetSelectedEntryPos())
            if (m_aValueList[i]->get_active())
                sOrder.append(" DESC ");
            else
                sOrder.append(" ASC ");
diff --git a/dbaccess/source/ui/inc/queryfilter.hxx b/dbaccess/source/ui/inc/queryfilter.hxx
index 1c4d46b..b7917fd 100644
--- a/dbaccess/source/ui/inc/queryfilter.hxx
+++ b/dbaccess/source/ui/inc/queryfilter.hxx
@@ -20,15 +20,7 @@
#ifndef INCLUDED_DBACCESS_SOURCE_UI_INC_QUERYFILTER_HXX
#define INCLUDED_DBACCESS_SOURCE_UI_INC_QUERYFILTER_HXX

#include <vcl/dialog.hxx>

#include <vcl/lstbox.hxx>

#include <vcl/edit.hxx>

#include <vcl/fixed.hxx>

#include <vcl/button.hxx>
#include <vcl/weld.hxx>
#include <connectivity/sqliterator.hxx>

#include <connectivity/predicateinput.hxx>
@@ -63,24 +55,10 @@ namespace com
// DlgFilterCrit
namespace dbaui
{
    class DlgFilterCrit final :public ModalDialog
                        ,public ::svxform::OParseContextClient
    class DlgFilterCrit final : public weld::GenericDialogController
                              , public ::svxform::OParseContextClient
    {
    private:
        VclPtr<ListBox>        m_pLB_WHEREFIELD1;
        VclPtr<ListBox>        m_pLB_WHERECOMP1;
        VclPtr<Edit>           m_pET_WHEREVALUE1;

        VclPtr<ListBox>        m_pLB_WHERECOND2;
        VclPtr<ListBox>        m_pLB_WHEREFIELD2;
        VclPtr<ListBox>        m_pLB_WHERECOMP2;
        VclPtr<Edit>           m_pET_WHEREVALUE2;

        VclPtr<ListBox>        m_pLB_WHERECOND3;
        VclPtr<ListBox>        m_pLB_WHEREFIELD3;
        VclPtr<ListBox>        m_pLB_WHERECOMP3;
        VclPtr<Edit>           m_pET_WHEREVALUE3;

        std::vector<OUString>  m_aSTR_COMPARE_OPERATORS;

        css::uno::Reference< css::sdb::XSingleSelectQueryComposer>    m_xQueryComposer;
@@ -90,35 +68,47 @@ namespace dbaui

        ::dbtools::OPredicateInputController    m_aPredicateInput;

        static void     SelectField( ListBox& rBox, const OUString& rField );
        DECL_LINK( ListSelectHdl, ListBox&, void );
        DECL_LINK( ListSelectCompHdl, ListBox&, void );
        std::unique_ptr<weld::ComboBox> m_xLB_WHEREFIELD1;
        std::unique_ptr<weld::ComboBox> m_xLB_WHERECOMP1;
        std::unique_ptr<weld::Entry> m_xET_WHEREVALUE1;

        std::unique_ptr<weld::ComboBox> m_xLB_WHERECOND2;
        std::unique_ptr<weld::ComboBox> m_xLB_WHEREFIELD2;
        std::unique_ptr<weld::ComboBox> m_xLB_WHERECOMP2;
        std::unique_ptr<weld::Entry> m_xET_WHEREVALUE2;

        std::unique_ptr<weld::ComboBox> m_xLB_WHERECOND3;
        std::unique_ptr<weld::ComboBox> m_xLB_WHEREFIELD3;
        std::unique_ptr<weld::ComboBox> m_xLB_WHERECOMP3;
        std::unique_ptr<weld::Entry> m_xET_WHEREVALUE3;

        static void SelectField(weld::ComboBox& rBox, const OUString& rField);
        DECL_LINK(ListSelectHdl, weld::ComboBox&, void);
        DECL_LINK(ListSelectCompHdl, weld::ComboBox&, void);

        void            SetLine( int nIdx, const css::beans::PropertyValue& _rItem, bool _bOr );
        void            EnableLines();
        sal_Int32       GetOSQLPredicateType( const OUString& _rSelectedPredicate ) const;
        static sal_Int32  GetSelectionPos(sal_Int32 eType, const ListBox& rListBox);
        bool            getCondition(const ListBox& _rField, const ListBox& _rComp, const Edit& _rValue, css::beans::PropertyValue& _rFilter) const;
        static sal_Int32  GetSelectionPos(sal_Int32 eType, const weld::ComboBox& rListBox);
        bool            getCondition(const weld::ComboBox& _rField, const weld::ComboBox& _rComp, const weld::Entry& _rValue, css::beans::PropertyValue& _rFilter) const;
        void            fillLines(int &i, const css::uno::Sequence< css::uno::Sequence< css::beans::PropertyValue > >& _aValues);

        css::uno::Reference< css::beans::XPropertySet > getMatchingColumn( const Edit& _rValueInput ) const;
        css::uno::Reference< css::beans::XPropertySet > getMatchingColumn( const weld::Entry& _rValueInput ) const;
        css::uno::Reference< css::beans::XPropertySet > getColumn( const OUString& _rFieldName ) const;
        css::uno::Reference< css::beans::XPropertySet > getQueryColumn( const OUString& _rFieldName ) const;

    public:
        DlgFilterCrit(  vcl::Window * pParent,
                        const css::uno::Reference< css::uno::XComponentContext >& rxContext,
                        const css::uno::Reference< css::sdbc::XConnection>& _rxConnection,
                        const css::uno::Reference< css::sdb::XSingleSelectQueryComposer>& _rxComposer,
                        const css::uno::Reference< css::container::XNameAccess>& _rxCols
                    );
        DlgFilterCrit(weld::Window * pParent,
                      const css::uno::Reference< css::uno::XComponentContext >& rxContext,
                      const css::uno::Reference< css::sdbc::XConnection>& _rxConnection,
                      const css::uno::Reference< css::sdb::XSingleSelectQueryComposer>& _rxComposer,
                      const css::uno::Reference< css::container::XNameAccess>& _rxCols);
        virtual ~DlgFilterCrit() override;
        virtual void dispose() override;

        void            BuildWherePart();

    private:
        DECL_LINK( PredicateLoseFocus, Control&, void );
        DECL_LINK(PredicateLoseFocus, weld::Widget&, void);
    };

}
diff --git a/dbaccess/source/ui/inc/queryorder.hxx b/dbaccess/source/ui/inc/queryorder.hxx
index 16cfa10..71b36b7 100644
--- a/dbaccess/source/ui/inc/queryorder.hxx
+++ b/dbaccess/source/ui/inc/queryorder.hxx
@@ -19,15 +19,7 @@
#ifndef INCLUDED_DBACCESS_SOURCE_UI_INC_QUERYORDER_HXX
#define INCLUDED_DBACCESS_SOURCE_UI_INC_QUERYORDER_HXX

#include <vcl/dialog.hxx>

#include <vcl/lstbox.hxx>

#include <vcl/edit.hxx>

#include <vcl/fixed.hxx>

#include <vcl/button.hxx>
#include <vcl/weld.hxx>

#define DOG_ROWS    3

@@ -56,33 +48,33 @@ namespace com
// DlgOrderCrit
namespace dbaui
{
    class DlgOrderCrit final : public ModalDialog
    class DlgOrderCrit final : public weld::GenericDialogController
    {
        VclPtr<ListBox>        m_pLB_ORDERFIELD1;
        VclPtr<ListBox>        m_pLB_ORDERVALUE1;
        VclPtr<ListBox>        m_pLB_ORDERFIELD2;
        VclPtr<ListBox>        m_pLB_ORDERVALUE2;
        VclPtr<ListBox>        m_pLB_ORDERFIELD3;
        VclPtr<ListBox>        m_pLB_ORDERVALUE3;
        OUString               m_sOrgOrder;

        css::uno::Reference< css::sdb::XSingleSelectQueryComposer> m_xQueryComposer;
        css::uno::Reference< css::container::XNameAccess>          m_xColumns;
        css::uno::Reference< css::sdbc::XConnection>               m_xConnection;

        VclPtr<ListBox>        m_aColumnList[DOG_ROWS];
        VclPtr<ListBox>        m_aValueList[DOG_ROWS];
        weld::ComboBox* m_aColumnList[DOG_ROWS];
        weld::ComboBox* m_aValueList[DOG_ROWS];

        DECL_LINK( FieldListSelectHdl, ListBox&, void );
        std::unique_ptr<weld::ComboBox> m_xLB_ORDERFIELD1;
        std::unique_ptr<weld::ComboBox> m_xLB_ORDERVALUE1;
        std::unique_ptr<weld::ComboBox> m_xLB_ORDERFIELD2;
        std::unique_ptr<weld::ComboBox> m_xLB_ORDERVALUE2;
        std::unique_ptr<weld::ComboBox> m_xLB_ORDERFIELD3;
        std::unique_ptr<weld::ComboBox> m_xLB_ORDERVALUE3;

        DECL_LINK(FieldListSelectHdl, weld::ComboBox&, void);
        void            EnableLines();

    public:
        DlgOrderCrit(   vcl::Window * pParent,
                        const css::uno::Reference< css::sdbc::XConnection>& _rxConnection,
                        const css::uno::Reference< css::sdb::XSingleSelectQueryComposer>& _rxComposer,
                        const css::uno::Reference< css::container::XNameAccess>& _rxCols);
        DlgOrderCrit(weld::Window * pParent,
                     const css::uno::Reference< css::sdbc::XConnection>& _rxConnection,
                     const css::uno::Reference< css::sdb::XSingleSelectQueryComposer>& _rxComposer,
                     const css::uno::Reference< css::container::XNameAccess>& _rxCols);
        virtual ~DlgOrderCrit() override;
        virtual void dispose() override;

        void            BuildOrderPart();

diff --git a/dbaccess/source/ui/uno/composerdialogs.cxx b/dbaccess/source/ui/uno/composerdialogs.cxx
index 9bbb3c0..95186c7 100644
--- a/dbaccess/source/ui/uno/composerdialogs.cxx
+++ b/dbaccess/source/ui/uno/composerdialogs.cxx
@@ -30,6 +30,7 @@
#include <toolkit/helper/vclunohelper.hxx>
#include <tools/diagnose_ex.h>
#include <osl/diagnose.h>
#include <vcl/svapp.hxx>

extern "C" void createRegistryInfo_ComposerDialogs()
{
@@ -123,7 +124,7 @@ namespace dbaui
            return svt::OGenericUnoDialog::Dialog();
        }

        return svt::OGenericUnoDialog::Dialog(createComposerDialog(VCLUnoHelper::GetWindow(rParent), xConnection, xColumns));
        return svt::OGenericUnoDialog::Dialog(createComposerDialog(Application::GetFrameWeld(rParent), xConnection, xColumns));
    }

    // RowsetFilterDialog
@@ -142,9 +143,9 @@ namespace dbaui
        return static_cast< XServiceInfo* >(new RowsetFilterDialog( comphelper::getComponentContext(_rxORB)));
    }

    VclPtr<Dialog> RowsetFilterDialog::createComposerDialog( vcl::Window* _pParent, const Reference< XConnection >& _rxConnection, const Reference< XNameAccess >& _rxColumns )
    std::unique_ptr<weld::GenericDialogController> RowsetFilterDialog::createComposerDialog(weld::Window* _pParent, const Reference< XConnection >& _rxConnection, const Reference< XNameAccess >& _rxColumns )
    {
        return VclPtr<DlgFilterCrit>::Create( _pParent, m_aContext, _rxConnection, m_xComposer, _rxColumns );
        return o3tl::make_unique<DlgFilterCrit>(_pParent, m_aContext, _rxConnection, m_xComposer, _rxColumns);
    }

    void SAL_CALL RowsetFilterDialog::initialize( const Sequence< Any >& aArguments )
@@ -171,7 +172,7 @@ namespace dbaui
        ComposerDialog::executedDialog( _nExecutionResult );

        if ( _nExecutionResult && m_aDialog )
            static_cast< DlgFilterCrit* >( m_aDialog.m_xVclDialog.get() )->BuildWherePart();
            static_cast<DlgFilterCrit*>(m_aDialog.m_xWeldDialog.get())->BuildWherePart();
    }

    // RowsetOrderDialog
@@ -190,9 +191,9 @@ namespace dbaui
        return static_cast< XServiceInfo* >(new RowsetOrderDialog( comphelper::getComponentContext(_rxORB)));
    }

    VclPtr<Dialog> RowsetOrderDialog::createComposerDialog( vcl::Window* _pParent, const Reference< XConnection >& _rxConnection, const Reference< XNameAccess >& _rxColumns )
    std::unique_ptr<weld::GenericDialogController> RowsetOrderDialog::createComposerDialog(weld::Window* pParent, const Reference< XConnection >& rxConnection, const Reference< XNameAccess >& rxColumns)
    {
        return VclPtr<DlgOrderCrit>::Create( _pParent, _rxConnection, m_xComposer, _rxColumns );
        return o3tl::make_unique<DlgOrderCrit>(pParent, rxConnection, m_xComposer, rxColumns);
    }

    void SAL_CALL RowsetOrderDialog::initialize( const Sequence< Any >& aArguments )
@@ -218,9 +219,9 @@ namespace dbaui
            return;

        if ( _nExecutionResult )
            static_cast< DlgOrderCrit* >( m_aDialog.m_xVclDialog.get() )->BuildOrderPart();
            static_cast< DlgOrderCrit* >( m_aDialog.m_xWeldDialog.get() )->BuildOrderPart();
        else if ( m_xComposer.is() )
            m_xComposer->setOrder( static_cast< DlgOrderCrit* >( m_aDialog.m_xVclDialog.get() )->GetOrignalOrder() );
            m_xComposer->setOrder( static_cast< DlgOrderCrit* >( m_aDialog.m_xWeldDialog.get() )->GetOrignalOrder() );
    }

}   // namespace dbaui
diff --git a/dbaccess/source/ui/uno/composerdialogs.hxx b/dbaccess/source/ui/uno/composerdialogs.hxx
index 865752f..5ab489f 100644
--- a/dbaccess/source/ui/uno/composerdialogs.hxx
+++ b/dbaccess/source/ui/uno/composerdialogs.hxx
@@ -60,8 +60,8 @@ namespace dbaui

    protected:
        // own overridables
        virtual VclPtr<::Dialog> createComposerDialog(
            vcl::Window* _pParent,
        virtual std::unique_ptr<weld::GenericDialogController> createComposerDialog(
            weld::Window* _pParent,
            const css::uno::Reference< css::sdbc::XConnection >& _rxConnection,
            const css::uno::Reference< css::container::XNameAccess >& _rxColumns
        ) = 0;
@@ -89,8 +89,8 @@ namespace dbaui

    protected:
        // own overridables
        virtual VclPtr<::Dialog> createComposerDialog(
            vcl::Window* _pParent,
        virtual std::unique_ptr<weld::GenericDialogController> createComposerDialog(
            weld::Window* _pParent,
            const css::uno::Reference< css::sdbc::XConnection >& _rxConnection,
            const css::uno::Reference< css::container::XNameAccess >& _rxColumns
        ) override;
@@ -119,8 +119,8 @@ namespace dbaui

    protected:
        // own overridables
        virtual VclPtr<::Dialog> createComposerDialog(
            vcl::Window* _pParent,
        virtual std::unique_ptr<weld::GenericDialogController> createComposerDialog(
            weld::Window* _pParent,
            const css::uno::Reference< css::sdbc::XConnection >& _rxConnection,
            const css::uno::Reference< css::container::XNameAccess >& _rxColumns
        ) override;
diff --git a/dbaccess/uiconfig/ui/queryfilterdialog.ui b/dbaccess/uiconfig/ui/queryfilterdialog.ui
index c2eb233..a52ea36 100644
--- a/dbaccess/uiconfig/ui/queryfilterdialog.ui
+++ b/dbaccess/uiconfig/ui/queryfilterdialog.ui
@@ -1,12 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.18.3 -->
<!-- Generated with glade 3.22.1 -->
<interface domain="dba">
  <requires lib="gtk+" version="3.18"/>
  <object class="GtkDialog" id="QueryFilterDialog">
    <property name="can_focus">False</property>
    <property name="border_width">6</property>
    <property name="title" translatable="yes" context="queryfilterdialog|QueryFilterDialog">Standard Filter</property>
    <property name="modal">True</property>
    <property name="default_width">0</property>
    <property name="default_height">0</property>
    <property name="type_hint">dialog</property>
    <child>
      <placeholder/>
    </child>
    <child internal-child="vbox">
      <object class="GtkBox" id="dialog-vbox1">
        <property name="can_focus">False</property>
@@ -92,9 +98,9 @@
                      <object class="GtkLabel" id="label2">
                        <property name="visible">True</property>
                        <property name="can_focus">False</property>
                        <property name="xalign">0</property>
                        <property name="label" translatable="yes" context="queryfilterdialog|label2">Operator</property>
                        <property name="ellipsize">end</property>
                        <property name="xalign">0</property>
                      </object>
                      <packing>
                        <property name="left_attach">0</property>
@@ -228,6 +234,7 @@
                      <object class="GtkEntry" id="value1">
                        <property name="visible">True</property>
                        <property name="can_focus">True</property>
                        <property name="activates_default">True</property>
                      </object>
                      <packing>
                        <property name="left_attach">3</property>
@@ -238,6 +245,7 @@
                      <object class="GtkEntry" id="value2">
                        <property name="visible">True</property>
                        <property name="can_focus">True</property>
                        <property name="activates_default">True</property>
                      </object>
                      <packing>
                        <property name="left_attach">3</property>
@@ -248,6 +256,7 @@
                      <object class="GtkEntry" id="value3">
                        <property name="visible">True</property>
                        <property name="can_focus">True</property>
                        <property name="activates_default">True</property>
                      </object>
                      <packing>
                        <property name="left_attach">3</property>
diff --git a/dbaccess/uiconfig/ui/sortdialog.ui b/dbaccess/uiconfig/ui/sortdialog.ui
index f546a2a..9349ef7 100644
--- a/dbaccess/uiconfig/ui/sortdialog.ui
+++ b/dbaccess/uiconfig/ui/sortdialog.ui
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.18.3 -->
<!-- Generated with glade 3.22.1 -->
<interface domain="dba">
  <requires lib="gtk+" version="3.18"/>
  <object class="GtkDialog" id="SortDialog">
@@ -7,7 +7,13 @@
    <property name="border_width">6</property>
    <property name="title" translatable="yes" context="sortdialog|SortDialog">Sort Order</property>
    <property name="resizable">False</property>
    <property name="modal">True</property>
    <property name="default_width">0</property>
    <property name="default_height">0</property>
    <property name="type_hint">dialog</property>
    <child>
      <placeholder/>
    </child>
    <child internal-child="vbox">
      <object class="GtkBox" id="dialog-vbox1">
        <property name="can_focus">False</property>
@@ -105,9 +111,9 @@
                      <object class="GtkLabel" id="label3">
                        <property name="visible">True</property>
                        <property name="can_focus">False</property>
                        <property name="xalign">1</property>
                        <property name="label" translatable="yes" context="sortdialog|label3">and then</property>
                        <property name="ellipsize">end</property>
                        <property name="xalign">1</property>
                      </object>
                      <packing>
                        <property name="left_attach">0</property>
@@ -118,9 +124,9 @@
                      <object class="GtkLabel" id="label4">
                        <property name="visible">True</property>
                        <property name="can_focus">False</property>
                        <property name="xalign">1</property>
                        <property name="label" translatable="yes" context="sortdialog|label4">and then</property>
                        <property name="ellipsize">end</property>
                        <property name="xalign">1</property>
                      </object>
                      <packing>
                        <property name="left_attach">0</property>