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.

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.RotateAngle = 3000<br />

Page.add(RectangleShape)<br />

Editing Drawing Objects<br />

The next example creates the same rectangle as in the previous example, but instead shears it through 30 degrees<br />

using the ShearAngle property.<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.ShearAngle = 3000<br />

Page.add(RectangleShape)<br />

Searching and Replacing<br />

As in text documents, drawing documents provide a function for searching and replace. This function is similar to<br />

the one that is used in text documents as described in Text Documents. However, in drawing documents the<br />

descriptor objects for searching and replacing are not created directly through the document object, but rather<br />

through the associated character level. The following example outlines the replacement process within a drawing:<br />

Dim Doc As Object<br />

Dim Page As Object<br />

Dim ReplaceDescriptor As Object<br />

Dim I As Integer<br />

Doc = ThisComponent<br />

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

ReplaceDescriptor = Page.createReplaceDescriptor()<br />

ReplaceDescriptor.SearchString = "is"<br />

ReplaceDescriptor.ReplaceString = "was"<br />

For I = 0 to Doc.DrawPages.Count - 1<br />

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

Page.ReplaceAll(ReplaceDescriptor)<br />

Next I<br />

This code uses the first page of the document to create a ReplaceDescriptor and then applies this descriptor<br />

in a loop to all of the pages in the drawing document.<br />

Chapter 8 · Drawings and Presentations 127

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

Saved successfully!

Ooh no, something went wrong!