2021-12-26

216: Writer '.uno:ExecuteSearch'

<The previous article in this series | The table of contents of this series | The next article in this series>

A UNO dispatch command that searches the text document for the string or paragraph style or with the regular expression, with optional replacing

Topics


About: UNO (Universal Network Objects)
About: LibreOffice
About: Apache OpenOffice
About: Writer

The table of contents of this article


Starting Context


  • The reader has knowledge of what 'UNO dispatch command' is and how to call one (if the URL and the arguments of the command are clear).

Target Context


  • The reader will know the specifications of the UNO dispatch command.

Orientation


There are some articles that explain how to execute any UNO dispatch commands and get the whole available information from the execution, in Java, in C++, in C#, in Python, and in LibreOffice or Apache OpenOffice Basic.

There are the list for the application foundations, the list for Writer, and the list for Calc of the UNO dispatch commands listed so far in this series.


Main Body


1: The Specifications


URL: .uno:ExecuteSearch

Description: This command searches the text document for the specified string or paragraph style or with the specified regular expression. The search can be done for the next occurrence or for all the occurrences. Some criteria like case sensitivity, similarity degree, etc. can be specified. The found strings or paragraph styles can be optionally replaced with the specified replacing string or paragraph style.

Arguments (the types are UNO datum types):

NameTypeValue
SearchItem.StyleFamilyshortSeems not be used
SearchItem.CellTypeshortSeems not be used
SearchItem.RowDirectionbooleanSeems not be used
SearchItem.AllTablesbooleanSeems not be used
SearchItem.SearchFilteredbooleanSeems not be used
SearchItem.BackwardbooleanWhether the search is performed backward: true -> performed backward, false -> performed forward
SearchItem.PatternbooleanWhether the search is a paragraph styles search or not: true -> a paragraph styles search, false -> a strings search
SearchItem.ContentbooleanSeems not be used
SearchItem.AsianOptionsbooleanWhether the search is performed for 'sounds-like' strings in Japanese or not: true -> performed for 'sounds-like' strings, false -> not performed for 'sounds-like' strings
SearchItem.AlgorithmTypeshortThe strings search algorithm: 0 -> plain text search, 1 -> regular expression search, 2 -> similarity search
SearchItem.SearchFlagslongThe sum of these flags: 16 -> search for only words that wholly match the search expression, 2048 -> search only the selected words, 4096 -> seems not be used, 65536 -> for similarity search (Weighted Levenshtein Distance search), relax the similarity criteria ("the search is also successful if the combined pool for insertions and deletions is below a doubled calculated limit and replacements are treated differently; additionally, swapped characters are counted as one replacement" according to the reference document, whatever that means); refer to this for more information, especially about '65536'.
SearchItem.SearchStringstringThe search expression (plain string, regular expression, or paragraph style name)
SearchItem.ReplaceStringstringThe replace expression (replacing string or replacing paragraph style name)
SearchItem.Localecom.sun.star.lang.LocaleThe locale used in case insensitive search (refer to this)
SearchItem.ChangedCharslongThe allowed number of changed characters for being judged to be similar
SearchItem.DeletedCharslongThe allowed number of deleted characters for being judged to be similar
SearchItem.InsertedCharslongThe allowed number of inserted characters for being judged to be similar
SearchItem.TransliterateFlagslongThe sum of language-specific flags: 256 -> ignore the cases, 1024 -> ignore the character widths, 1073741824 -> ignore diacritics, etc. (too many to be cited here: refer to this and this for more).
SearchItem.CommandshortThe execution type: 0 -> find the next occurrence, 1 -> find all the occurrences, 2 -> replace the current occurrence and find the next occurrence, 3 -> replace all the occurrences
SearchItem.SearchStartPointXlongThe find-next-occurence search starting position X coordinate in twips (the value '0' together with 'SearchItem.SearchStartPointY' '0' means that no starting position is specified, meaning that the search is performed from the current cursor)
SearchItem.SearchStartPointYlongThe find-next-occurence search starting position Y coordinate in twips (the value '0' together with 'SearchItem.SearchStartPointX' '0' means that no starting position is specified, meaning that the search is performed from the current cursor)
SearchItem.SearchFormattedbooleanSeems not be used
SearchItem.AlgorithmType2shortSeems not be used
QuietbooleanSeems not be used

The related information (the value of com.sun.star.frame.FeatureStateEvent.State) (the types are UNO datum types):

TypeValue
N/Avoid

The result information (the value of com.sun.star.frame.DispatchResultEvent.Result) (the type is a UNO datum type):

IfTypeValue
something is foundbooleantrue
otherwiseN/Anull

<The previous article in this series | The table of contents of this series | The next article in this series>