mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-04-07 13:55:33 +08:00
Refactoring TextAssociation types
This commit is contained in:
@ -50,10 +50,10 @@ namespace NSDocxRenderer
|
||||
{
|
||||
enum TextAssociationType
|
||||
{
|
||||
TextAssociationTypeDefault = 0,
|
||||
TextAssociationTypeLine = 1,
|
||||
TextAssociationTypeNoFrames = 2,
|
||||
TextAssociationTypeBlock = 3
|
||||
TextAssociationTypeBlockChar = 0, // Каждый символ во фрейме
|
||||
TextAssociationTypeBlockLine = 1, // Каждая линия - параграф во фрейме. Линии могут объединяться в рамках одного блока.
|
||||
TextAssociationTypePlainLine = 2, // Каждая линия - параграф обычный
|
||||
TextAssociationTypePlainParagraph = 3 // Линии объединяются в параграфы
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -585,8 +585,7 @@ namespace NSDocxRenderer
|
||||
|
||||
switch (m_eTextAssociationType)
|
||||
{
|
||||
case TextAssociationTypeDefault:
|
||||
case TextAssociationTypeLine:
|
||||
case TextAssociationTypeBlockChar:
|
||||
{
|
||||
oWriter.WriteString(L"<w:pPr><w:framePr w:hAnchor=\"page\" w:vAnchor=\"page\" w:x=\"");
|
||||
oWriter.AddInt((int)(m_dLeft * c_dMMToDx));
|
||||
@ -595,7 +594,7 @@ namespace NSDocxRenderer
|
||||
oWriter.WriteString(L"\"/></w:pPr>");
|
||||
break;
|
||||
}
|
||||
case TextAssociationTypeBlock:
|
||||
case TextAssociationTypeBlockLine:
|
||||
{
|
||||
oWriter.WriteString(L"<w:pPr><w:framePr w:hAnchor=\"page\" w:vAnchor=\"page\" w:x=\"");
|
||||
oWriter.AddInt((int)(m_dLeft * c_dMMToDx));
|
||||
@ -604,7 +603,7 @@ namespace NSDocxRenderer
|
||||
oWriter.WriteString(L"\"/></w:pPr>");
|
||||
break;
|
||||
}
|
||||
case TextAssociationTypeNoFrames:
|
||||
case TextAssociationTypePlainLine:
|
||||
{
|
||||
oWriter.WriteString(L"<w:pPr><w:spacing w:before=\"");
|
||||
oWriter.AddInt((int)(m_dSpaceBefore * c_dMMToDx));
|
||||
|
||||
@ -79,7 +79,7 @@ namespace NSDocxRenderer
|
||||
m_dHeight = 0;
|
||||
|
||||
m_pCurrentLine = NULL;
|
||||
m_eTextAssociationType = TextAssociationTypeNoFrames;
|
||||
m_eTextAssociationType = TextAssociationTypePlainLine;
|
||||
|
||||
m_bIsDeleteTextClipPage = true;
|
||||
}
|
||||
@ -145,9 +145,9 @@ namespace NSDocxRenderer
|
||||
|
||||
void SetCurrentLineByBaseline(const double& dBaseLinePos)
|
||||
{
|
||||
if ((NULL == m_pCurrentLine) || (TextAssociationTypeDefault == m_eTextAssociationType))
|
||||
if ((NULL == m_pCurrentLine) || (TextAssociationTypeBlockChar == m_eTextAssociationType))
|
||||
{
|
||||
// пуста¤ (в плане текста) страница
|
||||
// пустая (в плане текста) страница
|
||||
m_pCurrentLine = new CTextLine();
|
||||
|
||||
m_pCurrentLine->m_dBaselinePos = dBaseLinePos;
|
||||
@ -548,8 +548,7 @@ namespace NSDocxRenderer
|
||||
|
||||
switch (m_eTextAssociationType)
|
||||
{
|
||||
case TextAssociationTypeDefault:
|
||||
case TextAssociationTypeLine:
|
||||
case TextAssociationTypeBlockChar:
|
||||
{
|
||||
size_t nCount = m_arTextLine.size();
|
||||
for (size_t i = 0; i < nCount; ++i)
|
||||
@ -572,59 +571,59 @@ namespace NSDocxRenderer
|
||||
m_arTextLine.clear();
|
||||
break;
|
||||
}
|
||||
case TextAssociationTypeBlock:
|
||||
case TextAssociationTypeBlockLine:
|
||||
{
|
||||
size_t nCount = m_arTextLine.size();
|
||||
|
||||
if (0 == nCount)
|
||||
break;
|
||||
|
||||
CTextLine* pFirstLine = m_arTextLine[0];
|
||||
|
||||
CParagraph* pParagraph = new CParagraph(m_eTextAssociationType);
|
||||
pParagraph->m_pManagerLight = &m_oManagerLight;
|
||||
pParagraph->m_bIsTextFrameProperties = true;
|
||||
|
||||
pParagraph->m_dLeft = pFirstLine->m_dX;
|
||||
pParagraph->m_dTop = pFirstLine->m_dBaselinePos - pFirstLine->m_dHeight + pFirstLine->m_dBaselineOffset;
|
||||
double dCurrentTop = pParagraph->m_dTop;
|
||||
|
||||
pParagraph->m_arLines.push_back(pFirstLine);
|
||||
|
||||
m_arParagraphs.push_back(pParagraph);
|
||||
|
||||
for (size_t i = 1; i < nCount; ++i)
|
||||
{
|
||||
size_t nCount = m_arTextLine.size();
|
||||
|
||||
if (0 == nCount)
|
||||
break;
|
||||
|
||||
CTextLine* pFirstLine = m_arTextLine[0];
|
||||
CTextLine* pTextLine = m_arTextLine[i];
|
||||
|
||||
CParagraph* pParagraph = new CParagraph(m_eTextAssociationType);
|
||||
pParagraph->m_pManagerLight = &m_oManagerLight;
|
||||
pParagraph->m_bIsTextFrameProperties = true;
|
||||
|
||||
pParagraph->m_dLeft = pFirstLine->m_dX;
|
||||
pParagraph->m_dTop = pFirstLine->m_dBaselinePos - pFirstLine->m_dHeight + pFirstLine->m_dBaselineOffset;
|
||||
double dCurrentTop = pParagraph->m_dTop;
|
||||
|
||||
pParagraph->m_arLines.push_back(pFirstLine);
|
||||
|
||||
m_arParagraphs.push_back(pParagraph);
|
||||
|
||||
for (size_t i = 1; i < nCount; ++i)
|
||||
if (((fabs(pTextLine->m_dBaselinePos - pTextLine->m_dHeight - pFirstLine->m_dBaselinePos) > STANDART_STRING_HEIGHT_MM) && (pTextLine->m_dX == pFirstLine->m_dX)) ||
|
||||
((pTextLine->m_dX != pFirstLine->m_dX) && (pTextLine->m_dBaselinePos != pFirstLine->m_dBaselinePos)))
|
||||
{
|
||||
CTextLine* pTextLine = m_arTextLine[i];
|
||||
|
||||
CParagraph* pParagraph = new CParagraph(m_eTextAssociationType);
|
||||
pParagraph->m_pManagerLight = &m_oManagerLight;
|
||||
pParagraph->m_bIsTextFrameProperties = true;
|
||||
|
||||
if (((fabs(pTextLine->m_dBaselinePos - pTextLine->m_dHeight - pFirstLine->m_dBaselinePos) > STANDART_STRING_HEIGHT_MM) && (pTextLine->m_dX == pFirstLine->m_dX)) ||
|
||||
((pTextLine->m_dX != pFirstLine->m_dX) && (pTextLine->m_dBaselinePos != pFirstLine->m_dBaselinePos)))
|
||||
{
|
||||
pParagraph->m_dLeft = pTextLine->m_dX;
|
||||
pParagraph->m_dTop = pTextLine->m_dBaselinePos - pTextLine->m_dHeight + pTextLine->m_dBaselineOffset;
|
||||
dCurrentTop = pParagraph->m_dTop;
|
||||
}
|
||||
else
|
||||
{
|
||||
pParagraph->m_dLeft = pFirstLine->m_dX;
|
||||
pParagraph->m_dTop = dCurrentTop;
|
||||
}
|
||||
|
||||
pFirstLine = pTextLine;
|
||||
|
||||
pParagraph->m_arLines.push_back(pTextLine);
|
||||
m_arParagraphs.push_back(pParagraph);
|
||||
pParagraph->m_dLeft = pTextLine->m_dX;
|
||||
pParagraph->m_dTop = pTextLine->m_dBaselinePos - pTextLine->m_dHeight + pTextLine->m_dBaselineOffset;
|
||||
dCurrentTop = pParagraph->m_dTop;
|
||||
}
|
||||
else
|
||||
{
|
||||
pParagraph->m_dLeft = pFirstLine->m_dX;
|
||||
pParagraph->m_dTop = dCurrentTop;
|
||||
}
|
||||
|
||||
// удалим все линии
|
||||
m_arTextLine.clear();
|
||||
break;
|
||||
pFirstLine = pTextLine;
|
||||
|
||||
pParagraph->m_arLines.push_back(pTextLine);
|
||||
m_arParagraphs.push_back(pParagraph);
|
||||
}
|
||||
case TextAssociationTypeNoFrames:
|
||||
|
||||
// удалим все линии
|
||||
m_arTextLine.clear();
|
||||
break;
|
||||
}
|
||||
case TextAssociationTypePlainLine:
|
||||
{
|
||||
SortElements(m_arTextLine);
|
||||
Merge(STANDART_STRING_HEIGHT_MM / 3);
|
||||
|
||||
@ -4500,7 +4500,7 @@ namespace NExtractTools
|
||||
|
||||
CDocxRenderer oDocxRenderer(pApplicationFonts);
|
||||
|
||||
NSDocxRenderer::TextAssociationType taType = NSDocxRenderer::TextAssociationTypeNoFrames;
|
||||
NSDocxRenderer::TextAssociationType taType = NSDocxRenderer::TextAssociationTypePlainLine;
|
||||
if (params.m_oTextParams)
|
||||
{
|
||||
InputParamsText* oTextParams = params.m_oTextParams;
|
||||
@ -4510,16 +4510,16 @@ namespace NExtractTools
|
||||
switch (*oTextParams->m_nTextAssociationType)
|
||||
{
|
||||
case 0:
|
||||
taType = NSDocxRenderer::TextAssociationTypeDefault;
|
||||
taType = NSDocxRenderer::TextAssociationTypeBlockChar;
|
||||
break;
|
||||
case 1:
|
||||
taType = NSDocxRenderer::TextAssociationTypeLine;
|
||||
taType = NSDocxRenderer::TextAssociationTypeBlockLine;
|
||||
break;
|
||||
case 2:
|
||||
taType = NSDocxRenderer::TextAssociationTypeNoFrames;
|
||||
taType = NSDocxRenderer::TextAssociationTypePlainLine;
|
||||
break;
|
||||
case 3:
|
||||
taType = NSDocxRenderer::TextAssociationTypeBlock;
|
||||
taType = NSDocxRenderer::TextAssociationTypePlainParagraph;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user