I have a small problem that I just can't figure out at these late hours
(00:13 right now):
I have written a macro that reads highlighted text and replaces it with
something else (which is calculated by the macro).
To read the highlighted text I use ThisComponent.getCurrentSelection
().getByIndex(0).getString().
This caused me no problems, however I couldn't figure out the parameter in
getByIndex(0). Why 0? What does it mean? 0 what? I tried 1 and 2 but they
only caused errors.
Ok, I guess I can figure that one out myself with some help from Google, so
here is my real question:
When I replace the highlighted text, I do that with
ThisComponent.getCurrentSelection().getByIndex(0).setString(MyString). The
problem is that I want the new inserted string also to be highlighted, so I
can perform the macro on it without having to highlight it manually.
Any ideas? Is there some better way to do this?
Just an example to illustrate what I mean:
"Here is a sentence that will *illustrate* my example."
I hope you can see that one word ("illustrate") in the sentence above is
underlined. That is supposed to illustrate that it is highlighted.
Ok, now I run my macro (this is a fake example, my macro does something
else) and now it looks like this:
"Here is a sentence that will show my example."
As you hopefully can see, nothing is now underlined, however the cursor is
placed right after the word "show". What I want, is that the word "shows" in
this case should be highlighted after the macro was run:
"Here is a sentence that will *show* my example."
This would make it possible to run the macro once again and get the
following result (still a fake example):
"Here is a sentence that will *help you to understand* my example."
And so on...
Thanks in advance
Johnny Andersson