codeacrobat has asked for the wisdom of the Perl Monks concerning the following question:

Hello monks, I am doing some OpenOffice automation. For ages I am trying to find the right permutation of style definitions that give me an Impress document with one textbox containing "hello world" with font size 36. Can anyone point me to the right definition? Also I would be happy about some links to real life examples for OpenOffice::OODoc. This is what I tried so far. I figured out that somehow you need a style for the textbox and a separate style for the text itself.
use OpenOffice::OODoc; my $document = ooDocument( file => 'outputfile.odp', create => 'presentation' ); $document->createStyle( "TB", family => "paragraph", parent => "objectwithshadow", properties => { 'style:vertical-pos' => 'from-top', 'style:horizontal-pos' => 'from-left', 'style:vertical-rel' => 'page', 'style:horizontal-rel' => 'page', 'style:font-size' => '36pt', 'style:font-weight' => 'bold', } ); $document->createStyle ( "Colour", family => 'paragraph', parent => 'Standard', properties => { 'fo:margin-left' => '2cm', 'fo:margin-right' => '1.5cm', 'fo:text-align' => 'justify', 'fo:background-color' => '#ff00ff' 'fo:font-size' => '36pt', } ); $para = $document->createParagraph( "hello world", "Colour" ); $slide = $document->getDrawPage(0); $document->createTextBox( attachment => $slide, size => '10cm, 10cm', position => '4cm,4cm', content => $para, style => 'TB', ); $document->save;
*Solved*
OpenOffice::OODoc::Styles says the following on createStyle:

We could provide this new style with additional properties related to the text content of the paragraph. But, in a paragraph style definition, the "text" properties are not stored in the same logical area than the "paragraph" properties, and we can't set both in the same instruction. Fortunately, we can enrich any existing style at any time through the updateStyle() method

It has to be splitted into two statements. I just tested something similar successfully.
$document->createStyle ( "Colour", family => 'paragraph', parent => 'Standard' ); $document->updateStyle( "Colour", family => 'paragraph', parent => 'Standard', properties => { 'fo:margin-left' => '2cm', 'fo:margin-right' => '1.5cm', 'fo:text-align' => 'justify', 'fo:background-color' => '#ff00ff' 'fo:font-size' => '36pt', } );

print+qq(\L@{[ref\&@]}@{['@'x7^'!#2/"!4']});

Replies are listed 'Best First'.
Re: OpenOffice::OODoc howto set size for textboxes
by Anonymous Monk on Jun 05, 2009 at 15:28 UTC
    TB style family needs to be
    family => "graphic",

    For height not ignore need

    properties => {'draw:auto-grow-height' => "false"},
      Thank you for the advice. However I am still clueless how to scale the fontsize of text inside the textbox. The Style seems to work for the fo:margin-left property, but not for colors and font sizes.

      print+qq(\L@{[ref\&@]}@{['@'x7^'!#2/"!4']});
        change in openoffice, unzip file, run style.xml through xml_pp, compare