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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

More Than Just Text<br />

this way can then be inserted in the document using the insertTextContent method of the Text object. In so<br />

doing, the name of the proper com.sun.star.text.TextFrame service should be specified.<br />

The text frame's insert position is determined by a Cursor object, which is also executed when inserted.<br />

Note – VBA : Text frames are <strong>OpenOffice</strong>.<strong>org</strong>'s counterpart to the position frame used in Word. Whereas<br />

VBA uses the Document.Frames.Add method for this purpose, creation in <strong>OpenOffice</strong>.<strong>org</strong> Basic is performed<br />

using the previous procedure with the aid of a TextCursor as well as the createInstance method of the<br />

document object.<br />

Text frame objects provide a range of properties with which the position and behavior of the frame can be<br />

influenced. The majority of these properties are defined in the com.sun.star.text.BaseFrameProperties service,<br />

which is also supported by each TextFrame service. The central properties are:<br />

BackColor (Long)<br />

background color of the text frame.<br />

BottomMargin (Long)<br />

bottom margin in 100ths of a millimeter.<br />

LeftMargin (Long)<br />

left margin in 100ths of a millimeter.<br />

RightMargin (Long)<br />

right margin in 100ths of a millimeter.<br />

TopMargin (Long)<br />

top margin in 100ths of a millimeter.<br />

Height (Long)<br />

height of text frame in 100ths of a millimeter.<br />

Width (Long)<br />

width of text frame in 100ths of a millimeter.<br />

HoriOrient (const)<br />

horizontal orientation of text frame (in accordance with com.sun.star.text.HoriOrientation).<br />

VertOrient (const)<br />

vertical orientation of text frame (in accordance with com.sun.star.text.VertOrientation).<br />

The following example creates a text frame using the properties described previously:<br />

Dim Doc As Object<br />

Dim TextTables As Object<br />

Dim Cursor As Object<br />

Dim Frame As Object<br />

Doc = ThisComponent<br />

Cursor = Doc.Text.createTextCursor()<br />

Cursor.gotoNextWord(False)<br />

Frame = Doc.createInstance("com.sun.star.text.TextFrame")<br />

Frame.Width = 3000<br />

Frame.Height = 1000<br />

Frame.AnchorType = com.sun.star.text.TextContentAnchorType.AS_CHARACTER<br />

Frame.TopMargin = 0<br />

Frame.BottomMargin = 0<br />

Frame.LeftMargin = 0<br />

Frame.RightMargin = 0<br />

Frame.BorderDistance = 0<br />

Frame.HoriOrient = com.sun.star.text.HoriOrientation.NONE<br />

Frame.VertOrient = com.sun.star.text.VertOrientation.LINE_TOP<br />

Doc.Text.insertTextContent(Cursor, Frame, False)<br />

The example creates a TextCursor as the insertion mark for the text frame. This is positioned between the first<br />

and second word of the text. The text frame is created using Doc.createInstance. The properties of the text<br />

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