But i got incorected result, when i search by CharWeight. Instead of substring, I got the whole paragraph, which has a bold text. Why is it happens?
Code: Select all
import uno,sys,re
from com.sun.star.awt import FontWeight
from com.sun.star.beans import PropertyValue
..
oSearch = oDoc.createSearchDescriptor()
oSearch.SearchString = oSearchString
oSearch.SearchCaseSensitive = False
oSearch.SearchRegularExpression = True
oSearch.SearchStyles = True
oSearch.SearchWords = False
SrchAttributes = []
prop = PropertyValue()
prop.Name = 'CharWeight'
prop.Value = FontWeight.BOLD
SrchAttributes.append(prop)
oSearch.setSearchAttributes(SrchAttributes)
oFound = oDoc.findNext(oLCurs, oSearch)
while oFound != False:
if oDoc.Text.compareRegionEnds(oFound, oRCurs) <= 0:
break
oString = oFound.getString()
msgBox(oString)
oFound.setString('')
oFound = oDoc.findNext(oFound.End, oSearch)