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 2010-04-15 11:24:36.75115-07 by tbrowder
How Does One Determine the Type of an OODoc?
I have looked at the OODocs but haven't yet found a definitive way to determine the type of a document. I specifically need to know if it is a spreadsheet. Does anyone have a solution? Merci beaucoup. -Tom
Direct Responses: 12639 | 12640 | Write a response
Posted on 2010-04-15 12:20:04.459129-07 by jmgdoc in response to 12638
Re: How Does One Determine the Type of an OODoc?

There are at least two ways, depending on the related object and the current situation.

If we got an ODF container (through the odfContainer constructor, representing the physical file), we can retrieve the mimetype using the extract method. For example, assuming that $filename represents the path of a text (odt) document, the following code should return "application/vnd.oasis.opendocument.text", that is the full mime type of an ODF text document (the last part of the mimetype string changes according to the ODF document type):
my $container = odfContainer($filename); my $mimetype = $container->extract("mimetype");

If we start from a document content object (initialized through odfDocument), we have the contentClass() method that returns "text", "spreadsheet", etc, according to the document class (caution: that works with the "content" part only, not with other parts such as "styles", "settings" or "meta"):
my $doc = odfDocument(file => $filename, part => "content"); my $doc_type = $doc->contentClass;
Direct Responses: Write a response
Posted on 2010-04-15 13:13:03.698863-07 by tbrowder in response to 12638
Re: How Does One Determine the Type of an OODoc?

Aha, I believe I've found the answer:


my $typ = $doc->getElement('//office:spreadsheet'); die "File '$infil' is not a spreadsheet type.\n" if !defined $typ;

-Tom
Direct Responses: 12641 | Write a response
Posted on 2010-04-15 13:20:24.728954-07 by tbrowder in response to 12640
Re: How Does One Determine the Type of an OODoc?

Sorry I jumped the gun--I didn't see your response while I was experimenting. My solution I got from doing a Dumper on the doc object and looking at it. Then I looked at the content.xml. My test document was generated from oocalc.


Thank you for a wonderful set of modules! I look forward to using them extensively for a project I'm working on, and I'm sure I will be asking more questions.


Warmest regards,
-Tom
Direct Responses: Write a response