/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
/// Adds rMatches using rKey as a key to the rTree tree. staticvoid lcl_addContainerToJson(boost::property_tree::ptree& rTree, const OString& rKey, const std::vector<OString>& rMatches)
{
boost::property_tree::ptree aChildren;
/// Emits LOK callbacks (count, selection) for search results. staticvoid lcl_emitSearchResultCallbacks(SvxSearchItem const * pSearchItem, SwWrtShell const * pWrtShell, bool bHighlightAll)
{ // Emit a callback also about the selection rectangles, grouped by matches.
SwPaM* pPaM = pWrtShell->GetCursor(); if (!pPaM) return;
SfxViewShell* pNotifySh = pWrtShell->GetSfxViewShell(); if (pNotifySh)
pNotifySh->libreOfficeKitViewCallback(LOK_CALLBACK_SEARCH_RESULT_SELECTION, aPayload);
if(bHighlightAll)
{ // FindAll disables this during find, do it once when done.
SfxLokHelper::notifyUpdate(pNotifySh,LOK_CALLBACK_TEXT_SELECTION);
SfxLokHelper::notifyOtherViewsUpdatePerViewId(pNotifySh, LOK_CALLBACK_TEXT_VIEW_SELECTION);
}
}
if (nSlot == FN_REPEAT_SEARCH)
{
OSL_ENSURE(s_pSrchItem, "SearchItem missing"); if( !s_pSrchItem )
s_pSrchItem = new SvxSearchItem(SID_SEARCH_ITEM);
} else
{ // Get SearchItem from request
OSL_ENSURE(pArgs, "Args missing"); if ( pArgs )
{ delete s_pSrchItem;
s_pSrchItem = pArgs->Get(SID_SEARCH_ITEM).Clone();
}
}
// tdf#115665 Format in the CTRL+H search affects the CTRL+F search if (pArgs)
{ if (const SfxBoolItem* pUseAttrItemListItem
= pArgs->GetItemIfSet(SID_SEARCH_USE_ATTR_ITEM_LIST, false))
{ if (!pUseAttrItemListItem->GetValue())
s_xSearchList.reset();
}
}
{ //Scope for SwWait-Object
SwWait aWait( *GetDocShell(), true );
m_pWrtShell->StartAllAction();
// i#8288 "replace all" should not change cursor // position, so save current cursor
m_pWrtShell->Push();
if (!s_pSrchItem->GetSelection())
{ // if we don't want to search in the selection...
m_pWrtShell->KillSelection(nullptr, false); if (SwDocPositions::Start == aOpts.eEnd)
{
m_pWrtShell->EndOfSection();
} else
{
m_pWrtShell->StartOfSection();
}
}
nFound = FUNC_Search( aOpts ); // create it just to overwrite it with stack cursor
m_pWrtShell->CreateCursor(); // i#8288 restore the original cursor position
m_pWrtShell->Pop(SwCursorShell::PopMode::DeleteCurrent);
m_pWrtShell->EndAllAction();
}
// Remember starting position of the search for wraparound // Start- / EndAction perhaps because existing selections of 'search all'
m_pWrtShell->StartAllAction();
m_pWrtShell->Push();
// After a search all action we place the cursor at the beginning of // the document so that the single search selects the first matching // occurrence in the document instead of the second. if( m_eLastSearchCommand == SvxSearchCmd::FIND_ALL )
{ if( SwDocPositions::Start == aOpts.eEnd )
m_pWrtShell->EndOfSection(); else
m_pWrtShell->StartOfSection();
}
// fdo#65014 : Ensure that the point of the cursor is at the extremity of the // selection closest to the end being searched to as to exclude the selected // region from the search. (This doesn't work in the case of multiple // selected regions as the cursor doesn't mark the selection in that case.)
m_pWrtShell->GetCursor()->Normalize( s_pSrchItem->GetBackward() );
if (!m_pWrtShell->HasSelection() && (s_pSrchItem->HasStartPoint()))
{ // No selection -> but we have a start point (top left corner of the // current view), start searching from there, not from the current // cursor position.
SwEditShell& rShell = GetWrtShell();
Point aPosition(s_pSrchItem->GetStartPointX(), s_pSrchItem->GetStartPointY());
rShell.SetCursor(aPosition);
}
// If you want to search in selected areas, they must not be unselected. if (!s_pSrchItem->GetSelection())
m_pWrtShell->KillSelection(nullptr, false);
// Search in the specialized areas when no search is present in selections. // When searching selections will already searched in these special areas. bool bHasSrchInOther = s_bExtra; if (!s_pSrchItem->GetSelection() && !s_bExtra )
{
s_bExtra = true; if( FUNC_Search( aOpts ) )
{
s_bFound = true;
m_pWrtShell->Pop();
m_pWrtShell->EndAllAction(); returntrue;
}
s_bExtra = false;
} else
s_bExtra = !s_bExtra;
// If starting position is at the end or beginning of the document. if (aOpts.bDontWrap)
{
m_pWrtShell->EndAllAction(); if( !bApi )
{ #if HAVE_FEATURE_DESKTOP if (SfxViewShell* pNotifySh = m_pWrtShell->GetSfxViewShell())
pNotifySh->libreOfficeKitViewCallback(LOK_CALLBACK_SEARCH_NOT_FOUND, s_pSrchItem->GetSearchString().toUtf8());
SvxSearchDialogWrapper::SetSearchLabel(SearchLabel::NotFound); #endif
}
s_bFound = false;
m_pWrtShell->Pop(); returnfalse;
}
m_pWrtShell->EndAllAction(); // Try again with WrapAround?
if (bHasSrchInOther)
{
m_pWrtShell->ClearMark(); // Select the start or the end of the entire document if (bSrchBkwrd)
m_pWrtShell->SttEndDoc(false); else
m_pWrtShell->SttEndDoc(true);
}
s_bFound = bool(FUNC_Search( aOpts ));
// If WrapAround found no matches in the body text, search in the special // sections, too. if (!s_bFound && !s_pSrchItem->GetSelection() && !s_bExtra)
{
s_bExtra = true; if (FUNC_Search(aOpts))
s_bFound = true; else
s_bExtra = false;
}
m_pWrtShell->EndAllAction();
oWait.reset(); #if HAVE_FEATURE_DESKTOP if (s_bFound)
{ if (!bSrchBkwrd)
SvxSearchDialogWrapper::SetSearchLabel(SearchLabel::End); else
SvxSearchDialogWrapper::SetSearchLabel(SearchLabel::Start);
} elseif(!bApi)
{ if (SfxViewShell* pNotifySh = m_pWrtShell->GetSfxViewShell())
pNotifySh->libreOfficeKitViewCallback(LOK_CALLBACK_SEARCH_NOT_FOUND, s_pSrchItem->GetSearchString().toUtf8());
SvxSearchDialogWrapper::SetSearchLabel(SearchLabel::NotFound);
} #endif return s_bFound;
}
if (!s_pSrchItem->GetSelection())
{ // Cancel existing selections, if should not be sought in selected areas.
m_pWrtShell->KillSelection(nullptr, false);
//set back old search state
s_pSrchItem->SetCommand( nOldCmd );
s_pSrchItem->SetSelection(bHasSelection);
} /* * remove current selection * otherwise it is always replaced * no matter if the search string exists or not in the selection * Now the selection is removed and the next matching string is selected
*/
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.