4.4.3.2, Polish, Writer
Windows 8.1, Polish
Document is Writer, with single Input field (nothing else in it), and here is my code:
Global oListener as Object
Global oVetoListener as Object
Global oInput as Object
Sub Listen
oInput = GetTextInputField(ThisComponent, "a")
oListener = createUnoListener("MyEvent_", "com.sun.star.beans.XPropertyChangeListener")
oInput.addPropertyChangeListener("", oListener)
End Sub
Sub StopListen
oInput.removePropertyChangeListener("", oListener)
End Sub
Sub MyEvent_disposing(oEvent)
MsgBox "disposing"
End Sub
Sub MyEvent_propertyChange(oEvent)
MsgBox "modified"
End Sub
Function GetTextInputField(Doc as Object, FieldName as String) as Object
Dim TextFields as Object
Dim TextField as Object
TextFields = Doc.getTextFields.createEnumeration
While TextFields.hasMoreElements()
TextField = TextFields.nextElement()
If TextField.supportsService("com.sun.star.text.TextField.Input") Then
If TextField.Hint = FieldName Then
GetTextInputField = TextField
End If
End If
Wend
End Function
Sub ShowContent
F = GetTextInputField(ThisComponent, "a")
MsgBox F.getPropertyValue("Content")
End Sub
ShowContent shows Input field content corectly, so I assume GetTExtInputField works fine.
Unfortunately nothing happends on Content change. I have tried both
oInput.addPropertyChangeListener("", oListener)
and
oInput.addPropertyChangeListener("Content", oListener)
None of them works.
What is the problem?