From koffice Wed Aug 30 19:49:08 2000 From: Werner Trobin Date: Wed, 30 Aug 2000 19:49:08 +0000 To: koffice Subject: patch: KPresenter loading works X-MARC-Message: https://marc.info/?l=koffice&m=96766501126239 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--------------C0B27ABB75AB7731F375C165" This is a multi-part message in MIME format. --------------C0B27ABB75AB7731F375C165 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Hi! With this patch (I included the kprconverter.pl patch again because I'm CCing it to Cristian) KPresenter can finally read old files again. There are only minor glitches (i.e. it eats all the "not necessary" spaces. e.g. "fo o" -> "fo o") but the rest should work fine. Please report any problems you encounter. If it's possible please attach the file which breaks loading. Cristian: Please make sure to update the koffice dir because I already committed a few essential fixes today. --> May I commit? -- Werner Trobin - wtrobin@mandrakesoft.com --------------C0B27ABB75AB7731F375C165 Content-Type: text/plain; charset=us-ascii; name="kpresenter.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="kpresenter.diff" Index: kprconverter.pl =================================================================== RCS file: /home/kde/koffice/kpresenter/kprconverter.pl,v retrieving revision 1.5 diff -b -u -p -r1.5 kprconverter.pl --- kprconverter.pl 2000/08/29 13:20:03 1.5 +++ kprconverter.pl 2000/08/30 19:34:32 @@ -1,18 +1,32 @@ # converts a KPresenter document from the old format to the new one (v2) # due to the new text object + +use Time::Local; + open(INPUT, "<$ARGV[0]") || die "Cannot open $ARGV[0]"; open(OUTPUT, ">$ARGV[1]") || die "Cannot create $ARGV[1]"; $objType=""; $insideParag=0; $insideObj=0; +$insidePixmaps=0; # are we inside the tags? $currentText=""; $currentTextType=0; while () { if (/$/ syntaxVersion=\"2\">/; } + elsif (//) + { + $insidePixmaps=1; + } + elsif (/<\/PIXMAPS>/) + { + $insidePixmaps=0; + } elsif (/) } } $_=$toprint; + } + elsif ($insidePixmaps) + { + if(/\s+name=\"/) + { + # Aha - this file is not version 2 but was created as "proper" tgz storage... medieval times :) + print "Found a name attribute, no need to create one.\n"; + } + elsif (//) + { + # Okay - plain old kpresenter magic... + $key=$1; + # Note: The .*? is needed because it would be too greedy otherwise + $filename=$1 if($key =~ /filename=\"(.*?)\"/); + # Get the values - really straightforward + $year=$1 if($key =~ /year=\"(\d+)\"/); + $month=$1 if($key =~ /month=\"(\d+)\"/); + $day=$1 if($key =~ /day=\"(\d+)\"/); + $hour=$1 if($key =~ /hour=\"(\d+)\"/); + $minute=$1 if($key =~ /minute=\"(\d+)\"/); + $second=$1 if($key =~ /second=\"(\d+)\"/); + # In Perl the month is <0...11>!!! + $timestamp=timegm($second, $minute, $hour, $day, $month-1, $year); + # Unfortunately we even have to mess with that string... + $timestring=scalar gmtime($timestamp); + # There are still some spaces too much when day<10 + $timestring =~ s/ / /; + # Okay. Now let's cat the whole caboodle... + $nameattrib=$url . $filename . "_" . $timestring; + # ...and put it in place. + s/\/>/ name=\"$nameattrib\" \/>/; + } } print OUTPUT $_; Index: kpresenter_doc.cc =================================================================== RCS file: /home/kde/koffice/kpresenter/kpresenter_doc.cc,v retrieving revision 1.235 diff -b -u -p -r1.235 kpresenter_doc.cc --- kpresenter_doc.cc 2000/08/28 16:24:27 1.235 +++ kpresenter_doc.cc 2000/08/30 19:34:56 @@ -1240,7 +1240,11 @@ bool KPresenterDoc::completeLoading( KoS if ( _store->open( u ) ) { KoStoreDevice dev(_store ); QImageIO io( &dev, 0 ); - io.read( ); + if(!io.read()) + // okay - has to be a funky - old xpm in a very old kpr file... + // Don't ask me why this is needed... + img=QImage(_store->read(_store->size())); + else img = io.image(); _store->close(); --------------C0B27ABB75AB7731F375C165--