I need to find Character Styles from a macro script in a Writer document.
I can easily select any text attribute like this:
sub _SelectAttributes(SrchAttributes)
oDoc = ThisComponent
oSrch = oDoc.createSearchDescriptor
with oSrch
.searchAll=True
end with
oSrch.SetSearchAttributes(SrchAttributes())
oFound = oDoc.findAll(oSrch)
oDoc.CurrentController.select(oFound)
end sub
sub SelectBold()
Dim SrchAttributes(0) As New com.sun.star.beans.PropertyValue
SrchAttributes(0).Name = "CharWeight"
SrchAttributes(0).Value = com.sun.star.awt.FontWeight.BOLD
_SelectAttributes(SrchAttributes)
end sub
In this case I am selecting all bold text (direct formatting).
But the following code does not work:
sub SelectCharStyleEmphasis()
Dim SrchAttributes(0) As New com.sun.star.beans.PropertyValue
SrchAttributes(0).Name = "CharStyleName"
SrchAttributes(0).Value = "Emphasis"
_SelectAttributes(SrchAttributes)
end sub
Here is a test case:
bug demo.odt (19.4 KB)
Is it that a bug? Or should I file an enhancement request?
Thank you
Emanuele