add selection mode

Hi. Recently (August 2019) this article in French has described in detail the adding selection mode (Shift + F8) performed using only the keyboard.

I’ve been trying to use it for days. Apparently it highlights more blocks, but selects only the last one each time. I checked it with and without macros.

In addition, the highlighting remains permanent. If you delete the whole document, rectangular areas of the screen remain highlighted, as if they were represented on a superimposed graphic layer.

In your LO, performed with the keyboard alone, this selection mode, does it work?

If it works, are you able to record these selection operations with the macro recorder to report in this discussion?

“this” article?

Very sorry. LibreOffice Writer - Sélection de texte - Médiaforma

Works fine with Version: 6.3.3.2 (x64)
Build ID: a64200df03143b798afd1ec74a12ab50359878ed
CPU threads: 4; OS: Windows 10.0; UI render: GL; VCL: win;
Locale: ru-RU (ru_RU); UI-Language: en-US
Calc: threaded

Wrt macro recorder: it doesn’t properly record that (expectedly: the macro recorder is veeery basic and incomplete thing, which should not be used for any serious development/research).

I use LO version 6.2.6.2, Ubuntu, but I don’t think my problem is the version. Maybe I’m wrong, but I don’t know what. Hence the request for a “basic” macro, minimal but functional
The macro recorder does NOT recognize mouse operations (with the mouse I have no problem with multiselection) but recognizes keyboard operations well.

I was asking for a version with the macro recorder because this technique does NOT work with my LO, so it is useless for me to record something

If any nickname has a version in which this technical function is either with the macro recorder or directly with a user macro, it can select two or three blocks in multiselection (if it works with the keyboard it must also work with a macro)

With a minimal macro example I have a starting point to solve the problem I described in the first discussion I opened in this forum

Test this:

sub selectSeveralPieces
dim cursor as object, frame as object, dispatcher as object
cursor = ThisComponent.CurrentController.ViewCursor
frame = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

cursor.gotoStart(false)
dispatcher.executeDispatch(frame, ".uno:SetMultiSelection", "", 0, Array())
cursor.goRight(1, true)
cursor.goRight(1, false)
cursor.goRight(1, true)
end sub

I did some tests before answering. Your macro works for you and also for me, you can enter it as an answer.

I thank you because the use of “.uno: SetMultiSelection” is the the starting key for solve more complex problems.

Before your answer I tried to use the macro recorder and I saw that he used this technique, but encoding it as a comment !!!
Documentation and examples of its use in macros I have not found.

Sometimes I doesn’t really understand LO. It offers really flexible and versatile macro functions that unexpectedly solve complex problems, while making it difficult if not impossible to solve problems that are much simpler but vital for a code developer.

For example, the extension of your code to the selection of paragraphs is possible (it was one of my tests), but not so immediate (unless you use a support textcursor, but I haven’t tried it yet if it causes problems to multiselect)

Thanks again to you (and also to google translate)