 | OO-Snippets: insert special unicode charsCommons| Keywords | writer, unicode character, insert, current cursor position |
|---|
| Language | OOBasic |
|---|
| Application | Writer |
|---|
| Authors | Juergen
Schmidt (initial)
|
|---|
| Supported Versions | |
|---|
| Supported OS | |
|---|
| Question |
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.
|
|---|
| Answer | 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. |
|---|
Sub insertUnicodeCharacter
Dim doc as object
Dim controller as object
Dim textviewcursor as object
Dim character as String
doc = ThisComponent
controller = doc.getCurrentController()
textviewcursor = controller.getViewCursor()
character = chr(clng("&He347"))
textviewcursor.setString(character)
textviewcursor.goRight(1, false)
End Sub
|
Changelog| Date | User | Modification |
|---|
| 2004-06-22 | jsc | Initial version |
|