Chapter 15: Draw and Impress Documents


Overview

This chapter introduces methods to manipulate and modify the content contained in Draw and Impress documents. The drawing functionality is the same in Draw and Impress, but Impress contains extra functionality to facilitate presentations.

Draw and Impress are vector-oriented graphical applications. They can also display bitmap images, but their strength is not in photo editing. Vector-oriented applications represent many graphical objects as objects rather than as bitmapped images. For example, lines, circles, rectangles, and text are each represented as special objects. One advantage of vector graphics is that you can independently manipulate and transform multiple overlapping elements without worrying about resolution and pixels.

Photo-editing graphics packages typically represent and manipulate images as bitmaps. A bitmap representing an image is characterized by the width and height of the image in pixels. Each pixel represents a single, colored dot in the image. The drawing capability in OpenOffice.org, however, is focused on vector operations.

Every Draw document supports the com.sun.star.drawing.DrawingDocument service and every Impress document supports the com.sun.star.presentation.PresentationDocument service. When I write a macro that must be user friendly and requires a specific document type, I verify that the document is the correct type by using the object method supportsService(). See Listing 1 .

Listing 1: Check for an Impress document before checking for a Draw document.
start example
 REM If it really matters, you should check the document type REM to avoid a run-time error. sDraw$ = "com.sun.star.drawing.DrawingDocument" sImpress$ = "com.sun.star.presentation.PresentationDocument" If ThisComponent.SupportsService(sImpress$) Then   MsgBox "The current document is an Impress document", 0, "Impress Document" ElseIf ThisComponent.SupportsService(sDraw$) Then   MsgBox "The current document is a Draw document", 0, "Draw Document" Else   MsgBox "The current document is not the correct type", 48, "Error"   Exit Sub End If 
end example
 
Warning  

The PresentationDocument service implements the DrawingDocument service. This means that every presentation document looks like a drawing document. To distinguish between the two document types, you must first check for a presentation (Impress) document and then check for a drawing document.




OpenOffice.org Macros Explained
OpenOffice.org Macros Explained
ISBN: 1930919514
EAN: 2147483647
Year: 2004
Pages: 203

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net