Hi I am very new at OOo programming
I'm using OpenOffice.org 2.3 SDK and OpenOffice.org 2.3 on windows xp with Java 1.6.0.
I want to visually select text (Like when you are holding SHIFT and pressing on another point) that is currently selected by XSentenceCursor to display to the user. Here is a code segmant of the selection process. Or any other implementation would work. I just need the user to press a button and the process should start and select the text and show it visually:
xSentenceCursor.gotoPreviousSentence(false);
boolean hasNextSentence = true;
while(hasNextSentence)
{
xSentenceCursor.gotoEndOfSentence(true);
textTextPos = xSentenceCursor.getString();
System.out.println("Checking: " + textTextPos + "\n");
hasNextSentence = xSentenceCursor.gotoNextSentence(false);
}
This wil be changed (maybe without the while or at least with a break.)
Could anybody plz help me?
[Solved] Visually select text
[Solved] Visually select text
Last edited by HWO on Mon Mar 31, 2008 3:55 pm, edited 1 time in total.
Re: visually select text [Java]
[Moved to Macros and UNO API; add "[Java]" to title]
AOO4/LO5 • Linux • Fedora 23
Re: visually select text [Java]
I think, I missed the point of the question. What exactly is your problem? What are you trying to achieve?HWO wrote:Could anybody plz help me?
OOo 3.2.0 on Ubuntu 10.04 • OOo 3.2.1 on Windows 7 64-bit and MS Windows XP
Re: visually select text [Java]
I'm sorry I thought it might be a little vague.
What I want to do in code is to show a selection of text. That is, I want to show to the user the text I've selected using the XSentenceCursor (or any XTextCursor for that matter) as if the user had selected it using his/her mouse or the shift key and arrows. The only function of this code is therefore to inicate to the user the text that is currently being used as input to a function. I've thought about changing the format of the text, but I don't really want to do that as it might impact the working of another module that I'm (trying) to develop.
What I want to do in code is to show a selection of text. That is, I want to show to the user the text I've selected using the XSentenceCursor (or any XTextCursor for that matter) as if the user had selected it using his/her mouse or the shift key and arrows. The only function of this code is therefore to inicate to the user the text that is currently being used as input to a function. I've thought about changing the format of the text, but I don't really want to do that as it might impact the working of another module that I'm (trying) to develop.
Re: visually select text [Java]
I think I've got the point now. But after some digging I think what you have to deal with is a tough task. What you cannot use is the well known text cursor, because all the selections you apply to a text cursor don't get visual feedback in the GUI. So what you should use is the so called view cursor. But all I have found are some perhaps not so promising links:HWO wrote:What I want to do in code is to show a selection of text.
- Copying a Paragraph from one Writer Document to Another: http://user.services.openoffice.org/en/ ... 760#p13760
- How to copy and paste a text? [solved]: http://www.oooforum.org/forum/viewtopic ... viewcursor
- [Java] Problem enumerating document content: http://www.oooforum.org/forum/viewtopic ... viewcursor
Additionally I played around a little with a simple OOo Basic sample:
Code: Select all
Sub Cursors
rem ---------------------------------------------------------------------------
rem - Get access to the document
dim document as object
document = ThisComponent
rem ---------------------------------------------------------------------------
rem - Get the view cursor
viewCursor = document.getCurrentController().getViewCursor()
MsgBox(viewCursor.string)
viewCursor.gotoStart(false)
viewCursor.gotoEnd(true)
MsgBox(viewCursor.string)
rem ---------------------------------------------------------------------------
rem - Create a text cursor
textCursor = document.Text.createTextCursor
textCursor.gotoStart(false)
textCursor.gotoEndOfWord(true)
MsgBox(textCursor.string)
End Sub
viewCursor: XLineCursor, XViewCursor, XScreenCursor, XPageCursor, XTextViewCursor
textCursor: XParagraphCursor, XWordCursor, XSentenceCursor
So you cannot call the same functions/methods on both of them. The capabilities of each interface are documented in the IDL reference. Look for them for example in the IDL reference index for the letter X.
OOo 3.2.0 on Ubuntu 10.04 • OOo 3.2.1 on Windows 7 64-bit and MS Windows XP
Re: visually select text [SOLVED]
Thanks I shall try this