static void ME_WrapEndParagraph(ME_WrapContext *wc, ME_DisplayItem *p) { ME_DisplayItem *para = wc->pPara; PARAFORMAT2 *pFmt = para->member.para.pFmt; if (wc->pRowStart) ME_InsertRowStart(wc, p); if (wc->context->editor->bEmulateVersion10 && /* v1.0 - 3.0 */ pFmt->dwMask & PFM_TABLE && pFmt->wEffects & PFE_TABLE) { /* ME_BeginRow was called an extra time for the paragraph, and it shifts the * text down by one pixel for the border, so fix up the wrap context. */ wc->pt.y--; } /* p = para->next; while(p) { if (p->type == diParagraph || p->type == diTextEnd) return; if (p->type == diRun) { ME_Run *run = &p->member.run; TRACE("%s - (%d, %d)\n", debugstr_run(run), run->pt.x, run->pt.y); } p = p->next; } */ }
static void ME_WrapEndParagraph(ME_WrapContext *wc, ME_DisplayItem *p) { if (wc->pRowStart) ME_InsertRowStart(wc, p->next); /* p = p->member.para.prev_para->next; while(p) { if (p->type == diParagraph || p->type == diTextEnd) return; if (p->type == diRun) { ME_Run *run = &p->member.run; TRACE("%s - (%d, %d)\n", debugstr_w(run->strText->szData), run->pt.x, run->pt.y); } p = p->next; } */ }
static ME_DisplayItem *ME_WrapHandleRun(ME_WrapContext *wc, ME_DisplayItem *p) { ME_DisplayItem *pp; ME_Run *run; int len; assert(p->type == diRun); if (!wc->pRowStart) wc->pRowStart = p; run = &p->member.run; run->pt.x = wc->pt.x; run->pt.y = wc->pt.y; ME_WrapSizeRun(wc, p); len = run->len; if (wc->bOverflown) /* just skipping final whitespaces */ { /* End paragraph run can't overflow to the next line by itself. */ if (run->nFlags & MERF_ENDPARA) return p->next; if (run->nFlags & MERF_WHITESPACE) { wc->pt.x += run->nWidth; /* skip runs consisting of only whitespaces */ return p->next; } if (run->nFlags & MERF_STARTWHITE) { /* try to split the run at the first non-white char */ int black; black = find_non_whitespace( get_text( run, 0 ), run->len, 0 ); if (black) { wc->bOverflown = FALSE; pp = split_run_extents(wc, p, black); calc_run_extent(wc->context, &wc->pPara->member.para, wc->nRow ? wc->nLeftMargin : wc->nFirstMargin, &pp->member.run); ME_InsertRowStart(wc, pp); return pp; } } /* black run: the row goes from pRowStart to the previous run */ ME_InsertRowStart(wc, p); return p; } /* simply end the current row and move on to next one */ if (run->nFlags & MERF_ENDROW) { p = p->next; ME_InsertRowStart(wc, p); return p; } /* will current run fit? */ if (wc->bWordWrap && wc->pt.x + run->nWidth - wc->context->pt.x > wc->nAvailWidth) { int loc = wc->context->pt.x + wc->nAvailWidth - wc->pt.x; /* total white run ? */ if (run->nFlags & MERF_WHITESPACE) { /* let the overflow logic handle it */ wc->bOverflown = TRUE; return p; } /* TAB: we can split before */ if (run->nFlags & MERF_TAB) { wc->bOverflown = TRUE; if (wc->pRowStart == p) /* Don't split before the start of the run, or we will get an * endless loop. */ return p->next; else return p; } /* graphics: we can split before, if run's width is smaller than row's width */ if ((run->nFlags & MERF_GRAPHICS) && run->nWidth <= wc->nAvailWidth) { wc->bOverflown = TRUE; return p; } /* can we separate out the last spaces ? (to use overflow logic later) */ if (run->nFlags & MERF_ENDWHITE) { /* we aren't sure if it's *really* necessary, it's a good start however */ int black = reverse_find_non_whitespace( get_text( run, 0 ), len ); split_run_extents(wc, p, black); /* handle both parts again */ return p; } /* determine the split point by backtracking */ pp = ME_SplitByBacktracking(wc, p, loc); if (pp == wc->pRowStart) { if (run->nFlags & MERF_STARTWHITE) { /* We had only spaces so far, so we must be on the first line of the * paragraph (or the first line after MERF_ENDROW forced the line * break within the paragraph), since no other lines of the paragraph * start with spaces. */ /* The lines will only contain spaces, and the rest of the run will * overflow onto the next line. */ wc->bOverflown = TRUE; return p; } /* Couldn't split the first run, possible because we have a large font * with a single character that caused an overflow. */ wc->pt.x += run->nWidth; return p->next; } if (p != pp) /* found a suitable split point */ { wc->bOverflown = TRUE; return pp; } /* we detected that it's best to split on start of this run */ if (wc->bOverflown) return pp; ERR("failure!\n"); /* not found anything - writing over margins is the only option left */ } if ((run->nFlags & (MERF_SPLITTABLE | MERF_STARTWHITE)) || ((run->nFlags & (MERF_GRAPHICS|MERF_TAB)) && (p != wc->pRowStart))) { wc->pLastSplittableRun = p; } wc->pt.x += run->nWidth; return p->next; }
static ME_DisplayItem *ME_WrapHandleRun(ME_WrapContext *wc, ME_DisplayItem *p) { ME_DisplayItem *pp; ME_Run *run; int len; assert(p->type == diRun); if (!wc->pRowStart) wc->pRowStart = p; run = &p->member.run; run->pt.x = wc->pt.x; run->pt.y = wc->pt.y; ME_WrapSizeRun(wc, p); len = ME_StrVLen(run->strText); if (wc->bOverflown) /* just skipping final whitespaces */ { if (run->nFlags & (MERF_WHITESPACE|MERF_TAB)) { p->member.run.nFlags |= MERF_SKIPPED; /* wc->pt.x += run->nWidth; */ /* skip runs consisting of only whitespaces */ return p->next; } if (run->nFlags & MERF_STARTWHITE) { /* try to split the run at the first non-white char */ int black; black = ME_FindNonWhitespaceV(run->strText, 0); if (black) { wc->bOverflown = FALSE; pp = ME_SplitRun(wc, p, black); p->member.run.nFlags |= MERF_SKIPPED; ME_InsertRowStart(wc, pp); return pp; } } /* black run: the row goes from pRowStart to the previous run */ ME_InsertRowStart(wc, p); return p; } /* simply end the current row and move on to next one */ if (run->nFlags & MERF_ENDROW) { p = p->next; ME_InsertRowStart(wc, p); return p; } /* we're not at the end of the row */ if (run->nFlags & MERF_TAB) { /* force recomputation of tabs' size as it depends on position */ ME_CalcRunExtent(wc->context, &ME_GetParagraph(p)->member.para, wc->nRow ? wc->nLeftMargin : wc->nFirstMargin, run); } /* will current run fit? */ if (wc->pt.x + run->nWidth > wc->nAvailWidth) { int loc = wc->nAvailWidth - wc->pt.x; /* total white run ? */ if (run->nFlags & MERF_WHITESPACE) { /* let the overflow logic handle it */ wc->bOverflown = TRUE; return p; } /* TAB: we can split before */ if (run->nFlags & MERF_TAB) { wc->bOverflown = TRUE; return p; } /* graphics: we can split before, if run's width is smaller than row's width */ if ((run->nFlags & MERF_GRAPHICS) && run->nWidth <= wc->nAvailWidth) { wc->bOverflown = TRUE; return p; } /* can we separate out the last spaces ? (to use overflow logic later) */ if (run->nFlags & MERF_ENDWHITE) { /* we aren't sure if it's *really* necessary, it's a good start however */ int black = ME_ReverseFindNonWhitespaceV(run->strText, len); ME_SplitRun(wc, p, black); /* handle both parts again */ return p; } /* determine the split point by backtracking */ pp = ME_SplitByBacktracking(wc, p, loc); if (pp == wc->pRowStart) { /* we had only spaces so far, entire content can be omitted */ wc->pt.x = 0; return p->next; } if (p != pp) /* found a suitable split point */ { wc->bOverflown = TRUE; return pp; } /* we detected that it's best to split on start of this run */ if (wc->bOverflown) return pp; ERR("failure!\n"); /* not found anything - writing over margins is the only option left */ } if ((run->nFlags & (MERF_SPLITTABLE | MERF_STARTWHITE)) || ((run->nFlags & (MERF_GRAPHICS|MERF_TAB)) && (p != wc->pRowStart))) { wc->pLastSplittableRun = p; wc->ptLastSplittableRun = wc->pt; } wc->pt.x += run->nWidth; return p->next; }