Bug 127017 - Copy-Paste doesn't work when Impress is not the focused instance
Summary: Copy-Paste doesn't work when Impress is not the focused instance
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: sdk (show other bugs)
Version:
(earliest affected)
6.3.0.4 release
Hardware: All Linux (All)
: low normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-08-18 21:30 UTC by Konstantin Kharlamov
Modified: 2024-09-09 13:13 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments
Script to get instances of LO Impress and LO Calc, then copy a slide in LO Impress (2.00 KB, text/x-python)
2019-08-18 21:30 UTC, Konstantin Kharlamov
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Konstantin Kharlamov 2019-08-18 21:30:51 UTC
Created attachment 153492 [details]
Script to get instances of LO Impress and LO Calc, then copy a slide in LO Impress

As the title says. The bug seems to be only triggered when more than one instance of LO is involved.

# Steps to reproduce

1. Run `soffice --impress --accept="socket,host=localhost,port=2002;urp;StarOffice.ServiceManager"`, and dismiss "Select a Template" window.
2. Press menu `File → New → Spreadsheet`, so an LO Calc window appears.
3. (Important) focus LO Calc, and for further steps do not give focus to LO Impress anymore (you can unfocus localc, just make sure it was the last focused LO instance).
4. Run the attached script as `python test.py`

## Expected

Script successfully exits, and you can see a slide in LO Impress got copied.

## Actual

Script exits with IndexOutOfBoundsException, because the slide wasn't successfully copied.

# Additional information

You can make it work by making sure the last focused LO instance was the LO Impress.
Comment 1 Jean-Baptiste Faure 2019-09-08 15:41:31 UTC Comment hidden (obsolete)
Comment 2 Konstantin Kharlamov 2019-09-08 15:58:29 UTC
(In reply to Jean-Baptiste Faure from comment #1)
> Why do you think the problem is not in your python script ?
> 
> Best regards. JBF

The question sounds a bit abstract, so sorry if you wanted a different reply. The script works with variables it got from LibreOffice, like slides, etc. It is not normal if these variables suddenly disappear for reason outside of the script control.
Comment 3 Xisco Faulí 2020-05-11 07:39:07 UTC Comment hidden (obsolete)
Comment 4 Konstantin Kharlamov 2020-05-11 10:28:49 UTC Comment hidden (obsolete)
Comment 5 Buovjaga 2020-08-28 14:28:54 UTC
Repro with script.

Arch Linux 64-bit
Version: 7.1.0.0.alpha0+
Build ID: e2fe4fde592564d35099ad1e2659ad682dfb77f5
CPU threads: 8; OS: Linux 5.8; UI render: default; VCL: kf5
Locale: fi-FI (fi_FI.UTF-8); UI: en-US
Calc: threaded
Built on 25 August 2020

(In reply to Konstantin Kharlamov from comment #4)
> There is also a regression with the latest development version:
> 
>     Version: 7.0.0.0.alpha1+
>     Build ID: 7223d7312368bf9c917ef0558...
>     CPU threads: 4; OS: Linux 5.6; UI render: default; VCL: gtk3;
>     Locale: en-US (en_US.UTF-8); UI: en-US
>     Calc: threaded
> 
> There slide does not get copied even if LO Impress was the last focused
> instance. Instead it fails with `__main__.RuntimeException: Binary URP
> bridge disposed during call`.

This was fixed as bug 134106
Comment 6 QA Administrators 2022-08-29 06:43:31 UTC Comment hidden (obsolete)
Comment 7 Konstantin Kharlamov 2022-09-06 21:47:22 UTC
Still reproducible

Version: 7.4.0.3 / LibreOffice Community
Build ID: f85e47c08ddd19c015c0114a68350214f7066f5a
CPU threads: 4; OS: Linux 5.19; UI render: default; VCL: gtk3
Locale: en-US (en_US.UTF-8); UI: en-US
Calc: threaded
Comment 8 Timur 2022-09-08 10:45:00 UTC
Hi Mike. I think this could be under a myriad of your interests, please see.
Comment 9 Mike Kaganski 2022-09-08 12:27:41 UTC
As an unrelated note, I'd mention that it would be generally better to avoid use of dispatcher to execute UNO URIs, and in this case use SystemClipboard service [1] and getTransferable [2] from XTransferableSupplier interface, that is implemented by controllers.

But indeed, calling .uno:Copy on a specific frame would naturally be expected to act on that frame's document.

[1] https://api.libreoffice.org/docs/idl/ref/servicecom_1_1sun_1_1star_1_1datatransfer_1_1clipboard_1_1SystemClipboard.html
[2] https://api.libreoffice.org/docs/idl/ref/interfacecom_1_1sun_1_1star_1_1datatransfer_1_1XTransferableSupplier.html#ae9847e756ddd6ebeea6a0b1768e6f806
Comment 10 QA Administrators 2024-09-08 03:16:29 UTC Comment hidden (obsolete)
Comment 11 Konstantin Kharlamov 2024-09-09 03:54:25 UTC
The script currently gives:

    Traceback (most recent call last):
      File "/tmp/test.py", line 38, in <module>
        (smgr, desktop) = connectToLO()
                          ^^^^^^^^^^^^^
      File "/tmp/test.py", line 11, in connectToLO
        return (smgr, smgr.createInstanceWithContext( "com.sun.star.frame.Desktop", ctx))
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    com.sun.star.uno.RuntimeException: Binary URP bridge disposed during call at /usr/src/debug/libreoffice-fresh/libreoffice-24.8.0.3/binaryurp/source/bridge.cxx:613

It's a frequent error in UNO scripts in general, Idk what makes it happen.
Comment 12 Buovjaga 2024-09-09 13:13:51 UTC
Still failing in the usual way for me.

Traceback (most recent call last):
  File "/path/to/test.py", line 41, in <module>
    copiedTopSlideSample = copySlideTo(impressApp, impressApp, topSlideSample, 0, smgr)
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/path/to/test.py", line 26, in copySlideTo
    return dstComponent.DrawPages.getByIndex(insert_after+1)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
com.sun.star.lang.IndexOutOfBoundsException

Version: 25.2.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: 3231db0341baffd2547c50d36ef7c00aaa11601d
CPU threads: 8; OS: Linux 6.10; UI render: default; VCL: kf6 (cairo+wayland)
Locale: fi-FI (fi_FI.UTF-8); UI: en-US
Calc: CL threaded