[solved] Re: API to clone a row in a writer's table - ViewCursor positioning

Sandro <[email protected]>
Newsgroups gmane.comp.openoffice.devel.general
Message-ID <[email protected]>
Thaks Peter,

Peter Eberlein <pet.ebe <at> refofd.verwalt-berlin.de> writes:


> I didn't find a way to span a XTextRange over more then one cell to get 
> the selection at a whole, so try the following:
> 
> You have to iterate over each cell of your row, put the sample code in a 
> loop (after translating from Basic to Python):
> 
> cellSrc = thisComponent.TextTables.getByIndex(0).getCellByPosition(0,0,0,0)
> cursorSrc = cellSrc.getText.createTextCursorbyRange(cellSrc.getStart)
> cursorSrc.gotoEnd(true)

I started from here and after several try & error I ended up in the shorter form:

    view_cursor.gotoRange(src.Text, False)
    txt = controller.getTransferable()
    view_cursor.gotoRange(dst.Text, False)

    controller.insertTransferable(txt)

that seems to work correctly. I realized thought that is slower that copying
just the text and for that reason I also gave a try to dispatcher:

    view_cursor.gotoRange(src.Text, False)
    dispatcher.executeDispatch(frame, '.uno:EntireRow', '', 0, tuple())
    dispatcher.executeDispatch(frame, '.uno:Copy', '', 0, tuple())
    view_cursor.gotoRange(dst.Text, False)
    dispatcher.executeDispatch(frame, '.uno:Paste', '', 0, tuple())

But this doesn't work (unless I made some more mistakes) in headless mode.

So I will stick to copy/paste of single cell.

thanks for your time

sandro
*:-)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.