Subject: | getStyleElement(<stylename>) doesn't work with Table, Row or Cell Styles |
Hi,
I tried to execute the following code:
use OpenOffice::OODoc;
my $content = odfDocument( file => 'test.ods', part => 'content');
my $styles = odfDocument( file => $content, part => 'styles');
my $table = $content->getTable(0);
my $stylename = $content->getStyle($table);
my $styleobjekt = $styles->getStyleElement($stylename);
my %styleproperties = $styles->styleProperties($styleobjekt);
print Dumper(\%styleproperties)."\n";
Unfortunately it doesn't work. The command
$styles->getStyleElement($stylename);
returns 'undef'. I have the same problem with Rows and Cells of a table.
To use the function 'tableStyle($table)', 'columnStyle($column)' or
'cellStyle($cell)' instead of 'getStyle()' doesn't change anything.
Haphazardly I found out, that the command
$content->getStyleElement($stylename);
works. I'm a bit confused therefor, because in all your manuals (perldoc
and perlreview-v3i1) you wrote, that I have to use the first command.
I attached you my testfiles. I hope, you can reproduce this error.
Greetings
Florian Goslich
Subject: | test2.pl |
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
use OpenOffice::OODoc;
my $content = odfDocument( file => 'test.ods', part => 'content');
#my $styles = $content;
my $styles = odfDocument( file => $content, part => 'styles');
print "################## Table #################\n\n";
my $table = $content->getTable(0);
my $stylename = $content->getStyle($table);
print $stylename."\n";
my $styleobjekt = $content->getStyleElement($stylename);
print $styleobjekt."\n";
my %styleproperties = $styles->styleProperties($styleobjekt);
print Dumper(\%styleproperties)."\n";
print "################## Row #################\n\n";
my $row = $content->getRow(0,1);
$stylename = $content->getStyle($row);
print $stylename."\n";
$styleobjekt = $content->getStyleElement($stylename);
print $styleobjekt."\n";
%styleproperties = $styles->styleProperties($styleobjekt);
print Dumper(\%styleproperties)."\n";
print "################## Column #################\n\n";
my $column = $content->getColumn(0,1);
print $column."\n";
$stylename = $content->getStyle($column);
print $stylename."\n";
$styleobjekt = $content->getStyleElement($stylename);
print $styleobjekt."\n";
%styleproperties = $styles->styleProperties($styleobjekt);
print Dumper(\%styleproperties)."\n";
print "################## Cell #################\n\n";
my $cell = $content->getCell(0,1,1);
$stylename = $content->getStyle($cell);
print $stylename."\n";
$styleobjekt = $content->getStyleElement($stylename);
print $styleobjekt."\n";
%styleproperties = $styles->styleProperties($styleobjekt);
print Dumper(\%styleproperties)."\n";
Subject: | test.ods |
Message body not shown because it is not plain text.
Subject: | test.pl |
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
use OpenOffice::OODoc;
my $content = odfDocument( file => 'test.ods', part => 'content');
#my $styles = $content;
my $styles = odfDocument( file => $content, part => 'styles');
print "################## Table #################\n\n";
my $table = $content->getTable(0);
my $stylename = $content->getStyle($table);
print $stylename."\n";
my $styleobjekt = $styles->getStyleElement($stylename);
print $styleobjekt."\n";
my %styleproperties = $styles->styleProperties($styleobjekt);
print Dumper(\%styleproperties)."\n";
print "################## Row #################\n\n";
my $row = $content->getRow(0,1);
$stylename = $content->getStyle($row);
print $stylename."\n";
$styleobjekt = $styles->getStyleElement($stylename);
print $styleobjekt."\n";
%styleproperties = $styles->styleProperties($styleobjekt);
print Dumper(\%styleproperties)."\n";
print "################## Column #################\n\n";
my $column = $content->getColumn(0,1);
print $column."\n";
$stylename = $content->getStyle($column);
print $stylename."\n";
$styleobjekt = $styles->getStyleElement($stylename);
print $styleobjekt."\n";
%styleproperties = $styles->styleProperties($styleobjekt);
print Dumper(\%styleproperties)."\n";
print "################## Cell #################\n\n";
my $cell = $content->getCell(0,1,1);
$stylename = $content->getStyle($cell);
print $stylename."\n";
$styleobjekt = $styles->getStyleElement($stylename);
print $styleobjekt."\n";
%styleproperties = $styles->styleProperties($styleobjekt);
print Dumper(\%styleproperties)."\n";