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 2012-08-22 01:36:23.503333-07 by haacee
getStyleElement returns undef but createStyle fails with exists
Hi all,

though using the OODoc already for quite a while this is my first post here.

I run into an issue when creating styles.
I have an application that needs to write certain elements into an .odt.
The elements are (in some form) stored in a database. The output document may or may not have any content when my application is used.
Therefor I cannot be sure that the output document has all the styles that I need. I try to determine this with the following routine (getStylesRef() is refers to the ::Styles and getContentRef to the ::Text):
my %styleStore = (); sub getStyleElement { if (not exists ($styleStore{$styleName})) { $styleStore{$styleName} = $self->getStylesRef()->getStyleElement($styleName); } if (not defined $styleStore{$styleName}) { $styleStore{$styleName} = $self->getContentRef()->getStyleElement($styleName); } if (not defined ($styleStore{$styleName}) { $styleStore{$styleName} = $self->getStylesRef()->createStyle($styleName, #category => 'named', #namespace => ..., #type => ..., family => "paragraph", #class => ..., check => 'true', parent => $self->getStyleElement('SomeParentStyle'), next => $self->getStyleElement('SomeNextStyle'), properties => { 'fo:margin-top' => "0mm", 'fo:margin-bottom' => "0mm", 'fo:font-style' => "italic" }); } }
of course the real application will use some more logic to determine what the new style should look like.
When I execute this piece of code I get an error "[OpenOffice::OODoc::Styles::createStyle] Style MyStyle exists"

I use this same routine for both paragraph style as for list-styles. In the case of failure the style is a list-style.

Can anyone tell me why getStyleElement returns undef though the style does exist?
Direct Responses: Write a response