20 #include <osl/diagnose.h>
37 #include <com/sun/star/awt/XWindow.hpp>
38 #include <com/sun/star/container/XNameAccess.hpp>
39 #include <com/sun/star/frame/XDispatch.hpp>
40 #include <com/sun/star/frame/XDispatchProvider.hpp>
41 #include <com/sun/star/frame/XLayoutManager.hpp>
42 #include <com/sun/star/beans/PropertyValue.hpp>
43 #include <com/sun/star/beans/XPropertySet.hpp>
44 #include <com/sun/star/configuration/theDefaultProvider.hpp>
45 #include <com/sun/star/frame/ModuleManager.hpp>
46 #include <com/sun/star/ui/XUIElement.hpp>
57 #include <svx/strings.hrc>
58 #include <svx/svxids.hrc>
78 #include <officecfg/Office/Common.hxx>
87 #define IS_MOBILE (comphelper::LibreOfficeKit::isActive() && SfxViewShell::Current() && SfxViewShell::Current()->isLOKMobilePhone())
128 bool bSaveToModule : 1,
131 Timer aSelectionTimer {
"svx SearchDlg_Impl aSelectionTimer" };
139 : bSaveToModule(true)
140 , bFocusOnSearch(true)
142 aCommand1URL.Complete = aCommand1URL.Main =
"vnd.sun.search:SearchViaComponent1";
143 aCommand1URL.Protocol =
"vnd.sun.search:";
144 aCommand1URL.Path =
"SearchViaComponent1";
145 aCommand2URL.Complete = aCommand2URL.Main =
"vnd.sun.search:SearchViaComponent2";
146 aCommand2URL.Protocol =
"vnd.sun.search:";
147 aCommand2URL.Path =
"SearchViaComponent2";
159 std::vector<OUString> aLst = pSrchItem->
GetList();
161 if (aLst.size() > nRememberSize)
162 aLst.resize(nRememberSize);
164 for (
const OUString & s : aLst)
166 rStrLst.push_back(s);
173 DBG_ASSERT( !rStrLst.empty(),
"check in advance");
180 for (
size_t i = 0;
i <
size(); ++
i )
182 (*
this)[
i].pItem = (*this)[
i].pItem->Clone();
188 for (
size_t i = 0;
i <
size(); ++
i )
190 (*
this)[
i].pItem = (*this)[
i].pItem->Clone();
219 nWhich = pItem->
Which();
235 for (
size_t i = 0;
i <
size(); ++
i )
239 rSet.
Put( *(*
this)[
i].pItem );
246 for (
size_t i = 0;
i <
size(); ++
i )
248 delete (*
this)[
i].pItem;
249 SrchAttrItemList::clear();
257 if ( nPos + nLen >
size() )
258 nLen =
size() - nPos;
260 for (
size_t i = nPos;
i < nPos + nLen; ++
i )
262 delete (*this)[
i].pItem;
264 SrchAttrItemList::erase(
begin() + nPos,
begin() + nPos + nLen );
269 IS_MOBILE ? OUString(
"svx/ui/findreplacedialog-mobile.ui") : OUString(
"svx/ui/findreplacedialog.ui"),
272 , m_aPresentIdle(
"Bring SvxSearchDialog to Foreground")
276 , bReplaceBackwards(
false)
283 , m_xSearchFrame(m_xBuilder->weld_frame(
"searchframe"))
284 , m_xSearchLB(m_xBuilder->weld_combo_box(
"searchterm"))
285 , m_xSearchTmplLB(m_xBuilder->weld_combo_box(
"searchlist"))
286 , m_xSearchAttrText(m_xBuilder->weld_label(
"searchdesc"))
287 , m_xSearchLabel(m_xBuilder->weld_label(
"searchlabel"))
288 , m_xReplaceFrame(m_xBuilder->weld_frame(
"replaceframe"))
289 , m_xReplaceLB(m_xBuilder->weld_combo_box(
"replaceterm"))
290 , m_xReplaceTmplLB(m_xBuilder->weld_combo_box(
"replacelist"))
291 , m_xReplaceAttrText(m_xBuilder->weld_label(
"replacedesc"))
292 , m_xSearchBtn(m_xBuilder->weld_button(
"search"))
293 , m_xBackSearchBtn(m_xBuilder->weld_button(
"backsearch"))
294 , m_xSearchAllBtn(m_xBuilder->weld_button(
"searchall"))
295 , m_xReplaceBtn(m_xBuilder->weld_button(
"replace"))
296 , m_xReplaceAllBtn(m_xBuilder->weld_button(
"replaceall"))
297 , m_xComponentFrame(m_xBuilder->weld_frame(
"componentframe"))
298 , m_xSearchComponent1PB(m_xBuilder->weld_button(
"component1"))
299 , m_xSearchComponent2PB(m_xBuilder->weld_button(
"component2"))
300 , m_xMatchCaseCB(m_xBuilder->weld_check_button(
"matchcase"))
301 , m_xSearchFormattedCB(m_xBuilder->weld_check_button(
"searchformatted"))
302 , m_xWordBtn(m_xBuilder->weld_check_button(
"wholewords"))
303 , m_xCloseBtn(m_xBuilder->weld_button(
"close"))
304 , m_xIncludeDiacritics(m_xBuilder->weld_check_button(
"includediacritics"))
305 , m_xIncludeKashida(m_xBuilder->weld_check_button(
"includekashida"))
306 , m_xOtherOptionsExpander(m_xBuilder->weld_expander(
"OptionsExpander"))
307 , m_xSelectionBtn(m_xBuilder->weld_check_button(
"selection"))
308 , m_xRegExpBtn(m_xBuilder->weld_check_button(
"regexp"))
309 , m_xWildcardBtn(m_xBuilder->weld_check_button(
"wildcard"))
310 , m_xSimilarityBox(m_xBuilder->weld_check_button(
"similarity"))
311 , m_xSimilarityBtn(m_xBuilder->weld_button(
"similaritybtn"))
312 , m_xLayoutBtn(m_xBuilder->weld_check_button(
"layout"))
313 , m_xNotesBtn(m_xBuilder->weld_check_button(
"notes"))
314 , m_xJapMatchFullHalfWidthCB(m_xBuilder->weld_check_button(
"matchcharwidth"))
315 , m_xJapOptionsCB(m_xBuilder->weld_check_button(
"soundslike"))
316 , m_xReplaceBackwardsCB(m_xBuilder->weld_check_button(
"replace_backwards"))
317 , m_xJapOptionsBtn(m_xBuilder->weld_button(
"soundslikebtn"))
318 , m_xAttributeBtn(m_xBuilder->weld_button(
"attributes"))
319 , m_xFormatBtn(m_xBuilder->weld_button(
"format"))
320 , m_xNoFormatBtn(m_xBuilder->weld_button(
"noformat"))
321 , m_xCalcGrid(m_xBuilder->weld_widget(
"calcgrid"))
322 , m_xCalcSearchInFT(m_xBuilder->weld_label(
"searchinlabel"))
323 , m_xCalcSearchInLB(m_xBuilder->weld_combo_box(
"calcsearchin"))
324 , m_xCalcSearchDirFT(m_xBuilder->weld_label(
"searchdir"))
325 , m_xRowsBtn(m_xBuilder->weld_radio_button(
"rows"))
326 , m_xColumnsBtn(m_xBuilder->weld_radio_button(
"cols"))
327 , m_xAllSheetsCB(m_xBuilder->weld_check_button(
"allsheets"))
328 , m_xCalcStrFT(m_xBuilder->weld_label(
"entirecells"))
346 nRememberSize = officecfg::Office::Common::Misc::FindReplaceRememberedSearches::get();
350 auto nTermWidth =
m_xSearchLB->get_approximate_digit_width() * 28;
361 getDialog()->present();
366 PresentTimeoutHdl_Impl(
nullptr);
391 pImpl->aSelectionTimer.SetTimeout( 500 );
392 pImpl->aSelectionTimer.SetInvokeHandler(
435 pImpl->aSelectionTimer.Start();
463 const uno::Reference< frame::XDispatchProvider > xDispatchProv(xFrame, uno::UNO_QUERY);
465 bool bSearchComponent1 =
false;
466 bool bSearchComponent2 =
false;
467 if(xDispatchProv.is())
469 OUString sTarget(
"_self");
470 pImpl->xCommand1Dispatch = xDispatchProv->queryDispatch(
pImpl->aCommand1URL, sTarget, 0);
471 if (
pImpl->xCommand1Dispatch.is())
472 bSearchComponent1 =
true;
473 pImpl->xCommand2Dispatch = xDispatchProv->queryDispatch(
pImpl->aCommand2URL, sTarget, 0);
474 if (
pImpl->xCommand2Dispatch.is())
475 bSearchComponent2 =
true;
478 if( !(bSearchComponent1 || bSearchComponent2) )
483 uno::Reference< lang::XMultiServiceFactory > xConfigurationProvider =
485 uno::Sequence< uno::Any > aArgs {
486 Any(OUString(
"/org.openoffice.Office.Common/SearchOptions/")) };
488 uno::Reference< uno::XInterface > xIFace = xConfigurationProvider->createInstanceWithArguments(
489 "com.sun.star.configuration.ConfigurationUpdateAccess",
491 uno::Reference< container::XNameAccess> xDirectAccess(xIFace, uno::UNO_QUERY);
492 if(xDirectAccess.is())
495 uno::Any aRet = xDirectAccess->getByName(
"ComponentSearchGroupLabel");
498 aRet = xDirectAccess->getByName(
"ComponentSearchCommandLabel1");
501 aRet = xDirectAccess->getByName(
"ComponentSearchCommandLabel2");
506 catch(uno::Exception&){}
571 pImpl->bSaveToModule = b;
578 if (rStr ==
SvxResId(RID_SVXSTR_SEARCH_NOT_FOUND))
585 bool bVal(nSettings & TransliterationFlags::IGNORE_CASE);
587 bVal = bool(nSettings & TransliterationFlags::IGNORE_WIDTH);
684 const uno::Reference< frame::XFrame >
xFrame =
686 uno::Reference< frame::XModuleManager2 > xModuleManager(
689 OUString aModuleIdentifier = xModuleManager->identify( xFrame );
692 catch (
const uno::Exception&)
748 class ToggleSaveToModule
752 mrDialog(rDialog), mbValue(bValue)
754 mrDialog.SetSaveToModule(mbValue);
757 ~ToggleSaveToModule()
759 mrDialog.SetSaveToModule(!mbValue);
774 ToggleSaveToModule aNoModuleSave(*
this,
false);
807 if (
pSearchItem->GetAppFlag() == SvxSearchApp::CALC )
821 case SvxSearchCellType::FORMULA:
825 case SvxSearchCellType::VALUE:
829 case SvxSearchCellType::NOTE:
861 if (
pSearchItem->GetAppFlag() == SvxSearchApp::DRAW )
905 bool bDisableSearch =
false;
910 bool bText = !bSearchPattern;
922 if ( bSearchPattern )
939 pBase = pStylePool->
Next();
966 if ( !(
pSearchItem->GetSearchString().isEmpty()) && bSetSearch )
974 if ( bSetSearch && !bAttributes )
977 OUString aReplaceTxt =
pSearchItem->GetReplaceString();
982 if ( bSetReplace && !bAttributes )
1003 bDisableSearch =
m_xSearchLB->get_active_text().isEmpty() &&
1008 if ( bDisableSearch )
1047 pImpl->bSaveToModule =
false;
1049 pImpl->bSaveToModule =
true;
1057 if ( !pSSet && !pRSet )
1060 if (
pImpl->pRanges.empty() && pSSet )
1063 bool bSetOptimalLayoutSize =
false;
1072 if ( pSSet->
Count() )
1078 if ( !aDesc.isEmpty() )
1083 bSetOptimalLayoutSize =
true;
1094 if ( pRSet->
Count() )
1100 if ( !aDesc.isEmpty() )
1105 bSetOptimalLayoutSize =
true;
1112 if (bSetOptimalLayoutSize)
1118 ClickHdl_Impl(&rCtrl);
1123 ClickHdl_Impl(&rCtrl);
1128 if ( pCtrl && !
bSet )
1258 if (
pImpl->bSaveToModule )
1264 bool bInclusive = ( m_xLayoutBtn->get_label() == aLayoutStr );
1266 if ( ( &rBtn == m_xSearchBtn.get() ) ||
1267 (&rBtn == m_xBackSearchBtn.get()) ||
1268 ( &rBtn == m_xSearchAllBtn.get() )||
1269 ( &rBtn == m_xReplaceBtn.get() ) ||
1270 ( &rBtn == m_xReplaceAllBtn.get() ) )
1272 if ( m_xLayoutBtn->get_active() && !bInclusive )
1274 pSearchItem->SetSearchString ( m_xSearchTmplLB->get_active_text() );
1275 pSearchItem->SetReplaceString( m_xReplaceTmplLB->get_active_text() );
1279 pSearchItem->SetSearchString ( m_xSearchLB->get_active_text() );
1280 pSearchItem->SetReplaceString( m_xReplaceLB->get_active_text() );
1282 if ( &rBtn == m_xReplaceBtn.get() )
1283 Remember_Impl( m_xReplaceLB->get_active_text(),
false );
1286 Remember_Impl( m_xSearchLB->get_active_text(), true );
1288 if ( &rBtn == m_xReplaceAllBtn.get() )
1289 Remember_Impl( m_xReplaceLB->get_active_text(),
false );
1293 pSearchItem->SetRegExp(
false );
1294 pSearchItem->SetWildcard(
false );
1295 pSearchItem->SetLevenshtein(
false );
1296 if (GetCheckBoxValue(*m_xRegExpBtn))
1297 pSearchItem->SetRegExp(
true );
1298 else if (GetCheckBoxValue(*m_xWildcardBtn))
1299 pSearchItem->SetWildcard(
true );
1300 else if (GetCheckBoxValue(*m_xSimilarityBox))
1301 pSearchItem->SetLevenshtein(
true );
1303 pSearchItem->SetWordOnly(GetCheckBoxValue(*m_xWordBtn));
1305 bool bSetBackwards =
false;
1306 if( &rBtn == m_xBackSearchBtn.get())
1308 bSetBackwards =
true;
1310 else if( &rBtn == m_xReplaceBtn.get())
1312 bSetBackwards = GetCheckBoxValue(*m_xReplaceBackwardsCB);
1313 bReplaceBackwards = GetCheckBoxValue(*m_xReplaceBackwardsCB);
1316 pSearchItem->SetBackward(bSetBackwards);
1318 pSearchItem->SetNotes(GetCheckBoxValue(*m_xNotesBtn));
1319 pSearchItem->SetPattern(GetCheckBoxValue(*m_xLayoutBtn));
1320 pSearchItem->SetSelection(GetCheckBoxValue(*m_xSelectionBtn));
1321 pSearchItem->SetUseAsianOptions(GetCheckBoxValue(*m_xJapOptionsCB));
1323 if( !pSearchItem->IsUseAsianOptions())
1324 nFlags &= TransliterationFlags::IGNORE_CASE |
1325 TransliterationFlags::IGNORE_WIDTH;
1326 if (GetNegatedCheckBoxValue(*m_xIncludeDiacritics))
1327 nFlags |= TransliterationFlags::IGNORE_DIACRITICS_CTL;
1328 if (GetNegatedCheckBoxValue(*m_xIncludeKashida))
1329 nFlags |= TransliterationFlags::IGNORE_KASHIDA_CTL;
1330 pSearchItem->SetTransliterationFlags( nFlags );
1334 if ( m_xCalcSearchInLB->get_active() != -1)
1335 pSearchItem->SetCellType( static_cast<SvxSearchCellType>(m_xCalcSearchInLB->get_active()) );
1337 pSearchItem->SetRowDirection( m_xRowsBtn->get_active() );
1338 pSearchItem->SetAllTables( m_xAllSheetsCB->get_active() );
1339 pSearchItem->SetSearchFormatted( m_xSearchFormattedCB->get_active() );
1342 if ((&rBtn == m_xSearchBtn.get()) || (&rBtn == m_xBackSearchBtn.get()))
1343 pSearchItem->SetCommand( SvxSearchCmd::FIND );
1344 else if ( &rBtn == m_xSearchAllBtn.get() )
1345 pSearchItem->SetCommand( SvxSearchCmd::FIND_ALL );
1346 else if ( &rBtn == m_xReplaceBtn.get() )
1347 pSearchItem->SetCommand( SvxSearchCmd::REPLACE );
1348 else if ( &rBtn == m_xReplaceAllBtn.get() )
1349 pSearchItem->SetCommand( SvxSearchCmd::REPLACE_ALL );
1352 if ( !bFormat && pSearchItem->GetPattern() )
1355 pSearchList->Clear();
1358 pReplaceList->Clear();
1361 const SfxPoolItem* ppArgs[] = { pSearchItem.get(),
nullptr };
1364 else if ( &rBtn == m_xCloseBtn.get() )
1366 if ( !m_xLayoutBtn->get_active() || bInclusive )
1368 OUString
aStr( m_xSearchLB->get_active_text() );
1370 if ( !
aStr.isEmpty() )
1371 Remember_Impl(
aStr,
true );
1372 aStr = m_xReplaceLB->get_active_text();
1374 if ( !
aStr.isEmpty() )
1375 Remember_Impl(
aStr,
false );
1377 SaveToModule_Impl();
1380 else if (&rBtn == m_xSimilarityBtn.get())
1384 pSearchItem->IsLEVRelaxed(),
1385 pSearchItem->GetLEVOther(),
1386 pSearchItem->GetLEVShorter(),
1387 pSearchItem->GetLEVLonger() ));
1388 if ( executeSubDialog(pDlg.
get()) ==
RET_OK )
1390 pSearchItem->SetLEVRelaxed( pDlg->
IsRelaxed() );
1391 pSearchItem->SetLEVOther( pDlg->
GetOther() );
1392 pSearchItem->SetLEVShorter( pDlg->
GetShorter() );
1393 pSearchItem->SetLEVLonger( pDlg->
GetLonger() );
1394 SaveToModule_Impl();
1397 else if (&rBtn == m_xJapOptionsBtn.get())
1403 pSearchItem->GetTransliterationFlags() ));
1404 int nRet = executeSubDialog(aDlg.
get());
1408 pSearchItem->SetTransliterationFlags( nFlags );
1409 ApplyTransliterationFlags_Impl( nFlags );
1412 else if (&rBtn == m_xSearchComponent1PB.get() || &rBtn == m_xSearchComponent2PB.get())
1414 uno::Sequence < beans::PropertyValue > aArgs(2);
1415 beans::PropertyValue* pArgs = aArgs.getArray();
1416 pArgs[0].Name =
"SearchString";
1417 pArgs[0].Value <<= m_xSearchLB->get_active_text();
1418 pArgs[1].Name =
"ParentWindow";
1419 pArgs[1].Value <<=
m_xDialog->GetXWindow();
1420 if (&rBtn == m_xSearchComponent1PB.get())
1422 if ( pImpl->xCommand1Dispatch.is() )
1423 pImpl->xCommand1Dispatch->dispatch(pImpl->aCommand1URL, aArgs);
1427 if ( pImpl->xCommand2Dispatch.is() )
1428 pImpl->xCommand2Dispatch->dispatch(pImpl->aCommand2URL, aArgs);
1437 SetModifyFlag_Impl( &rEd );
1442 bool bAllowEmptySearch = (pSearchItem->GetAppFlag() == SvxSearchApp::CALC);
1444 if (&rEd != m_xSearchLB.get() && &rEd != m_xReplaceLB.get())
1447 sal_Int32 nSrchTxtLen = m_xSearchLB->get_active_text().getLength();
1448 sal_Int32 nReplTxtLen = 0;
1449 if (bAllowEmptySearch)
1450 nReplTxtLen = m_xReplaceLB->get_active_text().getLength();
1451 sal_Int32 nAttrTxtLen = m_xSearchAttrText->get_label().getLength();
1453 if (nSrchTxtLen || nReplTxtLen || nAttrTxtLen)
1455 EnableControl_Impl(*m_xSearchBtn);
1456 EnableControl_Impl(*m_xBackSearchBtn);
1457 EnableControl_Impl(*m_xReplaceBtn);
1458 if (!bWriter || !m_xNotesBtn->get_active())
1460 EnableControl_Impl(*m_xSearchAllBtn);
1461 EnableControl_Impl(*m_xReplaceAllBtn);
1466 m_xComponentFrame->set_sensitive(
false);
1467 m_xSearchBtn->set_sensitive(
false);
1468 m_xBackSearchBtn->set_sensitive(
false);
1469 m_xSearchAllBtn->set_sensitive(
false);
1470 m_xReplaceBtn->set_sensitive(
false);
1471 m_xReplaceAllBtn->set_sensitive(
false);
1477 if ( pImpl->bSaveToModule )
1478 SaveToModule_Impl();
1484 if ( m_xLayoutBtn->get_active() )
1486 if ( !pFamilyController )
1491 switch ( pSearchItem->GetFamily() )
1493 case SfxStyleFamily::Char:
1494 nId = SID_STYLE_FAMILY1;
break;
1496 case SfxStyleFamily::Para:
1497 nId = SID_STYLE_FAMILY2;
break;
1499 case SfxStyleFamily::Frame:
1500 nId = SID_STYLE_FAMILY3;
break;
1502 case SfxStyleFamily::Page:
1503 nId = SID_STYLE_FAMILY4;
break;
1505 case SfxStyleFamily::All:
1509 OSL_FAIL(
"StyleSheetFamily was changed?" );
1513 pFamilyController.reset(
1516 m_xSearchTmplLB->clear();
1517 m_xReplaceTmplLB->clear();
1519 m_xSearchTmplLB->show();
1520 m_xReplaceTmplLB->show();
1521 m_xSearchLB->hide();
1522 m_xReplaceLB->hide();
1524 m_xSearchAttrText->set_label( sDesc );
1525 m_xReplaceAttrText->set_label( sDesc );
1527 if(!sDesc.isEmpty())
1529 if (!m_xReplaceAttrText->get_visible() || !m_xReplaceAttrText->get_visible())
1531 m_xSearchAttrText->show();
1532 m_xReplaceAttrText->show();
1537 m_xFormatBtn->set_sensitive(
false);
1538 m_xNoFormatBtn->set_sensitive(
false);
1539 m_xAttributeBtn->set_sensitive(
false);
1540 m_xSimilarityBox->set_sensitive(
false);
1541 m_xSimilarityBtn->set_sensitive(
false);
1547 pFamilyController.reset();
1550 m_xSearchLB->show();
1551 m_xReplaceLB->show();
1552 m_xSearchTmplLB->hide();
1553 m_xReplaceTmplLB->hide();
1555 m_xSearchAttrText->set_label( BuildAttrText_Impl( sDesc,
true ) );
1556 m_xReplaceAttrText->set_label( BuildAttrText_Impl( sDesc,
false ) );
1558 if(!sDesc.isEmpty())
1560 if (!m_xReplaceAttrText->get_visible() || !m_xReplaceAttrText->get_visible())
1562 m_xSearchAttrText->show();
1563 m_xReplaceAttrText->show();
1568 EnableControl_Impl(*m_xFormatBtn);
1569 EnableControl_Impl(*m_xAttributeBtn);
1570 EnableControl_Impl(*m_xSimilarityBox);
1572 FocusHdl_Impl( bSearch ? *m_xSearchLB : *m_xReplaceLB );
1575 pImpl->bSaveToModule =
false;
1576 FlagHdl_Impl(*m_xLayoutBtn);
1577 pImpl->bSaveToModule =
true;
1582 if ( rStr.isEmpty() )
1589 if (std::find(pArr->begin(), pArr->end(), rStr) != pArr->end())
1592 pArr->insert(pArr->begin(), rStr);
1596 size_t nArrSize = pArr->size();
1599 pListBox->
remove(nArrSize - 1);
1600 pArr->erase(pArr->begin() + nArrSize - 1);
1619 pBase = rPool.
Next();
1625 if ( !aOldSrch.isEmpty() )
1629 if ( !aOldRepl.isEmpty() )
1650 bool bNoSearch =
true;
1652 bool bEnableSearch = bool( SearchOptionFlags::SEARCH &
nOptions );
1660 if ( SearchOptionFlags::SEARCHALL & nOptions )
1667 if ( SearchOptionFlags::REPLACE & nOptions )
1682 if ( SearchOptionFlags::REPLACE_ALL & nOptions )
1696 if ( SearchOptionFlags::WHOLE_WORDS & nOptions )
1700 if ( SearchOptionFlags::BACKWARDS & nOptions )
1710 if ( SearchOptionFlags::REG_EXP & nOptions )
1714 if ( SearchOptionFlags::WILDCARD & nOptions )
1718 if ( SearchOptionFlags::EXACT & nOptions )
1722 if ( SearchOptionFlags::SELECTION & nOptions )
1726 if ( SearchOptionFlags::FAMILIES & nOptions )
1730 if ( SearchOptionFlags::FORMAT & nOptions )
1743 if ( SearchOptionFlags::SIMILARITY & nOptions )
1772 ( SearchOptionFlags::SEARCHALL &
nOptions ) )
1783 ( SearchOptionFlags::REPLACE_ALL &
nOptions ) )
1793 if ( SearchOptionFlags::BACKWARDS &
nOptions )
1840 && ( SearchOptionFlags::FORMAT &
nOptions )
1878 sal_Int32 nTxtLen = m_xSearchAttrText->get_label().getLength();
1880 if (pCtrl == m_xSearchLB.get())
1883 pImpl->bFocusOnSearch =
true;
1884 pCtrl = m_xSearchLB.get();
1888 EnableControl_Impl(*m_xNoFormatBtn);
1890 m_xNoFormatBtn->set_sensitive(
false);
1891 EnableControl_Impl(*m_xAttributeBtn);
1895 pImpl->bFocusOnSearch =
false;
1896 pCtrl = m_xReplaceLB.get();
1899 if (!m_xReplaceAttrText->get_label().isEmpty())
1900 EnableControl_Impl(*m_xNoFormatBtn);
1903 m_xAttributeBtn->set_sensitive(
false);
1909 ModifyHdl_Impl(rComboBox);
1911 if (bFormat && nTxtLen)
1912 m_xLayoutBtn->set_label(aLayoutStr);
1923 m_xLayoutBtn->set_label(aLayoutWriterStr);
1927 m_xLayoutBtn->set_label(aLayoutCalcStr);
1929 m_xLayoutBtn->set_label(aStylesStr);
1936 SaveToModule_Impl();
1945 if ( !pSh || pImpl->pRanges.empty() )
1951 aSet.
MergeRange(SID_ATTR_PARA_MODEL, SID_ATTR_PARA_MODEL);
1965 aTxt =
SvxResId( RID_SVXSTR_SEARCH );
1966 pSearchList->Get( aSet );
1970 aTxt =
SvxResId( RID_SVXSTR_REPLACE );
1971 pReplaceList->Get( aSet );
1982 if ( executeSubDialog(pDlg.
get()) !=
RET_OK )
1991 for( sal_uInt16
n = 0;
n < pList->Count(); ++
n )
1995 SfxItemState::SET == aOutSet.GetItemState(
1998 delete pAItem->
pItem;
2004 if( aOutSet.Count() )
2005 pList->Put( aOutSet );
2007 PaintAttrText_Impl();
2020 m_xLayoutBtn->set_label( aLayoutCalcStr );
2024 m_xLayoutBtn->set_label( aLayoutWriterStr);
2026 m_xLayoutBtn->set_label( aStylesStr );
2030 m_xLayoutBtn->set_active(
false );
2032 bool bSetOptimalLayoutSize =
false;
2036 pSearchList->Clear();
2037 m_xSearchAttrText->set_label(
"" );
2038 if (m_xSearchAttrText->get_visible())
2040 m_xSearchAttrText->hide();
2041 bSetOptimalLayoutSize =
true;
2046 pReplaceList->Clear();
2047 m_xReplaceAttrText->set_label(
"" );
2048 if (m_xReplaceAttrText->get_visible())
2050 m_xReplaceAttrText->hide();
2051 bSetOptimalLayoutSize =
true;
2055 if (bSetOptimalLayoutSize)
2058 pImpl->bSaveToModule =
false;
2059 TemplateHdl_Impl(*m_xLayoutBtn);
2060 pImpl->bSaveToModule =
true;
2061 m_xNoFormatBtn->set_sensitive(
false);
2066 if ( !pSearchList || pImpl->pRanges.empty() )
2071 executeSubDialog(pDlg.
get());
2072 PaintAttrText_Impl();
2081 if ( pViewShell->
HasSelection( m_xSearchLB->get_visible() ) )
2082 EnableControl_Impl(*m_xSelectionBtn);
2085 m_xSelectionBtn->set_active(
false );
2086 m_xSelectionBtn->set_sensitive(
false);
2094 bool bSrchFlag )
const
2111 MapUnit eMapUnit = MapUnit::MapCM;
2113 switch ( eFieldUnit )
2115 case FieldUnit::MM: eMapUnit = MapUnit::MapMM;
break;
2118 case FieldUnit::KM: eMapUnit = MapUnit::MapCM;
break;
2119 case FieldUnit::TWIP: eMapUnit = MapUnit::MapTwip;
break;
2120 case FieldUnit::POINT:
2121 case FieldUnit::PICA: eMapUnit = MapUnit::MapPoint;
break;
2122 case FieldUnit::INCH:
2123 case FieldUnit::FOOT:
2124 case FieldUnit::MILE: eMapUnit = MapUnit::MapInch;
break;
2125 case FieldUnit::MM_100TH: eMapUnit = MapUnit::Map100thMM;
break;
2130 for ( sal_uInt16
i = 0;
i < pList->
Count(); ++
i )
2134 if ( !rStr.isEmpty() )
2143 if (rStr.endsWith(
", "))
2144 rStr = rStr.copy(0, rStr.lastIndexOf(
","));
2149 else if ( rItem.
nSlot == SID_ATTR_BRUSH_CHAR )
2152 rStr +=
SvxResId( RID_SVXITEMS_BRUSH_CHAR );
2170 if ( !
bFormat && !aDesc.isEmpty() )
2173 bool bSetOptimalLayoutSize =
false;
2181 bSetOptimalLayoutSize =
true;
2192 bSetOptimalLayoutSize =
true;
2198 if (bSetOptimalLayoutSize)
2285 nFlags &= TransliterationFlags::IGNORE_CASE |
2286 TransliterationFlags::IGNORE_WIDTH;
2288 nFlags |= TransliterationFlags::IGNORE_DIACRITICS_CTL;
2290 nFlags |= TransliterationFlags::IGNORE_KASHIDA_CTL;
2326 dialog->Initialize( pInfo );
2328 pBindings->
Update( SID_SEARCH_ITEM );
2329 pBindings->
Update( SID_SEARCH_OPTIONS );
2330 pBindings->
Update( SID_SEARCH_SEARCHSET );
2331 pBindings->
Update( SID_SEARCH_REPLACESET );
2332 dialog->bConstruct =
false;
2353 bool bNotFound = rStr ==
SvxResId(RID_SVXSTR_SEARCH_NOT_FOUND);
2355 css::uno::Reference< css::beans::XPropertySet > xPropSet(
2357 css::uno::Reference< css::frame::XLayoutManager > xLayoutManager;
2358 xPropSet->getPropertyValue(
"LayoutManager") >>= xLayoutManager;
2359 css::uno::Reference< css::ui::XUIElement > xUIElement =
2360 xLayoutManager->getElement(
"private:resource/toolbar/findbar");
2361 if (!xUIElement.is())
2363 css::uno::Reference< css::awt::XWindow > xWindow(
2364 xUIElement->getRealInterface(), css::uno::UNO_QUERY_THROW);
2366 for (ToolBox::ImplToolItems::size_type
i = 0; pToolBox &&
i < pToolBox->GetItemCount(); ++
i)
2369 if (pToolBox->GetItemCommand(
id) ==
".uno:SearchLabel")
2372 assert(pSearchLabel);
2380 if (pToolBox->GetItemCommand(
id) ==
".uno:FindText")
2390 xLayoutManager->doLayout();
2400 css::uno::Reference< css::beans::XPropertySet > xPropSet(
2402 css::uno::Reference< css::frame::XLayoutManager > xLayoutManager;
2403 xPropSet->getPropertyValue(
"LayoutManager") >>= xLayoutManager;
2404 if (!xLayoutManager.is())
2406 css::uno::Reference< css::ui::XUIElement > xUIElement =
2407 xLayoutManager->getElement(
"private:resource/toolbar/findbar");
2408 if (!xUIElement.is())
2410 css::uno::Reference< css::awt::XWindow > xWindow(
2411 xUIElement->getRealInterface(), css::uno::UNO_QUERY_THROW);
2413 for (ToolBox::ImplToolItems::size_type
i = 0; pToolBox &&
i < pToolBox->GetItemCount(); ++
i)
2416 if (pToolBox->GetItemCommand(
id) ==
".uno:SearchLabel")
2419 return pSearchLabel ? pSearchLabel->
get_label() : OUString();
2429 sStr =
SvxResId(RID_SVXSTR_SEARCH_END);
2431 sStr =
SvxResId(RID_SVXSTR_SEARCH_START);
2433 sStr =
SvxResId(RID_SVXSTR_SEARCH_END_WRAPPED);
2435 sStr =
SvxResId(RID_SVXSTR_SEARCH_START_WRAPPED);
2437 sStr =
SvxResId(RID_SVXSTR_SEARCH_END_SHEET);
2439 sStr =
SvxResId(RID_SVXSTR_SEARCH_NOT_FOUND);
2441 sStr =
SvxResId(RID_SVXSTR_SEARCH_NAV_ELEMENT_NOT_FOUND);
2443 sStr =
SvxResId(RID_SVXSTR_SEARCH_REMINDER_END_WRAPPED);
2445 sStr =
SvxResId(RID_SVXSTR_SEARCH_REMINDER_START_WRAPPED);
2449 GetChildWindow( SvxSearchDialogWrapper::GetChildWindowId() )))
2450 pWrp->getDialog()->SetSearchLabel(sStr);
2458 GetChildWindow( SvxSearchDialogWrapper::GetChildWindowId() )))
2459 pWrp->getDialog()->SetSearchLabel(sStr);
#define LINK(Instance, Class, Member)
SfxStyleSheetBase * First(SfxStyleFamily eFamily, SfxStyleSearchBits eMask=SfxStyleSearchBits::All)
std::unique_ptr< weld::Button > m_xSearchComponent2PB
virtual bool IsUsed() const
constexpr sal_uInt16 XATTR_FILL_LAST(XATTR_FILLUSESLIDEBACKGROUND)
static EFactory ClassifyFactoryByServiceName(std::u16string_view sName)
std::unique_ptr< SearchAttrItemList > pReplaceList
virtual bool GetPresentation(const SfxPoolItem &rItem, MapUnit ePresentationMetric, OUString &rText, const IntlWrapper &rIntlWrapper) const
uno::Reference< frame::XDispatch > xCommand2Dispatch
void SetSaveToModule(bool b)
std::unique_ptr< weld::Expander > m_xOtherOptionsExpander
virtual void Activate() override
SVX_DLLPRIVATE void ClickHdl_Impl(const weld::Widget *pCtrl)
std::unique_ptr< weld::Button > m_xSearchAllBtn
bool IsIgnoreKashida_CTL() const
SVX_DLLPRIVATE void EnableControls_Impl(const SearchOptionFlags nFlags)
std::unique_ptr< weld::Label > m_xReplaceAttrText
virtual const SfxItemSet * GetOutputItemSet() const =0
void insert_text(int pos, const OUString &rStr)
void set_entry_message_type(weld::EntryMessageType eType)
virtual SfxPoolItem * Clone(SfxItemPool *pPool=nullptr) const =0
static SvxAbstractDialogFactory * Create()
std::unique_ptr< weld::ComboBox > m_xCalcSearchInLB
Reference< XFrame > xFrame
css::uno::Reference< css::frame::XFrame > GetActiveFrame() const
const WhichRangesContainer & GetRanges() const
SVX_DLLPRIVATE void TemplatesChanged_Impl(SfxStyleSheetBasePool &rPool)
virtual Size GetSizePixel() const
virtual void SetSizePixel(const Size &rNewSize)
SearchOptionFlags nOptions
void InvalidateItem(sal_uInt16 nWhich)
const SfxItemSet & GetItemSet() const
void SetSimilaritySearch(bool bVal)
SVX_DLLPRIVATE void Remember_Impl(const OUString &rStr, bool bSearch)
SVX_DLLPRIVATE void PaintAttrText_Impl()
void SetUseWildcard(bool bVal)
SVX_DLLPRIVATE void Construct_Impl()
std::vector< SearchAttrItem > SrchAttrItemList
static SfxObjectShell * Current()
SearchAttrItem & GetObject(sal_uInt16 nPos)
std::unique_ptr< weld::Button > m_xFormatBtn
TransliterationFlags nTransliterationFlags
std::shared_ptr< T > make_shared(Args &&...args)
SVX_DLLPRIVATE bool IsOtherOptionsExpanded() const
void Invalidate(sal_uInt16 nId)
void Put(const SfxItemSet &rSet)
bool IsCTLFontEnabled() const
virtual short Execute()=0
virtual VclPtr< SfxAbstractTabDialog > CreateTabItemDialog(weld::Window *pParent, const SfxItemSet &rSet)=0
void PutItem(const SfxPoolItem &rItem)
std::unique_ptr< weld::CheckButton > m_xIncludeKashida
#define RESARRAY_INDEX_NOTFOUND
static void StrArrToList_Impl(sal_uInt16 nId, const std::vector< OUString > &rStrLst)
SfxItemSet & Get(SfxItemSet &rSet)
SvxSearchDialogWrapper(vcl::Window *pParent, sal_uInt16 nId, SfxBindings *pBindings, SfxChildWinInfo const *pInfo)
SfxApplication * SfxGetpApp()
virtual SfxStyleSheetBasePool * GetStyleSheetPool()
void ToggleChildWindow(sal_uInt16)
static void ListToStrArr_Impl(sal_uInt16 nId, std::vector< OUString > &rStrLst, weld::ComboBox &rCBox, sal_uInt16 nRememberSize)
std::unique_ptr< weld::CheckButton > m_xRegExpBtn
SfxModule * GetModule() const
SVX_DLLPRIVATE OUString & BuildAttrText_Impl(OUString &rStr, bool bSrchFlag) const
std::unique_ptr< weld::Frame > m_xComponentFrame
const SfxPoolItem * NextItem()
void MergeRange(sal_uInt16 nFrom, sal_uInt16 nTo)
SVX_DLLPRIVATE void SaveToModule_Impl()
void SetUseRegularExpression(bool bVal)
virtual ~SvxSearchDialog() override
const OUString & GetName() const
std::unique_ptr< weld::CheckButton > m_xWordBtn
enumrange< T >::Iterator begin(enumrange< T >)
bool IsJapaneseFindEnabled()
std::vector< OUString > aReplaceStrings
static vcl::Window * GetWindow(const css::uno::Reference< css::awt::XWindow > &rxWindow)
std::unique_ptr< weld::ComboBox > m_xSearchTmplLB
friend class SvxSearchController
SfxFrame & GetFrame() const
OUString SvxResId(TranslateId aId)
virtual void ChildWinDispose() override
SVX_DLLPRIVATE void ApplyTransliterationFlags_Impl(TransliterationFlags nSettings)
std::unique_ptr< weld::Widget > m_xCalcGrid
static SfxViewShell * Current()
std::unique_ptr< weld::CheckButton > m_xSimilarityBox
bool m_executingSubDialog
const SfxPoolItem * ExecuteSynchron(sal_uInt16 nSlot, const SfxPoolItem **pArgs=nullptr)
std::unique_ptr< weld::CheckButton > m_xReplaceBackwardsCB
std::unique_ptr< weld::ComboBox > m_xReplaceLB
void SetSearchLabel(const OUString &rStr)
std::unique_ptr< weld::CheckButton > m_xAllSheetsCB
std::unique_ptr< weld::Label > m_xCalcSearchInFT
std::unique_ptr< weld::Button > m_xBackSearchBtn
std::unique_ptr< weld::Button > m_xJapOptionsBtn
void SetIgnoreKashida_CTL(bool bVal)
std::unique_ptr< weld::CheckButton > m_xWildcardBtn
std::unique_ptr< weld::CheckButton > m_xSelectionBtn
SfxItemPool & GetPool() const
std::unique_ptr< weld::CheckButton > m_xJapOptionsCB
void SetBackwards(bool bVal)
std::unique_ptr< weld::CheckButton > m_xIncludeDiacritics
virtual VclPtr< VclAbstractDialog > CreateSvxSearchAttributeDialog(weld::Window *pParent, SearchAttrItemList &rLst, const WhichRangesContainer &pWhRanges)=0
const SfxPoolItem * GetItem(sal_uInt16 nSlotId) const
virtual VclPtr< AbstractSvxSearchSimilarityDialog > CreateSvxSearchSimilarityDialog(weld::Window *pParent, bool bRelax, sal_uInt16 nOther, sal_uInt16 nShorter, sal_uInt16 nLonger)=0
std::unique_ptr< SearchDlg_Impl > pImpl
std::unique_ptr< SvxSearchController > pFamilyController
void SetWholeWordsOnly(bool bVal)
SVX_DLLPRIVATE void InitControls_Impl()
FieldUnit GetFieldUnit() const
virtual void SetText(const OUString &rStr)=0
SFX_IMPL_CHILDWINDOW_WITHID(SvxSearchDialogWrapper, SID_SEARCH_DLG)
virtual void select_entry_region(int nStartPos, int nEndPos)=0
#define DBG_ASSERT(sCon, aError)
static OUString GetSearchLabel()
static void lcl_SetSearchLabelWindow(const OUString &rStr)
OUString aLayoutWriterStr
SVX_DLLPRIVATE void InitAttrList_Impl(const SfxItemSet *pSSet, const SfxItemSet *pRSet)
void SetSearchFormatted(bool bVal)
std::unique_ptr< weld::CheckButton > m_xLayoutBtn
void SetUseAsianOptions(bool bVal)
virtual void ChildWinDispose() override
bool IsIgnoreDiacritics_CTL() const
constexpr sal_uInt16 XATTR_FILL_FIRST(XATTRSET_LINE+1)
virtual SvxSearchItem * Clone(SfxItemPool *pPool=nullptr) const override
virtual void Start(bool bStartTimer=true) override
void LeaveRegistrations(const char *pFile=nullptr, int nLine=0)
virtual sal_uInt16 GetLonger()=0
WhichRangesContainer pRanges
virtual TransliterationFlags GetTransliterationFlags() const =0
std::unique_ptr< weld::Button > m_xCloseBtn
std::unique_ptr< weld::Label > m_xCalcSearchDirFT
std::unique_ptr< SvxSearchController > pOptionsController
sal_uInt16 GetSlotId(sal_uInt16 nWhich) const
sal_uInt16 GetWhichByPos(sal_uInt16 nPos) const
SVX_DLLPRIVATE void Init_Impl(bool bHasItemSet)
std::unique_ptr< SearchAttrItemList > pSearchList
std::unique_ptr< weld::Frame > m_xSearchFrame
virtual TransliterationFlags GetTransliterationFlags() const override
void SetTimeout(sal_uInt64 nTimeoutMs)
SfxItemPool * GetPool() const
std::shared_ptr< SvxSearchDialog > dialog
std::vector< OUString > & GetList()
static void SetSearchLabel(const SearchLabel &rSL)
const css::uno::Reference< css::frame::XFrame > & GetFrameInterface() const
IMPL_LINK(SvxSearchDialog, LBSelectHdl_Impl, weld::ComboBox &, rCtrl, void)
std::unique_ptr< weld::Label > m_xSearchLabel
std::unique_ptr< weld::RadioButton > m_xRowsBtn
TransliterationFlags GetTransliterationFlags() const
SVX_DLLPRIVATE short executeSubDialog(VclAbstractDialog *dialog)
std::unique_ptr< weld::Button > m_xSearchComponent1PB
sal_uInt16 GetCurPos() const
void Update(sal_uInt16 nId)
std::unique_ptr< weld::Button > m_xAttributeBtn
std::unique_ptr< weld::Button > m_xSimilarityBtn
SVX_DLLPRIVATE void EnableControl_Impl(const weld::Widget &rCtrl)
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
void SetSearchForStyles(bool bVal)
std::unique_ptr< weld::CheckButton > m_xMatchCaseCB
virtual void Activate() override
static SfxViewFrame * Current()
std::unique_ptr< weld::Label > m_xCalcStrFT
std::unique_ptr< weld::RadioButton > m_xColumnsBtn
virtual VclPtr< AbstractSvxJSearchOptionsDialog > CreateSvxJSearchOptionsDialog(weld::Window *pParent, const SfxItemSet &rOptionsSet, TransliterationFlags nInitialFlags)=0
void DisableItem(sal_uInt16 nWhich)
std::unique_ptr< weld::Label > m_xSearchAttrText
std::unique_ptr< weld::Button > m_xReplaceAllBtn
IMPL_LINK_NOARG(SvxSearchDialog, PresentTimeoutHdl_Impl, Timer *, void)
std::unique_ptr< weld::Button > m_xNoFormatBtn
std::unique_ptr< weld::Button > m_xSearchBtn
virtual sal_uInt16 GetOther()=0
sal_uInt16 GetWhich(sal_uInt16 nSlot, bool bDeep=true) const
constexpr tools::Long Height() const
void SetIgnoreDiacritics_CTL(bool bVal)
bool IsSearchFormatted() const
virtual bool IsRelaxed()=0
SfxStyleSheetBase * Next()
In this modeless dialog the attributes for a search are configured and a search is started from it...
virtual void Close() override
std::unique_ptr< weld::ComboBox > m_xSearchLB
std::unique_ptr< weld::ComboBox > m_xReplaceTmplLB
void SetController(std::shared_ptr< SfxDialogController > controller)
Reference< XExecutableDialog > m_xDialog
void Insert(const SearchAttrItem &rItem)
std::unique_ptr< weld::Button > m_xReplaceBtn
Reference< XComponentContext > getProcessComponentContext()
SVX_DLLPRIVATE void SetModifyFlag_Impl(const weld::Widget *pCtrl)
void SetInvokeHandler(const Link< Timer *, void > &rLink)
sal_uInt16 EnterRegistrations(const char *pFile=nullptr, int nLine=0)
SvxSearchDialog(weld::Window *pParent, SfxChildWindow *pChildWin, SfxBindings &rBind)
OUString get_label() const
virtual ~SvxSearchDialogWrapper() override
std::unique_ptr< weld::CheckButton > m_xSearchFormattedCB
SfxDispatcher * GetDispatcher() const
reference_type * get() const
virtual sal_uInt16 GetShorter()=0
virtual void remove(int pos)=0
std::unique_ptr< weld::CheckButton > m_xJapMatchFullHalfWidthCB
void append_text(const OUString &rStr)
void InvalidateAllItems()
std::unique_ptr< SvxSearchController > pSearchController
const SfxPoolItem * Execute(sal_uInt16 nSlot, SfxCallMode nCall=SfxCallMode::SLOT, const SfxPoolItem **pArgs=nullptr, sal_uInt16 nModi=0, const SfxPoolItem **pInternalArgs=nullptr)
std::unique_ptr< weld::CheckButton > m_xNotesBtn
virtual bool HasSelection(bool bText=true) const
SVX_DLLPRIVATE void SetItem_Impl(const SvxSearchItem *pItem)
bool IsInvalidItem(const SfxPoolItem *pItem)
uno::Reference< frame::XDispatch > xCommand1Dispatch
weld::Window * GetFrameWeld(const SfxFrame *pFrame)
virtual bool get_active() const =0
std::vector< OUString > aSearchStrings
virtual SfxChildWinInfo GetInfo() const
std::unique_ptr< weld::Frame > m_xReplaceFrame
const SfxPoolItem * GetCurItem() const
SVX_DLLPRIVATE void ShowOptionalControls_Impl()
std::unique_ptr< SvxSearchItem > pSearchItem
bool m_bDetectedRangeSegmentation false
void set_label(const OUString &rLabel)