I have this macro that works as expected. I type any junk word for e.g. testd on a new line, place the cursor at the beginning of the word and run the macro. The word is added to standard dic. I can verify Tools - Spellings - options - standard dic - edit
Sub wort_einfuegen()
V_Cursor = ThisComponent.GetCurrentController.ViewCursor
T_Cursor = ThisComponent.text.createtextcursor()
T_Cursor.gotoRange(V_Cursor,false)
With T_Cursor
.gotoEndofWord(True)
re_text = .String
End with
dl = createUnoService ("com.sun.star.linguistic2.DictionaryList")
wb = dl.GetDictionaryByName("standard.dic")
wb.Add(re_text, False, "")
End sub
The problem is - if I type this word:
testी
A blank line is added to the dict file. Is this a bug or this is expected behavior?
Update:
I think this must be a bug because I typed these 2 words :
भारत
इंडिया
Placed the cursor at the beginning of each word and run the same macro. The first word got added to the standard dic but the second word did not.
For some reason, gotoEndOfWord()
seems much less reliable than pressing Ctrl+Right Arrow. It looks like words ending in non-initial Devanagari vowels do not work. These do work:
इंडिय
इंडियात
testय
testओ
Anyway, the point is that way isn't very good. There are problems with some roman script words as well.
So why not do it with the dispatcher instead, which is similar to pressing the keys. Here is an example that correctly selects इंडिया.
Sub wort_einfuegen()
frame = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
dispatcher.executeDispatch(frame, ".uno:WordRightSel", "", 0, Array())
V_Cursor = ThisComponent.GetCurrentController.ViewCursor
re_text = V_Cursor.String
MsgBox """" & re_text & """"
End Sub