Table of Contents
Much of what you need to know about presentations has already been covered in the preceding chapter, because a presentation is at heart a series of <draw:page> elements within the <office:body>.
In fact, you can create multiple pages in an OpenOffice.org drawing document. They are simply stored as separate pages, and don’t have any of the transition elements that a presentation permits.
There’s enough information in the styles.xml file for even the simplest of presentations that you probably don’t want to create it from scratch. Instead, you will be better off to create an empty presentation with the background elements that you want, and then merge your own content.xml into the resulting jar file. Here are some of the names of <style:style>s that are in the styles.xml file for a plain presentation, along with their salient characteristics.
Table 7.1. Default Presentation Styles
| Style name | Characteristics |
|---|---|
| standard | a 24-point serif font; specifies bulleted lists with 0.6cm indenting at each level. All the other styles are based on this one. |
| textbody | a 16-point font |
| title | a 44-point font |
| title1 | a 24-point shadowed font |
| title2 | a 36-point shadowed font with a bulleted list |
| headline, headline1, headline2 | a 24-point, 18-point, and 14-point font. |
| measure | a 12-point font with arrow markers at both ends for lines |
| Default-title | This is the first of the styles with style:family equal to presentation. Specifies a 44-point serif font with bullets at 0.6cm indenting for each level. |
| Default-subtitle | A 32-point serif font with bullets at 0.6cm indenting for each level. |
| Default-background | If your master slide has a background fill color, gradient, or image, this is where you specify it. |
| Default-backgroundobjects | This style sets a 20-point serif font, and enables bulleted lists with 0.6cm indenting for each level, and it is the parent style for any objects that are on the master slide. |
| Default-outline1..9 | These nine styles are used for display in outline mode. Default-outline1 has 32-point serif font with bullets at unusual intervals: 0.3cm, 1.6cm, 3cm, and then at 1.2cm spacing. Default-outline2 is 28-point with a text indent of -0.8 centimeters. Default-outline3 is 24-point with a text indent of -0.6 centimeters, and the remaining styles are 20-point. Each one inherits from its predecessor; thus Default-outline5’s style:parent-style-name is Default-outline-4. Levels |
These <style:style> elements are followed by <style:presentation-page-layout> elements, one for each different kind of page layout that you use. These are incredibly important; if you want your document displayed correctly, you must have these page layout styles in the styles.xml file.
Each <style:presentation-page-layout> has a style:name attribute. There is one <presentation:placeholder> for each element on the slide master. This placeholder element has a presentation:object attribute that tells what kind of object you are dealing with: title, subtitle, text, outline, graphic, table (spreadsheet), object, chart, and orgchart. The value of handout is used to define the handout format; the values page and notes are not used in this context. Each <presentation:placeholder> has its location and size specified with svg:x, svg:y, svg:width, and svg:height attributes.
The <office:automatic-styles> is followed by <office:master-styles>. Just as described in the section called “A Drawing’s styles.xml File”, the <office:master-styles> begins with a <draw:layer-set> element.
In a presentation, the layer set is followed by a <style:handout-master> element. Its presentation:presentation-page-layout-name attribute refers to the style:presentation-page-layout whose <presentation:placeholder>s describe handouts. The <style:handout-master> contains one <draw:page-thumbnail> element for each thumbnail; the values of the thumbnail’s svg:x, svg:y, svg:width, and svg:height attributes are different from those of the <presentation:placeholder>, and are the ones that are actually used when displaying the thumbnail.
The next master style is a <style:master-page> element which describes the layout for the default slide type (text with outline) notes view. It contains a <draw:text-box> for a default title, a <draw:text-box> for an outline area, and a <presentation:notes> element, which contains two <draw:page-thumbnail> elements, one for the page and one for the notes, as specified in their presentation:class attribute.
Example 7.1, “Structure of a styles.xml file” shows a styles.xml file, with much non-essential information removed. Note how the names of the <style:page-master> elements are referenced in the <style:handout-master> and <style:master-page>; they are shown in boldface. Note also that the similar names of the <style:page-master> and <style:master-page> elements67 doesn’t make this any easier.
I have put the svg:width="-0.585cm" in italics. I have no idea why this width is set as it is, and I want to point it out and explain it.
Example 7.1. Structure of a styles.xml file
<office:styles>
<style:style style:name="standard" style:family="graphics">
<style:properties huge number of attributes>
<text:list-style>
<text:list-level-style-bullet text:level="1"
text:bullet-char="●">
<style:properties fo:font-family="StarSymbol"
style:use-window-font-color="true"
fo:font-size="45%"/>
</text:list-level-style-bullet>
</text:list-style>
</style:properties>
</style:style>
<!-- we have omitted many other default styles -->
<!-- This page layout is for the handout view -->
<style:presentation-page-layout style:name="AL0T25">
<presentation:placeholder presentation:object="handout"
svg:x="2.057cm" svg:y="1.743cm"
svg:width="10.555cm" svg:height="0.703cm"/>
<presentation:placeholder presentation:object="handout"
svg:x="15.412cm" svg:y="1.743cm"
svg:width="10.555cm" svg:height="0.703cm"/>
<presentation:placeholder presentation:object="handout"
svg:x="2.057cm" svg:y="4.546cm"
svg:width="10.555cm" svg:height="0.703cm"/>
<presentation:placeholder presentation:object="handout"
svg:x="15.412cm" svg:y="4.546cm"
svg:width="10.555cm" svg:height="0.703cm"/>
</style:presentation-page-layout>
<!-- A page layout for a title and subtitle page -->
<style:presentation-page-layout style:name="AL1T0">
<presentation:placeholder presentation:object="title"
svg:x="2.057cm" svg:y="1.743cm"
svg:width="23.911cm" svg:height="3.507cm"/>
<presentation:placeholder presentation:object="subtitle"
svg:x="2.057cm" svg:y="5.838cm"
svg:width="23.911cm" svg:height="13.23cm"/>
</style:presentation-page-layout>
<!-- A page layout for a title and two outlines -->
<style:presentation-page-layout style:name="AL3T3">
<presentation:placeholder presentation:object="title"
svg:x="2.057cm" svg:y="1.743cm"
svg:width="23.911cm" svg:height="3.507cm"/>
<presentation:placeholder presentation:object="outline"
svg:x="2.057cm" svg:y="5.838cm"
svg:width="11.669cm" svg:height="13.23cm"/>
<presentation:placeholder presentation:object="outline"
svg:x="14.309cm" svg:y="5.838cm"
svg:width="-0.585cm" svg:height="13.23cm"/>
</style:presentation-page-layout>
</office:styles>
<office:automatic-styles>
<!-- The page master for handouts -->
<style:page-master style:name="PM0">
<style:properties fo:margin-top="2cm" fo:margin-bottom="2cm"
fo:margin-left="2cm" fo:margin-right="2cm"
fo:page-width="27.94cm" fo:page-height="21.59cm"
style:print-orientation="landscape"/>
</style:page-master>
<!-- The page master for ordinary pages -->
<style:page-master style:name="PM1">
<style:properties fo:margin-top="0cm" fo:margin-bottom="0cm"
fo:margin-left="0cm" fo:margin-right="0cm"
fo:page-width="28cm" fo:page-height="21cm"
style:print-orientation="landscape"/>
</style:page-master>
<!-- The page master for notes -->
<style:page-master style:name="PM2">
<style:properties fo:margin-top="2cm" fo:margin-bottom="2cm"
fo:margin-left="2cm" fo:margin-right="2cm"
fo:page-width="21.59cm" fo:page-height="27.94cm"
style:print-orientation="portrait"/>
</style:page-master>
<!-- Style for the default page -->
<style:style style:name="dp1" style:family="drawing-page">
<style:properties draw:background-size="border"
draw:fill="none"/>
</style:style>
</office:automatic-styles>
<office:master-styles>
<draw:layer-set>
<draw:layer draw:name="layout"/>
<draw:layer draw:name="background"/>
<draw:layer draw:name="backgroundobjects"/>
<draw:layer draw:name="controls"/>
<draw:layer draw:name="measurelines"/>
</draw:layer-set>
<style:handout-master
presentation:presentation-page-layout-name="AL0T25"
style:page-master-name="PM0">
<draw:page-thumbnail draw:layer="backgroundobjects"
svg:width="10.393cm" svg:height="7.794cm"
svg:x="2.19cm" svg:y="2cm" draw:page-number="1"/>
<draw:page-thumbnail draw:layer="backgroundobjects"
svg:width="10.393cm" svg:height="7.794cm"
svg:x="15.357cm" svg:y="2cm" draw:page-number="2"/>
<draw:page-thumbnail draw:layer="backgroundobjects"
svg:width="10.393cm" svg:height="7.794cm"
svg:x="2.19cm" svg:y="11.795cm" draw:page-number="3"/>
<draw:page-thumbnail draw:layer="backgroundobjects"
svg:width="10.393cm" svg:height="7.794cm"
svg:x="15.357cm" svg:y="11.795cm" draw:page-number="4"/>
</style:handout-master>
<style:master-page style:name="Default" style:page-master-name="PM1"
draw:style-name="dp1">
<draw:text-box presentation:style-name="Default-title"
presentation:placeholder="true"
draw:layer="backgroundobjects"
svg:x="2.057cm" svg:y="1.743cm"
svg:width="23.911cm" svg:height="3.507cm"/>
<draw:text-box presentation:style-name="Default-outline1"
presentation:class="outline"
draw:layer="backgroundobjects"
svg:x="2.057cm" svg:y="5.838cm"
svg:width="23.911cm" svg:height="13.23cm"/>
<presentation:notes style:page-master-name="PM2">
<draw:page-thumbnail presentation:style-name="Default-title"
presentation:class="page"
draw:layer="backgroundobjects"
svg:x="4.411cm" svg:y="2.794cm"
svg:width="12.768cm" svg:height="9.576cm"/>
<draw:text-box presentation:style-name="Default-notes"
presentation:class="notes"
presentation:placeholder="true"
draw:layer="backgroundobjects"
svg:x="3.292cm" svg:y="13.299cm"
svg:width="15.021cm" svg:height="10.629cm"/>
</presentation:notes>
</style:master-page>
</office:master-styles>
The body of the content.xml consists of a series of <draw:page> elements, each of which has a draw:name attribute in the form pagen and a numeric draw:id which gives the slide number. The draw:master-page-name and draw:style-name attributes refer to the master page and style for the slide. These will normally be the same for all slides. The presentation:presentation-page-layout-name attribute points to the default layout from the styles.xml file.
The <draw:page> element contains child elements for each of the objects on the slide. These can be:
These elements have the following attributes in common: draw:layer is set to layout. The presentation:class attribute tells what kind of item this is: title, outline, subtitle, text, graphic (for clip art), object (for drawings), table (for spreadsheets), or chart. The item’s location and size is given by svg:x, svg:y, svg:width, and svg:height attributes. The element will also have a draw:style-name attribute that refers to a style in the <office:automatic-styles> section of the file.
The layout of a page is controlled by the style.xml’s <style:presentation-page-layout> elements as described in the section called “Page Layouts in styles.xml”. If you set the location and size attributes for a particular element in the content.xmlfile, they will not take effect unless you also set the presentation:user-transformed to true.
If a slide doesn’t have content yet (it shows up as “Click for title/text/chart” in OpenOffice.org), that means that the element has its presentation:placeholder attribute set to true.
The <draw:text-box> has additional presentation:style-name and draw:text-style-name attributes. The children of the <draw:text-box> element will normally be <text:p> elements for titles and <text:unordered-list> elements for outlines. (Of course, if you add anything other than the defaults, such as an ordered list, that will also go into the <draw:text-box>. Example 7.2, “Text Boxes for a Page with Title and Two Outlines” shows the text boxes for a page with a title and a left and right outline, each containing one item.
Example 7.2. Text Boxes for a Page with Title and Two Outlines
<draw:text-box presentation:style-name="pr2"
draw:text-style-name="P2" draw:layer="layout"
svg:width="23.911cm" svg:height="3.508cm"
svg:x="2.057cm" svg:y="1.743cm" presentation:class="title">
<text:p text:style-name="P2">Title</text:p>
</draw:text-box>
<draw:text-box presentation:style-name="pr5"
draw:text-style-name="P4" draw:layer="layout"
svg:width="11.668cm" svg:height="13.231cm"
svg:x="2.057cm" svg:y="5.838cm" presentation:class="outline">
<text:unordered-list text:style-name="L3">
<text:list-item>
<text:p text:style-name="P4">Left outline</text:p>
</text:list-item>
</text:unordered-list>
</draw:text-box>
<draw:text-box presentation:style-name="pr5"
draw:text-style-name="P4" draw:layer="layout"
svg:width="11.668cm" svg:height="13.231cm"
svg:x="14.308cm" svg:y="5.838cm" presentation:class="outline">
<text:unordered-list text:style-name="L3">
<text:list-item>
<text:p text:style-name="P4">Right outline</text:p>
</text:list-item>
</text:unordered-list>
</draw:text-box>
Clip art is represented by a <draw:image> element, with attributes exactly as described in the section called “Body Information for Images in Text”. Embedded spreadsheets and charts are represented by a <draw:object> element. Images and objects have these attributes in common:
Example 7.3, “Clip Art and Spreadsheet in a Presentation” shows the XML for clip art and an embedded spreadsheet.
Example 7.3. Clip Art and Spreadsheet in a Presentation
<draw:image presentation:class="graphic" xlink:href="#Pictures/1000000000000113000001136CE39527.jpg" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad" draw:style-name="gr3" draw:text-style-name="P3" draw:layer="layout" svg:width="11.668cm" svg:height="11.668cm" svg:x="14.307cm" svg:y="6.618cm"/> <draw:object presentation:class="table" xlink:href="#./Object 1" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad" draw:name="Object 1" draw:style-name="standard" draw:layer="layout" svg:width="23.911cm" svg:height="13.23cm" svg:x="2.057cm" svg:y="5.838cm"/>
Finally, each slide can have notes which are represented by a <presentation:notes> element with two children. The <draw:thumbnail> child element gives the size and position of the slide thumbnail, and has a presentation:class of page. The draw:page-number attribute tells which slide should be thumbnailed. The following <draw:text-box> element contains (naturally enough) the notes for the slide, and has a presentation:class of notes. Example 7.4, “Presentation Notes” shows the relevant XML.
Example 7.4. Presentation Notes
<presentation:notes>
<draw:page-thumbnail presentation:class="page"
draw:page-number="6"
draw:style-name="gr1" draw:layer="layout"
svg:width="12.768cm" svg:height="9.576cm"
svg:x="4.411cm" svg:y="2.794cm"/>
<draw:text-box presentation:class="notes"
presentation:style-name="pr1"
draw:text-style-name="P1" draw:layer="layout"
svg:width="15.021cm" svg:height="10.63cm"
svg:x="3.292cm" svg:y="13.299cm">
<text:p text:style-name="P1">Take note of this slide.</text:p>
</draw:text-box>
</presentation:notes>
To insert animated text into a slide, set the following attributes in the <draw:text-box>’s controlling style:
Transitions from one slide to the next are controlled by attributes in the draw:style-name given in that slide’s <draw:page> element. The slide’s draw:style-name will refer to a <style:style> element with a style:family attribute of drawing-page.
If you are creating a slideshow of your own, the draw:style-name must have the form dpn, where n is an integer. Using just any old name as an identifier will not work.
The <style:style> element will contain a <style:properties> element that sets the presentation:transition-style and presentation:transition-speed attributes. The speed may be one of slow, medium, or fast. There are lots of transition styles. To make this list a bit more compact, we will use the abbreviation direction to mean that you may use left, right, top, or bottom.
To include a sound with a slide transition, you insert a <presentation:sound> element in the slide’s controlling <style:style>. The <presentation:sound> has an xlink:href whose value is the path to the sound file. Other attributes should be set as: xlink:type="simple", xlink:show="new", and xlink:actuate="onRequest".
If you wish to have a text box or a drawing object to respond to a mouse click, add code like this between the opening and closing tags of the object:
<office:events>
<presentation:event script:event-name="on-click"
presentation:action="action-to-perform"/>
</office:events>
The presentation:action attribute can have a value of none (the default), previous-page, next-page, first-page, last-page, hide (hides the object), fade-out (fade out this object), or stop (exits the slideshow). These values require no additional information.
The presentation:action values of show (display a specific slide), execute (run a program), and sound require extra information. Running a macro in response to a mouse click is done in an entirely different manner altogether, and, since we have not covered scripting in this book, we will not discuss that option. Example 7.5, “XML for Presentation Actions Requiring Extra Information” shows the XML for showing slides, running programs, and playing sounds in response to a mouse click. In this example, all the actions are connected with text boxes. The style attributes for the text boxes are not shown. In the code for playing a sound, note that the <presentation:sound> element becomes a child of the <presentation:event> element.
Example 7.5. XML for Presentation Actions Requiring Extra Information
<!-- Show a specific slide -->
<draw:text-box>
<office:events>
<presentation:event presentation:action="show"
script:event-name="on-click"
xlink:href="#page3" xlink:type="simple"
xlink:show="new" xlink:actuate="onRequest"/>
</office:events>
<text:p text:style-name="P2">SHOW<text:tab-stop/></text:p>
</draw:text-box>
<!-- Run a program -->
<draw:text-box>
<office:events>
<presentation:event script:event-name="on-click"
presentation:action="execute"
xlink:href="../../../../opt/kde3/bin/kcalc"
xlink:type="simple" xlink:show="new"
xlink:actuate="onRequest"/>
</office:events>
<text:p text:style-name="P2">RUN PROGRAM</text:p>
</draw:text-box>
<!-- Play a sound -->
<draw:text-box>
<office:events>
<presentation:event presentation:action="sound"
script:event-name="on-click" >
<presentation:sound
xlink:href="../../snd/music.wav"
xlink:type="simple" xlink:show="new"
xlink:actuate="onRequest"/>
</presentation:event>
</office:events>
<text:p text:style-name="P2">SOUND</text:p>
</draw:text-box>
In this case study, we will use Perl to create (literally) a slide show from a series of photographs such as one might take on vacation.[14] The input file is a simple text file consisting of alternating file names and descriptions:
dscn0134_a.jpg Rubies at Smithsonian Institution dscn0157_a.jpg Mt. Rushmore dscn0181_a.jpg Devil's Tower National Monument dscn0210_a.jpg Buffalo at Yellowstone dscn0242_a.jpg Old Faithful dscn0274_a.jpg Grand Teton dscn0329_a.jpg Baby Llama
Our slide show will place the description at the top of the page and the picture beneath it. We will have “Next” and “Back” buttons at the bottom of each slide, with the exception of the first and last slides, which won’t let you fall off the edge of the earth. We will also have transitions for the slides; they will move onto the screen from the left.
The program starts off with variable declarations, and grabs two arguments from the command line: the file name containing the picture list, and an output file name.
#!/usr/bin/perl
use strict;
use warnings;
use Archive::Zip;
use File::Spec;
my $file_name; # file name to insert in slide show
my $description; # description of the slide
my ($width, $height); # height and width of a picture
my $left_edge; # where left edge of picture begins
my $archive; # zip archive
my $content_filename; # name of content file
my $styles_filename; # name of styles file
my @piclist; # stores picture file names and descriptions
my $i; # ubiquitous loop counter
my $slide_number; # current slide number
#
# This program requires two arguments: the picture list
# and the output file name.
if (scalar @ARGV != 2)
{
print "Usage: $0 picturelist outputFilename\n";
exit;
}
Because we don’t know how many pictures there are a priori, and we need to do something special on the last picture, we will have to read all the picture names and descriptions into an array for future use:
# Read the picture file names and their descriptions
# into an array.
#
open INFILE, "<$ARGV[0]" or die("Cannot find file $ARGV[0]");
while (<INFILE>)
{
chomp;
next if (m/^\s*$/); # skip blank lines
push @piclist, $_;
}
close INFILE;
The code continues by setting up a new .ZIP archive and adding the subdirectory for the images. We call File::Spec->tmpdir() to provide a temporary directory for storing the styles.xml and content.xml that we will be creating. Because the content of the styles.xml file is constant, we are putting that task in a separate subroutine named create_styles_file.
#
# Create a .ZIP archive
#
$archive = Archive::Zip->new( );
#
# Add a directory for the images
#
$archive->addDirectory( "Pictures" );
# create a temporary file for styles,
# create the styles.xml file, and
# add it to the archive.
#
$styles_filename = File::Spec->catfile(File::Spec->tmpdir(),
"styles.xml");
open STYLESFILE, ">$styles_filename" or
die("Cannot open $styles_filename");
create_styles_file( );
close STYLESFILE;
$archive->addFile( $styles_filename , "styles.xml" );
We now create the main part of the content file.
# create a temporary file for content
#
$content_filename = File::Spec->catfile(File::Spec->tmpdir(),
"content.xml");
open CONTENTFILE, ">$content_filename" or
die("Cannot open $content_filename");
insert_header();
for ($i=0; $i < @piclist; $i += 2)
{
$slide_number = ($i / 2) + 1;
($file_name, $description) = @piclist[$i,$i+1];
($width, $height) = get_jpg_dimensions($file_name);
# Presume that pictures are 72 dpi; convert width & height
# to centimeters.
$width = ($width / 72) * 2.54;
$height = ($height / 72) * 2.54;
$left_edge = (27.94-$width) / 2;
$archive->addFile( $file_name, "Pictures/$file_name");
print CONTENTFILE << "ONE_PAGE";
<draw:page draw:name="page$slide_number" draw:id="$slide_number"
draw:master-page-name="PM1" draw:style-name="dp1"
presentation:presentation-page-layout-name="slidepage">
<draw:text-box draw:layer="layout" presentation:class="title"
draw:style-name="standard"
svg:x="4.5cm" svg:y="2.25cm"
svg:width="20cm" svg:height="2cm">
<text:p text:style-name="P1">$description</text:p>
</draw:text-box>
<draw:image presentation:class="graphic"
xlink:href="#Pictures/$file_name"
xlink:type="simple" xlink:show="embed"
xlink:actuate="onLoad"
draw:layer="layout"
svg:width="${width}cm" svg:height="${height}cm"
svg:x="${left_edge}cm" svg:y="4cm"/>
ONE_PAGE
if ($slide_number != 1)
{
insert_back_button();
}
if ($slide_number != int(@piclist/2))
{
insert_next_button();
}
print CONTENTFILE "</draw:page>\n";
}
insert_footer();
close CONTENTFILE;
$archive->addFile( $content_filename , "content.xml" );
$archive->overwriteAs( $ARGV[1] );
unlink $styles_filename;
unlink $content_filename;
The code to insert the next and back buttons shows the use of interaction:
sub insert_back_button
{
print CONTENTFILE << "BACK_BUTTON";
<draw:rect draw:layer="layout" draw:style-name="buttonstyle"
svg:x="2.2cm" svg:y="18.3cm" svg:width="2cm" svg:height="1cm">
<office:events>
<presentation:event script:event-name="on-click"
presentation:action="previous-page"/>
</office:events>
<text:p text:style-name="buttonpara">
<text:span text:style-name="buttontext">Back</text:span>
</text:p>
</draw:rect>
BACK_BUTTON
}
sub insert_next_button
{
print CONTENTFILE << "NEXT_BUTTON";
<draw:rect draw:layer="layout" draw:style-name="buttonstyle"
svg:x="24cm" svg:y="18.3cm" svg:width="2cm" svg:height="1cm">
<office:events>
<presentation:event script:event-name="on-click"
presentation:action="next-page"/>
</office:events>
<text:p text:style-name="buttonpara">
<text:span text:style-name="buttontext">Next</text:span>
</text:p>
</draw:rect>
NEXT_BUTTON
}
Here’s the code that inserts the heading material into the content.xml file. Note the presentation:transition-style in the <style:style> named dp1.
sub insert_header
{
print CONTENTFILE <<"HEADER";
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE office:document-content
PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN"
"office.dtd">
<office:document-content
xmlns:office="http://openoffice.org/2000/office"
xmlns:style="http://openoffice.org/2000/style"
xmlns:text="http://openoffice.org/2000/text"
xmlns:table="http://openoffice.org/2000/table"
xmlns:draw="http://openoffice.org/2000/drawing"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:number="http://openoffice.org/2000/datastyle"
xmlns:presentation="http://openoffice.org/2000/presentation"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:form="http://openoffice.org/2000/form"
xmlns:script="http://openoffice.org/2000/script"
office:class="presentation" office:version="1.0">
<office:script/>
<office:automatic-styles>
<style:style style:name="dp1" style:family="drawing-page">
<style:properties
presentation:transition-style="move-from-left"
presentation:transition-speed="medium"
presentation:background-visible="true"
presentation:background-objects-visible="true"/>
</style:style>
<style:style style:name="P1" style:family="paragraph">
<style:properties style:font-name="Helvetica"
fo:font-family="swiss" fo:font-size="24pt"
fo:text-align="center"/>
</style:style>
<style:style style:name="buttonstyle" style:family="graphics">
<style:properties
draw:stroke="solid"
svg:stroke-width="0.05cm"
svg:stroke-color="#cccccc"
draw:fill="solid" draw:fill-color="#ffffcc"/>
</style:style>
<style:style style:name="buttonpara" style:family="paragraph">
<style:properties
style:font-name="Helvetica"
fo:font-family="swiss" fo:font-size="10pt"
fo:text-align="center"/>
</style:style>
<style:style style:name="buttontext" style:family="text">
<style:properties
style:font-name="Helvetica"
fo:font-family="swiss" fo:font-size="10pt"
fo:text-align="center"/>
</style:style>
</office:automatic-styles>
<office:body>
HEADER
}
sub insert_footer
{
print CONTENTFILE <<"FOOTER";
</office:body>
</office:document-content>
FOOTER
}
Finally, we have the code to create the information in the styles.xml file. It is pure boilerplate, adapted from an existing presentation file, with lots of unnecessary information removed.
sub create_styles_file
{
print STYLESFILE << "STYLES";
<office:document-styles
xmlns:office="http://openoffice.org/2000/office"
xmlns:style="http://openoffice.org/2000/style"
xmlns:text="http://openoffice.org/2000/text"
xmlns:table="http://openoffice.org/2000/table"
xmlns:draw="http://openoffice.org/2000/drawing"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:number="http://openoffice.org/2000/datastyle"
xmlns:presentation="http://openoffice.org/2000/presentation"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:chart="http://openoffice.org/2000/chart"
xmlns:dr3d="http://openoffice.org/2000/dr3d"
xmlns:script="http://openoffice.org/2000/script"
office:version="1.0">
<office:styles>
<style:presentation-page-layout style:name="slidepage">
<presentation:placeholder presentation:object="title"
svg:x="4.5cm" svg:y="2.25cm"
svg:width="20cm" svg:height="2cm"/>
<presentation:placeholder presentation:object="graphic"
svg:x="2cm" svg:y="5.5cm"
svg:width="20cm" svg:height="13cm"/>
</style:presentation-page-layout>
</office:styles>
<office:automatic-styles>
<style:page-master style:name="PM1">
<style:properties
fo:margin-top="1cm" fo:margin-bottom="1cm"
fo:margin-left="1cm" fo:margin-right="1cm"
fo:page-width="27.94cm" fo:page-height="21.59cm"
style:print-orientation="landscape"/>
</style:page-master>
</office:automatic-styles>
<office:master-styles>
<draw:layer-set>
<draw:layer draw:name="layout"/>
<draw:layer draw:name="background"/>
<draw:layer draw:name="backgroundobjects"/>
<draw:layer draw:name="controls"/>
<draw:layer draw:name="measurelines"/>
</draw:layer-set>
<style:master-page style:name="Default" style:page-master-name="PM1"
draw:style-name="dp1">
</style:master-page>
</office:master-styles>
</office:document-styles>
STYLES
}
We are omitting the get_jpg_dimensions code that gets the width and height of a JPEG; it is not relevant to OpenOffice.org. If you are interested in seeing it, just download it from the O’Reilly Web site.
[14] Thanks to my brother Steve, who provided photos from his vacation for the sample files that you may download.
Content licensed under a
Creative Commons
License.