23#include <boost/property_tree/json_parser.hpp>
48#include <LibreOfficeKit/LibreOfficeKitEnums.h>
73static void lcl_addContainerToJson(boost::property_tree::ptree& rTree,
const OString& rKey,
const std::vector<OString>& rMatches)
75 boost::property_tree::ptree aChildren;
77 for (
const OString& rMatch : rMatches)
79 boost::property_tree::ptree aChild;
80 aChild.put(
"part",
"0");
81 aChild.put(
"rectangles", rMatch.getStr());
82 aChildren.push_back(std::make_pair(
"", aChild));
85 rTree.add_child(rKey.getStr(), aChildren);
96 std::vector<OString> aMatches;
101 std::vector<OString> aSelectionRectangles;
102 pShellCursor->SwSelPaintRects::Show(&aSelectionRectangles);
103 std::vector<OString> aRect;
104 for (
const OString & rSelectionRectangle : aSelectionRectangles)
106 if (rSelectionRectangle.isEmpty())
108 aRect.push_back(rSelectionRectangle);
111 aMatches.push_back(sRect);
114 boost::property_tree::ptree aTree;
115 aTree.put(
"searchString", pSearchItem->
GetSearchString().toUtf8().getStr());
116 aTree.put(
"highlightAll", bHighlightAll);
119 std::stringstream aStream;
120 boost::property_tree::write_json(aStream, aTree);
121 OString aPayload( aStream.str() );
139 if(pArgs && SfxItemState::SET == pArgs->
GetItemState(SID_SEARCH_QUIET,
false, &pItem))
142 sal_uInt16 nSlot = rReq.
GetSlot();
156 case SID_SEARCH_ITEM:
183 if(
nullptr != pList && pList->
Count() )
187 if (
nullptr != pList && pList->
Count())
198 if(FID_SEARCH_NOW == nSlot && !rReq.
IsAPI())
209 if(
nullptr != pList && pList->
Count() )
213 if (
nullptr != pList && pList->
Count())
226 OSL_ENSURE(pArgs,
"Args missing");
236 case SvxSearchCmd::FIND:
250 case SvxSearchCmd::FIND_ALL:
253 m_pWrtShell->GetSfxViewShell()->setTiledSearching(
true);
255 m_pWrtShell->GetSfxViewShell()->setTiledSearching(
false);
258 SfxHint(SfxHintId::SwNavigatorUpdateTracking));
260 SfxHint(SfxHintId::SwNavigatorSelectOutlinesWithSelections));
264#if HAVE_FEATURE_DESKTOP
279 OUString sText(
SwResId(STR_SEARCH_KEY_FOUND_TIMES));
280 sText = sText.replaceFirst(
"%1", OUString::number(nFound));
287 case SvxSearchCmd::REPLACE:
321 nCmd = SvxSearchCmd::REPLACE;
335 case SvxSearchCmd::REPLACE_ALL:
373#if HAVE_FEATURE_DESKTOP
385 if( !bQuiet && ULONG_MAX != nFound)
387 OUString sText(
SwResId( STR_NB_REPLACED ) );
388 sText = sText.replaceFirst(
"XX", OUString::number( nFound ));
395 uno::Reference< frame::XDispatchRecorder > xRecorder =
398 if ( xRecorder.is() )
406 case FID_SEARCH_SEARCHSET:
407 case FID_SEARCH_REPLACESET:
423 SID_ATTR_PARA_MODEL, SID_ATTR_PARA_KEEP
441 if ( FID_SEARCH_REPLACESET == nSlot )
443 nWhich = SID_SEARCH_REPLACESET;
460 SAL_WARN_IF( nSlot,
"sw",
"nSlot: " << nSlot <<
" wrong Dispatcher (viewsrch.cxx)" );
505 std::optional<SwWait> oWait( std::in_place, *
GetDocShell(),
true );
544#if HAVE_FEATURE_DESKTOP
590#if HAVE_FEATURE_DESKTOP
625 sal_uInt16 nFound = o3tl::narrowing<sal_uInt16>(
FUNC_Search( aOpts ));
658 bool bReqReplace =
true;
743#if HAVE_FEATURE_DESKTOP
763 SID_ATTR_PARA_MODEL, SID_ATTR_PARA_KEEP
775 std::optional<SfxItemSet> xReplSet;
778 xReplSet.emplace(
m_pWrtShell->GetAttrPool(), aSearchAttrRange );
784 if( !xReplSet->Count() )
796 if( aSrchSet.
Count() || ( xReplSet && xReplSet->Count() ))
805 xReplSet ? &*xReplSet :
nullptr );
815 bDoReplace ? &sRplStr :
nullptr );
832#if HAVE_FEATURE_DESKTOP
833 const sal_uInt16
nId = SvxSearchDialogWrapper::GetChildWindowId();
855 case SID_SEARCH_OPTIONS:
860 SearchOptionFlags::REPLACE_ALL );
864 case SID_SEARCH_ITEM:
877 !( aText =
m_pWrtShell->SwCursorShell::GetSelText() ).isEmpty() )
const css::lang::Locale & getLocale(bool bResolveSystem=true) const
void Invalidate(sal_uInt16 nId)
const css::uno::Reference< css::frame::XDispatchRecorder > & GetRecorder() const
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
void MergeRange(sal_uInt16 nFrom, sal_uInt16 nTo)
static void notifyUpdate(SfxViewShell const *pViewShell, int nType)
static void notifyOtherViewsUpdatePerViewId(SfxViewShell const *pViewShell, int nType)
virtual SfxPoolItem * Clone(SfxItemPool *pPool=nullptr) const=0
sal_uInt16 GetSlot() const
const SfxItemSet * GetArgs() const
void AppendItem(const SfxPoolItem &)
void SetReturnValue(const SfxPoolItem &)
void Done(bool bRemove=false)
static SAL_WARN_UNUSED_RESULT SfxViewFrame * Current()
SfxBindings & GetBindings()
SfxChildWindow * GetChildWindow(sal_uInt16)
virtual void libreOfficeKitViewCallback(int nType, const OString &pPayload) const override
SfxViewFrame & GetViewFrame() const
static bool IsCTLFontEnabled()
SvxSearchDialog * getDialog()
static void SetSearchLabel(const SearchLabel &rSL)
const SearchAttrItemList * GetReplaceItemList() const
const SearchAttrItemList * GetSearchItemList() const
bool HasStartPoint() const
void SetReplaceString(const OUString &rNewString)
const OUString & GetSearchString() const
SvxSearchCmd GetCommand() const
void SetSelection(bool bNewSelection)
const OUString & GetReplaceString() const
const i18nutil::SearchOptions2 & GetSearchOptions() const
bool GetSelection() const
void SetCommand(SvxSearchCmd nNewCommand)
void SetSearchString(const OUString &rNewString)
sal_Int32 GetStartPointX() const
void SetFamily(SfxStyleFamily eNewFamily)
sal_Int32 GetStartPointY() const
int SetCursor(const Point &rPt, bool bOnlyText=false, bool bBlock=true)
SwCursor * GetCursor(bool bMakeTableCursor=true) const
Return pointer to the current shell cursor.
bool IsStartOfDoc() const
PaM is Point and Mark: a selection of the document model.
sal_uInt16 Replace(SvxSearchItem const *pItem)
void AddRule(SwUndoArg eWhat, const OUString &rWith)
Represents the current text cursor of one opened edit window.
SfxViewShell * GetSfxViewShell() const
SvxSearchCmd m_eLastSearchCommand
static SvxSearchItem * s_pSrchItem
SwWrtShell & GetWrtShell() const
SAL_DLLPRIVATE sal_uInt16 SearchAll()
void Scroll(const tools::Rectangle &rRect, sal_uInt16 nRangeX=USHRT_MAX, sal_uInt16 nRangeY=USHRT_MAX)
SAL_DLLPRIVATE bool SearchAndWrap(bool bApi)
std::unique_ptr< SwWrtShell > m_pWrtShell
SAL_DLLPRIVATE sal_uLong FUNC_Search(const SwSearchOptions &rOptions)
static std::unique_ptr< SearchAttrItemList > s_xReplaceList
static std::unique_ptr< SearchAttrItemList > s_xSearchList
SwPostItMgr * GetPostItMgr()
static SvxSearchDialog * GetSearchDialog()
SwDocShell * GetDocShell()
void StateSearch(SfxItemSet &)
static sal_uInt16 GetMoveType()
SAL_DLLPRIVATE void Replace()
static void SetMoveType(sal_uInt16 nSet)
void ExecSearch(SfxRequest &)
static bool s_bJustOpened
Used by the UI to modify the document model.
void addCurrentPosition()
ring_container GetRingContainer()
@ InSel
Find in selections.
@ InSelAll
All (only in non-body and selections).
@ InOther
Find "all" in Footer/Header/Fly...
@ InBody
Find "one" only in body text.
constexpr OUStringLiteral IsReadOnly(u"IsReadOnly")
constexpr sal_uInt16 RES_FRMATR_BEGIN(RES_PARATR_LIST_END)
constexpr TypedWhichId< SvxFontItem > RES_CHRATR_CJK_FONT(22)
constexpr sal_uInt16 RES_CHRATR_END(46)
constexpr TypedWhichId< SvxForbiddenRuleItem > RES_PARATR_FORBIDDEN_RULES(75)
constexpr sal_uInt16 RES_PARATR_BEGIN(RES_TXTATR_END)
constexpr TypedWhichId< SvxFirstLineIndentItem > RES_MARGIN_FIRSTLINE(91)
constexpr TypedWhichId< SvxShadowedItem > RES_CHRATR_SHADOWED(13)
constexpr TypedWhichId< SvxFontItem > RES_CHRATR_CTL_FONT(27)
constexpr sal_uInt16 RES_FRMATR_END(141)
constexpr TypedWhichId< SvxWeightItem > RES_CHRATR_CTL_WEIGHT(31)
constexpr TypedWhichId< SvxHyphenZoneItem > RES_PARATR_HYPHENZONE(69)
constexpr TypedWhichId< SvxCharReliefItem > RES_CHRATR_RELIEF(36)
constexpr sal_uInt16 RES_PARATR_END(82)
constexpr TypedWhichId< SvxCharScaleWidthItem > RES_CHRATR_SCALEW(35)
constexpr TypedWhichId< SvxBrushItem > RES_CHRATR_BACKGROUND(21)
constexpr TypedWhichId< SvxCaseMapItem > RES_CHRATR_CASEMAP(RES_CHRATR_BEGIN)
constexpr TypedWhichId< SvxLineSpacingItem > RES_PARATR_LINESPACING(RES_PARATR_BEGIN)
constexpr sal_uInt16 RES_CHRATR_BEGIN(HINT_BEGIN)
constexpr TypedWhichId< SvxEmphasisMarkItem > RES_CHRATR_EMPHASIS_MARK(33)
constexpr TypedWhichId< SvxPostureItem > RES_CHRATR_POSTURE(11)
constexpr TypedWhichId< SvxBlinkItem > RES_CHRATR_BLINK(18)
constexpr TypedWhichId< SvxOverlineItem > RES_CHRATR_OVERLINE(38)
constexpr TypedWhichId< SvxParaVertAlignItem > RES_PARATR_VERTALIGN(76)
constexpr TypedWhichId< SvxCharRotateItem > RES_CHRATR_ROTATE(32)
constexpr TypedWhichId< SvxRightMarginItem > RES_MARGIN_RIGHT(93)
constexpr TypedWhichId< SvxScriptSpaceItem > RES_PARATR_SCRIPTSPACE(73)
constexpr TypedWhichId< SvxWordLineModeItem > RES_CHRATR_WORDLINEMODE(16)
constexpr TypedWhichId< SvxWeightItem > RES_CHRATR_CJK_WEIGHT(26)
constexpr TypedWhichId< SvxTwoLinesItem > RES_CHRATR_TWO_LINES(34)
constexpr TypedWhichId< SwRegisterItem > RES_PARATR_REGISTER(71)
constexpr TypedWhichId< SvxColorItem > RES_CHRATR_COLOR(3)
constexpr TypedWhichId< SvxULSpaceItem > RES_UL_SPACE(98)
const LanguageTag & GetAppLanguageTag()
WhichRangesContainer const aTextFormatCollSetRange(svl::Items< RES_CHRATR_BEGIN, RES_CHRATR_END-1, RES_PARATR_BEGIN, RES_PARATR_END-1, RES_PARATR_LIST_LEVEL, RES_PARATR_LIST_LEVEL, RES_FRMATR_BEGIN, RES_FRMATR_END-1, RES_UNKNOWNATR_BEGIN, RES_UNKNOWNATR_END-1, XATTR_FILL_FIRST, XATTR_FILL_LAST >)
#define SAL_WARN_IF(condition, area, stream)
OString join(std::string_view rSeparator, const std::vector< OString > &rSequence)
static constexpr auto Items
std::optional< OUString > ReplaceBackReferences(const i18nutil::SearchOptions2 &rSearchOpt, SwPaM *const pPam, SwRootFrame const *const pLayout)
Helperfunction to resolve backward references in regular expressions.
Marks a position in the document model.
SwSearchOptions(SwWrtShell const *pSh, bool bBackward)
OUString SwResId(TranslateId aId)
static void lcl_emitSearchResultCallbacks(SvxSearchItem const *pSearchItem, SwWrtShell const *pWrtShell, bool bHighlightAll)
Emits LOK callbacks (count, selection) for search results.
static void lcl_addContainerToJson(boost::property_tree::ptree &rTree, const OString &rKey, const std::vector< OString > &rMatches)
Adds rMatches using rKey as a key to the rTree tree.