Bug 168066 - Calc: Inserting hyperlink from API fails, when not using cursor
Summary: Calc: Inserting hyperlink from API fails, when not using cursor
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
unspecified
Hardware: All All
: medium normal
Assignee: Mike Kaganski
URL:
Whiteboard: target:26.2.0
Keywords:
Depends on:
Blocks:
 
Reported: 2025-08-22 17:44 UTC by Mike Kaganski
Modified: 2025-08-23 06:48 UTC (History)
0 users

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mike Kaganski 2025-08-22 17:44:02 UTC
Consider this Basic macro:

sub addHyperlinkA1
  doc = StarDesktop.loadComponentFromURL("private:factory/scalc", "_blank", 0, Array())
  oCell = doc.Sheets(0).getCellByPosition(0,0)
  oField = doc.createInstance("com.sun.star.text.TextField.URL")
  oField.URL = "http://www.example.org/"
  oField.Representation = "hyperlink"
  'oCell.insertTextContent(oCell.createTextCursor(), oField, False)
  oCell.insertTextContent(oCell.getEnd(), oField, False)
end sub

This macro fails on the last line with 'insertTextContent' with:
> BASIC runtime error.
> An exception occurred 
> Type: com.sun.star.lang.IllegalArgumentException
> Message: .

But uncommenting the line with createTextCursor (and commenting the line with 'getEnd') succeeds.

insertTextContent doesn't require that the passed range be cursor. So it must succeed.
Comment 1 Mike Kaganski 2025-08-22 17:49:54 UTC
https://gerrit.libreoffice.org/c/core/+/190080
Comment 2 Commit Notification 2025-08-22 19:37:15 UTC
Mike Kaganski committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/48dae1af66b227e72d58935d5719610c957da30d

tdf#168066: implement Format property for Calc's URL field

It will be available in 26.2.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.