src/lib/CDRParser.cpp | 115 +++++++++++++++++++++++++++----------------------- 1 file changed, 63 insertions(+), 52 deletions(-)
New commits: commit 8378597beae61ef66807a0eaf56689e6de75c203 Author: Fridrich Štrba <fridrich.st...@bluewin.ch> AuthorDate: Wed Feb 19 08:18:21 2020 +0100 Commit: Fridrich Štrba <fridrich.st...@bluewin.ch> CommitDate: Wed Feb 19 08:18:21 2020 +0100 Some progress with multiparagraph text in versions x6 and more Change-Id: I4ecb2af0918bfe5a3f925ecf6e60cf72a2bbc282 diff --git a/src/lib/CDRParser.cpp b/src/lib/CDRParser.cpp index c6c9d97..7feba1a 100644 --- a/src/lib/CDRParser.cpp +++ b/src/lib/CDRParser.cpp @@ -2635,7 +2635,7 @@ void libcdr::CDRParser::readTxsm16(librevenge::RVNGInputStream *input) unsigned tlen = readU32(input); if (m_version < 1700) tlen *= 2; - input->seek(tlen + 4, librevenge::RVNG_SEEK_CUR); + input->seek(tlen, librevenge::RVNG_SEEK_CUR); } else { @@ -2657,65 +2657,72 @@ void libcdr::CDRParser::readTxsm16(librevenge::RVNGInputStream *input) } else input->seek(8, librevenge::RVNG_SEEK_CUR); - input->seek(4, librevenge::RVNG_SEEK_CUR); } - unsigned stlId = readU32(input); + unsigned numPara = readU32(input); + + for (unsigned j = 0; j < numPara; ++j) + { + + unsigned stlId = readU32(input); - if (frameFlag) + if (frameFlag) + input->seek(1, librevenge::RVNG_SEEK_CUR); input->seek(1, librevenge::RVNG_SEEK_CUR); - input->seek(1, librevenge::RVNG_SEEK_CUR); - unsigned len2 = readU32(input); - if (m_version < 1700) - len2 *= 2; - CDRStyle defaultStyle; - _readX6StyleString(input, len2, defaultStyle); + unsigned len2 = readU32(input); + if (m_version < 1700) + len2 *= 2; + CDRStyle defaultStyle; + _readX6StyleString(input, len2, defaultStyle); - unsigned numRecords = readU32(input); + unsigned numRecords = readU32(input); - unsigned i = 0; - std::map<unsigned, CDRStyle> styles; - for (i=0; i<numRecords && getRemainingLength(input) >= 17; ++i) - { - styles[i*2] = defaultStyle; - input->seek(4, librevenge::RVNG_SEEK_CUR); - unsigned flag = readU8(input); - input->seek(1, librevenge::RVNG_SEEK_CUR); - unsigned lenN = 0; - if (flag & 0x04) + unsigned i = 0; + std::map<unsigned, CDRStyle> styles; + for (i=0; i<numRecords && getRemainingLength(input) >= 17; ++i) { + styles[i*2] = defaultStyle; + input->seek(4, librevenge::RVNG_SEEK_CUR); + unsigned flag = readU8(input); + input->seek(1, librevenge::RVNG_SEEK_CUR); + unsigned lenN = 0; + if (flag & 0x04) + { + lenN = readU32(input); + lenN *= 2; + input->seek(lenN, librevenge::RVNG_SEEK_CUR); + } lenN = readU32(input); - lenN *= 2; - input->seek(lenN, librevenge::RVNG_SEEK_CUR); + if (m_version < 1700) + lenN *= 2; + _readX6StyleString(input, lenN, styles[i*2]); } - lenN = readU32(input); - if (m_version < 1700) - lenN *= 2; - _readX6StyleString(input, lenN, styles[i*2]); - } - unsigned numChars = readU32(input); - if (numChars > getRemainingLength(input) / 8) - numChars = getRemainingLength(input) / 8; - std::vector<unsigned char> charDescriptions(numChars); - for (i=0; i<numChars; ++i) - { - unsigned tmpCharDescription = 0; - tmpCharDescription = readU64(input) & 0xffffffff; - charDescriptions[i] = (tmpCharDescription >> 16) | (tmpCharDescription & 0x01); - } - unsigned numBytes = readU32(input); - unsigned long numBytesRead = 0; - const unsigned char *buffer = input->read(numBytes, numBytesRead); - if (numBytesRead != numBytes) - throw GenericException(); - std::vector<unsigned char> textData(numBytesRead); - if (numBytesRead) - memcpy(&textData[0], buffer, numBytesRead); + unsigned numChars = readU32(input); + if (numChars > getRemainingLength(input) / 8) + numChars = getRemainingLength(input) / 8; + std::vector<unsigned char> charDescriptions(numChars); + for (i=0; i<numChars; ++i) + { + unsigned tmpCharDescription = 0; + tmpCharDescription = readU64(input) & 0xffffffff; + charDescriptions[i] = (tmpCharDescription >> 16) | (tmpCharDescription & 0x01); + } + unsigned numBytes = readU32(input); + unsigned long numBytesRead = 0; + const unsigned char *buffer = input->read(numBytes, numBytesRead); + if (numBytesRead != numBytes) + throw GenericException(); + std::vector<unsigned char> textData(numBytesRead); + if (numBytesRead) + memcpy(&textData[0], buffer, numBytesRead); + input->seek(1, librevenge::RVNG_SEEK_CUR); //skip the 0 ending character + - if (!textData.empty()) - m_collector->collectText(textId, stlId, textData, charDescriptions, styles); + if (!textData.empty()) + m_collector->collectText(textId, stlId, textData, charDescriptions, styles); + } #ifndef DEBUG } catch (...) commit 900c54843680df8fe5c0209fd6935c2591b093f9 Author: Fridrich Štrba <fridrich.st...@bluewin.ch> AuthorDate: Wed Feb 19 08:17:04 2020 +0100 Commit: Fridrich Štrba <fridrich.st...@bluewin.ch> CommitDate: Wed Feb 19 08:17:04 2020 +0100 Move debug messages inside the _resolveColorPalette function Change-Id: I07aff123bf56d5202acca17233d525cf572a5ffc diff --git a/src/lib/CDRParser.cpp b/src/lib/CDRParser.cpp index d95a6bf..c6c9d97 100644 --- a/src/lib/CDRParser.cpp +++ b/src/lib/CDRParser.cpp @@ -784,12 +784,8 @@ libcdr::CDRColor libcdr::CDRParser::readColor(librevenge::RVNGInputStream *input tmpColor.m_colorValue = readU32(input); } - CDR_DEBUG_MSG(("CDRParser::readColor --> colorModel 0x%x -- colorPalette 0x%x -- colorValue 0x%x\n", tmpColor.m_colorModel, tmpColor.m_colorPalette, tmpColor.m_colorValue)); - _resolveColorPalette(tmpColor); - CDR_DEBUG_MSG(("CDRParser::readColor resolved --> colorModel 0x%x -- colorPalette 0x%x -- colorValue 0x%x\n", tmpColor.m_colorModel, tmpColor.m_colorPalette, tmpColor.m_colorValue)); - return tmpColor; } @@ -3144,6 +3140,8 @@ void libcdr::CDRParser::_skipX3Optional(librevenge::RVNGInputStream *input) void libcdr::CDRParser::_resolveColorPalette(libcdr::CDRColor &color) { + CDR_DEBUG_MSG(("CDRParser::_resolveColorPalette --> model 0x%x -- palette 0x%x -- value 0x%x\n", color.m_colorModel, color.m_colorPalette, color.m_colorValue)); + unsigned char r = 0; unsigned char g = 0; unsigned char b = 0; @@ -3561,6 +3559,9 @@ void libcdr::CDRParser::_resolveColorPalette(libcdr::CDRColor &color) break; } } + + CDR_DEBUG_MSG(("CDRParser::_resolveColorPalette resolved --> model 0x%x -- palette 0x%x -- value 0x%x\n", color.m_colorModel, color.m_colorPalette, color.m_colorValue)); + } /* vim:set shiftwidth=2 softtabstop=2 expandtab: */ commit 637b22b22fa71ee2d6e58f4dc12792b2b2ae8ea0 Author: Fridrich Štrba <fridrich.st...@bluewin.ch> AuthorDate: Wed Feb 19 08:15:48 2020 +0100 Commit: Fridrich Štrba <fridrich.st...@bluewin.ch> CommitDate: Wed Feb 19 08:15:48 2020 +0100 Some more palettes for text x6+ Change-Id: I614ce56b773b136aa2fb08fb5e527066cc352bd9 diff --git a/src/lib/CDRParser.cpp b/src/lib/CDRParser.cpp index 91d2e27..d95a6bf 100644 --- a/src/lib/CDRParser.cpp +++ b/src/lib/CDRParser.cpp @@ -130,6 +130,9 @@ static int parseColourString(const char *colourString, libcdr::CDRColor &colour, cpalette.add ("USER", 5) ("FOCTONE", 8) + ("DUPONT", 9) + ("TOYO", 10) + ("DIC", 11) ; auto it = colourString; const auto end = it + std::strlen(it); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits