Search and replace: supertext

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
Butch1
Posts: 31
Joined: Wed Apr 05, 2017 12:52 pm

Search and replace: supertext

Post by Butch1 »

How to search for supertext in a macro?
I am unable to find the SrchAttribute for superscript (and subtext) to use it in a macro, as shown below for italic.

Thank you in advance!

Code: Select all

SrchAttributes(0).Name  = "CharPosture"
SrchAttributes(0).Value = com.sun.star.awt.FontSlant.ITALIC
oReplace.SetSearchAttributes(SrchAttributes())
LibreOffice 7.4.5.1 (Portable)
User avatar
Zizi64
Volunteer
Posts: 11352
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Search and replace: supertext

Post by Zizi64 »

Just a tip:

CharEscapement
https://www.openoffice.org/api/docs/com ... rties.html

Have you used the styles for formatting the character (paragraph style or character style) or the characters are formatted by direct formatting method?

It is better to use the real (Unicode) sub- and superscript characters in the text body:

Code: Select all

Super:⁺⁻⁰¹²³⁴⁵⁶⁷⁸⁹⁼⁽⁾ᵃᵇᶜᵈᶠ⁻ᴬᴮᴰᴱ Sub:₀₁₃₄₅₆₇₈₉ₐₕᵢⱼₗ
The well featured Unicode fonts have not a full English alphabet fot the sub- and supercript...
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
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.
Butch1
Posts: 31
Joined: Wed Apr 05, 2017 12:52 pm

Re: Search and replace: supertext

Post by Butch1 »

@Zizi64:
CharEscapement: Yes, but there is no information how to be used in SrchAttributes...
Direct formatting.
Unicode superscript: Not complete enough. There is no superscript asterisk...
LibreOffice 7.4.5.1 (Portable)
User avatar
Zizi64
Volunteer
Posts: 11352
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Search and replace: supertext

Post by Zizi64 »

Unicode superscript: Not complete enough. There is no superscript asterisk...
Yes, it is true...
https://ask.libreoffice.org/en/question ... a-formula/
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
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
Zizi64
Volunteer
Posts: 11352
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Search and replace: supertext

Post by Zizi64 »

My second tip:

Two line from the Basic code of the extension named AltSearch:

Code: Select all

" Subscript (Auto) "+chr(160)+"[:::CharAutoEscapement=true|CharEscapementHeight=58|CharEscapement=-101::]", _
" Superscript (Auto) "+chr(160)+"[:::CharAutoEscapement=true|CharEscapementHeight=58|CharEscapement=101::]", _
Maybe it will give you some ideas, or maybe you can use the AltSearch itself, instead your code.
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
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.
Butch1
Posts: 31
Joined: Wed Apr 05, 2017 12:52 pm

Re: Search and replace: supertext

Post by Butch1 »

@Zizi64:
Thank you very much for your tip!!!

I am experimenting now with searching methods like this:

Code: Select all

SrchAttributes(0).Name = "CharEscapement"
SrchAttributes(0).Value = 33
(Superscript is raised by 33% in my document, according to character format data.)

But it doesn't work. Only searching for value 0 (normal text) works perfectly... (Searching for value 0 identifies all normal text, not superscript!)

Maybe an old bug: https://bz.apache.org/ooo/show_bug.cgi?id=31212
LibreOffice 7.4.5.1 (Portable)
Post Reply