2 * RichEdit functions dealing with on tables
4 * Copyright 2008 by Dylan Smith
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 * The implementation of tables differs greatly between version 3.0
23 * (in riched20.dll) and version 4.1 (in msftedit.dll) of richedit controls.
24 * Currently Wine is not distinguishing between version 3.0 and version 4.1,
25 * so v4.1 is assumed unless v1.0 is being emulated (i.e. riched32.dll is used).
26 * If this lack of distinction causes a bug in a Windows application, then Wine
27 * will need to start making this distinction.
29 * Richedit version 1.0 - 3.0:
30 * Tables are implemented in these versions using tabs at the end of cells,
31 * and tab stops to position the cells. The paragraph format flag PFE_TABLE
32 * will indicate that the paragraph is a table row. Note that in this
33 * implementation there is one paragraph per table row.
35 * Richedit version 4.1:
36 * Tables are implemented such that cells can contain multiple paragraphs,
37 * each with its own paragraph format, and cells may even contain tables
38 * nested within the cell.
40 * There is also a paragraph at the start of each table row that contains
41 * the rows paragraph format (e.g. to change the row alignment to row), and a
42 * paragraph at the end of the table row with the PFE_TABLEROWDELIMITER flag
43 * set. The paragraphs at the start and end of the table row should always be
44 * empty, but should have a length of 2.
46 * Wine implements this using display items (ME_DisplayItem) with a type of
47 * diCell. These cell display items store the cell properties, and are
48 * inserted into the editors linked list before each cell, and at the end of
49 * the last cell. The cell display item for a cell comes before the paragraphs
50 * for the cell, but the last cell display item refers to no cell, so it is
57 WINE_DEFAULT_DEBUG_CHANNEL(richedit_lists
);
59 static const WCHAR cr_lf
[] = {'\r', '\n', 0};
61 static ME_Paragraph
* table_insert_end_para( ME_TextEditor
*editor
, ME_Cursor
*cursor
,
62 const WCHAR
*eol_str
, int eol_len
, int para_flags
)
64 ME_Style
*style
= style_get_insert_style( editor
, cursor
);
67 if (cursor
->nOffset
) run_split( editor
, cursor
);
69 para
= para_split( editor
, &cursor
->pRun
->member
.run
, style
, eol_str
, eol_len
, para_flags
);
70 ME_ReleaseStyle( style
);
71 cursor
->pPara
= para_get_di( para
);
72 cursor
->pRun
= run_get_di( para_first_run( para
) );
76 ME_Paragraph
* table_insert_row_start( ME_TextEditor
*editor
, ME_Cursor
*cursor
)
80 para
= table_insert_end_para( editor
, cursor
, cr_lf
, 2, MEPF_ROWSTART
);
81 return para_prev( para
);
84 ME_Paragraph
* table_insert_row_start_at_para( ME_TextEditor
*editor
, ME_Paragraph
*para
)
86 ME_Paragraph
*prev_para
, *end_para
, *start_row
;
89 cursor
.pPara
= para_get_di( para
);
90 cursor
.pRun
= run_get_di( para_first_run( para
) );
93 start_row
= table_insert_row_start( editor
, &cursor
);
95 end_para
= para_next( &editor
->pCursors
[0].pPara
->member
.para
);
96 prev_para
= para_next( start_row
);
97 para
= para_next( prev_para
);
99 while (para
!= end_para
)
101 para
->pCell
= prev_para
->pCell
;
102 para
->nFlags
|= MEPF_CELL
;
103 para
->nFlags
&= ~(MEPF_ROWSTART
| MEPF_ROWEND
);
104 para
->fmt
.dwMask
|= PFM_TABLE
| PFM_TABLEROWDELIMITER
;
105 para
->fmt
.wEffects
|= PFE_TABLE
;
106 para
->fmt
.wEffects
&= ~PFE_TABLEROWDELIMITER
;
108 para
= para_next( para
);
113 /* Inserts a diCell and starts a new paragraph for the next cell.
115 * Returns the first paragraph of the new cell. */
116 ME_Paragraph
* table_insert_cell( ME_TextEditor
*editor
, ME_Cursor
*cursor
)
120 return table_insert_end_para( editor
, editor
->pCursors
, &tab
, 1, MEPF_CELL
);
123 ME_Paragraph
* table_insert_row_end( ME_TextEditor
*editor
, ME_Cursor
*cursor
)
127 para
= table_insert_end_para( editor
, cursor
, cr_lf
, 2, MEPF_ROWEND
);
128 return para_prev( para
);
131 ME_Paragraph
* table_row_end( ME_Paragraph
*para
)
133 ME_DisplayItem
*cell
;
135 if (para
->nFlags
& MEPF_ROWEND
) return para
;
136 if (para
->nFlags
& MEPF_ROWSTART
) para
= para_next( para
);
138 assert(cell
&& cell
->type
== diCell
);
139 while (cell
->member
.cell
.next_cell
)
140 cell
= cell
->member
.cell
.next_cell
;
142 para
= &ME_FindItemFwd( cell
, diParagraph
)->member
.para
;
143 assert( para
&& para
->nFlags
& MEPF_ROWEND
);
147 ME_Paragraph
* table_row_start( ME_Paragraph
*para
)
149 ME_DisplayItem
*cell
;
151 if (para
->nFlags
& MEPF_ROWSTART
) return para
;
152 if (para
->nFlags
& MEPF_ROWEND
) para
= para_prev( para
);
154 assert(cell
&& cell
->type
== diCell
);
155 while (cell
->member
.cell
.prev_cell
)
156 cell
= cell
->member
.cell
.prev_cell
;
158 para
= &ME_FindItemBack( cell
, diParagraph
)->member
.para
;
159 assert( para
&& para
->nFlags
& MEPF_ROWSTART
);
163 ME_Paragraph
* table_outer_para( ME_Paragraph
*para
)
165 if (para
->nFlags
& MEPF_ROWEND
) para
= para_prev( para
);
168 para
= table_row_start( para
);
169 if (!para
->pCell
) break;
170 para
= &ME_FindItemBack( para
->pCell
, diParagraph
)->member
.para
;
175 /* Make a bunch of assertions to make sure tables haven't been corrupted.
177 * These invariants may not hold true in the middle of streaming in rich text
178 * or during an undo and redo of streaming in rich text. It should be safe to
179 * call this method after an event is processed.
181 void ME_CheckTablesForCorruption(ME_TextEditor
*editor
)
183 if(TRACE_ON(richedit_lists
))
186 ME_DumpDocument(editor
->pBuffer
);
190 ME_DisplayItem
*p
, *pPrev
;
191 pPrev
= editor
->pBuffer
->pFirst
;
193 if (!editor
->bEmulateVersion10
) /* v4.1 */
195 while (p
->type
== diParagraph
)
197 assert(p
->member
.para
.fmt
.dwMask
& PFM_TABLE
);
198 assert(p
->member
.para
.fmt
.dwMask
& PFM_TABLEROWDELIMITER
);
199 if (p
->member
.para
.pCell
)
201 assert(p
->member
.para
.nFlags
& MEPF_CELL
);
202 assert(p
->member
.para
.fmt
.wEffects
& PFE_TABLE
);
204 if (p
->member
.para
.pCell
!= pPrev
->member
.para
.pCell
)
206 /* There must be a diCell in between the paragraphs if pCell changes. */
207 ME_DisplayItem
*pCell
= ME_FindItemBack(p
, diCell
);
209 assert(ME_FindItemBack(p
, diRun
) == ME_FindItemBack(pCell
, diRun
));
211 if (p
->member
.para
.nFlags
& MEPF_ROWEND
)
213 /* ROWEND must come after a cell. */
214 assert(pPrev
->member
.para
.pCell
);
215 assert(p
->member
.para
.pCell
216 == pPrev
->member
.para
.pCell
->member
.cell
.parent_cell
);
217 assert(p
->member
.para
.fmt
.wEffects
& PFE_TABLEROWDELIMITER
);
219 else if (p
->member
.para
.pCell
)
221 assert(!(p
->member
.para
.fmt
.wEffects
& PFE_TABLEROWDELIMITER
));
222 assert(pPrev
->member
.para
.pCell
||
223 pPrev
->member
.para
.nFlags
& MEPF_ROWSTART
);
224 if (pPrev
->member
.para
.pCell
&&
225 !(pPrev
->member
.para
.nFlags
& MEPF_ROWSTART
))
227 assert(p
->member
.para
.pCell
->member
.cell
.parent_cell
228 == pPrev
->member
.para
.pCell
->member
.cell
.parent_cell
);
229 if (pPrev
->member
.para
.pCell
!= p
->member
.para
.pCell
)
230 assert(pPrev
->member
.para
.pCell
231 == p
->member
.para
.pCell
->member
.cell
.prev_cell
);
234 else if (!(p
->member
.para
.nFlags
& MEPF_ROWSTART
))
236 assert(!(p
->member
.para
.fmt
.wEffects
& PFE_TABLEROWDELIMITER
));
237 /* ROWSTART must be followed by a cell. */
238 assert(!(p
->member
.para
.nFlags
& MEPF_CELL
));
239 /* ROWSTART must be followed by a cell. */
240 assert(!(pPrev
->member
.para
.nFlags
& MEPF_ROWSTART
));
243 p
= p
->member
.para
.next_para
;
245 } else { /* v1.0 - 3.0 */
246 while (p
->type
== diParagraph
)
248 assert(!(p
->member
.para
.nFlags
& (MEPF_ROWSTART
|MEPF_ROWEND
|MEPF_CELL
)));
249 assert(p
->member
.para
.fmt
.dwMask
& PFM_TABLE
);
250 assert(!(p
->member
.para
.fmt
.wEffects
& PFE_TABLEROWDELIMITER
));
251 assert(!p
->member
.para
.pCell
);
252 p
= p
->member
.para
.next_para
;
256 assert(p
->type
== diTextEnd
);
257 assert(!pPrev
->member
.para
.pCell
);
262 BOOL
ME_IsInTable(ME_DisplayItem
*pItem
)
267 if (pItem
->type
== diRun
)
268 pItem
= ME_GetParagraph(pItem
);
269 if (pItem
->type
!= diParagraph
)
271 pFmt
= &pItem
->member
.para
.fmt
;
272 return pFmt
->dwMask
& PFM_TABLE
&& pFmt
->wEffects
& PFE_TABLE
;
275 /* Table rows should either be deleted completely or not at all. */
276 void ME_ProtectPartialTableDeletion(ME_TextEditor
*editor
, ME_Cursor
*c
, int *nChars
)
278 int nOfs
= ME_GetCursorOfs(c
);
280 ME_DisplayItem
*this_para
= c
->pPara
;
281 ME_DisplayItem
*end_para
;
283 ME_MoveCursorChars(editor
, &c2
, *nChars
, FALSE
);
285 if (c2
.pRun
->member
.run
.nFlags
& MERF_ENDPARA
) {
286 /* End offset might be in the middle of the end paragraph run.
287 * If this is the case, then we need to use the next paragraph as the last
290 int remaining
= nOfs
+ *nChars
- c2
.pRun
->member
.run
.nCharOfs
291 - end_para
->member
.para
.nCharOfs
;
294 assert(remaining
< c2
.pRun
->member
.run
.len
);
295 end_para
= end_para
->member
.para
.next_para
;
298 if (!editor
->bEmulateVersion10
) { /* v4.1 */
299 if (this_para
->member
.para
.pCell
!= end_para
->member
.para
.pCell
||
300 ((this_para
->member
.para
.nFlags
|end_para
->member
.para
.nFlags
)
301 & (MEPF_ROWSTART
|MEPF_ROWEND
)))
303 while (this_para
!= end_para
)
305 ME_DisplayItem
*next_para
= this_para
->member
.para
.next_para
;
306 BOOL bTruancateDeletion
= FALSE
;
307 if (this_para
->member
.para
.nFlags
& MEPF_ROWSTART
) {
308 /* The following while loop assumes that next_para is MEPF_ROWSTART,
309 * so moving back one paragraph let's it be processed as the start
311 next_para
= this_para
;
312 this_para
= this_para
->member
.para
.prev_para
;
313 } else if (next_para
->member
.para
.pCell
!= this_para
->member
.para
.pCell
314 || this_para
->member
.para
.nFlags
& MEPF_ROWEND
)
316 /* Start of the deletion from after the start of the table row. */
317 bTruancateDeletion
= TRUE
;
319 while (!bTruancateDeletion
&&
320 next_para
->member
.para
.nFlags
& MEPF_ROWSTART
)
322 next_para
= table_row_end( &next_para
->member
.para
)->next_para
;
323 if (next_para
->member
.para
.nCharOfs
> nOfs
+ *nChars
)
325 /* End of deletion is not past the end of the table row. */
326 next_para
= this_para
->member
.para
.next_para
;
327 /* Delete the end paragraph preceding the table row if the
328 * preceding table row will be empty. */
329 if (this_para
->member
.para
.nCharOfs
>= nOfs
)
331 next_para
= next_para
->member
.para
.next_para
;
333 bTruancateDeletion
= TRUE
;
335 this_para
= next_para
->member
.para
.prev_para
;
338 if (bTruancateDeletion
)
340 ME_Run
*end_run
= &ME_FindItemBack(next_para
, diRun
)->member
.run
;
341 int nCharsNew
= (next_para
->member
.para
.nCharOfs
- nOfs
343 nCharsNew
= max(nCharsNew
, 0);
344 assert(nCharsNew
<= *nChars
);
348 this_para
= next_para
;
351 } else { /* v1.0 - 3.0 */
352 ME_DisplayItem
*pRun
;
353 int nCharsToBoundary
;
355 if ((this_para
->member
.para
.nCharOfs
!= nOfs
|| this_para
== end_para
) &&
356 this_para
->member
.para
.fmt
.dwMask
& PFM_TABLE
&&
357 this_para
->member
.para
.fmt
.wEffects
& PFE_TABLE
)
360 /* Find the next tab or end paragraph to use as a delete boundary */
361 while (!(pRun
->member
.run
.nFlags
& (MERF_TAB
|MERF_ENDPARA
)))
362 pRun
= ME_FindItemFwd(pRun
, diRun
);
363 nCharsToBoundary
= pRun
->member
.run
.nCharOfs
364 - c
->pRun
->member
.run
.nCharOfs
366 *nChars
= min(*nChars
, nCharsToBoundary
);
367 } else if (end_para
->member
.para
.fmt
.dwMask
& PFM_TABLE
&&
368 end_para
->member
.para
.fmt
.wEffects
& PFE_TABLE
)
370 /* The deletion starts from before the row, so don't join it with
371 * previous non-empty paragraphs. */
372 ME_DisplayItem
*curPara
;
374 if (nOfs
> this_para
->member
.para
.nCharOfs
) {
375 pRun
= ME_FindItemBack(end_para
, diRun
);
376 curPara
= end_para
->member
.para
.prev_para
;
379 pRun
= ME_FindItemFwd(end_para
, diRun
);
384 nCharsToBoundary
= curPara
->member
.para
.nCharOfs
385 + pRun
->member
.run
.nCharOfs
387 if (nCharsToBoundary
>= 0)
388 *nChars
= min(*nChars
, nCharsToBoundary
);
396 ME_Paragraph
* table_append_row( ME_TextEditor
*editor
, ME_Paragraph
*table_row
)
398 WCHAR endl
= '\r', tab
= '\t';
404 if (!editor
->bEmulateVersion10
) /* v4.1 */
406 ME_DisplayItem
*insertedCell
, *cell
;
407 ME_Paragraph
*para
, *prev_table_end
;
409 cell
= ME_FindItemFwd( para_get_di( table_row_start( table_row
) ), diCell
);
410 prev_table_end
= table_row_end( table_row
);
411 para
= para_next( prev_table_end
);
412 run
= para_first_run( para
);
413 editor
->pCursors
[0].pPara
= para_get_di( para
);
414 editor
->pCursors
[0].pRun
= run_get_di( run
);
415 editor
->pCursors
[0].nOffset
= 0;
416 editor
->pCursors
[1] = editor
->pCursors
[0];
417 para
= table_insert_row_start( editor
, editor
->pCursors
);
418 insertedCell
= ME_FindItemFwd( para_get_di( para
), diCell
);
419 /* Copy cell properties */
420 insertedCell
->member
.cell
.nRightBoundary
= cell
->member
.cell
.nRightBoundary
;
421 insertedCell
->member
.cell
.border
= cell
->member
.cell
.border
;
422 while (cell
->member
.cell
.next_cell
)
424 cell
= cell
->member
.cell
.next_cell
;
425 para
= table_insert_cell( editor
, editor
->pCursors
);
426 insertedCell
= ME_FindItemBack( para_get_di( para
), diCell
);
427 /* Copy cell properties */
428 insertedCell
->member
.cell
.nRightBoundary
= cell
->member
.cell
.nRightBoundary
;
429 insertedCell
->member
.cell
.border
= cell
->member
.cell
.border
;
431 para
= table_insert_row_end( editor
, editor
->pCursors
);
432 para
->fmt
= prev_table_end
->fmt
;
433 /* return the table row start for the inserted paragraph */
434 return para_next( &ME_FindItemFwd( cell
, diParagraph
)->member
.para
);
436 else /* v1.0 - 3.0 */
438 run
= para_end_run( table_row
);
439 pFmt
= &table_row
->fmt
;
440 assert(pFmt
->dwMask
& PFM_TABLE
&& pFmt
->wEffects
& PFE_TABLE
);
441 editor
->pCursors
[0].pPara
= para_get_di( table_row
);
442 editor
->pCursors
[0].pRun
= run_get_di( run
);
443 editor
->pCursors
[0].nOffset
= 0;
444 editor
->pCursors
[1] = editor
->pCursors
[0];
445 ME_InsertTextFromCursor( editor
, 0, &endl
, 1, run
->style
);
446 run
= &editor
->pCursors
[0].pRun
->member
.run
;
447 for (i
= 0; i
< pFmt
->cTabCount
; i
++)
448 ME_InsertTextFromCursor(editor
, 0, &tab
, 1, run
->style
);
450 return para_next( table_row
);
454 /* Selects the next table cell or appends a new table row if at end of table */
455 static void ME_SelectOrInsertNextCell( ME_TextEditor
*editor
, ME_DisplayItem
*run
)
457 ME_Paragraph
*para
= run
->member
.run
.para
;
460 assert(run
&& run
->type
== diRun
);
461 assert(ME_IsInTable(run
));
462 if (!editor
->bEmulateVersion10
) /* v4.1 */
464 ME_DisplayItem
*cell
;
465 /* Get the initial cell */
466 if (para
->nFlags
& MEPF_ROWSTART
) cell
= para_next( para
)->pCell
;
467 else if (para
->nFlags
& MEPF_ROWEND
) cell
= para_prev( para
)->pCell
;
468 else cell
= para
->pCell
;
471 /* Get the next cell. */
472 if (cell
->member
.cell
.next_cell
&&
473 cell
->member
.cell
.next_cell
->member
.cell
.next_cell
)
475 cell
= cell
->member
.cell
.next_cell
;
477 para
= para_next( table_row_end( &ME_FindItemFwd( cell
, diParagraph
)->member
.para
) );
478 if (para
->nFlags
& MEPF_ROWSTART
) cell
= para_next( para
)->pCell
;
482 para
= para_prev( para
);
483 para
= table_append_row( editor
, table_row_start( para
) );
484 /* Put cursor at the start of the new table row */
485 para
= para_next( para
);
486 editor
->pCursors
[0].pPara
= para_get_di( para
);
487 editor
->pCursors
[0].pRun
= run_get_di( para_first_run( para
) );
488 editor
->pCursors
[0].nOffset
= 0;
489 editor
->pCursors
[1] = editor
->pCursors
[0];
490 ME_WrapMarkedParagraphs(editor
);
495 editor
->pCursors
[1].pRun
= ME_FindItemFwd(cell
, diRun
);
496 editor
->pCursors
[1].pPara
= ME_GetParagraph(editor
->pCursors
[1].pRun
);
497 editor
->pCursors
[1].nOffset
= 0;
498 assert(editor
->pCursors
[0].pRun
);
499 cell
= cell
->member
.cell
.next_cell
;
500 editor
->pCursors
[0].pRun
= ME_FindItemBack(cell
, diRun
);
501 editor
->pCursors
[0].pPara
= ME_GetParagraph(editor
->pCursors
[0].pRun
);
502 editor
->pCursors
[0].nOffset
= 0;
503 assert(editor
->pCursors
[1].pRun
);
505 else /* v1.0 - 3.0 */
507 if (run
->member
.run
.nFlags
& MERF_ENDPARA
&&
508 ME_IsInTable(ME_FindItemFwd(run
, diParagraphOrEnd
)))
510 run
= ME_FindItemFwd(run
, diRun
);
513 for (i
= 0; i
< 2; i
++)
515 while (!(run
->member
.run
.nFlags
& MERF_TAB
))
517 run
= ME_FindItemFwd(run
, diRunOrParagraphOrEnd
);
518 if (run
->type
!= diRun
)
520 para
= &run
->member
.para
;
521 if (para_in_table( para
))
523 run
= run_get_di( para_first_run( para
) );
525 editor
->pCursors
[0].pPara
= para_get_di( para
);
526 editor
->pCursors
[0].pRun
= run
;
527 editor
->pCursors
[0].nOffset
= 0;
532 /* Insert table row */
533 para
= table_append_row( editor
, para_prev( para
) );
534 /* Put cursor at the start of the new table row */
535 editor
->pCursors
[0].pPara
= para_get_di( para
);
536 editor
->pCursors
[0].pRun
= run_get_di( para_first_run( para
) );
537 editor
->pCursors
[0].nOffset
= 0;
538 editor
->pCursors
[1] = editor
->pCursors
[0];
539 ME_WrapMarkedParagraphs(editor
);
545 run
= ME_FindItemFwd(run
, diRun
);
546 editor
->pCursors
[i
].pRun
= run
;
547 editor
->pCursors
[i
].pPara
= ME_GetParagraph(run
);
548 editor
->pCursors
[i
].nOffset
= 0;
554 void ME_TabPressedInTable(ME_TextEditor
*editor
, BOOL bSelectedRow
)
556 /* FIXME: Shift tab should move to the previous cell. */
557 ME_Cursor fromCursor
, toCursor
;
558 ME_InvalidateSelection(editor
);
561 from
= ME_GetCursorOfs(&editor
->pCursors
[0]);
562 to
= ME_GetCursorOfs(&editor
->pCursors
[1]);
565 fromCursor
= editor
->pCursors
[0];
566 toCursor
= editor
->pCursors
[1];
568 fromCursor
= editor
->pCursors
[1];
569 toCursor
= editor
->pCursors
[0];
572 if (!editor
->bEmulateVersion10
) /* v4.1 */
574 if (!ME_IsInTable(toCursor
.pRun
))
576 editor
->pCursors
[0] = toCursor
;
577 editor
->pCursors
[1] = toCursor
;
579 ME_SelectOrInsertNextCell(editor
, toCursor
.pRun
);
581 } else { /* v1.0 - 3.0 */
582 if (!ME_IsInTable(fromCursor
.pRun
)) {
583 editor
->pCursors
[0] = fromCursor
;
584 editor
->pCursors
[1] = fromCursor
;
585 /* FIXME: For some reason the caret is shown at the start of the
586 * previous paragraph in v1.0 to v3.0, and bCaretAtEnd only works
587 * within the paragraph for wrapped lines. */
588 if (ME_FindItemBack(fromCursor
.pRun
, diRun
))
589 editor
->bCaretAtEnd
= TRUE
;
590 } else if ((bSelectedRow
|| !ME_IsInTable(toCursor
.pRun
))) {
591 ME_SelectOrInsertNextCell(editor
, fromCursor
.pRun
);
593 if (ME_IsSelection(editor
) && !toCursor
.nOffset
)
596 run
= ME_FindItemBack(toCursor
.pRun
, diRunOrParagraphOrEnd
);
597 if (run
->type
== diRun
&& run
->member
.run
.nFlags
& MERF_TAB
)
598 ME_SelectOrInsertNextCell(editor
, run
);
600 ME_SelectOrInsertNextCell(editor
, toCursor
.pRun
);
602 ME_SelectOrInsertNextCell(editor
, toCursor
.pRun
);
606 ME_InvalidateSelection(editor
);
608 update_caret(editor
);
609 ME_SendSelChange(editor
);
612 /* Make sure the cursor is not in the hidden table row start paragraph
613 * without a selection. */
614 void ME_MoveCursorFromTableRowStartParagraph(ME_TextEditor
*editor
)
616 ME_DisplayItem
*para
= editor
->pCursors
[0].pPara
;
617 if (para
== editor
->pCursors
[1].pPara
&&
618 para
->member
.para
.nFlags
& MEPF_ROWSTART
) {
619 /* The cursors should not be at the hidden start row paragraph without
620 * a selection, so the cursor is moved into the first cell. */
621 para
= para
->member
.para
.next_para
;
622 editor
->pCursors
[0].pPara
= para
;
623 editor
->pCursors
[0].pRun
= ME_FindItemFwd(para
, diRun
);
624 editor
->pCursors
[0].nOffset
= 0;
625 editor
->pCursors
[1] = editor
->pCursors
[0];
629 struct RTFTable
*ME_MakeTableDef(ME_TextEditor
*editor
)
631 RTFTable
*tableDef
= heap_alloc_zero(sizeof(*tableDef
));
633 if (!editor
->bEmulateVersion10
) /* v4.1 */
638 void ME_InitTableDef(ME_TextEditor
*editor
, struct RTFTable
*tableDef
)
640 ZeroMemory(tableDef
->cells
, sizeof(tableDef
->cells
));
641 ZeroMemory(tableDef
->border
, sizeof(tableDef
->border
));
642 tableDef
->numCellsDefined
= 0;
643 tableDef
->leftEdge
= 0;
644 if (!editor
->bEmulateVersion10
) /* v4.1 */
646 else /* v1.0 - 3.0 */