1 /************************************************************************/
2 /*									*/
3 /*  Read the various document tables of an RTF text file into a		*/
4 /*  BufferDocument.							*/
5 /*									*/
6 /************************************************************************/
7 
8 #   include	"docRtfConfig.h"
9 
10 #   include	<stdio.h>
11 #   include	<ctype.h>
12 
13 #   include	<appDebugon.h>
14 
15 #   include	"docRtfReaderImpl.h"
16 
17 /************************************************************************/
18 /*									*/
19 /*  Read a color table.							*/
20 /*  Note that like the font table, the color table is flat. It does	*/
21 /*  not have groups for the colors.					*/
22 /*									*/
23 /************************************************************************/
24 
docRtfSaveColor(RtfReader * rrc,const char * text,int len)25 static int docRtfSaveColor(	RtfReader *		rrc,
26 				const char *		text,
27 				int			len )
28     {
29     DocumentProperties *	dp= &(rrc->rrDocument->bdProperties);
30     int				n= dp->dpColorPalette->cpColorCount;
31 
32     if  ( utilPaletteSetCount( dp->dpColorPalette, n+ 1 ) )
33 	{ LDEB(n); return -1;	}
34 
35     dp->dpColorPalette->cpColors[n]= rrc->rrcColor;
36 
37     if  ( ! rrc->rrcGotComponent )
38 	{
39 	if  ( dp->dpDefaultColor < 0 )
40 	    { dp->dpDefaultColor= n;	}
41 	}
42 
43     rrc->rrcGotComponent= 0;
44     return 0;
45     }
46 
docRtfColorIgnored(const RtfControlWord * rcw,int arg,RtfReader * rrc)47 int docRtfColorIgnored(	const RtfControlWord *	rcw,
48 			int			arg,
49 			RtfReader *		rrc )
50     { return 0;	}
51 
docRtfColorComp(const RtfControlWord * rcw,int arg,RtfReader * rrc)52 int docRtfColorComp(	const RtfControlWord *	rcw,
53 			int			arg,
54 			RtfReader *		rrc )
55     {
56     switch( rcw->rcwID )
57 	{
58 	case RGBAcompRED:
59 	    rrc->rrcGotComponent= 1;
60 	    rrc->rrcColor.rgb8Red= arg;
61 	    break;
62 	case RGBAcompGREEN:
63 	    rrc->rrcGotComponent= 1;
64 	    rrc->rrcColor.rgb8Green= arg;
65 	    break;
66 	case RGBAcompBLUE:
67 	    rrc->rrcGotComponent= 1;
68 	    rrc->rrcColor.rgb8Blue= arg;
69 	    break;
70 	default:
71 	    /* SLDEB(rcw->rcwWord,arg); */
72 	    break;
73 	}
74 
75     return 0;
76     }
77 
docRtfColorTable(const RtfControlWord * rcw,int arg,RtfReader * rrc)78 int docRtfColorTable(		const RtfControlWord *	rcw,
79 				int			arg,
80 				RtfReader *		rrc )
81     {
82     rrc->rrcGotComponent= 0;
83 
84     rrc->rrcColor.rgb8Red= 255;
85     rrc->rrcColor.rgb8Green= 255;
86     rrc->rrcColor.rgb8Blue= 255;
87     rrc->rrcColor.rgb8Alpha= 255;
88 
89     if  ( docRtfReadGroup( rcw, 0, 0, rrc,
90 		    (RtfControlWord *)0, docRtfSaveColor, (RtfCommitGroup)0 ) )
91 	{ SLDEB(rcw->rcwWord,arg); return -1;	}
92 
93     return 0;
94     }
95 
96