Bug 128556 - PyUno getCurrentComponent return None when loading presentation in headless mode
Summary: PyUno getCurrentComponent return None when loading presentation in headless mode
Status: RESOLVED NOTABUG
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Impress (show other bugs)
Version:
(earliest affected)
6.3.2.2 release
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: needsDevEval
Depends on:
Blocks:
 
Reported: 2019-11-02 18:08 UTC by Pablo
Modified: 2020-04-26 14:07 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
Keynote presentation (246.54 KB, application/zip)
2019-11-02 18:10 UTC, Pablo
Details
Impress presentation (11.79 KB, application/vnd.oasis.opendocument.presentation)
2019-11-02 18:10 UTC, Pablo
Details
test python script (132 bytes, text/plain)
2019-11-03 11:57 UTC, Oliver Brinzing
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Pablo 2019-11-02 18:08:54 UTC
Description:
When loading a Keynote presentation in headless mode it's not possible to access it with internal PyUno script.
Keynote in non-headless mode works fine.
ODP in headless mode works fine.

Steps to Reproduce:
1. create test.py internal python script with a function that get the current component and print it to the console.
Script location under Ubuntu:
/usr/lib/libreoffice/share/Scripts/python/test.py
test.py script content:
def test():
  desktop = XSCRIPTCONTEXT.getDesktop()
  cmp = desktop.getCurrentComponent()
  print(cmp)

2. Execute the script with a Keynote presentation:
libreoffice --headless 'vnd.sun.star.script:test.py$test?language=Python&location=share' test.key

3. None is printed to the console instead of the component object.

4. Test without headless mode:
libreoffice 'vnd.sun.star.script:test.py$test?language=Python&location=share' test.key

5. Verify the component object is printed to the console.

6. Execute the script with ODP presentation:
libreoffice --headless 'vnd.sun.star.script:test.py$test?language=Python&location=share' test.odp

7. Verify the component object is printed to the console.

Actual Results:
None is printed to the console. We can't access the Current Component.

Expected Results:
We should be able to access the Current Component and print it to the console.


Reproducible: Always


User Profile Reset: No



Additional Info:
Version: 6.3.2.2
Build ID: 1:6.3.2-0ubuntu0.18.04.1~lo1
CPU threads: 1; OS: Linux 5.0; UI render: default; VCL: gtk3; 
Locale: en-US (en_IL); UI-Language: en-US
Calc: threaded
Comment 1 Pablo 2019-11-02 18:10:06 UTC
Created attachment 155469 [details]
Keynote presentation
Comment 2 Pablo 2019-11-02 18:10:27 UTC
Created attachment 155470 [details]
Impress presentation
Comment 3 Oliver Brinzing 2019-11-03 11:57:01 UTC
Created attachment 155486 [details]
test python script

i cannot confirm this with:

Version: 6.3.3.2 (x64)
Build-ID: a64200df03143b798afd1ec74a12ab50359878ed
CPU-Threads: 4; BS: Windows 10.0; UI-Render: Standard; VCL: win; 
Gebietsschema: de-DE (de_DE); UI-Sprache: de-DE
Calc: 

soffice d:/test.key "vnd.sun.star.script:test.py$test?language=Python&
location=share"

and

soffice d:/test.odp "vnd.sun.star.script:test.py$test?language=Python&location=share"

will always print cmp, but with parameter "--headless" both will always print "None"
Comment 4 Pablo 2019-11-03 12:41:08 UTC
If both files print "None" with --headless parameter, that's a bug. Headless mode shouldn't break access to the presentation component. Can you change the status to confirmed?
Comment 5 Oliver Brinzing 2019-11-03 14:38:37 UTC
(In reply to Pablo from comment #4)
> If both files print "None" with --headless parameter, that's a bug. Headless
> mode shouldn't break access to the presentation component. Can you change
> the status to confirmed?

i am not sure if this is a bug:

"provides read access to the component inside the tree which has the UI focus"

https://api.libreoffice.org/docs/idl/ref/interfacecom_1_1sun_1_1star_1_1frame_1_1XDesktop.html#a50a9f0bc6e533b4616d9aee0176a1116
Comment 6 Pablo 2019-11-03 14:59:14 UTC
I'm not sure. I'll use this to get the Component instead:
cmp = desktop.getComponents().createEnumeration().nextElement()
Feel free to close this issue if you think it works as intended.
Comment 7 Buovjaga 2020-04-26 14:07:49 UTC
(In reply to Pablo from comment #6)
> I'm not sure. I'll use this to get the Component instead:
> cmp = desktop.getComponents().createEnumeration().nextElement()
> Feel free to close this issue if you think it works as intended.

You could always ask in https://ask.libreoffice.org/ for advice.

Let's close for now.