group Nicole Scholz How can I group shapes?

In this example two shapes are grouped together with the ShapeGrouper.

/* initialize connection to server, get XContext */ xContext = UNO.connect() -- connect to server and retrieve the XContext object XMcf = xContext~getServiceManager -- retrieve XMultiComponentFactory /* Retrieve the Desktop object, we need its XComponentLoader interface to load a new document */ oDesktop = UNO.createDesktop() -- get the UNO Desktop service object xComponentLoader = oDesktop~{%see com.sun.star.frame.XDesktop%XDesktop}~{%see com.sun.star.frame.XComponentLoader%XComponentLoader} -- get componentLoader interface /* open the blank file */ url = "private:factory/sdraw" xDrawComponent = xComponentLoader~loadComponentFromURL(url, "_blank", 0, - .UNO~noProps) xDocumentFactory = xDrawComponent~{%see com.sun.star.lang.XMultiServiceFactory%XMultiServiceFactory} /* get draw page by index */ xDrawPage = xDrawComponent~{%see com.sun.star.drawing.XDrawPagesSupplier%XDrawPagesSupplier}~getDrawPages~getByIndex(0)~{%see com.sun.star.drawing.XDrawPage%XDrawPage} /* draw a rectangle */ xrectangle = xDocumentFactory~createInstance("{%see com.sun.star.drawing.RectangleShape}")~{%see com.sun.star.drawing.XShape%xshape} xrectangle~setPosition(.bsf~new("{%see com.sun.star.awt.Point}", 1000, 1000)) xrectangle~setSize(.bsf~new("{%see com.sun.star.awt.Size}", 5000, 5000)) xDrawPage~add(xrectangle) -- adds the rectangle to the draw document /* draw a rectangle */ xrectangle1 = xDocumentFactory~createInstance("{%see com.sun.star.drawing.RectangleShape}")~{%see com.sun.star.drawing.XShape%xshape} xrectangle1~setPosition(.bsf~new("{%see com.sun.star.awt.Point}", 2500, 2500)) xrectangle1~setSize(.bsf~new("{%see com.sun.star.awt.Size}", 2000, 2000)) xDrawPage~add(xrectangle1) -- adds the rectangle to the draw document xShapeProps = xrectangle1~{%see com.sun.star.beans.XPropertySet%XPropertySet} /* set fill colour pink */ xShapeProps~setPropertyValue("FillColor", box("int", "ff 00 ff"x ~c2d)) /* group the 2 shapes */ /* get ShapeCollection from the XMultiComponentFactory */ xObj = xMcf~- createInstanceWithContext("{%see com.sun.star.drawing.ShapeCollection}", xContext) xToGroup = xObj~{%see com.sun.star.drawing.XShapes%XShapes} xToGroup~add(xrectangle) xToGroup~add(xrectangle1) xShapeGrouper = xDrawPage~{%see com.sun.star.drawing.XShapeGrouper%xShapeGrouper} xShapeGroup = xShapeGrouper~group(xToGroup) call syssleep 1 xShapeGroup~setPosition(.bsf~new("com.sun.star.awt.Point", 7000, 7000)) -- move the group to another position ::requires UNO.cls -- get UNO support