source: trunk/gsdl/packages/wv-0.5.44-gs/src/sep.c@ 1468

Last change on this file since 1468 was 1468, checked in by paynter, 24 years ago

The wv Packages from www.wvware.com is used to convert Word documents into
HTML. This is an adaptation of wv version 0.5.44 for greenstone; it is
called by the gsConvert.pl script.

  • Property svn:keywords set to Author Date Id Revision
File size: 4.3 KB
Line 
1#include <stdlib.h>
2#include <stdio.h>
3#include "wv.h"
4
5
6float wvRelativeWidth(S16 width,SEP *asep)
7 {
8 float fwidth;
9 if (asep == NULL)
10 return(100.00);
11 fwidth = (float)(asep->xaPage - asep->dxaLeft - asep->dxaRight);
12 fwidth = width/fwidth*100;
13 if (fwidth > 100.00)
14 fwidth = 100.00;
15 return(fwidth);
16 }
17
18float wvRelativeHeight(S16 height,SEP *asep)
19 {
20 float fheight;
21 if (asep == NULL)
22 return(100.00);
23 fheight = (float)(asep->yaPage - asep->dyaTop - asep->dyaBottom);
24 fheight = height/fheight*100;
25 if (fheight > 100.00)
26 fheight = 100.00;
27 return(fheight);
28 }
29
30/*
31The standard SEP is all zeros except as follows:
32 bkc 2 (new page)
33 dyaPgn 720 twips (equivalent to .5 in)
34 dxaPgn 720 twips
35 fEndnote 1 (True)
36 fEvenlySpaced 1 (True)
37 xaPage 12240 twips
38 yaPage 15840 twips
39 xaPageNUp 12240 twips
40 yaPageNUp 15840 twips
41 dyaHdrTop 720 twips
42 dyaHdrBottom 720 twips
43 dmOrientPage 1 (portrait orientation)
44 dxaColumns 720 twips
45 dyaTop 1440 twips
46 dxaLeft 1800 twips
47 dyaBottom 1440 twips
48 dxaRight 1800 twips
49 pgnStart 1
50cbSEP (count of bytes of SEP) is 704(decimal), 2C0(hex).
51*/
52
53void wvInitSEP(SEP *item)
54 {
55 U8 i;
56 item->bkc=2;
57 item->fTitlePage=0;
58 item->fAutoPgn=0;
59 item->nfcPgn=0;
60 item->fUnlocked=0;
61 item->cnsPgn=0;
62 item->fPgnRestart=0;
63 item->fEndNote=1;
64 item->lnc=0;
65 item->grpfIhdt=0;
66 item->nLnnMod=0;
67 item->dxaLnn=0;
68 item->dxaPgn=720;
69 item->dyaPgn=720;
70 item->fLBetween=0;
71 item->vjc=0;
72 item->dmBinFirst=0;
73 item->dmBinOther=0;
74 item->dmPaperReq=0;
75
76 wvInitBRC(&item->brcTop);
77 wvInitBRC(&item->brcLeft);
78 wvInitBRC(&item->brcBottom);
79 wvInitBRC(&item->brcRight);
80
81 item->fPropRMark=0;
82 item->ibstPropRMark=0;
83
84 wvInitDTTM(&item->dttmPropRMark);
85
86 item->dxtCharSpace=0;
87 item->dyaLinePitch=0;
88 item->clm=0;
89 item->reserved1=0;
90 item->dmOrientPage=0;
91 item->iHeadingPgn=0;
92 item->pgnStart=1;
93 item->lnnMin=0;
94 item->wTextFlow=0;
95 item->reserved2=0;
96 item->pgbProp=0;
97 item->pgbApplyTo=0;
98 item->pgbPageDepth=0;
99 item->pgbOffsetFrom=0;
100 item->reserved=0;
101 item->xaPage=12240;
102 item->yaPage=15840;
103 item->xaPageNUp=12240;
104 item->yaPageNUp=15840;
105 item->dxaLeft=1800;
106 item->dxaRight=1800;
107 item->dyaTop=1440;
108 item->dyaBottom=1440;
109 item->dzaGutter=0;
110 item->dyaHdrTop=720;
111 item->dyaHdrBottom=720;
112 item->ccolM1=0;
113 item->fEvenlySpaced=1;
114 item->reserved3=0;
115 item->dxaColumns=720;
116 for (i=0;i<89;i++)
117 item->rgdxaColumnWidthSpacing[i]=0;
118 item->dxaColumnWidth=0;
119 item->dmOrientFirst=0;
120 item->fLayout=0;
121 item->reserved4=0;
122 wvInitOLST(&item->olstAnm);
123 }
124
125void wvGetSEPX(version ver,SEPX *item,FILE *fd)
126 {
127 U16 i;
128 item->cb = read_16ubit(fd);
129
130 if (item->cb)
131 item->grpprl = (U8 *)malloc(item->cb);
132 else
133 item->grpprl = NULL;
134
135 for (i=0;i<item->cb;i++)
136 {
137 item->grpprl[i] = getc(fd);
138 wvTrace(("sep is %x\n",item->grpprl[i]));
139 }
140 }
141
142void wvReleaseSEPX(SEPX *item)
143 {
144 wvFree(item->grpprl);
145 }
146
147
148int wvAddSEPXFromBucket(SEP *asep,SEPX *item,STSH *stsh)
149 {
150 U8 *pointer;
151 U16 i=0;
152 U16 sprm;
153 int ret=0;
154 Sprm RetSprm;
155#ifdef SPRMTEST
156 fprintf(stderr,"\n");
157 while (i < item->cb)
158 {
159 fprintf(stderr,"%x (%d) ",*(item->grpprl+i),*(item->grpprl+i));
160 i++;
161 }
162 fprintf(stderr,"\n");
163 i=0;
164#endif
165 while (i < item->cb-2)
166 {
167 sprm = bread_16ubit(item->grpprl+i,&i);
168 pointer = item->grpprl+i;
169 RetSprm = wvApplySprmFromBucket(WORD8,sprm,NULL,NULL,asep,stsh,pointer,&i,NULL);
170 if (RetSprm.sgc == sgcSep) ret = 1;
171 }
172 return(ret);
173 }
174
175int wvAddSEPXFromBucket6(SEP *asep,SEPX *item,STSH *stsh)
176 {
177 U8 *pointer;
178 U16 i=0;
179 int ret=0;
180 U8 sprm8;
181 U16 sprm;
182 Sprm RetSprm;
183#ifdef SPRMTEST
184 fprintf(stderr,"\n");
185 while (i < item->cb)
186 {
187 fprintf(stderr,"%x (%d) ",*(item->grpprl+i),*(item->grpprl+i));
188 i++;
189 }
190 fprintf(stderr,"\n");
191 i=0;
192#endif
193 while (i < item->cb)
194 {
195 sprm8 = bgetc(item->grpprl+i,&i);
196#ifdef SPRMTEST
197 wvError(("sep word 6 sprm is %x (%d)\n",sprm8,sprm8));
198#endif
199 sprm = (U16)wvGetrgsprmWord6(sprm8);
200#ifdef SPRMTEST
201 wvTrace(("sep word 6 sprm is converted to %x\n",sprm));
202#endif
203 pointer = item->grpprl+i;
204 RetSprm = wvApplySprmFromBucket(WORD6,sprm,NULL,NULL,asep,stsh,pointer,&i,NULL);
205 if (RetSprm.sgc == sgcSep) ret = 1;
206 }
207 return(ret);
208 }
Note: See TracBrowser for help on using the repository browser.