Kaydet (Commit) de432c0a authored tarafından Miklos Vajna's avatar Miklos Vajna

sd: implement per-view LOK_CALLBACK_SEARCH_RESULT_SELECTION

This way views can search without disturbing each other.

Change-Id: I40e69b6102a959ef1f1825a7af1438c2f2fcf807
Reviewed-on: https://gerrit.libreoffice.org/26227Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.co.uk>
Tested-by: 's avatarJenkins <ci@libreoffice.org>
üst a61b7b81
...@@ -670,7 +670,13 @@ bool Outliner::SearchAndReplaceAll() ...@@ -670,7 +670,13 @@ bool Outliner::SearchAndReplaceAll()
std::stringstream aStream; std::stringstream aStream;
boost::property_tree::write_json(aStream, aTree); boost::property_tree::write_json(aStream, aTree);
OString aPayload = aStream.str().c_str(); OString aPayload = aStream.str().c_str();
pViewShell->GetDoc()->libreOfficeKitCallback(LOK_CALLBACK_SEARCH_RESULT_SELECTION, aPayload.getStr()); if (comphelper::LibreOfficeKit::isViewCallback())
{
SfxViewShell& rSfxViewShell = pViewShell->GetViewShellBase();
rSfxViewShell.libreOfficeKitViewCallback(LOK_CALLBACK_SEARCH_RESULT_SELECTION, aPayload.getStr());
}
else
pViewShell->GetDoc()->libreOfficeKitCallback(LOK_CALLBACK_SEARCH_RESULT_SELECTION, aPayload.getStr());
} }
} }
...@@ -680,7 +686,13 @@ bool Outliner::SearchAndReplaceAll() ...@@ -680,7 +686,13 @@ bool Outliner::SearchAndReplaceAll()
{ {
// Find-all, tiled rendering and we have at least one match. // Find-all, tiled rendering and we have at least one match.
OString aPayload = OString::number(mnStartPageIndex); OString aPayload = OString::number(mnStartPageIndex);
pViewShell->GetDoc()->libreOfficeKitCallback(LOK_CALLBACK_SET_PART, aPayload.getStr()); if (comphelper::LibreOfficeKit::isViewCallback())
{
SfxViewShell& rSfxViewShell = pViewShell->GetViewShellBase();
rSfxViewShell.libreOfficeKitViewCallback(LOK_CALLBACK_SET_PART, aPayload.getStr());
}
else
pViewShell->GetDoc()->libreOfficeKitCallback(LOK_CALLBACK_SET_PART, aPayload.getStr());
// Emit a selection callback here: // Emit a selection callback here:
// 1) The original one is no longer valid, as we there was a SET_PART in between // 1) The original one is no longer valid, as we there was a SET_PART in between
...@@ -693,7 +705,13 @@ bool Outliner::SearchAndReplaceAll() ...@@ -693,7 +705,13 @@ bool Outliner::SearchAndReplaceAll()
aRectangles.push_back(rSelection.m_aRectangles); aRectangles.push_back(rSelection.m_aRectangles);
} }
OString sRectangles = comphelper::string::join("; ", aRectangles); OString sRectangles = comphelper::string::join("; ", aRectangles);
pViewShell->GetDoc()->libreOfficeKitCallback(LOK_CALLBACK_TEXT_SELECTION, sRectangles.getStr()); if (comphelper::LibreOfficeKit::isViewCallback())
{
SfxViewShell& rSfxViewShell = pViewShell->GetViewShellBase();
rSfxViewShell.libreOfficeKitViewCallback(LOK_CALLBACK_TEXT_SELECTION, sRectangles.getStr());
}
else
pViewShell->GetDoc()->libreOfficeKitCallback(LOK_CALLBACK_TEXT_SELECTION, sRectangles.getStr());
} }
mnStartPageIndex = (sal_uInt16)-1; mnStartPageIndex = (sal_uInt16)-1;
...@@ -799,7 +817,13 @@ bool Outliner::SearchAndReplaceOnce(std::vector<SearchSelection>* pSelections) ...@@ -799,7 +817,13 @@ bool Outliner::SearchAndReplaceOnce(std::vector<SearchSelection>* pSelections)
{ {
// notify LibreOfficeKit about changed page // notify LibreOfficeKit about changed page
OString aPayload = OString::number(maCurrentPosition.mnPageIndex); OString aPayload = OString::number(maCurrentPosition.mnPageIndex);
pViewShell->GetDoc()->libreOfficeKitCallback(LOK_CALLBACK_SET_PART, aPayload.getStr()); if (comphelper::LibreOfficeKit::isViewCallback())
{
SfxViewShell& rSfxViewShell = pViewShell->GetViewShellBase();
rSfxViewShell.libreOfficeKitViewCallback(LOK_CALLBACK_SET_PART, aPayload.getStr());
}
else
pViewShell->GetDoc()->libreOfficeKitCallback(LOK_CALLBACK_SET_PART, aPayload.getStr());
// also about search result selections // also about search result selections
boost::property_tree::ptree aTree; boost::property_tree::ptree aTree;
...@@ -816,7 +840,13 @@ bool Outliner::SearchAndReplaceOnce(std::vector<SearchSelection>* pSelections) ...@@ -816,7 +840,13 @@ bool Outliner::SearchAndReplaceOnce(std::vector<SearchSelection>* pSelections)
std::stringstream aStream; std::stringstream aStream;
boost::property_tree::write_json(aStream, aTree); boost::property_tree::write_json(aStream, aTree);
aPayload = aStream.str().c_str(); aPayload = aStream.str().c_str();
pViewShell->GetDoc()->libreOfficeKitCallback(LOK_CALLBACK_SEARCH_RESULT_SELECTION, aPayload.getStr()); if (comphelper::LibreOfficeKit::isViewCallback())
{
SfxViewShell& rSfxViewShell = pViewShell->GetViewShellBase();
rSfxViewShell.libreOfficeKitViewCallback(LOK_CALLBACK_SEARCH_RESULT_SELECTION, aPayload.getStr());
}
else
pViewShell->GetDoc()->libreOfficeKitCallback(LOK_CALLBACK_SEARCH_RESULT_SELECTION, aPayload.getStr());
} }
else else
{ {
...@@ -1164,8 +1194,17 @@ void Outliner::ShowEndOfSearchDialog() ...@@ -1164,8 +1194,17 @@ void Outliner::ShowEndOfSearchDialog()
if (!mbStringFound) if (!mbStringFound)
{ {
SvxSearchDialogWrapper::SetSearchLabel(SL_NotFound); SvxSearchDialogWrapper::SetSearchLabel(SL_NotFound);
mpDrawDocument->libreOfficeKitCallback(LOK_CALLBACK_SEARCH_NOT_FOUND, if (comphelper::LibreOfficeKit::isViewCallback())
mpSearchItem->GetSearchString().toUtf8().getStr()); {
std::shared_ptr<ViewShell> pViewShell(mpWeakViewShell.lock());
if (pViewShell)
{
SfxViewShell& rSfxViewShell = pViewShell->GetViewShellBase();
rSfxViewShell.libreOfficeKitViewCallback(LOK_CALLBACK_SEARCH_NOT_FOUND, mpSearchItem->GetSearchString().toUtf8().getStr());
}
}
else
mpDrawDocument->libreOfficeKitCallback(LOK_CALLBACK_SEARCH_NOT_FOUND, mpSearchItem->GetSearchString().toUtf8().getStr());
} }
// don't do anything else for search // don't do anything else for search
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment