1 /************************************************************************/
2 /*									*/
3 /*  Read/Write paragraph cell to/from RTF.				*/
4 /*									*/
5 /************************************************************************/
6 
7 #   include	"docRtfConfig.h"
8 
9 #   include	<stdio.h>
10 #   include	<ctype.h>
11 
12 #   include	<appDebugon.h>
13 
14 #   include	"docRtfReaderImpl.h"
15 #   include	"docRtfTagEnum.h"
16 
17 /************************************************************************/
18 /*									*/
19 /*  Handle a cell property when reading RTF.				*/
20 /*									*/
21 /************************************************************************/
22 
docRtfRememberCellShadingProperty(const RtfControlWord * rcw,int arg,RtfReader * rrc)23 int docRtfRememberCellShadingProperty(	const RtfControlWord *	rcw,
24 					int			arg,
25 					RtfReader *		rrc )
26     {
27     if  ( docSetShadingProperty( &(rrc->rrcCellShading), rcw->rcwID, arg ) < 0 )
28 	{ SLDEB(rcw->rcwWord,arg); return -1;	}
29 
30     PROPmaskADD( &(rrc->rrcCellPropertyMask), CLpropSHADING );
31     PROPmaskADD( &(rrc->rrcStyle.dsCellMask), CLpropSHADING );
32 
33     return 0;
34     }
35 
docRtfResetCellProperties(RtfReader * rrc)36 void docRtfResetCellProperties(	RtfReader *	rrc )
37     {
38     docCleanCellProperties( &(rrc->rrcCellProperties) );
39     docInitCellProperties( &(rrc->rrcCellProperties) );
40     docInitItemShading( &(rrc->rrcCellShading) );
41     utilPropMaskClear( &(rrc->rrcCellPropertyMask) );
42 
43     return;
44     }
45 
docRtfSetCellX(RtfReader * rrc,int arg)46 static int docRtfSetCellX(		RtfReader *		rrc,
47 					int			arg )
48     {
49     CellProperties *	cp= &(rrc->rrcCellProperties);
50 
51     const int		col= -1;
52     const int		shiftTail= 0;
53 
54     cp->cpRightBoundaryTwips= arg;
55 
56     cp->cpShadingNumber= docItemShadingNumber( rrc->rrDocument,
57 						    &(rrc->rrcCellShading) );
58     if  ( cp->cpShadingNumber < 0 )
59 	{ LDEB(cp->cpShadingNumber);	}
60 
61     if  ( docInsertRowColumn( &(rrc->rrcRowProperties),
62 		    col, shiftTail, cp, (const DocumentAttributeMap *)0 ) )
63 	{ LDEB(rrc->rrcRowProperties.rpCellCount); return -1; }
64 
65     PROPmaskADD( &(rrc->rrcCellPropertyMask), CLpropCELLX );
66     PROPmaskADD( &(rrc->rrcStyle.dsCellMask), CLpropCELLX );
67     PROPmaskADD( &(rrc->rrcRowPropertyMask), RPpropCELL_LAYOUT );
68 
69     docRowMaskApplyCellMask( &(rrc->rrcRowPropertyMask),
70 						&(rrc->rrcCellPropertyMask) );
71 
72     return 0;
73     }
74 
docRtfRememberCellProperty(const RtfControlWord * rcw,int arg,RtfReader * rrc)75 int docRtfRememberCellProperty(		const RtfControlWord *	rcw,
76 					int			arg,
77 					RtfReader *		rrc )
78     {
79     switch( rcw->rcwID )
80 	{
81 	case CLprop_NONE:
82 	    docRtfResetCellProperties( rrc );
83 	    return 0;
84 
85 	case CLpropCELLX:
86 	    if  ( arg < 0 )
87 		{
88 		DocumentGeometry *	dg;
89 
90 		SLDEB(rcw->rcwWord,arg);
91 
92 		dg= &(rrc->rrcSectionProperties.spDocumentGeometry);
93 
94 		arg= dg->dgPageWideTwips-
95 			    ( dg->dgRightMarginTwips+ dg->dgLeftMarginTwips );
96 		}
97 
98 	    if  ( docRtfSetCellX( rrc, arg ) )
99 		{ SLDEB(rcw->rcwWord,arg); return -1;	}
100 
101 	    docRtfResetCellProperties( rrc );
102 	    return 0;
103 
104 	/**/
105 	case CLpropTOP_BORDER:
106 	case CLpropBOTTOM_BORDER:
107 	case CLpropLEFT_BORDER:
108 	case CLpropRIGHT_BORDER:
109 	    arg= docRtfReadGetBorderNumber( rrc );
110 	    if  ( arg < 0 )
111 		{ SLDEB(rcw->rcwWord,arg); return -1;	}
112 	    break;
113 
114 	case RTFid_NOT_SUPPORTED:
115 	    return 0;
116 
117 	case CLpropHOR_MERGE:
118 	case CLpropTEXT_FLOW:
119 	case CLpropVALIGN:
120 	case CLpropVERT_MERGE:
121 	    arg= rcw->rcwEnumValue;
122 	    break;
123 	}
124 
125     PROPmaskADD( &(rrc->rrcCellPropertyMask), rcw->rcwID );
126     if  ( docSetCellProperty( &(rrc->rrcCellProperties), rcw->rcwID, arg ) < 0 )
127 	{ SLDEB(rcw->rcwWord,arg); return -1;	}
128 
129     PROPmaskADD( &(rrc->rrcStyle.dsCellMask), rcw->rcwID );
130     if  ( docSetCellProperty( &(rrc->rrcStyle.dsCellProps),
131 						rcw->rcwID, arg ) < 0 )
132 	{ SLDEB(rcw->rcwWord,arg); return -1;	}
133 
134     return 0;
135     }
136 
137 /************************************************************************/
138 /*									*/
139 /*  Cell instance properties: How table styles are applied.		*/
140 /*									*/
141 /************************************************************************/
142 
docRtfRememberCellInstanceProperty(const RtfControlWord * rcw,int arg,RtfReader * rrc)143 int docRtfRememberCellInstanceProperty(	const RtfControlWord *	rcw,
144 					int			arg,
145 					RtfReader *	rrc )
146     {
147     return 0;
148     }
149