Page 1 of 1

[Solved] Basic: Find and replace characters with overline

Posted: Sun May 30, 2021 8:23 am
by pnm_asst_ed
I have a Writer document containing instances of the string "L.M.H", where each of "L", "M", and "H" might or might not have an overline (always single). There are also a few cases in which "L", "M", and "H" appear as singletons, also with or without overlines.

I need to change each instance of those characters to lowercase, small caps, adding 2 points to the font height, and retaining the overlines.

Both the Find/Replace dialog and (so far as I can tell) the Find/Replace code interfaces do not support searching characters with overlines, and if I try to take care of the other property changes on their own, the overlines are lost.

Is there some other way to detect characters with overlines?

Re: Basic: Find and replace characters with overline

Posted: Sun May 30, 2021 10:43 am
by karolus
It should be easy enough to find all instances of exactly L.M.H and just make the settings via →Format→Text…

Inside the Find&Replace-dialog thereis a Format-button available, either the Cursor is in the Search-field or in the Replace-field, use it.

Re: Basic: Find and replace characters with overline

Posted: Sun May 30, 2021 11:30 am
by JeJe
Find/replace dialog, more options/ Format button, overlining

Re: Basic: Find and replace characters with overline

Posted: Sat Jun 05, 2021 11:58 pm
by pnm_asst_ed
Unfortunately that doesn't work — at least not in OO 4.1.10. After selecting "single" in the overline option of the Format dialog, no such option is reflected below the "Search for" box, and the actual search finds every instance of whatever is in the Search For box, not just the overlined ones.

Re: Basic: Find and replace characters with overline

Posted: Sun Jun 06, 2021 1:26 am
by JeJe
You're right. Something like this then... (quickly based on Useful Macro Information For OpenOffice By Andrew Pitonyak example)

Code: Select all

Sub searchForOverlines
Dim vDescriptor, vFound
' Create a descriptor from a searchable document.
vDescriptor = ThisComponent.createSearchDescriptor()
With vDescriptor

.SearchString = searchstring 'SET TO WHATEVER
' These all default to false
.SearchWords = true
.SearchCaseSensitive = False
End With

vFound = ThisComponent.findall(vDescriptor)

for i = 0 to vfound.count -1 'GO THROUGH FIND RESULTS AND SEE WHICH HAVE OVERLINE
if vFound(i).charoverline then 
'do whatever
vFound(i).string = ucase(vfound(i).string)
end if
next
End Sub

Re: Basic: Find and replace characters with overline

Posted: Wed Jun 09, 2021 3:46 am
by pnm_asst_ed
That did it! I needed the "CharOverline" attribute name, which I hadn't found (and still haven't found — even on Pitonyak's site. Can you provide a link?). That was the key missing element.

Re: [Solved] Basic: Find and replace characters with overlin

Posted: Wed Jun 09, 2021 10:52 am
by JeJe
It should be here but isn't - there are missing bits on other API pages too.
https://www.openoffice.org/api/docs/com ... rties.html

You'd find it easily by using MRI though.

Re: [Solved] Basic: Find and replace characters with overlin

Posted: Wed Jun 09, 2021 12:01 pm
by DiGro
I suspect it was a new(er) attribute and not introduced in the API

Specs are here : https://www.openoffice.org/specs/appwid ... d_Text.odt