There is a similar question about how to search & replace styles here but I don’t find the answer helpuf in my case. I’d like to apply to a searched regex some attributes like FontColor & FontWeight.
Here is what I’ve done:
def apply_style_to_orphan_timecode(self):
bold = PropertyValue('CharWeight', 0, FontWeight.BOLD, 0)
rd = self.doc.createReplaceDescriptor()
rd.SearchRegularExpression = True
rd.SearchString = '^\s?(\[\d{2}:\d{2}:\d{2}\])\s?$'
rd.setPropertyValue('CharWeight', FontWeight.BOLD)
rd.ReplaceString = "$1"
self.doc.replaceAll(rd)
and the result is this error:
<class 'uno.com.sun.star.beans.UnknownPropertyException'>: Unknown property: CharWeight