https://bugs.documentfoundation.org/show_bug.cgi?id=141275

            Bug ID: 141275
           Summary: Macro in Writer generates runtime error when trying to
                    move the cursor from a Comment Box
           Product: LibreOffice
           Version: 6.3.4.2 release
          Hardware: x86-64 (AMD64)
                OS: Windows (All)
            Status: UNCONFIRMED
          Severity: normal
          Priority: medium
         Component: BASIC
          Assignee: libreoffice-bugs@lists.freedesktop.org
          Reporter: atem...@rogers.com

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

-- 
You are receiving this mail because:
You are the assignee for the bug.
_______________________________________________
Libreoffice-bugs mailing list
Libreoffice-bugs@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-bugs

Reply via email to