ntdll: Split the signal setup into process-wide and thread-specific routines.
[wine] / dlls / riched20 / para.c
1 /*
2  * RichEdit - functions working on paragraphs of text (diParagraph).
3  * 
4  * Copyright 2004 by Krzysztof Foltman
5  * Copyright 2006 by Phil Krylov
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20  */ 
21
22 #include "editor.h"
23
24 WINE_DEFAULT_DEBUG_CHANNEL(richedit);
25
26 static const WCHAR wszParagraphSign[] = {0xB6, 0};
27
28 void ME_MakeFirstParagraph(ME_TextEditor *editor)
29 {
30   ME_Context c;
31   PARAFORMAT2 fmt;
32   CHARFORMAT2W cf;
33   LOGFONTW lf;
34   HFONT hf;
35   ME_TextBuffer *text = editor->pBuffer;
36   ME_DisplayItem *para = ME_MakeDI(diParagraph);
37   ME_DisplayItem *run;
38   ME_Style *style;
39
40   ME_InitContext(&c, editor, GetDC(editor->hWnd));
41
42   hf = (HFONT)GetStockObject(SYSTEM_FONT);
43   assert(hf);
44   GetObjectW(hf, sizeof(LOGFONTW), &lf);
45   ZeroMemory(&cf, sizeof(cf));
46   cf.cbSize = sizeof(cf);
47   cf.dwMask = CFM_BACKCOLOR|CFM_COLOR|CFM_FACE|CFM_SIZE|CFM_CHARSET;
48   cf.dwMask |= CFM_ALLCAPS|CFM_BOLD|CFM_DISABLED|CFM_EMBOSS|CFM_HIDDEN;
49   cf.dwMask |= CFM_IMPRINT|CFM_ITALIC|CFM_LINK|CFM_OUTLINE|CFM_PROTECTED;
50   cf.dwMask |= CFM_REVISED|CFM_SHADOW|CFM_SMALLCAPS|CFM_STRIKEOUT;
51   cf.dwMask |= CFM_SUBSCRIPT|CFM_UNDERLINETYPE|CFM_WEIGHT;
52   
53   cf.dwEffects = CFE_AUTOCOLOR | CFE_AUTOBACKCOLOR;
54   lstrcpyW(cf.szFaceName, lf.lfFaceName);
55   /* Convert system font height from logical units to twips for cf.yHeight */
56   cf.yHeight = (lf.lfHeight * 72 * 1440) / (c.dpi.cy * c.dpi.cy);
57   if (lf.lfWeight > FW_NORMAL) cf.dwEffects |= CFE_BOLD;
58   cf.wWeight = lf.lfWeight;
59   if (lf.lfItalic) cf.dwEffects |= CFE_ITALIC;
60   cf.bUnderlineType = (lf.lfUnderline) ? CFU_CF1UNDERLINE : CFU_UNDERLINENONE;
61   if (lf.lfStrikeOut) cf.dwEffects |= CFE_STRIKEOUT;
62   cf.bPitchAndFamily = lf.lfPitchAndFamily;
63   cf.bCharSet = lf.lfCharSet;
64
65   ZeroMemory(&fmt, sizeof(fmt));
66   fmt.cbSize = sizeof(fmt);
67   fmt.dwMask = PFM_ALIGNMENT | PFM_OFFSET | PFM_STARTINDENT | PFM_RIGHTINDENT | PFM_TABSTOPS;
68   fmt.wAlignment = PFA_LEFT;
69
70   *para->member.para.pFmt = fmt;
71
72   style = ME_MakeStyle(&cf);
73   text->pDefaultStyle = style;
74   
75   run = ME_MakeRun(style, ME_MakeString(wszParagraphSign), MERF_ENDPARA);
76   run->member.run.nCharOfs = 0;
77   run->member.run.nCR = 1;
78   run->member.run.nLF = (editor->bEmulateVersion10) ? 1 : 0;
79
80   ME_InsertBefore(text->pLast, para);
81   ME_InsertBefore(text->pLast, run);
82   para->member.para.prev_para = text->pFirst;
83   para->member.para.next_para = text->pLast;
84   text->pFirst->member.para.next_para = para;
85   text->pLast->member.para.prev_para = para;
86
87   text->pLast->member.para.nCharOfs = 1;
88
89   ME_DestroyContext(&c, editor->hWnd);
90 }
91  
92 void ME_MarkAllForWrapping(ME_TextEditor *editor)
93 {
94   ME_MarkForWrapping(editor, editor->pBuffer->pFirst->member.para.next_para, editor->pBuffer->pLast);
95 }
96
97 void ME_MarkForWrapping(ME_TextEditor *editor, ME_DisplayItem *first, const ME_DisplayItem *last)
98 {
99   while(first != last)
100   {
101     first->member.para.nFlags |= MEPF_REWRAP;
102     first = first->member.para.next_para;
103   }
104 }
105
106 void ME_MarkForPainting(ME_TextEditor *editor, ME_DisplayItem *first, const ME_DisplayItem *last)
107 {
108   while(first != last && first)
109   {
110     first->member.para.nFlags |= MEPF_REPAINT;
111     first = first->member.para.next_para;
112   }
113 }
114
115 /* split paragraph at the beginning of the run */
116 ME_DisplayItem *ME_SplitParagraph(ME_TextEditor *editor, ME_DisplayItem *run, ME_Style *style, int numCR, int numLF)
117 {
118   ME_DisplayItem *next_para = NULL;
119   ME_DisplayItem *run_para = NULL;
120   ME_DisplayItem *new_para = ME_MakeDI(diParagraph);
121   ME_DisplayItem *end_run = ME_MakeRun(style,ME_MakeString(wszParagraphSign), MERF_ENDPARA);
122   ME_UndoItem *undo = NULL;
123   int ofs;
124   ME_DisplayItem *pp;
125   int end_len = numCR + numLF;
126   
127   assert(run->type == diRun);  
128
129   end_run->member.run.nCR = numCR;
130   end_run->member.run.nLF = numLF;
131   run_para = ME_GetParagraph(run);
132   assert(run_para->member.para.pFmt->cbSize == sizeof(PARAFORMAT2));
133
134   ofs = end_run->member.run.nCharOfs = run->member.run.nCharOfs;
135   next_para = run_para->member.para.next_para;
136   assert(next_para == ME_FindItemFwd(run_para, diParagraphOrEnd));
137   
138   undo = ME_AddUndoItem(editor, diUndoJoinParagraphs, NULL);
139   if (undo)
140     undo->nStart = run_para->member.para.nCharOfs + ofs;
141   
142   /* the new paragraph will have a different starting offset, so let's update its runs */
143   pp = run;
144   while(pp->type == diRun) {
145     pp->member.run.nCharOfs -= ofs;
146     pp = ME_FindItemFwd(pp, diRunOrParagraphOrEnd);
147   }
148   new_para->member.para.nCharOfs = ME_GetParagraph(run)->member.para.nCharOfs+ofs;
149   new_para->member.para.nCharOfs += end_len;
150   
151   new_para->member.para.nFlags = MEPF_REWRAP; /* FIXME copy flags (if applicable) */
152   /* FIXME initialize format style and call ME_SetParaFormat blah blah */
153   *new_para->member.para.pFmt = *run_para->member.para.pFmt;
154
155   new_para->member.para.bTable = run_para->member.para.bTable;
156   
157   /* Inherit previous cell definitions if any */
158   new_para->member.para.pCells = NULL;
159   if (run_para->member.para.pCells)
160   {
161     ME_TableCell *pCell, *pNewCell;
162
163     for (pCell = run_para->member.para.pCells; pCell; pCell = pCell->next)
164     {
165       pNewCell = ALLOC_OBJ(ME_TableCell);
166       pNewCell->nRightBoundary = pCell->nRightBoundary;
167       pNewCell->next = NULL;
168       if (new_para->member.para.pCells)
169         new_para->member.para.pLastCell->next = pNewCell;
170       else
171         new_para->member.para.pCells = pNewCell;
172       new_para->member.para.pLastCell = pNewCell;
173     }
174   }
175     
176   /* fix paragraph properties. FIXME only needed when called from RTF reader */
177   if (run_para->member.para.pCells && !run_para->member.para.bTable)
178   {
179     /* Paragraph does not have an \intbl keyword, so any table definition
180      * stored is invalid */
181     ME_DestroyTableCellList(run_para);
182   }
183   
184   /* insert paragraph into paragraph double linked list */
185   new_para->member.para.prev_para = run_para;
186   new_para->member.para.next_para = next_para;
187   run_para->member.para.next_para = new_para;
188   next_para->member.para.prev_para = new_para;
189
190   /* insert end run of the old paragraph, and new paragraph, into DI double linked list */
191   ME_InsertBefore(run, new_para);
192   ME_InsertBefore(new_para, end_run);
193
194   /* force rewrap of the */
195   run_para->member.para.prev_para->member.para.nFlags |= MEPF_REWRAP;
196   new_para->member.para.prev_para->member.para.nFlags |= MEPF_REWRAP;
197   
198   /* we've added the end run, so we need to modify nCharOfs in the next paragraphs */
199   ME_PropagateCharOffset(next_para, end_len);
200   editor->nParagraphs++;
201   
202   return new_para;
203 }
204
205 /* join tp with tp->member.para.next_para, keeping tp's style; this
206  * is consistent with the original */
207 ME_DisplayItem *ME_JoinParagraphs(ME_TextEditor *editor, ME_DisplayItem *tp)
208 {
209   ME_DisplayItem *pNext, *pFirstRunInNext, *pRun, *pTmp;
210   int i, shift;
211   ME_UndoItem *undo = NULL;
212   int end_len;
213
214   assert(tp->type == diParagraph);
215   assert(tp->member.para.next_para);
216   assert(tp->member.para.next_para->type == diParagraph);
217   
218   pNext = tp->member.para.next_para;
219   
220   /* Need to locate end-of-paragraph run here, in order to know end_len */
221   pRun = ME_FindItemBack(pNext, diRunOrParagraph);
222
223   assert(pRun);
224   assert(pRun->type == diRun);
225   assert(pRun->member.run.nFlags & MERF_ENDPARA);
226
227   end_len = pRun->member.run.nCR + pRun->member.run.nLF;
228
229   {
230     /* null char format operation to store the original char format for the ENDPARA run */
231     CHARFORMAT2W fmt;
232     ME_InitCharFormat2W(&fmt);
233     ME_SetCharFormat(editor, pNext->member.para.nCharOfs - end_len, end_len, &fmt);
234   }
235   undo = ME_AddUndoItem(editor, diUndoSplitParagraph, NULL);
236   if (undo)
237   {
238     undo->nStart = pNext->member.para.nCharOfs - end_len;
239     undo->nCR = pRun->member.run.nCR;
240     undo->nLF = pRun->member.run.nLF;
241     assert(pNext->member.para.pFmt->cbSize == sizeof(PARAFORMAT2));
242     *undo->di.member.para.pFmt = *pNext->member.para.pFmt;
243   }
244   
245   shift = pNext->member.para.nCharOfs - tp->member.para.nCharOfs - end_len;
246   
247   pFirstRunInNext = ME_FindItemFwd(pNext, diRunOrParagraph);
248
249   assert(pFirstRunInNext->type == diRun);
250   
251   /* if some cursor points at end of paragraph, make it point to the first
252      run of the next joined paragraph */
253   for (i=0; i<editor->nCursors; i++) {
254     if (editor->pCursors[i].pRun == pRun) {
255       editor->pCursors[i].pRun = pFirstRunInNext;
256       editor->pCursors[i].nOffset = 0;
257     }
258   }
259
260   pTmp = pNext;
261   do {
262     pTmp = ME_FindItemFwd(pTmp, diRunOrParagraphOrEnd);
263     if (pTmp->type != diRun)
264       break;
265     TRACE("shifting \"%s\" by %d (previous %d)\n", debugstr_w(pTmp->member.run.strText->szData), shift, pTmp->member.run.nCharOfs);
266     pTmp->member.run.nCharOfs += shift;
267   } while(1);
268   
269   ME_Remove(pRun);
270   ME_DestroyDisplayItem(pRun);
271
272   if (editor->pLastSelStartPara == pNext)
273     editor->pLastSelStartPara = tp;
274   if (editor->pLastSelEndPara == pNext)
275     editor->pLastSelEndPara = tp;
276     
277   tp->member.para.next_para = pNext->member.para.next_para;
278   pNext->member.para.next_para->member.para.prev_para = tp;
279   ME_Remove(pNext);
280   ME_DestroyDisplayItem(pNext);
281
282   ME_PropagateCharOffset(tp->member.para.next_para, -end_len);
283   
284   ME_CheckCharOffsets(editor);
285   
286   editor->nParagraphs--;
287   tp->member.para.nFlags |= MEPF_REWRAP;
288   return tp;
289 }
290
291 ME_DisplayItem *ME_GetParagraph(ME_DisplayItem *item) {
292   return ME_FindItemBackOrHere(item, diParagraph);
293 }
294
295 void ME_DumpParaStyleToBuf(const PARAFORMAT2 *pFmt, char buf[2048])
296 {
297   char *p;
298   p = buf;
299
300 #define DUMP(mask, name, fmt, field) \
301   if (pFmt->dwMask & (mask)) p += sprintf(p, "%-22s" fmt "\n", name, pFmt->field); \
302   else p += sprintf(p, "%-22sN/A\n", name);
303
304 /* we take for granted that PFE_xxx is the hiword of the corresponding PFM_xxx */
305 #define DUMP_EFFECT(mask, name) \
306   p += sprintf(p, "%-22s%s\n", name, (pFmt->dwMask & (mask)) ? ((pFmt->wEffects & ((mask) >> 8)) ? "yes" : "no") : "N/A");
307
308   DUMP(PFM_NUMBERING,      "Numbering:",         "%u", wNumbering);
309   DUMP_EFFECT(PFM_DONOTHYPHEN,     "Disable auto-hyphen:");
310   DUMP_EFFECT(PFM_KEEP,            "No page break in para:");
311   DUMP_EFFECT(PFM_KEEPNEXT,        "No page break in para & next:");
312   DUMP_EFFECT(PFM_NOLINENUMBER,    "No line number:");
313   DUMP_EFFECT(PFM_NOWIDOWCONTROL,  "No widow & orphan:");
314   DUMP_EFFECT(PFM_PAGEBREAKBEFORE, "Page break before:");
315   DUMP_EFFECT(PFM_RTLPARA,         "RTL para:");
316   DUMP_EFFECT(PFM_SIDEBYSIDE,      "Side by side:");
317   DUMP_EFFECT(PFM_TABLE,           "Table:");
318   DUMP(PFM_OFFSETINDENT,   "Offset indent:",     "%d", dxStartIndent);
319   DUMP(PFM_STARTINDENT,    "Start indent:",      "%d", dxStartIndent);
320   DUMP(PFM_RIGHTINDENT,    "Right indent:",      "%d", dxRightIndent);
321   DUMP(PFM_OFFSET,         "Offset:",            "%d", dxOffset);
322   if (pFmt->dwMask & PFM_ALIGNMENT) {
323     switch (pFmt->wAlignment) {
324     case PFA_LEFT   : p += sprintf(p, "Alignment:            left\n"); break;
325     case PFA_RIGHT  : p += sprintf(p, "Alignment:            right\n"); break;
326     case PFA_CENTER : p += sprintf(p, "Alignment:            center\n"); break;
327     case PFA_JUSTIFY: p += sprintf(p, "Alignment:            justify\n"); break;
328     default         : p += sprintf(p, "Alignment:            incorrect %d\n", pFmt->wAlignment); break;
329     }
330   }
331   else p += sprintf(p, "Alignment:            N/A\n");
332   DUMP(PFM_TABSTOPS,       "Tab Stops:",         "%d", cTabCount);
333   if (pFmt->dwMask & PFM_TABSTOPS) {
334     int i;
335     p += sprintf(p, "\t");
336     for (i = 0; i < pFmt->cTabCount; i++) p += sprintf(p, "%x ", pFmt->rgxTabs[i]);
337     p += sprintf(p, "\n");
338   }
339   DUMP(PFM_SPACEBEFORE,    "Space Before:",      "%d", dySpaceBefore);
340   DUMP(PFM_SPACEAFTER,     "Space After:",       "%d", dySpaceAfter);
341   DUMP(PFM_LINESPACING,    "Line spacing:",      "%d", dyLineSpacing);
342   DUMP(PFM_STYLE,          "Text style:",        "%d", sStyle);
343   DUMP(PFM_LINESPACING,    "Line spacing rule:", "%u", bLineSpacingRule);
344   /* bOutlineLevel should be 0 */
345   DUMP(PFM_SHADING,        "Shading Weigth:",    "%u", wShadingWeight);
346   DUMP(PFM_SHADING,        "Shading Style:",     "%u", wShadingStyle);
347   DUMP(PFM_NUMBERINGSTART, "Numbering Start:",   "%u", wNumberingStart);
348   DUMP(PFM_NUMBERINGSTYLE, "Numbering Style:",   "0x%x", wNumberingStyle);
349   DUMP(PFM_NUMBERINGTAB,   "Numbering Tab:",     "%u", wNumberingStyle);
350   DUMP(PFM_BORDER,         "Border Space:",      "%u", wBorderSpace);
351   DUMP(PFM_BORDER,         "Border Width:",      "%u", wBorderWidth);
352   DUMP(PFM_BORDER,         "Borders:",           "%u", wBorders);
353
354 #undef DUMP
355 #undef DUMP_EFFECT
356 }
357
358 void ME_SetParaFormat(ME_TextEditor *editor, ME_DisplayItem *para, const PARAFORMAT2 *pFmt)
359 {
360   PARAFORMAT2 copy;
361   assert(sizeof(*para->member.para.pFmt) == sizeof(PARAFORMAT2));
362   ME_AddUndoItem(editor, diUndoSetParagraphFormat, para);
363   
364   copy = *para->member.para.pFmt;
365
366 #define COPY_FIELD(m, f) \
367   if (pFmt->dwMask & (m)) {                     \
368     para->member.para.pFmt->dwMask |= m;        \
369     para->member.para.pFmt->f = pFmt->f;        \
370   }
371
372   COPY_FIELD(PFM_NUMBERING, wNumbering);
373 #define EFFECTS_MASK (PFM_RTLPARA|PFM_KEEP|PFM_KEEPNEXT|PFM_PAGEBREAKBEFORE| \
374                       PFM_NOLINENUMBER|PFM_NOWIDOWCONTROL|PFM_DONOTHYPHEN|PFM_SIDEBYSIDE| \
375                       PFM_TABLE)
376   /* we take for granted that PFE_xxx is the hiword of the corresponding PFM_xxx */
377   if (pFmt->dwMask & EFFECTS_MASK) {
378     para->member.para.pFmt->dwMask &= ~(pFmt->dwMask & EFFECTS_MASK);
379     para->member.para.pFmt->wEffects |= pFmt->wEffects & HIWORD(pFmt->dwMask);
380   }
381 #undef EFFECTS_MASK
382
383   COPY_FIELD(PFM_STARTINDENT, dxStartIndent);
384   if (pFmt->dwMask & PFM_OFFSETINDENT)
385     para->member.para.pFmt->dxStartIndent += pFmt->dxStartIndent;
386   COPY_FIELD(PFM_RIGHTINDENT, dxRightIndent);
387   COPY_FIELD(PFM_OFFSET, dxOffset);
388   COPY_FIELD(PFM_ALIGNMENT, wAlignment);
389
390   if (pFmt->dwMask & PFM_TABSTOPS)
391   {
392     para->member.para.pFmt->cTabCount = pFmt->cTabCount;
393     memcpy(para->member.para.pFmt->rgxTabs, pFmt->rgxTabs, pFmt->cTabCount*sizeof(LONG));
394   }
395   COPY_FIELD(PFM_SPACEBEFORE, dySpaceBefore);
396   COPY_FIELD(PFM_SPACEAFTER, dySpaceAfter);
397   COPY_FIELD(PFM_LINESPACING, dyLineSpacing);
398   COPY_FIELD(PFM_STYLE, sStyle);
399   COPY_FIELD(PFM_LINESPACING, bLineSpacingRule);
400   COPY_FIELD(PFM_SHADING, wShadingWeight);
401   COPY_FIELD(PFM_SHADING, wShadingStyle);
402   COPY_FIELD(PFM_NUMBERINGSTART, wNumberingStart);
403   COPY_FIELD(PFM_NUMBERINGSTYLE, wNumberingStyle);
404   COPY_FIELD(PFM_NUMBERINGTAB, wNumberingTab);
405   COPY_FIELD(PFM_BORDER, wBorderSpace);
406   COPY_FIELD(PFM_BORDER, wBorderWidth);
407   COPY_FIELD(PFM_BORDER, wBorders);
408
409   para->member.para.pFmt->dwMask |= pFmt->dwMask;
410 #undef COPY_FIELD
411
412   if (memcmp(&copy, para->member.para.pFmt, sizeof(PARAFORMAT2)))
413     para->member.para.nFlags |= MEPF_REWRAP;
414 }
415
416
417 void
418 ME_GetSelectionParas(ME_TextEditor *editor, ME_DisplayItem **para, ME_DisplayItem **para_end)
419 {
420   ME_Cursor *pEndCursor = &editor->pCursors[1];
421   
422   *para = ME_GetParagraph(editor->pCursors[0].pRun);
423   *para_end = ME_GetParagraph(editor->pCursors[1].pRun);
424   if ((*para_end)->member.para.nCharOfs < (*para)->member.para.nCharOfs) {
425     ME_DisplayItem *tmp = *para;
426
427     *para = *para_end;
428     *para_end = tmp;
429     pEndCursor = &editor->pCursors[0];
430   }
431   
432   /* selection consists of chars from nFrom up to nTo-1 */
433   if ((*para_end)->member.para.nCharOfs > (*para)->member.para.nCharOfs) {
434     if (!pEndCursor->nOffset) {
435       *para_end = ME_GetParagraph(ME_FindItemBack(pEndCursor->pRun, diRun));
436     }
437   }
438 }
439
440
441 void ME_SetSelectionParaFormat(ME_TextEditor *editor, const PARAFORMAT2 *pFmt)
442 {
443   ME_DisplayItem *para, *para_end;
444   
445   ME_GetSelectionParas(editor, &para, &para_end);
446  
447   do {
448     ME_SetParaFormat(editor, para, pFmt);
449     if (para == para_end)
450       break;
451     para = para->member.para.next_para;
452   } while(1);
453 }
454
455 void ME_GetParaFormat(ME_TextEditor *editor, const ME_DisplayItem *para, PARAFORMAT2 *pFmt)
456 {
457   if (pFmt->cbSize >= sizeof(PARAFORMAT2))
458   {
459     *pFmt = *para->member.para.pFmt;
460     return;
461   }
462   CopyMemory(pFmt, para->member.para.pFmt, pFmt->cbSize);  
463 }
464
465 void ME_GetSelectionParaFormat(ME_TextEditor *editor, PARAFORMAT2 *pFmt)
466 {
467   ME_DisplayItem *para, *para_end;
468   PARAFORMAT2 tmp;
469   
470   ME_GetSelectionParas(editor, &para, &para_end);
471   
472   ME_GetParaFormat(editor, para, pFmt);
473   if (para == para_end) return;
474   
475   do {
476     ZeroMemory(&tmp, sizeof(tmp));
477     tmp.cbSize = sizeof(tmp);
478     ME_GetParaFormat(editor, para, &tmp);
479
480 #define CHECK_FIELD(m, f) \
481     if (pFmt->f != tmp.f) pFmt->dwMask &= ~(m);
482
483     CHECK_FIELD(PFM_NUMBERING, wNumbering);
484     /* para->member.para.pFmt->wEffects = pFmt->wEffects; */
485     assert(tmp.dwMask & PFM_ALIGNMENT);
486     CHECK_FIELD(PFM_NUMBERING, wNumbering);
487     assert(tmp.dwMask & PFM_STARTINDENT);
488     CHECK_FIELD(PFM_STARTINDENT, dxStartIndent);
489     assert(tmp.dwMask & PFM_RIGHTINDENT);
490     CHECK_FIELD(PFM_RIGHTINDENT, dxRightIndent);
491     assert(tmp.dwMask & PFM_OFFSET);
492     CHECK_FIELD(PFM_OFFSET, dxOffset);
493     CHECK_FIELD(PFM_ALIGNMENT, wAlignment);
494
495     assert(tmp.dwMask & PFM_TABSTOPS);
496     if (pFmt->dwMask & PFM_TABSTOPS) {
497       if (pFmt->cTabCount != tmp.cTabCount ||
498           memcmp(pFmt->rgxTabs, tmp.rgxTabs, tmp.cTabCount*sizeof(int)))
499         pFmt->dwMask &= ~PFM_TABSTOPS;
500     }
501
502     CHECK_FIELD(PFM_SPACEBEFORE, dySpaceBefore);
503     CHECK_FIELD(PFM_SPACEAFTER, dySpaceAfter);
504     CHECK_FIELD(PFM_LINESPACING, dyLineSpacing);
505     CHECK_FIELD(PFM_STYLE, sStyle);
506     CHECK_FIELD(PFM_SPACEAFTER, bLineSpacingRule);
507     CHECK_FIELD(PFM_SHADING, wShadingWeight);
508     CHECK_FIELD(PFM_SHADING, wShadingStyle);
509     CHECK_FIELD(PFM_NUMBERINGSTART, wNumberingStart);
510     CHECK_FIELD(PFM_NUMBERINGSTYLE, wNumberingStyle);
511     CHECK_FIELD(PFM_NUMBERINGTAB, wNumberingTab);
512     CHECK_FIELD(PFM_BORDER, wBorderSpace);
513     CHECK_FIELD(PFM_BORDER, wBorderWidth);
514     CHECK_FIELD(PFM_BORDER, wBorders);
515
516 #undef CHECK_FIELD
517
518     if (para == para_end)
519       return;
520     para = para->member.para.next_para;
521   } while(1);
522 }