OpenOffice.org BASIC Guide - OpenOffice.org wiki
OpenOffice.org BASIC Guide - OpenOffice.org wiki
OpenOffice.org BASIC Guide - OpenOffice.org wiki
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
service.<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 />
Page.add(RectangleShape)<br />
RectangleShape.String = "This is a test"<br />
RectangleShape.CharWeight = com.sun.star.awt.FontWeight.BOLD<br />
RectangleShape.CharFontName = "Arial"<br />
The Structure of Drawings<br />
This code uses the String-property of the rectangle to insert the text and the CharWeight and CharFontName<br />
properties from the com.sun.star.style.CharacterProperties service to format the text font.<br />
The text can only be inserted after the drawing object has been added to the drawing page. You can also use the<br />
com.sun.star.drawing.Text service to position and format text in drawing object. The following are some of the<br />
important properties of this service:<br />
TextAutoGrowHeight (Boolean)<br />
adapts the height of the drawing element to the text it contains<br />
TextAutoGrowWidth (Boolean)<br />
adapts the width of the drawing element to the text it contains<br />
TextHorizontalAdjust (Enum)<br />
horizontal position of text within the drawing element (default values in accordance with<br />
com.sun.star.drawing.TextHorizontalAdjust)<br />
TextVerticalAdjust (Enum)<br />
vertical position of text within the drawing element (default values in accordance with<br />
com.sun.star.drawing.TextVerticalAdjust)<br />
TextLeftDistance (Long)<br />
left-hand distance between drawing element and text in hundredths of a millimeter<br />
TextRightDistance (Long)<br />
right-hand distance between drawing element and text in hundredths of a millimeter<br />
TextUpperDistance (Long)<br />
upper distance between drawing element and text in hundredths of a millimeter<br />
TextLowerDistance (Long)<br />
lower distance between drawing element and text in hundredths of a millimeter<br />
The following example demonstrates use of the named properties.<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 />
Chapter 8 · Drawings and Presentations 119