--- abi/src/wp/impexp/xp/ie_imp_RTF.cpp 2005-06-09 04:35:33.016866968 +0100 +++ abi/src/wp/impexp/xp/ie_imp_RTF.cpp-TARGET-BYTEBUF 2005-06-09 04:33:31.187387864 +0100 @@ -7940,7 +7930,7 @@ int codepage = 0; unsigned char panose[10]; memset(panose, 0, sizeof(unsigned char)); - UT_String sFontNames[2]; // Font name and alternative font name + UT_ByteBuf RawFontNames[2]; // Font name and alternative font name RTFTokenType tokenType; //TODO - this should be intialized once for the whole RTF reader. @@ -8013,7 +8003,7 @@ // Data indicates the start of the font name. case RTF_TOKEN_DATA: SkipBackChar(keyword[0]); // Data can only be one byte, right? - if (!ReadFontName(sFontNames)) + if (!ReadFontName(RawFontNames)) return false; break; case RTF_TOKEN_KEYWORD: @@ -8071,7 +8061,7 @@ if (strcmp(reinterpret_cast(&keyword[0]),"'") == 0) { SkipBackChar('\''); SkipBackChar('\\'); - if (!ReadFontName(sFontNames)) + if (!ReadFontName(RawFontNames)) return false; } break; @@ -8081,13 +8071,6 @@ } } -#ifndef XP_TARGET_COCOA - /*work around "helvetica" font name -replace it with "Helvetic"*/ - if (sFontNames[0] == "helvetica") - { - sFontNames[0] = "Helvetica"; - } -#endif /* ! XP_TARGET_COCOA */ // Clone/convert the font name and the alternative font name. If none was // specified in the font entry then we want to pass NULL to @@ -8096,13 +8079,15 @@ for (UT_sint32 i=0; i<2; i++) { fn[i] = NULL; - if (sFontNames[i].length()) + if (RawFontNames[i].getLength()) { // If the document specified a character encoding then convert to UTF8. // If not then we just have to hope it was in ASCII/UTF8. if (m_szDefaultEncoding) { - fn[i] = UT_convert(sFontNames[i].c_str(),sFontNames[i].length(), + fn[i] = UT_convert(reinterpret_cast + (RawFontNames[i].getPointer(0)), + RawFontNames[i].getLength(), m_szDefaultEncoding, "UTF-8", NULL, NULL); } else @@ -8110,7 +8095,9 @@ // UT_cloneString returns NULL in fn if the 2nd argument is zero // length or we ran out of memory. However, we known that // sFontName is not zero length so fn==NULL indicates OOM. - UT_cloneString(fn[i], sFontNames[i].c_str()); + UT_cloneString(fn[i], reinterpret_cast + (RawFontNames[i].getPointer(0))); + } // Catch errors. if (!fn[i]) @@ -8121,6 +8108,14 @@ } } } + +#ifndef XP_TARGET_COCOA + /*work around "helvetica" font name -replace it with "Helvetic"*/ + if (strcmp(fn[0], "helvetica") == 0) + { + fn[0][0] = 'H'; + } +#endif /* ! XP_TARGET_COCOA */ // Create the font entry and put it into the font table RTFFontTableItem* pNewFont = new RTFFontTableItem(fontFamily, charSet, @@ -8148,7 +8143,7 @@ else { UT_DEBUGMSG (("RTF: font %d (named %s) already defined. Ignoring\n", - fontIndex, sFontNames[0].c_str())); + fontIndex, RawFontNames[0].getPointer(0))); DELETEP (pNewFont); } @@ -8185,7 +8180,7 @@ bool bSkipping; // Are we skipping an unknown destination? }; -bool IE_Imp_RTF::ReadFontName(UT_String sFontNames[2]) +bool IE_Imp_RTF::ReadFontName(UT_ByteBuf RawFontNames[2]) { unsigned char keyword[MAX_KEYWORD_LEN]; RTFTokenType tokenType; @@ -8259,7 +8254,7 @@ } // Other data must be one of the font names, so write it to the // current font name pointer. - sFontNames[currentState->iFontNum] += keyword[0]; + RawFontNames[currentState->iFontNum].append(keyword, 1); break; case RTF_TOKEN_KEYWORD: // Are we skipping? @@ -8274,7 +8269,7 @@ // file. Also, escaped hex can only be one byte so the // UT_UCS4Char return type doesn't make much sense. ch = static_cast(ReadHexChar()); - sFontNames[currentState->iFontNum] += ch; + RawFontNames[currentState->iFontNum].append(&ch, 1); break; // Break out after handling keyword. } // Handle the "*" keyword. --- abi/src/wp/impexp/xp/ie_imp_RTF.h 2005-06-09 04:35:33.717760416 +0100 +++ abi/src/wp/impexp/xp/.#ie_imp_RTF.h.1.139 2005-06-07 14:30:43.000000000 +0100 @@ -612,7 +612,7 @@ bool ReadColourTable(); bool ReadFontTable(); bool ReadOneFontFromTable(bool bNested); - bool ReadFontName(UT_String sFontNames[2]); + bool ReadFontName(UT_ByteBuf RawFontNames[2]); bool ReadRevisionTable(); void setEncoding(); public: