21.08.2013 Views

OpenOffice.org BASIC Guide - OpenOffice.org wiki

OpenOffice.org BASIC Guide - OpenOffice.org wiki

OpenOffice.org BASIC Guide - 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.

The Structure of Drawings<br />

The following example creates and inserts a rectangle in a drawing document:<br />

Dim Doc As Object<br />

Dim Page As Object<br />

Dim RectangleShape As Object<br />

Dim Point As New com.sun.star.awt.Point<br />

Dim Size As New com.sun.star.awt.Size<br />

Doc = ThisComponent<br />

Page = Doc.DrawPages(0)<br />

Point.x = 1000<br />

Point.y = 1000<br />

Size.Width = 10000<br />

Size.Height = 10000<br />

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

RectangleShape.Size = Size<br />

RectangleShape.Position = Point<br />

Page.add(RectangleShape)<br />

The Point and Size structures with the point of origin (left hand corner) and the size of the drawing object are<br />

then initialized. The lengths are specified in hundredths of a millimeter.<br />

The program code then uses the Doc.createInstance call to create the rectangle drawing object as specified by<br />

the com.sun.star.drawing.RectangleShape service. At the end, the drawing object is assigned to a page using a<br />

Page.add call.<br />

Fill Properties<br />

This section describes four services and in each instance the sample program code uses a rectangle shape element<br />

that combines several types of formatting. Fill properties are combined in the com.sun.star.drawing.FillProperties<br />

service.<br />

<strong>OpenOffice</strong>.<strong>org</strong> recognizes four main types of formatting for a fill area. The simplest variant is a single-color fill.<br />

The options for defining color gradients and hatches let you create other colors into play. The fourth variant is the<br />

option of projecting existing graphics into the fill area.<br />

The fill mode of a drawing object is defined using the FillStyle property. The permissible values are defined in<br />

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

Single Color Fills<br />

The main property for single-color fills is:<br />

FillColor (Long)<br />

fill color of area<br />

To use the fill mode, you must the FillStyle property to the SOLID fill mode.<br />

The following example creates a rectangle shape and fills it with red (RGB value 255, 0, 0):<br />

Dim Doc As Object<br />

Dim Page As Object<br />

Dim RectangleShape As Object<br />

Dim Point As New com.sun.star.awt.Point<br />

Dim Size As New com.sun.star.awt.Size<br />

Point.x = 1000<br />

Point.y = 1000<br />

Size.Width = 10000<br />

Size.Height = 10000<br />

Doc = ThisComponent<br />

Page = Doc.DrawPages(0)<br />

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

RectangleShape.Size = Size<br />

114 <strong>OpenOffice</strong>.<strong>org</strong> 3.2 <strong>BASIC</strong> <strong>Guide</strong> · March 2010

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

Saved successfully!

Ooh no, something went wrong!