[Solved] Basic: Find and replace characters with overline

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
pnm_asst_ed
Posts: 14
Joined: Sun Jul 17, 2011 9:09 pm

[Solved] Basic: Find and replace characters with overline

Post 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?
Last edited by pnm_asst_ed on Wed Jun 09, 2021 3:47 am, edited 1 time in total.
AOO413m1(Build:9783) - Rev. 1761381
MacOS 10.12.3 (16D32)

Assistant Editor
Perspectives of New Music
User avatar
karolus
Volunteer
Posts: 1158
Joined: Sat Jul 02, 2011 9:47 am

Re: Basic: Find and replace characters with overline

Post 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.
AOO4, Libreoffice 6.1 on Rasbian OS (on ARM)
Libreoffice 7.4 on Debian 12 (Bookworm) (on RaspberryPI4)
Libreoffice 7.6 flatpak on Debian 12 (Bookworm) (on RaspberryPI4)
JeJe
Volunteer
Posts: 2764
Joined: Wed Mar 09, 2016 2:40 pm

Re: Basic: Find and replace characters with overline

Post by JeJe »

Find/replace dialog, more options/ Format button, overlining
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
pnm_asst_ed
Posts: 14
Joined: Sun Jul 17, 2011 9:09 pm

Re: Basic: Find and replace characters with overline

Post 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.
AOO413m1(Build:9783) - Rev. 1761381
MacOS 10.12.3 (16D32)

Assistant Editor
Perspectives of New Music
JeJe
Volunteer
Posts: 2764
Joined: Wed Mar 09, 2016 2:40 pm

Re: Basic: Find and replace characters with overline

Post 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
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
pnm_asst_ed
Posts: 14
Joined: Sun Jul 17, 2011 9:09 pm

Re: Basic: Find and replace characters with overline

Post 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.
AOO413m1(Build:9783) - Rev. 1761381
MacOS 10.12.3 (16D32)

Assistant Editor
Perspectives of New Music
JeJe
Volunteer
Posts: 2764
Joined: Wed Mar 09, 2016 2:40 pm

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

Post 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.
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
User avatar
DiGro
Posts: 173
Joined: Mon Oct 08, 2007 1:31 am
Location: Hoorn NH, The Netherlands

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

Post 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
____________
DiGro

AOO 4.1.15 (Dutch) on Windows 11. Scanned with Ziggo Safe Online (F-Secure)
Post Reply