1 /************************************************************************/
2 /* */
3 /* API for the document. (Editing and navigation.) */
4 /* */
5 /************************************************************************/
6
7 # include "tedConfig.h"
8
9 # include <stddef.h>
10 # include <stdio.h>
11 # include <string.h>
12 # include <ctype.h>
13 # include <sioGeneral.h>
14
15 # include "tedApp.h"
16 # include "tedEdit.h"
17 # include "tedSpellTool.h"
18 # include "tedDocFront.h"
19 # include "tedSelect.h"
20 # include "tedCopyPasteImpl.h"
21 # include "tedDocument.h"
22 # include "tedToolFront.h"
23 # include <docTreeType.h>
24 # include <docTextParticule.h>
25 # include <guiDrawingWidget.h>
26 # include <docEditCommand.h>
27 # include <docCollectStatistics.h>
28
29 # include <appDebugon.h>
30
31 /************************************************************************/
32 /* */
33 /* Handle a replace from one of the tools. */
34 /* (Used from the Find and Spell tools) */
35 /* */
36 /************************************************************************/
37
tedDocReplace(EditDocument * ed,const char * word)38 int tedDocReplace( EditDocument * ed,
39 const char * word )
40 {
41 TedDocument * td= (TedDocument *)ed->edPrivateData;
42
43 if ( ! word || ! word[0] )
44 { SDEB(word); return -1; }
45
46 if ( tedHasSelection( ed ) &&
47 ! tedHasIBarSelection( ed ) &&
48 td->tdSelectionDescription.sdCanReplace )
49 {
50 tedDocReplaceSelection( ed, EDITcmdREPLACE, word, strlen( word ),
51 td->tdTraced );
52 }
53
54 return 0;
55 }
56
57 /************************************************************************/
58 /* */
59 /* 'Select All' from the 'Edit' menu. */
60 /* */
61 /************************************************************************/
62
tedDocSelAll(EditDocument * ed)63 void tedDocSelAll( EditDocument * ed )
64 {
65 TedDocument * td= (TedDocument *)ed->edPrivateData;
66 BufferDocument * bd= td->tdDocument;
67
68 DocumentSelection dsNew;
69 SelectionGeometry sg;
70 SelectionDescription sd;
71
72 const int lastLine= 0;
73
74 if ( tedGetSelection( &dsNew, &sg, &sd,
75 (DocumentTree **)0, (struct BufferItem **)0, ed ) )
76 { docInitDocumentSelection( &dsNew ); }
77
78 if ( docSelectWholeBody( &dsNew, bd ) )
79 { LDEB(1); return; }
80
81 tedSetSelection( ed, &dsNew, lastLine, (int *)0, (int *)0 );
82
83 return;
84 }
85
86 /************************************************************************/
87 /* */
88 /* Navigation over columns. */
89 /* */
90 /************************************************************************/
91
tedDocSelectWholeCell(EditDocument * ed,int direction,int allRows)92 void tedDocSelectWholeCell( EditDocument * ed,
93 int direction,
94 int allRows )
95 {
96 DocumentSelection ds;
97 SelectionGeometry sg;
98 SelectionDescription sd;
99
100 const int lastLine= 0;
101
102 if ( tedGetSelection( &ds, &sg, &sd,
103 (DocumentTree **)0, (struct BufferItem **)0, ed ) )
104 { LDEB(1); return; }
105
106 if ( docSelectWholeCell( &ds, direction, allRows ) )
107 { LDEB(1); return; }
108
109 tedSetSelection( ed, &ds, lastLine, (int *)0, (int *)0 );
110
111 return;
112 }
113
tedDocSelectColumn(EditDocument * ed,int col)114 int tedDocSelectColumn( EditDocument * ed,
115 int col )
116 {
117 DocumentSelection ds;
118 SelectionGeometry sg;
119 SelectionDescription sd;
120
121 const int lastLine= 0;
122
123 if ( tedGetSelection( &ds, &sg, &sd,
124 (DocumentTree **)0, (struct BufferItem **)0, ed ) )
125 { LDEB(1); return -1; }
126
127 if ( docSelectColumn( &ds, col ) )
128 { LDEB(col); return -1; }
129
130 tedSetSelection( ed, &ds, lastLine, (int *)0, (int *)0 );
131
132 return 0;
133 }
134
135 /************************************************************************/
136 /* */
137 /* Navigation over rows. */
138 /* */
139 /************************************************************************/
140
tedDocSelectRow(EditDocument * ed,int direction,int allColumns)141 void tedDocSelectRow( EditDocument * ed,
142 int direction,
143 int allColumns )
144 {
145 DocumentSelection ds;
146 SelectionGeometry sg;
147 SelectionDescription sd;
148
149 const int lastLine= 0;
150
151 if ( tedGetSelection( &ds, &sg, &sd,
152 (DocumentTree **)0, (struct BufferItem **)0, ed ) )
153 { LDEB(1); return; }
154
155 if ( docSelectRow( &ds, direction, allColumns ) )
156 { LDEB(1); return; }
157
158 tedSetSelection( ed, &ds, lastLine, (int *)0, (int *)0 );
159
160 return;
161 }
162
163 /************************************************************************/
164 /* */
165 /* Select table. */
166 /* */
167 /************************************************************************/
168
tedDocSelectTable(EditDocument * ed)169 void tedDocSelectTable( EditDocument * ed )
170 {
171 DocumentSelection ds;
172 SelectionGeometry sg;
173 SelectionDescription sd;
174
175 const int lastLine= 0;
176
177 if ( tedGetSelection( &ds, &sg, &sd,
178 (DocumentTree **)0, (struct BufferItem **)0, ed ) )
179 { LDEB(1); return; }
180
181 if ( docSelectWholeTable( &ds ) )
182 { LDEB(1); return; }
183
184 tedSetSelection( ed, &ds, lastLine, (int *)0, (int *)0 );
185
186 return;
187 }
188
tedDocShiftRowsInTable(EditDocument * ed,int direction)189 int tedDocShiftRowsInTable( EditDocument * ed,
190 int direction )
191 {
192 TedDocument * td= (TedDocument *)ed->edPrivateData;
193
194 return tedEditShiftRowsInTable( ed, direction, td->tdTraced );
195 }
196
197 /************************************************************************/
198 /* */
199 /* Callback from 'Frame' tool. */
200 /* */
201 /************************************************************************/
202
tedDocSelectCurrentFrame(EditDocument * ed)203 int tedDocSelectCurrentFrame( EditDocument * ed )
204 {
205 DocumentSelection dsNew;
206 SelectionGeometry sg;
207 SelectionDescription sd;
208
209 const int lastLine= 0;
210
211 if ( tedGetSelection( &dsNew, &sg, &sd,
212 (DocumentTree **)0, (struct BufferItem **)0, ed ) )
213 { docInitDocumentSelection( &dsNew ); }
214
215 if ( docSelectFrameOfPosition( &dsNew, &(dsNew.dsHead) ) )
216 { LDEB(1); return -1; }
217
218 tedSetSelection( ed, &dsNew, lastLine, (int *)0, (int *)0 );
219
220 return 0;
221 }
222
APP_MENU_CALLBACK_H(tedDocInsertFootnote,option,voided,e)223 APP_MENU_CALLBACK_H( tedDocInsertFootnote, option, voided, e )
224 {
225 EditDocument * ed= (EditDocument *)voided;
226 TedDocument * td= (TedDocument *)ed->edPrivateData;
227
228 tedDocInsertNote( (EditDocument *)voided, DOCinFOOTNOTE, td->tdTraced );
229 }
230
APP_MENU_CALLBACK_H(tedDocInsertEndnote,option,voided,e)231 APP_MENU_CALLBACK_H( tedDocInsertEndnote, option, voided, e )
232 {
233 EditDocument * ed= (EditDocument *)voided;
234 TedDocument * td= (TedDocument *)ed->edPrivateData;
235
236 tedDocInsertNote( (EditDocument *)voided, DOCinENDNOTE, td->tdTraced );
237 }
238
APP_MENU_CALLBACK_H(tedDocTableSelectTable,option,voided,e)239 APP_MENU_CALLBACK_H( tedDocTableSelectTable, option, voided, e )
240 {
241 EditDocument * ed= (EditDocument *)voided;
242
243 tedDocSelectTable( ed );
244
245 return;
246 }
247
APP_MENU_CALLBACK_H(tedDocTableSelectRow,option,voided,e)248 APP_MENU_CALLBACK_H( tedDocTableSelectRow, option, voided, e )
249 {
250 EditDocument * ed= (EditDocument *)voided;
251 const int direction= 0;
252
253 const int allColumns= 1;
254
255 tedDocSelectRow( ed, direction, allColumns );
256
257 return;
258 }
259
APP_MENU_CALLBACK_H(tedDocTableSelectColumn,option,voided,e)260 APP_MENU_CALLBACK_H( tedDocTableSelectColumn, option, voided, e )
261 {
262 EditDocument * ed= (EditDocument *)voided;
263 const int direction= 0;
264
265 const int allRows= 1;
266
267 tedDocSelectWholeCell( ed, direction, allRows );
268
269 return;
270 }
271
APP_MENU_CALLBACK_H(tedDocEditUndo,option,voided,e)272 APP_MENU_CALLBACK_H( tedDocEditUndo, option, voided, e )
273 {
274 EditDocument * ed= (EditDocument *)voided;
275
276 tedDocUndo( ed );
277 }
278
APP_MENU_CALLBACK_H(tedDocEditRepeat,option,voided,e)279 APP_MENU_CALLBACK_H( tedDocEditRepeat, option, voided, e )
280 {
281 EditDocument * ed= (EditDocument *)voided;
282
283 tedDocRepeat( ed );
284 }
285
286 /************************************************************************/
287 /* */
288 /* Callback for the 'DrawTableGrid' toggle. */
289 /* */
290 /************************************************************************/
291
APP_MENU_CALLBACK_H(tedDocTableDrawGrid,option,voided,e)292 APP_MENU_CALLBACK_H( tedDocTableDrawGrid, option, voided, e )
293 {
294 EditDocument * ed= (EditDocument *)voided;
295 TedDocument * td= (TedDocument *)ed->edPrivateData;
296 int set;
297
298 set= appGuiGetMenuToggleStateFromCallback( option, e );
299
300 if ( set )
301 { td->tdDrawTableGrid= 1; }
302 else{ td->tdDrawTableGrid= -1; }
303
304 appDocExposeRectangle( ed, (const DocumentRectangle *)0, 0,0 );
305
306 return;
307 }
308
APP_MENU_CALLBACK_H(tedDocTableDeleteTable,option,voided,e)309 APP_MENU_CALLBACK_H( tedDocTableDeleteTable, option, voided, e )
310 {
311 EditDocument * ed= (EditDocument *)voided;
312 TedDocument * td= (TedDocument *)ed->edPrivateData;
313
314 tedDocDeleteTable( ed, td->tdTraced );
315 }
316
APP_MENU_CALLBACK_H(tedDocTableDeleteRow,option,voided,e)317 APP_MENU_CALLBACK_H( tedDocTableDeleteRow, option, voided, e )
318 {
319 EditDocument * ed= (EditDocument *)voided;
320 TedDocument * td= (TedDocument *)ed->edPrivateData;
321
322 tedDocDeleteRow( ed, td->tdTraced );
323 }
324
APP_MENU_CALLBACK_H(tedDocTableDeleteColumn,option,voided,e)325 APP_MENU_CALLBACK_H( tedDocTableDeleteColumn, option, voided, e )
326 {
327 EditDocument * ed= (EditDocument *)voided;
328 TedDocument * td= (TedDocument *)ed->edPrivateData;
329
330 tedDocDeleteColumn( ed, td->tdTraced );
331 }
332
333 /************************************************************************/
334 /* */
335 /* Insert a line/page/column break in the document. */
336 /* Insert a note separator. */
337 /* */
338 /* Note that page breaks and column breaks at the head of a paragraph */
339 /* are modified into a paragraph property by the editing code. */
340 /* */
341 /************************************************************************/
342
APP_MENU_CALLBACK_H(tedDocInsertLineBreak,option,voided,e)343 APP_MENU_CALLBACK_H( tedDocInsertLineBreak, option, voided, e )
344 {
345 EditDocument * ed= (EditDocument *)voided;
346 TedDocument * td= (TedDocument *)ed->edPrivateData;
347 const int redoLayout= 1;
348
349 tedEditInsertSpecialParticule( ed,
350 DOCkindLINEBREAK, EDITcmdREPLACE,
351 redoLayout, td->tdTraced );
352
353 return;
354 }
355
APP_MENU_CALLBACK_H(tedDocInsertPageBreak,option,voided,e)356 APP_MENU_CALLBACK_H( tedDocInsertPageBreak, option, voided, e )
357 {
358 EditDocument * ed= (EditDocument *)voided;
359 TedDocument * td= (TedDocument *)ed->edPrivateData;
360 const int redoLayout= 1;
361
362 tedEditInsertSpecialParticule( ed,
363 DOCkindPAGEBREAK, EDITcmdREPLACE_BODY_LEVEL,
364 redoLayout, td->tdTraced );
365
366 return;
367 }
368
APP_MENU_CALLBACK_H(tedDocInsertColumnBreak,option,voided,e)369 APP_MENU_CALLBACK_H( tedDocInsertColumnBreak, option, voided, e )
370 {
371 EditDocument * ed= (EditDocument *)voided;
372 TedDocument * td= (TedDocument *)ed->edPrivateData;
373 const int redoLayout= 1;
374
375 tedEditInsertSpecialParticule( ed,
376 DOCkindLINEBREAK, EDITcmdREPLACE_BODY_LEVEL, redoLayout, td->tdTraced );
377
378 return;
379 }
380
APP_MENU_CALLBACK_H(tedDocInsertChftnsep,option,voided,e)381 APP_MENU_CALLBACK_H( tedDocInsertChftnsep, option, voided, e )
382 {
383 EditDocument * ed= (EditDocument *)voided;
384 TedDocument * td= (TedDocument *)ed->edPrivateData;
385 const int redoLayout= 0;
386
387 tedEditInsertSpecialParticule( ed,
388 DOCkindLINEBREAK, EDITcmdREPLACE_FTNSEP, redoLayout, td->tdTraced );
389
390 return;
391 }
392
393 /************************************************************************/
394 /* */
395 /* Menu options to change paragraph alignment. */
396 /* */
397 /************************************************************************/
398
APP_MENU_CALLBACK_H(tedDocFormatAlignLeft,w,voided,e)399 APP_MENU_CALLBACK_H( tedDocFormatAlignLeft, w, voided, e )
400 {
401 EditDocument * ed= (EditDocument *)voided;
402 TedDocument * td= (TedDocument *)ed->edPrivateData;
403
404 tedDocFormatSetParaAlignment( ed, DOCthaLEFT, td->tdTraced );
405 }
406
APP_MENU_CALLBACK_H(tedDocFormatAlignRight,w,voided,e)407 APP_MENU_CALLBACK_H( tedDocFormatAlignRight, w, voided, e )
408 {
409 EditDocument * ed= (EditDocument *)voided;
410 TedDocument * td= (TedDocument *)ed->edPrivateData;
411
412 tedDocFormatSetParaAlignment( ed, DOCthaRIGHT, td->tdTraced );
413 }
414
APP_MENU_CALLBACK_H(tedDocFormatAlignCenter,w,voided,e)415 APP_MENU_CALLBACK_H( tedDocFormatAlignCenter, w, voided, e )
416 {
417 EditDocument * ed= (EditDocument *)voided;
418 TedDocument * td= (TedDocument *)ed->edPrivateData;
419
420 tedDocFormatSetParaAlignment( ed, DOCthaCENTERED, td->tdTraced );
421 }
422
APP_MENU_CALLBACK_H(tedDocFormatAlignJustify,w,voided,e)423 APP_MENU_CALLBACK_H( tedDocFormatAlignJustify, w, voided, e )
424 {
425 EditDocument * ed= (EditDocument *)voided;
426 TedDocument * td= (TedDocument *)ed->edPrivateData;
427
428 tedDocFormatSetParaAlignment( ed, DOCthaJUSTIFIED, td->tdTraced );
429 }
430
431 /************************************************************************/
432 /* */
433 /* Increase/Decrease the indentation level of the paragraphs in the */
434 /* selection. */
435 /* */
436 /************************************************************************/
437
APP_MENU_CALLBACK_H(tedDocFormatIncreaseIndent,w,voided,e)438 APP_MENU_CALLBACK_H( tedDocFormatIncreaseIndent, w, voided, e )
439 {
440 EditDocument * ed= (EditDocument *)voided;
441 TedDocument * td= (TedDocument *)ed->edPrivateData;
442 const int direction= 1;
443
444 tedFormatShiftIndent( ed, direction, td->tdTraced );
445 }
446
APP_MENU_CALLBACK_H(tedDocFormatDecreaseIndent,w,voided,e)447 APP_MENU_CALLBACK_H( tedDocFormatDecreaseIndent, w, voided, e )
448 {
449 EditDocument * ed= (EditDocument *)voided;
450 TedDocument * td= (TedDocument *)ed->edPrivateData;
451 const int direction= -1;
452
453 tedFormatShiftIndent( ed, direction, td->tdTraced );
454 }
455
456 /************************************************************************/
457 /* */
458 /* Replace the current selection with a page number field. */
459 /* */
460 /************************************************************************/
461
APP_MENU_CALLBACK_H(tedDocInsertPageNumber,option,voided,e)462 APP_MENU_CALLBACK_H( tedDocInsertPageNumber, option, voided, e )
463 {
464 EditDocument * ed= (EditDocument *)voided;
465 TedDocument * td= (TedDocument *)ed->edPrivateData;
466
467 tedInsertPageNumber( ed, td->tdTraced );
468 }
469
470 /************************************************************************/
471 /* */
472 /* Table related menu option callbacks. */
473 /* */
474 /************************************************************************/
475
APP_MENU_CALLBACK_H(tedDocTableInsertTable,option,voided,e)476 APP_MENU_CALLBACK_H( tedDocTableInsertTable, option, voided, e )
477 {
478 EditDocument * ed= (EditDocument *)voided;
479 TedDocument * td= (TedDocument *)ed->edPrivateData;
480
481 int rows= 2;
482 int columns= 2;
483
484
485 if ( tedInsertTable( ed, rows, columns, td->tdTraced ) )
486 { LLDEB(rows,columns); }
487
488 return;
489 }
490
APP_MENU_CALLBACK_H(tedDocTableAddRow,option,voided,e)491 APP_MENU_CALLBACK_H( tedDocTableAddRow, option, voided, e )
492 {
493 EditDocument * ed= (EditDocument *)voided;
494 TedDocument * td= (TedDocument *)ed->edPrivateData;
495 const int after= 1;
496
497 tedDocAddRowToTable( ed, after, td->tdTraced );
498
499 return;
500 }
501
APP_MENU_CALLBACK_H(tedDocTableAddColumn,option,voided,e)502 APP_MENU_CALLBACK_H( tedDocTableAddColumn, option, voided, e )
503 {
504 EditDocument * ed= (EditDocument *)voided;
505 TedDocument * td= (TedDocument *)ed->edPrivateData;
506 const int after= 1;
507
508 tedDocAddColumnToTable( ed, after, td->tdTraced );
509 }
510
511 /************************************************************************/
512 /* */
513 /* Font Menu. */
514 /* */
515 /************************************************************************/
516
APP_MENU_CALLBACK_H(tedDocFontPaste,option,voided,e)517 APP_MENU_CALLBACK_H( tedDocFontPaste, option, voided, e )
518 {
519 EditDocument * ed= (EditDocument *)voided;
520
521 appDocAskForPaste( ed, "RTFFONT" );
522 }
523
524 /************************************************************************/
525 /* */
526 /* Insert a section break. */
527 /* */
528 /************************************************************************/
529
APP_MENU_CALLBACK_H(tedDocMenuInsertSectBreak,option,voided,e)530 APP_MENU_CALLBACK_H( tedDocMenuInsertSectBreak, option, voided, e )
531 {
532 EditDocument * ed= (EditDocument *)voided;
533 TedDocument * td= (TedDocument *)ed->edPrivateData;
534
535 tedDocInsertSectBreak( ed, td->tdTraced );
536 }
537
538 /************************************************************************/
539 /* */
540 /* Toggle text attributes. */
541 /* */
542 /************************************************************************/
543
APP_MENU_CALLBACK_H(tedDocFontBold,option,voided,e)544 APP_MENU_CALLBACK_H( tedDocFontBold, option, voided, e )
545 {
546 int set= appGuiGetMenuToggleStateFromCallback( option, e );
547 tedToggleTextAttribute( (EditDocument *)voided, set, TApropFONTBOLD );
548 }
549
APP_MENU_CALLBACK_H(tedDocFontItalic,option,voided,e)550 APP_MENU_CALLBACK_H( tedDocFontItalic, option, voided, e )
551 {
552 int set= appGuiGetMenuToggleStateFromCallback( option, e );
553 tedToggleTextAttribute( (EditDocument *)voided, set, TApropFONTSLANTED );
554 }
555
APP_MENU_CALLBACK_H(tedDocFontUnderlined,option,voided,e)556 APP_MENU_CALLBACK_H( tedDocFontUnderlined, option, voided, e )
557 {
558 int set= appGuiGetMenuToggleStateFromCallback( option, e );
559 tedToggleTextAttribute( (EditDocument *)voided, set, TApropTEXTUNDERLINED );
560 }
561
562 /************************************************************************/
563 /* */
564 /* Change the base line of the current selection. */
565 /* */
566 /************************************************************************/
567
APP_MENU_CALLBACK_H(tedDocFontSupersub,option,voided,e)568 APP_MENU_CALLBACK_H( tedDocFontSupersub, option, voided, e )
569 {
570 EditDocument * ed= (EditDocument *)voided;
571 TedDocument * td= (TedDocument *)ed->edPrivateData;
572
573 int set;
574 int supersub= TEXTvaREGULAR;
575
576 set= appGuiGetMenuToggleStateFromCallback( option, e );
577 if ( set )
578 {
579 if ( option == td->tdFontSubscriptOption )
580 { supersub= TEXTvaSUBSCRIPT; }
581
582 if ( option == td->tdFontSuperscriptOption )
583 { supersub= TEXTvaSUPERSCRIPT; }
584 }
585 else{ supersub= TEXTvaREGULAR; }
586
587 tedSetFontSupersub( ed, supersub );
588 }
589
590 /************************************************************************/
591 /* */
592 /* Merge the paragraphs in the selection. */
593 /* */
594 /************************************************************************/
595
APP_MENU_CALLBACK_H(tedDocFormatOnePara,option,voided,e)596 APP_MENU_CALLBACK_H( tedDocFormatOnePara, option, voided, e )
597 {
598 EditDocument * ed= (EditDocument *)voided;
599 TedDocument * td= (TedDocument *)ed->edPrivateData;
600
601 tedMergeParagraphsInSelection( ed, td->tdTraced );
602 }
603
604 /************************************************************************/
605 /* */
606 /* Show or create a find tool. */
607 /* */
608 /************************************************************************/
609
APP_MENU_CALLBACK_H(tedDocToolFind,findOption,voided,e)610 APP_MENU_CALLBACK_H( tedDocToolFind, findOption, voided, e )
611 {
612 EditDocument * ed= (EditDocument *)voided;
613
614 tedShowFindTool( ed );
615
616 return;
617 }
618
APP_MENU_CALLBACK_H(tedDocToolFindNext,findOption,voided,e)619 APP_MENU_CALLBACK_H( tedDocToolFindNext, findOption, voided, e )
620 {
621 EditDocument * ed= (EditDocument *)voided;
622 TedDocument * td;
623
624 if ( ! ed )
625 { XDEB(ed); return; }
626 td= (TedDocument *)ed->edPrivateData;
627
628 if ( ! td->tdFindProg )
629 {
630 tedShowFindTool( ed );
631 return;
632 }
633
634 tedDocFindNext( ed );
635
636 return;
637 }
638
639 /************************************************************************/
640 /* */
641 /* Show or create a spelling tool. */
642 /* */
643 /************************************************************************/
644
APP_MENU_CALLBACK_H(tedDocToolSpell,spellOption,voided,e)645 APP_MENU_CALLBACK_H( tedDocToolSpell, spellOption, voided, e )
646 {
647 EditDocument * ed= (EditDocument *)voided;
648 EditApplication * ea= ed->edApplication;
649 TedDocument * td= (TedDocument *)ed->edPrivateData;
650
651 /* To get the correct title */
652 tedShowFormatTool( td->tdToolsFormatToolOption, ea );
653 tedAdaptFormatToolToDocument( ed, 0 );
654
655 tedFormatShowSpellPage( ea );
656
657 return;
658 }
659
660 /************************************************************************/
661 /* */
662 /* Custom 'Paste' functionality. */
663 /* */
664 /************************************************************************/
665
APP_MENU_CALLBACK_H(tedDocEditPaste,option,voided,e)666 APP_MENU_CALLBACK_H( tedDocEditPaste, option, voided, e )
667 {
668 EditDocument * ed= (EditDocument *)voided;
669 TedDocument * td= (TedDocument *)ed->edPrivateData;
670
671 if ( ! td->tdSelectionDescription.sdCanReplace )
672 { LDEB(td->tdSelectionDescription.sdCanReplace); return; }
673
674 /* 1 */
675 appDocAskForPaste( ed, "CLIPBOARD" );
676
677 return;
678 }
679
APP_MENU_CALLBACK_H(tedDocFormatPasteRul,fontsOption,voided,e)680 APP_MENU_CALLBACK_H( tedDocFormatPasteRul, fontsOption, voided, e )
681 {
682 EditDocument * ed= (EditDocument *)voided;
683
684 appDocAskForPaste( ed, "RTFRULER" );
685 }
686
APP_MENU_CALLBACK_H(tedDocFontCopy,fontsOption,voided,e)687 APP_MENU_CALLBACK_H( tedDocFontCopy, fontsOption, voided, e )
688 {
689 tedCopyFont( (EditDocument *)voided );
690 }
691
APP_MENU_CALLBACK_H(tedDocFormatCopyRul,fontsOption,voided,e)692 APP_MENU_CALLBACK_H( tedDocFormatCopyRul, fontsOption, voided, e )
693 {
694 tedCopyRuler( (EditDocument *)voided );
695 }
696
697 /************************************************************************/
698 /* */
699 /* Ted: The 'Set' button on the font tool was pushed. */
700 /* */
701 /************************************************************************/
702
tedDocFontToolSet(EditDocument * ed,const PropertyMask * taSetMask,const ExpandedTextAttribute * etaSet)703 int tedDocFontToolSet( EditDocument * ed,
704 const PropertyMask * taSetMask,
705 const ExpandedTextAttribute * etaSet )
706 {
707 TedDocument * td= (TedDocument *)ed->edPrivateData;
708 BufferDocument * bd= td->tdDocument;
709 DocumentProperties * dp= &(bd->bdProperties);
710 DocumentFontList * dfl= dp->dpFontList;
711
712 PropertyMask doneMask;
713 TextAttribute taSet;
714
715
716 utilInitTextAttribute( &taSet );
717 utilPropMaskClear( &doneMask );
718
719 docIndirectTextAttribute( &doneMask, &taSet, etaSet, taSetMask,
720 dfl, dp->dpColorPalette );
721
722 tedDocChangeTextAttribute( ed, taSetMask, &taSet, td->tdTraced );
723
724 return 0;
725 }
726
727 /************************************************************************/
728 /* */
729 /* Run the 'Link Dialog' from the 'Insert Link' menu option. */
730 /* */
731 /************************************************************************/
732
APP_MENU_CALLBACK_H(tedDocInsertLink,option,voided,e)733 APP_MENU_CALLBACK_H( tedDocInsertLink, option, voided, e )
734 {
735 EditDocument * ed= (EditDocument *)voided;
736 TedDocument * td= (TedDocument *)ed->edPrivateData;
737 EditApplication * ea= ed->edApplication;
738
739 tedShowFormatTool( td->tdToolsFormatToolOption, ea );
740
741 tedAdaptFormatToolToDocument( ed, 0 );
742
743 tedFormatShowLinkPage( ea );
744
745 return;
746 }
747
748 /************************************************************************/
749 /* */
750 /* Run the 'Bookmark Dialog' from the 'Insert Bookmark' menu option. */
751 /* */
752 /************************************************************************/
753
APP_MENU_CALLBACK_H(tedDocInsertBookmark,option,voided,e)754 APP_MENU_CALLBACK_H( tedDocInsertBookmark, option, voided, e )
755 {
756 EditDocument * ed= (EditDocument *)voided;
757 TedDocument * td= (TedDocument *)ed->edPrivateData;
758 EditApplication * ea= ed->edApplication;
759
760 tedShowFormatTool( td->tdToolsFormatToolOption, ea );
761
762 tedAdaptFormatToolToDocument( ed, 0 );
763
764 tedFormatShowBookmarkPage( ea );
765 }
766
767 /************************************************************************/
768 /* */
769 /* Table related menu option callbacks. */
770 /* */
771 /************************************************************************/
772
APP_MENU_CALLBACK_H(tedDocShowPageTool,pageOption,voided,e)773 APP_MENU_CALLBACK_H( tedDocShowPageTool, pageOption, voided, e )
774 {
775 EditDocument * ed= (EditDocument *)voided;
776 EditApplication * ea= ed->edApplication;
777
778 {
779 TedDocument * td= (TedDocument *)ed->edPrivateData;
780
781 /* To get the correct title */
782 tedShowFormatTool( td->tdToolsFormatToolOption, ea );
783 tedAdaptFormatToolToDocument( ed, 0 );
784
785 tedFormatShowPagePage( ea );
786 }
787
788 return;
789 }
790
791 /************************************************************************/
792 /* */
793 /* Font Menu. */
794 /* */
795 /************************************************************************/
796
APP_MENU_CALLBACK_H(tedDocToolFont,option,voided,e)797 APP_MENU_CALLBACK_H( tedDocToolFont, option, voided, e )
798 {
799 EditDocument * ed= (EditDocument *)voided;
800 EditApplication * ea= ed->edApplication;
801 TedDocument * td= (TedDocument *)ed->edPrivateData;
802
803 /* To get the correct title */
804 tedShowFormatTool( td->tdToolsFormatToolOption, ea );
805 tedAdaptFormatToolToDocument( ed, 0 );
806
807 tedFormatShowFontPage( ea );
808
809 return;
810 }
811
APP_MENU_CALLBACK_H(tedDocToolInsertSymbol,option,voided,e)812 APP_MENU_CALLBACK_H( tedDocToolInsertSymbol, option, voided, e )
813 {
814 EditDocument * ed= (EditDocument *)voided;
815 EditApplication * ea= ed->edApplication;
816 TedDocument * td= (TedDocument *)ed->edPrivateData;
817
818 /* To get the correct title */
819 tedShowFormatTool( td->tdToolsFormatToolOption, ea );
820 tedAdaptFormatToolToDocument( ed, 0 );
821
822 tedFormatShowSymbolPage( ea );
823
824 return;
825 }
826
827 /************************************************************************/
828 /* */
829 /* Show the format tool. */
830 /* */
831 /************************************************************************/
832
APP_MENU_CALLBACK_H(tedDocFormatTool,option,voided,e)833 APP_MENU_CALLBACK_H( tedDocFormatTool, option, voided, e )
834 {
835 EditDocument * ed= (EditDocument *)voided;
836 EditApplication * ea= ed->edApplication;
837
838 /* option == td->tdToolsFormatToolOption */
839
840 tedShowFormatTool( option, ea );
841 tedAdaptFormatToolToDocument( ed, 0 );
842 }
843
844 /************************************************************************/
845 /* */
846 /* Move the rezize handles of the image that is sellected as part of */
847 /* the scrollbar callback. */
848 /* */
849 /************************************************************************/
850
APP_SCROLLBAR_CALLBACK_H(tedDocHorizontalScrollbarCallback,w,voided,e)851 APP_SCROLLBAR_CALLBACK_H( tedDocHorizontalScrollbarCallback, w, voided, e )
852 {
853 EditDocument * ed= (EditDocument *)voided;
854 TedDocument * td= (TedDocument *)ed->edPrivateData;
855 int x= appGuiGetScrollbarValueFromCallback( w, e );
856
857 appDocScrollToX( ed, x );
858
859 if ( td->tdSelectionDescription.sdIsObjectSelection )
860 { tedMoveObjectWindows( ed ); }
861
862 return;
863 }
864
APP_SCROLLBAR_CALLBACK_H(tedDocVerticalScrollbarCallback,w,voided,e)865 APP_SCROLLBAR_CALLBACK_H( tedDocVerticalScrollbarCallback, w, voided, e )
866 {
867 EditDocument * ed= (EditDocument *)voided;
868 TedDocument * td= (TedDocument *)ed->edPrivateData;
869 int y= appGuiGetScrollbarValueFromCallback( w, e );
870
871 appDocScrollToY( ed, y );
872
873 if ( td->tdSelectionDescription.sdIsObjectSelection )
874 { tedMoveObjectWindows( ed ); }
875
876 return;
877 }
878
879 /************************************************************************/
880 /* */
881 /* Keep track of focus. */
882 /* */
883 /************************************************************************/
884
APP_EVENT_HANDLER_H(tedDocObserveFocus,w,voided,event)885 APP_EVENT_HANDLER_H( tedDocObserveFocus, w, voided, event )
886 {
887 EditDocument * ed= (EditDocument *)voided;
888
889 int inout= 0;
890
891 if ( guiDrawGetInoutFromFocusEvent( &inout, w, event ) )
892 { return; }
893
894 tedObserveFocus( ed, inout );
895 }
896
897 /************************************************************************/
898 /* */
899 /* Run document properties dialog. */
900 /* */
901 /************************************************************************/
902
APP_MENU_CALLBACK_H(tedDocFileProps,option,voided,e)903 APP_MENU_CALLBACK_H( tedDocFileProps, option, voided, e )
904 {
905 EditDocument * ed= (EditDocument *)voided;
906 TedDocument * td= (TedDocument *)ed->edPrivateData;
907 BufferDocument * bd= td->tdDocument;
908
909 DocumentStatistics ds;
910
911 docCollectDocumentStatistics( &ds, bd );
912
913 tedRunPropertyDialog( ed, &ds, option, "props" );
914 }
915
916
917 /************************************************************************/
918 /* */
919 /* Delete the table of contents */
920 /* */
921 /************************************************************************/
922
tedDocDeleteTocField(EditDocument * ed,int traced)923 void tedDocDeleteTocField( EditDocument * ed,
924 int traced )
925 {
926 tedDocFlattenTypedField( ed, DOCfkTOC,
927 (const PropertyMask *)0, (const TextAttribute *)0, traced );
928 }
929
930 /************************************************************************/
931 /* */
932 /* Unlock/Recover a document. */
933 /* */
934 /************************************************************************/
935
APP_MENU_CALLBACK_H(tedDocFileUnlock,option,voided,e)936 APP_MENU_CALLBACK_H( tedDocFileUnlock, option, voided, e )
937 {
938 EditDocument * ed= (EditDocument *)voided;
939
940 tedDocUnlock( ed );
941 }
942
APP_MENU_CALLBACK_H(tedDocFileRecover,option,voided,e)943 APP_MENU_CALLBACK_H( tedDocFileRecover, option, voided, e )
944 {
945 EditDocument * ed= (EditDocument *)voided;
946
947 tedDocRecover( ed );
948 }
949