From ab76f46fd413d8a50fe6417f2608cca6f8ffce8a Mon Sep 17 00:00:00 2001 From: Viktor Andreev Date: Thu, 9 Apr 2026 16:41:28 +0600 Subject: [PATCH] add extProps conversion --- OOXML/XlsxFormat/Styles/Styles.h | 1 + OOXML/XlsxFormat/Styles/XlsxStyles.cpp | 62 ++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) diff --git a/OOXML/XlsxFormat/Styles/Styles.h b/OOXML/XlsxFormat/Styles/Styles.h index a14f9d5d8a..bf8fb6dfdf 100644 --- a/OOXML/XlsxFormat/Styles/Styles.h +++ b/OOXML/XlsxFormat/Styles/Styles.h @@ -147,6 +147,7 @@ namespace OOX private: void SetFillXLS(XLS::BaseObjectPtr XFSPtr, XLS::BaseObjectPtr workbookPtr); void SetBordersXLS(XLS::BaseObjectPtr XFSPtr,XLS::BaseObjectPtr workbookPtr); + void SetExtPropsXLS(XLS::BaseObjectPtr XFSPt); }; } //Spreadsheet } // namespace OOX diff --git a/OOXML/XlsxFormat/Styles/XlsxStyles.cpp b/OOXML/XlsxFormat/Styles/XlsxStyles.cpp index 2df38ea3ed..2aafe838fc 100644 --- a/OOXML/XlsxFormat/Styles/XlsxStyles.cpp +++ b/OOXML/XlsxFormat/Styles/XlsxStyles.cpp @@ -68,6 +68,7 @@ #include "../../../MsBinaryFile/XlsFile/Format/Logic/Biff_unions/XFS.h" #include "../../../MsBinaryFile/XlsFile/Format/Logic/Biff_records/DXF.h" #include "../../../MsBinaryFile/XlsFile/Format/Logic/Biff_records/XF.h" +#include "../../../MsBinaryFile/XlsFile/Format/Logic/Biff_records/XFExt.h" namespace OOX { @@ -468,6 +469,7 @@ namespace OOX m_oCellXfs->toXLS(FormatPtr->m_XFS); SetFillXLS(FormatPtr->m_XFS, globalsStreamPtr); SetBordersXLS(FormatPtr->m_XFS, globalsStreamPtr); + SetExtPropsXLS(FormatPtr->m_XFS); } if(m_oDxfs.IsInit()) { @@ -720,6 +722,66 @@ namespace OOX } } } + XLS::FullColorExt getXLSColor(const CColor &inputClr) + { + XLS::FullColorExt color; + + if(inputClr.m_oRgb.IsInit()) + { + color.xclrType = 2; + color.xclrValue = inputClr.m_oRgb->ToInt(); + } + else if(inputClr.m_oThemeColor.IsInit()) + { + color.xclrType = 3; + color.xclrValue = inputClr.m_oThemeColor->m_eValue; + } + else if(inputClr.m_oIndexed.IsInit()) + { + color.xclrType = 1; + color.xclrValue = inputClr.m_oIndexed->GetValue(); + } + if(inputClr.m_oTint.IsInit()) + { + color.nTintShade = inputClr.m_oTint->GetValue(); + } + + return color; + } + void CStyles::SetExtPropsXLS(XLS::BaseObjectPtr XFSPtr) + { + auto CastedPtr = static_cast(XFSPtr.get()); + for(auto i = 0; i < CastedPtr->m_arCellXFs.size(); i++) + { + if(m_oCellXfs->m_arrItems.size() < i) + return; + auto ext = new XLS::XFExt; + ext->ixfe = i + CastedPtr->m_arCellStyles.size()+16; + auto cellXf = m_oCellXfs->m_arrItems.at(i); + if(cellXf->m_oFillId.IsInit() && m_oFills->m_arrItems.size() > cellXf->m_oFillId->GetValue()) + { + auto cellFill = m_oFills->m_arrItems.at(cellXf->m_oFillId->GetValue()); + if(cellFill->m_oPatternFill.IsInit()) + { + if(cellFill->m_oPatternFill->m_oFgColor.IsInit()) + { + auto fillProp = new XLS::ExtProp; + fillProp->extType = XLS::ExtProp::_type::ForeColor; + fillProp->extPropData.color = getXLSColor(cellFill->m_oPatternFill->m_oFgColor.get()); + ext->rgExt.push_back(XLS::BiffStructurePtr(fillProp)); + } + if(cellFill->m_oPatternFill->m_oBgColor.IsInit()) + { + auto fillProp = new XLS::ExtProp; + fillProp->extType = XLS::ExtProp::_type::BackColor; + fillProp->extPropData.color = getXLSColor(cellFill->m_oPatternFill->m_oBgColor.get()); + ext->rgExt.push_back(XLS::BiffStructurePtr(fillProp)); + } + } + } + CastedPtr->m_arXFext.push_back(XLS::BaseObjectPtr(ext)); + } + } void CStyles::read(const CPath& oPath) { //don't use this. use read(const CPath& oRootPath, const CPath& oFilePath)