This commit is contained in:
Alexey Nagaev
2026-01-29 22:03:24 +03:00
parent 325c2d3000
commit 9b9da90dcc
3 changed files with 12 additions and 8 deletions

View File

@ -977,8 +977,10 @@ namespace NSDocxRenderer
eHorizontalCrossingType eHType)
{
double first_height = pFirstCont->m_dBotWithDescent - pFirstCont->m_dTopWithAscent;
bool bIf1 = eVType == eVerticalCrossingType::vctCurrentAboveNext ||
eVType == eVerticalCrossingType::vctCurrentInsideNext;
eVType == eVerticalCrossingType::vctCurrentInsideNext &&
pSecondCont->m_dBot - pFirstCont->m_dBot > first_height * 0.2;
bool bIf2 = eVType == eVerticalCrossingType::vctCurrentBelowNext;

View File

@ -66,6 +66,8 @@ namespace NSDocxRenderer
std::sort(m_arConts.begin(), m_arConts.end(), [] (const cont_ptr_t& a, const cont_ptr_t& b) {
if (!a) return false;
if (!b) return true;
if (fabs(a->m_dLeft - b->m_dLeft) < c_dTHE_SAME_STRING_X_PRECISION_MM)
return a->m_dRight < b->m_dRight;
return a->m_dLeft < b->m_dLeft;
});
@ -245,12 +247,12 @@ namespace NSDocxRenderer
else if (this_top < other_top && this_bot > other_bot)
return eVerticalCrossingType::vctCurrentOutsideNext;
else if (this_top < other_top && this_bot < other_bot &&
(this_bot >= other_top || fabs(this_bot - other_top) < c_dTHE_SAME_STRING_Y_PRECISION_MM))
else if (this_top < other_top && this_bot < other_bot && this_bot > other_top &&
this_bot - other_top > c_dLINE_DISTANCE_ERROR_MM)
return eVerticalCrossingType::vctCurrentAboveNext;
else if (this_top > other_top && this_bot > other_bot &&
(this_top <= other_bot || fabs(this_top - other_bot) < c_dTHE_SAME_STRING_Y_PRECISION_MM))
else if (this_top > other_top && this_bot > other_bot && this_top < other_bot &&
other_bot - this_top > c_dLINE_DISTANCE_ERROR_MM)
return eVerticalCrossingType::vctCurrentBelowNext;
else if (this_top == other_top && this_bot == other_bot &&
@ -267,10 +269,10 @@ namespace NSDocxRenderer
else if (fabs(this_bot - other_bot) < c_dTHE_SAME_STRING_Y_PRECISION_MM)
return eVerticalCrossingType::vctBottomBorderMatch;
else if (this_bot < other_top)
else if (other_top - this_bot > -c_dLINE_DISTANCE_ERROR_MM)
return eVerticalCrossingType::vctNoCrossingCurrentAboveNext;
else if (this_top > other_bot)
else if (this_top - other_bot > -c_dLINE_DISTANCE_ERROR_MM)
return eVerticalCrossingType::vctNoCrossingCurrentBelowNext;
else

View File

@ -24,7 +24,7 @@ constexpr double c_dPtToEMU = 12700.0;
constexpr double c_dDegreeToAngle = 60000.0;
const double c_dSTANDART_STRING_HEIGHT_MM = 4.2333333333333334;
const double c_dTHE_SAME_STRING_Y_PRECISION_MM = 0.03;
const double c_dTHE_SAME_STRING_Y_PRECISION_MM = 0.015;
const double c_dTHE_SAME_STRING_X_PRECISION_MM = 0.03;
const double c_dTHE_SAME_SPACING_ERROR = 0.1;
const double c_dLINE_DISTANCE_ERROR_MM = 0.3;