patch - RTF import Bug fixed


Subject: patch - RTF import Bug fixed
From: Harald Fernengel (harry@bnro.de)
Date: Tue Feb 15 2000 - 14:41:28 CST


Hello,

Wow - my first patch. Please tell me if I have done something wrong.

Here we go... The RTF importer ignores CR and LF as keyword
separator. This works fine for Word, but StarOffice's RTF will fail
in certain conditions. I created a patch for ie_imp_RTF.cpp and
ie_imp_RTF.h to handle CR and LF as keyword separator. DIFF2.TXT is
for the .cpp, DIFF.TXT for the .h. I tested it and it compiles fine
without warnings on my machine.

Btw, what do I have to do to get direct CVS access....?

Harry

Index: ie_imp_RTF.cpp
===================================================================
RCS file: /cvsroot/abi/src/wp/impexp/xp/ie_imp_RTF.cpp,v
retrieving revision 1.21
diff -r1.21 ie_imp_RTF.cpp
547c547
< if (!ReadCharFromFile(&ch))

---
> 	if (!ReadCharFromFileWithCRLF(&ch))
563c563
< 		if (!ReadCharFromFile(&ch))
---
> 		if (!ReadCharFromFileWithCRLF(&ch))
572c572
< 		if (!ReadCharFromFile(&ch))
---
> 		if (!ReadCharFromFileWithCRLF(&ch))
583c583
< 			if (!ReadCharFromFile(&ch))
---
> 			if (!ReadCharFromFileWithCRLF(&ch))
593,594c593,594
< 	// If the delimeter was non-space then this character is part of the following text!
< 	if (ch != ' ')
---
> 	// If the delimeter was non-whitespace then this character is part of the following text!
> 	if ((ch != ' ') && (ch != 10) && (ch != 13))
603c603,604
< UT_Bool IE_Imp_RTF::ReadCharFromFile(unsigned char* pCh)
---
> // Reads a character from the file. Doesn't ignore CR and LF
> UT_Bool IE_Imp_RTF::ReadCharFromFileWithCRLF(unsigned char* pCh)
604a606,608
> 	
> 	UT_Bool ok = UT_FALSE;
> 
607c611
< 		while (fread(pCh, 1, sizeof(unsigned char), m_pImportFile) > 0)
---
> 		if (fread(pCh, 1, sizeof(unsigned char), m_pImportFile) > 0)
609,616c613,614
< 			// line feed and cr should be ignored in RTF files
< 			if (*pCh != 10  &&  *pCh != 13)
< 			{
< 				return UT_TRUE;
< 			}
< 		}
< 
< 		return UT_FALSE;
---
> 			ok = UT_TRUE;
> 		}		
620c618
< 		while (m_pCurrentCharInPasteBuffer < m_pPasteBuffer+m_lenPasteBuffer)
---
> 		if (m_pCurrentCharInPasteBuffer < m_pPasteBuffer+m_lenPasteBuffer)
623,628c621
< 			
< 			// line feed and cr should be ignored in RTF files
< 			if (*pCh != 10  &&  *pCh != 13)
< 			{
< 				return UT_TRUE;
< 			}
---
> 			ok = UT_TRUE;
630,631d622
< 
< 		return UT_FALSE;
632a624,640
> 
> 	return ok;
> }
> 
> // Reads a character from the file ignoring CR and LF
> UT_Bool IE_Imp_RTF::ReadCharFromFile(unsigned char* pCh)
> {
> 	// line feed and cr should be ignored in RTF files
> 	do
> 	{
> 		if (ReadCharFromFileWithCRLF(pCh) == UT_FALSE) {
> 			return UT_FALSE;
> 		}
> 	} while (*pCh == 10  ||  *pCh == 13);
> 	
> 	return UT_TRUE;
> 
1690a1699,1701
> 
> 
> 

Index: ie_imp_RTF.h =================================================================== RCS file: /cvsroot/abi/src/wp/impexp/xp/ie_imp_RTF.h,v retrieving revision 1.14 diff -r1.14 ie_imp_RTF.h 200a201 > UT_Bool ReadCharFromFileWithCRLF(unsigned char* pCh); 264a266 >



This archive was generated by hypermail 2b25 : Tue Feb 15 2000 - 14:38:03 CST