diff --git a/Common/3dParty/html/css/src/CCompiledStyle.cpp b/Common/3dParty/html/css/src/CCompiledStyle.cpp index a88d6fcda5..45af11794c 100644 --- a/Common/3dParty/html/css/src/CCompiledStyle.cpp +++ b/Common/3dParty/html/css/src/CCompiledStyle.cpp @@ -362,6 +362,7 @@ namespace NSCSS } //PADDING CASE(L"padding"): + CASE(L"mso-padding-alt"): { if (bIsThereBorder) break; @@ -385,6 +386,7 @@ namespace NSCSS break; } CASE(L"padding-top"): + CASE(L"mso-padding-top-alt"): { if (bIsThereBorder) break; @@ -408,6 +410,7 @@ namespace NSCSS break; } CASE(L"padding-right"): + CASE(L"mso-padding-right-alt"): { if (bIsThereBorder) break; @@ -432,6 +435,7 @@ namespace NSCSS break; } CASE(L"padding-bottom"): + CASE(L"mso-padding-bottom-alt"): { if (bIsThereBorder) break; @@ -455,6 +459,7 @@ namespace NSCSS break; } CASE(L"padding-left"): + CASE(L"mso-padding-left-alt"): { if (bIsThereBorder) break; diff --git a/Common/3dParty/html/css/src/CCssCalculator_Private.cpp b/Common/3dParty/html/css/src/CCssCalculator_Private.cpp index 61e0aafbdd..0b56159c1f 100644 --- a/Common/3dParty/html/css/src/CCssCalculator_Private.cpp +++ b/Common/3dParty/html/css/src/CCssCalculator_Private.cpp @@ -502,6 +502,8 @@ namespace NSCSS }); } + pStyle->AddStyle(arSelectors[i].m_mAttrs, i + 1); + for (const CElement* oElement : arFindElements) pStyle->AddStyle(oElement->GetStyle(), i + 1); diff --git a/Common/3dParty/html/css/src/CNode.h b/Common/3dParty/html/css/src/CNode.h index 89df5b80a6..15efe58fdb 100644 --- a/Common/3dParty/html/css/src/CNode.h +++ b/Common/3dParty/html/css/src/CNode.h @@ -3,7 +3,7 @@ #include #include -//#include +#include namespace NSCSS { @@ -13,7 +13,7 @@ namespace NSCSS std::wstring m_sClass; // Класс тэга std::wstring m_sId; // Id тэга std::wstring m_sStyle; // Стиль тэга - //std::map m_mAttrs; // Остальные аттрибуты тэга + std::map m_mAttrs; // Остальные аттрибуты тэга CNode(){}; CNode(std::wstring sName, std::wstring sClass, std::wstring sId) : m_sName(sName), m_sClass(sClass), m_sId(sId){}; diff --git a/Common/3dParty/html/css/src/ConstValues.h b/Common/3dParty/html/css/src/ConstValues.h index 3fb92dc4f1..784a339795 100644 --- a/Common/3dParty/html/css/src/ConstValues.h +++ b/Common/3dParty/html/css/src/ConstValues.h @@ -1738,7 +1738,7 @@ namespace NSCSS bool Empty() const { - return fWidth <= 0; + return fWidth < 0; } void SetWidthWithoutChecking(const float& fWidth, const unsigned int& unLevel, const bool &bHardMode = false) @@ -1926,7 +1926,10 @@ namespace NSCSS std::wstring GetStyle() const { - return (bBlock) ? L"auto" : sStyle; + if (bBlock) return L"auto"; + if (0 == fWidth) return L"none"; + else if (L"auto" == sStyle) return L"single"; + else return sStyle; } std::wstring GetColor() const @@ -1979,7 +1982,7 @@ namespace NSCSS else if (iswdigit(sValue[0])) { const float fWidth = wcstof(sValue.c_str(), NULL); - if (fWidth > 0.0f) + if (fWidth >= 0.0f) oBorderSide.fWidth = fWidth; } else if (sValue.substr(0, 3) == L"rgb") diff --git a/Common/3dParty/html/css/src/xhtml/CDocumentStyle.cpp b/Common/3dParty/html/css/src/xhtml/CDocumentStyle.cpp index 5730a0f45a..b2d446313e 100644 --- a/Common/3dParty/html/css/src/xhtml/CDocumentStyle.cpp +++ b/Common/3dParty/html/css/src/xhtml/CDocumentStyle.cpp @@ -279,6 +279,8 @@ namespace NSCSS sSpacingValue += L"w:after=\"" + oStyle.m_pMargin.GetTopSide() + L"\" "; sSpacingValue += L"w:before=\"" + oStyle.m_pMargin.GetTopSide() + L"\" "; } + else if (!oStyle.m_pBorder.Empty()) + sSpacingValue += L"w:after=\"0\" w:before=\"0\" "; const std::wstring &sLineHeight = oStyle.m_pFont.GetLineHeight(); if (!sLineHeight.empty()) @@ -286,6 +288,8 @@ namespace NSCSS sSpacingValue += L"w:line=\"" + sLineHeight + L"\" "; sSpacingValue += L"w:lineRule=\"auto\""; } + else if (!oStyle.m_pBorder.Empty()) + sSpacingValue += L"w:line=\"240\" w:lineRule=\"auto\" "; if (!sSpacingValue.empty()) { @@ -308,7 +312,7 @@ namespace NSCSS const std::wstring sBorderStyle = oStyle.m_pBorder.GetStyleBottomSide(); const std::wstring sBorderWidth = oStyle.m_pBorder.GetWidthBottomSideW(); - const std::wstring sBorder = L" w:color=\"" + sBorderColor + L"\" w:space=\"4\" w:sz=\"" + + const std::wstring sBorder = L" w:color=\"" + sBorderColor + L"\" w:space=\"0\" w:sz=\"" + sBorderWidth + L"\" w:val=\"" + sBorderStyle + L"\""; oXmlElement.AddPropertiesInP(NSConstValues::NSProperties::ParagraphProperties::P_TopBorder, sBorder); diff --git a/HtmlFile2/htmlfile2.cpp b/HtmlFile2/htmlfile2.cpp index d43f6f4570..3365fbdc46 100644 --- a/HtmlFile2/htmlfile2.cpp +++ b/HtmlFile2/htmlfile2.cpp @@ -574,21 +574,8 @@ public: oTree.m_oNode.m_sId = m_oLightReader.GetText(); else if(sNameA == L"style") oTree.m_oNode.m_sStyle += m_oLightReader.GetText(); - //else - // oTree.m_oNode.m_mAttrs[sNameA] = m_oLightReader.GetText(); - else if(sNameA == L"align") - oTree.m_oNode.m_sStyle += L"; text-align: " + m_oLightReader.GetText() + L";"; - - if (sName == L"table") - { - if (sNameA == L"border") - oTree.m_oNode.m_sStyle += L"; border: " + m_oLightReader.GetText() + L";"; - else if (sNameA == L"cellspacing") - oTree.m_oNode.m_sStyle += L"; border-spacing: " + m_oLightReader.GetText() + L";"; - else if (sNameA == L"cellpadding") - oTree.m_oNode.m_sStyle += L"; padding: " + m_oLightReader.GetText() + L";"; - } - // Удалять до сюда + else + oTree.m_oNode.m_mAttrs[sNameA] = m_oLightReader.GetText(); } m_oLightReader.MoveToElement(); @@ -638,8 +625,8 @@ private: oNode.m_sStyle += m_oLightReader.GetText(); else if(sName == L"title") sNote = m_oLightReader.GetText(); - else if(sName == L"align") - oNode.m_sStyle += L"; text-align: " + m_oLightReader.GetText() + L";"; + else + oNode.m_mAttrs[sName] = m_oLightReader.GetText(); } m_oLightReader.MoveToElement(); sSelectors.push_back(oNode); @@ -1166,22 +1153,27 @@ private: NSStringUtils::CStringBuilder oFoot; // Начало таблицы - oXml->WriteString(L""); + std::wstring wsTable = L""; + NSCSS::CNode oLast = sSelectors.back(); sSelectors.pop_back(); NSCSS::CCompiledStyle oStyle = m_oStylesCalculator.GetCompiledStyle(sSelectors); std::wstring sAlign = oStyle.m_pText.GetAlign(); if(sAlign == L"left" || sAlign == L"center" || sAlign == L"right" || sAlign == L"both") - oXml->WriteString(L""); - oXml->WriteString(L""); + wsTable += L""; + + wsTable += L""; + sSelectors.push_back(oLast); // borders - oStyle = m_oStylesCalculator.GetCompiledStyle(sSelectors, true); + oStyle = m_oStylesCalculator.GetCompiledStyle(sSelectors, false); + std::wstring sBorders; oStyle.m_pBorder.Unlock(); if (oStyle.m_pBorder.Empty()) { + wsTable.insert(35, L"table"); sBorders = L""; } else @@ -1190,31 +1182,47 @@ private: { std::wstring sColor = oStyle.m_pBorder.GetColorBottomSide(); std::wstring sSz = oStyle.m_pBorder.GetWidthBottomSideW(); - sBorders = L"" + - L"" + - L"" + - L"" + - L"" + - L""; + std::wstring sStyle = oStyle.m_pBorder.GetStyleBottomSide(); + + if (L"none" == sStyle) + wsTable.insert(35, oStyle.GetId()); + else + wsTable.insert(35, L"table"); + + sBorders = L"" + + L"" + + L"" + + L"" + + L"" + + L""; } else { + wsTable.insert(35, oStyle.GetId()); + std::wstring sColorLeftSide = oStyle.m_pBorder.GetColorLeftSide(); std::wstring sSzLeftSide = oStyle.m_pBorder.GetWidthLeftSideW(); + std::wstring sStyleLeftSide = oStyle.m_pBorder.GetStyleLeftSide(); std::wstring sColorTopSide = oStyle.m_pBorder.GetColorTopSide(); std::wstring sSzTopSide = oStyle.m_pBorder.GetWidthTopSideW(); + std::wstring sStyleTopSide = oStyle.m_pBorder.GetStyleLeftSide(); std::wstring sColorRightSide = oStyle.m_pBorder.GetColorRightSide(); std::wstring sSzRightSide = oStyle.m_pBorder.GetWidthRightSideW(); + std::wstring sStyleRightSide = oStyle.m_pBorder.GetStyleLeftSide(); std::wstring sColorBottomSide = oStyle.m_pBorder.GetColorBottomSide(); std::wstring sSzBottomSide = oStyle.m_pBorder.GetWidthBottomSideW(); + std::wstring sStyleBottomSide = oStyle.m_pBorder.GetStyleLeftSide(); - sBorders = L"" + - L"" + - L"" + - L""; + sBorders = L"" + + L"" + + L"" + + L""; } } + + oXml->WriteString(wsTable); + /* NSCSS::CCompiledStyle oStyleSetting = m_oStylesCalculator.GetCompiledStyle(sSelectors, true); oStyle = m_oStylesCalculator.GetCompiledStyle(sSelectors); diff --git a/HtmlFile2/test/main.cpp b/HtmlFile2/test/main.cpp index 35531ffbd3..5da1e5e732 100644 --- a/HtmlFile2/test/main.cpp +++ b/HtmlFile2/test/main.cpp @@ -97,7 +97,7 @@ int main() oParams.SetDescription(L"Description"); // Файл, который открываем - std::wstring sFile = NSFile::GetProcessDirectory() + L"/../../../examples/test.html"; + std::wstring sFile = NSFile::GetProcessDirectory() + L"/../../../examples/PrintRK.html"; CHtmlFile2 oFile; oFile.SetTmpDirectory(sOutputDirectory); nResConvert = (bMhtMode ? oFile.OpenMht(sFile, sOutputDirectory, &oParams) : oFile.OpenHtml(sFile, sOutputDirectory, &oParams));