[Libreoffice-bugs] [Bug 141123] New: Impossible to replace a TextGraphicObject's event after it has been set

bugzilla-daemon at bugs.documentfoundation.org bugzilla-daemon at bugs.documentfoundation.org
Sat Mar 20 08:18:27 UTC 2021


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

            Bug ID: 141123
           Summary: Impossible to replace a TextGraphicObject's event
                    after it has been set
           Product: LibreOffice
           Version: 6.4.6.2 release
          Hardware: All
                OS: All
            Status: UNCONFIRMED
          Severity: normal
          Priority: medium
         Component: BASIC
          Assignee: libreoffice-bugs at lists.freedesktop.org
          Reporter: rsaintier at gmail.com

I wrote a macro that inserts a TextGraphicObject in a text document. Another
macro is assigned to the OnSelect event of this object. To do the assignation I
get the object's events and replaceByName the OnSelect event. It works
successfully.

Later, I want to change the macro assigned to this event. So again I want to
replaceByName the event, but it does nothing: the previous macro stays assigned
to the event. Neither can I "erase" the event by replacing it with a "None"
type event.

Here is some sample code :
Sub test
    Graph = ThisComponent.createInstance("com.sun.star.text.TextGraphicObject") 

    ' on a side note : assigning events before inserting the TextGraphicObject
crashes LibreOffice
   
ThisComponent.getText().insertTextContent(ThisComponent.getText().getStart(),
Graph, false)

    ' sets the OnSelect event
    Dim Ev1(1) as new com.sun.star.beans.PropertyValue
    Ev1(0).Name = "EventType"
    Ev1(0).Value = "Script"
    Ev1(1).Name = "Script"
    Ev1(1).Value =
"vnd.sun.star.script:Standard.Module1.sub1?language=Basic&location=document" 
    Graph.getEvents().replaceByName("OnSelect", Ev1)

    ' the msgbox correctly displays the sub1 target
    Good = Graph.getEvents().getByName("OnSelect")
    msgbox Good(1).Value

    ' now replace the OnSelect event
    Dim Ev2(1) as new com.sun.star.beans.PropertyValue
    Ev2(0).Name = "EventType"
    Ev2(0).Value = "Script"
    Ev2(1).Name = "Script"
    Ev2(1).Value =
"vnd.sun.star.script:Standard.Module1.sub2?language=Basic&location=document" 
    Graph.getEvents().replaceByName("OnSelect", Ev2)

    ' the target is still sub1, where it should now be sub2 
    Bad = Graph.getEvents().getByName("OnSelect")
    msgbox Bad(1).Value
End Sub

I may not be using these API correctly, but doing the same with other types of
objects (like reassigning the OnLoad event of ThisComponent) works as I intend.

Had the same behaviour on LO6.4.6.2 on MacOS and Windows 10.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/libreoffice-bugs/attachments/20210320/02fd2d2e/attachment-0001.htm>


More information about the Libreoffice-bugs mailing list