Commit 70a2fe58 authored by Sergio Gómez Del Real's avatar Sergio Gómez Del Real Committed by Alexandre Julliard

riched20: Move y-adjust to its own function.

parent 3c0b519b
......@@ -980,38 +980,17 @@ static void ME_MarkRepaintEnd(ME_DisplayItem *para,
*repaint_end = para;
}
BOOL ME_WrapMarkedParagraphs(ME_TextEditor *editor)
static void adjust_para_y(ME_DisplayItem *item, ME_Context *c, ME_DisplayItem *repaint_start, ME_DisplayItem *repaint_end)
{
ME_DisplayItem *item;
ME_Context c;
int totalWidth = 0;
ME_DisplayItem *repaint_start = NULL, *repaint_end = NULL;
ME_InitContext(&c, editor, ITextHost_TxGetDC(editor->texthost));
c.pt.x = 0;
item = editor->pBuffer->pFirst->next;
while(item != editor->pBuffer->pLast) {
BOOL bRedraw = FALSE;
assert(item->type == diParagraph);
if ((item->member.para.nFlags & MEPF_REWRAP)
|| (item->member.para.pt.y != c.pt.y))
bRedraw = TRUE;
item->member.para.pt = c.pt;
ME_WrapTextParagraph(&c, item);
if (bRedraw)
ME_MarkRepaintEnd(item, &repaint_start, &repaint_end);
if (item->member.para.nFlags & MEPF_ROWSTART)
{
ME_DisplayItem *cell = ME_FindItemFwd(item, diCell);
ME_DisplayItem *endRowPara;
int borderWidth = 0;
cell->member.cell.pt = c.pt;
cell->member.cell.pt = c->pt;
/* Offset the text by the largest top border width. */
while (cell->member.cell.next_cell) {
while (cell->member.cell.next_cell)
{
borderWidth = max(borderWidth, cell->member.cell.border.top.width);
cell = cell->member.cell.next_cell;
}
......@@ -1019,19 +998,20 @@ BOOL ME_WrapMarkedParagraphs(ME_TextEditor *editor)
assert(endRowPara->member.para.nFlags & MEPF_ROWEND);
if (borderWidth > 0)
{
borderWidth = max(ME_twips2pointsY(&c, borderWidth), 1);
while (cell) {
borderWidth = max(ME_twips2pointsY(c, borderWidth), 1);
while (cell)
{
cell->member.cell.yTextOffset = borderWidth;
cell = cell->member.cell.prev_cell;
}
c.pt.y += borderWidth;
c->pt.y += borderWidth;
}
if (endRowPara->member.para.fmt.dxStartIndent > 0)
{
int dxStartIndent = endRowPara->member.para.fmt.dxStartIndent;
cell = ME_FindItemFwd(item, diCell);
cell->member.cell.pt.x += ME_twips2pointsX(&c, dxStartIndent);
c.pt.x = cell->member.cell.pt.x;
cell->member.cell.pt.x += ME_twips2pointsX(c, dxStartIndent);
c->pt.x = cell->member.cell.pt.x;
}
}
else if (item->member.para.nFlags & MEPF_ROWEND)
......@@ -1050,7 +1030,7 @@ BOOL ME_WrapMarkedParagraphs(ME_TextEditor *editor)
bottomBorder = max(bottomBorder, cell->member.cell.border.bottom.width);
cell = cell->member.cell.prev_cell;
}
bottomBorder = ME_twips2pointsY(&c, bottomBorder);
bottomBorder = ME_twips2pointsY(c, bottomBorder);
cell = ME_FindItemBack(item, diCell);
}
prevHeight = cell->member.cell.nHeight;
......@@ -1067,15 +1047,16 @@ BOOL ME_WrapMarkedParagraphs(ME_TextEditor *editor)
/* Also set the height of the start row paragraph */
startRowPara = ME_FindItemBack(cell, diParagraph);
startRowPara->member.para.nHeight = nHeight;
c.pt.x = startRowPara->member.para.pt.x;
c.pt.y = cell->member.cell.pt.y + nHeight;
c->pt.x = startRowPara->member.para.pt.x;
c->pt.y = cell->member.cell.pt.y + nHeight;
if (prevHeight < nHeight)
{
/* The height of the cells has grown, so invalidate the bottom of
* the cells. */
ME_MarkRepaintEnd(item, &repaint_start, &repaint_end);
cell = ME_FindItemBack(item, diCell);
while (cell) {
while (cell)
{
ME_MarkRepaintEnd(ME_FindItemBack(cell, diParagraph), &repaint_start, &repaint_end);
cell = cell->member.cell.prev_cell;
}
......@@ -1086,31 +1067,58 @@ BOOL ME_WrapMarkedParagraphs(ME_TextEditor *editor)
{
/* The next paragraph is in the next cell in the table row. */
ME_Cell *cell = &item->member.para.pCell->member.cell;
cell->nHeight = c.pt.y + item->member.para.nHeight - cell->pt.y;
cell->nHeight = c->pt.y + item->member.para.nHeight - cell->pt.y;
/* Propagate the largest height to the end so that it can be easily
* sent back to all the cells at the end of the row. */
if (cell->prev_cell)
cell->nHeight = max(cell->nHeight, cell->prev_cell->member.cell.nHeight);
c.pt.x = cell->pt.x + cell->nWidth;
c.pt.y = cell->pt.y;
cell->next_cell->member.cell.pt = c.pt;
c->pt.x = cell->pt.x + cell->nWidth;
c->pt.y = cell->pt.y;
cell->next_cell->member.cell.pt = c->pt;
if (!(item->member.para.next_para->member.para.nFlags & MEPF_ROWEND))
c.pt.y += cell->yTextOffset;
c->pt.y += cell->yTextOffset;
}
else
{
if (item->member.para.pCell) {
if (item->member.para.pCell)
{
/* Next paragraph in the same cell. */
c.pt.x = item->member.para.pCell->member.cell.pt.x;
} else {
/* Normal paragraph */
c.pt.x = 0;
c->pt.x = item->member.para.pCell->member.cell.pt.x;
}
c.pt.y += item->member.para.nHeight;
else
/* Normal paragraph */
c->pt.x = 0;
c->pt.y += item->member.para.nHeight;
}
}
BOOL ME_WrapMarkedParagraphs(ME_TextEditor *editor)
{
ME_DisplayItem *item;
ME_Context c;
int totalWidth = 0;
ME_DisplayItem *repaint_start = NULL, *repaint_end = NULL;
ME_InitContext(&c, editor, ITextHost_TxGetDC(editor->texthost));
c.pt.x = 0;
item = editor->pBuffer->pFirst->next;
while(item != editor->pBuffer->pLast) {
BOOL bRedraw = FALSE;
assert(item->type == diParagraph);
if ((item->member.para.nFlags & MEPF_REWRAP)
|| (item->member.para.pt.y != c.pt.y))
bRedraw = TRUE;
item->member.para.pt = c.pt;
ME_WrapTextParagraph(&c, item);
if (bRedraw)
ME_MarkRepaintEnd(item, &repaint_start, &repaint_end);
adjust_para_y(item, &c, repaint_start, repaint_end);
totalWidth = max(totalWidth, item->member.para.nWidth);
item = item->member.para.next_para;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment