How to copy text from shape to body text in a unit test

Miklos Vajna vmiklos at collabora.com
Thu Jan 11 08:18:52 UTC 2024


Hi Regina,

On Wed, Jan 10, 2024 at 06:29:24PM +0100, Regina Henschel <rb.henschel at t-online.de> wrote:
> please have a look at the unit test in
> https://gerrit.libreoffice.org/c/core/+/161842. It works but it looks
> strange to me.
> The task is this:
> Copy the text content of a shape and paste it in rich text format to the
> body text. Make sure, that a line break (shift enter) in the original text
> is preserved in the pasted text.
> 
> It there a better way for this task in a unit test?

I think you do want to copy and paste there, because that's how the
editeng RTF export is invoked. An alternative would be to go via
text::XTextCopy, but that is more about copying from Writer to Writer.

The other odd part of the test is how you enter and leave the shape text
edit mode. You can see how SwTiledRenderingTest's testViewLock uses
BeginTextEdit() and EndTextEdit() for this. If it works in your case,
then using those functions instead of pressing "enter" and "esc" at
magic places would be more clean, I guess.

Regards,

Miklos


More information about the LibreOffice mailing list