diff options
author | Caolán McNamara <caolanm@redhat.com> | 2019-02-09 19:41:10 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2019-02-10 18:04:37 +0100 |
commit | df230a23676dd992ee12c13273c3901bd56f6354 (patch) | |
tree | 2fbb1c53e1e9b9cc5b09fe2aa66eb1f3aa14abfc /cui | |
parent | d88911d172f7a57d097656eff6c2ebded627ddc4 (diff) |
weld FmSearchDialog
Change-Id: If7e87f725ea44732080fc0c57e4503c82b0cf4a0
Reviewed-on: https://gerrit.libreoffice.org/67595
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'cui')
-rw-r--r-- | cui/source/dialogs/cuifmsearch.cxx | 643 | ||||
-rw-r--r-- | cui/source/factory/dlgfact.cxx | 23 | ||||
-rw-r--r-- | cui/source/factory/dlgfact.hxx | 11 | ||||
-rw-r--r-- | cui/source/inc/cuifmsearch.hxx | 106 | ||||
-rw-r--r-- | cui/uiconfig/ui/fmsearchdialog.ui | 28 |
5 files changed, 348 insertions, 463 deletions
diff --git a/cui/source/dialogs/cuifmsearch.cxx b/cui/source/dialogs/cuifmsearch.cxx index 6882dde07c4a..444304efcca3 100644 --- a/cui/source/dialogs/cuifmsearch.cxx +++ b/cui/source/dialogs/cuifmsearch.cxx @@ -53,59 +53,58 @@ void FmSearchDialog::initCommon( const Reference< XResultSet >& _rxCursor ) if (!aCJKOptions.IsJapaneseFindEnabled()) { // hide the options for the japanese search - m_pSoundsLikeCJK->Hide(); - m_pSoundsLikeCJKSettings->Hide(); + m_pSoundsLikeCJK->hide(); + m_pSoundsLikeCJKSettings->hide(); } if (!aCJKOptions.IsCJKFontEnabled()) { - m_pHalfFullFormsCJK->Hide(); + m_pHalfFullFormsCJK->hide(); // never ignore the width (ignoring is expensive) if the option is not available at all m_pSearchEngine->SetIgnoreWidthCJK( false ); } // some initial record texts - m_pftRecord->SetText( OUString::number(_rxCursor->getRow()) ); - m_pbClose->SetHelpText(OUString()); + m_pftRecord->set_label( OUString::number(_rxCursor->getRow()) ); + m_pbClose->set_tooltip_text(OUString()); } -FmSearchDialog::FmSearchDialog(vcl::Window* pParent, const OUString& sInitialText, const std::vector< OUString >& _rContexts, sal_Int16 nInitialContext, +FmSearchDialog::FmSearchDialog(weld::Window* pParent, const OUString& sInitialText, const std::vector< OUString >& _rContexts, sal_Int16 nInitialContext, const Link<FmSearchContext&,sal_uInt32>& lnkContextSupplier) - :ModalDialog(pParent, "RecordSearchDialog", "cui/ui/fmsearchdialog.ui") - ,m_sCancel( Button::GetStandardText( StandardButtonType::Cancel ) ) - ,m_pPreSearchFocus( nullptr ) - ,m_lnkContextSupplier(lnkContextSupplier) + : GenericDialogController(pParent, "cui/ui/fmsearchdialog.ui", "RecordSearchDialog") + , m_sCancel( Button::GetStandardText( StandardButtonType::Cancel ) ) + , m_lnkContextSupplier(lnkContextSupplier) + , m_prbSearchForText(m_xBuilder->weld_radio_button("rbSearchForText")) + , m_prbSearchForNull(m_xBuilder->weld_radio_button("rbSearchForNull")) + , m_prbSearchForNotNull(m_xBuilder->weld_radio_button("rbSearchForNotNull")) + , m_pcmbSearchText(m_xBuilder->weld_combo_box("cmbSearchText")) + , m_pftForm(m_xBuilder->weld_label("ftForm")) + , m_plbForm(m_xBuilder->weld_combo_box("lbForm")) + , m_prbAllFields(m_xBuilder->weld_radio_button("rbAllFields")) + , m_prbSingleField(m_xBuilder->weld_radio_button("rbSingleField")) + , m_plbField(m_xBuilder->weld_combo_box("lbField")) + , m_pftPosition(m_xBuilder->weld_label("ftPosition")) + , m_plbPosition(m_xBuilder->weld_combo_box("lbPosition")) + , m_pcbUseFormat(m_xBuilder->weld_check_button("cbUseFormat")) + , m_pcbCase(m_xBuilder->weld_check_button("cbCase")) + , m_pcbBackwards(m_xBuilder->weld_check_button("cbBackwards")) + , m_pcbStartOver(m_xBuilder->weld_check_button("cbStartOver")) + , m_pcbWildCard(m_xBuilder->weld_check_button("cbWildCard")) + , m_pcbRegular(m_xBuilder->weld_check_button("cbRegular")) + , m_pcbApprox(m_xBuilder->weld_check_button("cbApprox")) + , m_ppbApproxSettings(m_xBuilder->weld_button("pbApproxSettings")) + , m_pHalfFullFormsCJK(m_xBuilder->weld_check_button("HalfFullFormsCJK")) + , m_pSoundsLikeCJK(m_xBuilder->weld_check_button("SoundsLikeCJK")) + , m_pSoundsLikeCJKSettings(m_xBuilder->weld_button("SoundsLikeCJKSettings")) + , m_pftRecord(m_xBuilder->weld_label("ftRecord")) + , m_pftHint(m_xBuilder->weld_label("ftHint")) + , m_pbSearchAgain(m_xBuilder->weld_button("pbSearchAgain")) + , m_pbClose(m_xBuilder->weld_button("close")) { - get(m_prbSearchForText,"rbSearchForText"); - get(m_prbSearchForNull,"rbSearchForNull"); - get(m_prbSearchForNotNull,"rbSearchForNotNull"); - get(m_pcmbSearchText,"cmbSearchText"); - m_pcmbSearchText->set_width_request(m_pcmbSearchText->approximate_char_width() * 42); - get(m_plbForm,"lbForm"); - m_plbForm->set_width_request(m_plbForm->approximate_char_width() * 42); - get(m_prbAllFields,"rbAllFields"); - get(m_prbSingleField,"rbSingleField"); - get(m_plbField,"lbField"); - get(m_plbPosition,"lbPosition"); - get(m_pcbUseFormat,"cbUseFormat"); - get(m_pcbCase,"cbCase"); - get(m_pcbBackwards,"cbBackwards"); - get(m_pcbStartOver,"cbStartOver"); - get(m_pcbWildCard,"cbWildCard"); - get(m_pcbRegular,"cbRegular"); - get(m_pcbApprox,"cbApprox"); - get(m_ppbApproxSettings,"pbApproxSettings"); - get(m_pHalfFullFormsCJK,"HalfFullFormsCJK"); - get(m_pSoundsLikeCJK,"SoundsLikeCJK"); - get(m_pSoundsLikeCJKSettings,"SoundsLikeCJKSettings"); - get(m_pbSearchAgain,"pbSearchAgain"); - m_sSearch = m_pbSearchAgain->GetText(); - get(m_pftRecord,"ftRecord"); - get(m_pftHint,"ftHint"); - get(m_pftPosition,"ftPosition"); - get(m_pftForm,"ftForm"); - get(m_pbClose,"close"); + m_pcmbSearchText->set_size_request(m_pcmbSearchText->get_approximate_digit_width() * 38, -1); + m_plbForm->set_size_request(m_plbForm->get_approximate_digit_width() * 38, -1); + m_sSearch = m_pbSearchAgain->get_label(); DBG_ASSERT(m_lnkContextSupplier.IsSet(), "FmSearchDialog::FmSearchDialog : have no ContextSupplier !"); @@ -128,17 +127,17 @@ FmSearchDialog::FmSearchDialog(vcl::Window* pParent, const OUString& sInitialTex ) { m_arrContextFields.emplace_back(); - m_plbForm->InsertEntry(*context); + m_plbForm->append_text(*context); } - m_plbForm->SelectEntryPos(nInitialContext); + m_plbForm->set_active(nInitialContext); - m_plbForm->SetSelectHdl(LINK(this, FmSearchDialog, OnContextSelection)); + m_plbForm->connect_changed(LINK(this, FmSearchDialog, OnContextSelection)); if (m_arrContextFields.size() == 1) { // hide dispensable controls - m_pftForm->Hide(); - m_plbForm->Hide(); + m_pftForm->hide(); + m_plbForm->hide(); } m_pSearchEngine.reset( new FmSearchEngine( @@ -157,81 +156,42 @@ FmSearchDialog::FmSearchDialog(vcl::Window* pParent, const OUString& sInitialTex FmSearchDialog::~FmSearchDialog() { - disposeOnce(); -} - -void FmSearchDialog::dispose() -{ - if (m_aDelayedPaint.IsActive()) - m_aDelayedPaint.Stop(); - SaveParams(); m_pConfig.reset(); - m_pSearchEngine.reset(); - - m_prbSearchForText.clear(); - m_prbSearchForNull.clear(); - m_prbSearchForNotNull.clear(); - m_pcmbSearchText.clear(); - m_pftForm.clear(); - m_plbForm.clear(); - m_prbAllFields.clear(); - m_prbSingleField.clear(); - m_plbField.clear(); - m_pftPosition.clear(); - m_plbPosition.clear(); - m_pcbUseFormat.clear(); - m_pcbCase.clear(); - m_pcbBackwards.clear(); - m_pcbStartOver.clear(); - m_pcbWildCard.clear(); - m_pcbRegular.clear(); - m_pcbApprox.clear(); - m_ppbApproxSettings.clear(); - m_pHalfFullFormsCJK.clear(); - m_pSoundsLikeCJK.clear(); - m_pSoundsLikeCJKSettings.clear(); - m_pftRecord.clear(); - m_pftHint.clear(); - m_pbSearchAgain.clear(); - m_pbClose.clear(); - m_pPreSearchFocus.clear(); - - ModalDialog::dispose(); } void FmSearchDialog::Init(const OUString& strVisibleFields, const OUString& sInitialText) { //the initialization of all the Controls - m_prbSearchForText->SetClickHdl(LINK(this, FmSearchDialog, OnClickedFieldRadios)); - m_prbSearchForNull->SetClickHdl(LINK(this, FmSearchDialog, OnClickedFieldRadios)); - m_prbSearchForNotNull->SetClickHdl(LINK(this, FmSearchDialog, OnClickedFieldRadios)); - - m_prbAllFields->SetClickHdl(LINK(this, FmSearchDialog, OnClickedFieldRadios)); - m_prbSingleField->SetClickHdl(LINK(this, FmSearchDialog, OnClickedFieldRadios)); - - m_pbSearchAgain->SetClickHdl(LINK(this, FmSearchDialog, OnClickedSearchAgain)); - m_ppbApproxSettings->SetClickHdl(LINK(this, FmSearchDialog, OnClickedSpecialSettings)); - m_pSoundsLikeCJKSettings->SetClickHdl(LINK(this, FmSearchDialog, OnClickedSpecialSettings)); - - m_plbPosition->SetSelectHdl(LINK(this, FmSearchDialog, OnPositionSelected)); - m_plbField->SetSelectHdl(LINK(this, FmSearchDialog, OnFieldSelected)); - - m_pcmbSearchText->SetModifyHdl(LINK(this, FmSearchDialog, OnSearchTextModified)); - m_pcmbSearchText->EnableAutocomplete(false); - m_pcmbSearchText->SetGetFocusHdl(LINK(this, FmSearchDialog, OnFocusGrabbed)); - - m_pcbUseFormat->SetToggleHdl(LINK(this, FmSearchDialog, OnCheckBoxToggled)); - m_pcbBackwards->SetToggleHdl(LINK(this, FmSearchDialog, OnCheckBoxToggled)); - m_pcbStartOver->SetToggleHdl(LINK(this, FmSearchDialog, OnCheckBoxToggled)); - m_pcbCase->SetToggleHdl(LINK(this, FmSearchDialog, OnCheckBoxToggled)); - m_pcbWildCard->SetToggleHdl(LINK(this, FmSearchDialog, OnCheckBoxToggled)); - m_pcbRegular->SetToggleHdl(LINK(this, FmSearchDialog, OnCheckBoxToggled)); - m_pcbApprox->SetToggleHdl(LINK(this, FmSearchDialog, OnCheckBoxToggled)); - m_pHalfFullFormsCJK->SetToggleHdl(LINK(this, FmSearchDialog, OnCheckBoxToggled)); - m_pSoundsLikeCJK->SetToggleHdl(LINK(this, FmSearchDialog, OnCheckBoxToggled)); + m_prbSearchForText->connect_clicked(LINK(this, FmSearchDialog, OnClickedFieldRadios)); + m_prbSearchForNull->connect_clicked(LINK(this, FmSearchDialog, OnClickedFieldRadios)); + m_prbSearchForNotNull->connect_clicked(LINK(this, FmSearchDialog, OnClickedFieldRadios)); + + m_prbAllFields->connect_clicked(LINK(this, FmSearchDialog, OnClickedFieldRadios)); + m_prbSingleField->connect_clicked(LINK(this, FmSearchDialog, OnClickedFieldRadios)); + + m_pbSearchAgain->connect_clicked(LINK(this, FmSearchDialog, OnClickedSearchAgain)); + m_ppbApproxSettings->connect_clicked(LINK(this, FmSearchDialog, OnClickedSpecialSettings)); + m_pSoundsLikeCJKSettings->connect_clicked(LINK(this, FmSearchDialog, OnClickedSpecialSettings)); + + m_plbPosition->connect_changed(LINK(this, FmSearchDialog, OnPositionSelected)); + m_plbField->connect_changed(LINK(this, FmSearchDialog, OnFieldSelected)); + + m_pcmbSearchText->connect_changed(LINK(this, FmSearchDialog, OnSearchTextModified)); + m_pcmbSearchText->set_entry_completion(false); + m_pcmbSearchText->connect_focus_in(LINK(this, FmSearchDialog, OnFocusGrabbed)); + + m_pcbUseFormat->connect_toggled(LINK(this, FmSearchDialog, OnCheckBoxToggled)); + m_pcbBackwards->connect_toggled(LINK(this, FmSearchDialog, OnCheckBoxToggled)); + m_pcbStartOver->connect_toggled(LINK(this, FmSearchDialog, OnCheckBoxToggled)); + m_pcbCase->connect_toggled(LINK(this, FmSearchDialog, OnCheckBoxToggled)); + m_pcbWildCard->connect_toggled(LINK(this, FmSearchDialog, OnCheckBoxToggled)); + m_pcbRegular->connect_toggled(LINK(this, FmSearchDialog, OnCheckBoxToggled)); + m_pcbApprox->connect_toggled(LINK(this, FmSearchDialog, OnCheckBoxToggled)); + m_pHalfFullFormsCJK->connect_toggled(LINK(this, FmSearchDialog, OnCheckBoxToggled)); + m_pSoundsLikeCJK->connect_toggled(LINK(this, FmSearchDialog, OnCheckBoxToggled)); // fill the listboxes // method of field comparison @@ -242,15 +202,15 @@ void FmSearchDialog::Init(const OUString& strVisibleFields, const OUString& sIni RID_STR_SEARCH_WHOLE }; for (auto pResId : aResIds) - m_plbPosition->InsertEntry(CuiResId(pResId)); - m_plbPosition->SelectEntryPos(MATCHING_ANYWHERE); + m_plbPosition->append_text(CuiResId(pResId)); + m_plbPosition->set_active(MATCHING_ANYWHERE); // the field listbox if (!strVisibleFields.isEmpty()) { sal_Int32 nPos {0}; do { - m_plbField->InsertEntry(strVisibleFields.getToken(0, ';', nPos)); + m_plbField->append_text(strVisibleFields.getToken(0, ';', nPos)); } while (nPos>=0); } @@ -258,89 +218,82 @@ void FmSearchDialog::Init(const OUString& strVisibleFields, const OUString& sIni m_pConfig.reset( new FmSearchConfigItem ); LoadParams(); - m_pcmbSearchText->SetText(sInitialText); + m_pcmbSearchText->set_entry_text(sInitialText); // if the Edit-line has changed the text (e.g. because it contains // control characters, as can be the case with memo fields), I use // an empty OUString. - OUString sRealSetText = m_pcmbSearchText->GetText(); + OUString sRealSetText = m_pcmbSearchText->get_active_text(); if (sRealSetText != sInitialText) - m_pcmbSearchText->SetText(OUString()); - LINK(this, FmSearchDialog, OnSearchTextModified).Call(*m_pcmbSearchText); + m_pcmbSearchText->set_entry_text(OUString()); + OnSearchTextModified(*m_pcmbSearchText); // initial - m_aDelayedPaint.SetInvokeHandler(LINK(this, FmSearchDialog, OnDelayedPaint)); - m_aDelayedPaint.SetTimeout(500); EnableSearchUI(true); - if ( m_prbSearchForText->IsChecked() ) - m_pcmbSearchText->GrabFocus(); + if ( m_prbSearchForText->get_active() ) + m_pcmbSearchText->grab_focus(); } -bool FmSearchDialog::Close() +short FmSearchDialog::run() { - // If the close button is disabled and ESC is pressed in a dialog, - // then Frame will call Close anyway, which I don't want to happen - // while I'm in the middle of a search (maybe one that's running - // in its own thread) - if (!m_pbClose->IsEnabled()) - return false; - return ModalDialog::Close(); + short nRet = weld::GenericDialogController::run(); + m_pSearchEngine->CancelSearch(); + return nRet; } -IMPL_LINK(FmSearchDialog, OnClickedFieldRadios, Button*, pButton, void) +IMPL_LINK(FmSearchDialog, OnClickedFieldRadios, weld::Button&, rButton, void) { - if ((pButton == m_prbSearchForText) || (pButton == m_prbSearchForNull) || (pButton == m_prbSearchForNotNull)) + if ((&rButton == m_prbSearchForText.get()) || (&rButton == m_prbSearchForNull.get()) || (&rButton == m_prbSearchForNotNull.get())) { EnableSearchForDependees(true); } else // en- or disable field list box accordingly - if (pButton == m_prbSingleField) + if (&rButton == m_prbSingleField.get()) { - m_plbField->Enable(); - m_pSearchEngine->RebuildUsedFields(m_plbField->GetSelectedEntryPos()); + m_plbField->set_sensitive(true); + m_pSearchEngine->RebuildUsedFields(m_plbField->get_active()); } else { - m_plbField->Disable(); + m_plbField->set_sensitive(false); m_pSearchEngine->RebuildUsedFields(-1); } } -IMPL_LINK_NOARG(FmSearchDialog, OnClickedSearchAgain, Button*, void) +IMPL_LINK_NOARG(FmSearchDialog, OnClickedSearchAgain, weld::Button&, void) { - if (m_pbClose->IsEnabled()) + if (m_pbClose->get_sensitive()) { // the button has the function 'search' - OUString strThisRoundText = m_pcmbSearchText->GetText(); + OUString strThisRoundText = m_pcmbSearchText->get_active_text(); // to history - m_pcmbSearchText->RemoveEntry(strThisRoundText); - m_pcmbSearchText->InsertEntry(strThisRoundText, 0); + m_pcmbSearchText->remove_text(strThisRoundText); + m_pcmbSearchText->insert_text(0, strThisRoundText); // the remove/insert makes sure that a) the OUString does not appear twice and // that b) the last searched strings are at the beginning and limit the list length - while (m_pcmbSearchText->GetEntryCount() > MAX_HISTORY_ENTRIES) - m_pcmbSearchText->RemoveEntryAt(m_pcmbSearchText->GetEntryCount()-1); + while (m_pcmbSearchText->get_count() > MAX_HISTORY_ENTRIES) + m_pcmbSearchText->remove(m_pcmbSearchText->get_count()-1); // take out the 'overflow' hint - m_pftHint->SetText(OUString()); - m_pftHint->Invalidate(); + m_pftHint->set_label(OUString()); - if (m_pcbStartOver->IsChecked()) + if (m_pcbStartOver->get_active()) { - m_pcbStartOver->Check(false); + m_pcbStartOver->set_active(false); EnableSearchUI(false); - if (m_prbSearchForText->IsChecked()) + if (m_prbSearchForText->get_active()) m_pSearchEngine->StartOver(strThisRoundText); else - m_pSearchEngine->StartOverSpecial(m_prbSearchForNull->IsChecked()); + m_pSearchEngine->StartOverSpecial(m_prbSearchForNull->get_active()); } else { EnableSearchUI(false); - if (m_prbSearchForText->IsChecked()) + if (m_prbSearchForText->get_active()) m_pSearchEngine->SearchNext(strThisRoundText); else - m_pSearchEngine->SearchNextSpecial(m_prbSearchForNull->IsChecked()); + m_pSearchEngine->SearchNextSpecial(m_prbSearchForNull->get_active()); } } else @@ -351,12 +304,12 @@ IMPL_LINK_NOARG(FmSearchDialog, OnClickedSearchAgain, Button*, void) } } -IMPL_LINK(FmSearchDialog, OnClickedSpecialSettings, Button*, pButton, void ) +IMPL_LINK(FmSearchDialog, OnClickedSpecialSettings, weld::Button&, rButton, void) { - if (m_ppbApproxSettings == pButton) + if (m_ppbApproxSettings.get() == &rButton) { SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); - ScopedVclPtr<AbstractSvxSearchSimilarityDialog> pDlg(pFact->CreateSvxSearchSimilarityDialog(GetFrameWeld(), m_pSearchEngine->GetLevRelaxed(), m_pSearchEngine->GetLevOther(), + ScopedVclPtr<AbstractSvxSearchSimilarityDialog> pDlg(pFact->CreateSvxSearchSimilarityDialog(m_xDialog.get(), m_pSearchEngine->GetLevRelaxed(), m_pSearchEngine->GetLevOther(), m_pSearchEngine->GetLevShorter(), m_pSearchEngine->GetLevLonger() )); if (pDlg->Execute() == RET_OK) { @@ -366,133 +319,129 @@ IMPL_LINK(FmSearchDialog, OnClickedSpecialSettings, Button*, pButton, void ) m_pSearchEngine->SetLevLonger( pDlg->GetLonger() ); } } - else if (m_pSoundsLikeCJKSettings == pButton) + else if (m_pSoundsLikeCJKSettings.get() == &rButton) { SfxItemSet aSet( SfxGetpApp()->GetPool() ); SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); - ScopedVclPtr<AbstractSvxJSearchOptionsDialog> aDlg(pFact->CreateSvxJSearchOptionsDialog(GetFrameWeld(), aSet, m_pSearchEngine->GetTransliterationFlags() )); + ScopedVclPtr<AbstractSvxJSearchOptionsDialog> aDlg(pFact->CreateSvxJSearchOptionsDialog(m_xDialog.get(), aSet, m_pSearchEngine->GetTransliterationFlags() )); aDlg->Execute(); TransliterationFlags nFlags = aDlg->GetTransliterationFlags(); m_pSearchEngine->SetTransliterationFlags(nFlags); - m_pcbCase->Check(m_pSearchEngine->GetCaseSensitive()); + m_pcbCase->set_active(m_pSearchEngine->GetCaseSensitive()); OnCheckBoxToggled( *m_pcbCase ); - m_pHalfFullFormsCJK->Check( !m_pSearchEngine->GetIgnoreWidthCJK() ); + m_pHalfFullFormsCJK->set_active( !m_pSearchEngine->GetIgnoreWidthCJK() ); OnCheckBoxToggled( *m_pHalfFullFormsCJK ); } } -IMPL_LINK_NOARG(FmSearchDialog, OnSearchTextModified, Edit&, void) +IMPL_LINK_NOARG(FmSearchDialog, OnSearchTextModified, weld::ComboBox&, void) { - if ((!m_pcmbSearchText->GetText().isEmpty()) || !m_prbSearchForText->IsChecked()) - m_pbSearchAgain->Enable(); + if ((!m_pcmbSearchText->get_active_text().isEmpty()) || !m_prbSearchForText->get_active()) + m_pbSearchAgain->set_sensitive(true); else - m_pbSearchAgain->Disable(); + m_pbSearchAgain->set_sensitive(false); m_pSearchEngine->InvalidatePreviousLoc(); } -IMPL_LINK_NOARG(FmSearchDialog, OnFocusGrabbed, Control&, void) +IMPL_LINK_NOARG(FmSearchDialog, OnFocusGrabbed, weld::Widget&, void) { - m_pcmbSearchText->SetSelection( Selection( SELECTION_MIN, SELECTION_MAX ) ); + m_pcmbSearchText->select_entry_region(0, -1); } -IMPL_LINK(FmSearchDialog, OnPositionSelected, ListBox&, rBox, void) +IMPL_LINK_NOARG(FmSearchDialog, OnPositionSelected, weld::ComboBox&, void) { - DBG_ASSERT(rBox.GetSelectedEntryCount() == 1, "FmSearchDialog::OnMethodSelected : unexpected : not exactly one entry selected!"); - - m_pSearchEngine->SetPosition(m_plbPosition->GetSelectedEntryPos()); + m_pSearchEngine->SetPosition(m_plbPosition->get_active()); } -IMPL_LINK(FmSearchDialog, OnFieldSelected, ListBox&, rBox, void) +IMPL_LINK_NOARG(FmSearchDialog, OnFieldSelected, weld::ComboBox&, void) { - DBG_ASSERT(rBox.GetSelectedEntryCount() == 1, "FmSearchDialog::OnFieldSelected : unexpected : not exactly one entry select!"); - - m_pSearchEngine->RebuildUsedFields(m_prbAllFields->IsChecked() ? -1 : static_cast<sal_Int16>(m_plbField->GetSelectedEntryPos())); - // calls m_pSearchEngine->InvalidatePreviousLoc too + m_pSearchEngine->RebuildUsedFields(m_prbAllFields->get_active() ? -1 : m_plbField->get_active()); + // calls m_pSearchEngine->InvalidatePreviousLoc too - sal_Int32 nCurrentContext = m_plbForm->GetSelectedEntryPos(); - if (nCurrentContext != LISTBOX_ENTRY_NOTFOUND) - m_arrContextFields[nCurrentContext] = m_plbField->GetSelectedEntry(); + int nCurrentContext = m_plbForm->get_active(); + if (nCurrentContext != -1) + m_arrContextFields[nCurrentContext] = m_plbField->get_active_text(); } -IMPL_LINK(FmSearchDialog, OnCheckBoxToggled, CheckBox&, rBox, void) +IMPL_LINK(FmSearchDialog, OnCheckBoxToggled, weld::ToggleButton&, rBox, void) { - bool bChecked = rBox.IsChecked(); + bool bChecked = rBox.get_active(); // formatter or case -> pass on to the engine - if (&rBox == m_pcbUseFormat) + if (&rBox == m_pcbUseFormat.get()) m_pSearchEngine->SetFormatterUsing(bChecked); - else if (&rBox == m_pcbCase) + else if (&rBox == m_pcbCase.get()) m_pSearchEngine->SetCaseSensitive(bChecked); // direction -> pass on and reset the checkbox-text for StartOver - else if (&rBox == m_pcbBackwards) + else if (&rBox == m_pcbBackwards.get()) { - m_pcbStartOver->SetText( CuiResId( bChecked ? RID_STR_FROM_BOTTOM : RID_STR_FROM_TOP ) ); + m_pcbStartOver->set_label( CuiResId( bChecked ? RID_STR_FROM_BOTTOM : RID_STR_FROM_TOP ) ); m_pSearchEngine->SetDirection(!bChecked); } // similarity-search or regular expression - else if ((&rBox == m_pcbApprox) || (&rBox == m_pcbRegular) || (&rBox == m_pcbWildCard)) + else if ((&rBox == m_pcbApprox.get()) || (&rBox == m_pcbRegular.get()) || (&rBox == m_pcbWildCard.get())) { - CheckBox* pBoxes[] = { m_pcbWildCard, m_pcbRegular, m_pcbApprox }; - for (CheckBox* pBoxe : pBoxes) + weld::CheckButton* pBoxes[] = { m_pcbWildCard.get(), m_pcbRegular.get(), m_pcbApprox.get() }; + for (weld::CheckButton* pBoxe : pBoxes) { if (pBoxe != &rBox) { if (bChecked) - pBoxe->Disable(); + pBoxe->set_sensitive(false); else - pBoxe->Enable(); + pBoxe->set_sensitive(true); } } // pass on to the engine - m_pSearchEngine->SetWildcard(m_pcbWildCard->IsEnabled() && m_pcbWildCard->IsChecked()); - m_pSearchEngine->SetRegular(m_pcbRegular->IsEnabled() && m_pcbRegular->IsChecked()); - m_pSearchEngine->SetLevenshtein(m_pcbApprox->IsEnabled() && m_pcbApprox->IsChecked()); + m_pSearchEngine->SetWildcard(m_pcbWildCard->get_sensitive() && m_pcbWildCard->get_active()); + m_pSearchEngine->SetRegular(m_pcbRegular->get_sensitive() && m_pcbRegular->get_active()); + m_pSearchEngine->SetLevenshtein(m_pcbApprox->get_sensitive() && m_pcbApprox->get_active()); // (disabled boxes have to be passed to the engine as sal_False) // adjust the Position-Listbox (which is not allowed during Wildcard-search) - if (&rBox == m_pcbWildCard) + if (&rBox == m_pcbWildCard.get()) { if (bChecked) { - m_pftPosition->Disable(); - m_plbPosition->Disable(); + m_pftPosition->set_sensitive(false); + m_plbPosition->set_sensitive(false); } else { - m_pftPosition->Enable(); - m_plbPosition->Enable(); + m_pftPosition->set_sensitive(true); + m_plbPosition->set_sensitive(true); } } // and the button for similarity-search - if (&rBox == m_pcbApprox) + if (&rBox == m_pcbApprox.get()) { if (bChecked) - m_ppbApproxSettings->Enable(); + m_ppbApproxSettings->set_sensitive(true); else - m_ppbApproxSettings->Disable(); + m_ppbApproxSettings->set_sensitive(false); } } - else if (&rBox == m_pHalfFullFormsCJK) + else if (&rBox == m_pHalfFullFormsCJK.get()) { // forward to the search engine m_pSearchEngine->SetIgnoreWidthCJK( !bChecked ); } - else if (&rBox == m_pSoundsLikeCJK) + else if (&rBox == m_pSoundsLikeCJK.get()) { - m_pSoundsLikeCJKSettings->Enable(bChecked); + m_pSoundsLikeCJKSettings->set_sensitive(bChecked); // two other buttons which depend on this one - bool bEnable = ( m_prbSearchForText->IsChecked() - && !m_pSoundsLikeCJK->IsChecked() + bool bEnable = ( m_prbSearchForText->get_active() + && !m_pSoundsLikeCJK->get_active() ) || !SvtCJKOptions().IsJapaneseFindEnabled(); - m_pcbCase->Enable(bEnable); - m_pHalfFullFormsCJK->Enable(bEnable); + m_pcbCase->set_sensitive(bEnable); + m_pHalfFullFormsCJK->set_sensitive(bEnable); // forward to the search engine m_pSearchEngine->SetTransliteration( bChecked ); @@ -508,7 +457,7 @@ void FmSearchDialog::InitContext(sal_Int16 nContext) DBG_ASSERT(nResult > 0, "FmSearchDialog::InitContext : ContextSupplier didn't give me any controls !"); // put the field names into the respective listbox - m_plbField->Clear(); + m_plbField->clear(); if (!fmscContext.sFieldDisplayNames.isEmpty()) { @@ -517,7 +466,7 @@ void FmSearchDialog::InitContext(sal_Int16 nContext) "FmSearchDialog::InitContext : invalid context description supplied !"); sal_Int32 nPos {0}; do { - m_plbField->InsertEntry(fmscContext.sFieldDisplayNames.getToken(0, ';', nPos)); + m_plbField->append_text(fmscContext.sFieldDisplayNames.getToken(0, ';', nPos)); } while (nPos>=0); } else if (!fmscContext.strUsedFields.isEmpty()) @@ -525,165 +474,97 @@ void FmSearchDialog::InitContext(sal_Int16 nContext) // else use the field names sal_Int32 nPos {0}; do { - m_plbField->InsertEntry(fmscContext.strUsedFields.getToken(0, ';', nPos)); + m_plbField->append_text(fmscContext.strUsedFields.getToken(0, ';', nPos)); } while (nPos>=0); } if (nContext < static_cast<sal_Int32>(m_arrContextFields.size()) && !m_arrContextFields[nContext].isEmpty()) { - m_plbField->SelectEntry(m_arrContextFields[nContext]); + m_plbField->set_active_text(m_arrContextFields[nContext]); } else { - m_plbField->SelectEntryPos(0); - if (m_prbSingleField->IsChecked() && (m_plbField->GetEntryCount() > 1)) - m_plbField->GrabFocus(); + m_plbField->set_active(0); + if (m_prbSingleField->get_active() && (m_plbField->get_count() > 1)) + m_plbField->grab_focus(); } m_pSearchEngine->SwitchToContext(fmscContext.xCursor, fmscContext.strUsedFields, fmscContext.arrFields, - m_prbAllFields->IsChecked() ? -1 : 0); + m_prbAllFields->get_active() ? -1 : 0); - m_pftRecord->SetText(OUString::number(fmscContext.xCursor->getRow())); + m_pftRecord->set_label(OUString::number(fmscContext.xCursor->getRow())); } -IMPL_LINK( FmSearchDialog, OnContextSelection, ListBox&, rBox, void) +IMPL_LINK(FmSearchDialog, OnContextSelection, weld::ComboBox&, rBox, void) { - InitContext(rBox.GetSelectedEntryPos()); + InitContext(rBox.get_active()); } void FmSearchDialog::EnableSearchUI(bool bEnable) { - // when the controls shall be disabled their paint is turned off and then turned on again after a delay - if (!bEnable) - EnableControlPaint(false); - else - { - if (m_aDelayedPaint.IsActive()) - m_aDelayedPaint.Stop(); - } - // (the whole thing goes on below) - // this small intricateness hopefully leads to no flickering when turning the SearchUI off - // and on again shortly after (like it's the case during a short search process) - - if ( !bEnable ) - { - // if one of my children has the focus, remember it - vcl::Window* pFocusWindow = Application::GetFocusWindow( ); - if ( pFocusWindow && IsChild( pFocusWindow ) ) - m_pPreSearchFocus = pFocusWindow; - else - m_pPreSearchFocus = nullptr; - } - // the search button has two functions -> adjust its text accordingly OUString sButtonText( bEnable ? m_sSearch : m_sCancel ); - m_pbSearchAgain->SetText( sButtonText ); - - m_prbSearchForText->Enable (bEnable); - m_prbSearchForNull->Enable (bEnable); - m_prbSearchForNotNull->Enable (bEnable); - m_plbForm->Enable (bEnable); - m_prbAllFields->Enable (bEnable); - m_prbSingleField->Enable (bEnable); - m_plbField->Enable (bEnable && m_prbSingleField->IsChecked()); - m_pcbBackwards->Enable (bEnable); - m_pcbStartOver->Enable (bEnable); - m_pbClose->Enable (bEnable); - EnableSearchForDependees (bEnable); + m_pbSearchAgain->set_label(sButtonText); + + m_prbSearchForText->set_sensitive(bEnable); + m_prbSearchForNull->set_sensitive(bEnable); + m_prbSearchForNotNull->set_sensitive(bEnable); + m_plbForm->set_sensitive(bEnable); + m_prbAllFields->set_sensitive(bEnable); + m_prbSingleField->set_sensitive(bEnable); + m_plbField->set_sensitive(bEnable && m_prbSingleField->get_active()); + m_pcbBackwards->set_sensitive(bEnable); + m_pcbStartOver->set_sensitive(bEnable); + m_pbClose->set_sensitive(bEnable); + EnableSearchForDependees(bEnable); if ( !bEnable ) { // this means we're preparing for starting a search // In this case, EnableSearchForDependees disabled the search button // But as we're about to use it for cancelling the search, we really need to enable it, again - m_pbSearchAgain->Enable(); + m_pbSearchAgain->set_sensitive(true); } - - if (!bEnable) - m_aDelayedPaint.Start(); - else - EnableControlPaint(true); - - if ( bEnable ) - { // restore focus - if ( m_pPreSearchFocus ) - { - m_pPreSearchFocus->GrabFocus(); - if ( WindowType::EDIT == m_pPreSearchFocus->GetType() ) - { - Edit* pEdit = static_cast< Edit* >( m_pPreSearchFocus.get() ); - pEdit->SetSelection( Selection( 0, pEdit->GetText().getLength() ) ); - } - } - m_pPreSearchFocus = nullptr; - } - } void FmSearchDialog::EnableSearchForDependees(bool bEnable) { - bool bSearchingForText = m_prbSearchForText->IsChecked(); - m_pbSearchAgain->Enable(bEnable && (!bSearchingForText || (!m_pcmbSearchText->GetText().isEmpty()))); + bool bSearchingForText = m_prbSearchForText->get_active(); + m_pbSearchAgain->set_sensitive(bEnable && (!bSearchingForText || (!m_pcmbSearchText->get_active_text().isEmpty()))); bEnable = bEnable && bSearchingForText; - bool bEnableRedundants = !m_pSoundsLikeCJK->IsChecked() || !SvtCJKOptions().IsJapaneseFindEnabled(); - - m_pcmbSearchText->Enable (bEnable); - m_pftPosition->Enable (bEnable && !m_pcbWildCard->IsChecked()); - m_pcbWildCard->Enable (bEnable && !m_pcbRegular->IsChecked() && !m_pcbApprox->IsChecked()); - m_pcbRegular->Enable (bEnable && !m_pcbWildCard->IsChecked() && !m_pcbApprox->IsChecked()); - m_pcbApprox->Enable (bEnable && !m_pcbWildCard->IsChecked() && !m_pcbRegular->IsChecked()); - m_ppbApproxSettings->Enable (bEnable && m_pcbApprox->IsChecked()); - m_pHalfFullFormsCJK->Enable (bEnable && bEnableRedundants); - m_pSoundsLikeCJK->Enable (bEnable); - m_pSoundsLikeCJKSettings->Enable (bEnable && m_pSoundsLikeCJK->IsChecked()); - m_plbPosition->Enable (bEnable && !m_pcbWildCard->IsChecked()); - m_pcbUseFormat->Enable (bEnable); - m_pcbCase->Enable (bEnable && bEnableRedundants); -} - -void FmSearchDialog::EnableControlPaint(bool bEnable) -{ - Control* pAffectedControls[] = { m_prbSearchForText, m_pcmbSearchText, m_prbSearchForNull, m_prbSearchForNotNull, - m_prbSearchForText, m_prbAllFields, m_prbSingleField, m_plbField, m_pftPosition, m_plbPosition, - m_pcbUseFormat, m_pcbCase, m_pcbBackwards, m_pcbStartOver, m_pcbWildCard, m_pcbRegular, m_pcbApprox, m_ppbApproxSettings, - m_pbSearchAgain, m_pbClose }; - - if (!bEnable) - for (Control* pAffectedControl : pAffectedControls) - { - pAffectedControl->SetUpdateMode(bEnable); - pAffectedControl->EnablePaint(bEnable); - } - else - for (Control* pAffectedControl : pAffectedControls) - { - pAffectedControl->EnablePaint(bEnable); - pAffectedControl->SetUpdateMode(bEnable); - } -} - -IMPL_LINK_NOARG(FmSearchDialog, OnDelayedPaint, Timer *, void) -{ - EnableControlPaint(true); + bool bEnableRedundants = !m_pSoundsLikeCJK->get_active() || !SvtCJKOptions().IsJapaneseFindEnabled(); + + m_pcmbSearchText->set_sensitive(bEnable); + m_pftPosition->set_sensitive(bEnable && !m_pcbWildCard->get_active()); + m_pcbWildCard->set_sensitive(bEnable && !m_pcbRegular->get_active() && !m_pcbApprox->get_active()); + m_pcbRegular->set_sensitive(bEnable && !m_pcbWildCard->get_active() && !m_pcbApprox->get_active()); + m_pcbApprox->set_sensitive(bEnable && !m_pcbWildCard->get_active() && !m_pcbRegular->get_active()); + m_ppbApproxSettings->set_sensitive(bEnable && m_pcbApprox->get_active()); + m_pHalfFullFormsCJK->set_sensitive(bEnable && bEnableRedundants); + m_pSoundsLikeCJK->set_sensitive(bEnable); + m_pSoundsLikeCJKSettings->set_sensitive(bEnable && m_pSoundsLikeCJK->get_active()); + m_plbPosition->set_sensitive(bEnable && !m_pcbWildCard->get_active()); + m_pcbUseFormat->set_sensitive(bEnable); + m_pcbCase->set_sensitive(bEnable && bEnableRedundants); } void FmSearchDialog::OnFound(const css::uno::Any& aCursorPos, sal_Int16 nFieldPos) { FmFoundRecordInformation friInfo; - friInfo.nContext = m_plbForm->GetSelectedEntryPos(); + friInfo.nContext = m_plbForm->get_active(); // if I don't do a search in a context, this has an invalid value - but then it doesn't matter anyway friInfo.aPosition = aCursorPos; - if (m_prbAllFields->IsChecked()) + if (m_prbAllFields->get_active()) friInfo.nFieldPos = nFieldPos; else - friInfo.nFieldPos = m_plbField->GetSelectedEntryPos(); + friInfo.nFieldPos = m_plbField->get_active(); // this of course implies that I have really searched in the field that is selected in the listbox, // which is made sure in RebuildUsedFields m_lnkFoundHandler.Call(friInfo); - m_pcmbSearchText->GrabFocus(); + m_pcmbSearchText->grab_focus(); } IMPL_LINK(FmSearchDialog, OnSearchProgress, const FmSearchProgress*, pProgress, void) @@ -697,21 +578,16 @@ IMPL_LINK(FmSearchDialog, OnSearchProgress, const FmSearchProgress*, pProgress, case FmSearchProgress::State::Progress: if (pProgress->bOverflow) { - OUString sHint( CuiResId( m_pcbBackwards->IsChecked() ? RID_STR_OVERFLOW_BACKWARD : RID_STR_OVERFLOW_FORWARD ) ); - m_pftHint->SetText( sHint ); - m_pftHint->Invalidate(); + OUString sHint( CuiResId( m_pcbBackwards->get_active() ? RID_STR_OVERFLOW_BACKWARD : RID_STR_OVERFLOW_FORWARD ) ); + m_pftHint->set_label( sHint ); } - m_pftRecord->SetText(OUString::number(1 + pProgress->nCurrentRecord)); - m_pftRecord->Invalidate(); + m_pftRecord->set_label(OUString::number(1 + pProgress->nCurrentRecord)); break; case FmSearchProgress::State::ProgressCounting: - m_pftHint->SetText(CuiResId(RID_STR_SEARCH_COUNTING)); - m_pftHint->Invalidate(); - - m_pftRecord->SetText(OUString::number(pProgress->nCurrentRecord)); - m_pftRecord->Invalidate(); + m_pftHint->set_label(CuiResId(RID_STR_SEARCH_COUNTING)); + m_pftRecord->set_label(OUString::number(pProgress->nCurrentRecord)); break; case FmSearchProgress::State::Successful: @@ -725,7 +601,7 @@ IMPL_LINK(FmSearchDialog, OnSearchProgress, const FmSearchProgress*, pProgress, const char* pErrorId = (FmSearchProgress::State::Error == pProgress->aSearchState) ? RID_STR_SEARCH_GENERAL_ERROR : RID_STR_SEARCH_NORECORD; - std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(GetFrameWeld(), + std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(m_xDialog.get(), VclMessageType::Warning, VclButtonsType::Ok, CuiResId(pErrorId))); xBox->run(); [[fallthrough]]; @@ -735,7 +611,7 @@ IMPL_LINK(FmSearchDialog, OnSearchProgress, const FmSearchProgress*, pProgress, if (m_lnkCanceledNotFoundHdl.IsSet()) { FmFoundRecordInformation friInfo; - friInfo.nContext = m_plbForm->GetSelectedEntryPos(); + friInfo.nContext = m_plbForm->get_active(); // if I don't do a search in a context, this has an invalid value - but then it doesn't matter anyway friInfo.aPosition = pProgress->aBookmark; m_lnkCanceledNotFoundHdl.Call(friInfo); @@ -743,7 +619,7 @@ IMPL_LINK(FmSearchDialog, OnSearchProgress, const FmSearchProgress*, pProgress, break; } - m_pftRecord->SetText(OUString::number(1 + pProgress->nCurrentRecord)); + m_pftRecord->set_label(OUString::number(1 + pProgress->nCurrentRecord)); } void FmSearchDialog::LoadParams() @@ -753,68 +629,68 @@ void FmSearchDialog::LoadParams() const OUString* pHistory = aParams.aHistory.getConstArray(); const OUString* pHistoryEnd = pHistory + aParams.aHistory.getLength(); for (; pHistory != pHistoryEnd; ++pHistory) - m_pcmbSearchText->InsertEntry( *pHistory ); + m_pcmbSearchText->append_text( *pHistory ); // I do the settings at my UI-elements and then I simply call the respective change-handler, // that way the data is handed on to the SearchEngine and all dependent settings are done // current field - sal_Int32 nInitialField = m_plbField->GetEntryPos( aParams.sSingleSearchField ); - if (nInitialField == LISTBOX_ENTRY_NOTFOUND) + int nInitialField = m_plbField->find_text( aParams.sSingleSearchField ); + if (nInitialField == -1) nInitialField = 0; - m_plbField->SelectEntryPos(nInitialField); - LINK(this, FmSearchDialog, OnFieldSelected).Call(*m_plbField); + m_plbField->set_active(nInitialField); + OnFieldSelected(*m_plbField); // all fields/single field (AFTER selecting the field because OnClickedFieldRadios expects a valid value there) if (aParams.bAllFields) { - m_prbSingleField->Check(false); - m_prbAllFields->Check(); - LINK(this, FmSearchDialog, OnClickedFieldRadios).Call(m_prbAllFields); + m_prbSingleField->set_active(false); + m_prbAllFields->set_active(true); + OnClickedFieldRadios(*m_prbAllFields); // OnClickedFieldRadios also calls to RebuildUsedFields } else { - m_prbAllFields->Check(false); - m_prbSingleField->Check(); - LINK(this, FmSearchDialog, OnClickedFieldRadios).Call(m_prbSingleField); + m_prbAllFields->set_active(false); + m_prbSingleField->set_active(true); + OnClickedFieldRadios(*m_prbSingleField); } - m_plbPosition->SelectEntryPos(aParams.nPosition); - LINK(this, FmSearchDialog, OnPositionSelected).Call(*m_plbPosition); + m_plbPosition->set_active(aParams.nPosition); + OnPositionSelected(*m_plbPosition); // field formatting/case sensitivity/direction - m_pcbUseFormat->Check(aParams.bUseFormatter); - m_pcbCase->Check( aParams.isCaseSensitive() ); - m_pcbBackwards->Check(aParams.bBackwards); - LINK(this, FmSearchDialog, OnCheckBoxToggled).Call(*m_pcbUseFormat); - LINK(this, FmSearchDialog, OnCheckBoxToggled).Call(*m_pcbCase); - LINK(this, FmSearchDialog, OnCheckBoxToggled).Call(*m_pcbBackwards); - - m_pHalfFullFormsCJK->Check( !aParams.isIgnoreWidthCJK( ) ); // BEWARE: this checkbox has a inverse semantics! - m_pSoundsLikeCJK->Check( aParams.bSoundsLikeCJK ); - LINK(this, FmSearchDialog, OnCheckBoxToggled).Call(*m_pHalfFullFormsCJK); - LINK(this, FmSearchDialog, OnCheckBoxToggled).Call(*m_pSoundsLikeCJK); - - m_pcbWildCard->Check(false); - m_pcbRegular->Check(false); - m_pcbApprox->Check(false); - LINK(this, FmSearchDialog, OnCheckBoxToggled).Call(*m_pcbWildCard); - LINK(this, FmSearchDialog, OnCheckBoxToggled).Call(*m_pcbRegular); - LINK(this, FmSearchDialog, OnCheckBoxToggled).Call(*m_pcbApprox); - - CheckBox* pToCheck = nullptr; + m_pcbUseFormat->set_active(aParams.bUseFormatter); + m_pcbCase->set_active( aParams.isCaseSensitive() ); + m_pcbBackwards->set_active(aParams.bBackwards); + OnCheckBoxToggled(*m_pcbUseFormat); + OnCheckBoxToggled(*m_pcbCase); + OnCheckBoxToggled(*m_pcbBackwards); + + m_pHalfFullFormsCJK->set_active( !aParams.isIgnoreWidthCJK( ) ); // BEWARE: this checkbox has a inverse semantics! + m_pSoundsLikeCJK->set_active( aParams.bSoundsLikeCJK ); + OnCheckBoxToggled(*m_pHalfFullFormsCJK); + OnCheckBoxToggled(*m_pSoundsLikeCJK); + + m_pcbWildCard->set_active(false); + m_pcbRegular->set_active(false); + m_pcbApprox->set_active(false); + OnCheckBoxToggled(*m_pcbWildCard); + OnCheckBoxToggled(*m_pcbRegular); + OnCheckBoxToggled(*m_pcbApprox); + + weld::CheckButton* pToCheck = nullptr; if (aParams.bWildcard) - pToCheck = m_pcbWildCard; + pToCheck = m_pcbWildCard.get(); if (aParams.bRegular) - pToCheck = m_pcbRegular; + pToCheck = m_pcbRegular.get(); if (aParams.bApproxSearch) - pToCheck = m_pcbApprox; + pToCheck = m_pcbApprox.get(); if (aParams.bSoundsLikeCJK) - pToCheck = m_pSoundsLikeCJK; + pToCheck = m_pSoundsLikeCJK.get(); if (pToCheck) { - pToCheck->Check(); - LINK(this, FmSearchDialog, OnCheckBoxToggled).Call(*pToCheck); + pToCheck->set_active(true); + OnCheckBoxToggled(*pToCheck); } // set Levenshtein-parameters directly at the SearchEngine @@ -825,16 +701,16 @@ void FmSearchDialog::LoadParams() m_pSearchEngine->SetTransliterationFlags( aParams.getTransliterationFlags( ) ); - m_prbSearchForText->Check(false); - m_prbSearchForNull->Check(false); - m_prbSearchForNotNull->Check(false); + m_prbSearchForText->set_active(false); + m_prbSearchForNull->set_active(false); + m_prbSearchForNotNull->set_active(false); switch (aParams.nSearchForType) { - case 1: m_prbSearchForNull->Check(); break; - case 2: m_prbSearchForNotNull->Check(); break; - default: m_prbSearchForText->Check(); break; + case 1: m_prbSearchForNull->set_active(true); break; + case 2: m_prbSearchForNotNull->set_active(true); break; + default: m_prbSearchForText->set_active(true); break; } - LINK(this, FmSearchDialog, OnClickedFieldRadios).Call(m_prbSearchForText); + OnClickedFieldRadios(*m_prbSearchForText); } void FmSearchDialog::SaveParams() const @@ -844,13 +720,14 @@ void FmSearchDialog::SaveParams() const FmSearchParams aCurrentSettings; - aCurrentSettings.aHistory.realloc( m_pcmbSearchText->GetEntryCount() ); + int nCount = m_pcmbSearchText->get_count(); + aCurrentSettings.aHistory.realloc(nCount); OUString* pHistory = aCurrentSettings.aHistory.getArray(); - for (sal_Int32 i=0; i<m_pcmbSearchText->GetEntryCount(); ++i, ++pHistory) - *pHistory = m_pcmbSearchText->GetEntry(i); + for (int i = 0; i < nCount; ++i, ++pHistory) + *pHistory = m_pcmbSearchText->get_text(i); - aCurrentSettings.sSingleSearchField = m_plbField->GetSelectedEntry(); - aCurrentSettings.bAllFields = m_prbAllFields->IsChecked(); + aCurrentSettings.sSingleSearchField = m_plbField->get_active_text(); + aCurrentSettings.bAllFields = m_prbAllFields->get_active(); aCurrentSettings.nPosition = m_pSearchEngine->GetPosition(); aCurrentSettings.bUseFormatter = m_pSearchEngine->GetFormatterUsing(); aCurrentSettings.setCaseSensitive ( m_pSearchEngine->GetCaseSensitive() ); @@ -866,9 +743,9 @@ void FmSearchDialog::SaveParams() const aCurrentSettings.bSoundsLikeCJK = m_pSearchEngine->GetTransliteration(); aCurrentSettings.setTransliterationFlags ( m_pSearchEngine->GetTransliterationFlags() ); - if (m_prbSearchForNull->IsChecked()) + if (m_prbSearchForNull->get_active()) aCurrentSettings.nSearchForType = 1; - else if (m_prbSearchForNotNull->IsChecked()) + else if (m_prbSearchForNotNull->get_active()) aCurrentSettings.nSearchForType = 2; else aCurrentSettings.nSearchForType = 0; diff --git a/cui/source/factory/dlgfact.cxx b/cui/source/factory/dlgfact.cxx index ec2b6015dff0..483e4352be73 100644 --- a/cui/source/factory/dlgfact.cxx +++ b/cui/source/factory/dlgfact.cxx @@ -217,7 +217,11 @@ short AbstractSvxPathSelectDialog_Impl::Execute() } IMPL_ABSTDLG_BASE(AbstractSvxHpLinkDlg_Impl); -IMPL_ABSTDLG_BASE(AbstractFmSearchDialog_Impl); + +short AbstractFmSearchDialog_Impl::Execute() +{ + return m_xDlg->run(); +} short AbstractGraphicFilterDialog_Impl::Execute() { @@ -792,18 +796,19 @@ bool AbstractSvxHpLinkDlg_Impl::QueryClose() return pDlg->QueryClose(); } - void AbstractFmSearchDialog_Impl::SetFoundHandler(const Link<FmFoundRecordInformation&,void>& lnk) { - pDlg->SetFoundHandler(lnk); + m_xDlg->SetFoundHandler(lnk); } + void AbstractFmSearchDialog_Impl::SetCanceledNotFoundHdl(const Link<FmFoundRecordInformation&,void>& lnk) { - pDlg->SetCanceledNotFoundHdl(lnk); + m_xDlg->SetCanceledNotFoundHdl(lnk); } + void AbstractFmSearchDialog_Impl::SetActiveField(const OUString& strField) { - pDlg->SetActiveField(strField); + m_xDlg->SetActiveField(strField); } Graphic AbstractGraphicFilterDialog_Impl::GetFilteredGraphic(const Graphic& rGraphic, double fScaleX, double fScaleY) @@ -1247,15 +1252,15 @@ VclPtr<AbstractSvxHpLinkDlg> AbstractDialogFactory_Impl::CreateSvxHpLinkDlg (vcl return VclPtr<AbstractSvxHpLinkDlg_Impl>::Create(pDlg); } -VclPtr<AbstractFmSearchDialog> AbstractDialogFactory_Impl::CreateFmSearchDialog(vcl::Window* pParent, +VclPtr<AbstractFmSearchDialog> AbstractDialogFactory_Impl::CreateFmSearchDialog(weld::Window* pParent, const OUString& strInitialText, const std::vector< OUString >& _rContexts, sal_Int16 nInitialContext, const Link<FmSearchContext&,sal_uInt32>& lnkContextSupplier) { - VclPtrInstance<FmSearchDialog> pDlg( pParent, strInitialText, _rContexts, - nInitialContext, lnkContextSupplier ); - return VclPtr<AbstractFmSearchDialog_Impl>::Create( pDlg ); + return VclPtr<AbstractFmSearchDialog_Impl>::Create(std::make_unique<FmSearchDialog>(pParent, + strInitialText, _rContexts, nInitialContext, lnkContextSupplier)); + } VclPtr<AbstractGraphicFilterDialog> AbstractDialogFactory_Impl::CreateGraphicFilterEmboss(weld::Window* pParent, diff --git a/cui/source/factory/dlgfact.hxx b/cui/source/factory/dlgfact.hxx index 7d7c165a4cee..ed27c2c8b6c6 100644 --- a/cui/source/factory/dlgfact.hxx +++ b/cui/source/factory/dlgfact.hxx @@ -506,7 +506,14 @@ class FmSearchDialog; struct FmFoundRecordInformation; class AbstractFmSearchDialog_Impl :public AbstractFmSearchDialog { - DECL_ABSTDLG_BASE(AbstractFmSearchDialog_Impl,FmSearchDialog) +protected: + std::unique_ptr<FmSearchDialog> m_xDlg; +public: + explicit AbstractFmSearchDialog_Impl(std::unique_ptr<FmSearchDialog> p) + : m_xDlg(std::move(p)) + { + } + virtual short Execute() override; virtual void SetFoundHandler(const Link<FmFoundRecordInformation&,void>& lnk) override ; virtual void SetCanceledNotFoundHdl(const Link<FmFoundRecordInformation&,void>& lnk) override; virtual void SetActiveField(const OUString& strField) override; @@ -783,7 +790,7 @@ public: virtual VclPtr<AbstractSvxMultiPathDialog> CreateSvxMultiPathDialog(weld::Window* pParent) override; virtual VclPtr<AbstractSvxMultiPathDialog> CreateSvxPathSelectDialog(weld::Window* pParent) override; virtual VclPtr<AbstractSvxHpLinkDlg> CreateSvxHpLinkDlg(vcl::Window* pParent, SfxBindings* pBindings) override; - virtual VclPtr<AbstractFmSearchDialog> CreateFmSearchDialog(vcl::Window* pParent, + virtual VclPtr<AbstractFmSearchDialog> CreateFmSearchDialog(weld::Window* pParent, const OUString& strInitialText, const std::vector< OUString >& _rContexts, sal_Int16 nInitialContext, diff --git a/cui/source/inc/cuifmsearch.hxx b/cui/source/inc/cuifmsearch.hxx index e137885de3c4..18ee588c63d6 100644 --- a/cui/source/inc/cuifmsearch.hxx +++ b/cui/source/inc/cuifmsearch.hxx @@ -41,42 +41,13 @@ struct FmSearchProgress; class FmSearchEngine; /// Dialog for searching in Forms/Tables -class FmSearchDialog final : public ModalDialog +class FmSearchDialog final : public weld::GenericDialogController { friend class FmSearchEngine; - // my all Controls - VclPtr<RadioButton> m_prbSearchForText; - VclPtr<RadioButton> m_prbSearchForNull; - VclPtr<RadioButton> m_prbSearchForNotNull; - VclPtr<ComboBox> m_pcmbSearchText; - VclPtr<FixedText> m_pftForm; - VclPtr<ListBox> m_plbForm; - VclPtr<RadioButton> m_prbAllFields; - VclPtr<RadioButton> m_prbSingleField; - VclPtr<ListBox> m_plbField; - VclPtr<FixedText> m_pftPosition; - VclPtr<ListBox> m_plbPosition; - VclPtr<CheckBox> m_pcbUseFormat; - VclPtr<CheckBox> m_pcbCase; - VclPtr<CheckBox> m_pcbBackwards; - VclPtr<CheckBox> m_pcbStartOver; - VclPtr<CheckBox> m_pcbWildCard; - VclPtr<CheckBox> m_pcbRegular; - VclPtr<CheckBox> m_pcbApprox; - VclPtr<PushButton> m_ppbApproxSettings; - VclPtr<CheckBox> m_pHalfFullFormsCJK; - VclPtr<CheckBox> m_pSoundsLikeCJK; - VclPtr<PushButton> m_pSoundsLikeCJKSettings; - VclPtr<FixedText> m_pftRecord; - VclPtr<FixedText> m_pftHint; - VclPtr<PushButton> m_pbSearchAgain; - VclPtr<CancelButton> m_pbClose; OUString m_sSearch; OUString m_sCancel; - VclPtr<vcl::Window> m_pPreSearchFocus; - Link<FmFoundRecordInformation&,void> m_lnkFoundHandler; ///< Handler for "found" Link<FmFoundRecordInformation&,void> m_lnkCanceledNotFoundHdl; ///< Handler for Positioning the Cursors @@ -87,10 +58,37 @@ class FmSearchDialog final : public ModalDialog std::unique_ptr<FmSearchEngine> m_pSearchEngine; - Timer m_aDelayedPaint; // see EnableSearchUI - std::unique_ptr<::svxform::FmSearchConfigItem> m_pConfig; + + // my all Controls + std::unique_ptr<weld::RadioButton> m_prbSearchForText; + std::unique_ptr<weld::RadioButton> m_prbSearchForNull; + std::unique_ptr<weld::RadioButton> m_prbSearchForNotNull; + std::unique_ptr<weld::ComboBox> m_pcmbSearchText; + std::unique_ptr<weld::Label> m_pftForm; + std::unique_ptr<weld::ComboBox> m_plbForm; + std::unique_ptr<weld::RadioButton> m_prbAllFields; + std::unique_ptr<weld::RadioButton> m_prbSingleField; + std::unique_ptr<weld::ComboBox> m_plbField; + std::unique_ptr<weld::Label> m_pftPosition; + std::unique_ptr<weld::ComboBox> m_plbPosition; + std::unique_ptr<weld::CheckButton> m_pcbUseFormat; + std::unique_ptr<weld::CheckButton> m_pcbCase; + std::unique_ptr<weld::CheckButton> m_pcbBackwards; + std::unique_ptr<weld::CheckButton> m_pcbStartOver; + std::unique_ptr<weld::CheckButton> m_pcbWildCard; + std::unique_ptr<weld::CheckButton> m_pcbRegular; + std::unique_ptr<weld::CheckButton> m_pcbApprox; + std::unique_ptr<weld::Button> m_ppbApproxSettings; + std::unique_ptr<weld::CheckButton> m_pHalfFullFormsCJK; + std::unique_ptr<weld::CheckButton> m_pSoundsLikeCJK; + std::unique_ptr<weld::Button> m_pSoundsLikeCJKSettings; + std::unique_ptr<weld::Label> m_pftRecord; + std::unique_ptr<weld::Label> m_pftHint; + std::unique_ptr<weld::Button> m_pbSearchAgain; + std::unique_ptr<weld::Button> m_pbClose; + public: /** This can search in different sets of fields. There is a number of contexts; their names are in strContexts (separated by ';'), the user can choose one of them. @@ -106,11 +104,12 @@ public: (of course needed : the string number i in strUsedFields of a context must correspond with the interface number i in the arrFields of the context) */ - FmSearchDialog(vcl::Window* pParent, const OUString& strInitialText, const std::vector< OUString >& _rContexts, sal_Int16 nInitialContext, + FmSearchDialog(weld::Window* pParent, const OUString& strInitialText, const std::vector< OUString >& _rContexts, sal_Int16 nInitialContext, const Link<FmSearchContext&,sal_uInt32>& lnkContextSupplier); + virtual short run() override; + virtual ~FmSearchDialog() override; - virtual void dispose() override; /** The found-handler gets in the 'found'-case a pointer on a FmFoundRecordInformation-structure (which is only valid in the handler; so if one needs to memorize the data, don't copy the pointer but @@ -131,58 +130,47 @@ public: inline void SetActiveField(const OUString& strField); private: - virtual bool Close() override; - void Init(const OUString& strVisibleFields, const OUString& strInitialText); // only to be used out of the constructors void OnFound(const css::uno::Any& aCursorPos, sal_Int16 nFieldPos); - /** When searching in an own thread I naturally want to disable the UI for starting the search and for setting search - parameters. If bEnable == sal_False, for all affected controls painting is turned off and shortly after turned on - again using m_aDelayedPaint. If there is a demand with bEnable == sal_True inbetween, the timer is stopped and - painting is turned on immediately. As a consequence for this intricateness there is no flickering when turning - off and on quickly. - */ + void EnableSearchUI(bool bEnable); void EnableSearchForDependees(bool bEnable); - void EnableControlPaint(bool bEnable); - void InitContext(sal_Int16 nContext); void LoadParams(); void SaveParams() const; // Handler for the Controls - DECL_LINK( OnClickedFieldRadios, Button*, void ); - DECL_LINK(OnClickedSearchAgain, Button *, void); - DECL_LINK( OnClickedSpecialSettings, Button*, void ); + DECL_LINK( OnClickedFieldRadios, weld::Button&, void ); + DECL_LINK( OnClickedSearchAgain, weld::Button&, void ); + DECL_LINK( OnClickedSpecialSettings, weld::Button&, void ); - DECL_LINK(OnSearchTextModified, Edit&, void); + DECL_LINK( OnSearchTextModified, weld::ComboBox&, void ); - DECL_LINK( OnPositionSelected, ListBox&, void ); - DECL_LINK( OnFieldSelected, ListBox&, void ); + DECL_LINK( OnPositionSelected, weld::ComboBox&, void ); + DECL_LINK( OnFieldSelected, weld::ComboBox&, void ); - DECL_LINK( OnFocusGrabbed, Control&, void ); - DECL_LINK( OnCheckBoxToggled, CheckBox&, void ); + DECL_LINK( OnFocusGrabbed, weld::Widget&, void ); + DECL_LINK( OnCheckBoxToggled, weld::ToggleButton&, void ); - DECL_LINK( OnContextSelection, ListBox&, void ); + DECL_LINK( OnContextSelection, weld::ComboBox&, void ); DECL_LINK( OnSearchProgress, const FmSearchProgress*, void ); - DECL_LINK( OnDelayedPaint, Timer*, void ); ///< see EnableSearchUI - void initCommon( const css::uno::Reference< css::sdbc::XResultSet >& _rxCursor ); }; inline void FmSearchDialog::SetActiveField(const OUString& strField) { - sal_Int32 nInitialField = m_plbField->GetEntryPos(strField); - if (nInitialField == LISTBOX_ENTRY_NOTFOUND) + int nInitialField = m_plbField->find_text(strField); + if (nInitialField == -1) nInitialField = 0; - m_plbField->SelectEntryPos(nInitialField); - LINK(this, FmSearchDialog, OnFieldSelected).Call(*m_plbField); + m_plbField->set_active(nInitialField); + OnFieldSelected(*m_plbField); } #endif // INCLUDED_CUI_SOURCE_INC_CUIFMSEARCH_HXX diff --git a/cui/uiconfig/ui/fmsearchdialog.ui b/cui/uiconfig/ui/fmsearchdialog.ui index 1c752e543dd5..92a7ed83fdfd 100644 --- a/cui/uiconfig/ui/fmsearchdialog.ui +++ b/cui/uiconfig/ui/fmsearchdialog.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="cui"> <requires lib="gtk+" version="3.18"/> <object class="GtkDialog" id="RecordSearchDialog"> <property name="can_focus">False</property> <property name="border_width">6</property> <property name="title" translatable="yes" context="fmsearchdialog|RecordSearchDialog">Record Search</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-vbox3"> <property name="can_focus">False</property> @@ -117,7 +123,7 @@ <property name="hexpand">True</property> <property name="column_spacing">12</property> <child> - <object class="GtkComboBox" id="cmbSearchText"> + <object class="GtkComboBoxText" id="cmbSearchText"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="valign">start</property> @@ -125,7 +131,8 @@ <property name="has_entry">True</property> <child internal-child="entry"> <object class="GtkEntry" id="combobox-entry2"> - <property name="can_focus">False</property> + <property name="can_focus">True</property> + <property name="activates_default">True</property> </object> </child> </object> @@ -279,7 +286,7 @@ </packing> </child> <child> - <object class="GtkComboBox" id="lbField"> + <object class="GtkComboBoxText" id="lbField"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="halign">start</property> @@ -323,10 +330,10 @@ <object class="GtkLabel" id="ftForm"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">0</property> <property name="label" translatable="yes" context="fmsearchdialog|ftForm">Form:</property> <property name="use_underline">True</property> <property name="mnemonic_widget">lbForm</property> + <property name="xalign">0</property> </object> <packing> <property name="left_attach">0</property> @@ -334,7 +341,7 @@ </packing> </child> <child> - <object class="GtkComboBox" id="lbForm"> + <object class="GtkComboBoxText" id="lbForm"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="halign">start</property> @@ -375,8 +382,8 @@ <property name="visible">True</property> <property name="can_focus">False</property> <property name="hexpand">True</property> - <property name="xalign">0</property> <property name="wrap">True</property> + <property name="xalign">0</property> </object> <packing> <property name="expand">False</property> @@ -448,10 +455,10 @@ <object class="GtkLabel" id="ftPosition"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">0</property> <property name="label" translatable="yes" context="fmsearchdialog|ftPosition">_Position:</property> <property name="use_underline">True</property> <property name="mnemonic_widget">lbPosition</property> + <property name="xalign">0</property> </object> <packing> <property name="left_attach">0</property> @@ -459,7 +466,7 @@ </packing> </child> <child> - <object class="GtkComboBox" id="lbPosition"> + <object class="GtkComboBoxText" id="lbPosition"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="halign">start</property> @@ -719,8 +726,8 @@ <object class="GtkLabel" id="ftRecordLabel"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">0</property> <property name="label" translatable="yes" context="fmsearchdialog|ftRecordLabel">Record:</property> + <property name="xalign">0</property> </object> <packing> <property name="left_attach">0</property> @@ -780,6 +787,7 @@ </object> </child> <action-widgets> + <action-widget response="-7">close</action-widget> <action-widget response="-11">help</action-widget> </action-widgets> </object> |