Import failing! What is wrong with XChartTypeTemplate

What is wrong with XChartTypeTemplate???
Import is failing.

I am trying to import XChartTypeTemplate in LibreOffice 7.4 on Ubuntu 22.04.

I have both snap LibreOffice 7.4 and Regular Installed LibreOffice 7.4 and both version report this same import error.

Here is a API link to XChartTypeTemplate

APSO python console [LibreOffice]
3.10.6 (main, Aug 10 2022, 11:40:04) [GCC 11.3.0]
Type "help", "copyright", "credits" or "license" for more information.
>>> from com.sun.star.chart2 import XChartTypeTemplate
Traceback (most recent call last):
  File "/usr/lib/python3.10/code.py", line 90, in runcode
    exec(code, self.locals)
  File "<console>", line 1, in <module>
  File "/usr/lib/python3/dist-packages/uno.py", line 428, in _uno_import
    raise uno_import_exc
  File "/usr/lib/python3/dist-packages/uno.py", line 349, in _uno_import
    return _builtin_import(name, *optargs, **kwargs)
ImportError: No module named 'com' (or 'com.sun.star.chart2.XChartTypeTemplate' is unknown)

other imports seem to be working fine.

No Errors.

>>> from com.sun.star.chart2 import XChartType
>>>

I download an AppImage of LibreOffice 7.3.
Tried the import.

>>> from com.sun.star.chart2 import XChartTypeTemplate
>>>

No Errors.
Why not working in LO 7.4?

Actually no clue, but I’ve read some questions on incomplete Setups on linux recently (not only the usual problems with base/java) like Latest Update has broken Libre Draw
.
I’d suggest to report at bugzilla and ubuntu, and stay at 7.3 for the moment.
.
Other possibility would by to try the install directly from tdf, if that fixes your problem…

After importing uno, I can also import XChartType from com.sun.star.chart2

as the traceback states, uno is imported before, and the “uno-import-hook” is already invoked!

Maybe related to the patch for this bug… but no! I have added the patch from there to uno.py and it works with:

from com.sun.star.chart2 import XChartTypeTemplate

with me LO7.0.4.2 from debian

I just wanted to confirm.

Same error on LIbreOffice 7.4.2.3 AppImage

I will check windows shortly.

APSO python console [LibreOffice]
3.8.14 (default, Oct 10 2022, 14:00:36) 
[GCC 7.3.1 20180303 (Red Hat 7.3.1-5)]
Type "help", "copyright", "credits" or "license" for more information.
>>> import uno
>>> from com.sun.star.chart2 import XChartTypeTemplate
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/tmp/.mount_LibreOQn43Su/opt/libreoffice7.4/program/uno.py", line 425, in _uno_import
    raise uno_import_exc
  File "/tmp/.mount_LibreOQn43Su/opt/libreoffice7.4/program/uno.py", line 346, in _uno_import
    return _builtin_import(name, *optargs, **kwargs)
ImportError: No module named 'com' (or 'com.sun.star.chart2.XChartTypeTemplate' is unknown)
>>> 

Hmm … Windows LO 7.4.0.3 imports fine.

I have a little more testing to do but I think a bug report is in order.

APSO python console [LibreOffice]
3.8.12 (default, Aug 10 2022, 16:24:11) [MSC v.1929 64 bit (AMD64)]
Type "help", "copyright", "credits" or "license" for more information.
>>> from com.sun.star.chart2 import XChartType
>>> 

Edit:

Opps - I tested for the wrong interface on this Windows test. Should have been XChartTypeTemplate and not XChartType

Test is also failing on Windows 10, LO 7.4

APSO python console [LibreOffice]
3.8.14 (default, Oct 10 2022, 12:22:41) [MSC v.1929 64 bit (AMD64)]
Type "help", "copyright", "credits" or "license" for more information.
>>> import uno
>>> from com.sun.star.chart2 import XChartTypeTemplate
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "C:\Program Files\LibreOffice\program\uno.py", line 425, in _uno_import
    raise uno_import_exc
  File "C:\Program Files\LibreOffice\program\uno.py", line 346, in _uno_import
    return _builtin_import(name, *optargs, **kwargs)
ImportError: No module named 'com' (or 'com.sun.star.chart2.XChartTypeTemplate' is unknown)
>>> 

Upgraded to LO 7.4.2.3 on Windows 10 and it also work fine.

Edit

Actually test is Failing. See above

can you run a diff on uno.py from windows and LIbreOffice 7.4.2.3 AppImage and|or from the Ubuntu?

Looks like Diff will not be helpful. I made a mistake when I said it was working in Windows. See above Edits.

I went into debugger and tried tried directly from pyuno ( Windows 10 )

>>> pyuno.getClass("com.sun.star.chart2.XChartTypeTemplate")
Traceback (most recent call last):
  File "C:\Program Files\LibreOffice\program\uno.py", line 381, in _uno_import
    d[class_name] = pyuno.getClass(name + "." + class_name)
uno.com.sun.star.uno.RuntimeException: pyuno.getClass: uno exception com.sun.star.chart2.XChartTypeTemplate is unknown

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
uno.com.sun.star.uno.RuntimeException: pyuno.getClass: uno exception com.sun.star.chart2.XChartTypeTemplate is unknown

However this worked

>>> pyuno.getClass("com.sun.star.chart2.XChartDocument")
<class 'uno.com.sun.star.chart2.XChartDocument'>

So I am guessing this is not a uno.py issue.

I removed LO 7.4 from my Windows 10 and installed LO 7.3

With this older version I was able to get everthing working.

Here is a demonstration. The demo is part of my OOO Development Tools project.

I put some notes in Chart2.set_template() method.

Tomorrow I will see about posting a bug report for this.

New bug report for this issue.

Bug 151846

Turns out there are several missing imports in the chart2 namespaces.

  • com.sun.star.chart2.InterpretedData
  • com.sun.star.chart2.XChartTypeTemplate
  • com.sun.star.chart2.XDataInterpreter
  • com.sun.star.chart2.XTransformation