Bug 141275 - Macro in Writer generates runtime error when trying to move the cursor from a Comment Box
Summary: Macro in Writer generates runtime error when trying to move the cursor from a...
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
6.3.4.2 release
Hardware: x86-64 (AMD64) All
: medium minor
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: Macro
  Show dependency treegraph
 
Reported: 2021-03-26 22:07 UTC by atemple
Modified: 2024-10-19 03:18 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
Writer odt file that illustrates the bug and contains the Macro that generates the runtime error (29.33 KB, application/vnd.oasis.opendocument.text)
2021-03-26 22:16 UTC, atemple
Details

Note You need to log in before you can comment on or make changes to this bug.
Description atemple 2021-03-26 22:07:00 UTC
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
Comment 1 atemple 2021-03-26 22:16:35 UTC
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.)
Comment 2 Buovjaga 2022-04-01 08:14:19 UTC
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
Comment 3 QA Administrators 2024-10-19 03:18:04 UTC
Dear atemple,

To make sure we're focusing on the bugs that affect our users today, LibreOffice QA is asking bug reporters and confirmers to retest open, confirmed bugs which have not been touched for over a year.

There have been thousands of bug fixes and commits since anyone checked on this bug report. During that time, it's possible that the bug has been fixed, or the details of the problem have changed. We'd really appreciate your help in getting confirmation that the bug is still present.

If you have time, please do the following:

Test to see if the bug is still present with the latest version of LibreOffice from https://www.libreoffice.org/download/

If the bug is present, please leave a comment that includes the information from Help - About LibreOffice.
 
If the bug is NOT present, please set the bug's Status field to RESOLVED-WORKSFORME and leave a comment that includes the information from Help - About LibreOffice.

Please DO NOT

Update the version field
Reply via email (please reply directly on the bug tracker)
Set the bug's Status field to RESOLVED - FIXED (this status has a particular meaning that is not 
appropriate in this case)


If you want to do more to help you can test to see if your issue is a REGRESSION. To do so:
1. Download and install oldest version of LibreOffice (usually 3.3 unless your bug pertains to a feature added after 3.3) from https://downloadarchive.documentfoundation.org/libreoffice/old/

2. Test your bug
3. Leave a comment with your results.
4a. If the bug was present with 3.3 - set version to 'inherited from OOo';
4b. If the bug was not present in 3.3 - add 'regression' to keyword


Feel free to come ask questions or to say hello in our QA chat: https://web.libera.chat/?settings=#libreoffice-qa

Thank you for helping us make LibreOffice even better for everyone!

Warm Regards,
QA Team

MassPing-UntouchedBug