36using namespace css::uno;
37using namespace css::i18n;
39using namespace css::sdbc;
40using namespace css::util;
42#define MAX_HISTORY_ENTRIES 50
67 m_pftRecord->set_label( OUString::number(_rxCursor->getRow()) );
73 : GenericDialogController(pParent,
"cui/ui/fmsearchdialog.ui",
"RecordSearchDialog")
75 , m_lnkContextSupplier(lnkContextSupplier)
76 , m_prbSearchForText(m_xBuilder->weld_radio_button(
"rbSearchForText"))
77 , m_prbSearchForNull(m_xBuilder->weld_radio_button(
"rbSearchForNull"))
78 , m_prbSearchForNotNull(m_xBuilder->weld_radio_button(
"rbSearchForNotNull"))
79 , m_pcmbSearchText(m_xBuilder->weld_combo_box(
"cmbSearchText"))
80 , m_pftForm(m_xBuilder->weld_label(
"ftForm"))
81 , m_plbForm(m_xBuilder->weld_combo_box(
"lbForm"))
82 , m_prbAllFields(m_xBuilder->weld_radio_button(
"rbAllFields"))
83 , m_prbSingleField(m_xBuilder->weld_radio_button(
"rbSingleField"))
84 , m_plbField(m_xBuilder->weld_combo_box(
"lbField"))
85 , m_pftPosition(m_xBuilder->weld_label(
"ftPosition"))
86 , m_plbPosition(m_xBuilder->weld_combo_box(
"lbPosition"))
87 , m_pcbUseFormat(m_xBuilder->weld_check_button(
"cbUseFormat"))
88 , m_pcbCase(m_xBuilder->weld_check_button(
"cbCase"))
89 , m_pcbBackwards(m_xBuilder->weld_check_button(
"cbBackwards"))
90 , m_pcbStartOver(m_xBuilder->weld_check_button(
"cbStartOver"))
91 , m_pcbWildCard(m_xBuilder->weld_check_button(
"cbWildCard"))
92 , m_pcbRegular(m_xBuilder->weld_check_button(
"cbRegular"))
93 , m_pcbApprox(m_xBuilder->weld_check_button(
"cbApprox"))
94 , m_ppbApproxSettings(m_xBuilder->weld_button(
"pbApproxSettings"))
95 , m_pHalfFullFormsCJK(m_xBuilder->weld_check_button(
"HalfFullFormsCJK"))
96 , m_pSoundsLikeCJK(m_xBuilder->weld_check_button(
"SoundsLikeCJK"))
97 , m_pSoundsLikeCJKSettings(m_xBuilder->weld_button(
"SoundsLikeCJKSettings"))
98 , m_pftRecord(m_xBuilder->weld_label(
"ftRecord"))
99 , m_pftHint(m_xBuilder->weld_label(
"ftHint"))
100 , m_pbSearchAgain(m_xBuilder->weld_button(
"pbSearchAgain"))
101 , m_pbClose(m_xBuilder->weld_button(
"close"))
110 fmscInitial.
nContext = nInitialContext;
112 DBG_ASSERT(fmscInitial.
xCursor.is(),
"FmSearchDialog::FmSearchDialog : invalid data supplied by ContextSupplier !");
114 "FmSearchDialog::FmSearchDialog : invalid data supplied by ContextSupplied !");
115#if (OSL_DEBUG_LEVEL > 1) || defined DBG_UTIL
116 for (
const Reference<XInterface> & arrField : fmscInitial.
arrFields)
118 DBG_ASSERT(arrField.is(),
"FmSearchDialog::FmSearchDialog : invalid data supplied by ContextSupplier !");
122 for ( std::vector< OUString >::const_iterator context = _rContexts.begin();
123 context != _rContexts.end();
148 "FmSearchDialog::FmSearchDialog : invalid initial context description !");
197 RID_STR_SEARCH_ANYWHERE,
198 RID_STR_SEARCH_BEGINNING,
202 for (
auto const & pResId : aResIds)
207 if (!strVisibleFields.empty())
216 m_pConfig.reset(
new FmSearchConfigItem );
224 if (sRealSetText != sInitialText)
245 if (!rButton.get_active())
247 EnableSearchForDependees(
true);
252 if (!rButton.get_active())
256 if (m_prbSingleField->get_active())
258 m_plbField->set_sensitive(
true);
259 m_pSearchEngine->RebuildUsedFields(m_plbField->get_active());
263 m_plbField->set_sensitive(
false);
264 m_pSearchEngine->RebuildUsedFields(-1);
270 if (m_pbClose->get_sensitive())
272 OUString strThisRoundText = m_pcmbSearchText->get_active_text();
274 m_pcmbSearchText->remove_text(strThisRoundText);
275 m_pcmbSearchText->insert_text(0, strThisRoundText);
279 m_pcmbSearchText->remove(m_pcmbSearchText->get_count()-1);
282 m_pftHint->set_label(OUString());
284 if (m_pcbStartOver->get_active())
286 m_pcbStartOver->set_active(
false);
287 EnableSearchUI(
false);
288 if (m_prbSearchForText->get_active())
289 m_pSearchEngine->StartOver(strThisRoundText);
291 m_pSearchEngine->StartOverSpecial(m_prbSearchForNull->get_active());
295 EnableSearchUI(
false);
296 if (m_prbSearchForText->get_active())
297 m_pSearchEngine->SearchNext(strThisRoundText);
299 m_pSearchEngine->SearchNextSpecial(m_prbSearchForNull->get_active());
305 m_pSearchEngine->CancelSearch();
312 if (m_ppbApproxSettings.get() == &rButton)
317 m_pSearchEngine->GetLevShorter(), m_pSearchEngine->GetLevLonger() ));
318 pDlg->StartExecuteAsync([pDlg,
this](sal_Int32 nResult){
322 m_pSearchEngine->SetLevRelaxed( pDlg->IsRelaxed() );
323 m_pSearchEngine->SetLevOther( pDlg->GetOther() );
324 m_pSearchEngine->SetLevShorter(pDlg->GetShorter() );
325 m_pSearchEngine->SetLevLonger( pDlg->GetLonger() );
330 else if (m_pSoundsLikeCJKSettings.get() == &rButton)
338 m_pSearchEngine->SetTransliterationFlags(nFlags);
340 m_pcbCase->set_active(m_pSearchEngine->GetCaseSensitive());
341 OnCheckBoxToggled( *m_pcbCase );
342 m_pHalfFullFormsCJK->set_active( !m_pSearchEngine->GetIgnoreWidthCJK() );
343 OnCheckBoxToggled( *m_pHalfFullFormsCJK );
349 if ((!m_pcmbSearchText->get_active_text().isEmpty()) || !m_prbSearchForText->get_active())
350 m_pbSearchAgain->set_sensitive(
true);
352 m_pbSearchAgain->set_sensitive(
false);
354 m_pSearchEngine->InvalidatePreviousLoc();
359 m_pcmbSearchText->select_entry_region(0, -1);
364 m_pSearchEngine->SetPosition(m_plbPosition->get_active());
369 m_pSearchEngine->RebuildUsedFields(m_prbAllFields->get_active() ? -1 : m_plbField->get_active());
372 int nCurrentContext = m_plbForm->get_active();
373 if (nCurrentContext != -1)
374 m_arrContextFields[nCurrentContext] = m_plbField->get_active_text();
379 bool bChecked = rBox.get_active();
382 if (&rBox == m_pcbUseFormat.get())
383 m_pSearchEngine->SetFormatterUsing(bChecked);
384 else if (&rBox == m_pcbCase.get())
385 m_pSearchEngine->SetCaseSensitive(bChecked);
387 else if (&rBox == m_pcbBackwards.get())
389 m_pcbStartOver->set_label(
CuiResId( bChecked ? RID_STR_FROM_BOTTOM : RID_STR_FROM_TOP ) );
390 m_pSearchEngine->SetDirection(!bChecked);
393 else if ((&rBox == m_pcbApprox.get()) || (&rBox == m_pcbRegular.get()) || (&rBox == m_pcbWildCard.get()))
395 weld::CheckButton* pBoxes[] = { m_pcbWildCard.get(), m_pcbRegular.get(), m_pcbApprox.get() };
403 pBoxe->set_sensitive(
true);
408 m_pSearchEngine->SetWildcard(m_pcbWildCard->get_sensitive() && m_pcbWildCard->get_active());
409 m_pSearchEngine->SetRegular(m_pcbRegular->get_sensitive() && m_pcbRegular->get_active());
410 m_pSearchEngine->SetLevenshtein(m_pcbApprox->get_sensitive() && m_pcbApprox->get_active());
414 if (&rBox == m_pcbWildCard.get())
418 m_pftPosition->set_sensitive(
false);
419 m_plbPosition->set_sensitive(
false);
423 m_pftPosition->set_sensitive(
true);
424 m_plbPosition->set_sensitive(
true);
429 if (&rBox == m_pcbApprox.get())
432 m_ppbApproxSettings->set_sensitive(
true);
434 m_ppbApproxSettings->set_sensitive(
false);
437 else if (&rBox == m_pHalfFullFormsCJK.get())
440 m_pSearchEngine->SetIgnoreWidthCJK( !bChecked );
442 else if (&rBox == m_pSoundsLikeCJK.get())
444 m_pSoundsLikeCJKSettings->set_sensitive(bChecked);
447 bool bEnable = ( m_prbSearchForText->get_active()
448 && !m_pSoundsLikeCJK->get_active()
451 m_pcbCase->set_sensitive(bEnable);
452 m_pHalfFullFormsCJK->set_sensitive(bEnable);
455 m_pSearchEngine->SetTransliteration( bChecked );
465 DBG_ASSERT(nResult > 0,
"FmSearchDialog::InitContext : ContextSupplier didn't give me any controls !");
474 "FmSearchDialog::InitContext : invalid context description supplied !");
508 InitContext(rBox.get_active());
542 bEnable = bEnable && bSearchingForText;
557 m_pcbCase->set_sensitive(bEnable && bEnableRedundants);
584 switch (pProgress->aSearchState)
587 if (pProgress->bOverflow)
589 OUString sHint(
CuiResId( m_pcbBackwards->get_active() ? RID_STR_OVERFLOW_BACKWARD : RID_STR_OVERFLOW_FORWARD ) );
590 m_pftHint->set_label( sHint );
593 m_pftRecord->set_label(OUString::number(1 + pProgress->nCurrentRecord));
597 m_pftHint->set_label(
CuiResId(RID_STR_SEARCH_COUNTING));
598 m_pftRecord->set_label(OUString::number(pProgress->nCurrentRecord));
602 OnFound(pProgress->aBookmark,
static_cast<sal_Int16
>(pProgress->nFieldIndex));
603 EnableSearchUI(
true);
610 ? RID_STR_SEARCH_GENERAL_ERROR
611 : RID_STR_SEARCH_NORECORD;
613 VclMessageType::Warning, VclButtonsType::Ok,
CuiResId(pErrorId)));
618 EnableSearchUI(
true);
619 if (m_lnkCanceledNotFoundHdl.IsSet())
622 friInfo.
nContext = m_plbForm->get_active();
624 friInfo.
aPosition = pProgress->aBookmark;
625 m_lnkCanceledNotFoundHdl.Call(friInfo);
630 m_pftRecord->set_label(OUString::number(1 + pProgress->nCurrentRecord));
635 FmSearchParams aParams(
m_pConfig->getParams());
637 const OUString* pHistory = aParams.aHistory.getConstArray();
638 const OUString* pHistoryEnd = pHistory + aParams.aHistory.getLength();
639 for (; pHistory != pHistoryEnd; ++pHistory)
646 int nInitialField =
m_plbField->find_text( aParams.sSingleSearchField );
647 if (nInitialField == -1)
652 if (aParams.bAllFields)
671 m_pcbCase->set_active( aParams.isCaseSensitive() );
690 if (aParams.bWildcard)
692 if (aParams.bRegular)
694 if (aParams.bApproxSearch)
696 if (aParams.bSoundsLikeCJK)
701 OnCheckBoxToggled(*pToCheck);
710 m_pSearchEngine->SetTransliterationFlags( aParams.getTransliterationFlags( ) );
715 switch (aParams.nSearchForType)
729 FmSearchParams aCurrentSettings;
732 aCurrentSettings.aHistory.realloc(
nCount);
733 OUString* pHistory = aCurrentSettings.aHistory.getArray();
734 for (
int i = 0;
i <
nCount; ++
i, ++pHistory)
737 aCurrentSettings.sSingleSearchField =
m_plbField->get_active_text();
741 aCurrentSettings.setCaseSensitive (
m_pSearchEngine->GetCaseSensitive() );
751 aCurrentSettings.bSoundsLikeCJK =
m_pSearchEngine->GetTransliteration();
752 aCurrentSettings.setTransliterationFlags (
m_pSearchEngine->GetTransliterationFlags() );
755 aCurrentSettings.nSearchForType = 1;
757 aCurrentSettings.nSearchForType = 2;
759 aCurrentSettings.nSearchForType = 0;
761 m_pConfig->setParams( aCurrentSettings );
SfxApplication * SfxGetpApp()
Reference< XExecutableDialog > m_xDialog
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, const ILibreOfficeKitNotifier *pNotifier=nullptr)
Dialog for searching in Forms/Tables.
std::unique_ptr< weld::Button > m_ppbApproxSettings
std::unique_ptr< weld::Button > m_pbSearchAgain
std::unique_ptr< weld::CheckButton > m_pcbWildCard
void InitContext(sal_Int16 nContext)
std::unique_ptr< weld::Label > m_pftForm
std::unique_ptr< weld::CheckButton > m_pcbStartOver
std::unique_ptr< weld::RadioButton > m_prbSingleField
std::unique_ptr< weld::CheckButton > m_pcbBackwards
void OnFound(const css::uno::Any &aCursorPos, sal_Int16 nFieldPos)
friend class FmSearchEngine
void EnableSearchForDependees(bool bEnable)
std::unique_ptr< weld::ComboBox > m_plbForm
std::unique_ptr< weld::CheckButton > m_pcbApprox
std::unique_ptr< weld::CheckButton > m_pcbRegular
std::unique_ptr< weld::CheckButton > m_pcbCase
std::unique_ptr< weld::CheckButton > m_pHalfFullFormsCJK
virtual short run() override
std::unique_ptr<::svxform::FmSearchConfigItem > m_pConfig
void initCommon(const css::uno::Reference< css::sdbc::XResultSet > &_rxCursor)
std::unique_ptr< weld::RadioButton > m_prbSearchForNotNull
void EnableSearchUI(bool bEnable)
std::unique_ptr< weld::ComboBox > m_plbPosition
void Init(std::u16string_view strVisibleFields, const OUString &strInitialText)
Link< FmFoundRecordInformation &, void > m_lnkFoundHandler
Handler for "found".
std::unique_ptr< weld::RadioButton > m_prbAllFields
std::unique_ptr< weld::CheckButton > m_pSoundsLikeCJK
std::unique_ptr< weld::Label > m_pftPosition
std::unique_ptr< weld::Button > m_pbClose
std::unique_ptr< weld::CheckButton > m_pcbUseFormat
FmSearchDialog(weld::Window *pParent, const OUString &strInitialText, const std::vector< OUString > &_rContexts, sal_Int16 nInitialContext, const Link< FmSearchContext &, sal_uInt32 > &lnkContextSupplier)
This can search in different sets of fields.
virtual ~FmSearchDialog() override
std::unique_ptr< FmSearchEngine > m_pSearchEngine
std::unique_ptr< weld::Button > m_pSoundsLikeCJKSettings
std::unique_ptr< weld::RadioButton > m_prbSearchForText
std::vector< OUString > m_arrContextFields
memorize the currently selected field for every context
Link< FmSearchContext &, sal_uInt32 > m_lnkContextSupplier
for search in contexts
std::unique_ptr< weld::ComboBox > m_plbField
std::unique_ptr< weld::ComboBox > m_pcmbSearchText
std::unique_ptr< weld::RadioButton > m_prbSearchForNull
std::unique_ptr< weld::Label > m_pftRecord
virtual VclPtr< AbstractSvxJSearchOptionsDialog > CreateSvxJSearchOptionsDialog(weld::Window *pParent, const SfxItemSet &rOptionsSet, TransliterationFlags nInitialFlags)=0
virtual VclPtr< AbstractSvxSearchSimilarityDialog > CreateSvxSearchSimilarityDialog(weld::Window *pParent, bool bRelax, sal_uInt16 nOther, sal_uInt16 nShorter, sal_uInt16 nLonger)=0
static SvxAbstractDialogFactory * Create()
virtual void set_active(bool active)=0
IMPL_LINK(FmSearchDialog, OnToggledSearchRadio, weld::Toggleable &, rButton, void)
#define MAX_HISTORY_ENTRIES
IMPL_LINK_NOARG(FmSearchDialog, OnClickedSearchAgain, weld::Button &, void)
OUString CuiResId(TranslateId aKey)
#define DBG_ASSERT(sCon, aError)
#define MATCHING_ANYWHERE
#define LINK(Instance, Class, Member)
bool IsJapaneseFindEnabled()
sal_Int32 getTokenCount(std::string_view rIn, char cTok)
std::basic_string_view< charT, traits > getToken(std::basic_string_view< charT, traits > sv, charT delimiter, std::size_t &position)
OUString VCL_DLLPUBLIC GetStandardText(StandardButtonType eButton)
::std::vector< css::uno::Reference< css::uno::XInterface > > arrFields
css::uno::Reference< css::sdbc::XResultSet > xCursor
OUString sFieldDisplayNames