问题描述
我有这个按预期工作的宏。我输入任何垃圾词,例如 测试 在新行上,将光标放在单词的开头并运行宏。这个词被添加到标准 dic 中。我可以验证工具 - 拼写 - 选项 - 标准 dic - 编辑
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
问题是 - 如果我输入这个词:
testी
更新:
भारत
इंडिया
将光标置于每个单词的开头并运行相同的宏。 第一个词被添加到标准 dic 中,但第二个词没有。
解决方法
出于某种原因,gotoEndOfWord()
似乎不如按 Ctrl+右箭头 可靠。看起来以非初始梵文元音结尾的单词不起作用。这些确实有效:
इंडिय
इंडियात
testय
testओ
无论如何,关键是这种方式不太好。一些罗马文字也有问题。
那么为什么不使用调度程序来代替,这类似于按键。这是一个正确选择इंडिया的示例。
Sub wort_einfuegen()
frame = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
dispatcher.executeDispatch(frame,".uno:WordRightSel","",Array())
V_Cursor = ThisComponent.GetCurrentController.ViewCursor
re_text = V_Cursor.String
MsgBox """" & re_text & """"
End Sub