src/lib/CDRParser.cpp | 54 +++++++++++++++++++++++++++++++++++++------------- src/lib/CDRTypes.h | 2 - 2 files changed, 42 insertions(+), 14 deletions(-)
New commits: commit 206178e5e978e4194cdfe42560aef3cd14088bcf Author: Fridrich Štrba <fridrich.st...@bluewin.ch> AuthorDate: Tue Feb 4 11:52:20 2020 +0100 Commit: Fridrich Štrba <fridrich.st...@bluewin.ch> CommitDate: Tue Feb 4 11:52:20 2020 +0100 Fix txsm reading for versions 16 and above Change-Id: I7f03558e5aa5aa73fdb22f58d29eeb64342c198d diff --git a/src/lib/CDRParser.cpp b/src/lib/CDRParser.cpp index eb8ab61..1b2b4ab 100644 --- a/src/lib/CDRParser.cpp +++ b/src/lib/CDRParser.cpp @@ -3086,7 +3086,9 @@ void libcdr::CDRParser::readTxsm16(librevenge::RVNGInputStream *input) std::vector<unsigned char> charDescriptions(numChars); for (i=0; i<numChars; ++i) { - charDescriptions[i] = readU64(input); + unsigned tmpCharDescription = 0; + tmpCharDescription = readU64(input) & 0xffffffff; + charDescriptions[i] = (tmpCharDescription >> 16) | (tmpCharDescription & 0x01); } unsigned numBytes = readU32(input); unsigned long numBytesRead = 0; commit eb46ee4ca53fd37406ee71cb04edd260a9134622 Author: Fridrich Štrba <fridrich.st...@bluewin.ch> AuthorDate: Tue Feb 4 11:51:24 2020 +0100 Commit: Fridrich Štrba <fridrich.st...@bluewin.ch> CommitDate: Tue Feb 4 11:51:24 2020 +0100 boost::property_tree::ptree::count does not recurse into children Change-Id: I6892218152d14036b468826fc91f763787554ee3 diff --git a/src/lib/CDRParser.cpp b/src/lib/CDRParser.cpp index bd3d1bb..eb8ab61 100644 --- a/src/lib/CDRParser.cpp +++ b/src/lib/CDRParser.cpp @@ -3416,16 +3416,20 @@ void libcdr::CDRParser::_readX6StyleString(librevenge::RVNGInputStream *input, u CDR_DEBUG_MSG(("CDRParser::_readX6StyleString - styleString = \"%s\"\n", styleString.cstr())); boost::property_tree::ptree pt; +#ifndef DEBUG try +#endif { std::stringstream ss; ss << styleString.cstr(); boost::property_tree::read_json(ss, pt); } +#ifndef DEBUG catch (...) { return; } +#endif if (pt.count("character")) { @@ -3440,7 +3444,7 @@ void libcdr::CDRParser::_readX6StyleString(librevenge::RVNGInputStream *input, u if (!!fontSize) style.m_fontSize = (double)fontSize.get() / 254000.0; - if (pt.count("character.outline")) + if (!!pt.get_child_optional("character.outline")) { style.m_lineStyle.lineType = 0; boost::optional<unsigned> lineWidth = pt.get_optional<unsigned>("character.outline.width"); @@ -3454,7 +3458,7 @@ void libcdr::CDRParser::_readX6StyleString(librevenge::RVNGInputStream *input, u } } - if (pt.count("character.fill")) + if (!!pt.get_child_optional("character.fill")) { boost::optional<unsigned short> type = pt.get_optional<unsigned short>("character.fill.type"); if (!!type) commit 4923f95bde2c07f33b645a298238cb79f615a016 Author: Fridrich Štrba <fridrich.st...@bluewin.ch> AuthorDate: Tue Feb 4 11:49:57 2020 +0100 Commit: Fridrich Štrba <fridrich.st...@bluewin.ch> CommitDate: Tue Feb 4 11:49:57 2020 +0100 Extend colour string parsing to RBG255 model Change-Id: I935d553727aef0e9ee21bac254c6fdc24349c93f diff --git a/src/lib/CDRParser.cpp b/src/lib/CDRParser.cpp index 40b9b68..bd3d1bb 100644 --- a/src/lib/CDRParser.cpp +++ b/src/lib/CDRParser.cpp @@ -108,7 +108,7 @@ static int parseColourString(const char *colourString, libcdr::CDRColor &colour, bool bRes = false; boost::optional<unsigned> colourModel; - unsigned val0, val1, val2, val3, val4; + std::vector<unsigned> val; if (colourString) { @@ -116,6 +116,7 @@ static int parseColourString(const char *colourString, libcdr::CDRColor &colour, cmodel.add ("CMYK", 2) ("CMYK255", 3) + ("RGB255", 5) ; auto it = colourString; const auto end = it + std::strlen(it); @@ -124,27 +125,48 @@ static int parseColourString(const char *colourString, libcdr::CDRColor &colour, ( (cmodel | omit[+alnum]) >> -lit(',') >> omit[+alnum] >> -lit(',') - >> uint_ >> -lit(',') - >> uint_ >> -lit(',') - >> uint_ >> -lit(',') - >> uint_ >> -lit(',') - >> uint_ >> -lit(',') + >> *(uint_ >> -lit(',')) >> (repeat(8)[alnum] >> '-' >> repeat(3)[repeat(4)[alnum] >> '-'] >> repeat(12)[alnum]) ), // End grammar space, - colourModel, val0, val1, val2, val3, val4) + colourModel, val) && it == end; } - if (!bRes) + if (bRes) return -1; if (colourModel) colour.m_colorModel = get(colourModel); - colour.m_colorValue = val0 | (val1 << 8) | (val2 << 16) | (val3 << 24); - opacity = (double)val4 / 100.0; + switch (colour.m_colorModel) + { + case 5: + if (val.size() >= 4) + { + colour.m_colorValue = val[0] | (val[1] << 8) | (val[2] << 16); + opacity = (double)val[3] / 100.0; + break; + } + else + { + CDR_DEBUG_MSG(("parseColourString error: not enough values read: %lu\n", val.size())); + return 0; + } + default: + if (val.size() >= 5) + { + colour.m_colorValue = val[0] | (val[1] << 8) | (val[2] << 16) | (val[3] << 24); + opacity = (double)val[4] / 100.0; + break; + } + else + { + CDR_DEBUG_MSG(("parseColourString error: not enough values read: %lu\n", val.size())); + return 0; + } + } return 1; } commit 6ec73cd4131fbb4bc6a5e4b3401cea19d5fa406b Author: Fridrich Štrba <fridrich.st...@bluewin.ch> AuthorDate: Tue Feb 4 11:38:35 2020 +0100 Commit: Fridrich Štrba <fridrich.st...@bluewin.ch> CommitDate: Tue Feb 4 11:38:35 2020 +0100 astyle Change-Id: Ibe31785f36920fc43de52833be25a1b82be9832c diff --git a/src/lib/CDRTypes.h b/src/lib/CDRTypes.h index 3ea5667..f3010e0 100644 --- a/src/lib/CDRTypes.h +++ b/src/lib/CDRTypes.h @@ -370,7 +370,7 @@ struct CDRFont CDRFont(const librevenge::RVNGString &name, unsigned short encoding) : m_name(name), m_encoding(encoding) {} CDRFont(const CDRFont &font) = default; - CDRFont& operator=(const CDRFont &font) = default; + CDRFont &operator=(const CDRFont &font) = default; librevenge::RVNGString m_name; unsigned short m_encoding; }; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits