Fix more bugs

This commit is contained in:
Alexey Nagaev
2026-01-29 22:26:37 +03:00
parent 9b9da90dcc
commit f4867bd9f9
3 changed files with 33 additions and 34 deletions

View File

@ -208,34 +208,34 @@ namespace NSDocxRenderer
return eVerticalCrossingType::vctCurrentInsideNext;
else if (this_top < other_top && this_bot > other_bot)
return eVerticalCrossingType::vctCurrentOutsideNext;
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))
return eVerticalCrossingType::vctCurrentAboveNext;
else if (this_top < other_top && this_bot < other_bot && this_bot > other_top &&
this_bot - other_top > c_dOVERLAP_TEXT_LINE_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))
return eVerticalCrossingType::vctCurrentBelowNext;
else if (this_top > other_top && this_bot > other_bot && this_top < other_bot &&
other_bot - this_top > c_dOVERLAP_TEXT_LINE_ERROR_MM)
return eVerticalCrossingType::vctCurrentBelowNext;
else if (this_top == other_top && this_bot == other_bot)
return eVerticalCrossingType::vctDublicate;
else if (fabs(this_top - other_top) < c_dTHE_SAME_STRING_Y_PRECISION_MM &&
fabs(this_bot - other_bot) < c_dTHE_SAME_STRING_Y_PRECISION_MM)
return eVerticalCrossingType::vctTopAndBottomBordersMatch;
return eVerticalCrossingType::vctTopAndBottomBordersMatch;
else if (fabs(this_top - other_top) < c_dTHE_SAME_STRING_Y_PRECISION_MM)
return eVerticalCrossingType::vctTopBorderMatch;
return eVerticalCrossingType::vctTopBorderMatch;
else if (fabs(this_bot - other_bot) < c_dTHE_SAME_STRING_Y_PRECISION_MM)
return eVerticalCrossingType::vctBottomBorderMatch;
return eVerticalCrossingType::vctBottomBorderMatch;
else if (this_bot < other_top)
return eVerticalCrossingType::vctNoCrossingCurrentAboveNext;
else if (other_top - this_bot > -c_dOVERLAP_TEXT_LINE_ERROR_MM)
return eVerticalCrossingType::vctNoCrossingCurrentAboveNext;
else if (this_top > other_bot)
return eVerticalCrossingType::vctNoCrossingCurrentBelowNext;
else if (this_top - other_bot > -c_dOVERLAP_TEXT_LINE_ERROR_MM)
return eVerticalCrossingType::vctNoCrossingCurrentBelowNext;
else
return eVerticalCrossingType::vctUnknown;
@ -894,12 +894,12 @@ namespace NSDocxRenderer
eHorizontalCrossingType eHType)
{
//Условие пересечения по вертикали
bool bIf1 = eVType == eVerticalCrossingType::vctCurrentAboveNext; //текущий cont выше
bool bIf2 = eVType == eVerticalCrossingType::vctCurrentBelowNext; //текущий cont ниже
bool bIf1 = eVType == eVerticalCrossingType::vctCurrentAboveNext;
bool bIf2 = eVType == eVerticalCrossingType::vctCurrentBelowNext;
//Условие пересечения по горизонтали
bool bIf3 = eHType == eHorizontalCrossingType::hctCurrentLeftOfNext; //текущий cont левее
bool bIf4 = eHType == eHorizontalCrossingType::hctCurrentRightOfNext; //текущий cont правее
bool bIf3 = eHType == eHorizontalCrossingType::hctCurrentLeftOfNext;
bool bIf4 = eHType == eHorizontalCrossingType::hctCurrentRightOfNext;
//Размеры шрифта и текст должны бать одинаковыми
bool bIf5 = pFirstCont->m_pFontStyle->dFontSize == pSecondCont->m_pFontStyle->dFontSize;
@ -915,9 +915,7 @@ namespace NSDocxRenderer
bool bIf11 = pFirstCont->m_pFontStyle->oBrush.Color1 == c_iGreyColor2;
bool bIf12 = pSecondCont->m_pFontStyle->oBrush.Color1 == c_iGreyColor2;
//note Каждый символ с Emboss или Engrave разбиваются на 3 символа с разными цветами
//note Логика подобрана для конкретного примера - возможно нужно будет ее обобщить.
//todo существует проблема неправильного определением FontEffects с физически пересекаемыми строчками - файл generaltest.pdf p.14
// каждый символ с Emboss или Engrave разбиваются на 3 символа с разными цветами
if (bIf5 && bIf6)
{
if (bIf12 && pFirstCont->m_bIsEmbossPresent)

View File

@ -245,15 +245,15 @@ namespace NSDocxRenderer
return eVerticalCrossingType::vctCurrentInsideNext;
else if (this_top < other_top && this_bot > other_bot)
return eVerticalCrossingType::vctCurrentOutsideNext;
return eVerticalCrossingType::vctCurrentOutsideNext;
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;
this_bot - other_top > c_dOVERLAP_TEXT_LINE_ERROR_MM)
return eVerticalCrossingType::vctCurrentAboveNext;
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;
other_bot - this_top > c_dOVERLAP_TEXT_LINE_ERROR_MM)
return eVerticalCrossingType::vctCurrentBelowNext;
else if (this_top == other_top && this_bot == other_bot &&
m_dLeft == pLine->m_dLeft && m_dRight == pLine->m_dRight)
@ -261,22 +261,22 @@ namespace NSDocxRenderer
else if (fabs(this_top - other_top) < c_dTHE_SAME_STRING_Y_PRECISION_MM &&
fabs(this_bot - other_bot) < c_dTHE_SAME_STRING_Y_PRECISION_MM)
return eVerticalCrossingType::vctTopAndBottomBordersMatch;
return eVerticalCrossingType::vctTopAndBottomBordersMatch;
else if (fabs(this_top - other_top) < c_dTHE_SAME_STRING_Y_PRECISION_MM)
return eVerticalCrossingType::vctTopBorderMatch;
return eVerticalCrossingType::vctTopBorderMatch;
else if (fabs(this_bot - other_bot) < c_dTHE_SAME_STRING_Y_PRECISION_MM)
return eVerticalCrossingType::vctBottomBorderMatch;
return eVerticalCrossingType::vctBottomBorderMatch;
else if (other_top - this_bot > -c_dLINE_DISTANCE_ERROR_MM)
return eVerticalCrossingType::vctNoCrossingCurrentAboveNext;
else if (other_top - this_bot > -c_dOVERLAP_TEXT_LINE_ERROR_MM)
return eVerticalCrossingType::vctNoCrossingCurrentAboveNext;
else if (this_top - other_bot > -c_dLINE_DISTANCE_ERROR_MM)
return eVerticalCrossingType::vctNoCrossingCurrentBelowNext;
else if (this_top - other_bot > -c_dOVERLAP_TEXT_LINE_ERROR_MM)
return eVerticalCrossingType::vctNoCrossingCurrentBelowNext;
else
return eVerticalCrossingType::vctUnknown;
return eVerticalCrossingType::vctUnknown;
}
void CTextLine::RecalcWithNewItem(const CContText* pCont)

View File

@ -28,6 +28,7 @@ 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;
const double c_dOVERLAP_TEXT_LINE_ERROR_MM = 0.5;
const double c_dERROR_OF_PARAGRAPH_BORDERS_MM = 1.0;
const double c_dCENTER_POSITION_ERROR_MM = 1.5;
const double c_dTHE_STRING_X_PRECISION_MM = 0.5;