I wanted to build an awesome place for people to discuss module specific issues, but I don't have any more time for this, and there are much better places to discuss Perl-related issues. I'd recommend asking your question on Stack Overflow or on Perl Monks.
If you are looking for a Perl tutorial or Perl-related news, I hope these links will serve you well.
Posted on 2011-02-03 13:25:23.637176-08 by joebury
Creating Styles for OOCalc through perl
I was trying to programmatically create some basic styles for OOCalc. While the styles are created correctly (they show in the Styles box in Calc) none of them has any required properties set (i.e. font face is always set to Arial rather than Times New Roman and there is no bold). What am I doing wrong? The example below shows several calls to styleCreate, none of which works.
#!/usr/bin/perl use strict; use warnings; use OpenOffice::OODoc; my $container = odfContainer( "aaa.ods", create => 'spreadsheet' ); my $doc = odfDocument( container => $container, part => 'content' ); my $styles = odfDocument( container => $container, part => 'styles' ); $doc->expandTable( 0, 40, 40 ); my $idx=0; printf "-- %s --\n", $styles->createStyle ( "style_$idx", "name" => "style_$idx", "family" => 'text', "properties" => { "fo:font-weight" => "bold", "style:font-name" => "Times New Roman", }, ); $idx += 1; printf "-- %s --\n", $styles->createStyle ( "style_$idx", "name" => "style_$idx", "family" => 'table-cell', "properties" => { "fo:font-weight" => "bold", "style:font-name" => "Times New Roman", }, ); $idx += 1; printf "-- %s --\n", $styles->createStyle ( "style_$idx", "name" => "style_$idx", "family" => 'table-cell', "properties" => { "text-properties" => { "fo:font-weight" => "bold", "style:font-name" => "Times New Roman", }, }, ); $idx += 1; printf "-- %s --\n", $styles->createStyle ( "style_$idx", "name" => "style_$idx", "family" => 'table-cell', "properties" => { "font-weight" => "bold", "font-name" => "Times New Roman", }, ); $idx += 1; printf "-- %s --\n", $styles->createStyle ( "style_$idx", "name" => "style_$idx", "family" => 'table-cell', "text-properties" => { "fo:font-weight" => "bold", "style:font-name" => "Times New Roman", }, ); $idx += 1; printf "-- %s --\n", $styles->createStyle ( "style_$idx", "name" => "style_$idx", "family" => 'table-cell', "text-properties" => { "font-weight" => "bold", "font-name" => "Times New Roman", }, ); $idx += 1; printf "-- %s --\n", $styles->createStyle ( "style_$idx", "name" => "style_$idx", "family" => 'table-cell', "style:text-properties" => { "fo:font-weight" => "bold", "style:font-name" => "Times New Roman", }, ); $idx += 1; printf "-- %s --\n", $styles->createStyle ( "style_$idx", "name" => "style_$idx", "family" => 'table-cell', "style:text-properties" => { "font-weight" => "bold", "font-name" => "Times New Roman", }, ); for ( 0 .. $idx ) { my $cell; $cell = $doc->getTableCell(0, 0, $_ ); $doc->updateCell( $cell, "style_$_" ); $doc->style( $cell, "style_$_" ); } $container->save();
Direct Responses: 13186 | Write a response