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

Jump to bookmark?

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
Cosmic P
OOo Enthusiast
OOo Enthusiast


Joined: 23 Mar 2005
Posts: 186

PostPosted: Wed Apr 13, 2005 4:30 am    Post subject: Jump to bookmark? Reply with quote

I'm trying to build a macro that, when the user wants to print out a file, checks if all the essential data has been filled out. If something's missing (like the user's name), the visible cursor should jump to it.

The following code didn't work:

Code:
      oViewCursor = ThisComponent.CurrentController.getviewCursor()
      oBookmark = ThisComponent.Bookmarks.getByName("your_name").Anchor
      oViewCursor.gotorange(oBookmark, false)


The second line produced the exception $arg1)
Back to top
View user's profile Send private message
pitonyak
Administrator
Administrator


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

PostPosted: Wed Apr 13, 2005 5:51 am    Post subject: Reply with quote

try to select the object with the current controller. Something like:
Code:
ThisComponent.getCurrentController().select(object)
Try selecting that text range...
_________________
--
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
Cosmic P
OOo Enthusiast
OOo Enthusiast


Joined: 23 Mar 2005
Posts: 186

PostPosted: Wed Apr 13, 2005 10:09 pm    Post subject: Reply with quote

What do I put in the select()-command?

Code:
ThisComponent.getCurrentController().select("your_name")


A similar problem: I want to insert a text at a bookmark, but the following code doesn't work. It produces the same exception as the one above:

Code:
ThisComponent.getBookmarks().getByName("MyBookmark").getAnchor.setString("Input this text here")
[/code]
Back to top
View user's profile Send private message
Peter
OOo Enthusiast
OOo Enthusiast


Joined: 28 May 2004
Posts: 105
Location: Berlin / Germany

PostPosted: Wed Apr 13, 2005 11:46 pm    Post subject: Reply with quote

Not tested:

oViewCursor = ThisComponent.CurrentController.getviewCursor()
sBookmark = "your_name"
oRange = BookmarkJumping(ThisComponent,sBookmark)

oViewCursor.gotoRange(oRange, false)
oViewCursor.String = "MyString"


Function BookmarkJumping(Doc,sBookmark) as Object

oBookmark = Doc.Bookmarks.GetByName(sBookmark)

BookmarkJumping = oBookmark.Anchor.Text.CreateTextCursorByRange(oBookmark.Anchor)
End Function

Keep in mind, that a bookmark is always a range, you can select text and then insertt the bookmark.

Peter
Back to top
View user's profile Send private message
Cosmic P
OOo Enthusiast
OOo Enthusiast


Joined: 23 Mar 2005
Posts: 186

PostPosted: Thu Apr 14, 2005 4:13 am    Post subject: Reply with quote

OK, I've found the problem: a simple typing error in the name.

So far I can use the methods setString en getString, but I can not type at the bookmarkt directly.

After executing the procedure, I see the visible cursor at the bookmark for a fraction of a second, then it's gone and I can not type.
Back to top
View user's profile Send private message
Peter
OOo Enthusiast
OOo Enthusiast


Joined: 28 May 2004
Posts: 105
Location: Berlin / Germany

PostPosted: Thu Apr 14, 2005 10:30 pm    Post subject: Reply with quote

With my posted code I can type immediately, if you want to modify the range, don't use oViewCursor.String but oRange.String =

Peter
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