Skip Menu |

This queue is for tickets about the OpenOffice-OODoc CPAN distribution.

Report information
The Basics
Id: 42939
Status: resolved
Priority: 0/
Queue: OpenOffice-OODoc

People
Owner: Nobody in particular
Requestors: FGOSLICH [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 2.107
Fixed in: (no value)



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
Download test.ods
application/octet-stream 27.5k

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";
Le Sam. Jan. 31 16:30:04 2009, FGOSLICH a écrit : Show quoted text
> [...] > Unfortunately it doesn't work. The command > $styles->getStyleElement($stylename); > returns 'undef'. I have the same problem with Rows and Cells of a table. > [...] > $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.
That looks right, though ! When a table is created through a text/spreadsheet editor such as OOo, the corresponding styles are generally created in the same time as automatic styles, so you can get them in the 'content' part and not in the 'style' part. As soon as a given style is an automatic style, its stored in the 'content' part of the ODF package. The 'styles' part contains the named styles only (i.e. the styles whose names are displayed through the style-definition dialog boxes in a typical text processor and which can be explicitly modified or created by the end user). See the Description paragraph in the beginning of the OpenOffice::OODoc::Styles, and in the style-related sections of OpenOffice::OODoc::Intro for details about the differences between automatic and named styles.