Date: prev next · Thread: first prev next last
2012 Archives by date, by thread · List index


On 11/03/2012 11:11 PM, Steven Marguet wrote:
I have difficulties to create a PolyLineShape using the Pyhton API of
LibreOffice (in the Draw application).
In fact, I don't know what kind of data structure I have to used for the
points of the PolyLineShape I want to create.

Here is my code :

====================================================================
from com.sun.star.awt import Point
PolyLineShape = "com.sun.star.drawing.PolyLineShape"

def Test(button):
     document = XSCRIPTCONTEXT.getDocument()

     pages = document.getDrawPages()
     page = pages.getByIndex(0)

     shape = document.createInstance(PolyLineShape)
     page.add(shape)
     shape.setPropertyValue("LineWidth", 50)
     shape.setPropertyValue("LineColor", 0)

     points = (Point(120,340), Point(1200,3400), Point(1200,6000))

The com.sun.star.drawing.PolyPolygonDescriptor.PolyPolygon property is of type com.sun.star.drawing.PointSequenceSequence, i.e., a list of lists, so the above probably needs to read

  points = ((Point(120,340), Point(1200,3400), Point(1200,600)),)

instead (but I didn't test it).


     shape.PolyPolygon = points
====================================================================

This code creates a CannotConvertException which seems to mean that a
tuple or a list is not suitable...

Stephan

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.