Subject: | getElement does not work |
Date: | Tue, 19 Oct 2010 17:18:45 +0200 |
To: | bug-OpenOffice-OODoc [...] rt.cpan.org |
From: | Richard Limanowski <r.limanowski [...] nttcable.de> |
Hello,
I discovered, that the functionality of OpenOffice::OODoc::XPath
changed between versions 2.223 and 2.237 in the sense, that
a call to getElemet(), which returned a value in the earlier version
returns undef in the newer version.
Please find attached a small demo consisting of:
1. test.odt - small document containing macro library
2. test.pl - script to illustrate the problem
Call it like: perl -d test.pl test.od
I do not have much experience in using your library
and ran into problems while trying to move from debian etch
to squeeze.
The code aims at replacing/extending the library by a macro (attached)
allowing us to save back an OpenOffice-Document using vanila
apache with webdav module.
Reagrds,
--
Richard Limanowski
NTTCable GmbH
IT
Message body not shown because it is not plain text.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
<script:module xmlns:script="http://openoffice.org/2000/script" script:name="nttmacro" script:language="StarBasic">REM ***** BASIC *****
Sub NttOpenDocEvent
SaveWebDAV
DisableDesignMode
End Sub
Sub SaveWebDAV
Dim oDoc
Dim Dummy()
oDoc = ThisComponent
' If ! oDoc.hasLocation() then
' MsgBox("This is a new file so Save it in the normal manner. Quitting.")
' End
'EndIf
odoc.storeAsURL("<FILE_NAME>", Dummy())
'odoc.storeAsURL("file:///tmp/test123456.odt", Dummy())
End Sub
sub DisableDesignMode
rem ----------------------------------------------------------------------
rem Disables the design mode for the current document, allowing the user
rem to fill out formulares without manual disabling this mode.
rem Created with macro recorder...
rem ----------------------------------------------------------------------
rem
rem ----------------------------------------------------------------------
rem define variables
dim document as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
rem ----------------------------------------------------------------------
dim args1(0) as new com.sun.star.beans.PropertyValue
args1(0).Name = "SwitchControlDesignMode"
args1(0).Value = false
dispatcher.executeDispatch(document, ".uno:SwitchControlDesignMode", "", 0, args1())
end sub
</script:module>
#!/usr/bin/perl -w
use strict;
use OpenOffice::OODoc;
use OpenOffice::OODoc::XPath;
use Data::Dumper;
my $file = shift;
my $ofile = ooFile($file);
my $basic = OpenOffice::OODoc::XPath->new(
member => 'Basic/script-lc.xml',
element => 'library:libraries',
file => $ofile
);
my $elem = $basic->getElement('//library:libraries');
# this yields something when using
# our $VERSION = 2.223;
# use XML::Twig 3.22;
#
# but undef when using
# our $VERSION = '2.237';
# use XML::Twig 3.32;
# have to supply undocumented context parameter
$elem = $basic->getElement('//library:libraries', 0, $basic->{'xpath'});
print "why?\n";
exit(0);