2 * RichEdit - operations on runs (diRun, rectangular pieces of paragraphs).
3 * Splitting/joining runs. Adjusting offsets after deleting/adding content.
4 * Character/pixel conversions.
6 * Copyright 2004 by Krzysztof Foltman
7 * Copyright 2006 by Phil Krylov
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
26 WINE_DEFAULT_DEBUG_CHANNEL(richedit);
27 WINE_DECLARE_DEBUG_CHANNEL(richedit_check);
28 WINE_DECLARE_DEBUG_CHANNEL(richedit_lists);
30 int ME_CanJoinRuns(ME_Run *run1, ME_Run *run2)
32 if ((run1->nFlags | run2->nFlags) & MERF_NOJOIN)
34 if (run1->style != run2->style)
36 if ((run1->nFlags & MERF_STYLEFLAGS) != (run2->nFlags & MERF_STYLEFLAGS))
41 void ME_SkipAndPropagateCharOffset(ME_DisplayItem *p, int shift)
43 p = ME_FindItemFwd(p, diRunOrParagraphOrEnd);
45 ME_PropagateCharOffset(p, shift);
48 void ME_PropagateCharOffset(ME_DisplayItem *p, int shift)
50 if (p->type == diRun) /* propagate in all runs in this para */
52 TRACE("PropagateCharOffset(%s, %d)\n", debugstr_w(p->member.run.strText->szData), shift);
54 p->member.run.nCharOfs += shift;
55 assert(p->member.run.nCharOfs >= 0);
56 p = ME_FindItemFwd(p, diRunOrParagraphOrEnd);
57 } while(p->type == diRun);
59 if (p->type == diParagraph) /* propagate in all next paras */
62 p->member.para.nCharOfs += shift;
63 assert(p->member.para.nCharOfs >= 0);
64 p = p->member.para.next_para;
65 } while(p->type == diParagraph);
67 if (p->type == diTextEnd)
69 p->member.para.nCharOfs += shift;
70 assert(p->member.para.nCharOfs >= 0);
74 void ME_CheckCharOffsets(ME_TextEditor *editor)
76 ME_DisplayItem *p = editor->pBuffer->pFirst;
77 int ofs = 0, ofsp = 0;
78 if(TRACE_ON(richedit_lists))
80 TRACE_(richedit_lists)("---\n");
81 ME_DumpDocument(editor->pBuffer);
84 p = ME_FindItemFwd(p, diRunOrParagraphOrEnd);
87 TRACE_(richedit_check)("tend, real ofsp = %d, counted = %d\n", p->member.para.nCharOfs, ofsp+ofs);
88 assert(ofsp+ofs == p->member.para.nCharOfs);
91 TRACE_(richedit_check)("para, real ofsp = %d, counted = %d\n", p->member.para.nCharOfs, ofsp+ofs);
92 assert(ofsp+ofs == p->member.para.nCharOfs);
93 ofsp = p->member.para.nCharOfs;
97 TRACE_(richedit_check)("run, real ofs = %d (+ofsp = %d), counted = %d, len = %d, txt = \"%s\", flags=%08x, fx&mask = %08lx\n",
98 p->member.run.nCharOfs, p->member.run.nCharOfs+ofsp, ofsp+ofs,
99 p->member.run.strText->nLen, debugstr_w(p->member.run.strText->szData),
100 p->member.run.nFlags,
101 p->member.run.style->fmt.dwMask & p->member.run.style->fmt.dwEffects);
102 assert(ofs == p->member.run.nCharOfs);
103 if (p->member.run.nFlags & MERF_ENDPARA)
104 ofs += (editor->bEmulateVersion10 ? 2 : 1);
106 ofs += ME_StrLen(p->member.run.strText);
114 int ME_CharOfsFromRunOfs(ME_TextEditor *editor, ME_DisplayItem *pRun, int nOfs)
116 ME_DisplayItem *pPara;
118 assert(pRun->type == diRun);
119 assert(pRun->member.run.nCharOfs != -1);
121 pPara = ME_FindItemBack(pRun, diParagraph);
123 assert(pPara->type==diParagraph);
124 return pPara->member.para.nCharOfs + pRun->member.run.nCharOfs
125 + ME_VPosToPos(pRun->member.run.strText, nOfs);
128 void ME_CursorFromCharOfs(ME_TextEditor *editor, int nCharOfs, ME_Cursor *pCursor)
130 ME_RunOfsFromCharOfs(editor, nCharOfs, &pCursor->pRun, &pCursor->nOffset);
133 void ME_RunOfsFromCharOfs(ME_TextEditor *editor, int nCharOfs, ME_DisplayItem **ppRun, int *pOfs)
135 ME_DisplayItem *pPara;
138 pPara = editor->pBuffer->pFirst->member.para.next_para;
142 while (pPara->type == diParagraph)
144 nParaOfs = pPara->member.para.nCharOfs;
145 assert(nCharOfs >= nParaOfs);
147 if (nCharOfs < pPara->member.para.next_para->member.para.nCharOfs)
150 *ppRun = ME_FindItemFwd(pPara, diRun);
152 while (!((*ppRun)->member.run.nFlags & MERF_ENDPARA))
154 ME_DisplayItem *pNext = ME_FindItemFwd(*ppRun, diRun);
156 assert(pNext->type == diRun);
157 if (nCharOfs < nParaOfs + pNext->member.run.nCharOfs) {
158 *pOfs = ME_PosToVPos((*ppRun)->member.run.strText,
159 nCharOfs - nParaOfs - (*ppRun)->member.run.nCharOfs);
164 /* the handling of bEmulateVersion10 may be a source of many bugs, I'm afraid */
165 eollen = (editor->bEmulateVersion10 ? 2 : 1);
166 if (nCharOfs >= nParaOfs + (*ppRun)->member.run.nCharOfs &&
167 nCharOfs < nParaOfs + (*ppRun)->member.run.nCharOfs + eollen) {
172 pPara = pPara->member.para.next_para;
174 *ppRun = ME_FindItemBack(editor->pBuffer->pLast, diRun);
176 assert((*ppRun)->member.run.nFlags & MERF_ENDPARA);
179 void ME_JoinRuns(ME_TextEditor *editor, ME_DisplayItem *p)
181 ME_DisplayItem *pNext = p->next;
183 assert(p->type == diRun && pNext->type == diRun);
184 assert(p->member.run.nCharOfs != -1);
185 ME_GetParagraph(p)->member.para.nFlags |= MEPF_REWRAP;
187 if (editor->bCaretAtEnd && editor->pCursors[0].pRun == pNext)
188 editor->bCaretAtEnd = FALSE;
189 for (i=0; i<editor->nCursors; i++) {
190 if (editor->pCursors[i].pRun == pNext) {
191 editor->pCursors[i].pRun = p;
192 editor->pCursors[i].nOffset += ME_StrVLen(p->member.run.strText);
196 ME_AppendString(p->member.run.strText, pNext->member.run.strText);
198 ME_DestroyDisplayItem(pNext);
199 ME_UpdateRunFlags(editor, &p->member.run);
200 if(TRACE_ON(richedit))
202 TRACE("Before check after join\n");
203 ME_CheckCharOffsets(editor);
204 TRACE("After check after join\n");
208 ME_DisplayItem *ME_SplitRun(ME_Context *c, ME_DisplayItem *item, int nVChar)
210 ME_TextEditor *editor = c->editor;
211 ME_DisplayItem *item2 = NULL;
213 ME_Paragraph *para = &ME_GetParagraph(item)->member.para;
215 assert(item->member.run.nCharOfs != -1);
216 if(TRACE_ON(richedit))
218 TRACE("Before check before split\n");
219 ME_CheckCharOffsets(editor);
220 TRACE("After check before split\n");
223 run = &item->member.run;
225 TRACE("Before split: %s(%ld, %ld)\n", debugstr_w(run->strText->szData),
226 run->pt.x, run->pt.y);
228 item2 = ME_SplitRunSimple(editor, item, nVChar);
230 run2 = &item2->member.run;
232 ME_CalcRunExtent(c, para, run);
233 ME_CalcRunExtent(c, para, run2);
235 run2->pt.x = run->pt.x+run->nWidth;
236 run2->pt.y = run->pt.y;
238 if(TRACE_ON(richedit))
240 TRACE("Before check after split\n");
241 ME_CheckCharOffsets(editor);
242 TRACE("After check after split\n");
243 TRACE("After split: %s(%ld, %ld), %s(%ld, %ld)\n",
244 debugstr_w(run->strText->szData), run->pt.x, run->pt.y,
245 debugstr_w(run2->strText->szData), run2->pt.x, run2->pt.y);
251 /* split a run starting from voffset */
252 ME_DisplayItem *ME_SplitRunSimple(ME_TextEditor *editor, ME_DisplayItem *item, int nVChar)
254 ME_Run *run = &item->member.run;
255 ME_DisplayItem *item2;
258 assert(nVChar > 0 && nVChar < ME_StrVLen(run->strText));
259 assert(item->type == diRun);
260 assert(!(item->member.run.nFlags & MERF_NONTEXT));
261 assert(item->member.run.nCharOfs != -1);
263 item2 = ME_MakeRun(run->style,
264 ME_VSplitString(run->strText, nVChar), run->nFlags&MERF_SPLITMASK);
266 item2->member.run.nCharOfs = item->member.run.nCharOfs+
267 ME_VPosToPos(item->member.run.strText, nVChar);
269 run2 = &item2->member.run;
270 ME_InsertBefore(item->next, item2);
272 ME_UpdateRunFlags(editor, run);
273 ME_UpdateRunFlags(editor, run2);
274 for (i=0; i<editor->nCursors; i++) {
275 if (editor->pCursors[i].pRun == item &&
276 editor->pCursors[i].nOffset >= nVChar) {
277 assert(item2->type == diRun);
278 editor->pCursors[i].pRun = item2;
279 editor->pCursors[i].nOffset -= nVChar;
282 ME_GetParagraph(item)->member.para.nFlags |= MEPF_REWRAP;
286 ME_DisplayItem *ME_MakeRun(ME_Style *s, ME_String *strData, int nFlags)
288 ME_DisplayItem *item = ME_MakeDI(diRun);
289 item->member.run.style = s;
290 item->member.run.strText = strData;
291 item->member.run.nFlags = nFlags;
292 item->member.run.nCharOfs = -1;
298 ME_DisplayItem *ME_InsertRun(ME_TextEditor *editor, int nCharOfs, ME_DisplayItem *pItem)
303 assert(pItem->type == diRun || pItem->type == diUndoInsertRun);
305 ME_CursorFromCharOfs(editor, nCharOfs, &tmp);
306 pDI = ME_InsertRunAtCursor(editor, &tmp, pItem->member.run.style,
307 pItem->member.run.strText->szData,
308 pItem->member.run.strText->nLen,
309 pItem->member.run.nFlags);
315 ME_InsertRunAtCursor(ME_TextEditor *editor, ME_Cursor *cursor, ME_Style *style,
316 const WCHAR *str, int len, int flags)
321 if (cursor->nOffset) {
322 cursor->pRun = ME_SplitRunSimple(editor, cursor->pRun, cursor->nOffset);
326 pUI = ME_AddUndoItem(editor, diUndoDeleteRun, NULL);
328 pUI->nStart = (ME_GetParagraph(cursor->pRun)->member.para.nCharOfs
329 + cursor->pRun->member.run.nCharOfs);
333 pDI = ME_MakeRun(style, ME_MakeStringN(str, len), flags);
334 pDI->member.run.nCharOfs = cursor->pRun->member.run.nCharOfs;
335 ME_InsertBefore(cursor->pRun, pDI);
336 TRACE("Shift length:%d\n", len);
337 ME_PropagateCharOffset(cursor->pRun, len);
338 ME_GetParagraph(cursor->pRun)->member.para.nFlags |= MEPF_REWRAP;
342 void ME_UpdateRunFlags(ME_TextEditor *editor, ME_Run *run)
344 assert(run->nCharOfs != -1);
346 if (RUN_IS_HIDDEN(run))
347 run->nFlags |= MERF_HIDDEN;
349 run->nFlags &= ~MERF_HIDDEN;
351 if (ME_IsSplitable(run->strText))
352 run->nFlags |= MERF_SPLITTABLE;
354 run->nFlags &= ~MERF_SPLITTABLE;
356 if (!(run->nFlags & MERF_NOTEXT)) {
357 if (ME_IsWhitespaces(run->strText))
358 run->nFlags |= MERF_WHITESPACE | MERF_STARTWHITE | MERF_ENDWHITE;
361 run->nFlags &= ~MERF_WHITESPACE;
363 if (ME_IsWSpace(ME_GetCharFwd(run->strText,0)))
364 run->nFlags |= MERF_STARTWHITE;
366 run->nFlags &= ~MERF_STARTWHITE;
368 if (ME_IsWSpace(ME_GetCharBack(run->strText,0)))
369 run->nFlags |= MERF_ENDWHITE;
371 run->nFlags &= ~MERF_ENDWHITE;
375 run->nFlags &= ~(MERF_WHITESPACE | MERF_STARTWHITE | MERF_ENDWHITE);
378 void ME_GetGraphicsSize(ME_TextEditor *editor, ME_Run *run, SIZE *pSize)
380 assert(run->nFlags & MERF_GRAPHICS);
385 int ME_CharFromPoint(ME_TextEditor *editor, int cx, ME_Run *run)
391 if (!run->strText->nLen)
394 if (run->nFlags & (MERF_TAB | MERF_CELL))
396 if (cx < run->nWidth/2)
400 if (run->nFlags & MERF_GRAPHICS)
403 ME_GetGraphicsSize(editor, run, &sz);
408 hDC = GetDC(editor->hWnd);
409 hOldFont = ME_SelectStyleFont(editor, hDC, run->style);
410 GetTextExtentExPointW(hDC, run->strText->szData, run->strText->nLen,
411 cx, &fit, NULL, &sz);
412 ME_UnselectStyleFont(editor, hDC, run->style, hOldFont);
413 ReleaseDC(editor->hWnd, hDC);
417 int ME_CharFromPointCursor(ME_TextEditor *editor, int cx, ME_Run *run)
419 int fit = 0, fit1 = 0;
423 if (!run->strText->nLen)
426 if (run->nFlags & (MERF_TAB | MERF_CELL))
428 if (cx < run->nWidth/2)
432 if (run->nFlags & MERF_GRAPHICS)
435 ME_GetGraphicsSize(editor, run, &sz);
441 hDC = GetDC(editor->hWnd);
442 hOldFont = ME_SelectStyleFont(editor, hDC, run->style);
443 GetTextExtentExPointW(hDC, run->strText->szData, run->strText->nLen,
444 cx, &fit, NULL, &sz);
445 if (fit != run->strText->nLen)
449 GetTextExtentPoint32W(hDC, run->strText->szData, fit, &sz2);
450 fit1 = ME_StrRelPos(run->strText, fit, &chars);
451 GetTextExtentPoint32W(hDC, run->strText->szData, fit1, &sz3);
452 if (cx >= (sz2.cx+sz3.cx)/2)
455 ME_UnselectStyleFont(editor, hDC, run->style, hOldFont);
456 ReleaseDC(editor->hWnd, hDC);
460 int ME_PointFromChar(ME_TextEditor *editor, ME_Run *pRun, int nOffset)
463 HDC hDC = GetDC(editor->hWnd);
466 if (pRun->nFlags & MERF_GRAPHICS)
468 if (!nOffset) return 0;
469 ME_GetGraphicsSize(editor, pRun, &size);
472 hOldFont = ME_SelectStyleFont(editor, hDC, pRun->style);
473 GetTextExtentPoint32W(hDC, pRun->strText->szData, nOffset, &size);
474 ME_UnselectStyleFont(editor, hDC, pRun->style, hOldFont);
475 ReleaseDC(editor->hWnd, hDC);
479 void ME_GetTextExtent(ME_Context *c, LPCWSTR szText, int nChars, ME_Style *s,
484 hOldFont = ME_SelectStyleFont(c->editor, hDC, s);
485 GetTextExtentPoint32W(hDC, szText, nChars, size);
486 ME_UnselectStyleFont(c->editor, hDC, s, hOldFont);
489 SIZE ME_GetRunSizeCommon(ME_Context *c, ME_Paragraph *para, ME_Run *run, int nLen, int *pAscent, int *pDescent)
492 int nMaxLen = ME_StrVLen(run->strText);
497 /* FIXME the following call also ensures that TEXTMETRIC structure is filled
498 * this is wasteful for MERF_NONTEXT runs, but that shouldn't matter
501 ME_GetTextExtent(c, run->strText->szData, nLen, run->style, &size);
502 *pAscent = run->style->tm.tmAscent;
503 *pDescent = run->style->tm.tmDescent;
504 size.cy = *pAscent + *pDescent;
506 if (run->nFlags & MERF_TAB)
508 int pos = 0, i = 0, ppos;
509 int lpsx = GetDeviceCaps(c->hDC, LOGPIXELSX);
510 PARAFORMAT2 *pFmt = para->pFmt;
512 if (i < pFmt->cTabCount)
514 pos = pFmt->rgxTabs[i]&0x00FFFFFF;
519 pos += 720-(pos%720);
521 ppos = pos*lpsx/1440;
522 if (ppos>run->pt.x) {
523 size.cx = ppos - run->pt.x;
527 size.cy = *pAscent + *pDescent;
530 if (run->nFlags & MERF_GRAPHICS)
532 ME_GetGraphicsSize(c->editor, run, &size);
533 if (size.cy > *pAscent)
535 /* descent is unchanged */
538 if (run->nFlags & MERF_CELL)
540 int lpsx = GetDeviceCaps(c->hDC, LOGPIXELSX);
542 size.cx = run->pCell->nRightBoundary * lpsx / 1440 - run->pt.x;
548 SIZE ME_GetRunSize(ME_Context *c, ME_Paragraph *para, ME_Run *run, int nLen)
551 return ME_GetRunSizeCommon(c, para, run, nLen, &asc, &desc);
554 void ME_CalcRunExtent(ME_Context *c, ME_Paragraph *para, ME_Run *run)
556 if (run->nFlags & MERF_HIDDEN)
560 int nEnd = ME_StrVLen(run->strText);
561 SIZE size = ME_GetRunSizeCommon(c, para, run, nEnd, &run->nAscent, &run->nDescent);
562 run->nWidth = size.cx;
564 WARN("size.cx == 0\n");
568 void ME_MustBeWrapped(ME_Context *c, ME_DisplayItem *para)
570 assert(para->type == diParagraph);
574 void ME_SetSelectionCharFormat(ME_TextEditor *editor, CHARFORMAT2W *pFmt)
577 ME_GetSelection(editor, &nFrom, &nTo);
581 if (!editor->pBuffer->pCharStyle)
582 editor->pBuffer->pCharStyle = ME_GetInsertStyle(editor, 0);
583 s = ME_ApplyStyle(editor->pBuffer->pCharStyle, pFmt);
584 ME_ReleaseStyle(editor->pBuffer->pCharStyle);
585 editor->pBuffer->pCharStyle = s;
588 ME_SetCharFormat(editor, nFrom, nTo-nFrom, pFmt);
591 void ME_SetCharFormat(ME_TextEditor *editor, int nOfs, int nChars, CHARFORMAT2W *pFmt)
594 ME_DisplayItem *para;
596 ME_CursorFromCharOfs(editor, nOfs, &tmp);
598 tmp.pRun = ME_SplitRunSimple(editor, tmp.pRun, tmp.nOffset);
600 ME_CursorFromCharOfs(editor, nOfs+nChars, &tmp2);
602 tmp2.pRun = ME_SplitRunSimple(editor, tmp2.pRun, tmp2.nOffset);
604 para = ME_GetParagraph(tmp.pRun);
605 para->member.para.nFlags |= MEPF_REWRAP;
607 while(tmp.pRun != tmp2.pRun)
609 ME_UndoItem *undo = NULL;
610 ME_Style *new_style = ME_ApplyStyle(tmp.pRun->member.run.style, pFmt);
611 /* ME_DumpStyle(new_style); */
612 undo = ME_AddUndoItem(editor, diUndoSetCharFormat, NULL);
614 undo->nStart = tmp.pRun->member.run.nCharOfs+para->member.para.nCharOfs;
615 undo->nLen = tmp.pRun->member.run.strText->nLen;
616 undo->di.member.ustyle = tmp.pRun->member.run.style;
617 /* we'd have to addref undo..ustyle and release tmp...style
618 but they'd cancel each other out so we can do nothing instead */
621 ME_ReleaseStyle(tmp.pRun->member.run.style);
622 tmp.pRun->member.run.style = new_style;
623 tmp.pRun = ME_FindItemFwd(tmp.pRun, diRunOrParagraph);
624 if (tmp.pRun->type == diParagraph)
627 tmp.pRun = ME_FindItemFwd(tmp.pRun, diRun);
628 if (tmp.pRun != tmp2.pRun)
629 para->member.para.nFlags |= MEPF_REWRAP;
635 void ME_SetDefaultCharFormat(ME_TextEditor *editor, CHARFORMAT2W *mod)
640 assert(mod->cbSize == sizeof(CHARFORMAT2W));
641 undo = ME_AddUndoItem(editor, diUndoSetDefaultCharFormat, NULL);
645 undo->di.member.ustyle = editor->pBuffer->pDefaultStyle;
646 ME_AddRefStyle(undo->di.member.ustyle);
648 style = ME_ApplyStyle(editor->pBuffer->pDefaultStyle, mod);
649 editor->pBuffer->pDefaultStyle->fmt = style->fmt;
650 editor->pBuffer->pDefaultStyle->tm = style->tm;
651 ME_ReleaseStyle(style);
652 ME_MarkAllForWrapping(editor);
653 /* pcf = editor->pBuffer->pDefaultStyle->fmt; */
656 void ME_GetRunCharFormat(ME_TextEditor *editor, ME_DisplayItem *run, CHARFORMAT2W *pFmt)
658 ME_CopyCharFormat(pFmt, &run->member.run.style->fmt);
661 void ME_GetDefaultCharFormat(ME_TextEditor *editor, CHARFORMAT2W *pFmt)
664 ME_GetSelection(editor, &nFrom, &nTo);
665 ME_CopyCharFormat(pFmt, &editor->pBuffer->pDefaultStyle->fmt);
668 void ME_GetSelectionCharFormat(ME_TextEditor *editor, CHARFORMAT2W *pFmt)
671 ME_GetSelection(editor, &nFrom, &nTo);
672 if (nFrom == nTo && editor->pBuffer->pCharStyle)
674 ME_CopyCharFormat(pFmt, &editor->pBuffer->pCharStyle->fmt);
677 ME_GetCharFormat(editor, nFrom, nTo, pFmt);
680 void ME_GetCharFormat(ME_TextEditor *editor, int nFrom, int nTo, CHARFORMAT2W *pFmt)
682 ME_DisplayItem *run, *run_end;
683 int nOffset, nOffset2;
686 ME_RunOfsFromCharOfs(editor, nFrom, &run, &nOffset);
687 if (nFrom == nTo) /* special case - if selection is empty, take previous char's formatting */
691 ME_DisplayItem *tmp_run = ME_FindItemBack(run, diRunOrParagraph);
692 if (tmp_run->type == diRun) {
693 ME_GetRunCharFormat(editor, tmp_run, pFmt);
697 ME_GetRunCharFormat(editor, run, pFmt);
701 if (nTo>nFrom) /* selection consists of chars from nFrom up to nTo-1 */
703 ME_RunOfsFromCharOfs(editor, nTo, &run_end, &nOffset2);
705 ME_GetRunCharFormat(editor, run, pFmt);
707 if (run == run_end) return;
710 /* FIXME add more style feature comparisons */
711 int nAttribs = CFM_SIZE | CFM_FACE | CFM_COLOR;
712 int nEffects = CFM_BOLD | CFM_ITALIC | CFM_UNDERLINE;
714 run = ME_FindItemFwd(run, diRun);
716 ZeroMemory(&tmp, sizeof(tmp));
717 tmp.cbSize = sizeof(tmp);
718 ME_GetRunCharFormat(editor, run, &tmp);
720 assert((tmp.dwMask & nAttribs) == nAttribs);
721 assert((tmp.dwMask & nEffects) == nEffects);
722 /* reset flags that differ */
724 if (pFmt->yHeight != tmp.yHeight)
725 pFmt->dwMask &= ~CFM_SIZE;
726 if (pFmt->dwMask & CFM_FACE)
728 if (!(tmp.dwMask & CFM_FACE))
729 pFmt->dwMask &= ~CFM_FACE;
730 else if (lstrcmpW(pFmt->szFaceName, tmp.szFaceName))
731 pFmt->dwMask &= ~CFM_FACE;
733 if (pFmt->yHeight != tmp.yHeight)
734 pFmt->dwMask &= ~CFM_SIZE;
735 if (pFmt->dwMask & CFM_COLOR)
737 if (!((pFmt->dwEffects&CFE_AUTOCOLOR) & (tmp.dwEffects&CFE_AUTOCOLOR)))
739 if (pFmt->crTextColor != tmp.crTextColor)
740 pFmt->dwMask &= ~CFM_COLOR;
744 pFmt->dwMask &= ~((pFmt->dwEffects ^ tmp.dwEffects) & nEffects);
746 } while(run != run_end);