Skip to content

Commit

Permalink
For bug #47709
Browse files Browse the repository at this point in the history
Implement a new plugin method to find and select specified text
  • Loading branch information
KirillovIlya committed Feb 19, 2024
1 parent 875b0e5 commit d378245
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions word/api_plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,35 @@

this.WordControl.m_oLogicDocument.ReplaceSearchElement(sReplace, true, null, false);
};
/**
* Find and select the next occurrence of the text starting at the current position.
* @memberof Api
* @typeofeditors ["CDE"]
* @alias SearchAndReplace
* @param {Object} oProperties - An object which contains the search and replacement strings.
* @param {string} oProperties.searchString - The search string.
* @param {string} oProperties.replaceString - The replacement string.
* @param {boolean} [isForward=true] - Search direction.
* @returns {boolean} returns false if text was not found
*/
window["asc_docs_api"].prototype["pluginMethod_SearchNext"] = function(oProperties, isForward)
{
let logicDocument = this.WordControl.m_oLogicDocument;
if (!logicDocument)
return false;

let searchProps = new AscCommon.CSearchSettings();
searchProps.SetText(oProperties["searchString"]);
searchProps.SetMatchCase(undefined !== oProperties["matchCase"] ? oProperties["matchCase"] : true);

logicDocument.Search(searchProps);
let elementId = logicDocument.GetSearchElementId(!(false === isForward || 0 === isForward));
if (null === elementId)
return false;

logicDocument.SelectSearchElement(elementId);
return true;
};
/**
* Returns file content in the HTML format.
* @memberof Api
Expand Down

0 comments on commit d378245

Please sign in to comment.