OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

To write in "exponent"

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
yho
General User
General User


Joined: 26 Jul 2006
Posts: 41

PostPosted: Mon Jul 31, 2006 9:49 pm    Post subject: To write in "exponent" Reply with quote

Hi,
I just have a little problem but I don't find the solution in any documentation.
I would like to write a string in exposant in my document :

ex : in my document I have the sentence:
bonjour

and I would like to have for example :
bonjourČ

It isfor a macro in openoffice

Thank you for your help
Back to top
View user's profile Send private message
cjopp
General User
General User


Joined: 29 Jan 2006
Posts: 22

PostPosted: Tue Aug 01, 2006 1:54 pm    Post subject: Reply with quote

Hi yho,
although it would be helpful to see your code first, I could tell you that you have to change the character properties of the characters you want superscript.
The properties you have to change are CharEscapement and CharEscapementHeight. If you want to have the same as if you are doing this manually you have to set the first value to 101 and the second to 58.

Hope that helps,
Christoph
Back to top
View user's profile Send private message
Villeroy
Super User
Super User


Joined: 04 Oct 2004
Posts: 10106
Location: Germany

PostPosted: Tue Aug 01, 2006 2:41 pm    Post subject: Reply with quote

Call Edit>Find&Replace
More Options
Check "Regular Expressions"
Check "Match Case"
Search: Bonjour([.!?;]|$)
Replace: BonjourČ

It finds the word "Bonjour", followed by either one ".", "!", "?", ";" or followed by a line-break. This should be "Bonjour" at the end of a sentence or heading.
_________________
Rest in peace, oooforum.org
Get help on https://forum.openoffice.org
Back to top
View user's profile Send private message
cjopp
General User
General User


Joined: 29 Jan 2006
Posts: 22

PostPosted: Tue Aug 01, 2006 10:06 pm    Post subject: Reply with quote

Hello Villeroy,

I think yho needs a way to change superscript/subscript properties by macro and not just to replace the word "Bonjour".

The best would be we could see the code that should do that.

Have a nice day
Christoph
Back to top
View user's profile Send private message
yho
General User
General User


Joined: 26 Jul 2006
Posts: 41

PostPosted: Tue Aug 01, 2006 10:45 pm    Post subject: Reply with quote

Hello,

Thank you for your help, but I have resolved the problem. In fact I studied footnotes and when I found it, I had to do some operations which deleted the footnote in the text :

Code:

oSect.setString(SortieFootnoteEndnote)

And I would like to rewrite to footnote.......

but somebody told me to use in my code :
Code:

oSect.getText().insertString(oSect.getEnd(), SortieFootnoteEndnote, false)

and it is perfect..

Thank you for your help

Yho
Back to top
View user's profile Send private message
Zarius
OOo Enthusiast
OOo Enthusiast


Joined: 21 Jan 2005
Posts: 142
Location: Brisbane, Australia

PostPosted: Wed Aug 02, 2006 12:45 am    Post subject: Reply with quote

Just in case anyone else wants to know about inserting superscript via a macro, here's a quick example of inserting superscript text (or modifying existing text) into a document. Just run this on a blank writer document to test.

Code:
sub insertSuperScript()
        oDocument = ThisComponent
        oText = oDocument.getText()
        oTextCursor = oText.createTextCursor()
       
        ' firstly add a little standard text
        oTextCursor = oText.getStart()
        oTextCursor.CharEscapement = 0
        oTextCursor.CharEscapementHeight = 0
        oText.getText().insertString(oTextCursor, " N^2 & make_me_superscript & Bonjour", false)

        ' insert a 'superscript' 2 at the current cursor location
        oTextCursor.CharEscapement = 101
        oTextCursor.CharEscapementHeight = 58
        oText.getText().insertString(oTextCursor, "2", false)
       
        ' example of walking through the text with the cursor and changing existing text
        oTextCursor = oText.getStart()
        oTextCursor.collapseToStart()
        oTextCursor.gotoNextWord(false)
        oTextCursor.goRight(2, false)
        oTextCursor.goRight(1, true) ' hopefully select the '2'
        oTextCursor.CharEscapement = 101
        oTextCursor.CharEscapementHeight = 58

        ' example of searching through the document and superscripting the matches
        ' Create a descriptor from a searchable document.
        oDescriptor = ThisComponent.createSearchDescriptor()
        ' Set the text for which to search and other
        ' http://api.openoffice.org/docs/common/ref/com/sun/star/util/SearchDescriptor.html
        with oDescriptor
            .SearchString = "make_me_superscript"
            ' These all default to false
            .SearchWords = true
            .SearchCaseSensitive = False
        end with
        ' Find the first one
        oFound = ThisComponent.findFirst(oDescriptor)
        while (not(IsNull(oFound)))
                oFound.CharEscapement = 101
                oFound.CharEscapementHeight = 58
                oFound = ThisComponent.findNext( oFound.End, oDescriptor)
        wend
end sub

_________________
Zarius Tularial. (WinXP - OOo 1.1.4, FedoraCore 4 - OOo 2.0, RHEL4 - StarOffice 7)
Quoots - a quicker way to open your documents and fill in template details in OOo. (written in OOBasic)
Back to top
View user's profile Send private message Visit poster's website
yho
General User
General User


Joined: 26 Jul 2006
Posts: 41

PostPosted: Thu Aug 03, 2006 2:54 am    Post subject: Reply with quote

Thank you very much for your help!!

yho
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group