From fa31f912a07bb9727174897b7fb2f819ccebc9e7 Mon Sep 17 00:00:00 2001 From: Jan Marvin Garbuszus Date: Tue, 15 Aug 2023 23:22:51 +0200 Subject: [PATCH] more work on colors for fills, fonts and borders --- src/xlsb.cpp | 40 ++++++++++++++++++++++++++++++++++++---- src/xlsb_funs.h | 19 +++++++++++++++++-- 2 files changed, 53 insertions(+), 6 deletions(-) diff --git a/src/xlsb.cpp b/src/xlsb.cpp index 26c1ef358..5050e9e9a 100644 --- a/src/xlsb.cpp +++ b/src/xlsb.cpp @@ -169,7 +169,14 @@ int styles_bin(std::string filePath, std::string outPath, bool debug) { } if (color[0] == 0x03) { - out << "" << std::endl; + + double tint = 0.0; + if (color[2] != 0) tint = (double)color[2]/32767; + + std::stringstream stream; + stream << std::setprecision(16) << tint; + + out << ""; } if (color[1]) @@ -278,8 +285,33 @@ int styles_bin(std::string filePath, std::string outPath, bool debug) { if (fls == 18) out << "gray0625"; out << "\">" << std::endl; // if FF000000 & FFFFFFFF they can be omitted - out << "" << std::endl; - out << "" << std::endl; + + double bgtint = 0.0, fgtint = 0.0; + if (bgColor[2] != 0) bgtint = (double)bgColor[2]/32767; + if (fgColor[2] != 0) fgtint = (double)fgColor[2]/32767; + + std::stringstream bgstream, fgstream; + bgstream << std::setprecision(16) << bgtint; + fgstream << std::setprecision(16) << fgtint; + + if (fgColor[0] == 0x00) + out << "" << std::endl; + if (fgColor[0] == 0x01) + out << ""; + if (fgColor[0] == 0x02) + out << ""; + if (fgColor[0] == 0x03) + out << ""; + + if (bgColor[0] == 0x00) + out << "" << std::endl; + if (bgColor[0] == 0x01) + out << ""; + if (bgColor[0] == 0x02) + out << ""; + if (bgColor[0] == 0x03) + out << ""; + out << "" << std::endl; out << "" << std::endl; } else { @@ -2307,7 +2339,7 @@ int worksheet_bin(std::string filePath, bool chartsheet, std::string outPath, bo out << " 0) - out << " s=\"" << ixfe << "\""; + out << " style=\"" << ixfe << "\""; out << " width=\"" << (double)coldx/256 << "\""; if (fields->fHidden) diff --git a/src/xlsb_funs.h b/src/xlsb_funs.h index de6871fda..b60321ea1 100644 --- a/src/xlsb_funs.h +++ b/src/xlsb_funs.h @@ -811,8 +811,23 @@ std::string brtBorder(std::string type, std::istream& sas, bool swapit) { out << "<" << type << " style = \"" << as_border_style(dg) << "\""; if (dg > 0) { - out << ">"; - out << "" << std::endl; + + double tint = 0.0; + if (color[2] != 0) tint = (double)color[2]/32767; + + std::stringstream stream; + stream << std::setprecision(16) << tint; + + if (color[0] == 0x00) + out << ">" << std::endl; + if (color[0] == 0x01) + out << ">"; + if (color[0] == 0x02) + out << ">"; + if (color[0] == 0x03) + out << ">"; + + out << "" << std::endl; } else { out << "/>" << std::endl; }