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,
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();
211 nWhich = pItem->
Which();
227 for (
size_t i = 0;
i <
size(); ++
i )
231 rSet.
Put( *(*
this)[
i].pItem );
238 for (
size_t i = 0;
i <
size(); ++
i )
240 delete (*
this)[
i].pItem;
241 SrchAttrItemList::clear();
249 if ( nPos + nLen >
size() )
250 nLen =
size() - nPos;
252 for (
size_t i = nPos;
i < nPos + nLen; ++
i )
254 delete (*this)[
i].pItem;
256 SrchAttrItemList::erase(
begin() + nPos,
begin() + nPos + nLen );
261 IS_MOBILE ? OUString(
"svx/ui/findreplacedialog-mobile.ui") : OUString(
"svx/ui/findreplacedialog.ui"),
264 , m_aPresentIdle(
"Bring SvxSearchDialog to Foreground")
268 , bReplaceBackwards(false)
275 , m_xSearchFrame(m_xBuilder->weld_frame(
"searchframe"))
276 , m_xSearchLB(m_xBuilder->weld_combo_box(
"searchterm"))
277 , m_xSearchTmplLB(m_xBuilder->weld_combo_box(
"searchlist"))
278 , m_xSearchAttrText(m_xBuilder->weld_label(
"searchdesc"))
279 , m_xSearchLabel(m_xBuilder->weld_label(
"searchlabel"))
280 , m_xReplaceFrame(m_xBuilder->weld_frame(
"replaceframe"))
281 , m_xReplaceLB(m_xBuilder->weld_combo_box(
"replaceterm"))
282 , m_xReplaceTmplLB(m_xBuilder->weld_combo_box(
"replacelist"))
283 , m_xReplaceAttrText(m_xBuilder->weld_label(
"replacedesc"))
284 , m_xSearchBtn(m_xBuilder->weld_button(
"search"))
285 , m_xBackSearchBtn(m_xBuilder->weld_button(
"backsearch"))
286 , m_xSearchAllBtn(m_xBuilder->weld_button(
"searchall"))
287 , m_xReplaceBtn(m_xBuilder->weld_button(
"replace"))
288 , m_xReplaceAllBtn(m_xBuilder->weld_button(
"replaceall"))
289 , m_xComponentFrame(m_xBuilder->weld_frame(
"componentframe"))
290 , m_xSearchComponent1PB(m_xBuilder->weld_button(
"component1"))
291 , m_xSearchComponent2PB(m_xBuilder->weld_button(
"component2"))
292 , m_xMatchCaseCB(m_xBuilder->weld_check_button(
"matchcase"))
293 , m_xSearchFormattedCB(m_xBuilder->weld_check_button(
"searchformatted"))
294 , m_xWordBtn(m_xBuilder->weld_check_button(
"wholewords"))
295 , m_xCloseBtn(m_xBuilder->weld_button(
"close"))
296 , m_xIncludeDiacritics(m_xBuilder->weld_check_button(
"includediacritics"))
297 , m_xIncludeKashida(m_xBuilder->weld_check_button(
"includekashida"))
298 , m_xOtherOptionsExpander(m_xBuilder->weld_expander(
"OptionsExpander"))
299 , m_xSelectionBtn(m_xBuilder->weld_check_button(
"selection"))
300 , m_xRegExpBtn(m_xBuilder->weld_check_button(
"regexp"))
301 , m_xWildcardBtn(m_xBuilder->weld_check_button(
"wildcard"))
302 , m_xSimilarityBox(m_xBuilder->weld_check_button(
"similarity"))
303 , m_xSimilarityBtn(m_xBuilder->weld_button(
"similaritybtn"))
304 , m_xLayoutBtn(m_xBuilder->weld_check_button(
"layout"))
305 , m_xNotesBtn(m_xBuilder->weld_check_button(
"notes"))
306 , m_xJapMatchFullHalfWidthCB(m_xBuilder->weld_check_button(
"matchcharwidth"))
307 , m_xJapOptionsCB(m_xBuilder->weld_check_button(
"soundslike"))
308 , m_xReplaceBackwardsCB(m_xBuilder->weld_check_button(
"replace_backwards"))
309 , m_xJapOptionsBtn(m_xBuilder->weld_button(
"soundslikebtn"))
310 , m_xAttributeBtn(m_xBuilder->weld_button(
"attributes"))
311 , m_xFormatBtn(m_xBuilder->weld_button(
"format"))
312 , m_xNoFormatBtn(m_xBuilder->weld_button(
"noformat"))
313 , m_xCalcGrid(m_xBuilder->weld_widget(
"calcgrid"))
314 , m_xCalcSearchInFT(m_xBuilder->weld_label(
"searchinlabel"))
315 , m_xCalcSearchInLB(m_xBuilder->weld_combo_box(
"calcsearchin"))
316 , m_xCalcSearchDirFT(m_xBuilder->weld_label(
"searchdir"))
317 , m_xRowsBtn(m_xBuilder->weld_radio_button(
"rows"))
318 , m_xColumnsBtn(m_xBuilder->weld_radio_button(
"cols"))
319 , m_xAllSheetsCB(m_xBuilder->weld_check_button(
"allsheets"))
320 , m_xCalcStrFT(m_xBuilder->weld_label(
"entirecells"))
338 nRememberSize = officecfg::Office::Common::Misc::FindReplaceRememberedSearches::get();
342 auto nTermWidth =
m_xSearchLB->get_approximate_digit_width() * 28;
353 getDialog()->present();
358 PresentTimeoutHdl_Impl(
nullptr);
381 pImpl->aSelectionTimer.SetTimeout( 500 );
382 pImpl->aSelectionTimer.SetInvokeHandler(
425 pImpl->aSelectionTimer.Start();
454 const uno::Reference< frame::XDispatchProvider > xDispatchProv(xFrame, uno::UNO_QUERY);
456 bool bSearchComponent1 =
false;
457 bool bSearchComponent2 =
false;
458 if(xDispatchProv.is())
460 OUString sTarget(
"_self");
461 pImpl->xCommand1Dispatch = xDispatchProv->queryDispatch(
pImpl->aCommand1URL, sTarget, 0);
462 if (
pImpl->xCommand1Dispatch.is())
463 bSearchComponent1 =
true;
464 pImpl->xCommand2Dispatch = xDispatchProv->queryDispatch(
pImpl->aCommand2URL, sTarget, 0);
465 if (
pImpl->xCommand2Dispatch.is())
466 bSearchComponent2 =
true;
469 if( !(bSearchComponent1 || bSearchComponent2) )
474 uno::Reference< lang::XMultiServiceFactory > xConfigurationProvider =
476 uno::Sequence< uno::Any > aArgs {
477 Any(OUString(
"/org.openoffice.Office.Common/SearchOptions/")) };
479 uno::Reference< uno::XInterface > xIFace = xConfigurationProvider->createInstanceWithArguments(
480 "com.sun.star.configuration.ConfigurationUpdateAccess",
482 uno::Reference< container::XNameAccess> xDirectAccess(xIFace, uno::UNO_QUERY);
483 if(xDirectAccess.is())
486 uno::Any aRet = xDirectAccess->getByName(
"ComponentSearchGroupLabel");
489 aRet = xDirectAccess->getByName(
"ComponentSearchCommandLabel1");
492 aRet = xDirectAccess->getByName(
"ComponentSearchCommandLabel2");
497 catch(uno::Exception&){}
562 pImpl->bSaveToModule = b;
569 if (rStr ==
SvxResId(RID_SVXSTR_SEARCH_NOT_FOUND))
576 bool bVal(nSettings & TransliterationFlags::IGNORE_CASE);
578 bVal = bool(nSettings & TransliterationFlags::IGNORE_WIDTH);
676 const uno::Reference< frame::XFrame >
xFrame =
678 uno::Reference< frame::XModuleManager2 > xModuleManager(
681 OUString aModuleIdentifier = xModuleManager->identify( xFrame );
684 catch (
const uno::Exception&)
741 class ToggleSaveToModule
745 mrDialog(rDialog), mbValue(bValue)
747 mrDialog.SetSaveToModule(mbValue);
750 ~ToggleSaveToModule()
752 mrDialog.SetSaveToModule(!mbValue);
767 ToggleSaveToModule aNoModuleSave(*
this,
false);
802 if (
pSearchItem->GetAppFlag() == SvxSearchApp::CALC )
816 case SvxSearchCellType::FORMULA:
820 case SvxSearchCellType::VALUE:
824 case SvxSearchCellType::NOTE:
856 if (
pSearchItem->GetAppFlag() == SvxSearchApp::DRAW )
900 bool bDisableSearch =
false;
905 bool bText = !bSearchPattern;
917 if ( bSearchPattern )
934 pBase = pStylePool->
Next();
961 if ( !(
pSearchItem->GetSearchString().isEmpty()) && bSetSearch )
969 if ( bSetSearch && !bAttributes )
972 OUString aReplaceTxt =
pSearchItem->GetReplaceString();
977 if ( bSetReplace && !bAttributes )
998 bDisableSearch =
m_xSearchLB->get_active_text().isEmpty() &&
1003 if ( bDisableSearch )
1042 pImpl->bSaveToModule =
false;
1044 pImpl->bSaveToModule =
true;
1052 if ( !pSSet && !pRSet )
1055 if ( !
pImpl->pRanges && pSSet )
1057 const sal_uInt16* pPtr = pSSet->
GetRanges();
1058 const sal_uInt16* pTmp = pPtr;
1064 sal_sSize nCnt = pPtr - pTmp + 1;
1065 pImpl->pRanges.reset(
new sal_uInt16[nCnt] );
1066 memcpy(
pImpl->pRanges.get(), pTmp,
sizeof(sal_uInt16) * nCnt );
1069 bool bSetOptimalLayoutSize =
false;
1078 if ( pSSet->
Count() )
1084 if ( !aDesc.isEmpty() )
1089 bSetOptimalLayoutSize =
true;
1100 if ( pRSet->
Count() )
1106 if ( !aDesc.isEmpty() )
1111 bSetOptimalLayoutSize =
true;
1118 if (bSetOptimalLayoutSize)
1124 ClickHdl_Impl(&rCtrl);
1129 ClickHdl_Impl(&rCtrl);
1134 if ( pCtrl && !
bSet )
1264 if (
pImpl->bSaveToModule )
1270 bool bInclusive = ( m_xLayoutBtn->get_label() == aLayoutStr );
1272 if ( ( &rBtn == m_xSearchBtn.get() ) ||
1273 (&rBtn == m_xBackSearchBtn.get()) ||
1274 ( &rBtn == m_xSearchAllBtn.get() )||
1275 ( &rBtn == m_xReplaceBtn.get() ) ||
1276 ( &rBtn == m_xReplaceAllBtn.get() ) )
1278 if ( m_xLayoutBtn->get_active() && !bInclusive )
1280 pSearchItem->SetSearchString ( m_xSearchTmplLB->get_active_text() );
1281 pSearchItem->SetReplaceString( m_xReplaceTmplLB->get_active_text() );
1285 pSearchItem->SetSearchString ( m_xSearchLB->get_active_text() );
1286 pSearchItem->SetReplaceString( m_xReplaceLB->get_active_text() );
1288 if ( &rBtn == m_xReplaceBtn.get() )
1289 Remember_Impl( m_xReplaceLB->get_active_text(), false );
1292 Remember_Impl( m_xSearchLB->get_active_text(), true );
1294 if ( &rBtn == m_xReplaceAllBtn.get() )
1295 Remember_Impl( m_xReplaceLB->get_active_text(), false );
1299 pSearchItem->SetRegExp(
false );
1300 pSearchItem->SetWildcard(
false );
1301 pSearchItem->SetLevenshtein(
false );
1302 if (GetCheckBoxValue(*m_xRegExpBtn))
1303 pSearchItem->SetRegExp(
true );
1304 else if (GetCheckBoxValue(*m_xWildcardBtn))
1305 pSearchItem->SetWildcard(
true );
1306 else if (GetCheckBoxValue(*m_xSimilarityBox))
1307 pSearchItem->SetLevenshtein(
true );
1309 pSearchItem->SetWordOnly(GetCheckBoxValue(*m_xWordBtn));
1311 bool bSetBackwards =
false;
1312 if( &rBtn == m_xBackSearchBtn.get())
1314 bSetBackwards =
true;
1316 else if( &rBtn == m_xReplaceBtn.get())
1318 bSetBackwards = GetCheckBoxValue(*m_xReplaceBackwardsCB);
1319 bReplaceBackwards = GetCheckBoxValue(*m_xReplaceBackwardsCB);
1322 pSearchItem->SetBackward(bSetBackwards);
1324 pSearchItem->SetNotes(GetCheckBoxValue(*m_xNotesBtn));
1325 pSearchItem->SetPattern(GetCheckBoxValue(*m_xLayoutBtn));
1326 pSearchItem->SetSelection(GetCheckBoxValue(*m_xSelectionBtn));
1327 pSearchItem->SetUseAsianOptions(GetCheckBoxValue(*m_xJapOptionsCB));
1329 if( !pSearchItem->IsUseAsianOptions())
1330 nFlags &= TransliterationFlags::IGNORE_CASE |
1331 TransliterationFlags::IGNORE_WIDTH;
1332 if (GetNegatedCheckBoxValue(*m_xIncludeDiacritics))
1333 nFlags |= TransliterationFlags::IGNORE_DIACRITICS_CTL;
1334 if (GetNegatedCheckBoxValue(*m_xIncludeKashida))
1335 nFlags |= TransliterationFlags::IGNORE_KASHIDA_CTL;
1336 pSearchItem->SetTransliterationFlags( nFlags );
1340 if ( m_xCalcSearchInLB->get_active() != -1)
1341 pSearchItem->SetCellType( static_cast<SvxSearchCellType>(m_xCalcSearchInLB->get_active()) );
1343 pSearchItem->SetRowDirection( m_xRowsBtn->get_active() );
1344 pSearchItem->SetAllTables( m_xAllSheetsCB->get_active() );
1345 pSearchItem->SetSearchFormatted( m_xSearchFormattedCB->get_active() );
1348 if ((&rBtn == m_xSearchBtn.get()) || (&rBtn == m_xBackSearchBtn.get()))
1349 pSearchItem->SetCommand( SvxSearchCmd::FIND );
1350 else if ( &rBtn == m_xSearchAllBtn.get() )
1351 pSearchItem->SetCommand( SvxSearchCmd::FIND_ALL );
1352 else if ( &rBtn == m_xReplaceBtn.get() )
1353 pSearchItem->SetCommand( SvxSearchCmd::REPLACE );
1354 else if ( &rBtn == m_xReplaceAllBtn.get() )
1355 pSearchItem->SetCommand( SvxSearchCmd::REPLACE_ALL );
1358 if ( !bFormat && pSearchItem->GetPattern() )
1361 pSearchList->Clear();
1364 pReplaceList->Clear();
1367 const SfxPoolItem* ppArgs[] = { pSearchItem.get(),
nullptr };
1370 else if ( &rBtn == m_xCloseBtn.get() )
1372 if ( !m_xLayoutBtn->get_active() || bInclusive )
1374 OUString
aStr( m_xSearchLB->get_active_text() );
1376 if ( !
aStr.isEmpty() )
1377 Remember_Impl(
aStr,
true );
1378 aStr = m_xReplaceLB->get_active_text();
1380 if ( !
aStr.isEmpty() )
1381 Remember_Impl(
aStr,
false );
1383 SaveToModule_Impl();
1386 else if (&rBtn == m_xSimilarityBtn.get())
1390 pSearchItem->IsLEVRelaxed(),
1391 pSearchItem->GetLEVOther(),
1392 pSearchItem->GetLEVShorter(),
1393 pSearchItem->GetLEVLonger() ));
1394 if ( executeSubDialog(pDlg.
get()) ==
RET_OK )
1396 pSearchItem->SetLEVRelaxed( pDlg->
IsRelaxed() );
1397 pSearchItem->SetLEVOther( pDlg->
GetOther() );
1398 pSearchItem->SetLEVShorter( pDlg->
GetShorter() );
1399 pSearchItem->SetLEVLonger( pDlg->
GetLonger() );
1400 SaveToModule_Impl();
1403 else if (&rBtn == m_xJapOptionsBtn.get())
1406 pSearchItem->SetTransliterationFlags( GetTransliterationFlags() );
1409 pSearchItem->GetTransliterationFlags() ));
1410 int nRet = executeSubDialog(aDlg.
get());
1414 pSearchItem->SetTransliterationFlags( nFlags );
1415 ApplyTransliterationFlags_Impl( nFlags );
1418 else if (&rBtn == m_xSearchComponent1PB.get() || &rBtn == m_xSearchComponent2PB.get())
1420 uno::Sequence < beans::PropertyValue > aArgs(2);
1421 beans::PropertyValue* pArgs = aArgs.getArray();
1422 pArgs[0].Name =
"SearchString";
1423 pArgs[0].Value <<= m_xSearchLB->get_active_text();
1424 pArgs[1].Name =
"ParentWindow";
1425 pArgs[1].Value <<=
m_xDialog->GetXWindow();
1426 if (&rBtn == m_xSearchComponent1PB.get())
1428 if ( pImpl->xCommand1Dispatch.is() )
1429 pImpl->xCommand1Dispatch->dispatch(pImpl->aCommand1URL, aArgs);
1433 if ( pImpl->xCommand2Dispatch.is() )
1434 pImpl->xCommand2Dispatch->dispatch(pImpl->aCommand2URL, aArgs);
1443 SetModifyFlag_Impl( &rEd );
1448 bool bAllowEmptySearch = (pSearchItem->GetAppFlag() == SvxSearchApp::CALC);
1450 if (&rEd != m_xSearchLB.get() && &rEd != m_xReplaceLB.get())
1453 sal_Int32 nSrchTxtLen = m_xSearchLB->get_active_text().getLength();
1454 sal_Int32 nReplTxtLen = 0;
1455 if (bAllowEmptySearch)
1456 nReplTxtLen = m_xReplaceLB->get_active_text().getLength();
1457 sal_Int32 nAttrTxtLen = m_xSearchAttrText->get_label().getLength();
1459 if (nSrchTxtLen || nReplTxtLen || nAttrTxtLen)
1461 EnableControl_Impl(*m_xSearchBtn);
1462 EnableControl_Impl(*m_xBackSearchBtn);
1463 EnableControl_Impl(*m_xReplaceBtn);
1464 if (!bWriter || !m_xNotesBtn->get_active())
1466 EnableControl_Impl(*m_xSearchAllBtn);
1467 EnableControl_Impl(*m_xReplaceAllBtn);
1472 m_xComponentFrame->set_sensitive(
false);
1473 m_xSearchBtn->set_sensitive(
false);
1474 m_xBackSearchBtn->set_sensitive(
false);
1475 m_xSearchAllBtn->set_sensitive(
false);
1476 m_xReplaceBtn->set_sensitive(
false);
1477 m_xReplaceAllBtn->set_sensitive(
false);
1483 if ( pImpl->bSaveToModule )
1484 SaveToModule_Impl();
1490 if ( m_xLayoutBtn->get_active() )
1492 if ( !pFamilyController )
1497 switch ( pSearchItem->GetFamily() )
1499 case SfxStyleFamily::Char:
1500 nId = SID_STYLE_FAMILY1;
break;
1502 case SfxStyleFamily::Para:
1503 nId = SID_STYLE_FAMILY2;
break;
1505 case SfxStyleFamily::Frame:
1506 nId = SID_STYLE_FAMILY3;
break;
1508 case SfxStyleFamily::Page:
1509 nId = SID_STYLE_FAMILY4;
break;
1511 case SfxStyleFamily::All:
1515 OSL_FAIL(
"StyleSheetFamily was changed?" );
1519 pFamilyController.reset(
1522 m_xSearchTmplLB->clear();
1523 m_xReplaceTmplLB->clear();
1525 m_xSearchTmplLB->show();
1526 m_xReplaceTmplLB->show();
1527 m_xSearchLB->hide();
1528 m_xReplaceLB->hide();
1530 m_xSearchAttrText->set_label( sDesc );
1531 m_xReplaceAttrText->set_label( sDesc );
1533 if(!sDesc.isEmpty())
1535 if (!m_xReplaceAttrText->get_visible() || !m_xReplaceAttrText->get_visible())
1537 m_xSearchAttrText->show();
1538 m_xReplaceAttrText->show();
1543 m_xFormatBtn->set_sensitive(
false);
1544 m_xNoFormatBtn->set_sensitive(
false);
1545 m_xAttributeBtn->set_sensitive(
false);
1546 m_xSimilarityBox->set_sensitive(
false);
1547 m_xSimilarityBtn->set_sensitive(
false);
1553 pFamilyController.reset();
1556 m_xSearchLB->show();
1557 m_xReplaceLB->show();
1558 m_xSearchTmplLB->hide();
1559 m_xReplaceTmplLB->hide();
1561 m_xSearchAttrText->set_label( BuildAttrText_Impl( sDesc,
true ) );
1562 m_xReplaceAttrText->set_label( BuildAttrText_Impl( sDesc,
false ) );
1564 if(!sDesc.isEmpty())
1566 if (!m_xReplaceAttrText->get_visible() || !m_xReplaceAttrText->get_visible())
1568 m_xSearchAttrText->show();
1569 m_xReplaceAttrText->show();
1574 EnableControl_Impl(*m_xFormatBtn);
1575 EnableControl_Impl(*m_xAttributeBtn);
1576 EnableControl_Impl(*m_xSimilarityBox);
1578 FocusHdl_Impl( bSearch ? *m_xSearchLB : *m_xReplaceLB );
1581 pImpl->bSaveToModule =
false;
1582 FlagHdl_Impl(*m_xLayoutBtn);
1583 pImpl->bSaveToModule =
true;
1588 if ( rStr.isEmpty() )
1595 if (std::find(pArr->begin(), pArr->end(), rStr) != pArr->end())
1598 pArr->insert(pArr->begin(), rStr);
1602 size_t nArrSize = pArr->size();
1605 pListBox->
remove(nArrSize - 1);
1606 pArr->erase(pArr->begin() + nArrSize - 1);
1625 pBase = rPool.
Next();
1631 if ( !aOldSrch.isEmpty() )
1635 if ( !aOldRepl.isEmpty() )
1656 bool bNoSearch =
true;
1658 bool bEnableSearch = bool( SearchOptionFlags::SEARCH &
nOptions );
1666 if ( SearchOptionFlags::SEARCHALL & nOptions )
1673 if ( SearchOptionFlags::REPLACE & nOptions )
1688 if ( SearchOptionFlags::REPLACE_ALL & nOptions )
1702 if ( SearchOptionFlags::WHOLE_WORDS & nOptions )
1706 if ( SearchOptionFlags::BACKWARDS & nOptions )
1716 if ( SearchOptionFlags::REG_EXP & nOptions )
1720 if ( SearchOptionFlags::WILDCARD & nOptions )
1724 if ( SearchOptionFlags::EXACT & nOptions )
1728 if ( SearchOptionFlags::SELECTION & nOptions )
1732 if ( SearchOptionFlags::FAMILIES & nOptions )
1736 if ( SearchOptionFlags::FORMAT & nOptions )
1749 if ( SearchOptionFlags::SIMILARITY & nOptions )
1774 ( SearchOptionFlags::SEARCHALL &
nOptions ) )
1785 ( SearchOptionFlags::REPLACE_ALL &
nOptions ) )
1795 if ( SearchOptionFlags::BACKWARDS &
nOptions )
1842 && ( SearchOptionFlags::FORMAT &
nOptions )
1880 sal_Int32 nTxtLen = m_xSearchAttrText->get_label().getLength();
1882 if (pCtrl == m_xSearchLB.get())
1885 pImpl->bFocusOnSearch =
true;
1886 pCtrl = m_xSearchLB.get();
1890 EnableControl_Impl(*m_xNoFormatBtn);
1892 m_xNoFormatBtn->set_sensitive(
false);
1893 EnableControl_Impl(*m_xAttributeBtn);
1897 pImpl->bFocusOnSearch =
false;
1898 pCtrl = m_xReplaceLB.get();
1901 if (!m_xReplaceAttrText->get_label().isEmpty())
1902 EnableControl_Impl(*m_xNoFormatBtn);
1905 m_xAttributeBtn->set_sensitive(
false);
1911 ModifyHdl_Impl(rComboBox);
1913 if (bFormat && nTxtLen)
1914 m_xLayoutBtn->set_label(aLayoutStr);
1925 m_xLayoutBtn->set_label(aLayoutWriterStr);
1929 m_xLayoutBtn->set_label(aLayoutCalcStr);
1931 m_xLayoutBtn->set_label(aStylesStr);
1938 SaveToModule_Impl();
1947 if ( !pSh || !pImpl->pRanges )
1951 SfxItemSet aSet(rPool, pImpl->pRanges.get());
1953 aSet.MergeRange(SID_ATTR_PARA_MODEL, SID_ATTR_PARA_MODEL);
1956 aSet.MergeRange(nBrushWhich, nBrushWhich);
1962 aSet.InvalidateAllItems();
1967 aTxt =
SvxResId( RID_SVXSTR_SEARCH );
1968 pSearchList->Get( aSet );
1972 aTxt =
SvxResId( RID_SVXSTR_REPLACE );
1973 pReplaceList->Get( aSet );
1975 aSet.DisableItem(SID_ATTR_PARA_MODEL);
1976 aSet.DisableItem(rPool.
GetWhich(SID_ATTR_PARA_PAGEBREAK));
1977 aSet.DisableItem(rPool.
GetWhich(SID_ATTR_PARA_KEEP));
1984 if ( executeSubDialog(pDlg.
get()) !=
RET_OK )
1993 for( sal_uInt16
n = 0;
n < pList->Count(); ++
n )
1997 SfxItemState::SET == aOutSet.GetItemState(
2000 delete pAItem->
pItem;
2006 if( aOutSet.Count() )
2007 pList->Put( aOutSet );
2009 PaintAttrText_Impl();
2022 m_xLayoutBtn->set_label( aLayoutCalcStr );
2026 m_xLayoutBtn->set_label( aLayoutWriterStr);
2028 m_xLayoutBtn->set_label( aStylesStr );
2032 m_xLayoutBtn->set_active(
false );
2034 bool bSetOptimalLayoutSize =
false;
2038 pSearchList->Clear();
2039 m_xSearchAttrText->set_label(
"" );
2040 if (m_xSearchAttrText->get_visible())
2042 m_xSearchAttrText->hide();
2043 bSetOptimalLayoutSize =
true;
2048 pReplaceList->Clear();
2049 m_xReplaceAttrText->set_label(
"" );
2050 if (m_xReplaceAttrText->get_visible())
2052 m_xReplaceAttrText->hide();
2053 bSetOptimalLayoutSize =
true;
2057 if (bSetOptimalLayoutSize)
2060 pImpl->bSaveToModule =
false;
2061 TemplateHdl_Impl(*m_xLayoutBtn);
2062 pImpl->bSaveToModule =
true;
2063 m_xNoFormatBtn->set_sensitive(
false);
2068 if ( !pSearchList || !pImpl->pRanges )
2073 executeSubDialog(pDlg.
get());
2074 PaintAttrText_Impl();
2083 if ( pViewShell->
HasSelection( m_xSearchLB->get_visible() ) )
2084 EnableControl_Impl(*m_xSelectionBtn);
2087 m_xSelectionBtn->set_active(
false );
2088 m_xSelectionBtn->set_sensitive(
false);
2096 bool bSrchFlag )
const
2113 MapUnit eMapUnit = MapUnit::MapCM;
2115 switch ( eFieldUnit )
2117 case FieldUnit::MM: eMapUnit = MapUnit::MapMM;
break;
2120 case FieldUnit::KM: eMapUnit = MapUnit::MapCM;
break;
2121 case FieldUnit::TWIP: eMapUnit = MapUnit::MapTwip;
break;
2122 case FieldUnit::POINT:
2123 case FieldUnit::PICA: eMapUnit = MapUnit::MapPoint;
break;
2124 case FieldUnit::INCH:
2125 case FieldUnit::FOOT:
2126 case FieldUnit::MILE: eMapUnit = MapUnit::MapInch;
break;
2127 case FieldUnit::MM_100TH: eMapUnit = MapUnit::Map100thMM;
break;
2132 for ( sal_uInt16
i = 0;
i < pList->
Count(); ++
i )
2136 if ( !rStr.isEmpty() )
2145 if (rStr.endsWith(
", "))
2146 rStr = rStr.copy(0, rStr.lastIndexOf(
","));
2151 else if ( rItem.
nSlot == SID_ATTR_BRUSH_CHAR )
2154 rStr +=
SvxResId( RID_SVXITEMS_BRUSH_CHAR );
2172 if ( !
bFormat && !aDesc.isEmpty() )
2175 bool bSetOptimalLayoutSize =
false;
2183 bSetOptimalLayoutSize =
true;
2194 bSetOptimalLayoutSize =
true;
2200 if (bSetOptimalLayoutSize)
2287 nFlags &= TransliterationFlags::IGNORE_CASE |
2288 TransliterationFlags::IGNORE_WIDTH;
2290 nFlags |= TransliterationFlags::IGNORE_DIACRITICS_CTL;
2292 nFlags |= TransliterationFlags::IGNORE_KASHIDA_CTL;
2328 dialog->Initialize( pInfo );
2330 pBindings->
Update( SID_SEARCH_ITEM );
2331 pBindings->
Update( SID_SEARCH_OPTIONS );
2332 pBindings->
Update( SID_SEARCH_SEARCHSET );
2333 pBindings->
Update( SID_SEARCH_REPLACESET );
2334 dialog->bConstruct =
false;
2355 bool bNotFound = rStr ==
SvxResId(RID_SVXSTR_SEARCH_NOT_FOUND);
2357 css::uno::Reference< css::beans::XPropertySet > xPropSet(
2359 css::uno::Reference< css::frame::XLayoutManager > xLayoutManager;
2360 xPropSet->getPropertyValue(
"LayoutManager") >>= xLayoutManager;
2361 css::uno::Reference< css::ui::XUIElement > xUIElement =
2362 xLayoutManager->getElement(
"private:resource/toolbar/findbar");
2363 if (!xUIElement.is())
2365 css::uno::Reference< css::awt::XWindow > xWindow(
2366 xUIElement->getRealInterface(), css::uno::UNO_QUERY_THROW);
2368 for (ToolBox::ImplToolItems::size_type
i = 0; pToolBox &&
i < pToolBox->GetItemCount(); ++
i)
2370 sal_uInt16
id = pToolBox->GetItemId(
i);
2371 if (pToolBox->GetItemCommand(
id) ==
".uno:SearchLabel")
2382 if (pToolBox->GetItemCommand(
id) ==
".uno:FindText")
2392 xLayoutManager->doLayout();
2402 css::uno::Reference< css::beans::XPropertySet > xPropSet(
2404 css::uno::Reference< css::frame::XLayoutManager > xLayoutManager;
2405 xPropSet->getPropertyValue(
"LayoutManager") >>= xLayoutManager;
2406 if (!xLayoutManager.is())
2408 css::uno::Reference< css::ui::XUIElement > xUIElement =
2409 xLayoutManager->getElement(
"private:resource/toolbar/findbar");
2410 if (!xUIElement.is())
2412 css::uno::Reference< css::awt::XWindow > xWindow(
2413 xUIElement->getRealInterface(), css::uno::UNO_QUERY_THROW);
2415 for (ToolBox::ImplToolItems::size_type
i = 0; pToolBox &&
i < pToolBox->GetItemCount(); ++
i)
2417 sal_uInt16
id = pToolBox->GetItemId(
i);
2418 if (pToolBox->GetItemCommand(
id) ==
".uno:SearchLabel")
2421 return pSearchLabel ? pSearchLabel->
get_label() : OUString();
2431 sStr =
SvxResId(RID_SVXSTR_SEARCH_END);
2433 sStr =
SvxResId(RID_SVXSTR_SEARCH_START);
2435 sStr =
SvxResId(RID_SVXSTR_SEARCH_END_WRAPPED);
2437 sStr =
SvxResId(RID_SVXSTR_SEARCH_START_WRAPPED);
2439 sStr =
SvxResId(RID_SVXSTR_SEARCH_END_SHEET);
2441 sStr =
SvxResId(RID_SVXSTR_SEARCH_NOT_FOUND);
2443 sStr =
SvxResId(RID_SVXSTR_SEARCH_NAV_ELEMENT_NOT_FOUND);
2445 sStr =
SvxResId(RID_SVXSTR_SEARCH_REMINDER_END_WRAPPED);
2447 sStr =
SvxResId(RID_SVXSTR_SEARCH_REMINDER_START_WRAPPED);
2451 GetChildWindow( SvxSearchDialogWrapper::GetChildWindowId() )))
2452 pWrp->getDialog()->SetSearchLabel(sStr);
2460 GetChildWindow( SvxSearchDialogWrapper::GetChildWindowId() )))
2461 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
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
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
bool IsCJKFontEnabled() const
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)
virtual VclPtr< VclAbstractDialog > CreateSvxSearchAttributeDialog(weld::Window *pParent, SearchAttrItemList &rLst, const sal_uInt16 *pWhRanges)=0
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)
bool IsJapaneseFindEnabled() const
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()
SVX_DLLPRIVATE void SaveToModule_Impl()
void SetUseRegularExpression(bool bVal)
std::unique_ptr< sal_uInt16[]> pRanges
virtual ~SvxSearchDialog() override
const OUString & GetName() const
std::unique_ptr< weld::CheckButton > m_xWordBtn
OUString SvxResId(const char *pId)
enumrange< T >::Iterator begin(enumrange< T >)
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
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
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
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
void LeaveRegistrations(const char *pFile=nullptr, int nLine=0)
virtual void Start() override
virtual sal_uInt16 GetLonger()=0
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
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
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
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)
tools::Long Height() const
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
const sal_uInt16 * GetRanges() 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)
constexpr sal_uInt16 XATTR_FILL_LAST(XATTR_FILLBACKGROUND)
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)
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
void set_label(const OUString &rLabel)