Skip Menu |

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

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

People
Owner: Nobody in particular
Requestors: no_mayl [...] hotmail.com
Cc:
AdminCc:

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



Subject: File::save() sees two 'content' in $self->{'linked'} preventing changes to be saved
This is where the two contents show up in File.pm:680 sub save ... ... my %newmembers = (); foreach my $nm (@{$self->{'linked'}}) { $newmembers{$nm->{'member'}} = $nm->getXMLContent; } ... In my case, it would seem that when setText() is invoked on an element that was selected via a Text::selectElementsByContent() rather than via Document::selectElementsBytContent(), then the order of the two linked 'content' members is "happy", and the changes are saved. If I change only: - $docText->selectElementsByContent(".",\&Filter, $docText); + $doc->selectElementsByContent(".",\&Filter, $docText); then the 'content' members are swapped and the change is not saved. -- $ uname -a Linux jpabgrall 2.4.21-37.ELsmp #1 SMP Wed Sep 7 13:32:18 EDT 2005 x86_64 x86_64 x86_64 GNU/Linux $ perl --version This is perl, v5.8.7 built for x86_64-linux-thread-multi OpenOffice/OODoc/Document.pm:our $VERSION = 2.021; OpenOffice/OODoc/File.pm:our $VERSION = 2.111; OpenOffice/OODoc/Image.pm:our $VERSION = 2.015; OpenOffice/OODoc/Manifest.pm:our $VERSION = 2.003; OpenOffice/OODoc/Meta.pm:our $VERSION = 2.007; OpenOffice/OODoc/Styles.pm:our $VERSION = 2.015; OpenOffice/OODoc/Text.pm:our $VERSION = 2.218; OpenOffice/OODoc/XPath.pm:our $VERSION = 2.209; -- jpa
I did use something like: $ooFile = ooFile($file); $doc = ooDocument(file => $ooFile); $docText = ooText(file => $ooFile, use_delimiters => 'off'); $docXPath = ooStyles(file=> $ooFile); and then switched between methods of each of the $doc... Using only $doc = ooDocument(file => $file, use_delimiters => 'off'); works. -- jpa
Le Jeu. Fév. 23 12:31:14 2006, guest a écrit : Show quoted text
> I did use something like: > $ooFile = ooFile($file); > $doc = ooDocument(file => $ooFile); > $docText = ooText(file => $ooFile, use_delimiters => 'off'); > $docXPath = ooStyles(file=> $ooFile); > > and then switched between methods of each of the $doc... > > Using only > $doc = ooDocument(file => $file, use_delimiters => 'off'); > works. > -- > jpa
Hm... I'm not sure I've to see this kind behaviour as a bug. Using Text, Style and/or Document objects in the same session is not recommended (and it's probably useless), even if the documentation doesn't explicitly forbid that. Text and Style are integrated in the compound Document class, so Document (created with the appropriate member selector, i.e. "content" or "styles") should be used instead of Text and Styles. Text, Styles & XPath are low level classes whose main purpose is to be silently inherited by Document. But the main issue comes now: The default member which is selected when a Text, XPath or Document object is "content" (i.e. the "content.xml" member of the file). So, in the example above, the same member, i.e. the "content" member of a single file, is used by three connectors. As a consequence, the same XML content is parsed and loaded in three separate data structures in memory. When the save() method is called, all these data structures are successively saved to the same physical member (content) of the OOo file... and, of course, the last one wins and the changes done in the other instances are lost. Instantiating more than one connector against the same member of the same file can work for read-only operations. But it should *NEVER* be used in read-write programs.
From: no_mayl [...] hotmail.com
On Sat Feb 25 12:50:58 2006, JMGDOC wrote: Show quoted text
> Instantiating more than one connector against the same member of the > same file can work for read-only operations. But it should *NEVER* be > used in read-write programs.
Ahhh. I was wrongly assuming they would detect the pre-opened $file, and hookup to the a single instance of the members... Maybe have that paragraph in OODoc::Intro for people like me, who think they can get away with only ::Text, and then pull in other stuff ;). bug is closeable. thx. -- jpa
Le Mar. Fév. 28 15:09:08 2006, guest wrote : Show quoted text
> > On Sat Feb 25 12:50:58 2006, JMGDOC wrote:
> > Instantiating more than one connector against the same member of the > > same file can work for read-only operations. But it should *NEVER* be > > used in read-write programs.
> > Ahhh. I was wrongly assuming they would detect the pre-opened $file, and > hookup to the a single instance of the members...
Multiple instances of document objects against the same content are not forbidden (and don't produce warnings) because such a practice could prove useful in read-only applications. Show quoted text
> > Maybe have that paragraph in OODoc::Intro for people like me, who think > they can get away with only ::Text, and then pull in other stuff ;).
The documentation is far from perfect about this topic; it could/should be improved in a future version. The use of ::Text only is not wrong! It avoids loading some pieces of code which could prove useless in very simple, text-focused applications. But the use of ::Text *and* ::Document in the same program should be avoided because it avoids nothing and it's a bit confusing. ::Document includes ::Text (and ::Image, and ::Styles, and ::XPath). Show quoted text
> > bug is closeable. > thx. > -- > jpa
Thank you !