KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > poi > hwpf > sprm > SectionSprmUncompressor


1
2 /* ====================================================================
3    Copyright 2002-2004 Apache Software Foundation
4
5    Licensed under the Apache License, Version 2.0 (the "License");
6    you may not use this file except in compliance with the License.
7    You may obtain a copy of the License at
8
9        http://www.apache.org/licenses/LICENSE-2.0
10
11    Unless required by applicable law or agreed to in writing, software
12    distributed under the License is distributed on an "AS IS" BASIS,
13    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14    See the License for the specific language governing permissions and
15    limitations under the License.
16 ==================================================================== */

17         
18
19 package org.apache.poi.hwpf.sprm;
20
21 import org.apache.poi.hwpf.usermodel.SectionProperties;
22 import org.apache.poi.hwpf.usermodel.BorderCode;
23
24 public class SectionSprmUncompressor extends SprmUncompressor
25 {
26   public SectionSprmUncompressor()
27   {
28   }
29   public static SectionProperties uncompressSEP(byte[] grpprl, int offset)
30   {
31     SectionProperties newProperties = new SectionProperties();
32
33     SprmIterator sprmIt = new SprmIterator(grpprl, offset);
34
35     while (sprmIt.hasNext())
36     {
37       SprmOperation sprm = (SprmOperation)sprmIt.next();
38       unCompressSEPOperation(newProperties, sprm);
39     }
40
41     return newProperties;
42   }
43
44   /**
45    * Used in decompression of a sepx. This performs an operation defined by
46    * a single sprm.
47    *
48    * @param newSEP The SectionProperty to perfrom the operation on.
49    * @param operand The operation to perform.
50    * @param param The operation's parameter.
51    * @param varParam The operation variable length parameter.
52    */

53   static void unCompressSEPOperation (SectionProperties newSEP, SprmOperation sprm)
54   {
55     switch (sprm.getOperation())
56     {
57       case 0:
58         newSEP.setCnsPgn ((byte) sprm.getOperand());
59         break;
60       case 0x1:
61         newSEP.setIHeadingPgn ((byte) sprm.getOperand());
62         break;
63       case 0x2:
64         byte[] buf = new byte[sprm.size() - 3];
65         System.arraycopy(sprm.getGrpprl(), sprm.getGrpprlOffset(), buf, 0, buf.length);
66         newSEP.setOlstAnm (buf);
67         break;
68       case 0x3:
69         //not quite sure
70
break;
71       case 0x4:
72         //not quite sure
73
break;
74       case 0x5:
75         newSEP.setFEvenlySpaced (getFlag (sprm.getOperand()));
76         break;
77       case 0x6:
78         newSEP.setFUnlocked (getFlag (sprm.getOperand()));
79         break;
80       case 0x7:
81         newSEP.setDmBinFirst ((short) sprm.getOperand());
82         break;
83       case 0x8:
84         newSEP.setDmBinOther ((short) sprm.getOperand());
85         break;
86       case 0x9:
87         newSEP.setBkc ((byte) sprm.getOperand());
88         break;
89       case 0xa:
90         newSEP.setFTitlePage (getFlag (sprm.getOperand()));
91         break;
92       case 0xb:
93         newSEP.setCcolM1 ((short) sprm.getOperand());
94         break;
95       case 0xc:
96         newSEP.setDxaColumns (sprm.getOperand());
97         break;
98       case 0xd:
99         newSEP.setFAutoPgn (getFlag (sprm.getOperand()));
100         break;
101       case 0xe:
102         newSEP.setNfcPgn ((byte) sprm.getOperand());
103         break;
104       case 0xf:
105         newSEP.setDyaPgn ((short) sprm.getOperand());
106         break;
107       case 0x10:
108         newSEP.setDxaPgn ((short) sprm.getOperand());
109         break;
110       case 0x11:
111         newSEP.setFPgnRestart (getFlag (sprm.getOperand()));
112         break;
113       case 0x12:
114         newSEP.setFEndNote (getFlag (sprm.getOperand()));
115         break;
116       case 0x13:
117         newSEP.setLnc ((byte) sprm.getOperand());
118         break;
119       case 0x14:
120         newSEP.setGrpfIhdt ((byte) sprm.getOperand());
121         break;
122       case 0x15:
123         newSEP.setNLnnMod ((short) sprm.getOperand());
124         break;
125       case 0x16:
126         newSEP.setDxaLnn (sprm.getOperand());
127         break;
128       case 0x17:
129         newSEP.setDyaHdrTop (sprm.getOperand());
130         break;
131       case 0x18:
132         newSEP.setDyaHdrBottom (sprm.getOperand());
133         break;
134       case 0x19:
135         newSEP.setFLBetween (getFlag (sprm.getOperand()));
136         break;
137       case 0x1a:
138         newSEP.setVjc ((byte) sprm.getOperand());
139         break;
140       case 0x1b:
141         newSEP.setLnnMin ((short) sprm.getOperand());
142         break;
143       case 0x1c:
144         newSEP.setPgnStart ((short) sprm.getOperand());
145         break;
146       case 0x1d:
147         newSEP.setDmOrientPage ((byte) sprm.getOperand());
148         break;
149       case 0x1e:
150
151         //nothing
152
break;
153       case 0x1f:
154         newSEP.setXaPage (sprm.getOperand());
155         break;
156       case 0x20:
157         newSEP.setYaPage (sprm.getOperand());
158         break;
159       case 0x21:
160         newSEP.setDxaLeft (sprm.getOperand());
161         break;
162       case 0x22:
163         newSEP.setDxaRight (sprm.getOperand());
164         break;
165       case 0x23:
166         newSEP.setDyaTop (sprm.getOperand());
167         break;
168       case 0x24:
169         newSEP.setDyaBottom (sprm.getOperand());
170         break;
171       case 0x25:
172         newSEP.setDzaGutter (sprm.getOperand());
173         break;
174       case 0x26:
175         newSEP.setDmPaperReq ((short) sprm.getOperand());
176         break;
177       case 0x27:
178         newSEP.setFPropMark (getFlag (sprm.getOperand()));
179         break;
180       case 0x28:
181         break;
182       case 0x29:
183         break;
184       case 0x2a:
185         break;
186       case 0x2b:
187         newSEP.setBrcTop(new BorderCode(sprm.getGrpprl(), sprm.getGrpprlOffset()));
188         break;
189       case 0x2c:
190         newSEP.setBrcLeft(new BorderCode(sprm.getGrpprl(), sprm.getGrpprlOffset()));
191         break;
192       case 0x2d:
193         newSEP.setBrcBottom(new BorderCode(sprm.getGrpprl(), sprm.getGrpprlOffset()));
194         break;
195       case 0x2e:
196         newSEP.setBrcRight(new BorderCode(sprm.getGrpprl(), sprm.getGrpprlOffset()));
197         break;
198       case 0x2f:
199         newSEP.setPgbProp (sprm.getOperand());
200         break;
201       case 0x30:
202         newSEP.setDxtCharSpace (sprm.getOperand());
203         break;
204       case 0x31:
205         newSEP.setDyaLinePitch (sprm.getOperand());
206         break;
207       case 0x33:
208         newSEP.setWTextFlow ((short) sprm.getOperand());
209         break;
210       default:
211         break;
212     }
213
214   }
215
216
217 }
218
Popular Tags