简体   繁体   English

不总是跟随到词尾

[英]go to end of word is not always followed

I have this macro that works as expected.我有这个按预期工作的宏。 I type any junk word for eg testd on a new line, place the cursor at the beginning of the word and run the macro.我在新的一行键入如TESTD任何垃圾话,将光标放在单词的开头和运行宏。 The word is added to standard dic.这个词被添加到标准 dic 中。 I can verify Tools - Spellings - options - standard dic - edit我可以验证工具 - 拼写 - 选项 - 标准 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

The problem is - if I type this word:问题是 - 如果我输入这个词:

testी 

A blank line is added to the dict file. dict 文件中添加了一个空行。 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.第一个词被添加到标准 dic 但第二个词没有。

For some reason, gotoEndOfWord() seems much less reliable than pressing Ctrl + Right Arrow .出于某种原因, gotoEndOfWord()似乎不如按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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM