21.08.2013 Views

OpenOffice.org BASIC Guide.pdf - OpenOffice.org wiki

OpenOffice.org BASIC Guide.pdf - OpenOffice.org wiki

OpenOffice.org BASIC Guide.pdf - OpenOffice.org wiki

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Editing Drawing Objects 176<br />

Square.Size = Size<br />

Square.Position = Point<br />

Square.FillColor = RGB(255,128,128)<br />

Page.add(Square)<br />

' create circle drawing element<br />

Circle = Doc.createInstance("com.sun.star.drawing.EllipseShape")<br />

Circle.Size = Size<br />

Circle.Position = Point<br />

Circle.FillColor = RGB(255,128,128)<br />

Circle.FillColor = RGB(0,255,0)<br />

Page.add(Circle)<br />

' combine square and circle drawing elements<br />

Shapes = createUnoService("com.sun.star.drawing.ShapeCollection")<br />

Shapes.add(Square)<br />

Shapes.add(Circle)<br />

Group = Page.group(Shapes)<br />

' centre combined drawing elements<br />

Height = Page.Height<br />

Width = Page.Width<br />

NewPos.X = Width / 2<br />

NewPos.Y = Height / 2<br />

Height = Group.Size.Height<br />

Width = Group.Size.Width<br />

NewPos.X = NewPos.X - Width / 2<br />

NewPos.Y = NewPos.Y - Height / 2<br />

Group.Position = NewPos<br />

This code creates a rectangle and a circle and inserts them into a page. It then creates an<br />

object that supports the<br />

com.sun.star.drawing.ShapeCollection<br />

service and uses the Add method to add the rectangle and the circle to this object. The<br />

ShapeCollection is added to the page using the Group method and returns the actual Group<br />

object that can be edited like an individual Shape.<br />

If you want to format the individual objects of a group, apply the formatting before you add<br />

them to the group. You cannot modify the objects once they are in the group.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!