Incorrect search result by FontWeight.BOLD style

Creating a macro - Writing a Script - Using the API

Incorrect search result by FontWeight.BOLD style

Postby karpo518 » Wed May 24, 2017 4:33 pm

I want to find substring by text styles. I try to search some characters by styles. I got correct substring, when i search by CharBackColor(or other) style.
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   Expand viewCollapse view
import uno,sys,re
from import FontWeight
from 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
oFound = oDoc.findNext(oLCurs, oSearch)
while oFound != False:
    if oDoc.Text.compareRegionEnds(oFound, oRCurs) <= 0:
    oString = oFound.getString()
    oFound = oDoc.findNext(oFound.End, oSearch)
Last edited by RoryOF on Wed May 24, 2017 4:35 pm, edited 1 time in total.
Reason: Corrected typo in Subject [RoryOF, Moderator]
Libre Office, Linux Mint 18 (64 bit)
Posts: 15
Joined: Wed May 24, 2017 4:17 pm

Re: Incorrect search result by FontWeight.BOLD style

Postby Zizi64 » Sun Jul 09, 2017 7:20 am

Code: Select all   Expand viewCollapse view
oSearch.SearchStyles = True
oSearch.SearchWords = False

Maybe the result is an applied PARAGRAPH STYLE. The parapgraph style is always applied to a whole paragraph.
Tibor Kovacs, Hungary; LO4.4.7, LO5.4.7 on Win7x64Prof.
PortableApps, winPenPack: LO3.3.0-LO6.0.5 and AOO4.1.5
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
User avatar
Posts: 6890
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Return to Macros and UNO API

Who is online

Users browsing this forum: Google [Bot] and 5 guests