diff --git a/Common/3dParty/html/css/src/StyleProperties.cpp b/Common/3dParty/html/css/src/StyleProperties.cpp index 69481e53de..69426ca486 100644 --- a/Common/3dParty/html/css/src/StyleProperties.cpp +++ b/Common/3dParty/html/css/src/StyleProperties.cpp @@ -917,6 +917,25 @@ namespace NSCSS } } + std::wstring CColor::ToHEX() const + { + switch(m_enType) + { + case ColorRGB: + { + TRGB* pRGB = static_cast(m_oValue); + return ConvertRGBtoHEX(*pRGB); + } + case ColorHEX: + { + std::wstring *pValue = static_cast(m_oValue); + return *pValue; + } + default: + return std::wstring(); + } + } + std::wstring CColor::EquateToColor(const std::vector> &arColors) const { if (arColors.empty()) diff --git a/Common/3dParty/html/css/src/StyleProperties.h b/Common/3dParty/html/css/src/StyleProperties.h index 7a0be6b03b..2fa1ce1935 100644 --- a/Common/3dParty/html/css/src/StyleProperties.h +++ b/Common/3dParty/html/css/src/StyleProperties.h @@ -242,6 +242,7 @@ namespace NSCSS int ToInt() const override; double ToDouble() const override; std::wstring ToWString() const override; + std::wstring ToHEX() const; std::wstring EquateToColor(const std::vector>& arColors) const; TRGB ToRGB() const; diff --git a/HtmlFile2/htmlfile2.cpp b/HtmlFile2/htmlfile2.cpp index 1fd8b087a1..3a0b628788 100644 --- a/HtmlFile2/htmlfile2.cpp +++ b/HtmlFile2/htmlfile2.cpp @@ -1561,7 +1561,7 @@ public: } // settings.xml - std::wstring sSettings = L""; + std::wstring sSettings = L""; NSFile::CFileBinary oSettingsWriter; if (oSettingsWriter.CreateFileW(m_sDst + L"/word/settings.xml")) { @@ -2178,10 +2178,12 @@ private: NSCSS::CCompiledStyle oStyle; m_oStylesCalculator.GetCompiledStyle(oStyle, sSelectors); - INT nMarLeft = 720; - INT nMarRight = 720; - INT nMarTop = 100; - INT nMarBottom = 100; + const bool bInTable = ElementInTable(sSelectors); + + INT nMarLeft = (!bInTable) ? 720 : 0; + INT nMarRight = (!bInTable) ? 720 : 0; + INT nMarTop = (!bInTable) ? 100 : 0; + INT nMarBottom = (!bInTable) ? 100 : 0; if (!oStyle.m_oMargin.GetLeft().Empty() && !oStyle.m_oMargin.GetLeft().Zero()) nMarLeft = oStyle.m_oMargin.GetLeft().ToInt(NSCSS::Twips, m_oPageData.GetWidth().ToInt(NSCSS::Twips)); @@ -2294,6 +2296,28 @@ private: m_oDocXml.WriteString(L"\"/>"); */ + if (!sSelectors.back().m_mAttributes.empty()) + { + std::map::iterator itFound = sSelectors.back().m_mAttributes.find(L"bgcolor"); + + if (sSelectors.back().m_mAttributes.end() != itFound) + { + NSCSS::NSProperties::CColor oColor; + oColor.SetValue(itFound->second); + + if (!oColor.Empty() && !oColor.None()) + { + const std::wstring wsHEXColor{oColor.ToHEX()}; + + if (!wsHEXColor.empty()) + m_oDocXml.WriteString(L""); + + sSelectors.back().m_mAttributes.erase(itFound); + } + } + } + m_oLightReader.MoveToElement(); + CTextSettings oTS; readStream(&m_oDocXml, sSelectors, oTS); } @@ -3627,12 +3651,14 @@ private: return true; } - bool ParseTable(NSStringUtils::CStringBuilder* oXml, std::vector& sSelectors, CTextSettings& oTS) + bool ParseTable(NSStringUtils::CStringBuilder* oXml, std::vector& sSelectors, const CTextSettings& oTS) { if(m_oLightReader.IsEmptyNode()) return false; CTable oTable; + CTextSettings oTextSettings{oTS}; + oTextSettings.sPStyle.clear(); NSCSS::CCompiledStyle oStyle; m_oStylesCalculator.GetCompiledStyle(oStyle, sSelectors); @@ -3729,11 +3755,11 @@ private: if(sName == L"caption") ParseTableCaption(oTable, sSelectors, oTS); if(sName == L"thead") - ParseTableRows(oTable, sSelectors, oTS, ERowParseMode::ParseModeHeader); + ParseTableRows(oTable, sSelectors, oTextSettings, ERowParseMode::ParseModeHeader); if(sName == L"tbody") - ParseTableRows(oTable, sSelectors, oTS, ERowParseMode::ParseModeBody); + ParseTableRows(oTable, sSelectors, oTextSettings, ERowParseMode::ParseModeBody); else if(sName == L"tfoot") - ParseTableRows(oTable, sSelectors, oTS, ERowParseMode::ParseModeFoother); + ParseTableRows(oTable, sSelectors, oTextSettings, ERowParseMode::ParseModeFoother); else if (sName == L"colgroup") ParseTableColspan(oTable);