OpenOffice.org BASIC Guide.pdf - OpenOffice.org wiki
OpenOffice.org BASIC Guide.pdf - OpenOffice.org wiki
OpenOffice.org BASIC Guide.pdf - OpenOffice.org wiki
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Editing Text Documents 104<br />
individually. Here are the associated properties of the com.sun.star.util.SearchDescriptor<br />
service:<br />
SearchSimilarity (Boolean)<br />
performs a similarity search.<br />
SearchSimilarityAdd (Short)<br />
number of characters which may be added for a similarity search.<br />
SearchSimilarityExchange (Short)<br />
number of characters which may be replaced as part of a similarity search.<br />
SearchSimilarityRemove (Short)<br />
number of characters which may be removed as part of a similarity search.<br />
SearchSimilarityRelax (Boolean)<br />
takes all deviation rules into consideration at the same time for the search expression.<br />
Once the SearchDescriptor has been prepared as requested, it can be applied to the text<br />
document. The <strong>OpenOffice</strong>.<strong>org</strong> documents provide the findFirst and findNext methods for<br />
this purpose:<br />
Found = Doc.findFirst (SearchDesc)<br />
Do While Found<br />
' Suchergebnis bearbeiten<br />
Found = Doc.findNext( Found.End, Search)<br />
Loop<br />
The example finds all matches in a loop and returns a TextRange object, which refers to the<br />
found text passage.<br />
Example: Similarity Search<br />
This example shows how a text can be searched for the word "turnover" and the results<br />
formatted in bold type. A similarity search is used so that not only the word “turnover”, but<br />
also the plural form "turnovers" and declinations such as "turnover's" are found. The found<br />
expressions differ by up to two letters from the search expression:<br />
Dim SearchDesc As Object<br />
Dim Doc As Object<br />
Doc = StarDesktop.CurrentComponent<br />
SearchDesc = Doc.createSearchDescriptor<br />
SearchDesc.SearchString="turnover"<br />
SearchDesc.SearchSimilarity = True<br />
SearchDesc.SearchSimilarityAdd = 2<br />
SearchDesc.SearchSimilarityExchange = 2<br />
SearchDesc.SearchSimilarityRemove = 2<br />
SearchDesc.SearchSimilarityRelax = False