diff --git a/Common/js/__pycache__/common.cpython-310.pyc b/Common/js/__pycache__/common.cpython-310.pyc new file mode 100644 index 0000000000..d8dcf0ac0d Binary files /dev/null and b/Common/js/__pycache__/common.cpython-310.pyc differ diff --git a/DesktopEditor/common/SystemUtils.h b/DesktopEditor/common/SystemUtils.h index cba837260b..452999db75 100644 --- a/DesktopEditor/common/SystemUtils.h +++ b/DesktopEditor/common/SystemUtils.h @@ -1,4 +1,4 @@ -/* +/* * (c) Copyright Ascensio System SIA 2010-2023 * * This program is a free software product. You can redistribute it and/or @@ -59,7 +59,7 @@ namespace NSSystemUtils static const wchar_t* gc_EnvLastModifiedBy = L"LAST_MODIFIED_BY"; static const wchar_t* gc_EnvModified = L"MODIFIED"; static const wchar_t* gc_EnvMemoryLimit = L"X2T_MEMORY_LIMIT"; - static const wchar_t* gc_EnvMemoryLimitDefault = L"4GiB"; + static const wchar_t* gc_EnvMemoryLimitDefault = L"3GiB"; KERNEL_DECL std::string GetEnvVariableA(const std::wstring& strName); KERNEL_DECL std::wstring GetEnvVariable(const std::wstring& strName); diff --git a/DesktopEditor/graphics/commands/AnnotField.cpp b/DesktopEditor/graphics/commands/AnnotField.cpp index 4b1c691215..6230f300a5 100644 --- a/DesktopEditor/graphics/commands/AnnotField.cpp +++ b/DesktopEditor/graphics/commands/AnnotField.cpp @@ -1199,6 +1199,8 @@ bool CWidgetsInfo::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMetafil } if (nFlags & (1 << 9)) pParent->nMaxLen = pReader->ReadInt(); + if (nFlags & (1 << 10)) + pParent->sTU = pReader->ReadString(); m_arrParents.push_back(pParent); } @@ -1207,7 +1209,10 @@ bool CWidgetsInfo::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMetafil for (int i = 0; i < n; ++i) { std::string sImagePath = pReader->ReadStringA(); - m_arrButtonImg.push_back(pCorrector->GetImagePath(UTF8_TO_U(sImagePath))); + std::wstring sImage = UTF8_TO_U(sImagePath); + if (sImagePath.find("data:") != 0 && !sImagePath.empty()) + sImage = pCorrector->GetImagePath(sImage); + m_arrButtonImg.push_back(sImage); } return true; diff --git a/DesktopEditor/graphics/commands/AnnotField.h b/DesktopEditor/graphics/commands/AnnotField.h index cdb0b18de8..3044a374e2 100644 --- a/DesktopEditor/graphics/commands/AnnotField.h +++ b/DesktopEditor/graphics/commands/AnnotField.h @@ -604,6 +604,7 @@ public: std::wstring sName; std::wstring sV; std::wstring sDV; + std::wstring sTU; std::vector arrI; std::vector arrV; std::vector arrAction; diff --git a/DesktopEditor/graphics/pro/js/wasm/js/drawingfile.js b/DesktopEditor/graphics/pro/js/wasm/js/drawingfile.js index a22689bb10..cd29b55f09 100644 --- a/DesktopEditor/graphics/pro/js/wasm/js/drawingfile.js +++ b/DesktopEditor/graphics/pro/js/wasm/js/drawingfile.js @@ -450,13 +450,10 @@ function readAction(reader, rec, readDoubleFunc, readStringFunc) } function readAnnot(reader, rec, readDoubleFunc, readDouble2Func, readStringFunc, isRead = false) { - if (!isRead) - rec["AP"] = {}; + rec["AP"] = {}; // Annot // number for relations with AP - let APi = reader.readInt(); - if (!isRead) - rec["AP"]["i"] = APi; + rec["AP"]["i"] = reader.readInt(); rec["annotflag"] = reader.readInt(); // 12.5.3 let bHidden = (rec["annotflag"] >> 1) & 1; // Hidden @@ -539,10 +536,7 @@ function readAnnot(reader, rec, readDoubleFunc, readDouble2Func, readStringFunc, if (flags & (1 << 6)) { if (isRead) - { - let APrender = reader.readData(); // TODO use Render - Uint8Array - // rec["AP"]["render"] = APrender; - } + rec["AP"]["render"] = reader.readData(); // TODO use Render - Uint8Array else rec["AP"]["have"] = (flags >> 6) & 1; } @@ -1049,7 +1043,7 @@ function readWidgetType(reader, rec, readDoubleFunc, readDouble2Func, readString let flags = reader.readInt(); // Alternative field name, used in tooltip and error messages - TU if (flags & (1 << 0)) - rec["userName"] = readStringFunc.call(reader); + rec["tooltip"] = readStringFunc.call(reader); // Default style string (CSS2 format) - DS if (flags & (1 << 1)) rec["defaultStyle"] = readStringFunc.call(reader); @@ -1180,15 +1174,9 @@ function readWidgetType(reader, rec, readDoubleFunc, readDouble2Func, readString if (isRead) { if (flags & (1 << 12)) - { - let APV = readStringFunc.call(reader); - // rec["AP"]["V"] = APV; - } + rec["AP"]["V"] = readStringFunc.call(reader); if (flags & (1 << 13)) - { - let APrender = reader.readData(); // TODO use Render - Uint8Array - // rec["AP"]["render"] = APrender; - } + rec["AP"]["render"] = reader.readData(); // TODO use Render - Uint8Array } // 12.7.4.3 if (rec["flag"] >= 0) @@ -1225,10 +1213,7 @@ function readWidgetType(reader, rec, readDoubleFunc, readDouble2Func, readString if (isRead) { if (flags & (1 << 12)) - { - let APV = readStringFunc.call(reader); - // rec["AP"]["V"] = APV; - } + rec["AP"]["V"] = readStringFunc.call(reader); } else { @@ -1257,10 +1242,7 @@ function readWidgetType(reader, rec, readDoubleFunc, readDouble2Func, readString rec["I"].push(reader.readInt()); } if (flags & (1 << 15)) - { - let APrender = reader.readData(); // TODO use Render - Uint8Array - // rec["AP"]["render"] = APrender; - } + rec["AP"]["render"] = reader.readData(); // TODO use Render - Uint8Array } // 12.7.4.4 if (rec["flag"] >= 0) @@ -1378,6 +1360,8 @@ CFile.prototype["getInteractiveFormsInfo"] = function() } if (flags & (1 << 9)) rec["maxLen"] = reader.readInt(); + if (flags & (1 << 10)) + rec["tooltip"] = reader.readString(); res["Parents"].push(rec); } @@ -1589,35 +1573,50 @@ CFile.prototype["readAnnotationsInfoFromBinary"] = function(AnnotInfo) let reader = new CBinaryReader(AnnotInfo, 0, AnnotInfo.length); if (!reader) return []; - let res = []; + let res = { annots:[], imgs:[] }; while (reader.isValid()) { let nCommand = reader.readByte(); let nPos = reader.pos; let nSize = reader.readInt(); - if (nCommand != 164) // ctAnnotField + if (nCommand == 164) // ctAnnotField + { + let rec = {}; + // Annotation type + // 0 - Text, 1 - Link, 2 - FreeText, 3 - Line, 4 - Square, 5 - Circle, + // 6 - Polygon, 7 - PolyLine, 8 - Highlight, 9 - Underline, 10 - Squiggly, + // 11 - Strikeout, 12 - Stamp, 13 - Caret, 14 - Ink, 15 - Popup, 16 - FileAttachment, + // 17 - Sound, 18 - Movie, 19 - Widget, 20 - Screen, 21 - PrinterMark, + // 22 - TrapNet, 23 - Watermark, 24 - 3D, 25 - Redact + rec["type"] = reader.readByte(); + // Annot + readAnnot(reader, rec, reader.readDouble3, reader.readDouble3, reader.readString2, true); + // Annot type + readAnnotType(reader, rec, reader.readDouble3, reader.readDouble3, reader.readString2, true); + if (rec["type"] >= 26 && rec["type"] <= 33) + { + // Widget type + readWidgetType(reader, rec, reader.readDouble3, reader.readDouble3, reader.readString2, true); + } + res.annots.push(rec); + } + else if (nCommand == 166) // ctWidgetsInfo + { + reader.readInt(); // CO must be 0 + reader.readInt(); // Parents must be 0 + // ButtonImg + let n = reader.readInt(); + for (let i = 0; i < n; ++i) + { + let data = reader.readString(); + res.imgs.push(data); + } + } + else { reader.pos = nPos + nSize; continue; } - let rec = {}; - // Annotation type - // 0 - Text, 1 - Link, 2 - FreeText, 3 - Line, 4 - Square, 5 - Circle, - // 6 - Polygon, 7 - PolyLine, 8 - Highlight, 9 - Underline, 10 - Squiggly, - // 11 - Strikeout, 12 - Stamp, 13 - Caret, 14 - Ink, 15 - Popup, 16 - FileAttachment, - // 17 - Sound, 18 - Movie, 19 - Widget, 20 - Screen, 21 - PrinterMark, - // 22 - TrapNet, 23 - Watermark, 24 - 3D, 25 - Redact - rec["type"] = reader.readByte(); - // Annot - readAnnot(reader, rec, reader.readDouble3, reader.readDouble3, reader.readString2, true); - // Annot type - readAnnotType(reader, rec, reader.readDouble3, reader.readDouble3, reader.readString2, true); - if (rec["type"] >= 26 && rec["type"] <= 33) - { - // Widget type - readWidgetType(reader, rec, reader.readDouble3, reader.readDouble3, reader.readString2, true); - } - res.push(rec); } return res; diff --git a/DesktopEditor/graphics/pro/js/wasm/src/drawingfile_test.cpp b/DesktopEditor/graphics/pro/js/wasm/src/drawingfile_test.cpp index 9d7888b1c2..a62f7ee2ed 100644 --- a/DesktopEditor/graphics/pro/js/wasm/src/drawingfile_test.cpp +++ b/DesktopEditor/graphics/pro/js/wasm/src/drawingfile_test.cpp @@ -415,6 +415,13 @@ void ReadInteractiveForms(BYTE* pWidgets, int& i) i += 4; std::cout << "MaxLen " << nPathLength << ", "; } + if (nFlags & (1 << 10)) + { + nPathLength = READ_INT(pWidgets + i); + i += 4; + std::cout << "TU " << std::string((char*)(pWidgets + i), nPathLength) << ", "; + i += nPathLength; + } std::cout << std::endl; } diff --git a/HwpFile/HWPFile.pro b/HwpFile/HWPFile.pro index f1d3d1318d..89dfe87fae 100644 --- a/HwpFile/HWPFile.pro +++ b/HwpFile/HWPFile.pro @@ -99,8 +99,8 @@ SOURCES += \ HEADERS += \ HWPFile.h \ HwpDoc/Common/Common.h \ - HwpDoc/Common/XMLNode.h \ HwpDoc/Common/WriterContext.h \ + HwpDoc/Common/XMLReader.h \ HwpDoc/Conversion/ConversionState.h \ HwpDoc/Conversion/Converter2OOXML.h \ HwpDoc/Conversion/FootnoteConverter.h \ diff --git a/HwpFile/HwpDoc/Common/XMLNode.h b/HwpFile/HwpDoc/Common/XMLNode.h deleted file mode 100644 index 518ea10488..0000000000 --- a/HwpFile/HwpDoc/Common/XMLNode.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef XMLNODEH_H -#define XMLNODEH_H - -#include "../../../DesktopEditor/xml/include/xmlutils.h" - -namespace HWP -{ -class CXMLNode : public XmlUtils::CXmlNode -{ -public: - CXMLNode(); - CXMLNode(const XmlUtils::CXmlNode& oNode); - - bool GetAttributeBool(const std::wstring& wsName); - int GetAttributeColor(const std::wstring& wsName, const int& _default = 0x00000000); - CXMLNode GetChild(const std::wstring& wsName); - std::vector GetChilds(); - std::vector GetChilds(const std::wstring& wsName); -}; - -int ConvertWidthToHWP(const std::wstring& wsValue); -int ConvertHexToInt(const std::string& wsValue, const int& _default = 0x00000000); -} - -#endif // XMLNODEH_H diff --git a/HwpFile/HwpDoc/Common/XMLReader.cpp b/HwpFile/HwpDoc/Common/XMLReader.cpp index 82d133855b..ea0312480e 100644 --- a/HwpFile/HwpDoc/Common/XMLReader.cpp +++ b/HwpFile/HwpDoc/Common/XMLReader.cpp @@ -1,86 +1,299 @@ -#include "XMLNode.h" +#include "XMLReader.h" +#include namespace HWP { -CXMLNode::CXMLNode() - : XmlUtils::CXmlNode() +CXMLReader::CXMLReader() + : m_pReader(new XmlUtils::CXmlLiteReader), m_bParseAttribute(false) {} -CXMLNode::CXMLNode(const CXmlNode& oNode) - : XmlUtils::CXmlNode(oNode) -{} - -bool CXMLNode::GetAttributeBool(const std::wstring& wsName) +CXMLReader::~CXMLReader() { - return L"1" == XmlUtils::CXmlNode::GetAttribute(wsName, L"0"); + if (nullptr != m_pReader) + delete m_pReader; } -int CXMLNode::GetAttributeColor(const std::wstring& wsName, const int& _default) +XmlUtils::CXmlLiteReader* CXMLReader::GetReader() { - return ConvertHexToInt(XmlUtils::CXmlNode::GetAttributeA(wsName), _default); + return m_pReader; } -CXMLNode CXMLNode::GetChild(const std::wstring& wsName) +unsigned int CXMLReader::GetDepth() { - return CXMLNode(XmlUtils::CXmlNode::GetNode(wsName)); + return (nullptr != m_pReader) ? m_pReader->GetDepth() : 0; } -std::vector CXMLNode::GetChilds() +bool CXMLReader::IsEmptyNode() { - std::vector arChilds; - XmlUtils::CXmlNode::GetChilds(arChilds); - - std::vector arNewChilds(arChilds.size()); - for (unsigned int unIndex = 0; unIndex < arChilds.size(); ++unIndex) - arNewChilds[unIndex] = CXMLNode(arChilds[unIndex]); - - return arNewChilds; + return (nullptr != m_pReader) ? m_pReader->IsEmptyNode() : true; } -std::vector CXMLNode::GetChilds(const std::wstring& wsName) +bool CXMLReader::GetBool() { - std::vector arChilds{XmlUtils::CXmlNode::GetNodes(wsName)}; - - std::vector arNewChilds(arChilds.size()); - for (unsigned int unIndex = 0; unIndex < arChilds.size(); ++unIndex) - arNewChilds[unIndex] = CXMLNode(arChilds[unIndex]); - - return arNewChilds; + return "1" == GetTextAValue(*this); } -int ConvertWidthToHWP(const std::wstring& wsValue) +int CXMLReader::GetColor(const int& nDefault) { - if (wsValue.empty() || L"0.1" == wsValue || L"0.1 mm" == wsValue) + return ConvertHexToInt(GetTextAValue(*this), nDefault); +} + +int CXMLReader::GetInt() +{ + return GetIntValue(*this); +} + +double CXMLReader::GetDouble() +{ + return GetDoubleValue(*this); +} + +std::string CXMLReader::GetTextA() +{ + if (nullptr == m_pReader) + return std::string(); + + return (m_bParseAttribute) ? m_pReader->GetTextA() : m_pReader->GetText2A(); +} + +std::wstring CXMLReader::GetText() +{ + if (nullptr == m_pReader) + return std::wstring(); + + return (m_bParseAttribute) ? m_pReader->GetText() : m_pReader->GetText2(); +} + +const char* CXMLReader::GetTextChar() +{ + if (nullptr == m_pReader) + return ""; + + return m_pReader->GetTextChar(); +} + +template +T CXMLReader::GetAttribute(const std::string& sName, T _default, T (*GetValue)(CXMLReader&)) +{ + if (!MoveToFirstAttribute()) + return _default; + + T oValue = _default; + + do + { + if (sName == m_pReader->GetNameA()) + { + oValue = GetValue(*this); + break; + } + }while(m_pReader->MoveToNextAttribute()); + + MoveToElement(); + + return oValue; +} + +int CXMLReader::GetAttributeInt(const std::string& sName, int nDefault) +{ + return GetAttribute(sName, nDefault, &GetIntValue); +} + +bool CXMLReader::GetAttributeBool(const std::string& sName) +{ + return GetAttribute(sName, false, &GetBoolValue); +} + +double CXMLReader::GetAttributeDouble(const std::string& sName) +{ + return GetAttribute(sName, 0., &GetDoubleValue); +} + +std::string CXMLReader::GetAttributeA(const std::string& sName) +{ + return GetAttribute(sName, "", &GetTextAValue); +} + +std::wstring CXMLReader::GetAttribute(const std::string& sName) +{ + return GetAttribute(sName, L"", &GetTextValue); +} + +bool CXMLReader::MoveToFirstAttribute() +{ + if (nullptr == m_pReader || !m_pReader->MoveToFirstAttribute()) + return false; + + m_bParseAttribute = true; + + return true; +} + +bool CXMLReader::MoveToNextAttribute() +{ + return (nullptr != m_pReader) ? m_pReader->MoveToNextAttribute() : false; +} + +bool CXMLReader::MoveToElement() +{ + if (nullptr == m_pReader || !m_pReader->MoveToElement()) + return false; + + m_bParseAttribute = false; + + return true; +} + +std::wstring CXMLReader::GetInnerXml() +{ + return m_pReader->GetInnerXml(); +} + +std::string CXMLReader::GetName() +{ + return (nullptr != m_pReader) ? m_pReader->GetNameA() : std::string(); +} + +bool CXMLReader::ReadNextSiblingNode(unsigned int unDepth) +{ + return (nullptr != m_pReader) ? m_pReader->ReadNextSiblingNode(unDepth) : false; +} + +bool CXMLReader::ReadNextNode() +{ + return (nullptr != m_pReader) ? m_pReader->ReadNextNode() : false; +} + +bool CXMLReader::Read(XmlUtils::XmlNodeType& eNodeType) +{ + return (nullptr != m_pReader) ? m_pReader->Read(eNodeType) : false; +} + +int CXMLReader::GetIntValue(CXMLReader& oXmlReader) +{ + return std::atoi(oXmlReader.GetTextA().c_str()); +} + +bool CXMLReader::GetBoolValue(CXMLReader& oXmlReader) +{ + return "1" == oXmlReader.GetTextA(); +} + +double CXMLReader::GetDoubleValue(CXMLReader& oXmlReader) +{ + const std::string sValue{oXmlReader.GetTextA()}; + const char* pCur = sValue.c_str(); + + while (std::isspace(*pCur)) + ++pCur; + + if (!pCur) + return 0.; + + bool bNegative = false; + + while ('-' == *pCur || '+' == *pCur) + { + if ('-' == *pCur) + bNegative = !bNegative; + + ++pCur; + } + + if (!pCur) + return 0.; + + double dResult = 0.; + + while (std::isdigit(*pCur)) + dResult = dResult * 10. + (*pCur++ - '0'); + + if (',' == *pCur || '.' == *pCur) + { + ++pCur; + + double dFraction = 0.0; + double dDivisor = 1.0; + + while (std::isdigit(*pCur)) + { + dFraction = dFraction * 10. + (*pCur++ - '0'); + dDivisor *= 10; + } + + dResult += dFraction / dDivisor; + } + + if ('e' == *pCur || 'E' == *pCur) + { + ++pCur; + + bool bExpNegative = false; + while ('-' == *pCur || '+' == *pCur) + { + if ('-' == *pCur) + bExpNegative = !bExpNegative; + + ++pCur; + } + + int nExponent = 0; + + while (std::isdigit(*pCur)) + nExponent = nExponent * 10 + (*pCur++ - '0'); + + if (bExpNegative) + nExponent = -nExponent; + + dResult *= std::pow(10., nExponent); + } + + return bNegative ? -dResult : dResult; +} + +std::string CXMLReader::GetTextAValue(CXMLReader& oXmlReader) +{ + return oXmlReader.GetTextA(); +} + +std::wstring CXMLReader::GetTextValue(CXMLReader& oXmlReader) +{ + return oXmlReader.GetText(); +} + +int ConvertWidthToHWP(const std::string& sValue) +{ + if (sValue.empty() || "0.1" == sValue || "0.1 mm" == sValue) return 0; - else if (L"0.12" == wsValue || L"0.12 mm" == wsValue) + else if ("0.12" == sValue || "0.12 mm" == sValue) return 1; - else if (L"0.15" == wsValue || L"0.15 mm" == wsValue) + else if ("0.15" == sValue || "0.15 mm" == sValue) return 2; - else if (L"0.2" == wsValue || L"0.2 mm" == wsValue) + else if ("0.2" == sValue || "0.2 mm" == sValue) return 3; - else if (L"0.25" == wsValue || L"0.25 mm" == wsValue) + else if ("0.25" == sValue || "0.25 mm" == sValue) return 4; - else if (L"0.3" == wsValue || L"0.3 mm" == wsValue) + else if ("0.3" == sValue || "0.3 mm" == sValue) return 5; - else if (L"0.4" == wsValue || L"0.4 mm" == wsValue) + else if ("0.4" == sValue || "0.4 mm" == sValue) return 6; - else if (L"0.5" == wsValue || L"0.5 mm" == wsValue) + else if ("0.5" == sValue || "0.5 mm" == sValue) return 7; - else if (L"0.6" == wsValue || L"0.6 mm" == wsValue) + else if ("0.6" == sValue || "0.6 mm" == sValue) return 8; - else if (L"0.7" == wsValue || L"0.7 mm" == wsValue) + else if ("0.7" == sValue || "0.7 mm" == sValue) return 9; - else if (L"1.0" == wsValue || L"1.0 mm" == wsValue) + else if ("1.0" == sValue || "1.0 mm" == sValue) return 10; - else if (L"1.5" == wsValue || L"1.5 mm" == wsValue) + else if ("1.5" == sValue || "1.5 mm" == sValue) return 11; - else if (L"2.0" == wsValue || L"2.0 mm" == wsValue) + else if ("2.0" == sValue || "2.0 mm" == sValue) return 12; - else if (L"3.0" == wsValue || L"3.0 mm" == wsValue) + else if ("3.0" == sValue || "3.0 mm" == sValue) return 13; - else if (L"4.0" == wsValue || L"4.0 mm" == wsValue) + else if ("4.0" == sValue || "4.0 mm" == sValue) return 14; - else if (L"5.0" == wsValue || L"5.0 mm" == wsValue) + else if ("5.0" == sValue || "5.0 mm" == sValue) return 15; return 0; diff --git a/HwpFile/HwpDoc/Common/XMLReader.h b/HwpFile/HwpDoc/Common/XMLReader.h new file mode 100644 index 0000000000..2ee8b0ca48 --- /dev/null +++ b/HwpFile/HwpDoc/Common/XMLReader.h @@ -0,0 +1,110 @@ +#ifndef XMLNODEH_H +#define XMLNODEH_H + +#include "../../../DesktopEditor/xml/include/xmlutils.h" + +namespace HWP +{ +class CXMLReader +{ + XmlUtils::CXmlLiteReader *m_pReader; + + bool m_bParseAttribute; +public: + CXMLReader(); + ~CXMLReader(); + + XmlUtils::CXmlLiteReader* GetReader(); + unsigned int GetDepth(); + bool IsEmptyNode(); + + bool GetBool(); + int GetColor(const int& nDefault = 0x000000); + int GetInt(); + double GetDouble(); + std::string GetTextA(); + std::wstring GetText(); + const char* GetTextChar(); + + int GetAttributeInt(const std::string& sName, int nDefault = 0); + bool GetAttributeBool(const std::string& sName); + double GetAttributeDouble(const std::string& sName); + std::string GetAttributeA(const std::string& sName); + std::wstring GetAttribute(const std::string& sName); + + bool MoveToFirstAttribute(); + bool MoveToNextAttribute(); + bool MoveToElement(); + + std::wstring GetInnerXml(); + + std::string GetName(); + bool ReadNextSiblingNode(unsigned int unDepth); + bool ReadNextNode(); + bool Read(XmlUtils::XmlNodeType& eNodeType); +private: + static int GetIntValue(CXMLReader& oXmlReader); + static bool GetBoolValue(CXMLReader& oXmlReader); + static double GetDoubleValue(CXMLReader& oXmlReader); + static std::string GetTextAValue(CXMLReader& oXmlReader); + static std::wstring GetTextValue(CXMLReader& oXmlReader); + + template + T GetAttribute(const std::string& sName, T _default, T (*GetValue)(CXMLReader& oXmlReader)); +}; + +#define WHILE_READ_NEXT_NODE_WITH_DEPTH(xml_reader, name_depth)\ + if (!xml_reader.IsEmptyNode())\ + {\ + const int n##name_depth = xml_reader.GetDepth();\ + while (xml_reader.ReadNextSiblingNode(n##name_depth))\ + { + +#define WHILE_READ_NEXT_NODE_WITH_DEPTH_AND_NAME(xml_reader, name_depth)\ + if (!xml_reader.IsEmptyNode())\ + {\ + const int n##name_depth##Depth = xml_reader.GetDepth();\ + std::string sNode##name_depth##Name;\ + while (xml_reader.ReadNextSiblingNode(n##name_depth##Depth))\ + {\ + sNode##name_depth##Name = xml_reader.GetName(); + +#define WHILE_READ_NEXT_NODE(xml_reader) WHILE_READ_NEXT_NODE_WITH_DEPTH(xml_reader, Depth) + +#define WHILE_READ_NEXT_NODE_WITH_NAME(xml_reader)\ + if (!xml_reader.IsEmptyNode())\ + {\ + const int nDepth = xml_reader.GetDepth();\ + std::string sNodeName;\ + while (xml_reader.ReadNextSiblingNode(nDepth))\ + {\ + sNodeName = xml_reader.GetName(); + +#define WHILE_READ_NEXT_NODE_WITH_DEPTH_ONE_NAME(xml_reader, name_depth, node_name)\ + WHILE_READ_NEXT_NODE_WITH_DEPTH(xml_reader, name_depth)\ + if (node_name != xml_reader.GetName())\ + continue; + +#define WHILE_READ_NEXT_NODE_WITH_ONE_NAME(xml_reader, node_name) WHILE_READ_NEXT_NODE_WITH_DEPTH_ONE_NAME(xml_reader, Depth, node_name) + +#define END_WHILE } } + +#define START_READ_ATTRIBUTES(xml_reader)\ + if (xml_reader.MoveToFirstAttribute())\ + {\ + std::string sAttributeName;\ + do\ + {\ + sAttributeName = xml_reader.GetName(); + +#define END_READ_ATTRIBUTES(xml_reader)\ + }\ + while(xml_reader.MoveToNextAttribute());\ + xml_reader.MoveToElement();\ + } + +int ConvertWidthToHWP(const std::string& sValue); +int ConvertHexToInt(const std::string& sValue, const int& _default = 0x00000000); +} + +#endif // XMLNODEH_H diff --git a/HwpFile/HwpDoc/Conversion/Converter2OOXML.cpp b/HwpFile/HwpDoc/Conversion/Converter2OOXML.cpp index 06250710e0..6a8a1126b5 100644 --- a/HwpFile/HwpDoc/Conversion/Converter2OOXML.cpp +++ b/HwpFile/HwpDoc/Conversion/Converter2OOXML.cpp @@ -321,6 +321,12 @@ void CConverter2OOXML::WriteCharacter(const CCtrlCharacter* pCharacter, short sh oState.m_eBreakType = TConversionState::EBreakType::TextWrapping; break; } + case ECtrlCharType::TABULATION: + { + OpenParagraph(shParaShapeID, shParaStyleID, oBuilder, oState); + oBuilder.WriteString(L""); + break; + } case ECtrlCharType::HARD_HYPHEN: case ECtrlCharType::HARD_SPACE: break; @@ -670,6 +676,60 @@ void CConverter2OOXML::WriteParaShapeProperties(short shParaShapeID, short shPar case EHeadingType::NONE: break; } + + if (oState.m_bInTable) + return; + + const CHwpRecordTabDef* pTabDef = m_pContext->GetTabDef(pParaShape->GetTabDef()); + + if (nullptr != pTabDef && 0 != pTabDef->GetCount()) + { + oBuilder.WriteString(L""); + + const TTab *pTab = nullptr; + for (unsigned int unIndex = 0; unIndex < pTabDef->GetCount(); ++unIndex) + { + pTab = pTabDef->GetTab(unIndex); + + if (nullptr == pTab) + continue; + + oBuilder.WriteString(L"m_eType) + { + case TTab::EType::LEFT: oBuilder.WriteString(L"start"); break; + case TTab::EType::RIGHT: oBuilder.WriteString(L"end"); break; + case TTab::EType::CENTER: oBuilder.WriteString(L"center"); break; + case TTab::EType::DECIMAL: oBuilder.WriteString(L"decimal"); break; + } + + oBuilder.WriteString(L"\" w:leader=\""); + + switch (pTab->m_eLeader) + { + case ELineStyle2::NONE: oBuilder.WriteString(L"none"); break; + case ELineStyle2::SOLID: + case ELineStyle2::DOUBLE_SLIM: + case ELineStyle2::SLIM_THICK: + case ELineStyle2::THICK_SLIM: + case ELineStyle2::SLIM_THICK_SLIM: + oBuilder.WriteString(L"heavy"); break; + case ELineStyle2::DASH: + case ELineStyle2::LONG_DASH: + case ELineStyle2::DASH_DOT: + case ELineStyle2::DASH_DOT_DOT: + oBuilder.WriteString(L"hyphen"); break; + case ELineStyle2::DOT: + case ELineStyle2::CIRCLE: + oBuilder.WriteString(L"dot"); break; + } + + oBuilder.WriteString(L"\" w:pos=\"" + std::to_wstring(pTab->m_nPos / 10) + L"\"/>"); + } + + oBuilder.WriteString(L""); + } } void CConverter2OOXML::WriteTable(const CCtrlTable* pTable, short shParaShapeID, short shParaStyleID, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState) @@ -1362,83 +1422,18 @@ bool CConverter2OOXML::SaveSVGFile(const HWP_STRING& sSVG, HWP_STRING& sFileName return false; } - NSGraphics::IGraphicsRenderer* pGrRenderer = NSGraphics::Create(); - pGrRenderer->SetFontManager(pSvgReader->get_FontManager()); - double dX, dY, dW, dH; pSvgReader->GetBounds(&dX, &dY, &dW, &dH); if (dW < 0) dW = -dW; if (dH < 0) dH = -dH; - double dOneMaxSize = (double)1000.; - - if (dW > dH && dW > dOneMaxSize) - { - dH *= (dOneMaxSize / dW); - dW = dOneMaxSize; - } - else if (dH > dW && dH > dOneMaxSize) - { - dW *= (dOneMaxSize / dH); - dH = dOneMaxSize; - } - - int nWidth = static_cast(dW + 0.5); - int nHeight = static_cast(dH + 0.5); - - double dWidth = 25.4 * nWidth / 96; - double dHeight = 25.4 * nHeight / 96; - - unsigned char* pBgraData = (unsigned char*)malloc(nWidth * nHeight * 4); - if (!pBgraData) - { - double dKoef = 2000.0 / (nWidth > nHeight ? nWidth : nHeight); - - nWidth = (int)(dKoef * nWidth); - nHeight = (int)(dKoef * nHeight); - - dWidth = 25.4 * nWidth / 96; - dHeight = 25.4 * nHeight / 96; - - pBgraData = (unsigned char*)malloc(nWidth * nHeight * 4); - } - - if (!pBgraData) - return false; - - unsigned int alfa = 0xffffff; - //дефолтный тон должен быть прозрачным, а не белым - //memset(pBgraData, 0xff, nWidth * nHeight * 4); - for (int i = 0; i < nWidth * nHeight; i++) - { - ((unsigned int*)pBgraData)[i] = alfa; - } - - CBgraFrame oFrame; - oFrame.put_Data(pBgraData); - oFrame.put_Width(nWidth); - oFrame.put_Height(nHeight); - oFrame.put_Stride(-4 * nWidth); - - pGrRenderer->CreateFromBgraFrame(&oFrame); - pGrRenderer->SetSwapRGB(false); - pGrRenderer->put_Width(dWidth); - pGrRenderer->put_Height(dHeight); - - pSvgReader->SetTempDirectory(m_sTempDirectory); - pSvgReader->DrawOnRenderer(pGrRenderer, 0, 0, dWidth, dHeight); - sFileName = sFileName.substr(0, sFileName.find(L'.')); sFileName += L".png"; - oFrame.SaveFile(m_sTempDirectory + L"/word/media/" + sFileName, 4); - oFrame.put_Data(NULL); + const std::wstring wsImagePath{m_sTempDirectory + L"/word/media/" + sFileName}; - RELEASEINTERFACE(pGrRenderer); - - if (pBgraData) - free(pBgraData); + pSvgReader->ConvertToRaster(wsImagePath.c_str(), 4, dW, dH); RELEASEINTERFACE(pSvgReader); RELEASEINTERFACE(pFonts); diff --git a/HwpFile/HwpDoc/Conversion/Converter2OOXML.h b/HwpFile/HwpDoc/Conversion/Converter2OOXML.h index 10510e1887..51f016ecc4 100644 --- a/HwpFile/HwpDoc/Conversion/Converter2OOXML.h +++ b/HwpFile/HwpDoc/Conversion/Converter2OOXML.h @@ -24,8 +24,6 @@ namespace HWP { - - struct TContentType { HWP_STRING m_wsName; diff --git a/HwpFile/HwpDoc/HWPDocInfo.cpp b/HwpFile/HwpDoc/HWPDocInfo.cpp index 09d461a450..78bc3277e0 100644 --- a/HwpFile/HwpDoc/HWPDocInfo.cpp +++ b/HwpFile/HwpDoc/HWPDocInfo.cpp @@ -182,81 +182,94 @@ bool CHWPDocInfo::Parse(CHWPStream& oBuffer, int nVersion) return true; } -bool CHWPDocInfo::Parse(CXMLNode& oNode, int nVersion) +bool CHWPDocInfo::Parse(CXMLReader& oReader, int nVersion) { - for (CXMLNode& oChild : oNode.GetChilds()) + WHILE_READ_NEXT_NODE_WITH_NAME(oReader) { - if (L"hh:beginNum" == oChild.GetName()) - m_arRecords.push_back(new CHWPRecordDocumentProperties(*this, oChild, nVersion)); - else if (L"hh:refList" == oChild.GetName()) - ReadRefList(oChild, nVersion); + if ("hh:beginNum" == sNodeName) + m_arRecords.push_back(new CHWPRecordDocumentProperties(*this, oReader, nVersion)); + else if ("hh:refList" == sNodeName) + ReadRefList(oReader, nVersion); } + END_WHILE return true; } -bool CHWPDocInfo::ReadRefList(CXMLNode& oNode, int nVersion) +bool CHWPDocInfo::ReadRefList(CXMLReader& oReader, int nVersion) { - for (CXMLNode& oChild : oNode.GetChilds()) + WHILE_READ_NEXT_NODE_WITH_NAME(oReader) { - if (L"hh:fontfaces" == oChild.GetName()) + if ("hh:fontfaces" == sNodeName) { - for (CXMLNode& oFontFaceNode : oChild.GetChilds(L"hh:fontface")) - for (CXMLNode& oFontNode : oFontFaceNode.GetChilds(L"hh:font")) - m_arFaseNames.push_back(new CHWPRecordFaceName(*this, oFontNode, nVersion)); + WHILE_READ_NEXT_NODE_WITH_DEPTH_ONE_NAME(oReader, FontFace, "hh:fontface") + WHILE_READ_NEXT_NODE_WITH_DEPTH_ONE_NAME(oReader, Font, "hh:font") + m_arFaseNames.push_back(new CHWPRecordFaceName(*this, oReader, nVersion)); + END_WHILE + END_WHILE } - else if (L"hh:borderFills" == oChild.GetName()) + else if ("hh:borderFills" == sNodeName) { - for (CXMLNode& oBorderFillNode : oChild.GetChilds(L"hh:borderFill")) - m_arBorderFills.push_back(new CHWPRecordBorderFill(*this, oBorderFillNode, nVersion)); + WHILE_READ_NEXT_NODE_WITH_DEPTH_ONE_NAME(oReader, BorderFill, "hh:borderFill") + m_arBorderFills.push_back(new CHWPRecordBorderFill(*this, oReader, nVersion)); + END_WHILE } - else if (L"hh:charProperties" == oChild.GetName()) + else if ("hh:charProperties" == sNodeName) { - for (CXMLNode& oCharPrNode : oChild.GetChilds(L"hh:charPr")) - m_arCharShapes.push_back(new CHWPRecordCharShape(*this, oCharPrNode, nVersion)); + WHILE_READ_NEXT_NODE_WITH_DEPTH_ONE_NAME(oReader, CharPr, "hh:charPr") + m_arCharShapes.push_back(new CHWPRecordCharShape(*this, oReader, nVersion)); + END_WHILE } - else if (L"hh:tabProperties" == oChild.GetName()) + else if ("hh:tabProperties" == sNodeName) { - for (CXMLNode& oTabPrNode : oChild.GetChilds(L"hh:tabPr")) - m_arTabDefs.push_back(new CHwpRecordTabDef(*this, oTabPrNode, nVersion)); + WHILE_READ_NEXT_NODE_WITH_DEPTH_ONE_NAME(oReader, TabPr, "hh:tabPr") + m_arTabDefs.push_back(new CHwpRecordTabDef(*this, oReader, nVersion)); + END_WHILE } - else if (L"hh:numberings" == oChild.GetName()) + else if ("hh:numberings" == sNodeName) { - for (CXMLNode& oNumberingNode : oChild.GetChilds(L"hh:numbering")) - m_arNumberings.push_back(new CHWPRecordNumbering(*this, oNumberingNode, nVersion)); + WHILE_READ_NEXT_NODE_WITH_DEPTH_ONE_NAME(oReader, Numbering, "hh:numbering") + m_arNumberings.push_back(new CHWPRecordNumbering(*this, oReader, nVersion)); + END_WHILE } - else if (L"hh:bullets" == oChild.GetName()) + else if ("hh:bullets" == sNodeName) { - for (CXMLNode& oBulletNode : oChild.GetChilds()) - m_arBullets.push_back(new CHWPRecordBullet(*this, oBulletNode, nVersion)); + WHILE_READ_NEXT_NODE_WITH_DEPTH(oReader, Bullet) + m_arBullets.push_back(new CHWPRecordBullet(*this, oReader, nVersion)); + END_WHILE } - else if (L"hh:paraProperties" == oChild.GetName()) + else if ("hh:paraProperties" == sNodeName) { - for (CXMLNode& oParaPrNode : oChild.GetChilds(L"hh:paraPr")) - m_arParaShapes.push_back(new CHWPRecordParaShape(*this, oParaPrNode, nVersion)); + WHILE_READ_NEXT_NODE_WITH_DEPTH_ONE_NAME(oReader, ParaPr, "hh:paraPr") + m_arParaShapes.push_back(new CHWPRecordParaShape(*this, oReader, nVersion)); + END_WHILE } - else if (L"hh:styles" == oChild.GetName()) + else if ("hh:styles" == sNodeName) { - for (CXMLNode& oStyleNode : oChild.GetChilds(L"hh:style")) - m_arStyles.push_back(new CHWPRecordStyle(*this, oStyleNode, nVersion)); + WHILE_READ_NEXT_NODE_WITH_DEPTH_ONE_NAME(oReader, Style, "hh:style") + m_arStyles.push_back(new CHWPRecordStyle(*this, oReader, nVersion)); + END_WHILE } } + END_WHILE return true; } -bool CHWPDocInfo::ReadContentHpf(CXMLNode& oNode, int nVersion) +bool CHWPDocInfo::ReadContentHpf(CXMLReader& oReader, int nVersion) { CHWPRecordBinData *pRecordBinData = nullptr; - for (CXMLNode& oChild : oNode.GetChilds(L"opf:manifest")) + WHILE_READ_NEXT_NODE_WITH_ONE_NAME(oReader, "opf:manifest") { - for (CXMLNode& oGrandChild : oChild.GetChilds(L"opf:item")) + WHILE_READ_NEXT_NODE_WITH_DEPTH_ONE_NAME(oReader, Item, "opf:item") { - pRecordBinData = new CHWPRecordBinData(oGrandChild, nVersion); + pRecordBinData = new CHWPRecordBinData(oReader, nVersion); m_mBinDatas.insert(std::make_pair(pRecordBinData->GetItemID(), (HWP::CHWPRecord*)pRecordBinData)); } + END_WHILE } + END_WHILE return true; } diff --git a/HwpFile/HwpDoc/HWPDocInfo.h b/HwpFile/HwpDoc/HWPDocInfo.h index 5f84717996..0f6143cffc 100644 --- a/HwpFile/HwpDoc/HWPDocInfo.h +++ b/HwpFile/HwpDoc/HWPDocInfo.h @@ -4,7 +4,7 @@ #include "HanType.h" #include "HWPStream.h" #include "HWPElements/HWPRecord.h" -#include "Common/XMLNode.h" +#include "Common/XMLReader.h" #include @@ -46,8 +46,8 @@ public: ~CHWPDocInfo(); bool Parse(CHWPStream& oBuffer, int nVersion); - bool Parse(CXMLNode& oNode, int nVersion); - bool ReadContentHpf(CXMLNode& oNode, int nVersion); + bool Parse(CXMLReader& oReader, int nVersion); + bool ReadContentHpf(CXMLReader& oReader, int nVersion); const CHWPRecord* GetRecord(int nIndex) const; const CHWPRecord* GetFaceName(int nIndex) const; @@ -65,7 +65,7 @@ public: EHanType GetHanType() const; ECompatDoc GetCompatibleDoc() const; private: - bool ReadRefList(CXMLNode& oNode, int nVersion); + bool ReadRefList(CXMLReader& oReader, int nVersion); }; } diff --git a/HwpFile/HwpDoc/HWPElements/HWPRecordBinData.cpp b/HwpFile/HwpDoc/HWPElements/HWPRecordBinData.cpp index 53ead34f05..76f2a350b7 100644 --- a/HwpFile/HwpDoc/HWPElements/HWPRecordBinData.cpp +++ b/HwpFile/HwpDoc/HWPElements/HWPRecordBinData.cpp @@ -74,35 +74,41 @@ CHWPRecordBinData::CHWPRecordBinData(CHWPDocInfo& oDocInfo, int nTagNum, int nLe oBuffer.Skip(nSize - oBuffer.GetDistanceToLastPos(true)); } -CHWPRecordBinData::CHWPRecordBinData(CXMLNode& oNode, int nVersion) +CHWPRecordBinData::CHWPRecordBinData(CXMLReader& oReader, int nVersion) : CHWPRecord(EHWPTag::HWPTAG_BIN_DATA, 0, 0) { - m_sItemID = oNode.GetAttribute(L"id"); + std::string sType; + HWP_STRING sSubPath; - HWP_STRING sType = oNode.GetAttribute(L"isEmbeded"); + START_READ_ATTRIBUTES(oReader) + { + if ("id" == sAttributeName) + m_sItemID = oReader.GetText(); + else if ("isEmbeded" == sAttributeName) + sType = oReader.GetTextA(); + else if ("href" == sAttributeName) + m_sAPath = oReader.GetText(); + else if ("sub-path" == sAttributeName) + sSubPath = oReader.GetText(); + else if ("media-type" == sAttributeName) + { + m_sFormat = oReader.GetText(); - if (L"0" == sType) + std::wregex oRegex(L"image/(.*)"); + m_sFormat = std::regex_replace(m_sFormat, oRegex, L"$1"); + } + } + END_READ_ATTRIBUTES(oReader) + + if ("0" == sType) { m_eType = EType::LINK; - m_sAPath = oNode.GetAttribute(L"sub-path"); - - if (m_sAPath.empty()) - m_sAPath = oNode.GetAttribute(L"href"); + if (!sSubPath.empty()) + m_sAPath = sSubPath; } - else if (L"1" == sType) - { + else if ("1" == sType) m_eType = EType::EMBEDDING; - m_sAPath = oNode.GetAttribute(L"href"); - } - else - m_sAPath = oNode.GetAttribute(L"href"); - - m_sFormat = oNode.GetAttribute(L"media-type"); - - std::wregex oRegex(L"image/(.*)"); - - m_sFormat = std::regex_replace(m_sFormat, oRegex, L"$1"); } HWP_STRING CHWPRecordBinData::GetPath() const diff --git a/HwpFile/HwpDoc/HWPElements/HWPRecordBinData.h b/HwpFile/HwpDoc/HWPElements/HWPRecordBinData.h index c225fa3f17..269c8d4203 100644 --- a/HwpFile/HwpDoc/HWPElements/HWPRecordBinData.h +++ b/HwpFile/HwpDoc/HWPElements/HWPRecordBinData.h @@ -4,7 +4,7 @@ #include "HWPRecord.h" #include "../HWPStream.h" #include "../HWPDocInfo.h" -#include "../Common/XMLNode.h" +#include "../Common/XMLReader.h" namespace HWP { @@ -44,7 +44,7 @@ class CHWPRecordBinData : public CHWPRecord HWP_STRING m_sItemID; public: CHWPRecordBinData(CHWPDocInfo& oDocInfo, int nTagNum, int nLevel, int nSize, CHWPStream& oBuffer, int nOff, int nVersion); - CHWPRecordBinData(CXMLNode& oNode, int nVersion); + CHWPRecordBinData(CXMLReader& oReader, int nVersion); HWP_STRING GetPath() const; HWP_STRING GetItemID() const; diff --git a/HwpFile/HwpDoc/HWPElements/HWPRecordBorderFill.cpp b/HwpFile/HwpDoc/HWPElements/HWPRecordBorderFill.cpp index e41b2e4b45..d4f185550b 100644 --- a/HwpFile/HwpDoc/HWPElements/HWPRecordBorderFill.cpp +++ b/HwpFile/HwpDoc/HWPElements/HWPRecordBorderFill.cpp @@ -58,19 +58,26 @@ EColorFillPattern GetColorFillPattern(int nPattern) } } -void TBorder::ReadFromNode(CXMLNode& oNode) +void TBorder::Read(CXMLReader& oReader) { - m_eStyle = GetLineStyle2(oNode.GetAttribute(L"type")); - m_nColor = oNode.GetAttributeColor(L"color"); - m_chWidth = (HWP_BYTE)ConvertWidthToHWP(oNode.GetAttribute(L"width")); + START_READ_ATTRIBUTES(oReader) + { + if ("type" == sAttributeName) + m_eStyle = GetLineStyle2(oReader.GetText()); + else if ("color" == sAttributeName) + m_nColor = oReader.GetInt(); + else if ("width" == sAttributeName) + m_chWidth = (HWP_BYTE)ConvertWidthToHWP(oReader.GetTextA()); + } + END_READ_ATTRIBUTES(oReader) } CFill::CFill() - : m_nFillType(0) + : m_nFillType(0), m_eHatchStyle(EColorFillPattern::NONE), m_eMode(EImageFillType::NONE), m_chAlpha(0xff) {} CFill::CFill(CHWPStream& oBuffer, int nOff, int nSize) - : m_nFillType(0) + : m_nFillType(0), m_eHatchStyle(EColorFillPattern::NONE), m_eMode(EImageFillType::NONE), m_chAlpha(0xff) { oBuffer.SavePosition(); @@ -147,82 +154,117 @@ CFill::CFill(CHWPStream& oBuffer, int nOff, int nSize) m_nSize = oBuffer.GetDistanceToLastPos(true); } -CFill::CFill(CXMLNode& oNode) - : m_nFillType(0) +CFill::CFill(CXMLReader& oReader) + : m_nFillType(0), m_eHatchStyle(EColorFillPattern::NONE), m_eMode(EImageFillType::NONE), m_chAlpha(0xff) { - for (CXMLNode& oChild : oNode.GetChilds()) + WHILE_READ_NEXT_NODE_WITH_NAME(oReader) { - if (L"hc:winBrush" == oChild.GetName()) + if ("hc:winBrush" == sNodeName) { - ReadWinBrush(oChild); + ReadWinBrush(oReader); m_nFillType |= 0x01; } - else if (L"hc:gradation" == oChild.GetName()) + else if ("hc:gradation" == sNodeName) { - ReadGradation(oChild); + ReadGradation(oReader); m_nFillType |= 0x04; } - else if (L"hc:imgBrush" == oChild.GetName()) + else if ("hc:imgBrush" == sNodeName) { - ReadImgBrush(oChild); + ReadImgBrush(oReader); m_nFillType |= 0x02; } } + END_WHILE } -void CFill::ReadWinBrush(CXMLNode& oNode) +void CFill::ReadWinBrush(CXMLReader& oReader) { - m_nFaceColor = oNode.GetAttributeColor(L"faceColor", 0xFFFFFFFF); - m_nHatchColor = oNode.GetAttributeColor(L"hatchColor", 0x000000); - m_eHatchStyle = GetColorFillPattern(oNode.GetAttributeInt(L"hatchStyle", -1)); - m_chAlpha = (HWP_BYTE)oNode.GetAttributeInt(L"alpha", 255); -} + m_eHatchStyle = EColorFillPattern::NONE; + m_chAlpha = 0xff; -void CFill::ReadGradation(CXMLNode& oNode) -{ - m_eGradType = ::HWP::GetGradFillType(oNode.GetAttributeInt(L"type")); - m_nAngle = oNode.GetAttributeInt(L"angle"); - m_nCenterX = oNode.GetAttributeInt(L"centerX"); - m_nCenterY = oNode.GetAttributeInt(L"centerY"); - m_nStep = oNode.GetAttributeInt(L"step"); - m_nColorNum = oNode.GetAttributeInt(L"colorNum"); - m_chStepCenter = (HWP_BYTE)oNode.GetAttributeInt(L"stepCenter"); - m_chAlpha = (HWP_BYTE)oNode.GetAttributeInt(L"alpha", 255); - - std::vector arChilds; - - oNode.GetNodes(L"hc:color", arChilds); - - m_arColors.resize(arChilds.size()); - - for (unsigned int unIndex = 0; unIndex < arChilds.size(); ++unIndex) - m_arColors[unIndex] = CXMLNode(arChilds[unIndex]).GetAttributeColor(L"value"); -} - -void CFill::ReadImgBrush(CXMLNode& oNode) -{ - m_eMode = GetImageFillType(oNode.GetAttributeInt(L"mode", (int)EImageFillType::NONE)); - - for (CXMLNode& oChild : oNode.GetChilds()) + START_READ_ATTRIBUTES(oReader) { - if (L"hc:img" == oChild.GetName()) - { - m_chBright = (HWP_BYTE)oChild.GetAttributeInt(L"bright"); - m_chContrast = (HWP_BYTE)oChild.GetAttributeInt(L"contrast"); - - HWP_STRING sEffect = oChild.GetAttribute(L"effect"); - - if (L"REAL_PIC" == sEffect) - m_chEffect = 0; - else if (L"GRAY_SCALE" == sEffect) - m_chEffect = 1; - else if (L"BLACK_WHITE" == sEffect) - m_chEffect = 2; - - m_sBinItemID = oChild.GetAttribute(L"binaryItemIDRef"); - m_chAlpha = (HWP_BYTE)oChild.GetAttributeInt(L"alpha", 255); - } + if ("faceColor" == sAttributeName) + m_nFaceColor = oReader.GetColor(0xFFFFFFFF); + else if ("hatchColor" == sAttributeName) + m_nHatchColor = oReader.GetColor(); + else if ("hatchStyle" == sAttributeName) + m_eHatchStyle = GetColorFillPattern(oReader.GetInt()); + else if ("alpha" == sAttributeName) + m_chAlpha = (HWP_BYTE)oReader.GetInt(); } + END_READ_ATTRIBUTES(oReader) +} + +void CFill::ReadGradation(CXMLReader& oReader) +{ + START_READ_ATTRIBUTES(oReader) + { + if ("type" == sAttributeName) + m_eGradType = ::HWP::GetGradFillType(oReader.GetInt()); + else if ("angle" == sAttributeName) + m_nAngle = oReader.GetInt(); + else if ("centerX" == sAttributeName) + m_nCenterX = oReader.GetInt(); + else if ("centerY" == sAttributeName) + m_nCenterY = oReader.GetInt(); + else if ("step" == sAttributeName) + m_nStep = oReader.GetInt(); + else if ("colorNum" == sAttributeName) + m_nColorNum = oReader.GetInt(); + else if ("stepCenter" == sAttributeName) + m_chStepCenter = (HWP_BYTE)oReader.GetInt(); + else if ("alpha" == sAttributeName) + m_chAlpha = (HWP_BYTE)oReader.GetInt(); + } + END_READ_ATTRIBUTES(oReader) + + WHILE_READ_NEXT_NODE_WITH_ONE_NAME(oReader, "hc:color") + { + START_READ_ATTRIBUTES(oReader) + { + if ("value" != oReader.GetName()) + continue; + + m_arColors.push_back(oReader.GetColor(true)); + } + END_READ_ATTRIBUTES(oReader) + } + END_WHILE +} + +void CFill::ReadImgBrush(CXMLReader& oReader) +{ + m_eMode = GetImageFillType(oReader.GetAttributeInt("mode")); + + WHILE_READ_NEXT_NODE_WITH_ONE_NAME(oReader, "hc:img") + { + START_READ_ATTRIBUTES(oReader) + { + if ("bright" == sAttributeName) + m_chBright = (HWP_BYTE)oReader.GetInt(); + else if ("contrast" == sAttributeName) + m_chContrast = (HWP_BYTE)oReader.GetInt(); + else if ("effect" == sAttributeName) + { + const std::string sEffect{oReader.GetTextA()}; + + if ("REAL_PIC" == sEffect) + m_chEffect = 0; + else if ("GRAY_SCALE" == sEffect) + m_chEffect = 1; + else if ("BLACK_WHITE" == sEffect) + m_chEffect = 2; + } + else if ("binaryItemIDRef" == sAttributeName) + m_sBinItemID = oReader.GetText(); + else if ("alpha" == sAttributeName) + m_chAlpha = (HWP_BYTE)oReader.GetInt(); + } + END_READ_ATTRIBUTES(oReader) + } + END_WHILE } int CFill::GetSize() const @@ -333,66 +375,88 @@ CHWPRecordBorderFill::CHWPRecordBorderFill(CHWPDocInfo& oDocInfo, int nTagNum, i m_pFill = new CFill(oBuffer, 0, 0); // TODO:: перейти от использования off и size } -CHWPRecordBorderFill::CHWPRecordBorderFill(CHWPDocInfo& oDocInfo, CXMLNode& oNode, int nVersion) +CHWPRecordBorderFill::CHWPRecordBorderFill(CHWPDocInfo& oDocInfo, CXMLReader& oReader, int nVersion) : CHWPRecord(EHWPTag::HWPTAG_BORDER_FILL, 0, 0), m_pFill(nullptr) { - m_bThreeD = oNode.GetAttributeBool(L"threeD"); - m_bShadow = oNode.GetAttributeBool(L"shadow"); - m_bBreakCellSeparateLine = oNode.GetAttributeBool(L"breakCellSeparateLine"); - - HWP_STRING sChildName; - - for (CXMLNode& oChild : oNode.GetChilds()) + START_READ_ATTRIBUTES(oReader) { - if (L"hh:slash" == oChild.GetName()) - { - HWP_STRING sType = oChild.GetAttribute(L"type"); - - if (L"NONE" == sType) - m_chSlash = 0x0; - else if (L"CENTER" == sType) - m_chSlash = 0b010; - else if (L"CENTER_BELOW" == sType) - m_chSlash = 0b011; - else if (L"CENTER_ABOVE" == sType) - m_chSlash = 0b110; - else if (L"ALL" == sType) - m_chSlash = 0b111; - - m_chCrookedSlash = oChild.GetAttributeBool(L"Crooked"); - m_bCounterSlash = oChild.GetAttributeBool(L"isCounter"); - } - else if (L"hh:backSlash" == oChild.GetName()) - { - HWP_STRING sType = oChild.GetAttribute(L"type"); - - if (L"NONE" == sType) - m_chBackSlash = 0x0; - else if (L"CENTER" == sType) - m_chBackSlash = 0b010; - else if (L"CENTER_BELOW" == sType) - m_chBackSlash = 0b011; - else if (L"CENTER_ABOVE" == sType) - m_chBackSlash = 0b110; - else if (L"ALL" == sType) - m_chBackSlash = 0b111; - - m_chCrookedBackSlash = oChild.GetAttributeBool(L"Crooked"); - m_bCounterBackSlash = oChild.GetAttributeBool(L"isCounter"); - } - else if (L"hh:leftBorder" == oChild.GetName()) - m_oLeft.ReadFromNode(oChild); - else if (L"hh:rightBorder" == oChild.GetName()) - m_oRight.ReadFromNode(oChild); - else if (L"hh:topBorder" == oChild.GetName()) - m_oTop.ReadFromNode(oChild); - else if (L"hh:bottomBorder" == oChild.GetName()) - m_oBottom.ReadFromNode(oChild); - else if (L"hh:diagonal" == oChild.GetName()) - m_oDiagonal.ReadFromNode(oChild); - else if (L"hc:fillBrush" == oChild.GetName()) - m_pFill = new CFill(oChild); + if ("threeD" == sAttributeName) + m_bThreeD = oReader.GetBool(); + else if ("shadow" == sAttributeName) + m_bShadow = oReader.GetBool(); + else if ("breakCellSeparateLine" == sAttributeName) + m_bBreakCellSeparateLine = oReader.GetBool(); } + END_READ_ATTRIBUTES(oReader) + + WHILE_READ_NEXT_NODE_WITH_NAME(oReader) + { + if ("hh:slash" == sNodeName) + { + START_READ_ATTRIBUTES(oReader) + { + if ("type" == sAttributeName) + { + const std::string sType{oReader.GetTextA()}; + + if ("NONE" == sType) + m_chSlash = 0x0; + else if ("CENTER" == sType) + m_chSlash = 0b010; + else if ("CENTER_BELOW" == sType) + m_chSlash = 0b011; + else if ("CENTER_ABOVE" == sType) + m_chSlash = 0b110; + else if ("ALL" == sType) + m_chSlash = 0b111; + } + else if ("Crooked" == sAttributeName) + m_chCrookedSlash = oReader.GetBool(); + else if ("isCounter" == sAttributeName) + m_bCounterSlash = oReader.GetBool(); + } + END_READ_ATTRIBUTES(oReader) + } + else if ("hh:backSlash" == sNodeName) + { + START_READ_ATTRIBUTES(oReader) + { + if ("type" == sAttributeName) + { + const std::string sType{oReader.GetTextA()}; + + if ("NONE" == sType) + m_chBackSlash = 0x0; + else if ("CENTER" == sType) + m_chBackSlash = 0b010; + else if ("CENTER_BELOW" == sType) + m_chBackSlash = 0b011; + else if ("CENTER_ABOVE" == sType) + m_chBackSlash = 0b110; + else if ("ALL" == sType) + m_chBackSlash = 0b111; + } + else if ("Crooked" == sAttributeName) + m_chCrookedBackSlash = oReader.GetBool(); + else if ("isCounter" == sAttributeName) + m_bCounterBackSlash = oReader.GetBool(); + } + END_READ_ATTRIBUTES(oReader) + } + else if ("hh:leftBorder" == sNodeName) + m_oLeft.Read(oReader); + else if ("hh:rightBorder" == sNodeName) + m_oRight.Read(oReader); + else if ("hh:topBorder" == sNodeName) + m_oTop.Read(oReader); + else if ("hh:bottomBorder" == sNodeName) + m_oBottom.Read(oReader); + else if ("hh:diagonal" == sNodeName) + m_oDiagonal.Read(oReader); + else if ("hc:fillBrush" == sNodeName) + m_pFill = new CFill(oReader); + } + END_WHILE } CHWPRecordBorderFill::~CHWPRecordBorderFill() diff --git a/HwpFile/HwpDoc/HWPElements/HWPRecordBorderFill.h b/HwpFile/HwpDoc/HWPElements/HWPRecordBorderFill.h index b84dbab16f..3b3557a60a 100644 --- a/HwpFile/HwpDoc/HWPElements/HWPRecordBorderFill.h +++ b/HwpFile/HwpDoc/HWPElements/HWPRecordBorderFill.h @@ -4,7 +4,7 @@ #include "../HWPDocInfo.h" #include "HwpRecordTypes.h" #include "../HWPStream.h" -#include "../Common/XMLNode.h" +#include "../Common/XMLReader.h" #include namespace HWP @@ -15,7 +15,7 @@ struct TBorder HWP_BYTE m_chWidth; int m_nColor; - void ReadFromNode(CXMLNode& oNode); + void Read(CXMLReader& oReader); }; enum class EImageFillType @@ -86,13 +86,13 @@ class CFill : public IRef HWP_BYTE m_chAlpha; - void ReadWinBrush(CXMLNode& oNode); - void ReadGradation(CXMLNode& oNode); - void ReadImgBrush(CXMLNode& oNode); + void ReadWinBrush(CXMLReader& oReader); + void ReadGradation(CXMLReader& oReader); + void ReadImgBrush(CXMLReader& oReader); public: CFill(); CFill(CHWPStream& oBuffer, int nOff, int nSize); - CFill(CXMLNode& oNode); + CFill(CXMLReader& oReader); int GetSize() const; bool NoneFill() const; @@ -136,7 +136,7 @@ class CHWPRecordBorderFill : public CHWPRecord public: CHWPRecordBorderFill(int nTagNum, int nLevel, int nSize); CHWPRecordBorderFill(CHWPDocInfo& oDocInfo, int nTagNum, int nLevel, int nSize, CHWPStream& oBuffer, int nOff, int nVersion); - CHWPRecordBorderFill(CHWPDocInfo& oDocInfo, CXMLNode& oNode, int nVersion); + CHWPRecordBorderFill(CHWPDocInfo& oDocInfo, CXMLReader& oReader, int nVersion); ~CHWPRecordBorderFill(); TBorder GetLeftBorder() const; diff --git a/HwpFile/HwpDoc/HWPElements/HWPRecordBullet.cpp b/HwpFile/HwpDoc/HWPElements/HWPRecordBullet.cpp index 91ee5db3a3..bcabed7a5a 100644 --- a/HwpFile/HwpDoc/HWPElements/HWPRecordBullet.cpp +++ b/HwpFile/HwpDoc/HWPElements/HWPRecordBullet.cpp @@ -45,25 +45,32 @@ CHWPRecordBullet::CHWPRecordBullet(CHWPDocInfo& oDocInfo, int nTagNum, int nLeve oBuffer.ReadChar(m_chCheckBulletChar); } -CHWPRecordBullet::CHWPRecordBullet(CHWPDocInfo& oDocInfo, CXMLNode& oNode, int nVersion) +CHWPRecordBullet::CHWPRecordBullet(CHWPDocInfo& oDocInfo, CXMLReader& oReader, int nVersion) : CHWPRecord(EHWPTag::HWPTAG_BULLET, 0, 0), m_pParent(&oDocInfo) { - std::wstring wsAttributeValue = oNode.GetAttribute(L"char"); - - if (!wsAttributeValue.empty()) - m_chBulletChar = wsAttributeValue.at(0); - - wsAttributeValue = oNode.GetAttribute(L"checkedChar"); - - if (!wsAttributeValue.empty()) - m_chCheckBulletChar = wsAttributeValue.at(0); - - m_nBulletImage = oNode.GetAttributeInt(L"useImage"); - - for (CXMLNode& oChild : oNode.GetChilds()) + START_READ_ATTRIBUTES(oReader) { - if (L"hc:img" == oChild.GetName()) - m_sBinItemRefID = oChild.GetAttribute(L"binaryItemIDRef"); + if ("char" == sAttributeName) + { + const HWP_STRING wsValue{oReader.GetText()}; + + if (!wsValue.empty()) + m_chBulletChar = wsValue.at(0); + } + else if ("checkedChar" == sAttributeName) + { + const HWP_STRING wsValue{oReader.GetText()}; + + if (!wsValue.empty()) + m_chCheckBulletChar = wsValue.at(0); + } + else if ("useImage" == sAttributeName) + m_nBulletImage = oReader.GetInt(); } + END_READ_ATTRIBUTES(oReader) + + WHILE_READ_NEXT_NODE_WITH_ONE_NAME(oReader, "hc:img") + m_sBinItemRefID = oReader.GetAttribute("binaryItemIDRef"); + END_WHILE } } diff --git a/HwpFile/HwpDoc/HWPElements/HWPRecordBullet.h b/HwpFile/HwpDoc/HWPElements/HWPRecordBullet.h index 2037770d04..ac11bcbdfe 100644 --- a/HwpFile/HwpDoc/HWPElements/HWPRecordBullet.h +++ b/HwpFile/HwpDoc/HWPElements/HWPRecordBullet.h @@ -5,7 +5,7 @@ #include "../HWPStream.h" #include "../HWPDocInfo.h" #include "HWPRecordNumbering.h" -#include "../Common/XMLNode.h" +#include "../Common/XMLReader.h" namespace HWP { @@ -24,7 +24,7 @@ class CHWPRecordBullet : public CHWPRecord HWP_CHAR m_chCheckBulletChar; public: CHWPRecordBullet(CHWPDocInfo& oDocInfo, int nTagNum, int nLevel, int nSize, CHWPStream& oBuffer, int nOff, int nVersion); - CHWPRecordBullet(CHWPDocInfo& oDocInfo, CXMLNode& oNode, int nVersion); + CHWPRecordBullet(CHWPDocInfo& oDocInfo, CXMLReader& oReader, int nVersion); }; } diff --git a/HwpFile/HwpDoc/HWPElements/HWPRecordCharShape.cpp b/HwpFile/HwpDoc/HWPElements/HWPRecordCharShape.cpp index fd470e685a..3a954c317d 100644 --- a/HwpFile/HwpDoc/HWPElements/HWPRecordCharShape.cpp +++ b/HwpFile/HwpDoc/HWPElements/HWPRecordCharShape.cpp @@ -107,15 +107,29 @@ EShadow GetShadow(const HWP_STRING& sValue) ELSE_STRING_IN_ENUM(NONE, EShadow); } -void CHWPRecordCharShape::ReadContainerData(CXMLNode& oNode, short arValues[], int nDefaultValue) +void CHWPRecordCharShape::ReadContainerData(CXMLReader& oReader, short arValues[], int nDefaultValue) { - arValues[(int)ELang::HANGUL] = oNode.GetAttributeInt(L"hangul", nDefaultValue); - arValues[(int)ELang::LATIN] = oNode.GetAttributeInt(L"latin", nDefaultValue); - arValues[(int)ELang::HANJA] = oNode.GetAttributeInt(L"hanja", nDefaultValue); - arValues[(int)ELang::JAPANESE] = oNode.GetAttributeInt(L"japanese", nDefaultValue); - arValues[(int)ELang::OTHER] = oNode.GetAttributeInt(L"other", nDefaultValue); - arValues[(int)ELang::SYMBOL] = oNode.GetAttributeInt(L"symbol", nDefaultValue); - arValues[(int)ELang::USER] = oNode.GetAttributeInt(L"user", nDefaultValue); + for (unsigned int unIndex = 0; unIndex < (int)ELang::MAX; ++unIndex) + arValues[unIndex] = nDefaultValue; + + START_READ_ATTRIBUTES(oReader) + { + if ("hangul" == sAttributeName) + arValues[(int)ELang::HANGUL] = oReader.GetInt(); + else if ("latin" == sAttributeName) + arValues[(int)ELang::LATIN] = oReader.GetInt(); + else if ("hanja" == sAttributeName) + arValues[(int)ELang::HANJA] = oReader.GetInt(); + else if ("japanese" == sAttributeName) + arValues[(int)ELang::JAPANESE] = oReader.GetInt(); + else if ("other" == sAttributeName) + arValues[(int)ELang::OTHER] = oReader.GetInt(); + else if ("symbol" == sAttributeName) + arValues[(int)ELang::SYMBOL] = oReader.GetInt(); + else if ("user" == sAttributeName) + arValues[(int)ELang::USER] = oReader.GetInt(); + } + END_READ_ATTRIBUTES(oReader) } CHWPRecordCharShape::CHWPRecordCharShape(CHWPDocInfo& oDocInfo, int nTagNum, int nLevel, int nSize, CHWPStream& oBuffer, int nOff, int nVersion) @@ -194,103 +208,138 @@ CHWPRecordCharShape::CHWPRecordCharShape(CHWPDocInfo& oDocInfo, int nTagNum, int oBuffer.RemoveLastSavedPos(); } -CHWPRecordCharShape::CHWPRecordCharShape(CHWPDocInfo& oDocInfo, CXMLNode& oNode, int nVersion) +CHWPRecordCharShape::CHWPRecordCharShape(CHWPDocInfo& oDocInfo, CXMLReader& oReader, int nVersion) : CHWPRecord(EHWPTag::HWPTAG_HWP_CHAR_SHAPE, 0, 0), m_pParent(&oDocInfo), - m_bItalic(false), m_bBold(false), m_bEmboss(false), m_bEngrave(false), - m_bSuperScript(false), m_bSubScript(false) + m_nHeight(1000), m_bItalic(false), m_bBold(false), m_eUnderline(EUnderline::NONE), + m_eUnderLineShape(ELineStyle1::SOLID), m_eOutline(EOutline::NONE), m_eShadow(EShadow::NONE), m_bEmboss(false), m_bEngrave(false), + m_bSuperScript(false), m_bSubScript(false), m_eStrikeOutShape(ELineStyle2::NONE), m_nShadeColor(0xFFFFFFFF) { - m_eUnderline = EUnderline::NONE; - m_eUnderLineShape = ELineStyle1::SOLID; - m_eOutline = EOutline::NONE; - m_eShadow = EShadow::NONE; - m_eStrikeOutShape = ELineStyle2::NONE; - - m_nHeight = oNode.GetAttributeInt(L"height", 1000); - m_nTextColor = oNode.GetAttributeColor(L"textColor", 0x000000); - m_nShadeColor = oNode.GetAttributeColor(L"shadeColor", 0xFFFFFFFF); - m_bUseFontSpace = oNode.GetAttributeBool(L"useFontSpace"); - m_bUseKerning = oNode.GetAttributeBool(L"useKerning"); - - m_eSymMark = GetAccent(oNode.GetAttribute(L"symMark")); - - m_shBorderFillIDRef = oNode.GetAttributeInt(L"borderFillIDRef"); - - for (CXMLNode& oChild : oNode.GetChilds()) + START_READ_ATTRIBUTES(oReader) { - if (L"hh:fontRef" == oChild.GetName()) + if ("height" == sAttributeName) + m_nHeight = oReader.GetInt(); + else if ("textColor" == sAttributeName) + m_nTextColor = oReader.GetColor(); + else if ("shadeColor" == sAttributeName) + m_nShadeColor = oReader.GetColor(0xFFFFFFFF); + else if ("useFontSpace" == sAttributeName) + m_bUseFontSpace = oReader.GetBool(); + else if ("useKerning" == sAttributeName) + m_bUseKerning = oReader.GetBool(); + else if ("symMark" == sAttributeName) + m_eSymMark = GetAccent(oReader.GetText()); + else if ("borderFillIDRef" == sAttributeName) + m_shBorderFillIDRef = oReader.GetInt(); + } + END_READ_ATTRIBUTES(oReader) + + WHILE_READ_NEXT_NODE_WITH_NAME(oReader) + { + if ("hh:fontRef" == sNodeName) { if (nullptr == m_pParent) continue; const CHWPRecordFaceName* pFaceName = nullptr; - #define UPDATE_FACENAME(node_name, elang_type) \ - pFaceName = dynamic_cast(m_pParent->GetFaceName(oChild.GetAttributeInt(node_name))); \ - if (nullptr != pFaceName) \ - m_arFontNames[(int)elang_type] = pFaceName->GetFaceName() + #define UPDATE_FACENAME(elang_type)\ + {\ + pFaceName = dynamic_cast(m_pParent->GetFaceName(oReader.GetInt()));\ + if (nullptr != pFaceName)\ + m_arFontNames[(int)elang_type] = pFaceName->GetFaceName();\ + } - UPDATE_FACENAME(L"hangul", ELang::HANGUL); - UPDATE_FACENAME(L"latin", ELang::LATIN); - UPDATE_FACENAME(L"hanja", ELang::HANJA); - UPDATE_FACENAME(L"japanese", ELang::JAPANESE); - UPDATE_FACENAME(L"other", ELang::OTHER); - UPDATE_FACENAME(L"symbol", ELang::SYMBOL); - UPDATE_FACENAME(L"user", ELang::USER); + START_READ_ATTRIBUTES(oReader) + { + if ("hangul" == sAttributeName) + UPDATE_FACENAME(ELang::HANGUL) + else if ("latin" == sAttributeName) + UPDATE_FACENAME(ELang::LATIN) + else if ("hanja" == sAttributeName) + UPDATE_FACENAME(ELang::HANJA) + else if ("japanese" == sAttributeName) + UPDATE_FACENAME(ELang::JAPANESE) + else if ("other" == sAttributeName) + UPDATE_FACENAME(ELang::OTHER) + else if ("symbol" == sAttributeName) + UPDATE_FACENAME(ELang::SYMBOL) + else if ("user" == sAttributeName) + UPDATE_FACENAME(ELang::USER) + } + END_READ_ATTRIBUTES(oReader) } - else if (L"hh:ratio" == oChild.GetName()) - ReadContainerData(oChild, m_arRatios, 100); - else if (L"hh:spacing" == oChild.GetName()) - ReadContainerData(oChild, m_arSpacings); - else if (L"hh:relSz" == oChild.GetName()) - ReadContainerData(oChild, m_arRelSizes, 100); - else if (L"hh:offset" == oChild.GetName()) - ReadContainerData(oChild, m_arCharOffset); - else if (L"hh:underline" == oChild.GetName()) + else if ("hh:ratio" == sNodeName) + ReadContainerData(oReader, m_arRatios, 100); + else if ("hh:spacing" == sNodeName) + ReadContainerData(oReader, m_arSpacings); + else if ("hh:relSz" == sNodeName) + ReadContainerData(oReader, m_arRelSizes, 100); + else if ("hh:offset" == sNodeName) + ReadContainerData(oReader, m_arCharOffset); + else if ("hh:underline" == sNodeName) { - m_eUnderline = GetUnderline(oChild.GetAttribute(L"type")); - m_eUnderLineShape = GetLineStyle1(oChild.GetAttribute(L"shape")); - m_nUnderlineColor = oChild.GetAttributeColor(L"color"); + START_READ_ATTRIBUTES(oReader) + { + if ("type" == sAttributeName) + m_eUnderline = GetUnderline(oReader.GetText()); + else if ("shape" == sAttributeName) + m_eUnderLineShape = GetLineStyle1(oReader.GetText()); + else if ("color" == sAttributeName) + m_nUnderlineColor = oReader.GetColor(); + } + END_READ_ATTRIBUTES(oReader) } - else if (L"hh:strikeout" == oChild.GetName()) + else if ("hh:strikeout" == sNodeName) { - m_eStrikeOutShape = GetLineStyle2(oChild.GetAttribute(L"shape")); - m_nStrikeOutColor = oChild.GetAttributeColor(L"color"); + START_READ_ATTRIBUTES(oReader) + { + if ("shape" == sAttributeName) + m_eStrikeOutShape = GetLineStyle2(oReader.GetText()); + else if ("color" == sAttributeName) + m_nStrikeOutColor = oReader.GetColor(); + } + END_READ_ATTRIBUTES(oReader) + } + else if ("hh:outline" == sNodeName) + m_eOutline = GetOutline(oReader.GetAttribute("type")); + else if ("hh:shadow" == sNodeName) + { + START_READ_ATTRIBUTES(oReader) + { + if ("type" == sAttributeName) + { + const std::string sType{oReader.GetTextA()}; - if (L"3D" == oChild.GetAttribute(L"shape")) - m_eStrikeOutShape = ELineStyle2::NONE; + if ("DROP" == sType) + m_eShadow = EShadow::DISCRETE; + else if ("CONTINUOUS" == sType) + m_eShadow = EShadow::CONTINUOUS; + else + m_eShadow = EShadow::NONE; + } + else if ("color" == sAttributeName) + m_nShadowColor = oReader.GetColor(); + else if ("offsetX" == sAttributeName) + m_chShadowOffsetX = (HWP_BYTE)oReader.GetInt(); + else if ("offsetY" == sAttributeName) + m_chShadowOffsetY = (HWP_BYTE)oReader.GetInt(); + } + END_READ_ATTRIBUTES(oReader) } - else if (L"hh:outline" == oChild.GetName()) - { - m_eOutline = GetOutline(oChild.GetAttribute(L"type")); - } - else if (L"hh:shadow" == oChild.GetName()) - { - HWP_STRING sType = oChild.GetAttribute(L"type"); - - if (L"DROP" == sType) - m_eShadow = EShadow::DISCRETE; - else if (L"CONTINUOUS" == sType) - m_eShadow = EShadow::CONTINUOUS; - else - m_eShadow = EShadow::NONE; - - m_nShadowColor = oChild.GetAttributeColor(L"color"); - m_chShadowOffsetX = (HWP_BYTE)oChild.GetAttributeInt(L"offsetX"); - m_chShadowOffsetY = (HWP_BYTE)oChild.GetAttributeInt(L"offsetY"); - } - else if (L"hh:italic" == oChild.GetName()) + else if ("hh:italic" == sNodeName) m_bItalic = true; - else if (L"hh:bold" == oChild.GetName()) + else if ("hh:bold" == sNodeName) m_bBold = true; - else if (L"hh:emboss" == oChild.GetName()) + else if ("hh:emboss" == sNodeName) m_bEmboss = true; - else if (L"hh:engrave" == oChild.GetName()) - m_bEmboss = true; - else if (L"hh:supscript" == oChild.GetName()) + else if ("hh:engrave" == sNodeName) + m_bEngrave = true; + else if ("hh:supscript" == sNodeName) m_bSuperScript = true; - else if (L"hh:subscript" == oChild.GetName()) + else if ("hh:subscript" == sNodeName) m_bSubScript = true; } + END_WHILE } bool CHWPRecordCharShape::Bold() const diff --git a/HwpFile/HwpDoc/HWPElements/HWPRecordCharShape.h b/HwpFile/HwpDoc/HWPElements/HWPRecordCharShape.h index d33a066452..4ebee45ba3 100644 --- a/HwpFile/HwpDoc/HWPElements/HWPRecordCharShape.h +++ b/HwpFile/HwpDoc/HWPElements/HWPRecordCharShape.h @@ -5,7 +5,7 @@ #include "../HWPStream.h" #include "HWPRecord.h" #include "HwpRecordTypes.h" -#include "../Common/XMLNode.h" +#include "../Common/XMLReader.h" namespace HWP { @@ -100,10 +100,10 @@ class CHWPRecordCharShape : public CHWPRecord short m_shBorderFillIDRef; int m_nStrikeOutColor; - void ReadContainerData(CXMLNode& oNode, short arValues[], int nDefaultValue = 0); + void ReadContainerData(CXMLReader& oReader, short arValues[], int nDefaultValue = 0); public: CHWPRecordCharShape(CHWPDocInfo& oDocInfo, int nTagNum, int nLevel, int nSize, CHWPStream& oBuffer, int nOff, int nVersion); - CHWPRecordCharShape(CHWPDocInfo& oDocInfo, CXMLNode& oNode, int nVersion); + CHWPRecordCharShape(CHWPDocInfo& oDocInfo, CXMLReader& oReader, int nVersion); bool Bold() const; bool Italic() const; diff --git a/HwpFile/HwpDoc/HWPElements/HWPRecordDocumentProperties.cpp b/HwpFile/HwpDoc/HWPElements/HWPRecordDocumentProperties.cpp index cada1bee0e..b68d223b3c 100644 --- a/HwpFile/HwpDoc/HWPElements/HWPRecordDocumentProperties.cpp +++ b/HwpFile/HwpDoc/HWPElements/HWPRecordDocumentProperties.cpp @@ -16,14 +16,24 @@ CHWPRecordDocumentProperties::CHWPRecordDocumentProperties(CHWPDocInfo& oDocInfo oBuffer.ReadInt(m_nCharUnitLocInPara); } -CHWPRecordDocumentProperties::CHWPRecordDocumentProperties(CHWPDocInfo& oDocInfo, CXMLNode& oNode, int nVersion) +CHWPRecordDocumentProperties::CHWPRecordDocumentProperties(CHWPDocInfo& oDocInfo, CXMLReader& oReader, int nVersion) : CHWPRecord(EHWPTag::HWPTAG_DOCUMENT_PROPERTIES, 0, 0), m_pParent(&oDocInfo) { - m_shFigureStartNo = oNode.GetAttributeInt(L"page"); - m_shFootNoteStartNo = oNode.GetAttributeInt(L"footnote"); - m_shEndNoteStartNo = oNode.GetAttributeInt(L"endnote"); - m_shFigureStartNo = oNode.GetAttributeInt(L"pic"); - m_shTableStartNo = oNode.GetAttributeInt(L"tbl"); - m_shEqStartNo = oNode.GetAttributeInt(L"equation"); + START_READ_ATTRIBUTES(oReader) + { + if ("page" == sAttributeName) + m_shPageStartNo = oReader.GetInt(); + else if ("footnote" == sAttributeName) + m_shFootNoteStartNo = oReader.GetInt(); + else if ("endnote" == sAttributeName) + m_shEndNoteStartNo = oReader.GetInt(); + else if ("pic" == sAttributeName) + m_shFigureStartNo = oReader.GetInt(); + else if ("tbl" == sAttributeName) + m_shTableStartNo = oReader.GetInt(); + else if ("equation" == sAttributeName) + m_shEqStartNo = oReader.GetInt(); + } + END_READ_ATTRIBUTES(oReader) } } diff --git a/HwpFile/HwpDoc/HWPElements/HWPRecordDocumentProperties.h b/HwpFile/HwpDoc/HWPElements/HWPRecordDocumentProperties.h index ab2dd86a1f..5693b1c55c 100644 --- a/HwpFile/HwpDoc/HWPElements/HWPRecordDocumentProperties.h +++ b/HwpFile/HwpDoc/HWPElements/HWPRecordDocumentProperties.h @@ -4,7 +4,7 @@ #include "../HWPDocInfo.h" #include "../HWPStream.h" #include "HWPRecord.h" -#include "../Common/XMLNode.h" +#include "../Common/XMLReader.h" namespace HWP { @@ -24,7 +24,7 @@ class CHWPRecordDocumentProperties : public CHWPRecord int m_nCharUnitLocInPara; public: CHWPRecordDocumentProperties(CHWPDocInfo& oDocInfo, int nTagNum, int nLevel, int nSize, CHWPStream& oBuffer, int nOff, int nVersion); - CHWPRecordDocumentProperties(CHWPDocInfo& oDocInfo, CXMLNode& oNode, int nVersion); + CHWPRecordDocumentProperties(CHWPDocInfo& oDocInfo, CXMLReader& oReader, int nVersion); }; } diff --git a/HwpFile/HwpDoc/HWPElements/HWPRecordFaceName.cpp b/HwpFile/HwpDoc/HWPElements/HWPRecordFaceName.cpp index 4652f37580..c097a44c41 100644 --- a/HwpFile/HwpDoc/HWPElements/HWPRecordFaceName.cpp +++ b/HwpFile/HwpDoc/HWPElements/HWPRecordFaceName.cpp @@ -53,47 +53,71 @@ CHWPRecordFaceName::CHWPRecordFaceName(CHWPDocInfo& oDocInfo, int nTagNum, int n oBuffer.ReadString(m_sBasicFaceName, EStringCharacter::UTF16); } -CHWPRecordFaceName::CHWPRecordFaceName(CHWPDocInfo& oDocInfo, CXMLNode& oNode, int nVersion) +CHWPRecordFaceName::CHWPRecordFaceName(CHWPDocInfo& oDocInfo, CXMLReader& oReader, int nVersion) : CHWPRecord(EHWPTag::HWPTAG_FACE_NAME, 0, 0), m_pParent(&oDocInfo) { - m_sFaceName = oNode.GetAttribute(L"face"); + m_sFaceName = oReader.GetAttribute("face"); - for (CXMLNode& oChild: oNode.GetChilds()) + WHILE_READ_NEXT_NODE_WITH_NAME(oReader) { - if (L"hh:substFont" == oChild.GetName()) + if ("hh:substFont" == sNodeName) { m_bSubstExists = true; - m_sSubstFace = oChild.GetAttribute(L"face"); - HWP_STRING sType = oChild.GetAttribute(L"type"); + START_READ_ATTRIBUTES(oReader) + { + if ("face" == sAttributeName) + m_sSubstFace = oReader.GetText(); + else if ("type" == sAttributeName) + { + const std::string sType{oReader.GetTextA()}; - if (L"TTF" == sType) - m_eSubstType = EAltType::FFT; - else if (L"HFT" == sType) - m_eSubstType = EAltType::HFT; - else - m_eSubstType = EAltType::UNKNOWN; + if ("TTF" == sType) + m_eSubstType = EAltType::FFT; + else if ("HFT" == sType) + m_eSubstType = EAltType::HFT; + else + m_eSubstType = EAltType::UNKNOWN; + } + } + END_READ_ATTRIBUTES(oReader) } - else if (L"hh:typeInfo" == oChild.GetName()) + else if ("hh:typeInfo" == sNodeName) { m_bAttrExists = true; - m_sBasicFaceName = oChild.GetAttribute(L"familyType"); + START_READ_ATTRIBUTES(oReader) + { + if ("familyType" == sAttributeName) + { + m_sBasicFaceName = oReader.GetText(); - if (!m_sBasicFaceName.empty()) - m_bBasicFaceExists = true; - - m_chSerifStyle = (HWP_BYTE)oChild.GetAttributeInt(L"serifStyle"); - m_shWeight = oChild.GetAttributeInt(L"weight"); - m_shPropotion = oChild.GetAttributeInt(L"proportion"); - m_shContrast = oChild.GetAttributeInt(L"contrast"); - m_shStrokeVariation = oChild.GetAttributeInt(L"strokeVariation"); - m_shArmStyle = oChild.GetAttributeInt(L"armStyle"); - m_shLetterform = oChild.GetAttributeInt(L"letterform"); - m_shMidLine = oChild.GetAttributeInt(L"midline"); - m_shXHeight = oChild.GetAttributeInt(L"xHeight"); + if (!m_sBasicFaceName.empty()) + m_bBasicFaceExists = true; + } + else if ("serifStyle" == sAttributeName) + m_chSerifStyle = (HWP_BYTE)oReader.GetInt(); + else if ("weight" == sAttributeName) + m_shWeight = oReader.GetInt(); + else if ("proportion" == sAttributeName) + m_shPropotion = oReader.GetInt(); + else if ("contrast" == sAttributeName) + m_shContrast = oReader.GetInt(); + else if ("strokeVariation" == sAttributeName) + m_shStrokeVariation = oReader.GetInt(); + else if ("armStyle" == sAttributeName) + m_shArmStyle = oReader.GetInt(); + else if ("letterform" == sAttributeName) + m_shLetterform = oReader.GetInt(); + else if ("midline" == sAttributeName) + m_shMidLine = oReader.GetInt(); + else if ("xHeight" == sAttributeName) + m_shXHeight = oReader.GetInt(); + } + END_READ_ATTRIBUTES(oReader) } } + END_WHILE } HWP_STRING CHWPRecordFaceName::GetFaceName() const diff --git a/HwpFile/HwpDoc/HWPElements/HWPRecordFaceName.h b/HwpFile/HwpDoc/HWPElements/HWPRecordFaceName.h index cad477eb29..7db968951c 100644 --- a/HwpFile/HwpDoc/HWPElements/HWPRecordFaceName.h +++ b/HwpFile/HwpDoc/HWPElements/HWPRecordFaceName.h @@ -1,7 +1,7 @@ #ifndef HWPRECORDFACENAME_H #define HWPRECORDFACENAME_H -#include "../Common/XMLNode.h" +#include "../Common/XMLReader.h" #include "../HWPDocInfo.h" #include "../HWPStream.h" #include "HWPRecord.h" @@ -41,7 +41,7 @@ class CHWPRecordFaceName : public CHWPRecord short m_shXHeight; public: CHWPRecordFaceName(CHWPDocInfo& oDocInfo, int nTagNum, int nLevel, int nSize, CHWPStream& oBuffer, int nOff, int nVersion); - CHWPRecordFaceName(CHWPDocInfo& oDocInfo, CXMLNode& oNode, int nVersion); + CHWPRecordFaceName(CHWPDocInfo& oDocInfo, CXMLReader& oReader, int nVersion); HWP_STRING GetFaceName() const; }; diff --git a/HwpFile/HwpDoc/HWPElements/HWPRecordNumbering.cpp b/HwpFile/HwpDoc/HWPElements/HWPRecordNumbering.cpp index 76ad9df268..1325983893 100644 --- a/HwpFile/HwpDoc/HWPElements/HWPRecordNumbering.cpp +++ b/HwpFile/HwpDoc/HWPElements/HWPRecordNumbering.cpp @@ -54,52 +54,68 @@ CHWPRecordNumbering::CHWPRecordNumbering(CHWPDocInfo& oDocInfo, int nTagNum, int oBuffer.RemoveLastSavedPos(); } -CHWPRecordNumbering::CHWPRecordNumbering(CHWPDocInfo& oDocInfo, CXMLNode& oNode, int nVersion) +CHWPRecordNumbering::CHWPRecordNumbering(CHWPDocInfo& oDocInfo, CXMLReader& oReader, int nVersion) : CHWPRecord(EHWPTag::HWPTAG_NUMBERING, 0, 0), m_pParent(&oDocInfo) { - m_shStart = oNode.GetAttributeInt(L"start", 1); + m_shStart = oReader.GetAttributeInt("start", 1); unsigned int unIndex = 0; - HWP_STRING sType; + short shLevel = 0; + std::string sNumFormat; - for (CXMLNode& oChild : oNode.GetChilds()) + WHILE_READ_NEXT_NODE_WITH_NAME(oReader) { - if (L"hh:paraHead" == oChild.GetName() || - L"paraHead" == oChild.GetName()) + if ("hh:paraHead" == sNodeName || + "paraHead" == sNodeName) { - sType = oChild.GetAttribute(L"align"); + START_READ_ATTRIBUTES(oReader) + { + if ("align" == sAttributeName) + { + const std::string sType{oReader.GetTextA()}; - if (L"LEFT" == sType) - m_arNumbering[unIndex].m_chAlign = 0; - else if (L"CENTER" == sType) - m_arNumbering[unIndex].m_chAlign = 1; - else if (L"RIGHT" == sType) - m_arNumbering[unIndex].m_chAlign = 2; + if ("LEFT" == sType) + m_arNumbering[unIndex].m_chAlign = 0; + else if ("CENTER" == sType) + m_arNumbering[unIndex].m_chAlign = 1; + else if ("RIGHT" == sType) + m_arNumbering[unIndex].m_chAlign = 2; + } + else if ("useInstWidth" == sAttributeName) + m_arNumbering[unIndex].m_bUseInstWidth = oReader.GetBool(); + else if ("autoIndent" == sAttributeName) + m_arNumbering[unIndex].m_bAutoIndent = oReader.GetBool(); + else if ("widthAdjust" == sAttributeName) + m_arNumbering[unIndex].m_shWidthAdjust = oReader.GetInt(); + else if ("textOffsetType" == sAttributeName) + { + const std::string sType{oReader.GetTextA()}; - m_arNumbering[unIndex].m_bUseInstWidth = oChild.GetAttributeBool(L"useInstWidth"); - m_arNumbering[unIndex].m_bAutoIndent = oChild.GetAttributeBool(L"autoIndent"); - m_arNumbering[unIndex].m_shWidthAdjust = oChild.GetAttributeInt(L"widthAdjust"); + if ("PERCENT" == sType) + m_arNumbering[unIndex].m_chTextOffsetType = 0; + else if ("HWPUNIT" == sType) + m_arNumbering[unIndex].m_chTextOffsetType = 1; + } + else if ("textOffset" == sAttributeName) + m_arNumbering[unIndex].m_shTextOffset = oReader.GetInt(); + else if ("charPrIDRef" == sAttributeName) + m_arNumbering[unIndex].m_nCharShape = std::abs(oReader.GetInt()); + else if ("start" == sAttributeName) + m_arNumbering[unIndex].m_nStartNumber = oReader.GetInt(); + else if ("numFormat" == sAttributeName) + sNumFormat = oReader.GetTextA(); + else if ("level" == sAttributeName) + shLevel = oReader.GetInt(); + } + END_READ_ATTRIBUTES(oReader) - sType = oChild.GetAttribute(L"textOffsetType"); - - if (L"PERCENT" == sType) - m_arNumbering[unIndex].m_chTextOffsetType = 0; - else if (L"HWPUNIT" == sType) - m_arNumbering[unIndex].m_chTextOffsetType = 1; - - m_arNumbering[unIndex].m_shTextOffset = oChild.GetAttributeInt(L"textOffset"); - - short shLevel = oChild.GetAttributeInt(L"level"); - - sType = oChild.GetAttribute(L"numFormat"); - - if (L"DIGIT" == sType) + if ("DIGIT" == sNumFormat) { if (shLevel > 0 && shLevel < 11) m_arNumbering[unIndex].m_sNumFormat = L'^' + std::to_wstring(shLevel) + L'.'; } - else if (L"HANGUL_SYLLABLE" == sType || - L"HANGUL_JAMO" == sType) + else if ("HANGUL_SYLLABLE" == sNumFormat || + "HANGUL_JAMO" == sNumFormat) { switch (shLevel) { @@ -115,7 +131,7 @@ CHWPRecordNumbering::CHWPRecordNumbering(CHWPDocInfo& oDocInfo, CXMLNode& oNode, case 10: m_arNumbering[unIndex].m_sNumFormat = L"^차."; break; } } - else if (L"CIRCLED_DIGIT" == sType) + else if ("CIRCLED_DIGIT" == sNumFormat) { switch (shLevel) { @@ -131,7 +147,7 @@ CHWPRecordNumbering::CHWPRecordNumbering(CHWPDocInfo& oDocInfo, CXMLNode& oNode, case 10: m_arNumbering[unIndex].m_sNumFormat = L"^\u2469."; break; } } - else if (L"LATIN_SMALL" == sType) + else if ("LATIN_SMALL" == sNumFormat) { switch (shLevel) { @@ -147,7 +163,7 @@ CHWPRecordNumbering::CHWPRecordNumbering(CHWPDocInfo& oDocInfo, CXMLNode& oNode, case 10: m_arNumbering[unIndex].m_sNumFormat = L"^j."; break; } } - else if (L"CIRCLED_HANGUL_SYLLABLE" == sType) + else if ("CIRCLED_HANGUL_SYLLABLE" == sNumFormat) { switch (shLevel) { @@ -163,7 +179,7 @@ CHWPRecordNumbering::CHWPRecordNumbering(CHWPDocInfo& oDocInfo, CXMLNode& oNode, case 10: m_arNumbering[unIndex].m_sNumFormat = L"^\u3277."; break; } } - else if (L"ROMAN_SMALL" == sType) + else if ("ROMAN_SMALL" == sNumFormat) { switch (shLevel) { @@ -180,14 +196,13 @@ CHWPRecordNumbering::CHWPRecordNumbering(CHWPDocInfo& oDocInfo, CXMLNode& oNode, } } - m_arNumbering[unIndex].m_nCharShape = std::abs(oChild.GetAttributeInt(L"charPrIDRef")); - m_arNumbering[unIndex].m_nStartNumber = oChild.GetAttributeInt(L"start"); ++unIndex; } if (7 == unIndex) return; } + END_WHILE } short CHWPRecordNumbering::GetStart() const diff --git a/HwpFile/HwpDoc/HWPElements/HWPRecordNumbering.h b/HwpFile/HwpDoc/HWPElements/HWPRecordNumbering.h index 6798cad30a..4e19482b56 100644 --- a/HwpFile/HwpDoc/HWPElements/HWPRecordNumbering.h +++ b/HwpFile/HwpDoc/HWPElements/HWPRecordNumbering.h @@ -4,7 +4,7 @@ #include "../HWPDocInfo.h" #include "../HWPStream.h" #include "HWPRecord.h" -#include "../Common/XMLNode.h" +#include "../Common/XMLReader.h" namespace HWP { @@ -36,7 +36,7 @@ class CHWPRecordNumbering : public CHWPRecord int m_arExtLevelStart[3]; public: CHWPRecordNumbering(CHWPDocInfo& oDocInfo, int nTagNum, int nLevel, int nSize, CHWPStream& oBuffer, int nOff, int nVersion); - CHWPRecordNumbering(CHWPDocInfo& oDocInfo, CXMLNode& oNode, int nVersion); + CHWPRecordNumbering(CHWPDocInfo& oDocInfo, CXMLReader& oReader, int nVersion); short GetStart() const; HWP_STRING GetNumFormat(unsigned short ushIndex) const; diff --git a/HwpFile/HwpDoc/HWPElements/HWPRecordParaShape.cpp b/HwpFile/HwpDoc/HWPElements/HWPRecordParaShape.cpp index a5d1a06264..52f4ab1368 100644 --- a/HwpFile/HwpDoc/HWPElements/HWPRecordParaShape.cpp +++ b/HwpFile/HwpDoc/HWPElements/HWPRecordParaShape.cpp @@ -131,116 +131,166 @@ CHWPRecordParaShape::CHWPRecordParaShape(CHWPDocInfo& oDocInfo, int nTagNum, int oBuffer.Skip(8); } -CHWPRecordParaShape::CHWPRecordParaShape(CHWPDocInfo& oDocInfo, CXMLNode& oNode, int nVersion) +CHWPRecordParaShape::CHWPRecordParaShape(CHWPDocInfo& oDocInfo, CXMLReader& oReader, int nVersion) : CHWPRecord(EHWPTag::HWPTAG_PARA_SHAPE, 0, 0), m_pParent(&oDocInfo), m_eAlign(EHorizontalAlign::JUSTIFY), m_bWidowOrphan(false), m_bKeepWithNext(false), m_bPageBreakBefore(false), m_eVertAlign(EVerticalAlign::BASELINE), m_eHeadingType(EHeadingType::NONE), m_bConnect(false), m_bIgnoreMargin(false), m_bParaTailShape(false) { - m_shTabDef = oNode.GetAttributeInt(L"tabPrIDRef"); - m_chCondense = (HWP_BYTE)oNode.GetAttributeInt(L"condense"); + START_READ_ATTRIBUTES(oReader) + { + if ("tabPrIDRef" == sAttributeName) + m_shTabDef = oReader.GetInt(); + else if ("condense" == sAttributeName) + m_chCondense = (HWP_BYTE)oReader.GetInt(); + else if ("fontLineHeight" == sAttributeName) + m_bFontLineHeight = oReader.GetBool(); + else if ("snapToGrid" == sAttributeName) + m_bSnapToGrid = oReader.GetBool(); + } + END_READ_ATTRIBUTES(oReader) - m_bFontLineHeight = oNode.GetAttributeBool(L"fontLineHeight"); - m_bSnapToGrid = oNode.GetAttributeBool(L"snapToGrid"); - - for (CXMLNode& oChild : oNode.GetChilds()) - RecursiveParaShape(oChild); + RecursiveParaShape(oReader); } -void CHWPRecordParaShape::RecursiveParaShape(CXMLNode& oNode) +void CHWPRecordParaShape::RecursiveParaShape(CXMLReader& oReader) { - if (L"hh:align" == oNode.GetName()) + WHILE_READ_NEXT_NODE_WITH_NAME(oReader) { - m_eAlign = ::HWP::GetHorizontalAlign(oNode.GetAttribute(L"horizontal")); - m_eVertAlign = ::HWP::GetVerticalAlign(oNode.GetAttribute(L"vertical")); - } - else if (L"hh:heading" == oNode.GetName()) - { - m_eHeadingType = ::HWP::GetHeadingType(oNode.GetAttribute(L"type")); - m_shHeadingIdRef = oNode.GetAttributeInt(L"idRef"); - m_chHeadingLevel = (HWP_BYTE)oNode.GetAttributeInt(L"level"); - } - else if (L"hh:breakSetting" == oNode.GetName()) - { - HWP_STRING sType = oNode.GetAttribute(L"breakLatinWord"); - - if (L"KEEP_WORD" == sType) - m_chBreakLatinWord = 0; - else if (L"BREAK_WORD" == sType) - m_chBreakLatinWord = 1; - - sType = oNode.GetAttribute(L"breakNonLatinWord"); - - if (L"KEEP_WORD" == sType) - m_chBreakNonLatinWord = 0; - else if (L"BREAK_WORD" == sType) - m_chBreakNonLatinWord = 1; - - m_bWidowOrphan = oNode.GetAttributeBool(L"widowOrphan"); - m_bKeepWithNext = oNode.GetAttributeBool(L"keepWithNext"); - m_bPageBreakBefore = oNode.GetAttributeBool(L"pageBreakBefore"); - - sType = oNode.GetAttribute(L"lineWrap"); - - if (L"BREAK" == sType) - m_chLineWrap = 0; - else if (L"SQUEEZE" == sType) - m_chLineWrap = 1; - } - else if (L"hh:lineSpacing" == oNode.GetName()) - { - HWP_STRING sType = oNode.GetAttribute(L"type"); - - if (L"PERCENT" == sType) - m_nLineSpacingType = 0; - else if (L"FIXED" == sType) - m_nLineSpacingType = 1; - else if (L"BETWEENLINES" == sType) - m_nLineSpacingType = 2; - else if (L"AT_LEAST" == sType) - m_nLineSpacingType = 4; - - m_nLineSpacing = oNode.GetAttributeInt(L"value"); - } - else if (L"hh:border" == oNode.GetName()) - { - m_shBorderFill = oNode.GetAttributeInt(L"borderFillIDRef"); - m_shOffsetLeft = oNode.GetAttributeInt(L"offsetLeft"); - m_shOffsetRight = oNode.GetAttributeInt(L"offsetRight"); - m_shOffsetTop = oNode.GetAttributeInt(L"offsetTop"); - m_shOffsetBottom = oNode.GetAttributeInt(L"offsetBottom"); - - m_bConnect = oNode.GetAttributeBool(L"connect"); - m_bIgnoreMargin = oNode.GetAttributeBool(L"ignoreMargin"); - } - else if (L"hh:autoSpacing" == oNode.GetName()) - { - m_bAutoSpaceEAsianEng = oNode.GetAttributeBool(L"eAsianEng"); - m_bAutoSpaceEAsianNum = oNode.GetAttributeBool(L"eAsianNum"); - } - else if (L"hc:intent" == oNode.GetName()) - m_nIndent = oNode.GetAttributeInt(L"value"); - else if (L"hc:left" == oNode.GetName()) - m_nMarginLeft = oNode.GetAttributeInt(L"value"); - else if (L"hc:right" == oNode.GetName()) - m_nMarginRight = oNode.GetAttributeInt(L"value"); - else if (L"hc:prev" == oNode.GetName()) - m_nMarginPrev = oNode.GetAttributeInt(L"value"); - else if (L"hc:next" == oNode.GetName()) - m_nMarginNext = oNode.GetAttributeInt(L"value"); - else if (/*L"hp:switch" == oNode.GetName() || - L"hp:case" == oNode.GetName() || - L"hp:default" == oNode.GetName() ||*/ - L"hh:margin" == oNode.GetName()) - { - for (CXMLNode& oChild : oNode.GetChilds()) - RecursiveParaShape(oChild); - } - else if (L"hp:switch" == oNode.GetName()) - { - for (CXMLNode& oChild : oNode.GetChild(L"hp:default").GetChilds()) - RecursiveParaShape(oChild); + if ("hh:align" == sNodeName) + { + START_READ_ATTRIBUTES(oReader) + { + if ("horizontal" == sAttributeName) + m_eAlign = ::HWP::GetHorizontalAlign(oReader.GetText()); + else if ("vertical" == sAttributeName) + m_eVertAlign = ::HWP::GetVerticalAlign(oReader.GetText()); + } + END_READ_ATTRIBUTES(oReader) + } + else if ("hh:heading" == sNodeName) + { + START_READ_ATTRIBUTES(oReader) + { + if ("type" == sAttributeName) + m_eHeadingType = ::HWP::GetHeadingType(oReader.GetText()); + else if ("idRef" == sAttributeName) + m_shHeadingIdRef = oReader.GetInt(); + else if ("level" == sAttributeName) + m_chHeadingLevel = (HWP_BYTE)oReader.GetInt(); + } + END_READ_ATTRIBUTES(oReader) + } + else if ("hh:breakSetting" == sNodeName) + { + START_READ_ATTRIBUTES(oReader) + { + if ("breakLatinWord" == sAttributeName) + { + const std::string sType{oReader.GetTextA()}; + + if ("KEEP_WORD" == sType) + m_chBreakLatinWord = 0; + else if ("BREAK_WORD" == sType) + m_chBreakLatinWord = 1; + } + else if ("breakNonLatinWord" == sAttributeName) + { + const std::string sType{oReader.GetTextA()}; + + if ("KEEP_WORD" == sType) + m_chBreakNonLatinWord = 0; + else if ("BREAK_WORD" == sType) + m_chBreakNonLatinWord = 1; + } + else if ("widowOrphan" == sAttributeName) + m_bWidowOrphan = oReader.GetBool(); + else if ("keepWithNext" == sAttributeName) + m_bKeepWithNext = oReader.GetBool(); + else if ("pageBreakBefore" == sAttributeName) + m_bPageBreakBefore = oReader.GetBool(); + else if ("lineWrap" == sAttributeName) + { + const std::string sType{oReader.GetTextA()}; + + if ("BREAK" == sType) + m_chLineWrap = 0; + else if ("SQUEEZE" == sType) + m_chLineWrap = 1; + } + } + END_READ_ATTRIBUTES(oReader) + } + else if ("hh:lineSpacing" == sNodeName) + { + START_READ_ATTRIBUTES(oReader) + { + if ("type" == sAttributeName) + { + const std::string sType{oReader.GetTextA()}; + + if ("PERCENT" == sType) + m_nLineSpacingType = 0; + else if ("FIXED" == sType) + m_nLineSpacingType = 1; + else if ("BETWEENLINES" == sType) + m_nLineSpacingType = 2; + else if ("AT_LEAST" == sType) + m_nLineSpacingType = 4; + } + else if ("value" == sAttributeName) + m_nLineSpacing = oReader.GetInt(); + } + END_READ_ATTRIBUTES(oReader) + } + else if ("hh:border" == sNodeName) + { + START_READ_ATTRIBUTES(oReader) + { + if ("borderFillIDRef" == sAttributeName) + m_shBorderFill = oReader.GetInt(); + else if ("offsetLeft" == sAttributeName) + m_shOffsetLeft = oReader.GetInt(); + else if ("offsetRight" == sAttributeName) + m_shOffsetRight = oReader.GetInt(); + else if ("offsetTop" == sAttributeName) + m_shOffsetTop = oReader.GetInt(); + else if ("offsetBottom" == sAttributeName) + m_shOffsetBottom = oReader.GetInt(); + else if ("connect" == sAttributeName) + m_bConnect = oReader.GetBool(); + else if ("ignoreMargin" == sAttributeName) + m_bIgnoreMargin = oReader.GetBool(); + } + END_READ_ATTRIBUTES(oReader) + } + else if ("hh:autoSpacing" == sNodeName) + { + START_READ_ATTRIBUTES(oReader) + { + if ("eAsianEng" == sAttributeName) + m_bAutoSpaceEAsianEng = oReader.GetBool(); + else if ("eAsianNum" == sAttributeName) + m_bAutoSpaceEAsianNum = oReader.GetBool(); + } + END_READ_ATTRIBUTES(oReader) + } + else if ("hc:intent" == sNodeName) + m_nIndent = oReader.GetAttributeInt("value"); + else if ("hc:left" == sNodeName) + m_nMarginLeft = oReader.GetAttributeInt("value"); + else if ("hc:right" == sNodeName) + m_nMarginRight = oReader.GetAttributeInt("value"); + else if ("hc:prev" == sNodeName) + m_nMarginPrev = oReader.GetAttributeInt("value"); + else if ("hc:next" == sNodeName) + m_nMarginNext = oReader.GetAttributeInt("value"); + else if ("hh:margin" == sNodeName || + "hp:switch" == sNodeName || + "hp:default" == sNodeName) + RecursiveParaShape(oReader); } + END_WHILE } EHorizontalAlign CHWPRecordParaShape::GetHorizantalAlign() const @@ -308,6 +358,11 @@ int CHWPRecordParaShape::GetRightIndent() const return m_nMarginRight; } +short CHWPRecordParaShape::GetTabDef() const +{ + return m_shTabDef; +} + bool CHWPRecordParaShape::KeepWithNext() const { return m_bKeepWithNext; diff --git a/HwpFile/HwpDoc/HWPElements/HWPRecordParaShape.h b/HwpFile/HwpDoc/HWPElements/HWPRecordParaShape.h index 55193ee47d..35ea0b9587 100644 --- a/HwpFile/HwpDoc/HWPElements/HWPRecordParaShape.h +++ b/HwpFile/HwpDoc/HWPElements/HWPRecordParaShape.h @@ -3,7 +3,7 @@ #include "HWPRecord.h" #include "../HWPDocInfo.h" -#include "../Common/XMLNode.h" +#include "../Common/XMLReader.h" namespace HWP { @@ -74,10 +74,10 @@ class CHWPRecordParaShape : public CHWPRecord bool m_bAutoSpaceEAsianNum; int m_nLineSpacingType; - void RecursiveParaShape(CXMLNode& oNode); + void RecursiveParaShape(CXMLReader& oReader); public: CHWPRecordParaShape(CHWPDocInfo& oDocInfo, int nTagNum, int nLevel, int nSize, CHWPStream& oBuffer, int nOff, int nVersion); - CHWPRecordParaShape(CHWPDocInfo& oDocInfo, CXMLNode& oNode, int nVersion); + CHWPRecordParaShape(CHWPDocInfo& oDocInfo, CXMLReader& oReader, int nVersion); EHorizontalAlign GetHorizantalAlign() const; EVerticalAlign GetVerticalAlign() const; @@ -94,6 +94,8 @@ public: int GetLeftIndent() const; int GetRightIndent() const; + short GetTabDef() const; + bool KeepWithNext() const; }; } diff --git a/HwpFile/HwpDoc/HWPElements/HWPRecordParaText.cpp b/HwpFile/HwpDoc/HWPElements/HWPRecordParaText.cpp index d4fa2e0023..d021e6f41f 100644 --- a/HwpFile/HwpDoc/HWPElements/HWPRecordParaText.cpp +++ b/HwpFile/HwpDoc/HWPElements/HWPRecordParaText.cpp @@ -148,11 +148,21 @@ LIST CHWPRecordParaText::Parse(int nTagNum, int nLevel, int nSize, CHWPS unIndex += unInfoLength + 2; break; } + case 0x09: // Tabs + { + UPDATE_CURRENT_TEXT(); + + if (sText.length() < unIndex + 6 || (sText[unIndex] != sText[unIndex + 6] && sText[unIndex] != sText[unIndex + 7])) + continue; + + arParas.push_back(new CCtrlCharacter(L" _", ECtrlCharType::TABULATION)); + unIndex += 6; + break; + } case 0x05: // Scheduling case 0x06: // Scheduling case 0x07: // Scheduling case 0x08: // Title mark - case 0x09: // Tabs case 0x13: // Scheduling case 0x14: // Scheduling { diff --git a/HwpFile/HwpDoc/HWPElements/HWPRecordStyle.cpp b/HwpFile/HwpDoc/HWPElements/HWPRecordStyle.cpp index c287a95034..edebd143c6 100644 --- a/HwpFile/HwpDoc/HWPElements/HWPRecordStyle.cpp +++ b/HwpFile/HwpDoc/HWPElements/HWPRecordStyle.cpp @@ -20,23 +20,36 @@ CHWPRecordStyle::CHWPRecordStyle(CHWPDocInfo& oDocInfo, int nTagNum, int nLevel, m_nCharShape = oBuffer.ReadShort(); } -CHWPRecordStyle::CHWPRecordStyle(CHWPDocInfo& oDocInfo, CXMLNode& oNode, int nVersion) +CHWPRecordStyle::CHWPRecordStyle(CHWPDocInfo& oDocInfo, CXMLReader& oReader, int nVersion) : CHWPRecord(EHWPTag::HWPTAG_STYLE, 0, 0), m_pParent(&oDocInfo) { - HWP_STRING sType = oNode.GetAttribute(L"type"); + START_READ_ATTRIBUTES(oReader) + { + if ("type" == sAttributeName) + { + const std::string sType{oReader.GetTextA()}; - if (L"PARA" == sType) - m_chType = 0; - else if (L"CHAR" == sType) - m_chType = 1; - - m_sName = oNode.GetAttribute(L"name"); - m_sEngName = oNode.GetAttribute(L"engName"); - m_nParaShape = oNode.GetAttributeInt(L"paraPrIDRef"); - m_nCharShape = oNode.GetAttributeInt(L"charPrIDRef"); - m_chNextStyle = oNode.GetAttributeInt(L"nextStyleIDRef"); - m_shLangID = oNode.GetAttributeInt(L"langID"); - m_bLockForm = oNode.GetAttributeBool(L"lockForm"); + if ("PARA" == sType) + m_chType = 0; + else if ("CHAR" == sType) + m_chType = 1; + } + else if ("name" == sAttributeName) + m_sName = oReader.GetText(); + else if ("engName" == sAttributeName) + m_sEngName = oReader.GetText(); + else if ("paraPrIDRef" == sAttributeName) + m_nParaShape = oReader.GetInt(); + else if ("charPrIDRef" == sAttributeName) + m_nCharShape = oReader.GetInt(); + else if ("nextStyleIDRef" == sAttributeName) + m_chNextStyle = oReader.GetInt(); + else if ("langID" == sAttributeName) + m_shLangID = oReader.GetInt(); + else if ("lockForm" == sAttributeName) + m_bLockForm = oReader.GetBool(); + } + END_READ_ATTRIBUTES(oReader) } HWP_STRING CHWPRecordStyle::GetName() const diff --git a/HwpFile/HwpDoc/HWPElements/HWPRecordStyle.h b/HwpFile/HwpDoc/HWPElements/HWPRecordStyle.h index 6715dce63f..cf1c8eb341 100644 --- a/HwpFile/HwpDoc/HWPElements/HWPRecordStyle.h +++ b/HwpFile/HwpDoc/HWPElements/HWPRecordStyle.h @@ -3,7 +3,7 @@ #include "HWPRecord.h" #include "../HWPDocInfo.h" -#include "../Common/XMLNode.h" +#include "../Common/XMLReader.h" namespace HWP { @@ -22,7 +22,7 @@ class CHWPRecordStyle : public CHWPRecord public: CHWPRecordStyle(int nTagNum, int nLevel, int nSize); CHWPRecordStyle(CHWPDocInfo& oDocInfo, int nTagNum, int nLevel, int nSize, CHWPStream& oBuffer, int nOff, int nVersion); - CHWPRecordStyle(CHWPDocInfo& oDocInfo, CXMLNode& oNode, int nVersion); + CHWPRecordStyle(CHWPDocInfo& oDocInfo, CXMLReader& oReader, int nVersion); HWP_STRING GetName() const; HWP_STRING GetEngName() const; diff --git a/HwpFile/HwpDoc/HWPElements/HwpRecordTabDef.cpp b/HwpFile/HwpDoc/HWPElements/HwpRecordTabDef.cpp index 70321d8e49..f6aa5e846e 100644 --- a/HwpFile/HwpDoc/HWPElements/HwpRecordTabDef.cpp +++ b/HwpFile/HwpDoc/HWPElements/HwpRecordTabDef.cpp @@ -5,11 +5,18 @@ namespace HWP TTab::TTab() {} -TTab::TTab(CXMLNode& oNode) +TTab::TTab(CXMLReader& oReader) { - m_nPos = oNode.GetAttributeInt(L"pos"); - SetType(oNode.GetAttributeInt(L"type")); - m_eLeader = GetLineStyle2(oNode.GetAttribute(L"leader")); + START_READ_ATTRIBUTES(oReader) + { + if ("pos" == sAttributeName) + m_nPos = oReader.GetInt(); + else if ("type" == sAttributeName) + SetType(oReader.GetInt()); + else if ("leader" == sAttributeName) + m_eLeader = GetLineStyle2(oReader.GetText()); + } + END_READ_ATTRIBUTES(oReader) } void TTab::SetType(int nValue) @@ -24,7 +31,7 @@ void TTab::SetType(int nValue) } CHwpRecordTabDef::CHwpRecordTabDef(int nTagNum, int nLevel, int nSize) - : CHWPRecord(nTagNum, nLevel, nSize), m_pParent(nullptr) + : CHWPRecord(nTagNum, nLevel, nSize), m_pParent(nullptr), m_nAttr(0) {} CHwpRecordTabDef::CHwpRecordTabDef(CHWPDocInfo& oDocInfo, int nTagNum, int nLevel, int nSize, CHWPStream& oBuffer, int nOff, int nVersion) @@ -33,13 +40,15 @@ CHwpRecordTabDef::CHwpRecordTabDef(CHWPDocInfo& oDocInfo, int nTagNum, int nLeve oBuffer.SavePosition(); oBuffer.ReadInt(m_nAttr); - oBuffer.ReadInt(m_nCount); - if (nSize - oBuffer.GetDistanceToLastPos() != m_nCount * 8) + int nCount = 0; + oBuffer.ReadInt(nCount); + + if (nSize - oBuffer.GetDistanceToLastPos() != nCount * 8) return; // TODO:: ошибка TTab *pTab = nullptr; - for (unsigned int unIndex = 0; unIndex < m_nCount; ++unIndex) + for (unsigned int unIndex = 0; unIndex < nCount; ++unIndex) { pTab = new TTab(); @@ -60,24 +69,48 @@ CHwpRecordTabDef::CHwpRecordTabDef(CHWPDocInfo& oDocInfo, int nTagNum, int nLeve oBuffer.RemoveLastSavedPos(); } -CHwpRecordTabDef::CHwpRecordTabDef(CHWPDocInfo& oDocInfo, CXMLNode& oNode, int nVersion) - : CHWPRecord(EHWPTag::HWPTAG_TAB_DEF, 0, 0), m_pParent(&oDocInfo) +CHwpRecordTabDef::CHwpRecordTabDef(CHWPDocInfo& oDocInfo, CXMLReader& oReader, int nVersion) + : CHWPRecord(EHWPTag::HWPTAG_TAB_DEF, 0, 0), m_pParent(&oDocInfo), m_nAttr(0) { - if (oNode.GetAttributeBool(L"autoTabLeft")) - m_nAttr |= 0x00000001; - else - m_nAttr &= 0xFFFFFFFE; - - if (oNode.GetAttributeBool(L"autoTabRight")) - m_nAttr |= 0x00000002; - else - m_nAttr &= 0xFFFFFFFD; - - for (CXMLNode& oChild : oNode.GetChilds(L"hp:switch")) - for (CXMLNode& oGrandChild : oChild.GetChilds(L"hp:default")) + START_READ_ATTRIBUTES(oReader) + { + if ("autoTabLeft" == sAttributeName) { - CXMLNode oTabItem{oGrandChild.GetChild(L"hh:tabItem")}; - m_arTabs.push_back(new TTab(oTabItem)); + if (oReader.GetBool()) + m_nAttr |= 0x00000001; + else + m_nAttr &= 0xFFFFFFFE; } + else if ("autoTabRight" == sAttributeName) + { + if (oReader.GetBool()) + m_nAttr |= 0x00000002; + else + m_nAttr &= 0xFFFFFFFD; + } + } + END_READ_ATTRIBUTES(oReader) + + WHILE_READ_NEXT_NODE_WITH_ONE_NAME(oReader, "hp:switch") + WHILE_READ_NEXT_NODE_WITH_DEPTH_ONE_NAME(oReader, Child, "hp:default") + WHILE_READ_NEXT_NODE_WITH_DEPTH_ONE_NAME(oReader, TabChild, "hh:tabItem") + m_arTabs.push_back(new TTab(oReader)); + END_WHILE + END_WHILE + END_WHILE + +} + +int CHwpRecordTabDef::GetCount() const +{ + return m_arTabs.size(); +} + +const TTab* CHwpRecordTabDef::GetTab(unsigned int unIndex) const +{ + if (unIndex >= m_arTabs.size()) + return nullptr; + + return dynamic_cast(m_arTabs.at(unIndex)); } } diff --git a/HwpFile/HwpDoc/HWPElements/HwpRecordTabDef.h b/HwpFile/HwpDoc/HWPElements/HwpRecordTabDef.h index 3e466de2f3..ba8fa26b6c 100644 --- a/HwpFile/HwpDoc/HWPElements/HwpRecordTabDef.h +++ b/HwpFile/HwpDoc/HWPElements/HwpRecordTabDef.h @@ -4,7 +4,7 @@ #include "HWPRecord.h" #include "../HWPDocInfo.h" #include "HwpRecordTypes.h" -#include "../Common/XMLNode.h" +#include "../Common/XMLReader.h" namespace HWP { @@ -22,7 +22,7 @@ struct TTab TTab(); - TTab(CXMLNode& oNode); + TTab(CXMLReader& oReader); void SetType(int nValue); }; @@ -32,12 +32,14 @@ class CHwpRecordTabDef : public CHWPRecord CHWPDocInfo *m_pParent; int m_nAttr; - int m_nCount; - LIST m_arTabs; + VECTOR m_arTabs; public: CHwpRecordTabDef(int nTagNum, int nLevel, int nSize); CHwpRecordTabDef(CHWPDocInfo& oDocInfo, int nTagNum, int nLevel, int nSize, CHWPStream& oBuffer, int nOff, int nVersion); - CHwpRecordTabDef(CHWPDocInfo& oDocInfo, CXMLNode& oNode, int nVersion); + CHwpRecordTabDef(CHWPDocInfo& oDocInfo, CXMLReader& oReader, int nVersion); + + int GetCount() const; + const TTab* GetTab(unsigned int unIndex) const; }; } diff --git a/HwpFile/HwpDoc/HWPSection.cpp b/HwpFile/HwpDoc/HWPSection.cpp index 8921a247bf..ea524c01f1 100644 --- a/HwpFile/HwpDoc/HWPSection.cpp +++ b/HwpFile/HwpDoc/HWPSection.cpp @@ -111,14 +111,11 @@ CHWPSection::~CHWPSection() CLEAR_ARRAY(CHWPPargraph, m_arParas); } -bool CHWPSection::Parse(CXMLNode& oNode, int nVersion) +bool CHWPSection::Parse(CXMLReader& oReader, int nVersion) { - std::vector arParagraphNodes{oNode.GetChilds(L"hp:p")}; - - m_arParas.resize(arParagraphNodes.size()); - - for (unsigned int unIndex = 0; unIndex < arParagraphNodes.size(); ++unIndex) - m_arParas[unIndex] = new CHWPPargraph(arParagraphNodes[unIndex], nVersion); + WHILE_READ_NEXT_NODE_WITH_ONE_NAME(oReader, "hp:p") + m_arParas.push_back(new CHWPPargraph(oReader, nVersion)); + END_WHILE return true; } diff --git a/HwpFile/HwpDoc/HWPSection.h b/HwpFile/HwpDoc/HWPSection.h index dbeb8ffd24..6b362ab5ef 100644 --- a/HwpFile/HwpDoc/HWPSection.h +++ b/HwpFile/HwpDoc/HWPSection.h @@ -16,7 +16,7 @@ public: CHWPSection(); ~CHWPSection(); - bool Parse(CXMLNode& oNode, int nVersion); + bool Parse(CXMLReader& oReader, int nVersion); bool Parse(CHWPStream& oBuffer, int nVersion); int ParseRecurse(CHWPPargraph* oCurrPara, int nRunLevel, CHWPStream& oBuffer, int nOff, int nVersion); int ParseCtrlRecurse(CCtrl* oCurrCtrl, int nRunLevel, CHWPStream& oBuffer, int nOff, int nVersion); diff --git a/HwpFile/HwpDoc/HWPXFile.cpp b/HwpFile/HwpDoc/HWPXFile.cpp index 19377036d8..d37f043236 100644 --- a/HwpFile/HwpDoc/HWPXFile.cpp +++ b/HwpFile/HwpDoc/HWPXFile.cpp @@ -115,8 +115,12 @@ VECTOR CHWPXFile::GetPathsToSections() const bool CHWPXFile::GetFileHeader() { - CXMLNode oVersionXml{GetDocument(L"version.xml")}; - return m_oFileHeader.Parse(oVersionXml); + CXMLReader oReader; + + if (!GetDocument(L"version.xml", oReader)) + return false; + + return m_oFileHeader.Parse(oReader); } const CHWPDocInfo* CHWPXFile::GetDocInfo() const @@ -146,11 +150,19 @@ bool CHWPXFile::GetChildStream(const HWP_STRING& sFileName, CHWPStream& oBuffer) bool CHWPXFile::GetDocInfo(int nVersion) { - CXMLNode oContent{GetDocument(L"Contents/content.hpf")}; - if (m_oDocInfo.ReadContentHpf(oContent, nVersion)) + CXMLReader oContentReader; + + if (!GetDocument(L"Contents/content.hpf", oContentReader)) + return false; + + if (m_oDocInfo.ReadContentHpf(oContentReader, nVersion)) { - CXMLNode oHeader{GetDocument(L"Contents/header.xml")}; - return m_oDocInfo.Parse(oHeader, nVersion); + CXMLReader oHeaderReader; + + if (!GetDocument(L"Contents/header.xml", oHeaderReader)) + return false; + + return m_oDocInfo.Parse(oHeaderReader, nVersion); } return false; @@ -158,10 +170,13 @@ bool CHWPXFile::GetDocInfo(int nVersion) bool CHWPXFile::ReadSection(const HWP_STRING& sName, int nVersion) { - CXMLNode oRootNode{GetDocument(sName)}; + CXMLReader oReader; + + if (!GetDocument(sName, oReader)) + return false; CHWPSection* pSection = new CHWPSection(); - const bool bResult = pSection->Parse(oRootNode, nVersion); + const bool bResult = pSection->Parse(oReader, nVersion); if (bResult) m_arSections.push_back(pSection); @@ -171,11 +186,14 @@ bool CHWPXFile::ReadSection(const HWP_STRING& sName, int nVersion) return bResult; } -CXMLNode CHWPXFile::GetDocument(const HWP_STRING& sEntryName) +bool CHWPXFile::GetDocument(const HWP_STRING& sEntryName, CXMLReader& oReader) { - if (nullptr == m_pZipFolder) - return CXMLNode(); + if (nullptr == m_pZipFolder || nullptr == oReader.GetReader()) + return false; - return CXMLNode(m_pZipFolder->getNodeFromFile(sEntryName)); + if (m_pZipFolder->getReaderFromFile(sEntryName, *oReader.GetReader())) + return oReader.ReadNextNode(); + + return false; } } diff --git a/HwpFile/HwpDoc/HWPXFile.h b/HwpFile/HwpDoc/HWPXFile.h index 867ad4cff4..9034b47bd5 100644 --- a/HwpFile/HwpDoc/HWPXFile.h +++ b/HwpFile/HwpDoc/HWPXFile.h @@ -32,7 +32,7 @@ private: bool GetFileHeader(); bool GetDocInfo(int nVersion); bool ReadSection(const HWP_STRING& sName, int nVersion); - CXMLNode GetDocument(const HWP_STRING& sEntryName); + bool GetDocument(const HWP_STRING& sEntryName, CXMLReader& oReader); }; } diff --git a/HwpFile/HwpDoc/HwpFileHeader.cpp b/HwpFile/HwpDoc/HwpFileHeader.cpp index 7a5655eeed..422e714c2a 100644 --- a/HwpFile/HwpDoc/HwpFileHeader.cpp +++ b/HwpFile/HwpDoc/HwpFileHeader.cpp @@ -60,15 +60,27 @@ bool CHwpFileHeader::Parse(CHWPStream& oBuffer) return true; } -bool CHwpFileHeader::Parse(CXMLNode& oNode) +bool CHwpFileHeader::Parse(CXMLReader& oReader) { - if (!oNode.IsValid()) - return false; + HWP_STRING wsMajor, wsMinor, wsMicro, wsBuildNumber; - m_sVersion += oNode.GetAttribute(L"major"); - m_sVersion += oNode.GetAttribute(L"minor"); - m_sVersion += oNode.GetAttribute(L"micro"); - m_sVersion += oNode.GetAttribute(L"buildNumber"); + START_READ_ATTRIBUTES(oReader) + { + if ("major" == sAttributeName) + wsMajor = oReader.GetText(); + else if ("minor" == sAttributeName) + wsMinor = oReader.GetText(); + else if ("micro" == sAttributeName) + wsMicro = oReader.GetText(); + else if ("buildNumber" == sAttributeName) + wsBuildNumber = oReader.GetText(); + } + END_READ_ATTRIBUTES(oReader) + + m_sVersion = ((!wsMajor.empty()) ? wsMajor : L"0") + + ((!wsMinor.empty()) ? wsMinor : L"0") + + ((!wsMicro.empty()) ? wsMicro : L"0") + + ((!wsBuildNumber.empty()) ? wsBuildNumber : L"0"); return true; } diff --git a/HwpFile/HwpDoc/HwpFileHeader.h b/HwpFile/HwpDoc/HwpFileHeader.h index 54103ca9c8..497f1ce23f 100644 --- a/HwpFile/HwpDoc/HwpFileHeader.h +++ b/HwpFile/HwpDoc/HwpFileHeader.h @@ -2,7 +2,7 @@ #define HWPFILEHEADER_H #include "HWPStream.h" -#include "Common/XMLNode.h" +#include "Common/XMLReader.h" namespace HWP { @@ -47,7 +47,7 @@ public: HWP_STRING GetVersion() const; bool Parse(CHWPStream& oBuffer); - bool Parse(CXMLNode& oNode); + bool Parse(CXMLReader& oReader); }; } diff --git a/HwpFile/HwpDoc/Paragraph/CapParagraph.cpp b/HwpFile/HwpDoc/Paragraph/CapParagraph.cpp index 144d56c1f5..493b92882c 100644 --- a/HwpFile/HwpDoc/Paragraph/CapParagraph.cpp +++ b/HwpFile/HwpDoc/Paragraph/CapParagraph.cpp @@ -6,8 +6,8 @@ CCapParagraph::CCapParagraph() : CHWPPargraph() {} -CCapParagraph::CCapParagraph(CXMLNode& oNode, int nVersion) - : CHWPPargraph(oNode, nVersion) +CCapParagraph::CCapParagraph(CXMLReader& oReader, int nVersion) + : CHWPPargraph(oReader, nVersion) {} EParagraphType CCapParagraph::GetType() const diff --git a/HwpFile/HwpDoc/Paragraph/CapParagraph.h b/HwpFile/HwpDoc/Paragraph/CapParagraph.h index a107e66b0f..09d1bae865 100644 --- a/HwpFile/HwpDoc/Paragraph/CapParagraph.h +++ b/HwpFile/HwpDoc/Paragraph/CapParagraph.h @@ -9,7 +9,7 @@ class CCapParagraph : public CHWPPargraph { public: CCapParagraph(); - CCapParagraph(CXMLNode& oNode, int nVersion); + CCapParagraph(CXMLReader& oReader, int nVersion); EParagraphType GetType() const override; }; diff --git a/HwpFile/HwpDoc/Paragraph/CellParagraph.cpp b/HwpFile/HwpDoc/Paragraph/CellParagraph.cpp index 8087a97027..b68ad224e9 100644 --- a/HwpFile/HwpDoc/Paragraph/CellParagraph.cpp +++ b/HwpFile/HwpDoc/Paragraph/CellParagraph.cpp @@ -7,8 +7,8 @@ CCellParagraph::CCellParagraph() { } -CCellParagraph::CCellParagraph(CXMLNode& oNode, int nVersion) - : CHWPPargraph(oNode, nVersion) +CCellParagraph::CCellParagraph(CXMLReader& oReader, int nVersion) + : CHWPPargraph(oReader, nVersion) {} EParagraphType CCellParagraph::GetType() const diff --git a/HwpFile/HwpDoc/Paragraph/CellParagraph.h b/HwpFile/HwpDoc/Paragraph/CellParagraph.h index 8f24372d76..267f6b539d 100644 --- a/HwpFile/HwpDoc/Paragraph/CellParagraph.h +++ b/HwpFile/HwpDoc/Paragraph/CellParagraph.h @@ -9,7 +9,7 @@ class CCellParagraph : public CHWPPargraph { public: CCellParagraph(); - CCellParagraph(CXMLNode& oNode, int nVersion); + CCellParagraph(CXMLReader& oReader, int nVersion); EParagraphType GetType() const override; }; diff --git a/HwpFile/HwpDoc/Paragraph/CommonObj.h b/HwpFile/HwpDoc/Paragraph/CommonObj.h index c6794c4f15..dee4dd99e5 100644 --- a/HwpFile/HwpDoc/Paragraph/CommonObj.h +++ b/HwpFile/HwpDoc/Paragraph/CommonObj.h @@ -2,9 +2,6 @@ #define COMMONOBJ_H #include "HWPPargraph.h" -#include -#include -#include namespace HWP { diff --git a/HwpFile/HwpDoc/Paragraph/Ctrl.cpp b/HwpFile/HwpDoc/Paragraph/Ctrl.cpp index 8257483ed0..39a8dd3fd2 100644 --- a/HwpFile/HwpDoc/Paragraph/Ctrl.cpp +++ b/HwpFile/HwpDoc/Paragraph/Ctrl.cpp @@ -50,27 +50,29 @@ bool CCtrl::Equals(CCtrl* pFirstCtrl, CCtrl* pSecondCtrl) pFirstCtrl->m_bFullFilled == pSecondCtrl->m_bFullFilled; } -CCtrl* CCtrl::GetCtrl(CXMLNode& oNode, int nVersion) +CCtrl* CCtrl::GetCtrl(CXMLReader& oReader, int nVersion) { - if (L"hp:colPr" == oNode.GetName()) - return new CCtrlColumnDef(L"dloc", oNode, nVersion); - else if (L"hp:header" == oNode.GetName()) - return new CCtrlHeadFoot(L"daeh", oNode, nVersion); - else if (L"hp:footer" == oNode.GetName()) - return new CCtrlHeadFoot(L"toof", oNode, nVersion); - else if (L"hp:footNote" == oNode.GetName()) - return new CCtrlNote(L" nf", oNode, nVersion); - else if (L"hp:endNote" == oNode.GetName()) - return new CCtrlNote(L" ne", oNode, nVersion); - else if (L"hp:autoNum" == oNode.GetName()) - return new CCtrlAutoNumber(L"onta", oNode, nVersion); - else if (L"hp:newNum" == oNode.GetName()) - return new CCtrlNewNumber(L"onwn", oNode, nVersion); - else if (L"hp:pageNum" == oNode.GetName()) - return new CCtrlPageNumPos(L"pngp", oNode, nVersion); - else if (L"hp:fieldBegin" == oNode.GetName() || - L"hp:fieldEnd" == oNode.GetName()) - return new CCtrlField(L"", oNode, nVersion); + const std::string sNodeName{oReader.GetName()}; + + if ("hp:colPr" == sNodeName) + return new CCtrlColumnDef(L"dloc", oReader, nVersion); + else if ("hp:header" == sNodeName) + return new CCtrlHeadFoot(L"daeh", oReader, nVersion); + else if ("hp:footer" == sNodeName) + return new CCtrlHeadFoot(L"toof", oReader, nVersion); + else if ("hp:footNote" == sNodeName) + return new CCtrlNote(L" nf", oReader, nVersion); + else if ("hp:endNote" == sNodeName) + return new CCtrlNote(L" ne", oReader, nVersion); + else if ("hp:autoNum" == sNodeName) + return new CCtrlAutoNumber(L"onta", oReader, nVersion); + else if ("hp:newNum" == sNodeName) + return new CCtrlNewNumber(L"onwn", oReader, nVersion); + else if ("hp:pageNum" == sNodeName) + return new CCtrlPageNumPos(L"pngp", oReader, nVersion); + else if ("hp:fieldBegin" == sNodeName || + "hp:fieldEnd" == sNodeName) + return new CCtrlField(L"", oReader, nVersion); return nullptr; } diff --git a/HwpFile/HwpDoc/Paragraph/Ctrl.h b/HwpFile/HwpDoc/Paragraph/Ctrl.h index ae50822346..3f61ef7970 100644 --- a/HwpFile/HwpDoc/Paragraph/Ctrl.h +++ b/HwpFile/HwpDoc/Paragraph/Ctrl.h @@ -2,7 +2,7 @@ #define CTRL_H #include "../Common/Common.h" -#include "../Common/XMLNode.h" +#include "../Common/XMLReader.h" namespace HWP { @@ -46,7 +46,7 @@ public: void SetFullFilled(); static bool Equals(CCtrl* pFirstCtrl, CCtrl* pSecondCtrl); - static CCtrl* GetCtrl(CXMLNode& oNode, int nVersion); + static CCtrl* GetCtrl(CXMLReader& oReader, int nVersion); }; } diff --git a/HwpFile/HwpDoc/Paragraph/CtrlAutoNumber.cpp b/HwpFile/HwpDoc/Paragraph/CtrlAutoNumber.cpp index fdab363ca2..c61e1a9cdc 100644 --- a/HwpFile/HwpDoc/Paragraph/CtrlAutoNumber.cpp +++ b/HwpFile/HwpDoc/Paragraph/CtrlAutoNumber.cpp @@ -44,58 +44,65 @@ CCtrlAutoNumber::CCtrlAutoNumber(const HWP_STRING& sCtrlID, int nSize, CHWPStrea m_bFullFilled = true; } -CCtrlAutoNumber::CCtrlAutoNumber(const HWP_STRING& sCtrlID, CXMLNode& oNode, int nVersion) +CCtrlAutoNumber::CCtrlAutoNumber(const HWP_STRING& sCtrlID, CXMLReader& oReader, int nVersion) : CCtrl(sCtrlID) { - m_eNumType = ::HWP::GetNumType(oNode.GetAttribute(L"numType")); + m_eNumType = ::HWP::GetNumType(oReader.GetAttribute("numType")); - HWP_STRING sType; - - for (CXMLNode& oChild : oNode.GetChilds()) + WHILE_READ_NEXT_NODE(oReader) { - m_bSuperscript = oChild.GetAttributeBool(L"supscript"); + START_READ_ATTRIBUTES(oReader) + { + if ("supscript" == sAttributeName) + m_bSuperscript = oReader.GetBool(); + else if ("type" == sAttributeName) + { + const std::string sType{oReader.GetTextA()}; - sType = oChild.GetAttribute(L"type"); - - if (L"DIGIT" == sType) - m_eNumShape = ENumberShape2::DIGIT; - else if (L"CIRCLE_DIGIT" == sType) - m_eNumShape = ENumberShape2::CIRCLE_DIGIT; - else if (L"ROMAN_CAPITAL" == sType) - m_eNumShape = ENumberShape2::ROMAN_CAPITAL; - else if (L"ROMAN_SMALL" == sType) - m_eNumShape = ENumberShape2::ROMAN_SMALL; - else if (L"LATIN_CAPITAL" == sType) - m_eNumShape = ENumberShape2::LATIN_CAPITAL; - else if (L"LATIN_SMALL" == sType) - m_eNumShape = ENumberShape2::LATIN_SMALL; - else if (L"CIRCLED_LATIN_CAPITAL" == sType) - m_eNumShape = ENumberShape2::CIRCLED_LATIN_CAPITAL; - else if (L"CIRCLED_LATIN_SMALL" == sType) - m_eNumShape = ENumberShape2::CIRCLED_LATIN_SMALL; - else if (L"CIRCLED_HANGUL_SYLLABLE" == sType) - m_eNumShape = ENumberShape2::CIRCLED_HANGUL_SYLLABLE; - else if (L"HANGUL_JAMO" == sType) - m_eNumShape = ENumberShape2::HANGUL_JAMO; - else if (L"CIRCLED_HANGUL_JAMO" == sType) - m_eNumShape = ENumberShape2::CIRCLED_HANGUL_JAMO; - else if (L"HANGUL_PHONETIC" == sType) - m_eNumShape = ENumberShape2::HANGUL_PHONETIC; - else if (L"IDEOGRAPH" == sType) - m_eNumShape = ENumberShape2::IDEOGRAPH; - else if (L"CIRCLED_IDEOGRAPH" == sType) - m_eNumShape = ENumberShape2::CIRCLED_IDEOGRAPH; - else if (L"DECAGON_CIRCLE" == sType) - m_eNumShape = ENumberShape2::DECAGON_CIRCLE; - else if (L"DECAGON_CRICLE_HANGJA" == sType) - m_eNumShape = ENumberShape2::DECAGON_CRICLE_HANGJA; - else if (L"SYMBOL" == sType) - m_eNumShape = ENumberShape2::SYMBOL; - else if (L"USER_CHAR" == sType) - m_eNumShape = ENumberShape2::USER_HWP_CHAR; - - m_eNumShape = GetNumberShape2(oChild.GetAttributeInt(L"hp:autoNumFormat", oChild.GetAttributeInt(L"autoNumFormat"))); + if ("DIGIT" == sType) + m_eNumShape = ENumberShape2::DIGIT; + else if ("CIRCLE_DIGIT" == sType) + m_eNumShape = ENumberShape2::CIRCLE_DIGIT; + else if ("ROMAN_CAPITAL" == sType) + m_eNumShape = ENumberShape2::ROMAN_CAPITAL; + else if ("ROMAN_SMALL" == sType) + m_eNumShape = ENumberShape2::ROMAN_SMALL; + else if ("LATIN_CAPITAL" == sType) + m_eNumShape = ENumberShape2::LATIN_CAPITAL; + else if ("LATIN_SMALL" == sType) + m_eNumShape = ENumberShape2::LATIN_SMALL; + else if ("CIRCLED_LATIN_CAPITAL" == sType) + m_eNumShape = ENumberShape2::CIRCLED_LATIN_CAPITAL; + else if ("CIRCLED_LATIN_SMALL" == sType) + m_eNumShape = ENumberShape2::CIRCLED_LATIN_SMALL; + else if ("CIRCLED_HANGUL_SYLLABLE" == sType) + m_eNumShape = ENumberShape2::CIRCLED_HANGUL_SYLLABLE; + else if ("HANGUL_JAMO" == sType) + m_eNumShape = ENumberShape2::HANGUL_JAMO; + else if ("CIRCLED_HANGUL_JAMO" == sType) + m_eNumShape = ENumberShape2::CIRCLED_HANGUL_JAMO; + else if ("HANGUL_PHONETIC" == sType) + m_eNumShape = ENumberShape2::HANGUL_PHONETIC; + else if ("IDEOGRAPH" == sType) + m_eNumShape = ENumberShape2::IDEOGRAPH; + else if ("CIRCLED_IDEOGRAPH" == sType) + m_eNumShape = ENumberShape2::CIRCLED_IDEOGRAPH; + else if ("DECAGON_CIRCLE" == sType) + m_eNumShape = ENumberShape2::DECAGON_CIRCLE; + else if ("DECAGON_CRICLE_HANGJA" == sType) + m_eNumShape = ENumberShape2::DECAGON_CRICLE_HANGJA; + else if ("SYMBOL" == sType) + m_eNumShape = ENumberShape2::SYMBOL; + else if ("USER_CHAR" == sType) + m_eNumShape = ENumberShape2::USER_HWP_CHAR; + } + else if ("hp:autoNumFormat" == sAttributeName || + "autoNumFormat" == sAttributeName) + m_eNumShape = GetNumberShape2(oReader.GetInt()); + } + END_READ_ATTRIBUTES(oReader) } + END_WHILE m_bFullFilled = true; } diff --git a/HwpFile/HwpDoc/Paragraph/CtrlAutoNumber.h b/HwpFile/HwpDoc/Paragraph/CtrlAutoNumber.h index 9b7906a5c8..29cd53f1c7 100644 --- a/HwpFile/HwpDoc/Paragraph/CtrlAutoNumber.h +++ b/HwpFile/HwpDoc/Paragraph/CtrlAutoNumber.h @@ -5,7 +5,7 @@ #include "../HWPStream.h" #include "../HWPElements/HwpRecordTypes.h" #include "../Common/Common.h" -#include "../Common/XMLNode.h" +#include "../Common/XMLReader.h" namespace HWP { @@ -31,7 +31,7 @@ class CCtrlAutoNumber : public CCtrl public: CCtrlAutoNumber(const HWP_STRING& sCtrlID); CCtrlAutoNumber(const HWP_STRING& sCtrlID, int nSize, CHWPStream& oBuffer, int nOff, int nVersion); - CCtrlAutoNumber(const HWP_STRING& sCtrlID, CXMLNode& oNode, int nVersion); + CCtrlAutoNumber(const HWP_STRING& sCtrlID, CXMLReader& oReader, int nVersion); ECtrlObjectType GetCtrlType() const override; diff --git a/HwpFile/HwpDoc/Paragraph/CtrlCharacter.h b/HwpFile/HwpDoc/Paragraph/CtrlCharacter.h index 65d0664152..55fafd680c 100644 --- a/HwpFile/HwpDoc/Paragraph/CtrlCharacter.h +++ b/HwpFile/HwpDoc/Paragraph/CtrlCharacter.h @@ -10,7 +10,8 @@ enum class ECtrlCharType LINE_BREAK = 0x1, PARAGRAPH_BREAK = 0x2, HARD_HYPHEN = 0x3, - HARD_SPACE = 0x04 + HARD_SPACE = 0x04, + TABULATION = 0x05 }; class CCtrlCharacter : public CCtrl diff --git a/HwpFile/HwpDoc/Paragraph/CtrlColumnDef.cpp b/HwpFile/HwpDoc/Paragraph/CtrlColumnDef.cpp index fa69f62886..baed9d74f6 100644 --- a/HwpFile/HwpDoc/Paragraph/CtrlColumnDef.cpp +++ b/HwpFile/HwpDoc/Paragraph/CtrlColumnDef.cpp @@ -40,12 +40,17 @@ CCtrlColumnDef::CCtrlColumnDef(const HWP_STRING& sCtrlID, int nSize, CHWPStream& m_bFullFilled = true; } -CCtrlColumnDef::CCtrlColumnDef(const HWP_STRING& sCtrlID, CXMLNode& oNode, int nVersion) - : CCtrl(sCtrlID) +CCtrlColumnDef::CCtrlColumnDef(const HWP_STRING& sCtrlID, CXMLReader& oReader, int nVersion) + : CCtrl(sCtrlID), m_eColLineStyle(ELineStyle2::SOLID) { - m_eColLineStyle = ELineStyle2::SOLID; - m_shColCount = oNode.GetAttributeInt(L"colCount"); - m_bSameSz = oNode.GetAttributeBool(L"sameSz"); + START_READ_ATTRIBUTES(oReader) + { + if ("colCount" == sAttributeName) + m_shColCount = oReader.GetInt(); + else if ("sameSz" == sAttributeName) + m_bSameSz = oReader.GetBool(); + } + END_READ_ATTRIBUTES(oReader) if (!m_bSameSz) { @@ -55,20 +60,34 @@ CCtrlColumnDef::CCtrlColumnDef(const HWP_STRING& sCtrlID, CXMLNode& oNode, int n unsigned int unColSzIndex = 0; - for (CXMLNode& oChild : oNode.GetChilds()) + WHILE_READ_NEXT_NODE_WITH_NAME(oReader) { - if (L"hp:colLine" == oChild.GetName()) + if ("hp:colLine" == sNodeName) { - m_eColLineStyle = GetLineStyle2(oChild.GetAttribute(L"type")); - m_chColLineWidth = (HWP_BYTE)ConvertWidthToHWP(oChild.GetAttribute(L"width")); - m_nColLineColor = oChild.GetAttributeColor(L"color"); + START_READ_ATTRIBUTES(oReader) + { + if ("type" == sAttributeName) + m_eColLineStyle = GetLineStyle2(oReader.GetText()); + else if ("width" == sAttributeName) + m_chColLineWidth = (HWP_BYTE)ConvertWidthToHWP(oReader.GetTextA()); + else if ("color" == sAttributeName) + m_nColLineColor = oReader.GetColor(); + } + END_READ_ATTRIBUTES(oReader) } - else if (L"hp:colSz" == oChild.GetName()) + else if ("hp:colSz" == sNodeName) { - m_arColSzWidths[unColSzIndex] = oChild.GetAttributeInt(L"width"); - m_arColSzGaps[unColSzIndex++] = oChild.GetAttributeInt(L"gap"); + START_READ_ATTRIBUTES(oReader) + { + if ("width" == sAttributeName) + m_arColSzWidths[unColSzIndex] = oReader.GetInt(); + else if ("gap" == sAttributeName) + m_arColSzGaps[unColSzIndex++] = oReader.GetInt(); + } + END_READ_ATTRIBUTES(oReader) } } + END_WHILE m_bFullFilled = true; } diff --git a/HwpFile/HwpDoc/Paragraph/CtrlColumnDef.h b/HwpFile/HwpDoc/Paragraph/CtrlColumnDef.h index 1ae218e8c4..268b94c829 100644 --- a/HwpFile/HwpDoc/Paragraph/CtrlColumnDef.h +++ b/HwpFile/HwpDoc/Paragraph/CtrlColumnDef.h @@ -4,7 +4,7 @@ #include "../HWPElements/HwpRecordTypes.h" #include "../HWPStream.h" #include "Ctrl.h" -#include "../Common/XMLNode.h" +#include "../Common/XMLReader.h" namespace HWP { @@ -22,7 +22,7 @@ class CCtrlColumnDef : public CCtrl public: CCtrlColumnDef(const HWP_STRING& sCtrlID); CCtrlColumnDef(const HWP_STRING& sCtrlID, int nSize, CHWPStream& oBuffer, int nOff, int nVersion); - CCtrlColumnDef(const HWP_STRING& sCtrlID, CXMLNode& oNode, int nVersion); + CCtrlColumnDef(const HWP_STRING& sCtrlID, CXMLReader& oReader, int nVersion); ECtrlObjectType GetCtrlType() const override; diff --git a/HwpFile/HwpDoc/Paragraph/CtrlCommon.cpp b/HwpFile/HwpDoc/Paragraph/CtrlCommon.cpp index 32451fa36c..c9a9908862 100644 --- a/HwpFile/HwpDoc/Paragraph/CtrlCommon.cpp +++ b/HwpFile/HwpDoc/Paragraph/CtrlCommon.cpp @@ -1,6 +1,8 @@ #include "CtrlCommon.h" #include "../Common/Common.h" #include +#include +#include #include "CapParagraph.h" @@ -250,116 +252,58 @@ namespace HWP oBuffer.Skip(nSize - oBuffer.GetDistanceToLastPos(true)); } - CCtrlCommon::CCtrlCommon(const HWP_STRING& sCtrlID, CXMLNode& oNode, int nVersion) + CCtrlCommon::CCtrlCommon(const HWP_STRING& sCtrlID, CXMLReader& oReader, int nVersion) : CCtrl(sCtrlID), m_bTreatAsChar(false), m_eVertRelTo(EVRelTo::PARA), m_eHorzRelTo(EHRelTo::PARA), m_nVertOffset(0), m_nHorzOffset(0), m_nWidth(0), m_nHeight(0), m_arOutMargin{0, 0, 0, 0}, m_arInMargin{0, 0, 0, 0}, m_eTextVerAlign(EVertAlign::TOP) { - m_nObjInstanceID = std::abs(oNode.GetAttributeInt(L"id")); + std::string sType; - HWP_STRING sType = oNode.GetAttribute(L"textFlow"); - - if (L"BOTH_SIDES" == sType) - m_chTextFlow = 0; - else if (L"LEFT_ONLY" == sType) - m_chTextFlow = 1; - else if (L"RIGHT_ONLY" == sType) - m_chTextFlow = 2; - else if (L"LARGEST_ONLY" == sType) - m_chTextFlow = 3; - - sType = oNode.GetAttribute(L"textWrap"); - - if (L"SQUARE" == sType) - m_eTextWrap = ETextWrap::SQUARE; - else if (L"TOP_AND_BOTTOM" == sType) - m_eTextWrap = ETextWrap::TOP_AND_BOTTOM; - else if (L"BEHIND_TEXT" == sType) - m_eTextWrap = ETextWrap::BEHIND_TEXT; - else if (L"IN_FRONT_OF_TEXT" == sType) - m_eTextWrap = ETextWrap::IN_FRONT_OF_TEXT; - - m_nZOrder = oNode.GetAttributeInt(L"zOrder"); - - sType = oNode.GetAttribute(L"numberingType"); - - if (L"NONE" == sType) - m_chNumeringType = 0; - else if (L"PICTURE" == sType) - m_chNumeringType = 1; - else if (L"TABLE" == sType) - m_chNumeringType = 2; - else if (L"EQUATION" == sType) - m_chNumeringType = 3; - - for (CXMLNode& oChild : oNode.GetChilds()) + START_READ_ATTRIBUTES(oReader) { - if (L"hp:sz" == oChild.GetName()) + if ("id" == sAttributeName) + m_nObjInstanceID = std::abs(oReader.GetInt()); + else if ("textFlow" == sAttributeName) { - m_nWidth = oChild.GetAttributeInt(L"width"); - m_eWidthRelTo = ::HWP::GetWidthRelTo(oChild.GetAttribute(L"widthRelTo")); - m_nHeight = oChild.GetAttributeInt(L"height"); - m_eHeightRelTo = ::HWP::GetHeightRelTo(oChild.GetAttribute(L"heightRelTo")); + sType = oReader.GetTextA(); + + if ("BOTH_SIDES" == sType) + m_chTextFlow = 0; + else if ("LEFT_ONLY" == sType) + m_chTextFlow = 1; + else if ("RIGHT_ONLY" == sType) + m_chTextFlow = 2; + else if ("LARGEST_ONLY" == sType) + m_chTextFlow = 3; } - else if (L"hp:pos" == oChild.GetName()) + else if ("textWrap" == sAttributeName) { - m_bTreatAsChar = oChild.GetAttributeBool(L"treatAsChar"); + sType = oReader.GetTextA(); - if (m_bTreatAsChar) - m_bAffectLSpacing = oChild.GetAttributeBool(L"affectLSpacing"); - else - m_bAllowOverlap = oChild.GetAttributeBool(L"allowOverlap"); - - m_eVertRelTo = GetVRelTo(oChild.GetAttribute(L"vertRelTo")); - m_eHorzRelTo = GetHRelTo(oChild.GetAttribute(L"horzRelTo")); - - if (EVRelTo::PARA == m_eVertRelTo) - m_bFlowWithText = oChild.GetAttributeBool(L"flowWithText"); - - m_eVertAlign = GetVertAlign(oChild.GetAttribute(L"vertAlign")); - m_eHorzAlign = GetHorzAlign(oChild.GetAttribute(L"horzAlign")); - m_nVertOffset = oChild.GetAttributeInt(L"vertOffset"); - m_nHorzOffset = oChild.GetAttributeInt(L"horzOffset"); + if ("SQUARE" == sType) + m_eTextWrap = ETextWrap::SQUARE; + else if ("TOP_AND_BOTTOM" == sType) + m_eTextWrap = ETextWrap::TOP_AND_BOTTOM; + else if ("BEHIND_TEXT" == sType) + m_eTextWrap = ETextWrap::BEHIND_TEXT; + else if ("IN_FRONT_OF_TEXT" == sType) + m_eTextWrap = ETextWrap::IN_FRONT_OF_TEXT; } - else if (L"hp:outMargin" == oChild.GetName()) + else if ("zOrder" == sAttributeName) + m_nZOrder = oReader.GetInt(); + else if ("numberingType" == sAttributeName) { - m_arOutMargin[0] = oChild.GetAttributeInt(L"left"); - m_arOutMargin[1] = oChild.GetAttributeInt(L"right"); - m_arOutMargin[2] = oChild.GetAttributeInt(L"top"); - m_arOutMargin[3] = oChild.GetAttributeInt(L"bottom"); - } - else if (L"hp:inMargin" == oChild.GetName()) - { - m_arInMargin[0] = oChild.GetAttributeInt(L"left"); - m_arInMargin[1] = oChild.GetAttributeInt(L"right"); - m_arInMargin[2] = oChild.GetAttributeInt(L"top"); - m_arInMargin[3] = oChild.GetAttributeInt(L"bottom"); - } - else if (L"hp:caption" == oChild.GetName()) - { - HWP_STRING sType = oChild.GetAttribute(L"side"); + sType = oReader.GetTextA(); - if (L"LEFT" == sType) - m_nCaptionAttr = 0b00; - else if (L"RIGHT" == sType) - m_nCaptionAttr = 0b01; - else if (L"TOP" == sType) - m_nCaptionAttr = 0b10; - else if (L"BOTTOM" == sType) - m_nCaptionAttr = 0b11; - - if (oChild.GetAttributeBool(L"fullSz")) - m_nCaptionAttr |= 0b100; - - m_nCaptionWidth = oChild.GetAttributeInt(L"width"); - m_nCaptionSpacing = oChild.GetAttributeInt(L"gap"); - m_nCaptionMaxW = oChild.GetAttributeInt(L"lastWidth"); - - for (CXMLNode& oSubList : oChild.GetChilds(L"hp:subList")) - { - for (CXMLNode& oParagraph : oSubList.GetChilds(L"hp:p")) - m_arCaption.push_back(new CCapParagraph(oParagraph, nVersion)); - } + if ("NONE" == sType) + m_chNumeringType = 0; + else if ("PICTURE" == sType) + m_chNumeringType = 1; + else if ("TABLE" == sType) + m_chNumeringType = 2; + else if ("EQUATION" == sType) + m_chNumeringType = 3; } } + END_READ_ATTRIBUTES(oReader) } CCtrlCommon::~CCtrlCommon() @@ -387,6 +331,121 @@ namespace HWP m_eTextVerAlign = eVertAlign; } + void CCtrlCommon::ParseChildren(CXMLReader& oReader, int nVersion) + { + const std::string sNodeName{oReader.GetName()}; + + if ("hp:sz" == sNodeName) + { + START_READ_ATTRIBUTES(oReader) + { + if ("width" == sAttributeName) + m_nWidth = oReader.GetInt(); + else if ("widthRelTo" == sAttributeName) + m_eWidthRelTo = ::HWP::GetWidthRelTo(oReader.GetText()); + else if ("height" == sAttributeName) + m_nHeight = oReader.GetInt(); + else if ("heightRelTo" == sAttributeName) + m_eHeightRelTo = ::HWP::GetHeightRelTo(oReader.GetText()); + } + END_READ_ATTRIBUTES(oReader) + } + else if ("hp:pos" == sNodeName) + { + START_READ_ATTRIBUTES(oReader) + { + if ("treatAsChar" == sAttributeName) + m_bTreatAsChar = oReader.GetBool(); + else if ("affectLSpacing" == sAttributeName) + m_bAffectLSpacing = oReader.GetBool(); + else if ("allowOverlap" == sAttributeName) + m_bAllowOverlap = oReader.GetBool(); + else if ("vertRelTo" == sAttributeName) + m_eVertRelTo = GetVRelTo(oReader.GetText()); + else if ("horzRelTo" == sAttributeName) + m_eHorzRelTo = GetHRelTo(oReader.GetText()); + else if ("flowWithText" == sAttributeName) + m_bFlowWithText = oReader.GetBool(); + else if ("vertAlign" == sAttributeName) + m_eVertAlign = GetVertAlign(oReader.GetText()); + else if ("horzAlign" == sAttributeName) + m_eHorzAlign = GetHorzAlign(oReader.GetText()); + else if ("vertOffset" == sAttributeName) + m_nVertOffset = oReader.GetInt(); + else if ("horzOffset" == sAttributeName) + m_nHorzOffset = oReader.GetInt(); + } + END_READ_ATTRIBUTES(oReader) + } + else if ("hp:outMargin" == sNodeName) + { + START_READ_ATTRIBUTES(oReader) + { + if ("left" == sAttributeName) + m_arOutMargin[0] = oReader.GetInt(); + else if ("right" == sAttributeName) + m_arOutMargin[1] = oReader.GetInt(); + else if ("top" == sAttributeName) + m_arOutMargin[2] = oReader.GetInt(); + else if ("bottom" == sAttributeName) + m_arOutMargin[3] = oReader.GetInt(); + } + END_READ_ATTRIBUTES(oReader) + } + else if ("hp:inMargin" == sNodeName) + { + START_READ_ATTRIBUTES(oReader) + { + if ("left" == sAttributeName) + m_arInMargin[0] = oReader.GetInt(); + else if ("right" == sAttributeName) + m_arInMargin[1] = oReader.GetInt(); + else if ("top" == sAttributeName) + m_arInMargin[2] = oReader.GetInt(); + else if ("bottom" == sAttributeName) + m_arInMargin[3] = oReader.GetInt(); + } + END_READ_ATTRIBUTES(oReader) + } + else if ("hp:caption" == sNodeName) + { + START_READ_ATTRIBUTES(oReader) + { + if ("side" == sAttributeName) + { + const std::string sType{oReader.GetTextA()}; + + if ("LEFT" == sType) + m_nCaptionAttr = 0b00; + else if ("RIGHT" == sType) + m_nCaptionAttr = 0b01; + else if ("TOP" == sType) + m_nCaptionAttr = 0b10; + else if ("BOTTOM" == sType) + m_nCaptionAttr = 0b11; + } + else if ("fullSz" == sAttributeName) + { + if (oReader.GetBool()) + m_nCaptionAttr |= 0b100; + } + else if ("width" == sAttributeName) + m_nCaptionWidth = oReader.GetInt(); + else if ("gap" == sAttributeName) + m_nCaptionSpacing = oReader.GetInt(); + else if ("lastWidth" == sAttributeName) + m_nCaptionMaxW = oReader.GetInt(); + } + END_READ_ATTRIBUTES(oReader) + + WHILE_READ_NEXT_NODE_WITH_DEPTH_ONE_NAME(oReader, SubList, "hp:subList") + WHILE_READ_NEXT_NODE_WITH_DEPTH_ONE_NAME(oReader, Paragraph, "hp:p") + m_arCaption.push_back(new CCapParagraph(oReader, nVersion)); + END_WHILE + END_WHILE + } + } + void CCtrlCommon::AddParagraph(CHWPPargraph* pParagraph) { m_arParas.push_back(pParagraph); diff --git a/HwpFile/HwpDoc/Paragraph/CtrlCommon.h b/HwpFile/HwpDoc/Paragraph/CtrlCommon.h index a3d80e3b8b..7ec5dc965d 100644 --- a/HwpFile/HwpDoc/Paragraph/CtrlCommon.h +++ b/HwpFile/HwpDoc/Paragraph/CtrlCommon.h @@ -114,13 +114,15 @@ public: CCtrlCommon(const HWP_STRING& sCtrlID); CCtrlCommon(const CCtrlCommon& oCtrlCommon); CCtrlCommon(const HWP_STRING& sCtrlID, int nSize, CHWPStream& oBuffer, int nOff, int nVersion); - CCtrlCommon(const HWP_STRING& sCtrlID, CXMLNode& oNode, int nVersion); + CCtrlCommon(const HWP_STRING& sCtrlID, CXMLReader& oReader, int nVersion); virtual ~CCtrlCommon(); ECtrlObjectType GetCtrlType() const override; void SetTextVerAlign(EVertAlign eVertAlign); + void ParseChildren(CXMLReader& oReader, int nVersion); + void AddParagraph(CHWPPargraph* pParagraph); void AddCaption(CCapParagraph* pCapPara); diff --git a/HwpFile/HwpDoc/Paragraph/CtrlContainer.cpp b/HwpFile/HwpDoc/Paragraph/CtrlContainer.cpp index 42f98354d4..047f20f100 100644 --- a/HwpFile/HwpDoc/Paragraph/CtrlContainer.cpp +++ b/HwpFile/HwpDoc/Paragraph/CtrlContainer.cpp @@ -25,32 +25,33 @@ CCtrlContainer::CCtrlContainer(const HWP_STRING& sCtrlID, int nSize, CHWPStream& : CCtrlGeneralShape(sCtrlID, nSize, oBuffer, nOff, nVersion) {} -CCtrlContainer::CCtrlContainer(const HWP_STRING& sCtrlID, CXMLNode& oNode, int nVersion) - : CCtrlGeneralShape(sCtrlID, oNode, nVersion) +CCtrlContainer::CCtrlContainer(const HWP_STRING& sCtrlID, CXMLReader& oReader, int nVersion) + : CCtrlGeneralShape(sCtrlID, oReader, nVersion) { - for (CXMLNode& oChild : oNode.GetChilds()) + WHILE_READ_NEXT_NODE_WITH_NAME(oReader) { - if (L"hp:container" == oChild.GetName()) - m_arShapes.push_back(new CCtrlContainer(L"noc$", oChild, nVersion)); - else if (L"hp:line" == oChild.GetName()) - m_arShapes.push_back(new CCtrlShapeLine(L"nil$", oChild, nVersion)); - else if (L"hp:rect" == oChild.GetName()) - m_arShapes.push_back(new CCtrlShapeRect(L"cer$", oChild, nVersion)); - else if (L"hp:ellipse" == oChild.GetName()) - m_arShapes.push_back(new CCtrlShapeEllipse(L"lle$", oChild, nVersion)); - else if (L"hp:arc" == oChild.GetName()) - m_arShapes.push_back(new CCtrlShapeArc(L"cra$", oChild, nVersion)); - else if (L"hp:polygon" == oChild.GetName()) - m_arShapes.push_back(new CCtrlShapePolygon(L"lop$", oChild, nVersion)); - else if (L"hp:curve" == oChild.GetName()) - m_arShapes.push_back(new CCtrlShapeCurve(L"ruc$", oChild, nVersion)); - else if (L"hp:connectLine" == oChild.GetName()) - m_arShapes.push_back(new CCtrlShapeConnectLine(L"loc$", oChild, nVersion)); - else if (L"hp:pic" == oChild.GetName()) - m_arShapes.push_back(new CCtrlShapePic(L"cip$", oChild, nVersion)); - else if (L"hp:ole" == oChild.GetName()) - m_arShapes.push_back(new CCtrlShapeOle(L"elo$", oChild, nVersion)); + if ("hp:container" == sNodeName) + m_arShapes.push_back(new CCtrlContainer(L"noc$", oReader, nVersion)); + else if ("hp:line" == sNodeName) + m_arShapes.push_back(new CCtrlShapeLine(L"nil$", oReader, nVersion)); + else if ("hp:rect" == sNodeName) + m_arShapes.push_back(new CCtrlShapeRect(L"cer$", oReader, nVersion)); + else if ("hp:ellipse" == sNodeName) + m_arShapes.push_back(new CCtrlShapeEllipse(L"lle$", oReader, nVersion)); + else if ("hp:arc" == sNodeName) + m_arShapes.push_back(new CCtrlShapeArc(L"cra$", oReader, nVersion)); + else if ("hp:polygon" == sNodeName) + m_arShapes.push_back(new CCtrlShapePolygon(L"lop$", oReader, nVersion)); + else if ("hp:curve" == sNodeName) + m_arShapes.push_back(new CCtrlShapeCurve(L"ruc$", oReader, nVersion)); + else if ("hp:connectLine" == sNodeName) + m_arShapes.push_back(new CCtrlShapeConnectLine(L"loc$", oReader, nVersion)); + else if ("hp:pic" == sNodeName) + m_arShapes.push_back(new CCtrlShapePic(L"cip$", oReader, nVersion)); + else if ("hp:ole" == sNodeName) + m_arShapes.push_back(new CCtrlShapeOle(L"elo$", oReader, nVersion)); } + END_WHILE m_shNElement = m_arShapes.size(); } diff --git a/HwpFile/HwpDoc/Paragraph/CtrlContainer.h b/HwpFile/HwpDoc/Paragraph/CtrlContainer.h index 3c92cf5d4d..590781d349 100644 --- a/HwpFile/HwpDoc/Paragraph/CtrlContainer.h +++ b/HwpFile/HwpDoc/Paragraph/CtrlContainer.h @@ -14,7 +14,7 @@ public: CCtrlContainer(const HWP_STRING& sCtrlID); CCtrlContainer(const CCtrlGeneralShape& oShape); CCtrlContainer(const HWP_STRING& sCtrlID, int nSize, CHWPStream& oBuffer, int nOff, int nVersion); - CCtrlContainer(const HWP_STRING& sCtrlID, CXMLNode& oNode, int nVersion); + CCtrlContainer(const HWP_STRING& sCtrlID, CXMLReader& oReader, int nVersion); ~CCtrlContainer(); diff --git a/HwpFile/HwpDoc/Paragraph/CtrlEqEdit.cpp b/HwpFile/HwpDoc/Paragraph/CtrlEqEdit.cpp index f0730e8dc6..274b1b20bb 100644 --- a/HwpFile/HwpDoc/Paragraph/CtrlEqEdit.cpp +++ b/HwpFile/HwpDoc/Paragraph/CtrlEqEdit.cpp @@ -17,23 +17,41 @@ CCtrlEqEdit::CCtrlEqEdit(const HWP_STRING& sCtrlID, int nSize, CHWPStream& oBuff : CCtrlGeneralShape(sCtrlID, nSize, oBuffer, nOff, nVersion) {} -CCtrlEqEdit::CCtrlEqEdit(const HWP_STRING& sCtrlID, CXMLNode& oNode, int nVersion) - : CCtrlGeneralShape(sCtrlID) +CCtrlEqEdit::CCtrlEqEdit(const HWP_STRING& sCtrlID, CXMLReader& oReader, int nVersion) + : CCtrlGeneralShape(sCtrlID, oReader, nVersion) { - m_sVersion = oNode.GetAttribute(L"version"); - m_nBaseline = oNode.GetAttributeInt(L"baseLine"); - m_nColor = oNode.GetAttributeColor(L"textColor"); - m_nCharSize = oNode.GetAttributeInt(L"baseUnit"); + START_READ_ATTRIBUTES(oReader) + { + if ("version" == sAttributeName) + m_sVersion = oReader.GetText(); + else if ("baseLine" == sAttributeName) + m_nBaseline = oReader.GetInt(); + else if ("textColor" == sAttributeName) + m_nColor = oReader.GetColor(); + else if ("baseUnit" == sAttributeName) + m_nCharSize = oReader.GetInt(); + else if ("lineMode" == sAttributeName) + { + const std::string sType{oReader.GetTextA()}; - HWP_STRING sType = oNode.GetAttribute(L"lineMode"); + if ("LINE" == sType) + m_nAttr = 1; + else if ("CHAR" == sType) + m_nAttr = 0; + } + else if ("font" == sAttributeName) + m_sFont = oReader.GetText(); + } + END_READ_ATTRIBUTES(oReader) - if (L"LINE" == sType) - m_nAttr = 1; - else if (L"CHAR" == sType) - m_nAttr = 0; - - m_sFont = oNode.GetAttribute(L"font"); - m_sEqn = oNode.GetChild(L"hp:script").GetText(); + WHILE_READ_NEXT_NODE(oReader) + { + if ("hp:script" == oReader.GetName()) + m_sEqn = oReader.GetText(); + else + CCtrlGeneralShape::ParseChildren(oReader, nVersion); + } + END_WHILE m_bFullFilled = true; } diff --git a/HwpFile/HwpDoc/Paragraph/CtrlEqEdit.h b/HwpFile/HwpDoc/Paragraph/CtrlEqEdit.h index e4602c5cbe..deca8a9137 100644 --- a/HwpFile/HwpDoc/Paragraph/CtrlEqEdit.h +++ b/HwpFile/HwpDoc/Paragraph/CtrlEqEdit.h @@ -19,7 +19,7 @@ public: CCtrlEqEdit(const HWP_STRING& sCtrlID); CCtrlEqEdit(const CCtrlGeneralShape& oShape); CCtrlEqEdit(const HWP_STRING& sCtrlID, int nSize, CHWPStream& oBuffer, int nOff, int nVersion); - CCtrlEqEdit(const HWP_STRING& sCtrlID, CXMLNode& oNode, int nVersion); + CCtrlEqEdit(const HWP_STRING& sCtrlID, CXMLReader& oReader, int nVersion); EShapeType GetShapeType() const override; diff --git a/HwpFile/HwpDoc/Paragraph/CtrlField.cpp b/HwpFile/HwpDoc/Paragraph/CtrlField.cpp index 5a891c3bd9..f3e757c003 100644 --- a/HwpFile/HwpDoc/Paragraph/CtrlField.cpp +++ b/HwpFile/HwpDoc/Paragraph/CtrlField.cpp @@ -1,6 +1,4 @@ #include "CtrlField.h" -#include -#include namespace HWP { @@ -33,37 +31,50 @@ void CCtrlField::UpdateType(const HWP_STRING& sCtrlID) m_eType = EFieldType::BookmarkClosing; } -CCtrlField::CCtrlField(const HWP_STRING& sCtrlID, CXMLNode& oNode, int nVersion) +CCtrlField::CCtrlField(const HWP_STRING& sCtrlID, CXMLReader& oReader, int nVersion) : CCtrl(sCtrlID), m_eType(EFieldType::Unknown) { - if (L"hp:fieldBegin" == oNode.GetName()) + const std::string sNodeName{oReader.GetName()}; + HWP_STRING wsName; + + if ("hp:fieldBegin" == sNodeName) { - HWP_STRING sType = oNode.GetAttribute(L"type"); - - if (L"HYPERLINK" == sType) - m_eType = EFieldType::Hyperlink; - else if (L"BOOKMARK" == sType) - m_eType = EFieldType::Bookmark; - - m_nInstanceID = oNode.GetAttributeInt(L"fieldid"); - - HWP_STRING sName = oNode.GetAttribute(L"name"); - - if (!sName.empty() && EFieldType::Bookmark == m_eType) - AddStringParam(L"bookmarkname", sName); - - for (CXMLNode& oChild : oNode.GetChild(L"hp:parameters").GetChilds()) + START_READ_ATTRIBUTES(oReader) { - if (L"hp:stringParam" == oChild.GetName()) - AddStringParam(oChild.GetAttribute(L"name"), oChild.GetText()); - else if (L"hp:integerParam" == oChild.GetName()) - AddIntegerParam(oChild.GetAttribute(L"name"), std::stoi(oChild.GetText())); + if ("type" == sAttributeName) + { + const std::string sType{oReader.GetTextA()}; + + if ("HYPERLINK" == sType) + m_eType = EFieldType::Hyperlink; + else if ("BOOKMARK" == sType) + m_eType = EFieldType::Bookmark; + } + else if ("fieldid" == sAttributeName) + m_nInstanceID = oReader.GetInt(); + else if ("name" == sAttributeName) + wsName = oReader.GetText(); } + END_READ_ATTRIBUTES(oReader) + + if (!wsName.empty() && EFieldType::Bookmark == m_eType) + AddStringParam(L"bookmarkname", wsName); + + WHILE_READ_NEXT_NODE_WITH_ONE_NAME(oReader, "hp:parameters") + { + WHILE_READ_NEXT_NODE_WITH_DEPTH_AND_NAME(oReader, Child) + { + if ("hp:stringParam" == sNodeChildName) + AddStringParam(oReader.GetAttribute("name"), oReader.GetText()); + else if ("hp:integerParam" == sNodeChildName) + AddIntegerParam(oReader.GetAttribute("name"), oReader.GetInt()); + } + END_WHILE + } + END_WHILE } - else if (L"hp:fieldEnd" == oNode.GetName()) - { - m_nInstanceID = oNode.GetAttributeInt(L"fieldid"); - } + else if ("hp:fieldEnd" == sNodeName) + m_nInstanceID = oReader.GetAttributeInt("fieldid"); } ECtrlObjectType CCtrlField::GetCtrlType() const diff --git a/HwpFile/HwpDoc/Paragraph/CtrlField.h b/HwpFile/HwpDoc/Paragraph/CtrlField.h index f84944566e..bda7d49c1c 100644 --- a/HwpFile/HwpDoc/Paragraph/CtrlField.h +++ b/HwpFile/HwpDoc/Paragraph/CtrlField.h @@ -32,7 +32,7 @@ class CCtrlField : public CCtrl public: CCtrlField(const HWP_STRING& sCtrlID); CCtrlField(const HWP_STRING& sCtrlID, int nSize, CHWPStream& oBuffer, int nOff, int nVersion); - CCtrlField(const HWP_STRING& sCtrlID, CXMLNode& oNode, int nVersion); + CCtrlField(const HWP_STRING& sCtrlID, CXMLReader& oReader, int nVersion); ECtrlObjectType GetCtrlType() const override; diff --git a/HwpFile/HwpDoc/Paragraph/CtrlGeneralShape.cpp b/HwpFile/HwpDoc/Paragraph/CtrlGeneralShape.cpp index 8a3160f034..d1b4a5a61e 100644 --- a/HwpFile/HwpDoc/Paragraph/CtrlGeneralShape.cpp +++ b/HwpFile/HwpDoc/Paragraph/CtrlGeneralShape.cpp @@ -62,121 +62,10 @@ CCtrlGeneralShape::CCtrlGeneralShape(const HWP_STRING& sCtrlID, int nSize, CHWPS InitData(); } -CCtrlGeneralShape::CCtrlGeneralShape(const HWP_STRING& sCtrlID, CXMLNode& oNode, int nVersion) - : CCtrlObjElement(sCtrlID, oNode, nVersion) +CCtrlGeneralShape::CCtrlGeneralShape(const HWP_STRING& sCtrlID, CXMLReader& oReader, int nVersion) + : CCtrlObjElement(sCtrlID, oReader, nVersion) { InitData(); - - for (CXMLNode& oChild : oNode.GetChilds()) - { - if (L"hp:lineShape" == oChild.GetName()) - { - m_nLineColor = oChild.GetAttributeColor(L"color"); - m_nLineThick = std::abs(oChild.GetAttributeInt(L"width")); - m_eLineStyle = GetLineStyle2(oChild.GetAttribute(L"style")); - - HWP_STRING sType = oChild.GetAttribute(L"headStyle"); - - if (L"ARROW" == sType) - m_eLineHead = ELineArrowStyle::ARROW; - else if (L"SPEAR" == sType) - m_eLineHead = ELineArrowStyle::SPEAR; - else if (L"CONCAVE_ARROW" == sType) - m_eLineHead = ELineArrowStyle::CONCAVE_ARROW; - else if (L"EMPTY_DIAMOND" == sType) - m_eLineHead = (oChild.GetAttributeBool(L"headfill")) ? ELineArrowStyle::DIAMOND : ELineArrowStyle::EMPTY_DIAMOND; - else if (L"EMPTY_CIRCLE" == sType) - m_eLineHead = (oChild.GetAttributeBool(L"headfill")) ? ELineArrowStyle::CIRCLE : ELineArrowStyle::EMPTY_CIRCLE; - else if (L"EMPTY_BOX" == sType) - m_eLineHead = (oChild.GetAttributeBool(L"headfill")) ? ELineArrowStyle::BOX : ELineArrowStyle::EMPTY_BOX; - else - m_eLineHead = ELineArrowStyle::NORMAL; - - sType = oChild.GetAttribute(L"headSz"); - - if (L"SMALL_SMALL" == sType) - m_eLineHeadSz = ELineArrowSize::SMALL_SMALL; - else if (L"SMALL_MEDIUM" == sType) - m_eLineHeadSz = ELineArrowSize::SMALL_MEDIUM; - else if (L"SMALL_LARGE" == sType) - m_eLineHeadSz = ELineArrowSize::SMALL_LARGE; - else if (L"MEDIUM_SMALL" == sType) - m_eLineHeadSz = ELineArrowSize::MEDIUM_SMALL; - else if (L"MEDIUM_MEDIUM" == sType) - m_eLineHeadSz = ELineArrowSize::MEDIUM_MEDIUM; - else if (L"MEDIUM_LARGE" == sType) - m_eLineHeadSz = ELineArrowSize::MEDIUM_LARGE; - else if (L"LARGE_SMALL" == sType) - m_eLineHeadSz = ELineArrowSize::LARGE_SMALL; - else if (L"LARGE_MEDIUM" == sType) - m_eLineHeadSz = ELineArrowSize::LARGE_MEDIUM; - else if (L"LARGE_LARGE" == sType) - m_eLineHeadSz = ELineArrowSize::LARGE_LARGE; - else - m_eLineHeadSz = ELineArrowSize::MEDIUM_MEDIUM; - - sType = oChild.GetAttribute(L"tailStyle"); - - if (L"ARROW" == sType) - m_eLineTail = ELineArrowStyle::ARROW; - else if (L"SPEAR" == sType) - m_eLineTail = ELineArrowStyle::SPEAR; - else if (L"CONCAVE_ARROW" == sType) - m_eLineTail = ELineArrowStyle::CONCAVE_ARROW; - else if (L"EMPTY_DIAMOND" == sType) - m_eLineTail = (oChild.GetAttributeBool(L"tailfill")) ? ELineArrowStyle::DIAMOND : ELineArrowStyle::EMPTY_DIAMOND; - else if (L"EMPTY_CIRCLE" == sType) - m_eLineTail = (oChild.GetAttributeBool(L"tailfill")) ? ELineArrowStyle::CIRCLE : ELineArrowStyle::EMPTY_CIRCLE; - else if (L"EMPTY_BOX" == sType) - m_eLineTail = (oChild.GetAttributeBool(L"tailfill")) ? ELineArrowStyle::BOX : ELineArrowStyle::EMPTY_BOX; - else - m_eLineTail = ELineArrowStyle::NORMAL; - - sType = oChild.GetAttribute(L"tailSz"); - - if (L"SMALL_SMALL" == sType) - m_eLineTailSz = ELineArrowSize::SMALL_SMALL; - else if (L"SMALL_MEDIUM" == sType) - m_eLineTailSz = ELineArrowSize::SMALL_MEDIUM; - else if (L"SMALL_LARGE" == sType) - m_eLineTailSz = ELineArrowSize::SMALL_LARGE; - else if (L"MEDIUM_SMALL" == sType) - m_eLineTailSz = ELineArrowSize::MEDIUM_SMALL; - else if (L"MEDIUM_MEDIUM" == sType) - m_eLineTailSz = ELineArrowSize::MEDIUM_MEDIUM; - else if (L"MEDIUM_LARGE" == sType) - m_eLineTailSz = ELineArrowSize::MEDIUM_LARGE; - else if (L"LARGE_SMALL" == sType) - m_eLineTailSz = ELineArrowSize::LARGE_SMALL; - else if (L"LARGE_MEDIUM" == sType) - m_eLineTailSz = ELineArrowSize::LARGE_MEDIUM; - else if (L"LARGE_LARGE" == sType) - m_eLineTailSz = ELineArrowSize::LARGE_LARGE; - else - m_eLineTailSz = ELineArrowSize::MEDIUM_MEDIUM; - } - else if (L"hc:fillBrush" == oChild.GetName()) - m_pFill = new CFill(oChild); - else if (L"hp:drawText" == oChild.GetName()) - { - m_nMaxTxtWidth = oChild.GetAttributeInt(L"lastWidth"); - - for (CXMLNode& oGrandChild : oChild.GetChilds()) - { - if (L"hp:textMargin" == oGrandChild.GetName()) - { - m_shLeftSpace = oGrandChild.GetAttributeInt(L"left"); - m_shRightSpace = oGrandChild.GetAttributeInt(L"right"); - m_shTopSpace = oGrandChild.GetAttributeInt(L"top"); - m_shBottomSpace = oGrandChild.GetAttributeInt(L"bottom"); - } - else if (L"hp:subList" == oGrandChild.GetName()) - { - ReadSubList(oGrandChild, nVersion); - } - } - } - } } CCtrlGeneralShape::~CCtrlGeneralShape() @@ -195,36 +84,177 @@ EShapeType CCtrlGeneralShape::GetShapeType() const return EShapeType::GeneralShape; } +void CCtrlGeneralShape::ParseChildren(CXMLReader& oReader, int nVersion) +{ + bool bHeadFill = false, bTailFill = false; + + const std::string sNodeName{oReader.GetName()}; + + if ("hp:lineShape" == sNodeName) + { + std::string sHeadStyle, sTailStyle; + + START_READ_ATTRIBUTES(oReader) + { + if ("color" == sAttributeName) + m_nLineColor = oReader.GetInt(); + else if ("width" == sAttributeName) + m_nLineThick = oReader.GetInt(); + else if ("style" == sAttributeName) + m_eLineStyle = GetLineStyle2(oReader.GetText()); + else if ("headStyle" == sAttributeName) + sHeadStyle = oReader.GetTextA(); + else if ("headfill" == sAttributeName) + bHeadFill = oReader.GetBool(); + else if ("headSz" == sAttributeName) + { + const std::string sHeadSz{oReader.GetTextA()}; + + if ("SMALL_SMALL" == sHeadSz) + m_eLineHeadSz = ELineArrowSize::SMALL_SMALL; + else if ("SMALL_MEDIUM" == sHeadSz) + m_eLineHeadSz = ELineArrowSize::SMALL_MEDIUM; + else if ("SMALL_LARGE" == sHeadSz) + m_eLineHeadSz = ELineArrowSize::SMALL_LARGE; + else if ("MEDIUM_SMALL" == sHeadSz) + m_eLineHeadSz = ELineArrowSize::MEDIUM_SMALL; + else if ("MEDIUM_MEDIUM" == sHeadSz) + m_eLineHeadSz = ELineArrowSize::MEDIUM_MEDIUM; + else if ("MEDIUM_LARGE" == sHeadSz) + m_eLineHeadSz = ELineArrowSize::MEDIUM_LARGE; + else if ("LARGE_SMALL" == sHeadSz) + m_eLineHeadSz = ELineArrowSize::LARGE_SMALL; + else if ("LARGE_MEDIUM" == sHeadSz) + m_eLineHeadSz = ELineArrowSize::LARGE_MEDIUM; + else if ("LARGE_LARGE" == sHeadSz) + m_eLineHeadSz = ELineArrowSize::LARGE_LARGE; + else + m_eLineHeadSz = ELineArrowSize::MEDIUM_MEDIUM; + } + else if ("tailStyle" == sAttributeName) + sTailStyle = oReader.GetTextA(); + else if ("tailfill" == sAttributeName) + bTailFill = oReader.GetBool(); + else if ("tailSz" == sAttributeName) + { + const std::string sType{oReader.GetTextA()}; + + if ("SMALL_SMALL" == sType) + m_eLineTailSz = ELineArrowSize::SMALL_SMALL; + else if ("SMALL_MEDIUM" == sType) + m_eLineTailSz = ELineArrowSize::SMALL_MEDIUM; + else if ("SMALL_LARGE" == sType) + m_eLineTailSz = ELineArrowSize::SMALL_LARGE; + else if ("MEDIUM_SMALL" == sType) + m_eLineTailSz = ELineArrowSize::MEDIUM_SMALL; + else if ("MEDIUM_MEDIUM" == sType) + m_eLineTailSz = ELineArrowSize::MEDIUM_MEDIUM; + else if ("MEDIUM_LARGE" == sType) + m_eLineTailSz = ELineArrowSize::MEDIUM_LARGE; + else if ("LARGE_SMALL" == sType) + m_eLineTailSz = ELineArrowSize::LARGE_SMALL; + else if ("LARGE_MEDIUM" == sType) + m_eLineTailSz = ELineArrowSize::LARGE_MEDIUM; + else if ("LARGE_LARGE" == sType) + m_eLineTailSz = ELineArrowSize::LARGE_LARGE; + else + m_eLineTailSz = ELineArrowSize::MEDIUM_MEDIUM; + } + } + END_READ_ATTRIBUTES(oReader) + + if (sHeadStyle.empty()) + m_eLineHead = ELineArrowStyle::NORMAL; + else if ("ARROW" == sHeadStyle) + m_eLineHead = ELineArrowStyle::ARROW; + else if ("SPEAR" == sHeadStyle) + m_eLineHead = ELineArrowStyle::SPEAR; + else if ("CONCAVE_ARROW" == sHeadStyle) + m_eLineHead = ELineArrowStyle::CONCAVE_ARROW; + else if ("EMPTY_DIAMOND" == sHeadStyle) + m_eLineHead = bHeadFill ? ELineArrowStyle::DIAMOND : ELineArrowStyle::EMPTY_DIAMOND; + else if ("EMPTY_CIRCLE" == sHeadStyle) + m_eLineHead = bHeadFill ? ELineArrowStyle::CIRCLE : ELineArrowStyle::EMPTY_CIRCLE; + else if ("EMPTY_BOX" == sHeadStyle) + m_eLineHead = bHeadFill ? ELineArrowStyle::BOX : ELineArrowStyle::EMPTY_BOX; + else + m_eLineHead = ELineArrowStyle::NORMAL; + + if (sTailStyle.empty()) + m_eLineTail = ELineArrowStyle::NORMAL; + else if ("ARROW" == sTailStyle) + m_eLineTail = ELineArrowStyle::ARROW; + else if ("SPEAR" == sTailStyle) + m_eLineTail = ELineArrowStyle::SPEAR; + else if ("CONCAVE_ARROW" == sTailStyle) + m_eLineTail = ELineArrowStyle::CONCAVE_ARROW; + else if ("EMPTY_DIAMOND" == sTailStyle) + m_eLineTail = bTailFill ? ELineArrowStyle::DIAMOND : ELineArrowStyle::EMPTY_DIAMOND; + else if ("EMPTY_CIRCLE" == sTailStyle) + m_eLineTail = bTailFill ? ELineArrowStyle::CIRCLE : ELineArrowStyle::EMPTY_CIRCLE; + else if ("EMPTY_BOX" == sTailStyle) + m_eLineTail = bTailFill ? ELineArrowStyle::BOX : ELineArrowStyle::EMPTY_BOX; + else + m_eLineTail = ELineArrowStyle::NORMAL; + } + else if ("hc:fillBrush" == sNodeName) + m_pFill = new CFill(oReader); + else if ("hp:drawText" == sNodeName) + { + m_nMaxTxtWidth = oReader.GetAttributeInt("lastWidth"); + + WHILE_READ_NEXT_NODE_WITH_DEPTH_AND_NAME(oReader, Child) + { + if ("hp:textMargin" == sNodeChildName) + { + START_READ_ATTRIBUTES(oReader) + { + if ("left" == sAttributeName) + m_shLeftSpace = oReader.GetInt(); + else if ("right" == sAttributeName) + m_shRightSpace = oReader.GetInt(); + else if ("top" == sAttributeName) + m_shTopSpace = oReader.GetInt(); + else if ("bottom" == sAttributeName) + m_shBottomSpace = oReader.GetInt(); + } + END_READ_ATTRIBUTES(oReader) + } + else if ("hp:subList" == sNodeChildName) + ReadSubList(oReader, nVersion); + } + END_WHILE + } + else + CCtrlObjElement::ParseChildren(oReader, nVersion); +} + void CCtrlGeneralShape::InitData() { m_eLineStyle = ELineStyle2::NONE; m_pFill = nullptr; } -void CCtrlGeneralShape::ReadSubList(CXMLNode& oNode, int nVersion) +void CCtrlGeneralShape::ReadSubList(CXMLReader& oReader, int nVersion) { - m_eTextVerAlign = GetVertAlign(oNode.ReadAttributeInt(L"vertAlign")); + m_eTextVerAlign = GetVertAlign(oReader.GetAttributeInt("vertAlign")); - std::vector arChilds{oNode.GetChilds()}; + // CHWPPargraph* pLatestParagraph = nullptr; - for (unsigned int unIndex = 0; unIndex < arChilds.size(); ++unIndex) + WHILE_READ_NEXT_NODE_WITH_ONE_NAME(oReader, "hp:p") { - CHWPPargraph* pLatestParagraph = nullptr; + CHWPPargraph* pParagraph = new CHWPPargraph(oReader, nVersion); - if (L"hp:p" == arChilds[unIndex].GetName()) - { - CHWPPargraph* pParagraph = new CHWPPargraph(arChilds[unIndex], nVersion); + if (nullptr == pParagraph) + continue; - if (nullptr == pParagraph) - continue; + m_arParas.push_back(pParagraph); + // pLatestParagraph = pParagraph; - m_arParas.push_back(pParagraph); - pLatestParagraph = pParagraph; - } - - if (nullptr != pLatestParagraph && 0 != pLatestParagraph->GetCountCtrls() && ECtrlObjectType::ParaText == pLatestParagraph->GetCtrls().back()->GetCtrlType() && unIndex < arChilds.size() - 1) - pLatestParagraph->AddCtrl(new CCtrlCharacter(L" _", ECtrlCharType::PARAGRAPH_BREAK)); + // if (nullptr != pLatestParagraph && 0 != pLatestParagraph->GetCountCtrls() && ECtrlObjectType::ParaText == pLatestParagraph->GetCtrls().back()->GetCtrlType()) + // pLatestParagraph->AddCtrl(new CCtrlCharacter(L" _", ECtrlCharType::PARAGRAPH_BREAK)); } + END_WHILE } void CCtrlGeneralShape::SetParent(CHWPPargraph* pParent) diff --git a/HwpFile/HwpDoc/Paragraph/CtrlGeneralShape.h b/HwpFile/HwpDoc/Paragraph/CtrlGeneralShape.h index 0f6d127da3..fce2957c88 100644 --- a/HwpFile/HwpDoc/Paragraph/CtrlGeneralShape.h +++ b/HwpFile/HwpDoc/Paragraph/CtrlGeneralShape.h @@ -53,18 +53,20 @@ class CCtrlGeneralShape : public CCtrlObjElement friend class CCtrlShapePolygon; friend class CCtrlShapeRect; - void ReadSubList(CXMLNode& oNode, int nVersion); + void ReadSubList(CXMLReader& oReader, int nVersion); public: CCtrlGeneralShape(); CCtrlGeneralShape(const HWP_STRING& sCtrlID); CCtrlGeneralShape(const CCtrlGeneralShape& oGeneralShape); CCtrlGeneralShape(const HWP_STRING& sCtrlID, int nSize, CHWPStream& oBuffer, int nOff, int nVersion); - CCtrlGeneralShape(const HWP_STRING& sCtrlID, CXMLNode& oNode, int nVersion); + CCtrlGeneralShape(const HWP_STRING& sCtrlID, CXMLReader& oReader, int nVersion); virtual ~CCtrlGeneralShape(); ECtrlObjectType GetCtrlType() const override; virtual EShapeType GetShapeType() const; + void ParseChildren(CXMLReader& oReader, int nVersion); + void SetParent(CHWPPargraph* pParent); CHWPPargraph* GetParent(); diff --git a/HwpFile/HwpDoc/Paragraph/CtrlHeadFoot.cpp b/HwpFile/HwpDoc/Paragraph/CtrlHeadFoot.cpp index daa01db178..ff899e968c 100644 --- a/HwpFile/HwpDoc/Paragraph/CtrlHeadFoot.cpp +++ b/HwpFile/HwpDoc/Paragraph/CtrlHeadFoot.cpp @@ -24,23 +24,33 @@ CCtrlHeadFoot::CCtrlHeadFoot(const HWP_STRING& sCtrlID, int nSize, CHWPStream& o oBuffer.ReadInt(m_nSerialInSec); } -CCtrlHeadFoot::CCtrlHeadFoot(const HWP_STRING& sCtrlID, CXMLNode& oNode, int nVersion) +CCtrlHeadFoot::CCtrlHeadFoot(const HWP_STRING& sCtrlID, CXMLReader& oReader, int nVersion) : CCtrl(sCtrlID) { m_bIsHeader = L"daeh" == sCtrlID; - m_eWhichPage = GetPageRange(oNode.GetAttributeInt(L"applyPageType")); + m_eWhichPage = GetPageRange(oReader.GetAttributeInt("applyPageType")); - for (CXMLNode& oChild : oNode.GetChilds(L"hp:subList")) + WHILE_READ_NEXT_NODE_WITH_ONE_NAME(oReader, "hp:subList") { - m_chRefLevelNum = (HWP_BYTE)oChild.GetAttributeInt(L"hasNumRef"); - m_chRefLevelText = (HWP_BYTE)oChild.GetAttributeInt(L"hasTextRef"); - m_nTextHeight = oChild.GetAttributeInt(L"textHeight"); - m_nTextWidth = oChild.GetAttributeInt(L"textWidth"); + START_READ_ATTRIBUTES(oReader) + { + if ("hasNumRef" == sAttributeName) + m_chRefLevelNum = (HWP_BYTE)oReader.GetInt(); + else if ("hasTextRef" == sAttributeName) + m_chRefLevelText = (HWP_BYTE)oReader.GetInt(); + else if ("textHeight" == sAttributeName) + m_nTextHeight = oReader.GetInt(); + else if ("textWidth" == sAttributeName) + m_nTextWidth = oReader.GetInt(); + } + END_READ_ATTRIBUTES(oReader) - for (CXMLNode& oGrandChild : oChild.GetChilds(L"hp:p")) - m_arParas.push_back(new CHWPPargraph(oGrandChild, nVersion)); + WHILE_READ_NEXT_NODE_WITH_DEPTH_ONE_NAME(oReader, Child, "hp:p") + m_arParas.push_back(new CHWPPargraph(oReader, nVersion)); + END_WHILE } + END_WHILE m_bFullFilled = true; } diff --git a/HwpFile/HwpDoc/Paragraph/CtrlHeadFoot.h b/HwpFile/HwpDoc/Paragraph/CtrlHeadFoot.h index bd1d55e0d5..926fbf70ed 100644 --- a/HwpFile/HwpDoc/Paragraph/CtrlHeadFoot.h +++ b/HwpFile/HwpDoc/Paragraph/CtrlHeadFoot.h @@ -31,7 +31,7 @@ class CCtrlHeadFoot : public CCtrl public: CCtrlHeadFoot(const HWP_STRING& sCtrlID); CCtrlHeadFoot(const HWP_STRING& sCtrlID, int nSize, CHWPStream& oBuffer, int nOff, int nVersion, bool bIsHeader); - CCtrlHeadFoot(const HWP_STRING& sCtrlID, CXMLNode& oNode, int nVersion); + CCtrlHeadFoot(const HWP_STRING& sCtrlID, CXMLReader& oReader, int nVersion); ECtrlObjectType GetCtrlType() const override; diff --git a/HwpFile/HwpDoc/Paragraph/CtrlNewNumber.cpp b/HwpFile/HwpDoc/Paragraph/CtrlNewNumber.cpp index b6f8dcfd10..cc578321d9 100644 --- a/HwpFile/HwpDoc/Paragraph/CtrlNewNumber.cpp +++ b/HwpFile/HwpDoc/Paragraph/CtrlNewNumber.cpp @@ -20,13 +20,20 @@ CCtrlNewNumber::CCtrlNewNumber(const HWP_STRING& sCtrlID, int nSize, CHWPStream& m_bFullFilled = true; } -CCtrlNewNumber::CCtrlNewNumber(const HWP_STRING& sCtrlID, CXMLNode& oNode, int nVersion) +CCtrlNewNumber::CCtrlNewNumber(const HWP_STRING& sCtrlID, CXMLReader& oReader, int nVersion) : CCtrl(sCtrlID) { - m_shNum = oNode.GetAttributeInt(L"num"); - m_eNumType = ::HWP::GetNumType(oNode.GetAttribute(L"numType")); - //TODO:: проверить данный момент - m_eNumShape = GetNumberShape2(oNode.GetAttributeInt(L"autoNumFormat")); + START_READ_ATTRIBUTES(oReader) + { + if ("num" == sAttributeName) + m_shNum = oReader.GetInt(); + else if ("numType" == sAttributeName) + m_eNumType = ::HWP::GetNumType(oReader.GetText()); + //TODO:: проверить данный момент + else if ("autoNumFormat" == sAttributeName) + m_eNumShape = GetNumberShape2(oReader.GetInt()); + } + END_READ_ATTRIBUTES(oReader) m_bFullFilled = true; } diff --git a/HwpFile/HwpDoc/Paragraph/CtrlNewNumber.h b/HwpFile/HwpDoc/Paragraph/CtrlNewNumber.h index 845b3f2e2f..9eb927620f 100644 --- a/HwpFile/HwpDoc/Paragraph/CtrlNewNumber.h +++ b/HwpFile/HwpDoc/Paragraph/CtrlNewNumber.h @@ -13,7 +13,7 @@ class CCtrlNewNumber : public CCtrl public: CCtrlNewNumber(const HWP_STRING& sCtrlID); CCtrlNewNumber(const HWP_STRING& sCtrlID, int nSize, CHWPStream& oBuffer, int nOff, int nVersion); - CCtrlNewNumber(const HWP_STRING& sCtrlID, CXMLNode& oNode, int nVersion); + CCtrlNewNumber(const HWP_STRING& sCtrlID, CXMLReader& oReader, int nVersion); ECtrlObjectType GetCtrlType() const override; diff --git a/HwpFile/HwpDoc/Paragraph/CtrlNote.cpp b/HwpFile/HwpDoc/Paragraph/CtrlNote.cpp index da96c5ad66..e5f58a9004 100644 --- a/HwpFile/HwpDoc/Paragraph/CtrlNote.cpp +++ b/HwpFile/HwpDoc/Paragraph/CtrlNote.cpp @@ -16,14 +16,14 @@ CCtrlNote::CCtrlNote(const HWP_STRING& sCtrlID, int nSize, CHWPStream& oBuffer, m_bFullFilled = true; } -CCtrlNote::CCtrlNote(const HWP_STRING& sCtrlID, CXMLNode& oNode, int nVersion) +CCtrlNote::CCtrlNote(const HWP_STRING& sCtrlID, CXMLReader& oReader, int nVersion) : CCtrl(sCtrlID) { - for (CXMLNode& oChild : oNode.GetChilds(L"hp:subList")) - { - for (CXMLNode& oGrandChild : oChild.GetChilds(L"hp:p")) - m_arParas.push_back(new CHWPPargraph(oGrandChild, nVersion)); - } + WHILE_READ_NEXT_NODE_WITH_ONE_NAME(oReader, "hp:subList") + WHILE_READ_NEXT_NODE_WITH_DEPTH_ONE_NAME(oReader, Child, "hp:p") + m_arParas.push_back(new CHWPPargraph(oReader, nVersion)); + END_WHILE + END_WHILE m_bFullFilled = true; } diff --git a/HwpFile/HwpDoc/Paragraph/CtrlNote.h b/HwpFile/HwpDoc/Paragraph/CtrlNote.h index 679db83307..ee6b561bd6 100644 --- a/HwpFile/HwpDoc/Paragraph/CtrlNote.h +++ b/HwpFile/HwpDoc/Paragraph/CtrlNote.h @@ -14,7 +14,7 @@ public: CCtrlNote(); CCtrlNote(const HWP_STRING& sCtrlID); CCtrlNote(const HWP_STRING& sCtrlID, int nSize, CHWPStream& oBuffer, int nOff, int nVersion); - CCtrlNote(const HWP_STRING& sCtrlID, CXMLNode& oNode, int nVersion); + CCtrlNote(const HWP_STRING& sCtrlID, CXMLReader& oReader, int nVersion); ECtrlObjectType GetCtrlType() const override; diff --git a/HwpFile/HwpDoc/Paragraph/CtrlObjElement.cpp b/HwpFile/HwpDoc/Paragraph/CtrlObjElement.cpp index 3577795689..81f8df6b23 100644 --- a/HwpFile/HwpDoc/Paragraph/CtrlObjElement.cpp +++ b/HwpFile/HwpDoc/Paragraph/CtrlObjElement.cpp @@ -47,66 +47,115 @@ CCtrlObjElement::CCtrlObjElement(const HWP_STRING& sCtrlID, int nSize, CHWPStrea : CCtrlCommon(sCtrlID, nSize, oBuffer, nOff, nVersion) {} -TMatrix ReadMatrix(CXMLNode& oNode) +TMatrix ReadMatrix(CXMLReader& oReader) { - return TMatrix + TMatrix oMatrix; + + START_READ_ATTRIBUTES(oReader) { - oNode.GetAttributeDouble(L"e1", 1.), - oNode.GetAttributeDouble(L"e2"), - oNode.GetAttributeDouble(L"e4"), - oNode.GetAttributeDouble(L"e5", 1.), - oNode.GetAttributeDouble(L"e3"), - oNode.GetAttributeDouble(L"e6"), - }; + if ("e1" == sAttributeName) + oMatrix.m_dM11 = oReader.GetDouble(); + else if ("e2" == sAttributeName) + oMatrix.m_dM12 = oReader.GetDouble(); + else if ("e3" == sAttributeName) + oMatrix.m_dDX = oReader.GetDouble(); + else if ("e4" == sAttributeName) + oMatrix.m_dM21 = oReader.GetDouble(); + else if ("e5" == sAttributeName) + oMatrix.m_dM22 = oReader.GetDouble(); + else if ("e6" == sAttributeName) + oMatrix.m_dDY = oReader.GetDouble(); + } + END_READ_ATTRIBUTES(oReader) + + return oMatrix; } -CCtrlObjElement::CCtrlObjElement(const HWP_STRING& sCtrlID, CXMLNode& oNode, int nVersion) - : CCtrlCommon(sCtrlID, oNode, nVersion) +CCtrlObjElement::CCtrlObjElement(const HWP_STRING& sCtrlID, CXMLReader& oReader, int nVersion) + : CCtrlCommon(sCtrlID, oReader, nVersion) { - m_shNGrp = oNode.GetAttributeInt(L"groupLevel"); + m_shNGrp = oReader.GetAttributeInt("groupLevel"); +} - for (CXMLNode& oChild : oNode.GetChilds()) +void CCtrlObjElement::ParseChildren(CXMLReader& oReader, int nVersion) +{ + const std::string sNodeName{oReader.GetName()}; + + if ("hp:offset" == sNodeName) { - if (L"hp:offset" == oChild.GetName()) + START_READ_ATTRIBUTES(oReader) { - m_nXGrpOffset = oChild.GetAttributeInt(L"x"); - m_nYGrpOffset = oChild.GetAttributeInt(L"y"); - } - else if (L"hp:orgSz" == oChild.GetName()) - { - m_nOrgWidth = oChild.GetAttributeInt(L"width"); - m_nOrgHeight = oChild.GetAttributeInt(L"height"); - } - else if (L"hp:curSz" == oChild.GetName()) - { - m_nCurWidth = oChild.GetAttributeInt(L"width"); - m_nCurHeight = oChild.GetAttributeInt(L"height"); - } - else if (L"hp:flip" == oChild.GetName()) - { - m_bHorzFlip = oChild.GetAttributeBool(L"horizontal"); - m_bVerFlip = oChild.GetAttributeBool(L"vertical"); - } - else if (L"hp:rotationInfo" == oChild.GetName()) - { - m_shRotat = oChild.GetAttributeInt(L"angle"); - m_nXCenter = oChild.GetAttributeInt(L"centerX"); - m_nYCenter = oChild.GetAttributeInt(L"centerY"); - } - else if (L"hp:renderingInfo" == oChild.GetName()) - { - for (CXMLNode& oGrandChild : oChild.GetChilds()) - { - // Сначала идёт 1 hc:transMatrix, а после попарно идут hc:scaMatrix с hc:rotMatrix - if (L"hc:transMatrix" == oGrandChild.GetName()) - m_arMatrixs.push_back(ReadMatrix(oGrandChild)); - else if (L"hc:scaMatrix" == oGrandChild.GetName()) - m_arMatrixs.push_back(ReadMatrix(oGrandChild)); - else if (L"hc:rotMatrix" == oGrandChild.GetName()) - m_arMatrixs.push_back(ReadMatrix(oGrandChild)); - } + if ("x" == sAttributeName) + m_nXGrpOffset = oReader.GetInt(); + else if ("y" == sAttributeName) + m_nYGrpOffset = oReader.GetInt(); } + END_READ_ATTRIBUTES(oReader) } + + else if ("hp:orgSz" == sNodeName) + { + START_READ_ATTRIBUTES(oReader) + { + if ("width" == sAttributeName) + m_nOrgWidth = oReader.GetInt(); + else if ("height" == sAttributeName) + m_nOrgHeight = oReader.GetInt(); + } + END_READ_ATTRIBUTES(oReader) + } + else if ("hp:curSz" == sNodeName) + { + START_READ_ATTRIBUTES(oReader) + { + if ("width" == sAttributeName) + m_nCurWidth = oReader.GetInt(); + else if ("height" == sAttributeName) + m_nCurHeight = oReader.GetInt(); + } + END_READ_ATTRIBUTES(oReader) + } + else if ("hp:flip" == sNodeName) + { + START_READ_ATTRIBUTES(oReader) + { + if ("horizontal" == sAttributeName) + m_bHorzFlip = oReader.GetBool(); + else if ("vertical" == sAttributeName) + m_bVerFlip = oReader.GetBool(); + } + END_READ_ATTRIBUTES(oReader) + } + else if ("hp:rotationInfo" == sNodeName) + { + START_READ_ATTRIBUTES(oReader) + { + if ("angle" == sAttributeName) + m_shRotat = oReader.GetInt(); + else if ("centerX" == sAttributeName) + m_nXCenter = oReader.GetInt(); + else if ("centerY" == sAttributeName) + m_nYCenter = oReader.GetInt(); + } + END_READ_ATTRIBUTES(oReader) + } + else if ("hp:renderingInfo" == sNodeName) + { + WHILE_READ_NEXT_NODE_WITH_DEPTH_AND_NAME(oReader, Child) + { + // Сначала идёт 1 hc:transMatrix, а после попарно идут hc:scaMatrix с hc:rotMatrix + + if ("hc:transMatrix" != sNodeChildName && + "hc:scaMatrix" != sNodeChildName && + "hc:rotMatrix" != sNodeChildName) + continue; + + m_arMatrixs.push_back(ReadMatrix(oReader)); + } + END_WHILE + } + else + CCtrlCommon::ParseChildren(oReader, nVersion); } int CCtrlObjElement::GetCurWidth() const @@ -145,9 +194,14 @@ int CCtrlObjElement::GetFinalHeight() const return CCtrlCommon::GetHeight(); } +short CCtrlObjElement::GetGroupLevel() const +{ + return m_shNGrp; +} + TMatrix CCtrlObjElement::GetFinalMatrix() const { - if (m_arMatrixs.empty() || 0 == m_shNGrp) + if (m_arMatrixs.empty()) return TMatrix(); TMatrix oMatrix{m_arMatrixs.front()}; diff --git a/HwpFile/HwpDoc/Paragraph/CtrlObjElement.h b/HwpFile/HwpDoc/Paragraph/CtrlObjElement.h index b1a2f5d39a..2045c3acab 100644 --- a/HwpFile/HwpDoc/Paragraph/CtrlObjElement.h +++ b/HwpFile/HwpDoc/Paragraph/CtrlObjElement.h @@ -44,7 +44,9 @@ public: CCtrlObjElement(const HWP_STRING& sCtrlID); CCtrlObjElement(const CCtrlObjElement& oObjElement); CCtrlObjElement(const HWP_STRING& sCtrlID, int nSize, CHWPStream& oBuffer, int nOff, int nVersion); - CCtrlObjElement(const HWP_STRING& sCtrlID, CXMLNode& oNode, int nVersion); + CCtrlObjElement(const HWP_STRING& sCtrlID, CXMLReader& oReader, int nVersion); + + void ParseChildren(CXMLReader& oReader, int nVersion); int GetCurWidth() const; int GetCurHeight() const; @@ -55,6 +57,8 @@ public: int GetFinalWidth() const; int GetFinalHeight() const; + short GetGroupLevel() const; + TMatrix GetFinalMatrix() const; bool HorzFlip() const; diff --git a/HwpFile/HwpDoc/Paragraph/CtrlPageNumPos.cpp b/HwpFile/HwpDoc/Paragraph/CtrlPageNumPos.cpp index fdd6846b4b..3b077236d1 100644 --- a/HwpFile/HwpDoc/Paragraph/CtrlPageNumPos.cpp +++ b/HwpFile/HwpDoc/Paragraph/CtrlPageNumPos.cpp @@ -54,13 +54,20 @@ CCtrlPageNumPos::CCtrlPageNumPos(const HWP_STRING& sCtrlID, int nSize, CHWPStrea oBuffer.ReadString(m_sConstantDash, 2, EStringCharacter::UTF16); } -CCtrlPageNumPos::CCtrlPageNumPos(const HWP_STRING& sCtrlID, CXMLNode& oNode, int nVersion) +CCtrlPageNumPos::CCtrlPageNumPos(const HWP_STRING& sCtrlID, CXMLReader& oReader, int nVersion) : CCtrl(sCtrlID) { - m_ePos = GetNumPos(oNode.GetAttribute(L"pos")); - m_eNumShape = GetNumberShape2(oNode.GetAttributeInt(L"formatType")); + START_READ_ATTRIBUTES(oReader) + { + if ("pos" == sAttributeName) + m_ePos = GetNumPos(oReader.GetText()); + else if ("formatType" == sAttributeName) + m_eNumShape = GetNumberShape2(oReader.GetInt()); + else if ("sideChar" == sAttributeName) + m_sPostfix = oReader.GetText(); + } + END_READ_ATTRIBUTES(oReader) - m_sPostfix = oNode.GetAttribute(L"sideChar"); m_sPrefix = m_sPostfix; } diff --git a/HwpFile/HwpDoc/Paragraph/CtrlPageNumPos.h b/HwpFile/HwpDoc/Paragraph/CtrlPageNumPos.h index 036d306afd..e03f0198df 100644 --- a/HwpFile/HwpDoc/Paragraph/CtrlPageNumPos.h +++ b/HwpFile/HwpDoc/Paragraph/CtrlPageNumPos.h @@ -4,7 +4,7 @@ #include "Ctrl.h" #include "../HWPStream.h" #include "../HWPElements/HwpRecordTypes.h" -#include "../Common/XMLNode.h" +#include "../Common/XMLReader.h" namespace HWP { @@ -34,7 +34,7 @@ class CCtrlPageNumPos : public CCtrl public: CCtrlPageNumPos(const HWP_STRING& sCtrlID); CCtrlPageNumPos(const HWP_STRING& sCtrlID, int nSize, CHWPStream& oBuffer, int nOff, int nVersion); - CCtrlPageNumPos(const HWP_STRING& sCtrlID, CXMLNode& oNode, int nVersion); + CCtrlPageNumPos(const HWP_STRING& sCtrlID, CXMLReader& oReader, int nVersion); ENumPos GetPos() const; diff --git a/HwpFile/HwpDoc/Paragraph/CtrlSectionDef.cpp b/HwpFile/HwpDoc/Paragraph/CtrlSectionDef.cpp index bf36ad142e..7bce2c250a 100644 --- a/HwpFile/HwpDoc/Paragraph/CtrlSectionDef.cpp +++ b/HwpFile/HwpDoc/Paragraph/CtrlSectionDef.cpp @@ -40,100 +40,140 @@ CCtrlSectionDef::CCtrlSectionDef(const HWP_STRING& sCtrlID, int nSize, CHWPStrea m_bFullFilled = true; } -CCtrlSectionDef::CCtrlSectionDef(const HWP_STRING& sCtrlID, CXMLNode& oNode, int nVersion) +CCtrlSectionDef::CCtrlSectionDef(const HWP_STRING& sCtrlID, CXMLReader& oReader, int nVersion) : CCtrl(sCtrlID), m_pPage(nullptr) { - HWP_STRING sType = oNode.GetAttribute(L"textDirection"); + std::string sType; - if (L"HORIZONTAL" == sType) - m_chTextDirection = 0; - else if (L"VERTICAL" == sType) - m_chTextDirection = 1; - - m_shSpaceColumns = oNode.GetAttributeInt(L"spaceColumns"); - m_nTabStop = oNode.GetAttributeInt(L"tabStop"); - m_nOutlineNumberingID = oNode.GetAttributeInt(L"outlineShapeIDRef"); - - for (CXMLNode& oChild : oNode.GetChilds()) + START_READ_ATTRIBUTES(oReader) { - if (L"hp:startNum" == oChild.GetName()) + if ("textDirection" == sAttributeName) { - sType = oChild.GetAttribute(L"pageStartsOn"); + sType = oReader.GetTextA(); - if (L"BOTH" == sType) - m_chPageStartOn = 0; - else if (L"EVEN" == sType) - m_chPageStartOn = 1; - else if (L"ODD" == sType) - m_chPageStartOn = 2; - - m_shPageNum = oChild.GetAttributeInt(L"page"); - m_shFigure = oChild.GetAttributeInt(L"pic"); - m_shTable = oChild.GetAttributeInt(L"tbl"); - m_shEquation = oChild.GetAttributeInt(L"equation"); + if ("HORIZONTAL" == sType) + m_chTextDirection = 0; + else if ("VERTICAL" == sType) + m_chTextDirection = 1; } - else if (L"hp:grid" == oChild.GetName()) + else if ("spaceColumns" == sAttributeName) + m_shSpaceColumns = oReader.GetInt(); + else if ("tabStop" == sAttributeName) + m_nTabStop = oReader.GetInt(); + else if ("outlineShapeIDRef" == sAttributeName) + m_nOutlineNumberingID = oReader.GetInt(); + } + END_READ_ATTRIBUTES(oReader) + + WHILE_READ_NEXT_NODE_WITH_NAME(oReader) + { + if ("hp:startNum" == sNodeName) { - m_shLineGrid = oChild.GetAttributeInt(L"lineGrid"); - m_shCharGrid = oChild.GetAttributeInt(L"charGrid"); + START_READ_ATTRIBUTES(oReader) + { + if ("pageStartsOn" == sAttributeName) + { + sType = oReader.GetTextA(); + + if ("BOTH" == sType) + m_chPageStartOn = 0; + else if ("EVEN" == sType) + m_chPageStartOn = 1; + else if ("ODD" == sType) + m_chPageStartOn = 2; + } + else if ("page" == sAttributeName) + m_shPageNum = oReader.GetInt(); + else if ("pic" == sAttributeName) + m_shFigure = oReader.GetInt(); + else if ("tbl" == sAttributeName) + m_shTable = oReader.GetInt(); + else if ("equation" == sAttributeName) + m_shEquation = oReader.GetInt(); + } + END_READ_ATTRIBUTES(oReader) } - else if (L"hp:visibility" == oChild.GetName()) + else if ("hp:grid" == sNodeName) { - m_bHideHeader = oChild.GetAttributeBool(L"hideFirstHeader"); - m_bHideFooter = oChild.GetAttributeBool(L"hideFirstFooter"); - m_bHideMasterPage = oChild.GetAttributeBool(L"hideFirstMasterPage"); - - sType = oChild.GetAttribute(L"border"); - - if (L"HIDE_FIRST" == sType) + START_READ_ATTRIBUTES(oReader) { - m_bHideBorder = true; - m_bShowFirstBorder = false; + if ("lineGrid" == sAttributeName) + m_shLineGrid = oReader.GetInt(); + else if ("charGrid" == sAttributeName) + m_shCharGrid = oReader.GetInt(); } - else if (L"SHOW_FIRST" == sType) - { - m_bHideBorder = true; - m_bShowFirstBorder = true; - } - else if (L"SHOW_ALL" == sType) - { - m_bHideBorder = false; - m_bShowFirstBorder = false; - } - - sType = oChild.GetAttribute(L"fill"); - - if (L"HIDE_FIRST" == sType) - { - m_bHideFill = true; - m_bShowFirstFill = false; - } - else if (L"SHOW_FIRST" == sType) - { - m_bHideFill = true; - m_bShowFirstFill = true; - } - else if (L"SHOW_ALL" == sType) - { - m_bHideFill = false; - m_bShowFirstFill = false; - } - - m_bHidePageNumPos = oChild.GetAttributeBool(L"hideFirstPageNum"); - m_bHideEmptyLine = oChild.GetAttributeBool(L"hideFirstEmptyLine"); + END_READ_ATTRIBUTES(oReader) } - else if (L"hp:pagePr" == oChild.GetName()) - m_pPage = new CPage(oChild); - else if (L"hp:footNotePr" == oChild.GetName() || - L"hp:endNotePr" == oChild.GetName()) - m_arNoteShapes.push_back(new CNoteShape(oChild, nVersion)); - else if (L"hp:pageBorderFill" == oChild.GetName()) - m_arBorderFills.push_back(new CPageBorderFill(oChild, nVersion)); - else if (L"hp:masterPage" == oChild.GetName()) + else if ("hp:visibility" == sNodeName) + { + START_READ_ATTRIBUTES(oReader) + { + if ("hideFirstHeader" == sAttributeName) + m_bHideHeader = oReader.GetBool(); + else if ("hideFirstFooter" == sAttributeName) + m_bHideFooter = oReader.GetBool(); + else if ("hideFirstMasterPage" == sAttributeName) + m_bHideMasterPage = oReader.GetBool(); + else if ("border" == sAttributeName) + { + sType = oReader.GetTextA(); + + if ("HIDE_FIRST" == sType) + { + m_bHideBorder = true; + m_bShowFirstBorder = false; + } + else if ("SHOW_FIRST" == sType) + { + m_bHideBorder = true; + m_bShowFirstBorder = true; + } + else if ("SHOW_ALL" == sType) + { + m_bHideBorder = false; + m_bShowFirstBorder = false; + } + } + else if ("fill" == sAttributeName) + { + sType = oReader.GetTextA(); + + if ("HIDE_FIRST" == sType) + { + m_bHideFill = true; + m_bShowFirstFill = false; + } + else if ("SHOW_FIRST" == sType) + { + m_bHideFill = true; + m_bShowFirstFill = true; + } + else if ("SHOW_ALL" == sType) + { + m_bHideFill = false; + m_bShowFirstFill = false; + } + } + else if ("hp:visibility" == sAttributeName) + m_bHidePageNumPos = oReader.GetBool(); + else if ("hideFirstEmptyLine" == sAttributeName) + m_bHideEmptyLine = oReader.GetBool(); + } + END_READ_ATTRIBUTES(oReader) + } + else if ("hp:pagePr" == sNodeName) + m_pPage = new CPage(oReader); + else if ("hp:footNotePr" == sNodeName || + "hp:endNotePr" == sNodeName) + m_arNoteShapes.push_back(new CNoteShape(oReader, nVersion)); + else if ("hp:pageBorderFill" == sNodeName) + m_arBorderFills.push_back(new CPageBorderFill(oReader, nVersion)); + else if ("hp:masterPage" == sNodeName) { //TODO:: добавить реализацию } } + END_WHILE m_bFullFilled = true; } diff --git a/HwpFile/HwpDoc/Paragraph/CtrlSectionDef.h b/HwpFile/HwpDoc/Paragraph/CtrlSectionDef.h index a16478934d..04ebc2ad93 100644 --- a/HwpFile/HwpDoc/Paragraph/CtrlSectionDef.h +++ b/HwpFile/HwpDoc/Paragraph/CtrlSectionDef.h @@ -45,7 +45,7 @@ class CCtrlSectionDef : public CCtrl public: CCtrlSectionDef(const HWP_STRING& sCtrlID); CCtrlSectionDef(const HWP_STRING& sCtrlID, int nSize, CHWPStream& oBuffer, int nOff, int nVersion); - CCtrlSectionDef(const HWP_STRING& sCtrlID, CXMLNode& oNode, int nVersion); + CCtrlSectionDef(const HWP_STRING& sCtrlID, CXMLReader& oReader, int nVersion); ~CCtrlSectionDef(); ECtrlObjectType GetCtrlType() const override; diff --git a/HwpFile/HwpDoc/Paragraph/CtrlShapeArc.cpp b/HwpFile/HwpDoc/Paragraph/CtrlShapeArc.cpp index 0ee8be0f52..9d4d3f7a00 100644 --- a/HwpFile/HwpDoc/Paragraph/CtrlShapeArc.cpp +++ b/HwpFile/HwpDoc/Paragraph/CtrlShapeArc.cpp @@ -17,29 +17,50 @@ CCtrlShapeArc::CCtrlShapeArc(const HWP_STRING& sCtrlID, int nSize, CHWPStream& o : CCtrlGeneralShape(sCtrlID, nSize, oBuffer, nOff, nVersion) {} -CCtrlShapeArc::CCtrlShapeArc(const HWP_STRING& sCtrlID, CXMLNode& oNode, int nVersion) - : CCtrlGeneralShape(sCtrlID, oNode, nVersion) +CCtrlShapeArc::CCtrlShapeArc(const HWP_STRING& sCtrlID, CXMLReader& oReader, int nVersion) + : CCtrlGeneralShape(sCtrlID, oReader, nVersion) { - m_eType = GetArcType(oNode.GetAttributeInt(L"type")); + m_eType = GetArcType(oReader.GetAttributeInt("type")); - for (CXMLNode& oChild : oNode.GetChilds()) + WHILE_READ_NEXT_NODE_WITH_NAME(oReader) { - if (L"hp:center" == oChild.GetName()) + if ("hp:center" == sNodeName) { - m_nCenterX = oChild.GetAttributeInt(L"x"); - m_nCenterY = oChild.GetAttributeInt(L"y"); + START_READ_ATTRIBUTES(oReader) + { + if ("x" == sAttributeName) + m_nCenterX = oReader.GetInt(); + else if ("y" == sAttributeName) + m_nCenterY = oReader.GetInt(); + } + END_READ_ATTRIBUTES(oReader) } - else if (L"hp:ax1" == oChild.GetName()) + else if ("hp:ax1" == sNodeName) { - m_nAxixX1 = oChild.GetAttributeInt(L"x"); - m_nAxixY1 = oChild.GetAttributeInt(L"y"); + START_READ_ATTRIBUTES(oReader) + { + if ("x" == sAttributeName) + m_nAxixX1 = oReader.GetInt(); + else if ("y" == sAttributeName) + m_nAxixY1 = oReader.GetInt(); + } + END_READ_ATTRIBUTES(oReader) } - else if (L"hp:ax2" == oChild.GetName()) + else if ("hp:ax2" == sNodeName) { - m_nAxixX2 = oChild.GetAttributeInt(L"x"); - m_nAxixY2 = oChild.GetAttributeInt(L"y"); + START_READ_ATTRIBUTES(oReader) + { + if ("x" == sAttributeName) + m_nAxixX2 = oReader.GetInt(); + else if ("y" == sAttributeName) + m_nAxixY2 = oReader.GetInt(); + } + END_READ_ATTRIBUTES(oReader) } + else + CCtrlGeneralShape::ParseChildren(oReader, nVersion); } + END_WHILE } EShapeType CCtrlShapeArc::GetShapeType() const diff --git a/HwpFile/HwpDoc/Paragraph/CtrlShapeArc.h b/HwpFile/HwpDoc/Paragraph/CtrlShapeArc.h index f9e891d572..f3407d46fd 100644 --- a/HwpFile/HwpDoc/Paragraph/CtrlShapeArc.h +++ b/HwpFile/HwpDoc/Paragraph/CtrlShapeArc.h @@ -20,7 +20,7 @@ public: CCtrlShapeArc(const HWP_STRING& sCtrlID); CCtrlShapeArc(const CCtrlGeneralShape& oShape); CCtrlShapeArc(const HWP_STRING& sCtrlID, int nSize, CHWPStream& oBuffer, int nOff, int nVersion); - CCtrlShapeArc(const HWP_STRING& sCtrlID, CXMLNode& oNode, int nVersion); + CCtrlShapeArc(const HWP_STRING& sCtrlID, CXMLReader& oReader, int nVersion); EShapeType GetShapeType() const override; diff --git a/HwpFile/HwpDoc/Paragraph/CtrlShapeConnectLine.cpp b/HwpFile/HwpDoc/Paragraph/CtrlShapeConnectLine.cpp index d3f3fe44f2..31745f6fab 100644 --- a/HwpFile/HwpDoc/Paragraph/CtrlShapeConnectLine.cpp +++ b/HwpFile/HwpDoc/Paragraph/CtrlShapeConnectLine.cpp @@ -25,28 +25,47 @@ CCtrlShapeConnectLine::CCtrlShapeConnectLine(const HWP_STRING& sCtrlID, int nSiz : CCtrlGeneralShape(sCtrlID, nSize, oBuffer, nOff, nVersion) {} -CCtrlShapeConnectLine::CCtrlShapeConnectLine(const HWP_STRING& sCtrlID, CXMLNode& oNode, int nVersion) - : CCtrlGeneralShape(sCtrlID, oNode, nVersion) +CCtrlShapeConnectLine::CCtrlShapeConnectLine(const HWP_STRING& sCtrlID, CXMLReader& oReader, int nVersion) + : CCtrlGeneralShape(sCtrlID, oReader, nVersion) { - m_eType = GetConnectLineType(oNode.GetAttributeInt(L"type")); + m_eType = GetConnectLineType(oReader.GetAttributeInt("type")); - for (CXMLNode& oChild : oNode.GetChilds()) + WHILE_READ_NEXT_NODE_WITH_NAME(oReader) { - if (L"hp:startPt" == oChild.GetName()) + if ("hp:startPt" == sNodeName) { - m_oStartPt.m_nX = oChild.GetAttributeInt(L"x"); - m_oStartPt.m_nY = oChild.GetAttributeInt(L"y"); - m_oStartPt.m_shSubjectIDRef = oChild.GetAttributeInt(L"subjectIDRef"); - m_oStartPt.m_shSubjectIdx = oChild.GetAttributeInt(L"subjectIdx"); + START_READ_ATTRIBUTES(oReader) + { + if ("x" == sAttributeName) + m_oStartPt.m_nX = oReader.GetInt(); + else if ("y" == sAttributeName) + m_oStartPt.m_nY = oReader.GetInt(); + else if ("subjectIDRef" == sAttributeName) + m_oStartPt.m_shSubjectIDRef = oReader.GetInt(); + else if ("subjectIdx" == sAttributeName) + m_oStartPt.m_shSubjectIdx = oReader.GetInt(); + } + END_READ_ATTRIBUTES(oReader) } - else if (L"hp:endPt" == oChild.GetName()) + else if ("hp:endPt" == sNodeName) { - m_oEndPt.m_nX = oChild.GetAttributeInt(L"x"); - m_oEndPt.m_nY = oChild.GetAttributeInt(L"y"); - m_oEndPt.m_shSubjectIDRef = oChild.GetAttributeInt(L"subjectIDRef"); - m_oEndPt.m_shSubjectIdx = oChild.GetAttributeInt(L"subjectIdx"); + START_READ_ATTRIBUTES(oReader) + { + if ("x" == sAttributeName) + m_oEndPt.m_nX = oReader.GetInt(); + else if ("y" == sAttributeName) + m_oEndPt.m_nY = oReader.GetInt(); + else if ("subjectIDRef" == sAttributeName) + m_oEndPt.m_shSubjectIDRef = oReader.GetInt(); + else if ("subjectIdx" == sAttributeName) + m_oEndPt.m_shSubjectIdx = oReader.GetInt(); + } + END_READ_ATTRIBUTES(oReader) } + else + CCtrlGeneralShape::ParseChildren(oReader, nVersion); } + END_WHILE } EShapeType CCtrlShapeConnectLine::GetShapeType() const diff --git a/HwpFile/HwpDoc/Paragraph/CtrlShapeConnectLine.h b/HwpFile/HwpDoc/Paragraph/CtrlShapeConnectLine.h index 2ac0ee7daf..a1971b08bc 100644 --- a/HwpFile/HwpDoc/Paragraph/CtrlShapeConnectLine.h +++ b/HwpFile/HwpDoc/Paragraph/CtrlShapeConnectLine.h @@ -33,7 +33,7 @@ class CCtrlShapeConnectLine : public CCtrlGeneralShape TConnectPoint m_oEndPt; public: CCtrlShapeConnectLine(const HWP_STRING& sCtrlID, int nSize, CHWPStream& oBuffer, int nOff, int nVersion); - CCtrlShapeConnectLine(const HWP_STRING& sCtrlID, CXMLNode& oNode, int nVersion); + CCtrlShapeConnectLine(const HWP_STRING& sCtrlID, CXMLReader& oReader, int nVersion); EShapeType GetShapeType() const override; }; diff --git a/HwpFile/HwpDoc/Paragraph/CtrlShapeCurve.cpp b/HwpFile/HwpDoc/Paragraph/CtrlShapeCurve.cpp index 937b4016f4..1c16541c6e 100644 --- a/HwpFile/HwpDoc/Paragraph/CtrlShapeCurve.cpp +++ b/HwpFile/HwpDoc/Paragraph/CtrlShapeCurve.cpp @@ -17,34 +17,52 @@ CCtrlShapeCurve::CCtrlShapeCurve(const HWP_STRING& sCtrlID, int nSize, CHWPStrea : CCtrlGeneralShape(sCtrlID, nSize, oBuffer, nOff, nVersion) {} -CCtrlShapeCurve::CCtrlShapeCurve(const HWP_STRING& sCtrlID, CXMLNode& oNode, int nVersion) - : CCtrlGeneralShape(sCtrlID, oNode, nVersion) +CCtrlShapeCurve::CCtrlShapeCurve(const HWP_STRING& sCtrlID, CXMLReader& oReader, int nVersion) + : CCtrlGeneralShape(sCtrlID, oReader, nVersion) { - std::vector arChilds{oNode.GetChilds(L"hp:seg")}; + // bool bReadedType + TPoint oPoint1{0, 0}, oPoint2{0, 0}; + HWP_BYTE chSegmentType = 0; - m_arPoints.resize(arChilds.size() + 1); - m_arSegmentType.resize(arChilds.size()); - - HWP_STRING sType; - - for (unsigned int unIndex = 0; unIndex < arChilds.size(); ++unIndex) + WHILE_READ_NEXT_NODE(oReader) { - sType = arChilds[unIndex].GetAttribute(L"type"); - - if (L"CURVE" == sType) - m_arSegmentType[unIndex] = 1; - else if (L"LINE" == sType) - m_arSegmentType[unIndex] = 0; - - m_arPoints[unIndex].m_nX = arChilds[unIndex].GetAttributeInt(L"x1"); - m_arPoints[unIndex].m_nY = arChilds[unIndex].GetAttributeInt(L"y1"); - - if (unIndex == arChilds.size() - 1) + if ("hp:seg" == oReader.GetName()) { - m_arPoints[unIndex + 1].m_nX = arChilds[unIndex].GetAttributeInt(L"x2"); - m_arPoints[unIndex + 1].m_nY = arChilds[unIndex].GetAttributeInt(L"y2"); + chSegmentType = 0; + oPoint1 = {0, 0}; + oPoint2 = {0, 0}; + + START_READ_ATTRIBUTES(oReader) + { + if ("type" == sAttributeName) + { + const std::string sType{oReader.GetTextA()}; + + if ("CURVE" == sType) + chSegmentType = 1; + else if ("LINE" == sType) + chSegmentType = 0; + } + else if ("x1" == sAttributeName) + oPoint1.m_nX = oReader.GetInt(); + else if ("y1" == sAttributeName) + oPoint1.m_nY = oReader.GetInt(); + else if ("x2" == sAttributeName) + oPoint2.m_nX = oReader.GetInt(); + else if ("y2" == sAttributeName) + oPoint2.m_nY = oReader.GetInt(); + } + END_READ_ATTRIBUTES(oReader) + + m_arSegmentType.push_back(chSegmentType); + m_arPoints.push_back(oPoint1); } + else + CCtrlGeneralShape::ParseChildren(oReader, nVersion); } + END_WHILE + + m_arPoints.push_back(oPoint2); } EShapeType CCtrlShapeCurve::GetShapeType() const diff --git a/HwpFile/HwpDoc/Paragraph/CtrlShapeCurve.h b/HwpFile/HwpDoc/Paragraph/CtrlShapeCurve.h index 11a3bc1ab8..4ae6551bc8 100644 --- a/HwpFile/HwpDoc/Paragraph/CtrlShapeCurve.h +++ b/HwpFile/HwpDoc/Paragraph/CtrlShapeCurve.h @@ -16,7 +16,7 @@ public: CCtrlShapeCurve(const HWP_STRING& sCtrlID); CCtrlShapeCurve(const CCtrlGeneralShape& oShape); CCtrlShapeCurve(const HWP_STRING& sCtrlID, int nSize, CHWPStream& oBuffer, int nOff, int nVersion); - CCtrlShapeCurve(const HWP_STRING& sCtrlID, CXMLNode& oNode, int nVersion); + CCtrlShapeCurve(const HWP_STRING& sCtrlID, CXMLReader& oReader, int nVersion); EShapeType GetShapeType() const override; diff --git a/HwpFile/HwpDoc/Paragraph/CtrlShapeEllipse.cpp b/HwpFile/HwpDoc/Paragraph/CtrlShapeEllipse.cpp index 30f534d17c..de8abcdb8c 100644 --- a/HwpFile/HwpDoc/Paragraph/CtrlShapeEllipse.cpp +++ b/HwpFile/HwpDoc/Paragraph/CtrlShapeEllipse.cpp @@ -34,51 +34,103 @@ CCtrlShapeEllipse::CCtrlShapeEllipse(const HWP_STRING& sCtrlID, int nSize, CHWPS : CCtrlGeneralShape(sCtrlID, nSize, oBuffer, nOff, nVersion) {} -CCtrlShapeEllipse::CCtrlShapeEllipse(const HWP_STRING& sCtrlID, CXMLNode& oNode, int nVersion) - : CCtrlGeneralShape(sCtrlID, oNode, nVersion) +CCtrlShapeEllipse::CCtrlShapeEllipse(const HWP_STRING& sCtrlID, CXMLReader& oReader, int nVersion) + : CCtrlGeneralShape(sCtrlID, oReader, nVersion) { - m_bIntervalDirty = oNode.GetAttributeBool(L"intervalDirty"); - m_bHasArcProperty = oNode.GetAttributeBool(L"hasArcPr"); - m_eArcType = GetArcType(oNode.GetAttribute(L"arcType")); - - for (CXMLNode& oChild : oNode.GetChilds()) + START_READ_ATTRIBUTES(oReader) { - if (L"hc:center" == oChild.GetName()) - { - m_nCenterX = oChild.GetAttributeInt(L"x"); - m_nCenterY = oChild.GetAttributeInt(L"y"); - } - else if (L"hp:ax1" == oChild.GetName()) - { - m_nAxixX1 = oChild.GetAttributeInt(L"x"); - m_nAxixY1 = oChild.GetAttributeInt(L"y"); - } - else if (L"hp:ax2" == oChild.GetName()) - { - m_nAxixX2 = oChild.GetAttributeInt(L"x"); - m_nAxixY2 = oChild.GetAttributeInt(L"y"); - } - else if (L"hc:start1" == oChild.GetName()) - { - m_nStartX1 = oChild.GetAttributeInt(L"x"); - m_nStartY1 = oChild.GetAttributeInt(L"y"); - } - else if (L"hc:start2" == oChild.GetName()) - { - m_nStartX2 = oChild.GetAttributeInt(L"x"); - m_nStartY2 = oChild.GetAttributeInt(L"y"); - } - else if (L"hc:end1" == oChild.GetName()) - { - m_nEndX1 = oChild.GetAttributeInt(L"x"); - m_nEndY1 = oChild.GetAttributeInt(L"y"); - } - else if (L"hc:end2" == oChild.GetName()) - { - m_nEndX2 = oChild.GetAttributeInt(L"x"); - m_nEndY2 = oChild.GetAttributeInt(L"y"); - } + if ("intervalDirty" == sAttributeName) + m_bIntervalDirty = oReader.GetBool(); + else if ("hasArcPr" == sAttributeName) + m_bHasArcProperty = oReader.GetBool(); + else if ("arcType" == sAttributeName) + m_eArcType = GetArcType(oReader.GetText()); } + END_READ_ATTRIBUTES(oReader) + + WHILE_READ_NEXT_NODE_WITH_NAME(oReader) + { + if ("hc:center" == sNodeName) + { + START_READ_ATTRIBUTES(oReader) + { + if ("x" == sAttributeName) + m_nCenterX = oReader.GetInt(); + else if ("y" == sAttributeName) + m_nCenterY = oReader.GetInt(); + } + END_READ_ATTRIBUTES(oReader) + } + else if ("hp:ax1" == sNodeName) + { + START_READ_ATTRIBUTES(oReader) + { + if ("x" == sAttributeName) + m_nAxixX1 = oReader.GetInt(); + else if ("y" == sAttributeName) + m_nAxixY1 = oReader.GetInt(); + } + END_READ_ATTRIBUTES(oReader) + } + else if ("hp:ax2" == sNodeName) + { + START_READ_ATTRIBUTES(oReader) + { + if ("x" == sAttributeName) + m_nAxixX2 = oReader.GetInt(); + else if ("y" == sAttributeName) + m_nAxixY2 = oReader.GetInt(); + } + END_READ_ATTRIBUTES(oReader) + } + else if ("hp:start1" == sNodeName) + { + START_READ_ATTRIBUTES(oReader) + { + if ("x" == sAttributeName) + m_nStartX1 = oReader.GetInt(); + else if ("y" == sAttributeName) + m_nStartY1 = oReader.GetInt(); + } + END_READ_ATTRIBUTES(oReader) + } + else if ("hp:start2" == sNodeName) + { + START_READ_ATTRIBUTES(oReader) + { + if ("x" == sAttributeName) + m_nStartX2 = oReader.GetInt(); + else if ("y" == sAttributeName) + m_nStartY2 = oReader.GetInt(); + } + END_READ_ATTRIBUTES(oReader) + } + else if ("hp:end1" == sNodeName) + { + START_READ_ATTRIBUTES(oReader) + { + if ("x" == sAttributeName) + m_nEndX1 = oReader.GetInt(); + else if ("y" == sAttributeName) + m_nEndY1 = oReader.GetInt(); + } + END_READ_ATTRIBUTES(oReader) + } + else if ("hp:end2" == sNodeName) + { + START_READ_ATTRIBUTES(oReader) + { + if ("x" == sAttributeName) + m_nEndX2 = oReader.GetInt(); + else if ("y" == sAttributeName) + m_nEndY2 = oReader.GetInt(); + } + END_READ_ATTRIBUTES(oReader) + } + else + CCtrlGeneralShape::ParseChildren(oReader, nVersion); + } + END_WHILE } EShapeType CCtrlShapeEllipse::GetShapeType() const diff --git a/HwpFile/HwpDoc/Paragraph/CtrlShapeEllipse.h b/HwpFile/HwpDoc/Paragraph/CtrlShapeEllipse.h index ad0b28ba7c..670dc4c994 100644 --- a/HwpFile/HwpDoc/Paragraph/CtrlShapeEllipse.h +++ b/HwpFile/HwpDoc/Paragraph/CtrlShapeEllipse.h @@ -39,7 +39,7 @@ public: CCtrlShapeEllipse(const HWP_STRING& sCtrlID); CCtrlShapeEllipse(const CCtrlGeneralShape& oShape); CCtrlShapeEllipse(const HWP_STRING& sCtrlID, int nSize, CHWPStream& oBuffer, int nOff, int nVersion); - CCtrlShapeEllipse(const HWP_STRING& sCtrlID, CXMLNode& oNode, int nVersion); + CCtrlShapeEllipse(const HWP_STRING& sCtrlID, CXMLReader& oReader, int nVersion); EShapeType GetShapeType() const override; diff --git a/HwpFile/HwpDoc/Paragraph/CtrlShapeLine.cpp b/HwpFile/HwpDoc/Paragraph/CtrlShapeLine.cpp index 665df293f9..a832005dd3 100644 --- a/HwpFile/HwpDoc/Paragraph/CtrlShapeLine.cpp +++ b/HwpFile/HwpDoc/Paragraph/CtrlShapeLine.cpp @@ -17,24 +17,39 @@ CCtrlShapeLine::CCtrlShapeLine(const HWP_STRING& sCtrlID, int nSize, CHWPStream& : CCtrlGeneralShape(sCtrlID, nSize, oBuffer, nOff, nVersion) {} -CCtrlShapeLine::CCtrlShapeLine(const HWP_STRING& sCtrlID, CXMLNode& oNode, int nVersion) - : CCtrlGeneralShape(sCtrlID, oNode, nVersion) +CCtrlShapeLine::CCtrlShapeLine(const HWP_STRING& sCtrlID, CXMLReader& oReader, int nVersion) + : CCtrlGeneralShape(sCtrlID, oReader, nVersion) { - m_shAttr = (short)oNode.GetAttributeBool(L"isReverseHV"); + m_shAttr = (short)oReader.GetAttributeBool("isReverseHV"); - for (CXMLNode& oChild : oNode.GetChilds()) + WHILE_READ_NEXT_NODE_WITH_NAME(oReader) { - if (L"hc:startPt" == oChild.GetName()) + if ("hc:startPt" == sNodeName) { - m_nStartX = oChild.GetAttributeInt(L"x"); - m_nStartY = oChild.GetAttributeInt(L"y"); + START_READ_ATTRIBUTES(oReader) + { + if ("x" == sAttributeName) + m_nStartX = oReader.GetInt(); + else if ("y" == sAttributeName) + m_nStartY = oReader.GetInt(); + } + END_READ_ATTRIBUTES(oReader) } - else if (L"hc:endPt" == oChild.GetName()) + else if ("hc:endPt" == sNodeName) { - m_nEndX = oChild.GetAttributeInt(L"x"); - m_nEndY = oChild.GetAttributeInt(L"y"); + START_READ_ATTRIBUTES(oReader) + { + if ("x" == sAttributeName) + m_nEndX = oReader.GetInt(); + else if ("y" == sAttributeName) + m_nEndY = oReader.GetInt(); + } + END_READ_ATTRIBUTES(oReader) } + else + CCtrlGeneralShape::ParseChildren(oReader, nVersion); } + END_WHILE } EShapeType CCtrlShapeLine::GetShapeType() const diff --git a/HwpFile/HwpDoc/Paragraph/CtrlShapeLine.h b/HwpFile/HwpDoc/Paragraph/CtrlShapeLine.h index 45aa7d8722..0e214b5129 100644 --- a/HwpFile/HwpDoc/Paragraph/CtrlShapeLine.h +++ b/HwpFile/HwpDoc/Paragraph/CtrlShapeLine.h @@ -17,7 +17,7 @@ public: CCtrlShapeLine(const HWP_STRING& sCtrlID); CCtrlShapeLine(const CCtrlGeneralShape& oShape); CCtrlShapeLine(const HWP_STRING& sCtrlID, int nSize, CHWPStream& oBuffer, int nOff, int nVersion); - CCtrlShapeLine(const HWP_STRING& sCtrlID, CXMLNode& oNode, int nVersion); + CCtrlShapeLine(const HWP_STRING& sCtrlID, CXMLReader& oReader, int nVersion); EShapeType GetShapeType() const override; diff --git a/HwpFile/HwpDoc/Paragraph/CtrlShapeOle.cpp b/HwpFile/HwpDoc/Paragraph/CtrlShapeOle.cpp index d209927c52..8152281646 100644 --- a/HwpFile/HwpDoc/Paragraph/CtrlShapeOle.cpp +++ b/HwpFile/HwpDoc/Paragraph/CtrlShapeOle.cpp @@ -17,16 +17,28 @@ CCtrlShapeOle::CCtrlShapeOle(const HWP_STRING& sCtrlID, int nSize, CHWPStream& o : CCtrlGeneralShape(sCtrlID, nSize, oBuffer, nOff, nVersion) {} -CCtrlShapeOle::CCtrlShapeOle(const HWP_STRING& sCtrlID, CXMLNode& oNode, int nVersion) - : CCtrlGeneralShape(sCtrlID, oNode, nVersion) +CCtrlShapeOle::CCtrlShapeOle(const HWP_STRING& sCtrlID, CXMLReader& oReader, int nVersion) + : CCtrlGeneralShape(sCtrlID, oReader, nVersion) { - m_sBinDataID = oNode.GetAttribute(L"binaryItemIDRef"); + m_sBinDataID = oReader.GetAttribute("binaryItemIDRef"); - for (CXMLNode& oChild : oNode.GetChilds(L"hc:extent")) + WHILE_READ_NEXT_NODE(oReader) { - m_nExtentX = oChild.GetAttributeInt(L"x"); - m_nExtentY = oChild.GetAttributeInt(L"y"); + if ("hc:extent" == oReader.GetName()) + { + START_READ_ATTRIBUTES(oReader) + { + if ("x" == sAttributeName) + m_nExtentX = oReader.GetInt(); + else if ("y" == sAttributeName) + m_nExtentY = oReader.GetInt(); + } + END_READ_ATTRIBUTES(oReader) + } + else + CCtrlGeneralShape::ParseChildren(oReader, nVersion); } + END_WHILE } EShapeType CCtrlShapeOle::GetShapeType() const diff --git a/HwpFile/HwpDoc/Paragraph/CtrlShapeOle.h b/HwpFile/HwpDoc/Paragraph/CtrlShapeOle.h index 97bd07b4ec..33e2305dae 100644 --- a/HwpFile/HwpDoc/Paragraph/CtrlShapeOle.h +++ b/HwpFile/HwpDoc/Paragraph/CtrlShapeOle.h @@ -19,7 +19,7 @@ public: CCtrlShapeOle(const HWP_STRING& sCtrlID); CCtrlShapeOle(const CCtrlGeneralShape& oShape); CCtrlShapeOle(const HWP_STRING& sCtrlID, int nSize, CHWPStream& oBuffer, int nOff, int nVersion); - CCtrlShapeOle(const HWP_STRING& sCtrlID, CXMLNode& oNode, int nVersion); + CCtrlShapeOle(const HWP_STRING& sCtrlID, CXMLReader& oReader, int nVersion); EShapeType GetShapeType() const override; diff --git a/HwpFile/HwpDoc/Paragraph/CtrlShapePic.cpp b/HwpFile/HwpDoc/Paragraph/CtrlShapePic.cpp index 9d49958d92..31b218106e 100644 --- a/HwpFile/HwpDoc/Paragraph/CtrlShapePic.cpp +++ b/HwpFile/HwpDoc/Paragraph/CtrlShapePic.cpp @@ -25,7 +25,7 @@ CPicColor::CPicColor(CHWPStream& oBuffer, int nOff, int nSize) m_nSize = nSize; } -CPicColor::CPicColor(CXMLNode& oNode) +CPicColor::CPicColor(CXMLReader& oReader) { //TODO:: проверить m_nType = 0; @@ -65,33 +65,54 @@ CShadow::CShadow(int nTypeNum, CHWPStream& oBuffer, int nOff, int nSize) m_nSize = oBuffer.GetDistanceToLastPos(true); } -CShadow::CShadow(CXMLNode& oNode, int nVersion) +CShadow::CShadow(CXMLReader& oReader, int nVersion) : CPicEffect(EPicEffectType::SHADOW), m_pColor(nullptr) { - m_nStyle = oNode.GetAttributeInt(L"style"); - m_nTransparency = oNode.GetAttributeInt(L"alpha"); - m_nBlur = oNode.GetAttributeInt(L"radius"); - m_nDirection = oNode.GetAttributeInt(L"direction"); - m_nDistance = oNode.GetAttributeInt(L"distance"); - m_nRotation = (int)oNode.GetAttributeBool(L"rotationStyle"); - - for (CXMLNode& oChild : oNode.GetChilds()) + START_READ_ATTRIBUTES(oReader) { - if (L"hp:skew" == oChild.GetName()) - { - m_fAngleX = oChild.GetAttributeDouble(L"x"); - m_fAngleY = oChild.GetAttributeDouble(L"y"); - } - else if (L"hp:scale" == oChild.GetName()) - { - m_fMagnifyX = oChild.GetAttributeDouble(L"x"); - m_fMagnifyY = oChild.GetAttributeDouble(L"y"); - } - else if (L"hp:effectsColor" == oChild.GetName()) - { - m_pColor = new CPicColor(oChild); - } + if ("style" == sAttributeName) + m_nStyle = oReader.GetInt(); + else if ("alpha" == sAttributeName) + m_nTransparency = oReader.GetInt(); + else if ("radius" == sAttributeName) + m_nBlur = oReader.GetInt(); + else if ("direction" == sAttributeName) + m_nDirection = oReader.GetInt(); + else if ("distance" == sAttributeName) + m_nDistance = oReader.GetInt(); + else if ("rotationStyle" == sAttributeName) + m_nRotation = (int)oReader.GetBool(); } + END_READ_ATTRIBUTES(oReader) + + WHILE_READ_NEXT_NODE_WITH_NAME(oReader) + { + if ("hp:skew" == sNodeName) + { + START_READ_ATTRIBUTES(oReader) + { + if ("x" == sAttributeName) + m_fAngleX = oReader.GetInt(); + else if ("y" == sAttributeName) + m_fAngleY = oReader.GetInt(); + } + END_READ_ATTRIBUTES(oReader) + } + else if ("hp:scale" == sNodeName) + { + START_READ_ATTRIBUTES(oReader) + { + if ("x" == sAttributeName) + m_fMagnifyX = oReader.GetInt(); + else if ("y" == sAttributeName) + m_fMagnifyY = oReader.GetInt(); + } + END_READ_ATTRIBUTES(oReader) + } + else if ("hp:effectsColor" == sNodeName) + m_pColor = new CPicColor(oReader); + } + END_WHILE } CShadow::~CShadow() @@ -112,14 +133,24 @@ CNeon::CNeon(int nTypeNum, CHWPStream& oBuffer, int nOff, int nSize) m_nSize = oBuffer.GetDistanceToLastPos(true); } -CNeon::CNeon(CXMLNode& oNode, int nVersion) +CNeon::CNeon(CXMLReader& oReader, int nVersion) : CPicEffect(EPicEffectType::GLOW), m_pColor(nullptr) { - m_fTransparency = oNode.GetAttributeDouble(L"alpha"); - m_fRadius = oNode.GetAttributeDouble(L"radius"); + START_READ_ATTRIBUTES(oReader) + { + if ("alpha" == sAttributeName) + m_fTransparency = oReader.GetDouble(); + else if ("radius" == sAttributeName) + m_fRadius = oReader.GetDouble(); + } + END_READ_ATTRIBUTES(oReader) - CXMLNode oChild{oNode.GetChild(L"hp:effectsColor")}; - m_pColor = new CPicColor(oChild); + WHILE_READ_NEXT_NODE_WITH_ONE_NAME(oReader, "hp:effectsColor") + { + m_pColor = new CPicColor(oReader); + break; + } + END_WHILE } CNeon::~CNeon() @@ -136,10 +167,10 @@ CSoftEdge::CSoftEdge(int nTypeNum, CHWPStream& oBuffer, int nOff, int nSize) m_nSize = 4; } -CSoftEdge::CSoftEdge(CXMLNode& oNode, int nVersion) +CSoftEdge::CSoftEdge(CXMLReader& oReader, int nVersion) : CPicEffect(EPicEffectType::SOFT_EDGE) { - m_fRadius = oNode.GetAttributeDouble(L"radius"); + m_fRadius = oReader.GetAttributeDouble("radius"); } CReflect::CReflect(int nTypeNum, CHWPStream& oBuffer, int nOff, int nSize) @@ -165,38 +196,48 @@ CReflect::CReflect(int nTypeNum, CHWPStream& oBuffer, int nOff, int nSize) m_nSize = oBuffer.GetDistanceToLastPos(true); } -CReflect::CReflect(CXMLNode& oNode, int nVersion) +CReflect::CReflect(CXMLReader& oReader, int nVersion) : CPicEffect(EPicEffectType::REFLECT) { - m_fRadius = oNode.GetAttributeDouble(L"radius"); - m_fDirection = oNode.GetAttributeInt(L"direction"); - m_fDistance = oNode.GetAttributeInt(L"distance"); - m_nRotateStyle = (int)oNode.GetAttributeBool(L"rotationStyle"); - m_fOffsetDirection = oNode.GetAttributeInt(L"fadeDirection"); - - for (CXMLNode& oChild : oNode.GetChilds()) + START_READ_ATTRIBUTES(oReader) { - if (L"hp:skew" == oChild.GetName()) - { - m_fAngleX = oChild.GetAttributeDouble(L"x"); - m_fAngleY = oChild.GetAttributeDouble(L"y"); - } - else if (L"hp:scale" == oChild.GetName()) - { - m_fMagnifyX = oChild.GetAttributeDouble(L"x"); - m_fMagnifyY = oChild.GetAttributeDouble(L"y"); - } - else if (L"hp:alpha" == oChild.GetName()) - { - m_fStartTrans = oChild.GetAttributeDouble(L"start"); - m_fEndTrans = oChild.GetAttributeDouble(L"end"); - } - else if (L"hp:pos" == oChild.GetName()) - { - m_fStartPos = oChild.GetAttributeDouble(L"start"); - m_fEndPos = oChild.GetAttributeDouble(L"end"); - } + if ("radius" == sAttributeName) + m_fRadius = oReader.GetDouble(); + else if ("direction" == sAttributeName) + m_fDirection = oReader.GetDouble(); + else if ("distance" == sAttributeName) + m_fDistance = oReader.GetDouble(); + else if ("rotationStyle" == sAttributeName) + m_nRotateStyle = (int)oReader.GetBool(); + else if ("fadeDirection" == sAttributeName) + m_fOffsetDirection = oReader.GetDouble(); } + END_READ_ATTRIBUTES(oReader) + + #define READ_VALUES(value_1_name, value_1_variable, value_2_name, value_2_variable)\ + {\ + START_READ_ATTRIBUTES(oReader)\ + {\ + if (value_1_name == sAttributeName)\ + value_1_variable = oReader.GetDouble();\ + else if (value_2_name == sAttributeName)\ + value_2_variable = oReader.GetDouble();\ + }\ + END_READ_ATTRIBUTES(oReader)\ + } + + WHILE_READ_NEXT_NODE_WITH_NAME(oReader) + { + if ("hp:skew" == sNodeName) + READ_VALUES("x", m_fAngleX, "y", m_fAngleY) + else if ("hp:scale" == sNodeName) + READ_VALUES("x", m_fMagnifyX, "y", m_fMagnifyY) + else if ("hp:alpha" == sNodeName) + READ_VALUES("start", m_fStartTrans, "end", m_fEndTrans) + else if ("hp:pos" == sNodeName) + READ_VALUES("start", m_fStartPos, "end", m_fEndPos) + } + END_WHILE } CCtrlShapePic::CCtrlShapePic() @@ -215,69 +256,110 @@ CCtrlShapePic::CCtrlShapePic(const HWP_STRING& sCtrlID, int nSize, CHWPStream& o : CCtrlGeneralShape(sCtrlID, nSize, oBuffer, nOff, nVersion) {} -CCtrlShapePic::CCtrlShapePic(const HWP_STRING& sCtrlID, CXMLNode& oNode, int nVersion) - : CCtrlGeneralShape(sCtrlID, oNode, nVersion) +CCtrlShapePic::CCtrlShapePic(const HWP_STRING& sCtrlID, CXMLReader& oReader, int nVersion) + : CCtrlGeneralShape(sCtrlID, oReader, nVersion) { - for (CXMLNode& oChild : oNode.GetChilds()) + WHILE_READ_NEXT_NODE_WITH_NAME(oReader) { - if (L"hp:imgRect" == oChild.GetName()) + if ("hp:imgRect" == sNodeName) { - for (CXMLNode& oGrandChild : oChild.GetChilds()) + #define READ_POINT(index_point)\ + {\ + START_READ_ATTRIBUTES(oReader)\ + {\ + if ("x" == sAttributeName)\ + m_arBorderPoints[index_point].m_nX = oReader.GetInt();\ + else if ("y" == sAttributeName)\ + m_arBorderPoints[index_point].m_nY = oReader.GetInt();\ + }\ + END_READ_ATTRIBUTES(oReader)\ + } + + WHILE_READ_NEXT_NODE_WITH_DEPTH_AND_NAME(oReader, Child) { - for (unsigned int unIndex = 0; unIndex < 4; ++unIndex) + if ("hc:pt0" == sNodeChildName) + READ_POINT(0) + else if ("hc:pt1" == sNodeChildName) + READ_POINT(1) + else if ("hc:pt2" == sNodeChildName) + READ_POINT(2) + else if ("hc:pt3" == sNodeChildName) + READ_POINT(3) + } + END_WHILE + } + else if ("hp:imgClip" == sNodeName) + { + START_READ_ATTRIBUTES(oReader) + { + if ("left" == sAttributeName) + m_nCropLeft = oReader.GetInt(); + else if ("right" == sAttributeName) + m_nCropRight = oReader.GetInt(); + else if ("top" == sAttributeName) + m_nCropTop = oReader.GetInt(); + else if ("bottom" == sAttributeName) + m_nCropBottom = oReader.GetInt(); + } + END_READ_ATTRIBUTES(oReader) + } + else if ("hp:effects" == sNodeName) + { + if (oReader.GetReader()->IsEmptyNode()) + continue; + + WHILE_READ_NEXT_NODE_WITH_DEPTH_AND_NAME(oReader, Child) + { + if ("hp:shadow" == sNodeChildName) + m_arPicEffect.push_back(new CShadow(oReader, nVersion)); + else if ("hp:glow" == sNodeChildName) + m_arPicEffect.push_back(new CNeon(oReader, nVersion)); + else if ("hp:softEdge" == sNodeChildName) + m_arPicEffect.push_back(new CSoftEdge(oReader, nVersion)); + else if ("hp:reflection" == sNodeChildName) + m_arPicEffect.push_back(new CReflect(oReader, nVersion)); + } + END_WHILE + } + else if ("hc:img" == sNodeName) + { + START_READ_ATTRIBUTES(oReader) + { + if ("bright" == sAttributeName) + m_chBright = (HWP_BYTE)oReader.GetInt(); + else if ("contrast" == sAttributeName) + m_chContrast = (HWP_BYTE)oReader.GetInt(); + else if ("effect" == sAttributeName) { - if ((L"hc:pt" + std::to_wstring(unIndex)) == oGrandChild.GetName()) - { - m_arBorderPoints[unIndex].m_nX = oGrandChild.GetAttributeInt(L"x"); - m_arBorderPoints[unIndex].m_nY = oGrandChild.GetAttributeInt(L"y"); - break; - } + const std::string sType{oReader.GetTextA()}; + + if ("REAL_PIC" == sType) + m_chEffect = 0; + else if ("GRAY_SCALE" == sType) + m_chEffect = 1; + else if ("BLACK_WHITE" == sType) + m_chEffect = 2; } + else if ("binaryItemIDRef" == sAttributeName) + m_sBinDataID = oReader.GetText(); } + END_READ_ATTRIBUTES(oReader) } - else if (L"hp:imgClip" == oChild.GetName()) + else if ("hp:imgDim" == sNodeName) { - m_nCropLeft = oChild.GetAttributeInt(L"left"); - m_nCropRight = oChild.GetAttributeInt(L"right"); - m_nCropTop = oChild.GetAttributeInt(L"top"); - m_nCropBottom = oChild.GetAttributeInt(L"bottom"); - } - else if (L"hp:effects" == oChild.GetName()) - { - for (CXMLNode& oGrandChild : oChild.GetChilds()) + START_READ_ATTRIBUTES(oReader) { - if (L"hp:shadow" == oGrandChild.GetName()) - m_arPicEffect.push_back(new CShadow(oGrandChild, nVersion)); - else if (L"hp:glow" == oGrandChild.GetName()) - m_arPicEffect.push_back(new CNeon(oGrandChild, nVersion)); - else if (L"hp:softEdge" == oGrandChild.GetName()) - m_arPicEffect.push_back(new CSoftEdge(oGrandChild, nVersion)); - else if (L"hp:reflection" == oGrandChild.GetName()) - m_arPicEffect.push_back(new CReflect(oGrandChild, nVersion)); + if ("dimwidth" == sAttributeName) + m_nIniPicWidth = oReader.GetInt(); + else if ("dimheight" == sAttributeName) + m_nIniPicHeight = oReader.GetInt(); } + END_READ_ATTRIBUTES(oReader) } - else if (L"hc:img" == oChild.GetName()) - { - m_chBright = (HWP_BYTE)oChild.GetAttributeInt(L"bright"); - m_chContrast = (HWP_BYTE)oChild.GetAttributeInt(L"contrast"); - - HWP_STRING sType = oChild.GetAttribute(L"effect"); - - if (L"REAL_PIC" == sType) - m_chEffect = 0; - else if (L"GRAY_SCALE" == sType) - m_chEffect = 1; - else if (L"BLACK_WHITE" == sType) - m_chEffect = 2; - - m_sBinDataID = oChild.GetAttribute(L"binaryItemIDRef"); - } - else if (L"hp:imgDim" == oChild.GetName()) - { - m_nIniPicWidth = oChild.GetAttributeInt(L"dimwidth"); - m_nIniPicHeight = oChild.GetAttributeInt(L"dimheight"); - } + else + CCtrlGeneralShape::ParseChildren(oReader, nVersion); } + END_WHILE } CCtrlShapePic::~CCtrlShapePic() diff --git a/HwpFile/HwpDoc/Paragraph/CtrlShapePic.h b/HwpFile/HwpDoc/Paragraph/CtrlShapePic.h index deaaa9479b..21c9b25e4d 100644 --- a/HwpFile/HwpDoc/Paragraph/CtrlShapePic.h +++ b/HwpFile/HwpDoc/Paragraph/CtrlShapePic.h @@ -31,7 +31,7 @@ class CPicColor int m_nRGB; public: CPicColor(CHWPStream& oBuffer, int nOff, int nSize); - CPicColor(CXMLNode& oNode); + CPicColor(CXMLReader& oReader); }; class CPicEffect @@ -61,7 +61,7 @@ class CShadow : public CPicEffect CPicColor *m_pColor; public: CShadow(int nTypeNum, CHWPStream& oBuffer, int nOff, int nSize); - CShadow(CXMLNode& oNode, int nVersion); + CShadow(CXMLReader& oReader, int nVersion); ~CShadow(); }; @@ -72,7 +72,7 @@ class CNeon : public CPicEffect CPicColor *m_pColor; public: CNeon(int nTypeNum, CHWPStream& oBuffer, int nOff, int nSize); - CNeon(CXMLNode& oNode, int nVersion); + CNeon(CXMLReader& oReader, int nVersion); ~CNeon(); }; @@ -81,7 +81,7 @@ class CSoftEdge : public CPicEffect float m_fRadius; public: CSoftEdge(int nTypeNum, CHWPStream& oBuffer, int nOff, int nSize); - CSoftEdge(CXMLNode& oNode, int nVersion); + CSoftEdge(CXMLReader& oReader, int nVersion); }; class CReflect : public CPicEffect @@ -102,7 +102,7 @@ class CReflect : public CPicEffect float m_fOffsetDirection; public: CReflect(int nTypeNum, CHWPStream& oBuffer, int nOff, int nSize); - CReflect(CXMLNode& oNode, int nVersion); + CReflect(CXMLReader& oReader, int nVersion); }; class CCtrlShapePic : public CCtrlGeneralShape @@ -134,7 +134,7 @@ public: CCtrlShapePic(const HWP_STRING& sCtrlID); CCtrlShapePic(const CCtrlGeneralShape& oShape); CCtrlShapePic(const HWP_STRING& sCtrlID, int nSize, CHWPStream& oBuffer, int nOff, int nVersion); - CCtrlShapePic(const HWP_STRING& sCtrlID, CXMLNode& oNode, int nVersion); + CCtrlShapePic(const HWP_STRING& sCtrlID, CXMLReader& oReader, int nVersion); ~CCtrlShapePic(); EShapeType GetShapeType() const override; diff --git a/HwpFile/HwpDoc/Paragraph/CtrlShapePolygon.cpp b/HwpFile/HwpDoc/Paragraph/CtrlShapePolygon.cpp index a5fe6ce9e3..a2c71aaa2c 100644 --- a/HwpFile/HwpDoc/Paragraph/CtrlShapePolygon.cpp +++ b/HwpFile/HwpDoc/Paragraph/CtrlShapePolygon.cpp @@ -17,18 +17,32 @@ CCtrlShapePolygon::CCtrlShapePolygon(const HWP_STRING& sCtrlID, int nSize, CHWPS : CCtrlGeneralShape(sCtrlID, nSize, oBuffer, nOff, nVersion) {} -CCtrlShapePolygon::CCtrlShapePolygon(const HWP_STRING& sCtrlID, CXMLNode& oNode, int nVersion) - : CCtrlGeneralShape(sCtrlID, oNode, nVersion) +CCtrlShapePolygon::CCtrlShapePolygon(const HWP_STRING& sCtrlID, CXMLReader& oReader, int nVersion) + : CCtrlGeneralShape(sCtrlID, oReader, nVersion) { - std::vector arChilds{oNode.GetChilds(L"hc:pt")}; + TPoint oPoint{0, 0}; - m_arPoints.resize(arChilds.size()); - - for (unsigned int unIndex = 0; unIndex < arChilds.size(); ++unIndex) + WHILE_READ_NEXT_NODE(oReader) { - m_arPoints[unIndex].m_nX = arChilds[unIndex].GetAttributeInt(L"x"); - m_arPoints[unIndex].m_nY = arChilds[unIndex].GetAttributeInt(L"y"); + if ("hc:pt" == oReader.GetName()) + { + START_READ_ATTRIBUTES(oReader) + { + if ("x" == sAttributeName) + oPoint.m_nX = oReader.GetInt(); + else if ("y" == sAttributeName) + oPoint.m_nY = oReader.GetInt(); + } + END_READ_ATTRIBUTES(oReader) + + m_arPoints.push_back(oPoint); + + oPoint = {0, 0}; + } + else + CCtrlGeneralShape::ParseChildren(oReader, nVersion); } + END_WHILE m_nPoints = m_arPoints.size(); } diff --git a/HwpFile/HwpDoc/Paragraph/CtrlShapePolygon.h b/HwpFile/HwpDoc/Paragraph/CtrlShapePolygon.h index 0aa129fde4..ef41a5921d 100644 --- a/HwpFile/HwpDoc/Paragraph/CtrlShapePolygon.h +++ b/HwpFile/HwpDoc/Paragraph/CtrlShapePolygon.h @@ -15,7 +15,7 @@ public: CCtrlShapePolygon(const HWP_STRING& sCtrlID); CCtrlShapePolygon(const CCtrlGeneralShape& oShape); CCtrlShapePolygon(const HWP_STRING& sCtrlID, int nSize, CHWPStream& oBuffer, int nOff, int nVersion); - CCtrlShapePolygon(const HWP_STRING& sCtrlID, CXMLNode& oNode, int nVersion); + CCtrlShapePolygon(const HWP_STRING& sCtrlID, CXMLReader& oReader, int nVersion); EShapeType GetShapeType() const override; diff --git a/HwpFile/HwpDoc/Paragraph/CtrlShapeRect.cpp b/HwpFile/HwpDoc/Paragraph/CtrlShapeRect.cpp index f01f39ecd2..4ee90cd900 100644 --- a/HwpFile/HwpDoc/Paragraph/CtrlShapeRect.cpp +++ b/HwpFile/HwpDoc/Paragraph/CtrlShapeRect.cpp @@ -17,20 +17,37 @@ CCtrlShapeRect::CCtrlShapeRect(const HWP_STRING& sCtrlID, int nSize, CHWPStream& : CCtrlGeneralShape(sCtrlID, nSize, oBuffer, nOff, nVersion) {} -CCtrlShapeRect::CCtrlShapeRect(const HWP_STRING& sCtrlID, CXMLNode& oNode, int nVersion) - : CCtrlGeneralShape(sCtrlID, oNode, nVersion) +CCtrlShapeRect::CCtrlShapeRect(const HWP_STRING& sCtrlID, CXMLReader& oReader, int nVersion) + : CCtrlGeneralShape(sCtrlID, oReader, nVersion) { - m_chCurv = (HWP_BYTE)oNode.GetAttributeInt(L"ratio"); + m_chCurv = (HWP_BYTE)oReader.GetAttributeInt("ratio"); - for (unsigned int unIndex = 0; unIndex < 4; ++unIndex) - { - if ((L"hc:pt" + std::to_wstring(unIndex)) == oNode.GetName()) - { - m_arPoints[unIndex].m_nX = oNode.GetAttributeInt(L"x"); - m_arPoints[unIndex].m_nY = oNode.GetAttributeInt(L"y"); - break; - } + #define READ_POINT(point_index)\ + {\ + START_READ_ATTRIBUTES(oReader)\ + {\ + if ("x" == sAttributeName)\ + m_arPoints[point_index].m_nX = oReader.GetInt();\ + else if ("y" == sAttributeName)\ + m_arPoints[point_index].m_nY = oReader.GetInt();\ + }\ + END_READ_ATTRIBUTES(oReader)\ } + + WHILE_READ_NEXT_NODE_WITH_NAME(oReader) + { + if ("hc:pt0" == sNodeName) + READ_POINT(0) + else if ("hc:pt1" == sNodeName) + READ_POINT(1) + else if ("hc:pt2" == sNodeName) + READ_POINT(2) + else if ("hc:pt3" == sNodeName) + READ_POINT(3) + else + CCtrlGeneralShape::ParseChildren(oReader, nVersion); + } + END_WHILE } EShapeType CCtrlShapeRect::GetShapeType() const diff --git a/HwpFile/HwpDoc/Paragraph/CtrlShapeRect.h b/HwpFile/HwpDoc/Paragraph/CtrlShapeRect.h index ad12478cac..bab8e5102e 100644 --- a/HwpFile/HwpDoc/Paragraph/CtrlShapeRect.h +++ b/HwpFile/HwpDoc/Paragraph/CtrlShapeRect.h @@ -15,7 +15,7 @@ public: CCtrlShapeRect(const HWP_STRING& sCtrlID); CCtrlShapeRect(const CCtrlGeneralShape& oShape); CCtrlShapeRect(const HWP_STRING& sCtrlID, int nSize, CHWPStream& oBuffer, int nOff, int nVersion); - CCtrlShapeRect(const HWP_STRING& sCtrlID, CXMLNode& oNode, int nVersion); + CCtrlShapeRect(const HWP_STRING& sCtrlID, CXMLReader& oReader, int nVersion); EShapeType GetShapeType() const override; diff --git a/HwpFile/HwpDoc/Paragraph/CtrlShapeTextArt.cpp b/HwpFile/HwpDoc/Paragraph/CtrlShapeTextArt.cpp index 7436ab8657..796b0e6886 100644 --- a/HwpFile/HwpDoc/Paragraph/CtrlShapeTextArt.cpp +++ b/HwpFile/HwpDoc/Paragraph/CtrlShapeTextArt.cpp @@ -17,58 +17,81 @@ CCtrlShapeTextArt::CCtrlShapeTextArt(const HWP_STRING& sCtrlID, int nSize, CHWPS : CCtrlGeneralShape(sCtrlID, nSize, oBuffer, nOff, nVersion) {} -CCtrlShapeTextArt::CCtrlShapeTextArt(const HWP_STRING& sCtrlID, CXMLNode& oNode, int nVersion) - : CCtrlGeneralShape(sCtrlID, oNode, nVersion) +CCtrlShapeTextArt::CCtrlShapeTextArt(const HWP_STRING& sCtrlID, CXMLReader& oReader, int nVersion) + : CCtrlGeneralShape(sCtrlID, oReader, nVersion) { - m_sText = oNode.GetAttribute(L"text"); + m_sText = oReader.GetAttribute("text"); - for (CXMLNode& oChild : oNode.GetChilds()) - { - if (L"hp:pt0" == oChild.GetName()) - { - m_oPt0.m_nX = oNode.GetAttributeInt(L"x"); - m_oPt0.m_nY = oNode.GetAttributeInt(L"y"); - } - else if (L"hp:pt1" == oChild.GetName()) - { - m_oPt1.m_nX = oNode.GetAttributeInt(L"x"); - m_oPt1.m_nY = oNode.GetAttributeInt(L"y"); - } - else if (L"hp:pt2" == oChild.GetName()) - { - m_oPt2.m_nX = oNode.GetAttributeInt(L"x"); - m_oPt2.m_nY = oNode.GetAttributeInt(L"y"); - } - else if (L"hp:pt3" == oChild.GetName()) - { - m_oPt3.m_nX = oNode.GetAttributeInt(L"x"); - m_oPt3.m_nY = oNode.GetAttributeInt(L"y"); - } - else if (L"hp:textartPr" == oChild.GetName()) - { - m_sFontName = oChild.GetAttribute(L"fontName"); - m_sFontStyle = oChild.GetAttribute(L"fontStyle"); - m_sFontType = oChild.GetAttribute(L"fontType"); - m_sTextShape = oChild.GetAttribute(L"textShape"); - m_sFontStyle = oChild.GetAttribute(L"fontStyle"); - m_shLineSpacing = oChild.GetAttributeInt(L"lineSpacing"); - m_shSpacing = oChild.GetAttributeInt(L"spacing"); - m_sAlign = oChild.GetAttribute(L"align"); - - //TODO:: реализовать shadows - } - else if (L"hp:outline" == oChild.GetName()) - { - std::vector arGrandChilds{oChild.GetChilds(L"hp:pt")}; - m_arOutline.resize(arGrandChilds.size()); - - for (unsigned int unIndex = 0; unIndex < arGrandChilds.size(); ++unIndex) - { - m_arOutline[unIndex].m_nX = arGrandChilds[unIndex].GetAttributeInt(L"x"); - m_arOutline[unIndex].m_nY = arGrandChilds[unIndex].GetAttributeInt(L"y"); - } - } + #define READ_POINT(variable_point)\ + {\ + START_READ_ATTRIBUTES(oReader)\ + {\ + if ("x" == sAttributeName)\ + variable_point.m_nX = oReader.GetInt();\ + else if ("y" == sAttributeName)\ + variable_point.m_nY = oReader.GetInt();\ + }\ + END_READ_ATTRIBUTES(oReader)\ } + + WHILE_READ_NEXT_NODE_WITH_NAME(oReader) + { + if ("hp:pt0" == sNodeName) + READ_POINT(m_oPt0) + else if ("hp:pt1" == sNodeName) + READ_POINT(m_oPt1) + else if ("hp:pt2" == sNodeName) + READ_POINT(m_oPt2) + else if ("hp:pt3" == sNodeName) + READ_POINT(m_oPt3) + else if ("hp:textartPr" == sNodeName) + { + START_READ_ATTRIBUTES(oReader) + { + if ("fontName" == sAttributeName) + m_sFontName = oReader.GetText(); + else if ("fontStyle" == sAttributeName) + m_sFontStyle = oReader.GetText(); + else if ("fontType" == sAttributeName) + m_sFontType = oReader.GetText(); + else if ("textShape" == sAttributeName) + m_sTextShape = oReader.GetText(); + else if ("align" == sAttributeName) + m_sAlign = oReader.GetText(); + else if ("lineSpacing" == sAttributeName) + m_shLineSpacing = oReader.GetInt(); + else if ("spacing" == sAttributeName) + m_shSpacing = oReader.GetInt(); + + //TODO:: реализовать shadows + } + END_READ_ATTRIBUTES(oReader) + } + else if ("hp:outline" == sNodeName) + { + TPoint oPoint{0, 0}; + + WHILE_READ_NEXT_NODE_WITH_ONE_NAME(oReader, "hp:pt") + { + START_READ_ATTRIBUTES(oReader) + { + if ("x" == sAttributeName) + oPoint.m_nX = oReader.GetInt(); + else if ("y" == sAttributeName) + oPoint.m_nY = oReader.GetInt(); + } + END_READ_ATTRIBUTES(oReader) + + m_arOutline.push_back(oPoint); + + oPoint = {0, 0}; + } + END_WHILE + } + else + CCtrlGeneralShape::ParseChildren(oReader, nVersion); + } + END_WHILE } EShapeType CCtrlShapeTextArt::GetShapeType() const diff --git a/HwpFile/HwpDoc/Paragraph/CtrlShapeTextArt.h b/HwpFile/HwpDoc/Paragraph/CtrlShapeTextArt.h index 37ba39b597..e653789804 100644 --- a/HwpFile/HwpDoc/Paragraph/CtrlShapeTextArt.h +++ b/HwpFile/HwpDoc/Paragraph/CtrlShapeTextArt.h @@ -28,7 +28,7 @@ public: CCtrlShapeTextArt(const HWP_STRING& sCtrlID); CCtrlShapeTextArt(const CCtrlGeneralShape& oShape); CCtrlShapeTextArt(const HWP_STRING& sCtrlID, int nSize, CHWPStream& oBuffer, int nOff, int nVersion); - CCtrlShapeTextArt(const HWP_STRING& sCtrlID, CXMLNode& oNode, int nVersion); + CCtrlShapeTextArt(const HWP_STRING& sCtrlID, CXMLReader& oReader, int nVersion); EShapeType GetShapeType() const override; diff --git a/HwpFile/HwpDoc/Paragraph/CtrlShapeVideo.cpp b/HwpFile/HwpDoc/Paragraph/CtrlShapeVideo.cpp index afb2f8736a..98c499bfa0 100644 --- a/HwpFile/HwpDoc/Paragraph/CtrlShapeVideo.cpp +++ b/HwpFile/HwpDoc/Paragraph/CtrlShapeVideo.cpp @@ -14,21 +14,32 @@ CCtrlShapeVideo::CCtrlShapeVideo(const HWP_STRING& sCtrlID, int nSize, CHWPStrea : CCtrlGeneralShape(sCtrlID, nSize, oBuffer, nOff, nVersion) {} -CCtrlShapeVideo::CCtrlShapeVideo(const HWP_STRING& sCtrlID, CXMLNode& oNode, int nVersion) - : CCtrlGeneralShape(sCtrlID, oNode, nVersion) +CCtrlShapeVideo::CCtrlShapeVideo(const HWP_STRING& sCtrlID, CXMLReader& oReader, int nVersion) + : CCtrlGeneralShape(sCtrlID, oReader, nVersion) { - HWP_STRING sType = oNode.GetAttribute(L"videotype"); + START_READ_ATTRIBUTES(oReader) + { + if ("type" == sAttributeName) + { + const std::string sType{oReader.GetTextA()}; - if (L"Local" == sType) - m_nVideoType = 0; - else if (L"Web" == sType) - m_nVideoType = 1; + if ("Local" == sType) + m_nVideoType = 0; + else if ("Web" == sType) + m_nVideoType = 1; + } + else if ("fileIDRef" == sAttributeName) + m_shVideoBinID = oReader.GetInt(); + else if ("imageIDRef" == sAttributeName) + m_sThumnailBinID = oReader.GetInt(); + else if ("tag" == sAttributeName) + m_sWebURL = oReader.GetText(); + } + END_READ_ATTRIBUTES(oReader) - m_shVideoBinID = oNode.GetAttributeInt(L"fileIDRef"); - m_sThumnailBinID = oNode.GetAttribute(L"imageIDRef"); - - if (1 == m_nVideoType) - m_sWebURL = oNode.GetAttribute(L"tag"); + WHILE_READ_NEXT_NODE(oReader) + CCtrlGeneralShape::ParseChildren(oReader, nVersion); + END_WHILE } EShapeType CCtrlShapeVideo::GetShapeType() const diff --git a/HwpFile/HwpDoc/Paragraph/CtrlShapeVideo.h b/HwpFile/HwpDoc/Paragraph/CtrlShapeVideo.h index d3716a2bfe..3e6469b823 100644 --- a/HwpFile/HwpDoc/Paragraph/CtrlShapeVideo.h +++ b/HwpFile/HwpDoc/Paragraph/CtrlShapeVideo.h @@ -15,7 +15,7 @@ public: CCtrlShapeVideo(const HWP_STRING& sCtrlID); CCtrlShapeVideo(const CCtrlGeneralShape& oShape); CCtrlShapeVideo(const HWP_STRING& sCtrlID, int nSize, CHWPStream& oBuffer, int nOff, int nVersion); - CCtrlShapeVideo(const HWP_STRING& sCtrlID, CXMLNode& oNode, int nVersion); + CCtrlShapeVideo(const HWP_STRING& sCtrlID, CXMLReader& oReader, int nVersion); EShapeType GetShapeType() const override; diff --git a/HwpFile/HwpDoc/Paragraph/CtrlTable.cpp b/HwpFile/HwpDoc/Paragraph/CtrlTable.cpp index 786b580bea..5ef4f2e5c9 100644 --- a/HwpFile/HwpDoc/Paragraph/CtrlTable.cpp +++ b/HwpFile/HwpDoc/Paragraph/CtrlTable.cpp @@ -10,44 +10,74 @@ CCtrlTable::CCtrlTable(const HWP_STRING& sCtrlID, int nSize, CHWPStream& oBuffer : CCtrlCommon(sCtrlID, nSize, oBuffer, nOff, nVersion) {} -CCtrlTable::CCtrlTable(const HWP_STRING& sCtrlID, CXMLNode& oNode, int nVersion) - : CCtrlCommon(sCtrlID, oNode, nVersion) +CCtrlTable::CCtrlTable(const HWP_STRING& sCtrlID, CXMLReader& oReader, int nVersion) + : CCtrlCommon(sCtrlID, oReader, nVersion) { - m_shNRows = oNode.GetAttributeInt(L"rowCnt"); - m_shNCols = oNode.GetAttributeInt(L"colCnt"); - m_shCellSpacing = oNode.GetAttributeInt(L"cellSpacing"); - m_shBorderFillID = oNode.GetAttributeInt(L"borderFillIDRef"); - - for (CXMLNode& oChild : oNode.GetChilds()) + START_READ_ATTRIBUTES(oReader) { - if (L"hp:inMargin" == oChild.GetName()) + if ("rowCnt" == sAttributeName) + m_shNRows = oReader.GetInt(); + else if ("colCnt" == sAttributeName) + m_shNCols = oReader.GetInt(); + else if ("cellSpacing" == sAttributeName) + m_shCellSpacing = oReader.GetInt(); + else if ("borderFillIDRef" == sAttributeName) + m_shBorderFillID = oReader.GetInt(); + } + END_READ_ATTRIBUTES(oReader) + + WHILE_READ_NEXT_NODE_WITH_NAME(oReader) + { + if ("hp:inMargin" == sNodeName) { - m_shInLSpace = oChild.GetAttributeInt(L"left"); - m_shInRSpace = oChild.GetAttributeInt(L"right"); - m_shInTSpace = oChild.GetAttributeInt(L"top"); - m_shInBSpace = oChild.GetAttributeInt(L"bottom"); + START_READ_ATTRIBUTES(oReader) + { + if ("left" == sAttributeName) + m_shInLSpace = oReader.GetInt(); + else if ("right" == sAttributeName) + m_shInRSpace = oReader.GetInt(); + else if ("top" == sAttributeName) + m_shInTSpace = oReader.GetInt(); + else if ("bottom" == sAttributeName) + m_shInBSpace = oReader.GetInt(); + } + END_READ_ATTRIBUTES(oReader) } - else if (L"hp:cellzoneList" == oChild.GetName()) + else if ("hp:cellzoneList" == sNodeName) { - for (CXMLNode& oGrandChild : oChild.GetChilds(L"hp:cellzone")) + WHILE_READ_NEXT_NODE_WITH_DEPTH_ONE_NAME(oReader, Child, "hp:cellzone") { TCellZone* pCellZone = new TCellZone(); - pCellZone->m_shStartRowAddr = oGrandChild.GetAttributeInt(L"startRowAddr"); - pCellZone->m_shStartColAddr = oGrandChild.GetAttributeInt(L"startColAddr"); - pCellZone->m_shEndRowAddr = oGrandChild.GetAttributeInt(L"endRowAddr"); - pCellZone->m_shEndColAddr = oGrandChild.GetAttributeInt(L"endColAddr"); - pCellZone->m_shBorderFillIDRef = oGrandChild.GetAttributeInt(L"borderFillIDRef"); + START_READ_ATTRIBUTES(oReader) + { + if ("startRowAddr" == sAttributeName) + pCellZone->m_shStartRowAddr = oReader.GetInt(); + else if ("startColAddr" == sAttributeName) + pCellZone->m_shStartColAddr = oReader.GetInt(); + else if ("endRowAddr" == sAttributeName) + pCellZone->m_shEndRowAddr = oReader.GetInt(); + else if ("endColAddr" == sAttributeName) + pCellZone->m_shEndColAddr = oReader.GetInt(); + else if ("borderFillIDRef" == sAttributeName) + pCellZone->m_shBorderFillIDRef = oReader.GetInt(); + } + END_READ_ATTRIBUTES(oReader) m_arCellzoneList.push_back(pCellZone); } + END_WHILE } - else if(L"hp:tr" == oChild.GetName()) + else if ("hp:tr" == sNodeName) { - for (CXMLNode& oGrandChild : oChild.GetChilds(L"hp:tc")) - m_arCells.push_back(new CTblCell(oGrandChild, nVersion)); + WHILE_READ_NEXT_NODE_WITH_DEPTH_ONE_NAME(oReader, Child, "hp:tc") + m_arCells.push_back(new CTblCell(oReader, nVersion)); + END_WHILE } + else + CCtrlCommon::ParseChildren(oReader, nVersion); } + END_WHILE } CCtrlTable::~CCtrlTable() diff --git a/HwpFile/HwpDoc/Paragraph/CtrlTable.h b/HwpFile/HwpDoc/Paragraph/CtrlTable.h index 8b4613299c..4c1dff33c9 100644 --- a/HwpFile/HwpDoc/Paragraph/CtrlTable.h +++ b/HwpFile/HwpDoc/Paragraph/CtrlTable.h @@ -32,7 +32,7 @@ class CCtrlTable : public CCtrlCommon public: CCtrlTable(const HWP_STRING& sCtrlID); CCtrlTable(const HWP_STRING& sCtrlID, int nSize, CHWPStream& oBuffer, int nOff, int nVersion); - CCtrlTable(const HWP_STRING& sCtrlID, CXMLNode& oNode, int nVersion); + CCtrlTable(const HWP_STRING& sCtrlID, CXMLReader& oReader, int nVersion); ~CCtrlTable(); ECtrlObjectType GetCtrlType() const override; diff --git a/HwpFile/HwpDoc/Paragraph/HWPPargraph.cpp b/HwpFile/HwpDoc/Paragraph/HWPPargraph.cpp index b399fb85f4..f6966a93f5 100644 --- a/HwpFile/HwpDoc/Paragraph/HWPPargraph.cpp +++ b/HwpFile/HwpDoc/Paragraph/HWPPargraph.cpp @@ -19,45 +19,63 @@ #include "CtrlShapeVideo.h" #include "ParaText.h" +#include "../../../DesktopEditor/common/File.h" + namespace HWP { CHWPPargraph::CHWPPargraph() : m_pLineSegs(nullptr) {} -CHWPPargraph::CHWPPargraph(CXMLNode& oNode, int nVersion) +CHWPPargraph::CHWPPargraph(CXMLReader& oReader, int nVersion) : m_chBreakType(0), m_pLineSegs(nullptr) { - m_shParaShapeID = oNode.GetAttributeInt(L"paraPrIDRef"); - m_shParaStyleID = oNode.GetAttributeInt(L"styleIDRef"); - - if (oNode.GetAttributeBool(L"pageBreak")) - m_chBreakType |= 0b00000100; - else - m_chBreakType &= 0b11111011; - - if (oNode.GetAttributeBool(L"columnBreak")) - m_chBreakType |= 0b00001000; - else - m_chBreakType &= 0b11110111; + START_READ_ATTRIBUTES(oReader) + { + if ("paraPrIDRef" == sAttributeName) + m_shParaShapeID = oReader.GetInt(); + else if ("styleIDRef" == sAttributeName) + m_shParaStyleID = oReader.GetInt(); + else if ("pageBreak" == sAttributeName) + { + if (oReader.GetBool()) + m_chBreakType |= 0b00000100; + else + m_chBreakType &= 0b11111011; + } + else if ("columnBreak" == sAttributeName) + { + if (oReader.GetBool()) + m_chBreakType |= 0b00001000; + else + m_chBreakType &= 0b11110111; + } + } + END_READ_ATTRIBUTES(oReader) int nCharShapeID = 0; - for (CXMLNode& oChild : oNode.GetChilds()) + WHILE_READ_NEXT_NODE_WITH_NAME(oReader) { - if (L"hp:run" == oChild.GetName()) + if ("hp:run" == sNodeName) { - nCharShapeID = oChild.GetAttributeInt(L"charPrIDRef"); + nCharShapeID = oReader.GetAttributeInt("charPrIDRef"); - for (CXMLNode& oGrandChild : oChild.GetChilds()) - ParseHWPParagraph(oGrandChild, nCharShapeID, nVersion); + WHILE_READ_NEXT_NODE_WITH_DEPTH(oReader, Child) + ParseHWPParagraph(oReader, nCharShapeID, nVersion); + END_WHILE } - else if (L"hp:linesegarray" == oChild.GetName()) + else if ("hp:linesegarray" == sNodeName) { - CXMLNode oGrandChild{oChild.GetChild(L"hp:lineseg")}; - m_pLineSegs = new CLineSeg(oGrandChild, nVersion); + WHILE_READ_NEXT_NODE_WITH_DEPTH_ONE_NAME(oReader, Child, "hp:lineseg") + { + m_pLineSegs = new CLineSeg(oReader, nVersion); + break; + } + END_WHILE } } + END_WHILE if (m_arP.empty() || ECtrlObjectType::Character != m_arP.back()->GetCtrlType()) m_arP.push_back(new CCtrlCharacter(L" _", ECtrlCharType::PARAGRAPH_BREAK, nCharShapeID)); @@ -69,79 +87,105 @@ CHWPPargraph::~CHWPPargraph() delete m_pLineSegs; } -bool CHWPPargraph::ParseHWPParagraph(CXMLNode& oNode, int nCharShapeID, int nVersion) +bool CHWPPargraph::ParseHWPParagraph(CXMLReader& oReader, int nCharShapeID, int nVersion) { const size_t unCurrentParaCount = m_arP.size(); - if (L"hp:secPr" == oNode.GetName()) - m_arP.push_back(new CCtrlSectionDef(L"dces", oNode, nVersion)); - else if (L"hp:ctrl" == oNode.GetName()) - { - for(CXMLNode& oChild : oNode.GetChilds()) - AddCtrl(CCtrl::GetCtrl(oChild, nVersion)); - } - else if (L"hp:t" == oNode.GetName()) - { - m_arP.push_back(new CParaText(L"____", oNode.GetText(), 0, nCharShapeID)); + const std::string sNodeName{oReader.GetName()}; - for(CXMLNode& oChild : oNode.GetChilds()) + if ("hp:secPr" == sNodeName) + m_arP.push_back(new CCtrlSectionDef(L"dces", oReader, nVersion)); + else if ("hp:ctrl" == sNodeName) + { + WHILE_READ_NEXT_NODE(oReader) + AddCtrl(CCtrl::GetCtrl(oReader, nVersion)); + END_WHILE + } + else if ("hp:t" == sNodeName) + { + if (oReader.IsEmptyNode()) + return false; + + const int nDepth = oReader.GetDepth(); + XmlUtils::XmlNodeType eNodeType = XmlUtils::XmlNodeType_EndElement; + while (oReader.Read(eNodeType) && oReader.GetDepth() >= nDepth && XmlUtils::XmlNodeType_EndElement != eNodeType) { - if (L"hp:lineBreak" == oChild.GetName()) - m_arP.push_back(new CCtrlCharacter(L" _", ECtrlCharType::LINE_BREAK)); - else if (L"hp:hyphen" == oChild.GetName()) - m_arP.push_back(new CCtrlCharacter(L" _", ECtrlCharType::HARD_HYPHEN)); - else if (L"hp:nbSpace" == oChild.GetName()|| - L"hp:fwSpace" == oChild.GetName()) - m_arP.push_back(new CCtrlCharacter(L" _", ECtrlCharType::HARD_SPACE)); - else if (L"hp:tab" == oChild.GetName()) - m_arP.push_back(new CParaText(L"____", L"\t", 0)); + if (eNodeType == XmlUtils::XmlNodeType_Text || + eNodeType == XmlUtils::XmlNodeType_Whitespace || + eNodeType == XmlUtils::XmlNodeType_SIGNIFICANT_WHITESPACE || + eNodeType == XmlUtils::XmlNodeType_CDATA) + { + const char* pValue = oReader.GetTextChar(); + std::wstring wsValue; + + if('\0' != pValue[0]) + { + NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)pValue, (LONG)strlen(pValue), wsValue); + m_arP.push_back(new CParaText(L"____", wsValue, 0, nCharShapeID)); + } + } + else if (eNodeType == XmlUtils::XmlNodeType_Element) + { + const std::string sChildNodeName{oReader.GetName()}; + + if ("hp:lineBreak" == sChildNodeName) + m_arP.push_back(new CCtrlCharacter(L" _", ECtrlCharType::LINE_BREAK)); + else if ("hp:hyphen" == sChildNodeName) + m_arP.push_back(new CCtrlCharacter(L" _", ECtrlCharType::HARD_HYPHEN)); + else if ("hp:nbSpace" == sChildNodeName || + "hp:fwSpace" == sChildNodeName) + m_arP.push_back(new CCtrlCharacter(L" _", ECtrlCharType::HARD_SPACE)); + else if ("hp:tab" == sChildNodeName) + m_arP.push_back(new CCtrlCharacter(L" _", ECtrlCharType::TABULATION)); + } } } - else if (L"hp:tbl" == oNode.GetName()) - m_arP.push_back(new CCtrlTable(L" lbt", oNode, nVersion)); - else if (L"hp:pic" == oNode.GetName()) - m_arP.push_back(new CCtrlShapePic(L"cip$", oNode, nVersion)); - else if (L"hp:container" == oNode.GetName()) - m_arP.push_back(new CCtrlContainer(L"noc$", oNode, nVersion)); - else if (L"hp:ole" == oNode.GetName()) - m_arP.push_back(new CCtrlShapeOle(L"elo$", oNode, nVersion)); - else if (L"hp:equation" == oNode.GetName()) - m_arP.push_back(new CCtrlEqEdit(L"deqe", oNode, nVersion)); - else if (L"hp:line" == oNode.GetName()) - m_arP.push_back(new CCtrlShapeLine(L"nil$", oNode, nVersion)); - else if (L"hp:rect" == oNode.GetName()) - m_arP.push_back(new CCtrlShapeRect(L"cer$", oNode, nVersion)); - else if (L"hp:ellipse" == oNode.GetName()) - m_arP.push_back(new CCtrlShapeEllipse(L"lle$", oNode, nVersion)); - else if (L"hp:arc" == oNode.GetName()) - m_arP.push_back(new CCtrlShapeArc(L"cra$", oNode, nVersion)); - else if (L"hp:polygon" == oNode.GetName()) - m_arP.push_back(new CCtrlShapePolygon(L"lop$", oNode, nVersion)); - else if (L"hp:curve" == oNode.GetName()) - m_arP.push_back(new CCtrlShapeCurve(L"ruc$", oNode, nVersion)); - else if (L"hp:connectLine" == oNode.GetName()) - m_arP.push_back(new CCtrlShapeConnectLine(L"loc$", oNode, nVersion)); - else if (L"hp:textart" == oNode.GetName()) - m_arP.push_back(new CCtrlShapeTextArt(L"tat$", oNode, nVersion)); - else if (L"hp:video" == oNode.GetName()) - m_arP.push_back(new CCtrlShapeVideo(L"div$", oNode, nVersion)); + else if ("hp:tbl" == sNodeName) + m_arP.push_back(new CCtrlTable(L" lbt", oReader, nVersion)); + else if ("hp:pic" == sNodeName) + m_arP.push_back(new CCtrlShapePic(L"cip$", oReader, nVersion)); + else if ("hp:container" == sNodeName) + m_arP.push_back(new CCtrlContainer(L"noc$", oReader, nVersion)); + else if ("hp:ole" == sNodeName) + m_arP.push_back(new CCtrlShapeOle(L"elo$", oReader, nVersion)); + else if ("hp:equation" == sNodeName) + m_arP.push_back(new CCtrlEqEdit(L"deqe", oReader, nVersion)); + else if ("hp:line" == sNodeName) + m_arP.push_back(new CCtrlShapeLine(L"nil$", oReader, nVersion)); + else if ("hp:rect" == sNodeName) + m_arP.push_back(new CCtrlShapeRect(L"cer$", oReader, nVersion)); + else if ("hp:ellipse" == sNodeName) + m_arP.push_back(new CCtrlShapeEllipse(L"lle$", oReader, nVersion)); + else if ("hp:arc" == sNodeName) + m_arP.push_back(new CCtrlShapeArc(L"cra$", oReader, nVersion)); + else if ("hp:polygon" == sNodeName) + m_arP.push_back(new CCtrlShapePolygon(L"lop$", oReader, nVersion)); + else if ("hp:curve" == sNodeName) + m_arP.push_back(new CCtrlShapeCurve(L"ruc$", oReader, nVersion)); + else if ("hp:connectLine" == sNodeName) + m_arP.push_back(new CCtrlShapeConnectLine(L"loc$", oReader, nVersion)); + else if ("hp:textart" == sNodeName) + m_arP.push_back(new CCtrlShapeTextArt(L"tat$", oReader, nVersion)); + else if ("hp:video" == sNodeName) + m_arP.push_back(new CCtrlShapeVideo(L"div$", oReader, nVersion)); if (unCurrentParaCount != m_arP.size()) return true; - if (L"hp:switch" == oNode.GetName()) + if ("hp:switch" == sNodeName) { - for (CXMLNode& oCaseChild : oNode.GetChilds(L"hp:case")) + WHILE_READ_NEXT_NODE(oReader) { - for (CXMLNode& oChild : oCaseChild.GetChilds()) - if (ParseHWPParagraph(oChild, nCharShapeID, nVersion)) - return true; - } + if ("hp:case" != oReader.GetName() && + "hp:default" != oReader.GetName()) + continue; - CXMLNode oDefaultChild{oNode.GetChild(L"hp:default")}; - for (CXMLNode& oChild : oDefaultChild.GetChilds()) - if (ParseHWPParagraph(oChild, nCharShapeID, nVersion)) - return true; + WHILE_READ_NEXT_NODE(oReader) + if (ParseHWPParagraph(oReader, nCharShapeID, nVersion)) + return true; + END_WHILE + } + END_WHILE } return false; diff --git a/HwpFile/HwpDoc/Paragraph/HWPPargraph.h b/HwpFile/HwpDoc/Paragraph/HWPPargraph.h index 7a18af0306..ec481f3ff2 100644 --- a/HwpFile/HwpDoc/Paragraph/HWPPargraph.h +++ b/HwpFile/HwpDoc/Paragraph/HWPPargraph.h @@ -4,7 +4,7 @@ #include "LineSeg.h" #include "RangeTag.h" #include "Ctrl.h" -#include "../Common/XMLNode.h" +#include "../Common/XMLReader.h" namespace HWP { @@ -26,10 +26,10 @@ class CHWPPargraph : public IRef VECTOR m_arP; //HWPTAG_PARA_TEXT - bool ParseHWPParagraph(CXMLNode& oNode, int nCharShapeID, int nVersion); + bool ParseHWPParagraph(CXMLReader& oReader, int nCharShapeID, int nVersion); public: CHWPPargraph(); - CHWPPargraph(CXMLNode& oNode, int nVersion); + CHWPPargraph(CXMLReader& oReader, int nVersion); virtual ~CHWPPargraph(); virtual EParagraphType GetType() const; diff --git a/HwpFile/HwpDoc/Paragraph/LineSeg.cpp b/HwpFile/HwpDoc/Paragraph/LineSeg.cpp index b781577bb9..30b79f73ad 100644 --- a/HwpFile/HwpDoc/Paragraph/LineSeg.cpp +++ b/HwpFile/HwpDoc/Paragraph/LineSeg.cpp @@ -20,11 +20,18 @@ CLineSeg::CLineSeg(int nTagNum, int nLevel, int nSize, CHWPStream& oBuffer, int oBuffer.Skip(nSize - oBuffer.GetDistanceToLastPos(true)); } -CLineSeg::CLineSeg(CXMLNode& oNode, int nVersion) +CLineSeg::CLineSeg(CXMLReader& oReader, int nVersion) { //TODO:: реализовать - m_nLineSpacing = oNode.GetAttributeInt(L"spacing"); - m_nTextHeight = oNode.GetAttributeInt(L"textheight"); + + START_READ_ATTRIBUTES(oReader) + { + if ("spacing" == sAttributeName) + m_nLineSpacing = oReader.GetInt(); + else if ("textheight" == sAttributeName) + m_nTextHeight = oReader.GetInt(); + } + END_READ_ATTRIBUTES(oReader) } int CLineSeg::GetLineSpacing() const diff --git a/HwpFile/HwpDoc/Paragraph/LineSeg.h b/HwpFile/HwpDoc/Paragraph/LineSeg.h index 56419e161b..ea4ba534be 100644 --- a/HwpFile/HwpDoc/Paragraph/LineSeg.h +++ b/HwpFile/HwpDoc/Paragraph/LineSeg.h @@ -2,7 +2,7 @@ #define LINESEG_H #include "../HWPStream.h" -#include "../Common/XMLNode.h" +#include "../Common/XMLReader.h" namespace HWP { @@ -20,7 +20,7 @@ class CLineSeg bool m_bIsHeadingApplied; public: CLineSeg(int nTagNum, int nLevel, int nSize, CHWPStream& oBuffer, int nOff, int nVersion); - CLineSeg(CXMLNode& oNode, int nVersion); + CLineSeg(CXMLReader& oReader, int nVersion); int GetLineSpacing() const; }; diff --git a/HwpFile/HwpDoc/Paragraph/TblCell.cpp b/HwpFile/HwpDoc/Paragraph/TblCell.cpp index e5b6a61c2f..63669f6eaf 100644 --- a/HwpFile/HwpDoc/Paragraph/TblCell.cpp +++ b/HwpFile/HwpDoc/Paragraph/TblCell.cpp @@ -25,41 +25,67 @@ CTblCell::CTblCell(int nSize, CHWPStream& oBuffer, int nOff, int nVersion) oBuffer.Skip(nSize - oBuffer.GetDistanceToLastPos(true)); } -CTblCell::CTblCell(CXMLNode& oNode, int nVersion) +CTblCell::CTblCell(CXMLReader& oReader, int nVersion) { - m_shBorderFill = oNode.GetAttributeInt(L"borderFillIDRef"); + m_shBorderFill = oReader.GetAttributeInt("borderFillIDRef"); - for (CXMLNode& oChild : oNode.GetChilds()) + WHILE_READ_NEXT_NODE_WITH_NAME(oReader) { - if (L"hp:cellAddr" == oChild.GetName()) + if ("hp:cellAddr" == sNodeName) { - m_shColAddr = oChild.GetAttributeInt(L"colAddr"); - m_shRowAddr = oChild.GetAttributeInt(L"rowAddr"); - } - else if (L"hp:cellSpan" == oChild.GetName()) - { - m_shColSpan = oChild.GetAttributeInt(L"colSpan"); - m_shRowSpan = oChild.GetAttributeInt(L"rowSpan"); - } - else if (L"hp:cellSz" == oChild.GetName()) - { - m_nWidth = oChild.GetAttributeInt(L"width"); - m_nHeight = oChild.GetAttributeInt(L"height"); - } - else if (L"hp:cellMargin" == oChild.GetName()) - { - m_arMargin[0] = oChild.GetAttributeInt(L"left"); - m_arMargin[1] = oChild.GetAttributeInt(L"rifht"); - m_arMargin[2] = oChild.GetAttributeInt(L"top"); - m_arMargin[3] = oChild.GetAttributeInt(L"bottom"); - } - else if (L"hp:subList" == oChild.GetName()) - { - m_eVertAlign = ::HWP::GetVertAlign(oChild.GetAttribute(L"vertAlign")); - - for (CXMLNode& oGrandChild : oChild.GetChilds(L"hp:p")) + START_READ_ATTRIBUTES(oReader) { - CCellParagraph *pCellParagraphs = new CCellParagraph(oGrandChild, nVersion); + if ("colAddr" == sAttributeName) + m_shColAddr = oReader.GetInt(); + else if ("rowAddr" == sAttributeName) + m_shRowAddr = oReader.GetInt(); + } + END_READ_ATTRIBUTES(oReader) + } + else if ("hp:cellSpan" == sNodeName) + { + START_READ_ATTRIBUTES(oReader) + { + if ("colSpan" == sAttributeName) + m_shColSpan = oReader.GetInt(); + else if ("rowSpan" == sAttributeName) + m_shRowSpan = oReader.GetInt(); + } + END_READ_ATTRIBUTES(oReader) + } + else if ("hp:cellSz" == sNodeName) + { + START_READ_ATTRIBUTES(oReader) + { + if ("width" == sAttributeName) + m_nWidth = oReader.GetInt(); + else if ("height" == sAttributeName) + m_nHeight = oReader.GetInt(); + } + END_READ_ATTRIBUTES(oReader) + } + else if ("hp:cellSz" == sNodeName) + { + START_READ_ATTRIBUTES(oReader) + { + if ("left" == sAttributeName) + m_arMargin[0] = oReader.GetInt(); + else if ("right" == sAttributeName) + m_arMargin[1] = oReader.GetInt(); + else if ("top" == sAttributeName) + m_arMargin[2] = oReader.GetInt(); + else if ("bottom" == sAttributeName) + m_arMargin[3] = oReader.GetInt(); + } + END_READ_ATTRIBUTES(oReader) + } + else if ("hp:subList" == sNodeName) + { + m_eVertAlign = ::HWP::GetVertAlign(oReader.GetAttribute("vertAlign")); + + WHILE_READ_NEXT_NODE_WITH_ONE_NAME(oReader, "hp:p") + { + CCellParagraph *pCellParagraphs = new CCellParagraph(oReader, nVersion); if (nullptr == pCellParagraphs) continue; @@ -69,8 +95,10 @@ CTblCell::CTblCell(CXMLNode& oNode, int nVersion) m_arParas.push_back(pCellParagraphs); } + END_WHILE } } + END_WHILE } void CTblCell::SetVertAlign(EVertAlign eVertAlign) diff --git a/HwpFile/HwpDoc/Paragraph/TblCell.h b/HwpFile/HwpDoc/Paragraph/TblCell.h index dc056d0c9e..f5cf3e9777 100644 --- a/HwpFile/HwpDoc/Paragraph/TblCell.h +++ b/HwpFile/HwpDoc/Paragraph/TblCell.h @@ -24,7 +24,7 @@ class CTblCell HWP_STRING m_sMergedColName; public: CTblCell(int nSize, CHWPStream& oBuffer, int nOff, int nVersion); - CTblCell(CXMLNode& oNode, int nVersion); + CTblCell(CXMLReader& oReader, int nVersion); void SetVertAlign(EVertAlign eVertAlign); diff --git a/HwpFile/HwpDoc/Section/NoteShape.cpp b/HwpFile/HwpDoc/Section/NoteShape.cpp index f4955d2a6a..dd2220b374 100644 --- a/HwpFile/HwpDoc/Section/NoteShape.cpp +++ b/HwpFile/HwpDoc/Section/NoteShape.cpp @@ -17,7 +17,7 @@ ENoteNumbering GetNoteNumbering(int nValue) CNoteShape::CNoteShape() {} -CNoteShape::CNoteShape(CXMLNode& oNode, int nVersion) +CNoteShape::CNoteShape(CXMLReader& oReader, int nVersion) {} CNoteShape* CNoteShape::Parse(int nLevel, int nSize, CHWPStream& oBuffer, int nOff, int nVersion) diff --git a/HwpFile/HwpDoc/Section/NoteShape.h b/HwpFile/HwpDoc/Section/NoteShape.h index 9d9069793a..d79b4ee14c 100644 --- a/HwpFile/HwpDoc/Section/NoteShape.h +++ b/HwpFile/HwpDoc/Section/NoteShape.h @@ -3,7 +3,7 @@ #include "../HWPElements/HwpRecordTypes.h" #include "../HWPStream.h" -#include "../Common/XMLNode.h" +#include "../Common/XMLReader.h" namespace HWP { @@ -47,7 +47,7 @@ class CNoteShape int m_nNoteLineColor; public: CNoteShape(); - CNoteShape(CXMLNode& oNode, int nVersion); + CNoteShape(CXMLReader& oReader, int nVersion); static CNoteShape* Parse(int nLevel, int nSize, CHWPStream& oBuffer, int nOff, int nVersion); }; diff --git a/HwpFile/HwpDoc/Section/Page.cpp b/HwpFile/HwpDoc/Section/Page.cpp index 43b075f854..d0f29db5c7 100644 --- a/HwpFile/HwpDoc/Section/Page.cpp +++ b/HwpFile/HwpDoc/Section/Page.cpp @@ -5,32 +5,53 @@ namespace HWP HWP::CPage::CPage() {} -CPage::CPage(CXMLNode& oNode) +CPage::CPage(CXMLReader& oReader) { - m_bLandscape = L"NARROWLY" == oNode.GetAttribute(L"landscape"); - - m_nWidth = oNode.GetAttributeInt(L"width"); - m_nHeight = oNode.GetAttributeInt(L"height"); - - std::wstring wsType = oNode.GetAttribute(L"gutterType"); - - if (L"LEFT_ONELY" == wsType) - m_chGutterType = 0; - else if (L"LEFT_RIGHT" == wsType) - m_chGutterType = 1; - else if (L"TOP_BOTTOM" == wsType) - m_chGutterType = 2; - - for (CXMLNode& oChild : oNode.GetChilds(L"hp:margin")) + START_READ_ATTRIBUTES(oReader) { - m_nMarginLeft = oChild.GetAttributeInt(L"left"); - m_nMarginRight = oChild.GetAttributeInt(L"right"); - m_nMarginTop = oChild.GetAttributeInt(L"top"); - m_nMarginBottom = oChild.GetAttributeInt(L"bottom"); - m_nMarginHeader = oChild.GetAttributeInt(L"header"); - m_nMarginFooter = oChild.GetAttributeInt(L"footer"); - m_nMarginGutter = oChild.GetAttributeInt(L"gutter"); + if ("landscape" == sAttributeName) + m_bLandscape = "NARROWLY" == oReader.GetTextA(); + else if ("width" == sAttributeName) + m_nWidth = oReader.GetInt(); + else if ("height" == sAttributeName) + m_nHeight = oReader.GetInt(); + else if ("gutterType" == sAttributeName) + { + const std::string sType{oReader.GetTextA()}; + + if ("LEFT_ONELY" == sType) + m_chGutterType = 0; + else if ("LEFT_RIGHT" == sType) + m_chGutterType = 1; + else if ("TOP_BOTTOM" == sType) + m_chGutterType = 2; + } } + END_READ_ATTRIBUTES(oReader) + + WHILE_READ_NEXT_NODE_WITH_ONE_NAME(oReader, "hp:margin") + { + START_READ_ATTRIBUTES(oReader) + { + if ("left" == sAttributeName) + m_nMarginLeft = oReader.GetInt(); + else if ("right" == sAttributeName) + m_nMarginRight = oReader.GetInt(); + else if ("top" == sAttributeName) + m_nMarginTop = oReader.GetInt(); + else if ("bottom" == sAttributeName) + m_nMarginBottom = oReader.GetInt(); + else if ("header" == sAttributeName) + m_nMarginHeader = oReader.GetInt(); + else if ("footer" == sAttributeName) + m_nMarginFooter = oReader.GetInt(); + else if ("gutter" == sAttributeName) + m_nMarginGutter = oReader.GetInt(); + + } + END_READ_ATTRIBUTES(oReader) + } + END_WHILE } int CPage::GetWidth() const diff --git a/HwpFile/HwpDoc/Section/Page.h b/HwpFile/HwpDoc/Section/Page.h index a2b5f49243..ba3bdc9a41 100644 --- a/HwpFile/HwpDoc/Section/Page.h +++ b/HwpFile/HwpDoc/Section/Page.h @@ -2,7 +2,7 @@ #define PAGE_H #include "../HWPStream.h" -#include "../Common/XMLNode.h" +#include "../Common/XMLReader.h" namespace HWP { @@ -21,7 +21,7 @@ class CPage int m_nMarginGutter; public: CPage(); - CPage(CXMLNode& oNode); + CPage(CXMLReader& oReader); int GetWidth() const; int GetHeight() const; diff --git a/HwpFile/HwpDoc/Section/PageBorderFill.cpp b/HwpFile/HwpDoc/Section/PageBorderFill.cpp index 7ea47183a5..08d1fbec0f 100644 --- a/HwpFile/HwpDoc/Section/PageBorderFill.cpp +++ b/HwpFile/HwpDoc/Section/PageBorderFill.cpp @@ -5,29 +5,48 @@ namespace HWP CPageBorderFill::CPageBorderFill() {} -CPageBorderFill::CPageBorderFill(CXMLNode& oNode, int nVersion) +CPageBorderFill::CPageBorderFill(CXMLReader& oReader, int nVersion) { - m_shBorderFill = oNode.GetAttributeInt(L"borderFillIDRef"); - m_bTextBorder = L"PAPER" == oNode.GetAttribute(L"textBorder"); - m_bHeaderInside = oNode.GetAttributeBool(L"headerInside"); - m_bFooterInside = oNode.GetAttributeBool(L"footerInside"); - - HWP_STRING sType = oNode.GetAttribute(L"fillArea"); - - if (L"PAPER" == sType) - m_chFillArea = 0; - else if (L"PAGE" == sType) - m_chFillArea = 1; - else if (L"BORDER" == sType) - m_chFillArea = 2; - - for (CXMLNode& oChild : oNode.GetChilds(L"offset")) + START_READ_ATTRIBUTES(oReader) { - m_shOffsetLeft = oChild.GetAttributeInt(L"left"); - m_shOffsetRight = oChild.GetAttributeInt(L"right"); - m_shOffsetTop = oChild.GetAttributeInt(L"top"); - m_shOffsetBottom = oChild.GetAttributeInt(L"bottom"); + if ("borderFillIDRef" == sAttributeName) + m_shBorderFill = oReader.GetInt(); + else if ("textBorder" == sAttributeName) + m_bTextBorder = "PAPER" == oReader.GetTextA(); + else if ("headerInside" == sAttributeName) + m_bHeaderInside = oReader.GetBool(); + else if ("footerInside" == sAttributeName) + m_bFooterInside = oReader.GetBool(); + else if ("fillArea" == sAttributeName) + { + const std::string sType{oReader.GetTextA()}; + + if ("PAPER" == sType) + m_chFillArea = 0; + else if ("PAGE" == sType) + m_chFillArea = 1; + else if ("BORDER" == sType) + m_chFillArea = 2; + } } + END_READ_ATTRIBUTES(oReader) + + WHILE_READ_NEXT_NODE_WITH_ONE_NAME(oReader, "offset") + { + START_READ_ATTRIBUTES(oReader) + { + if ("left" == sAttributeName) + m_shOffsetLeft = oReader.GetInt(); + else if ("right" == sAttributeName) + m_shOffsetRight = oReader.GetInt(); + else if ("top" == sAttributeName) + m_shOffsetTop = oReader.GetInt(); + else if ("bottom" == sAttributeName) + m_shOffsetBottom = oReader.GetInt(); + } + END_READ_ATTRIBUTES(oReader) + } + END_WHILE } CPageBorderFill* CPageBorderFill::Parse(int nLevel, int nSize, CHWPStream& oBuffer, int nOff, int nVersion) diff --git a/HwpFile/HwpDoc/Section/PageBorderFill.h b/HwpFile/HwpDoc/Section/PageBorderFill.h index 5993f5b542..bd6962611f 100644 --- a/HwpFile/HwpDoc/Section/PageBorderFill.h +++ b/HwpFile/HwpDoc/Section/PageBorderFill.h @@ -2,7 +2,7 @@ #define PAGEBORDERFILL_H #include "../HWPStream.h" -#include "../Common/XMLNode.h" +#include "../Common/XMLReader.h" namespace HWP { @@ -19,7 +19,7 @@ class CPageBorderFill short m_shBorderFill; public: CPageBorderFill(); - CPageBorderFill(CXMLNode& oNode, int nVersion); + CPageBorderFill(CXMLReader& oReader, int nVersion); static CPageBorderFill* Parse(int nLevel, int nSize, CHWPStream& oBuffer, int nOff, int nVersion); }; diff --git a/MsBinaryFile/Projects/XlsFormatLib/Linux/XlsFormatLib.pro b/MsBinaryFile/Projects/XlsFormatLib/Linux/XlsFormatLib.pro index 2b4d461d9b..699fa3e16c 100644 --- a/MsBinaryFile/Projects/XlsFormatLib/Linux/XlsFormatLib.pro +++ b/MsBinaryFile/Projects/XlsFormatLib/Linux/XlsFormatLib.pro @@ -78,7 +78,8 @@ SOURCES += \ ../../../XlsFile/Converter/xlsx_external_context.cpp \ ../../../XlsFile/Converter/xlsx_activeX_context.cpp \ ../../../XlsFile/Converter/xlsx_comments.cpp \ - ../../../XlsFile/Converter/xlsx_comments_context.cpp + ../../../XlsFile/Converter/xlsx_comments_context.cpp \ + ../../../XlsFile/Converter/xls_writer.cpp HEADERS += \ ../../../XlsFile/Format/Binary/BinSmartPointers.h \ @@ -129,5 +130,6 @@ HEADERS += \ \ ../../../XlsFile/Converter/ShapeType.h \ ../../../XlsFile/Converter/xlsx_chart_context.h \ - ../../../XlsFile/Format/Auxiliary/HelpFunc.h + ../../../XlsFile/Format/Auxiliary/HelpFunc.h \ + ../../../XlsFile/Converter/xls_writer.h diff --git a/MsBinaryFile/XlsFile/Converter/xls_writer.cpp b/MsBinaryFile/XlsFile/Converter/xls_writer.cpp new file mode 100644 index 0000000000..7faad1de4d --- /dev/null +++ b/MsBinaryFile/XlsFile/Converter/xls_writer.cpp @@ -0,0 +1,78 @@ +#/* + * (c) Copyright Ascensio System SIA 2010-2025 + * + * This program is a free software product. You can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License (AGPL) + * version 3 as published by the Free Software Foundation. In accordance with + * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect + * that Ascensio System SIA expressly excludes the warranty of non-infringement + * of any third-party rights. + * + * This program is distributed WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For + * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html + * + * You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish + * street, Riga, Latvia, EU, LV-1050. + * + * The interactive user interfaces in modified source and object code versions + * of the Program must display Appropriate Legal Notices, as required under + * Section 5 of the GNU AGPL version 3. + * + * Pursuant to Section 7(b) of the License you must retain the original Product + * logo when distributing the program. Pursuant to Section 7(e) we decline to + * grant you any rights under trademark law for use of our trademarks. + * + * All the Product's GUI elements, including illustrations and icon sets, as + * well as technical writing content are licensed under the terms of the + * Creative Commons Attribution-ShareAlike 4.0 International. See the License + * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode + * + */ + +#include "xls_writer.h" +#include "../Format/Binary/CompoundFile.h" +#include "../Format/Binary/CFStreamCacheWriter.h" +#include "../Format/Logic/WorkbookStreamObject.h" + +bool XlsWriter::Open(const std::wstring &fileName) +{ + xls_file = boost::shared_ptr(new XLS::CompoundFile(fileName, XLS::CompoundFile::cf_WriteMode)); + if(xls_file->isError()) + return false; + return true; +} +bool XlsWriter::WriteWorkbook(XLS::BaseObjectPtr streamObject) +{ + auto WokrkbokStreamName = L"Workbook"; + auto xls_global_info = boost::shared_ptr(new XLS::GlobalWorkbookInfo(XLS::WorkbookStreamObject::DefaultCodePage, nullptr)); + auto BookStream = xls_file->createNamedStream(WokrkbokStreamName); + if(BookStream == nullptr) + return false; + XLS::StreamCacheWriterPtr cacheWriter(new XLS::CFStreamCacheWriter(BookStream, xls_global_info)); + XLS::BinWriterProcessor stream_proc(cacheWriter, nullptr); + stream_proc.mandatory(*streamObject); + + //writing fileptrs + { + auto filePos = BookStream->getStreamPointer(); + for(auto sheet : xls_global_info->sheets_info) + { + //bof of worksheet + BookStream->seekFromBegin(sheet.BoundSheetPos); + BookStream->write(&sheet.StreamPos, 4); + } + BookStream->seekFromBegin(filePos); + } + + return true; +} +bool XlsWriter::WriteStreamObject(std::wstring &streamName, XLS::BaseObjectPtr streamObject) +{ + auto xls_global_info = boost::shared_ptr(new XLS::GlobalWorkbookInfo(XLS::WorkbookStreamObject::DefaultCodePage, nullptr)); + XLS::StreamCacheWriterPtr cacheWriter(new XLS::CFStreamCacheWriter(xls_file->createNamedStream(streamName), xls_global_info)); + + XLS::BinWriterProcessor stream_proc(cacheWriter, nullptr); + stream_proc.mandatory(*streamObject); + return true; +} diff --git a/MsBinaryFile/XlsFile/Converter/xls_writer.h b/MsBinaryFile/XlsFile/Converter/xls_writer.h new file mode 100644 index 0000000000..1617dcced4 --- /dev/null +++ b/MsBinaryFile/XlsFile/Converter/xls_writer.h @@ -0,0 +1,52 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2025 + * + * This program is a free software product. You can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License (AGPL) + * version 3 as published by the Free Software Foundation. In accordance with + * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect + * that Ascensio System SIA expressly excludes the warranty of non-infringement + * of any third-party rights. + * + * This program is distributed WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For + * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html + * + * You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish + * street, Riga, Latvia, EU, LV-1050. + * + * The interactive user interfaces in modified source and object code versions + * of the Program must display Appropriate Legal Notices, as required under + * Section 5 of the GNU AGPL version 3. + * + * Pursuant to Section 7(b) of the License you must retain the original Product + * logo when distributing the program. Pursuant to Section 7(e) we decline to + * grant you any rights under trademark law for use of our trademarks. + * + * All the Product's GUI elements, including illustrations and icon sets, as + * well as technical writing content are licensed under the terms of the + * Creative Commons Attribution-ShareAlike 4.0 International. See the License + * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode + * + */ + +#pragma once +#include +#include +#include "../Format/Logic/CompositeObject.h" +namespace XLS +{ + class CompoundFile; + typedef boost::shared_ptr CompoundFilePtr; +} +class XlsWriter +{ +public: + bool Open(const std::wstring &fileName); + bool WriteWorkbook(XLS::BaseObjectPtr streamObject); + bool WriteStreamObject(std::wstring &streamName, XLS::BaseObjectPtr streamObject); +private: + std::wstring fileName_ = L""; + + XLS::CompoundFilePtr xls_file; +}; diff --git a/MsBinaryFile/XlsFile/Format/Binary/CFRecord.cpp b/MsBinaryFile/XlsFile/Format/Binary/CFRecord.cpp index 2015a5dd94..a2b710532c 100644 --- a/MsBinaryFile/XlsFile/Format/Binary/CFRecord.cpp +++ b/MsBinaryFile/XlsFile/Format/Binary/CFRecord.cpp @@ -478,6 +478,13 @@ void CFRecord::save(NSBinPptxRW::CXlsbBinaryWriter& writer) writer.WriteBYTEArray((BYTE*)&intData[0], rdPtr); } +void CFRecord::save(CFStreamPtr& writer) +{ + writer->write(&type_id_, 2); + writer->write(&rdPtr, 2); + writer->write(&intData[0], rdPtr); +} + CFRecord& CFRecord::operator >> (bool& val) { throw;// EXCEPT::LE::WrongAPIUsage("This function may only be called by mistake.", __FUNCTION__); diff --git a/MsBinaryFile/XlsFile/Format/Binary/CFRecord.h b/MsBinaryFile/XlsFile/Format/Binary/CFRecord.h index 8ad0ee56f3..f899a8a379 100644 --- a/MsBinaryFile/XlsFile/Format/Binary/CFRecord.h +++ b/MsBinaryFile/XlsFile/Format/Binary/CFRecord.h @@ -33,6 +33,7 @@ #include "CFRecordType.h" #include "CFStream.h" +#include "CFStreamCacheWriter.h" #include "BinSmartPointers.h" #include "../Logic/GlobalWorkbookInfo.h" @@ -90,6 +91,7 @@ public: //save record to stream void save(NSBinPptxRW::CXlsbBinaryWriter& writer); + void save(CFStreamPtr& writer); template const T* getCurData() const diff --git a/MsBinaryFile/XlsFile/Format/Binary/CFStreamCacheWriter.cpp b/MsBinaryFile/XlsFile/Format/Binary/CFStreamCacheWriter.cpp index 8e6fe5e4c2..7ad148e2b7 100644 --- a/MsBinaryFile/XlsFile/Format/Binary/CFStreamCacheWriter.cpp +++ b/MsBinaryFile/XlsFile/Format/Binary/CFStreamCacheWriter.cpp @@ -77,10 +77,15 @@ CFStreamCacheWriter::~CFStreamCacheWriter() // Returns whether the record was saved to file or stored for later saving bool CFStreamCacheWriter::storeNextRecord(CFRecordPtr record) { - //record->save(stream_); + record->save(stream_); return true; } +const size_t CFStreamCacheWriter::GetRecordPosition() +{ + return stream_->getStreamPointer(); +} + // Actual transporting record to the CFStream and then to IStream const size_t CFStreamCacheWriter::writeToStream(const size_t num_of_records_min_necessary) { diff --git a/MsBinaryFile/XlsFile/Format/Binary/CFStreamCacheWriter.h b/MsBinaryFile/XlsFile/Format/Binary/CFStreamCacheWriter.h index 0212b4fefa..cf83b6a3ec 100644 --- a/MsBinaryFile/XlsFile/Format/Binary/CFStreamCacheWriter.h +++ b/MsBinaryFile/XlsFile/Format/Binary/CFStreamCacheWriter.h @@ -55,6 +55,7 @@ public: // Saves the next CFRecord to the stream or caches for later saving. Returns whether the record was saved to file or stored for later saving virtual bool storeNextRecord(CFRecordPtr record); + virtual const size_t GetRecordPosition() = 0; GlobalWorkbookInfoPtr getGlobalWorkbookInfo() { return global_info_; } private: @@ -78,6 +79,8 @@ public: // Saves the next CFRecord to the CFStream or caches for later saving. Returns whether the record was saved to file or stored for later saving bool storeNextRecord(CFRecordPtr record) override; + const size_t GetRecordPosition()override; + private: // Actual transporting record to the CFStream and then to IStream const size_t writeToStream(const size_t num_of_records_min_necessary) override; @@ -91,7 +94,7 @@ class BinaryStreamCacheWriter : public StreamCacheWriter public: BinaryStreamCacheWriter(boost::shared_ptr binaryStream, const GlobalWorkbookInfoPtr global_info); ~BinaryStreamCacheWriter(); - + const size_t GetRecordPosition()override{return 0;} private: const size_t writeToStream(const size_t num_of_records_min_necessary) override; diff --git a/MsBinaryFile/XlsFile/Format/Binary/CompoundFile.h b/MsBinaryFile/XlsFile/Format/Binary/CompoundFile.h index 85076de889..af424a8cfb 100644 --- a/MsBinaryFile/XlsFile/Format/Binary/CompoundFile.h +++ b/MsBinaryFile/XlsFile/Format/Binary/CompoundFile.h @@ -64,14 +64,15 @@ public: CFStreamPtr getNamedStream (const std::wstring& name); POLE::Storage *storage_; + + CFStreamPtr createNamedStream (const std::wstring& name); + void closeNamedStream (const std::wstring& name); private: void copy_stream(std::wstring streamNameOpen, std::wstring streamNameCreate, POLE::Storage * storageOut, bool bWithRoot = true); POLE::Stream* openStream (const std::wstring & stream_name); // Opens a stream in the storage (shall be called not more than once per stream) POLE::Stream* createStream (const std::wstring & stream_name); // Creates a new stream in the storage - CFStreamPtr createNamedStream (const std::wstring& name); - void closeNamedStream (const std::wstring& name); std::map streams; ReadWriteMode rwMode; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/AlRuns.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/AlRuns.cpp index 14270a6398..76ee450482 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/AlRuns.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/AlRuns.cpp @@ -63,5 +63,14 @@ void AlRuns::readFields(CFRecord& record) } } +void AlRuns::writeFields(CFRecord& record) +{ + unsigned short cRuns = rgRuns.size(); + for(auto i : rgRuns) + { + record << *i; + } +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/AlRuns.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/AlRuns.h index f1f83bf8c3..e7fbdbe53e 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/AlRuns.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/AlRuns.h @@ -50,6 +50,7 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeAlRuns; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Area.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Area.cpp index efec43e6d4..0a574157af 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Area.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Area.cpp @@ -59,6 +59,15 @@ void Area::readFields(CFRecord& record) fHasShadow = GETBIT(flags, 2); } +void Area::writeFields(CFRecord& record) +{ + unsigned short flags = 0; + SETBIT(flags, 0, fStacked) + SETBIT(flags, 1, f100) + SETBIT(flags, 2, fHasShadow) + record << flags; +} + int Area::serialize(std::wostream & _stream) { CP_XML_WRITER(_stream) diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Area.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Area.h index e882df5ea3..a0d9d87a14 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Area.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Area.h @@ -50,14 +50,15 @@ public: void readFields(CFRecord& record); + void writeFields(CFRecord& record); int serialize(std::wostream & _stream); static const ElementType type = typeArea; - bool fStacked; - bool f100; - bool fHasShadow; + bool fStacked = false; + bool f100 = false; + bool fHasShadow = false; }; } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/AreaFormat.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/AreaFormat.cpp index b74a984e4e..5c82e70fa0 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/AreaFormat.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/AreaFormat.cpp @@ -60,6 +60,14 @@ void AreaFormat::readFields(CFRecord& record) fInvertNeg = GETBIT(flags, 1); } +void AreaFormat::writeFields(CFRecord& record) +{ + unsigned short flags = 0; + SETBIT(flags, 0, fAuto) + SETBIT(flags, 1, fInvertNeg) + record << rgbFore << rgbBack << fls << flags << icvFore << icvBack; +} + int AreaFormat::serialize(std::wostream & _stream) { CP_XML_WRITER(_stream) diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/AreaFormat.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/AreaFormat.h index 3f87e84f87..fce793af66 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/AreaFormat.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/AreaFormat.h @@ -51,6 +51,7 @@ public: void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeAreaFormat; @@ -59,13 +60,13 @@ public: LongRGB rgbFore; LongRGB rgbBack; - _UINT16 fls; + _UINT16 fls = 0; - bool fAuto; - bool fInvertNeg; + bool fAuto = false; + bool fInvertNeg = false; - IcvChart icvFore; - IcvChart icvBack; + IcvChart icvFore = 0; + IcvChart icvBack = 0; }; } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/AttachedLabel.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/AttachedLabel.cpp index bfcd8c1074..749b0485a1 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/AttachedLabel.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/AttachedLabel.cpp @@ -65,6 +65,18 @@ void AttachedLabel::readFields(CFRecord& record) fShowSeriesName = GETBIT(flags, 6); } +void AttachedLabel::writeFields(CFRecord& record) +{ + unsigned short flags = 0; + SETBIT(flags, 0, fShowValue) + SETBIT(flags, 1, fShowPercent) + SETBIT(flags, 2, fShowLabelAndPerc) + SETBIT(flags, 4, fShowLabel) + SETBIT(flags, 5, fShowBubbleSizes) + SETBIT(flags, 6, fShowSeriesName) + record << flags; +} + int AttachedLabel::serialize(std::wostream & _stream) { CP_XML_WRITER(_stream) diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/AttachedLabel.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/AttachedLabel.h index 03f24ef910..093f06288e 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/AttachedLabel.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/AttachedLabel.h @@ -50,21 +50,22 @@ public: void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeAttachedLabel; int serialize(std::wostream & _stream); - bool fShowValue; - bool fShowPercent; - bool fShowLabelAndPerc; - bool fShowLabel; - bool fShowBubbleSizes; - bool fShowSeriesName; + bool fShowValue = false; + bool fShowPercent = false; + bool fShowLabelAndPerc = false; + bool fShowLabel = false; + bool fShowBubbleSizes = false; + bool fShowSeriesName = false; //----------------------------- - bool is_area; + bool is_area = false; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/AutoFilter.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/AutoFilter.cpp index fb9d7ada9b..6fa427b376 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/AutoFilter.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/AutoFilter.cpp @@ -142,5 +142,46 @@ void AutoFilter::readFields(CFRecord& record) } } +void AutoFilter::writeFields(CFRecord& record) +{ + unsigned short flags = 0; + + SETBITS(flags, 0, 1, wJoin) + + SETBIT(flags, 2, fSimple1) + SETBIT(flags, 3, fSimple2) + SETBIT(flags, 4, fTopN) + SETBIT(flags, 5, fTop) //top(1) or bottom(0) + SETBIT(flags, 6, fPercent) + + SETBITS(flags, 7, 15, wTopN) + + record << iEntry << flags; + if (fTopN != 1) + { + record << doper1; + record << doper2; + if(doper1.vt == 0x06) + { + XLUnicodeStringNoCch s; + s.setSize(doper1.vtValueStr.cch); + s = str1; + record << s; + } + if(doper2.vt == 0x06) + { + XLUnicodeStringNoCch s; + s.setSize(doper2.vtValueStr.cch); + s = str2; + record << s; + } + } + else + { + record.reserveNunBytes(20); + } + +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/AutoFilter.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/AutoFilter.h index 12b69f8941..80df90cb3c 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/AutoFilter.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/AutoFilter.h @@ -48,33 +48,34 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeAutoFilter; _UINT16 iEntry; - unsigned char wJoin; + unsigned char wJoin = 0; - bool fSimple1; - bool fSimple2; + bool fSimple1 = false; + bool fSimple2 = false; - bool fTopN; - bool fPercent; + bool fTopN = false; + bool fPercent = false; - unsigned char fTop; - _UINT16 wTopN; + unsigned char fTop = 0; + _UINT16 wTopN = 0; AFDOper doper1; AFDOper doper2; - bool m_bAutoFilter12; + bool m_bAutoFilter12 = false; - std::wstring str1; - std::wstring str2; + std::wstring str1 = L""; + std::wstring str2 = L""; //---------------------------------------- - bool bExist; - _UINT32 size; + bool bExist = false; + _UINT32 size = 0; }; } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/AutoFilter12.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/AutoFilter12.cpp index e5c4f8394c..de1834404a 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/AutoFilter12.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/AutoFilter12.cpp @@ -109,5 +109,25 @@ void AutoFilter12::readFields(CFRecord& record) } } +void AutoFilter12::writeFields(CFRecord& record) +{ + _UINT16 flags = 0; + record << frtRefHeader << iEntry << fHideArrow << ft << cft << cCriteria << cDateGroupings; + bool fWorksheetAutoFilter = false; + if(idList == 0xFFFFFFFF) + fWorksheetAutoFilter = true; + SETBIT(flags, 3, fWorksheetAutoFilter) + record << flags; + record.reserveNunBytes(4); + record << idList; + + _GUID_ guid_num; + STR::bstr2guid(guidSview, guid_num); + record << guid_num; + if(rgb != nullptr) + rgb->save(record); + +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/AutoFilter12.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/AutoFilter12.h index d0b8167aac..6890c21692 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/AutoFilter12.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/AutoFilter12.h @@ -50,20 +50,21 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeAutoFilter12; FrtRefHeader frtRefHeader; - _UINT16 iEntry; - _UINT32 fHideArrow; - _UINT32 ft; - _UINT32 cft; - _UINT32 cCriteria; - _UINT32 cDateGroupings; - _UINT32 idList; + _UINT16 iEntry = 0; + _UINT32 fHideArrow = 0; + _UINT32 ft = 0; + _UINT32 cft = 0; + _UINT32 cCriteria = 0; + _UINT32 cDateGroupings = 0; + _UINT32 idList = 0; - std::wstring guidSview; + std::wstring guidSview = L""; BiffStructurePtr rgb; BiffStructurePtrVector arAF12Criteries; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/AutoFilterInfo.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/AutoFilterInfo.cpp index 3330bf9f27..28fbf49a06 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/AutoFilterInfo.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/AutoFilterInfo.cpp @@ -56,5 +56,10 @@ void AutoFilterInfo::readFields(CFRecord& record) record >> cEntries; } +void AutoFilterInfo::writeFields(CFRecord& record) +{ + record << cEntries; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/AutoFilterInfo.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/AutoFilterInfo.h index e4d038c04c..3ed3f9300c 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/AutoFilterInfo.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/AutoFilterInfo.h @@ -52,8 +52,9 @@ class AutoFilterInfo: public BiffRecord void readFields(CFRecord& record); + void writeFields(CFRecord& record); //----------------------------- - _UINT16 cEntries; + _UINT16 cEntries = 0; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/AxcExt.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/AxcExt.cpp index 184b91c4b9..f15a2bd71f 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/AxcExt.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/AxcExt.cpp @@ -67,6 +67,21 @@ void AxcExt::readFields(CFRecord& record) fAutoDate = GETBIT(flags, 7); } +void AxcExt::writeFields(CFRecord& record) +{ + unsigned char flags = 0; + SETBIT(flags, 0, fAutoMin) + SETBIT(flags, 1, fAutoMax) + SETBIT(flags, 2, fAutoMajor) + SETBIT(flags, 3, fAutoMinor) + + SETBIT(flags, 4, fDateAxis) + SETBIT(flags, 5, fAutoBase) + SETBIT(flags, 6, fAutoCross) + SETBIT(flags, 7, fAutoDate) + record << catMin << catMax << catMajor << duMajor << catMinor << duMinor << duBase << catCrossDate << flags; +} + int AxcExt::serialize(std::wostream & _stream) { if (fDateAxis == false) return 0; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/AxcExt.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/AxcExt.h index ef59e597c8..e2d7cee6ea 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/AxcExt.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/AxcExt.h @@ -50,30 +50,30 @@ public: void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeAxcExt; int serialize(std::wostream & _stream); //----------------------------- - _UINT16 catMin; - _UINT16 catMax; - _UINT16 catMajor; - _UINT16 duMajor; - _UINT16 catMinor; - _UINT16 duMinor; - _UINT16 duBase; - _UINT16 catCrossDate; - - bool fAutoMin; - bool fAutoMax; - bool fAutoMajor; - bool fAutoMinor; - bool fDateAxis; - bool fAutoBase; - bool fAutoCross; - bool fAutoDate; + _UINT16 catMin = 0; + _UINT16 catMax = 0; + _UINT16 catMajor = 0; + _UINT16 duMajor = 0; + _UINT16 catMinor = 0; + _UINT16 duMinor = 0; + _UINT16 duBase = 0; + _UINT16 catCrossDate = 0; + bool fAutoMin = false; + bool fAutoMax = false; + bool fAutoMajor = false; + bool fAutoMinor = false; + bool fDateAxis = false; + bool fAutoBase = false; + bool fAutoCross = false; + bool fAutoDate = false; }; } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/AxesUsed.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/AxesUsed.cpp index 397b462473..d944c6efbe 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/AxesUsed.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/AxesUsed.cpp @@ -55,5 +55,10 @@ void AxesUsed::readFields(CFRecord& record) record >> cAxes; } +void AxesUsed::writeFields(CFRecord& record) +{ + record << cAxes; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/AxesUsed.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/AxesUsed.h index 5ebea41dbd..35632e9a95 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/AxesUsed.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/AxesUsed.h @@ -50,11 +50,12 @@ public: void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeAxesUsed; //----------------------------- - _UINT16 cAxes; + _UINT16 cAxes = 1; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Axis.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Axis.cpp index 294bc12eb7..b0a5d9fdcc 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Axis.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Axis.cpp @@ -56,5 +56,11 @@ void Axis::readFields(CFRecord& record) record.skipNunBytes(16); // reserved } +void Axis::writeFields(CFRecord& record) +{ + record << wType; + record.reserveNunBytes(16); +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Axis.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Axis.h index c36a15b0e7..f65935b715 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Axis.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Axis.h @@ -50,11 +50,12 @@ public: void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeAxis; //----------------------------- - _UINT16 wType; + _UINT16 wType = 0; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/AxisLine.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/AxisLine.cpp index 9fbcd310de..cc4e5e92d7 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/AxisLine.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/AxisLine.cpp @@ -55,5 +55,10 @@ void AxisLine::readFields(CFRecord& record) record >> id; } +void AxisLine::writeFields(CFRecord& record) +{ + record << id; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/AxisLine.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/AxisLine.h index 63d490a793..0bb8eb5651 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/AxisLine.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/AxisLine.h @@ -48,11 +48,12 @@ public: void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeAxisLine; //----------------------------- - _UINT16 id; + _UINT16 id = 0; }; } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/AxisParent.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/AxisParent.cpp index bc0dc8d77e..8bb754c988 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/AxisParent.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/AxisParent.cpp @@ -56,7 +56,11 @@ void AxisParent::readFields(CFRecord& record) record.skipNunBytes(16); // unused } - +void AxisParent::writeFields(CFRecord& record) +{ + record << iax; + record.reserveNunBytes(16); +} } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/AxisParent.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/AxisParent.h index a8c7e224a0..6a14b3e253 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/AxisParent.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/AxisParent.h @@ -50,11 +50,12 @@ public: void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeAxisParent; //----------------------------- - unsigned short iax; + unsigned short iax = 0; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BOF.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BOF.cpp index e7066f62b1..eb09f9f294 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BOF.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BOF.cpp @@ -132,6 +132,29 @@ void BOF::readFields(CFRecord& record) } } +void BOF::writeFields(CFRecord& record) +{ + record << vers << dt << rupBuild << rupYear; + _UINT32 flags = 0; + + SETBIT(flags, 0, fWin); + SETBIT(flags, 1, fRisc); + SETBIT(flags, 2, fBeta); + SETBIT(flags, 3, fWinAny); + SETBIT(flags, 4, fMacAny); + SETBIT(flags, 5, fBetaAny); + SETBIT(flags, 8, fRiscAny); + SETBIT(flags, 9, fOOM); + SETBIT(flags, 10, fGlJmp); + SETBIT(flags, 13, fFontLimit); + + SETBITS(flags, 14, 17, verXLHigh); + + record << flags; + record << verLowestBiff << verLastXLSaved; + record.reserveNunBytes(2);// reserved +} + unsigned short BOF::getSubstreamType() { return dt; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BOF.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BOF.h index 89e4cee93a..f457ead445 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BOF.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BOF.h @@ -49,6 +49,7 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeBOF; @@ -71,25 +72,25 @@ public: //----------------------------- - _UINT16 vers = 0; + _UINT16 vers = 0x0600; _UINT16 dt = 0; - _UINT16 rupBuild = 0; - _UINT16 rupYear = 0; + _UINT16 rupBuild = 0x4F5A; + _UINT16 rupYear = 0x07CD; - bool fWin; - bool fRisc; - bool fBeta; - bool fWinAny; - bool fMacAny; - bool fBetaAny; - bool fRiscAny; - bool fOOM; - bool fGlJmp; - bool fFontLimit; + bool fWin = 1; + bool fRisc = 0; + bool fBeta = 0; + bool fWinAny = 1; + bool fMacAny = 0; + bool fBetaAny = 0; + bool fRiscAny = 0; + bool fOOM = 0; + bool fGlJmp = 0; + bool fFontLimit = 0; - _UINT16 verXLHigh; - unsigned char verLowestBiff; - unsigned char verLastXLSaved; + _UINT16 verXLHigh = 0x7; + unsigned char verLowestBiff = 0x6; + unsigned char verLastXLSaved = 0x7; _CP_OPT(unsigned int) stream_ptr; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BRAI.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BRAI.cpp index 56fb8ff098..5d4218f99c 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BRAI.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BRAI.cpp @@ -66,5 +66,13 @@ void BRAI::readFields(CFRecord& record) } +void BRAI::writeFields(CFRecord& record) +{ + unsigned short flags = 0; + SETBIT(flags, 0, fUnlinkedIfmt) + record << id << rt << flags << ifmt; + formula.save(record); +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BRAI.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BRAI.h index 9f883965bc..1c936e1ae0 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BRAI.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BRAI.h @@ -52,14 +52,15 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeBRAI; //----------------------------- - unsigned char id; - unsigned char rt; - bool fUnlinkedIfmt; - unsigned short ifmt; + unsigned char id = 0; + unsigned char rt = 0; + bool fUnlinkedIfmt = 0; + unsigned short ifmt = 0; ChartParsedFormula formula; //набор диапазонов и ячеек }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Backup.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Backup.cpp index b1b4a7a9fe..7b96486ffd 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Backup.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Backup.cpp @@ -55,5 +55,10 @@ void Backup::readFields(CFRecord& record) record >> fBackup; } +void Backup::writeFields(CFRecord& record) +{ + record << fBackup; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Backup.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Backup.h index 556ba1150f..241e01e30d 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Backup.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Backup.h @@ -50,11 +50,12 @@ public: void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeBackup; //----------------------------- - Boolean fBackup; + Boolean fBackup= false; }; } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Bar.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Bar.cpp index 070be9923b..1eb0686856 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Bar.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Bar.cpp @@ -63,6 +63,17 @@ void Bar::readFields(CFRecord& record) fHasShadow = GETBIT(flags, 3); } +void Bar::writeFields(CFRecord& record) +{ + unsigned short flags = 0; + SETBIT(flags, 0, fTranspose) + SETBIT(flags, 1, fStacked) + SETBIT(flags, 2, f100) + SETBIT(flags, 3, fHasShadow) + + record << pcOverlap << pcGap << flags; +} + int Bar::serialize(std::wostream & _stream) { Chart3d *chart3D = dynamic_cast(m_chart3D.get()); diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Bar.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Bar.h index 731144799b..60fabe2266 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Bar.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Bar.h @@ -50,18 +50,19 @@ public: void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeBar; int serialize(std::wostream & _stream); - _INT16 pcOverlap; - _UINT16 pcGap; + _INT16 pcOverlap = 0; + _UINT16 pcGap = 0; - bool fTranspose; - bool fStacked; - bool f100; - bool fHasShadow; + bool fTranspose = false; + bool fStacked = false; + bool f100 = false; + bool fHasShadow = false; //------------------------------------ BaseObjectPtr m_chart3D; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BkHim.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BkHim.cpp index 03452832fd..fe40dca112 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BkHim.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BkHim.cpp @@ -87,5 +87,27 @@ void BkHim::readFields(CFRecord& record) } } +void BkHim::writeFields(CFRecord& record) +{ + record << cf; + unsigned short reserve = 1; + record << reserve; + record << lcb; + auto maxRecordSize = 8224; + if(pData) + { + if(lcb < maxRecordSize) + { + for(auto i = 0; i < lcb; i++) + record << pData[i]; + } + else + { + for(auto i = 0; i < maxRecordSize; i++) + record << pData[i]; + } + } +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BkHim.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BkHim.h index 718e2e2a4d..07e80ef4f9 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BkHim.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BkHim.h @@ -47,11 +47,12 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeBkHim; - _UINT16 cf; - _UINT32 lcb; + _UINT16 cf = 0x0009; + _UINT32 lcb = 0; boost::shared_array pData; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Blank.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Blank.cpp index ac27672c7a..682f20d13d 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Blank.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Blank.cpp @@ -58,6 +58,11 @@ void Blank::readFields(CFRecord& record) record >> cell; } +void Blank::writeFields(CFRecord& record) +{ + record << cell; +} + const CellRef Blank::getLocation() const { return cell.getLocation(); diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Blank.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Blank.h index f0af35ec0b..30d3861a7d 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Blank.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Blank.h @@ -48,6 +48,7 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeBlank; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BookBool.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BookBool.cpp index cc1e04b824..72aa2a6343 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BookBool.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BookBool.cpp @@ -80,5 +80,22 @@ void BookBool::readFields(CFRecord& record) fHideBorderUnselLists = GETBIT(flags, 8); } +void BookBool::writeFields(CFRecord& record) +{ + unsigned short flags = 0; + SETBIT(flags, 0, fNoSaveSup) + SETBIT(flags, 2, fHasEnvelope) + SETBIT(flags, 3, fEnvelopeVisible) + SETBIT(flags, 4, fEnvelopeInitDone) + unsigned char grUpdateLinks_num = 0; + if(grUpdateLinks == L"never") + grUpdateLinks_num = 1; + else if(grUpdateLinks == L"always") + grUpdateLinks_num = 2; + SETBITS(flags, 5, 6, grUpdateLinks_num) + SETBIT(flags, 8, fHideBorderUnselLists) + record << flags; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BookBool.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BookBool.h index 859656495c..0bebc76646 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BookBool.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BookBool.h @@ -47,16 +47,16 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeBookBool; - bool fNoSaveSup; - bool fHasEnvelope; - bool fEnvelopeVisible; - bool fEnvelopeInitDone; - bool fHideBorderUnselLists; - - std::wstring grUpdateLinks; + bool fNoSaveSup = false; + bool fHasEnvelope = false; + bool fEnvelopeVisible = false; + bool fEnvelopeInitDone = false; + bool fHideBorderUnselLists = false; + std::wstring grUpdateLinks = L"userSet"; }; } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BookExt.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BookExt.cpp index d28d4fc52e..963bd9d8c5 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BookExt.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BookExt.cpp @@ -100,9 +100,29 @@ void BookExt::readFields(CFRecord& record) } } +} +void BookExt::writeFields(CFRecord& record) +{ + FrtHeader header(rt_BookExt); + record << header << cb; + _UINT32 flags = 0; + SETBIT(flags, 0, fDontAutoRecover) + SETBIT(flags, 1, fHidePivotList) + SETBIT(flags, 2, fFilterPrivacy) + SETBIT(flags, 3, fEmbedFactoids) + SETBITS(flags, 4, 5, mdFactoidDisplay) + SETBIT(flags, 6, fSavedDuringRecovery) + SETBIT(flags, 7, fCreatedViaMinimalSave) + SETBIT(flags, 8, fOpenedViaDataRecovery) + SETBIT(flags, 9, fOpenedViaSafeLoad) + record << flags; + if(cb > 20) + record << grbit1; + if(cb > 21) + record << grbit2; } } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BookExt.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BookExt.h index 9a70ed128b..cfc3b9b83d 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BookExt.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BookExt.h @@ -51,20 +51,21 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeBookExt; - _UINT32 cb; + _UINT32 cb = 20; - bool fDontAutoRecover; - bool fHidePivotList; - bool fFilterPrivacy; - bool fEmbedFactoids; - unsigned char mdFactoidDisplay; - bool fSavedDuringRecovery; - bool fCreatedViaMinimalSave; - bool fOpenedViaDataRecovery; - bool fOpenedViaSafeLoad; + bool fDontAutoRecover = false; + bool fHidePivotList = false; + bool fFilterPrivacy = false; + bool fEmbedFactoids = false; + unsigned char mdFactoidDisplay = 0; + bool fSavedDuringRecovery = false; + bool fCreatedViaMinimalSave = false; + bool fOpenedViaDataRecovery = false; + bool fOpenedViaSafeLoad = false; BookExt_Conditional11 grbit1; BookExt_Conditional12 grbit2; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BoolErr.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BoolErr.cpp index e5580069fd..040c2bc462 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BoolErr.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BoolErr.cpp @@ -56,6 +56,11 @@ void BoolErr::readFields(CFRecord& record) record >> cell >> bes; } +void BoolErr::writeFields(CFRecord& record) +{ + record << cell << bes; +} + const CellRef BoolErr::getLocation() const { return cell.getLocation(); diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BoolErr.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BoolErr.h index 9f78fb9669..2b2165deec 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BoolErr.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BoolErr.h @@ -53,6 +53,7 @@ public: void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeBoolErr; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BopPop.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BopPop.cpp index a74064ec61..350162d256 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BopPop.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BopPop.cpp @@ -60,6 +60,13 @@ void BopPop::readFields(CFRecord& record) fHasShadow = GETBIT(flags, 0); } +void BopPop::writeFields(CFRecord& record) +{ + unsigned short flags = 0; + SETBIT(flags, 0, fHasShadow); + record << pst << fAutoSplit << split << iSplitPos << pcSplitPercent << pcPie2Size << pcGap << numSplitValue << flags; +} + int BopPop::serialize(std::wostream & _stream) { CP_XML_WRITER(_stream) diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BopPop.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BopPop.h index 7aff1b8dc8..3c21baf154 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BopPop.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BopPop.h @@ -48,22 +48,23 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeBopPop; int serialize(std::wostream & _stream); //----------------------------- - unsigned char pst; - unsigned char fAutoSplit; - _UINT16 split; - _INT16 iSplitPos; - _INT16 pcSplitPercent; - _INT16 pcPie2Size; - _INT16 pcGap; - Xnum numSplitValue; + unsigned char pst = 0; + unsigned char fAutoSplit = 0; + _UINT16 split = 0; + _INT16 iSplitPos = 0; + _INT16 pcSplitPercent = 0; + _INT16 pcPie2Size = 0; + _INT16 pcGap = 0; + Xnum numSplitValue; - bool fHasShadow; + bool fHasShadow = false; BaseObjectPtr m_Custom; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BopPopCustom.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BopPopCustom.cpp index 5bc48ecba0..c450021d8e 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BopPopCustom.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BopPopCustom.cpp @@ -56,6 +56,11 @@ void BopPopCustom::readFields(CFRecord& record) record >> rggrbit; } +void BopPopCustom::writeFields(CFRecord& record) +{ + record << rggrbit; +} + BiffStructurePtr BopPopCustomPiesIndices::clone() { return BiffStructurePtr(new BopPopCustomPiesIndices(*this)); @@ -64,7 +69,6 @@ BiffStructurePtr BopPopCustomPiesIndices::clone() void BopPopCustomPiesIndices::load(CFRecord& record) { - unsigned short cxi; record >> cxi; const unsigned short padding = 8 - cxi % 8; @@ -87,6 +91,45 @@ void BopPopCustomPiesIndices::load(CFRecord& record) } } +void BopPopCustomPiesIndices::save(CFRecord& record) +{ + // 1. Сохраняем количество точек + record << cxi; + + const unsigned short padding = (8 - (cxi % 8)) % 8; + const unsigned short total_bits = padding + cxi + 1; // +1 = final flag bit + const unsigned short total_bytes = (total_bits + 7) / 8; + + // 2. Создаем массив нулевых байтов + std::vector rggrbit(total_bytes, 0); + + // 3. Устанавливаем биты точек + for (unsigned short idx : pie_indices) + { + if (idx >= cxi) + continue; // игнорируем некорректные индексы + + unsigned short bit_pos = padding + idx; + unsigned short byte_index = bit_pos / 8; + unsigned short bit_in_byte = 7 - (bit_pos % 8); // MSB-first + + rggrbit[byte_index] |= (1 << bit_in_byte); + } + + // 4. Устанавливаем финальный бит (последний бит последнего байта) + bool no_secondary = pie_indices.empty(); + if (no_secondary) + { + rggrbit.back() |= 0x01; // LSB = 1 + } + + // 5. Пишем все байты в поток + for (unsigned char b : rggrbit) + { + record << b; + } +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BopPopCustom.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BopPopCustom.h index 7310660088..f9fa92d055 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BopPopCustom.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BopPopCustom.h @@ -43,10 +43,13 @@ public: BiffStructurePtr clone(); virtual void load(CFRecord& record); + virtual void save(CFRecord& record); static const ElementType type = typeBopPopCustomPiesIndices; //----------------------------- std::vector pie_indices; + unsigned short cxi = 0; + }; @@ -64,6 +67,7 @@ public: void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeBopPopCustom; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BottomMargin.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BottomMargin.cpp index 7529ffc28d..65627b63d8 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BottomMargin.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BottomMargin.cpp @@ -37,6 +37,7 @@ namespace XLS BottomMargin::BottomMargin() { + num.data.value = 0.75; } @@ -55,5 +56,10 @@ void BottomMargin::readFields(CFRecord& record) record >> num; } +void BottomMargin::writeFields(CFRecord& record) +{ + record << num; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BottomMargin.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BottomMargin.h index fe1f871664..e4e7b97135 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BottomMargin.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BottomMargin.h @@ -49,6 +49,7 @@ public: void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeBottomMargin; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BoundSheet8.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BoundSheet8.cpp index c8758cad09..b07d8e934c 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BoundSheet8.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BoundSheet8.cpp @@ -98,5 +98,25 @@ void BoundSheet8::readFields(CFRecord& record) dt = GETBITS(flags, 8, 15); } +void BoundSheet8::writeFields(CFRecord& record) +{ + record << lbPlyPos; + unsigned short flags = 0; + if( hsState == L"hidden") + { + SETBITS(flags, 0, 1, 1) + } + else if( hsState == L"veryHidden") + { + SETBITS(flags, 0, 1, 2) + } + SETBITS(flags, 8, 15, dt) + record << flags; + + ShortXLUnicodeString stName; + stName = name_; + record << stName; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BoundSheet8.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BoundSheet8.h index 44a7458b8a..d7fe0886de 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BoundSheet8.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BoundSheet8.h @@ -50,14 +50,15 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeBoundSheet8; - _UINT32 lbPlyPos; - std::wstring hsState; - unsigned char dt; + _UINT32 lbPlyPos = 0; + std::wstring hsState = L"visible"; + unsigned char dt = 0; //----------------------------- - std::wstring name_; + std::wstring name_ = L"Sheet1"; }; } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BuiltInFnGroupCount.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BuiltInFnGroupCount.cpp index 96bc706b31..412f808115 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BuiltInFnGroupCount.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BuiltInFnGroupCount.cpp @@ -55,5 +55,10 @@ void BuiltInFnGroupCount::readFields(CFRecord& record) record >> count; } +void BuiltInFnGroupCount::writeFields(CFRecord& record) +{ + record << count; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BuiltInFnGroupCount.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BuiltInFnGroupCount.h index cabd39fa41..3347290bdc 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BuiltInFnGroupCount.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BuiltInFnGroupCount.h @@ -50,12 +50,13 @@ public: void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeBuiltInFnGroupCount; //----------------------------- - _UINT16 count; + _UINT16 count = 0; }; } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CF.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CF.cpp index 4350f27591..3fdce0d056 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CF.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CF.cpp @@ -79,6 +79,29 @@ void CF::readFields(CFRecord& record) dxfId_ = global_info_->RegistrDxfn(strm.str()); } +void CF::writeFields(CFRecord& record) +{ + record << ct << cp; + record.reserveNunBytes(4); + auto ccePos = record.getRdPtr(); + record << rgbdxf; + auto rgce1pos = record.getRdPtr(); + auto dxfSize = rgce1pos - ccePos; + rgce1.save(record); + unsigned short rgceSize = record.getRdPtr() - rgce1pos; + record.RollRdPtrBack(rgceSize + dxfSize + 4); + record << rgceSize; + record.skipNunBytes(2 + rgceSize + dxfSize); + + auto rgce2pos = record.getRdPtr(); + rgce2.save(record); + rgceSize = record.getRdPtr() - rgce2pos; + record.RollRdPtrBack((record.getRdPtr() - ccePos) + 2); + record << rgceSize; + record.skipNunBytes((rgce2pos - ccePos) + rgceSize); + +} + int CF::serialize(std::wostream & stream) { if (ct != 1 && ct != 2 && ct !=6) diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CF.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CF.h index 777ca01f57..d299843ac2 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CF.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CF.h @@ -49,6 +49,7 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeCF; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CF12.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CF12.cpp index aba57cf39a..5ed16aabb1 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CF12.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CF12.cpp @@ -82,7 +82,7 @@ void CF12::readFields(CFRecord& record) record >> flags; fStopIfTrue = GETBIT(flags, 1); - record >> ipriority >> icfTemplate; + record >> ipriority >> icfTemplate; unsigned char cbTemplateParm; @@ -117,6 +117,42 @@ void CF12::readFields(CFRecord& record) dxfId_ = global_info->RegistrDxfn(strm.str()); } +void CF12::writeFields(CFRecord& record) +{ frtRefHeader.rt = 0x087A; + record << frtRefHeader; + record << ct << cp; + + record.reserveNunBytes(4); + auto ccePos = record.getRdPtr(); + record << dxf; + auto rgce1pos = record.getRdPtr(); + auto dxfSize = rgce1pos - ccePos; + rgce1.save(record); + unsigned short rgceSize = record.getRdPtr() - rgce1pos; + record.RollRdPtrBack(rgceSize + dxfSize + 4); + record << rgceSize; + record.skipNunBytes(2 + rgceSize + dxfSize); + + auto rgce2pos = record.getRdPtr(); + rgce2.save(record); + rgceSize = record.getRdPtr() - rgce2pos; + record.RollRdPtrBack((record.getRdPtr() - ccePos) + 2); + record << rgceSize; + record.skipNunBytes((rgce2pos - ccePos) + rgceSize); + + fmlaActive.save(record); + + unsigned char flags = 0; + + SETBIT(flags, 1, fStopIfTrue); + record << flags; + BYTE cbTemplateParm = 16; + record << ipriority << icfTemplate << cbTemplateParm; + record << rgbTemplateParms; + if(rgbCT != nullptr) + rgbCT->save(record); + +} int CF12::serialize(std::wostream & stream) { CFEx * cfEx = dynamic_cast(m_CFEx.get()); diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CF12.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CF12.h index b6bd6250a9..83d9c1d378 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CF12.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CF12.h @@ -54,6 +54,7 @@ public: void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeCF12; @@ -61,8 +62,8 @@ public: FrtRefHeader frtRefHeader; - unsigned char ct; - unsigned char cp; + unsigned char ct = 0; + unsigned char cp = 0; DXFN12 dxf; @@ -70,16 +71,16 @@ public: CFParsedFormulaNoCCE rgce2; CFParsedFormula fmlaActive; - _UINT16 ipriority; - _UINT16 icfTemplate; + _UINT16 ipriority = 0; + _UINT16 icfTemplate = 0; CFExTemplateParams rgbTemplateParms; BiffStructurePtr rgbCT; //----------------------------- - bool fStopIfTrue; - int ipriority_; - int dxfId_; + bool fStopIfTrue = 0; + int ipriority_ = 0; + int dxfId_ = 0; BaseObjectPtr m_CFEx; BaseObjectPtr m_CF12_2; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CFEx.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CFEx.cpp index a6208b6c8b..b26d3a8161 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CFEx.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CFEx.cpp @@ -68,5 +68,14 @@ void CFEx::readFields(CFRecord& record) } } +void CFEx::writeFields(CFRecord& record) +{ + record << frtRefHeaderU << fIsCF12 << nID; + if(!fIsCF12) + { + record << content; + } +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CFEx.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CFEx.h index 19ea15863e..e8b0105d53 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CFEx.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CFEx.h @@ -49,6 +49,7 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeCFEx; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CRN.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CRN.cpp index 69be22a39c..7dc48d7723 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CRN.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CRN.cpp @@ -64,5 +64,13 @@ void CRN::readFields(CFRecord& record) } } +void CRN::writeFields(CFRecord& record) +{ + record << colLast << colFirst << row; + for(auto i : crnOper) + if(i != nullptr) + i->save(record); +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CRN.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CRN.h index c5857d08be..2deb5bcd10 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CRN.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CRN.h @@ -48,12 +48,13 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeCRN; - unsigned char colLast; - unsigned char colFirst; - _UINT16 row; + unsigned char colLast = 0; + unsigned char colFirst = 0; + _UINT16 row = 0; BiffStructurePtrVector crnOper; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CalcCount.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CalcCount.cpp index bc7b49b090..c7d1a64734 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CalcCount.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CalcCount.cpp @@ -54,6 +54,10 @@ void CalcCount::readFields(CFRecord& record) { record >> cIter; } +void CalcCount::writeFields(CFRecord& record) +{ + record << cIter; +} } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CalcCount.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CalcCount.h index d359819248..a4155e0ad8 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CalcCount.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CalcCount.h @@ -47,11 +47,12 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeCalcCount; //----------------------------- - _INT16 cIter; + _INT16 cIter = 100; }; } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CalcDelta.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CalcDelta.cpp index a58af83b91..787349659a 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CalcDelta.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CalcDelta.cpp @@ -37,6 +37,7 @@ namespace XLS CalcDelta::CalcDelta() { + numDelta.data.value = 0.001; } @@ -56,5 +57,10 @@ void CalcDelta::readFields(CFRecord& record) record >> numDelta; } +void CalcDelta::writeFields(CFRecord& record) +{ + record << numDelta; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CalcDelta.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CalcDelta.h index 41adabaa64..8913048df1 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CalcDelta.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CalcDelta.h @@ -49,11 +49,12 @@ public: void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeCalcDelta; //----------------------------- - Xnum numDelta; + Xnum numDelta; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CalcIter.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CalcIter.cpp index 076facf03b..9dfb419a7f 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CalcIter.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CalcIter.cpp @@ -55,6 +55,10 @@ void CalcIter::readFields(CFRecord& record) { record >> vfIter; } +void CalcIter::writeFields(CFRecord& record) +{ + record << vfIter; +} } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CalcIter.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CalcIter.h index a923fd4d8c..13607f51c1 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CalcIter.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CalcIter.h @@ -48,13 +48,13 @@ public: BaseObjectPtr clone(); - + void writeFields(CFRecord& record); void readFields(CFRecord& record); static const ElementType type = typeCalcIter; //----------------------------- - Boolean vfIter; + Boolean vfIter = 0; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CalcMode.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CalcMode.cpp index 1d19d925ba..1c2bde7fa2 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CalcMode.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CalcMode.cpp @@ -55,5 +55,10 @@ void CalcMode::readFields(CFRecord& record) record >> nAutoRecalc; } +void CalcMode::writeFields(CFRecord& record) +{ + record << nAutoRecalc; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CalcMode.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CalcMode.h index 52b3f07599..f1cd76af2b 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CalcMode.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CalcMode.h @@ -46,10 +46,11 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeCalcMode; - unsigned short nAutoRecalc; + unsigned short nAutoRecalc = 1; }; } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CalcPrecision.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CalcPrecision.cpp index cc421cfe5e..6815e2c4bd 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CalcPrecision.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CalcPrecision.cpp @@ -56,5 +56,10 @@ void CalcPrecision::readFields(CFRecord& record) record >> fFullPrec; } +void CalcPrecision::writeFields(CFRecord& record) +{ + record << fFullPrec; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CalcPrecision.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CalcPrecision.h index fa703ef53f..01d7f2125d 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CalcPrecision.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CalcPrecision.h @@ -46,11 +46,12 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeCalcPrecision; //----------------------------- - Boolean fFullPrec; + Boolean fFullPrec = true; }; } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CalcRefMode.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CalcRefMode.cpp index b81ca78bc1..64d6f34f25 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CalcRefMode.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CalcRefMode.cpp @@ -55,5 +55,10 @@ void CalcRefMode::readFields(CFRecord& record) record >> fRef; } +void CalcRefMode::writeFields(CFRecord& record) +{ + record << fRef; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CalcRefMode.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CalcRefMode.h index 8a2d8fd988..dfda1c175f 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CalcRefMode.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CalcRefMode.h @@ -47,11 +47,12 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeCalcRefMode; //----------------------------- - Boolean fRef; + Boolean fRef = 1; }; } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CalcSaveRecalc.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CalcSaveRecalc.cpp index b27229626c..8d8794ad4f 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CalcSaveRecalc.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CalcSaveRecalc.cpp @@ -56,5 +56,10 @@ void CalcSaveRecalc::readFields(CFRecord& record) record >> fSaveRecalc; } +void CalcSaveRecalc::writeFields(CFRecord& record) +{ + record << fSaveRecalc; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CalcSaveRecalc.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CalcSaveRecalc.h index 36295d9945..ad0afa7dc9 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CalcSaveRecalc.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CalcSaveRecalc.h @@ -46,11 +46,12 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeCalcSaveRecalc; //----------------------------- - Boolean fSaveRecalc; + Boolean fSaveRecalc = true; }; } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CatLab.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CatLab.cpp index 7292956439..909a2c2746 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CatLab.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CatLab.cpp @@ -60,5 +60,14 @@ void CatLab::readFields(CFRecord& record) record.skipNunBytes(2); // reserved } +void CatLab::writeFields(CFRecord& record) +{ + FrtHeaderOld frtHeaderOld(rt_CatLab); + unsigned short flags = 0; + SETBIT(flags, 0, cAutoCatLabelReal); + record << frtHeaderOld << wOffset << at << flags; + record.reserveNunBytes(2); +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CatLab.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CatLab.h index d5f2a4e0c8..0fb9368a7a 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CatLab.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CatLab.h @@ -50,13 +50,14 @@ public: void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeCatLab; //----------------------------- - _UINT16 wOffset; - _UINT16 at; - bool cAutoCatLabelReal; + _UINT16 wOffset = 0; + _UINT16 at = 0; + bool cAutoCatLabelReal = false; }; } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CatSerRange.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CatSerRange.cpp index 2356180f9d..71f5385ba0 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CatSerRange.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CatSerRange.cpp @@ -60,5 +60,14 @@ void CatSerRange::readFields(CFRecord& record) fReversed = GETBIT(flags, 2); } +void CatSerRange::writeFields(CFRecord& record) +{ + unsigned short flags = 0; + SETBIT(flags, 0, fBetween) + SETBIT(flags, 1, fMaxCross) + SETBIT(flags, 2, fReversed) + record << catCross << catLabel << catMark << flags; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CatSerRange.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CatSerRange.h index 874bdb6260..194e3add28 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CatSerRange.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CatSerRange.h @@ -50,17 +50,18 @@ public: void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeCatSerRange; //----------------------------- - _INT16 catCross; - _INT16 catLabel; - _INT16 catMark; + _INT16 catCross = 0; + _INT16 catLabel = 0; + _INT16 catMark = 0; - bool fBetween; - bool fMaxCross; - bool fReversed; + bool fBetween = false; + bool fMaxCross = false; + bool fReversed = false; }; } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Chart.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Chart.cpp index 591dab6465..909b15c7be 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Chart.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Chart.cpp @@ -62,5 +62,10 @@ void Chart::readFields(CFRecord& record) } +void Chart::writeFields(CFRecord& record) +{ + record << x << y << dx << dy; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Chart.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Chart.h index c8148fece2..804b8006ff 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Chart.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Chart.h @@ -51,6 +51,7 @@ public: void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeChart; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Chart3DBarShape.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Chart3DBarShape.cpp index aecbf19e58..6d3bda8b25 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Chart3DBarShape.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Chart3DBarShape.cpp @@ -55,6 +55,11 @@ void Chart3DBarShape::readFields(CFRecord& record) record >> riser >> taper; } +void Chart3DBarShape::writeFields(CFRecord& record) +{ + record << riser << taper; +} + int Chart3DBarShape::serialize(std::wostream & _stream) { CP_XML_WRITER(_stream) diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Chart3DBarShape.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Chart3DBarShape.h index 0b00945abc..d19ac1ec62 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Chart3DBarShape.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Chart3DBarShape.h @@ -50,14 +50,15 @@ public: void readFields(CFRecord& record); + void writeFields(CFRecord& record); int serialize(std::wostream & _stream); static const ElementType type = typeChart3DBarShape; //----------------------------- - unsigned char riser; - unsigned char taper; + unsigned char riser = 0; + unsigned char taper = 0; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Chart3d.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Chart3d.cpp index 4512589660..7939bf3d17 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Chart3d.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Chart3d.cpp @@ -67,5 +67,18 @@ void Chart3d::readFields(CFRecord& record) } } +void Chart3d::writeFields(CFRecord& record) +{ + unsigned short flags = 0; + SETBIT(flags, 0, fPerspective) + SETBIT(flags, 1, fCluster) + SETBIT(flags, 2, f3DScaling) + SETBIT(flags, 4, fNotPieChart) + SETBIT(flags, 5, fWalls2D) + if(fNotPieChart) + pcHeightPie = pcHeight3D; + record << anRot << anElev << pcDist << pcHeightPie << pcDepth << pcGap << flags; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Chart3d.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Chart3d.h index 090ae37c24..f3bed5b0b4 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Chart3d.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Chart3d.h @@ -49,23 +49,24 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeChart3d; //----------------------------- - _INT16 anRot; - _INT16 anElev; - _INT16 pcDist; - _UINT16 pcHeightPie; - short pcHeight3D; - _INT16 pcDepth; - _UINT16 pcGap; + _INT16 anRot = 0; + _INT16 anElev = 0; + _INT16 pcDist = 0; + _UINT16 pcHeightPie = 0; + short pcHeight3D = 0; + _INT16 pcDepth = 0; + _UINT16 pcGap = 0; - bool fPerspective; - bool fCluster; - bool f3DScaling; - bool fNotPieChart; - bool fWalls2D; + bool fPerspective = false; + bool fCluster = false; + bool f3DScaling = false; + bool fNotPieChart = false; + bool fWalls2D = false; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ChartFormat.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ChartFormat.cpp index f49c9a0970..276b156279 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ChartFormat.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ChartFormat.cpp @@ -60,6 +60,14 @@ void ChartFormat::readFields(CFRecord& record) fVaried = GETBIT(flags, 0); } +void ChartFormat::writeFields(CFRecord& record) +{ + record.reserveNunBytes(16); + unsigned short flags = 0; + SETBIT(flags, 0, fVaried); + record << flags << icrt; +} + int ChartFormat::serialize(std::wostream & _stream) { CP_XML_WRITER(_stream) diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ChartFormat.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ChartFormat.h index 7cf2e35028..32c673c04d 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ChartFormat.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ChartFormat.h @@ -50,13 +50,14 @@ public: void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeChartFormat; int serialize(std::wostream & _stream); //----------------------------- - bool fVaried; - _UINT16 icrt; + bool fVaried = false; + _UINT16 icrt = 0; }; } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CodeName.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CodeName.cpp index 571199c840..72f193bd5b 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CodeName.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CodeName.cpp @@ -59,5 +59,12 @@ void CodeName::readFields(CFRecord& record) value = codeName.value(); } +void CodeName::writeFields(CFRecord& record) +{ + XLUnicodeString codeName; + codeName = value; + record << codeName; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CodeName.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CodeName.h index 5fe259b11d..5c959b5d1e 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CodeName.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CodeName.h @@ -48,10 +48,11 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeCodeName; - std::wstring value; + std::wstring value = L""; }; } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CodePage.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CodePage.cpp index d1e4669368..74a25fd032 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CodePage.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CodePage.cpp @@ -55,5 +55,10 @@ void CodePage::readFields(CFRecord& record) record >> cv; } +void CodePage::writeFields(CFRecord& record) +{ + record << cv; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CodePage.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CodePage.h index ec0644bd73..c01e9dd31e 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CodePage.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CodePage.h @@ -50,8 +50,9 @@ public: void readFields(CFRecord& record); + void writeFields(CFRecord& record); //----------------------------- - _UINT16 cv; + _UINT16 cv = 1200; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ColInfo.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ColInfo.h index c7f2629c50..6afc80ecfd 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ColInfo.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ColInfo.h @@ -51,9 +51,9 @@ public: static const ElementType type = typeColInfo; //----------------------------- - _UINT32 colFirst; - _UINT32 colLast; - _UINT32 coldx; + _UINT32 colFirst = 0; + _UINT32 colLast = 0; + _UINT32 coldx = 0; IXFCell ixfe = 0xffff; _UINT32 ixfeXLSB = 0xffffffff; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CondFmt.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CondFmt.cpp index 2fe269081b..36d667b080 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CondFmt.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CondFmt.cpp @@ -61,6 +61,15 @@ void CondFmt::readFields(CFRecord& record) refBound = static_cast(refBound_ref); } +void CondFmt::writeFields(CFRecord& record) +{ + unsigned short flags = 0; + record << ccf << flags; + SETBIT(flags, 0, fToughRecalc); + SETBITS(flags, 1, 15, nID); + Ref8U refBound_ref = refBound; + record << refBound_ref << sqref; +} const CellRef CondFmt::getLocation() const { diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CondFmt.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CondFmt.h index f13a34716c..17ec8cb628 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CondFmt.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CondFmt.h @@ -47,6 +47,7 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeCondFmt; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CondFmt12.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CondFmt12.cpp index 5776d34702..52c12813f0 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CondFmt12.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CondFmt12.cpp @@ -57,6 +57,13 @@ void CondFmt12::readFields(CFRecord& record) record >> mainCF; } +void CondFmt12::writeFields(CFRecord& record) +{ + frtRefHeaderU.rt = 0x0879; + frtRefHeaderU.grbitFrt.fFrtRef = 1; + record << frtRefHeaderU; + record << mainCF; +} const CellRef CondFmt12::getLocation() const { diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CondFmt12.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CondFmt12.h index c0e67b9cf2..bb259c6da5 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CondFmt12.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CondFmt12.h @@ -52,6 +52,7 @@ public: void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeCondFmt12; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Continue.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Continue.cpp index 52f5734f41..70668d5a17 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Continue.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Continue.cpp @@ -78,5 +78,10 @@ void Continue::readFields(CFRecord& record) record.skipNunBytes(m_iDataSize); } +void Continue::writeFields(CFRecord& record) +{ + record.appendRawDataToStatic(reinterpret_cast(m_pData), m_iDataSize); +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Continue.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Continue.h index a6fb08a212..57fe62aeb7 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Continue.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Continue.h @@ -47,11 +47,12 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeContinue; - char* m_pData; - int m_iDataSize; + char* m_pData = NULL; + int m_iDataSize = 0; }; } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ContinueFrt12.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ContinueFrt12.cpp index 3650a5c0f2..e6e052cca4 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ContinueFrt12.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ContinueFrt12.cpp @@ -55,5 +55,13 @@ void ContinueFrt12::readFields(CFRecord& record) { } +void ContinueFrt12::writeFields(CFRecord& record) +{ + frtHeader.rt = rt_ContinueFrt12; + record << frtHeader; + for(auto i: rgb) + record << i; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ContinueFrt12.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ContinueFrt12.h index e7dcc5df33..051c57e527 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ContinueFrt12.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ContinueFrt12.h @@ -32,7 +32,7 @@ #pragma once #include "BiffRecord.h" - +#include "../Biff_structures/FrtRefHeader.h" namespace XLS { @@ -50,7 +50,10 @@ public: void readFields(CFRecord& record); + void writeFields(CFRecord& record); + FrtRefHeader frtHeader; + std::vector rgb; static const ElementType type = typeContinueFrt12; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Country.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Country.cpp index 0c601bbf4a..34f2b5164f 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Country.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Country.cpp @@ -56,5 +56,10 @@ void Country::readFields(CFRecord& record) record >> iCountryDef >> iCountryWinIni; } +void Country::writeFields(CFRecord& record) +{ + record << iCountryDef << iCountryWinIni; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Country.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Country.h index ea5571b759..9fd323ac3e 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Country.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Country.h @@ -50,11 +50,12 @@ public: void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeCountry; - _UINT16 iCountryDef; - _UINT16 iCountryWinIni; + _UINT16 iCountryDef = 7; + _UINT16 iCountryWinIni = 7; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CrtLayout12.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CrtLayout12.cpp index 67e41a949c..7ea85a88e5 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CrtLayout12.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CrtLayout12.cpp @@ -62,6 +62,16 @@ void CrtLayout12::readFields(CFRecord& record) record.skipNunBytes(2); // reserved2 } +void CrtLayout12::writeFields(CFRecord& record) +{ + FrtHeader frtHeader(rt_CrtLayout12); + record << frtHeader; + unsigned short flags = 0; + SETBITS(flags, 1, 4, autolayouttype); + record << dwCheckSum << flags << wXMode << wYMode << wWidthMode << wHeightMode << x << y << dx << dy; + record.reserveNunBytes(2); +} + int CrtLayout12::serialize (std::wostream & _stream) { CP_XML_WRITER(_stream) diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CrtLayout12.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CrtLayout12.h index c40fbd5e2f..513cfbd61c 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CrtLayout12.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CrtLayout12.h @@ -47,18 +47,19 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); int serialize (std::wostream & _stream); static const ElementType type = typeCrtLayout12; //----------------------------- - _UINT32 dwCheckSum; - unsigned char autolayouttype; + _UINT32 dwCheckSum = 0; + unsigned char autolayouttype = 0; - CrtLayout12Mode wXMode; - CrtLayout12Mode wYMode; - CrtLayout12Mode wWidthMode; - CrtLayout12Mode wHeightMode; + CrtLayout12Mode wXMode = 0; + CrtLayout12Mode wYMode = 0; + CrtLayout12Mode wWidthMode = 0; + CrtLayout12Mode wHeightMode = 0; Xnum x; Xnum y; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CrtLayout12A.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CrtLayout12A.cpp index 5613d32b34..3c81967902 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CrtLayout12A.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CrtLayout12A.cpp @@ -62,6 +62,19 @@ void CrtLayout12A::readFields(CFRecord& record) record >> x >> y >> dx >> dy >> reserved; } +void CrtLayout12A::writeFields(CFRecord& record) +{ + frtheader.rt = rt_CrtLayout12A; + unsigned short flags = 0; + SETBIT(flags, 0, fLayoutTargetInner) + + record << frtheader << dwCheckSum << flags; + record << xTL << yTL << xBR << yBR; + record << wXMode << wYMode << wWidthMode << wHeightMode; + record << x << y << dx << dy; + record.reserveNunBytes(2); +} + int CrtLayout12A::serialize (std::wostream & _stream) { CP_XML_WRITER(_stream) diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CrtLayout12A.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CrtLayout12A.h index 4bad5887cf..5acf1dde6e 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CrtLayout12A.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CrtLayout12A.h @@ -48,25 +48,26 @@ public: BaseObjectPtr clone(); void readFields (CFRecord& record); + void writeFields (CFRecord& record); int serialize (std::wostream & _stream); static const ElementType type = typeCrtLayout12A; FrtHeader frtheader; - _UINT32 dwCheckSum; + _UINT32 dwCheckSum = 0; - bool fLayoutTargetInner; + bool fLayoutTargetInner = false; - short xTL; - short yTL; - short xBR; - short yBR; + short xTL = 0; + short yTL = 0; + short xBR = 0; + short yBR = 0; - CrtLayout12Mode wXMode; - CrtLayout12Mode wYMode; + CrtLayout12Mode wXMode = 0; + CrtLayout12Mode wYMode = 0; - CrtLayout12Mode wWidthMode; - CrtLayout12Mode wHeightMode; + CrtLayout12Mode wWidthMode = 0; + CrtLayout12Mode wHeightMode = 0; Xnum x; Xnum y; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CrtLine.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CrtLine.cpp index 2d5aa0c10d..7b6c8f0559 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CrtLine.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CrtLine.cpp @@ -56,6 +56,11 @@ void CrtLine::readFields(CFRecord& record) record >> id; } +void CrtLine::writeFields(CFRecord& record) +{ + record << id; +} + int CrtLine::serialize(std::wostream & _stream) { std::wstring sNode; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CrtLine.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CrtLine.h index 219ec6da63..4eaf553c9d 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CrtLine.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CrtLine.h @@ -50,12 +50,13 @@ public: void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeCrtLine; int serialize(std::wostream & _stream); - _UINT16 id; + _UINT16 id = 0; BaseObjectPtr m_LineFormat; //----------------------------- diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CrtLink.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CrtLink.cpp index df334086e4..565396d717 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CrtLink.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CrtLink.cpp @@ -55,5 +55,10 @@ void CrtLink::readFields(CFRecord& record) record.skipNunBytes(10); //unused } +void CrtLink::writeFields(CFRecord& record) +{ + record.reserveNunBytes(10); +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CrtLink.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CrtLink.h index d4eb3ceaa7..9a7a0936ce 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CrtLink.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/CrtLink.h @@ -50,6 +50,7 @@ public: void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeCrtLink; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DBCell.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DBCell.cpp index 83cd14faf5..5a32bd50d8 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DBCell.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DBCell.cpp @@ -60,6 +60,14 @@ void DBCell::readFields(CFRecord& record) rgdb.push_back(element); } } +void DBCell::writeFields(CFRecord& record) +{ + record << dbRtrw; + for(auto i : rgdb) + { + record << i; + } +} } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DBCell.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DBCell.h index 41b276cf9a..c3fa5cc947 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DBCell.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DBCell.h @@ -50,10 +50,11 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeDBCell; //----------------------------- - _UINT32 dbRtrw; + _UINT32 dbRtrw = 0; BiffStructurePtrVector rgdb; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DBQueryExt.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DBQueryExt.cpp index 3cc23091be..11675787be 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DBQueryExt.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DBQueryExt.cpp @@ -103,5 +103,36 @@ void DBQueryExt::readFields(CFRecord& record) } } +void DBQueryExt::writeFields(CFRecord& record) +{ + unsigned short flags1 = 0, flags2 = 0; + frtHeaderOld.rt = rt_DBQueryExt; + record << frtHeaderOld << dbt << flags1; + + SETBIT(flags1, 0, fMaintain) + SETBIT(flags1, 1, fNewQuery) + SETBIT(flags1, 2, fImportXmlSource) + SETBIT(flags1, 3, fSPListSrc) + SETBIT(flags1, 4, fSPListReinitCache) + SETBIT(flags1, 7, fSrcIsXml) + + record << frtHeaderOld << dbt << flags1; + if(dbt == 4 || dbt == 5 || dbt == 7) + { + grbitDbt->save(record); + } + else + record.reserveNunBytes(2); + + SETBIT(flags2, 0, fTxtWiz) + SETBIT(flags2, 1, fTableNames) + record << flags2 << bVerDbqueryEdit << bVerDbqueryRefreshed << bVerDbqueryRefreshableMin; + record.reserveNunBytes(3); + record << coledb << cstFuture << wRefreshInterval << wHtmlFmt << cwParamFlags; + for(auto i : rgPbt) + i.save(record); + record.reserveNunBytes(cstFuture); +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DBQueryExt.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DBQueryExt.h index cb83603845..36443d8745 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DBQueryExt.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DBQueryExt.h @@ -49,27 +49,28 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeDBQueryExt; FrtHeaderOld frtHeaderOld; - unsigned short dbt; //enum DataSourceType - bool fMaintain; - bool fNewQuery; - bool fImportXmlSource; - bool fSPListSrc; - bool fSPListReinitCache; - bool fSrcIsXml; + unsigned short dbt = 0; //enum DataSourceType + bool fMaintain = false; + bool fNewQuery = false; + bool fImportXmlSource = false; + bool fSPListSrc = false; + bool fSPListReinitCache = false; + bool fSrcIsXml = false; BiffStructurePtr grbitDbt; - bool fTxtWiz; + bool fTxtWiz = false; bool fTableNames; - unsigned char bVerDbqueryEdit; //DataFunctionalityLevel - unsigned char bVerDbqueryRefreshed; - unsigned char bVerDbqueryRefreshableMin; - unsigned short coledb; - unsigned short cstFuture; - unsigned short wRefreshInterval; - unsigned short wHtmlFmt; + unsigned char bVerDbqueryEdit = 0; //DataFunctionalityLevel + unsigned char bVerDbqueryRefreshed = 0; + unsigned char bVerDbqueryRefreshableMin = 0; + unsigned short coledb = 0; + unsigned short cstFuture = 0; + unsigned short wRefreshInterval = 0; + unsigned short wHtmlFmt = 0; unsigned short cwParamFlags; std::vector rgPbt; std::string rgbFutureBytes; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DCon.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DCon.cpp index 64da8f7f93..f2b0f8d125 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DCon.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DCon.cpp @@ -55,5 +55,10 @@ void DCon::readFields(CFRecord& record) record >> iiftab >> fLeftCat >> fTopCat >> fLinkConsole; } +void DCon::writeFields(CFRecord& record) +{ + record << iiftab << fLeftCat << fTopCat << fLinkConsole; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DCon.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DCon.h index cfc6fa6008..a1c5952e10 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DCon.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DCon.h @@ -48,13 +48,14 @@ public: void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeDCon; //----------------------------- - unsigned short iiftab; - unsigned short fLeftCat; - unsigned short fTopCat; - unsigned short fLinkConsole; + unsigned short iiftab = 0; + unsigned short fLeftCat = 0; + unsigned short fTopCat = 0; + unsigned short fLinkConsole = 0; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DConBin.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DConBin.cpp index fa34c8f29d..32d4dd65ac 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DConBin.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DConBin.cpp @@ -67,5 +67,17 @@ void DConBin::readFields(CFRecord& record) record.skipNunBytes(record.getDataSize() - record.getRdPtr()); } +void DConBin::writeFields(CFRecord& record) +{ + record << nBuiltin; + record.reserveNunBytes(3); + record << cchFile; + if (cchFile > 0 && cchFile < 0xffff) + { + record << stFile; + record.reserveNunBytes(2); + } +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DConBin.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DConBin.h index ebba41f781..24729a0dd5 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DConBin.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DConBin.h @@ -48,11 +48,12 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeDConBin; - unsigned char nBuiltin; - unsigned short cchFile; + unsigned char nBuiltin = 0; + unsigned short cchFile = 0; XLUnicodeStringNoCch stFile; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DConName.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DConName.cpp index d355082efa..bf2522a1f3 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DConName.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DConName.cpp @@ -62,5 +62,16 @@ void DConName::readFields(CFRecord& record) record.skipNunBytes(record.getDataSize() - record.getRdPtr()); } +void DConName::writeFields(CFRecord& record) +{ + cchFile = stFile.getSize(); + record << stName << cchFile; + if (cchFile > 0 && cchFile < 0xffff) + { + record << stFile; + record.reserveNunBytes(2); + } +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DConName.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DConName.h index 899b067d5e..74d0a94d6a 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DConName.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DConName.h @@ -48,11 +48,12 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeDConName; XLUnicodeString stName; - unsigned short cchFile; + unsigned short cchFile = 0; XLUnicodeStringNoCch stFile; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DConRef.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DConRef.cpp index 919650d79b..7786e57f64 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DConRef.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DConRef.cpp @@ -118,6 +118,16 @@ void DConRef::readFields(CFRecord& record) record.skipNunBytes(unused); } +void DConRef::writeFields(CFRecord& record) +{ + record << ref << cchFile; + if (cchFile > 0 && cchFile < 0xffff) + { + record << stFile; + record.reserveNunBytes(2); + } +} + void DConRef::check_external() { bool bFound = false; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DConRef.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DConRef.h index 3361dbef13..a1f8825c7f 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DConRef.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DConRef.h @@ -50,6 +50,7 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeDConRef; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DConn.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DConn.cpp index 1b96154d4f..68536851d2 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DConn.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DConn.cpp @@ -158,5 +158,86 @@ void DConn::readFields(CFRecord& record) record.skipNunBytes(skip); } +void DConn::writeFields(CFRecord& record) +{ + frtHeaderOld.rt = rt_DConn; + record << frtHeaderOld << dbt; + + { + unsigned short flags1 = 0; + SETBIT(flags1, 0, fSavePwd) + SETBIT(flags1, 1, fTablesOnlyHtml) + SETBIT(flags1, 2, fTableNames) + SETBIT(flags1, 3, fDeleted) + SETBIT(flags1, 4, fStandAlone) + SETBIT(flags1, 5, fAlwaysUseConnectionFile) + SETBIT(flags1, 6, fBackgroundQuery) + SETBIT(flags1, 7, fRefreshOnLoad) + SETBIT(flags1, 8, fSaveData) + record << flags1 << cParams; + } + record.reserveNunBytes(2); + { + unsigned short flags1 = 0; + SETBIT(flags1, 0, fMaintain) + SETBIT(flags1, 1, fNewQuery) + SETBIT(flags1, 2, fImportXmlSource) + SETBIT(flags1, 3, fSPListSrc) + SETBIT(flags1, 4, fSPListReinitCache) + SETBIT(flags1, 7, fSrcIsXml) + record << flags1; + } + + if(grbitDbt != nullptr && (dbt== 4 || dbt == 5 || dbt == 7)) + record << *grbitDbt; + else + record.reserveNunBytes(2); + record << bVerDbqueryEdit << bVerDbqueryRefreshed << bVerDbqueryRefreshableMin << wRefreshInterval << wHtmlFmt << rcc << credMethod; + record.reserveNunBytes(1); + if (dbt == 5) + { + record << rgchSourceDataFile; + } + record << rgchSourceConnectionFile << rgchConnectionName << rgchConnectionDesc; + if (dbt == 1 || dbt == 5) + { + record << rgchSSOApplicationID; + } + if (fTableNames) + { + record << tableNames; + } + if(fStandAlone != 0) + { + for(auto i : params) + { + i.save(record); + } + } + if(dbt == 1 || dbt == 4 || dbt == 5 || dbt == 6) + { + if (connection) + { + connection->save(record); + } + } + if (dbt == 1 || dbt == 5) + { + record << rgbSQL; + } + + if (dbt == 1)//7183958.xls + { + record << rgbSQLSav; + } + + if (dbt == 4 ) + { + record << rgbEditWebPage; + } + + record << id; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DConn.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DConn.h index 4e9a4f9c54..b8df0dccdf 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DConn.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DConn.h @@ -51,36 +51,37 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeDConn; FrtHeaderOld frtHeaderOld; - unsigned short dbt; - bool fSavePwd; - bool fTablesOnlyHtml; - bool fTableNames; - bool fDeleted; - bool fStandAlone; - bool fAlwaysUseConnectionFile; - bool fBackgroundQuery; - bool fRefreshOnLoad; - bool fSaveData; - unsigned short cParams; - bool fMaintain; - bool fNewQuery; - bool fImportXmlSource; - bool fSPListSrc; - bool fSPListReinitCache; - bool fSrcIsXml; + unsigned short dbt = 0; + bool fSavePwd = false; + bool fTablesOnlyHtml = false; + bool fTableNames = false; + bool fDeleted = false; + bool fStandAlone = false; + bool fAlwaysUseConnectionFile = false; + bool fBackgroundQuery = false; + bool fRefreshOnLoad = false; + bool fSaveData = false; + unsigned short cParams = 0; + bool fMaintain = false; + bool fNewQuery = false; + bool fImportXmlSource = false; + bool fSPListSrc = false; + bool fSPListReinitCache = false; + bool fSrcIsXml = false; BiffStructurePtr grbitDbt; - unsigned char bVerDbqueryEdit; - unsigned char bVerDbqueryRefreshed; - unsigned char bVerDbqueryRefreshableMin; - unsigned short wRefreshInterval; - unsigned short wHtmlFmt; - _UINT32 rcc; - unsigned char credMethod; + unsigned char bVerDbqueryEdit = 0; + unsigned char bVerDbqueryRefreshed = 0; + unsigned char bVerDbqueryRefreshableMin = 0; + unsigned short wRefreshInterval = 0; + unsigned short wHtmlFmt = 0; + _UINT32 rcc = 0; + unsigned char credMethod = 0; XLUnicodeStringSegmented rgchSourceDataFile; XLUnicodeStringSegmented rgchSourceConnectionFile; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DSF.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DSF.cpp index 5e6bf36bac..89577fc0e7 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DSF.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DSF.cpp @@ -56,5 +56,10 @@ void DSF::readFields(CFRecord& record) record.skipNunBytes(2); // reserved } +void DSF::writeFields(CFRecord& record) +{ + record.reserveNunBytes(2); +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DSF.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DSF.h index 19fa0da7b6..35f00d0c79 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DSF.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DSF.h @@ -50,6 +50,7 @@ public: void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeDSF; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Dat.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Dat.cpp index fb6d64ea71..95611cdaee 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Dat.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Dat.cpp @@ -61,5 +61,17 @@ void Dat::readFields(CFRecord& record) fShowSeriesKey = GETBIT(flags, 3); } +void Dat::writeFields(CFRecord& record) +{ + unsigned short flags = 0; + + SETBIT(flags, 0, fHasBordHorz) + SETBIT(flags, 1, fHasBordVert) + SETBIT(flags, 2, fHasBordOutline) + SETBIT(flags, 3, fShowSeriesKey) + + record << flags; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Dat.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Dat.h index e7cbd9e929..33fbd6d5e8 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Dat.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Dat.h @@ -50,14 +50,15 @@ public: void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeDat; //----------------------------- - bool fHasBordHorz; - bool fHasBordVert; - bool fHasBordOutline; - bool fShowSeriesKey; + bool fHasBordHorz = false; + bool fHasBordVert = false; + bool fHasBordOutline = false; + bool fShowSeriesKey = false; }; } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DataFormat.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DataFormat.cpp index 74644c2d32..7baa3dc932 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DataFormat.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DataFormat.cpp @@ -57,5 +57,12 @@ void DataFormat::readFields(CFRecord& record) fUnknown = GETBIT(flags, 0); } +void DataFormat::writeFields(CFRecord& record) +{ + unsigned short flags = 0; + SETBIT(flags, 0, fUnknown); + record << xi << yi << iss << flags; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DataFormat.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DataFormat.h index 5611907f96..c28b0b9bc6 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DataFormat.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DataFormat.h @@ -46,14 +46,15 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeDataFormat; - _UINT16 xi; - _UINT16 yi; - _UINT16 iss; + _UINT16 xi = 0; + _UINT16 yi = 0; + _UINT16 iss = 0; - bool fUnknown; + bool fUnknown = false; }; } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DataLabExt.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DataLabExt.cpp index b7f0711542..45ac5f43e9 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DataLabExt.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DataLabExt.cpp @@ -57,5 +57,11 @@ void DataLabExt::readFields(CFRecord& record) record >> frtHeader; } +void DataLabExt::writeFields(CFRecord& record) +{ + FrtHeader frtHeader(rt_DataLabExt); + record << frtHeader; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DataLabExt.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DataLabExt.h index 4e7f7d3902..b1b39d642e 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DataLabExt.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DataLabExt.h @@ -50,6 +50,7 @@ public: void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeDataLabExt; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DataLabExtContents.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DataLabExtContents.cpp index 8042ad546e..d154dcaef7 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DataLabExtContents.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DataLabExtContents.cpp @@ -68,6 +68,19 @@ void DataLabExtContents::readFields(CFRecord& record) fBubSizes = GETBIT(flags, 4); } +void DataLabExtContents::writeFields(CFRecord& record) +{ + FrtHeader frtHeader(rt_DataLabExtContents); + record << frtHeader; + unsigned short flags = 0; + SETBIT(flags, 0, fSerName) + SETBIT(flags, 1, fCatName) + SETBIT(flags, 2, fValue) + SETBIT(flags, 3, fPercent) + SETBIT(flags, 4, fBubSizes) + record << flags << rgchSep; +} + int DataLabExtContents::serialize(std::wostream & _stream) { CP_XML_WRITER(_stream) diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DataLabExtContents.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DataLabExtContents.h index 3332001a55..6a22dbe565 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DataLabExtContents.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DataLabExtContents.h @@ -51,16 +51,17 @@ public: void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeDataLabExtContents; int serialize(std::wostream & _stream); - bool fSerName; - bool fCatName; - bool fValue; - bool fPercent; - bool fBubSizes; + bool fSerName = false; + bool fCatName = false; + bool fValue = false; + bool fPercent = false; + bool fBubSizes = false; XLUnicodeStringMin2 rgchSep; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Date1904.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Date1904.cpp index 4fe16b2e64..9a6f180778 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Date1904.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Date1904.cpp @@ -56,5 +56,10 @@ void Date1904::readFields(CFRecord& record) record >> f1904DateSystem; } +void Date1904::writeFields(CFRecord& record) +{ + record << f1904DateSystem; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Date1904.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Date1904.h index 04a2abaeaa..e5e379ea17 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Date1904.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Date1904.h @@ -50,11 +50,12 @@ public: void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeDate1904; //----------------------------- - Boolean f1904DateSystem; + Boolean f1904DateSystem = false; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DbOrParamQry.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DbOrParamQry.cpp index 5935cc8173..bd4c583c22 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DbOrParamQry.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DbOrParamQry.cpp @@ -82,5 +82,28 @@ void DbOrParamQry::readFields(CFRecord& record) } } +void DbOrParamQry::writeFields(CFRecord& record) +{ + unsigned short flags = 0; + if (typeRecord == 2) + { + SETBITS(flags, 0, 2, query.dbt) + SETBIT(flags, 3, query.fOdbcConn) + SETBIT(flags, 4, query.fSql) + SETBIT(flags, 5, query.fSqlSav) + SETBIT(flags, 6, query.fWeb) + SETBIT(flags, 7, query.fSavePwd) + SETBIT(flags, 8, query.fTablesOnlyHTML) + + record << flags << query.cparams << query.cstQuery << query.cstWebPost << query.cstSQLSav << query.cstOdbcConn; + } + else + { + SETBITS(flags, 0, 1, param.pbt) + SETBIT(flags, 2, param.fNonDefaultName) + record << param.wTypeSql << flags << param.grbit << param.fVal; + } +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DbOrParamQry.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DbOrParamQry.h index cdf75e5fe2..ae30605802 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DbOrParamQry.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DbOrParamQry.h @@ -47,36 +47,37 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeDbOrParamQry; - int typeRecord; + int typeRecord = 2; //PARAMQRY_Fixed - 8 bytes + variable struct { - unsigned short wTypeSql; - unsigned char pbt; - bool fNonDefaultName; - unsigned short grbit; - unsigned short fVal; + unsigned short wTypeSql = 0; + unsigned char pbt = 0; + bool fNonDefaultName = false; + unsigned short grbit = 0; + unsigned short fVal = 0; }param; //--------------------------------------- struct { - unsigned char dbt; - bool fOdbcConn; - bool fSql; - bool fSqlSav; - bool fWeb; - bool fSavePwd; - bool fTablesOnlyHTML; - short cparams; - short cstQuery; - short cstWebPost; - short cstSQLSav; - short cstOdbcConn; + unsigned char dbt = 0; + bool fOdbcConn = false; + bool fSql = false; + bool fSqlSav = false; + bool fWeb = false; + bool fSavePwd = false; + bool fTablesOnlyHTML = false; + short cparams = 0; + short cstQuery = 0; + short cstWebPost = 0; + short cstSQLSav = 0; + short cstOdbcConn = 0; }query; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DefColWidth.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DefColWidth.cpp index f35385bea4..2a9307ad35 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DefColWidth.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DefColWidth.cpp @@ -61,5 +61,10 @@ void DefColWidth::readFields(CFRecord& record) } } +void DefColWidth::writeFields(CFRecord& record) +{ + record << cchdefColWidth; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DefColWidth.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DefColWidth.h index c7a6c1be35..007ccbc72e 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DefColWidth.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DefColWidth.h @@ -50,11 +50,12 @@ public: void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeDefColWidth; //----------------------------- - _UINT16 cchdefColWidth; + _UINT16 cchdefColWidth = 8; }; } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DefaultRowHeight.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DefaultRowHeight.cpp index 32875fd981..b877a2b946 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DefaultRowHeight.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DefaultRowHeight.cpp @@ -78,5 +78,19 @@ namespace XLS } } + + void DefaultRowHeight::writeFields(CFRecord& record) + { + if(miyRw == -1) + miyRw = 290; + unsigned short flags = 0; + + SETBIT(flags, 0, fUnsynced); + SETBIT(flags, 1, fDyZero); + SETBIT(flags, 2, fExAsc); + SETBIT(flags, 3, fExDsc); + + record << flags << miyRw; + } } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DefaultRowHeight.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DefaultRowHeight.h index efbe964a3b..1ef00388bd 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DefaultRowHeight.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DefaultRowHeight.h @@ -46,15 +46,16 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeDefaultRowHeight; //----------------------------- - bool fUnsynced; - bool fDyZero; - bool fExAsc; - bool fExDsc; + bool fUnsynced = false; + bool fDyZero = false; + bool fExAsc = false; + bool fExDsc = false; - _INT16 miyRw; // measured in twips (1/20 of of a printer's point) + _INT16 miyRw = 290; // measured in twips (1/20 of of a printer's point) }; class DefaultRowHeight_BIFF2 : public DefaultRowHeight diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DefaultText.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DefaultText.cpp index c1a752afb8..3370fc20ae 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DefaultText.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DefaultText.cpp @@ -55,5 +55,10 @@ void DefaultText::readFields(CFRecord& record) record >> id; } +void DefaultText::writeFields(CFRecord& record) +{ + record << id; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DefaultText.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DefaultText.h index 7f18168914..eaf301d80b 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DefaultText.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DefaultText.h @@ -50,11 +50,12 @@ public: void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeDefaultText; //----------------------------- - _UINT16 id; + _UINT16 id = 0; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Dimensions.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Dimensions.cpp index ef9ec1d4b4..80b06685e2 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Dimensions.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Dimensions.cpp @@ -81,6 +81,22 @@ void Dimensions::readFields(CFRecord& record) } } +void Dimensions::writeFields(CFRecord& record) +{ + if(ref_ != L"") + { + CellRangeRef rangeRef; + rangeRef.fromString(ref_); + rwMic = rangeRef.rowFirst; + colMic = rangeRef.columnFirst; + rwMac = rangeRef.rowLast; + colMac = rangeRef.columnLast; + } + record << rwMic << rwMac; + record << colMic << colMac; + record.reserveNunBytes(2); // reserved +} + int Dimensions::serialize(std::wostream & stream) { if (ref_.empty()) return 0; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Dimensions.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Dimensions.h index a853a22848..9c0f251a78 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Dimensions.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Dimensions.h @@ -47,17 +47,18 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeDimensions; int serialize(std::wostream & stream); - std::wstring ref_; + std::wstring ref_ = L""; //----------------------------- - _UINT32 rwMic; - _UINT32 rwMac; - _UINT16 colMic; - _UINT16 colMac; + _UINT32 rwMic = 0; + _UINT32 rwMac = 0; + _UINT16 colMic = 0; + _UINT16 colMac = 0; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DropBar.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DropBar.cpp index a796f5687f..0f463b3ad0 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DropBar.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DropBar.cpp @@ -56,5 +56,10 @@ void DropBar::readFields(CFRecord& record) record >> pcGap; } +void DropBar::writeFields(CFRecord& record) +{ + record << pcGap; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DropBar.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DropBar.h index 16d20c312f..65b9b0d6b4 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DropBar.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DropBar.h @@ -50,10 +50,11 @@ public: void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeDropBar; - _INT16 pcGap; + _INT16 pcGap = 0; }; } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DropDownObjIds.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DropDownObjIds.cpp index a2616fcb0d..e1e6dee7df 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DropDownObjIds.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DropDownObjIds.cpp @@ -63,5 +63,18 @@ void DropDownObjIds::readFields(CFRecord& record) } } +void DropDownObjIds::writeFields(CFRecord& record) +{ + FrtHeader frtHeader(rt_DropDownObjIds); + record << frtHeader; + unsigned short cidObj = rgidObj.size(); + record << cidObj; + for(auto i : rgidObj) + { + if(i != nullptr) + record << *i; + } +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DropDownObjIds.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DropDownObjIds.h index 31eeb421b0..ad46aa1654 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DropDownObjIds.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DropDownObjIds.h @@ -47,6 +47,7 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeDropDownObjIds; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DxGCol.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DxGCol.cpp index 595300e701..c56dfe2bdb 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DxGCol.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DxGCol.cpp @@ -55,5 +55,10 @@ void DxGCol::readFields(CFRecord& record) record >> dxgCol; } +void DxGCol::writeFields(CFRecord& record) +{ + record << dxgCol; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DxGCol.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DxGCol.h index c7465b88d8..941a6b88dd 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DxGCol.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/DxGCol.h @@ -50,11 +50,12 @@ public: void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeDxGCol; //----------------------------- - _UINT16 dxgCol; + _UINT16 dxgCol = 0xFFFF; }; } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/EndObject.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/EndObject.cpp index d6c086723a..c8d03f9a8c 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/EndObject.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/EndObject.cpp @@ -59,5 +59,12 @@ void EndObject::readFields(CFRecord& record) record >> iObjectKind >> unused1 >> unused2 >> unused3; } +void EndObject::writeFields(CFRecord& record) +{ + FrtHeaderOld rt(rt_EndObject); + record << rt << iObjectKind; + record.reserveNunBytes(6); +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/EndObject.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/EndObject.h index 6ea07cadb2..487e95bc58 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/EndObject.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/EndObject.h @@ -50,11 +50,12 @@ public: void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeEndObject; //----------------------------- - _UINT16 iObjectKind; + _UINT16 iObjectKind = 0x0010; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ExtSST.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ExtSST.cpp index 874e96bb92..119a033f81 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ExtSST.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ExtSST.cpp @@ -64,5 +64,12 @@ void ExtSST::readFields(CFRecord& record) } } +void ExtSST::writeFields(CFRecord& record) +{ + record << dsst; + for(auto i : rgISSTInf) + record << *i; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ExtSST.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ExtSST.h index 4e238d52bd..66cd07f24e 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ExtSST.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ExtSST.h @@ -51,13 +51,14 @@ public: void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeExtSST; //----------------------------- - _UINT16 dsst; + _UINT16 dsst = 8; BiffStructurePtrVector rgISSTInf; - _UINT32 num_sets; + _UINT32 num_sets = 0; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ExtString.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ExtString.cpp index 46af119e53..1b35b5df51 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ExtString.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ExtString.cpp @@ -57,5 +57,16 @@ void ExtString::readFields(CFRecord& record) record.skipNunBytes(record.getDataSize() - record.getRdPtr()); } +void ExtString::writeFields(CFRecord& record) +{ + frtHeaderOld.rt = rt_ExtString; + record << frtHeaderOld << string; + auto stringSize = string.getSize(); + if(stringSize < 8) + { + record.reserveNunBytes( 8 - stringSize); + } +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ExtString.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ExtString.h index f0fcc71a34..6b2a0b538a 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ExtString.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ExtString.h @@ -49,6 +49,7 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeExtString; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ExternName.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ExternName.cpp index 447e39e45a..c00b0cd0f2 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ExternName.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ExternName.cpp @@ -107,5 +107,19 @@ void ExternName::readFields(CFRecord& record) } } +void ExternName::writeFields(CFRecord& record) +{ + unsigned short flags = 0; + SETBIT(flags, 0, fBuiltIn) + SETBIT(flags, 1, fWantAdvise) + SETBIT(flags, 2, fWantPict) + SETBIT(flags, 3, fOle) + SETBIT(flags, 4, fOleLink) + SETBITS(flags, 5, 14, cf) + SETBIT(flags, 15, fIcon) + record << flags; + record << body; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ExternName.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ExternName.h index f410afe3f1..be03303f5b 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ExternName.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ExternName.h @@ -53,22 +53,23 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeExternName; //----------------------------- - bool fBuiltIn; - bool fWantAdvise; - bool fWantPict; - bool fOle; - bool fOleLink; - short cf; - bool fIcon; + bool fBuiltIn = false; + bool fWantAdvise = false; + bool fWantPict = false; + bool fOle = false; + bool fOleLink = false; + short cf = 0; + bool fIcon = false; BiffStructurePtr body; //----------------------------- - _UINT16 supbook_cch; - bool bOleVirtualPath; + _UINT16 supbook_cch = 0; + bool bOleVirtualPath = false; }; typedef boost::shared_ptr ExternNamePtr; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ExternSheet.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ExternSheet.h index f838fc7683..892f84b75d 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ExternSheet.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ExternSheet.h @@ -53,7 +53,7 @@ public: static const ElementType type = typeExternSheet; - _UINT32 cXTI; + _UINT32 cXTI = 0; BiffStructurePtrVector rgXTI; //------------------------------------------------ std::wstring name; //biff5 diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Fbi.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Fbi.cpp index 11b7937718..370e2c861c 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Fbi.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Fbi.cpp @@ -55,5 +55,10 @@ void Fbi::readFields(CFRecord& record) record >> dmixBasis >> dmiyBasis >> twpHeightBasis >> scab >> ifnt; } +void Fbi::writeFields(CFRecord& record) +{ + record << dmixBasis << dmiyBasis << twpHeightBasis << scab << ifnt; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Fbi.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Fbi.h index f4b4a964d1..9015c498f1 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Fbi.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Fbi.h @@ -51,14 +51,15 @@ public: void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeFbi; //----------------------------- - _UINT16 dmixBasis; - _UINT16 dmiyBasis; - _UINT16 twpHeightBasis; - _UINT16 scab; + _UINT16 dmixBasis = 0; + _UINT16 dmiyBasis = 0; + _UINT16 twpHeightBasis = 0; + _UINT16 scab = 0; FontIndex ifnt; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Fbi2.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Fbi2.cpp index 67e724c6cf..a64b0ec37d 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Fbi2.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Fbi2.cpp @@ -47,5 +47,11 @@ void Fbi2::readFields(CFRecord& record) scab = (val != 0); } +void Fbi2::writeFields(CFRecord& record) +{ + unsigned short val = scab!= false; + record << dmixBasis << dmiyBasis << twpHeightBasis << val << ifnt; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Fbi2.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Fbi2.h index 0af1693f59..83410c977b 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Fbi2.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Fbi2.h @@ -50,11 +50,12 @@ public: static const ElementType type = typeFbi2; void readFields(CFRecord& record); + void writeFields(CFRecord& record); - unsigned short dmixBasis; - unsigned short dmiyBasis; - unsigned short twpHeightBasis; - bool scab; + unsigned short dmixBasis = 0; + unsigned short dmiyBasis = 0; + unsigned short twpHeightBasis = 0; + bool scab = false; FontIndex ifnt; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/FeatHdr.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/FeatHdr.cpp index 822a4e00c5..ef305ba609 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/FeatHdr.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/FeatHdr.cpp @@ -77,5 +77,28 @@ void FeatHdr::readFields(CFRecord& record) } +void FeatHdr::writeFields(CFRecord& record) +{ + FrtHeader frtHeader(rt_FeatHdr); + record << frtHeader << isf; + unsigned char reserved = 1; + record << reserved << cbHdrData; + if(cbHdrData = 0) + return; + switch(isf) + { + case 0x0002://ISFPROTECTION: + record << protection; + break; + case 0x0004://ISFFACTOID: + if(is_contained_in_Globals) + { + record << prop; + } + break; + } + +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/FeatHdr.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/FeatHdr.h index 909529785e..21e730a319 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/FeatHdr.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/FeatHdr.h @@ -52,11 +52,12 @@ public: void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeFeatHdr; - _UINT16 isf; - _UINT32 cbHdrData; + _UINT16 isf = 0x0002; + _UINT32 cbHdrData = 0xFFFFFFFF; EnhancedProtection protection; OSHARED::PropertyBagStore prop; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/FileSharing.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/FileSharing.cpp index a0fe84b4c2..da3490af33 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/FileSharing.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/FileSharing.cpp @@ -95,6 +95,14 @@ void FileSharing::writeFields(CFRecord& record) } record << wResPassNum << stUserName; } + else + { + record << fReadOnlyRec << wResPassNum; + if(wResPassNum == 0) + record.reserveNunBytes(2); + record << stUNUsername; + + } } } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/FileSharing.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/FileSharing.h index 0da5c89195..1dd1a6dd4b 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/FileSharing.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/FileSharing.h @@ -55,10 +55,10 @@ public: static const ElementType type = typeFileSharing; - Boolean fReadOnlyRec; + Boolean fReadOnlyRec = false; unsigned short wResPassNum = 0; std::wstring wResPass; - _UINT16 iNoResPass; + _UINT16 iNoResPass = 0; XLUnicodeString stUNUsername; XLSB::XLNullableWideString stUserName; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/FnGroupName.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/FnGroupName.cpp index e5c20221ef..50fc4ef2dc 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/FnGroupName.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/FnGroupName.cpp @@ -56,5 +56,10 @@ void FnGroupName::readFields(CFRecord& record) record >> rgch; } +void FnGroupName::writeFields(CFRecord& record) +{ + record << rgch; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/FnGroupName.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/FnGroupName.h index e05a6c69e5..2d96230e40 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/FnGroupName.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/FnGroupName.h @@ -51,6 +51,8 @@ public: void readFields(CFRecord& record); + void writeFields(CFRecord& record); + static const ElementType type = typeFnGroupName; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/FnGrp12.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/FnGrp12.cpp index 94c4254985..b5a74d9fd4 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/FnGrp12.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/FnGrp12.cpp @@ -55,5 +55,11 @@ void FnGrp12::readFields(CFRecord& record) record >> frtHeader >> astFnGrp; } +void FnGrp12::writeFields(CFRecord& record) +{ + frtHeader.rt = 0x0898; + record << frtHeader << astFnGrp; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/FnGrp12.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/FnGrp12.h index 3f2669c1c9..ba57363ca6 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/FnGrp12.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/FnGrp12.h @@ -49,6 +49,7 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeFnGrp12; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Font.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Font.h index adb43be590..eac40f0d38 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Font.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Font.h @@ -63,26 +63,26 @@ public: GlobalWorkbookInfoPtr global_info; //----------------------------- - _UINT16 dyHeight; // measured in twips (1/20 of of a printer's point) + _UINT16 dyHeight = 220; // measured in twips (1/20 of of a printer's point) - bool fItalic; - bool fStrikeOut; - bool fOutline; - bool fShadow; - bool fCondense; - bool fExtend; + bool fItalic = false; + bool fStrikeOut = false; + bool fOutline = false; + bool fShadow = false; + bool fCondense = false; + bool fExtend = false; - _UINT16 icv; - _UINT16 bls = 0; + _UINT16 icv = 8; + _UINT16 bls = 400; _UINT16 sss = 0; unsigned char uls = 0; - unsigned char bFamily = 0; - unsigned char bCharSet = 0; + unsigned char bFamily = 0x02; + unsigned char bCharSet = 0xCC; - std::wstring fontName; + std::wstring fontName = L"calibri"; FillInfoExt color_ext; - bool correct; + bool correct = true; //xlsb XLSB::Color brtColor; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/FontX.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/FontX.cpp index 170915d146..4d86606bcb 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/FontX.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/FontX.cpp @@ -56,5 +56,10 @@ void FontX::readFields(CFRecord& record) record >> iFont; } +void FontX::writeFields(CFRecord& record) +{ + record << iFont; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/FontX.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/FontX.h index 1aaedae026..2b5a73e177 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/FontX.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/FontX.h @@ -50,11 +50,12 @@ public: void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeFontX; //----------------------------- - _UINT16 iFont; + _UINT16 iFont = 0; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Footer.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Footer.cpp index 579288793f..adcddc4414 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Footer.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Footer.cpp @@ -37,6 +37,7 @@ namespace XLS Footer::Footer() { + ast = L""; } @@ -68,5 +69,11 @@ void Footer::readFields(CFRecord& record) } } +void Footer::writeFields(CFRecord& record) +{ + if(ast.getSize()) + record << ast; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Footer.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Footer.h index 8555d3e0c3..47967e0803 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Footer.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Footer.h @@ -51,6 +51,7 @@ public: void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeFooter; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Format.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Format.cpp index 6004fb7d2c..22c353c83a 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Format.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Format.cpp @@ -87,6 +87,14 @@ void Format::readFields(CFRecord& record) stFormat = XmlUtils::EncodeXmlString(format.value(), true); } } + +void Format::writeFields(CFRecord& record) +{ + XLUnicodeString format; + format = stFormat; + record << ifmt << format; +} + int Format::serialize(std::wostream & stream) { if (ifmt < 5 || (ifmt > 8 && ifmt < 23) || (ifmt > 36 && ifmt < 41) || (ifmt > 44 && ifmt < 50)) return 0; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Format.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Format.h index e4d4455c62..92a72e9404 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Format.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Format.h @@ -48,14 +48,14 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); - + void writeFields(CFRecord& record); static const ElementType type = typeFormat; int serialize(std::wostream & stream); //----------------------------- _UINT16 ifmt_used = 0xFFFF; - _UINT16 ifmt = 0xFFFF; - std::wstring stFormat; + _UINT16 ifmt = 164; + std::wstring stFormat = L"General"; }; class Format_BIFF23 : public Format diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Formula.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Formula.cpp index 351d22e0be..71fc9c79f5 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Formula.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Formula.cpp @@ -73,6 +73,18 @@ void Formula::readFields(CFRecord& record) formula.load(record); } +void Formula::writeFields(CFRecord& record) +{ + unsigned short flags = 0; + SETBIT(flags, 0, fAlwaysCalc); + SETBIT(flags, 2, fFill); + SETBIT(flags, 3, fShrFmla); + SETBIT(flags, 5, fClearErrors); + record << cell << val << flags; + record.reserveNunBytes(4); + formula.save(record); +} + const CellRef Formula::getLocation() const { return cell.getLocation(); diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Formula.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Formula.h index 7f92b5b1df..db3c4c2797 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Formula.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Formula.h @@ -49,6 +49,7 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeFormula; @@ -58,11 +59,11 @@ public: bool bBiff_3_4 = false; Cell cell; FormulaValue val; - bool fAlwaysCalc; - bool fShrFmla; + bool fAlwaysCalc = false; + bool fShrFmla = false; - bool fFill; - bool fClearErrors; + bool fFill = false; + bool fClearErrors = false; CellParsedFormula formula; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Frame.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Frame.cpp index 1717ee4db6..98e93c6b60 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Frame.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Frame.cpp @@ -58,5 +58,14 @@ void Frame::readFields(CFRecord& record) fAutoPosition = GETBIT(flags, 1); } +void Frame::writeFields(CFRecord& record) +{ + unsigned short flags = 0; + + SETBIT(flags, 0, fAutoSize) + SETBIT(flags, 1, fAutoPosition) + record << frt << flags; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Frame.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Frame.h index eada188624..eede859569 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Frame.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Frame.h @@ -47,13 +47,14 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeFrame; //----------------------------- - _UINT16 frt; - bool fAutoSize; - bool fAutoPosition; + _UINT16 frt = 0; + bool fAutoSize = false; + bool fAutoPosition = false; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/GridSet.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/GridSet.cpp index b5815c524c..83c8584aab 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/GridSet.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/GridSet.cpp @@ -56,5 +56,10 @@ void GridSet::readFields(CFRecord& record) record.skipNunBytes(2); // reserved } +void GridSet::writeFields(CFRecord& record) +{ + _UINT16 gridset = 1; // reserved + record << gridset; +} } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/GridSet.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/GridSet.h index de10905864..e0bbaa9a97 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/GridSet.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/GridSet.h @@ -50,6 +50,7 @@ public: void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeGridSet; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Guts.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Guts.cpp index 13f531cbeb..17d03e5f7a 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Guts.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Guts.cpp @@ -56,5 +56,11 @@ void Guts::readFields(CFRecord& record) record >> iLevelRwMac >> iLevelColMac; } +void Guts::writeFields(CFRecord& record) +{ + record.reserveNunBytes(4); // unused + record << iLevelRwMac << iLevelColMac; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Guts.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Guts.h index 7ea4a8dbe3..5111fa0134 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Guts.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Guts.h @@ -50,12 +50,13 @@ public: void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeGuts; //----------------------------- - _UINT16 iLevelRwMac; - _UINT16 iLevelColMac; + _UINT16 iLevelRwMac = 0; + _UINT16 iLevelColMac = 0; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/HCenter.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/HCenter.cpp index 9c211451c7..2576819cb4 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/HCenter.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/HCenter.cpp @@ -55,5 +55,10 @@ void HCenter::readFields(CFRecord& record) record >> hcenter; } +void HCenter::writeFields(CFRecord& record) +{ + record << hcenter; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/HCenter.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/HCenter.h index 4962e97bf3..1bb816cc84 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/HCenter.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/HCenter.h @@ -47,11 +47,12 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeHCenter; //----------------------------- - Boolean hcenter; + Boolean hcenter = 0; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/HFPicture.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/HFPicture.cpp index 27685a6239..95e90983ec 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/HFPicture.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/HFPicture.cpp @@ -71,5 +71,22 @@ void HFPicture::readFields(CFRecord& record) record.skipNunBytes(size); } +void HFPicture::writeFields(CFRecord& record) +{ + FrtHeader frtHeader(rt_HFPicture); + record << frtHeader; + + unsigned short flags = 0; + SETBIT(flags, 0, fIsDrawing) + SETBIT(flags, 1, fIsDrawingGroup) + SETBIT(flags, 2, fContinue) + record << flags; + if(recordDrawingGroup != nullptr) + { + record.appendRawDataToStatic(recordDrawingGroup->getCurData(), recordDrawingGroup->getRdPtr()); + } + +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/HFPicture.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/HFPicture.h index bc18786b96..e446ba289d 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/HFPicture.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/HFPicture.h @@ -50,12 +50,13 @@ public: void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeHFPicture; - bool fIsDrawing; - bool fIsDrawingGroup; - bool fContinue; + bool fIsDrawing = false; + bool fIsDrawingGroup = true; + bool fContinue = false; CFRecordPtr recordDrawingGroup; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/HLink.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/HLink.cpp index 44a3957f24..4670d2ad29 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/HLink.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/HLink.cpp @@ -58,5 +58,13 @@ void HLink::readFields(CFRecord& record) hlinkClsid = STR::guid2bstr(clsid); } +void HLink::writeFields(CFRecord& record) +{ + record << ref8; + _GUID_ guid_num(0, 0, 0, 0); + STR::bstr2guid(hlinkClsid, guid_num); + record << guid_num << hyperlink; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/HLink.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/HLink.h index 21740e3e9a..d79b2e0bca 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/HLink.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/HLink.h @@ -52,6 +52,7 @@ public: void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeHLink; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/HLinkTooltip.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/HLinkTooltip.cpp index 8e51391797..a2c8ed11a8 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/HLinkTooltip.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/HLinkTooltip.cpp @@ -65,5 +65,16 @@ void HLinkTooltip::readFields(CFRecord& record) wzTooltip = std::wstring (wzTooltip_prep.c_str()); } +void HLinkTooltip::writeFields(CFRecord& record) +{ + FrtRefHeaderNoGrbit frtRefHeaderNoGrbit(rt_HLinkTooltip); + frtRefHeaderNoGrbit.ref8 = ref_; + record << frtRefHeaderNoGrbit; + if(wzTooltip.empty() || wzTooltip.at(wzTooltip.size() -1) != L'\0') + wzTooltip += L'\0'; + for(auto i : wzTooltip) + record << i; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/HLinkTooltip.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/HLinkTooltip.h index 214a180dbe..562f278a7b 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/HLinkTooltip.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/HLinkTooltip.h @@ -47,6 +47,7 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeHLinkTooltip; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Header.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Header.cpp index 0458e8262c..c3e96a9bca 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Header.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Header.cpp @@ -37,6 +37,7 @@ namespace XLS Header::Header() { + ast = L""; } @@ -68,5 +69,11 @@ void Header::readFields(CFRecord& record) } } +void Header::writeFields(CFRecord& record) +{ + if(ast.getSize() > 0) + record << ast; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Header.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Header.h index f33103812c..d854d7bf5e 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Header.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Header.h @@ -51,6 +51,7 @@ public: void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeHeader; //----------------------------- diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/HeaderFooter.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/HeaderFooter.cpp index c116cf4d6f..3ac4fa70e7 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/HeaderFooter.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/HeaderFooter.cpp @@ -80,5 +80,40 @@ void HeaderFooter::readFields(CFRecord& record) } } +void HeaderFooter::writeFields(CFRecord& record) +{ + FrtHeader frtHeader(rt_HeaderFooter); + frtHeader.grbitFrt.fFrtRef = 0; + frtHeader.grbitFrt.fFrtAlert = 0; + record << frtHeader; + _GUID_ guid_num; + STR::bstr2guid(guidSView ,guid_num); + record << guid_num; + _UINT16 flags = 0; + SETBIT(flags, 0, fHFDiffOddEven); + SETBIT(flags, 1, fHFDiffFirst); + SETBIT(flags, 2, fHFScaleWithDoc); + SETBIT(flags, 3, fHFAlignMargins); + record << flags; + record << cchHeaderEven << cchFooterEven << cchHeaderFirst << cchFooterFirst; + if(cchHeaderEven && strHeaderEven.getSize()) + { + record << strHeaderEven; + } + if(cchFooterEven && strFooterEven.getSize()) + { + record << strFooterEven; + } + if(cchHeaderFirst && strHeaderFirst.getSize()) + { + record << strHeaderFirst; + } + if(cchFooterFirst && strFooterFirst.getSize()) + { + record << strFooterFirst; + } + +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/HeaderFooter.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/HeaderFooter.h index 1bf82510f9..772b7fd8ea 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/HeaderFooter.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/HeaderFooter.h @@ -47,21 +47,22 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeHeaderFooter; //----------------------------- - std::wstring guidSView; + std::wstring guidSView = L"{00000000-0000-0000-0000-000000000000}"; - bool fHFDiffOddEven; - bool fHFDiffFirst; - bool fHFScaleWithDoc; - bool fHFAlignMargins; + bool fHFDiffOddEven = false; + bool fHFDiffFirst = false; + bool fHFScaleWithDoc = true; + bool fHFAlignMargins = true; - _UINT16 cchHeaderEven; - _UINT16 cchFooterEven; - _UINT16 cchHeaderFirst; - _UINT16 cchFooterFirst; + _UINT16 cchHeaderEven = 0; + _UINT16 cchFooterEven = 0; + _UINT16 cchHeaderFirst = 0; + _UINT16 cchFooterFirst = 0; XLUnicodeString strHeaderEven; XLUnicodeString strFooterEven; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/HideObj.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/HideObj.cpp index ef9de95ecc..4b832c087d 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/HideObj.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/HideObj.cpp @@ -37,6 +37,7 @@ namespace XLS HideObj::HideObj() { + hideObj.value() = 0; } @@ -56,5 +57,11 @@ void HideObj::readFields(CFRecord& record) record >> hideObj; } +void HideObj::writeFields(CFRecord& record) +{ + record << hideObj; +} + + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/HideObj.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/HideObj.h index c7b77c4c66..c10c37da05 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/HideObj.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/HideObj.h @@ -51,11 +51,12 @@ public: void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeHideObj; //----------------------------- - HideObjEnum hideObj; + HideObjEnum hideObj; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/HorizontalPageBreaks.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/HorizontalPageBreaks.cpp index 22f8bf80ce..e63bbf2491 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/HorizontalPageBreaks.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/HorizontalPageBreaks.cpp @@ -52,6 +52,15 @@ namespace XLS rgbrk.push_back(hb); } } + void HorizontalPageBreaks::writeFields(CFRecord& record) + { + cbrk = rgbrk.size(); + record << cbrk; + for (auto i:rgbrk) + { + record << *i; + } + } int HorizontalPageBreaks::serialize(std::wostream & stream) { if (rgbrk.empty()) return 0; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/HorizontalPageBreaks.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/HorizontalPageBreaks.h index 8eba147c8d..8e668d86a1 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/HorizontalPageBreaks.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/HorizontalPageBreaks.h @@ -48,12 +48,13 @@ namespace XLS BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeHorizontalPageBreaks; virtual int serialize(std::wostream & stream); //----------------------------- - _UINT16 cbrk; + _UINT16 cbrk = 0; BiffStructurePtrVector rgbrk; }; } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/IFmtRecord.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/IFmtRecord.cpp index 1fe269acf7..87bcab1b6f 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/IFmtRecord.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/IFmtRecord.cpp @@ -60,5 +60,10 @@ void IFmtRecord::readFields(CFRecord& record) ifmt = global_info->RegisterNumFormat(ifmt, L""); // return update } +void IFmtRecord::writeFields(CFRecord& record) +{ + record << ifmt; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/IFmtRecord.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/IFmtRecord.h index a4061aaccb..c67aebf91b 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/IFmtRecord.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/IFmtRecord.h @@ -50,11 +50,12 @@ public: void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeIFmtRecord; //----------------------------- - _UINT16 ifmt; + _UINT16 ifmt = 0; }; } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Index.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Index.cpp index 651bfafd21..3b1ef86118 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Index.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Index.cpp @@ -63,5 +63,16 @@ void Index::readFields(CFRecord& record) } } +void Index::writeFields(CFRecord& record) +{ + record.reserveNunBytes(4); // reserved + record << rwMic << rwMac << ibXF; + + for(auto i:rgibRw) + { + record << *i; + } +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Index.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Index.h index 59d9ce6dbb..8f7ae22d73 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Index.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Index.h @@ -48,13 +48,14 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeIndex; //----------------------------- - _UINT32 rwMic; - _UINT32 rwMac; - _UINT32 ibXF; + _UINT32 rwMic = 0; + _UINT32 rwMac = 0; + _UINT32 ibXF = 0; BiffStructurePtrVector rgibRw; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/InterfaceHdr.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/InterfaceHdr.cpp index 1994b8711a..e784b1564a 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/InterfaceHdr.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/InterfaceHdr.cpp @@ -56,4 +56,9 @@ void InterfaceHdr::readFields(CFRecord& record) record >> codePage; } +void InterfaceHdr::writeFields(CFRecord& record) +{ + record << codePage; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/InterfaceHdr.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/InterfaceHdr.h index 4f0544da7e..5084c95368 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/InterfaceHdr.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/InterfaceHdr.h @@ -51,8 +51,9 @@ public: void readFields(CFRecord& record); + void writeFields(CFRecord& record); //----------------------------- - _UINT16 codePage; + _UINT16 codePage = 0x04B0; }; } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/LRng.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/LRng.cpp index aa4b024f04..60413d937b 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/LRng.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/LRng.cpp @@ -69,5 +69,19 @@ void LRng::readFields(CFRecord& record) } +void LRng::writeFields(CFRecord& record) +{ + crefRw = refRow.size(); + record << crefRw; + for(auto i : refRow) + if(i!= nullptr) + record << *i; + crefCol = refCol.size(); + for(auto i : refCol) + if(i!= nullptr) + record << *i; + +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/LRng.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/LRng.h index 95c11632a7..e48e50ec4a 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/LRng.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/LRng.h @@ -51,13 +51,14 @@ public: void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeLRng; //----------------------------- - _UINT16 crefRw; + _UINT16 crefRw = 0 ; BiffStructurePtrVector refRow; - _UINT16 crefCol; + _UINT16 crefCol = 0; BiffStructurePtrVector refCol; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Label.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Label.cpp index 4d8070ccbe..1e400090df 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Label.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Label.cpp @@ -102,6 +102,11 @@ void Label::readFields(CFRecord& record) global_info_->arAddedSharedStrings.push_back(st.value()); } +void Label::writeFields(CFRecord& record) +{ + record << cell << st; +} + int Label::serialize(std::wostream & stream) { CP_XML_WRITER(stream) diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Label.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Label.h index 2c732cc6ab..40475580e5 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Label.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Label.h @@ -49,6 +49,7 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); int serialize(std::wostream & stream); diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/LabelSst.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/LabelSst.cpp index 29ae2e636f..0ee75214ad 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/LabelSst.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/LabelSst.cpp @@ -54,6 +54,11 @@ void LabelSst::readFields(CFRecord& record) record >> cell >> isst; } +void LabelSst::writeFields(CFRecord& record) +{ + record << cell << isst; +} + const CellRef LabelSst::getLocation() const { return cell.getLocation(); diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/LabelSst.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/LabelSst.h index b1dc9742d3..02f01be8e3 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/LabelSst.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/LabelSst.h @@ -49,6 +49,7 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); int serialize(std::wostream & stream); @@ -59,7 +60,7 @@ public: CellOffsetResender resender; Cell cell; - _UINT32 isst; + _UINT32 isst = 0; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Lbl.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Lbl.cpp index 14e1ca33f8..26af1ba138 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Lbl.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Lbl.cpp @@ -206,7 +206,34 @@ void Lbl::writeFields(CFRecord& record) if (record.getGlobalWorkbookInfo()->Version < 0x0800) { - //stub + unsigned short flags = 0; + + SETBIT(flags, 0, fHidden) + SETBIT(flags, 1, fFunc) + SETBIT(flags, 2, fOB) + SETBIT(flags, 3, fProc) + SETBIT(flags, 4, fCalcExp) + SETBIT(flags, 5, fBuiltin) + SETBITS(flags, 6, 11, fGrp) + SETBIT(flags, 13, fPublished) + SETBIT(flags, 14, fWorkbookParam) + + unsigned char cch = Name_bin.getSize(); + record << flags << chKey << cch; + auto ccePos = record.getRdPtr(); + record.reserveNunBytes(4); + + _UINT16 itab_2b = itab; + record << itab_2b; + record.reserveNunBytes(4); + record << Name_bin; + auto rgceStart = record.getRdPtr(); + rgce.save(record); + + unsigned short cce = record.getRdPtr() - rgceStart; + record.RollRdPtrBack(record.getRdPtr() - ccePos); + record << cce; + record.skipNunBytes((rgceStart - record.getRdPtr()) + cce); } else diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Lbl.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Lbl.h index 16d51fe033..54950257a5 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Lbl.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Lbl.h @@ -56,22 +56,22 @@ public: static const ElementType type = typeLbl; - bool fHidden; - bool fFunc; - bool fOB; - bool fProc; - bool fCalcExp; - bool fBuiltin; + bool fHidden = false; + bool fFunc = false; + bool fOB = false; + bool fProc = false; + bool fCalcExp = false; + bool fBuiltin = false; //unsigned char fGrp; - unsigned short fGrp; - bool fPublished; - bool fWorkbookParam; + unsigned short fGrp = 0; + bool fPublished = false; + bool fWorkbookParam = false; - bool fFutureFunction; //biff12 + bool fFutureFunction = false; //biff12 - unsigned char chKey; + unsigned char chKey = 0; //_UINT16 itab; - _UINT32 itab; + _UINT32 itab = 0; XLUnicodeStringNoCch Name_bin; std::wstring Name; XLSB::XLNameWideString name; //biff12 diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/LeftMargin.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/LeftMargin.cpp index dfe9f6994d..883588afe7 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/LeftMargin.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/LeftMargin.cpp @@ -37,6 +37,7 @@ namespace XLS LeftMargin::LeftMargin() { + num.data.value = 0.7; } @@ -56,5 +57,10 @@ void LeftMargin::readFields(CFRecord& record) record >> num; } +void LeftMargin::writeFields(CFRecord& record) +{ + record << num; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/LeftMargin.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/LeftMargin.h index 42d4c74563..79233b8f14 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/LeftMargin.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/LeftMargin.h @@ -50,6 +50,7 @@ public: static const ElementType type = typeLeftMargin; void readFields(CFRecord& record); + void writeFields(CFRecord& record); //----------------------------- Xnum num; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Legend.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Legend.cpp index 6eb80f56aa..0e6e5af5d9 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Legend.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Legend.cpp @@ -67,6 +67,19 @@ void Legend::readFields(CFRecord& record) fWasDataTable = GETBIT(flags, 5); } +void Legend::writeFields(CFRecord& record) +{ + unsigned short flags = 0; + SETBIT(flags, 0, fAutoPosition) + SETBIT(flags, 2, fAutoPosX) + SETBIT(flags, 3, fAutoPosY) + SETBIT(flags, 4, fVert) + SETBIT(flags, 5, fWasDataTable) + record << x << y << dx << dy; + record.reserveNunBytes(1); // unused + record << wSpace << flags; +} + int Legend::serialize(std::wostream & _stream, int size) { CrtLayout12 *crtLayout = dynamic_cast (m_CrtLayout12.get()); diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Legend.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Legend.h index 7145c13872..8b8014204a 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Legend.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Legend.h @@ -47,22 +47,23 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); int serialize(std::wostream & _stream, int sz); static const ElementType type = typeLegend; - _UINT32 x; - _UINT32 y; - _UINT32 dx; - _UINT32 dy; - unsigned char wSpace; + _UINT32 x = 0; + _UINT32 y = 0; + _UINT32 dx = 0; + _UINT32 dy = 0; + unsigned char wSpace = 0; - bool fAutoPosition; - bool fAutoPosX; - bool fAutoPosY; - bool fVert; - bool fWasDataTable; + bool fAutoPosition = false; + bool fAutoPosX = false; + bool fAutoPosY = false; + bool fVert = false; + bool fWasDataTable = false; //----------------------------- BaseObjectPtr m_CrtLayout12; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/LegendException.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/LegendException.cpp index 897a9cba4c..199cae165a 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/LegendException.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/LegendException.cpp @@ -58,6 +58,15 @@ void LegendException::readFields(CFRecord& record) fDelete = GETBIT(flags, 0); fLabel = GETBIT(flags, 1); } + +void LegendException::writeFields(CFRecord& record) +{ + unsigned short flags = 0; + SETBIT(flags, 0, fDelete) + SETBIT(flags, 1, fLabel) + record << iss << flags; +} + int LegendException::serialize(std::wostream & _stream) { CP_XML_WRITER(_stream) diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/LegendException.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/LegendException.h index b23da37eff..a8befe4786 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/LegendException.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/LegendException.h @@ -50,10 +50,11 @@ public: void readFields(CFRecord& record); + void writeFields(CFRecord& record); - _UINT16 iss; - bool fDelete; - bool fLabel; + _UINT16 iss = 0; + bool fDelete = false; + bool fLabel = false; int serialize(std::wostream & _stream); diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Lel.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Lel.cpp index ca905638cf..3257f4569e 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Lel.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Lel.cpp @@ -57,5 +57,10 @@ void Lel::readFields(CFRecord& record) record >> stFormulaName; } +void Lel::writeFields(CFRecord& record) +{ + record << stFormulaName; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Lel.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Lel.h index 9c53b790af..fbfec9a2b7 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Lel.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Lel.h @@ -51,6 +51,7 @@ public: void readFields(CFRecord& record); + void writeFields(CFRecord& record); //----------------------------- XLUnicodeString stFormulaName; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Line.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Line.cpp index 0ae40d0985..d525beedd6 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Line.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Line.cpp @@ -59,6 +59,15 @@ void Line::readFields(CFRecord& record) fHasShadow = GETBIT(flags, 2); } +void Line::writeFields(CFRecord& record) +{ + unsigned short flags = 0; + SETBIT(flags, 0, fStacked) + SETBIT(flags, 1, f100) + SETBIT(flags, 2, fHasShadow) + record << flags; +} + int Line::serialize(std::wostream & _stream) { CP_XML_WRITER(_stream) diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Line.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Line.h index 8919c08caa..64824f567e 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Line.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Line.h @@ -50,15 +50,16 @@ public: void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeLine; int serialize(std::wostream & _stream); //----------------------------- - bool fStacked; - bool f100; - bool fHasShadow; + bool fStacked = false; + bool f100 = false; + bool fHasShadow = false; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/LineFormat.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/LineFormat.cpp index 6f87c62835..d460f5e9f8 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/LineFormat.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/LineFormat.cpp @@ -60,6 +60,16 @@ void LineFormat::readFields(CFRecord& record) fAutoCo = GETBIT(flags, 3); } +void LineFormat::writeFields(CFRecord& record) +{ + unsigned short flags = 0; + + SETBIT(flags, 0, fAuto) + SETBIT(flags, 2, fAxisOn) + SETBIT(flags, 3, fAutoCo) + record << rgb << lns << we << flags << icv; +} + int LineFormat::serialize(std::wostream & _stream) { CP_XML_WRITER(_stream) diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/LineFormat.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/LineFormat.h index 91469ac864..d58dcde598 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/LineFormat.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/LineFormat.h @@ -48,17 +48,18 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeLineFormat; int serialize(std::wostream & _stream); //----------------------------- LongRGB rgb; - _UINT16 lns; - _UINT16 we; - bool fAuto; - bool fAxisOn; - bool fAutoCo; - IcvChart icv; + _UINT16 lns = 0; + _UINT16 we = 0; + bool fAuto = false; + bool fAxisOn = false; + bool fAutoCo = false; + IcvChart icv = 0; }; } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MDB.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MDB.cpp index 67f17e8050..ae7df5faa1 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MDB.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MDB.cpp @@ -62,5 +62,21 @@ void MDB::readFields(CFRecord& record) } } +void MDB::writeFields(CFRecord& record) +{ + frtHeader.rt = rt_MDB; + const auto maxRecordLen = 8224; + record << frtHeader; + auto curSize = 12; + for(auto i : rgmdir) + { + if(curSize + 8 > maxRecordLen) + break; + if(i != nullptr) + record << *i; + curSize += 8; + } +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MDB.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MDB.h index 61287e668d..050d07ff88 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MDB.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MDB.h @@ -49,6 +49,7 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); //----------------------------- BiffStructurePtrVector rgmdir; FrtHeader frtHeader; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MDTInfo.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MDTInfo.cpp index 49f9a1c511..a0df566ff7 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MDTInfo.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MDTInfo.cpp @@ -86,5 +86,48 @@ void MDTInfo::readFields(CFRecord& record) record >> stName; } +void MDTInfo::writeFields(CFRecord& record) +{ + frtHeader.rt = rt_MDTInfo; + record << frtHeader; + _UINT32 flags = 0; + + SETBIT(flags, 0, fGhostRow) + SETBIT(flags, 1, fGhostCol) + SETBIT(flags, 2, fEdit) + SETBIT(flags, 3, fDelete) + SETBIT(flags, 4, fCopy) + SETBIT(flags, 5, fPasteAll) + SETBIT(flags, 6, fPasteFormulas) + SETBIT(flags, 7, fPasteValues) + SETBIT(flags, 8, fPasteFormats) + SETBIT(flags, 9, fPasteComments) + SETBIT(flags, 10, fPasteDataValidation) + SETBIT(flags, 11, fPasteBorders) + SETBIT(flags, 12, fPasteColWidths) + SETBIT(flags, 13, fPasteNumberFormats) + SETBIT(flags, 14, fMerge) + SETBIT(flags, 15, fSplitFirst) + SETBIT(flags, 16, fSplitAll) + SETBIT(flags, 17, fRowColShift) + SETBIT(flags, 18, fClearAll) + SETBIT(flags, 19, fClearFormats) + SETBIT(flags, 20, fClearContents) + SETBIT(flags, 21, fClearComments) + SETBIT(flags, 22, fAssign) + SETBIT(flags, 28, fCoerce) + SETBIT(flags, 29, fAdjust) + SETBIT(flags, 30, fCellMeta) + + record << flags; + if(stName.getSize() <= 4104) + record << stName; + else + { + LPWideString tempVal = stName.value().substr(0, 4104); + record << tempVal; + } +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MDTInfo.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MDTInfo.h index a115d2204d..86deea73f4 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MDTInfo.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MDTInfo.h @@ -50,6 +50,7 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); //----------------------------- bool fGhostRow; bool fGhostCol; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MDXKPI.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MDXKPI.cpp index 4ca2c15df8..2071e1a043 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MDXKPI.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MDXKPI.cpp @@ -55,5 +55,11 @@ void MDXKPI::readFields(CFRecord& record) record >> frtHeader >> istrConnName >> tfnSrc >> kpiprop >> istrKPIName >> istrMbrKPI; } +void MDXKPI::writeFields(CFRecord& record) +{ + frtHeader.rt = rt_MDXKPI; + record << frtHeader << istrConnName << tfnSrc << kpiprop << istrKPIName << istrMbrKPI; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MDXKPI.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MDXKPI.h index 9f1abf4155..1a63555370 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MDXKPI.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MDXKPI.h @@ -49,12 +49,13 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); //----------------------------- - _INT32 istrConnName; - unsigned char tfnSrc; - unsigned char kpiprop; - _INT32 istrKPIName; - _INT32 istrMbrKPI; + _INT32 istrConnName = 0; + unsigned char tfnSrc = 0; + unsigned char kpiprop = 0; + _INT32 istrKPIName = 0; + _INT32 istrMbrKPI = 0; FrtHeader frtHeader; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MDXProp.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MDXProp.cpp index cf04939bd6..6e2c8d54f3 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MDXProp.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MDXProp.cpp @@ -55,5 +55,11 @@ void MDXProp::readFields(CFRecord& record) record >> frtHeader >> istrConnName >> tfnSrc >> istrMbr >> istrProp; } +void MDXProp::writeFields(CFRecord& record) +{ + frtHeader.rt = rt_MDXProp; + record << frtHeader << istrConnName << tfnSrc << istrMbr << istrProp; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MDXProp.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MDXProp.h index 59c511704c..0b6452d55a 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MDXProp.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MDXProp.h @@ -48,11 +48,12 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); //----------------------------- - _INT32 istrConnName; - unsigned char tfnSrc; - _UINT32 istrMbr; - _UINT32 istrProp; + _INT32 istrConnName = 0; + unsigned char tfnSrc = 0; + _UINT32 istrMbr = 0; + _UINT32 istrProp = 0; FrtHeader frtHeader; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MDXSet.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MDXSet.cpp index 6d453edcaa..2440f94141 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MDXSet.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MDXSet.cpp @@ -62,5 +62,24 @@ void MDXSet::readFields(CFRecord& record) } } +void MDXSet::writeFields(CFRecord& record) +{ + frtHeader.rt = rt_MDXTuple; + record << frtHeader << istrConnName << tfnSrc << sso << istrSetDef << cistr; + const auto maxElemCount = 2049; + if(rgistr.size() < maxElemCount) + { + for(auto i : rgistr) + if(i != nullptr) + record << *i; + } + else + { + for(auto i = 0; i < maxElemCount; i++) + if(rgistr[i] != nullptr) + record << *rgistr[i]; + } +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MDXSet.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MDXSet.h index e97f4de776..2f8aa059ba 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MDXSet.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MDXSet.h @@ -49,12 +49,13 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); //----------------------------- - _INT32 istrConnName; - unsigned char tfnSrc; - unsigned char sso; - _UINT32 istrSetDef; - _INT32 cistr; + _INT32 istrConnName = 0; + unsigned char tfnSrc = 0; + unsigned char sso = 0; + _UINT32 istrSetDef = 0; + _INT32 cistr = 0; BiffStructurePtrVector rgistr; FrtHeader frtHeader; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MDXStr.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MDXStr.cpp index aa7cf8f8b0..9dd61b1eac 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MDXStr.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MDXStr.cpp @@ -55,5 +55,18 @@ void MDXStr::readFields(CFRecord& record) record >> frtHeader >> st; } +void MDXStr::writeFields(CFRecord& record) +{ + frtHeader.rt = rt_MDXStr; + record << frtHeader; + if(st.getSize() <= 4104) + record << st; + else + { + LPWideString tempVal = st.value().substr(0, 4104); + record << tempVal; + } +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MDXStr.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MDXStr.h index 3391981457..3d187a2a8d 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MDXStr.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MDXStr.h @@ -50,6 +50,7 @@ public: void readFields(CFRecord& record); + void writeFields(CFRecord& record); //----------------------------- LPWideString st; FrtHeader frtHeader; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MDXTuple.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MDXTuple.cpp index d5c42c6180..36e40410f7 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MDXTuple.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MDXTuple.cpp @@ -62,5 +62,24 @@ void MDXTuple::readFields(CFRecord& record) } } +void MDXTuple::writeFields(CFRecord& record) +{ + frtHeader.rt = rt_MDXTuple; + record << frtHeader << istrConnName << tfnSrc << cistr; + const auto maxElemCount = 2050; + if(rgistr.size() < maxElemCount) + { + for(auto i : rgistr) + if(i != nullptr) + record << *i; + } + else + { + for(auto i = 0; i < maxElemCount; i++) + if(rgistr[i] != nullptr) + record << *rgistr[i]; + } +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MDXTuple.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MDXTuple.h index f10983720a..ab80abddba 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MDXTuple.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MDXTuple.h @@ -49,13 +49,15 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); + static const ElementType type = typeMDXTuple; //----------------------------- - _INT32 istrConnName; - unsigned char tfnSrc; - _INT32 cistr; + _INT32 istrConnName = 0; + unsigned char tfnSrc = 0; + _INT32 cistr = 0; BiffStructurePtrVector rgistr; FrtHeader frtHeader; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MTRSettings.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MTRSettings.cpp index 41f77c3d55..a829ce3571 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MTRSettings.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MTRSettings.cpp @@ -31,7 +31,7 @@ */ #include "MTRSettings.h" - +#include "../Biff_structures/FrtHeader.h" namespace XLS { @@ -61,5 +61,15 @@ void MTRSettings::readFields(CFRecord& record) fUserSetThreadCount = temp2; } +void MTRSettings::writeFields(CFRecord& record) +{ + FrtHeader header(rt_MTRSettings); + record << header; + _UINT32 flags1 = 0, flags2 = 0; + flags1 = fMTREnabled; + flags2 = fUserSetThreadCount; + record << flags1 << flags2 << cUserThreadCount; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MTRSettings.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MTRSettings.h index b39547c400..2aa26e4403 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MTRSettings.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MTRSettings.h @@ -50,11 +50,12 @@ public: void readFields(CFRecord& record); + void writeFields(CFRecord& record); //----------------------------- - bool fMTREnabled; - bool fUserSetThreadCount; + bool fMTREnabled = false; + bool fUserSetThreadCount = false; - _UINT32 cUserThreadCount; + _UINT32 cUserThreadCount = 0; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MarkerFormat.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MarkerFormat.cpp index 617facb729..51e0900d63 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MarkerFormat.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MarkerFormat.cpp @@ -80,6 +80,16 @@ void MarkerFormat::readFields(CFRecord& record) fNotShowInt = GETBIT(flags, 4); fNotShowBrd = GETBIT(flags, 5); } + +void MarkerFormat::writeFields(CFRecord& record) +{ + unsigned short flags = 0; + SETBIT(flags, 0, fAuto) + SETBIT(flags, 4, fNotShowInt) + SETBIT(flags, 5, fNotShowBrd) + record << rgbFore << rgbBack << imk << flags << icvFore << icvBack << miSize; +} + int MarkerFormat::serialize(std::wostream & _stream) { return serialize(_stream, -1, BaseObjectPtr()); diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MarkerFormat.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MarkerFormat.h index 318427e6a1..79d3877d45 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MarkerFormat.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MarkerFormat.h @@ -48,6 +48,7 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); int serialize(std::wostream & _stream, int index, BaseObjectPtr _GELFRAME); int serialize(std::wostream & _stream); @@ -55,14 +56,14 @@ public: LongRGB rgbFore; LongRGB rgbBack; - _UINT16 imk; - bool fAuto; - bool fNotShowInt; - bool fNotShowBrd; + _UINT16 imk = 0; + bool fAuto = false; + bool fNotShowInt = false; + bool fNotShowBrd = false; - IcvChart icvFore; - IcvChart icvBack; - _UINT32 miSize; + IcvChart icvFore = 0; + IcvChart icvBack = 0; + _UINT32 miSize = 0; GlobalWorkbookInfoPtr global_info; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MergeCells.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MergeCells.cpp index aa64e9fd46..82612c1936 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MergeCells.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MergeCells.cpp @@ -62,6 +62,13 @@ void MergeCells::readFields(CFRecord& record) } } +void MergeCells::writeFields(CFRecord& record) +{ + cmcs = rgref.size(); + for(auto i : rgref) + record << *i; +} + int MergeCells::serialize(std::wostream & stream) { CP_XML_WRITER(stream) diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MergeCells.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MergeCells.h index 27b6afd547..daa4b6db89 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MergeCells.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MergeCells.h @@ -51,13 +51,14 @@ public: void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeMergeCells; int serialize(std::wostream & stream); //----------------------------- - _UINT16 cmcs; + _UINT16 cmcs = 0; BiffStructurePtrVector rgref; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Mms.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Mms.cpp index 56837cad18..96cb982a8e 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Mms.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Mms.cpp @@ -58,4 +58,11 @@ void Mms::readFields(CFRecord& record) record.skipNunBytes(2); // reserved } + +void Mms::writeFields(CFRecord& record) +{ + // This record is reserved and MUST be ignored. + record.reserveNunBytes(2); // reserved +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Mms.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Mms.h index e114d5c2da..61008d4add 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Mms.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Mms.h @@ -52,6 +52,7 @@ public: void readFields(CFRecord& record); + void writeFields(CFRecord& record); }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MulBlank.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MulBlank.cpp index a9823b3d5d..c35ff468c4 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MulBlank.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MulBlank.cpp @@ -97,7 +97,13 @@ void MulBlank::readFields(CFRecord& record) record.skipNunBytes(sizeof(unsigned short)); } - +void MulBlank::writeFields(CFRecord& record) +{ + record << rw << colFirst; + for(auto i:rgixfe.rgixfe) + record << i; + record << colLast; +} const int MulBlank::GetRow() const { return static_cast(rw); diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MulBlank.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MulBlank.h index 29dd9c1a48..d068224ce7 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MulBlank.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MulBlank.h @@ -64,6 +64,7 @@ public: void readFields(CFRecord& record); + void writeFields(CFRecord& record); const int GetRow() const; const int GetColumn() const; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MulRk.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MulRk.cpp index a14280fa8c..9b475e9902 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MulRk.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MulRk.cpp @@ -68,6 +68,14 @@ void MulRk::readFields(CFRecord& record) record.skipNunBytes(sizeof(unsigned short)); } +void MulRk::writeFields(CFRecord& record) +{ + record << rw << colFirst; + for(auto i:rgrkrec) + record << i; + record << colLast; +} + const int MulRk::GetRow() const { return static_cast(rw); diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MulRk.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MulRk.h index ab675f5e3b..99d27027a1 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MulRk.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MulRk.h @@ -49,6 +49,7 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); const int GetRow() const; const int GetColumn() const; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Note.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Note.cpp index d4da364faa..d7e6739f92 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Note.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Note.cpp @@ -63,5 +63,10 @@ void Note::readFields(CFRecord& record) // } } +void Note::writeFields(CFRecord& record) +{ + record << note_sh; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Note.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Note.h index 50f9b2934a..9c12d8312f 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Note.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Note.h @@ -48,6 +48,7 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeNote; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Number.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Number.cpp index 5c25ca8a63..24d84775f8 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Number.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Number.cpp @@ -80,6 +80,12 @@ void Number::readFields(CFRecord& record) record >> val; } } + +void Number::writeFields(CFRecord& record) +{ + record << cell << num; +} + const CellRef Number::getLocation() const { return cell.getLocation(); diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Number.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Number.h index 739e27de6e..e39d43e709 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Number.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Number.h @@ -50,6 +50,8 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); + static const ElementType type = typeNumber; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ObjProtect.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ObjProtect.cpp index 61eacad02c..fb5aa9813e 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ObjProtect.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ObjProtect.cpp @@ -55,5 +55,10 @@ void ObjProtect::readFields(CFRecord& record) record >> fLockObj; } +void ObjProtect::writeFields(CFRecord& record) +{ + record << fLockObj; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ObjProtect.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ObjProtect.h index e7fa6acf8e..3330cac17a 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ObjProtect.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ObjProtect.h @@ -48,11 +48,12 @@ public: void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeObjProtect; //----------------------------- - Boolean fLockObj; + Boolean fLockObj = false; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ObjectLink.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ObjectLink.cpp index eeb14a9f03..01cf4e4c1a 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ObjectLink.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ObjectLink.cpp @@ -60,5 +60,10 @@ void ObjectLink::readFields(CFRecord& record) testLinkVar2= wLinkVar2; } +void ObjectLink::writeFields(CFRecord& record) +{ + record << wLinkObj << wLinkVar1 << wLinkVar2; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ObjectLink.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ObjectLink.h index 5d8d308ea9..14e6316c64 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ObjectLink.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ObjectLink.h @@ -50,18 +50,19 @@ public: void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeObjectLink; - _UINT16 wLinkObj; - _UINT16 wLinkVar1; - _UINT16 wLinkVar2; + _UINT16 wLinkObj = 0; + _UINT16 wLinkVar1 = 0; + _UINT16 wLinkVar2 = 0; //------------------------------- - int testLinkObj; - int testLinkVar1; - int testLinkVar2; + int testLinkObj = 0; + int testLinkVar1 = 0; + int testLinkVar2 = 0; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/OleDbConn.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/OleDbConn.cpp index 62443ba700..d21ade73a6 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/OleDbConn.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/OleDbConn.cpp @@ -60,5 +60,16 @@ void OleDbConn::readFields(CFRecord& record) record.skipNunBytes(4); //reserved2 } +void OleDbConn::writeFields(CFRecord& record) +{ + unsigned short flags = 0; + + SETBIT(flags, 0, fPasswd) + SETBIT(flags, 1, fLocal) + + record << frtHeaderOld << flags << cst; + record.reserveNunBytes(4); +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/OleDbConn.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/OleDbConn.h index 97cddf9151..1596863b53 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/OleDbConn.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/OleDbConn.h @@ -48,13 +48,14 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeOleDbConn; FrtHeaderOld frtHeaderOld; - bool fPasswd; - bool fLocal; - unsigned short cst; + bool fPasswd = false; + bool fLocal = false; + unsigned short cst = 0; }; } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/PLV.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/PLV.cpp index 24fea82667..e2fd6717a1 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/PLV.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/PLV.cpp @@ -62,5 +62,17 @@ void PLV::readFields(CFRecord& record) fWhitespaceHidden = GETBIT(flags, 2); } +void PLV::writeFields(CFRecord& record) +{ + FrtHeader frtHeader(rt_PLV); + record << frtHeader; + unsigned short flags = 0; + SETBIT(flags, 0, fPageLayoutView); + SETBIT(flags, 1, fRulerVisible); + SETBIT(flags, 2, fWhitespaceHidden); + record << wScalePLV << flags; + +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/PLV.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/PLV.h index 52449a4704..18fec409b6 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/PLV.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/PLV.h @@ -50,15 +50,16 @@ public: void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typePLV; //----------------------------- _UINT16 wScalePLV; - bool fPageLayoutView; - bool fRulerVisible; - bool fWhitespaceHidden; + bool fPageLayoutView = false; + bool fRulerVisible = true; + bool fWhitespaceHidden = false; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Palette.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Palette.cpp index e9005b9834..2c6643e5c7 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Palette.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Palette.cpp @@ -87,6 +87,15 @@ void Palette::readFields(CFRecord& record) } } +void Palette::writeFields(CFRecord& record) +{ + ccv = rgColor.size(); + record << ccv; + for(auto i: rgColor) + if(i != nullptr) + record << i; +} + int Palette::serialize(std::wostream & stream) diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Palette.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Palette.h index 9dd9751146..68ea77791e 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Palette.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Palette.h @@ -51,6 +51,7 @@ public: void readFields(CFRecord& record); + void writeFields(CFRecord& record); int serialize(std::wostream & stream); @@ -58,7 +59,7 @@ public: //----------------------------- BiffStructurePtrVector rgColor; - unsigned short ccv; + unsigned short ccv = 0; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Password.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Password.cpp index 331b58a311..6e7be227c1 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Password.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Password.cpp @@ -31,6 +31,7 @@ */ #include "Password.h" +#include namespace XLS { @@ -57,5 +58,16 @@ void Password::readFields(CFRecord& record) wPassword = STR::int2hex_wstr(wPassword_num, sizeof(wPassword_num)); } +void Password::writeFields(CFRecord& record) +{ + if(wPassword_num == 0 && !wPassword.empty()) + { + std::wstringstream ss; + ss << std::hex << wPassword; + ss >> wPassword_num; + } + record << wPassword_num; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Password.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Password.h index 71d8b587c8..fa4c386afd 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Password.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Password.h @@ -47,12 +47,13 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typePassword; //----------------------------- - unsigned short wPassword_num; - std::wstring wPassword; + unsigned short wPassword_num = 0; + std::wstring wPassword = L""; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Pie.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Pie.cpp index 2388fa51d2..2a6ef4dcd2 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Pie.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Pie.cpp @@ -59,6 +59,14 @@ void Pie::readFields(CFRecord& record) fShowLdrLines = GETBIT(flags, 1); } +void Pie::writeFields(CFRecord& record) +{ + unsigned short flags = 0; + SETBIT(flags, 0, fHasShadow) + SETBIT(flags, 1, fShowLdrLines) + record << anStart << pcDonut << flags; +} + int Pie::serialize(std::wostream & _stream) { CP_XML_WRITER(_stream) diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Pie.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Pie.h index 42fafb69f0..364359ffd0 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Pie.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Pie.h @@ -50,16 +50,17 @@ public: void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typePie; int serialize(std::wostream & _stream); //----------------------------- - _UINT16 anStart; - _UINT16 pcDonut; - bool fHasShadow; - bool fShowLdrLines; + _UINT16 anStart = 0; + _UINT16 pcDonut = 0; + bool fHasShadow = false; + bool fShowLdrLines = false; }; } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/PivotChartBits.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/PivotChartBits.cpp index 7d9a0e1b3b..968cc0017c 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/PivotChartBits.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/PivotChartBits.cpp @@ -56,5 +56,15 @@ void PivotChartBits::readFields(CFRecord& record) fGXHide = GETBIT(flags, 0); } +void PivotChartBits::writeFields(CFRecord& record) +{ + record << rt; + record.reserveNunBytes(2); + unsigned short flags; + SETBIT(flags, 0, fGXHide); + record << flags; + record.reserveNunBytes(6); +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/PivotChartBits.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/PivotChartBits.h index 3379e2467a..61dff57afd 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/PivotChartBits.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/PivotChartBits.h @@ -47,11 +47,12 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typePivotChartBits; - unsigned short rt; - bool fGXHide; + unsigned short rt = 0x0859; + bool fGXHide = false; }; } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/PlotGrowth.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/PlotGrowth.cpp index 5e07620f8e..f800831d49 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/PlotGrowth.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/PlotGrowth.cpp @@ -56,5 +56,10 @@ void PlotGrowth::readFields(CFRecord& record) record >> dxPlotGrowth >> dyPlotGrowth; } +void PlotGrowth::writeFields(CFRecord& record) +{ + record << dxPlotGrowth << dyPlotGrowth; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/PlotGrowth.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/PlotGrowth.h index c8adfc2f32..891e43ce99 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/PlotGrowth.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/PlotGrowth.h @@ -51,6 +51,7 @@ public: void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typePlotGrowth; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Pos.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Pos.cpp index 026bb30342..6dde32a08f 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Pos.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Pos.cpp @@ -69,6 +69,18 @@ void Pos::readFields(CFRecord& record) record >> y2; record.skipNunBytes(2); // unused4 } +void Pos::writeFields(CFRecord& record) +{ + record << mdTopLt << mdBotRt; + record << x1; + record.reserveNunBytes(2); // unused1 + record << y1; + record.reserveNunBytes(2); // unused2 + record << x2; + record.reserveNunBytes(2); // unused3 + record << y2; + record.reserveNunBytes(2); // unused4 +} int Pos::serialize(std::wostream & _stream) { diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Pos.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Pos.h index a6c6b2b125..2864404b19 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Pos.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Pos.h @@ -49,6 +49,7 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); GlobalWorkbookInfoPtr pGlobalWorkbookInfoPtr; @@ -56,18 +57,18 @@ public: static const ElementType type = typePos; - _UINT16 mdTopLt; - _UINT16 mdBotRt; + _UINT16 mdTopLt = 0; + _UINT16 mdBotRt = 0; - _INT16 x1; - _INT16 y1; - _INT16 x2; - _INT16 y2; + _INT16 x1 = 0; + _INT16 y1 = 0; + _INT16 x2 = 0; + _INT16 y2 = 0; //----------------------------- - int m_iLayoutTarget; - short m_iLinkObject; + int m_iLayoutTarget = 0; + short m_iLinkObject = 0; BaseObjectPtr m_Frame; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/PrintGrid.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/PrintGrid.cpp index 7570f7eb95..b10058aeff 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/PrintGrid.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/PrintGrid.cpp @@ -57,5 +57,12 @@ void PrintGrid::readFields(CFRecord& record) fPrintGrid = GETBIT(flags, 0); } +void PrintGrid::writeFields(CFRecord& record) +{ + unsigned short flags = 0; + SETBIT(flags, 0, fPrintGrid); + record << flags; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/PrintGrid.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/PrintGrid.h index 65d88db077..a58aa70fa4 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/PrintGrid.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/PrintGrid.h @@ -50,11 +50,13 @@ public: void readFields(CFRecord& record); + void writeFields(CFRecord& record); + static const ElementType type = typePrintGrid; //----------------------------- - bool fPrintGrid; + bool fPrintGrid = false; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/PrintRowCol.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/PrintRowCol.cpp index 8eace8b2b4..06384f147e 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/PrintRowCol.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/PrintRowCol.cpp @@ -55,5 +55,10 @@ void PrintRowCol::readFields(CFRecord& record) record >> printRwCol; } +void PrintRowCol::writeFields(CFRecord& record) +{ + record << printRwCol; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/PrintRowCol.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/PrintRowCol.h index f43e7d81ca..29ca12cd0e 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/PrintRowCol.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/PrintRowCol.h @@ -50,12 +50,13 @@ public: void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typePrintRowCol; //----------------------------- - Boolean printRwCol; + Boolean printRwCol = false; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/PrintSize.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/PrintSize.cpp index 31a9a29594..e277b3e23d 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/PrintSize.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/PrintSize.cpp @@ -55,5 +55,10 @@ void PrintSize::readFields(CFRecord& record) record >> printSize; } +void PrintSize::writeFields(CFRecord& record) +{ + record << printSize; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/PrintSize.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/PrintSize.h index 5ea6e7c037..2d18dbf142 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/PrintSize.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/PrintSize.h @@ -50,11 +50,12 @@ public: void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typePrintSize; //----------------------------- - _UINT16 printSize; + _UINT16 printSize = 0; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Prot4Rev.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Prot4Rev.cpp index 63769e65ef..ba78c9feb5 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Prot4Rev.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Prot4Rev.cpp @@ -55,5 +55,11 @@ void Prot4Rev::readFields(CFRecord& record) record >> fRevLock; } +void Prot4Rev::writeFields(CFRecord& record) +{ + record << fRevLock; +} + + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Prot4Rev.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Prot4Rev.h index 2fe0df9362..9c7afdb6e9 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Prot4Rev.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Prot4Rev.h @@ -49,12 +49,13 @@ public: BaseObjectPtr clone(); - void readFields(CFRecord& record); + void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeProt4Rev; //----------------------------- - Boolean fRevLock; + Boolean fRevLock = false; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Prot4RevPass.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Prot4RevPass.cpp index e07e92f48e..cb44c287eb 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Prot4RevPass.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Prot4RevPass.cpp @@ -31,6 +31,7 @@ */ #include "Prot4RevPass.h" +#include namespace XLS { @@ -57,5 +58,16 @@ void Prot4RevPass::readFields(CFRecord& record) protPwdRev = STR::int2hex_wstr(protPwdRev_num, sizeof(protPwdRev_num)); } +void Prot4RevPass::writeFields(CFRecord& record) +{ + if(protPwdRev_num == 0 && !protPwdRev.empty()) + { + std::wstringstream ss; + ss << std::hex << protPwdRev; + ss >> protPwdRev; + } + record << protPwdRev_num; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Prot4RevPass.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Prot4RevPass.h index 342eb120df..04f7bd1331 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Prot4RevPass.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Prot4RevPass.h @@ -50,12 +50,13 @@ public: void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeProt4RevPass; //----------------------------- - unsigned short protPwdRev_num; - std::wstring protPwdRev; + unsigned short protPwdRev_num = 0; + std::wstring protPwdRev = L""; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Protect.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Protect.cpp index 60bb5d0f50..5a8fb5e2f1 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Protect.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Protect.cpp @@ -55,5 +55,10 @@ void Protect::readFields(CFRecord& record) record >> fLock; } +void Protect::writeFields(CFRecord& record) +{ + record << fLock; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Protect.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Protect.h index b7e8ee7001..889a4f148a 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Protect.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Protect.h @@ -48,11 +48,12 @@ public: void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeProtect; //----------------------------- - Boolean fLock; + Boolean fLock = 0; }; } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Qsi.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Qsi.h index 969fbc6e63..16bd90750c 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Qsi.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Qsi.h @@ -52,33 +52,33 @@ public: static const ElementType type = typeQsi; - bool fTitles; - bool fRowNums; - bool fDisableRefresh; - bool fAsync; - bool fNewAsync; - bool fAutoRefresh; - bool fShrink; - bool fFill; - bool fAutoFormat; - bool fSaveData; - bool fDisableEdit; - bool fOverwrite; - unsigned short itblAutoFmt; //AutoFmt8 - bool fibitAtrNum; - bool fibitAtrFnt; - bool fibitAtrAlc; - bool fibitAtrBdr; - bool fibitAtrPat; - bool fibitAtrProt; + bool fTitles = false; + bool fRowNums = false; + bool fDisableRefresh = false; + bool fAsync = false; + bool fNewAsync = false; + bool fAutoRefresh = false; + bool fShrink = false; + bool fFill = false; + bool fAutoFormat = false; + bool fSaveData = false; + bool fDisableEdit = false; + bool fOverwrite = false; + unsigned short itblAutoFmt = 0; //AutoFmt8 + bool fibitAtrNum = false; + bool fibitAtrFnt = false; + bool fibitAtrAlc = false; + bool fibitAtrBdr = false; + bool fibitAtrPat = false; + bool fibitAtrProt = false; //biff12 - _UINT32 dwConnID; - bool fDummyList; - bool fAutoFit; - bool fPreserveFmt; + _UINT32 dwConnID = 0; + bool fDummyList = false; + bool fAutoFit = false; + bool fPreserveFmt = false; - std::wstring name; + std::wstring name = L""; }; } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/QsiSXTag.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/QsiSXTag.cpp index 920c2f92b5..b6899adc48 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/QsiSXTag.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/QsiSXTag.cpp @@ -92,5 +92,36 @@ void QsiSXTag::readFields(CFRecord& record) record.skipNunBytes(skip); } +void QsiSXTag::writeFields(CFRecord& record) +{ + frtHeaderOld.rt = rt_QsiSXTag; + unsigned short flags = 0; + SETBIT(flags, 0, fEnableRefresh) + SETBIT(flags, 1, fInvalid) + SETBIT(flags, 2, fTensorEx) + record << frtHeaderOld << fSx << flags; + if (fSx) + { + //dwQsiFuture is SXView9Save + SETBIT(dwQsiFuture, 0, fNoStencil) + SETBIT(dwQsiFuture, 1, fHideTotAnnotation) + SETBIT(dwQsiFuture, 3, fIncludeEmptyRw) + SETBIT(dwQsiFuture, 4, fIncludeEmptyCol) + } + else + { + //dwQsiFuture is DwQsiFuture + SETBIT(dwQsiFuture, 0, fPreserveFmt) + SETBIT(dwQsiFuture, 1, fAutoFit) + SETBIT(dwQsiFuture, 4, fExtDataList) + SETBIT(dwQsiFuture, 6, fCreateQTList) + SETBIT(dwQsiFuture, 7, fDummyList) + } + record << dwQsiFuture << verSxLastUpdated << verSxUpdatableMin << obCchName; + record.reserveNunBytes(1); + record << stName; + record.reserveNunBytes(2); +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/QsiSXTag.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/QsiSXTag.h index 727de668ea..487eb86945 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/QsiSXTag.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/QsiSXTag.h @@ -49,21 +49,22 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeQsiSXTag; FrtHeaderOld frtHeaderOld; - unsigned short fSx; + unsigned short fSx = 0; - bool fEnableRefresh; - bool fInvalid; - bool fTensorEx; + bool fEnableRefresh = false; + bool fInvalid = false; + bool fTensorEx = false; - _UINT32 dwQsiFuture; - unsigned char verSxLastUpdated; - unsigned char verSxUpdatableMin; + _UINT32 dwQsiFuture = 0; + unsigned char verSxLastUpdated = 0; + unsigned char verSxUpdatableMin = 0; - unsigned char obCchName; + unsigned char obCchName = 0x10; XLUnicodeString stName; _CP_OPT(bool) fNoStencil; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/RK.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/RK.cpp index 27f0dd55a8..11a8abb859 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/RK.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/RK.cpp @@ -61,6 +61,13 @@ void RK::readFields(CFRecord& record) cell = Cell(rw, col, rkrec.get_ixfe()); } +void RK::writeFields(CFRecord& record) +{ + Rw rw = cell.rw; + Col col = cell.col; + + record << rw << col << rkrec; +} const CellRef RK::getLocation() const { diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/RK.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/RK.h index 62c9cbe28f..4ea0977cf3 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/RK.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/RK.h @@ -49,6 +49,7 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeRK; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/RRTabId.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/RRTabId.cpp index 2f740e071b..096d1e110a 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/RRTabId.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/RRTabId.cpp @@ -60,5 +60,18 @@ void RRTabId::readFields(CFRecord& record) } } +void RRTabId::writeFields(CFRecord& record) +{ + for(auto i : sheet_ids) + { + record << *i; + } + if(sheet_ids.empty()) + { + SheetId sheetId1; + record << sheetId1; + } +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/RRTabId.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/RRTabId.h index 4b9f330317..394b0a22a0 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/RRTabId.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/RRTabId.h @@ -47,6 +47,7 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeRRTabId; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Radar.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Radar.cpp index 430bb14efe..5d8f401c00 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Radar.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Radar.cpp @@ -61,6 +61,15 @@ void Radar::readFields(CFRecord& record) record.skipNunBytes(2); // unused } +void Radar::writeFields(CFRecord& record) +{ + unsigned short flags = 0; + SETBIT(flags, 0, fRdrAxLab) + SETBIT(flags, 1, fHasShadow) + record << flags; + record.reserveNunBytes(2); +} + int Radar::serialize(std::wostream & _stream) { CP_XML_WRITER(_stream) diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Radar.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Radar.h index 2659e973a8..33825eed47 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Radar.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Radar.h @@ -50,14 +50,15 @@ public: void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeRadar; int serialize(std::wostream & _stream); //----------------------------- - bool fRdrAxLab; - bool fHasShadow; + bool fRdrAxLab = false; + bool fHasShadow = false; }; } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/RadarArea.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/RadarArea.cpp index 58dc8d8067..aacc47bd59 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/RadarArea.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/RadarArea.cpp @@ -62,6 +62,15 @@ void RadarArea::readFields(CFRecord& record) record.skipNunBytes(2); // unused } +void RadarArea::writeFields(CFRecord& record) +{ + unsigned short flags = 0; + SETBIT(flags, 0, fRdrAxLab) + SETBIT(flags, 1, fHasShadow) + record << flags; + record.reserveNunBytes(2); +} + int RadarArea::serialize(std::wostream & _stream) { CP_XML_WRITER(_stream) diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/RadarArea.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/RadarArea.h index fcb5ef9cbc..0cc35e136d 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/RadarArea.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/RadarArea.h @@ -50,14 +50,15 @@ public: void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeRadarArea; int serialize(std::wostream & _stream); //----------------------------- - bool fRdrAxLab; - bool fHasShadow; + bool fRdrAxLab = false; + bool fHasShadow = false; }; } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/RefreshAll.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/RefreshAll.cpp index 5cd6369d77..6f9b9ac23d 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/RefreshAll.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/RefreshAll.cpp @@ -55,5 +55,10 @@ void RefreshAll::readFields(CFRecord& record) record >> refreshAll; } +void RefreshAll::writeFields(CFRecord& record) +{ + record << refreshAll; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/RefreshAll.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/RefreshAll.h index 9706d1e3ff..5c447e7270 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/RefreshAll.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/RefreshAll.h @@ -48,13 +48,14 @@ public: BaseObjectPtr clone(); - + void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeRefreshAll; //----------------------------- - Boolean refreshAll; + Boolean refreshAll = false; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/RightMargin.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/RightMargin.cpp index da3df84a8d..047afdbb6f 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/RightMargin.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/RightMargin.cpp @@ -37,6 +37,7 @@ namespace XLS RightMargin::RightMargin() { + num.data.value = 0.7; } @@ -55,5 +56,10 @@ void RightMargin::readFields(CFRecord& record) record >> num; } +void RightMargin::writeFields(CFRecord& record) +{ + record << num; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/RightMargin.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/RightMargin.h index e71450383b..64a21b503a 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/RightMargin.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/RightMargin.h @@ -47,6 +47,7 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeRightMargin; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Row.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Row.cpp index a10f929fef..e888f47ef6 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Row.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Row.cpp @@ -148,7 +148,7 @@ void Row::writeFields(CFRecord& record) _UINT16 ixfe_val_2b = 0xffff; record << rw_2b << colMic << colMac << miyRw; - _UINT16 unused1, rel_offset = 0xffff, flags1 = 0, flags2 = 0; + _UINT16 rel_offset = 0xffff, flags1 = 0, flags2 = 0; record.reserveNunBytes(2);// unused1 if (ixfe_val != 0xffff) @@ -181,6 +181,7 @@ void Row::writeFields(CFRecord& record) SETBIT(flags1, 5, fDyZero) SETBIT(flags1, 6, fUnsynced) SETBIT(flags1, 7, fGhostDirty) + SETBIT(flags1, 8, 1)// reserved3 must be 1 SETBITS(flags2, 0, 11, ixfe_val_2b) SETBIT(flags2, 12, fExAsc) diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Row.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Row.h index edbcfa17c1..ceb112cd56 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Row.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Row.h @@ -53,10 +53,10 @@ namespace XLS static const ElementType type = typeRow; - UncheckedRw rw; - unsigned short colMic; - unsigned short colMac; - _UINT16 miyRw; + UncheckedRw rw = 0; + unsigned short colMic = 0; + unsigned short colMac = 0; + _UINT16 miyRw = 256; unsigned char iOutLevel = 0; bool fCollapsed = false; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SBaseRef.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SBaseRef.cpp index c2d36283ea..94f63a8722 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SBaseRef.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SBaseRef.cpp @@ -45,5 +45,10 @@ void SBaseRef::readFields(CFRecord& record) record >> ref; } +void SBaseRef::writeFields(CFRecord& record) +{ + record << ref; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SBaseRef.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SBaseRef.h index c62e461f2b..5ef19cfd1d 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SBaseRef.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SBaseRef.h @@ -48,6 +48,7 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeSBaseRef; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SIIndex.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SIIndex.cpp index dc8213cc81..8391add664 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SIIndex.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SIIndex.cpp @@ -63,6 +63,11 @@ void SIIndex::readFields(CFRecord& record) record >> numIndex; } +void SIIndex::writeFields(CFRecord& record) +{ + record << numIndex; +} + int SIIndex::serialize(std::wostream & _stream, int idx, const CellRef & in_ref) { int res = 0; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SIIndex.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SIIndex.h index 3a4e31fa48..8150ed1be3 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SIIndex.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SIIndex.h @@ -52,6 +52,7 @@ public: void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeSIIndex; @@ -59,7 +60,7 @@ public: int serialize(std::wostream & _stream, int idx, const CellRef & in_ref); //----------------------------- - _UINT16 numIndex; + _UINT16 numIndex = 0x0001; std::vector m_arData; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SST.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SST.cpp index 2983208515..0262344c17 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SST.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SST.cpp @@ -82,6 +82,26 @@ void SST::readFields(CFRecord& record) } } +void SST::writeFields(CFRecord& record) +{ + const auto MaxRecordSize = 8224; + cstUnique = rgb.size(); + if(cstTotal == 0 && cstTotal < cstUnique) + cstTotal = cstUnique; + record << cstTotal << cstUnique; + while(!rgb.empty()) + { + auto oldPose = record.getRdPtr(); + record << *rgb.at(0); + if(record.getRdPtr() > MaxRecordSize) + { + record.RollRdPtrBack(record.getRdPtr() - oldPose); + break; + } + rgb.erase(rgb.begin()); + } + +} int SST::serialize(std::wostream & stream) { diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SST.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SST.h index 153050960b..7155e5c27c 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SST.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SST.h @@ -51,14 +51,15 @@ public: void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeSST; int serialize(std::wostream & stream); //----------------------------- - _INT32 cstTotal; - _INT32 cstUnique; + _INT32 cstTotal = 0; + _INT32 cstUnique = 0; BiffStructurePtrVector rgb; //----------------------------- diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXDI.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXDI.cpp index 4de3798de7..fef3111c2d 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXDI.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXDI.cpp @@ -64,6 +64,16 @@ void SXDI::readFields(CFRecord& record) ifmt = global_info->RegisterNumFormat(ifmt, L""); // return update } +void SXDI::writeFields(CFRecord& record) +{ + cchName = stName.getSize(); + record << isxvdData << iiftab << df << isxvd << isxvi << ifmt << cchName; + if (cchName > 0 && cchName < 0xFFFF) + { + record << stName; + } +} + int SXDI::serialize(std::wostream & strm) { CP_XML_WRITER(strm) diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXDI.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXDI.h index f763893724..e03dde07f4 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXDI.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXDI.h @@ -48,18 +48,19 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); int serialize(std::wostream & strm); static const ElementType type = typeSXDI; - short isxvdData; - short iiftab; - short df; - short isxvd; - short isxvi; - unsigned short ifmt; - unsigned short cchName; + short isxvdData = 0; + short iiftab = 0; + short df = 0; + short isxvd = 0; + short isxvi = 0; + unsigned short ifmt = 0; + unsigned short cchName = 0; XLUnicodeStringNoCch stName; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXEx.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXEx.cpp index aac45845c7..8bf9db3a8b 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXEx.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXEx.cpp @@ -106,5 +106,55 @@ void SXEx::readFields(CFRecord& record) record.skipNunBytes(skip); } +void SXEx::writeFields(CFRecord& record) +{ + cchErrorString = stError.getSize(); + cchNullString = stDisplayNull.getSize(); + cchTag = stTag.getSize(); + record << csxformat << cchErrorString << cchNullString << cchTag << csxselect; + _UINT32 flags = 0; + SETBIT(flags, 0, fAcrossPageLay) + SETBITS(flags, 1, 9, cWrapPage) + SETBIT(flags, 16, fEnableWizard) + SETBIT(flags, 17, fEnableDrilldown) + SETBIT(flags, 18, fEnableFieldDialog) + SETBIT(flags, 19, fPreserveFormatting) + SETBIT(flags, 20, fMergeLabels) + SETBIT(flags, 21, fDisplayErrorString) + SETBIT(flags, 22, fDisplayNullString) + SETBIT(flags, 23, fSubtotalHiddenPageItems) + record << crwPage << ccolPage << flags; + + cchPageFieldStyle = stPageFieldStyle.getSize(); + cchTableStyle = stTableStyle.getSize(); + cchVacateStyle = stVacateStyle.getSize(); + record << cchPageFieldStyle << cchTableStyle << cchVacateStyle; + if (cchErrorString > 0 && cchErrorString != 0xffff) + { + record >> stError; + } + if (cchNullString > 0 && cchNullString != 0xffff) + { + record << stDisplayNull; + } + if (cchTag > 0 && cchTag != 0xffff) + { + record << stTag; + } + if (cchPageFieldStyle > 0 && cchPageFieldStyle != 0xffff) + { + record << stPageFieldStyle; + } + if (cchTableStyle > 0 && cchTableStyle != 0xffff) + { + record << cchTableStyle; + } + if (cchVacateStyle > 0 && cchVacateStyle != 0xffff) + { + record << cchVacateStyle; + } + +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXEx.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXEx.h index b3e92f2370..d2cf7e2314 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXEx.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXEx.h @@ -49,32 +49,33 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeSXEx; - unsigned short csxformat; - unsigned short cchErrorString; - unsigned short cchNullString; - unsigned short cchTag; - unsigned short csxselect; + unsigned short csxformat = 0; + unsigned short cchErrorString = 0xFFFF; + unsigned short cchNullString = 0xFFFF; + unsigned short cchTag = 0xFFFF; + unsigned short csxselect = 0; - DRw crwPage; - ColU ccolPage; + DRw crwPage = 0; + ColU ccolPage = 0; - bool fAcrossPageLay; - unsigned char cWrapPage; - bool fEnableWizard; - bool fEnableDrilldown; - bool fEnableFieldDialog; - bool fPreserveFormatting; - bool fMergeLabels; - bool fDisplayErrorString; - bool fDisplayNullString; - bool fSubtotalHiddenPageItems; + bool fAcrossPageLay = false; + unsigned char cWrapPage = 0; + bool fEnableWizard = false; + bool fEnableDrilldown = false; + bool fEnableFieldDialog = false; + bool fPreserveFormatting = false; + bool fMergeLabels = false; + bool fDisplayErrorString = false; + bool fDisplayNullString = false; + bool fSubtotalHiddenPageItems = false; - unsigned short cchPageFieldStyle; - unsigned short cchTableStyle; - unsigned short cchVacateStyle; + unsigned short cchPageFieldStyle = 0; + unsigned short cchTableStyle = 0; + unsigned short cchVacateStyle = 0; XLUnicodeStringNoCch stError; XLUnicodeStringNoCch stDisplayNull; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXLI.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXLI.cpp index a161c7d006..30e1c30866 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXLI.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXLI.cpp @@ -95,5 +95,39 @@ void SXLI::readFields(CFRecord& record) } } +void SXLIItem::save(CFRecord& record) +{ + unsigned short flags = 0; + SETBIT(flags, 0, fMultiDataName) + SETBITS(flags, 1, 8, iData) + SETBIT(flags, 9, fSbt) + SETBIT(flags, 10, fBlock) + SETBIT(flags, 11, fGrand) + SETBIT(flags, 12, fMultiDataOnAxis) + cSic = rgisxvi.size(); + if (fGrand) + isxviMac = 1; + record << cSic << itmType << isxviMac << flags; + for(auto i : rgisxvi) + record << i; +} + +void SXLI::writeFields(CFRecord& record) +{ + const auto maxRecSize = 8224; + while(!m_arItems.empty()) + { + auto itemPose = record.getRdPtr(); + m_arItems.at(0).save(record); + if(record.getRdPtr() > maxRecSize) + { + auto itemSize = record.getRdPtr() - itemPose; + record.RollRdPtrBack(itemSize); + return; + } + m_arItems.erase(m_arItems.begin()); + } +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXLI.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXLI.h index 48a81bb761..1133948626 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXLI.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXLI.h @@ -37,15 +37,17 @@ namespace XLS { struct SXLIItem { - short cSic; - unsigned short itmType; - short isxviMac; - bool fMultiDataName; - unsigned char iData; - bool fSbt; - bool fBlock; - bool fGrand; - bool fMultiDataOnAxis; + void save(CFRecord& record); + + short cSic = 0; + unsigned short itmType = 0; + short isxviMac = 0; + bool fMultiDataName = 0; + unsigned char iData = 0; + bool fSbt = 0; + bool fBlock = 0; + bool fGrand = 0; + bool fMultiDataOnAxis = 0; std::vector rgisxvi; }; @@ -61,11 +63,12 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeSXLI; std::vector m_arItems; - int count; + int count = 0; }; } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXPI.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXPI.cpp index f227067769..e09309a03b 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXPI.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXPI.cpp @@ -63,5 +63,20 @@ void SXPI::readFields(CFRecord& record) } } +void SXPI::writeFields(CFRecord& record) +{ + const auto maxRecSize = 8224; + while(!m_arItems.empty()) + { + record << m_arItems.at(0); + if(record.getRdPtr() > maxRecSize) + { + record.RollRdPtrBack(6); + return; + } + m_arItems.erase(m_arItems.begin()); + } +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXPI.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXPI.h index 7841be22b8..b0c362c391 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXPI.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXPI.h @@ -38,9 +38,9 @@ namespace XLS struct SXPI_Item { - short isxvd; - short isxvi; - short idObj; + short isxvd = 0; + short isxvi = 0; + short idObj = 0; }; class SXPI: public BiffRecordContinued @@ -54,6 +54,7 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeSXPI; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXStreamID.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXStreamID.cpp index 30f2bde98e..f68ba9c746 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXStreamID.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXStreamID.cpp @@ -56,5 +56,10 @@ void SXStreamID::readFields(CFRecord& record) record >> idStm; } +void SXStreamID::writeFields(CFRecord& record) +{ + record << idStm; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXStreamID.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXStreamID.h index e77add4c90..3afede1c59 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXStreamID.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXStreamID.h @@ -47,10 +47,11 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeSXStreamID; - short idStm; + short idStm = 0; }; } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXString.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXString.cpp index a8c0e64cbc..8889011fec 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXString.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXString.cpp @@ -60,6 +60,16 @@ void SXString::readFields(CFRecord& record) } } +void SXString::writeFields(CFRecord& record) +{ + cch = segment.getSize(); + record << cch; + if (cch > 0 && cch < 0xffff) + { + record << segment; + } +} + std::wstring SXString::value() { std::wstring s = segment.value(); diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXString.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXString.h index a4e5f0d063..ed3664a8fc 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXString.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXString.h @@ -48,12 +48,13 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); std::wstring value(); static const ElementType type = typeSXString; - unsigned short cch; + unsigned short cch = 0; XLUnicodeStringNoCch segment; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXTBRGIITM.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXTBRGIITM.cpp index 470531869a..441c7402ab 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXTBRGIITM.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXTBRGIITM.cpp @@ -56,5 +56,10 @@ void SXTBRGIITM::readFields(CFRecord& record) record >> cItems; } +void SXTBRGIITM::writeFields(CFRecord& record) +{ + record << cItems; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXTBRGIITM.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXTBRGIITM.h index 831a6931fc..0f43a286bc 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXTBRGIITM.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXTBRGIITM.h @@ -47,10 +47,11 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeSXTBRGIITM; - unsigned short cItems; + unsigned short cItems = 0; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXTbl.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXTbl.cpp index 5d92eb3601..8be3f4ad0e 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXTbl.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXTbl.cpp @@ -56,5 +56,13 @@ void SXTbl::readFields(CFRecord& record) cPages = GETBITS(cPages, 0, 14); } +void SXTbl::writeFields(CFRecord& record) +{ + unsigned short flags = 0; + SETBIT(flags, 15, fAutoPage); + SETBITS(flags, 0, 14, cPages); + record << cdref << csxtbpg << flags; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXTbl.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXTbl.h index 9f09709c0d..6866f83411 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXTbl.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXTbl.h @@ -47,14 +47,15 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeSXTbl; - unsigned short cdref; - unsigned short csxtbpg; - unsigned short cPages; + unsigned short cdref = 0; + unsigned short csxtbpg = 0; + unsigned short cPages = 0; - bool fAutoPage; + bool fAutoPage = false; }; } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXVDEx.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXVDEx.cpp index 6dc94c47e3..5f4844a59f 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXVDEx.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXVDEx.cpp @@ -90,5 +90,39 @@ void SXVDEx::readFields(CFRecord& record) } } +void SXVDEx::writeFields(CFRecord& record) +{ + unsigned short flags1 = 0; + unsigned char flags2 = 0; + SETBIT(flags1, 0, fShowAllItems) + SETBIT(flags1, 1, fDragToRow) + SETBIT(flags1, 2, fDragToColumn) + SETBIT(flags1, 3, fDragToPage) + SETBIT(flags1, 4, fDragToHide) + SETBIT(flags1, 5, fNotDragToData) + + SETBIT(flags1, 7, fServerBased) + + SETBIT(flags1, 9, fAutoSort) + SETBIT(flags1, 10, fAscendSort) + SETBIT(flags1, 11, fAutoShow) + SETBIT(flags1, 12, fTopAutoShow) + SETBIT(flags1, 13, fCalculatedField) + SETBIT(flags1, 14, fPageBreaksBetweenItems) + SETBIT(flags1, 15, fHideNewItems) + + SETBIT(flags2, 5, fOutline) + SETBIT(flags2, 6, fInsertBlankRow) + SETBIT(flags2, 7, fSubtotalAtTop) + record << flags1 << flags2 << citmAutoShow << isxdiAutoSort << isxdiAutoShow << ifmt; + cchSubName = stSubName.getSize(); + if (cchSubName > 0 && cchSubName < 0xffff) + { + record << cchSubName; + record.reserveNunBytes(8); + record << stSubName; + } +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXVDEx.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXVDEx.h index f72beac8b9..dcf3449ea9 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXVDEx.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXVDEx.h @@ -48,32 +48,33 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeSXVDEx; - bool fShowAllItems; - bool fDragToRow; - bool fDragToColumn; - bool fDragToPage; - bool fDragToHide; - bool fNotDragToData; - bool fServerBased; - bool fAutoSort; - bool fAscendSort; - bool fAutoShow; - bool fTopAutoShow; - bool fCalculatedField; - bool fPageBreaksBetweenItems; - bool fHideNewItems; - bool fOutline; - bool fInsertBlankRow; - bool fSubtotalAtTop; + bool fShowAllItems = false; + bool fDragToRow = false; + bool fDragToColumn = false; + bool fDragToPage = false; + bool fDragToHide = false; + bool fNotDragToData = false; + bool fServerBased = false; + bool fAutoSort = false; + bool fAscendSort = false; + bool fAutoShow = false; + bool fTopAutoShow = false; + bool fCalculatedField = false; + bool fPageBreaksBetweenItems = false; + bool fHideNewItems = false; + bool fOutline = false; + bool fInsertBlankRow = false; + bool fSubtotalAtTop = false; - unsigned char citmAutoShow; - short isxdiAutoSort; - short isxdiAutoShow; - unsigned short ifmt; - unsigned short cchSubName; + unsigned char citmAutoShow = 0; + short isxdiAutoSort = 0; + short isxdiAutoShow = 0; + unsigned short ifmt = 0; + unsigned short cchSubName = 0; XLUnicodeStringNoCch stSubName; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXVI.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXVI.cpp index b8eed49b7d..2554f3922d 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXVI.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXVI.cpp @@ -67,6 +67,23 @@ void SXVI::readFields(CFRecord& record) } } + +void SXVI::writeFields(CFRecord& record) +{ + unsigned short flags = 0; + SETBIT(flags, 0, fHidden) + SETBIT(flags, 1, fHideDetail) + SETBIT(flags, 3, fFormula) + SETBIT(flags, 4, fMissing) + cchName = stName.getSize(); + + record << itmType << flags << iCache << cchName; + if (cchName > 0 && cchName < 0xFFFF) + { + record << stName; + } +} + int SXVI::serialize(std::wostream & strm) { CP_XML_WRITER(strm) diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXVI.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXVI.h index de5ece798d..7338d7f11f 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXVI.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXVI.h @@ -47,12 +47,13 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); int serialize(std::wostream & strm); static const ElementType type = typeSXVI; - unsigned short itmType; //enum + unsigned short itmType = 0; //enum //0x0000 itmtypeData //0x0001 itmtypeDEFAULT //0x0002 itmtypeSUM @@ -67,13 +68,13 @@ public: //0x000B itmtypeVAR //0x000C itmtypeVARP - bool fHidden; - bool fHideDetail; - bool fFormula; - bool fMissing; + bool fHidden = false; + bool fHideDetail = false; + bool fFormula = false; + bool fMissing = false; - short iCache; - unsigned short cchName; + short iCache = 0; + unsigned short cchName = 0; XLUnicodeStringNoCch stName; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXVS.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXVS.cpp index a7582fd51e..421c3d32be 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXVS.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXVS.cpp @@ -55,5 +55,10 @@ void SXVS::readFields(CFRecord& record) record >> sxvs; } +void SXVS::writeFields(CFRecord& record) +{ + record << sxvs; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXVS.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXVS.h index f31de72847..6821fa55bb 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXVS.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXVS.h @@ -47,10 +47,11 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeSXVS; - short sxvs; + short sxvs = 1; //enum //SHEET 0x0001 diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXViewLink.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXViewLink.cpp index 07bca99f97..d694a3207b 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXViewLink.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXViewLink.cpp @@ -63,5 +63,17 @@ void SXViewLink::readFields(CFRecord& record) } } +void SXViewLink::writeFields(CFRecord& record) +{ + record << rt; + record.reserveNunBytes(4); + cch = stPivotTable.getSize(); + record << cch; + if (cch > 0 && cch < 0xff) + { + record << stPivotTable; + } +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXViewLink.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXViewLink.h index 57c04fe96b..6542a58e46 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXViewLink.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SXViewLink.h @@ -48,11 +48,12 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeSXViewLink; - unsigned short rt; - unsigned char cch; + unsigned short rt = 0x0858; + unsigned char cch = 0; XLUnicodeStringNoCch stPivotTable; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Scatter.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Scatter.cpp index 823c3647be..7372cae70a 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Scatter.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Scatter.cpp @@ -60,6 +60,15 @@ void Scatter::readFields(CFRecord& record) fHasShadow = GETBIT(flags, 2); } +void Scatter::writeFields(CFRecord& record) +{ + unsigned short flags = 0; + SETBIT(flags, 0, fBubbles) + SETBIT(flags, 1, fShowNegBubbles) + SETBIT(flags, 2, fHasShadow) + record << pcBubbleSizeRatio << wBubbleSize << flags; +} + int Scatter::serialize(std::wostream & _stream) { CP_XML_WRITER(_stream) diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Scatter.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Scatter.h index 6decf6d816..4c2034ad94 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Scatter.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Scatter.h @@ -47,17 +47,18 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeScatter; int serialize(std::wostream & _stream); //----------------------------- - _UINT16 pcBubbleSizeRatio; - _UINT16 wBubbleSize; - bool fBubbles; - bool fShowNegBubbles; - bool fHasShadow; + _UINT16 pcBubbleSizeRatio = 0; + _UINT16 wBubbleSize = 0; + bool fBubbles = false; + bool fShowNegBubbles = false; + bool fHasShadow = false; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ScenarioProtect.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ScenarioProtect.cpp index 4c7a835097..1362bd2e4d 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ScenarioProtect.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ScenarioProtect.cpp @@ -54,5 +54,10 @@ void ScenarioProtect::readFields(CFRecord& record) record >> fScenProtect; } +void ScenarioProtect::writeFields(CFRecord& record) +{ + record << fScenProtect; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ScenarioProtect.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ScenarioProtect.h index 7c22e642a9..478336888e 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ScenarioProtect.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ScenarioProtect.h @@ -47,11 +47,12 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeScenarioProtect; //----------------------------- - Boolean fScenProtect; + Boolean fScenProtect = false; }; } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Scl.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Scl.cpp index b96fc95db6..66762f54fe 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Scl.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Scl.cpp @@ -56,5 +56,11 @@ void Scl::readFields(CFRecord& record) //Fraction = static_cast(nscl) / static_cast(dscl); } +void Scl::writeFields(CFRecord& record) +{ + record << nscl << dscl; + //Fraction = static_cast(nscl) / static_cast(dscl); +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Scl.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Scl.h index c04ae2ec3e..1992f2c420 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Scl.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Scl.h @@ -50,12 +50,13 @@ public: void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeScl; //----------------------------- - _INT16 nscl; - _INT16 dscl; + _INT16 nscl = 0; + _INT16 dscl = 1; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Selection.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Selection.cpp index 356bc7b570..2242b2d65a 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Selection.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Selection.cpp @@ -38,6 +38,7 @@ namespace XLS Selection::Selection() { + pnn.value() = 0x3; } diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Selection.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Selection.h index f3996fdc5a..917e6cd34d 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Selection.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Selection.h @@ -57,17 +57,17 @@ public: int serialize(std::wostream & stream); - PaneType pnn;//4 byte in biff12 + PaneType pnn;//4 byte in biff12 //R_RwU rwAct; - UncheckedRw rwAct; + UncheckedRw rwAct = 0; //ColU colAct; - UncheckedCol colAct; + UncheckedCol colAct = 0; //_INT16 irefAct; - _UINT32 irefAct; //dwRfxAct in biff12 + _UINT32 irefAct = 0; //dwRfxAct in biff12 - std::wstring sqref; - std::wstring activeCell; + std::wstring sqref = L"A1"; + std::wstring activeCell = L"A1"; //biff12 _UINT32 pnn_xlsb; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SerAuxErrBar.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SerAuxErrBar.cpp index 0b5e71ab15..d3c19ec132 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SerAuxErrBar.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SerAuxErrBar.cpp @@ -57,5 +57,13 @@ void SerAuxErrBar::readFields(CFRecord& record) record >> numValue >> cnum; } +void SerAuxErrBar::writeFields(CFRecord& record) +{ + record << sertm << ebsrc << fTeeTop; + unsigned char reserv = 1; + record << reserv; + record << numValue << cnum; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SerAuxErrBar.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SerAuxErrBar.h index 4a8ba88d55..56d7003a1b 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SerAuxErrBar.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SerAuxErrBar.h @@ -48,15 +48,16 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeSerAuxErrBar; //----------------------------- - unsigned char sertm; - unsigned char ebsrc; - unsigned char fTeeTop; + unsigned char sertm = 0; + unsigned char ebsrc = 0; + unsigned char fTeeTop = 0; Xnum numValue; - _UINT16 cnum; + _UINT16 cnum = 0; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SerAuxTrend.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SerAuxTrend.cpp index ab90499592..2f07309f54 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SerAuxTrend.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SerAuxTrend.cpp @@ -56,5 +56,11 @@ void SerAuxTrend::readFields(CFRecord& record) record >> regt >> ordUser >> numIntercept >> fEquation >> fRSquared >> numForecast >> numBackcast; } +void SerAuxTrend::writeFields(CFRecord& record) +{ + + record << regt << ordUser << numIntercept << fEquation << fRSquared << numForecast << numBackcast; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SerAuxTrend.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SerAuxTrend.h index 814294dace..11690b6075 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SerAuxTrend.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SerAuxTrend.h @@ -49,15 +49,16 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeSerAuxTrend; //----------------------------- - unsigned char regt; - unsigned char ordUser; + unsigned char regt = 0; + unsigned char ordUser = 0; ChartNumNillable numIntercept; - unsigned char fEquation; - unsigned char fRSquared; + unsigned char fEquation = 0; + unsigned char fRSquared = 0; Xnum numForecast; Xnum numBackcast; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SerFmt.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SerFmt.cpp index b226d6b2cb..e45a8bc261 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SerFmt.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SerFmt.cpp @@ -61,5 +61,15 @@ void SerFmt::readFields(CFRecord& record) fArShadow = GETBIT(flags, 2); } +void SerFmt::writeFields(CFRecord& record) +{ + unsigned short flags = 0; + + SETBIT(flags, 0, fSmoothedLine) + SETBIT(flags, 1, f3DBubbles) + SETBIT(flags, 2, fArShadow) + record << flags; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SerFmt.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SerFmt.h index 276f2fbbd0..577ad7b9c1 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SerFmt.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SerFmt.h @@ -50,13 +50,14 @@ public: void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeSerFmt; //----------------------------- - bool fSmoothedLine; - bool f3DBubbles; - bool fArShadow; + bool fSmoothedLine = false; + bool f3DBubbles = false; + bool fArShadow = false; }; } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SerParent.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SerParent.cpp index 9f8cec8773..e1b5f5a676 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SerParent.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SerParent.cpp @@ -58,6 +58,11 @@ void SerParent::readFields(CFRecord& record) record >> series; } +void SerParent::writeFields(CFRecord& record) +{ + record << series; +} + void SerParent::recalc(size_t current_index, std::vector & arSERIESFORMAT) { SerAuxErrBar * err_bars_current = dynamic_cast(m_SerAuxErrBar.get()); diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SerParent.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SerParent.h index f53fef6474..76210017ff 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SerParent.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SerParent.h @@ -46,10 +46,11 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeSerParent; - _UINT16 series; + _UINT16 series = 0; BaseObjectPtr m_SerAuxTrend; BaseObjectPtr m_SerAuxErrBar; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SerToCrt.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SerToCrt.cpp index bc8a9f5974..e874a0b6d9 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SerToCrt.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SerToCrt.cpp @@ -55,5 +55,10 @@ void SerToCrt::readFields(CFRecord& record) record >> id; } +void SerToCrt::writeFields(CFRecord& record) +{ + record << id; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SerToCrt.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SerToCrt.h index 2480c54fea..f916a9ae7f 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SerToCrt.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SerToCrt.h @@ -50,11 +50,12 @@ public: void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeSerToCrt; //----------------------------- - _UINT16 id; + _UINT16 id = 0; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Series.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Series.cpp index c38acc561a..72e14645f1 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Series.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Series.cpp @@ -56,5 +56,10 @@ void Series::readFields(CFRecord& record) record >> sdtX >> sdtY >> cValx >> cValy >> sdtBSize >> cValBSize; } +void Series::writeFields(CFRecord& record) +{ + record << sdtX << sdtY << cValx << cValy << sdtBSize << cValBSize; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Series.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Series.h index c8a2f6fae2..94199c8609 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Series.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Series.h @@ -50,17 +50,18 @@ public: void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeSeries; //----------------------------- - _UINT16 sdtX; - _UINT16 sdtY; - _UINT16 sdtBSize; + _UINT16 sdtX = 0; + _UINT16 sdtY = 0; + _UINT16 sdtBSize = 0; - _UINT16 cValx; - _UINT16 cValy; - _UINT16 cValBSize; + _UINT16 cValx = 0; + _UINT16 cValy = 0; + _UINT16 cValBSize = 0; }; } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SeriesList.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SeriesList.cpp index 850d5fdadf..fa0dbccd01 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SeriesList.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SeriesList.cpp @@ -55,6 +55,10 @@ void SeriesList::readFields(CFRecord& record) rgiser.load(record); } +void SeriesList::writeFields(CFRecord& record) +{ + rgiser.save(record); +} BiffStructurePtr RGISeriesListSpecial::clone() { @@ -75,6 +79,15 @@ void RGISeriesListSpecial::load(CFRecord& record) } } +void RGISeriesListSpecial::save(CFRecord& record) +{ + unsigned short cser = series.size(); + record << cser; + for(auto i : series) + { + record << i; + } +} } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SeriesList.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SeriesList.h index 71eeeb9141..15e497ef1d 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SeriesList.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SeriesList.h @@ -44,6 +44,8 @@ public: virtual void load(CFRecord& record); + virtual void save(CFRecord& record); + static const ElementType type = typeRGISeriesListSpecial; @@ -67,6 +69,7 @@ public: void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeSeriesList; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SeriesText.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SeriesText.cpp index deeb45d14e..6bf3c27def 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SeriesText.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SeriesText.cpp @@ -65,5 +65,11 @@ void SeriesText::readFields(CFRecord& record) record >> stText; } +void SeriesText::writeFields(CFRecord& record) +{ + record.reserveNunBytes(2); + record << stText; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SeriesText.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SeriesText.h index 7322417f93..f03d290a57 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SeriesText.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SeriesText.h @@ -51,6 +51,7 @@ public: void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeSeriesText; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Setup.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Setup.cpp index 3cf7a01dde..0631d94df2 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Setup.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Setup.cpp @@ -38,9 +38,8 @@ namespace XLS { Setup::Setup(bool isChart) -: _isChart(isChart), iPaperSize(0), iScale(255), iRes(0), iVRes(0), iCopies(0), fNoOrient(false), fPortrait(false), iPageStart(1), iErrors(0) { - numHdr.data.value = numFtr.data.value = 0.5; + numHdr.data.value = numFtr.data.value = 0.7875; } Setup::~Setup() {} @@ -135,7 +134,7 @@ void Setup::readFields(CFRecord& record) void Setup::writeFields(CFRecord& record) { - _UINT16 flags; + _UINT16 flags = 0; if (record.getGlobalWorkbookInfo()->Version < 0x0800) { diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Setup.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Setup.h index 4ff608d0db..9f50d033c1 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Setup.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Setup.h @@ -52,25 +52,25 @@ public: static const ElementType type = typeSetup; - _UINT32 iPaperSize = 0; + _UINT32 iPaperSize = 9; _UINT32 iScale = 100; _INT32 iPageStart = 1; - _UINT32 iFitWidth = 0; - _UINT32 iFitHeight = 0; + _UINT32 iFitWidth = 1; + _UINT32 iFitHeight = 1; bool fLeftToRight = false; - bool fPortrait = false; + bool fPortrait = true; bool fNoPls = false; bool fNoColor = false; bool fDraft = false; bool fNotes = false; bool fNoOrient = false; - bool fUsePage = false; + bool fUsePage = true; bool fEndNotes = false; unsigned char iErrors = 0; - _UINT32 iRes = 0; - _UINT32 iVRes = 0; + _UINT32 iRes = 300; + _UINT32 iVRes = 300; Xnum numHdr; Xnum numFtr; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ShapePropsStream.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ShapePropsStream.cpp index 9b8b0c054f..faab943093 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ShapePropsStream.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ShapePropsStream.cpp @@ -69,5 +69,20 @@ void ShapePropsStream::readFields(CFRecord& record) } } +void ShapePropsStream::writeFields(CFRecord& record) +{ + FrtHeader header(rt_ShapePropsStream); + record << header << wObjContext; + record.reserveNunBytes(2); + record << dwChecksum; + _UINT32 cb= xml_.size(); + record << cb; + auto limit = 8200; + if(cb <= limit) + limit = cb; + for(auto i = 0; i < limit; i++) + record << xml_[i]; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ShapePropsStream.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ShapePropsStream.h index 1da945cea2..8f1710e1dc 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ShapePropsStream.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ShapePropsStream.h @@ -50,13 +50,14 @@ public: void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeShapePropsStream; FrtHeader frtHeader; - _UINT16 wObjContext; - _UINT32 dwChecksum; + _UINT16 wObjContext = 0; + _UINT32 dwChecksum = 0; std::string xml_; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SheetExt.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SheetExt.cpp index 960c640697..59c2b72557 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SheetExt.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SheetExt.cpp @@ -70,5 +70,22 @@ void SheetExt::readFields(CFRecord& record) } } +void SheetExt::writeFields(CFRecord& record) +{ + FrtHeader frtHeader(rt_SheetExt); + record << frtHeader; + if(sheetExtOptional.bEnabled) + cb = 0x00000028; + else + cb = 0x00000014; + record << cb; + + _UINT32 flags = 0; + SETBITS(flags, 0, 6, icvPlain) + record << flags; + if(sheetExtOptional.bEnabled) + record << sheetExtOptional; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SheetExt.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SheetExt.h index 253dfb95cc..547faea397 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SheetExt.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SheetExt.h @@ -48,11 +48,12 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeSheetExt; //----------------------------- - _UINT32 cb; + _UINT32 cb = 0; unsigned char icvPlain; SheetExtOptional sheetExtOptional; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ShtProps.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ShtProps.cpp index 9cfa8902ce..44321ca0eb 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ShtProps.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ShtProps.cpp @@ -64,5 +64,18 @@ void ShtProps::readFields(CFRecord& record) record.skipNunBytes(1); // reserved2 } +void ShtProps::writeFields(CFRecord& record) +{ + unsigned short flags = 0; + + SETBIT(flags, 0, fManSerAlloc) + SETBIT(flags, 1, fPlotVisOnly) + SETBIT(flags, 2, fNotSizeWith) + SETBIT(flags, 3, fManPlotArea) + SETBIT(flags, 4, fAlwaysAutoPlotArea) + record << flags << mdBlank; + record.reserveNunBytes(1); +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ShtProps.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ShtProps.h index f6c3158488..607c835546 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ShtProps.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ShtProps.h @@ -50,16 +50,17 @@ public: void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeShtProps; //----------------------------- - bool fManSerAlloc; - bool fManPlotArea; - bool fPlotVisOnly; - bool fNotSizeWith; - bool fAlwaysAutoPlotArea; - unsigned char mdBlank; + bool fManSerAlloc = false; + bool fManPlotArea = false; + bool fPlotVisOnly = false; + bool fNotSizeWith = false; + bool fAlwaysAutoPlotArea = false; + unsigned char mdBlank = 0; }; } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Sort.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Sort.cpp index 070650d0bc..b6c99b2a0e 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Sort.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Sort.cpp @@ -117,5 +117,40 @@ void Sort::readFields(CFRecord& record) record.skipNunBytes(1); // reserved } +void Sort::writeFields(CFRecord& record) +{ + unsigned short flags = 0; + + SETBIT(flags, 0, fCol); + SETBIT(flags, 1, fKey1Dsc); + SETBIT(flags, 2, fKey2Dsc); + SETBIT(flags, 3, fKey3Dsc); + SETBIT(flags, 4, fCaseSensitive); + SETBITS(flags, 5, 9, iOrder); + SETBIT(flags, 10, fAltMethod); + record << flags; + + unsigned char cchKey1 = stKey1.size(); + unsigned char cchKey2 = stKey2.size(); + unsigned char cchKey3 = stKey3.size(); + record << cchKey1 << cchKey2 << cchKey3; + if(cchKey1) + { + XLUnicodeStringNoCch stKey1_ = stKey1; + record << stKey1_; + } + if(cchKey2) + { + XLUnicodeStringNoCch stKey2_ = stKey2; + record << stKey2_; + } + if(cchKey3) + { + XLUnicodeStringNoCch stKey3_ = stKey3; + record << stKey3_; + } + record.reserveNunBytes(1); +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Sort.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Sort.h index 36aff1a3e4..a7d2abd1d3 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Sort.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Sort.h @@ -50,22 +50,23 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeSort; //----------------------------- - bool fCol; - bool fKey1Dsc; - bool fKey2Dsc; - bool fKey3Dsc; - bool fCaseSensitive; - _INT16 iOrder; - bool fAltMethod; + bool fCol = false; + bool fKey1Dsc = false; + bool fKey2Dsc = false; + bool fKey3Dsc = false; + bool fCaseSensitive = false; + _INT16 iOrder = 0; + bool fAltMethod = false; - std::wstring stKey1; - std::wstring stKey2; - std::wstring stKey3; + std::wstring stKey1 = L""; + std::wstring stKey2 = L""; + std::wstring stKey3 = L""; }; } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SortData.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SortData.h index ff323a5e65..05077d25a3 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SortData.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SortData.h @@ -55,13 +55,13 @@ public: static const ElementType type = typeSortData; - bool fCol; - bool fCaseSensitive; - bool fAltMethod; - unsigned char sfp; + bool fCol = false; + bool fCaseSensitive = false; + bool fAltMethod = false; + unsigned char sfp = false; - _UINT32 cconditions; - _UINT32 idParent; + _UINT32 cconditions = 0; + _UINT32 idParent = 0; BiffStructurePtrVector sortCond12Array; FrtHeader frtHeader; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/StartObject.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/StartObject.cpp index 0e3a10158e..279f2a3e2d 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/StartObject.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/StartObject.cpp @@ -58,5 +58,12 @@ void StartObject::readFields(CFRecord& record) record >> iObjectKind >> iObjectContext >> iObjectInstance1 >> iObjectInstance2; } +void StartObject::writeFields(CFRecord& record) +{ + FrtHeaderOld rt(rt_StartObject); + record << rt; + record << iObjectKind << iObjectContext << iObjectInstance1 << iObjectInstance2; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/StartObject.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/StartObject.h index 8261a97761..3a29182bea 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/StartObject.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/StartObject.h @@ -50,14 +50,15 @@ public: void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeStartObject; //----------------------------- - _UINT16 iObjectKind; - _UINT16 iObjectContext; - _UINT16 iObjectInstance1; - _UINT16 iObjectInstance2; + _UINT16 iObjectKind = 0x0010; + _UINT16 iObjectContext = 0; + _UINT16 iObjectInstance1 = 0; + _UINT16 iObjectInstance2 = 0; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/String.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/String.cpp index d6ed3985c4..f5a1bb7dd6 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/String.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/String.cpp @@ -71,5 +71,10 @@ void String::readFields(CFRecord& record) } } +void String::writeFields(CFRecord& record) +{ + record << string; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/String.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/String.h index 674d250ec8..4fc4851ff3 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/String.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/String.h @@ -48,6 +48,7 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeString; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Style.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Style.cpp index 4896464fd7..77aeb82fd0 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Style.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Style.cpp @@ -78,6 +78,18 @@ void Style::readFields(CFRecord& record) } } +void Style::writeFields(CFRecord& record) +{ + unsigned short flags = 0; + SETBITS(flags, 0, 11, ixfe); + SETBIT(flags, 15, fBuiltIn); + record << flags; + if(fBuiltIn) + record << builtInData; + else + record << user; +} + int Style::serialize(std::wostream & stream) { return 0; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Style.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Style.h index dca54a0a88..77b6c49247 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Style.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Style.h @@ -49,16 +49,17 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeStyle; int serialize(std::wostream & stream); //----------------------------- - _UINT16 ixfe; + _UINT16 ixfe = 0; BuiltInStyle builtInData; XLUnicodeString user; - bool fBuiltIn; + bool fBuiltIn = true; }; } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/StyleExt.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/StyleExt.cpp index 66bdc5ef3f..d5be02c6f9 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/StyleExt.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/StyleExt.cpp @@ -37,6 +37,7 @@ namespace XLS StyleExt::StyleExt() { + stName = L""; } @@ -63,6 +64,23 @@ void StyleExt::readFields(CFRecord& record) record >> iCategory>> builtInData >> stName >> xfProps; } +void StyleExt::writeFields(CFRecord& record) +{ + unsigned char flags = 0; + frtHeader.rt = 0x0892; + SETBIT(flags, 0, fBuiltIn); + SETBIT(flags, 1, fHidden); + SETBIT(flags, 2, fCustom); + record << frtHeader << flags; + if(!fBuiltIn) + { + builtInData.iLevel = 0xFF; + builtInData.istyBuiltIn = 0xFF; + } + record << iCategory << builtInData << stName << xfProps; + +} + int StyleExt::serialize(std::wostream & stream) { diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/StyleExt.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/StyleExt.h index 29017e3483..adaab133f8 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/StyleExt.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/StyleExt.h @@ -52,17 +52,18 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeStyleExt; int serialize(std::wostream & stream); //----------------------------- - bool fBuiltIn; - bool fHidden; - bool fCustom; + bool fBuiltIn = false; + bool fHidden = false; + bool fCustom = false; - unsigned char iCategory; + unsigned char iCategory = 0; BuiltInStyle builtInData; LPWideString stName; XFProps xfProps; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SupBook.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SupBook.cpp index 7b0670098f..a653ff34f7 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SupBook.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SupBook.cpp @@ -186,6 +186,21 @@ void SupBook::readFields(CFRecord& record) } } +void SupBook::writeFields(CFRecord& record) +{ + record << ctab << cch; + if(0x0001 <= cch && 0x00ff >= cch) + { + XLUnicodeStringNoCch temp = origin; + record << temp; + } + for(auto i : rgst) + { + XLUnicodeString temp = i; + record << temp; + } +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SupBook.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SupBook.h index 5ea1b02949..d762f2fc85 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SupBook.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SupBook.h @@ -48,20 +48,21 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeSupBook; - _UINT16 ctab; - _UINT16 cch; + _UINT16 ctab = 0; + _UINT16 cch = 0x0401; std::wstring origin; std::vector rgst; //----------------------------- std::vector virtPath; - bool bOleLink; - bool bSimple; - bool bPath; + bool bOleLink = false; + bool bSimple = false; + bool bPath = false; }; typedef boost::shared_ptr SupBookPtr; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Surf.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Surf.cpp index 77f0144b4b..0a2b0de252 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Surf.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Surf.cpp @@ -59,6 +59,14 @@ void Surf::readFields(CFRecord& record) f3DPhongShade = GETBIT(flags, 1); } +void Surf::writeFields(CFRecord& record) +{ + unsigned short flags = 0; + SETBIT(flags, 0, fFillSurface) + SETBIT(flags, 1, f3DPhongShade) + record << flags; +} + int Surf::serialize(std::wostream & _stream) { CP_XML_WRITER(_stream) diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Surf.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Surf.h index 64f29fd3e1..f1e7219813 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Surf.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Surf.h @@ -50,14 +50,15 @@ public: void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeSurf; int serialize(std::wostream & _stream); //----------------------------- - bool fFillSurface; - bool f3DPhongShade; + bool fFillSurface = false; + bool f3DPhongShade = false; }; } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SxDXF.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SxDXF.cpp index 35f5d43ca6..a3bbdd5526 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SxDXF.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SxDXF.cpp @@ -57,5 +57,12 @@ void SxDXF::readFields(CFRecord& record) record >> *dxfn.xfext; } +void SxDXF::writeFields(CFRecord& record) +{ + record << dxfn; + if(dxfn.xfext != nullptr) + record << *(dxfn.xfext); +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SxDXF.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SxDXF.h index aa4c0e3551..8e20a527d3 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SxDXF.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SxDXF.h @@ -49,6 +49,7 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeSxDXF; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SxFilt.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SxFilt.cpp index ce71591e5c..28e46edf2d 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SxFilt.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SxFilt.cpp @@ -67,5 +67,19 @@ void SxFilt::readFields(CFRecord& record) fSelected = GETBIT(flags2, 10); } +void SxFilt::writeFields(CFRecord& record) +{ + unsigned short flags1 = 0, flags2 = 0; + SETBIT(flags1, 0, sxaxisRw) + SETBIT(flags1, 1, sxaxisCol) + SETBIT(flags1, 2, sxaxisPage) + SETBIT(flags1, 3, sxaxisData) + SETBITS(flags1, 6, 15, iDim) + + SETBITS(flags2, 0, 9, isxvd) + SETBIT(flags2, 10, fSelected) + record << flags1 << flags2 << grbitSbt << cisxvi; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SxFilt.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SxFilt.h index b6581154df..d5d9234408 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SxFilt.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SxFilt.h @@ -47,21 +47,22 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeSxFilt; - bool sxaxisRw; - bool sxaxisCol; - bool sxaxisPage; - bool sxaxisData; + bool sxaxisRw = false; + bool sxaxisCol = false; + bool sxaxisPage = false; + bool sxaxisData = false; - char iDim; - char isxvd; + char iDim = 0; + char isxvd = 0; - bool fSelected; + bool fSelected = false; - short grbitSbt; - unsigned short cisxvi; + short grbitSbt = 0; + unsigned short cisxvi = 0; }; } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SxFormat.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SxFormat.cpp index c29b9288c5..7daa51786d 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SxFormat.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SxFormat.cpp @@ -59,5 +59,12 @@ void SxFormat::readFields(CFRecord& record) rlType = GETBITS(flags, 0, 3); } +void SxFormat::writeFields(CFRecord& record) +{ + unsigned short flags = 0; + SETBITS(flags, 0, 3, rlType) + record << flags << cbData; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SxFormat.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SxFormat.h index e097ee9c8d..a4a8244e4b 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SxFormat.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SxFormat.h @@ -47,11 +47,12 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeSxFormat; - unsigned char rlType; - unsigned short cbData; + unsigned char rlType = 0; + unsigned short cbData = 0; }; } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SxItm.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SxItm.cpp index a76bdc832d..66ab10661d 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SxItm.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SxItm.cpp @@ -62,5 +62,20 @@ void SxItm::readFields(CFRecord& record) } } +void SxItm::writeFields(CFRecord& record) +{ + const auto maxRecSize = 8224; + while(!rgisxvi.empty()) + { + record << rgisxvi.at(0); + if(record.getRdPtr() > maxRecSize) + { + record.RollRdPtrBack(2); + return; + } + rgisxvi.erase(rgisxvi.begin()); + } +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SxItm.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SxItm.h index 030dc5ce9a..1a06ac2e8a 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SxItm.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SxItm.h @@ -47,6 +47,7 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeSxItm; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SxIvd.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SxIvd.cpp index 3e9926e134..f81dc12793 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SxIvd.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SxIvd.cpp @@ -53,5 +53,20 @@ void SxIvd::readFields(CFRecord& record) } } +void SxIvd::writeFields(CFRecord& record) +{ + const auto maxRecSize = 8224; + while(!rgSxivd.empty()) + { + record << rgSxivd.at(0); + if(record.getRdPtr() > maxRecSize) + { + record.RollRdPtrBack(2); + return; + } + rgSxivd.erase(rgSxivd.begin()); + } +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SxIvd.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SxIvd.h index 93972d1d1e..cd5733bd50 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SxIvd.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SxIvd.h @@ -47,6 +47,7 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeSxIvd; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SxRule.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SxRule.cpp index 55ae6b6966..e0db8f685f 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SxRule.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SxRule.cpp @@ -69,5 +69,32 @@ void SxRule::readFields(CFRecord& record) fGrandColSav = GETBIT(flags, 15); } +void SxRule::writeFields(CFRecord& record) +{ + unsigned short flags = 0; + SETBIT(flags, 0, sxaxisRw) + SETBIT(flags, 1, sxaxisCol) + SETBIT(flags, 2, sxaxisPage) + SETBIT(flags, 3, sxaxisData) + SETBITS(flags, 4, 7, sxrType) + SETBIT(flags, 8, fPart) + SETBIT(flags, 9, fDataOnly) + SETBIT(flags, 10, fLabelOnly) + SETBIT(flags, 11, fGrandRw) + SETBIT(flags, 12, fGrandCol) + SETBIT(flags, 13, fGrandRwSav) + SETBIT(flags, 14, fCacheBased) + SETBIT(flags, 15, fGrandColSav) + + record << iDim << isxvd << flags; + record.reserveNunBytes(2); + record << csxFilt; + if(fPart) + { + record << irwFirst << irwLast << icolFirst << icolLast; + } + +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SxRule.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SxRule.h index 49d6496bb4..97df966358 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SxRule.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SxRule.h @@ -47,30 +47,31 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeSxRule; - unsigned char iDim; - unsigned char isxvd; + unsigned char iDim = 0; + unsigned char isxvd = 0; - bool sxaxisRw; - bool sxaxisCol; - bool sxaxisPage; - bool sxaxisData; - unsigned char sxrType; - bool fPart; - bool fDataOnly; - bool fLabelOnly; - bool fGrandRw; - bool fGrandCol; - bool fGrandRwSav; - bool fCacheBased; - bool fGrandColSav; - unsigned short csxFilt; - unsigned char irwFirst; - unsigned char irwLast; - unsigned char icolFirst; - unsigned char icolLast; + bool sxaxisRw = false; + bool sxaxisCol = false; + bool sxaxisPage = false; + bool sxaxisData = false; + unsigned char sxrType = 0; + bool fPart = false; + bool fDataOnly = false; + bool fLabelOnly = false; + bool fGrandRw = false; + bool fGrandCol = false; + bool fGrandRwSav = false; + bool fCacheBased = false; + bool fGrandColSav = false; + unsigned short csxFilt = 0; + unsigned char irwFirst = 0; + unsigned char irwLast = 0; + unsigned char icolFirst = 0; + unsigned char icolLast = 0; }; } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SxSelect.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SxSelect.cpp index f26378f2cb..c09a2073ae 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SxSelect.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SxSelect.cpp @@ -68,5 +68,23 @@ void SxSelect::readFields(CFRecord& record) fExtendable = GETBIT(flags, 9); } +void SxSelect::writeFields(CFRecord& record) +{ + record.reserveNunBytes(2); + record << pnn; + record.reserveNunBytes(1); + record << sxaxisAct << iDimAct << iLiStart << iLiAct << iLiMin << iLiMax; + record << rwClick << colClick << rwClickPrev << colClickPrev; + + unsigned short flags = 0; + SETBITS(flags, 0, 4, cClick) + SETBIT(flags, 5, fLabelOnly) + SETBIT(flags, 6, fDataOnly) + SETBIT(flags, 7, fToggleDataHeader) + SETBIT(flags, 8, fSelectionClick) + SETBIT(flags, 9, fExtendable) + record << flags; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SxSelect.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SxSelect.h index baf64004fa..d0c47f8b10 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SxSelect.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SxSelect.h @@ -48,28 +48,28 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeSxSelect; - unsigned char pnn; //enum PaneType + unsigned char pnn = 0; //enum PaneType SXAxis sxaxisAct; - unsigned short iDimAct; - unsigned short iLiStart; - unsigned short iLiAct; - unsigned short iLiMin; - unsigned short iLiMax; - RwU rwClick; - ColU colClick; - RwU rwClickPrev; - ColU colClickPrev; - - unsigned char cClick; - bool fLabelOnly; - bool fDataOnly; - bool fToggleDataHeader; - bool fSelectionClick; - bool fExtendable; + unsigned short iDimAct = 0; + unsigned short iLiStart = 0; + unsigned short iLiAct = 0; + unsigned short iLiMin = 0; + unsigned short iLiMax = 0; + RwU rwClick = 0; + ColU colClick = 0; + RwU rwClickPrev = 0; + ColU colClickPrev = 0; + unsigned char cClick = 0; + bool fLabelOnly = false; + bool fDataOnly = false; + bool fToggleDataHeader = false; + bool fSelectionClick = false; + bool fExtendable = false; }; } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SxTbpg.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SxTbpg.cpp index 378a7168f5..583a715ba8 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SxTbpg.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SxTbpg.cpp @@ -64,5 +64,11 @@ void SxTbpg::readFields(CFRecord& record) } +void SxTbpg::writeFields(CFRecord& record) +{ + for(auto i : rgiitem) + record << i; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SxTbpg.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SxTbpg.h index 93148e9b74..c18aeb89c2 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SxTbpg.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SxTbpg.h @@ -47,6 +47,7 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeSxTbpg; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SxView.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SxView.cpp index a97f3dec00..4e8d32365d 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SxView.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SxView.cpp @@ -74,5 +74,38 @@ void SxView::readFields(CFRecord& record) record.skipNunBytes(skip); } +void SxView::writeFields(CFRecord& record) +{ + unsigned short flags = 0; + record << ref << rwFirstHead << rwFirstData << colFirstData << iCache; + record.reserveNunBytes(2); + record << sxaxis4Data << ipos4Data; + record << cDim << cDimRw << cDimCol << cDimPg << cDimData << cRw << cCol; + + SETBIT(flags, 0, fRwGrand) + SETBIT(flags, 1, fColGrand) + SETBIT(flags, 3, fAutoFormat) + SETBIT(flags, 4, fAtrNum) + SETBIT(flags, 5, fAtrFnt) + SETBIT(flags, 6, fAtrAlc) + SETBIT(flags, 7, fAtrBdr) + SETBIT(flags, 8, fAtrPat) + SETBIT(flags, 9, fAtrProc) + record << flags; + + cchTableName = stTable.getSize(); + cchDataName = stData.getSize(); + record << itblAutoFmt << cchTableName << cchDataName; + if(cchTableName && cchTableName <= 0x00FF) + { + record << stTable; + } + if(cchDataName > 0 && cchDataName <= 0x00FE) + { + record << stData; + } + +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SxView.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SxView.h index 5ff8d54776..274e8df785 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SxView.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/SxView.h @@ -50,38 +50,39 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeSxView; Ref8U ref; - RwU rwFirstHead; - RwU rwFirstData; - ColU colFirstData; - short iCache; - short reserved; + RwU rwFirstHead = 0; + RwU rwFirstData = 0; + ColU colFirstData = 0; + short iCache = 0; + short reserved = 0; SXAxis sxaxis4Data; - short ipos4Data; - short cDim; - unsigned short cDimRw; - unsigned short cDimCol; - unsigned short cDimPg; - short cDimData; - unsigned short cRw; - unsigned short cCol; + short ipos4Data = 0; + short cDim = 0; + unsigned short cDimRw = 0; + unsigned short cDimCol = 0; + unsigned short cDimPg = 0; + short cDimData = 0; + unsigned short cRw = 0; + unsigned short cCol = 0; - bool fRwGrand; - bool fColGrand; - bool fAutoFormat; - bool fAtrNum; - bool fAtrFnt; - bool fAtrAlc; - bool fAtrBdr; - bool fAtrPat; - bool fAtrProc; + bool fRwGrand = false; + bool fColGrand = false; + bool fAutoFormat = false; + bool fAtrNum = false; + bool fAtrFnt = false; + bool fAtrAlc = false; + bool fAtrBdr = false; + bool fAtrPat = false; + bool fAtrProc = false; - unsigned short itblAutoFmt; //enum AutoFmt8 - unsigned short cchTableName; - unsigned short cchDataName; + unsigned short itblAutoFmt = 0; //enum AutoFmt8 + unsigned short cchTableName = 0; + unsigned short cchDataName = 0; XLUnicodeStringNoCch stTable; XLUnicodeStringNoCch stData; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Sxvd.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Sxvd.cpp index 53119bf6ce..4cb8bfa512 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Sxvd.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Sxvd.cpp @@ -76,7 +76,34 @@ void Sxvd::readFields(CFRecord& record) record >> stName; } int skip = record.getDataSize() - record.getRdPtr(); - record.skipNunBytes(skip);} + record.skipNunBytes(skip); +} + +void Sxvd::writeFields(CFRecord& record) +{ + short flags = 0; + + SETBIT(flags, 0, fDefault) + SETBIT(flags, 1, fSum) + SETBIT(flags, 2, fCounta) + SETBIT(flags, 3, fAverage) + SETBIT(flags, 4, fMax) + SETBIT(flags, 5, fMin) + SETBIT(flags, 6, fProduct) + SETBIT(flags, 7, fCount) + SETBIT(flags, 8, fStdev) + SETBIT(flags, 9, fStdevp) + SETBIT(flags, 10, fVariance) + SETBIT(flags, 11, fVariancep) + + record << sxaxis << cSub << flags; + cchName = stName.getSize(); + record << cItm << cchName; + if(cchName && cchName != 0xffff) + { + record << stName; + } +} } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Sxvd.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Sxvd.h index bad2ef08c0..fd63bb1cde 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Sxvd.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Sxvd.h @@ -49,27 +49,28 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeSxvd; SXAxis sxaxis; - unsigned short cSub; + unsigned short cSub = 0; - bool fDefault; - bool fSum; - bool fCounta; - bool fAverage; - bool fMax; - bool fMin; - bool fProduct; - bool fCount; - bool fStdev; - bool fStdevp; - bool fVariance; - bool fVariancep; + bool fDefault = false; + bool fSum = false; + bool fCounta = false; + bool fAverage = false; + bool fMax = false; + bool fMin = false; + bool fProduct = false; + bool fCount = false; + bool fStdev = false; + bool fStdevp = false; + bool fVariance = false; + bool fVariancep = false; - short cItm; - unsigned short cchName; + short cItm = 0; + unsigned short cchName = 0; XLUnicodeStringNoCch stName; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/TableStyle.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/TableStyle.cpp index 53de8a2b22..066c60f359 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/TableStyle.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/TableStyle.cpp @@ -92,7 +92,7 @@ void TableStyle::writeFields(CFRecord& record) { SETBIT(flags, 1, fIsPivot) SETBIT(flags, 2, fIsTable) - + frtHeader.rt = 0x088F; record << frtHeader << flags; _UINT16 cchName; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/TableStyle.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/TableStyle.h index 73b53e7b50..0e1c0c3f9f 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/TableStyle.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/TableStyle.h @@ -55,11 +55,11 @@ public: static const ElementType type = typeTableStyle; //----------------------------- - bool fIsPivot; - bool fIsTable; - _UINT32 ctse; + bool fIsPivot = false; + bool fIsTable = false; + _UINT32 ctse = 0; //LPWideStringNoCch rgchName; - std::wstring rgchName; //strName in biff12 + std::wstring rgchName = L""; //strName in biff12 FrtHeader frtHeader; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/TableStyleElement.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/TableStyleElement.cpp index 598fbe6814..9cc81419b4 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/TableStyleElement.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/TableStyleElement.cpp @@ -62,6 +62,7 @@ void TableStyleElement::writeFields(CFRecord& record) { if (record.getGlobalWorkbookInfo()->Version < 0x0800) { + frtHeader.rt = 0x0890; record << frtHeader; } diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/TableStyles.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/TableStyles.cpp index 7e4359424e..384982aba8 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/TableStyles.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/TableStyles.cpp @@ -90,7 +90,7 @@ void TableStyles::writeFields(CFRecord& record) cchDefTableStyle = rgchDefTableStyle_.getSize(); cchDefPivotStyle = rgchDefPivotStyle_.getSize(); - + frtHeader.rt = 0x088E; record << frtHeader << cts << cchDefTableStyle << cchDefPivotStyle; record << rgchDefTableStyle_ << rgchDefPivotStyle_; } diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Text.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Text.cpp index b1c7529aa2..28331e530a 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Text.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Text.cpp @@ -93,6 +93,31 @@ void Text::readFields(CFRecord& record) } +void Text::writeFields(CFRecord& record) +{ + unsigned short flags1 = 0; + unsigned short flags2 = 0; + + SETBIT(flags1, 0, fAutoColor) + SETBIT(flags1, 1, fShowKey) + SETBIT(flags1, 2, fShowValue) + SETBIT(flags1, 4, fAutoText) + SETBIT(flags1, 5, fGenerated) + SETBIT(flags1, 6, fDeleted) + SETBIT(flags1, 7, fAutoMode) + SETBIT(flags1, 11, fShowLabelAndPerc) + SETBIT(flags1, 12, fShowPercent) + SETBIT(flags1, 13, fShowBubbleSizes) + SETBIT(flags1, 14, fShowLabel) + record << at << vat << wBkgMode << rgbText << x << y << dx << dy << flags1; + + SETBITS(flags2, 0, 3, dlp); + SETBITS(flags2, 14, 15, iReadingOrder); + record << icvText << flags2 << trot; + + +} + int Text::serialize(std::wostream & _stream) { CP_XML_WRITER(_stream) diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Text.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Text.h index 079ad393c7..1c193164da 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Text.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Text.h @@ -50,38 +50,39 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeText; int serialize(std::wostream & _stream); - unsigned char at; - unsigned char vat; + unsigned char at = 0; + unsigned char vat = 0; - _UINT16 wBkgMode; + _UINT16 wBkgMode = 0; LongRGB rgbText; - _INT32 x; - _INT32 y; - _INT32 dx; - _INT32 dy; + _INT32 x = 0; + _INT32 y = 0; + _INT32 dx = 0; + _INT32 dy = 0; - bool fAutoColor; - bool fShowKey; - bool fShowValue; - bool fAutoText; - bool fGenerated; - bool fDeleted; - bool fAutoMode; - bool fShowLabelAndPerc; - bool fShowPercent; - bool fShowBubbleSizes; - bool fShowLabel; + bool fAutoColor = false; + bool fShowKey = false; + bool fShowValue = false; + bool fAutoText = false; + bool fGenerated = false; + bool fDeleted = false; + bool fAutoMode = false; + bool fShowLabelAndPerc = false; + bool fShowPercent = false; + bool fShowBubbleSizes = false; + bool fShowLabel = false; - Icv icvText; - unsigned char dlp; - unsigned char iReadingOrder; - _UINT16 trot; + Icv icvText = 0; + unsigned char dlp = 0; + unsigned char iReadingOrder = 0; + _UINT16 trot = 0; //----------------------------- bool is_area; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Theme.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Theme.cpp index 781247c4b7..52347e0461 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Theme.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Theme.cpp @@ -108,4 +108,23 @@ global_info->sTheme = \ } } +void Theme::writeFields(CFRecord& record) +{ + frtHeader.rt = rt_Theme; + record << frtHeader << dwThemeVersion; + if(dwThemeVersion == 0) + { + const auto maxSize = 8208; + auto loadingSize = 0; + if(nThemeDataSize < maxSize) + loadingSize = nThemeDataSize; + else + loadingSize = maxSize; + for(auto i = 0; i < loadingSize; i++) + { + record << pThemeData[i]; + } + } +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Theme.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Theme.h index 36fa6fd2b4..03181e2ae5 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Theme.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Theme.h @@ -48,14 +48,15 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeTheme; //----------------------------- - _UINT32 dwThemeVersion; + _UINT32 dwThemeVersion = 0; FrtHeader frtHeader; - _UINT32 nThemeDataSize; + _UINT32 nThemeDataSize = 0; boost::shared_array pThemeData; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Tick.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Tick.cpp index 749a4cb2bf..68fbbca473 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Tick.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Tick.cpp @@ -69,6 +69,20 @@ void Tick::readFields(CFRecord& record) _rott = rot; } +void Tick::writeFields(CFRecord& record) +{ + unsigned short flags = 0; + SETBIT(flags, 0, fAutoCo) + SETBIT(flags, 1, fAutoMode) + SETBITS(flags, 2, 4, rot) + SETBIT(flags, 5, fAutoRot) + SETBITS(flags, 14, 15, iReadingOrder) + + record << tktMajor << tktMinor << tlt << wBkgMode << rgb; + record.reserveNunBytes(16); + record << flags << icv << trot; +} + int Tick::serialize(std::wostream & _stream) { CP_XML_WRITER(_stream) diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Tick.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Tick.h index 84e5fdf970..e2e28030b0 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Tick.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Tick.h @@ -50,28 +50,29 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeTick; int serialize(std::wostream & _stream); //----------------------------- - unsigned char tktMajor; - unsigned char tktMinor; - unsigned char tlt; - unsigned char wBkgMode; + unsigned char tktMajor = 0; + unsigned char tktMinor = 0; + unsigned char tlt = 0; + unsigned char wBkgMode = 0; LongRGB rgb; - bool fAutoCo; - bool fAutoMode; - unsigned char rot; - bool fAutoRot; - unsigned char iReadingOrder; + bool fAutoCo = false; + bool fAutoMode = false; + unsigned char rot = 0; + bool fAutoRot = false; + unsigned char iReadingOrder = 0; - _UINT16 icv; - _UINT16 trot; + _UINT16 icv = 0; + _UINT16 trot = 0; - int _rott; + int _rott = 0; }; } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/TopMargin.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/TopMargin.cpp index db91c3b6f1..8d365b8404 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/TopMargin.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/TopMargin.cpp @@ -37,6 +37,7 @@ namespace XLS TopMargin::TopMargin() { + num.data.value = 0.75; } @@ -55,5 +56,10 @@ void TopMargin::readFields(CFRecord& record) record >> num; } +void TopMargin::writeFields(CFRecord& record) +{ + record << num; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/TopMargin.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/TopMargin.h index bf2453be57..c3896994f2 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/TopMargin.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/TopMargin.h @@ -48,6 +48,7 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeTopMargin; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/TxtQry.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/TxtQry.cpp index 2d9968d62d..39b7aae4bc 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/TxtQry.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/TxtQry.cpp @@ -85,5 +85,38 @@ void TxtQry::readFields(CFRecord& record) record >> rgchFile; } +void TxtQry::writeFields(CFRecord& record) +{ + record << rt; + record.reserveNunBytes(2); + unsigned short flags1 = 0; + + SETBIT(flags1, 0, fFile) + SETBIT(flags1, 1, fDelimited) + SETBITS(flags1, 2, 3, iCpid) + SETBIT(flags1, 4, fPromptForFile) + SETBITS(flags1, 5, 14, iCpidNew) + SETBIT(flags1, 15, fUseNewiCpid) + record << flags1; + record.reserveNunBytes(2); + + unsigned short flags2 = 0; + SETBIT(flags2, 0, fTab) + SETBIT(flags2, 1, fSpace) + SETBIT(flags2, 2, fComma) + SETBIT(flags2, 3, fSemiColon) + SETBIT(flags2, 4, fCustom) + SETBIT(flags2, 5, fConsecutive) + SETBITS(flags1, 6, 7, iTextDelm) + record << rowStartAt << flags2 << chCustom; + record.reserveNunBytes(1); + record << itwf << chDecimal << chThousSep; + for(auto i : rgtxtwf) + { + i.save(record); + } + record << rgchFile; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/TxtQry.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/TxtQry.h index 62b13719a7..24ee8a3505 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/TxtQry.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/TxtQry.h @@ -49,28 +49,29 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeTxtQry; - unsigned short rt; - bool fFile; - bool fDelimited; - unsigned char iCpid; - bool fPromptForFile; - unsigned char iCpidNew; - bool fUseNewiCpid; - _INT32 rowStartAt; - bool fTab; - bool fSpace; - bool fComma; - bool fSemiColon; - bool fCustom; - bool fConsecutive; - unsigned char iTextDelm; - unsigned short chCustom; - _INT32 itwf; - unsigned char chDecimal; - unsigned char chThousSep; + unsigned short rt = 0x0805; + bool fFile = false; + bool fDelimited = false; + unsigned char iCpid = 0; + bool fPromptForFile = false; + unsigned char iCpidNew = 0; + bool fUseNewiCpid = 0; + _INT32 rowStartAt = 0; + bool fTab = false; + bool fSpace = false; + bool fComma = false; + bool fSemiColon = false; + bool fCustom = false; + bool fConsecutive = false; + unsigned char iTextDelm = 0; + unsigned short chCustom = 0; + _INT32 itwf = 0; + unsigned char chDecimal = 0; + unsigned char chThousSep = 0; std::vector rgtxtwf; XLUnicodeString rgchFile; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Uncalced.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Uncalced.cpp index d57bc183e0..da071e409a 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Uncalced.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Uncalced.cpp @@ -55,5 +55,10 @@ void Uncalced::readFields(CFRecord& record) record.skipNunBytes(2); // reserved } +void Uncalced::writeFields(CFRecord& record) +{ + record.reserveNunBytes(2); // reserved +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Uncalced.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Uncalced.h index 5c0d41de1c..426499ef18 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Uncalced.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Uncalced.h @@ -49,6 +49,7 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeUncalced; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Units.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Units.cpp index 1dbfce2d93..e41ec036b1 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Units.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Units.cpp @@ -55,5 +55,10 @@ void Units::readFields(CFRecord& record) record.skipNunBytes(2); // reserved } +void Units::writeFields(CFRecord& record) +{ + record.reserveNunBytes(2); +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Units.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Units.h index 9078e33e41..203e091ada 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Units.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Units.h @@ -49,6 +49,7 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeUnits; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/UserBView.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/UserBView.cpp index d281b3ffe3..700f5b71d1 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/UserBView.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/UserBView.cpp @@ -179,6 +179,61 @@ void UserBView::readFields(CFRecord& record) } } +void UserBView::writeFields(CFRecord& record) +{ + record.reserveNunBytes(4); + _UINT16 tabId_2b = tabId; + record << tabId_2b; + record.reserveNunBytes(2); // reserved1 + + _GUID_ guid_num; + _UINT16 wTabRatio_2b = wTabRatio; + STR::bstr2guid(guid, guid_num); + record << guid_num << x << y << dx << dy << wTabRatio_2b; + + unsigned short flags1 = 0; + + SETBIT(flags1, 0, fDspFmlaBar) + SETBIT(flags1, 1, fDspStatus) + + unsigned char mdNoteDisp_num = 0; + if(mdNoteDisp == L"commIndAndComment") + mdNoteDisp_num = 0x2; + else if(mdNoteDisp == L"commIndicator") + mdNoteDisp_num =0x1; + SETBITS(flags1, 2, 3, mdNoteDisp_num) + + SETBIT(flags1, 4, fDspHScroll) + SETBIT(flags1, 5, fDspVScroll) + SETBIT(flags1, 6, fBotAdornment) + SETBIT(flags1, 7, fZoom) + + unsigned char fHideObj_num = 0; + + if(fHideObj == L"placeholders") + fHideObj_num = 0x1; + else if(fHideObj == L"none") + fHideObj_num = 0x2; + SETBITS(flags1, 8, 9, fHideObj_num) + SETBIT(flags1, 10, fPrintIncl) + SETBIT(flags1, 11, fRowColIncl) + SETBIT(flags1, 12, fInvalidTabId) + SETBIT(flags1, 13, fTimedUpdate) + SETBIT(flags1, 14, fAllMemChanges) + SETBIT(flags1, 15, fOnlySync) + + record << flags1; + record.reserveNunBytes(2); // unused2 + + unsigned short flags2 = 0; + + SETBIT(flags2, 0, fPersonalView) + SETBIT(flags2, 1, fIconic) + record << flags2; + + record << wMergeInterval << st; +} + int UserBView::serialize(std::wostream & stream) { CP_XML_WRITER(stream) diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/UserBView.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/UserBView.h index 95b000a4bc..526820d4ce 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/UserBView.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/UserBView.h @@ -50,45 +50,46 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeUserBView; int serialize(std::wostream & stream); //----------------------------- //_UINT16 tabId; - _UINT32 tabId; //iTabid in biff12 - std::wstring guid; + _UINT32 tabId = 0; //iTabid in biff12 + std::wstring guid = L""; - _INT32 x; //xLeft in biff12 - _INT32 y; //xRight in biff12 - _INT32 dx; //yTop in biff12 - _INT32 dy; //yBot in biff12 + _INT32 x = 0; //xLeft in biff12 + _INT32 y = 0; //xRight in biff12 + _INT32 dx = 0; //yTop in biff12 + _INT32 dy = 0; //yBot in biff12 //_UINT16 wTabRatio; - _UINT32 wTabRatio; //iTabRatio in biff12 + _UINT32 wTabRatio = 0; //iTabRatio in biff12 - bool fDspFmlaBar; - bool fDspStatus; + bool fDspFmlaBar = false; + bool fDspStatus = false; - std::wstring mdNoteDisp; + std::wstring mdNoteDisp = L""; - bool fDspHScroll; - bool fDspVScroll; - bool fBotAdornment; - bool fZoom; + bool fDspHScroll = false; + bool fDspVScroll = false; + bool fBotAdornment = false; + bool fZoom = false; - std::wstring fHideObj; + std::wstring fHideObj = L""; - bool fPrintIncl; - bool fRowColIncl; - bool fInvalidTabId; - bool fTimedUpdate; - bool fAllMemChanges; - bool fOnlySync; - bool fPersonalView; - bool fIconic; + bool fPrintIncl = false; + bool fRowColIncl = false; + bool fInvalidTabId = false; + bool fTimedUpdate = false; + bool fAllMemChanges = false; + bool fOnlySync = false; + bool fPersonalView = false; + bool fIconic = false; - _UINT16 wMergeInterval; + _UINT16 wMergeInterval = 0; XLUnicodeString st; XLSB::XLWideString stName; //biff12 diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/UserSViewBegin.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/UserSViewBegin.cpp index fa7652a586..37cdadceff 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/UserSViewBegin.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/UserSViewBegin.cpp @@ -104,5 +104,60 @@ void UserSViewBegin::readFields(CFRecord& record) pane_top_left_cell = CellRef(fSplitH ? (int)rwBPane : 0 , fSplitV ? (int)colRPane : 0, true, true).toString(); } +void UserSViewBegin::writeFields(CFRecord& record) +{ + _GUID_ guid_num; + STR::bstr2guid(guid, guid_num); + record << guid_num << iTabid; + record.reserveNunBytes(2); + record << wScale << icvHdr; + record.reserveNunBytes(2); + record << pnnSel; + record.reserveNunBytes(3); + unsigned short flags = 0; + + SETBIT(flags, 0, fShowBrks) + SETBIT(flags, 1, fDspFmlaSv) + SETBIT(flags, 2, fDspGridSv) + SETBIT(flags, 3, fDspRwColSv) + SETBIT(flags, 4, fDspGutsSv) + SETBIT(flags, 5, fDspZerosSv) + SETBIT(flags, 6, fHorizontal) + SETBIT(flags, 7, fVertical) + SETBIT(flags, 8, fPrintRwCol) + SETBIT(flags, 9, fPrintGrid) + SETBIT(flags, 10, fFitToPage) + SETBIT(flags, 11, fPrintArea) + SETBIT(flags, 12, fOnePrintArea) + SETBIT(flags, 13, fFilterMode) + SETBIT(flags, 14, fEzFilter) + SETBIT(flags, 15, fFrozen) + record << flags; + + Ref8U top_left; + top_left.fromString(ref8TopLeft); + record << top_left; + flags = 0; + SETBIT(flags, 0, fFrozenNoSplit) + SETBIT(flags, 1, fSplitV) + SETBIT(flags, 2, fSplitH) + SETBIT(flags, 3, fHiddenRw) + SETBIT(flags, 5, fHiddenCol) + SETBIT(flags, 9, fFilterUnique) + SETBIT(flags, 10, fSheetLayoutView) + SETBIT(flags, 11, fPageLayoutView) + SETBIT(flags, 13, fRuler) + record << flags; + if(!pane_top_left_cell.empty()) + { + CellRef paneRef; + paneRef.fromString(pane_top_left_cell); + colRPane = paneRef.column; + rwBPane = paneRef.row; + } + record << operNumX << operNumY << colRPane << rwBPane; + +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/UserSViewBegin.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/UserSViewBegin.h index 8a1a81d6d0..82c6973163 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/UserSViewBegin.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/UserSViewBegin.h @@ -49,13 +49,14 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeUserSViewBegin; //----------------------------- - std::wstring guid; - TabId iTabid; - _UINT32 wScale; + std::wstring guid = L""; + TabId iTabid = 0; + _UINT32 wScale = 0; Icv icvHdr = 64; PaneType pnnSel; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/UserSViewEnd.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/UserSViewEnd.cpp index dcdbf851cb..033adabee9 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/UserSViewEnd.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/UserSViewEnd.cpp @@ -55,5 +55,11 @@ void UserSViewEnd::readFields(CFRecord& record) record.skipNunBytes(2); // reserved } +void UserSViewEnd::writeFields(CFRecord& record) +{ + unsigned short reserve = 1; // reserved + record << reserve; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/UserSViewEnd.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/UserSViewEnd.h index e77238f4f4..8996199d94 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/UserSViewEnd.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/UserSViewEnd.h @@ -49,6 +49,7 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeUserSViewEnd; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/UsesELFs.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/UsesELFs.cpp index ea5134ea84..afd53911f3 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/UsesELFs.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/UsesELFs.cpp @@ -55,5 +55,10 @@ void UsesELFs::readFields(CFRecord& record) record >> useselfs; } +void UsesELFs::writeFields(CFRecord& record) +{ + record << useselfs; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/UsesELFs.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/UsesELFs.h index 7b4b99f430..b9d533c93d 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/UsesELFs.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/UsesELFs.h @@ -46,10 +46,11 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeUsesELFs; - Boolean useselfs; + Boolean useselfs = false; }; } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/VCenter.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/VCenter.cpp index d45842d8d2..937d2feed9 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/VCenter.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/VCenter.cpp @@ -53,5 +53,10 @@ void VCenter::readFields(CFRecord& record) record >> vcenter; } +void VCenter::writeFields(CFRecord& record) +{ + record << vcenter; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/VCenter.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/VCenter.h index 25bf2114f7..b4798d65a6 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/VCenter.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/VCenter.h @@ -47,11 +47,12 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeVCenter; //----------------------------- - Boolean vcenter; + Boolean vcenter = 0; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ValueRange.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ValueRange.cpp index e7c43cc082..b5bcadffc8 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ValueRange.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ValueRange.cpp @@ -65,5 +65,20 @@ void ValueRange::readFields(CFRecord& record) fMaxCross = GETBIT(flags, 7); } +void ValueRange::writeFields(CFRecord& record) +{ + unsigned short flags = 0; + + SETBIT(flags, 0, fAutoMin) + SETBIT(flags, 1, fAutoMax) + SETBIT(flags, 2, fAutoMajor) + SETBIT(flags, 3, fAutoMinor) + SETBIT(flags, 4, fAutoCross) + SETBIT(flags, 5, fLog) + SETBIT(flags, 6, fReversed) + SETBIT(flags, 7, fMaxCross) + record << numMin << numMax << numMajor << numMinor << numCross << flags; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ValueRange.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ValueRange.h index 9d95f41790..0de7b76dc4 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ValueRange.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/ValueRange.h @@ -48,6 +48,7 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeValueRange; @@ -58,14 +59,14 @@ public: Xnum numMinor; Xnum numCross; - bool fAutoMin; - bool fAutoMax; - bool fAutoMajor; - bool fAutoMinor; - bool fAutoCross; - bool fLog; - bool fReversed; - bool fMaxCross; + bool fAutoMin = false; + bool fAutoMax = false; + bool fAutoMajor = false; + bool fAutoMinor = false; + bool fAutoCross = false; + bool fLog = false; + bool fReversed = false; + bool fMaxCross = false; }; } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/VerticalPageBreaks.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/VerticalPageBreaks.cpp index 0947390f65..0b7ecfe2ff 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/VerticalPageBreaks.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/VerticalPageBreaks.cpp @@ -52,6 +52,15 @@ namespace XLS rgbrk.push_back(vb); } } + void VerticalPageBreaks::writeFields(CFRecord& record) + { + cbrk = rgbrk.size(); + record << cbrk; + for (auto i:rgbrk) + { + record << *i; + } + } int VerticalPageBreaks::serialize(std::wostream & stream) { if (rgbrk.empty()) return 0; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/VerticalPageBreaks.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/VerticalPageBreaks.h index 6403673a76..92d6bcebd1 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/VerticalPageBreaks.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/VerticalPageBreaks.h @@ -47,7 +47,7 @@ namespace XLS BaseObjectPtr clone(); void readFields(CFRecord& record); - + void writeFields(CFRecord& record); static const ElementType type = typeVerticalPageBreaks; virtual int serialize(std::wostream & stream); diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/WinProtect.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/WinProtect.cpp index 07fad45a48..9c2aef1875 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/WinProtect.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/WinProtect.cpp @@ -55,5 +55,10 @@ void WinProtect::readFields(CFRecord& record) record >> fLockWn; } +void WinProtect::writeFields(CFRecord& record) +{ + record << fLockWn; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/WinProtect.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/WinProtect.h index 6db6ac13b3..378db5387e 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/WinProtect.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/WinProtect.h @@ -47,11 +47,12 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeWinProtect; //----------------------------- - Boolean fLockWn; + Boolean fLockWn = false; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Window1.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Window1.cpp index ceafce00a6..3309386699 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Window1.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Window1.cpp @@ -105,11 +105,27 @@ void Window1::readFields(CFRecord& record) void Window1::writeFields(CFRecord& record) { - unsigned short flags; + unsigned short flags = 0; if (record.getGlobalWorkbookInfo()->Version < 0x0800) { - //stub + _UINT16 flags = 0; + _INT16 xWn_2b = xWn; + _INT16 yWn_2b = yWn; + _INT16 dxWn_2b = dxWn; + _INT16 dyWn_2b = dyWn; + _UINT16 itabCur_2b = itabCur; + _UINT16 itabFirst_2b = itabFirst; + _UINT16 wTabRatio_2b = wTabRatio; + record << xWn_2b << yWn_2b << dxWn_2b << dyWn_2b; + SETBIT(flags, 0, fHidden) + SETBIT(flags, 1, fIconic) + SETBIT(flags, 2, fVeryHidden) + SETBIT(flags, 3, fDspHScroll) + SETBIT(flags, 4, fDspVScroll) + SETBIT(flags, 5, fBotAdornment) + SETBIT(flags, 6, fNoAFDateGroup) + record << flags << itabCur_2b << itabFirst_2b << ctabSel << wTabRatio_2b; } else diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Window1.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Window1.h index 8183cf8662..31c3dec4c5 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Window1.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Window1.h @@ -55,21 +55,21 @@ public: int serialize(std::wostream & stream); //----------------------------- - _INT32 xWn; - _INT32 yWn; - _UINT32 dxWn; - _UINT32 dyWn; - bool fHidden; - bool fIconic; - bool fVeryHidden; - bool fDspHScroll; - bool fDspVScroll; - bool fBotAdornment; - bool fNoAFDateGroup; //fAFDateGroup in BIFF12 - _UINT32 itabCur; - _UINT32 itabFirst; - _UINT16 ctabSel; - _UINT32 wTabRatio; //itabRatio in BIFF12 + _INT32 xWn = 0; + _INT32 yWn = 0; + _UINT32 dxWn = 16384; + _UINT32 dyWn = 8192; + bool fHidden = false; + bool fIconic = false; + bool fVeryHidden = false; + bool fDspHScroll = true; + bool fDspVScroll = true; + bool fBotAdornment = true; + bool fNoAFDateGroup = false; //fAFDateGroup in BIFF12 + _UINT32 itabCur = 0; + _UINT32 itabFirst = 0; + _UINT16 ctabSel = 1; + _UINT32 wTabRatio = 500; //itabRatio in BIFF12 }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Window2.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Window2.cpp index bc27878896..85c1d0558e 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Window2.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Window2.cpp @@ -39,7 +39,7 @@ Window2::Window2(bool isChart) { is_contained_in_chart_substream = false; - fSelected = false; + /*fSelected = false; fDspFmlaRt = false; fDspGridRt = false; fDspRwColRt = false; @@ -50,7 +50,7 @@ Window2::Window2(bool isChart) fDspGuts = false; fFrozenNoSplit = false; fPaged = false; - fSLV = false; + fSLV = false;*/ wScaleSLV = wScaleNormal = 0; @@ -202,6 +202,7 @@ void Window2::writeFields(CFRecord& record) record.reserveNunBytes(2); // reserved record << wScaleSLV << wScaleNormal; + record.reserveNunBytes(4); // must be ignored } else diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Window2.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Window2.h index e839e43363..e79db2949e 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Window2.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/Window2.h @@ -54,28 +54,28 @@ public: static const ElementType type = typeWindow2; bool fDspFmlaRt = false; //fDspFmla in biff12 - bool fDspGridRt = false; //fDspGrid in biff12 - bool fDspRwColRt = false; //fDspRwCol in biff12 + bool fDspGridRt = true; //fDspGrid in biff12 + bool fDspRwColRt = true; //fDspRwCol in biff12 bool fFrozenRt = false; - bool fDspZerosRt = false; // fDspZeros in biff12 - bool fDefaultHdr = false; // * + bool fDspZerosRt = true; // fDspZeros in biff12 + bool fDefaultHdr = true; // * bool fRightToLeft = false; // * - bool fDspGuts = false; // * + bool fDspGuts = true; // * bool fFrozenNoSplit = false; - bool fSelected = false; // * - bool fPaged = false; + bool fSelected = false; // * + bool fPaged = true; bool fSLV = false; - bool is_contained_in_chart_substream; + bool is_contained_in_chart_substream = false; - UncheckedRw rwTop; - UncheckedCol colLeft; + UncheckedRw rwTop = 0; + UncheckedCol colLeft = 0; _UINT16 icvHdr = 64; // 1 Byte in biff12 - _UINT16 wScaleSLV; - _UINT16 wScaleNormal; - std::wstring topLeftCell; + _UINT16 wScaleSLV = 0; + _UINT16 wScaleNormal = 0; + std::wstring topLeftCell = L"A1"; //biff12 bool fWnProt = false; @@ -84,9 +84,9 @@ public: _UINT32 xlView; - _UINT16 wScale; - _UINT16 wScalePLV; - _UINT32 iWbkView; + _UINT16 wScale = 0; + _UINT16 wScalePLV = 0; + _UINT32 iWbkView = 0; bool _isChart = false; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/WriteAccess.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/WriteAccess.cpp index bf6ea65bd7..5fc57db87b 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/WriteAccess.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/WriteAccess.cpp @@ -37,6 +37,7 @@ namespace XLS WriteAccess::WriteAccess() { + userName = L""; } @@ -66,5 +67,21 @@ void WriteAccess::readFields(CFRecord& record) record.skipNunBytes(record.getDataSize() - record.getRdPtr()); // unused } +void WriteAccess::writeFields(CFRecord& record) +{ + auto maxRecordSize = 112; + auto userNamePos = record.getRdPtr(); + if(userName.value() == L"") + { + XLUnicodeString name; + name = std::wstring(L" "); + record << name; + record.reserveNunBytes(maxRecordSize - (record.getRdPtr() - userNamePos)); + return; + } + record << userName; + record.reserveNunBytes(maxRecordSize - (record.getRdPtr() - userNamePos)); +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/WriteAccess.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/WriteAccess.h index f85a955f37..13ff84cc35 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/WriteAccess.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/WriteAccess.h @@ -50,6 +50,7 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeWriteAccess; //----------------------------- diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/WsBool.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/WsBool.cpp index 5880ebd290..6ca889e3fe 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/WsBool.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/WsBool.cpp @@ -67,6 +67,25 @@ void WsBool::readFields(CFRecord& record) fAltFormulaEntry = GETBIT(flags, 15); } +void WsBool::writeFields(CFRecord& record) +{ + unsigned short flags = 0; + + SETBIT(flags, 0, fShowAutoBreaks); + if(fDialog) + SETBIT(flags, 4, fDialog); + SETBIT(flags, 5, fApplyStyles); + SETBIT(flags, 6, fRowSumsBelow); + SETBIT(flags, 7, fColSumsRight); + SETBIT(flags, 8, fFitToPage); + SETBIT(flags, 10, fDspGuts); + SETBIT(flags, 12, fSyncHoriz); + SETBIT(flags, 13, fSyncVert); + SETBIT(flags, 14, fAltExprEval); + SETBIT(flags, 15, fAltFormulaEntry); + + record << flags; +} } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/WsBool.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/WsBool.h index 5a69acde4b..6f00d14869 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/WsBool.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/WsBool.h @@ -47,21 +47,22 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeWsBool; //----------------------------- - bool fShowAutoBreaks; - bool& fDialog; - bool fApplyStyles; - bool fRowSumsBelow; - bool fColSumsRight; - bool fFitToPage; - bool fDspGuts; - bool fSyncHoriz; - bool fSyncVert; - bool fAltExprEval; - bool fAltFormulaEntry; + bool fShowAutoBreaks = true; + bool& fDialog; + bool fApplyStyles = false; + bool fRowSumsBelow = true; + bool fColSumsRight = true; + bool fFitToPage = false; + bool fDspGuts = true; + bool fSyncHoriz = false; + bool fSyncVert = false; + bool fAltExprEval = false; + bool fAltFormulaEntry = false; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/XCT.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/XCT.cpp index 5c145be536..b4ef3df9f0 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/XCT.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/XCT.cpp @@ -61,5 +61,12 @@ void XCT::readFields(CFRecord& record) } } +void XCT::writeFields(CFRecord& record) +{ + record << ccrn; + if(itab_exist) + record >> itab; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/XCT.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/XCT.h index fd2be47599..8473ed8bb6 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/XCT.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/XCT.h @@ -47,12 +47,13 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeXCT; - _UINT16 ccrn; - _UINT16 itab; - bool itab_exist; + _UINT16 ccrn = 0; + _UINT16 itab = 0; + bool itab_exist = false; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/XF.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/XF.cpp index 04d81c5622..14411c2e79 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/XF.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/XF.cpp @@ -172,6 +172,8 @@ namespace XLS font_x_id = -1; fill.fls = 0; + fill.icvBack = 0x41; + fill.icvFore = 0x40; ixfParent = 0; font_index = 0xffff; @@ -399,7 +401,7 @@ void XF::writeFields(CFRecord& record) global_info = record.getGlobalWorkbookInfo(); - if (global_info->Version == 0x0400) + /*if (global_info->Version == 0x0400) { //stub } @@ -410,7 +412,81 @@ void XF::writeFields(CFRecord& record) else if (global_info->Version == 0x0600) { //stub - } + }*/ + if (global_info->Version < 0x0800) + { + if(font_index == 0xffff) + font_index = 0; + if(ifmt == 0xffff) + ifmt = 0; + if(ixfParent == 0) + ixfParent = 0xfff; + FontIndex ifnt; + ifnt.setValue(font_index); + record <> cxfs >> crc; } +void XFCRC::writeFields(CFRecord& record) +{ + frtHeader.rt = 0x87C; + record << frtHeader; + record.reserveNunBytes(2); // reserved + record << cxfs << crc; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/XFCRC.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/XFCRC.h index e2187dabde..bbf3a4704e 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/XFCRC.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/XFCRC.h @@ -48,12 +48,13 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeXFCRC; //----------------------------- - _UINT16 cxfs; - _UINT32 crc; + _UINT16 cxfs = 0; + _UINT32 crc = 0; FrtHeader frtHeader; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/XFExt.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/XFExt.cpp index e9f8a40ded..07f8a1134e 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/XFExt.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/XFExt.cpp @@ -66,5 +66,18 @@ void XFExt::readFields(CFRecord& record) } } +void XFExt::writeFields(CFRecord& record) +{ + frtHeader.rt = 0x0892; + record << frtHeader; + record.reserveNunBytes(2); // reserved + record << ixfe; + record.reserveNunBytes(2); // reserved + cexts = rgExt.size(); + record << cexts; + for(auto i : rgExt) + record << *i; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/XFExt.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/XFExt.h index baa25dfb59..ea4415945a 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/XFExt.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/XFExt.h @@ -49,12 +49,13 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeXFExt; //----------------------------- - _UINT16 ixfe; - _UINT16 cexts; + _UINT16 ixfe = 0; + _UINT16 cexts = 0; BiffStructurePtrVector rgExt; FrtHeader frtHeader; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/YMult.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/YMult.cpp index 40fa2f908b..395ac38f6f 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/YMult.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/YMult.cpp @@ -50,5 +50,14 @@ void YMult::readFields(CFRecord& record) fBeingEditted = GETBIT(flags, 1); } +void YMult::writeFields(CFRecord& record) +{ + unsigned short flags = 0; + SETBIT(flags, 0, fAutoShowMultiplier) + SETBIT(flags, 1, fBeingEditted) + + record << frtHeaderOld << axmid << numLabelMultiplier << flags; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/YMult.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/YMult.h index 4971cd855d..83809b0640 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/YMult.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/YMult.h @@ -48,14 +48,15 @@ public: BaseObjectPtr clone(); void readFields(CFRecord& record); + void writeFields(CFRecord& record); static const ElementType type = typeYMult; FrtHeaderOld frtHeaderOld; - short axmid; + short axmid = 0; Xnum numLabelMultiplier; - bool fAutoShowMultiplier; - bool fBeingEditted; + bool fAutoShowMultiplier = false; + bool fBeingEditted = false; }; } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/AF12CellIcon.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/AF12CellIcon.cpp index 524512270f..484bfa81a6 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/AF12CellIcon.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/AF12CellIcon.cpp @@ -50,6 +50,10 @@ void AF12CellIcon::load(CFRecord& record) record >> iIconSet >> iIcon; } +void AF12CellIcon::save(CFRecord& record) +{ + record << iIconSet << iIcon; +} } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/AF12CellIcon.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/AF12CellIcon.h index 361a665c8f..96418ca26e 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/AF12CellIcon.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/AF12CellIcon.h @@ -46,11 +46,12 @@ public: ~AF12CellIcon(); virtual void load(CFRecord& record); + virtual void save(CFRecord& record); static const ElementType type = typeAF12CellIcon; - _UINT32 iIconSet; - _UINT32 iIcon; + _UINT32 iIconSet = 0; + _UINT32 iIcon = 0; }; typedef boost::shared_ptr AF12CellIconPtr; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/AF12Criteria.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/AF12Criteria.cpp index 8dcc3e99ed..eb43e29d36 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/AF12Criteria.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/AF12Criteria.cpp @@ -65,6 +65,13 @@ void AF12Criteria::load(CFRecord& record) } } +void AF12Criteria::save(CFRecord& record) +{ + record << doper; + if(doper.vt == 0x06) + record << str; + +} } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/AF12Criteria.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/AF12Criteria.h index 48de5e986a..ab73c092f4 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/AF12Criteria.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/AF12Criteria.h @@ -47,6 +47,7 @@ public: ~AF12Criteria(); virtual void load(CFRecord& record); + virtual void save(CFRecord& record); static const ElementType type = typeAF12Criteria; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/AFDOper.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/AFDOper.cpp index 6be26d18b2..5dbf75c30a 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/AFDOper.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/AFDOper.cpp @@ -92,6 +92,38 @@ void AFDOper::load(CFRecord& record) } } +void AFDOper::save(CFRecord& record) +{ + record << vt << grbitSign; + switch(vt) + { + case 0x02: + { + record << vtValueRk; + }break; + case 0x04: + { + record << vtValueNum; + }break; + case 0x06: + { + vtValueStr.m_bAutoFilter = m_bAutoFilter; + record << vtValueStr; + }break; + case 0x08: + { + record << vtValueBool; + }break; + case 0x0C: //All blanks are matched. + case 0x0E: //All non-blanks are matched. + case 0x00: + default: + { + record.reserveNunBytes(8); + }break; + } +} + int AFDOper::serialize(std::wostream & strm, const std::wstring &node_name, const std::wstring &val) { if (grbitSign < 1 || grbitSign > 6) return 0; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/AFDOper.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/AFDOper.h index 276381aab6..fb72f722db 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/AFDOper.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/AFDOper.h @@ -52,11 +52,12 @@ public: ~AFDOper(); virtual void load(CFRecord& record); + virtual void save(CFRecord& record); static const ElementType type = typeAFDOper; - unsigned char vt; - unsigned char grbitSign; + unsigned char vt = 0; + unsigned char grbitSign = 0; AFDOperStr vtValueStr; AFDOperBoolErr vtValueBool; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/AFDOperBoolErr.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/AFDOperBoolErr.cpp index eff2ef1718..315be1e33c 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/AFDOperBoolErr.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/AFDOperBoolErr.cpp @@ -49,6 +49,12 @@ void AFDOperBoolErr::load(CFRecord& record) record.skipNunBytes(4); } +void AFDOperBoolErr::save(CFRecord& record) +{ + record << bes; + record.reserveNunBytes(6); +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/AFDOperBoolErr.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/AFDOperBoolErr.h index edc5724f15..27062f8570 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/AFDOperBoolErr.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/AFDOperBoolErr.h @@ -43,10 +43,11 @@ public: BiffStructurePtr clone(); virtual void load(CFRecord& record); + virtual void save(CFRecord& record); static const ElementType type = typeAFDOperBoolErr; - _INT16 bes; + _INT16 bes = 0; }; -} // namespace XLS \ No newline at end of file +} // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/AFDOperRk.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/AFDOperRk.cpp index 4da2769113..13dcc78398 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/AFDOperRk.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/AFDOperRk.cpp @@ -50,6 +50,12 @@ void AFDOperRk::load(CFRecord& record) record.skipNunBytes(4); } +void AFDOperRk::save(CFRecord& record) +{ + record << rk; + record.reserveNunBytes(4); +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/AFDOperRk.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/AFDOperRk.h index 1692c7a794..c474bd69ad 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/AFDOperRk.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/AFDOperRk.h @@ -43,11 +43,12 @@ public: BiffStructurePtr clone(); virtual void load(CFRecord& record); + virtual void save(CFRecord& record); static const ElementType type = typeAFDOperRk; - _UINT32 rk; + _UINT32 rk = 0; }; -} // namespace XLS \ No newline at end of file +} // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/AFDOperStr.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/AFDOperStr.cpp index c410007e72..1a849a6032 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/AFDOperStr.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/AFDOperStr.cpp @@ -70,6 +70,17 @@ void AFDOperStr::load(CFRecord& record) record.skipNunBytes(4); } +void AFDOperStr::save(CFRecord& record) +{ + if (m_bAutoFilter) // AutoFilter + record.reserveNunBytes(4); + record << cch << fCompare; + record.reserveNunBytes(2); + + if (!m_bAutoFilter) // AutoFilter12 + record.reserveNunBytes(4); +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/AFDOperStr.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/AFDOperStr.h index ada1a54caf..35e4754771 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/AFDOperStr.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/AFDOperStr.h @@ -51,11 +51,12 @@ public: static const ElementType type = typeAFDOperStr; virtual void load(CFRecord& record); + virtual void save(CFRecord& record); - unsigned char cch; - unsigned char fCompare; + unsigned char cch = 0; + unsigned char fCompare = false; - bool m_bAutoFilter; + bool m_bAutoFilter = false; }; } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/AFDOperXNum.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/AFDOperXNum.cpp index 83e7fefd8c..dff01f7376 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/AFDOperXNum.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/AFDOperXNum.cpp @@ -31,6 +31,7 @@ */ #include "AFDOperXNum.h" +#include "../../../MsBinaryFile/XlsFile/Format/Logic/Biff_structures/Xnum.h" namespace XLS { @@ -48,6 +49,13 @@ void AFDOperXNum::load(CFRecord& record) val = 0; } +void AFDOperXNum::save(CFRecord& record) +{ + Xnum numValue; + numValue.data.value = val; + record << numValue; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/AFDOperXNum.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/AFDOperXNum.h index 32946509fa..bd077f1fc2 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/AFDOperXNum.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/AFDOperXNum.h @@ -43,11 +43,12 @@ public: BiffStructurePtr clone(); virtual void load(CFRecord& record); + virtual void save(CFRecord& record); static const ElementType type = typeAFDOperXNum; - double val; + double val = 0; }; -} // namespace XLS \ No newline at end of file +} // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/AddinUdf.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/AddinUdf.cpp index 37de1a6e79..905f7884e6 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/AddinUdf.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/AddinUdf.cpp @@ -51,6 +51,13 @@ void AddinUdf::load(CFRecord& record) record.skipNunBytes(cb); // unused } +void AddinUdf::save(CFRecord& record) +{ + record.reserveNunBytes(4); + record << udfName; + unsigned short cb = 0; + record << cb; +} } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/AddinUdf.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/AddinUdf.h index dc945e5c3a..8034fb82df 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/AddinUdf.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/AddinUdf.h @@ -46,6 +46,7 @@ public: BiffStructurePtr clone(); virtual void load(CFRecord& record); + virtual void save(CFRecord& record); static const ElementType type = typeAddinUdf; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/AntiMoniker.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/AntiMoniker.cpp index 6c44311662..a66c27c904 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/AntiMoniker.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/AntiMoniker.cpp @@ -46,6 +46,10 @@ void AntiMoniker::load(XLS::CFRecord& record) record >> count; } +void AntiMoniker::save(XLS::CFRecord& record) +{ + record << count; +} } // namespace OSHARED diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/AntiMoniker.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/AntiMoniker.h index a638d1e2cf..e7b20a8fb4 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/AntiMoniker.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/AntiMoniker.h @@ -47,9 +47,10 @@ public: static const XLS::ElementType type = XLS::typeAntiMoniker; virtual void load(XLS::CFRecord& record); + virtual void save(XLS::CFRecord& record); - _UINT32 count; + _UINT32 count = 0; }; } // namespace OSHARED diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/Bes.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/Bes.cpp index 1dfa2bee1f..67fcbaa2b1 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/Bes.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/Bes.cpp @@ -49,6 +49,11 @@ void Bes::load(CFRecord& record) record >> bBoolErr >> fError; } +void Bes::save(CFRecord& record) +{ + record << bBoolErr << fError; +} + const std::wstring Bes::toString() { diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/Bes.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/Bes.h index dfc85527b8..a792d0043b 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/Bes.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/Bes.h @@ -46,12 +46,13 @@ public: static const ElementType type = typeBes; virtual void load(CFRecord& record); + virtual void save(CFRecord& record); const std::wstring toString(); void fromString(const std::wstring str); - unsigned char bBoolErr; - Boolean fError; + unsigned char bBoolErr = 0; + Boolean fError = 0; }; } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/BiffString.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/BiffString.cpp index 4443acc6c2..e4033d3fe0 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/BiffString.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/BiffString.cpp @@ -319,6 +319,17 @@ namespace XLS strTotal += arStrings.back(); } } + void XLUnicodeStringSegmented::save(CFRecord& record) + { + record << cchTotal; + for(auto tempStr : arStrings) + { + XLUnicodeString string; + string = tempStr; + record << string; + } + } + void XLUnicodeStringSegmented::load(IBinaryReader* reader) { cchTotal = reader->ReadUInt32(); diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/BiffString.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/BiffString.h index b7c74f9efc..6e38cc283b 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/BiffString.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/BiffString.h @@ -95,9 +95,9 @@ public: const bool getWideRecommendation() const; protected: - std::wstring str_; + std::wstring str_= L""; - size_t struct_size; + size_t struct_size = 0; _CP_OPT(size_t) cch_; }; @@ -215,8 +215,12 @@ public: case aw_READ_FROM_RECORD_IF_CCH_NOT_ZERO: if(0 == cch) break; case aw_READ_FROM_RECORD: - //stub - break; + { + is_wide = true; + unsigned char wideFlag = 1; // for wide chars writing + record << wideFlag; + break; + } case aw_WIDE: is_wide = true; break; @@ -319,10 +323,11 @@ public: virtual void load(CFRecord& record); virtual void load(IBinaryReader* reader); + virtual void save(CFRecord& record); static const ElementType type = typeStringSegmented; - _UINT32 cchTotal; + _UINT32 cchTotal = 0; std::vector arStrings; std::wstring strTotal; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/BitMarkedStructs.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/BitMarkedStructs.h index 1b00497a7e..2a9c4c13c5 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/BitMarkedStructs.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/BitMarkedStructs.h @@ -125,7 +125,7 @@ private: struct BErr { - unsigned char err; + unsigned char err = 0; BErr() {} BErr(const std::wstring str) { @@ -258,9 +258,9 @@ private: struct DXFNumIFmt { private: - unsigned char unused; + unsigned char unused = 0; public: - unsigned char ifmt; + unsigned char ifmt = 0; }; struct FFErrorCheck diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/BookExt_Conditional11.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/BookExt_Conditional11.cpp index 63d431ee8f..4b606d10e1 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/BookExt_Conditional11.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/BookExt_Conditional11.cpp @@ -49,6 +49,13 @@ void BookExt_Conditional11::load(CFRecord& record) fShowInkAnnotation = GETBIT(flags, 1); } +void BookExt_Conditional11::save(CFRecord& record) +{ + unsigned char flags = 0; + SETBIT(flags, 0, fBuggedUserAboutSolution) + SETBIT(flags, 1, fShowInkAnnotation) + record << flags; +} } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/BookExt_Conditional11.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/BookExt_Conditional11.h index 7a26835ce6..dca94c8290 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/BookExt_Conditional11.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/BookExt_Conditional11.h @@ -48,10 +48,10 @@ public: virtual void load(CFRecord& record); + virtual void save(CFRecord& record); - - bool fBuggedUserAboutSolution; - bool fShowInkAnnotation; + bool fBuggedUserAboutSolution = false; + bool fShowInkAnnotation = false; }; } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/BookExt_Conditional12.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/BookExt_Conditional12.cpp index aeb3d5162b..951cdf1216 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/BookExt_Conditional12.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/BookExt_Conditional12.cpp @@ -49,6 +49,14 @@ void BookExt_Conditional12::load(CFRecord& record) fShowPivotChartFilter = GETBIT(flags, 2); } +void BookExt_Conditional12::save(CFRecord& record) +{ + unsigned char flags = 0; + SETBIT(flags, 1, fPublishedBookItems) + SETBIT(flags, 2, fShowPivotChartFilter) + record << flags; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/BookExt_Conditional12.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/BookExt_Conditional12.h index 6507acd033..8528c6d557 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/BookExt_Conditional12.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/BookExt_Conditional12.h @@ -47,10 +47,10 @@ public: static const ElementType type = typeBookExt_Conditional12; virtual void load(CFRecord& record); + virtual void save(CFRecord& record); - - bool fPublishedBookItems; - bool fShowPivotChartFilter; + bool fPublishedBookItems = false; + bool fShowPivotChartFilter = false; }; } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/BuiltInStyle.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/BuiltInStyle.cpp index 97dc9bcef1..4213f220d2 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/BuiltInStyle.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/BuiltInStyle.cpp @@ -46,5 +46,10 @@ void BuiltInStyle::load(CFRecord& record) record >> istyBuiltIn >> iLevel; } +void BuiltInStyle::save(CFRecord& record) +{ + record << istyBuiltIn << iLevel; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/BuiltInStyle.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/BuiltInStyle.h index 850bc28ae1..c6aeed20f1 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/BuiltInStyle.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/BuiltInStyle.h @@ -47,10 +47,11 @@ public: static const ElementType type = typeBuiltInStyle; virtual void load(CFRecord& record); + virtual void save(CFRecord& record); - unsigned char istyBuiltIn; - unsigned char iLevel; + unsigned char istyBuiltIn = 0; + unsigned char iLevel = 0xFF; }; //#pragma pack() // restore diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CFColor.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CFColor.cpp index 25729fb708..f94bdfdc7e 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CFColor.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CFColor.cpp @@ -76,6 +76,29 @@ void CFColor::load(CFRecord& record) record >> numTint; } +void CFColor::save(CFRecord& record) +{ + record << xclrType; + switch(xclrType.type) + { + case XColorType::XCLRINDEXED: + record << icv; + break; + case XColorType::XCLRRGB: + record << rgb; + break; + case XColorType::XCLRTHEMED: + record << theme; + break; + case XColorType::XCLRNINCHED: + case XColorType::XCLRAUTO: + record.reserveNunBytes(4); // ignored + break; + default: + break; + } + record << numTint; +} } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CFColor.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CFColor.h index 7baa402f31..692aa1ff93 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CFColor.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CFColor.h @@ -51,12 +51,13 @@ public: static const ElementType type = typeCFColor; virtual void load(CFRecord& record); + virtual void save(CFRecord& record); XColorType xclrType; - ColorICV icv; + ColorICV icv = 0; LongRGBA rgb; - ColorTheme theme; - double numTint; + ColorTheme theme = 0; + double numTint = 0; }; } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CFDatabar.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CFDatabar.cpp index 1fff785131..f5cf085c23 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CFDatabar.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CFDatabar.cpp @@ -60,6 +60,19 @@ void CFDatabar::load(CFRecord& record) cfvoDB2.load(record); } +void CFDatabar::save(CFRecord& record) +{ + record.reserveNunBytes(3); // unused + + unsigned char flags = 0; + SETBIT(flags, 0, fRightToLeft); + SETBIT(flags, 1, fShowValue); + record << flags; + record << iPercentMin << iPercentMax << color; + cfvoDB1.save(record); + cfvoDB2.save(record); +} + int CFDatabar::serialize(std::wostream & stream) { CP_XML_WRITER(stream) diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CFDatabar.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CFDatabar.h index d54f6b48ac..85db68ea97 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CFDatabar.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CFDatabar.h @@ -47,6 +47,7 @@ public: static const ElementType type = typeCFDatabar; virtual void load(CFRecord& record); + virtual void save(CFRecord& record); virtual int serialize(std::wostream & _stream); diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CFExNonCF12.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CFExNonCF12.cpp index 0787b14a67..8d5fc49fa9 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CFExNonCF12.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CFExNonCF12.cpp @@ -60,6 +60,23 @@ void CFExNonCF12::load(CFRecord& record) record >> rgbTemplateParms; } +void CFExNonCF12::save(CFRecord& record) +{ + unsigned char flags = 0; + SETBIT(flags, 0, fActive); + SETBIT(flags, 1, fStopIfTrue); + record << icf << cp << icfTemplate << ipriority_ << flags; + + record << fHasDXF; + + if(fHasDXF) + { + record << dxf; + } + unsigned char cbTemplateParm = 16; + record << cbTemplateParm; + record << rgbTemplateParms; +} } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CFExNonCF12.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CFExNonCF12.h index fa9e604498..3b0ba8a0c6 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CFExNonCF12.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CFExNonCF12.h @@ -49,6 +49,7 @@ public: static const ElementType type = typeCFExNonCF12; virtual void load(CFRecord& record); + virtual void save(CFRecord& record); unsigned short icf; unsigned char cp; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CFExTemplateParams.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CFExTemplateParams.cpp index abf20e5ab9..994bf62807 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CFExTemplateParams.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CFExTemplateParams.cpp @@ -47,5 +47,10 @@ void CFExTemplateParams::load(CFRecord& record) record.loadAnyData(data); } +void CFExTemplateParams::save(CFRecord& record) +{ + record.storeAnyData(data); +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CFExTemplateParams.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CFExTemplateParams.h index 7a1bd78f99..89720c40bb 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CFExTemplateParams.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CFExTemplateParams.h @@ -110,6 +110,7 @@ public: BiffStructurePtr clone(); virtual void load(CFRecord& record); + virtual void save(CFRecord& record); static const ElementType type = typeCFExTemplateParams; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CFGradient.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CFGradient.cpp index 297b810f06..7ddadc3bcb 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CFGradient.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CFGradient.cpp @@ -49,6 +49,15 @@ void CFGradientInterpItem::load(CFRecord& record) //record >> val; numDomain = val << 32; //record >> val; numDomain = val; } +void CFGradientInterpItem::save(CFRecord& record) +{ + cfvo.save(record); + record << numDomain; + //record.skipNunBytes(8); + //int val; + //record >> val; numDomain = val << 32; + //record >> val; numDomain = val; +} //--------------------------------------------------------------------------------------------- BiffStructurePtr CFGradientItem::clone() { @@ -66,6 +75,13 @@ void CFGradientItem::load(CFRecord& record) color.load(record); } +void CFGradientItem::save(CFRecord& record) +{ + record << numGrange; + + color.save(record); +} + //-------------------------------------------------------------------------------------------- BiffStructurePtr CFGradient::clone() @@ -113,6 +129,23 @@ void CFGradient::load(CFRecord& record) rgCurve.push_back(item); } } +void CFGradient::save(CFRecord& record) +{ + record.reserveNunBytes(3); + cInterpCurve = rgInterp.size(); + cGradientCurve = cInterpCurve; + record << cInterpCurve << cGradientCurve; + unsigned char flags = 0; + SETBIT(flags, 0, fClamp); + SETBIT(flags, 1, fBackground); + record << flags; + for(auto i : rgInterp) + if(i!= nullptr) + record << i; + for(auto i : rgCurve) + if(i!= nullptr) + record << i; +} int CFGradient::serialize(std::wostream & stream) { CP_XML_WRITER(stream) diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CFGradient.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CFGradient.h index 99cad2db6b..919abfd3df 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CFGradient.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CFGradient.h @@ -47,10 +47,11 @@ public: static const ElementType type = typeAnyObject; virtual void load(CFRecord& record); + virtual void save(CFRecord& record); - CFVO cfvo; - double numDomain; + CFVO cfvo; + double numDomain = 0; }; typedef boost::shared_ptr CFGradientInterpItemPtr; @@ -64,6 +65,7 @@ public: static const ElementType type = typeAnyObject; virtual void load(CFRecord& record); + virtual void save(CFRecord& record); Xnum numGrange; CFColor color; @@ -79,14 +81,15 @@ public: static const ElementType type = typeCFGradient; virtual void load(CFRecord& record); + virtual void save(CFRecord& record); virtual int serialize(std::wostream & stream); - unsigned char cInterpCurve; //MUST be 0x2 or 0x3. - unsigned char cGradientCurve; // == cInterpCurve + unsigned char cInterpCurve = 0x2; //MUST be 0x2 or 0x3. + unsigned char cGradientCurve = 0x2; // == cInterpCurve - bool fClamp; - bool fBackground; + bool fClamp = 0; + bool fBackground = 0; std::vectorrgInterp; std::vector rgCurve; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CFMStateItem.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CFMStateItem.cpp index a889da4f90..9ddbeaf5e5 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CFMStateItem.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CFMStateItem.cpp @@ -48,6 +48,12 @@ void CFMStateItem::load(CFRecord& record) record.skipNunBytes(4); // unused } +void CFMStateItem::save(CFRecord& record) +{ + cfvo.save(record); + record << fEqual; + record.reserveNunBytes(4); +} } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CFMStateItem.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CFMStateItem.h index 332f8502de..29fe2e5a4f 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CFMStateItem.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CFMStateItem.h @@ -49,9 +49,10 @@ public: static const ElementType type = typeCFMStateItem; virtual void load(CFRecord& record); + virtual void save(CFRecord& record); CFVO cfvo; - Boolean fEqual; + Boolean fEqual = 0; }; typedef boost::shared_ptr CFMStateItemPtr; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CFMultistate.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CFMultistate.cpp index f0ffb343b5..71a9b75d43 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CFMultistate.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CFMultistate.cpp @@ -59,6 +59,21 @@ void CFMultistate::load(CFRecord& record) rgStates.push_back(item); } } + +void CFMultistate::save(CFRecord& record) +{ + record.reserveNunBytes(3); + cStates = rgStates.size(); + record << cStates << iIconSet; + unsigned char flags = 0; + SETBIT(flags, 0, fIconOnly); + SETBIT(flags, 2, fReverse); + record << flags; + for (auto i : rgStates) + if(i != nullptr) + i->save(record); +} + int CFMultistate::serialize(std::wostream & stream) { CP_XML_WRITER(stream) diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CFMultistate.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CFMultistate.h index 20faba3aa4..cfdfc3bb76 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CFMultistate.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CFMultistate.h @@ -46,11 +46,12 @@ public: static const ElementType type = typeCFMultistate; virtual void load(CFRecord& record); + virtual void save(CFRecord& record); virtual int serialize(std::wostream & _stream); - unsigned char cStates; - unsigned char iIconSet; + unsigned char cStates = 0; + unsigned char iIconSet = 0; bool fIconOnly; bool fReverse; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CFParsedFormulaNoCCE.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CFParsedFormulaNoCCE.cpp index 716be327b5..ced27b39eb 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CFParsedFormulaNoCCE.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CFParsedFormulaNoCCE.cpp @@ -54,6 +54,10 @@ void CFParsedFormulaNoCCE::load(CFRecord& record, const unsigned short cce) rgce.load(record, cce); } +void CFParsedFormulaNoCCE::save(CFRecord& record) +{ + rgce.save(record); +} } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CFParsedFormulaNoCCE.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CFParsedFormulaNoCCE.h index 00a1149ecb..ab6f219181 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CFParsedFormulaNoCCE.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CFParsedFormulaNoCCE.h @@ -43,6 +43,7 @@ public: CFParsedFormulaNoCCE(const CellRef& cell_base_ref_init); BiffStructurePtr clone(); void load(CFRecord& record, const unsigned short cce); + void save(CFRecord& record); private: // stub to make the class non-abstract diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CFVO.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CFVO.cpp index 60e380f598..6ce51af4f5 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CFVO.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CFVO.cpp @@ -52,6 +52,19 @@ void CFVO::load(CFRecord& record) } } +void CFVO::save(CFRecord& record) +{ + record << cfvoType; + if(!fmla.rgce.sequence.empty()) + { + fmla.save(record); + } + else if(cfvoType != 2 && cfvoType != 3) + { + record << numValue; + } +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CFVO.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CFVO.h index 0781098757..4e27901145 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CFVO.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CFVO.h @@ -46,11 +46,11 @@ public: static const ElementType type = typeCFVO; virtual void load(CFRecord& record); + virtual void save(CFRecord& record); - - unsigned char cfvoType; + unsigned char cfvoType = 0; CFVOParsedFormula fmla; - double numValue; + double numValue = 0; }; typedef boost::shared_ptr CFVOPtr; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/Cell.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/Cell.cpp index b4cff4fc91..024c301d11 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/Cell.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/Cell.cpp @@ -85,7 +85,10 @@ void Cell::load(CFRecord& record) record >> ixfe; } } - +void Cell::save(CFRecord& record) +{ + record << rw << col << ixfe; +} const CellRef Cell::getLocation() const { diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/Cell.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/Cell.h index 1e23673577..409f9e5245 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/Cell.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/Cell.h @@ -50,14 +50,15 @@ public: BiffStructurePtr clone(); virtual void load(CFRecord& record); + virtual void save(CFRecord& record); const CellRef getLocation() const; static const ElementType type = typeCell; - Rw rw; - Col col; - IXFCell ixfe; + Rw rw = 0; + Col col = 0; + IXFCell ixfe = 0; }; typedef boost::shared_ptr CellPtr; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CellParsedFormula.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CellParsedFormula.cpp index ae90263d27..3bcbf78381 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CellParsedFormula.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CellParsedFormula.cpp @@ -101,7 +101,7 @@ void CellParsedFormula::save(CFRecord& record) size = record.getRdPtr() - rdPtr; - record.RollRdPtrBack(size + 4); + record.RollRdPtrBack(size + 2); record << size; record.skipNunBytes(size); }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CellRangeRef.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CellRangeRef.h index 6c9fa24d27..0a3d49488e 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CellRangeRef.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CellRangeRef.h @@ -83,14 +83,14 @@ public: void load(CFRecord& record) override {} void save(CFRecord& record) override {} - int rowFirst; - int rowLast; - bool rowFirstRelative; - bool rowLastRelative; - int columnFirst; - int columnLast; - bool columnFirstRelative; - bool columnLastRelative; + int rowFirst = 0; + int rowLast = 0; + bool rowFirstRelative = 0; + bool rowLastRelative = 0; + int columnFirst = 0; + int columnLast = 0; + bool columnFirstRelative = 0; + bool columnLastRelative = 0; mutable std::wstring to_string_cache; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ChartNumNillable.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ChartNumNillable.h index f12ed2530f..1245037f32 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ChartNumNillable.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ChartNumNillable.h @@ -63,7 +63,7 @@ private: unsigned short type; unsigned short fExprO; }; - double xnum; + double xnum = 0; } data; unsigned short nil_type_; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ChartParsedFormula.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ChartParsedFormula.cpp index 6efbabe13f..8b2598f32e 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ChartParsedFormula.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ChartParsedFormula.cpp @@ -97,6 +97,18 @@ void ChartParsedFormula::load(CFRecord& record) } } +void ChartParsedFormula::save(CFRecord& record) +{ + unsigned short cce = 0; + record.reserveNunBytes(2);//cce + auto rgceBeginPos = record.getRdPtr(); + rgce.save(record); + cce = record.getRdPtr() - rgceBeginPos; + record.RollRdPtrBack(cce+2); + record << cce; + record.skipNunBytes(cce); +} + bool ChartParsedFormula::inRange(const CellRef & ref) { for (size_t i = 0 ; i < cell_ranges.size(); i++) diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ChartParsedFormula.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ChartParsedFormula.h index 87c6b8c312..b8fec1d981 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ChartParsedFormula.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ChartParsedFormula.h @@ -45,6 +45,7 @@ public: BiffStructurePtr clone(); void load(CFRecord& record); + void save(CFRecord& record); std::vector cell_ranges; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CompositeMoniker.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CompositeMoniker.cpp index 0ad0520b2d..6a1951014f 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CompositeMoniker.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CompositeMoniker.cpp @@ -65,6 +65,14 @@ void CompositeMoniker::load(XLS::CFRecord& record) } } +void CompositeMoniker::save(XLS::CFRecord& record) +{ + unsigned int cMonikers = monikerArray.size(); + record << cMonikers; + for(auto i : monikerArray) + record << i; +} + } // namespace OSHARED diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CompositeMoniker.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CompositeMoniker.h index f888e650f0..de5287fc24 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CompositeMoniker.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CompositeMoniker.h @@ -48,6 +48,7 @@ public: static const XLS::ElementType type = XLS::typeCompositeMoniker; virtual void load(XLS::CFRecord& record); + virtual void save(XLS::CFRecord& record); std::vector monikerArray; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CondFmtStructure.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CondFmtStructure.cpp index 9c04abb1ba..51eade23db 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CondFmtStructure.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CondFmtStructure.cpp @@ -52,6 +52,17 @@ void CondFmtStructure::load(CFRecord& record) record >> refBound >> sqref; } +void CondFmtStructure::save(CFRecord& record) +{ + record << ccf; + unsigned short flags = 0; + SETBIT(flags, 0, fToughRecalc); + SETBITS(flags, 1, 15, nID); + record << flags; + + record << refBound << sqref; +} + const CellRef CondFmtStructure::getLocation() const { diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CondFmtStructure.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CondFmtStructure.h index 35bd3d7038..afa2bc34f8 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CondFmtStructure.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/CondFmtStructure.h @@ -46,13 +46,14 @@ public: static const ElementType type = typeCondFmtStructure; virtual void load(CFRecord& record); + virtual void save(CFRecord& record); const CellRef getLocation() const; - unsigned short ccf; - bool fToughRecalc; - unsigned short nID; + unsigned short ccf = 0; + bool fToughRecalc = 0; + unsigned short nID = 0; Ref8U refBound; SqRefU sqref; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ConnGrbitDbtAdo.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ConnGrbitDbtAdo.cpp index ba55612629..bf613bc121 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ConnGrbitDbtAdo.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ConnGrbitDbtAdo.cpp @@ -48,6 +48,12 @@ void ConnGrbitDbtAdo::load(CFRecord& record) fAdoRefreshable = GETBIT(flags, 1); } +void ConnGrbitDbtAdo::save(CFRecord& record) +{ + unsigned short flags = 0; + SETBIT(flags, 1, fAdoRefreshable) + record << flags; +} } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ConnGrbitDbtAdo.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ConnGrbitDbtAdo.h index c0b8a81b80..18f844a68d 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ConnGrbitDbtAdo.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ConnGrbitDbtAdo.h @@ -48,9 +48,10 @@ public: static const ElementType type = typeConnGrbitDbtAdo; virtual void load(CFRecord& record); + virtual void save(CFRecord& record); - bool fAdoRefreshable; + bool fAdoRefreshable = false; }; -} // namespace XLS \ No newline at end of file +} // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ConnGrbitDbtOledb.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ConnGrbitDbtOledb.cpp index 519724965b..06a4724396 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ConnGrbitDbtOledb.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ConnGrbitDbtOledb.cpp @@ -56,6 +56,23 @@ void ConnGrbitDbtOledb::load(CFRecord& record) fSrvSupportsClientCube = GETBIT(flags, 11); } +void ConnGrbitDbtOledb::save(CFRecord& record) +{ + unsigned short flags = 0; + + SETBITS(flags, 0, 2, dbost) + SETBIT(flags, 3, fLocalConn) + SETBIT(flags, 4, fNoRefreshCube) + SETBIT(flags, 5, fUseOfficeLcid) + SETBIT(flags, 6, fSrvFmtNum) + SETBIT(flags, 7, fSrvFmtBack) + SETBIT(flags, 8, fSrvFmtFore) + SETBIT(flags, 9, fSrvFmtFlags) + SETBIT(flags, 10, fSupportsLangCellProp) + SETBIT(flags, 11, fSrvSupportsClientCube) + + record << flags; +} } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ConnGrbitDbtOledb.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ConnGrbitDbtOledb.h index 22124e18cf..397e48be05 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ConnGrbitDbtOledb.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ConnGrbitDbtOledb.h @@ -48,17 +48,18 @@ public: static const ElementType type = typeConnGrbitDbtOledb; virtual void load(CFRecord& record); + virtual void save(CFRecord& record); - unsigned char dbost; - bool fLocalConn; - bool fNoRefreshCube; - bool fUseOfficeLcid; - bool fSrvFmtNum; - bool fSrvFmtBack; - bool fSrvFmtFore; - bool fSrvFmtFlags; - bool fSupportsLangCellProp; - bool fSrvSupportsClientCube; + unsigned char dbost = 0; + bool fLocalConn = false; + bool fNoRefreshCube = false; + bool fUseOfficeLcid = false; + bool fSrvFmtNum = false; + bool fSrvFmtBack = false; + bool fSrvFmtFore = false; + bool fSrvFmtFlags = false; + bool fSupportsLangCellProp = false; + bool fSrvSupportsClientCube = false; }; -} // namespace XLS \ No newline at end of file +} // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ConnGrbitDbtWeb.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ConnGrbitDbtWeb.cpp index febadaa60d..e26b42c993 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ConnGrbitDbtWeb.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ConnGrbitDbtWeb.cpp @@ -52,6 +52,18 @@ void ConnGrbitDbtWeb::load(CFRecord& record) } +void ConnGrbitDbtWeb::save(CFRecord& record) +{ + unsigned short flags = 0; + SETBIT(flags, 0, fParsePreFormatted) + SETBIT(flags, 1, fConsecDelim) + SETBIT(flags, 2, fSameSettings) + SETBIT(flags, 3, fXL97Format) + SETBIT(flags, 4, fNoDateRecog) + SETBIT(flags, 5, fRefreshedInXl9) + + record << flags; +} } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ConnGrbitDbtWeb.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ConnGrbitDbtWeb.h index cbf603c80c..d5c873417a 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ConnGrbitDbtWeb.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ConnGrbitDbtWeb.h @@ -48,14 +48,15 @@ public: static const ElementType type = typeConnGrbitDbtWeb; virtual void load(CFRecord& record); + virtual void save(CFRecord& record); - bool fParsePreFormatted; - bool fConsecDelim; - bool fSameSettings; - bool fXL97Format; - bool fNoDateRecog; - bool fRefreshedInXl9; + bool fParsePreFormatted = false; + bool fConsecDelim = false; + bool fSameSettings = false; + bool fXL97Format = false; + bool fNoDateRecog = false; + bool fRefreshedInXl9 = false; }; -} // namespace XLS \ No newline at end of file +} // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DConnConnectionOleDb.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DConnConnectionOleDb.cpp index 62a4b32f8f..5d91223cea 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DConnConnectionOleDb.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DConnConnectionOleDb.cpp @@ -73,6 +73,18 @@ void DConnConnectionOleDb::load(CFRecord& record) } } +void DConnConnectionOleDb::save(CFRecord& record) +{ + record << nDrillthroughRows << cOleDb; + for(auto i : rgIOleDbValid) + record << i; + if(cOleDb <= 4) + record.skipNunBytes(2 * (4 - cOleDb)); + record.reserveNunBytes(2); + for(auto i : rgConn) + record << i; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DConnConnectionOleDb.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DConnConnectionOleDb.h index 623d37f226..1eb208170a 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DConnConnectionOleDb.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DConnConnectionOleDb.h @@ -48,13 +48,14 @@ public: static const ElementType type = typeDConnConnectionOleDb; virtual void load(CFRecord& record); + virtual void save(CFRecord& record); - _UINT32 nDrillthroughRows; - unsigned short cOleDb; + _UINT32 nDrillthroughRows = 0; + unsigned short cOleDb = 0; std::vector rgIOleDbValid; //rgIOleDbInvalid; //size in bytes = 2 * (4 – cOleDb) std::vector rgConn; }; -} // namespace XLS \ No newline at end of file +} // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DConnConnectionWeb.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DConnConnectionWeb.cpp index 8b5377b66e..74b49833c1 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DConnConnectionWeb.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DConnConnectionWeb.cpp @@ -54,6 +54,11 @@ void DConnConnectionWeb::load(CFRecord& record) record >> rgbURL >> rgbWebPost; } +void DConnConnectionWeb::save(CFRecord& record) +{ + record << rgbURL << rgbWebPost; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DConnConnectionWeb.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DConnConnectionWeb.h index 2bc8e7878b..b18bfee8f8 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DConnConnectionWeb.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DConnConnectionWeb.h @@ -48,10 +48,11 @@ public: static const ElementType type = typeDConnConnectionWeb; virtual void load(CFRecord& record); + virtual void save(CFRecord& record); DConnStringSequence rgbURL; DConnStringSequence rgbWebPost; }; -} // namespace XLS \ No newline at end of file +} // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DConnId.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DConnId.cpp index 373bfb0d91..dc96fab4e8 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DConnId.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DConnId.cpp @@ -58,6 +58,16 @@ void DConnId::load(CFRecord& record) } } +void DConnId::save(CFRecord& record) +{ + record << bType; + switch(bType) + { + case 1: record << string; break; + case 2: sxStreamID.writeFields(record); break; + default: break; + } +} } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DConnId.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DConnId.h index 92d017ca11..311fc1a266 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DConnId.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DConnId.h @@ -49,11 +49,12 @@ public: static const ElementType type = typeDConnId; virtual void load(CFRecord& record); + virtual void save(CFRecord& record); - unsigned char bType; + unsigned char bType = 0; XLUnicodeStringSegmented string; SXStreamID sxStreamID; }; -} // namespace XLS \ No newline at end of file +} // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DConnParamBindingValType.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DConnParamBindingValType.cpp index 98225fcf7d..d7eea9bcf0 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DConnParamBindingValType.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DConnParamBindingValType.cpp @@ -59,6 +59,15 @@ void DConnParamBindingValType::load(CFRecord& record) rgbBindingValue->load(record); } } +void DConnParamBindingValType::save(CFRecord& record) +{ + record << wBindingValueGrbit; + if(wBindingValueGrbit == 0x0002 && rgbBindingValue != nullptr) + record.reserveNunBytes(8); + if(rgbBindingValue != nullptr) + rgbBindingValue->save(record); +} + //----------------------------------------------------------------------------------- BiffStructurePtr DConnParamBindingValByte::clone() { @@ -73,6 +82,12 @@ void DConnParamBindingValByte::load(CFRecord& record) record >> fVal >> reserved1 >> reserved2 >> reserved3; } +void DConnParamBindingValByte::save(CFRecord& record) +{ + record << fVal; + record.reserveNunBytes(7); +} + //----------------------------------------------------------------------------------- BiffStructurePtr DConnParamBindingValInt::clone() { @@ -86,5 +101,10 @@ void DConnParamBindingValInt::load(CFRecord& record) record >> val >> reserved; } +void DConnParamBindingValInt::save(CFRecord& record) +{ + record << val; + record.reserveNunBytes(4); +} } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DConnParamBindingValType.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DConnParamBindingValType.h index 2d7d2ef455..edd9d81417 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DConnParamBindingValType.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DConnParamBindingValType.h @@ -47,8 +47,9 @@ public: static const ElementType type = typeDConnParamBindingValType; virtual void load(CFRecord& record); + virtual void save(CFRecord& record); - unsigned short wBindingValueGrbit; + unsigned short wBindingValueGrbit = 1; BiffStructurePtr rgbBindingValue; }; @@ -65,8 +66,9 @@ public: static const ElementType type = typeDConnParamBindingValByte; virtual void load(CFRecord& record); + virtual void save(CFRecord& record); - unsigned char fVal; + unsigned char fVal = false; }; class DConnParamBindingValInt: public BiffStructure @@ -81,8 +83,9 @@ public: static const ElementType type = typeDConnParamBindingValInt; virtual void load(CFRecord& record); + virtual void save(CFRecord& record); - _UINT32 val; + _UINT32 val = 0; }; -} // namespace XLS \ No newline at end of file +} // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DConnParameter.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DConnParameter.cpp index a94d338690..5dc28a1500 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DConnParameter.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DConnParameter.cpp @@ -68,6 +68,17 @@ void DConnParameter::load(CFRecord& record) } } +void DConnParameter::save(CFRecord& record) +{ + unsigned short flags1 = 0, flags2 = 0; + SETBITS(flags1, 0, 2, pbt) + SETBIT(flags2, 0, fDefaultName) + record << rgchName << flags1 << wTypeSql << flags2; + if (paramBinding != nullptr) + { + record << *paramBinding; + } +} } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DConnParameter.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DConnParameter.h index 624edd78e3..0251d4418e 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DConnParameter.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DConnParameter.h @@ -48,13 +48,14 @@ public: static const ElementType type = typeDConnParameter; virtual void load(CFRecord& record); + virtual void save(CFRecord& record); XLUnicodeStringSegmented rgchName; - unsigned char pbt; - short wTypeSql;// enum ODBCType - bool fDefaultName; + unsigned char pbt = 0; + short wTypeSql = 0;// enum ODBCType + bool fDefaultName = false; BiffStructurePtr paramBinding; }; -} // namespace XLS \ No newline at end of file +} // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DConnStringSequence.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DConnStringSequence.cpp index 851a7fad56..e1941d952c 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DConnStringSequence.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DConnStringSequence.cpp @@ -60,6 +60,17 @@ void DConnStringSequence::load(CFRecord& record) } } +void DConnStringSequence::save(CFRecord& record) +{ + record << cst; + for(auto i : rgString) + { + XLUnicodeStringSegmented val; + val = i; + record << val; + } +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DConnStringSequence.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DConnStringSequence.h index 1f894d4baa..bc0cb84985 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DConnStringSequence.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DConnStringSequence.h @@ -48,10 +48,11 @@ public: static const ElementType type = typeDConnStringSequence; virtual void load(CFRecord& record); + virtual void save(CFRecord& record); - unsigned short cst; + unsigned short cst = 0; std::vector rgString; }; -} // namespace XLS \ No newline at end of file +} // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DXFALC.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DXFALC.cpp index 176aecfbd3..78a5e7d624 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DXFALC.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DXFALC.cpp @@ -56,6 +56,22 @@ void DXFALC::load(CFRecord& record) record >> iIndent; } +void DXFALC::save(CFRecord& record) +{ + _UINT32 flags = 0; + SETBITS(flags, 0, 2, alc) + SETBIT(flags, 3, fWrap) + SETBITS(flags, 4, 6, alcv) + SETBIT(flags, 7, fJustLast) + SETBITS(flags, 8, 15, trot) + SETBITS(flags, 16, 19, cIndent) + SETBIT(flags, 20, fShrinkToFit) + SETBIT(flags, 21, fMergeCell) + SETBITS(flags, 22, 23, iReadingOrder) + + record << flags << iIndent; +} + int DXFALC::serialize(std::wostream & stream) { if (parent->iReadingOrderNinch && parent->alchNinch && parent->alcvNinch && parent->wrapNinch && diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DXFALC.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DXFALC.h index 6ed028f783..79597cd3f7 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DXFALC.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DXFALC.h @@ -48,21 +48,21 @@ public: static const ElementType type = typeDXFALC; virtual void load(CFRecord& record); - + virtual void save(CFRecord& record); int serialize(std::wostream & stream); - unsigned char alc; - bool fWrap; - unsigned char alcv; - bool fJustLast; - unsigned char trot; - unsigned char cIndent; - bool fShrinkToFit; - bool fMergeCell; - unsigned char iReadingOrder; + unsigned char alc = 0; + bool fWrap = 0; + unsigned char alcv = 0; + bool fJustLast = 0; + unsigned char trot = 0; + unsigned char cIndent = 0; + bool fShrinkToFit = 0; + bool fMergeCell = 0; + unsigned char iReadingOrder = 0; - _UINT32 iIndent; + _UINT32 iIndent = 0; //------------------------------------------------ DXFN *parent; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DXFBdr.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DXFBdr.cpp index da6d200fa6..5a3335e0d1 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DXFBdr.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DXFBdr.cpp @@ -66,6 +66,31 @@ void DXFBdr::load(CFRecord& record) } +void DXFBdr::save(CFRecord& record) +{ + _UINT32 flags = 0; + SETBITS(flags, 0, 3, dgLeft) + SETBITS(flags, 4, 7, dgRight) + SETBITS(flags, 8, 11, dgTop) + SETBITS(flags, 12, 15, dgBottom) + + SETBITS(flags, 16, 22, icvLeft) + SETBITS(flags, 23, 29, icvRight) + + SETBIT(flags, 30, bitDiagDown); + SETBIT(flags, 31, bitDiagUp); + + record << flags; + flags = 0; + + SETBITS(flags, 0, 6, icvTop) + SETBITS(flags, 7, 13, icvBottom) + SETBITS(flags, 14, 20, icvDiag) + SETBITS(flags, 21, 24, dgDiag) + + record << flags; +} + void serialize_one(std::wostream & stream, const std::wstring & name, unsigned char type, unsigned char color, FullColorExt* colorExt) { CP_XML_WRITER(stream) diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DXFBdr.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DXFBdr.h index e2e53d48c0..7cb2a3cca5 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DXFBdr.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DXFBdr.h @@ -48,6 +48,7 @@ public: static const ElementType type = typeDXFBdr; virtual void load(CFRecord& record); + virtual void save(CFRecord& record); int serialize(std::wostream & stream); diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DXFFntD.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DXFFntD.cpp index cca859c48c..202a8fa77b 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DXFFntD.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DXFFntD.cpp @@ -43,6 +43,11 @@ BiffStructurePtr DXFFntD::clone() return BiffStructurePtr(new DXFFntD(*this)); } +DXFFntD::DXFFntD() +{ + stFontName = L""; +} + void DXFFntD::load(CFRecord& record) { global_info = record.getGlobalWorkbookInfo(); @@ -69,6 +74,21 @@ void DXFFntD::load(CFRecord& record) record >> ich >> cch >> iFnt; } +void DXFFntD::save(CFRecord& record) +{ + + unsigned char cchFont = stFontName.getSize(); + record << cchFont; + if(cchFont) + record << stFontName; + record.reserveNunBytes(63 - cchFont); + record << stxp << icvFore; + record.reserveNunBytes(4); // reserved + record << tsNinch << fSssNinch << fUlsNinch << fBlsNinch; + record.reserveNunBytes(4); // reserved + record << ich << cch << iFnt; +} + int DXFFntD::serialize(std::wostream & stream, bool extOnly) { std::map::iterator pFind; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DXFFntD.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DXFFntD.h index 49e238b756..8ab877cf14 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DXFFntD.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DXFFntD.h @@ -48,15 +48,17 @@ class DXFFntD : public BiffStructure { BASE_STRUCTURE_DEFINE_CLASS_NAME(DXFFntD) public: + DXFFntD(); BiffStructurePtr clone(); static const ElementType type = typeDXFFntD; virtual void load(CFRecord& record); + virtual void save(CFRecord& record); int serialize(std::wostream & stream, bool extOnly = false); - XLUnicodeStringNoCch stFontName; + XLUnicodeStringNoCch stFontName; Stxp stxp; _INT32 icvFore = 0; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DXFN.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DXFN.cpp index 0c3bad5a25..807b9a37c0 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DXFN.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DXFN.cpp @@ -116,6 +116,76 @@ void DXFN::load(CFRecord& record) } } +void DXFN::save(CFRecord& record) +{ + _UINT32 flags = 0; + SETBIT(flags, 0, alchNinch); + SETBIT(flags, 1, alcvNinch); + SETBIT(flags, 2, wrapNinch); + SETBIT(flags, 3, trotNinch); + SETBIT(flags, 4, kintoNinch); + SETBIT(flags, 5, cIndentNinch); + SETBIT(flags, 6, fShrinkNinch); + SETBIT(flags, 7, fMergeCellNinch); + + SETBIT(flags, 8, lockedNinch); + SETBIT(flags, 9, hiddenNinch); + + SETBIT(flags, 10, glLeftNinch); + SETBIT(flags, 11, glRightNinch); + SETBIT(flags, 12, glTopNinch); + SETBIT(flags, 13, glBottomNinch); + SETBIT(flags, 14, glDiagDownNinch); + SETBIT(flags, 15, glDiagUpNinch); + + SETBIT(flags, 16, flsNinch); + SETBIT(flags, 17, icvFNinch); + SETBIT(flags, 18, icvBNinch); + + SETBIT(flags, 19, ifmtNinch); + SETBIT(flags, 20, fIfntNinch); + + SETBIT(flags, 25, ibitAtrNum); + SETBIT(flags, 26, ibitAtrFnt); + SETBIT(flags, 27, ibitAtrAlc); + SETBIT(flags, 28, ibitAtrBdr); + SETBIT(flags, 29, ibitAtrPat); + SETBIT(flags, 30, ibitAtrProt); + + SETBIT(flags, 31, iReadingOrderNinch); + record << flags; + + unsigned short flags2 = 0; + + SETBIT(flags2, 0, fIfmtUser); + SETBIT(flags2, 2, fNewBorder); + SETBIT(flags2, 15, fZeroInited); + + record << flags2; + + if(ibitAtrNum) + { + dxfnum.parent = this; + record << dxfnum; + } + if(ibitAtrFnt) + { + record << dxffntd; + } + if(ibitAtrAlc) + { + record << dxfalc; + } + if(ibitAtrBdr) + { + record << dxfbdr; + } + if(ibitAtrProt) + { + record << dxfprot; + } +} + int DXFN::serialize(std::wostream & stream) { CP_XML_WRITER(stream) diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DXFN.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DXFN.h index 9689ca0c2f..fc5091e1d4 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DXFN.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DXFN.h @@ -57,6 +57,7 @@ public: static const ElementType type = typeDXFN; virtual void load(CFRecord& record); + virtual void save(CFRecord& record); int serialize(std::wostream & stream); diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DXFN12.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DXFN12.cpp index 3f86ea9a06..4953a8e818 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DXFN12.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DXFN12.cpp @@ -67,6 +67,25 @@ void DXFN12::load(CFRecord& record) } } +void DXFN12::save(CFRecord& record) +{ + record.reserveNunBytes(4); + auto StartDataPose = record.getRdPtr(); + if(dxfn) + { + record >> *dxfn; + + if(dxfn->xfext != nullptr) + record << *dxfn->xfext; + cbDxf = record.getRdPtr() - StartDataPose; + record.RollRdPtrBack(cbDxf+4); + record << cbDxf; + record.skipNunBytes(cbDxf); + } + else + record.reserveNunBytes(2); +} + int DXFN12::serialize(std::wostream & stream) { if (!dxfn) return -1; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DXFN12.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DXFN12.h index e1f16f49e4..f779c65954 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DXFN12.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DXFN12.h @@ -48,10 +48,11 @@ public: static const ElementType type = typeDXFN12; virtual void load(CFRecord& record); + virtual void save(CFRecord& record); int serialize(std::wostream & stream); - _UINT32 cbDxf; + _UINT32 cbDxf = 0; DXFNPtr dxfn; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DXFN12List.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DXFN12List.cpp index 470a885ef5..3b9028b675 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DXFN12List.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DXFN12List.cpp @@ -91,6 +91,12 @@ void DXFN12List::load(CFRecord& record) } } +void DXFN12List::save(CFRecord& record) +{ + record << dxfn; + if(dxfn.xfext != nullptr) + record << *(dxfn.xfext); +} } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DXFN12List.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DXFN12List.h index 897a2f1cf3..db649601dd 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DXFN12List.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DXFN12List.h @@ -51,6 +51,7 @@ public: static const ElementType type = typeDXFN12List; virtual void load(CFRecord& record); + virtual void save(CFRecord& record); DXFN dxfn; //----------------------------------------------------------------- @@ -61,4 +62,4 @@ public: typedef boost::shared_ptr DXFN12ListPtr; -} // namespace XLS \ No newline at end of file +} // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DXFNum.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DXFNum.cpp index 3f9c9bb8c6..1d6485ea2a 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DXFNum.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DXFNum.cpp @@ -61,6 +61,17 @@ void DXFNum::load(CFRecord& record) fmt_id.ifmt = global_info->RegisterNumFormat(fmt_id.ifmt, user_defined.fmt.value()); // return update } +void DXFNum::save(CFRecord& record) +{ + if (parent->fIfmtUser) + { + record << user_defined; + } + else + { + record << fmt_id; + } +} int DXFNum::serialize(std::wostream & stream) { diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DXFNum.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DXFNum.h index d64b41f92c..7c4351f7f6 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DXFNum.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DXFNum.h @@ -49,6 +49,7 @@ public: static const ElementType type = typeDXFNum; virtual void load(CFRecord& record); + virtual void save(CFRecord& record); int serialize(std::wostream & stream); diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DXFNumUsr.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DXFNumUsr.cpp index 10d688d034..d2efaa15cb 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DXFNumUsr.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DXFNumUsr.cpp @@ -55,6 +55,17 @@ void DXFNumUsr::load(CFRecord& record) record >> fmt; } +void DXFNumUsr::save(CFRecord& record) +{ + auto cbPos = record.getRdPtr(); + record.reserveNunBytes(2); + record << fmt; + cb = record.getRdPtr() - cbPos; + record.RollRdPtrBack(cb); + record << cb; + record.skipNunBytes(cb - 2); +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DXFNumUsr.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DXFNumUsr.h index 04f8d1458c..41fed9c000 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DXFNumUsr.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DXFNumUsr.h @@ -49,8 +49,9 @@ public: static const ElementType type = typeDXFNumUsr; virtual void load(CFRecord& record); + virtual void save(CFRecord& record); - unsigned short cb; + unsigned short cb = 0; XLUnicodeString fmt; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DXFPat.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DXFPat.cpp index 96e46d1f85..8490931fb3 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DXFPat.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DXFPat.cpp @@ -52,6 +52,18 @@ void DXFPat::load(CFRecord& record) icvForeground = GETBITS(flags, 0, 6); icvBackground = GETBITS(flags, 7, 13); } + +void DXFPat::save(CFRecord& record) +{ + unsigned short flags = 0; + SETBITS(flags, 10, 15, fls); + record << flags; + flags = 0; + SETBITS(flags, 0, 6, icvForeground); + SETBITS(flags, 7, 13, icvBackground); + record << flags; +} + std::wstring GetPatternType(unsigned char fls) { std::wstring res; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DXFPat.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DXFPat.h index c70d49f230..6dd9dd3c7e 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DXFPat.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DXFPat.h @@ -48,6 +48,7 @@ public: static const ElementType type = typeDXFPat; virtual void load(CFRecord& record); + virtual void save(CFRecord& record); int serialize(std::wostream & stream); diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DXFProt.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DXFProt.cpp index 25084ace45..a67d9fa722 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DXFProt.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DXFProt.cpp @@ -50,6 +50,14 @@ void DXFProt::load(CFRecord& record) fHidden = GETBIT(flags, 1); } +void DXFProt::save(CFRecord& record) +{ + unsigned short flags = 0; + SETBIT(flags, 0, fLocked) + SETBIT(flags, 1, fHidden) + record << flags; +} + int DXFProt::serialize(std::wostream & stream) { if (parent->lockedNinch && parent->hiddenNinch) return 0; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DXFProt.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DXFProt.h index 00bf745223..864b0f1060 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DXFProt.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DXFProt.h @@ -47,7 +47,7 @@ public: static const ElementType type = typeDXFProt; virtual void load(CFRecord& record); - + virtual void save(CFRecord& record); int serialize(std::wostream & stream); diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DropDownObjId.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DropDownObjId.cpp index c24d607344..c704476a4e 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DropDownObjId.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DropDownObjId.cpp @@ -45,6 +45,11 @@ void DropDownObjId::load(CFRecord& record) record >> id; } +void DropDownObjId::save(CFRecord& record) +{ + record << id; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DropDownObjId.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DropDownObjId.h index 59e0510061..89ff608932 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DropDownObjId.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/DropDownObjId.h @@ -47,8 +47,9 @@ public: static const ElementType type = typeDropDownObjId; virtual void load(CFRecord& record); + virtual void save(CFRecord& record); - ObjId id; + ObjId id = 0; }; typedef boost::shared_ptr DropDownObjIdPtr; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/EnhancedProtection.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/EnhancedProtection.cpp index f531e949ad..5e97eac9d1 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/EnhancedProtection.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/EnhancedProtection.cpp @@ -75,6 +75,29 @@ void EnhancedProtection::load(CFRecord& record) record.skipNunBytes(2); // reserved } +void EnhancedProtection::save(CFRecord& record) +{ + unsigned short flags = 0; + + SETBIT(flags, 0, iprotObjects) + SETBIT(flags, 1, iprotScenarios) + SETBIT(flags, 2, iprotFormatCells) + SETBIT(flags, 3, iprotFormatColumns) + SETBIT(flags, 4, iprotFormatRows) + SETBIT(flags, 5, iprotInsertColumns) + SETBIT(flags, 6, iprotInsertRows) + SETBIT(flags, 7, iprotInsertHyperlinks) + SETBIT(flags, 8, iprotDeleteColumns) + SETBIT(flags, 9, iprotDeleteRows) + SETBIT(flags, 10, iprotSelLockedCells) + SETBIT(flags, 11, iprotSort) + SETBIT(flags, 12, iprotAutoFilter) + SETBIT(flags, 13, iprotPivotTables) + SETBIT(flags, 14, iprotSelUnlockedCells) + + record << flags; + record.reserveNunBytes(2); +} } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/EnhancedProtection.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/EnhancedProtection.h index 0111ff451e..7a278d8bf2 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/EnhancedProtection.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/EnhancedProtection.h @@ -49,23 +49,23 @@ public: static const ElementType type = typeEnhancedProtection; virtual void load(CFRecord& record); + virtual void save(CFRecord& record); - - bool iprotObjects; - bool iprotScenarios; - bool iprotFormatCells; - bool iprotFormatColumns; - bool iprotFormatRows; - bool iprotInsertColumns; - bool iprotInsertRows; - bool iprotInsertHyperlinks; - bool iprotDeleteColumns; - bool iprotDeleteRows; - bool iprotSelLockedCells; - bool iprotSort; - bool iprotAutoFilter; - bool iprotPivotTables; - bool iprotSelUnlockedCells; + bool iprotObjects = false; + bool iprotScenarios = false; + bool iprotFormatCells = false; + bool iprotFormatColumns = false; + bool iprotFormatRows = false; + bool iprotInsertColumns = false; + bool iprotInsertRows = false; + bool iprotInsertHyperlinks = false; + bool iprotDeleteColumns = false; + bool iprotDeleteRows = false; + bool iprotSelLockedCells = false; + bool iprotSort = false; + bool iprotAutoFilter = false; + bool iprotPivotTables = false; + bool iprotSelUnlockedCells = false; }; } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ExtProp.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ExtProp.cpp index 8a0805fe11..63b334a6de 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ExtProp.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ExtProp.cpp @@ -83,5 +83,45 @@ void ExtProp::load(CFRecord& record) } } +void ExtProp::save(CFRecord& record) +{ + unsigned short t = extType; + record << t << cb; + auto dataPos = record.getRdPtr(); + switch(extType) + { + case 0x0004: + case 0x0005: + case 0x0007: + case 0x0008: + case 0x0009: + case 0x000A: + case 0x000B: + case 0x000C: + case 0x000D: + { + record << extPropData.color; + }break; + case 0x0006: + { + record << extPropData.gradient_fill; + }break; + case 0x000E: + { + record << extPropData.font_scheme; + }break; + case 0x000F: + { + record << extPropData.indent_level; + }break; + default: + break; + } + cb = record.getRdPtr() - dataPos; + record.RollRdPtrBack(cb + 2); + cb += 4; + record << cb; + record.skipNunBytes(cb - 4); +} } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ExtProp.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ExtProp.h index f601576bc3..7f10de7c8b 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ExtProp.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ExtProp.h @@ -47,10 +47,11 @@ public: BiffStructurePtr clone(); virtual void load(CFRecord& record); + virtual void save(CFRecord& record); static const ElementType type = typeExtProp; - unsigned short cb; + unsigned short cb = 0; enum _type { diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ExtRst.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ExtRst.cpp index d13b87c678..0919161561 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ExtRst.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ExtRst.cpp @@ -76,6 +76,22 @@ void ExtRst::load(CFRecord& record) } +void ExtRst::save(CFRecord& record) +{ + unsigned short reserve1 = 1; + record << reserve1; + auto cbPose = record.getRdPtr(); + record.reserveNunBytes(2); + record << phs; + auto rphssubStart = record.getRdPtr(); + record << rphssub; + cb = record.getRdPtr() - rphssubStart; + record.RollRdPtrBack(record.getRdPtr() - cbPose); + record << cb; + record.skipNunBytes((rphssubStart - record.getRdPtr()) + cb); + for(auto i : rgphruns) + record << i; +} const size_t ExtRst::getSize() const { diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ExtRst.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ExtRst.h index fef0a082ad..7b3d897389 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ExtRst.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ExtRst.h @@ -52,11 +52,12 @@ public: static const ElementType type = typeExtRst; virtual void load(CFRecord& record); + virtual void save(CFRecord& record); const size_t getSize() const; - unsigned short cb; + unsigned short cb = 0; Phs phs; RPHSSub rphssub; std::vector rgphruns; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ExternDdeLinkNoOper.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ExternDdeLinkNoOper.cpp index f1f28de33d..4d7c4bcd91 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ExternDdeLinkNoOper.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ExternDdeLinkNoOper.cpp @@ -48,6 +48,12 @@ void ExternDdeLinkNoOper::load(CFRecord& record) record >> linkName; } +void ExternDdeLinkNoOper::save(CFRecord& record) +{ + record.reserveNunBytes(4); // reserved + record << linkName; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ExternDdeLinkNoOper.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ExternDdeLinkNoOper.h index 7df9c44d3b..cdb737e9f6 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ExternDdeLinkNoOper.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ExternDdeLinkNoOper.h @@ -46,6 +46,7 @@ public: BiffStructurePtr clone(); virtual void load(CFRecord& record); + virtual void save(CFRecord& record); static const ElementType type = typeExternDdeLinkNoOper; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ExternDocName.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ExternDocName.cpp index 3d8b15c532..2dc0dca8dc 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ExternDocName.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ExternDocName.cpp @@ -51,6 +51,13 @@ void ExternDocName::load(CFRecord& record) nameDefinition.load(record); } +void ExternDocName::save(CFRecord& record) +{ + record << ixals; + record.reserveNunBytes(2); + record << extName; + nameDefinition.save(record); +} } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ExternDocName.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ExternDocName.h index 02dd5c4b39..f0c69b6fbc 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ExternDocName.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ExternDocName.h @@ -48,8 +48,9 @@ public: static const ElementType type = typeExternDocName; virtual void load(CFRecord& record); + virtual void save(CFRecord& record); - unsigned short ixals; + unsigned short ixals = 0; ShortXLUnicodeString extName; ExtNameParsedFormula nameDefinition; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ExternOleDdeLink.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ExternOleDdeLink.cpp index b5a6c08f9a..89ce705f0f 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ExternOleDdeLink.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ExternOleDdeLink.cpp @@ -50,6 +50,11 @@ void ExternOleDdeLink::load(CFRecord& record) } } +void ExternOleDdeLink::save(CFRecord& record) +{ + record << lStgName << linkName; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ExternOleDdeLink.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ExternOleDdeLink.h index 0818e5617b..8d2790a7c8 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ExternOleDdeLink.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ExternOleDdeLink.h @@ -47,10 +47,11 @@ public: BiffStructurePtr clone(); virtual void load(CFRecord& record); + virtual void save(CFRecord& record); static const ElementType type = typeExternOleDdeLink; - _UINT32 lStgName; + _UINT32 lStgName = 0; ShortXLUnicodeString linkName; MOper moper; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/FactoidType.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/FactoidType.cpp index e66ef2b01d..784b2ce9de 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/FactoidType.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/FactoidType.cpp @@ -48,6 +48,18 @@ void FactoidType::load(XLS::CFRecord& record) record >> cbFactoid >> id >> rgbUri >> rgbTag >> rgbDownLoadURL; } +void FactoidType::save(XLS::CFRecord& record) +{ + _UINT32 cbFactoid = 0; + auto structStartPos = record.getRdPtr(); + record << cbFactoid << id << rgbUri << rgbTag << rgbDownLoadURL; + cbFactoid = record.getRdPtr() - structStartPos; + record.RollRdPtrBack(cbFactoid); + cbFactoid -= 4; + record << cbFactoid; + record.skipNunBytes(cbFactoid); +} + } // namespace OSHARED diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/FactoidType.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/FactoidType.h index 6d83a5c0bf..cb126b8f1c 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/FactoidType.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/FactoidType.h @@ -49,9 +49,10 @@ public: static const XLS::ElementType type = XLS::typeFactoidType; virtual void load(XLS::CFRecord& record); + virtual void save(XLS::CFRecord& record); - _UINT32 id; + _UINT32 id = 0; PBString rgbUri; PBString rgbTag; PBString rgbDownLoadURL; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/FileMoniker.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/FileMoniker.cpp index 2a1a656833..ea598e212b 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/FileMoniker.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/FileMoniker.cpp @@ -73,6 +73,26 @@ void FileMoniker::load(XLS::CFRecord& record) } } +void FileMoniker::save(XLS::CFRecord& record) +{ + _UINT32 ansiLength = ansiPath.size(); + record << cAnti << ansiLength << ansiPath << endServer << versionNumber; + record.reserveNunBytes(20); + if(!unicodePath.empty()) + { + cbUnicodePathSize = (unicodePath.size() * 2) + 6; + _UINT32 cbUnicodePathBytes = (unicodePath.size() * 2); + record << cbUnicodePathSize << cbUnicodePathBytes << usKeyValue; + for(auto i : unicodePath) + record << i; + + } + else + record.reserveNunBytes(4); + + + +} } // namespace OSHARED diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/FileMoniker.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/FileMoniker.h index c0809ce826..2f4731b671 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/FileMoniker.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/FileMoniker.h @@ -49,15 +49,16 @@ public: static const XLS::ElementType type = XLS::typeFileMoniker; virtual void load(XLS::CFRecord& record); + virtual void save(XLS::CFRecord& record); - _UINT16 cAnti; - std::string ansiPath; - _UINT16 endServer; - _UINT16 versionNumber; - _UINT32 cbUnicodePathSize; - _UINT16 usKeyValue; - std::wstring unicodePath; + _UINT16 cAnti = 0; + std::string ansiPath = ""; + _UINT16 endServer = 0; + _UINT16 versionNumber = 0; + _UINT32 cbUnicodePathSize = 0; + _UINT16 usKeyValue = 3; + std::wstring unicodePath = L""; }; } // namespace OSHARED diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/FileOffset.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/FileOffset.cpp index ea61a49ff8..944c7adb03 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/FileOffset.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/FileOffset.cpp @@ -47,6 +47,11 @@ void FileOffset::load(CFRecord& record) record >> offset; } +void FileOffset::save(CFRecord& record) +{ + record << offset; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/FileOffset.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/FileOffset.h index 01f572a3e9..62b749d210 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/FileOffset.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/FileOffset.h @@ -47,9 +47,10 @@ public: static const ElementType type = typeFileOffset; virtual void load(CFRecord& record); + virtual void save(CFRecord& record); - unsigned short offset; + unsigned short offset = 0; }; typedef boost::shared_ptr FileOffsetPtr; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/FilePointer.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/FilePointer.cpp index 1467f4386f..d50ecb14cc 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/FilePointer.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/FilePointer.cpp @@ -57,6 +57,10 @@ void FilePointer::load(CFRecord& record) record >> offset; } +void FilePointer::save(CFRecord& record) +{ + record << offset; +} } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/FilePointer.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/FilePointer.h index 712f507755..c72f72f860 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/FilePointer.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/FilePointer.h @@ -50,9 +50,10 @@ public: static const ElementType type = typeFilePointer; virtual void load(CFRecord& record); + virtual void save(CFRecord& record); - _UINT32 offset; + _UINT32 offset = 0; }; typedef boost::shared_ptr FilePointerPtr; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/FixedPoint.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/FixedPoint.cpp index 9078ee7472..6d44551e9d 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/FixedPoint.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/FixedPoint.cpp @@ -72,6 +72,17 @@ void FixedPoint::load(IBinaryReader* reader) dVal = Integral + Fractional/65536.; } +void FixedPoint::save(XLS::CFRecord& record) +{ + if(Fractional== 0 && Integral == 0 && dVal != 0) + { + Integral = dVal; + double tempValue = dVal - Integral; + Fractional = tempValue * 65536.; + + } + record << Integral << Fractional; +} } // namespace OSHARED diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/FixedPoint.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/FixedPoint.h index 872275a85c..3017b9ece5 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/FixedPoint.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/FixedPoint.h @@ -51,12 +51,13 @@ public: XLS::BiffStructurePtr clone(); virtual void load(XLS::CFRecord& record); + virtual void save(XLS::CFRecord& record); virtual void load(IBinaryReader* reader); - short Integral; - unsigned short Fractional; + short Integral = 0; + unsigned short Fractional = 0; - double dVal; + double dVal = 0; }; } // namespace OSHARED diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/FormatRun.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/FormatRun.cpp index 18b6faa64f..cca9815d62 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/FormatRun.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/FormatRun.cpp @@ -46,5 +46,9 @@ void FormatRun::load(CFRecord& record) record >> ich >> ifnt; } +void FormatRun::save(CFRecord& record) +{ + record << ich << ifnt; +} } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/FormatRun.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/FormatRun.h index 51b0a906ee..0c94a5a16d 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/FormatRun.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/FormatRun.h @@ -48,10 +48,11 @@ public: static const ElementType type = typeFormatRun; virtual void load(CFRecord& record); + virtual void save(CFRecord& record); - unsigned short ich; - FontIndex ifnt; + unsigned short ich = 0; + FontIndex ifnt; }; typedef boost::shared_ptr FormatRunPtr; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/FormulaValue.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/FormulaValue.cpp index 1a31090779..f389392e2c 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/FormulaValue.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/FormulaValue.cpp @@ -82,6 +82,10 @@ void FormulaValue::load(CFRecord& record) record >> data.xnum; } +void FormulaValue::save(CFRecord& record) +{ + record << data.xnum; +} unsigned char FormulaValue::getType() { diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/FormulaValue.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/FormulaValue.h index 8696f2c2db..0534ce9ccc 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/FormulaValue.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/FormulaValue.h @@ -45,6 +45,7 @@ public: BiffStructurePtr clone(); virtual void load(CFRecord& record); + virtual void save(CFRecord& record); static const ElementType type = typeFormulaValue; @@ -63,7 +64,7 @@ public: unsigned char Byte6; unsigned short fExprO; }; - double xnum; + double xnum = 0; } data; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/FrtRefHeader.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/FrtRefHeader.cpp index 2a1d37b491..62033820f4 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/FrtRefHeader.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/FrtRefHeader.cpp @@ -48,6 +48,12 @@ void FrtRefHeader::load(CFRecord& record) record >> ref8; } +void FrtRefHeader::save(CFRecord& record) +{ + record << rt << grbitFrt; + record << ref8; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/FrtRefHeader.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/FrtRefHeader.h index 94cfd1dfa0..8b40fb8f17 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/FrtRefHeader.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/FrtRefHeader.h @@ -50,6 +50,7 @@ public: static const ElementType type = typeFrtRefHeader; virtual void load(CFRecord& record); + virtual void save(CFRecord& record); CFRecordType::TypeId rt; FrtFlags grbitFrt; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/FrtRefHeaderNoGrbit.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/FrtRefHeaderNoGrbit.cpp index 5d0179b99b..1fad5f6d63 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/FrtRefHeaderNoGrbit.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/FrtRefHeaderNoGrbit.cpp @@ -61,6 +61,11 @@ void FrtRefHeaderNoGrbit::load(CFRecord& record) record >> ref8; } +void FrtRefHeaderNoGrbit::save(CFRecord& record) +{ + record << rt; + record << ref8; +} } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/FrtRefHeaderNoGrbit.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/FrtRefHeaderNoGrbit.h index c4b76f9f3b..298472e379 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/FrtRefHeaderNoGrbit.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/FrtRefHeaderNoGrbit.h @@ -52,6 +52,7 @@ public: static const ElementType type = typeFrtRefHeaderNoGrbit; virtual void load(CFRecord& record); + virtual void save(CFRecord& record); CFRecordType::TypeId rt; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/FullColorExt.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/FullColorExt.cpp index 1dc16fc177..e1751047c6 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/FullColorExt.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/FullColorExt.cpp @@ -49,6 +49,12 @@ void FullColorExt::load(CFRecord& record) record.skipNunBytes(8); //unused } +void FullColorExt::save(CFRecord& record) +{ + record << xclrType << nTintShade << xclrValue; + record.reserveNunBytes(8); //unused +} + int FullColorExt::serialize(std::wostream & stream, const std::wstring &node_name) { if (xclrType > 3) return 0;//not set diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/FullColorExt.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/FullColorExt.h index d707b102fa..0bea974e66 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/FullColorExt.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/FullColorExt.h @@ -47,6 +47,8 @@ public: BiffStructurePtr clone(); virtual void load(CFRecord& record); + virtual void save(CFRecord& record); + int serialize(std::wostream & stream, const std::wstring &sNode); static const ElementType type = typeFullColorExt; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/GradStop.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/GradStop.cpp index f96a541d7f..fdca00e4fc 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/GradStop.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/GradStop.cpp @@ -48,5 +48,11 @@ void GradStop::load(CFRecord& record) record >> numPosition >> numTint; } +void GradStop::save(CFRecord& record) +{ + record << xclrType << xclrValue; + + record << numPosition << numTint; +} } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/GradStop.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/GradStop.h index 171da043a9..0c5f22509e 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/GradStop.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/GradStop.h @@ -46,13 +46,14 @@ public: BiffStructurePtr clone(); virtual void load(CFRecord& record); + virtual void save(CFRecord& record); static const ElementType type = typeGradStop; - _UINT16 xclrType; - _UINT32 xclrValue; + _UINT16 xclrType = 0; + _UINT32 xclrValue = 0; - Xnum numPosition; + Xnum numPosition; Xnum numTint; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/HorzBrk.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/HorzBrk.cpp index 895cac9184..0501c747d0 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/HorzBrk.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/HorzBrk.cpp @@ -44,6 +44,10 @@ namespace XLS { record >> row >> colStart >> colEnd; } + void HorzBrk::save(CFRecord& record) + { + record << row << colStart << colEnd; + } int HorzBrk::serialize(std::wostream & stream) { CP_XML_WRITER(stream) diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/HorzBrk.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/HorzBrk.h index 53e92e8888..2344b9bd81 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/HorzBrk.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/HorzBrk.h @@ -45,11 +45,12 @@ public: static const ElementType type = typeHorzBrk; virtual void load(CFRecord& record); + virtual void save(CFRecord& record); virtual int serialize(std::wostream & stream); - RwU row; - unsigned short colStart; - unsigned short colEnd; + RwU row = 0; + unsigned short colStart = 0; + unsigned short colEnd = 0; }; typedef boost::shared_ptr HorzBrkPtr; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/HyperlinkMoniker.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/HyperlinkMoniker.cpp index b79bd5e5f0..c9ffe63555 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/HyperlinkMoniker.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/HyperlinkMoniker.cpp @@ -131,6 +131,16 @@ void HyperlinkMoniker::load(XLS::CFRecord& record) } } +void HyperlinkMoniker::save(XLS::CFRecord& record) +{ + _GUID_ clsid(0, 0, 0, 0); + STR::bstr2guid(monikerClsid, clsid); + record << clsid; + if (data) + { + data->save(record); + } +} } // namespace OSHARED diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/HyperlinkMoniker.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/HyperlinkMoniker.h index cb57671f9f..08b16c420d 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/HyperlinkMoniker.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/HyperlinkMoniker.h @@ -45,6 +45,7 @@ public: XLS::BiffStructurePtr clone(); virtual void load(XLS::CFRecord& record); + virtual void save(XLS::CFRecord& record); virtual void load(IBinaryReader* reader); static const XLS::ElementType type = XLS::typeHyperlinkMoniker; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/HyperlinkObject.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/HyperlinkObject.cpp index 4c9312f715..9fed5ce6af 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/HyperlinkObject.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/HyperlinkObject.cpp @@ -89,6 +89,55 @@ void HyperlinkObject::load(XLS::CFRecord& record) } } +void HyperlinkObject::save(XLS::CFRecord& record) +{ + record << streamVersion; + { + _UINT32 flags = 0; + SETBIT(flags, 0, hlstmfHasMoniker); + SETBIT(flags, 1, hlstmfIsAbsolute); + SETBIT(flags, 2, hlstmfIsAbsolute); + SETBIT(flags, 3, hlstmfHasLocationStr); + SETBIT(flags, 4, hlstmfHasDisplayName); + SETBIT(flags, 5, hlstmfHasGUID); + SETBIT(flags, 6, hlstmfHasCreationTime); + SETBIT(flags, 7, hlstmfHasFrameName); + SETBIT(flags, 8, hlstmfMonikerSavedAsStr); + SETBIT(flags, 9, hlstmfAbsFromGetdataRel); + record << flags; + } + if(hlstmfHasDisplayName) + { + saveHyperlinkString(record, displayName); + } + if(hlstmfHasFrameName) + { + saveHyperlinkString(record, targetFrameName); + } + if(hlstmfHasMoniker && hlstmfMonikerSavedAsStr) + { + saveHyperlinkString(record, moniker); + } + if(hlstmfHasMoniker && !hlstmfMonikerSavedAsStr) + { + record << oleMoniker; + } + if(hlstmfHasLocationStr) + { + saveHyperlinkString(record, location); + } + if(hlstmfHasGUID) + { + _GUID_ guid_num; + STR::bstr2guid(guid, guid_num); + record << guid_num; + } + if(hlstmfHasCreationTime) + { + record.storeAnyData(fileTime); + } +} + std::wstring HyperlinkObject::loadHyperlinkString(XLS::CFRecord& record) { std::wstring result; @@ -111,6 +160,16 @@ std::wstring HyperlinkObject::loadHyperlinkString(XLS::CFRecord& record) return result; } +void HyperlinkObject::saveHyperlinkString(XLS::CFRecord& record, std::wstring hlinkString) +{ + _INT32 size = hlinkString.size(); + record << size; + for(auto i : hlinkString) + { + record << i; + } +} + std::wstring HyperlinkObject::loadHyperlinkString(IBinaryReader* reader) { std::wstring result; @@ -188,6 +247,5 @@ void HyperlinkObject::load(IBinaryReader* reader) } } - } // namespace OSHARED diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/HyperlinkObject.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/HyperlinkObject.h index 53a1a81ea3..c380e23a51 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/HyperlinkObject.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/HyperlinkObject.h @@ -55,25 +55,27 @@ public: XLS::BiffStructurePtr clone(); virtual void load(XLS::CFRecord& record); + virtual void save(XLS::CFRecord& record); void load(IBinaryReader* reader); std::wstring loadHyperlinkString(XLS::CFRecord& record); + void saveHyperlinkString(XLS::CFRecord& record, std::wstring hlinkString); std::wstring loadHyperlinkString(IBinaryReader* reader); - _UINT32 streamVersion; + _UINT32 streamVersion = 2; static const XLS::ElementType type = XLS::typeHyperlinkObject; - bool hlstmfHasMoniker; - bool hlstmfIsAbsolute; - bool hlstmfSiteGaveDisplayName; - bool hlstmfHasLocationStr; - bool hlstmfHasDisplayName; - bool hlstmfHasGUID; - bool hlstmfHasCreationTime; - bool hlstmfHasFrameName; - bool hlstmfMonikerSavedAsStr; - bool hlstmfAbsFromGetdataRel; + bool hlstmfHasMoniker = 0; + bool hlstmfIsAbsolute = 0; + bool hlstmfSiteGaveDisplayName = 0; + bool hlstmfHasLocationStr = 0; + bool hlstmfHasDisplayName = 0; + bool hlstmfHasGUID = 0; + bool hlstmfHasCreationTime = 0; + bool hlstmfHasFrameName = 0; + bool hlstmfMonikerSavedAsStr = 0; + bool hlstmfAbsFromGetdataRel = 0; std::wstring displayName; std::wstring targetFrameName; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ISSTInf.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ISSTInf.cpp index 15c70b8b0d..a2a55b930b 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ISSTInf.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ISSTInf.cpp @@ -48,6 +48,12 @@ void ISSTInf::load(CFRecord& record) record.skipNunBytes(2); // reserved } +void ISSTInf::save(CFRecord& record) +{ + record << ib << cbOffset; + record.reserveNunBytes(2); +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ISSTInf.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ISSTInf.h index 38a5b6c3be..fe74ebff50 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ISSTInf.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ISSTInf.h @@ -47,10 +47,11 @@ public: static const ElementType type = typeISSTInf; virtual void load(CFRecord& record); + virtual void save(CFRecord& record); - _UINT32 ib; - _UINT16 cbOffset; + _UINT32 ib = 0; + _UINT16 cbOffset = 0; }; typedef boost::shared_ptr ISSTInfPtr; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ItemMoniker.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ItemMoniker.cpp index 36cdf7c3c0..4250a28b28 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ItemMoniker.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ItemMoniker.cpp @@ -86,6 +86,30 @@ void ItemMoniker::load(XLS::CFRecord& record) } +void ItemMoniker::save(XLS::CFRecord& record) +{ + if(delimiterAnsi.empty() || delimiterAnsi.at(delimiterAnsi.size()-1) != '\0') + { + delimiterAnsi += '\0'; + } + _UINT32 length = delimiterAnsi.size() + (delimiterUnicode.size() * 2); + record << length; + for(auto i : delimiterAnsi) + record << i; + for(auto i : delimiterUnicode) + record << i; + + if(itemAnsi.empty() || itemAnsi.at(itemAnsi.size()-1) != '\0') + { + itemAnsi += '\0'; + } + length = itemAnsi.size() + (itemUnicode.size() * 2); + record << length; + for(auto i : itemAnsi) + record << i; + for(auto i : itemUnicode) + record << i; +} } // namespace OSHARED diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ItemMoniker.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ItemMoniker.h index 7779da432f..89d3ccdfa4 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ItemMoniker.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ItemMoniker.h @@ -49,6 +49,7 @@ public: static const XLS::ElementType type = XLS::typeItemMoniker; virtual void load(XLS::CFRecord& record); + virtual void save(XLS::CFRecord& record); std::string delimiterAnsi; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/LongRGB.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/LongRGB.h index 88328957e0..8740b05624 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/LongRGB.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/LongRGB.h @@ -51,10 +51,10 @@ public: void load(CFRecord& record) override; void save(CFRecord& record) override; - unsigned char red; - unsigned char green; - unsigned char blue; - unsigned char alpha; + unsigned char red = 0; + unsigned char green = 0; + unsigned char blue = 0; + unsigned char alpha = 0; std::wstring strARGB; std::wstring strRGB; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/MDXStrIndex.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/MDXStrIndex.cpp index 7ef948b337..60f723f9cd 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/MDXStrIndex.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/MDXStrIndex.cpp @@ -46,6 +46,10 @@ void MDXStrIndex::load(CFRecord& record) record >> index; } +void MDXStrIndex::save(CFRecord& record) +{ + record << index; +} } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/MDXStrIndex.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/MDXStrIndex.h index 8df720402d..b5c2dbd1e3 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/MDXStrIndex.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/MDXStrIndex.h @@ -47,9 +47,9 @@ public: static const ElementType type = typeMDXStrIndex; virtual void load(CFRecord& record); + virtual void save(CFRecord& record); - - _UINT32 index; + _UINT32 index = 0; }; typedef boost::shared_ptr MDXStrIndexPtr; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/MDir.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/MDir.cpp index a2b003e029..819616edfa 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/MDir.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/MDir.cpp @@ -46,5 +46,12 @@ void MDir::load(CFRecord& record) record >> imdt >> mdd; } +void MDir::save(CFRecord& record) +{ + record << imdt; + _UINT32 mdd4b = mdd; + record << mdd4b; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/MDir.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/MDir.h index f713fd55d8..f7f494149c 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/MDir.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/MDir.h @@ -47,10 +47,10 @@ public: static const ElementType type = typeMDir; virtual void load(CFRecord& record); + virtual void save(CFRecord& record); - - _INT32 imdt; - _UINT16 mdd; + _INT32 imdt = 0; + _UINT16 mdd = 0; }; typedef boost::shared_ptr MDirPtr; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/MOper.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/MOper.cpp index 5a06a1d350..ce7aa48fc8 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/MOper.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/MOper.cpp @@ -63,6 +63,15 @@ void MOper::load(CFRecord& record) } } +void MOper::save(CFRecord& record) +{ + record << colLast << rowLast; + for (auto i : extOper) + { + record << i; + } +} + int MOper::serialize(std::wostream & strm) { if (extOper.empty()) return 0; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/MOper.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/MOper.h index 3608f09681..8ed38e147f 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/MOper.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/MOper.h @@ -49,10 +49,11 @@ public: static const ElementType type = typeMOper; virtual void load(CFRecord& record); + virtual void save(CFRecord& record); int serialize(std::wostream & strm); - ColunByteU colLast; - RwU rowLast; + ColunByteU colLast = 0; + RwU rowLast = 0; std::vector extOper; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/NoteSh.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/NoteSh.cpp index 58481e351e..039c36a8c3 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/NoteSh.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/NoteSh.cpp @@ -43,6 +43,7 @@ NoteSh::NoteSh() fShow = false; fRwHidden = false; fColHidden = false; + stAuthor = L" "; } NoteSh::NoteSh(CFRecord& record) @@ -84,6 +85,19 @@ void NoteSh::load(CFRecord& record) } } +void NoteSh::save(CFRecord& record) +{ + record << row << col; + + unsigned short flags = 0; + SETBIT(flags, 0, fShow) + SETBIT(flags, 7, fRwHidden) + SETBIT(flags, 8, fColHidden) + record << flags; + record << idObj << stAuthor; + record.reserveNunBytes(1); +} + //----------------------------------------------------------------------- void NoteSh::calculate() { diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/NoteSh.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/NoteSh.h index e3bf5a4684..6e9e988efa 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/NoteSh.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/NoteSh.h @@ -51,13 +51,14 @@ public: static const ElementType type = typeNoteSh; virtual void load(CFRecord& record); + virtual void save(CFRecord& record); - Rw row; - Col col; - bool fShow; - bool fRwHidden; - bool fColHidden; - ObjId idObj; + Rw row = 0; + Col col = 0; + bool fShow = false; + bool fRwHidden = false; + bool fColHidden = false; + ObjId idObj = 0; XLUnicodeString stAuthor; XLUnicodeString stText; @@ -66,9 +67,9 @@ public: void calculate(); - std::wstring ref_; - int x_; - int y_; + std::wstring ref_ = L""; + int x_ = 0; + int y_ = 0; }; } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/PBT.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/PBT.cpp index 57cdc31dc8..2b8b2a7abb 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/PBT.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/PBT.cpp @@ -49,6 +49,14 @@ void PBT::load(CFRecord& record) fNeedRefresh = GETBIT(flags, 4); } +void PBT::save(CFRecord& record) +{ + unsigned short flags = 0; + SETBITS(flags, 0, 2, pbt) + SETBIT(flags, 3, fAutoRefresh) + SETBIT(flags, 4, fNeedRefresh) + record << flags; +} } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/PBT.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/PBT.h index e9f0f6ada3..32b1ee158c 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/PBT.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/PBT.h @@ -48,10 +48,11 @@ public: static const ElementType type = typePBT; virtual void load(CFRecord& record); + virtual void save(CFRecord& record); - unsigned char pbt; - bool fAutoRefresh; - bool fNeedRefresh; + unsigned char pbt = 0; + bool fAutoRefresh = false; + bool fNeedRefresh = false; }; -} // namespace XLS \ No newline at end of file +} // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/PhRuns.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/PhRuns.cpp index a0fbf57ad0..ce5f2b0805 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/PhRuns.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/PhRuns.cpp @@ -47,6 +47,10 @@ void PhRuns::load(CFRecord& record) record >> ichFirst >> ichMom >> cchMom; } +void PhRuns::save(CFRecord& record) +{ + record << ichFirst << ichMom << cchMom; +} } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/PhRuns.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/PhRuns.h index d4d9ae57dd..99cf4149ff 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/PhRuns.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/PhRuns.h @@ -47,11 +47,11 @@ public: static const ElementType type = typePhRuns; virtual void load(CFRecord& record); + virtual void save(CFRecord& record); - - short ichFirst; - short ichMom; - short cchMom; + short ichFirst = 0; + short ichMom = 0; + short cchMom = 0; }; } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/Phs.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/Phs.cpp index 0b91d80169..0a483a81e1 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/Phs.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/Phs.cpp @@ -47,5 +47,11 @@ void Phs::load(CFRecord& record) record.loadAnyData(data); } +void Phs::save(CFRecord& record) +{ + record << ifnt; + record.storeAnyData(data); +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/Phs.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/Phs.h index c785059012..f15d03456e 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/Phs.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/Phs.h @@ -48,9 +48,10 @@ public: static const ElementType type = typePhs; virtual void load(CFRecord& record); + virtual void save(CFRecord& record); - unsigned short ifnt; + unsigned short ifnt = 0; struct Phs_Data { unsigned short phType : 2; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/PropertyBagStore.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/PropertyBagStore.cpp index a484776a1e..e775633bf3 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/PropertyBagStore.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/PropertyBagStore.cpp @@ -64,6 +64,20 @@ void PropertyBagStore::load(XLS::CFRecord& record) } } +void PropertyBagStore::save(XLS::CFRecord& record) +{ + _UINT32 cFactoidType = factoidTypes.size(); + record << cFactoidType; + for(auto i : factoidTypes) + record << i; + record << cbHdr << sVer; + record.reserveNunBytes(4); + _UINT32 cste = stringTable.size(); + record << cste; + for(auto i : stringTable) + record << i; +} + } // namespace OSHARED diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/PropertyBagStore.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/PropertyBagStore.h index 509c6343aa..93b873829c 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/PropertyBagStore.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/PropertyBagStore.h @@ -49,11 +49,12 @@ public: static const XLS::ElementType type = XLS::typePropertyBagStore; virtual void load(XLS::CFRecord& record); + virtual void save(XLS::CFRecord& record); std::vector factoidTypes; - unsigned short cbHdr; - unsigned short sVer; + unsigned short cbHdr = 0xC; + unsigned short sVer = 0x0100; std::vector stringTable; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/RPHSSub.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/RPHSSub.cpp index ff36958867..23c254272f 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/RPHSSub.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/RPHSSub.cpp @@ -52,6 +52,11 @@ void RPHSSub::load(CFRecord& record) record >> st; } +void RPHSSub::save(CFRecord& record) +{ + unsigned short cch = st.getSize(); + record << crun << cch << st; +} const size_t RPHSSub::getSize() const { diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/RPHSSub.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/RPHSSub.h index 3c88ea7488..f2f59bae8b 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/RPHSSub.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/RPHSSub.h @@ -47,15 +47,16 @@ public: static const ElementType type = typeRPHSSub; virtual void load(CFRecord& record); + virtual void save(CFRecord& record); const size_t getSize() const; const unsigned short getRunsNumber() const; - unsigned short crun; + unsigned short crun = 0; LPWideString st; - int sz; + int sz = 0; }; } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/RkRec.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/RkRec.cpp index d646996f70..08b30a5b72 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/RkRec.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/RkRec.cpp @@ -47,7 +47,10 @@ void RkRec::load(CFRecord& record) record >> ixfe >> RK_; } - +void RkRec::save(CFRecord& record) +{ + record << ixfe << RK_; +} const unsigned short RkRec::get_ixfe() const { diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/RkRec.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/RkRec.h index 0c65b89825..d661ce6497 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/RkRec.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/RkRec.h @@ -46,6 +46,7 @@ public: BiffStructurePtr clone(); virtual void load(CFRecord& record); + virtual void save(CFRecord& record); static const ElementType type = typeRkRec; @@ -53,7 +54,7 @@ public: const unsigned short get_ixfe() const; GlobalWorkbookInfoPtr global_info_; - unsigned short ixfe; + unsigned short ixfe = 0; RkNumber RK_; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/SerBool.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/SerBool.h index 2e158cbb03..c8ab10cdc7 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/SerBool.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/SerBool.h @@ -50,7 +50,7 @@ public: private: - unsigned char f; + unsigned char f = false; }; } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/SheetExtOptional.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/SheetExtOptional.cpp index 3597d862c5..c6c5504252 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/SheetExtOptional.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/SheetExtOptional.cpp @@ -71,6 +71,16 @@ void SheetExtOptional::load(CFRecord& record) record >> color; } +void SheetExtOptional::save(CFRecord& record) +{ + _UINT32 flags = 0; + SETBITS(flags, 0, 6, icvPlain12); + SETBIT(flags, 7, fCondFmtCalc) + SETBIT(flags, 8, fNotPublished) + record << flags; + record << color; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/SheetExtOptional.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/SheetExtOptional.h index 856337c70b..dac1671982 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/SheetExtOptional.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/SheetExtOptional.h @@ -50,15 +50,16 @@ public: static const ElementType type = typeSheetExtOptional; virtual void load(CFRecord& record); + virtual void save(CFRecord& record); - unsigned char icvPlain12; - bool fCondFmtCalc; - bool fNotPublished; + unsigned char icvPlain12 = 0; + bool fCondFmtCalc = false; + bool fNotPublished = false; CFColor color; //---------------------------------------- - bool bEnabled; + bool bEnabled = false; }; } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/SheetId.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/SheetId.cpp index 869b624ff5..8b91b57ead 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/SheetId.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/SheetId.cpp @@ -47,6 +47,10 @@ void SheetId::load(CFRecord& record) record >> id; } +void SheetId::save(CFRecord& record) +{ + record << id; +} } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/SheetId.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/SheetId.h index a3aa5f5a26..c91f7b8370 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/SheetId.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/SheetId.h @@ -47,9 +47,9 @@ public: static const ElementType type = typeSheetId; virtual void load(CFRecord& record); + virtual void save(CFRecord& record); - - unsigned short id; + unsigned short id = 1; }; typedef boost::shared_ptr SheetIdPtr; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/SortCond12.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/SortCond12.cpp index d22f0ae80b..aa3e706a5e 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/SortCond12.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/SortCond12.cpp @@ -72,6 +72,35 @@ void SortCond12::load(CFRecord& record) } } +void SortCond12::save(CFRecord& record) +{ + unsigned short flags = 0; + SETBIT(flags, 0, fSortDes) + SETBITS(flags, 1, 4, sortOn) + record << flags << rfx; + switch(sortOn) + { + case 0x00: + case 0x01: + case 0x02: + record << condDataValue; + break; + case 0x03: + record << cfflag; + break; + } + if(cchSt) + { + stSslist.setSize(cchSt); + record >> stSslist; + } + cchSt = stSslist.getSize(); + record << cchSt; + if(cchSt) + { + record << stSslist; + } +} } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/SortCond12.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/SortCond12.h index 329fe4cf54..3e803932e7 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/SortCond12.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/SortCond12.h @@ -50,16 +50,17 @@ public: static const ElementType type = typeSortCond12; virtual void load(CFRecord& record); + virtual void save(CFRecord& record); - bool fSortDes; - unsigned short sortOn; + bool fSortDes = false; + unsigned short sortOn = 0; RFX rfx; CondDataValue condDataValue; CFFlag cfflag; - _INT32 cchSt; + _INT32 cchSt = 0; XLUnicodeStringNoCch stSslist; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/SqRefU.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/SqRefU.cpp index 98720c804e..c5c9d61a9d 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/SqRefU.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/SqRefU.cpp @@ -32,6 +32,7 @@ #include "SqRefU.h" #include "CellRangeRef.h" +#include namespace XLS { @@ -55,6 +56,22 @@ void SqRefU::load(CFRecord& record) strValue += std::wstring (ref8.toString(false).c_str()) + ((i == cref - 1) ? L"" : L" "); } } +void SqRefU::save(CFRecord& record) +{ + std::vector results; + + boost::algorithm::split(results, strValue, boost::is_any_of(L" ")); + unsigned short crfx = results.size(); + + record << crfx; + + for (auto& item : results) + { + Ref8U rfx(item); + record << rfx; + } +} + struct refs_sort { inline bool operator() (const CellRangeRef& ref1, const CellRangeRef& ref2) diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/SqRefU.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/SqRefU.h index dc7bd005af..793a988a62 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/SqRefU.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/SqRefU.h @@ -48,6 +48,7 @@ public: static const ElementType type = typeSqRefU; virtual void load(CFRecord& record); + virtual void save(CFRecord& record); const CellRef getLocationFirstCell() const; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/Stxp.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/Stxp.cpp index 5141227205..c658dd0171 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/Stxp.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/Stxp.cpp @@ -48,6 +48,11 @@ void Stxp::load(CFRecord& record) record.skipNunBytes(1); // unused } +void Stxp::save(CFRecord& record) +{ + record << twpHeight << ts << bls << sss << uls << bFamily << bCharSet; + record.reserveNunBytes(1); // unused +} } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/Stxp.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/Stxp.h index 230b81b0b4..abbc3aea54 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/Stxp.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/Stxp.h @@ -48,6 +48,8 @@ public: static const ElementType type = typeStxp; virtual void load(CFRecord& record); + virtual void save(CFRecord& record); + int twpHeight = 0; Ts ts; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/SxAxis.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/SxAxis.h index 2c0e682039..4c256c6b6b 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/SxAxis.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/SxAxis.h @@ -50,10 +50,10 @@ public: static const ElementType type = typeSXAxis; - bool bRw; - bool bCol; - bool bPage; - bool bData; + bool bRw = false; + bool bCol = false; + bool bPage = false; + bool bData = false; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/TxtWf.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/TxtWf.cpp index 40048ee432..5fe582719c 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/TxtWf.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/TxtWf.cpp @@ -44,6 +44,11 @@ void TxtWf::load(CFRecord& record) record >> fieldType >> fieldStart; } +void TxtWf::save(CFRecord& record) +{ + record << fieldType << fieldStart; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/TxtWf.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/TxtWf.h index 8936265935..291fc3ed66 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/TxtWf.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/TxtWf.h @@ -48,9 +48,10 @@ public: static const ElementType type = typeTxtWf; virtual void load(CFRecord& record); + virtual void save(CFRecord& record); - _UINT32 fieldType; - _UINT32 fieldStart; + _UINT32 fieldType = 0; + _UINT32 fieldStart = 0; }; -} // namespace XLS \ No newline at end of file +} // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/URLMoniker.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/URLMoniker.cpp index edf93b94fd..7e2d4dcaf7 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/URLMoniker.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/URLMoniker.cpp @@ -74,6 +74,19 @@ void URLMoniker::load(XLS::CFRecord& record) } } +void URLMoniker::save(XLS::CFRecord& record) +{ + if(!url.empty() && url.at(url.size()-1) != L'\0') + { + url+= L'\0'; + } + _UINT32 length = url.size() * 2; + record << length; + for(auto i : url) + { + record << i; + } +} } // namespace OSHARED diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/URLMoniker.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/URLMoniker.h index 26808c088a..480b252600 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/URLMoniker.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/URLMoniker.h @@ -48,6 +48,7 @@ public: XLS::BiffStructurePtr clone(); virtual void load(XLS::CFRecord& record); + virtual void save(XLS::CFRecord& record); static const XLS::ElementType type = XLS::typeURLMoniker; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/VertBrk.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/VertBrk.cpp index d963711c32..d4e9579552 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/VertBrk.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/VertBrk.cpp @@ -43,6 +43,10 @@ namespace XLS { record >> col >> rowStart >> rowEnd; } + void VertBrk::save(CFRecord& record) + { + record << col << rowStart << rowEnd; + } int VertBrk::serialize(std::wostream & stream) { CP_XML_WRITER(stream) diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/VertBrk.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/VertBrk.h index 19217c5614..64481a34c5 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/VertBrk.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/VertBrk.h @@ -44,11 +44,13 @@ namespace XLS static const ElementType type = typeVertBrk; virtual void load(CFRecord& record); + virtual void save(CFRecord& record); + virtual int serialize(std::wostream & stream); - ColU col; - RwU rowStart; - RwU rowEnd; + ColU col = 0; + RwU rowStart = 0; + RwU rowEnd = 0; }; typedef boost::shared_ptr VertBrkPtr; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/XFExtGradient.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/XFExtGradient.cpp index 2553e92342..66e19c4988 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/XFExtGradient.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/XFExtGradient.cpp @@ -55,6 +55,14 @@ void XFExtGradient::load(CFRecord& record) } } +void XFExtGradient::save(CFRecord& record) +{ + cGradStops = rgGradStops.size(); + record << gradient << cGradStops; + for(auto i : rgGradStops) + record << i; +} + int XFExtGradient::serialize(std::wostream & stream) { CP_XML_WRITER(stream) diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/XFExtGradient.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/XFExtGradient.h index 23482a781e..bde849f81a 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/XFExtGradient.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/XFExtGradient.h @@ -47,6 +47,7 @@ public: BiffStructurePtr clone(); virtual void load(CFRecord& record); + virtual void save(CFRecord& record); int serialize(std::wostream & stream); diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/XFExtNoFRT.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/XFExtNoFRT.cpp index 8368b2045a..63b2a28a2c 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/XFExtNoFRT.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/XFExtNoFRT.cpp @@ -72,5 +72,17 @@ void XFExtNoFRT::load(CFRecord& record) } } +void XFExtNoFRT::save(CFRecord& record) +{ + record.reserveNunBytes(2); + unsigned short reserved2 = 0xFFFF; + record << reserved2; + record.reserveNunBytes(2); + unsigned short cexts = mapRgExt.size(); + record << cexts; + for(auto i:mapRgExt) + record << i.second; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/XFExtNoFRT.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/XFExtNoFRT.h index dd54ae1cde..375fa33d5a 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/XFExtNoFRT.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/XFExtNoFRT.h @@ -50,6 +50,7 @@ public: static const ElementType type = typeXFExtNoFRT; virtual void load(CFRecord& record); + virtual void save(CFRecord& record); std::map mapRgExt; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/XFPropGradient.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/XFPropGradient.h index 3602f29240..1fba52daa2 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/XFPropGradient.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/XFPropGradient.h @@ -60,13 +60,13 @@ public: void serialize_attr(CP_ATTR_NODE); int deserialize(XmlUtils::CXmlLiteReader& oReader); - bool type1; + bool type1 = 0; - double numDegree; - double numFillToLeft; - double numFillToRight; - double numFillToTop; - double numFillToBottom; + double numDegree = 0; + double numFillToLeft = 0; + double numFillToRight = 0; + double numFillToTop = 0; + double numFillToBottom = 0; }; } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/XLUnicodeRichExtendedString.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/XLUnicodeRichExtendedString.cpp index 8d0d99079a..c996767287 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/XLUnicodeRichExtendedString.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/XLUnicodeRichExtendedString.cpp @@ -258,6 +258,46 @@ void XLUnicodeRichExtendedString::load(CFRecord& record) } } +void XLUnicodeRichExtendedString::save(CFRecord& record) +{ + if(!rgRun.empty()) + fRichSt = true; + unsigned short cch = str_.size(); + unsigned char flags = 0; + SETBIT(flags, 0, fHighByte) + SETBIT(flags, 2, fExtSt) + SETBIT(flags, 3, fRichSt) + record << cch << flags; + if(fRichSt) + { + unsigned short cRun = rgRun.size(); + record << cRun; + } + auto cbExtPos = record.getRdPtr(); + if(fExtSt) + { + record.reserveNunBytes(4); + } + for(auto i: str_) + record << i; + if(fRichSt) + { + for(auto i : rgRun) + record << i; + } + if(fExtSt) + { + auto rstBegin = record.getRdPtr(); + record << extRst; + auto rstend = record.getRdPtr(); + record.RollRdPtrBack(rstend - cbExtPos); + int cbExtRst = rstBegin - rstend; + record << cbExtRst; + record.skipNunBytes(rstend - record.getRdPtr()); + } + +} + void XLUnicodeRichExtendedString::loadSymbols(CFRecord& record, const size_t cch, const bool is_wide) { size_t raw_length = cch << (is_wide ? 1 : 0); diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/XLUnicodeRichExtendedString.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/XLUnicodeRichExtendedString.h index b4cb04a657..71aef2e2eb 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/XLUnicodeRichExtendedString.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/XLUnicodeRichExtendedString.h @@ -59,6 +59,7 @@ public: void set_code_page(short cp) ; virtual void load (CFRecord& record); + virtual void save (CFRecord& record); GlobalWorkbookInfoPtr pGlobalWorkbookInfoPtr; @@ -71,17 +72,17 @@ public: std::wstring str_; - bool fHighByte; - bool fExtSt; - bool fRichSt; + bool fHighByte = true; + bool fExtSt = false; + bool fRichSt = false; std::vector rgRun; ExtRst extRst; std::list& cont_recs_; - bool mark_set_start; + bool mark_set_start = false; - unsigned short code_page_ ; + unsigned short code_page_ = 0 ; }; typedef boost::shared_ptr XLUnicodeRichExtendedStringPtr; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/AI.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/AI.cpp index 416e4ed352..49508fc1f2 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/AI.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/AI.cpp @@ -74,6 +74,16 @@ const bool AI::loadContent(BinProcessor& proc) return true; } +const bool AI::saveContent(BinProcessor& proc) +{ + if(m_BRAI == nullptr) + return false; + proc.mandatory(*m_BRAI); + if(m_SeriesText != nullptr) + proc.mandatory(*m_SeriesText); + return true; +} + bool AI::empty() { if (!m_SeriesText && !m_BRAI) return true; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/AI.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/AI.h index 55257439ce..75547c2614 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/AI.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/AI.h @@ -45,6 +45,7 @@ public: BaseObjectPtr clone(); virtual const bool loadContent(BinProcessor& proc); + virtual const bool saveContent(BinProcessor& proc); int serialize(std::wostream & _stream); diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/ATTACHEDLABEL.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/ATTACHEDLABEL.h index 39d55a4a15..38e76a3b3c 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/ATTACHEDLABEL.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/ATTACHEDLABEL.h @@ -46,6 +46,7 @@ public: BaseObjectPtr clone(); virtual const bool loadContent (BinProcessor& proc); + virtual const bool saveContent (BinProcessor& proc); int serialize (std::wostream & _stream); int serialize (std::wostream & _stream, bool position); diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/ATTACHEDLABEL_bu.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/ATTACHEDLABEL_bu.cpp index da21e08f59..6b8014ff31 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/ATTACHEDLABEL_bu.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/ATTACHEDLABEL_bu.cpp @@ -158,6 +158,32 @@ const bool ATTACHEDLABEL::loadContent(BinProcessor& proc) return true; } +const bool ATTACHEDLABEL::saveContent(BinProcessor& proc) +{ + if(m_TextProperties == nullptr) + return false; + proc.mandatory(*m_TextProperties); + proc.mandatory(); + if(m_Pos != nullptr) + proc.mandatory(*m_Pos); + if(m_FontX != nullptr) + proc.mandatory(*m_FontX); + if(m_AlRuns != nullptr) + proc.mandatory(*m_AlRuns); + if(m_AI != nullptr) + proc.mandatory(*m_AI); + if(m_FRAME != nullptr) + proc.mandatory(*m_FRAME); + if(m_ObjectLink) + proc.mandatory(*m_ObjectLink); + if(m_DataLabExtContents != nullptr) + proc.mandatory(*m_DataLabExtContents); + if(m_CrtLayout12 != nullptr) + proc.mandatory(*m_CrtLayout12); + proc.mandatory(); + return true; +} + int ATTACHEDLABEL::serialize_txPr(std::wostream & _stream) { FontX *font = dynamic_cast(m_FontX.get()); diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/AUTOFILTER.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/AUTOFILTER.h index 3bb7257271..2c03447b46 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/AUTOFILTER.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/AUTOFILTER.h @@ -46,6 +46,7 @@ public: BaseObjectPtr clone(); virtual const bool loadContent(BinProcessor& proc); + virtual const bool saveContent(BinProcessor& proc); int serialize(std::wostream & stream); diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/AUTOFILTER_bu.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/AUTOFILTER_bu.cpp index 4ce1ae1aca..6187b8d9be 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/AUTOFILTER_bu.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/AUTOFILTER_bu.cpp @@ -132,6 +132,38 @@ const bool AUTOFILTER::loadContent(BinProcessor& proc) return true; } +const bool AUTOFILTER::saveContent(BinProcessor& proc) +{ + if(m_AutoFilterInfo == nullptr) + return false; + proc.mandatory(*m_AutoFilterInfo); + for(auto i : m_arFilters) + if(i!= nullptr) + { + proc.mandatory(*i); + if(i->get_type() == typeAutoFilter12) + { + auto castedPtr = static_cast(i.get()); + if(castedPtr->cCriteria > 0 && castedPtr->ft == 0) + { + for(auto j : castedPtr->arAF12Criteries) + { + ContinueFrt12 continueRecord; + CFRecord tempRecord(rt_ContinueFrt12, proc.getGlobalWorkbookInfo()); + j->save(tempRecord); + continueRecord.rgb.reserve(tempRecord.getRdPtr()); + memcpy(continueRecord.rgb.data(), tempRecord.getCurStaticData(), tempRecord.getRdPtr()); + proc.mandatory(continueRecord); + } + } + } + } + for(auto i : m_arSORTDATA12) + if(i != nullptr) + proc.mandatory(*i); + return true; +} + int AUTOFILTER::serialize(std::wostream & stream) { if (m_AutoFilterInfo == NULL) return 0; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/AXES.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/AXES.cpp index 2a9717249c..b0f02b57cc 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/AXES.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/AXES.cpp @@ -222,6 +222,22 @@ const bool AXES::loadContent(BinProcessor& proc) return res; } +const bool AXES::saveContent(BinProcessor& proc) +{ + for(auto i: m_arAxes) + if(i != nullptr) + proc.mandatory(*i); + for(auto i: m_arATTACHEDLABEL) + if(i!= nullptr) + proc.mandatory(*i); + if(m_PlotArea_FRAME != nullptr) + { + proc.mandatory(); + proc.mandatory(*m_PlotArea_FRAME); + } + return true; +} + int AXES::serialize(std::wostream & _stream) { return serialize(_stream, false); diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/AXES.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/AXES.h index 0e9797668a..cad68a58ab 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/AXES.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/AXES.h @@ -46,6 +46,7 @@ public: BaseObjectPtr clone(); virtual const bool loadContent(BinProcessor& proc); + virtual const bool saveContent(BinProcessor& proc); int serialize(std::wostream & _stream); int serialize(std::wostream & _stream, bool secondary); diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/AXISPARENT.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/AXISPARENT.h index 5b55a0f269..ed26834b98 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/AXISPARENT.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/AXISPARENT.h @@ -46,6 +46,7 @@ public: BaseObjectPtr clone(); virtual const bool loadContent(BinProcessor& proc); + virtual const bool saveContent(BinProcessor& proc); BaseObjectPtr m_AxisParent; BaseObjectPtr m_Pos; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/AXISPARENT_bu.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/AXISPARENT_bu.cpp index 458c33fac2..3e97d0ce0a 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/AXISPARENT_bu.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/AXISPARENT_bu.cpp @@ -99,6 +99,23 @@ const bool AXISPARENT::loadContent(BinProcessor& proc) return true; } +const bool AXISPARENT::saveContent(BinProcessor& proc) +{ + if(m_AxisParent == nullptr) + return false; + proc.mandatory(*m_AxisParent); + proc.mandatory(); + if(m_Pos != nullptr) + proc.mandatory(*m_Pos); + if(m_AXES != nullptr) + proc.mandatory(*m_AXES); + for(auto i: m_arCRT) + if(i!= nullptr) + proc.mandatory(*i); + proc.mandatory(); + return true; +} + void AXISPARENT::concatinate_second (BaseObjectPtr & addit) { AXISPARENT * second = dynamic_cast(addit.get()); diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/AXM.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/AXM.cpp index 788039ce01..0069e960de 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/AXM.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/AXM.cpp @@ -78,5 +78,17 @@ const bool AXM::loadContent(BinProcessor& proc) return true; } +const bool AXM::saveContent(BinProcessor& proc) +{ + if(m_YMult != nullptr) + return false; + proc.mandatory(*m_YMult); + proc.mandatory(); + if(m_ATTACHEDLABEL != nullptr) + proc.mandatory(*m_ATTACHEDLABEL); + proc.mandatory(); + return true; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/AXM.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/AXM.h index 153e78ec29..a33b3b0bd6 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/AXM.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/AXM.h @@ -48,6 +48,7 @@ public: BaseObjectPtr clone(); virtual const bool loadContent(BinProcessor& proc); + virtual const bool saveContent(BinProcessor& proc); BaseObjectPtr m_YMult; BaseObjectPtr m_ATTACHEDLABEL; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/AXS.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/AXS.cpp index 156a84fe43..cd7d2fb318 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/AXS.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/AXS.cpp @@ -153,6 +153,28 @@ const bool AXS::loadContent(BinProcessor& proc) return true; } +const bool AXS::saveContent(BinProcessor& proc) +{ + if(m_IFmtRecord != nullptr) + proc.mandatory(*m_IFmtRecord); + if(m_Tick != nullptr) + proc.mandatory(*m_Tick); + if(m_FontX != nullptr) + proc.mandatory(*m_FontX); + for(auto i : m_AxisLine_Format) + { + if(i.axisLine != nullptr) + proc.mandatory(*i.axisLine); + if(i.lineFormat != nullptr) + proc.mandatory(*i.lineFormat); + } + if(m_AreaFormat != nullptr) + proc.mandatory(*m_AreaFormat); + if(m_GELFRAME != nullptr) + proc.optional(*m_GELFRAME); + return true; +} + int AXS::serialize(std::wostream & _stream) { BaseObjectPtr axis_line_format; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/AXS.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/AXS.h index 1ca252d226..27338a39fa 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/AXS.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/AXS.h @@ -48,6 +48,7 @@ public: BaseObjectPtr clone(); virtual const bool loadContent(BinProcessor& proc); + virtual const bool saveContent(BinProcessor& proc); int serialize (std::wostream & _stream); int serialize_rPr (std::wostream & _stream, int iFmt, _CP_OPT(unsigned int) color, bool rtl, bool defRPr); diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/BACKGROUND.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/BACKGROUND.cpp index 30ff345ae3..b214109b50 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/BACKGROUND.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/BACKGROUND.cpp @@ -70,6 +70,43 @@ const bool BACKGROUND::loadContent(BinProcessor& proc) return true; } + +const bool BACKGROUND::saveContent(BinProcessor& proc) +{ + if(m_BkHim == nullptr) + return false; + proc.mandatory(*m_BkHim); + auto maxRecordSize = 8224; + auto castedPtr = static_cast(m_BkHim.get()); + if(castedPtr->lcb > maxRecordSize) + { + int remainedDataSize = castedPtr->lcb - maxRecordSize; + size_t curDataPtr = maxRecordSize; + while (remainedDataSize > 0) + { + Continue continueRecord; + if(remainedDataSize < maxRecordSize) + { + continueRecord.m_iDataSize = remainedDataSize; + continueRecord.m_pData = new char[remainedDataSize]; + memcpy(continueRecord.m_pData, (castedPtr->pData.get() + curDataPtr), remainedDataSize); + proc.mandatory(continueRecord); + break; + } + else + { + continueRecord.m_iDataSize = maxRecordSize; + continueRecord.m_pData = new char[continueRecord.m_iDataSize]; + memcpy(continueRecord.m_pData, (castedPtr->pData.get() + curDataPtr), remainedDataSize); + proc.mandatory(continueRecord); + remainedDataSize -= maxRecordSize; + curDataPtr += maxRecordSize; + } + } + } + return true; +} + int BACKGROUND::serialize(std::wostream & _stream) { return 0; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/BACKGROUND.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/BACKGROUND.h index a9a4bd1011..f9152bfff1 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/BACKGROUND.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/BACKGROUND.h @@ -48,6 +48,7 @@ public: BaseObjectPtr clone(); virtual const bool loadContent(BinProcessor& proc); + virtual const bool saveContent(BinProcessor& proc); int serialize (std::wostream & _stream); diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/BUNDLESHEET.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/BUNDLESHEET.cpp index 4eac07d2d4..bf56918b44 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/BUNDLESHEET.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/BUNDLESHEET.cpp @@ -63,5 +63,24 @@ const bool BUNDLESHEET::loadContent(BinProcessor& proc) return true; } +const bool BUNDLESHEET::saveContent(BinProcessor& proc) +{ + if( bundleSheetRecord == nullptr) + { + bundleSheetRecord = BaseObjectPtr(new BoundSheet8); + } + { + auto castedPtr = static_cast(bundleSheetRecord.get()); + auto globInfo = proc.getGlobalWorkbookInfo(); + GlobalWorkbookInfo::_sheet_info sheet_info; + sheet_info.state = castedPtr->hsState; + sheet_info.name = castedPtr->name_; + sheet_info.BoundSheetPos = proc.GetRecordPosition() + 4; // + size and type of record + globInfo->sheets_info.push_back(sheet_info); + } + proc.mandatory(*bundleSheetRecord); + return true; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/BUNDLESHEET.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/BUNDLESHEET.h index fc487bb1a7..67ee2960e3 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/BUNDLESHEET.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/BUNDLESHEET.h @@ -48,6 +48,9 @@ public: BaseObjectPtr clone(); virtual const bool loadContent(BinProcessor& proc); + virtual const bool saveContent(BinProcessor& proc); + + BaseObjectPtr bundleSheetRecord; // for xls writing }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/CELL.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/CELL.h index 6d9ebbf67a..5888c4f862 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/CELL.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/CELL.h @@ -48,6 +48,7 @@ public: BaseObjectPtr clone(); virtual const bool loadContent(BinProcessor& proc); + virtual const bool saveContent(BinProcessor& proc); int serialize(std::wostream & stream); @@ -56,6 +57,8 @@ public: int RowNumber; int ColumnNumber; + BaseObjectPtr cellContent; // for xls writing + std::vector& shared_formulas_locations_ref_; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/CELLTABLE.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/CELLTABLE.cpp index d13a880414..04f5180da8 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/CELLTABLE.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/CELLTABLE.cpp @@ -42,133 +42,122 @@ namespace XLS { -class CELL_GROUP : public CompositeObject + +const bool CELL_GROUP::loadContent(BinProcessor& proc) { - BASE_OBJECT_DEFINE_CLASS_NAME(CELL_GROUP) -public: - CELL_GROUP(std::vector& shared_formulas_locations_ref) : - shared_formulas_locations_ref_(shared_formulas_locations_ref) - { - } + global_info_ = proc.getGlobalWorkbookInfo(); + int index_sheet_info_ = global_info_->current_sheet - 1; - BaseObjectPtr clone() - { - return BaseObjectPtr(new CELL_GROUP(*this)); - } + GlobalWorkbookInfo::_sheet_info & sheet_info = global_info_->sheets_info[index_sheet_info_]; - const bool loadContent(BinProcessor& proc) - { - global_info_ = proc.getGlobalWorkbookInfo(); - int index_sheet_info_ = global_info_->current_sheet - 1; + int count, count_row = 0; - GlobalWorkbookInfo::_sheet_info & sheet_info = global_info_->sheets_info[index_sheet_info_]; - - int count, count_row = 0; - - bool bRow = false; + bool bRow = false; - bRow = (global_info_->Version == 0x0200) ? proc.mandatory() : proc.mandatory(); - - if (bRow == true) - { - count_row = count = 1 + ((global_info_->Version == 0x0200) ? proc.repeated(0, 0) : proc.repeated(0, 0)); - - while(count > 0) - { - Row* row = dynamic_cast(elements_.front().get()); - if (row) - { - if (row->miyRw > 0 && std::abs(row->miyRw/20. - sheet_info.defaultRowHeight) > 0.001) - { - sheet_info.customRowsHeight.insert(std::make_pair(row->rw, row->miyRw / 20.)); - } - } - std::map::iterator pFindRow = sheet_info.mapRows.find(row->rw); - if (pFindRow == sheet_info.mapRows.end()) - { - GlobalWorkbookInfo::_row_info row_info; + bRow = (global_info_->Version == 0x0200) ? proc.mandatory() : proc.mandatory(); - row_info.row_info = elements_.front(); - sheet_info.mapRows.insert(std::make_pair(row->rw, row_info)); - } - else - { - if (!pFindRow->second.row_info) - { - pFindRow->second.row_info = elements_.front(); - } - else - { - Row* row_find = dynamic_cast(pFindRow->second.row_info.get()); - if ((row_find) && (false == row_find->bValid) && row->bValid) - { - pFindRow->second.row_info = elements_.front(); - } + if (bRow == true) + { + count_row = count = 1 + ((global_info_->Version == 0x0200) ? proc.repeated(0, 0) : proc.repeated(0, 0)); - } - } + while(count > 0) + { + Row* row = dynamic_cast(elements_.front().get()); + if (row) + { + if (row->miyRw > 0 && std::abs(row->miyRw/20. - sheet_info.defaultRowHeight) > 0.001) + { + sheet_info.customRowsHeight.insert(std::make_pair(row->rw, row->miyRw / 20.)); + } + } + std::map::iterator pFindRow = sheet_info.mapRows.find(row->rw); + if (pFindRow == sheet_info.mapRows.end()) + { + GlobalWorkbookInfo::_row_info row_info; - elements_.pop_front(); - count--; - } - } - - //------------------------------------------------------------------------------------------------------------------ - CELL cell(shared_formulas_locations_ref_); + row_info.row_info = elements_.front(); + sheet_info.mapRows.insert(std::make_pair(row->rw, row_info)); + } + else + { + if (!pFindRow->second.row_info) + { + pFindRow->second.row_info = elements_.front(); + } + else + { + Row* row_find = dynamic_cast(pFindRow->second.row_info.get()); + if ((row_find) && (false == row_find->bValid) && row->bValid) + { + pFindRow->second.row_info = elements_.front(); + } - int count_cells = count = proc.repeated(cell, 0, 0); + } + } - while(count > 0) - { - CELL * cell = dynamic_cast(elements_.front().get()); - if (cell) - { - std::map::iterator pFindRow = sheet_info.mapRows.find(cell->RowNumber); - if (pFindRow == sheet_info.mapRows.end()) - { - GlobalWorkbookInfo::_row_info row_info; - sheet_info.mapRows.insert(std::make_pair(cell->RowNumber, row_info)); + elements_.pop_front(); + count--; + } + } - pFindRow = sheet_info.mapRows.find(cell->RowNumber); - } - std::map::iterator pFindCell = pFindRow->second.mapCells.find(cell->ColumnNumber); + //------------------------------------------------------------------------------------------------------------------ + CELL cell(shared_formulas_locations_ref_); - if (pFindCell != pFindRow->second.mapCells.end()) - { - CELL* cell_prev = dynamic_cast(pFindCell->second.get()); + int count_cells = count = proc.repeated(cell, 0, 0); - pFindCell->second = elements_.front(); - } - else - { - pFindRow->second.mapCells.insert(std::make_pair(cell->ColumnNumber, elements_.front())); - } - } - elements_.pop_front(); - count--; - } - count = proc.repeated(0, 0); - // OpenOffice Calc stored files workaround (DBCell must be present at least once according to [MS-XLS]) - while(count > 0) - { - m_DBCells.insert(m_DBCells.begin(), elements_.back()); - elements_.pop_back(); - count--; - } - if (count_cells > 0 || count_row > 0) return true; - else return false; - } - - static const ElementType type = typeCELL_GROUP; + while(count > 0) + { + CELL * cell = dynamic_cast(elements_.front().get()); + if (cell) + { + std::map::iterator pFindRow = sheet_info.mapRows.find(cell->RowNumber); + if (pFindRow == sheet_info.mapRows.end()) + { + GlobalWorkbookInfo::_row_info row_info; + sheet_info.mapRows.insert(std::make_pair(cell->RowNumber, row_info)); -//--------------------------------------------------------------------------- - std::list m_DBCells; + pFindRow = sheet_info.mapRows.find(cell->RowNumber); + } + std::map::iterator pFindCell = pFindRow->second.mapCells.find(cell->ColumnNumber); -private: - std::vector& shared_formulas_locations_ref_; + if (pFindCell != pFindRow->second.mapCells.end()) + { + CELL* cell_prev = dynamic_cast(pFindCell->second.get()); - GlobalWorkbookInfoPtr global_info_; -}; + pFindCell->second = elements_.front(); + } + else + { + pFindRow->second.mapCells.insert(std::make_pair(cell->ColumnNumber, elements_.front())); + } + } + elements_.pop_front(); + count--; + } + count = proc.repeated(0, 0); + // OpenOffice Calc stored files workaround (DBCell must be present at least once according to [MS-XLS]) + while(count > 0) + { + m_DBCells.insert(m_DBCells.begin(), elements_.back()); + elements_.pop_back(); + count--; + } + if (count_cells > 0 || count_row > 0) return true; + else return false; +} +const bool CELL_GROUP::saveContent(BinProcessor& proc) +{ + for(auto i: m_arRows) + if(i != nullptr) + proc.mandatory(*i); + for(auto i : m_arCells) + if(i != nullptr) + proc.mandatory(*i); + /*for(auto i : m_DBCells) + if(i != nullptr) + proc.mandatory(*i);*/ + return true; +} //----------------------------------------------------------------------------------------------------------------- CELLTABLE::CELLTABLE(std::vector& shared_formulas_locations_ref) : isConcatinate_(false), shared_formulas_locations_ref_(shared_formulas_locations_ref) @@ -222,6 +211,16 @@ const bool CELLTABLE::loadContent(BinProcessor& proc) } return true; } + +const bool CELLTABLE::saveContent(BinProcessor& proc) +{ + for(auto i: m_arCellGroups) + if(i != nullptr) + proc.mandatory(*i); + return true; +} + + int CELLTABLE::serialize(std::wostream & stream) { GlobalWorkbookInfo::_sheet_info & sheet_info = global_info_->sheets_info[index_sheet_info_]; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/CELLTABLE.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/CELLTABLE.h index 58383874e8..42fe591dfd 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/CELLTABLE.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/CELLTABLE.h @@ -48,6 +48,7 @@ public: BaseObjectPtr clone(); virtual const bool loadContent(BinProcessor& proc); + virtual const bool saveContent(BinProcessor& proc); static const ElementType type = typeCELLTABLE; @@ -57,10 +58,44 @@ public: std::vector m_arEntExU2; + std::vector m_arCellGroups; + GlobalWorkbookInfoPtr global_info_; int index_sheet_info_; bool isConcatinate_; }; +class CELL_GROUP : public CompositeObject +{ + BASE_OBJECT_DEFINE_CLASS_NAME(CELL_GROUP) +public: + CELL_GROUP(std::vector& shared_formulas_locations_ref) : + shared_formulas_locations_ref_(shared_formulas_locations_ref) + { + } + + BaseObjectPtr clone() + { + return BaseObjectPtr(new CELL_GROUP(*this)); + } + + const bool loadContent(BinProcessor& proc); + const bool saveContent(BinProcessor& proc); + + + static const ElementType type = typeCELL_GROUP; + +//--------------------------------------------------------------------------- + std::vector m_arRows;//for xls writing + std::vector m_arCells; + + std::list m_DBCells; + +private: + std::vector& shared_formulas_locations_ref_; + + GlobalWorkbookInfoPtr global_info_; +}; + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/CELL_bu.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/CELL_bu.cpp index d3ca2fc2e3..3fd4644aae 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/CELL_bu.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/CELL_bu.cpp @@ -151,6 +151,15 @@ const bool CELL::loadContent(BinProcessor& proc) return true; } +const bool CELL::saveContent(BinProcessor& proc) +{ + if(cellContent != nullptr) + proc.mandatory(*cellContent); + else + return false; + return true; +} + int CELL::serialize(std::wostream & stream) { CP_XML_WRITER(stream) diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/CHARTFOMATS.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/CHARTFOMATS.cpp index e8097d486b..751c9422c3 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/CHARTFOMATS.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/CHARTFOMATS.cpp @@ -287,6 +287,54 @@ const bool CHARTFORMATS::loadContent(BinProcessor& proc) return true; } + +const bool CHARTFORMATS::saveContent(BinProcessor& proc) +{ + if(m_ChartRect == nullptr) + return false; + proc.mandatory(*m_ChartRect); + proc.mandatory(); + if(m_Scl != nullptr) + proc.mandatory(*m_Scl); + else + proc.mandatory(); + if(m_PlotGrowth != nullptr) + proc.mandatory(*m_PlotGrowth); + else + proc.mandatory(); + if(m_FRAME != nullptr) + proc.mandatory(*m_FRAME); + for(auto i : m_arSERIESFORMAT) + if(i != nullptr) + proc.mandatory(*i); + for(auto i : m_arSS) + if(i != nullptr) + proc.mandatory(*i); + if(m_ShtProps != nullptr) + proc.mandatory(*m_ShtProps); + else + proc.mandatory(); + for(auto i : m_arDFTTEXT) + if(i != nullptr) + proc.mandatory(*i); + if(m_AxesUsed != nullptr) + proc.mandatory(*m_AxesUsed); + else + proc.mandatory(); + for(auto i : m_arAXISPARENT) + if(i != nullptr) + proc.mandatory(*i); + if(m_CrtLayout12A != nullptr) + proc.mandatory(*m_CrtLayout12A); + if(m_DAT != nullptr) + proc.mandatory(*m_DAT); + for(auto i : m_arATTACHEDLABEL) + if(i!= nullptr) + proc.mandatory(*i); + proc.mandatory(); + return true; +} + BaseObjectPtr CHARTFORMATS::find_label( _UINT16 link_id, unsigned short ex) { for (size_t i = 0 ; i < m_arATTACHEDLABEL.size(); i++) diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/CHARTFOMATS.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/CHARTFOMATS.h index 2fdcd1cc88..6b2ea9927b 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/CHARTFOMATS.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/CHARTFOMATS.h @@ -45,6 +45,7 @@ public: BaseObjectPtr clone(); virtual const bool loadContent(BinProcessor& proc); + virtual const bool saveContent(BinProcessor& proc); BaseObjectPtr m_ChartRect; std::vector m_arSERIESFORMAT; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/COLUMNS.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/COLUMNS.cpp index 744f0a0a6e..8400e5e813 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/COLUMNS.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/COLUMNS.cpp @@ -92,7 +92,25 @@ const bool COLUMNS::loadContent(BinProcessor& proc) return def_ok || (count > 0); } - +const bool COLUMNS::saveContent(BinProcessor& proc) +{ + if(m_DefColWidth != nullptr) + proc.mandatory(*m_DefColWidth); + else + proc.mandatory(); + /*if(global_info_ && global_info_->sheets_info.size() > global_info_->current_sheet) + { + for(auto i:global_info_->sheets_info[global_info_->current_sheet - 1].customColumnsWidth) + { + ColInfo column_info; + column_info.colFirst = i.first; + column_info.colLast = i.first; + column_info.coldx = i.second * 256; + proc.mandatory(column_info); + } + }*/ + return true; +} int COLUMNS::serialize(std::wostream & stream) { if (elements_.size() < 1) return 0; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/COLUMNS.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/COLUMNS.h index 4a3cbcd532..b64620d6f1 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/COLUMNS.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/COLUMNS.h @@ -46,6 +46,7 @@ public: BaseObjectPtr clone(); virtual const bool loadContent(BinProcessor& proc); + virtual const bool saveContent(BinProcessor& proc); int serialize(std::wostream & stream); diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/CONDFMT.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/CONDFMT.h index e20032a7c0..61907df5f2 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/CONDFMT.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/CONDFMT.h @@ -48,6 +48,7 @@ public: BaseObjectPtr clone(); virtual const bool loadContent(BinProcessor& proc); + virtual const bool saveContent(BinProcessor& proc); static const ElementType type = typeCONDFMT; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/CONDFMT12.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/CONDFMT12.h index 821095bdbb..e43095177a 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/CONDFMT12.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/CONDFMT12.h @@ -48,6 +48,7 @@ public: BaseObjectPtr clone(); virtual const bool loadContent(BinProcessor& proc); + virtual const bool saveContent(BinProcessor& proc); static const ElementType type = typeCONDFMT12; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/CONDFMT12_bu.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/CONDFMT12_bu.cpp index e6ee435357..50e83e9b5e 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/CONDFMT12_bu.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/CONDFMT12_bu.cpp @@ -96,6 +96,17 @@ const bool CONDFMT12::loadContent(BinProcessor& proc) return true; } + +const bool CONDFMT12::saveContent(BinProcessor& proc) +{ + if(m_CondFmt12 != nullptr) + proc.mandatory(*m_CondFmt12); + for(auto i : m_arCF12) + if(i != nullptr) + proc.mandatory(*i); + return true; +} + int CONDFMT12::serialize(std::wostream & stream) { if (!m_CondFmt12) return 0; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/CONDFMTS.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/CONDFMTS.cpp index d2c56ae512..339ab5026c 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/CONDFMTS.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/CONDFMTS.cpp @@ -199,6 +199,21 @@ const bool CONDFMTS::loadContent(BinProcessor& proc) return res; } +const bool CONDFMTS::saveContent(BinProcessor& proc) +{ + for(auto i : m_arCONDFMT) + if(i != nullptr) + proc.mandatory(*i); + for(auto i : m_arCFEx) + { + if(i.ex != nullptr) + proc.mandatory(*i.ex); + if(i.cf12 != nullptr) + proc.mandatory(*i.cf12); + } + return true; +} + int CONDFMTS::serialize(std::wostream & stream) { if (m_arCONDFMT.empty()) return 0; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/CONDFMTS.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/CONDFMTS.h index 649503e374..8da261b2a2 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/CONDFMTS.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/CONDFMTS.h @@ -46,6 +46,7 @@ public: BaseObjectPtr clone(); virtual const bool loadContent(BinProcessor& proc); + virtual const bool saveContent(BinProcessor& proc); static const ElementType type = typeCONDFMTS; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/CONDFMT_bu.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/CONDFMT_bu.cpp index 3c9dc33f70..1c5c66bd0a 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/CONDFMT_bu.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/CONDFMT_bu.cpp @@ -79,6 +79,16 @@ const bool CONDFMT::loadContent(BinProcessor& proc) return true; } + +const bool CONDFMT::saveContent(BinProcessor& proc) +{ + if(m_CondFmt != nullptr) + proc.mandatory(*m_CondFmt); + for(auto i : m_arCF) + if(i != nullptr) + proc.mandatory(*i); + return true; +} int CONDFMT::serialize(std::wostream & stream) { if (!m_CondFmt) return 0; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/CRT.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/CRT.cpp index 547bce018a..a5c06862ce 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/CRT.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/CRT.cpp @@ -305,6 +305,52 @@ const bool CRT::loadContent(BinProcessor& proc) return true; } +const bool CRT::saveContent(BinProcessor& proc) +{ + if(m_ChartFormat == nullptr) + return false; + proc.mandatory(*m_ChartFormat); + proc.mandatory(); + if(m_ChartType != nullptr) + { + proc.mandatory(*m_ChartType); + if("BopPop" == m_ChartType->getClassName()) + { + BopPop *bp = dynamic_cast(m_ChartType.get()); + if(bp->m_Custom != nullptr) + proc.mandatory(*(bp->m_Custom)); + } + } + proc.mandatory(); + if(m_SeriesList != nullptr) + proc.mandatory(*m_SeriesList); + if(m_Chart3d != nullptr) + proc.mandatory(*m_Chart3d); + if(m_LD != nullptr) + proc.mandatory(*m_LD); + if(m_DROPBAR[0] != nullptr) + proc.mandatory(*m_DROPBAR[0]); + if(m_DROPBAR[1] != nullptr) + proc.mandatory(*m_DROPBAR[1]); + for(auto i : m_arCrtLine) + { + if(i != nullptr) + proc.mandatory(*i); + auto castedPtr = static_cast(i.get()); + if(castedPtr->m_LineFormat != nullptr) + proc.mandatory(*(castedPtr->m_LineFormat)); + } + for(auto i : m_arDFTTEXT) + if(i != nullptr) + proc.mandatory(*i); + if(m_DataLabExtContents != nullptr) + proc.mandatory(*m_DataLabExtContents); + if(m_SS!= nullptr) + proc.mandatory(*m_SS); + proc.mandatory(); + return true; +} + std::wstring CRT::getOoxChartType() { switch(m_ChartType->get_type()) diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/CRT.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/CRT.h index 9112f885e7..aea6fb9f00 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/CRT.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/CRT.h @@ -46,6 +46,7 @@ public: BaseObjectPtr clone(); virtual const bool loadContent(BinProcessor& proc); + virtual const bool saveContent(BinProcessor& proc); static const ElementType type = typeCRT; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/CUSTOMVIEW.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/CUSTOMVIEW.cpp index 6b0b005e06..4aad36644b 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/CUSTOMVIEW.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/CUSTOMVIEW.cpp @@ -133,6 +133,24 @@ const bool CUSTOMVIEW::loadContent(BinProcessor& proc) return true; } +const bool CUSTOMVIEW::saveContent(BinProcessor& proc) +{ + if(m_UserSView == nullptr) + return false; + proc.mandatory(*m_UserSView); + for(auto i : m_arSelection) + if(i != nullptr) + proc.mandatory(*i); + if(m_HorizontalPageBreaks != nullptr) + proc.mandatory(*m_HorizontalPageBreaks); + if(m_VerticalPageBreaks != nullptr) + proc.mandatory(*m_VerticalPageBreaks); + if(m_AUTOFILTER != nullptr) + proc.mandatory(*m_AUTOFILTER); + proc.mandatory(); + return true; +} + int CUSTOMVIEW::serialize(std::wostream & stream) { if (m_UserSView == NULL) return 0; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/CUSTOMVIEW.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/CUSTOMVIEW.h index 8464ab38a7..6568adecaa 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/CUSTOMVIEW.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/CUSTOMVIEW.h @@ -45,6 +45,7 @@ namespace XLS BaseObjectPtr clone(); virtual const bool loadContent(BinProcessor& proc); + virtual const bool saveContent(BinProcessor& proc); static const ElementType type = typeCUSTOMVIEW; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/DAT.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/DAT.h index 5b6e0cb74a..a27da00641 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/DAT.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/DAT.h @@ -48,6 +48,7 @@ public: BaseObjectPtr clone(); virtual const bool loadContent(BinProcessor& proc); + virtual const bool saveContent(BinProcessor& proc); int serialize (std::wostream & _stream); static const ElementType type = typeDAT; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/DAT_bu.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/DAT_bu.cpp index 29db606bbb..dadf55b4fa 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/DAT_bu.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/DAT_bu.cpp @@ -72,6 +72,18 @@ const bool DAT::loadContent(BinProcessor& proc) return true; } +const bool DAT::saveContent(BinProcessor& proc) +{ + if(m_Dat == nullptr) + return false; + proc.mandatory(*m_Dat); + proc.mandatory(); + if(m_LD != nullptr) + proc.mandatory(*m_LD); + proc.mandatory(); + return true; +} + int DAT::serialize (std::wostream & _stream) { Dat * dat = dynamic_cast(m_Dat.get()); diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/DBQUERY.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/DBQUERY.cpp index 493c8761da..69a79fabff 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/DBQUERY.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/DBQUERY.cpp @@ -195,6 +195,58 @@ const bool DBQUERY::loadContent(BinProcessor& proc) return true; } +const bool DBQUERY::saveContent(BinProcessor& proc) +{ + if(m_DbQry == nullptr) + return false; + auto cstSQLSav = 0; + { + auto castedPtr = static_cast(m_DbQry.get()); + castedPtr->typeRecord = 2; + cstSQLSav = castedPtr->query.cstSQLSav; + } + proc.mandatory(*m_DbQry); + for(auto i = 0; i < m_arSXString.size(); i++) + { + if(i== m_arSXString.size() -1 - cstSQLSav) + break; + SXString str; + str.segment = m_arSXString.at(i); + str.cch = m_arSXString.at(i).size(); + proc.mandatory(str); + } + if(m_DbParam != nullptr) + { + { + auto castedPtr = static_cast(m_DbParam.get()); + castedPtr->typeRecord = 1; + } + proc.mandatory(*m_DbParam); + for(auto i : m_arParams) + { + SXString str; + str.segment = i.string; + str.cch = i.string.size(); + proc.mandatory(str); + + auto castedPtr = static_cast(i.param.get()); + castedPtr->typeRecord = 1; + proc.mandatory(*i.param); + } + + } + for(auto i = (m_arSXString.size() -1 - cstSQLSav); i < m_arSXString.size(); i++) + { + if(i < 0) + break; + SXString str; + str.segment = m_arSXString.at(i); + str.cch = m_arSXString.at(i).size(); + proc.mandatory(str); + } + return true; +} + int DBQUERY::serialize(std::wostream & strm) { std::wstring name; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/DBQUERY.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/DBQUERY.h index 62fceaa668..57d624123a 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/DBQUERY.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/DBQUERY.h @@ -53,6 +53,7 @@ public: BaseObjectPtr clone(); virtual const bool loadContent(BinProcessor& proc); + virtual const bool saveContent(BinProcessor& proc); int serialize(std::wostream & stream); diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/DBQUERYEXT.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/DBQUERYEXT.h index 911c03ad44..0963f0f6ce 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/DBQUERYEXT.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/DBQUERYEXT.h @@ -51,6 +51,7 @@ public: BaseObjectPtr clone(); virtual const bool loadContent(BinProcessor& proc); + virtual const bool saveContent(BinProcessor& proc); BaseObjectPtr m_TxtQry; BaseObjectPtr m_DBQueryExt; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/DBQUERYEXT_bu.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/DBQUERYEXT_bu.cpp index 726d260e22..028013cf18 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/DBQUERYEXT_bu.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/DBQUERYEXT_bu.cpp @@ -124,5 +124,28 @@ const bool DBQUERYEXT::loadContent(BinProcessor& proc) return true; } +const bool DBQUERYEXT::saveContent(BinProcessor& proc) +{ + if(m_DBQueryExt == nullptr) + return false; + proc.mandatory(*m_DBQueryExt); + if(m_ExtString != nullptr) + proc.mandatory(*m_ExtString); + for(auto i : m_arOleDbConn) + { + if(i.oleDbConn != nullptr) + proc.mandatory(*i.oleDbConn); + for(auto j : i.arExtString) + if(j != nullptr) + proc.mandatory(*j); + } + if(m_TxtQry != nullptr) + proc.mandatory(*m_TxtQry); + for(auto i : m_arExtString) + if(i != nullptr) + proc.mandatory(*i); + return true; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/DCON.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/DCON.h index ff028e7715..cb014dae79 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/DCON.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/DCON.h @@ -46,6 +46,7 @@ public: BaseObjectPtr clone(); virtual const bool loadContent(BinProcessor& proc); + virtual const bool saveContent(BinProcessor& proc); static const ElementType type = typeDCON; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/DCON_bu.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/DCON_bu.cpp index 4b56765f40..27c6ede810 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/DCON_bu.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/DCON_bu.cpp @@ -94,5 +94,18 @@ const bool DCON::loadContent(BinProcessor& proc) return true; } +const bool DCON::saveContent(BinProcessor& proc) +{ + if(m_DCon == nullptr) + return false; + proc.mandatory(*m_DCon); + + for(auto i : m_arDCon) + if(i != nullptr) + proc.mandatory(*i); + + return true; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/DFTTEXT.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/DFTTEXT.cpp index 354e5affc3..4aeadfc88a 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/DFTTEXT.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/DFTTEXT.cpp @@ -97,5 +97,22 @@ const bool DFTTEXT::loadContent(BinProcessor& proc) return true; } +const bool DFTTEXT::saveContent(BinProcessor& proc) +{ + if(m_DefaultText == nullptr) + return false; + if(m_DataLabExt != nullptr) + { + proc.mandatory(*m_DataLabExt); + proc.mandatory(); + } + proc.mandatory(*m_DefaultText); + if(m_ATTACHEDLABEL != nullptr) + proc.mandatory(*m_ATTACHEDLABEL); + if(m_DataLabExt != nullptr) + proc.mandatory(); + return true; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/DFTTEXT.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/DFTTEXT.h index 21b6276067..995316e1a7 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/DFTTEXT.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/DFTTEXT.h @@ -46,6 +46,7 @@ public: BaseObjectPtr clone(); virtual const bool loadContent(BinProcessor& proc); + virtual const bool saveContent(BinProcessor& proc); static const ElementType type = typeDFTTEXT; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/DREF.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/DREF.cpp index 69b5c97706..a3ef0ec413 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/DREF.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/DREF.cpp @@ -70,6 +70,14 @@ const bool DREF::loadContent(BinProcessor& proc) return true; } +const bool DREF::saveContent(BinProcessor& proc) +{ + if(m_DCon == nullptr) + return false; + proc.mandatory(*m_DCon); + return true; +} + int DREF::serialize(std::wostream & strm) { if (!m_DCon)return 0; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/DREF.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/DREF.h index 6ca7d669e3..1fa63ea5c2 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/DREF.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/DREF.h @@ -46,6 +46,7 @@ public: BaseObjectPtr clone(); virtual const bool loadContent(BinProcessor& proc); + virtual const bool saveContent(BinProcessor& proc); int serialize(std::wostream & stream); diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/DROPBAR.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/DROPBAR.h index 192c8a3fe3..c2646681e0 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/DROPBAR.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/DROPBAR.h @@ -46,6 +46,7 @@ public: BaseObjectPtr clone(); virtual const bool loadContent(BinProcessor& proc); + virtual const bool saveContent(BinProcessor& proc); static const ElementType type = typeDROPBAR; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/DROPBAR_bu.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/DROPBAR_bu.cpp index c1ee0c103d..18c842ab4e 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/DROPBAR_bu.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/DROPBAR_bu.cpp @@ -101,6 +101,24 @@ const bool DROPBAR::loadContent(BinProcessor& proc) return true; } +const bool DROPBAR::saveContent(BinProcessor& proc) +{ + if(m_DropBar == nullptr) + return false; + proc.mandatory(*m_DropBar); + proc.mandatory(); + if(m_LineFormat != nullptr) + proc.mandatory(*m_LineFormat); + if(m_AreaFormat != nullptr) + proc.mandatory(*m_AreaFormat); + if(m_GELFRAME != nullptr) + proc.optional(*m_GELFRAME); + if(m_SHAPEPROPS != nullptr) + proc.mandatory(*m_SHAPEPROPS); + proc.mandatory(); + return true; +} + int DROPBAR::serialize(std::wostream & _stream) { DropBar *dropBar = dynamic_cast(m_DropBar.get()); diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/DVAXIS.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/DVAXIS.cpp index 0c7a6a8f59..e39a833e82 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/DVAXIS.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/DVAXIS.cpp @@ -121,6 +121,22 @@ const bool DVAXIS::loadContent(BinProcessor& proc) return true; } +const bool DVAXIS::saveContent(BinProcessor& proc) +{ + if(m_Axis == nullptr) + return false; + proc.mandatory(*m_Axis); + proc.mandatory(); + if(m_ValueRange != nullptr) + proc.mandatory(*m_ValueRange); + if(m_AXM != nullptr) + proc.mandatory(*m_AXM); + if(m_AXS != nullptr) + proc.mandatory(*m_AXS); + proc.mandatory(); + return true; +} + int DVAXIS::serialize(std::wostream & _stream) { ValueRange *value_range = dynamic_cast (m_ValueRange.get()); diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/DVAXIS.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/DVAXIS.h index af7d0f8c70..7340eafce9 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/DVAXIS.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/DVAXIS.h @@ -49,6 +49,7 @@ public: virtual const bool loadContentRead(BinReaderProcessor& proc); virtual const bool loadContent(BinProcessor& proc); + virtual const bool saveContent(BinProcessor& proc); static const ElementType type = typeDVAXIS; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/FEAT.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/FEAT.h index cf6423f17b..4021f2c0ef 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/FEAT.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/FEAT.h @@ -46,6 +46,7 @@ public: BaseObjectPtr clone(); virtual const bool loadContent(BinProcessor& proc); + virtual const bool saveContent(BinProcessor& proc); static const ElementType type = typeFEAT; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/FEAT_bu.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/FEAT_bu.cpp index 345b26a727..fcdda636e5 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/FEAT_bu.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/FEAT_bu.cpp @@ -111,5 +111,15 @@ const bool FEAT::loadContent(BinProcessor& proc) return true; } +const bool FEAT::saveContent(BinProcessor& proc) +{ + if(m_FeatHdr == nullptr) + { + m_FeatHdr = BaseObjectPtr(new FeatHdr(false)); + } + proc.mandatory(*m_FeatHdr); + return true; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/FNGROUPS.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/FNGROUPS.cpp index 58ac1c293a..88e49cdb17 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/FNGROUPS.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/FNGROUPS.cpp @@ -69,5 +69,18 @@ const bool FNGROUPS::loadContent(BinProcessor& proc) return true; } +const bool FNGROUPS::saveContent(BinProcessor& proc) +{ + if(fnGroupCount == nullptr) + return false; + proc.mandatory(*fnGroupCount); + for(auto i : fnGroupNames) + if(i != nullptr) + proc.mandatory(*i); + for(auto i : fnGrp12) + if(i != nullptr) + proc.mandatory(*i); +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/FNGROUPS.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/FNGROUPS.h index ea77872f16..3feb86da3d 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/FNGROUPS.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/FNGROUPS.h @@ -48,8 +48,14 @@ public: BaseObjectPtr clone(); virtual const bool loadContent(BinProcessor& proc); + virtual const bool saveContent(BinProcessor& proc); static const ElementType type = typeFNGROUPS; + + BaseObjectPtr fnGroupCount; + std::vector fnGroupNames; + std::vector fnGrp12; + }; } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/FORMATTING.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/FORMATTING.cpp index 11510a8d2b..0d66d53ab3 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/FORMATTING.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/FORMATTING.cpp @@ -154,6 +154,36 @@ const bool FORMATTING::loadContent(BinProcessor& proc) return true; } +const bool FORMATTING::saveContent(BinProcessor& proc) +{ + global_info = proc.getGlobalWorkbookInfo(); + for(auto i:global_info->m_arFonts) + proc.mandatory(*i); + if(global_info->m_arFonts.empty()) + proc.mandatory(); + for(auto i:global_info->m_mapNumFormats) + proc.mandatory(*i.second); + if(global_info->m_mapNumFormats.empty()) + { + proc.mandatory(); + } + if(m_XFS != nullptr) + proc.mandatory(*m_XFS); + else + proc.mandatory(); + if(m_Styles != nullptr) + proc.mandatory(*m_Styles); + else + proc.mandatory(); + if(m_TABLESTYLES != nullptr) + proc.mandatory(*m_TABLESTYLES); + if(m_Palette != nullptr) + proc.mandatory(*m_Palette); + if(m_ClrtClient != nullptr) + proc.mandatory(*m_ClrtClient); + return true; +} + void FORMATTING::update_xfs() { STYLES * st = dynamic_cast(m_Styles.get()); diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/FORMATTING.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/FORMATTING.h index 088b7fa5e9..c31bdc740d 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/FORMATTING.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/FORMATTING.h @@ -48,6 +48,7 @@ public: BaseObjectPtr clone(); virtual const bool loadContent(BinProcessor& proc); + virtual const bool saveContent(BinProcessor& proc); int serialize(std::wostream & stream); @@ -58,8 +59,8 @@ public: BaseObjectPtr m_Styles; BaseObjectPtr m_XFS; - //std::vector m_arFormats; in global - //std::vector m_arFonts; in global + //std::vector m_arFormats; in global + //std::vector m_arFonts; in global BaseObjectPtr m_Palette; BaseObjectPtr m_ClrtClient; std::vector m_arDXF; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/FORMULA.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/FORMULA.h index c5766e8084..7974186e95 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/FORMULA.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/FORMULA.h @@ -34,6 +34,8 @@ #include "../CompositeObject.h" #include "../Biff_structures/CellRef.h" #include "../Biff_structures/CellRangeRef.h" +#include "../Biff_structures/BiffString.h" +#include "../Base/Nullable.h" namespace XLS { @@ -51,6 +53,7 @@ public: BaseObjectPtr clone(); virtual const bool loadContent(BinProcessor& proc); + virtual const bool saveContent(BinProcessor& proc); static const ElementType type = typeFORMULA; int serialize(std::wostream & stream); @@ -64,6 +67,7 @@ public: BaseObjectPtr m_Cash; std::vector m_arContinue; + nullable m_stringValCache; CellRef location; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/FORMULA_bu.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/FORMULA_bu.cpp index 0f53b5af38..655678055e 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/FORMULA_bu.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/FORMULA_bu.cpp @@ -147,6 +147,54 @@ const bool FORMULA::loadContent(BinProcessor& proc) return true; } +const bool FORMULA::saveContent(BinProcessor& proc) +{ + if(m_Formula != nullptr) + proc.mandatory(*m_Formula); + if(m_ArrayFormula != nullptr) + proc.mandatory(*m_ArrayFormula); + else if (m_TableFormula != nullptr) + proc.mandatory(*m_TableFormula); + else if (m_SharedFormula != nullptr) + proc.mandatory(*m_SharedFormula); + if(m_stringValCache.IsInit()) + { + String strVal; + _UINT32 maxRecordSize = 4112; + auto cachePtr = m_stringValCache.GetPointer(); + if(cachePtr->getSize() <= maxRecordSize) + { + strVal.string = *cachePtr; + proc.mandatory(strVal); + } + else + { + auto tempVal = cachePtr->value(); + strVal.string = tempVal.substr(0, maxRecordSize); + proc.mandatory(strVal); + tempVal.erase(0, maxRecordSize); + while(tempVal.size() > 0) + { + size_t bytesSize = 0; + if(tempVal.size() > maxRecordSize) + bytesSize = sizeof(wchar_t) * maxRecordSize; + else + bytesSize = sizeof(wchar_t) * tempVal.size(); + Continue continueRecord; + continueRecord.m_pData = new char[bytesSize * 2]; + continueRecord.m_iDataSize = bytesSize * 2; + memcpy(continueRecord.m_pData, tempVal.data() ,bytesSize * 2); + proc.mandatory(continueRecord); + if(tempVal.size() > bytesSize) + tempVal.erase(0, bytesSize); + else + break; + } + } + } + return true; +} + const CellRef FORMULA::getLocation() const { return location; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/FRAME.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/FRAME.h index f50cf43bfe..84fa9e11f3 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/FRAME.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/FRAME.h @@ -48,6 +48,7 @@ public: BaseObjectPtr clone(); virtual const bool loadContent(BinProcessor& proc); + virtual const bool saveContent(BinProcessor& proc); int serialize(std::wostream & stream_); diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/FRAME_bu.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/FRAME_bu.cpp index a2b3ca18ba..ca28bea52a 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/FRAME_bu.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/FRAME_bu.cpp @@ -104,6 +104,22 @@ const bool FRAME::loadContent(BinProcessor& proc) return true; } +const bool FRAME::saveContent(BinProcessor& proc) +{ + if(m_Frame == nullptr) + return false; + proc.mandatory(*m_Frame); + proc.mandatory(); + if(m_LineFormat != nullptr) + proc.mandatory(*m_LineFormat); + if(m_AreaFormat != nullptr) + proc.mandatory(*m_AreaFormat); + if(m_SHAPEPROPS != nullptr) + proc.mandatory(*m_SHAPEPROPS); + proc.mandatory(); + return true; +} + int FRAME::serialize(std::wostream & _stream) { AreaFormat * area = dynamic_cast(m_AreaFormat.get()); diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/GLOBALS.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/GLOBALS.cpp index c14eafcbeb..4f4ceeb8cf 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/GLOBALS.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/GLOBALS.cpp @@ -156,6 +156,49 @@ const bool GLOBALS::loadContent(BinProcessor& proc) return true; } +const bool GLOBALS::saveContent(BinProcessor& proc) +{ + if(m_CalcMode != nullptr) + proc.mandatory(*m_CalcMode); + else + proc.mandatory(); + + proc.optional(); + + if(m_CalcRefMode != nullptr) + proc.mandatory(*m_CalcRefMode); + else + proc.mandatory(); + + proc.optional(); + proc.optional(); + proc.optional(); + proc.optional(); + proc.optional(); + proc.optional(); + + if(m_Guts != nullptr) + proc.mandatory(*m_Guts); + else + proc.mandatory(); + if(m_DefaultRowHeight != nullptr) + proc.mandatory(*m_DefaultRowHeight); + else + proc.mandatory(); + if(m_WsBool != nullptr) + proc.mandatory(*m_WsBool); + else + { + WsBool wsbool(is_dialog); + proc.mandatory(wsbool); + } + if(m_HorizontalPageBreaks != nullptr) + proc.mandatory(*m_HorizontalPageBreaks); + + if(m_VerticalPageBreaks != nullptr) + proc.mandatory(*m_VerticalPageBreaks); + return true; +} int GLOBALS::serialize_calcPr(std::wostream & stream) { if (!m_CalcMode) return 0; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/GLOBALS.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/GLOBALS.h index 0173e493aa..6a8816655e 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/GLOBALS.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/GLOBALS.h @@ -46,6 +46,7 @@ public: BaseObjectPtr clone(); virtual const bool loadContent (BinProcessor& proc); + virtual const bool saveContent (BinProcessor& proc); static const ElementType type = typeGLOBALS; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/HLINK.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/HLINK.h index cca6088625..d2c4147654 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/HLINK.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/HLINK.h @@ -48,6 +48,7 @@ public: BaseObjectPtr clone(); virtual const bool loadContent(BinProcessor& proc); + virtual const bool saveContent(BinProcessor& proc); static const ElementType type = typeHLINK; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/HLINK_bu.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/HLINK_bu.cpp index 870b8fbf4d..02047d7cd2 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/HLINK_bu.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/HLINK_bu.cpp @@ -73,5 +73,14 @@ const bool HLINK::loadContent(BinProcessor& proc) return true; } +const bool HLINK::saveContent(BinProcessor& proc) +{ + if(m_HLink != nullptr) + proc.mandatory(*m_HLink); + if(m_HLinkTooltip != nullptr) + proc.mandatory(*m_HLinkTooltip); + return true; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/INTERFACE.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/INTERFACE.cpp index 11e7cb134d..f2c4432e71 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/INTERFACE.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/INTERFACE.cpp @@ -77,5 +77,13 @@ const bool INTERFACE_T::loadContent(BinProcessor& proc) return true; } +const bool INTERFACE_T::saveContent(BinProcessor& proc) +{ + proc.mandatory(); + proc.mandatory(); + proc.mandatory(); + return true; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/INTERFACE.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/INTERFACE.h index 038fc0104e..b06d8e9ebf 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/INTERFACE.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/INTERFACE.h @@ -49,6 +49,7 @@ public: BaseObjectPtr clone(); virtual const bool loadContent(BinProcessor& proc); + virtual const bool saveContent(BinProcessor& proc); static const ElementType type = typeINTERFACE_T; }; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/IVAXIS.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/IVAXIS.cpp index c78db9ed93..f79dd46513 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/IVAXIS.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/IVAXIS.cpp @@ -128,6 +128,24 @@ const bool IVAXIS::loadContent(BinProcessor& proc) return true; } +const bool IVAXIS::saveContent(BinProcessor& proc) +{ + if(m_Axis == nullptr) + return false; + proc.mandatory(*m_Axis); + proc.mandatory(); + if(m_CatSerRange != nullptr) + proc.mandatory(*m_CatSerRange); + if(m_AxcExt != nullptr) + proc.mandatory(*m_AxcExt); + if(m_CatLab != nullptr) + proc.mandatory(*m_CatLab); + if(m_AXS != nullptr) + proc.mandatory(*m_AXS); + proc.mandatory(); + return true; +} + int IVAXIS::serialize(std::wostream & _stream) { CatSerRange * cat_ser_range = dynamic_cast(m_CatSerRange.get()); diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/IVAXIS.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/IVAXIS.h index 14d6655fd7..a6ae99ba81 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/IVAXIS.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/IVAXIS.h @@ -49,6 +49,7 @@ public: virtual const bool loadContentRead(BinReaderProcessor& proc); virtual const bool loadContent(BinProcessor& proc); + virtual const bool saveContent(BinProcessor& proc); static const ElementType type = typeIVAXIS; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/LBL.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/LBL.h index 318d81cd44..9e89d00332 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/LBL.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/LBL.h @@ -46,6 +46,7 @@ public: BaseObjectPtr clone(); virtual const bool loadContent(BinProcessor& proc); + virtual const bool saveContent(BinProcessor& proc); int serialize(std::wostream & stream); diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/LBL_bu.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/LBL_bu.cpp index a53f4faad2..26cb772496 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/LBL_bu.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/LBL_bu.cpp @@ -93,6 +93,14 @@ const bool LBL::loadContent(BinProcessor& proc) } return true; } +const bool LBL::saveContent(BinProcessor& proc) +{ + if(m_Lbl == nullptr) + return false; + proc.mandatory(*m_Lbl); + return true; +} + int LBL::serialize(std::wostream & stream) { Lbl *lbl = dynamic_cast(m_Lbl.get()); diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/LD.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/LD.cpp index baa27f1f62..dadb527760 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/LD.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/LD.cpp @@ -106,6 +106,24 @@ const bool LD::loadContent(BinProcessor& proc) return true; } +const bool LD::saveContent(BinProcessor& proc) +{ + if(m_Legend == nullptr) + return false; + proc.mandatory(*m_Legend); + proc.mandatory(); + if(m_Pos != nullptr) + proc.mandatory(*m_Pos); + if(m_ATTACHEDLABEL != nullptr) + proc.mandatory(*m_ATTACHEDLABEL); + if(m_FRAME != nullptr) + proc.mandatory(*m_FRAME); + if(m_CrtLayout12 != nullptr) + proc.mandatory(*m_CrtLayout12); + proc.mandatory(); + return true; +} + int LD::serialize (std::wostream & _stream, const std::wstring & entries) { ATTACHEDLABEL *att = dynamic_cast (m_ATTACHEDLABEL.get()); diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/LD.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/LD.h index 4743cf2754..03f178a2b9 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/LD.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/LD.h @@ -46,6 +46,7 @@ public: BaseObjectPtr clone(); virtual const bool loadContent(BinProcessor& proc); + virtual const bool saveContent(BinProcessor& proc); int serialize (std::wostream & _stream, const std::wstring & entries); static const ElementType type = typeLD; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/MDBLOCK.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/MDBLOCK.cpp index 981328d3ef..63f3e90889 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/MDBLOCK.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/MDBLOCK.cpp @@ -66,5 +66,39 @@ const bool MDBLOCK::loadContent(BinProcessor& proc) return true; } +const bool MDBLOCK::saveContent(BinProcessor& proc) +{ + if(m_MDB == nullptr) + return false; + proc.mandatory(*m_MDB); + auto castedPtr = static_cast(m_MDB.get()); + auto maxElemCount = 1026; //max size for one record storage + if(castedPtr->rgmdir.size() > maxElemCount) + { + auto arraySize = castedPtr->rgmdir.size(); + auto Stpos = maxElemCount; + while(Stpos+1 < arraySize) + { + auto tempLen = 0; + if(arraySize < Stpos + maxElemCount) + tempLen = arraySize - Stpos; + else + tempLen = maxElemCount; + { + ContinueFrt12 continueRecord; + continueRecord.rgb.reserve(tempLen*8); + CFRecord TempRecord(rt_ContinueFrt12, proc.getGlobalWorkbookInfo()); + for(auto i = Stpos; i < Stpos+ tempLen; i++) + TempRecord << *(castedPtr->rgmdir[i]); + memcpy(continueRecord.rgb.data(), (TempRecord.getCurStaticData()), tempLen*8); + proc.mandatory(continueRecord); + } + Stpos+=tempLen; + } + } + return true; + +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/MDBLOCK.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/MDBLOCK.h index ad6c95d103..471d3e9d3e 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/MDBLOCK.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/MDBLOCK.h @@ -46,6 +46,7 @@ public: BaseObjectPtr clone(); virtual const bool loadContent(BinProcessor& proc); + virtual const bool saveContent(BinProcessor& proc); static const ElementType type = typeMDBLOCK; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/MDTINFO.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/MDTINFO.h index a0d1a1c751..9842687565 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/MDTINFO.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/MDTINFO.h @@ -46,6 +46,7 @@ public: BaseObjectPtr clone(); virtual const bool loadContent(BinProcessor& proc); + virtual const bool saveContent(BinProcessor& proc); static const ElementType type = typeMDTINFO; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/MDTINFO_bu.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/MDTINFO_bu.cpp index 88d07f984a..00cabf9960 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/MDTINFO_bu.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/MDTINFO_bu.cpp @@ -66,5 +66,34 @@ const bool MDTINFO::loadContent(BinProcessor& proc) return true; } +const bool MDTINFO::saveContent(BinProcessor& proc) +{ + constexpr auto maxStNameLen = 4104; + if(m_MDTInfo == nullptr) + return false; + proc.mandatory(*m_MDTInfo); + auto castedPtr = static_cast(m_MDTInfo.get()); + if(castedPtr->stName.getSize() > maxStNameLen) + { auto NameSize = castedPtr->stName.getSize(); + auto Stpos = maxStNameLen; + while(Stpos+1 < NameSize) + { + auto tempLen = 0; + if(NameSize < Stpos + maxStNameLen) + tempLen = NameSize - Stpos; + else + tempLen = maxStNameLen; + { + ContinueFrt12 continueRecord; + continueRecord.rgb.reserve(tempLen*2); + memcpy(continueRecord.rgb.data(), (castedPtr->stName.value().c_str() + Stpos), tempLen*2); + proc.mandatory(continueRecord); + } + Stpos+=tempLen; + } + } + return true; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/MDXSTR.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/MDXSTR.h index 4ac850acb5..27c2a796fb 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/MDXSTR.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/MDXSTR.h @@ -46,6 +46,7 @@ public: BaseObjectPtr clone(); virtual const bool loadContent(BinProcessor& proc); + virtual const bool saveContent(BinProcessor& proc); static const ElementType type = typeMDXSTR; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/MDXSTR_bu.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/MDXSTR_bu.cpp index e6b3207927..6a9437fa2f 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/MDXSTR_bu.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/MDXSTR_bu.cpp @@ -67,5 +67,34 @@ const bool MDXSTR::loadContent(BinProcessor& proc) return true; } +const bool MDXSTR::saveContent(BinProcessor& proc) +{ + if(m_MDXStr == nullptr) + return false; + proc.mandatory(*m_MDXStr); + auto maxStNameLen = 4104; + auto castedPtr = static_cast(m_MDXStr.get()); + if(castedPtr->st.getSize() > maxStNameLen) + { auto StSize = castedPtr->st.getSize(); + auto Stpos = maxStNameLen; + while(Stpos+1 < StSize) + { + auto tempLen = 0; + if(StSize < Stpos + maxStNameLen) + tempLen = StSize - Stpos; + else + tempLen = maxStNameLen; + { + ContinueFrt12 continueRecord; + continueRecord.rgb.reserve(tempLen*2); + memcpy(continueRecord.rgb.data(), (castedPtr->st.value().c_str() + Stpos), tempLen*2); + proc.mandatory(continueRecord); + } + Stpos+=tempLen; + } + } + return true; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/MDXTUPLESET.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/MDXTUPLESET.cpp index fc70d32745..ec2790f42d 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/MDXTUPLESET.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/MDXTUPLESET.cpp @@ -72,5 +72,72 @@ const bool MDXTUPLESET::loadContent(BinProcessor& proc) return true; } +const bool MDXTUPLESET::saveContent(BinProcessor& proc) +{ + if(m_MDXVarious == nullptr) + return false; + proc.mandatory(*m_MDXVarious); + auto type = m_MDXVarious->get_type(); + if(type == typeMDXTuple) + { + auto tuple = static_cast(m_MDXVarious.get()); + auto maxSize = 2050; + if(tuple->cistr > maxSize) + { + auto currentPose = maxSize; + while(currentPose < tuple->cistr) + { + + CFRecord tempRecord(rt_ContinueFrt12, proc.getGlobalWorkbookInfo()); + auto limit = 0; + if(currentPose + maxSize > tuple->cistr) + limit = tuple->cistr; + else + limit = currentPose + maxSize; + for(auto i = currentPose; i < limit; i++) + tempRecord << *(tuple->rgistr[i]); + { + ContinueFrt12 continueRecord; + auto capacity = 4*(limit - currentPose); + continueRecord.rgb.reserve(capacity); + memcpy(continueRecord.rgb.data(), tempRecord.getCurStaticData(), capacity); + proc.mandatory(continueRecord); + } + currentPose = limit; + } + } + } + else + { + auto set = static_cast(m_MDXVarious.get()); + auto maxSize = 2049; + if(set->cistr > maxSize) + { + auto currentPose = maxSize; + while(currentPose < set->cistr) + { + + CFRecord tempRecord(rt_ContinueFrt12, proc.getGlobalWorkbookInfo()); + auto limit = 0; + if(currentPose + maxSize > set->cistr) + limit = set->cistr; + else + limit = currentPose + maxSize; + for(auto i = currentPose; i < limit; i++) + tempRecord << *(set->rgistr[i]); + { + ContinueFrt12 continueRecord; + auto capacity = 4*(limit - currentPose); + continueRecord.rgb.reserve(capacity); + memcpy(continueRecord.rgb.data(), tempRecord.getCurStaticData(), capacity); + proc.mandatory(continueRecord); + } + currentPose = limit; + } + } + } + return true; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/MDXTUPLESET.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/MDXTUPLESET.h index c59121850f..641ae29ff4 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/MDXTUPLESET.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/MDXTUPLESET.h @@ -46,6 +46,7 @@ public: BaseObjectPtr clone(); virtual const bool loadContent(BinProcessor& proc); + virtual const bool saveContent(BinProcessor& proc); static const ElementType type = typeMDXTUPLESET; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/METADATA.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/METADATA.cpp index 7631cd70dc..9535d814f6 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/METADATA.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/METADATA.cpp @@ -120,5 +120,22 @@ const bool METADATA::loadContent(BinProcessor& proc) return false; } +const bool METADATA::saveContent(BinProcessor& proc) +{ + for(auto i : m_arMDTINFO) + if(i != nullptr) + proc.mandatory(*i); + for(auto i : m_arMDXSTR) + if(i != nullptr) + proc.mandatory(*i); + for(auto i : m_arMDTSET) + if(i != nullptr) + proc.mandatory(*i); + for(auto i : m_arMDBLOCK) + if(i != nullptr) + proc.mandatory(*i); + return true; +} + } // namespace XLS diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/METADATA.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/METADATA.h index c92122b272..563a7d791f 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/METADATA.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/METADATA.h @@ -46,6 +46,7 @@ public: BaseObjectPtr clone(); virtual const bool loadContent(BinProcessor& proc); + virtual const bool saveContent(BinProcessor& proc); static const ElementType type = typeMETADATA; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/PAGESETUP.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/PAGESETUP.cpp index 137c71b9f1..7828353afe 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/PAGESETUP.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_unions/PAGESETUP.cpp @@ -168,6 +168,31 @@ namespace XLS return true; } +const bool PAGESETUP::saveContent(BinProcessor& proc) +{ + if(m_Header != nullptr) + proc.mandatory(*m_Header); + else + proc.mandatory
(); + if(m_Footer != nullptr) + proc.mandatory(*m_Footer); + else + proc.mandatory