File: docRtfCellProperties.c

package info (click to toggle)
ted 2.16-5
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 13,944 kB
  • ctags: 20,273
  • sloc: ansic: 167,980; makefile: 12,518; sh: 263
file content (290 lines) | stat: -rw-r--r-- 7,199 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
/************************************************************************/
/*									*/
/*  Read/Write paragraph cell to/from RTF.				*/
/*									*/
/************************************************************************/

#   include	"tedConfig.h"

#   include	<stdlib.h>
#   include	<string.h>
#   include	<stdio.h>
#   include	<ctype.h>

#   include	<appDebugon.h>

#   include	"docRtf.h"

/************************************************************************/
/*									*/
/*  Save Cell Properties.						*/
/*									*/
/************************************************************************/

void docRtfSaveCellProperties(		const CellProperties *	cp,
					int *			pCol,
					int			shiftLeft,
					SimpleOutputStream *	sos )
    {
    switch( cp->cpTextVerticalAlignment )
	{
	case DOCtvaTOP:
	    /*
	    docRtfWriteTag( "\\clvertalt", pCol, sos );
	    */
	    break;
	    
	case DOCtvaCENTERED:
	    docRtfWriteTag( "\\clvertalc", pCol, sos );
	    break;
	    
	case DOCtvaBOTTOM:
	    docRtfWriteTag( "\\clvertalb", pCol, sos );
	    break;
	    
	default:
	    LDEB(cp->cpTextVerticalAlignment);
	    break;
	}

    if  ( cp->cpLeftInMergedRow )
	{ docRtfWriteTag( "\\clmgf", pCol, sos );	}
    if  ( cp->cpMergedWithLeft )
	{ docRtfWriteTag( "\\clmrg", pCol, sos );	}
    if  ( cp->cpTopInMergedColumn )
	{ docRtfWriteTag( "\\clvmgf", pCol, sos );	}
    if  ( cp->cpMergedWithAbove )
	{ docRtfWriteTag( "\\clvmrg", pCol, sos );	}

    docRtfWriteNextLine( pCol, sos );

    if  ( cp->cpTopBorder.bpStyle != DOCbsNONE )
	{ docRtfSaveBorder( "\\clbrdrt", pCol, &(cp->cpTopBorder), sos ); }
    if  ( cp->cpLeftBorder.bpStyle != DOCbsNONE )
	{ docRtfSaveBorder( "\\clbrdrl", pCol, &(cp->cpLeftBorder), sos ); }
    if  ( cp->cpRightBorder.bpStyle != DOCbsNONE )
	{ docRtfSaveBorder( "\\clbrdrr", pCol, &(cp->cpRightBorder), sos ); }
    if  ( cp->cpBottomBorder.bpStyle != DOCbsNONE )
	{ docRtfSaveBorder( "\\clbrdrb", pCol, &(cp->cpBottomBorder), sos ); }

    switch( cp->cpShading.isPattern )
	{
	case DOCspSOLID:
	    break;

	case DOCspBGBDIAG:
	    docRtfWriteTag( "\\clbgbdiag", pCol, sos );
	    break;
	case DOCspBGCROSS:
	    docRtfWriteTag( "\\clbgcross", pCol, sos );
	    break;
	case DOCspBGDCROSS:
	    docRtfWriteTag( "\\clbgdcross", pCol, sos );
	    break;
	case DOCspBGDKBDIAG:
	    docRtfWriteTag( "\\clbgdkbdiag", pCol, sos );
	    break;
	case DOCspBGDKCROSS:
	    docRtfWriteTag( "\\clbgdkcross", pCol, sos );
	    break;
	case DOCspBGDKDCROSS:
	    docRtfWriteTag( "\\clbgdkdcross", pCol, sos );
	    break;
	case DOCspBGDKFDIAG:
	    docRtfWriteTag( "\\clbgdkfdiag", pCol, sos );
	    break;
	case DOCspBGDKHORIZ:
	    docRtfWriteTag( "\\clbgdkhor", pCol, sos );
	    break;
	case DOCspBGDKVERT:
	    docRtfWriteTag( "\\clbgdkvert", pCol, sos );
	    break;
	case DOCspBGFDIAG:
	    docRtfWriteTag( "\\clbgfdiag", pCol, sos );
	    break;
	case DOCspBGHORIZ:
	    docRtfWriteTag( "\\clbghoriz", pCol, sos );
	    break;
	case DOCspBGVERT:
	    docRtfWriteTag( "\\clbgvert", pCol, sos );
	    break;

	default:
	    LDEB(cp->cpShading.isPattern);
	    break;
	}

    if  ( cp->cpShading.isForeColor > 0 )
	{
	docRtfWriteArgTag( "\\clcfpat", pCol, cp->cpShading.isForeColor, sos );
	}
    if  ( cp->cpShading.isBackColor > 0 )
	{
	docRtfWriteArgTag( "\\clcbpat", pCol, cp->cpShading.isBackColor, sos );
	}
    if  ( cp->cpShading.isLevel > 0 )
	{
	docRtfWriteArgTag( "\\clshdng", pCol, cp->cpShading.isLevel, sos );
	}

    /**/
    docRtfSaveAutoSpace( pCol, sos,
			"\\clftsWidth", cp->cpPreferredWidthUnit,
			"\\clwWidth", cp->cpPreferredWidth );

    /**/
    switch( cp->cpTextFlow )
	{
	case CLflowTXLRTB:
	    /*
	    docRtfWriteTag( "\\cltxlrtb", pCol, sos );
	    */
	    break;
	case CLflowTXTBRL:
	    docRtfWriteTag( "\\cltxtbrl", pCol, sos );
	    break;
	case CLflowTXBTLR:
	    docRtfWriteTag( "\\cltxbtlr", pCol, sos );
	    break;
	case CLflowTXLRTBV:
	    docRtfWriteTag( "\\cltxlrtbv", pCol, sos );
	    break;
	case CLflowTXTBRLV:
	    docRtfWriteTag( "\\cltxtbrlv", pCol, sos );
	    break;
	    
	default:
	    LDEB(cp->cpTextFlow);
	    break;
	}

    docRtfWriteArgTag( "\\cellx", pCol,
				cp->cpRightBoundaryTwips- shiftLeft, sos );

    docRtfWriteNextLine( pCol, sos );
    }

/************************************************************************/
/*									*/
/*  Handle a cell property when reading RTF.				*/
/*									*/
/************************************************************************/

int docRtfRememberCellProperty(		SimpleInputStream *	sis,
					const RtfControlWord *	rcw,
					int			arg,
					RtfReadingContext *	rrc )
    {
    CellProperties *	cp= &(rrc->rrcCellProperties);

    switch( rcw->rcwID )
	{
	case CLprop_NONE:
	    docCleanCellProperties( cp );
	    docInitCellProperties(  cp );
	    return 0;

	/**/
	case CLpropTOP_BORDER:
	    cp->cpTopBorder= rrc->rrcBorderProperties;
	    docInitBorderProperties( &(rrc->rrcBorderProperties) );
	    break;
	case CLpropBOTTOM_BORDER:
	    cp->cpBottomBorder= rrc->rrcBorderProperties;
	    docInitBorderProperties( &(rrc->rrcBorderProperties) );
	    break;
	case CLpropLEFT_BORDER:
	    cp->cpLeftBorder= rrc->rrcBorderProperties;
	    docInitBorderProperties( &(rrc->rrcBorderProperties) );
	    break;
	case CLpropRIGHT_BORDER:
	    cp->cpRightBorder= rrc->rrcBorderProperties;
	    docInitBorderProperties( &(rrc->rrcBorderProperties) );
	    break;

	/**/
	case CLpropSHADE_FORE_COLOR:
	    cp->cpShading.isForeColor= arg;
	    break;
	case CLpropSHADE_BACK_COLOR:
	    cp->cpShading.isBackColor= arg;
	    break;
	case CLpropSHADE_LEVEL:
	    cp->cpShading.isLevel= arg;
	    break;
	case CLpropSHADE_PATTERN:
	    cp->cpShading.isPattern= rcw->rcwEnumValue;
	    break;

	/**/
	case CLpropCLW_WIDTH:
	    cp->cpPreferredWidth= arg;
	    break;
	case CLpropCLFTS_WIDTH:
	    cp->cpPreferredWidthUnit= arg;
	    break;

	/**/
	case CLpropTOP_PADDING:
	    cp->cpTopPadding= arg;
	    break;
	case CLpropBOTTOM_PADDING:
	    cp->cpBottomPadding= arg;
	    break;
	case CLpropLEFT_PADDING:
	    cp->cpLeftPadding= arg;
	    break;
	case CLpropRIGHT_PADDING:
	    cp->cpRightPadding= arg;
	    break;

	/**/
	case CLpropTOP_PADDING_UNIT:
	    cp->cpTopPaddingUnit= arg;
	    break;
	case CLpropBOTTOM_PADDING_UNIT:
	    cp->cpBottomPaddingUnit= arg;
	    break;
	case CLpropLEFT_PADDING_UNIT:
	    cp->cpLeftPaddingUnit= arg;
	    break;
	case CLpropRIGHT_PADDING_UNIT:
	    cp->cpRightPaddingUnit= arg;
	    break;

	/**/
	case CLpropLEFT_IN_MERGED:
	    cp->cpLeftInMergedRow= ( arg != 0 );
	    break;
	case CLpropMERGED_WITH_LEFT:
	    cp->cpMergedWithLeft= ( arg != 0 );
	    break;
	case CLpropTOP_IN_MERGED:
	    cp->cpTopInMergedColumn= ( arg != 0 );
	    break;
	case CLpropMERGED_WITH_ABOVE:
	    cp->cpMergedWithAbove= ( arg != 0 );
	    break;
	case CLpropNO_WRAP:
	    cp->cpNoWrap= ( arg != 0 );
	    break;

	case CLpropNO_SHADING:
	    cp->cpNoShading= ( arg != 0 );
	    break;

	case CLpropTEXT_VERT_ALIGN:
	    cp->cpTextVerticalAlignment= rcw->rcwEnumValue;
	    break;

	case CLpropTEXT_FLOW:
	    cp->cpTextFlow= rcw->rcwEnumValue;
	    break;

	default:
	    SDEB(rcw->rcwWord);
	    return -1;
	}

    return 0;
    }