~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Wine Cross Reference
wine/dlls/riched20/para.c

Version: ~ [ wine-1.1.33 ] ~ [ wine-1.1.32 ] ~ [ wine-1.1.31 ] ~ [ wine-1.1.30 ] ~ [ wine-1.1.29 ] ~ [ wine-1.1.28 ] ~ [ wine-1.1.27 ] ~ [ wine-1.1.26 ] ~ [ wine-1.1.25 ] ~ [ wine-1.1.24 ] ~ [ wine-1.1.23 ] ~ [ wine-1.1.22 ] ~ [ wine-1.1.21 ] ~ [ wine-1.1.20 ] ~ [ wine-1.1.19 ] ~ [ wine-1.1.18 ] ~ [ wine-1.1.17 ] ~ [ wine-1.1.16 ] ~ [ wine-1.1.15 ] ~ [ wine-1.1.14 ] ~ [ wine-1.1.13 ] ~ [ wine-1.1.12 ] ~ [ wine-1.1.11 ] ~ [ wine-1.1.10 ] ~ [ wine-1.1.9 ] ~ [ wine-1.1.8 ] ~ [ wine-1.1.7 ] ~ [ wine-1.0.1 ] ~ [ wine-1.1.6 ] ~ [ wine-1.1.5 ] ~ [ wine-1.1.4 ] ~ [ wine-1.1.3 ] ~ [ wine-1.1.2 ] ~ [ wine-1.1.1 ] ~ [ wine-1.1.0 ] ~ [ wine-1.0 ] ~

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

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.