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 />

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

RectangleShape.Size = Size<br />

RectangleShape.Position = Point<br />

Page.add(RectangleShape)<br />

RectangleShape.String = "This is a test" ' May only take place after Page.add!<br />

RectangleShape.TextVerticalAdjust = com.sun.star.drawing.TextVerticalAdjust.TOP<br />

RectangleShape.TextHorizontalAdjust = com.sun.star.drawing.TextHorizontalAdjust.LEFT<br />

RectangleShape.TextLeftDistance = 300<br />

RectangleShape.TextRightDistance = 300<br />

RectangleShape.TextUpperDistance = 300<br />

RectangleShape.TextLowerDistance = 300<br />

This code inserts a drawing element in a page and then adds text to the top left corner of the drawing object using<br />

the TextVerticalAdjust and TextHorizontalAdjust properties. The minimum distance between the text<br />

edge of the drawing object is set to three millimeters.<br />

Shadow Properties<br />

You can add a shadow to most drawing objects with the com.sun.star.drawing.ShadowProperties service. The<br />

properties of this service are:<br />

Shadow (Boolean)<br />

activates the shadow<br />

ShadowColor (Long)<br />

shadow color<br />

ShadowTransparence (Short)<br />

transparency of the shadow<br />

ShadowXDistance (Long)<br />

vertical distance of the shadow from the drawing object in hundredths of a millimeter<br />

ShadowYDistance (Long)<br />

horizontal distance of the shadow from the drawing object in hundredths of a millimeter<br />

The following example creates a rectangle with a shadow that is vertically and horizontally offset from the<br />

rectangle by 2 millimeters. The shadow is rendered in dark gray with 50 percent transparency.<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 />

RectangleShape.Position = Point<br />

RectangleShape.Shadow = True<br />

RectangleShape.ShadowColor = RGB(192,192,192)<br />

RectangleShape.ShadowTransparence = 50<br />

RectangleShape.ShadowXDistance = 200<br />

RectangleShape.ShadowYDistance = 200<br />

Page.add(RectangleShape)<br />

120 <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!