ReactOS 0.4.16-dev-1041-g8b6907f
table.c File Reference
#include "editor.h"
#include "rtf.h"
Include dependency graph for table.c:

Go to the source code of this file.

Functions

static ME_Paragraphtable_insert_end_para (ME_TextEditor *editor, ME_Cursor *cursor, const WCHAR *eol_str, int eol_len, int para_flags)
 
ME_Paragraphtable_insert_row_start (ME_TextEditor *editor, ME_Cursor *cursor)
 
ME_Paragraphtable_insert_row_start_at_para (ME_TextEditor *editor, ME_Paragraph *para)
 
ME_Paragraphtable_insert_cell (ME_TextEditor *editor, ME_Cursor *cursor)
 
ME_Paragraphtable_insert_row_end (ME_TextEditor *editor, ME_Cursor *cursor)
 
ME_Paragraphtable_row_end (ME_Paragraph *para)
 
ME_Paragraphtable_row_start (ME_Paragraph *para)
 
ME_Paragraphtable_outer_para (ME_Paragraph *para)
 
ME_Celltable_row_first_cell (ME_Paragraph *para)
 
ME_Celltable_row_end_cell (ME_Paragraph *para)
 
ME_Cellcell_create (void)
 
ME_Cellcell_next (ME_Cell *cell)
 
ME_Cellcell_prev (ME_Cell *cell)
 
ME_Paragraphcell_first_para (ME_Cell *cell)
 
ME_Paragraphcell_end_para (ME_Cell *cell)
 
void table_protect_partial_deletion (ME_TextEditor *editor, ME_Cursor *c, int *num_chars)
 
ME_Paragraphtable_append_row (ME_TextEditor *editor, ME_Paragraph *table_row)
 
static void table_select_next_cell_or_append (ME_TextEditor *editor, ME_Run *run)
 
void table_handle_tab (ME_TextEditor *editor, BOOL selected_row)
 
void table_move_from_row_start (ME_TextEditor *editor)
 
struct RTFTableME_MakeTableDef (ME_TextEditor *editor)
 
void ME_InitTableDef (ME_TextEditor *editor, struct RTFTable *tableDef)
 

Function Documentation

◆ cell_create()

ME_Cell * cell_create ( void  )

Definition at line 186 of file table.c.

187{
189 return &item->member.cell;
190}
ME_DisplayItem * ME_MakeDI(ME_DIType type) DECLSPEC_HIDDEN
Definition: list.c:133
@ diCell
Definition: editstr.h:85
static ATOM item
Definition: dde.c:856

Referenced by para_split().

◆ cell_end_para()

ME_Paragraph * cell_end_para ( ME_Cell cell)

Definition at line 207 of file table.c.

208{
209 ME_Cell *next = cell_next( cell );
210
211 if (!next) return cell_first_para( cell ); /* End of row */
212
214}
ME_Paragraph * cell_first_para(ME_Cell *cell)
Definition: table.c:202
ME_Cell * cell_next(ME_Cell *cell)
Definition: table.c:192
ME_DisplayItem * ME_FindItemBack(ME_DisplayItem *di, ME_DIType nTypeOrClass) DECLSPEC_HIDDEN
Definition: list.c:66
static ME_DisplayItem * cell_get_di(ME_Cell *cell)
Definition: editor.h:319
@ diParagraph
Definition: editstr.h:84
static unsigned __int64 next
Definition: rand_nt.c:6
union tagME_DisplayItem::@568 member
ME_Paragraph para
Definition: editstr.h:261

Referenced by adjust_para_y(), cursor_move_line(), draw_table_borders(), editor_draw(), and table_select_next_cell_or_append().

◆ cell_first_para()

ME_Paragraph * cell_first_para ( ME_Cell cell)

Definition at line 202 of file table.c.

203{
204 return &ME_FindItemFwd( cell_get_di( cell ), diParagraph )->member.para;
205}
ME_DisplayItem * ME_FindItemFwd(ME_DisplayItem *di, ME_DIType nTypeOrClass) DECLSPEC_HIDDEN
Definition: list.c:89

Referenced by cell_end_para(), cursor_move_line(), draw_table_borders(), editor_draw(), ME_RTFSpecialCharHook(), pixel_pos_in_table_row(), and table_select_next_cell_or_append().

◆ cell_next()

◆ cell_prev()

ME_Cell * cell_prev ( ME_Cell cell)

Definition at line 197 of file table.c.

198{
199 return cell->prev_cell;
200}
struct tagME_Cell * prev_cell
Definition: editstr.h:228

Referenced by adjust_para_y(), cursor_move_line(), ME_BeginRow(), ME_RTFSpecialCharHook(), para_join(), para_split(), and table_row_start().

◆ ME_InitTableDef()

void ME_InitTableDef ( ME_TextEditor editor,
struct RTFTable tableDef 
)

Definition at line 556 of file table.c.

557{
558 ZeroMemory(tableDef->cells, sizeof(tableDef->cells));
559 ZeroMemory(tableDef->border, sizeof(tableDef->border));
560 tableDef->numCellsDefined = 0;
561 tableDef->leftEdge = 0;
562 if (!editor->bEmulateVersion10) /* v4.1 */
563 tableDef->gapH = 10;
564 else /* v1.0 - 3.0 */
565 tableDef->gapH = 0;
566}
RTFCell cells[MAX_TABLE_CELLS]
Definition: rtf.h:1027
int numCellsDefined
Definition: rtf.h:1028
int gapH
Definition: rtf.h:1030
RTFBorder border[6]
Definition: rtf.h:1032
int leftEdge
Definition: rtf.h:1030
unsigned int bEmulateVersion10
Definition: editstr.h:385
#define ZeroMemory
Definition: winbase.h:1743

Referenced by ME_RTFTblAttrHook().

◆ ME_MakeTableDef()

struct RTFTable * ME_MakeTableDef ( ME_TextEditor editor)

Definition at line 547 of file table.c.

548{
549 RTFTable *tableDef = heap_alloc_zero(sizeof(*tableDef));
550
551 if (!editor->bEmulateVersion10) /* v4.1 */
552 tableDef->gapH = 10;
553 return tableDef;
554}
Definition: rtf.h:1026

Referenced by ME_RTFTblAttrHook().

◆ table_append_row()

ME_Paragraph * table_append_row ( ME_TextEditor editor,
ME_Paragraph table_row 
)

Definition at line 327 of file table.c.

328{
329 WCHAR endl = '\r', tab = '\t';
330 ME_Run *run;
331 int i;
332
333 if (!editor->bEmulateVersion10) /* v4.1 */
334 {
335 ME_Cell *new_cell, *cell;
336 ME_Paragraph *para, *prev_table_end, *new_row_start;
337
338 cell = table_row_first_cell( table_row );
339 prev_table_end = table_row_end( table_row );
340 para = para_next( prev_table_end );
341 run = para_first_run( para );
342 editor->pCursors[0].para = para;
343 editor->pCursors[0].run = run;
344 editor->pCursors[0].nOffset = 0;
345 editor->pCursors[1] = editor->pCursors[0];
346 new_row_start = table_insert_row_start( editor, editor->pCursors );
347 new_cell = table_row_first_cell( new_row_start );
348 /* Copy cell properties */
349 new_cell->nRightBoundary = cell->nRightBoundary;
350 new_cell->border = cell->border;
351 while (cell_next( cell ))
352 {
353 cell = cell_next( cell );
354 para = table_insert_cell( editor, editor->pCursors );
355 new_cell = para_cell( para );
356 /* Copy cell properties */
357 new_cell->nRightBoundary = cell->nRightBoundary;
358 new_cell->border = cell->border;
359 };
360 para = table_insert_row_end( editor, editor->pCursors );
361 para->fmt = prev_table_end->fmt;
362 /* return the table row start for the inserted paragraph */
363 return new_row_start;
364 }
365 else /* v1.0 - 3.0 */
366 {
367 run = para_end_run( table_row );
368 assert( para_in_table( table_row ) );
369 editor->pCursors[0].para = table_row;
370 editor->pCursors[0].run = run;
371 editor->pCursors[0].nOffset = 0;
372 editor->pCursors[1] = editor->pCursors[0];
373 ME_InsertTextFromCursor( editor, 0, &endl, 1, run->style );
374 run = editor->pCursors[0].run;
375 for (i = 0; i < table_row->fmt.cTabCount; i++)
376 ME_InsertTextFromCursor( editor, 0, &tab, 1, run->style );
377
378 return para_next( table_row );
379 }
380}
basic_ostream< _CharT, _Traits > &_STLP_CALL endl(basic_ostream< _CharT, _Traits > &__os)
Definition: _ostream.h:357
void ME_InsertTextFromCursor(ME_TextEditor *editor, int nCursor, const WCHAR *str, int len, ME_Style *style)
Definition: caret.c:553
ME_Paragraph * table_insert_row_end(ME_TextEditor *editor, ME_Cursor *cursor)
Definition: table.c:119
ME_Cell * table_row_first_cell(ME_Paragraph *para)
Definition: table.c:170
ME_Paragraph * table_insert_row_start(ME_TextEditor *editor, ME_Cursor *cursor)
Definition: table.c:72
ME_Paragraph * table_row_end(ME_Paragraph *para)
Definition: table.c:127
ME_Paragraph * table_insert_cell(ME_TextEditor *editor, ME_Cursor *cursor)
Definition: table.c:112
#define assert(x)
Definition: debug.h:53
ME_Run * para_first_run(ME_Paragraph *para) DECLSPEC_HIDDEN
Definition: para.c:104
ME_Cell * para_cell(ME_Paragraph *para) DECLSPEC_HIDDEN
Definition: para.c:127
BOOL para_in_table(ME_Paragraph *para) DECLSPEC_HIDDEN
Definition: para.c:122
ME_Paragraph * para_next(ME_Paragraph *para) DECLSPEC_HIDDEN
Definition: para.c:57
ME_Run * para_end_run(ME_Paragraph *para) DECLSPEC_HIDDEN
Definition: para.c:117
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
SHORT cTabCount
Definition: richedit.h:674
int nRightBoundary
Definition: editstr.h:223
ME_BorderRect border
Definition: editstr.h:224
ME_Paragraph * para
Definition: editstr.h:274
int nOffset
Definition: editstr.h:276
ME_Run * run
Definition: editstr.h:275
PARAFORMAT2 fmt
Definition: editstr.h:203
ME_Style * style
Definition: editstr.h:159
ME_Cursor * pCursors
Definition: editstr.h:389
static struct wctab tab[]
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by handle_enter(), and table_select_next_cell_or_append().

◆ table_handle_tab()

void table_handle_tab ( ME_TextEditor editor,
BOOL  selected_row 
)

Definition at line 473 of file table.c.

474{
475 /* FIXME: Shift tab should move to the previous cell. */
476 ME_Cursor fromCursor, toCursor;
478 {
479 int from, to;
480 from = ME_GetCursorOfs(&editor->pCursors[0]);
481 to = ME_GetCursorOfs(&editor->pCursors[1]);
482 if (from <= to)
483 {
484 fromCursor = editor->pCursors[0];
485 toCursor = editor->pCursors[1];
486 }
487 else
488 {
489 fromCursor = editor->pCursors[1];
490 toCursor = editor->pCursors[0];
491 }
492 }
493 if (!editor->bEmulateVersion10) /* v4.1 */
494 {
495 if (!para_in_table( toCursor.para ))
496 {
497 editor->pCursors[0] = toCursor;
498 editor->pCursors[1] = toCursor;
499 }
500 else table_select_next_cell_or_append( editor, toCursor.run );
501 }
502 else /* v1.0 - 3.0 */
503 {
504 if (!para_in_table( fromCursor.para ))
505 {
506 editor->pCursors[0] = fromCursor;
507 editor->pCursors[1] = fromCursor;
508 /* FIXME: For some reason the caret is shown at the start of the
509 * previous paragraph in v1.0 to v3.0 */
510 }
511 else if ((selected_row || !para_in_table( toCursor.para )))
512 table_select_next_cell_or_append( editor, fromCursor.run );
513 else
514 {
515 ME_Run *run = run_prev( toCursor.run );
516
517 if (ME_IsSelection(editor) && !toCursor.nOffset && run && run->nFlags & MERF_TAB)
519 else
520 table_select_next_cell_or_append( editor, toCursor.run );
521 }
522 }
524 ME_Repaint(editor);
525 update_caret(editor);
526 ME_SendSelChange(editor);
527}
BOOL ME_IsSelection(ME_TextEditor *editor)
Definition: caret.c:1400
int ME_GetCursorOfs(const ME_Cursor *cursor)
Definition: caret.c:889
void ME_SendSelChange(ME_TextEditor *editor)
Definition: caret.c:1420
void update_caret(ME_TextEditor *editor)
Definition: caret.c:277
static void table_select_next_cell_or_append(ME_TextEditor *editor, ME_Run *run)
Definition: table.c:383
void ME_InvalidateSelection(ME_TextEditor *editor) DECLSPEC_HIDDEN
Definition: paint.c:1247
ME_Run * run_prev(ME_Run *run) DECLSPEC_HIDDEN
Definition: run.c:82
void ME_Repaint(ME_TextEditor *editor) DECLSPEC_HIDDEN
Definition: paint.c:119
#define MERF_TAB
Definition: editstr.h:106
CardRegion * from
Definition: spigame.cpp:19
int nFlags
Definition: editstr.h:164

Referenced by handle_wm_char().

◆ table_insert_cell()

ME_Paragraph * table_insert_cell ( ME_TextEditor editor,
ME_Cursor cursor 
)

Definition at line 112 of file table.c.

113{
114 WCHAR tab = '\t';
115
116 return table_insert_end_para( editor, editor->pCursors, &tab, 1, MEPF_CELL );
117}
static ME_Paragraph * table_insert_end_para(ME_TextEditor *editor, ME_Cursor *cursor, const WCHAR *eol_str, int eol_len, int para_flags)
Definition: table.c:57
#define MEPF_CELL
Definition: editstr.h:142

Referenced by ME_RTFSpecialCharHook(), and table_append_row().

◆ table_insert_end_para()

static ME_Paragraph * table_insert_end_para ( ME_TextEditor editor,
ME_Cursor cursor,
const WCHAR eol_str,
int  eol_len,
int  para_flags 
)
static

Definition at line 57 of file table.c.

59{
61 ME_Paragraph *para;
62
63 if (cursor->nOffset) run_split( editor, cursor );
64
65 para = para_split( editor, cursor->run, style, eol_str, eol_len, para_flags );
67 cursor->para = para;
68 cursor->run = para_first_run( para );
69 return para;
70}
Arabic default style
Definition: afstyles.h:94
void ME_ReleaseStyle(ME_Style *item) DECLSPEC_HIDDEN
Definition: style.c:462
ME_Style * style_get_insert_style(ME_TextEditor *editor, ME_Cursor *cursor) DECLSPEC_HIDDEN
Definition: style.c:476
ME_Paragraph * para_split(ME_TextEditor *editor, ME_Run *run, ME_Style *style, const WCHAR *eol_str, int eol_len, int paraFlags) DECLSPEC_HIDDEN
Definition: para.c:540
ME_Run * run_split(ME_TextEditor *editor, ME_Cursor *cursor) DECLSPEC_HIDDEN
Definition: run.c:305
const char cursor[]
Definition: icontest.c:13

Referenced by table_insert_cell(), table_insert_row_end(), and table_insert_row_start().

◆ table_insert_row_end()

ME_Paragraph * table_insert_row_end ( ME_TextEditor editor,
ME_Cursor cursor 
)

Definition at line 119 of file table.c.

120{
121 ME_Paragraph *para;
122
123 para = table_insert_end_para( editor, cursor, L"\r\n", 2, MEPF_ROWEND );
124 return para_prev( para );
125}
ME_Paragraph * para_prev(ME_Paragraph *para) DECLSPEC_HIDDEN
Definition: para.c:63
#define MEPF_ROWEND
Definition: editstr.h:144
#define L(x)
Definition: ntvdm.h:50

Referenced by ME_RTFSpecialCharHook(), and table_append_row().

◆ table_insert_row_start()

ME_Paragraph * table_insert_row_start ( ME_TextEditor editor,
ME_Cursor cursor 
)

Definition at line 72 of file table.c.

73{
74 ME_Paragraph *para;
75
76 para = table_insert_end_para( editor, cursor, L"\r\n", 2, MEPF_ROWSTART );
77 return para_prev( para );
78}
#define MEPF_ROWSTART
Definition: editstr.h:143

Referenced by ME_RTFParAttrHook(), table_append_row(), and table_insert_row_start_at_para().

◆ table_insert_row_start_at_para()

ME_Paragraph * table_insert_row_start_at_para ( ME_TextEditor editor,
ME_Paragraph para 
)

Definition at line 80 of file table.c.

81{
82 ME_Paragraph *prev_para, *end_para, *start_row;
84
85 cursor.para = para;
86 cursor.run = para_first_run( para );
87 cursor.nOffset = 0;
88
89 start_row = table_insert_row_start( editor, &cursor );
90
91 end_para = para_next( editor->pCursors[0].para );
92 prev_para = para_next( start_row );
93 para = para_next( prev_para );
94
95 while (para != end_para)
96 {
97 para->cell = para_cell( prev_para );
98 para->nFlags |= MEPF_CELL;
99 para->nFlags &= ~(MEPF_ROWSTART | MEPF_ROWEND);
101 para->fmt.wEffects |= PFE_TABLE;
102 para->fmt.wEffects &= ~PFE_TABLEROWDELIMITER;
103 prev_para = para;
104 para = para_next( para );
105 }
106 return start_row;
107}
#define PFM_TABLE
Definition: richedit.h:870
#define PFE_TABLE
Definition: richedit.h:944
#define PFM_TABLEROWDELIMITER
Definition: richedit.h:868
DWORD dwMask
Definition: richedit.h:667
WORD wEffects
Definition: richedit.h:669
struct tagME_Cell * cell
Definition: editstr.h:206

Referenced by ME_RTFParAttrHook(), and ME_RTFSpecialCharHook().

◆ table_move_from_row_start()

void table_move_from_row_start ( ME_TextEditor editor)

Definition at line 531 of file table.c.

532{
533 ME_Paragraph *para = editor->pCursors[0].para;
534
535 if (para == editor->pCursors[1].para && para->nFlags & MEPF_ROWSTART)
536 {
537 /* The cursors should not be at the hidden start row paragraph without
538 * a selection, so the cursor is moved into the first cell. */
539 para = para_next( para );
540 editor->pCursors[0].para = para;
541 editor->pCursors[0].run = para_first_run( para );
542 editor->pCursors[0].nOffset = 0;
543 editor->pCursors[1] = editor->pCursors[0];
544 }
545}

Referenced by ME_KeyDown(), ME_Redo(), and ME_Undo().

◆ table_outer_para()

ME_Paragraph * table_outer_para ( ME_Paragraph para)

Definition at line 158 of file table.c.

159{
160 if (para->nFlags & MEPF_ROWEND) para = para_prev( para );
161 while (para_cell( para ))
162 {
163 para = table_row_start( para );
164 if (!para_cell( para )) break;
166 }
167 return para;
168}
ME_Paragraph * table_row_start(ME_Paragraph *para)
Definition: table.c:142

Referenced by para_range_invalidate(), and wrap_marked_paras_dc().

◆ table_protect_partial_deletion()

void table_protect_partial_deletion ( ME_TextEditor editor,
ME_Cursor c,
int num_chars 
)

Definition at line 217 of file table.c.

218{
219 int start_ofs = ME_GetCursorOfs( c );
220 ME_Cursor c2 = *c;
221 ME_Paragraph *this_para = c->para, *end_para;
222
223 ME_MoveCursorChars( editor, &c2, *num_chars, FALSE );
224 end_para = c2.para;
225 if (c2.run->nFlags & MERF_ENDPARA)
226 {
227 /* End offset might be in the middle of the end paragraph run.
228 * If this is the case, then we need to use the next paragraph as the last
229 * paragraphs.
230 */
231 int remaining = start_ofs + *num_chars - c2.run->nCharOfs - end_para->nCharOfs;
232 if (remaining)
233 {
234 assert( remaining < c2.run->len );
235 end_para = para_next( end_para );
236 }
237 }
238 if (!editor->bEmulateVersion10) /* v4.1 */
239 {
240 if (para_cell( this_para ) != para_cell( end_para ) ||
241 ((this_para->nFlags | end_para->nFlags) & (MEPF_ROWSTART | MEPF_ROWEND)))
242 {
243 while (this_para != end_para)
244 {
245 ME_Paragraph *next_para = para_next( this_para );
246 BOOL truancate_del = FALSE;
247 if (this_para->nFlags & MEPF_ROWSTART)
248 {
249 /* The following while loop assumes that next_para is MEPF_ROWSTART,
250 * so moving back one paragraph lets it be processed as the start
251 * of the row. */
252 next_para = this_para;
253 this_para = para_prev( this_para );
254 }
255 else if (para_cell( next_para) != para_cell( this_para ) || this_para->nFlags & MEPF_ROWEND)
256 {
257 /* Start of the deletion from after the start of the table row. */
258 truancate_del = TRUE;
259 }
260 while (!truancate_del && next_para->nFlags & MEPF_ROWSTART)
261 {
262 next_para = para_next( table_row_end( next_para ) );
263 if (next_para->nCharOfs > start_ofs + *num_chars)
264 {
265 /* End of deletion is not past the end of the table row. */
266 next_para = para_next( this_para );
267 /* Delete the end paragraph preceding the table row if the
268 * preceding table row will be empty. */
269 if (this_para->nCharOfs >= start_ofs) next_para = para_next( next_para );
270 truancate_del = TRUE;
271 }
272 else this_para = para_prev( next_para );
273 }
274 if (truancate_del)
275 {
276 ME_Run *end_run = para_end_run( para_prev( next_para ) );
277 int new_chars = next_para->nCharOfs - start_ofs - end_run->len;
278 new_chars = max( new_chars, 0 );
279 assert( new_chars <= *num_chars);
280 *num_chars = new_chars;
281 break;
282 }
283 this_para = next_para;
284 }
285 }
286 }
287 else /* v1.0 - 3.0 */
288 {
289 ME_Run *run;
290 int chars_to_boundary;
291
292 if ((this_para->nCharOfs != start_ofs || this_para == end_para) && para_in_table( this_para ))
293 {
294 run = c->run;
295 /* Find the next tab or end paragraph to use as a delete boundary */
296 while (!(run->nFlags & (MERF_TAB | MERF_ENDPARA)))
297 run = run_next( run );
298 chars_to_boundary = run->nCharOfs - c->run->nCharOfs - c->nOffset;
299 *num_chars = min( *num_chars, chars_to_boundary );
300 }
301 else if (para_in_table( end_para ))
302 {
303 /* The deletion starts from before the row, so don't join it with
304 * previous non-empty paragraphs. */
305 ME_Paragraph *cur_para;
306 run = NULL;
307 if (start_ofs > this_para->nCharOfs)
308 {
309 cur_para = para_prev( end_para );
310 run = para_end_run( cur_para );
311 }
312 if (!run)
313 {
314 cur_para = end_para;
315 run = para_first_run( end_para );
316 }
317 if (run)
318 {
319 chars_to_boundary = cur_para->nCharOfs + run->nCharOfs - start_ofs;
320 if (chars_to_boundary >= 0) *num_chars = min( *num_chars, chars_to_boundary );
321 }
322 }
323 if (*num_chars < 0) *num_chars = 0;
324 }
325}
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
int ME_MoveCursorChars(ME_TextEditor *editor, ME_Cursor *cursor, int nRelOfs, BOOL final_eop)
Definition: caret.c:678
ME_Run * run_next(ME_Run *run) DECLSPEC_HIDDEN
Definition: run.c:68
#define MERF_ENDPARA
Definition: editstr.h:121
unsigned int BOOL
Definition: ntddk_ex.h:94
const GLubyte * c
Definition: glext.h:8905
GLenum GLsizei len
Definition: glext.h:6722
#define c
Definition: ke_i.h:80
#define min(a, b)
Definition: monoChain.cc:55
int nCharOfs
Definition: editstr.h:161
int len
Definition: editstr.h:162
#define max(a, b)
Definition: svc.c:63

Referenced by ME_InternalDeleteText().

◆ table_row_end()

ME_Paragraph * table_row_end ( ME_Paragraph para)

Definition at line 127 of file table.c.

128{
129 ME_Cell *cell;
130
131 if (para->nFlags & MEPF_ROWEND) return para;
132 if (para->nFlags & MEPF_ROWSTART) para = para_next( para );
133 cell = para_cell( para );
134 while (cell_next( cell ))
135 cell = cell_next( cell );
136
137 para = &ME_FindItemFwd( cell_get_di( cell ), diParagraph )->member.para;
138 assert( para && para->nFlags & MEPF_ROWEND );
139 return para;
140}

Referenced by adjust_para_y(), cursor_from_virtual_coords(), cursor_move_line(), draw_table_borders(), ME_BeginRow(), ME_WrapTextParagraph(), pixel_pos_in_table_row(), stream_out_table_props(), table_append_row(), table_protect_partial_deletion(), table_row_end_cell(), and table_select_next_cell_or_append().

◆ table_row_end_cell()

ME_Cell * table_row_end_cell ( ME_Paragraph para)

Definition at line 178 of file table.c.

179{
180 if (!para_in_table( para )) return NULL;
181
182 para = para_prev( table_row_end( para ));
183 return cell_next( para_cell( para ) );
184}

Referenced by adjust_para_y(), cursor_move_line(), draw_paragraph(), draw_table_borders(), and ME_BeginRow().

◆ table_row_first_cell()

ME_Cell * table_row_first_cell ( ME_Paragraph para)

Definition at line 170 of file table.c.

171{
172 if (!para_in_table( para )) return NULL;
173
174 para = para_next( table_row_start( para ) );
175 return para_cell( para );
176}

Referenced by adjust_para_y(), cursor_move_line(), draw_paragraph(), ME_RTFSpecialCharHook(), pixel_pos_in_table_row(), stream_out_table_props(), and table_append_row().

◆ table_row_start()

ME_Paragraph * table_row_start ( ME_Paragraph para)

Definition at line 142 of file table.c.

143{
144 ME_Cell *cell;
145
146 if (para->nFlags & MEPF_ROWSTART) return para;
147 if (para->nFlags & MEPF_ROWEND) para = para_prev( para );
148 cell = para_cell( para );
149
150 while (cell_prev( cell ))
151 cell = cell_prev( cell );
152
154 assert( para && para->nFlags & MEPF_ROWSTART );
155 return para;
156}
ME_Cell * cell_prev(ME_Cell *cell)
Definition: table.c:197

Referenced by adjust_para_y(), cursor_move_line(), table_outer_para(), table_row_first_cell(), and table_select_next_cell_or_append().

◆ table_select_next_cell_or_append()

static void table_select_next_cell_or_append ( ME_TextEditor editor,
ME_Run run 
)
static

Definition at line 383 of file table.c.

384{
385 ME_Paragraph *para = run->para;
386 ME_Cell *cell;
387 int i;
388
389 assert( para_in_table( para ) );
390 if (!editor->bEmulateVersion10) /* v4.1 */
391 {
392 /* Get the initial cell */
393 if (para->nFlags & MEPF_ROWSTART) cell = para_cell( para_next( para ) );
394 else if (para->nFlags & MEPF_ROWEND) cell = para_cell( para_prev( para ) );
395 else cell = para_cell( para );
396
397 /* Get the next cell. */
398 if (cell_next( cell ) && cell_next( cell_next( cell ) ))
399 cell = cell_next( cell );
400 else
401 {
402 para = para_next( table_row_end( para ) );
403 if (para->nFlags & MEPF_ROWSTART) cell = para_cell( para_next( para ) );
404 else
405 {
406 /* Insert row */
407 para = para_prev( para );
408 para = table_append_row( editor, table_row_start( para ) );
409 /* Put cursor at the start of the new table row */
410 para = para_next( para );
411 editor->pCursors[0].para = para;
412 editor->pCursors[0].run = para_first_run( para );
413 editor->pCursors[0].nOffset = 0;
414 editor->pCursors[1] = editor->pCursors[0];
416 return;
417 }
418 }
419 /* Select cell */
420 editor->pCursors[1].para = cell_first_para( cell );
421 editor->pCursors[1].run = para_first_run( editor->pCursors[1].para );
422 editor->pCursors[1].nOffset = 0;
423 editor->pCursors[0].para = cell_end_para( cell );
424 editor->pCursors[0].run = para_end_run( editor->pCursors[0].para );
425 editor->pCursors[0].nOffset = 0;
426 }
427 else /* v1.0 - 3.0 */
428 {
429 if (run->nFlags & MERF_ENDPARA && para_in_table( para_next( para ) ))
430 {
431 run = run_next_all_paras( run );
432 assert(run);
433 }
434 for (i = 0; i < 2; i++)
435 {
436 while (!(run->nFlags & MERF_TAB))
437 {
438 if (!run_next( run ))
439 {
440 para = para_next( run->para );
441 if (para_in_table( para ))
442 {
443 run = para_first_run( para );
444 editor->pCursors[0].para = para;
445 editor->pCursors[0].run = run;
446 editor->pCursors[0].nOffset = 0;
447 i = 1;
448 }
449 else
450 {
451 /* Insert table row */
452 para = table_append_row( editor, para_prev( para ) );
453 /* Put cursor at the start of the new table row */
454 editor->pCursors[0].para = para;
455 editor->pCursors[0].run = para_first_run( para );
456 editor->pCursors[0].nOffset = 0;
457 editor->pCursors[1] = editor->pCursors[0];
459 return;
460 }
461 }
462 else run = run_next( run );
463 }
464 if (i == 0) run = run_next_all_paras( run );
465 editor->pCursors[i].run = run;
466 editor->pCursors[i].para = run->para;
467 editor->pCursors[i].nOffset = 0;
468 }
469 }
470}
ME_Paragraph * table_append_row(ME_TextEditor *editor, ME_Paragraph *table_row)
Definition: table.c:327
ME_Paragraph * cell_end_para(ME_Cell *cell)
Definition: table.c:207
ME_Run * run_next_all_paras(ME_Run *run) DECLSPEC_HIDDEN
Definition: run.c:96
BOOL ME_WrapMarkedParagraphs(ME_TextEditor *editor) DECLSPEC_HIDDEN
Definition: wrap.c:1094
struct tagME_Paragraph * para
Definition: editstr.h:160

Referenced by table_handle_tab().