[prev in list] [next in list] [prev in thread] [next in thread] 

List:       koffice
Subject:    patch: KPresenter loading works
From:       Werner Trobin <wtrobin () mandrakesoft ! com>
Date:       2000-08-30 19:49:08
[Download RAW message or body]

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
["kpresenter.diff" (text/plain)]

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 <PIXMAPS> tags?
 $currentText="";
 $currentTextType=0;
 while (<INPUT>)
 {
   if (/<DOC/)
     {
+      # store the url because this is a prart of the "path" for the images
+      $url=$1 if(m/url=\"(.*)\"/);
       s/>$/ syntaxVersion=\"2\">/;
     }
+  elsif (/<PIXMAPS>/)
+    {
+      $insidePixmaps=1;
+    }
+  elsif (/<\/PIXMAPS>/)
+    {
+      $insidePixmaps=0;
+    }
   elsif (/<TEXTOBJ/)
     {
       # Save object type of the TEXTOBJ tag
@@ -115,6 +129,38 @@ while (<INPUT>)
 	    }
 	}
       $_=$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 (/<KEY(.*)\/>/)
+      {
+        # 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();



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic