Modify next Impress slide with LibreOffice Basic

asked 2018-06-20 08:30:13 +0100

joe.mcbeal gravatar image

I'm trying to modify the next slide in a running Impress presentation. To this end, I've registered a "XSlideShowListener" in order to process the "slideEnded" event. In this event, I change the text of a "com.sun.star.drawing.CustomShape".

In principle, this works well. However, the changes are not shown in the presentation for the upcoming slide, although the changes have been made.

Do I have to additionally trigger a redraw!?

Here is what I have:

Sub Test
    Dim oListener As Object
    oListener = createUnoListener("X_","com.sun.star.presentation.XSlideShowListener")

    Dim oPresentation As Object
    oPresentation = ThisComponent.Presentation
    oPresentation.Start()
    Wait 100

    oController = oPresentation.Controller
    oController.addSlideShowListener(oListener)
End Sub

Sub X_slideEnded(reverse)
    Dim oController As Object
    oController =  ThisComponent.Presentation.Controller

    i = oController.getCurrentSlideIndex()
    If reverse Then
        i = i -1
    Else
        i = i +1
    End If

    Dim oSlide As Object
    oSlide = oController.getSlideByIndex(i)

    For i = 0 to oSlide.Count-1
        Dim oItem As Object
        oItem = oSlide.getByIndex(i)
        if oItem.Name = "Test" Then
            oItem.setString("New Text")
            Exit For
        End If
    Next i
End Sub

If I modify the slide after the next slide, the changes are correctly displayed.

edit retag flag offensive close merge delete