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

Search and cursor

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


Joined: 04 Dec 2005
Posts: 6

PostPosted: Thu Dec 22, 2005 11:30 pm    Post subject: Search and cursor Reply with quote

Hi everybody,

Beginner with OO Basic language, I would like to know something about cursor and search.
1) Once a search completed, is it possible to get the cursor position and then, for example, to go further by one paragraph ?
2) I have found a script ( by Andrew Pitonyak- Complicated Search And Replace ) which allows to delete all the lines between two delimiters.
But now I need to insert inside those same delimiters the content of an array made of several lines. Do I need to use a cursor to do it ?

Thanks for your help

Jean-michel
Back to top
View user's profile Send private message
jrkrideau
Super User
Super User


Joined: 08 Aug 2005
Posts: 6733
Location: Kingston ON Canada

PostPosted: Fri Dec 23, 2005 7:40 am    Post subject: Re: Search and cursor Reply with quote

theophanie wrote:
Hi everybody,

Beginner with OO Basic language, I would like to know something about cursor and search.
1) Once a search completed, is it possible to get the cursor position and then, for example, to go further by one paragraph ?
2) I have found a script ( by Andrew Pitonyak- Complicated Search And Replace ) which allows to delete all the lines between two delimiters.
But now I need to insert inside those same delimiters the content of an array made of several lines. Do I need to use a cursor to do it ?

Thanks for your help

Jean-michel


Hi Jean-Michel

I'm sorry I cannot answer your questions but I would suggest that you will get more anwsers if you post in the Macros forum. Good luck and joyeux noël
_________________
jrkrideau
Kingston ON Canada
Currently using Windows 7 & OOo 3.4.0 and Ubuntu 12.04 & LibreOffice 3.5.2.2
Back to top
View user's profile Send private message
JohnV
Administrator
Administrator


Joined: 07 Mar 2003
Posts: 8984
Location: Lexinton, Kentucky, USA

PostPosted: Fri Dec 23, 2005 8:14 am    Post subject: Reply with quote

The best I can tell when you search you are moving a cursor so I'll assuming Andrew's code has somthing like this.

Find = oDoc.FindFirst(MyFind)
While Not isNull(Find)
do something
Find = oDoc.FindNext(Find.End,MyFind)
Wend

In this example Find is a cursor and you can move another cursor, such as the View Cursor, to its location like this.

oVC = oDoc.CurrentController.getViewCursor
oVC.gotoRange(Find,False)
Back to top
View user's profile Send private message
pitonyak
Administrator
Administrator


Joined: 09 Mar 2004
Posts: 3618
Location: Columbus, Ohio, USA

PostPosted: Sun Dec 25, 2005 8:34 am    Post subject: Reply with quote

Based on the examle that you are quoting from my free macro document, the macro is called deleteTextBetweenDlimiters. To summarize what the macro does, it creates TWO search descriptors. The first searches for "[" and the second searches for "]". The code can be characterized as follows:
Code:
find "[".
Starting from the found "[", look for a "]".
Remove the "[".
Select ALL text from the found "[" to "]"
Clear the selected text.
Clear any extra spaces

It sounds to me like you want to NOT remove anything, but instead, you want to insert data between the delimiters. So, if you have [hello], you would replace this with [new text]. Is this correct? Here is the code that you are starting with (well, a portion anyway). I made some modifications that might work...
Code:
      ' DONT Clear the open bracket
      REM vOpenFound.setString("")
      REM In fact, I might need to do this: vOpenFound.goRight(1, False)
      ' select the text inside the brackets
      vOpenFound.gotoRange(vCloseFound, True)
      Print "Found " & vOpenFound.getString()
      ' SET the text inside the brackets
      vOpenFound.setString("Place my text here!")
      ' DONt Clear the close bracket
      'vCloseFound.setString("")
      ' Do you really want to delete ALL of the spaces?
      ' If so, then do it here!
      'If vCloseFound.goRight(1, True) Then
      '  If vCloseFound.getString() = " " Then vCloseFound.setString("")
     ' End If

I can not test this at the moment, but it might be a start...
_________________
--
Andrew Pitonyak
http://www.pitonyak.org/oo.php
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address
theophanie
General User
General User


Joined: 04 Dec 2005
Posts: 6

PostPosted: Thu Dec 29, 2005 2:52 pm    Post subject: thank you - it works Reply with quote

Thank you for all the replies.
My macro works now.
I have used Andrew P.'s last commands.

Here is a part of the macro :
vOpenSearch.SearchString = "--- DEBUT INDEX LOUANGE ---"
vCloseSearch.SearchString = "--- FIN INDEX LOUANGE ---"
...
vOpenFound.goRight(1, False)
vOpenFound.gotoRange(vCloseFound, True)
rem I do not want to keep the delimiter in my selection
vOpenFound.goLeft(25, True)
...
Do Until louange(i) = "THE_END"
rem I insert the content of an array
vopenFound.setString(louange(i)+CHR(13))
vOpenFound.gotoNextParagraph(false)
i = i + 1
Loop
...

Thanks and bye
Jean-michel
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