writer unicode character insert current cursor position Juergen Schmidt

How to insert a special unicode character at the current cursor position? The unicode character is provided as hexadecimal value and the cursor should be positioned behind the character.

document -> current controller -> view cursor -> insert First you can simply get the current document by 'ThisComponent'. Then you ask the document object for the current controller and the controller for the view cursor. The hex value of the unicode character needs to be converted to a string. 'clng' converts the hex value to long and 'chr' converts the long value to a string. Finally you insert the character string using the text view cursor and move the cursor behind the new inserted character.

REM ***** BASIC ***** Sub insertUnicodeCharacter Dim doc as object Dim controller as object Dim textviewcursor as object Dim character as String ' get current document -> controller -> view cursor doc = ThisComponent controller = doc.getCurrentController() textviewcursor = controller.getViewCursor() ' hex value 'e347' = StarSymbol character ? ' chr expect an integer value, clng converts a hex value to long character = chr(clng("&He347")) ' insert character at the current cursor position textviewcursor.setString(character) ' move cursor behind textviewcursor.goRight(1, false) End Sub
Initial version