You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
100 lines
3.4 KiB
100 lines
3.4 KiB
From 0b8b5c98904ea0d0f337e897cca32ca7b088b646 Mon Sep 17 00:00:00 2001
|
|
From: osnola <alonso@loria.fr>
|
|
Date: Sun, 16 Feb 2014 11:36:32 +0100
|
|
Subject: [PATCH 7/8] MacWrite/MacWrite II parser: try to accept more files,
|
|
ie. files with "odd" PrintInfo...
|
|
|
|
---
|
|
src/lib/MWParser.cxx | 15 +++++++++------
|
|
src/lib/MWProParser.cxx | 14 +++++++++++---
|
|
2 files changed, 20 insertions(+), 9 deletions(-)
|
|
|
|
diff --git a/src/lib/MWParser.cxx b/src/lib/MWParser.cxx
|
|
index fd0b60a..c422406 100644
|
|
--- a/src/lib/MWParser.cxx
|
|
+++ b/src/lib/MWParser.cxx
|
|
@@ -736,7 +736,7 @@ bool MWParser::checkHeader(MWAWHeader *header, bool /*strict*/)
|
|
|
|
f << "FileHeader: vers=" << vers << ",";
|
|
|
|
- if (version() <= 3) fHeader.m_dataPos = (int) input->readULong(2);
|
|
+ if (vers <= 3) fHeader.m_dataPos = (int) input->readULong(2);
|
|
|
|
for (int i = 0; i < 3; i++) {
|
|
int numParag = (int) input->readLong(2);
|
|
@@ -748,7 +748,7 @@ bool MWParser::checkHeader(MWAWHeader *header, bool /*strict*/)
|
|
}
|
|
}
|
|
|
|
- if (version() <= 3) {
|
|
+ if (vers <= 3) {
|
|
input->seek(6, WPX_SEEK_CUR); // unknown
|
|
if (input->readLong(1)) f << "hasFooter(?);";
|
|
if (input->readLong(1)) f << "hasHeader(?),";
|
|
@@ -768,9 +768,12 @@ bool MWParser::checkHeader(MWAWHeader *header, bool /*strict*/)
|
|
|
|
//
|
|
input->seek(headerSize, WPX_SEEK_SET);
|
|
- if (!readPrintInfo())
|
|
- return false;
|
|
- long testPos = version() <= 3 ? fHeader.m_dataPos : fHeader.m_freeListPos;
|
|
+ if (!readPrintInfo()) {
|
|
+ input->seek(headerSize+0x78, WPX_SEEK_SET);
|
|
+ for (int i=0; i<3; ++i)
|
|
+ if (!readWindowsInfo(i) && i==2) return false;
|
|
+ }
|
|
+ long testPos = vers <= 3 ? fHeader.m_dataPos : fHeader.m_freeListPos;
|
|
input->seek(testPos, WPX_SEEK_SET);
|
|
if (long(input->tell()) != testPos)
|
|
return false;
|
|
@@ -780,7 +783,7 @@ bool MWParser::checkHeader(MWAWHeader *header, bool /*strict*/)
|
|
|
|
// ok, we can finish initialization
|
|
if (header)
|
|
- header->reset(MWAWDocument::MWAW_T_MACWRITE, version());
|
|
+ header->reset(MWAWDocument::MWAW_T_MACWRITE, vers);
|
|
|
|
ascii().addPos(0);
|
|
ascii().addNote(f.str().c_str());
|
|
diff --git a/src/lib/MWProParser.cxx b/src/lib/MWProParser.cxx
|
|
index 8dbdbe4..c81837e 100644
|
|
--- a/src/lib/MWProParser.cxx
|
|
+++ b/src/lib/MWProParser.cxx
|
|
@@ -688,14 +688,22 @@ bool MWProParser::checkHeader(MWAWHeader *header, bool strict)
|
|
setVersion(vers);
|
|
f << "vers=" << vers << ",";
|
|
if (strict) {
|
|
- if (!readPrintInfo())
|
|
- return false;
|
|
if (vers) {
|
|
input->seek(0xdd, WPX_SEEK_SET);
|
|
// "MP" seems always in this position
|
|
if (input->readULong(2) != 0x4d50)
|
|
return false;
|
|
}
|
|
+ else if (!readPrintInfo()) { // last chance, check DocHeader
|
|
+ input->seek(4+0x78, WPX_SEEK_SET);
|
|
+ if (input->readULong(2)) return false;
|
|
+ val=(int) input->readULong(2);
|
|
+ if ((val&0x0280)!=0x0280) return false;
|
|
+ for (int i=0; i<4; ++i) {
|
|
+ val=(int) input->readLong(1);
|
|
+ if (val<-1 || val>1) return false;
|
|
+ }
|
|
+ }
|
|
}
|
|
|
|
|
|
@@ -1441,7 +1449,7 @@ bool MWProParser::sendText(shared_ptr<MWProParserInternal::TextZone> zone, bool
|
|
}
|
|
std::vector<int> pageBreaks=listenerState.getPageBreaksPos();
|
|
for (size_t i = 0; i < pageBreaks.size(); i++) {
|
|
- if (pageBreaks[i] >= zone->m_textLength) {
|
|
+ if (pageBreaks[i]<=0 && pageBreaks[i] >= zone->m_textLength) {
|
|
MWAW_DEBUG_MSG(("MWProParser::sendText: page breaks seems bad\n"));
|
|
break;
|
|
}
|
|
--
|
|
1.9.0
|
|
|