1 /************************************************************************/
2 /*									*/
3 /*  Exchange between row properties and 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 
16 /************************************************************************/
17 /*									*/
18 /*  Handle a row property when reading RTF.				*/
19 /*									*/
20 /************************************************************************/
21 
docRtfResetRowProperties(RtfReader * rrc)22 static void docRtfResetRowProperties(	RtfReader *	rrc )
23     {
24     RowProperties *	rp= &(rrc->rrcRowProperties);
25 
26     docCleanRowProperties( rp );
27     docInitRowProperties(  rp );
28     utilPropMaskClear( &(rrc->rrcRowPropertyMask) );
29     docInitItemShading(  &(rrc->rrcRowShading) );
30 
31     docRtfResetCellProperties( rrc );
32     }
33 
docRtfRememberRowShadingProperty(const RtfControlWord * rcw,int arg,RtfReader * rrc)34 int docRtfRememberRowShadingProperty(	const RtfControlWord *	rcw,
35 					int			arg,
36 					RtfReader *	rrc )
37     {
38     if  ( docSetShadingProperty( &(rrc->rrcRowShading), rcw->rcwID, arg ) < 0 )
39 	{ SLDEB(rcw->rcwWord,arg); return -1;	}
40 
41     PROPmaskADD( &(rrc->rrcRowPropertyMask), RPpropSHADING );
42 
43     return 0;
44     }
45 
docRtfRememberRowProperty(const RtfControlWord * rcw,int arg,RtfReader * rrc)46 int docRtfRememberRowProperty(		const RtfControlWord *	rcw,
47 					int			arg,
48 					RtfReader *		rrc )
49     {
50     RowProperties *	rp= &(rrc->rrcRowProperties);
51 
52     switch( rcw->rcwID )
53 	{
54 	case RPprop_NONE:
55 	    docRtfResetRowProperties( rrc );
56 	    return 0;
57 
58 	case RPpropTOP_BORDER:
59 	    arg= docRtfReadGetBorderNumber( rrc );
60 	    if  ( arg < 0 )
61 		{ LDEB(arg); return -1;	}
62 	    break;
63 	case RPpropBOTTOM_BORDER:
64 	    arg= docRtfReadGetBorderNumber( rrc );
65 	    if  ( arg < 0 )
66 		{ LDEB(arg); return -1;	}
67 	    break;
68 	case RPpropLEFT_BORDER:
69 	    arg= docRtfReadGetBorderNumber( rrc );
70 	    if  ( arg < 0 )
71 		{ LDEB(arg); return -1;	}
72 	    break;
73 	case RPpropRIGHT_BORDER:
74 	    arg= docRtfReadGetBorderNumber( rrc );
75 	    if  ( arg < 0 )
76 		{ LDEB(arg); return -1;	}
77 	    break;
78 	case RPpropHORIZ_BORDER:
79 	    arg= docRtfReadGetBorderNumber( rrc );
80 	    if  ( arg < 0 )
81 		{ LDEB(arg); return -1;	}
82 	    break;
83 	case RPpropVERT_BORDER:
84 	    arg= docRtfReadGetBorderNumber( rrc );
85 	    if  ( arg < 0 )
86 		{ LDEB(arg); return -1;	}
87 	    break;
88 
89 	case RPprop_IGNORED:
90 	    return 0;
91 	}
92 
93     if  ( docSetRowProperty( rp, rcw->rcwID, arg ) < 0 )
94 	{ SLDEB(rcw->rcwWord,arg); return -1;	}
95 
96     PROPmaskADD( &(rrc->rrcRowPropertyMask), rcw->rcwID );
97 
98     return 0;
99     }
100 
101 /************************************************************************/
102 /*									*/
103 /*  Cope with Word10 {\trowd ...... } peculiarity.			*/
104 /*									*/
105 /************************************************************************/
106 
docRtfReadRowProperties(const RtfControlWord * rcw,int arg,RtfReader * rrc)107 int docRtfReadRowProperties(	const RtfControlWord *	rcw,
108 				int			arg,
109 				RtfReader *		rrc )
110     {
111     int			rval= 0;
112 
113     RowProperties	savedRp;
114     CellProperties	savedCp;
115     ItemShading		savedRowShading;
116     ItemShading		savedCellShading;
117 
118     savedRp= rrc->rrcRowProperties;
119     savedCp= rrc->rrcCellProperties;
120     savedRowShading= rrc->rrcRowShading;
121     savedCellShading= rrc->rrcCellShading;
122 
123     docInitRowProperties( &(rrc->rrcRowProperties) );
124     docInitCellProperties( &(rrc->rrcCellProperties) );
125     docInitItemShading(  &(rrc->rrcRowShading) );
126     docInitItemShading(  &(rrc->rrcCellShading) );
127 
128     if  ( docRtfReadGroup( rcw, 0, 0, rrc,
129 	    docRtfDocumentGroups, docRtfTextParticule, (RtfCommitGroup)0 ) )
130 	{ SDEB(rcw->rcwWord); rval= -1; goto ready;	}
131 
132   ready:
133 
134     docCleanRowProperties( &(rrc->rrcRowProperties) );
135     docCleanCellProperties( &(rrc->rrcCellProperties) );
136 
137     rrc->rrcRowProperties= savedRp;
138     rrc->rrcCellProperties= savedCp;
139     rrc->rrcRowShading= savedRowShading;
140     rrc->rrcCellShading= savedCellShading;
141 
142     return rval;
143     }
144 
145