Page 1 of 1

Search and replace: supertext

Posted: Wed Apr 05, 2017 12:59 pm
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())

Re: Search and replace: supertext

Posted: Wed Apr 05, 2017 2:07 pm
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...

Re: Search and replace: supertext

Posted: Wed Apr 05, 2017 8:05 pm
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...

Re: Search and replace: supertext

Posted: Wed Apr 05, 2017 9:08 pm
by Zizi64
Unicode superscript: Not complete enough. There is no superscript asterisk...
Yes, it is true...
https://ask.libreoffice.org/en/question ... a-formula/

Re: Search and replace: supertext

Posted: Wed Apr 05, 2017 9:54 pm
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.

Re: Search and replace: supertext

Posted: Thu Apr 06, 2017 9:26 am
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