1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-24 03:35:53 +01:00

Compare commits

..

2 Commits

4 changed files with 29 additions and 28 deletions

View File

@ -180,7 +180,7 @@ Label LBLFile::str2label(const QVector<quint8> &str, bool capitalize,
Shield(shieldType, _codec.toString(shieldLabel))); Shield(shieldType, _codec.toString(shieldLabel)));
} }
Label LBLFile::label6b(const SubFile *file, Handle &hdl, bool capitalize, Label LBLFile::label6b(const SubFile *file, Handle &fileHdl, bool capitalize,
bool convert) const bool convert) const
{ {
Shield::Type shieldType = Shield::None; Shield::Type shieldType = Shield::None;
@ -191,8 +191,8 @@ Label LBLFile::label6b(const SubFile *file, Handle &hdl, bool capitalize,
int split = -1; int split = -1;
while (true) { while (true) {
if (!(file->readByte(hdl, &b1) && file->readByte(hdl, &b2) if (!(file->readByte(fileHdl, &b1) && file->readByte(fileHdl, &b2)
&& file->readByte(hdl, &b3))) && file->readByte(fileHdl, &b3)))
return Label(); return Label();
int c[]= {b1>>2, (b1&0x3)<<4|b2>>4, (b2&0xF)<<2|b3>>6, b3&0x3F}; int c[]= {b1>>2, (b1&0x3)<<4|b2>>4, (b2&0xF)<<2|b3>>6, b3&0x3F};
@ -244,14 +244,14 @@ Label LBLFile::label6b(const SubFile *file, Handle &hdl, bool capitalize,
} }
} }
Label LBLFile::label8b(const SubFile *file, Handle &hdl, bool capitalize, Label LBLFile::label8b(const SubFile *file, Handle &fileHdl, bool capitalize,
bool convert) const bool convert) const
{ {
QVector<quint8> str; QVector<quint8> str;
quint8 c; quint8 c;
do { do {
if (!file->readByte(hdl, &c)) if (!file->readByte(fileHdl, &c))
return Label(); return Label();
str.append(c); str.append(c);
} while (c); } while (c);
@ -259,13 +259,12 @@ Label LBLFile::label8b(const SubFile *file, Handle &hdl, bool capitalize,
return str2label(str, capitalize, convert); return str2label(str, capitalize, convert);
} }
Label LBLFile::labelHuffman(const SubFile *file, Handle &hdl, bool capitalize, Label LBLFile::labelHuffman(Handle &hdl, const SubFile *file, Handle &fileHdl,
bool convert) const bool capitalize, bool convert) const
{ {
QVector<quint8> str; QVector<quint8> str;
quint32 end = _offset + _size;
if (!_huffmanText->decode(file, hdl, end - pos(hdl), str)) if (!_huffmanText->decode(file, fileHdl, 0xFFFFFFFF, str))
return Label(); return Label();
if (!_table) if (!_table)
return str2label(str, capitalize, convert); return str2label(str, capitalize, convert);
@ -284,7 +283,7 @@ Label LBLFile::labelHuffman(const SubFile *file, Handle &hdl, bool capitalize,
else if (str2.size()) else if (str2.size())
str2.append(' '); str2.append(' ');
if (!_huffmanText->decode(file, hdl, end - off, str2)) if (!_huffmanText->decode(this, hdl, _offset + _size - off, str2))
return Label(); return Label();
} else { } else {
if (str.at(i) == 7) { if (str.at(i) == 7) {
@ -320,20 +319,20 @@ Label LBLFile::label(Handle &hdl, quint32 offset, bool poi, bool capitalize,
if (!seek(hdl, labelOffset)) if (!seek(hdl, labelOffset))
return Label(); return Label();
return label(this, hdl, capitalize, convert); return label(hdl, this, hdl, capitalize, convert);
} }
Label LBLFile::label(const SubFile *file, Handle &hdl, bool capitalize, Label LBLFile::label(Handle &hdl, const SubFile *file, Handle &fileHdl,
bool convert) const bool capitalize, bool convert) const
{ {
switch (_encoding) { switch (_encoding) {
case 6: case 6:
return label6b(file, hdl, capitalize, convert); return label6b(file, fileHdl, capitalize, convert);
case 9: case 9:
case 10: case 10:
return label8b(file, hdl, capitalize, convert); return label8b(file, fileHdl, capitalize, convert);
case 11: case 11:
return labelHuffman(file, hdl, capitalize, convert); return labelHuffman(hdl, file, fileHdl, capitalize, convert);
default: default:
return Label(); return Label();
} }

View File

@ -33,8 +33,8 @@ public:
Label label(Handle &hdl, quint32 offset, bool poi = false, Label label(Handle &hdl, quint32 offset, bool poi = false,
bool capitalize = true, bool convert = false) const; bool capitalize = true, bool convert = false) const;
Label label(const SubFile *file, Handle &hdl, bool capitalize = true, Label label(Handle &hdl, const SubFile *file, Handle &fileHdl,
bool convert = false) const; bool capitalize = true, bool convert = false) const;
quint8 imageIdSize() const {return _imgOffsetIdSize;} quint8 imageIdSize() const {return _imgOffsetIdSize;}
QPixmap image(Handle &hdl, quint32 id) const; QPixmap image(Handle &hdl, quint32 id) const;
@ -47,12 +47,12 @@ private:
Label str2label(const QVector<quint8> &str, bool capitalize, Label str2label(const QVector<quint8> &str, bool capitalize,
bool convert) const; bool convert) const;
Label label6b(const SubFile *file, Handle &hdl, bool capitalize, Label label6b(const SubFile *file, Handle &fileHdl, bool capitalize,
bool convert) const; bool convert) const;
Label label8b(const SubFile *file, Handle &hdl, bool capitalize, Label label8b(const SubFile *file, Handle &fileHdl, bool capitalize,
bool convert) const;
Label labelHuffman(const SubFile *file, Handle &hdl, bool capitalize,
bool convert) const; bool convert) const;
Label labelHuffman(Handle &hdl, const SubFile *file, Handle &fileHdl,
bool capitalize, bool convert) const;
bool loadRasterTable(Handle &hdl, quint32 offset, quint32 size, bool loadRasterTable(Handle &hdl, quint32 offset, quint32 size,
quint32 recordSize); quint32 recordSize);

View File

@ -33,7 +33,7 @@ RGNFile::~RGNFile()
} }
bool RGNFile::readClassFields(Handle &hdl, SegmentType segmentType, bool RGNFile::readClassFields(Handle &hdl, SegmentType segmentType,
void *object, const LBLFile *lbl) const void *object, const LBLFile *lbl, Handle &lblHdl) const
{ {
quint8 flags; quint8 flags;
quint32 rs; quint32 rs;
@ -83,10 +83,11 @@ bool RGNFile::readClassFields(Handle &hdl, SegmentType segmentType,
if (point && (flags & 1) && lbl) { if (point && (flags & 1) && lbl) {
quint32 p = pos(hdl); quint32 p = pos(hdl);
point->label = lbl->label(this, hdl); point->label = lbl->label(lblHdl, this, hdl);
point->classLabel = true; point->classLabel = true;
rs -= (pos(hdl) - p); Q_ASSERT(pos(hdl) - p <= rs + 4);
seek(hdl, p);
} }
return seek(hdl, pos(hdl) + rs); return seek(hdl, pos(hdl) + rs);
@ -356,7 +357,8 @@ bool RGNFile::extPolyObjects(Handle &hdl, const SubDiv *subdiv, quint32 shift,
if (subtype & 0x20 && !readUInt24(hdl, labelPtr)) if (subtype & 0x20 && !readUInt24(hdl, labelPtr))
return false; return false;
if (subtype & 0x80 && !readClassFields(hdl, segmentType, &poly, lbl)) if (subtype & 0x80 && !readClassFields(hdl, segmentType, &poly, lbl,
lblHdl))
return false; return false;
if (subtype & 0x40 && !skipLclFields(hdl, segmentType == Line if (subtype & 0x40 && !skipLclFields(hdl, segmentType == Line
? _linesLclFlags : _polygonsLclFlags)) ? _linesLclFlags : _polygonsLclFlags))
@ -446,7 +448,7 @@ bool RGNFile::extPointObjects(Handle &hdl, const SubDiv *subdiv,
if (subtype & 0x20 && !readUInt24(hdl, labelPtr)) if (subtype & 0x20 && !readUInt24(hdl, labelPtr))
return false; return false;
if (subtype & 0x80 && !readClassFields(hdl, Point, &point, lbl)) if (subtype & 0x80 && !readClassFields(hdl, Point, &point, lbl, lblHdl))
return false; return false;
if (subtype & 0x40 && !skipLclFields(hdl, _pointsLclFlags)) if (subtype & 0x40 && !skipLclFields(hdl, _pointsLclFlags))
return false; return false;

View File

@ -63,7 +63,7 @@ public:
private: private:
bool segments(Handle &hdl, SubDiv *subdiv, SubDiv::Segment seg[5]) const; bool segments(Handle &hdl, SubDiv *subdiv, SubDiv::Segment seg[5]) const;
bool readClassFields(Handle &hdl, SegmentType segmentType, void *object, bool readClassFields(Handle &hdl, SegmentType segmentType, void *object,
const LBLFile *lbl) const; const LBLFile *lbl, Handle &lblHdl) const;
bool skipLclFields(Handle &hdl, const quint32 flags[3]) const; bool skipLclFields(Handle &hdl, const quint32 flags[3]) const;
bool skipGblFields(Handle &hdl, quint32 flags) const; bool skipGblFields(Handle &hdl, quint32 flags) const;