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

How to select a document via a link (URL)

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


Joined: 07 Nov 2004
Posts: 261

PostPosted: Sat Feb 25, 2006 2:40 pm    Post subject: How to select a document via a link (URL) Reply with quote

Hi,

is it possible to insert a URL (link/hyperlink) in a TextBox, TextField or Label and use that to select a document?

For example:

Click here to open a file.

And then when you click on it the URL is forwarded to a macro or OOo.org opens or focuses that document.

I understand you can insert a hyperlink in a form or in writer or anywhere else, but I don't know how to do it in any of the mentioned controls.

Thanks,

Marinus.
Back to top
View user's profile Send private message Visit poster's website
Villeroy
Super User
Super User


Joined: 04 Oct 2004
Posts: 10106
Location: Germany

PostPosted: Sat Feb 25, 2006 3:11 pm    Post subject: Reply with quote

The search-function came up with this:
http://www.oooforum.org/forum/viewtopic.phtml?t=12164&highlight=textfield+hyperlink[/u]
Back to top
View user's profile Send private message
Marinus
OOo Advocate
OOo Advocate


Joined: 07 Nov 2004
Posts: 261

PostPosted: Sat Feb 25, 2006 3:48 pm    Post subject: Reply with quote

Yea have seen that, but that applies to inserting at a viewcursor in the controller.

I'm talking about inserting this in a control.

So:

Code:

   oTextField.Text = "Click " & {"here" -> the url} & " to open document " & sURL
Back to top
View user's profile Send private message Visit poster's website
Villeroy
Super User
Super User


Joined: 04 Oct 2004
Posts: 10106
Location: Germany

PostPosted: Sat Feb 25, 2006 5:00 pm    Post subject: Reply with quote

Sorry,
I can not see how to do that. I assumed it should be possible with any text cursor.
This fails silently with a text box in a writer-doc:
Code:

Sub Main
oTextBox = thisComponent.Drawpage.forms.getByindex(0).getByName("TextBox")
oTxt = oTextBox.getText
oCursor = oTxt.createTextCursor
oField = thisComponent.createInstance("com.sun.star.text.TextField.URL")
oField.Representation = "Yahoo"
oField.URL = "http://www.yahoo.com"
oTxt.insertTextContent(oCursor, oField, false)
End Sub

You can create a hyperlink through the UI and paste it into the text box, but the result is something unusable.
Back to top
View user's profile Send private message
Marinus
OOo Advocate
OOo Advocate


Joined: 07 Nov 2004
Posts: 261

PostPosted: Sat Feb 25, 2006 5:19 pm    Post subject: Reply with quote

Here's what I'm trying to accomplish:

<if component is loaded>
offer two hyperlinks in Dialog
<1> -> Save & close document
<2> -> Select document

If it is possible in OOo.org's help function it should be possible via a macro too!! Smile

Thanks so far,

Marinus.
Back to top
View user's profile Send private message Visit poster's website
Villeroy
Super User
Super User


Joined: 04 Oct 2004
Posts: 10106
Location: Germany

PostPosted: Sun Feb 26, 2006 1:32 pm    Post subject: Reply with quote

Marinus wrote:
Here's what I'm trying to accomplish:

<if component is loaded>
offer two hyperlinks in Dialog
<1> -> Save & close document
<2> -> Select document

If it is possible in OOo.org's help function it should be possible via a macro too!! Smile

Thanks so far,

Marinus.

Oh, you are talking about controls in a basic-dialog (com.sun.star.awt.UnoControl). They are another kind of animals than form-controls embedded in a drawpage. I guess they won't take hyperlinks neither (not tried yet).
The left pane of the help window has a listbox and a "Show"-button. There are no hyperlinks involved.
StarDesktop.getComponents gives you a container with all loaded components having an URL, which can be added to the StringItemList of a listbox (unsaved docs have "" as URL). Add two buttons for activating and for closing the selected document.
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