Hello Josef,
Il lunedì 4 agosto 2008 17:23:50 Josef Dalcolmo ha scritto:
Please bear with me - I am new to the OOo UDK and API.
I am also not completely sure this is the right mailing list,
perhaps because I am not sure what the problem is.
IMHO this is an API related problem.
Anyway, see my comments inline:
I am trying to generate a hyperlink in Calc, using Python as
scripting language. Setting the formula to =HYPERLINK(target, rep)
only yields an absolute hyperlink, and is thereby useless for me.
so I've tried (replace '' with a tab or spaces):
[]
...Link = Doc.createInstance('com.sun.star.text.TextField.URL')
...Link.URL = uno.systemPathToFileUrl(os.path.abspath('readme.txt'))
...Link.Representation = 'readme'
...Link.TargetFrame = ''
...Selection.Text.insertString(Selection.Text.Start, 'ABC', False)
...Selection.Text.insertTextContent(Selection.Text.End, Link, False)
this works fine up to the last line, where OOo crashes. According to the
Developers Guide, insertTextContent() is the method to attach a TextField.
I am lost about what I am doing wrong here, and would appreciate any hint.
Sorry I can't explain what is the cause of the crash, anyway I can suggest a
workaround (in StarBasic) because in past I've developed something similar.
I've tested this code in OOo 2.4.0 (Linux) and it works:
oDoc = ThisComponent
oSelection = oDoc.CurrentSelection
If oSelection.supportsService(com.sun.star.sheet.SheetCell) Then
oTextContent = oDoc.createInstance(com.sun.star.text.TextField.URL)
oTextContent.Representation = OpenOffice.org
oTextContent.URL = http://www.openoffice.org/;
oTextCursor = oSelection.createTextCursor()
oSelection.insertTextContent(oTextCursor, oTextContent, True)
oSelection.insertString(oSelection.Start, ABC, False)
End If
HTH
Paolo M
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]