fixed LibreCAD 2 issue #1371, read failed with binary DXF

This commit is contained in:
Roman Telezhynskyi 2021-11-23 14:48:30 +02:00
parent 0db9e1f728
commit b9958e9953
2 changed files with 23 additions and 0 deletions

View File

@ -48,6 +48,10 @@ bool dxfReader::readRec(int *codeData) {
readInt16();
else if (code < 300) //TODO this is a boolean indicator, int in Binary?
readBool();
else if (code < 310)
readString();
else if (code < 320)
readBinary();
else if (code < 370)
readString();
else if (code < 390)
@ -74,6 +78,8 @@ bool dxfReader::readRec(int *codeData) {
readString();
return readRec( codeData);
}
else if (code == 1004)
readBinary();
else if (code > 998 && code < 1009) //skip not used at the v2012
readString();
else if (code < 1060) //TODO this is a floating point double precision??
@ -138,6 +144,16 @@ bool dxfReaderBinary::readString(std::string *text) {
return (filestr->good());
}
bool dxfReaderBinary::readBinary() {
unsigned char chunklen {0};
filestr->read( reinterpret_cast<char *>(&chunklen), 1);
filestr->seekg( chunklen, std::ios_base::cur);
DRW_DBG( chunklen); DRW_DBG( " byte(s) binary data bypassed\n");
return (filestr->good());
}
bool dxfReaderBinary::readInt16() {
type = INT32;
char buffer[2];
@ -214,6 +230,10 @@ bool dxfReaderAscii::readString() {
return (filestr->good());
}
bool dxfReaderAscii::readBinary() {
return readString();
}
bool dxfReaderAscii::readInt16() {
type = INT32;
std::string text;

View File

@ -59,6 +59,7 @@ protected:
virtual bool readCode(int *code) = 0; //return true if successful (not EOF)
virtual bool readString(std::string *text) = 0;
virtual bool readString() = 0;
virtual bool readBinary() = 0;
virtual bool readInt16() = 0;
virtual bool readInt32() = 0;
virtual bool readInt64() = 0;
@ -88,6 +89,7 @@ public:
virtual bool readCode(int *code) override;
virtual bool readString(std::string *text) override;
virtual bool readString() override;
virtual bool readBinary() override;
virtual bool readInt16() override;
virtual bool readInt32() override;
virtual bool readInt64() override;
@ -105,6 +107,7 @@ public:
virtual bool readCode(int *code) override;
virtual bool readString(std::string *text) override;
virtual bool readString() override;
virtual bool readBinary() override;
virtual bool readInt16() override;
virtual bool readDouble() override;
virtual bool readInt32() override;