Search and replace: supertext

Creating a macro - Writing a Script - Using the API

Search and replace: supertext

Postby Butch1 » Wed Apr 05, 2017 12:59 pm

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   Expand viewCollapse view
SrchAttributes(0).Name  = "CharPosture"
SrchAttributes(0).Value = com.sun.star.awt.FontSlant.ITALIC
oReplace.SetSearchAttributes(SrchAttributes())
LibreOffice 5.3.2.2 (Portable)
Butch1
 
Posts: 21
Joined: Wed Apr 05, 2017 12:52 pm

Re: Search and replace: supertext

Postby Zizi64 » Wed Apr 05, 2017 2:07 pm

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   Expand viewCollapse view
Super:⁺⁻⁰¹²³⁴⁵⁶⁷⁸⁹⁼⁽⁾ᵃᵇᶜᵈᶠ⁻ᴬᴮᴰᴱ Sub:₀₁₃₄₅₆₇₈₉ₐₕᵢⱼₗ

The well featured Unicode fonts have not a full English alphabet fot the sub- and supercript...
Tibor Kovacs, Hungary; LibreOffice4.4.7 on Win7x64Prof.
And the portable versions: LO3.3.0-LO5.4.1 and AOO4.1.3
Please, edit the topic's initial post, and add the word "[Solved]" at the beginning of the subject line - if your problem has been solved.
User avatar
Zizi64
Volunteer
 
Posts: 5786
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Search and replace: supertext

Postby Butch1 » Wed Apr 05, 2017 8:05 pm

@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 5.3.2.2 (Portable)
Butch1
 
Posts: 21
Joined: Wed Apr 05, 2017 12:52 pm

Re: Search and replace: supertext

Postby Zizi64 » Wed Apr 05, 2017 9:08 pm

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; LibreOffice4.4.7 on Win7x64Prof.
And the portable versions: LO3.3.0-LO5.4.1 and AOO4.1.3
Please, edit the topic's initial post, and add the word "[Solved]" at the beginning of the subject line - if your problem has been solved.
User avatar
Zizi64
Volunteer
 
Posts: 5786
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Search and replace: supertext

Postby Zizi64 » Wed Apr 05, 2017 9:54 pm

My second tip:

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

Code: Select all   Expand viewCollapse view
" 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; LibreOffice4.4.7 on Win7x64Prof.
And the portable versions: LO3.3.0-LO5.4.1 and AOO4.1.3
Please, edit the topic's initial post, and add the word "[Solved]" at the beginning of the subject line - if your problem has been solved.
User avatar
Zizi64
Volunteer
 
Posts: 5786
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Search and replace: supertext

Postby Butch1 » Thu Apr 06, 2017 9:26 am

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

I am experimenting now with searching methods like this:
Code: Select all   Expand viewCollapse view
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 5.3.2.2 (Portable)
Butch1
 
Posts: 21
Joined: Wed Apr 05, 2017 12:52 pm


Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 9 guests