Bug 168073 - Calc: Inserting hyperlink from API fails, when using SheetCell as the range
Summary: Calc: Inserting hyperlink from API fails, when using SheetCell as the range
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 target:25.8.1
Keywords:
Depends on:
Blocks:
 
Reported: 2025-08-23 06:48 UTC by Mike Kaganski
Modified: 2025-08-26 09:43 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-23 06:48:23 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, oField, False)
end sub

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

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

oCell implements XTextRange interface itself, so it must succeed.
Comment 1 Mike Kaganski 2025-08-23 07:17:19 UTC
https://gerrit.libreoffice.org/c/core/+/190085
Comment 2 Commit Notification 2025-08-23 10:59:51 UTC
Mike Kaganski committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/a8ce5af575ea5e05eb7c349d50b4eb08cab983ff

tdf#168073: check if xRange is this

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.
Comment 3 Commit Notification 2025-08-23 18:54:57 UTC
Mike Kaganski committed a patch related to this issue.
It has been pushed to "libreoffice-25-8":

https://git.libreoffice.org/core/commit/1e040b72222012f9a5f1e47d19aaf0c0369e08ad

tdf#168073: check if xRange is this

It will be available in 25.8.1.

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.
Comment 4 Commit Notification 2025-08-24 07:44:16 UTC
Mike Kaganski committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/02c9a71ea5344178b2849d153d0b1d83a681e334

tdf#168073: generalize the fix to other XText methods

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.
Comment 5 Commit Notification 2025-08-25 11:51:25 UTC
Mike Kaganski committed a patch related to this issue.
It has been pushed to "libreoffice-25-8":

https://git.libreoffice.org/core/commit/d4fb438cf3f3375ff72209b994f040a92b5c68db

tdf#168073: generalize the fix to other XText methods

It will be available in 25.8.1.

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.
Comment 6 Commit Notification 2025-08-26 09:43:55 UTC
Mike Kaganski committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/e7895c4a8e630de1ce88b721eef90ba8eb7da179

Related: tdf#168073 Extract ScEditFieldObj insertion into a function

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.