From 35a897b248ca48583149dd2b26de63d68b9bfbbb Mon Sep 17 00:00:00 2001 From: Andy McFadden Date: Sat, 11 Nov 2017 14:53:28 -0800 Subject: [PATCH] Add support for AW5 inverse and MouseText AppleWorks 5 added inverse text and MouseText. We can handle inverse text with RTF features, and convert MouseText to something vaguely similar in the Unicode symbol set. --- reformat/AppleWorks.cpp | 89 ++++++++++++++++++++++++++++++++------- reformat/ReformatBase.cpp | 77 +++++++++++++++++++++++++++++++-- reformat/ReformatBase.h | 11 ++++- 3 files changed, 156 insertions(+), 21 deletions(-) diff --git a/reformat/AppleWorks.cpp b/reformat/AppleWorks.cpp index 756ccde..b45fdde 100644 --- a/reformat/AppleWorks.cpp +++ b/reformat/AppleWorks.cpp @@ -24,6 +24,20 @@ * array of line records * $ff $ff * optional tags + * + * AppleWorks 5.0 introduced inverse and MouseText characters. + * These just use previously-unused byte ranges. The full set + * of values is thus: + * 00-1f special + * 20-7f plain ASCII + * 80-9f inverse upper (map to 40-5f) + * a0-bf inverse symbols/numbers (map to 20-3f) + * c0-df MouseText + * e0-ff inverse lower (map to 60-7f) + * + * We can output MouseText as Unicode symbols. Inverse text can use the Rich + * Text "highlight" feature; the "background color" feature doesn't seem to + * have any effect. */ /* @@ -308,6 +322,7 @@ int ReformatAWP::HandleTextRecord(uint8_t lineRecData, uint8_t byteCountPlusCR; int byteCount = lineRecData; bool noOutput = false; + bool inverse = false; int ic; tabFlags = Read8(pSrcPtr, pLength); @@ -372,40 +387,40 @@ int ReformatAWP::HandleTextRecord(uint8_t lineRecData, break; case kSpecialCharEnterKeyboard: if (fShowEmbeds) { - RTFSetColor(kColorBlue); + TextColor oldColor = RTFSetColor(kColorBlue); BufPrintf(""); - RTFSetColor(kColorNone); + RTFSetColor(oldColor); } break; case kSpecialCharPrintPageNumber: if (fShowEmbeds) { - RTFSetColor(kColorBlue); + TextColor oldColor = RTFSetColor(kColorBlue); BufPrintf(""); - RTFSetColor(kColorNone); + RTFSetColor(oldColor); } break; case kSpecialCharStickySpace: /* MSWord uses "\~", but RichEdit ignores that */ - BufPrintf(" "); + BufPrintf("\u00a0"); // Unicode NO-BREAK SPACE break; case kSpecialCharMailMerge: if (fShowEmbeds) { - RTFSetColor(kColorBlue); + TextColor oldColor = RTFSetColor(kColorBlue); BufPrintf(""); - RTFSetColor(kColorNone); + RTFSetColor(oldColor); } case kSpecialCharPrintDate: if (fShowEmbeds) { - RTFSetColor(kColorBlue); + TextColor oldColor = RTFSetColor(kColorBlue); BufPrintf(""); - RTFSetColor(kColorNone); + RTFSetColor(oldColor); } break; case kSpecialCharPrintTime: if (fShowEmbeds) { - RTFSetColor(kColorBlue); + TextColor oldColor = RTFSetColor(kColorBlue); BufPrintf("