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

List:       koffice-devel
Subject:    Patch for KWord RTF import bug
From:       Tommi Rantala <tommi.rantala () cs ! helsinki ! fi>
Date:       2005-11-28 10:41:14
Message-ID: 200511281241.14497.tommi.rantala () cs ! helsinki ! fi
[Download RAW message or body]

Hi,

The KWord RTF import filter has some problems with hex values (e.g. \'2d), it 
skips some bytes and can eat for example commands right after the hex value. 
Here's a small patch that should fix this bug.

For example my OOo generates \u8226\'2d\tab for list items:

http://www.saunalahti.fi/~rantala/misc/rtf/before.png
http://www.saunalahti.fi/~rantala/misc/rtf/after.png

Comments?

-- 
Tommi Rantala

["rtf.patch" (text/x-diff)]

Index: rtfimport_tokenizer.cpp
===================================================================
--- rtfimport_tokenizer.cpp	(revision 483824)
+++ rtfimport_tokenizer.cpp	(working copy)
@@ -2,6 +2,7 @@
    This file is part of the KDE project
    Copyright (C) 2001 Ewald Snel <ewald@rambo.its.tudelft.nl>
    Copyright (C) 2001 Tomasz Grobelny <grotk@poczta.onet.pl>
+   Copyright (C) 2005 Tommi Rantala <tommi.rantala@cs.helsinki.fi>
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
@@ -169,31 +170,29 @@ void RTFTokenizer::next()
 	}
 	else if (ch=='\'')
 	{
+	    // Got hex value, for example \'2d
+
 	    type = RTFTokenizer::ControlWord;
 	    *_text++ = ch;
 
-            int n = nextChar();
-
-            if ( n <= 0 ) {
-                type = RTFTokenizer::CloseGroup;
-                return;
-            }
-	    ch = *fileBufferPtr++;
 	    for(int i=0;i<2;i++)
 	    {
+		if ( nextChar() <= 0 ) {
+		    if ( i == 0 ) {
+		        type = RTFTokenizer::CloseGroup;
+		        return;
+		    } else {
+                        ch = ' ';
+			break;
+		    }
+		}
+
+		ch = *fileBufferPtr;
+
 		hasParam = true;
 		value<<=4;
 		value=value|((ch + ((ch & 16) ? 0 : 9)) & 0xf);
-
-                int n = nextChar();
-
-                if ( n <= 0 ) {
-                    ch = ' ';
-                    break;
-                }
-		ch = *fileBufferPtr++;
 	    }
-            --fileBufferPtr;
         }
 	else
 	{


_______________________________________________
koffice-devel mailing list
koffice-devel@kde.org
https://mail.kde.org/mailman/listinfo/koffice-devel


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

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