65 lines
2.0 KiB
XML
65 lines
2.0 KiB
XML
<?xml version="1.0" encoding="UTF-8"?>
|
|
<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
|
|
<script:module xmlns:script="http://openoffice.org/2000/script" script:name="ConditionalShow" script:language="StarBasic" script:moduleType="normal">Sub ShowImageBasedOnValue(oEvent)
|
|
|
|
Dim oListBox As Object
|
|
oListBox = oEvent.Source.Model
|
|
|
|
' Get the selected indices (array, since multi-select is possible)
|
|
Dim sel() As Long
|
|
sel = oListBox.SelectedItems
|
|
|
|
If UBound(sel) >= 0 Then
|
|
Dim idx As Long
|
|
idx = sel(0) ' take the first selected index
|
|
|
|
' Get the corresponding string
|
|
Dim selectedValue As String
|
|
selectedValue = oListBox.StringItemList(idx)
|
|
|
|
'MsgBox "Selected index: " & idx & Chr(10) & "Selected value: " & selectedValue
|
|
' Define possible values and matching image names
|
|
Dim values(1) As String
|
|
Dim images(1) As String
|
|
|
|
values(0) = "Bremen"
|
|
images(0) = "Shape 1"
|
|
|
|
values(1) = "Bremerhaven"
|
|
images(1) = "Shape 2"
|
|
|
|
' Hide all images first
|
|
Dim i As Integer
|
|
For i = LBound(images) To UBound(images)
|
|
Dim slide As Object
|
|
Dim shape As Object
|
|
Dim j As Integer
|
|
|
|
slide = ThisComponent.DrawPages(0) ' first slide, index starts at 0
|
|
|
|
For j = 0 To UBound(images)
|
|
' Loop through shapes to find one with the name
|
|
For Each shape In slide.Shapes
|
|
If shape.Name = images(i) Then
|
|
shape.Visible = False
|
|
End If
|
|
Next
|
|
Next j
|
|
|
|
Next i
|
|
|
|
' Show the one that matches
|
|
For i = LBound(values) To UBound(values)
|
|
If selectedValue = values(i) Then
|
|
ThisComponent.DrawPage.getByName(images(i)).Visible = True
|
|
Exit For
|
|
End If
|
|
Next i
|
|
|
|
Else
|
|
MsgBox "Nothing selected"
|
|
End If
|
|
|
|
End Sub
|
|
|
|
</script:module> |