Description: In a Writer odt file, I can insert a Comment (Annotation) somewhere in the text. (Doesn't matter where.) I then insert a bookmark elsewhere in the text, say named __Target. If I then place the cursor into the actual Comment box, shown at the right edge of the document page, then click on an icon that calls a Macro that I wrote that simply checks to see if the named bookmark exists, then moves the view cursor to the bookmark, I get a runtime error. Steps to Reproduce: 1. Start with a new odt Writer file. 2. Write a para of text and then create a Comment at the start of the line. 3. Write another para and insert a bookmark at the start of that line. 4. Write a Macro as follows: (I'll be attaching an odt file that shows all of this.) Sub GotoBookmark() Dim ViewCursor, AllBookmarks, BookmarkAnchor As Object ' We first check to see if the desired bookmark exists AllBookmarks = ThisComponent.getBookmarks() If NOT AllBookmarks.hasByName("__Target") Then MsgBox("The bookmark __Target does not exist!") Exit Sub End If ' At this point we can try to move the ViewCursor to the bookmark ViewCursor = ThisComponent.CurrentController.getviewCursor() If isNull(ViewCursor) OR isEmpty(ViewCursor) Then MsgBox("Cursor invalid!") : Exit Sub If NOT isEmpty(ViewCursor.TextSection) Then MsgBox("Cursor in a TextSection!") If NOT isEmpty(ViewCursor.Cell) Then MsgBox("Cursor in a Cell!") If NOT isEmpty(ViewCursor.TextField) Then MsgBox("Cursor in a TextField!") BookmarkAnchor = ThisComponent.Bookmarks.getByName("__Target").Anchor ViewCursor.gotorange(BookmarkAnchor, False) End Sub 4. You'll find that you get a runtime error if you call the above Sub while the cursor is inside the Comment box, but not if it is anywhere else in the doc. Actual Results: What I got was this runtime error: BASIC runtime error. An exception occurred Type: com.sun.star.uno.RuntimException Message: no text selection. Expected Results: I expected the cursor to be moved to the named bookmark. It does get moved there so long as the cursor is anywhere else in the document. If it's in the Comment box, you get the runtime error. Reproducible: Always User Profile Reset: No Additional Info: Version: 6.3.3.2 (x64) Build ID: a64200df03143b798afd1ec74a12ab50359878ed CPU threads: 4; OS: Windows 10.0; UI render: default; VCL: win; Locale: en-CA (en_CA); UI-Language: en-US Calc: CL
Created attachment 170777 [details] Writer odt file that illustrates the bug and contains the Macro that generates the runtime error The attached Writer odt file contains the Macro that generates the runtime error along with a Comment and a bookmark named __Target. I've also copied the Macro in the original submission so that others could see that there is nothing special about it. I really don't see why it would generate the runtime error other than a bug in LO's BASIC. (I could very well be wrong.)
Reproduced BASIC runtime error. An exception occurred Type: com.sun.star.uno.RuntimeException Message: no text selection at sw/source/uibase/uno/unotxvw.cxx:1035. Arch Linux 64-bit Version: 7.4.0.0.alpha0+ / LibreOffice Community Build ID: 678446780446ae568ee8b1b814158c54ea5e393f CPU threads: 8; OS: Linux 5.17; UI render: default; VCL: kf5 (cairo+xcb) Locale: fi-FI (fi_FI.UTF-8); UI: en-US Calc: threaded Jumbo Built on 1 April 2022