Question about PolyPolygon (and all kind of Shape involving several points) with python API
sbergman at redhat.com
Mon Nov 5 01:09:21 PST 2012
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)
> 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...
More information about the LibreOffice