From 73b32984e210bda55fbbc74e20b4c1932ddc6366 Mon Sep 17 00:00:00 2001 From: Viktor Andreev Date: Fri, 3 Apr 2026 21:47:41 +0600 Subject: [PATCH] fix ptgList toArea conversion --- .../Format/Logic/Biff_structures/PtgList.cpp | 13 +++++++++++-- .../Format/Logic/Biff_structures/PtgList.h | 18 +++++++++--------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/PtgList.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/PtgList.cpp index 56b099153c..69dbc1440f 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/PtgList.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/PtgList.cpp @@ -166,11 +166,16 @@ Ptg* PtgList::toArea() { tableRef.fromString(tableRefIndex->second); tableRef.columnFirst += colFirst; - tableRef.columnLast = tableRef.columnFirst + (colLast - colFirst); + tableRef.columnLast = tableRef.columnFirst; + if(colLast > colFirst) + tableRef.columnLast += (colLast - colFirst); if(rowType == 0x2) //headers tableRef.rowLast = tableRef.rowFirst; else if(rowType == 0x0) //data + { tableRef.rowFirst++; + tableRef.rowLast--; + } else if(rowType == 0x6) //dataheaders tableRef.rowLast--; else if(rowType == 0x0C) // datatotals @@ -178,7 +183,11 @@ Ptg* PtgList::toArea() else if(rowType == 0x8) //totals tableRef.rowFirst = tableRef.rowLast; } - PtgArea3d* listArea = new PtgArea3d(0x3B, CellRef()); + unsigned char ptgType = type_+1; + unsigned char areaType = 0x3B; + SETBITS(areaType,5,6, ptgType); + + PtgArea3d* listArea = new PtgArea3d(areaType, CellRef()); listArea->ixti = ixti; listArea->area = tableRef; listArea->area.rowFirstRelative = false; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/PtgList.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/PtgList.h index 856465e922..26ef7e4423 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/PtgList.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/PtgList.h @@ -59,17 +59,17 @@ public: //const std::wstring toString() const; - _UINT16 ixti; - BYTE columns; - BYTE rowType; - bool squareBracketSpace; - bool commaSpace; + _UINT16 ixti = 0; + BYTE columns = 0; + BYTE rowType = 0; + bool squareBracketSpace = false; + bool commaSpace = false; BYTE type_; - bool invalid; - bool nonresident; + bool invalid = false; + bool nonresident = false; _UINT32 listIndex; - _UINT16 colFirst; - _UINT16 colLast; + _UINT16 colFirst = 0; + _UINT16 colLast = 0; private: GlobalWorkbookInfoPtr global_info;