Add vestigal support for Gutenberg Word Processor formatting

This commit is contained in:
David Schmidt 2009-01-05 02:11:31 +00:00
parent abd3515424
commit 5637461d8a
9 changed files with 1401 additions and 1293 deletions

View File

@ -2644,6 +2644,8 @@ MainWindow::ConfigureReformatFromPreferences(ReformatHolder* pReformat)
pPreferences->GetPrefBool(kPrConvGWP));
pReformat->SetReformatAllowed(ReformatHolder::kReformatMagicWindow,
pPreferences->GetPrefBool(kPrConvText8));
pReformat->SetReformatAllowed(ReformatHolder::kReformatGutenberg,
pPreferences->GetPrefBool(kPrConvGutenberg));
pReformat->SetReformatAllowed(ReformatHolder::kReformatAWP,
pPreferences->GetPrefBool(kPrConvAWP));
pReformat->SetReformatAllowed(ReformatHolder::kReformatAWP,
@ -2707,7 +2709,13 @@ MainWindow::ConfigureReformatFromPreferences(ReformatHolder* pReformat)
/*static*/ ReformatHolder::SourceFormat
MainWindow::ReformatterSourceFormat(DiskImg::FSFormat format)
{
if (DiskImg::UsesDOSFileStructure(format))
/*
* Gutenberg both UsesDOSFileStructure and is formatted with
* kFormatGutenberg, so check for the latter first.
*/
if (format == DiskImg::kFormatGutenberg)
return ReformatHolder::kSourceFormatGutenberg;
else if (DiskImg::UsesDOSFileStructure(format))
return ReformatHolder::kSourceFormatDOS;
else if (format == DiskImg::kFormatCPM)
return ReformatHolder::kSourceFormatCPM;

View File

@ -118,6 +118,7 @@ const Preferences::PrefMap Preferences::fPrefMaps[kPrefNumLastEntry] = {
{ kPrConvBusiness, kBool, kPrefsSect, _T("conv-business") },
{ kPrConvGWP, kBool, kPrefsSect, _T("conv-gwp") },
{ kPrConvText8, kBool, kPrefsSect, _T("conv-text8") },
{ kPrConvGutenberg, kBool, kPrefsSect, _T("conv-gutenberg") },
{ kPrConvAWP, kBool, kPrefsSect, _T("conv-awp") },
{ kPrConvADB, kBool, kPrefsSect, _T("conv-adb") },
{ kPrConvASP, kBool, kPrefsSect, _T("conv-asp") },
@ -227,6 +228,7 @@ Preferences::Preferences(void)
SetPrefBool(kPrConvBusiness, true);
SetPrefBool(kPrConvGWP, true);
SetPrefBool(kPrConvText8, true);
SetPrefBool(kPrConvGutenberg, true);
SetPrefBool(kPrConvAWP, true);
SetPrefBool(kPrConvADB, true);
SetPrefBool(kPrConvASP, true);

View File

@ -171,6 +171,7 @@ typedef enum {
kPrConvBusiness, // bool
kPrConvGWP, // bool
kPrConvText8, // bool
kPrConvGutenberg, // bool
kPrConvAWP, // bool
kPrConvADB, // bool
kPrConvASP, // bool

View File

@ -86,6 +86,7 @@ ReformatHolder::GetReformatInstance(ReformatID id)
case kReformatSHR_DG3200: pReformat = new ReformatDG3200SHR; break;
case kReformatPrintShop: pReformat = new ReformatPrintShop; break;
case kReformatMacPaint: pReformat = new ReformatMacPaint; break;
case kReformatGutenberg: pReformat = new ReformatGutenberg; break;
case kReformatUnknown:
case kReformatMAX:
default: assert(false); break;
@ -191,6 +192,9 @@ ReformatHolder::GetReformatName(ReformatID id)
case kReformatMagicWindow:
descr = "Magic Window";
break;
case kReformatGutenberg:
descr = "Gutenberg Word Processor";
break;
case kReformatAWP:
descr = "AppleWorks Word Processor";
break;

View File

@ -1,5 +1,6 @@
/*
* CiderPress
* Copyright (C) 2009 by CiderPress authors. All Rights Reserved.
* Copyright (C) 2007, 2008 by faddenSoft, LLC. All Rights Reserved.
* See the file LICENSE for distribution terms.
*/
@ -96,6 +97,7 @@ public:
kReformatGWP,
kReformatMagicWindow,
kReformatGutenberg,
kReformatAWP,
kReformatADB,
@ -182,12 +184,14 @@ public:
*
* We want to know if it's DOS so we can relax some file-type checking,
* and we want to know if it's CP/M so we can adjust the way we think
* about text files.
* about text files. We want to know if it's Gutenberg because they only
* have one type of file, and it's indistingusihable from any other text file!
*/
typedef enum SourceFormat {
kSourceFormatGeneric = 0,
kSourceFormatDOS,
kSourceFormatCPM,
kSourceFormatGutenberg,
} SourceFormat;
@ -268,6 +272,7 @@ public:
friend class ReformatTeach;
friend class ReformatGWP;
friend class ReformatMagicWindow;
friend class ReformatGutenberg;
friend class ReformatAWP;
friend class ReformatADB;
friend class ReformatASP;

View File

@ -712,6 +712,23 @@ ReformatText::RTFProportionalOff(void) {
void
ReformatText::ConvertEOL(const unsigned char* srcBuf, long srcLen,
bool stripHiBits)
{
/* Compatibility - assume we're not stripping nulls */
ConvertEOL(srcBuf, srcLen, stripHiBits, false);
}
/*
* Convert the EOL markers in a buffer. The output is written to the work
* buffer. The input buffer may be CR, LF, or CRLF.
*
* If "stripHiBits" is set, the high bit of each character is cleared before
* the value is considered.
*
* If "stripNulls" is true, no null values will make it through.
*/
void
ReformatText::ConvertEOL(const unsigned char* srcBuf, long srcLen,
bool stripHiBits, bool stripNulls)
{
unsigned char ch;
int mask;
@ -741,6 +758,8 @@ ReformatText::ConvertEOL(const unsigned char* srcBuf, long srcLen,
} else if (ch == '\n') {
BufPrintf("\r\n");
} else {
/* Strip out null bytes if requested */
if ((stripNulls && ch != 0x00) || !stripNulls)
BufPrintf("%c", ch);
}
}

View File

@ -314,6 +314,8 @@ protected:
void ConvertEOL(const unsigned char* srcBuf, long srcLen,
bool stripHiBits);
void ConvertEOL(const unsigned char* srcBuf, long srcLen,
bool stripHiBits, bool stripNulls);
void BufHexDump(const unsigned char* srcBuf, long srcLen);
void SetResultBuffer(ReformatOutput* pOutput, bool multiFont = false);

View File

@ -1,5 +1,6 @@
/*
* CiderPress
* Copyright (C) 2009 by CiderPress authors. All Rights Reserved.
* Copyright (C) 2007 by faddenSoft, LLC. All Rights Reserved.
* See the file LICENSE for distribution terms.
*/
@ -142,7 +143,7 @@ ReformatMagicWindow::IsFormatted(const ReformatHolder* pHolder)
/*
* Skip the header and text-convert the reset.
* Skip the header and text-convert the rest.
*/
int
ReformatMagicWindow::Process(const ReformatHolder* pHolder,
@ -172,3 +173,53 @@ ReformatMagicWindow::Process(const ReformatHolder* pHolder,
bail:
return retval;
}
/*
* ===========================================================================
* Gutenberg Word Processor
* ===========================================================================
*/
/*
* Decide whether or not we want to handle this file.
*/
void
ReformatGutenberg::Examine(ReformatHolder* pHolder)
{
if ((pHolder->GetFileType() == kTypeTXT) &&
(pHolder->GetSourceFormat() == ReformatHolder::kSourceFormatGutenberg)) {
pHolder->SetApplic(ReformatHolder::kReformatGutenberg,
ReformatHolder::kApplicYes,
ReformatHolder::kApplicNot, ReformatHolder::kApplicNot);
}
}
/*
* Convert the text.
*/
int
ReformatGutenberg::Process(const ReformatHolder* pHolder,
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
ReformatOutput* pOutput)
{
const unsigned char* srcPtr = pHolder->GetSourceBuf(part);
long srcLen = pHolder->GetSourceLen(part);
long length = srcLen;
int retval = -1;
fUseRTF = false;
RTFBegin();
ConvertEOL(srcPtr, srcLen, true, true);
RTFEnd();
SetResultBuffer(pOutput);
retval = 0;
return retval;
}

View File

@ -1,5 +1,6 @@
/*
* CiderPress
* Copyright (C) 2009 by Ciderpress authors. All Rights Reserved.
* Copyright (C) 2007 by faddenSoft, LLC. All Rights Reserved.
* See the file LICENSE for distribution terms.
*/
@ -30,4 +31,19 @@ private:
enum { kHeaderLen = 256 };
};
/*
* Guterberg Word Processor
*/
class ReformatGutenberg : public ReformatText {
public:
ReformatGutenberg(void) {}
virtual ~ReformatGutenberg(void) {}
virtual void Examine(ReformatHolder* pHolder);
virtual int Process(const ReformatHolder* pHolder,
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
ReformatOutput* pOutput);
};
#endif /*__LR_TEXT8__*/