[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: libreoffice-nogui: application crash when using the loadComponentFromURL method



Hi,

Le 05/06/2023 à 20:07, Rene Engelhard a écrit :
Am 05.06.23 um 10:54 schrieb Étienne Loks:
ODT documents with python UNO library (python3-uno package).

Doing what exactly? A Calc document here? Because it mentions a calc ui file?


Creating a new calc document but this occurs with other type of documents.

Here a python script adapted from TableSample.py from https://wiki.openoffice.org/wiki/PyUNO_samples
(file attached)

===============================================================

import uno

from com.sun.star.text.ControlCharacter import PARAGRAPH_BREAK
from com.sun.star.text.TextContentAnchorType import AS_CHARACTER
from com.sun.star.awt import Size

from com.sun.star.lang import XMain

LIBREOFFICE_HOST, LIBREOFFICE_PORT = "127.0.0.1", "8101"


def createTable():
    ctx = uno.getComponentContext()

    resolver = ctx.ServiceManager.createInstanceWithContext(
                            "com.sun.star.bridge.UnoUrlResolver", ctx)
connection = f"socket,host={LIBREOFFICE_HOST},port={LIBREOFFICE_PORT};urp"
    try:
service_manager = resolver.resolve(f"uno:{connection};StarOffice.ServiceManager")
    except:
        print("connection error")
        return

    remote_context = service_manager.getPropertyValue("DefaultContext")
    desktop = service_manager.createInstanceWithContext(
"com.sun.star.frame.Desktop", remote_context)
    for app in [
            "schart",
            "swriter",
            #"scalc",
            #"sdraw",
            #"smath",
            #"simpress",
            ]:
        print(f"Try {app}")
doc = desktop.loadComponentFromURL(f"private:factory/{app}","_blank", 0, ())
        print("OK")


createTable()

===============================================================


The libreoffice service is launched with:

/usr/bin/libreoffice --headless \
    --accept=socket,host=127.0.0.1,port=8101;urp; \
    --nodefault --nofirststartwizard --nolockcheck \
    --nologo --norestore \
    --pidfile=/var/run/libreoffice.pid

The script can create "schart" and "swriter" documents.
Crash of the LO service with "scalc", "sdraw", "smath", "simpress" (commented on the script).


The problem is that something explicitely built without UI needs .ui files. This - as said - is hilariously broken upstream.


I have experienced other strange bugs and it seems that the LO API is pretty fragile. Sadly it does not surprise me... :/

Idealy it should be fixed upstream...

Versions of packages libreoffice-nogui depends on:
pn  libreoffice-base-nogui                <none>
pn  libreoffice-calc-nogui                <none>
pn  libreoffice-core-nogui                <none>
pn  libreoffice-draw-nogui                <none>
pn  libreoffice-impress-nogui             <none>
pn  libreoffice-math-nogui                <none>
pn  libreoffice-report-builder-bin-nogui  <none>
pn  libreoffice-writer-nogui              <none>

Hmm. none of -nogui installed?

My bad, I used reportbug on the wrong terminal...

Sorry.

The relevant piece of informations are:

-- System Information:
Debian Release: 11.7
  APT prefers stable-updates
APT policy: (500, 'stable-updates'), (500, 'stable-security'), (500, 'stable')
Architecture: amd64 (x86_64)

Kernel: Linux 5.15.64-1-pve (SMP w/5 CPU threads)
Kernel taint flags: TAINT_PROPRIETARY_MODULE, TAINT_OOT_MODULE
Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages libreoffice-nogui depends on:
ii  libreoffice-base-nogui                1:7.0.4-4+deb11u7
ii  libreoffice-calc-nogui                1:7.0.4-4+deb11u7
ii  libreoffice-core-nogui                1:7.0.4-4+deb11u7
ii  libreoffice-draw-nogui                1:7.0.4-4+deb11u7
ii  libreoffice-impress-nogui             1:7.0.4-4+deb11u7
ii  libreoffice-math-nogui                1:7.0.4-4+deb11u7
ii  libreoffice-report-builder-bin-nogui  1:7.0.4-4+deb11u7
ii  libreoffice-writer-nogui              1:7.0.4-4+deb11u7
ii  python3-uno                           1:7.0.4-4+deb11u7


Best regards,

--
Étienne Loks - Iggdrasil
import uno
 
from com.sun.star.text.ControlCharacter import PARAGRAPH_BREAK
from com.sun.star.text.TextContentAnchorType import AS_CHARACTER
from com.sun.star.awt import Size

from com.sun.star.lang import XMain

LIBREOFFICE_HOST, LIBREOFFICE_PORT = "127.0.0.1", "8101"

                     
def createTable():
    ctx = uno.getComponentContext()

    resolver = ctx.ServiceManager.createInstanceWithContext(
                            "com.sun.star.bridge.UnoUrlResolver", ctx)
    connection = f"socket,host={LIBREOFFICE_HOST},port={LIBREOFFICE_PORT};urp"
    try:
        service_manager = resolver.resolve(f"uno:{connection};StarOffice.ServiceManager")
    except:
        print("connection error")
        return

    remote_context = service_manager.getPropertyValue("DefaultContext")
    desktop = service_manager.createInstanceWithContext(
                                    "com.sun.star.frame.Desktop", remote_context)
    for app in [
            "schart",
            "swriter",
            #"scalc",
            #"sdraw",
            #"smath",
            #"simpress",
            ]:
        print(f"Try {app}")
        desktop.loadComponentFromURL(f"private:factory/{app}","_blank", 0, ())
        print("OK")


createTable()

Reply to: