1 /************************************************************************/
2 /*									*/
3 /*  Positioned Objects and Frames					*/
4 /*									*/
5 /************************************************************************/
6 
7 #   include	"docBaseConfig.h"
8 
9 #   include	<appDebugon.h>
10 
11 #   include	"docFrameProperties.h"
12 
13 /************************************************************************/
14 /*									*/
15 /*  Manage text frame properties.					*/
16 /*									*/
17 /************************************************************************/
18 
docInitFrameProperties(FrameProperties * fp)19 void docInitFrameProperties(	FrameProperties *	fp )
20     {
21     fp->fpWideTwips= 0;
22     fp->fpHighTwips= 0;
23 
24     fp->fpXTwips= 0;
25     fp->fpYTwips= 0;
26 
27     fp->fpDistanceFromTextTwipsLeft= 0;
28     fp->fpDistanceFromTextTwipsRight= 0;
29     fp->fpDistanceFromTextTwipsTop= 0;
30     fp->fpDistanceFromTextTwipsBottom= 0;
31     fp->fpDistanceFromTextSet= 0;
32 
33     fp->fpIsSet= 0;
34 
35     fp->fpXReference= FXrefCOLUMN;
36     fp->fpXPosition= FXposXL;
37 
38     fp->fpYReference= FYrefMARGIN;
39     fp->fpYPosition= FYposYT;
40     fp->fpLockAnchor= 0;
41 
42     fp->fpFrameWrapStyle= FWSwrapWRAP;
43     fp->fpNoOverlap= 0;
44     fp->fpLockAnchor= 0;
45 
46     fp->fpTextFlowDirection= TXflowTXLRTB;
47 
48     return;
49     }
50 
51 const unsigned char docFrameYAllowed[FYpos_COUNT][FYref_COUNT]=
52 {
53 /*			FYrefMARGIN	FYrefPAGE	FYrefPARA	*/
54 /* FYposYGIVEN	*/ {	1,		1,		1,		},
55 /* FYposYT	*/ {	1,		1,		0,		},
56 /* FYposYC	*/ {	1,		1,		0,		},
57 /* FYposYB	*/ {	1,		1,		0,		},
58 /* FYposYIN	*/ {	1,		1,		0,		},
59 /* FYposYOUT	*/ {	1,		1,		0,		},
60 };
61 
docSetFrameProperty(FrameProperties * fp,int prop,int arg)62 int docSetFrameProperty(	FrameProperties *	fp,
63 				int			prop,
64 				int			arg )
65     {
66     switch( prop )
67 	{
68 	case TFPpropABSW:
69 	    fp->fpWideTwips= arg;
70 	    fp->fpIsSet= 1;
71 	    break;
72 
73 	case TFPpropABSH:
74 	    fp->fpHighTwips= arg;
75 	    fp->fpIsSet= 1;
76 	    break;
77 
78 	case TFPpropHORIZONTAL_REF:
79 	    fp->fpXReference= arg;
80 	    fp->fpIsSet= 1;
81 	    break;
82 
83 	case TFPpropHORIZONTAL_POS:
84 	    fp->fpXTwips= arg;
85 	    fp->fpXPosition= FXposXGIVEN;
86 	    fp->fpIsSet= 1;
87 	    break;
88 
89 	case TFPpropHORIZONTAL_ALIGN:
90 	    fp->fpXPosition= arg;
91 	    fp->fpIsSet= 1;
92 	    break;
93 
94 	case TFPpropVERTICAL_REF:
95 	    fp->fpYReference= arg;
96 	    fp->fpIsSet= 1;
97 	    break;
98 
99 	case TFPpropVERTICAL_POS:
100 	    fp->fpYTwips= arg;
101 	    fp->fpYPosition= FYposYGIVEN;
102 	    fp->fpIsSet= 1;
103 	    break;
104 
105 	case TFPpropVERTICAL_ALIGN:
106 	    fp->fpYPosition= arg;
107 	    fp->fpIsSet= 1;
108 	    break;
109 
110 	case TFPpropLOCK_ANCHOR:
111 	    fp->fpLockAnchor= arg != 0;
112 	    fp->fpIsSet= 1;
113 	    break;
114 
115 	case TFPpropWRAP_STYLE:
116 	    fp->fpFrameWrapStyle= arg;
117 	    fp->fpIsSet= 1;
118 	    break;
119 
120 	case TFPpropNO_OVERLAP:
121 	    fp->fpNoOverlap= arg != 0;
122 	    fp->fpIsSet= 1;
123 	    break;
124 
125 	case TFPprop_DFRMTXT:
126 	    fp->fpDistanceFromTextTwipsLeft= arg;
127 	    fp->fpDistanceFromTextTwipsRight= arg;
128 	    fp->fpDistanceFromTextTwipsTop= arg;
129 	    fp->fpDistanceFromTextTwipsBottom= arg;
130 	    fp->fpDistanceFromTextSet |=
131 			(DISTsetLEFT|DISTsetRIGHT|DISTsetTOP|DISTsetBOTTOM);
132 	    break;
133 
134 	case TFPprop_DFRMTXTX:
135 	    fp->fpDistanceFromTextTwipsLeft= arg;
136 	    fp->fpDistanceFromTextTwipsRight= arg;
137 	    fp->fpDistanceFromTextSet |= (DISTsetLEFT|DISTsetRIGHT);
138 	    break;
139 
140 	case TFPprop_DFRMTXTY:
141 	    fp->fpDistanceFromTextTwipsTop= arg;
142 	    fp->fpDistanceFromTextTwipsBottom= arg;
143 	    fp->fpDistanceFromTextSet |= (DISTsetTOP|DISTsetBOTTOM);
144 	    break;
145 
146 	case TFPpropDFRMTXTL:
147 	    fp->fpDistanceFromTextTwipsLeft= arg;
148 	    fp->fpDistanceFromTextSet |= DISTsetLEFT;
149 	    break;
150 
151 	case TFPpropDFRMTXTR:
152 	    fp->fpDistanceFromTextTwipsRight= arg;
153 	    fp->fpDistanceFromTextSet |= DISTsetRIGHT;
154 	    break;
155 
156 	case TFPpropDFRMTXTT:
157 	    fp->fpDistanceFromTextTwipsTop= arg;
158 	    fp->fpDistanceFromTextSet |= DISTsetTOP;
159 	    break;
160 
161 	case TFPpropDFRMTXTB:
162 	    fp->fpDistanceFromTextTwipsBottom= arg;
163 	    fp->fpDistanceFromTextSet |= DISTsetBOTTOM;
164 	    break;
165 
166 	case TFPpropTEXT_FLOW:
167 	    fp->fpTextFlowDirection= arg;
168 	    break;
169 
170 	default:
171 	    LDEB(prop); return -1;
172 	}
173 
174     return 0;
175     }
176 
docGetFrameProperty(const FrameProperties * fp,int prop)177 int docGetFrameProperty(	const FrameProperties *	fp,
178 				int			prop )
179     {
180     switch( prop )
181 	{
182 	case TFPpropISSET:
183 	    return fp->fpIsSet;
184 
185 	case TFPpropABSW:
186 	    return fp->fpWideTwips;
187 
188 	case TFPpropABSH:
189 	    return fp->fpHighTwips;
190 
191 	case TFPpropHORIZONTAL_REF:
192 	    return fp->fpXReference;
193 
194 	case TFPpropHORIZONTAL_POS:
195 	    return fp->fpXTwips;
196 
197 	case TFPpropHORIZONTAL_ALIGN:
198 	    return fp->fpXPosition;
199 
200 	case TFPpropVERTICAL_REF:
201 	    return fp->fpYReference;
202 
203 	case TFPpropVERTICAL_POS:
204 	    return fp->fpYTwips;
205 
206 	case TFPpropVERTICAL_ALIGN:
207 	    return fp->fpYPosition;
208 
209 	case TFPpropLOCK_ANCHOR:
210 	    return fp->fpLockAnchor;
211 
212 	case TFPpropWRAP_STYLE:
213 	    return fp->fpFrameWrapStyle;
214 
215 	case TFPpropNO_OVERLAP:
216 	    return fp->fpNoOverlap;
217 
218 	case TFPpropDFRMTXTL:
219 	    return fp->fpDistanceFromTextTwipsLeft;
220 
221 	case TFPpropDFRMTXTR:
222 	    return fp->fpDistanceFromTextTwipsRight;
223 
224 	case TFPpropDFRMTXTT:
225 	    return fp->fpDistanceFromTextTwipsTop;
226 
227 	case TFPpropDFRMTXTB:
228 	    return fp->fpDistanceFromTextTwipsBottom;
229 
230 	case TFPpropTEXT_FLOW:
231 	    return fp->fpTextFlowDirection;
232 
233 	default:
234 	    LDEB(prop); return -1;
235 	}
236     }
237