1 /************************************************************************/
2 /* */
3 /* Ted: application level API for menu and tools. */
4 /* */
5 /************************************************************************/
6
7 # include "tedConfig.h"
8
9 # include <stddef.h>
10 # include <stdio.h>
11 # include <ctype.h>
12 # include <sioGeneral.h>
13
14 # include "tedAppFront.h"
15 # include "tedDocFront.h"
16 # include "tedDocument.h"
17
18 # include "tedApp.h"
19
20 # include <appDebugon.h>
21
22 /************************************************************************/
23 /* */
24 /* Handle a replace from one of the tools. */
25 /* (Used from the Find and Spell tools) */
26 /* */
27 /************************************************************************/
28
tedAppReplace(void * voidea,const char * word)29 void tedAppReplace( void * voidea,
30 const char * word )
31 {
32 EditApplication * ea= (EditApplication *)voidea;
33 EditDocument * ed= ea->eaCurrentDocument;
34
35 if ( ! ed )
36 { XDEB(ed); return; }
37
38 (void) tedDocReplace( ed, word );
39
40 return;
41 }
42
tedAppSelectCurrentFrame(EditApplication * ea)43 int tedAppSelectCurrentFrame( EditApplication * ea )
44 {
45 EditDocument * ed= ea->eaCurrentDocument;
46 if ( ! ed )
47 { XDEB(ed); return -1; }
48
49 return tedDocSelectCurrentFrame( ed );
50 }
51
tedAppSelectWholeCell(EditApplication * ea,int direction,int allRows)52 void tedAppSelectWholeCell( EditApplication * ea,
53 int direction,
54 int allRows )
55 {
56 EditDocument * ed= ea->eaCurrentDocument;
57 if ( ! ed )
58 { XDEB(ed); return; }
59
60 tedDocSelectWholeCell( ed, direction, allRows );
61 }
62
tedAppSelectRow(EditApplication * ea,int direction,int allColumns)63 void tedAppSelectRow( EditApplication * ea,
64 int direction,
65 int allColumns )
66 {
67 EditDocument * ed= ea->eaCurrentDocument;
68 if ( ! ed )
69 { XDEB(ed); return; }
70
71 tedDocSelectRow( ed, direction, allColumns );
72 }
73
tedAppSelectTable(EditApplication * ea)74 void tedAppSelectTable( EditApplication * ea )
75 {
76 EditDocument * ed= ea->eaCurrentDocument;
77 if ( ! ed )
78 { XDEB(ed); return; }
79
80 tedDocSelectTable( ed );
81 }
82
tedAppGotoNoteDef(EditApplication * ea)83 void tedAppGotoNoteDef( EditApplication * ea )
84 {
85 EditDocument * ed= ea->eaCurrentDocument;
86 if ( ! ed )
87 { XDEB(ed); return; }
88
89 tedDocGotoNoteDef( ed );
90 }
91
tedAppDeleteCurrentFrame(EditApplication * ea)92 int tedAppDeleteCurrentFrame( EditApplication * ea )
93 {
94 EditDocument * ed= ea->eaCurrentDocument;
95
96 if ( ! ed )
97 { XDEB(ed); return -1; }
98
99 return tedDocDeleteCurrentFrame( ed,
100 ((TedDocument *)ed->edPrivateData)->tdTraced );
101 }
102
tedAppDeleteSelectedParagraphs(EditApplication * ea)103 int tedAppDeleteSelectedParagraphs( EditApplication * ea )
104 {
105 EditDocument * ed= ea->eaCurrentDocument;
106
107 if ( ! ed )
108 { XDEB(ed); return -1; }
109
110 return tedDocDeleteSelectedParagraphs( ed,
111 ((TedDocument *)ed->edPrivateData)->tdTraced );
112 }
113
tedAppDeleteSelectedSections(EditApplication * ea)114 int tedAppDeleteSelectedSections( EditApplication * ea )
115 {
116 EditDocument * ed= ea->eaCurrentDocument;
117
118 if ( ! ed )
119 { XDEB(ed); return -1; }
120
121 return tedDocDeleteSelectedSections( ed,
122 ((TedDocument *)ed->edPrivateData)->tdTraced );
123 }
124
tedAppInsertParagraph(EditApplication * ea,int after)125 int tedAppInsertParagraph( EditApplication * ea,
126 int after )
127 {
128 EditDocument * ed= ea->eaCurrentDocument;
129
130 if ( ! ed )
131 { XDEB(ed); return -1; }
132
133 return tedDocInsertParagraph( ed, after,
134 ((TedDocument *)ed->edPrivateData)->tdTraced );
135 }
136
tedAppInsertSection(EditApplication * ea,int after)137 int tedAppInsertSection( EditApplication * ea,
138 int after )
139 {
140 EditDocument * ed= ea->eaCurrentDocument;
141
142 if ( ! ed )
143 { XDEB(ed); return -1; }
144
145 return tedDocInsertSection( ed, after,
146 ((TedDocument *)ed->edPrivateData)->tdTraced );
147 }
148
tedAppSetTocField(EditApplication * ea,const TocField * tf)149 void tedAppSetTocField( EditApplication * ea,
150 const TocField * tf )
151 {
152 EditDocument * ed= ea->eaCurrentDocument;
153
154 if ( ! ed )
155 { XDEB(ed); }
156
157 tedDocSetTocField( ed, tf, ((TedDocument *)ed->edPrivateData)->tdTraced );
158 }
159
tedAppAddTocField(EditApplication * ea,const TocField * tf)160 void tedAppAddTocField( EditApplication * ea,
161 const TocField * tf )
162 {
163 EditDocument * ed= ea->eaCurrentDocument;
164
165 if ( ! ed )
166 { XDEB(ed); }
167
168 tedDocAddTocField( ed, tf, ((TedDocument *)ed->edPrivateData)->tdTraced );
169 }
170
tedAppDeleteTocField(EditApplication * ea)171 void tedAppDeleteTocField( EditApplication * ea )
172 {
173 EditDocument * ed= ea->eaCurrentDocument;
174
175 if ( ! ed )
176 { XDEB(ed); return; }
177
178 tedDocDeleteTocField( ed, ((TedDocument *)ed->edPrivateData)->tdTraced );
179 }
180
tedAppSetHyperlink(EditApplication * ea,const HyperlinkField * hf)181 int tedAppSetHyperlink( EditApplication * ea,
182 const HyperlinkField * hf )
183 {
184 EditDocument * ed= ea->eaCurrentDocument;
185
186 if ( ! ed )
187 { XDEB(ed); return -1; }
188
189 return tedDocSetHyperlink( ed, hf,
190 ((TedDocument *)ed->edPrivateData)->tdTraced );
191 }
192
tedAppRemoveHyperlink(EditApplication * ea)193 int tedAppRemoveHyperlink( EditApplication * ea )
194 {
195 EditDocument * ed= ea->eaCurrentDocument;
196
197 if ( ! ed )
198 { XDEB(ed); return -1; }
199
200 return tedDocRemoveHyperlink( ed,
201 ((TedDocument *)ed->edPrivateData)->tdTraced );
202 }
203
tedAppFindBookmarkField(DocumentField ** pDf,EditApplication * ea,const MemoryBuffer * markName)204 int tedAppFindBookmarkField( DocumentField ** pDf,
205 EditApplication * ea,
206 const MemoryBuffer * markName )
207 {
208 EditDocument * ed= ea->eaCurrentDocument;
209
210 if ( ! ed )
211 { XDEB(ed); return -1; }
212
213 return tedDocFindBookmarkField( pDf, ed, markName );
214 }
215
tedAppSetBookmark(EditApplication * ea,const MemoryBuffer * markName)216 int tedAppSetBookmark( EditApplication * ea,
217 const MemoryBuffer * markName )
218 {
219 EditDocument * ed= ea->eaCurrentDocument;
220
221 if ( ! ed )
222 { XDEB(ed); return -1; }
223
224 return tedDocSetBookmark( ed, markName,
225 ((TedDocument *)ed->edPrivateData)->tdTraced );
226 }
227
tedAppRemoveBookmark(EditApplication * ea)228 int tedAppRemoveBookmark( EditApplication * ea )
229 {
230 EditDocument * ed= ea->eaCurrentDocument;
231
232 if ( ! ed )
233 { XDEB(ed); return -1; }
234
235 return tedDocRemoveBookmark( ed,
236 ((TedDocument *)ed->edPrivateData)->tdTraced );
237 }
238
tedAppGoToBookmark(EditApplication * ea,const MemoryBuffer * markName)239 int tedAppGoToBookmark( EditApplication * ea,
240 const MemoryBuffer * markName )
241 {
242 EditDocument * ed= ea->eaCurrentDocument;
243
244 if ( ! ed )
245 { XDEB(ed); return -1; }
246
247 return tedDocGoToBookmark( ed, markName );
248 }
249
tedAppSetParaOutlineLevel(EditApplication * ea,int level)250 void tedAppSetParaOutlineLevel( EditApplication * ea,
251 int level )
252 {
253 EditDocument * ed= ea->eaCurrentDocument;
254
255 if ( ! ed )
256 { XDEB(ed); return; }
257
258 tedDocSetParaOutlineLevel( ed, level,
259 ((TedDocument *)ed->edPrivateData)->tdTraced );
260
261 return;
262 }
263
tedAppDeleteTable(EditApplication * ea)264 void tedAppDeleteTable( EditApplication * ea )
265 {
266 EditDocument * ed= ea->eaCurrentDocument;
267
268 if ( ! ed )
269 { XDEB(ed); return; }
270
271 tedDocDeleteTable( ed, ((TedDocument *)ed->edPrivateData)->tdTraced );
272 }
273
tedAppDeleteRow(EditApplication * ea)274 void tedAppDeleteRow( EditApplication * ea )
275 {
276 EditDocument * ed= ea->eaCurrentDocument;
277
278 if ( ! ed )
279 { XDEB(ed); return; }
280
281 tedDocDeleteRow( ed, ((TedDocument *)ed->edPrivateData)->tdTraced );
282 }
283
tedAppDeleteColumn(EditApplication * ea)284 void tedAppDeleteColumn( EditApplication * ea )
285 {
286 EditDocument * ed= ea->eaCurrentDocument;
287
288 if ( ! ed )
289 { XDEB(ed); return; }
290
291 tedDocDeleteColumn( ed, ((TedDocument *)ed->edPrivateData)->tdTraced );
292 }
293
tedAppAddRowToTable(EditApplication * ea,int after)294 void tedAppAddRowToTable( EditApplication * ea,
295 int after )
296 {
297 EditDocument * ed= ea->eaCurrentDocument;
298
299 if ( ! ed )
300 { XDEB(ed); return; }
301
302 tedDocAddRowToTable( ed, after,
303 ((TedDocument *)ed->edPrivateData)->tdTraced );
304
305 return;
306 }
307
tedAppAddColumnToTable(EditApplication * ea,int after)308 void tedAppAddColumnToTable( EditApplication * ea,
309 int after )
310 {
311 EditDocument * ed= ea->eaCurrentDocument;
312
313 if ( ! ed )
314 { XDEB(ed); return; }
315
316 tedDocAddColumnToTable( ed, after,
317 ((TedDocument *)ed->edPrivateData)->tdTraced );
318
319 return;
320 }
321
tedAppDeleteHeaderFooter(EditApplication * ea,int treeType)322 void tedAppDeleteHeaderFooter( EditApplication * ea,
323 int treeType )
324 {
325 EditDocument * ed= ea->eaCurrentDocument;
326
327 if ( ! ed )
328 { XDEB(ed); return; }
329
330 tedDocDeleteHeaderFooter( ed, treeType,
331 ((TedDocument *)ed->edPrivateData)->tdTraced );
332
333 return;
334 }
335
tedAppEditHeaderFooter(EditApplication * ea,APP_WIDGET relative,APP_WIDGET option,int treeType)336 void tedAppEditHeaderFooter( EditApplication * ea,
337 APP_WIDGET relative,
338 APP_WIDGET option,
339 int treeType )
340 {
341 EditDocument * ed= ea->eaCurrentDocument;
342
343 if ( ! ed )
344 { XDEB(ed); return; }
345
346 tedDocEditHeaderFooter( ed, relative, option, treeType );
347
348 return;
349 }
350
tedAppChangeParagraphProperties(EditApplication * ea,const PropertyMask * ppSetMask,const ParagraphProperties * ppNew)351 int tedAppChangeParagraphProperties(
352 EditApplication * ea,
353 const PropertyMask * ppSetMask,
354 const ParagraphProperties * ppNew )
355 {
356 EditDocument * ed= ea->eaCurrentDocument;
357
358 if ( ! ed )
359 { XDEB(ed); return -1; }
360
361 return tedDocChangeParagraphProperties( ed, ppSetMask, ppNew,
362 ((TedDocument *)ed->edPrivateData)->tdTraced );
363 }
364
tedAppChangeSectionProperties(EditApplication * ea,const PropertyMask * spSetMask,const SectionProperties * spNew)365 int tedAppChangeSectionProperties(
366 EditApplication * ea,
367 const PropertyMask * spSetMask,
368 const SectionProperties * spNew )
369 {
370 EditDocument * ed= ea->eaCurrentDocument;
371
372 if ( ! ed )
373 { XDEB(ed); return -1; }
374
375 return tedDocChangeSectionProperties( ed, spSetMask, spNew,
376 ((TedDocument *)ed->edPrivateData)->tdTraced );
377 }
378
tedAppChangeAllSectionProperties(EditApplication * ea,const PropertyMask * spSetMask,const SectionProperties * spNew,const PropertyMask * dpSetMask,const DocumentProperties * dpSet)379 int tedAppChangeAllSectionProperties(
380 EditApplication * ea,
381 const PropertyMask * spSetMask,
382 const SectionProperties * spNew,
383 const PropertyMask * dpSetMask,
384 const DocumentProperties * dpSet )
385 {
386 EditDocument * ed= ea->eaCurrentDocument;
387
388 if ( ! ed )
389 { XDEB(ed); return -1; }
390
391 return tedDocChangeAllSectionProperties( ed,
392 spSetMask, spNew, dpSetMask, dpSet,
393 ((TedDocument *)ed->edPrivateData)->tdTraced );
394 }
395
tedAppSetParagraphTabs(EditApplication * ea,const struct TabStopList * tsl)396 int tedAppSetParagraphTabs( EditApplication * ea,
397 const struct TabStopList * tsl )
398 {
399 EditDocument * ed= ea->eaCurrentDocument;
400
401 if ( ! ed )
402 { XDEB(ed); return -1; }
403
404 return tedDocSetParagraphTabs( ed, tsl,
405 ((TedDocument *)ed->edPrivateData)->tdTraced );
406 }
407
tedAppSetDocumentProperties(EditApplication * ea,const PropertyMask * dpSetMask,const DocumentProperties * dpSet)408 int tedAppSetDocumentProperties( EditApplication * ea,
409 const PropertyMask * dpSetMask,
410 const DocumentProperties * dpSet )
411 {
412 EditDocument * ed= ea->eaCurrentDocument;
413
414 if ( ! ed )
415 { XDEB(ed); return -1; }
416
417 return tedDocSetDocumentProperties( ed, dpSetMask, dpSet,
418 ((TedDocument *)ed->edPrivateData)->tdTraced );
419 }
420
tedAppSetNewList(EditApplication * ea)421 int tedAppSetNewList( EditApplication * ea )
422 {
423 EditDocument * ed= ea->eaCurrentDocument;
424
425 if ( ! ed )
426 { XDEB(ed); return -1; }
427
428 return tedDocSetNewList( ed,
429 ((TedDocument *)ed->edPrivateData)->tdTraced );
430 }
431
tedAppSetImageProperties(EditApplication * ea,const PropertyMask * pipSetMask,const PictureProperties * pip)432 void tedAppSetImageProperties( EditApplication * ea,
433 const PropertyMask * pipSetMask,
434 const PictureProperties * pip )
435 {
436 EditDocument * ed= ea->eaCurrentDocument;
437
438 if ( ! ed )
439 { XDEB(ed); return; }
440
441 tedDocSetImageProperties( ed, pipSetMask, pip,
442 ((TedDocument *)ed->edPrivateData)->tdTraced );
443
444 return;
445 }
446
tedAppChangeCurrentNote(EditApplication * ea,const PropertyMask * npSetMask,const NoteProperties * npSet)447 void tedAppChangeCurrentNote( EditApplication * ea,
448 const PropertyMask * npSetMask,
449 const NoteProperties * npSet )
450 {
451 EditDocument * ed= ea->eaCurrentDocument;
452
453 if ( ! ed )
454 { XDEB(ed); return; }
455
456 tedDocChangeCurrentNote( ed, npSetMask, npSet,
457 ((TedDocument *)ed->edPrivateData)->tdTraced );
458
459 return;
460 }
461
tedAppGotoNoteRef(EditApplication * ea)462 void tedAppGotoNoteRef( EditApplication * ea )
463 {
464 EditDocument * ed= ea->eaCurrentDocument;
465
466 if ( ! ed )
467 { XDEB(ed); return; }
468
469 tedDocGotoNoteRef( ed );
470
471 return;
472 }
473
tedAppNextNote(EditApplication * ea)474 void tedAppNextNote( EditApplication * ea )
475 {
476 EditDocument * ed= ea->eaCurrentDocument;
477
478 if ( ! ed )
479 { XDEB(ed); return; }
480
481 tedDocNextNote( ed );
482
483 return;
484 }
485
tedAppPrevNote(EditApplication * ea)486 void tedAppPrevNote( EditApplication * ea )
487 {
488 EditDocument * ed= ea->eaCurrentDocument;
489
490 if ( ! ed )
491 { XDEB(ed); return; }
492
493 tedDocPrevNote( ed );
494
495 return;
496 }
497
tedAppShiftRowsInTable(EditApplication * ea,int direction)498 int tedAppShiftRowsInTable( EditApplication * ea,
499 int direction )
500 {
501 EditDocument * ed= ea->eaCurrentDocument;
502
503 if ( ! ed )
504 { XDEB(ed); return -1; }
505
506 return tedDocShiftRowsInTable( ed, direction );
507 }
508
tedAppSetTableProperties(EditApplication * ea,int wholeRow,int wholeColumn,const PropertyMask * cpSetMask,const CellProperties * cpSet,const PropertyMask * rpSetMask,const RowProperties * rpSet)509 void tedAppSetTableProperties( EditApplication * ea,
510 int wholeRow,
511 int wholeColumn,
512 const PropertyMask * cpSetMask,
513 const CellProperties * cpSet,
514 const PropertyMask * rpSetMask,
515 const RowProperties * rpSet )
516 {
517 EditDocument * ed= ea->eaCurrentDocument;
518
519 if ( ! ed )
520 { XDEB(ed); return; }
521
522 tedDocSetTableProperties( ed, wholeRow, wholeColumn,
523 cpSetMask, cpSet, rpSetMask, rpSet,
524 ((TedDocument *)ed->edPrivateData)->tdTraced );
525
526 return;
527 }
528
tedAppFollowLink(APP_WIDGET option,EditApplication * ea,const MemoryBuffer * fileName,const MemoryBuffer * markName)529 int tedAppFollowLink( APP_WIDGET option,
530 EditApplication * ea,
531 const MemoryBuffer * fileName,
532 const MemoryBuffer * markName )
533 {
534 EditDocument * ed= ea->eaCurrentDocument;
535
536 if ( ! ed )
537 { XDEB(ed); return -1; }
538
539 return tedDocFollowLink( option, ed, fileName, markName );
540 }
541
tedAppChangeCurrentList(EditApplication * ea,const struct DocumentList * dlNew)542 int tedAppChangeCurrentList( EditApplication * ea,
543 const struct DocumentList * dlNew )
544 {
545 EditDocument * ed= ea->eaCurrentDocument;
546
547 if ( ! ed )
548 { XDEB(ed); return -1; }
549
550 return tedDocChangeCurrentList( ed, dlNew,
551 ((TedDocument *)ed->edPrivateData)->tdTraced );
552 }
553
tedAppFindNext(void * voidea)554 int tedAppFindNext( void * voidea )
555 {
556 EditApplication * ea= (EditApplication *)voidea;
557 EditDocument * ed= ea->eaCurrentDocument;
558
559 if ( ! ed )
560 { XDEB(ed); return -1; }
561
562 return tedDocFindNext( ed );
563 }
564
tedAppFindPrev(void * voidea)565 int tedAppFindPrev( void * voidea )
566 {
567 EditApplication * ea= (EditApplication *)voidea;
568 EditDocument * ed= ea->eaCurrentDocument;
569
570 if ( ! ed )
571 { XDEB(ed); return -1; }
572
573 return tedDocFindPrev( ed );
574 }
575
tedAppListFontToolSet(void * voidea,const PropertyMask * taSetMask,const ExpandedTextAttribute * etaSet)576 int tedAppListFontToolSet( void * voidea,
577 const PropertyMask * taSetMask,
578 const ExpandedTextAttribute * etaSet )
579 {
580 EditApplication * ea= (EditApplication *)voidea;
581 EditDocument * ed= ea->eaCurrentDocument;
582
583 if ( ! ed )
584 { XDEB(ed); return -1; }
585
586 return tedDocListFontToolSet( ed, taSetMask, etaSet );
587 }
588
tedAppFontToolSet(void * voidea,const PropertyMask * taSetMask,const ExpandedTextAttribute * etaSet)589 int tedAppFontToolSet( void * voidea,
590 const PropertyMask * taSetMask,
591 const ExpandedTextAttribute * etaSet )
592 {
593 EditApplication * ea= (EditApplication *)voidea;
594 EditDocument * ed= ea->eaCurrentDocument;
595
596 if ( ! ed )
597 { XDEB(ed); return -1; }
598
599 return tedDocFontToolSet( ed, taSetMask, etaSet );
600 }
601
602