24 #include <dialmgr.hxx>
28 #include <strings.hrc>
41 #define MAX_HISTORY_ENTRIES 50
46 DBG_ASSERT( m_pSearchEngine,
"FmSearchDialog::initCommon: have no engine!" );
54 m_pSoundsLikeCJK->hide();
55 m_pSoundsLikeCJKSettings->hide();
60 m_pHalfFullFormsCJK->hide();
63 m_pSearchEngine->SetIgnoreWidthCJK(
false );
67 m_pftRecord->set_label( OUString::number(_rxCursor->getRow()) );
68 m_pbClose->set_tooltip_text(OUString());
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 !");
120 #endif // (OSL_DEBUG_LEVEL > 1) || DBG_UTIL
122 for ( std::vector< OUString >::const_iterator context = _rContexts.begin();
123 context != _rContexts.end();
145 if ( !fmscInitial.sFieldDisplayNames.isEmpty() )
148 "FmSearchDialog::FmSearchDialog : invalid initial context description !");
149 Init(fmscInitial.sFieldDisplayNames, sInitialText);
152 Init(fmscInitial.strUsedFields, sInitialText);
196 const char*
const aResIds[] = {
197 RID_STR_SEARCH_ANYWHERE,
198 RID_STR_SEARCH_BEGINNING,
202 for (
auto pResId : aResIds)
207 if (!strVisibleFields.isEmpty())
216 m_pConfig.reset(
new FmSearchConfigItem );
224 if (sRealSetText != sInitialText)
245 if ((&rButton == m_prbSearchForText.get()) || (&rButton == m_prbSearchForNull.get()) || (&rButton == m_prbSearchForNotNull.get()))
247 EnableSearchForDependees(
true);
251 if (&rButton == m_prbSingleField.get())
253 m_plbField->set_sensitive(
true);
254 m_pSearchEngine->RebuildUsedFields(m_plbField->get_active());
258 m_plbField->set_sensitive(
false);
259 m_pSearchEngine->RebuildUsedFields(-1);
265 if (m_pbClose->get_sensitive())
267 OUString strThisRoundText = m_pcmbSearchText->get_active_text();
269 m_pcmbSearchText->remove_text(strThisRoundText);
270 m_pcmbSearchText->insert_text(0, strThisRoundText);
274 m_pcmbSearchText->remove(m_pcmbSearchText->get_count()-1);
277 m_pftHint->set_label(OUString());
279 if (m_pcbStartOver->get_active())
281 m_pcbStartOver->set_active(
false);
282 EnableSearchUI(
false);
283 if (m_prbSearchForText->get_active())
284 m_pSearchEngine->StartOver(strThisRoundText);
286 m_pSearchEngine->StartOverSpecial(m_prbSearchForNull->get_active());
290 EnableSearchUI(
false);
291 if (m_prbSearchForText->get_active())
292 m_pSearchEngine->SearchNext(strThisRoundText);
294 m_pSearchEngine->SearchNextSpecial(m_prbSearchForNull->get_active());
300 m_pSearchEngine->CancelSearch();
307 if (m_ppbApproxSettings.get() == &rButton)
311 m_pSearchEngine->GetLevShorter(), m_pSearchEngine->GetLevLonger() ));
312 if (pDlg->Execute() ==
RET_OK)
314 m_pSearchEngine->SetLevRelaxed( pDlg->
IsRelaxed() );
315 m_pSearchEngine->SetLevOther( pDlg->
GetOther() );
316 m_pSearchEngine->SetLevShorter(pDlg->
GetShorter() );
317 m_pSearchEngine->SetLevLonger( pDlg->
GetLonger() );
320 else if (m_pSoundsLikeCJKSettings.get() == &rButton)
328 m_pSearchEngine->SetTransliterationFlags(nFlags);
330 m_pcbCase->set_active(m_pSearchEngine->GetCaseSensitive());
331 OnCheckBoxToggled( *m_pcbCase );
332 m_pHalfFullFormsCJK->set_active( !m_pSearchEngine->GetIgnoreWidthCJK() );
333 OnCheckBoxToggled( *m_pHalfFullFormsCJK );
339 if ((!m_pcmbSearchText->get_active_text().isEmpty()) || !m_prbSearchForText->get_active())
340 m_pbSearchAgain->set_sensitive(
true);
342 m_pbSearchAgain->set_sensitive(
false);
344 m_pSearchEngine->InvalidatePreviousLoc();
349 m_pcmbSearchText->select_entry_region(0, -1);
354 m_pSearchEngine->SetPosition(m_plbPosition->get_active());
359 m_pSearchEngine->RebuildUsedFields(m_prbAllFields->get_active() ? -1 : m_plbField->get_active());
362 int nCurrentContext = m_plbForm->get_active();
363 if (nCurrentContext != -1)
364 m_arrContextFields[nCurrentContext] = m_plbField->get_active_text();
369 bool bChecked = rBox.get_active();
372 if (&rBox == m_pcbUseFormat.get())
373 m_pSearchEngine->SetFormatterUsing(bChecked);
374 else if (&rBox == m_pcbCase.get())
375 m_pSearchEngine->SetCaseSensitive(bChecked);
377 else if (&rBox == m_pcbBackwards.get())
379 m_pcbStartOver->set_label(
CuiResId( bChecked ? RID_STR_FROM_BOTTOM : RID_STR_FROM_TOP ) );
380 m_pSearchEngine->SetDirection(!bChecked);
383 else if ((&rBox == m_pcbApprox.get()) || (&rBox == m_pcbRegular.get()) || (&rBox == m_pcbWildCard.get()))
385 weld::CheckButton* pBoxes[] = { m_pcbWildCard.get(), m_pcbRegular.get(), m_pcbApprox.get() };
393 pBoxe->set_sensitive(
true);
398 m_pSearchEngine->SetWildcard(m_pcbWildCard->get_sensitive() && m_pcbWildCard->get_active());
399 m_pSearchEngine->SetRegular(m_pcbRegular->get_sensitive() && m_pcbRegular->get_active());
400 m_pSearchEngine->SetLevenshtein(m_pcbApprox->get_sensitive() && m_pcbApprox->get_active());
404 if (&rBox == m_pcbWildCard.get())
408 m_pftPosition->set_sensitive(
false);
409 m_plbPosition->set_sensitive(
false);
413 m_pftPosition->set_sensitive(
true);
414 m_plbPosition->set_sensitive(
true);
419 if (&rBox == m_pcbApprox.get())
422 m_ppbApproxSettings->set_sensitive(
true);
424 m_ppbApproxSettings->set_sensitive(
false);
427 else if (&rBox == m_pHalfFullFormsCJK.get())
430 m_pSearchEngine->SetIgnoreWidthCJK( !bChecked );
432 else if (&rBox == m_pSoundsLikeCJK.get())
434 m_pSoundsLikeCJKSettings->set_sensitive(bChecked);
437 bool bEnable = ( m_prbSearchForText->get_active()
438 && !m_pSoundsLikeCJK->get_active()
441 m_pcbCase->set_sensitive(bEnable);
442 m_pHalfFullFormsCJK->set_sensitive(bEnable);
445 m_pSearchEngine->SetTransliteration( bChecked );
455 DBG_ASSERT(nResult > 0,
"FmSearchDialog::InitContext : ContextSupplier didn't give me any controls !");
464 "FmSearchDialog::InitContext : invalid context description supplied !");
498 InitContext(rBox.get_active());
532 bEnable = bEnable && bSearchingForText;
547 m_pcbCase->set_sensitive(bEnable && bEnableRedundants);
574 switch (pProgress->aSearchState)
577 if (pProgress->bOverflow)
579 OUString sHint(
CuiResId( m_pcbBackwards->get_active() ? RID_STR_OVERFLOW_BACKWARD : RID_STR_OVERFLOW_FORWARD ) );
580 m_pftHint->set_label( sHint );
583 m_pftRecord->set_label(OUString::number(1 + pProgress->nCurrentRecord));
587 m_pftHint->set_label(
CuiResId(RID_STR_SEARCH_COUNTING));
588 m_pftRecord->set_label(OUString::number(pProgress->nCurrentRecord));
592 OnFound(pProgress->aBookmark, static_cast<sal_Int16>(pProgress->nFieldIndex));
593 EnableSearchUI(
true);
600 ? RID_STR_SEARCH_GENERAL_ERROR
601 : RID_STR_SEARCH_NORECORD;
603 VclMessageType::Warning, VclButtonsType::Ok,
CuiResId(pErrorId)));
608 EnableSearchUI(
true);
609 if (m_lnkCanceledNotFoundHdl.IsSet())
612 friInfo.
nContext = m_plbForm->get_active();
614 friInfo.
aPosition = pProgress->aBookmark;
615 m_lnkCanceledNotFoundHdl.Call(friInfo);
620 m_pftRecord->set_label(OUString::number(1 + pProgress->nCurrentRecord));
625 FmSearchParams aParams(
m_pConfig->getParams());
627 const OUString* pHistory = aParams.aHistory.getConstArray();
628 const OUString* pHistoryEnd = pHistory + aParams.aHistory.getLength();
629 for (; pHistory != pHistoryEnd; ++pHistory)
636 int nInitialField =
m_plbField->find_text( aParams.sSingleSearchField );
637 if (nInitialField == -1)
642 if (aParams.bAllFields)
661 m_pcbCase->set_active( aParams.isCaseSensitive() );
680 if (aParams.bWildcard)
682 if (aParams.bRegular)
684 if (aParams.bApproxSearch)
686 if (aParams.bSoundsLikeCJK)
691 OnCheckBoxToggled(*pToCheck);
700 m_pSearchEngine->SetTransliterationFlags( aParams.getTransliterationFlags( ) );
705 switch (aParams.nSearchForType)
719 FmSearchParams aCurrentSettings;
722 aCurrentSettings.aHistory.realloc(nCount);
723 OUString* pHistory = aCurrentSettings.aHistory.getArray();
724 for (
int i = 0;
i < nCount; ++
i, ++pHistory)
727 aCurrentSettings.sSingleSearchField =
m_plbField->get_active_text();
731 aCurrentSettings.setCaseSensitive (
m_pSearchEngine->GetCaseSensitive() );
741 aCurrentSettings.bSoundsLikeCJK =
m_pSearchEngine->GetTransliteration();
742 aCurrentSettings.setTransliterationFlags (
m_pSearchEngine->GetTransliterationFlags() );
745 aCurrentSettings.nSearchForType = 1;
747 aCurrentSettings.nSearchForType = 2;
749 aCurrentSettings.nSearchForType = 0;
751 m_pConfig->setParams( aCurrentSettings );
#define LINK(Instance, Class, Member)
std::unique_ptr< weld::ComboBox > m_plbPosition
std::unique_ptr< weld::Button > m_pSoundsLikeCJKSettings
IMPL_LINK(FmSearchDialog, OnClickedFieldRadios, weld::Button &, rButton, void)
OUString GetStandardText(StandardButtonType eButton)
std::unique_ptr< weld::RadioButton > m_prbSingleField
std::unique_ptr< weld::ComboBox > m_plbForm
static SvxAbstractDialogFactory * Create()
std::unique_ptr< weld::CheckButton > m_pcbCase
::std::vector< css::uno::Reference< css::uno::XInterface > > arrFields
bool IsCJKFontEnabled() const
std::unique_ptr< weld::Button > m_pbClose
std::unique_ptr< weld::CheckButton > m_pcbStartOver
std::unique_ptr< weld::ComboBox > m_pcmbSearchText
sal_Int32 getTokenCount(const OString &rIn, char cTok)
SfxApplication * SfxGetpApp()
#define MAX_HISTORY_ENTRIES
bool IsJapaneseFindEnabled() const
std::unique_ptr< weld::CheckButton > m_pcbBackwards
void EnableSearchUI(bool bEnable)
friend class FmSearchEngine
std::unique_ptr< weld::Label > m_pftPosition
std::unique_ptr< weld::Label > m_pftRecord
Link< FmFoundRecordInformation &, void > m_lnkFoundHandler
Handler for "found".
css::uno::Reference< css::sdbc::XResultSet > xCursor
std::unique_ptr< weld::Label > m_pftForm
std::unique_ptr< weld::RadioButton > m_prbSearchForNull
virtual VclPtr< AbstractSvxSearchSimilarityDialog > CreateSvxSearchSimilarityDialog(weld::Window *pParent, bool bRelax, sal_uInt16 nOther, sal_uInt16 nShorter, sal_uInt16 nLonger)=0
OUString sFieldDisplayNames
IMPL_LINK_NOARG(FmSearchDialog, OnClickedSearchAgain, weld::Button &, void)
std::unique_ptr< weld::CheckButton > m_pcbRegular
#define DBG_ASSERT(sCon, aError)
std::unique_ptr< weld::CheckButton > m_pSoundsLikeCJK
std::unique_ptr< weld::ComboBox > m_plbField
std::unique_ptr< weld::Button > m_ppbApproxSettings
virtual sal_uInt16 GetLonger()=0
std::unique_ptr< weld::CheckButton > m_pHalfFullFormsCJK
virtual TransliterationFlags GetTransliterationFlags() const =0
std::vector< OUString > m_arrContextFields
memorize the currently selected field for every context
std::unique_ptr< weld::CheckButton > m_pcbWildCard
#define MATCHING_ANYWHERE
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.
OUString CuiResId(const char *pKey)
std::unique_ptr< weld::RadioButton > m_prbSearchForText
void EnableSearchForDependees(bool bEnable)
std::unique_ptr< FmSearchEngine > m_pSearchEngine
Dialog for searching in Forms/Tables.
std::unique_ptr< weld::Button > m_pbSearchAgain
std::unique_ptr< weld::CheckButton > m_pcbApprox
virtual VclPtr< AbstractSvxJSearchOptionsDialog > CreateSvxJSearchOptionsDialog(weld::Window *pParent, const SfxItemSet &rOptionsSet, TransliterationFlags nInitialFlags)=0
std::unique_ptr< weld::RadioButton > m_prbAllFields
virtual sal_uInt16 GetOther()=0
void initCommon(const css::uno::Reference< css::sdbc::XResultSet > &_rxCursor)
virtual bool IsRelaxed()=0
Reference< XExecutableDialog > m_xDialog
Reference< XComponentContext > getProcessComponentContext()
std::unique_ptr< weld::CheckButton > m_pcbUseFormat
void InitContext(sal_Int16 nContext)
std::unique_ptr< weld::RadioButton > m_prbSearchForNotNull
std::unique_ptr<::svxform::FmSearchConfigItem > m_pConfig
virtual ~FmSearchDialog() override
virtual sal_uInt16 GetShorter()=0
void Init(const OUString &strVisibleFields, const OUString &strInitialText)
if(!pCandidateA->getEnd().equal(pCandidateB->getStart()))
void OnFound(const css::uno::Any &aCursorPos, sal_Int16 nFieldPos)
Link< FmSearchContext &, sal_uInt32 > m_lnkContextSupplier
for search in contexts
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, bool bMobile=false)
virtual short run() override