Merge branch 'hotfix/v9.2.0' into fix/bug-72300

This commit is contained in:
Kirill Polyakov
2025-10-27 19:37:13 +03:00
76 changed files with 1623 additions and 1086 deletions

View File

@ -523,7 +523,7 @@ namespace NSCSS
unStart = itFound.base() - arSelectors.cbegin();
std::vector<std::wstring> arNodes = CalculateAllNodes(arSelectors, unStart);
std::vector<std::wstring> arPrevNodes;
std::vector<std::wstring> arPrevNodes = CalculateAllNodes(arSelectors, 0, unStart);
bool bInTable = false;
for (size_t i = 0; i < unStart; ++i)
@ -592,11 +592,14 @@ namespace NSCSS
}
#endif
std::vector<std::wstring> CCssCalculator_Private::CalculateAllNodes(const std::vector<CNode> &arSelectors, unsigned int unStart)
std::vector<std::wstring> CCssCalculator_Private::CalculateAllNodes(const std::vector<CNode> &arSelectors, unsigned int unStart, unsigned int unEnd)
{
if (0 != unEnd && (unEnd < unStart || unEnd > arSelectors.size()))
return std::vector<std::wstring>();
std::vector<std::wstring> arNodes;
for (std::vector<CNode>::const_reverse_iterator oNode = arSelectors.rbegin(); oNode != arSelectors.rend() - unStart; ++oNode)
for (std::vector<CNode>::const_reverse_iterator oNode = arSelectors.rbegin() + ((0 != unEnd) ? (arSelectors.size() - unEnd) : 0); oNode != arSelectors.rend() - unStart; ++oNode)
{
if (!oNode->m_wsName.empty())
arNodes.push_back(oNode->m_wsName);

View File

@ -110,7 +110,7 @@ namespace NSCSS
void ClearPageData();
#endif
std::vector<std::wstring> CalculateAllNodes(const std::vector<CNode>& arSelectors, unsigned int unStart = 0);
std::vector<std::wstring> CalculateAllNodes(const std::vector<CNode>& arSelectors, unsigned int unStart = 0, unsigned int unEnd = 0);
std::vector<const CElement*> FindElements(std::vector<std::wstring>& arNodes, std::vector<std::wstring>& arNextNodes);
void AddStyles(const std::string& sStyle);

View File

@ -436,12 +436,13 @@ namespace NSCSS
return true;
}
bool CDigit::SetValue(const double& dValue, unsigned int unLevel, bool bHardMode)
bool CDigit::SetValue(const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel, bool bHardMode)
{
if (CHECK_CONDITIONS && !bHardMode)
return false;
m_oValue = dValue;
m_enUnitMeasure = enUnitMeasure;
m_oValue = dValue;
if (UINT_MAX == unLevel)
m_unLevel++;
@ -1760,9 +1761,9 @@ namespace NSCSS
return m_oWidth.SetValue(wsNewValue, unLevel, bHardMode);
}
bool CBorderSide::SetWidth(const double& dValue, unsigned int unLevel, bool bHardMode)
bool CBorderSide::SetWidth(const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel, bool bHardMode)
{
return m_oWidth.SetValue(dValue, unLevel, bHardMode);
return m_oWidth.SetValue(dValue, enUnitMeasure, unLevel, bHardMode);
}
bool CBorderSide::SetStyle(const std::wstring &wsValue, unsigned int unLevel, bool bHardMode)
@ -1938,14 +1939,14 @@ namespace NSCSS
return bResult;
}
bool CBorder::SetWidth(const double& dValue, unsigned int unLevel, bool bHardMode)
bool CBorder::SetWidth(const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel, bool bHardMode)
{
bool bResult = false;
if (m_oLeft .SetWidth(dValue, unLevel, bHardMode)) bResult = true;
if (m_oTop .SetWidth(dValue, unLevel, bHardMode)) bResult = true;
if (m_oRight .SetWidth(dValue, unLevel, bHardMode)) bResult = true;
if (m_oBottom.SetWidth(dValue, unLevel, bHardMode)) bResult = true;
if (m_oLeft .SetWidth(dValue, enUnitMeasure, unLevel, bHardMode)) bResult = true;
if (m_oTop .SetWidth(dValue, enUnitMeasure, unLevel, bHardMode)) bResult = true;
if (m_oRight .SetWidth(dValue, enUnitMeasure, unLevel, bHardMode)) bResult = true;
if (m_oBottom.SetWidth(dValue, enUnitMeasure, unLevel, bHardMode)) bResult = true;
return bResult;
}
@ -1989,9 +1990,9 @@ namespace NSCSS
return m_oLeft.SetWidth(wsValue, unLevel, bHardMode);
}
bool CBorder::SetWidthLeftSide(const double& dValue, unsigned int unLevel, bool bHardMode)
bool CBorder::SetWidthLeftSide(const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel, bool bHardMode)
{
return m_oLeft.SetWidth(dValue, unLevel, bHardMode);
return m_oLeft.SetWidth(dValue, enUnitMeasure, unLevel, bHardMode);
}
bool CBorder::SetStyleLeftSide(const std::wstring &wsValue, unsigned int unLevel, bool bHardMode)
@ -2014,9 +2015,9 @@ namespace NSCSS
return m_oTop.SetWidth(wsValue, unLevel, bHardMode);
}
bool CBorder::SetWidthTopSide(const double& dValue, unsigned int unLevel, bool bHardMode)
bool CBorder::SetWidthTopSide(const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel, bool bHardMode)
{
return m_oTop.SetWidth(dValue, unLevel, bHardMode);
return m_oTop.SetWidth(dValue, enUnitMeasure, unLevel, bHardMode);
}
bool CBorder::SetStyleTopSide(const std::wstring &wsValue, unsigned int unLevel, bool bHardMode)
@ -2039,9 +2040,9 @@ namespace NSCSS
return m_oRight.SetWidth(wsValue, unLevel, bHardMode);
}
bool CBorder::SetWidthRightSide(const double& dValue, unsigned int unLevel, bool bHardMode)
bool CBorder::SetWidthRightSide(const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel, bool bHardMode)
{
return m_oRight.SetWidth(dValue, unLevel, bHardMode);
return m_oRight.SetWidth(dValue, enUnitMeasure, unLevel, bHardMode);
}
bool CBorder::SetStyleRightSide(const std::wstring &wsValue, unsigned int unLevel, bool bHardMode)
@ -2064,9 +2065,9 @@ namespace NSCSS
return m_oBottom.SetWidth(wsValue, unLevel, bHardMode);
}
bool CBorder::SetWidthBottomSide(const double& dValue, unsigned int unLevel, bool bHardMode)
bool CBorder::SetWidthBottomSide(const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel, bool bHardMode)
{
return m_oBottom.SetWidth(dValue, unLevel, bHardMode);
return m_oBottom.SetWidth(dValue, enUnitMeasure, unLevel, bHardMode);
}
bool CBorder::SetStyleBottomSide(const std::wstring &wsValue, unsigned int unLevel, bool bHardMode)
@ -2365,39 +2366,49 @@ namespace NSCSS
return m_oTop.SetValue(wsValue, unLevel, bHardMode);
}
bool CIndent::SetTop(const double& dValue, unsigned int unLevel, bool bHardMode)
{
return m_oTop.SetValue(dValue, unLevel, bHardMode);
}
bool CIndent::SetRight(const std::wstring &wsValue, unsigned int unLevel, bool bHardMode)
{
return m_oRight.SetValue(wsValue, unLevel, bHardMode);
}
bool CIndent::SetRight(const double& dValue, unsigned int unLevel, bool bHardMode)
{
return m_oRight.SetValue(dValue, unLevel, bHardMode);
}
bool CIndent::SetBottom(const std::wstring &wsValue, unsigned int unLevel, bool bHardMode)
{
return m_oBottom.SetValue(wsValue, unLevel, bHardMode);
}
bool CIndent::SetBottom(const double& dValue, unsigned int unLevel, bool bHardMode)
{
return m_oBottom.SetValue(dValue, unLevel, bHardMode);
}
bool CIndent::SetLeft(const std::wstring &wsValue, unsigned int unLevel, bool bHardMode)
{
return m_oLeft.SetValue(wsValue, unLevel, bHardMode);
}
bool CIndent::SetLeft(const double& dValue, unsigned int unLevel, bool bHardMode)
bool CIndent::SetValues(const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel, bool bHardMode)
{
return m_oLeft.SetValue(dValue, unLevel, bHardMode);
const bool bTopResult = SetTop (dValue, enUnitMeasure, unLevel, bHardMode);
const bool bRightResult = SetRight (dValue, enUnitMeasure, unLevel, bHardMode);
const bool bBottomResult = SetBottom (dValue, enUnitMeasure, unLevel, bHardMode);
const bool bLeftResult = SetLeft (dValue, enUnitMeasure, unLevel, bHardMode);
return bTopResult || bRightResult || bBottomResult || bLeftResult;
}
bool CIndent::SetTop(const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel, bool bHardMode)
{
return m_oTop.SetValue(dValue, enUnitMeasure, unLevel, bHardMode);
}
bool CIndent::SetRight(const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel, bool bHardMode)
{
return m_oRight.SetValue(dValue, enUnitMeasure, unLevel, bHardMode);
}
bool CIndent::SetBottom(const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel, bool bHardMode)
{
return m_oBottom.SetValue(dValue, enUnitMeasure, unLevel, bHardMode);
}
bool CIndent::SetLeft(const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel, bool bHardMode)
{
return m_oLeft.SetValue(dValue, enUnitMeasure, unLevel, bHardMode);
}
void CIndent::UpdateAll(const double& dParentFontSize, const double& dCoreFontSize)
@ -2689,9 +2700,9 @@ namespace NSCSS
return m_oSize.SetValue(wsNewValue, unLevel, bHardMode);
}
bool CFont:: SetSize(const double& dValue, unsigned int unLevel, bool bHardMode)
bool CFont:: SetSize(const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel, bool bHardMode)
{
return m_oSize.SetValue(dValue, unLevel, bHardMode);
return m_oSize.SetValue(dValue, enUnitMeasure, unLevel, bHardMode);
}
bool CFont::SetLineHeight(const std::wstring &wsValue, unsigned int unLevel, bool bHardMode)
@ -3016,6 +3027,31 @@ namespace NSCSS
return m_oHeader.SetValue(wsValue, unLevel, bHardMode);
}
bool CPage::SetWidth(const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel, bool bHardMode)
{
return m_oWidth.SetValue(dValue, enUnitMeasure, unLevel, bHardMode);
}
bool CPage::SetHeight(const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel, bool bHardMode)
{
return m_oHeight.SetValue(dValue, enUnitMeasure, unLevel, bHardMode);
}
bool CPage::SetMargin(const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel, bool bHardMode)
{
return m_oMargin.SetValues(dValue, enUnitMeasure, unLevel, bHardMode);
}
bool CPage::SetFooter(const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel, bool bHardMode)
{
return m_oFooter.SetValue(dValue, enUnitMeasure, unLevel, bHardMode);
}
bool CPage::SetHeader(const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel, bool bHardMode)
{
return m_oHeader.SetValue(dValue, enUnitMeasure, unLevel, bHardMode);
}
const CDigit &CPage::GetWidth() const
{
return m_oWidth;

View File

@ -138,7 +138,7 @@ namespace NSCSS
bool SetValue(const std::wstring& wsValue, unsigned int unLevel = 0, bool bHardMode = true) override;
bool SetValue(const CDigit& oValue);
bool SetValue(const double& dValue, unsigned int unLevel = 0, bool bHardMode = true);
bool SetValue(const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel = 0, bool bHardMode = true);
bool Empty() const override;
bool Zero() const;
@ -474,7 +474,7 @@ namespace NSCSS
bool SetValue(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetWidth(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetWidth(const double& dValue, unsigned int unLevel, bool bHardMode = false);
bool SetWidth(const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel, bool bHardMode = false);
bool SetStyle(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetColor(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
@ -526,7 +526,7 @@ namespace NSCSS
bool SetSides(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetWidth(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetWidth(const double& dValue, unsigned int unLevel, bool bHardMode = false);
bool SetWidth(const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel, bool bHardMode = false);
bool SetStyle(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetColor(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetCollapse(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
@ -534,28 +534,28 @@ namespace NSCSS
//Left Side
bool SetLeftSide (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetWidthLeftSide (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetWidthLeftSide (const double& dValue, unsigned int unLevel, bool bHardMode = false);
bool SetWidthLeftSide (const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel, bool bHardMode = false);
bool SetStyleLeftSide (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetColorLeftSide (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
//Top Side
bool SetTopSide (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetWidthTopSide (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetWidthTopSide (const double& dValue, unsigned int unLevel, bool bHardMode = false);
bool SetWidthTopSide (const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel, bool bHardMode = false);
bool SetStyleTopSide (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetColorTopSide (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
//Right Side
bool SetRightSide (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetWidthRightSide (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetWidthRightSide (const double& dValue, unsigned int unLevel, bool bHardMode = false);
bool SetWidthRightSide (const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel, bool bHardMode = false);
bool SetStyleRightSide (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetColorRightSide (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
//Bottom Side
bool SetBottomSide (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetWidthBottomSide(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetWidthBottomSide(const double& dValue, unsigned int unLevel, bool bHardMode = false);
bool SetWidthBottomSide(const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel, bool bHardMode = false);
bool SetStyleBottomSide(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetColorBottomSide(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
@ -668,13 +668,15 @@ namespace NSCSS
bool SetValues (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetTop (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetTop (const double& dValue, unsigned int unLevel, bool bHardMode = false);
bool SetRight (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetRight (const double& dValue, unsigned int unLevel, bool bHardMode = false);
bool SetBottom (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetBottom (const double& dValue, unsigned int unLevel, bool bHardMode = false);
bool SetLeft (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetLeft (const double& dValue, unsigned int unLevel, bool bHardMode = false);
bool SetValues (const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel, bool bHardMode = false);
bool SetTop (const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel, bool bHardMode = false);
bool SetRight (const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel, bool bHardMode = false);
bool SetBottom (const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel, bool bHardMode = false);
bool SetLeft (const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel, bool bHardMode = false);
void UpdateAll (const double& dParentFontSize, const double& dCoreFontSize);
void UpdateTop (const double& dParentFontSize, const double& dCoreFontSize);
@ -687,6 +689,9 @@ namespace NSCSS
const CDigit& GetBottom() const;
const CDigit& GetLeft () const;
bool GetAfterAutospacing () const;
bool GetBeforeAutospacing() const;
bool Empty() const;
bool Zero() const;
@ -714,7 +719,7 @@ namespace NSCSS
bool SetValue (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetSize (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetSize (const double& dValue, unsigned int unLevel, bool bHardMode = false);
bool SetSize (const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel, bool bHardMode = false);
bool SetLineHeight (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetFamily (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetStretch (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
@ -764,6 +769,12 @@ namespace NSCSS
bool SetFooter (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetHeader (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetWidth (const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel, bool bHardMode = false);
bool SetHeight (const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel, bool bHardMode = false);
bool SetMargin (const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel, bool bHardMode = false);
bool SetFooter (const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel, bool bHardMode = false);
bool SetHeader (const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel, bool bHardMode = false);
const CDigit& GetWidth() const;
const CDigit& GetHeight() const;
const CIndent& GetMargin() const;

View File

@ -341,14 +341,14 @@ namespace NSCSS
sSpacingValue.reserve(128);
if (!oStyle.m_oMargin.GetTop().Empty() && !oStyle.m_oMargin.GetTop().Zero())
sSpacingValue += L"w:before=\"" + std::to_wstring(VALUE_TO_INT(oStyle.m_oMargin.GetTop(), NSCSS::Twips)) + L"\" w:beforeAutospacing=\"0\"";
sSpacingValue += L"w:before=\"" + std::to_wstring(VALUE_TO_INT(oStyle.m_oMargin.GetTop(), NSCSS::Twips)) + L"\" w:beforeAutospacing=\"1\"";
else if (oStyle.m_oMargin.GetBottom().Zero() || bInTable)
sSpacingValue += L"w:before=\"0\" w:beforeAutospacing=\"0\"";
sSpacingValue += L"w:before=\"0\" w:beforeAutospacing=\"1\"";
if (!oStyle.m_oMargin.GetBottom().Empty() && !oStyle.m_oMargin.GetBottom().Zero())
sSpacingValue += L" w:after=\"" + std::to_wstring(VALUE_TO_INT(oStyle.m_oMargin.GetBottom(), NSCSS::Twips)) + L"\" w:afterAutospacing=\"0\"";
sSpacingValue += L" w:after=\"" + std::to_wstring(VALUE_TO_INT(oStyle.m_oMargin.GetBottom(), NSCSS::Twips)) + L"\" w:afterAutospacing=\"1\"";
else if (oStyle.m_oMargin.GetBottom().Zero() || bInTable)
sSpacingValue += L" w:after=\"0\" w:afterAutospacing=\"0\"";
sSpacingValue += L" w:after=\"0\" w:afterAutospacing=\"1\"";
if (!oStyle.m_oFont.GetLineHeight().Empty() && !oStyle.m_oFont.GetLineHeight().Zero())
{