GraphicExportFilter and headless mode

Maxim Lacrima lacrima.maxim at gmail.com
Tue Nov 26 05:51:51 PST 2013


Hello,

I have found an interesting issue.

Start libreoffice as following:

$ /usr/bin/libreoffice4.0 "--accept=socket,host=localhost,port=2002;urp;"

draw.odg contains some asian text. Let's export it using using
GraphicExportFilter. I created a sample python script for this
(drawpages.py):

$ cp draw.odg /tmp/
$ python drawpages.py

Now open /tmp/draw.png. Everything is displayed correctly.

Now start libreoffice in headless mode:

/usr/bin/libreoffice4.0 "--accept=socket,host=localhost,port=2002;urp;"
--headless

Repeat steps above. If you open /tmp/draw.png, you will notice that all
asian characters are mangled.

For convenience I attached drawpages.py and other documents. For clarity
here it is:
--------------------------
import uno

localContext = uno.getComponentContext()
resolver = localContext.ServiceManager.createInstanceWithContext(
        "com.sun.star.bridge.UnoUrlResolver", localContext)

context = resolver.resolve("uno:socket,host=localhost,port=2002;"
                "urp;StarOffice.ComponentContext")

desktop = context.ServiceManager.createInstanceWithContext(
        "com.sun.star.frame.Desktop", context)

url = uno.systemPathToFileUrl('/tmp/draw.odg')
doc = desktop.loadComponentFromURL(url, "_blank", 0, ())

draw_pages = doc.getDrawPages()
page = draw_pages.getByIndex(0)

gf = context.ServiceManager.createInstanceWithContext(
        "com.sun.star.drawing.GraphicExportFilter", context)
gf.setSourceDocument(page)

url = uno.systemPathToFileUrl('/tmp/draw.png')
pv1 = uno.createUnoStruct("com.sun.star.beans.PropertyValue")
pv1.Name, pv1.Value = "URL", url

pv2 = uno.createUnoStruct("com.sun.star.beans.PropertyValue")
pv2.Name, pv2.Value = "MediaType", "image/png"

args = (pv1, pv2)

gf.filter(args)
--------------------------

-- 
Regards,
Maxim
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/libreoffice/attachments/20131126/722e9594/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: draw.odg
Type: application/vnd.oasis.opendocument.graphics
Size: 16104 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/libreoffice/attachments/20131126/722e9594/attachment.odg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: draw.png
Type: image/png
Size: 66824 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/libreoffice/attachments/20131126/722e9594/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: draw1.png
Type: image/png
Size: 17741 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/libreoffice/attachments/20131126/722e9594/attachment-0001.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: drawpages.py
Type: text/x-python
Size: 1008 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/libreoffice/attachments/20131126/722e9594/attachment.py>


More information about the LibreOffice mailing list