Index: src/wp/impexp/xp/ie_imp_RTF.cpp =================================================================== RCS file: /cvsroot/abi/src/wp/impexp/xp/ie_imp_RTF.cpp,v retrieving revision 1.24 diff -u -r1.24 ie_imp_RTF.cpp --- src/wp/impexp/xp/ie_imp_RTF.cpp 2000/03/28 20:22:23 1.24 +++ src/wp/impexp/xp/ie_imp_RTF.cpp 2000/04/19 05:10:57 @@ -1262,6 +1262,31 @@ } } +// Assuming you've just read a '{' (indicating that a block just started), +// but you don't want to deal with it, just call SkipBlock to skip over it. +UT_Bool IE_Imp_RTF::SkipBlock() +{ + unsigned int depth = 0; + unsigned char ch; + if(!ReadCharFromFile(&ch)) + return UT_FALSE; + while(depth > 0 || ch != '}') + { + if(ch == '{') + depth++; + if(ch == '{') + depth++; + else if(ch == '}') + { + UT_ASSERT(depth > 0); // Uh oh, more } than { + depth--; + } + if(!ReadCharFromFile(&ch)) + return UT_FALSE; + } + return UT_TRUE; +} + ////////////////////////////////////////////////////////////////////////////// // Font table reader @@ -1327,6 +1352,7 @@ unsigned char ch; long parameter = 0; UT_Bool paramUsed = UT_FALSE; + unsigned int depth = 0; // run though the item reading in these values RTFFontTableItem::FontFamilyEnum fontFamily = RTFFontTableItem::ffNone; @@ -1383,12 +1409,16 @@ } // Now (possibly) comes some optional keyword before the fontname + // There may be a subblock before the font name. Right now just + // ignore the block marks and look for interesting keywords. + // TODO: properly handle subblocks. if (!ReadCharFromFile(&ch)) return UT_FALSE; while (ch == '\\' || ch == '{') { if (ch == '{') { + depth++; if (!ReadCharFromFile(&ch)) return UT_FALSE; } @@ -1427,17 +1457,35 @@ if (!ReadCharFromFile(&ch)) return UT_FALSE; + + while (ch == '}') + { + UT_ASSERT(depth > 0); // Too many closing blocks + depth--; + if (!ReadCharFromFile(&ch)) + return UT_FALSE; + } } - // Now comes the font name, terminated by either a close brace or a slash or a semi-colon + // Now comes the font name, terminated by either a close brace or a slash + // or a semi-colon or an open brace int count = 0; - while ( ch != '}' && ch != '\\' && ch != ';' ) + while ( ch != '}' && ch != '\\' && ch != ';' && ch != '{') { keyword[count++] = ch; if (!ReadCharFromFile(&ch)) return UT_FALSE; } keyword[count] = 0; + + if(ch == '{') + { + // There is another block after the font name. For now, it gets + // skipped. TODO parse it, since it may hold a \falt keyword + // specifying an alternative font name. + if(!SkipBlock()) + return UT_FALSE; + } if (!UT_cloneString(pFontName, (char*)keyword)) { Index: src/wp/impexp/xp/ie_imp_RTF.h =================================================================== RCS file: /cvsroot/abi/src/wp/impexp/xp/ie_imp_RTF.h,v retrieving revision 1.16 diff -u -r1.16 ie_imp_RTF.h --- src/wp/impexp/xp/ie_imp_RTF.h 2000/02/29 15:11:01 1.16 +++ src/wp/impexp/xp/ie_imp_RTF.h 2000/04/19 05:10:58 @@ -207,6 +207,7 @@ UT_Bool ReadColourTable(); UT_Bool ReadFontTable(); UT_Bool ReadOneFontFromTable(); + UT_Bool SkipBlock(); RTFFontTableItem* GetNthTableFont(UT_uint32 fontNum); UT_uint32 GetNthTableColour(UT_uint32 colNum);