harryC has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks How do i get text from a frame and ad text into a frame with OpenOffice::OODoc I started with a code to select te frame by name but got errors
use strict; use OpenOffice::OODoc; use OpenOffice::OODoc::Meta; use OpenOffice::OODoc::XPath ; use OpenOffice::OODoc::Image; &test; sub test { my $doc = ooDocument(file => "C:\\macros\\OOSjablonen\\test.odt") ; my $element = getFrameElement('frame_name'); print "el: $element text:\n"; }
gives error: Undefined subroutine &main::getFrameElement called at C:\scripts\test1.pl line 10. what is wrong ?
use strict; use OpenOffice::OODoc; use OpenOffice::OODoc::Meta; use OpenOffice::OODoc::XPath ; use OpenOffice::OODoc::Image; &test; sub test { my $doc = ooDocument(file => "C:\\macros\\OOSjablonen\\test.odt") ; my $element = OpenOffice::OODoc::XPath::getFrameElement('frame_name'); print "el: $element text:\n"; }
gives: Use of uninitialized value $element in concatenation (.) or string at C:\scripts\test1.pl line 11.
This is correct because i do not give a certain two values to the subroutine getFrameElement
i need to give someting like $self ?
sub getFrameElement { my $self = shift; my $frame = shift; return undef unless defined $frame; my $tag = shift || 'draw:frame'; my $element = undef; if (ref $frame) { $element = $frame; } else { if ($frame =~ /^[\-0-9]*$/) { return $self->getElement("//$tag", $frame, @_); } else { return $self->selectFrameElementByName ($frame, $tag, @_); } } }
thks for giving me a answer

Replies are listed 'Best First'.
Re: OpenOffice::OODoc I need to add text into a frame
by harryC (Sexton) on Jul 28, 2010 at 15:08 UTC
    sorry found the error myself
    this is the correct code
    use strict; use OpenOffice::OODoc; use OpenOffice::OODoc::Meta; use OpenOffice::OODoc::XPath ; use OpenOffice::OODoc::Image; &test; sub test { my $doc = ooDocument(file => "C:\\macros\\OOSjablonen\\test.odt") ; my $element = $doc -> getFrameElement('frame_name'); print "el: $element text:\n"; }