File: sep.c

package info (click to toggle)
abiword 0.7.7-1
  • links: PTS
  • area: main
  • in suites: potato
  • size: 20,604 kB
  • ctags: 18,358
  • sloc: cpp: 88,791; ansic: 66,296; sh: 7,777; makefile: 3,397; xml: 687; perl: 361; awk: 273; sed: 36; csh: 28
file content (208 lines) | stat: -rw-r--r-- 4,415 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
#include <stdlib.h>
#include <stdio.h>
#include "wv.h"


float wvRelativeWidth(S16 width,SEP *asep)
	{
	float fwidth;
	if (asep == NULL)
		return(100.00);
	fwidth = (float)(asep->xaPage - asep->dxaLeft - asep->dxaRight);
	fwidth = width/fwidth*100;
	if (fwidth > 100.00) 
		fwidth = 100.00;
	return(fwidth);
	}
	
float wvRelativeHeight(S16 height,SEP *asep)
	{
	float fheight;
	if (asep == NULL)
		return(100.00);
	fheight = (float)(asep->yaPage - asep->dyaTop - asep->dyaBottom);
	fheight = height/fheight*100;
	if (fheight > 100.00)
		fheight = 100.00;
	return(fheight);
	}

/*
The standard SEP is all zeros except as follows:
 bkc           2 (new page)
 dyaPgn        720 twips (equivalent to .5 in)
 dxaPgn        720 twips
 fEndnote      1 (True)
 fEvenlySpaced 1 (True)
 xaPage        12240 twips
 yaPage        15840 twips
 xaPageNUp     12240 twips
 yaPageNUp     15840 twips
 dyaHdrTop     720 twips
 dyaHdrBottom  720 twips
 dmOrientPage  1 (portrait orientation)
 dxaColumns    720 twips
 dyaTop        1440 twips
 dxaLeft       1800 twips
 dyaBottom     1440 twips
 dxaRight      1800 twips
 pgnStart      1
cbSEP (count of bytes of SEP) is 704(decimal), 2C0(hex).
*/

void wvInitSEP(SEP *item)
	{
	U8 i;
 	item->bkc=2;
 	item->fTitlePage=0;
	item->fAutoPgn=0;
 	item->nfcPgn=0;
 	item->fUnlocked=0;
	item->cnsPgn=0;
 	item->fPgnRestart=0;
 	item->fEndNote=1;
 	item->lnc=0;
 	item->grpfIhdt=0;
 	item->nLnnMod=0;
 	item->dxaLnn=0;
 	item->dxaPgn=720;
 	item->dyaPgn=720;
 	item->fLBetween=0;
 	item->vjc=0;
 	item->dmBinFirst=0;
 	item->dmBinOther=0;
 	item->dmPaperReq=0;

 	wvInitBRC(&item->brcTop);
 	wvInitBRC(&item->brcLeft);
 	wvInitBRC(&item->brcBottom);
 	wvInitBRC(&item->brcRight);

 	item->fPropRMark=0;
	item->ibstPropRMark=0;

 	wvInitDTTM(&item->dttmPropRMark);

 	item->dxtCharSpace=0;
 	item->dyaLinePitch=0;
 	item->clm=0;
    item->reserved1=0;
 	item->dmOrientPage=0;
 	item->iHeadingPgn=0;
 	item->pgnStart=1;
	item->lnnMin=0;
 	item->wTextFlow=0;
 	item->reserved2=0;
 	item->pgbProp=0;
 	item->pgbApplyTo=0;
	item->pgbPageDepth=0;
	item->pgbOffsetFrom=0;
	item->reserved=0;
 	item->xaPage=12240;
 	item->yaPage=15840;
 	item->xaPageNUp=12240;
 	item->yaPageNUp=15840;
 	item->dxaLeft=1800;
 	item->dxaRight=1800;
 	item->dyaTop=1440;
 	item->dyaBottom=1440;
 	item->dzaGutter=0;
 	item->dyaHdrTop=720;
 	item->dyaHdrBottom=720;
 	item->ccolM1=0;
 	item->fEvenlySpaced=1;
 	item->reserved3=0;
 	item->dxaColumns=720;
	for (i=0;i<89;i++)
 		item->rgdxaColumnWidthSpacing[i]=0;
 	item->dxaColumnWidth=0;
 	item->dmOrientFirst=0;
 	item->fLayout=0;
 	item->reserved4=0;
 	wvInitOLST(&item->olstAnm);
	} 

void wvGetSEPX(version ver,SEPX *item,FILE *fd)
	{
	U16 i;
	item->cb = read_16ubit(fd);

	if (item->cb)
		item->grpprl = (U8 *)malloc(item->cb);
	else
		item->grpprl = NULL;

	for (i=0;i<item->cb;i++)	
		{
		item->grpprl[i] = getc(fd);
		wvTrace(("sep is %x\n",item->grpprl[i]));
		}
	}

void wvReleaseSEPX(SEPX *item)
	{
	wvFree(item->grpprl);
	}


int wvAddSEPXFromBucket(SEP *asep,SEPX *item,STSH *stsh)
	{
	U8 *pointer;
    U16 i=0;
    U16 sprm;
	int ret=0;
	Sprm RetSprm;
#ifdef SPRMTEST
	fprintf(stderr,"\n");
    while (i < item->cb)
        {
        fprintf(stderr,"%x (%d) ",*(item->grpprl+i),*(item->grpprl+i));
        i++;
        }
    fprintf(stderr,"\n");
	i=0;
#endif
    while (i < item->cb-2)
        {
        sprm = bread_16ubit(item->grpprl+i,&i);
        pointer = item->grpprl+i;
        RetSprm = wvApplySprmFromBucket(WORD8,sprm,NULL,NULL,asep,stsh,pointer,&i,NULL);
		if (RetSprm.sgc == sgcSep)  ret = 1;
        }
	return(ret);
	}

int wvAddSEPXFromBucket6(SEP *asep,SEPX *item,STSH *stsh)
	{
	U8 *pointer;
    U16 i=0;
	int ret=0;
    U8 sprm8;
    U16 sprm;
	Sprm RetSprm;
#ifdef SPRMTEST
	fprintf(stderr,"\n");
    while (i < item->cb)
        {
        fprintf(stderr,"%x (%d) ",*(item->grpprl+i),*(item->grpprl+i));
        i++;
        }
    fprintf(stderr,"\n");
	i=0;
#endif
    while (i < item->cb)
        {
        sprm8 = bgetc(item->grpprl+i,&i);
#ifdef SPRMTEST
		wvError(("sep word 6 sprm is %x (%d)\n",sprm8,sprm8));
#endif
		sprm = (U16)wvGetrgsprmWord6(sprm8);
#ifdef SPRMTEST
		wvTrace(("sep word 6 sprm is converted to %x\n",sprm));
#endif
        pointer = item->grpprl+i;
        RetSprm = wvApplySprmFromBucket(WORD6,sprm,NULL,NULL,asep,stsh,pointer,&i,NULL);
		if (RetSprm.sgc == sgcSep)  ret = 1;
        }
	return(ret);
	}