From b5c349db867b1368b38f02f020c018d69b64210c Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Mar 05 2015 13:10:16 +0000 Subject: import libmwaw-0.2.0-4.el7 --- diff --git a/.gitignore b/.gitignore index 05eee24..b15a56b 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -SOURCES/libmwaw-0.1.11.tar.xz +SOURCES/libmwaw-0.2.0.tar.xz diff --git a/.libmwaw.metadata b/.libmwaw.metadata index 48a76cc..c54f1f1 100644 --- a/.libmwaw.metadata +++ b/.libmwaw.metadata @@ -1 +1 @@ -b889efeef10213c80c378044796f45633682b8ce SOURCES/libmwaw-0.1.11.tar.xz +f771a8e726c205b26b895e3dff813ae8d2742f2b SOURCES/libmwaw-0.2.0.tar.xz diff --git a/SOURCES/0001-std-isfinite-is-C-11.patch b/SOURCES/0001-std-isfinite-is-C-11.patch new file mode 100644 index 0000000..46c9de0 --- /dev/null +++ b/SOURCES/0001-std-isfinite-is-C-11.patch @@ -0,0 +1,43 @@ +From 5da59d9aa9298136d447e4014aef207f00cdc82b Mon Sep 17 00:00:00 2001 +From: David Tardon +Date: Sun, 3 Nov 2013 12:26:26 +0100 +Subject: [PATCH 1/8] std::isfinite is C++11 + +--- + configure.ac | 10 ++++++++++ + src/lib/CWDbaseContent.cxx | 5 +++-- + 2 files changed, 13 insertions(+), 2 deletions(-) + +diff --git a/src/lib/CWDbaseContent.cxx b/src/lib/CWDbaseContent.cxx +index f27148d..7198103 100644 +--- a/src/lib/CWDbaseContent.cxx ++++ b/src/lib/CWDbaseContent.cxx +@@ -33,7 +33,6 @@ + + #include + +-#include + #include + #include + #include +@@ -41,6 +40,8 @@ + #include + #include + ++#include ++ + #include + + #include "MWAWContentListener.hxx" +@@ -969,7 +970,7 @@ void CWDbaseContent::send(double val, CWStyleManager::CellFormat const &format) + if (type>=10&&type<=11) type += 4; + else if (type>=14) type=16; + } +- if (type <= 0 || type >=16 || type==10 || type==11 || !std::isfinite(val)) { ++ if (type <= 0 || type >=16 || type==10 || type==11 || !boost::math::isfinite(val)) { + s << val; + listener->insertUnicodeString(s.str().c_str()); + return; +-- +1.9.0 + diff --git a/SOURCES/0002-use-correct-type.patch b/SOURCES/0002-use-correct-type.patch new file mode 100644 index 0000000..8b230b5 --- /dev/null +++ b/SOURCES/0002-use-correct-type.patch @@ -0,0 +1,52 @@ +From cde8d7c47cdea327f8153ab72cde650f1b36f7f8 Mon Sep 17 00:00:00 2001 +From: David Tardon +Date: Sun, 3 Nov 2013 12:59:29 +0100 +Subject: [PATCH 2/8] use correct type + +--- + src/lib/HMWJGraph.cxx | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +diff --git a/src/lib/HMWJGraph.cxx b/src/lib/HMWJGraph.cxx +index fca366c..dd83ace 100644 +--- a/src/lib/HMWJGraph.cxx ++++ b/src/lib/HMWJGraph.cxx +@@ -2668,7 +2668,7 @@ bool HMWJGraph::sendGroup(HMWJGraphInternal::Group const &group, MWAWPosition po + return true; + } + +- std::multimap::const_iterator fIt; ++ std::map::const_iterator fIt; + int numFrames = int(m_state->m_framesList.size()); + for (size_t c=0; c::const_iterator fIt; ++ std::map::const_iterator fIt; + int page = group.m_page; + int numFrames = int(m_state->m_framesList.size()); + for (size_t c=0; cm_input; +- std::multimap::const_iterator fIt; ++ std::map::const_iterator fIt; + int numFrames = int(m_state->m_framesList.size()); + for (size_t c=0; cm_input; +- std::multimap::const_iterator fIt; ++ std::map::const_iterator fIt; + int numFrames = int(m_state->m_framesList.size()); + for (size_t c=0; c +Date: Mon, 4 Nov 2013 18:35:36 +0100 +Subject: [PATCH 3/8] Correct some cppcheck errors + change code to avoid + calling isfinite... + +--- + configure.ac | 10 ------- + src/conv/csv/mwaw2csv.cpp | 2 +- + src/conv/raw/mwaw2raw.cpp | 2 +- + src/conv/text/mwaw2text.cpp | 2 +- + src/lib/CWDbaseContent.cxx | 19 +++++++------ + src/lib/CWDbaseContent.hxx | 6 ++-- + src/lib/CWGraph.cxx | 30 ++++++++++---------- + src/lib/CWGraph.hxx | 2 +- + src/lib/HMWKGraph.cxx | 12 ++++---- + src/lib/MSKGraph.cxx | 2 +- + src/lib/MSKGraph.hxx | 2 +- + src/lib/MSKParser.cxx | 18 ++---------- + src/lib/MSKParser.hxx | 2 -- + src/lib/MSWTextStyles.cxx | 2 +- + src/lib/MWAWDocument.cxx | 6 ++-- + src/lib/MWAWInputStream.cxx | 4 ++- + src/lib/MWAWInputStream.hxx | 2 +- + src/lib/MWAWOLEParser.cxx | 2 +- + src/lib/MWAWOLEStream.cxx | 2 +- + src/lib/MWAWPropertyHandler.cxx | 63 +++++++++++++++++++++-------------------- + 20 files changed, 84 insertions(+), 106 deletions(-) + +diff --git a/src/conv/csv/mwaw2csv.cpp b/src/conv/csv/mwaw2csv.cpp +index 0937a46..ed3799d 100644 +--- a/src/conv/csv/mwaw2csv.cpp ++++ b/src/conv/csv/mwaw2csv.cpp +@@ -103,7 +103,7 @@ int main(int argc, char *argv[]) + CSVGenerator documentGenerator(output); + error = MWAWDocument::parse(&input, &documentGenerator); + } +- catch(MWAWDocument::Result err) ++ catch(MWAWDocument::Result const &err) + { + error=err; + } +diff --git a/src/conv/raw/mwaw2raw.cpp b/src/conv/raw/mwaw2raw.cpp +index 5e365f1..8e6a92c 100644 +--- a/src/conv/raw/mwaw2raw.cpp ++++ b/src/conv/raw/mwaw2raw.cpp +@@ -90,7 +90,7 @@ int main(int argc, char *argv[]) + { + error=MWAWDocument::parse(&input, &documentGenerator); + } +- catch (MWAWDocument::Result err) ++ catch (MWAWDocument::Result const &err) + { + error=err; + } +diff --git a/src/conv/text/mwaw2text.cpp b/src/conv/text/mwaw2text.cpp +index edb980d..2b561bf 100644 +--- a/src/conv/text/mwaw2text.cpp ++++ b/src/conv/text/mwaw2text.cpp +@@ -96,7 +96,7 @@ int main(int argc, char *argv[]) + { + MWAWDocument::parse(&input, &documentGenerator); + } +- catch (MWAWDocument::Result err) ++ catch (MWAWDocument::Result const &err) + { + error=err; + } +diff --git a/src/lib/CWDbaseContent.cxx b/src/lib/CWDbaseContent.cxx +index 7198103..2c2d971 100644 +--- a/src/lib/CWDbaseContent.cxx ++++ b/src/lib/CWDbaseContent.cxx +@@ -518,7 +518,7 @@ bool CWDbaseContent::readRecordSSV1(Vec2i const &id, long pos, CWDbaseContent::R + break; + } + record.m_resType=Record::R_Double; +- if (input->readDouble(record.m_resDouble)) ++ if (input->readDouble(record.m_resDouble, record.m_resDoubleNaN)) + f << record.m_resDouble << ","; + else { + MWAW_DEBUG_MSG(("CWDbaseContent::readRecordSSV1: can not read a float\n")); +@@ -572,7 +572,7 @@ bool CWDbaseContent::readRecordSSV1(Vec2i const &id, long pos, CWDbaseContent::R + f << "###int" << rType << "[res],"; + break; + case 2: +- if (input->checkPosition(resPos+10) && input->readDouble(record.m_resDouble)) { ++ if (input->checkPosition(resPos+10) && input->readDouble(record.m_resDouble, record.m_resDoubleNaN)) { + record.m_resType=Record::R_Double; + f << "=" << record.m_resDouble << ","; + break; +@@ -674,7 +674,7 @@ bool CWDbaseContent::readRecordSS(Vec2i const &id, long pos, CWDbaseContent::Rec + break; + } + record.m_resType=Record::R_Double; +- if (input->readDouble(record.m_resDouble)) ++ if (input->readDouble(record.m_resDouble, record.m_resDoubleNaN)) + f << record.m_resDouble << ","; + else { + MWAW_DEBUG_MSG(("CWDbaseContent::readRecordSS: can not read a float\n")); +@@ -736,7 +736,7 @@ bool CWDbaseContent::readRecordSS(Vec2i const &id, long pos, CWDbaseContent::Rec + f << "###int" << rType << "[res],"; + break; + case 2: +- if (remainSz>=10 && input->readDouble(record.m_resDouble)) { ++ if (remainSz>=10 && input->readDouble(record.m_resDouble, record.m_resDoubleNaN)) { + record.m_resType=Record::R_Double; + f << "=" << record.m_resDouble << ","; + break; +@@ -858,7 +858,7 @@ bool CWDbaseContent::readRecordDB(Vec2i const &id, long pos, CWDbaseContent::Rec + f << "###"; + break; + } +- if (input->readDouble(record.m_resDouble)) { ++ if (input->readDouble(record.m_resDouble, record.m_resDoubleNaN)) { + record.m_resType=Record::R_Double; + f << record.m_resDouble << ","; + } else { +@@ -929,7 +929,7 @@ bool CWDbaseContent::send(Vec2i const &pos) + switch(record.m_resType) { + case Record::R_Long: + if (format.m_format) +- send(double(record.m_resLong), format); ++ send(double(record.m_resLong), false, format); + else { + std::stringstream s; + s << record.m_resLong; +@@ -937,7 +937,7 @@ bool CWDbaseContent::send(Vec2i const &pos) + } + break; + case Record::R_Double: +- send(record.m_resDouble, format); ++ send(record.m_resDouble, record.m_resDoubleNaN, format); + break; + case Record::R_String: + if (record.m_resString.valid()) { +@@ -959,7 +959,7 @@ bool CWDbaseContent::send(Vec2i const &pos) + return true; + } + +-void CWDbaseContent::send(double val, CWStyleManager::CellFormat const &format) ++void CWDbaseContent::send(double val, bool isNotANumber, CWStyleManager::CellFormat const &format) + { + MWAWContentListenerPtr listener=m_parserState->m_listener; + if (!listener) +@@ -970,7 +970,8 @@ void CWDbaseContent::send(double val, CWStyleManager::CellFormat const &format) + if (type>=10&&type<=11) type += 4; + else if (type>=14) type=16; + } +- if (type <= 0 || type >=16 || type==10 || type==11 || !boost::math::isfinite(val)) { ++ // note: if val*0!=0, val is a NaN so better so simply print NaN ++ if (type <= 0 || type >=16 || type==10 || type==11 || isNotANumber) { + s << val; + listener->insertUnicodeString(s.str().c_str()); + return; +diff --git a/src/lib/CWDbaseContent.hxx b/src/lib/CWDbaseContent.hxx +index 36596e9..04177fe 100644 +--- a/src/lib/CWDbaseContent.hxx ++++ b/src/lib/CWDbaseContent.hxx +@@ -78,7 +78,7 @@ protected: + //! different result type + enum Type { R_Unknown, R_Long, R_Double, R_String }; + //! contructor +- Record() : m_style(-1), m_resType(R_Unknown), m_resLong(0), m_resDouble(0), m_resString(), m_format(0), m_font(3,9), m_justify(0), m_borders(0) { ++ Record() : m_style(-1), m_resType(R_Unknown), m_resLong(0), m_resDouble(0), m_resDoubleNaN(false), m_resString(), m_format(0), m_font(3,9), m_justify(0), m_borders(0) { + } + + //! the style if known +@@ -89,6 +89,8 @@ protected: + long m_resLong; + //! the result id double + double m_resDouble; ++ //! a flag to know if a double result is nan or not ++ bool m_resDoubleNaN; + //! the result entry if string + MWAWEntry m_resString; + //! the format ( in a v1-3 spreadsheet) +@@ -123,7 +125,7 @@ protected: + bool readRecordDB(Vec2i const &where, long pos, Record &record); + + //! send a double with a corresponding cell format +- void send(double val, CWStyleManager::CellFormat const &format); ++ void send(double val, bool isNotaNumber, CWStyleManager::CellFormat const &format); + + //! the file version + int m_version; +diff --git a/src/lib/CWGraph.cxx b/src/lib/CWGraph.cxx +index 6f34628..01109f6 100644 +--- a/src/lib/CWGraph.cxx ++++ b/src/lib/CWGraph.cxx +@@ -311,7 +311,7 @@ struct ZonePict : public Zone { + struct Bitmap : public CWStruct::DSET { + //! constructor + Bitmap(CWStruct::DSET const &dset = CWStruct::DSET()) : +- DSET(dset), m_bitmapType(-1), m_size(0,0), m_entry(), m_colorMap() { ++ DSET(dset), m_bitmapType(-1), m_bitmapSize(0,0), m_entry(), m_colorMap() { + } + + //! operator<< +@@ -324,7 +324,7 @@ struct Bitmap : public CWStruct::DSET { + //! the bitmap type + int m_bitmapType; + //! the bitmap size +- Vec2i m_size; ++ Vec2i m_bitmapSize; + //! the bitmap entry + MWAWEntry m_entry; + //! the color map +@@ -666,7 +666,7 @@ void CWGraph::askToSend(int number, bool asGraphic, MWAWPosition const& pos) + //////////////////////////////////////////////////////////// + // Intermediate level + //////////////////////////////////////////////////////////// +-bool CWGraph::getSurfaceColor(CWGraphInternal::Style const style, MWAWColor &col) const ++bool CWGraph::getSurfaceColor(CWGraphInternal::Style const &style, MWAWColor &col) const + { + if (!style.hasSurfaceColor()) + return false; +@@ -814,7 +814,7 @@ shared_ptr CWGraph::readBitmapZone + dim[j] = (int) input->readLong(2); + f << "sz=" << dim[1] << "x" << dim[0] << ","; + if (dim[0] > 0 && dim[1] > 0) { +- bitmap->m_size = Vec2i(dim[1]+2, dim[0]+2); ++ bitmap->m_bitmapSize = Vec2i(dim[1]+2, dim[0]+2); + sizeSet = true; + } + ascFile.addDelimiter(input->tell(),']'); +@@ -852,7 +852,7 @@ shared_ptr CWGraph::readBitmapZone + for (int j = 0; j < 2; j++) + dim[j] = (int) input->readLong(2); + if (i == N-1 && !sizeSet) +- bitmap->m_size = Vec2i(dim[0]+2, dim[1]+2); ++ bitmap->m_bitmapSize = Vec2i(dim[0]+2, dim[1]+2); + + f << "dim?=" << dim[0] << "x" << dim[1] << ","; + for (int j = 3; j < 6; j++) { +@@ -1993,18 +1993,18 @@ bool CWGraph::readBitmapData(CWGraphInternal::Bitmap &zone) + return false; + } + /* Fixme: this code can not works for the packed bitmap*/ +- long numColors = zone.m_size[0]*zone.m_size[1]; ++ long numColors = zone.m_bitmapSize[0]*zone.m_bitmapSize[1]; + int numBytes = numColors ? int(sz/numColors) : 0; + if (sz != numBytes*numColors) { + // check for different row alignement: 2 and 4 + for (int align=2; align <= 4; align*=2) { +- int diffToAlign=align-(zone.m_size[0]%align); ++ int diffToAlign=align-(zone.m_bitmapSize[0]%align); + if (diffToAlign==align) continue; +- numColors = (zone.m_size[0]+diffToAlign)*zone.m_size[1]; ++ numColors = (zone.m_bitmapSize[0]+diffToAlign)*zone.m_bitmapSize[1]; + numBytes = numColors ? int(sz/numColors) : 0; + if (sz == numBytes*numColors) { +- zone.m_size[0]+=diffToAlign; +- MWAW_DEBUG_MSG(("CWGraph::readBitmapData: increase width to %d\n",zone.m_size[0])); ++ zone.m_bitmapSize[0]+=diffToAlign; ++ MWAW_DEBUG_MSG(("CWGraph::readBitmapData: increase width to %d\n",zone.m_bitmapSize[0])); + break; + } + } +@@ -2048,7 +2048,7 @@ void CWGraph::checkNumberAccrossPages(CWGraphInternal::Group &group) const + + void CWGraph::updateInformation(CWGraphInternal::Group &group) const + { +- if (group.m_blockToSendList.size() || group.m_idLinkedZonesMap.size()) ++ if (!group.m_blockToSendList.empty() || !group.m_idLinkedZonesMap.empty()) + return; + std::set forbiddenZone; + +@@ -2633,19 +2633,19 @@ bool CWGraph::sendBitmap(CWGraphInternal::Bitmap &bitmap, bool asGraphic, MWAWPo + MWAWPictBitmapColor *bmapColor = 0; + bool indexed = false; + if (numColors > 2) { +- bmapIndexed = new MWAWPictBitmapIndexed(bitmap.m_size); ++ bmapIndexed = new MWAWPictBitmapIndexed(bitmap.m_bitmapSize); + bmapIndexed->setColors(bitmap.m_colorMap); + bmap.reset(bmapIndexed); + indexed = true; + } else +- bmap.reset((bmapColor=new MWAWPictBitmapColor(bitmap.m_size))); ++ bmap.reset((bmapColor=new MWAWPictBitmapColor(bitmap.m_bitmapSize))); + + //! let go + int fSz = bitmap.m_bitmapType; + MWAWInputStreamPtr &input= m_parserState->m_input; + input->seek(bitmap.m_entry.begin(), WPX_SEEK_SET); +- for (int r = 0; r < bitmap.m_size[1]; r++) { +- for (int c = 0; c < bitmap.m_size[0]; c++) { ++ for (int r = 0; r < bitmap.m_bitmapSize[1]; r++) { ++ for (int c = 0; c < bitmap.m_bitmapSize[0]; c++) { + long val = (long) input->readULong(fSz); + if (indexed) { + bmapIndexed->set(c,r,(int)val); +diff --git a/src/lib/CWGraph.hxx b/src/lib/CWGraph.hxx +index 0655464..bdb2bd5 100644 +--- a/src/lib/CWGraph.hxx ++++ b/src/lib/CWGraph.hxx +@@ -98,7 +98,7 @@ public: + (CWStruct::DSET const &zone, MWAWEntry const &entry, bool &complete); + + //! return the surface color which corresponds to some ids (if possible) +- bool getSurfaceColor(CWGraphInternal::Style const style, MWAWColor &col) const; ++ bool getSurfaceColor(CWGraphInternal::Style const &style, MWAWColor &col) const; + protected: + //! set the slide list ( for presentation ) + void setSlideList(std::vector const &slideList); +diff --git a/src/lib/HMWKGraph.cxx b/src/lib/HMWKGraph.cxx +index 2ad56d2..ab8b904 100644 +--- a/src/lib/HMWKGraph.cxx ++++ b/src/lib/HMWKGraph.cxx +@@ -292,7 +292,7 @@ std::string Group::print() const + //! Internal: the picture of a HMWKGraph + struct PictureFrame : public Frame { + //! constructor +- PictureFrame(Frame const &orig) : Frame(orig), m_type(0), m_dim(0,0), m_borderDim(0,0) { ++ PictureFrame(Frame const &orig) : Frame(orig), m_pictureType(0), m_dim(0,0), m_borderDim(0,0) { + for (int i = 0; i < 7; ++i) m_values[i] = 0; + } + //! destructor +@@ -307,7 +307,7 @@ struct PictureFrame : public Frame { + //! print local data + std::string print() const { + std::stringstream s; +- if (m_type) s << "type?=" << m_type << ","; ++ if (m_pictureType) s << "type?=" << m_pictureType << ","; + if (m_dim[0] || m_dim[1]) + s << "dim?=" << m_dim << ","; + if (m_borderDim[0] > 0 || m_borderDim[1] > 0) +@@ -319,7 +319,7 @@ struct PictureFrame : public Frame { + } + + //! a type +- int m_type; ++ int m_pictureType; + //! a dim? + Vec2i m_dim; + //! the border dim? +@@ -422,7 +422,7 @@ private: + //! Internal: the textbox of a HMWKGraph + struct TextBox : public Frame { + //! constructor +- TextBox(Frame const &orig, bool isComment) : Frame(orig), m_commentBox(isComment), m_textFileId(-1), m_linkedIdList(), m_isLinked(false), m_extra("") { ++ TextBox(Frame const &orig, bool isComment) : Frame(orig), m_commentBox(isComment), m_textFileId(-1), m_linkedIdList(), m_isLinked(false) { + for (int i = 0; i < 2; ++i) m_dim[i] = 0; + } + //! destructor +@@ -517,8 +517,6 @@ struct TextBox : public Frame { + std::vector m_linkedIdList; + //! a flag to know if this textbox is linked to a previous box + bool m_isLinked; +- //! extra data +- std::string m_extra; + }; + + bool TableCell::sendContent(MWAWContentListenerPtr, MWAWTable &table) +@@ -1603,7 +1601,7 @@ shared_ptr HMWKGraph::readPictureFrame(shared_p + picture.reset(new HMWKGraphInternal::PictureFrame(header)); + libmwaw::DebugFile &asciiFile = zone->ascii(); + libmwaw::DebugStream f; +- picture->m_type = (int) input->readLong(2); // 0 or 4 : or maybe wrapping ++ picture->m_pictureType = (int) input->readLong(2); // 0 or 4 : or maybe wrapping + for (int i = 0; i < 5; ++i) // always 0 + picture->m_values[i] = (int) input->readLong(2); + float bDim[2]; +diff --git a/src/lib/MSKGraph.cxx b/src/lib/MSKGraph.cxx +index fa876a1..dd873c1 100644 +--- a/src/lib/MSKGraph.cxx ++++ b/src/lib/MSKGraph.cxx +@@ -2729,7 +2729,7 @@ void MSKGraph::sendAll(int zoneId, bool mainZone) + } + } + +-void MSKGraph::sendObjects(MSKGraph::SendData what) ++void MSKGraph::sendObjects(MSKGraph::SendData const &what) + { + MWAWContentListenerPtr listener=m_parserState->m_listener; + if (!listener) { +diff --git a/src/lib/MSKGraph.hxx b/src/lib/MSKGraph.hxx +index 29ee53a..f9518e4 100644 +--- a/src/lib/MSKGraph.hxx ++++ b/src/lib/MSKGraph.hxx +@@ -110,7 +110,7 @@ public: + Vec2i m_size; + }; + /** sends all the object of a page, frame, ... */ +- void sendObjects(SendData const what); ++ void sendObjects(SendData const &what); + + /** try to update positions knowing pages and lines height */ + void computePositions(int zoneId, std::vector &linesHeight, std::vector &pagesHeight); +diff --git a/src/lib/MSKParser.cxx b/src/lib/MSKParser.cxx +index 16b7d84..c527e90 100644 +--- a/src/lib/MSKParser.cxx ++++ b/src/lib/MSKParser.cxx +@@ -36,27 +36,13 @@ + + #include "MSKParser.hxx" + +-/** Internal: the structures of a MSKParser */ +-namespace MSKParserInternal +-{ +-//////////////////////////////////////// +-//! Internal: the state of a MSK3Parser +-struct State { +- //! constructor +- State() { +- } +-}; +-} +- + MSKParser::MSKParser(MWAWInputStreamPtr input, MWAWRSRCParserPtr rsrcParser, MWAWHeader *header) : +- MWAWParser(input, rsrcParser, header), m_state(new MSKParserInternal::State), +- m_input(input), m_asciiFile(input) ++ MWAWParser(input, rsrcParser, header), m_input(input), m_asciiFile(input) + { + } + + MSKParser::MSKParser(MWAWInputStreamPtr input, MWAWParserStatePtr parserState) : +- MWAWParser(parserState), m_state(new MSKParserInternal::State), +- m_input(input), m_asciiFile(input) ++ MWAWParser(parserState), m_input(input), m_asciiFile(input) + { + } + +diff --git a/src/lib/MSKParser.hxx b/src/lib/MSKParser.hxx +index eb29d1b..88244b9 100644 +--- a/src/lib/MSKParser.hxx ++++ b/src/lib/MSKParser.hxx +@@ -94,8 +94,6 @@ public: + return m_asciiFile; + } + protected: +- //! the state +- shared_ptr m_state; + //! the input which can be an OLE in MSWorks 4 file + MWAWInputStreamPtr m_input; + //! the debug file of the actual input +diff --git a/src/lib/MSWTextStyles.cxx b/src/lib/MSWTextStyles.cxx +index 93a6e62..2bba921 100644 +--- a/src/lib/MSWTextStyles.cxx ++++ b/src/lib/MSWTextStyles.cxx +@@ -386,6 +386,7 @@ bool MSWTextStyles::readParagraph(MSWStruct::Paragraph ¶, int dataSz) + int const vers = version(); + libmwaw::DebugFile &ascFile = m_parserState->m_asciiFile; + libmwaw::DebugStream f; ++ int numFont=0; + while (long(input->tell()) < endPos) { + long actPos = input->tell(); + /* 5-16: basic paragraph properties +@@ -403,7 +404,6 @@ bool MSWTextStyles::readParagraph(MSWStruct::Paragraph ¶, int dataSz) + } + bool done = false; + long dSz = endPos-actPos; +- int numFont=0; + switch(wh) { + case 0: + done = (actPos+1==endPos||(dataSz==2 && actPos+2==endPos)); +diff --git a/src/lib/MWAWDocument.cxx b/src/lib/MWAWDocument.cxx +index ef9d280..182de89 100644 +--- a/src/lib/MWAWDocument.cxx ++++ b/src/lib/MWAWDocument.cxx +@@ -522,9 +522,9 @@ void GraphicExporter::endElement(const char *psName) + m_output->endTextObject(); + #ifdef DEBUG + else if (strcmp(psName, "SetStyle") && strcmp(psName, "Rectangle") && +- strcmp(psName, "Rectangle") && strcmp(psName, "Ellipse") && +- strcmp(psName, "Polygon") && strcmp(psName, "Polyline") && +- strcmp(psName, "Path") && strcmp(psName, "GraphicObject")) { ++ strcmp(psName, "Ellipse") && strcmp(psName, "Polygon") && ++ strcmp(psName, "Polyline") && strcmp(psName, "Path") && ++ strcmp(psName, "GraphicObject")) { + MWAW_DEBUG_MSG(("GraphicExporter::endElement: called with unexpected name %s\n", psName)); + } + #endif +diff --git a/src/lib/MWAWInputStream.cxx b/src/lib/MWAWInputStream.cxx +index c4dc2b6..9b2e28c 100644 +--- a/src/lib/MWAWInputStream.cxx ++++ b/src/lib/MWAWInputStream.cxx +@@ -229,7 +229,7 @@ uint8_t MWAWInputStream::readU8(WPXInputStream *stream) + return *(uint8_t const *)(p); + } + +-bool MWAWInputStream::readDouble(double &res) ++bool MWAWInputStream::readDouble(double &res, bool &isNotANumber) + { + if (!m_stream) return false; + long pos=tell(); +@@ -244,6 +244,7 @@ bool MWAWInputStream::readDouble(double &res) + } + exp -= 0x3fff; + ++ isNotANumber=false; + unsigned long mantisse = (unsigned long) readULong(4); + if ((mantisse & 0x80000000) == 0) { + if (readULong(4) != 0) return false; +@@ -251,6 +252,7 @@ bool MWAWInputStream::readDouble(double &res) + if (exp == -0x3fff && mantisse == 0) return true; // ok zero + if (exp == 0x4000 && (mantisse & 0xFFFFFFL)==0) { // ok Nan + res=std::numeric_limits::quiet_NaN(); ++ isNotANumber = true; + return true; + } + return false; +diff --git a/src/lib/MWAWInputStream.hxx b/src/lib/MWAWInputStream.hxx +index 818451a..bc29165 100644 +--- a/src/lib/MWAWInputStream.hxx ++++ b/src/lib/MWAWInputStream.hxx +@@ -139,7 +139,7 @@ public: + //! return a int8, int16, int32 readed from actualPos + long readLong(int num); + //! try to read a double (ppc) +- bool readDouble(double &res); ++ bool readDouble(double &res, bool &isNotANumber); + + /**! reads numbytes data, WITHOUT using any endian or section consideration + * \return a pointer to the read elements +diff --git a/src/lib/MWAWOLEParser.cxx b/src/lib/MWAWOLEParser.cxx +index a14aee1..70d6dd6 100644 +--- a/src/lib/MWAWOLEParser.cxx ++++ b/src/lib/MWAWOLEParser.cxx +@@ -622,7 +622,7 @@ bool MWAWOLEParser::readCompObj(MWAWInputStreamPtr ip, std::string const &oleNam + if (clsName) + f << "'" << clsName << "'"; + else { +- MWAW_DEBUG_MSG(("MWAWOLEParser::readCompObj: unknown clsid=%ld\n", clsData[0])); ++ MWAW_DEBUG_MSG(("MWAWOLEParser::readCompObj: unknown clsid=%ld\n", (long) clsData[0])); + f << "unknCLSID='" << std::hex << clsData[0] << "'"; + } + } else { +diff --git a/src/lib/MWAWOLEStream.cxx b/src/lib/MWAWOLEStream.cxx +index 6ffebea..9abdd90 100644 +--- a/src/lib/MWAWOLEStream.cxx ++++ b/src/lib/MWAWOLEStream.cxx +@@ -454,7 +454,7 @@ void DirEntry::load( unsigned char *buffer, unsigned len ) + m_name="R"; + m_macRootEntry=true; + } else { +- for( unsigned j=0; ( buffer[j]) && (j='0' && val[0]<='9'))) { +- std::istringstream iss(val); +- double res = 0.0; +- iss >> res; +- if (!iss.fail()) { +- if (iss.eof() || iss.peek() == std::char_traits::eof()) { +- list.insert(key.c_str(), res); +- return true; +- } +- std::string remain; +- iss >> remain; +- if (iss.peek() == std::char_traits::eof()) { +- if (remain=="pt") { +- list.insert(key.c_str(), res/72., WPX_INCH); +- return true; +- } +- if (remain=="in") { +- list.insert(key.c_str(), res, WPX_INCH); +- return true; +- } +- if (remain=="%") { +- list.insert(key.c_str(), res/100., WPX_PERCENT); +- return true; +- } +- if (remain=="*") { +- list.insert(key.c_str(), res/1440., WPX_INCH); +- return true; +- } +- } ++ std::string number(""), remain(""); ++ // check if the val can be a double, first isolate the potential numbering part ... ++ for (size_t s=0; s='0' && c<='9')) { ++ number+=c; ++ continue; + } ++ remain=val.substr(s); ++ break; ++ } ++ if (number.empty()) { ++ list.insert(key.c_str(), val.c_str()); ++ return true; ++ } ++ std::istringstream iss(number); ++ double res = 0.0; ++ iss >> res; ++ if (iss.fail() || iss.peek()!=std::char_traits::eof()) { ++ list.insert(key.c_str(), val.c_str()); ++ return true; + } +- list.insert(key.c_str(), val.c_str()); ++ if (remain.empty()) ++ list.insert(key.c_str(), res); ++ else if (remain=="pt") ++ list.insert(key.c_str(), res/72., WPX_INCH); ++ else if (remain=="in") ++ list.insert(key.c_str(), res, WPX_INCH); ++ else if (remain=="%") ++ list.insert(key.c_str(), res/100., WPX_PERCENT); ++ else if (remain=="*") ++ list.insert(key.c_str(), res/1440., WPX_INCH); ++ else ++ list.insert(key.c_str(), val.c_str()); + return true; + } + +-- +1.9.0 + diff --git a/SOURCES/0004-avoid-leak.patch b/SOURCES/0004-avoid-leak.patch new file mode 100644 index 0000000..1ac00c2 --- /dev/null +++ b/SOURCES/0004-avoid-leak.patch @@ -0,0 +1,29 @@ +From d1dc868e2530d3301b401e45662392a173de1557 Mon Sep 17 00:00:00 2001 +From: David Tardon +Date: Wed, 20 Nov 2013 09:03:23 +0100 +Subject: [PATCH 4/8] avoid leak + +(cherry picked from commit 454a6ce3062da9d273978868088bf07b68cd9fa2) +Signed-off-by: osnola +--- + src/lib/MSKGraph.cxx | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/src/lib/MSKGraph.cxx b/src/lib/MSKGraph.cxx +index dd873c1..7c1a9f6 100644 +--- a/src/lib/MSKGraph.cxx ++++ b/src/lib/MSKGraph.cxx +@@ -1550,7 +1550,10 @@ int MSKGraph::getEntryPicture(int zoneId, MWAWEntry &zone, bool autoSend, int or + MSKGraphInternal::Chart *chart = new MSKGraphInternal::Chart(pict); + int chartId = m_state->m_chartId++; + if (!m_tableParser->readChart(chartId, chart->m_style)) ++ { ++ delete chart; + return -1; ++ } + m_tableParser->setChartZoneId(chartId, int(m_state->m_zonesList.size())); + chart->m_chartId = chartId; + res.reset(chart); +-- +1.9.0 + diff --git a/SOURCES/0005-ClarisWorks-parser-try-to-reconstruct-compressed-bit.patch b/SOURCES/0005-ClarisWorks-parser-try-to-reconstruct-compressed-bit.patch new file mode 100644 index 0000000..bdc36a4 --- /dev/null +++ b/SOURCES/0005-ClarisWorks-parser-try-to-reconstruct-compressed-bit.patch @@ -0,0 +1,183 @@ +From b814213e898e9f394fac3dc07102baae1aba5304 Mon Sep 17 00:00:00 2001 +From: osnola +Date: Sun, 1 Dec 2013 09:38:52 +0100 +Subject: [PATCH 5/8] ClarisWorks parser: try to reconstruct compressed bitmap + ... + +(cherry picked from commit ecbabfcc912700602abba3c56543845d1cd243a8) +Signed-off-by: osnola + +Conflicts: + src/lib/CWGraph.cxx +--- + src/lib/CWGraph.cxx | 89 ++++++++++++++++++++++++++++++++++++++++------------- + 1 file changed, 67 insertions(+), 22 deletions(-) + +diff --git a/src/lib/CWGraph.cxx b/src/lib/CWGraph.cxx +index 01109f6..52f2a5c 100644 +--- a/src/lib/CWGraph.cxx ++++ b/src/lib/CWGraph.cxx +@@ -311,20 +311,24 @@ struct ZonePict : public Zone { + struct Bitmap : public CWStruct::DSET { + //! constructor + Bitmap(CWStruct::DSET const &dset = CWStruct::DSET()) : +- DSET(dset), m_bitmapType(-1), m_bitmapSize(0,0), m_entry(), m_colorMap() { ++ DSET(dset), m_numBytesPerPixel(0), m_bitmapSize(0,0), m_bitmapRowSize(0), m_entry(), m_colorMap() ++ { + } + + //! operator<< + friend std::ostream &operator<<(std::ostream &o, Bitmap const &bt) { + o << static_cast(bt); +- if (bt.m_bitmapType >= 0) o << "type=" << bt.m_bitmapType << ","; ++ if (bt.m_numBytesPerPixel > 0) o << "type=" << bt.m_numBytesPerPixel << ","; ++ else if (bt.m_numBytesPerPixel < 0) o << "type=1/" << (-bt.m_numBytesPerPixel) << ","; + return o; + } + +- //! the bitmap type +- int m_bitmapType; ++ //! the number of bite by pixel ++ int m_numBytesPerPixel; + //! the bitmap size + Vec2i m_bitmapSize; ++ //! the bitmap row size in the file ( with potential alignement) ++ int m_bitmapRowSize; + //! the bitmap entry + MWAWEntry m_entry; + //! the color map +@@ -1992,33 +1996,52 @@ bool CWGraph::readBitmapData(CWGraphInternal::Bitmap &zone) + MWAW_DEBUG_MSG(("CWGraph::readBitmapData: file is too short\n")); + return false; + } +- /* Fixme: this code can not works for the packed bitmap*/ +- long numColors = zone.m_bitmapSize[0]*zone.m_bitmapSize[1]; +- int numBytes = numColors ? int(sz/numColors) : 0; +- if (sz != numBytes*numColors) { ++ ++ long numPixels = zone.m_bitmapSize[0]*zone.m_bitmapSize[1]; ++ if (numPixels<=0) { ++ MWAW_DEBUG_MSG(("CWGraph::readBitmapData: unexpected empty size\n")); ++ return false; ++ } ++ ++ int numBytesPerPixel = int(sz/numPixels); ++ int bitmapRowSize=zone.m_bitmapSize[0]*numBytesPerPixel; ++ if (sz < numPixels) { ++ int nHalfPixel=(zone.m_bitmapSize[0]+1)/2; ++ for (int align=1; align <= 4; align*=2) { ++ int diffToAlign=align==1 ? 0 : align-(nHalfPixel%align); ++ if (diffToAlign==align) continue; ++ if (sz == (nHalfPixel+diffToAlign)*zone.m_bitmapSize[1]) { ++ bitmapRowSize=(nHalfPixel+diffToAlign); ++ numBytesPerPixel=-2; ++ break; ++ } ++ } ++ } ++ else if (sz > numBytesPerPixel*numPixels) { + // check for different row alignement: 2 and 4 + for (int align=2; align <= 4; align*=2) { + int diffToAlign=align-(zone.m_bitmapSize[0]%align); + if (diffToAlign==align) continue; +- numColors = (zone.m_bitmapSize[0]+diffToAlign)*zone.m_bitmapSize[1]; +- numBytes = numColors ? int(sz/numColors) : 0; +- if (sz == numBytes*numColors) { +- zone.m_bitmapSize[0]+=diffToAlign; +- MWAW_DEBUG_MSG(("CWGraph::readBitmapData: increase width to %d\n",zone.m_bitmapSize[0])); ++ numPixels = (zone.m_bitmapSize[0]+diffToAlign)*zone.m_bitmapSize[1]; ++ numBytesPerPixel = int(sz/numPixels); ++ if (sz == numBytesPerPixel*numPixels) { ++ bitmapRowSize=(zone.m_bitmapSize[0]+diffToAlign)*numBytesPerPixel; + break; + } + } + } +- if (sz != numBytes*numColors) { ++ ++ if (sz != bitmapRowSize*zone.m_bitmapSize[1]) { + MWAW_DEBUG_MSG(("CWGraph::readBitmapData: unexpected size\n")); + return false; + } +- zone.m_bitmapType = numBytes; ++ zone.m_numBytesPerPixel = numBytesPerPixel; ++ zone.m_bitmapRowSize = bitmapRowSize; + zone.m_entry.setBegin(pos+4); + zone.m_entry.setEnd(endPos); + libmwaw::DebugFile &ascFile = m_parserState->m_asciiFile; + libmwaw::DebugStream f; +- f << "Entries(BitmapData):nBytes=" << numBytes; ++ f << "Entries(BitmapData):[" << numBytesPerPixel << "]"; + ascFile.addPos(pos); + ascFile.addNote(f.str().c_str()); + ascFile.skipZone(pos+4, endPos-1); +@@ -2615,9 +2638,13 @@ bool CWGraph::sendBitmap(int number, bool asGraphic, MWAWPosition const &pos) + + bool CWGraph::sendBitmap(CWGraphInternal::Bitmap &bitmap, bool asGraphic, MWAWPosition pos) + { +- if (!bitmap.m_entry.valid() || !bitmap.m_bitmapType) ++ if (!bitmap.m_entry.valid() || !bitmap.m_numBytesPerPixel) + return false; +- ++ int bytesPerPixel = bitmap.m_numBytesPerPixel; ++ if (bytesPerPixel<0 && (bytesPerPixel!=-2 && bytesPerPixel!=-4)) { ++ MWAW_DEBUG_MSG(("CWGraph::sendBitmap: unknown group of color\n")); ++ return false; ++ } + if (asGraphic) { + if (!m_parserState->m_graphicListener || + !m_parserState->m_graphicListener->isDocumentStarted()) { +@@ -2637,21 +2664,38 @@ bool CWGraph::sendBitmap(CWGraphInternal::Bitmap &bitmap, bool asGraphic, MWAWPo + bmapIndexed->setColors(bitmap.m_colorMap); + bmap.reset(bmapIndexed); + indexed = true; +- } else ++ } ++ else { ++ if (bytesPerPixel<0) { ++ MWAW_DEBUG_MSG(("CWGraph::sendBitmap: unexpected mode for compressed bitmap. Bitmap ignored.\n")); ++ return false; ++ } + bmap.reset((bmapColor=new MWAWPictBitmapColor(bitmap.m_bitmapSize))); ++ } + ++ bool const isCompressed = bytesPerPixel<0; ++ int const numColorByData= isCompressed ? -bytesPerPixel : 1; ++ long const colorMask= !isCompressed ? 0 : numColorByData==2 ? 0xF : 0x3; ++ int const numColorBytes = isCompressed ? 8/numColorByData : 8*bytesPerPixel; + //! let go +- int fSz = bitmap.m_bitmapType; + MWAWInputStreamPtr &input= m_parserState->m_input; + input->seek(bitmap.m_entry.begin(), WPX_SEEK_SET); + for (int r = 0; r < bitmap.m_bitmapSize[1]; r++) { ++ long rPos=input->tell(); ++ int numRead=0; ++ long read=0; + for (int c = 0; c < bitmap.m_bitmapSize[0]; c++) { +- long val = (long) input->readULong(fSz); ++ if (numRead==0) { ++ read=(long) input->readULong(isCompressed ? 1 : bytesPerPixel); ++ numRead=numColorByData; ++ } ++ --numRead; ++ long val=!isCompressed ? read : (read>>(numColorBytes*numRead))&colorMask; + if (indexed) { + bmapIndexed->set(c,r,(int)val); + continue; + } +- switch(fSz) { ++ switch (bytesPerPixel) { + case 1: + bmapColor->set(c,r, MWAWColor((unsigned char)val,(unsigned char)val,(unsigned char)val)); + break; +@@ -2671,6 +2715,7 @@ bool CWGraph::sendBitmap(CWGraphInternal::Bitmap &bitmap, bool asGraphic, MWAWPo + } + } + } ++ input->seek(rPos+bitmap.m_bitmapRowSize, WPX_SEEK_SET); + } + + WPXBinaryData data; +-- +1.9.0 + diff --git a/SOURCES/0006-ClarisWorks-parser-use-the-page-size-to-define-the-b.patch b/SOURCES/0006-ClarisWorks-parser-use-the-page-size-to-define-the-b.patch new file mode 100644 index 0000000..be82696 --- /dev/null +++ b/SOURCES/0006-ClarisWorks-parser-use-the-page-size-to-define-the-b.patch @@ -0,0 +1,34 @@ +From 018676e577356f7cd933680c1caf710f15a54c8d Mon Sep 17 00:00:00 2001 +From: osnola +Date: Tue, 4 Feb 2014 19:27:53 +0100 +Subject: [PATCH 6/8] ClarisWorks parser: use the page size to define the + bitmap final size when converting a paint document... + +--- + src/lib/CWGraph.cxx | 10 ++++++++-- + 1 file changed, 8 insertions(+), 2 deletions(-) + +diff --git a/src/lib/CWGraph.cxx b/src/lib/CWGraph.cxx +index 52f2a5c..8a6e946 100644 +--- a/src/lib/CWGraph.cxx ++++ b/src/lib/CWGraph.cxx +@@ -2722,8 +2722,14 @@ bool CWGraph::sendBitmap(CWGraphInternal::Bitmap &bitmap, bool asGraphic, MWAWPo + std::string type; + if (!bmap->getBinary(data,type)) return false; + if (pos.size()[0] <= 0 || pos.size()[1] <= 0) { +- MWAW_DEBUG_MSG(("CWGraph::sendBitmap: can not find bitmap size\n")); +- pos.setSize(Vec2f(0,0)); ++ if (m_mainParser->getHeader() && ++ m_mainParser->getHeader()->getKind()==MWAWDocument::MWAW_K_PAINT) // fixme ++ pos.setSize(Vec2f(0.9f*float(m_mainParser->getPageWidth()), ++ 0.9f*float(m_mainParser->getPageLength()))); ++ else { ++ MWAW_DEBUG_MSG(("CWGraph::sendBitmap: can not find bitmap size\n")); ++ pos.setSize(Vec2f(0,0)); ++ } + } + if (asGraphic) { + MWAWGraphicStyle style; +-- +1.9.0 + diff --git a/SOURCES/0007-MacWrite-MacWrite-II-parser-try-to-accept-more-files.patch b/SOURCES/0007-MacWrite-MacWrite-II-parser-try-to-accept-more-files.patch new file mode 100644 index 0000000..5aa5aae --- /dev/null +++ b/SOURCES/0007-MacWrite-MacWrite-II-parser-try-to-accept-more-files.patch @@ -0,0 +1,99 @@ +From 0b8b5c98904ea0d0f337e897cca32ca7b088b646 Mon Sep 17 00:00:00 2001 +From: osnola +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 zone, bool + } + std::vector 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 + diff --git a/SOURCES/0008-Correct-a-potential-out-of-bounds-problem.patch b/SOURCES/0008-Correct-a-potential-out-of-bounds-problem.patch new file mode 100644 index 0000000..abb54b9 --- /dev/null +++ b/SOURCES/0008-Correct-a-potential-out-of-bounds-problem.patch @@ -0,0 +1,25 @@ +From 228ae77a4f5308326b597f0c883ddb61545a8014 Mon Sep 17 00:00:00 2001 +From: Stephan Bergmann +Date: Thu, 24 Apr 2014 11:58:13 +0200 +Subject: [PATCH 8/8] Correct a potential out-of-bounds problem... + +--- + src/lib/MSKGraph.cxx | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/lib/MSKGraph.cxx b/src/lib/MSKGraph.cxx +index 7c1a9f6..f32d7c6 100644 +--- a/src/lib/MSKGraph.cxx ++++ b/src/lib/MSKGraph.cxx +@@ -728,7 +728,7 @@ void State::initPatterns(int vers) + 0x55ff, 0x55ff, 0x55ff, 0x55ff, 0x55ff, 0xeeff, 0x55ff, 0xbbff, 0x77ff, 0xddff, 0x77ff, 0xddff, 0x7fff, 0xf7ff, 0x7fff, 0xf7ff, + 0x7fff, 0xffff, 0xf7ff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff + }; +- m_rsrcPatternsMap.insert(std::map::value_type(4003,Patterns(28, values4003))); ++ m_rsrcPatternsMap.insert(std::map::value_type(4003,Patterns(22, values4003))); + static uint16_t const (values4004[]) = { + 0xf0f0, 0xf0f0, 0x0f0f, 0x0f0f, 0xcccc, 0x3333, 0xcccc, 0x3333, 0x3333, 0xcccc, 0x3333, 0xcccc + }; +-- +1.9.0 + diff --git a/SPECS/libmwaw.spec b/SPECS/libmwaw.spec index f3ab530..1493f45 100644 --- a/SPECS/libmwaw.spec +++ b/SPECS/libmwaw.spec @@ -1,27 +1,36 @@ -%global apiversion 0.1 +%global apiversion 0.2 Name: libmwaw -Version: 0.1.11 -Release: 3%{?dist} -Summary: Import library for some old mac text documents +Version: 0.2.0 +Release: 4%{?dist} +Summary: An import library for many old mac document formats Group: System Environment/Libraries -# The entire source code is LGPLv2+/MPLv2.0 except -# src/lib/MWAWOLEStream.[ch]xx which are BSD. There is also -# src/tools/zip/zip.cpp which is GPLv2+, but we do not build the binary -# it is used for. -License: (LGPLv2+ or MPLv2.0) and BSD +License: LGPLv2+ or MPLv2.0 URL: http://sourceforge.net/projects/libmwaw/ Source: http://downloads.sourceforge.net/%{name}/%{name}-%{version}.tar.xz BuildRequires: boost-devel BuildRequires: doxygen -BuildRequires: libwpd-devel +BuildRequires: help2man +BuildRequires: pkgconfig(libwpd-0.9) +BuildRequires: pkgconfig(libwpg-0.2) + +Patch0: 0001-std-isfinite-is-C-11.patch +Patch1: 0002-use-correct-type.patch +Patch2: 0003-Correct-some-cppcheck-errors-change-code-to-avoid-ca.patch +Patch3: 0004-avoid-leak.patch +Patch4: 0005-ClarisWorks-parser-try-to-reconstruct-compressed-bit.patch +Patch5: 0006-ClarisWorks-parser-use-the-page-size-to-define-the-b.patch +Patch6: 0007-MacWrite-MacWrite-II-parser-try-to-accept-more-files.patch +Patch7: 0008-Correct-a-potential-out-of-bounds-problem.patch %description -libmwaw contains some import filters for old mac text documents -(MacWrite, ClarisWorks, ... ) based on top of the libwpd (which is -already used in three word processors). +libmwaw contains import filters for many old mac documents, mostly text +formats like ClarisWorks, MacWrite or MS Word for Mac, but it has a +limited support for vector drawings and spreadsheets as well (limited in +the sense that it treats them as text documents). Full list of supported +formats is available at https://sourceforge.net/p/libmwaw/wiki/Home/ . %package devel Summary: Development files for %{name} @@ -43,17 +52,14 @@ The %{name}-doc package contains documentation files for %{name}. %package tools Summary: Tools to transform the supported formats into other formats Group: Applications/Publishing -License: LGPLv2+ Requires: %{name}%{?_isa} = %{version}-%{release} %description tools Tools to transform the supported document formats into other formats. -Supported output formats are XHTML, text and raw. - +Supported output formats are CSV, XHTML, text and raw. %prep -%setup -q - +%autosetup -p1 %build %configure --disable-static --disable-werror --disable-zip --enable-docs @@ -63,6 +69,11 @@ sed -i \ libtool make %{?_smp_mflags} V=1 +export LD_LIBRARY_PATH=`pwd`/src/lib/.libs${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}} +help2man -N -n 'convert Mac spreadsheet into CSV' -o mwaw2csv.1 ./src/conv/csv/.libs/mwaw2csv +help2man -N -n 'debug the conversion library' -o mwaw2raw.1 ./src/conv/raw/.libs/mwaw2raw +help2man -N -n 'convert Mac text document into HTML' -o mwaw2html.1 ./src/conv/html/.libs/mwaw2html +help2man -N -n 'convert Mac text document into plain text' -o mwaw2text.1 ./src/conv/text/.libs/mwaw2text %install make install DESTDIR=%{buildroot} @@ -72,36 +83,40 @@ rm -f %{buildroot}/%{_bindir}/mwawFile # rhbz#1001297 we install API docs directly from build rm -rf %{buildroot}/%{_docdir}/%{name} +install -m 0755 -d %{buildroot}/%{_mandir}/man1 +install -m 0644 mwaw2*.1 %{buildroot}/%{_mandir}/man1 %post -p /sbin/ldconfig - - %postun -p /sbin/ldconfig - %files %doc CHANGES COPYING.* README %{_libdir}/%{name}-%{apiversion}.so.* - %files devel +%doc HACKING %{_includedir}/%{name}-%{apiversion} %{_libdir}/%{name}-%{apiversion}.so %{_libdir}/pkgconfig/%{name}-%{apiversion}.pc - %files doc %doc COPYING.* %doc docs/doxygen/html - %files tools +%{_bindir}/mwaw2csv %{_bindir}/mwaw2html %{_bindir}/mwaw2raw %{_bindir}/mwaw2text - +%{_mandir}/man1/mwaw2csv.1* +%{_mandir}/man1/mwaw2html.1* +%{_mandir}/man1/mwaw2raw.1* +%{_mandir}/man1/mwaw2text.1* %changelog +* Fri Aug 22 2014 David Tardon - 0.2.0-4 +- Resolves: rhbz#1132070 rebase to 0.2.0 + * Fri Jan 24 2014 Daniel Mach - 0.1.11-3 - Mass rebuild 2014-01-24