001: /* ====================================================================
002: Licensed to the Apache Software Foundation (ASF) under one or more
003: contributor license agreements. See the NOTICE file distributed with
004: this work for additional information regarding copyright ownership.
005: The ASF licenses this file to You under the Apache License, Version 2.0
006: (the "License"); you may not use this file except in compliance with
007: the License. You may obtain a copy of the License at
008:
009: http://www.apache.org/licenses/LICENSE-2.0
010:
011: Unless required by applicable law or agreed to in writing, software
012: distributed under the License is distributed on an "AS IS" BASIS,
013: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: See the License for the specific language governing permissions and
015: limitations under the License.
016: ==================================================================== */
017:
018: package org.apache.poi.hwpf.usermodel;
019:
020: import org.apache.poi.hwpf.model.types.CHPAbstractType;
021:
022: /**
023: * @author Ryan Ackley
024: */
025: public class CharacterProperties extends CHPAbstractType implements
026: Cloneable {
027: public final static short SPRM_FRMARKDEL = (short) 0x0800;
028: public final static short SPRM_FRMARK = 0x0801;
029: public final static short SPRM_FFLDVANISH = 0x0802;
030: public final static short SPRM_PICLOCATION = 0x6A03;
031: public final static short SPRM_IBSTRMARK = 0x4804;
032: public final static short SPRM_DTTMRMARK = 0x6805;
033: public final static short SPRM_FDATA = 0x0806;
034: public final static short SPRM_SYMBOL = 0x6A09;
035: public final static short SPRM_FOLE2 = 0x080A;
036: public final static short SPRM_HIGHLIGHT = 0x2A0C;
037: public final static short SPRM_OBJLOCATION = 0x680E;
038: public final static short SPRM_ISTD = 0x4A30;
039: public final static short SPRM_FBOLD = 0x0835;
040: public final static short SPRM_FITALIC = 0x0836;
041: public final static short SPRM_FSTRIKE = 0x0837;
042: public final static short SPRM_FOUTLINE = 0x0838;
043: public final static short SPRM_FSHADOW = 0x0839;
044: public final static short SPRM_FSMALLCAPS = 0x083A;
045: public final static short SPRM_FCAPS = 0x083B;
046: public final static short SPRM_FVANISH = 0x083C;
047: public final static short SPRM_KUL = 0x2A3E;
048: public final static short SPRM_DXASPACE = (short) 0x8840;
049: public final static short SPRM_LID = 0x4A41;
050: public final static short SPRM_ICO = 0x2A42;
051: public final static short SPRM_HPS = 0x4A43;
052: public final static short SPRM_HPSPOS = 0x4845;
053: public final static short SPRM_ISS = 0x2A48;
054: public final static short SPRM_HPSKERN = 0x484B;
055: public final static short SPRM_YSRI = 0x484E;
056: public final static short SPRM_RGFTCASCII = 0x4A4F;
057: public final static short SPRM_RGFTCFAREAST = 0x4A50;
058: public final static short SPRM_RGFTCNOTFAREAST = 0x4A51;
059: public final static short SPRM_CHARSCALE = 0x4852;
060: public final static short SPRM_FDSTRIKE = 0x2A53;
061: public final static short SPRM_FIMPRINT = 0x0854;
062: public final static short SPRM_FSPEC = 0x0855;
063: public final static short SPRM_FOBJ = 0x0856;
064: public final static short SPRM_PROPRMARK = (short) 0xCA57;
065: public final static short SPRM_FEMBOSS = 0x0858;
066: public final static short SPRM_SFXTEXT = 0x2859;
067: public final static short SPRM_DISPFLDRMARK = (short) 0xCA62;
068: public final static short SPRM_IBSTRMARKDEL = 0x4863;
069: public final static short SPRM_DTTMRMARKDEL = 0x6864;
070: public final static short SPRM_BRC = 0x6865;
071: public final static short SPRM_SHD = 0x4866;
072: public final static short SPRM_IDSIRMARKDEL = 0x4867;
073: public final static short SPRM_CPG = 0x486B;
074: public final static short SPRM_NONFELID = 0x486D;
075: public final static short SPRM_FELID = 0x486E;
076: public final static short SPRM_IDCTHINT = 0x286F;
077:
078: int _ico24 = -1; // default to -1 so we can ignore it for word 97 files
079:
080: public CharacterProperties() {
081: field_17_fcPic = -1;
082: field_22_dttmRMark = new DateAndTime();
083: field_23_dttmRMarkDel = new DateAndTime();
084: field_36_dttmPropRMark = new DateAndTime();
085: field_40_dttmDispFldRMark = new DateAndTime();
086: field_41_xstDispFldRMark = new byte[36];
087: field_42_shd = new ShadingDescriptor();
088: field_43_brc = new BorderCode();
089: field_7_hps = 20;
090: field_24_istd = 10;
091: field_16_wCharScale = 100;
092: field_13_lidDefault = 0x0400;
093: field_14_lidFE = 0x0400;
094: }
095:
096: public boolean isMarkedDeleted() {
097: return isFRMarkDel();
098: }
099:
100: public void markDeleted(boolean mark) {
101: super .setFRMarkDel(mark);
102: }
103:
104: public boolean isBold() {
105: return isFBold();
106: }
107:
108: public void setBold(boolean bold) {
109: super .setFBold(bold);
110: }
111:
112: public boolean isItalic() {
113: return isFItalic();
114: }
115:
116: public void setItalic(boolean italic) {
117: super .setFItalic(italic);
118: }
119:
120: public boolean isOutlined() {
121: return isFOutline();
122: }
123:
124: public void setOutline(boolean outlined) {
125: super .setFOutline(outlined);
126: }
127:
128: public boolean isFldVanished() {
129: return isFFldVanish();
130: }
131:
132: public void setFldVanish(boolean fldVanish) {
133: super .setFFldVanish(fldVanish);
134: }
135:
136: public boolean isSmallCaps() {
137: return isFSmallCaps();
138: }
139:
140: public void setSmallCaps(boolean smallCaps) {
141: super .setFSmallCaps(smallCaps);
142: }
143:
144: public boolean isCapitalized() {
145: return isFCaps();
146: }
147:
148: public void setCapitalized(boolean caps) {
149: super .setFCaps(caps);
150: }
151:
152: public boolean isVanished() {
153: return isFVanish();
154: }
155:
156: public void setVanished(boolean vanish) {
157: super .setFVanish(vanish);
158:
159: }
160:
161: public boolean isMarkedInserted() {
162: return isFRMark();
163: }
164:
165: public void markInserted(boolean mark) {
166: super .setFRMark(mark);
167: }
168:
169: public boolean isStrikeThrough() {
170: return isFStrike();
171: }
172:
173: public void strikeThrough(boolean strike) {
174: super .setFStrike(strike);
175: }
176:
177: public boolean isShadowed() {
178: return isFShadow();
179: }
180:
181: public void setShadow(boolean shadow) {
182: super .setFShadow(shadow);
183:
184: }
185:
186: public boolean isEmbossed() {
187: return isFEmboss();
188: }
189:
190: public void setEmbossed(boolean emboss) {
191: super .setFEmboss(emboss);
192: }
193:
194: public boolean isImprinted() {
195: return isFImprint();
196: }
197:
198: public void setImprinted(boolean imprint) {
199: super .setFImprint(imprint);
200: }
201:
202: public boolean isDoubleStrikeThrough() {
203: return isFDStrike();
204: }
205:
206: public void setDoubleStrikeThrough(boolean dstrike) {
207: super .setFDStrike(dstrike);
208: }
209:
210: public int getFontSize() {
211: return getHps();
212: }
213:
214: public void setFontSize(int halfPoints) {
215: super .setHps(halfPoints);
216: }
217:
218: public int getCharacterSpacing() {
219: return getDxaSpace();
220: }
221:
222: public void setCharacterSpacing(int twips) {
223: super .setDxaSpace(twips);
224: }
225:
226: public short getSubSuperScriptIndex() {
227: return getIss();
228: }
229:
230: public void setSubSuperScriptIndex(short iss) {
231: super .setDxaSpace(iss);
232: }
233:
234: public int getUnderlineCode() {
235: return super .getKul();
236: }
237:
238: public void setUnderlineCode(int kul) {
239: super .setKul((byte) kul);
240: }
241:
242: public int getColor() {
243: return super .getIco();
244: }
245:
246: public void setColor(int color) {
247: super .setIco((byte) color);
248: }
249:
250: public int getVerticalOffset() {
251: return super .getHpsPos();
252: }
253:
254: public void setVerticalOffset(int hpsPos) {
255: super .setHpsPos(hpsPos);
256: }
257:
258: public int getKerning() {
259: return super .getHpsKern();
260: }
261:
262: public void setKerning(int kern) {
263: super .setHpsKern(kern);
264: }
265:
266: public boolean isHighlighted() {
267: return super .isFHighlight();
268: }
269:
270: public void setHighlighted(byte color) {
271: super .setIcoHighlight(color);
272: }
273:
274: /**
275: * Get the ico24 field for the CHP record.
276: */
277: public int getIco24() {
278: if (_ico24 == -1) {
279: switch (field_11_ico) // convert word 97 colour numbers to 0xBBGGRR value
280: {
281: case 0: // auto
282: return -1;
283: case 1: // black
284: return 0x000000;
285: case 2: // blue
286: return 0xFF0000;
287: case 3: // cyan
288: return 0xFFFF00;
289: case 4: // green
290: return 0x00FF00;
291: case 5: // magenta
292: return 0xFF00FF;
293: case 6: // red
294: return 0x0000FF;
295: case 7: // yellow
296: return 0x00FFFF;
297: case 8: // white
298: return 0x0FFFFFF;
299: case 9: // dark blue
300: return 0x800000;
301: case 10: // dark cyan
302: return 0x808000;
303: case 11: // dark green
304: return 0x008000;
305: case 12: // dark magenta
306: return 0x800080;
307: case 13: // dark red
308: return 0x000080;
309: case 14: // dark yellow
310: return 0x008080;
311: case 15: // dark grey
312: return 0x808080;
313: case 16: // light grey
314: return 0xC0C0C0;
315: }
316: }
317: return _ico24;
318: }
319:
320: /**
321: * Set the ico24 field for the CHP record.
322: */
323: public void setIco24(int colour24) {
324: _ico24 = colour24 & 0xFFFFFF; // only keep the 24bit 0xBBGGRR colour
325: }
326:
327: public Object clone() throws CloneNotSupportedException {
328: CharacterProperties cp = (CharacterProperties) super .clone();
329: cp.field_22_dttmRMark = (DateAndTime) field_22_dttmRMark
330: .clone();
331: cp.field_23_dttmRMarkDel = (DateAndTime) field_23_dttmRMarkDel
332: .clone();
333: cp.field_36_dttmPropRMark = (DateAndTime) field_36_dttmPropRMark
334: .clone();
335: cp.field_40_dttmDispFldRMark = (DateAndTime) field_40_dttmDispFldRMark
336: .clone();
337: cp.field_41_xstDispFldRMark = (byte[]) field_41_xstDispFldRMark
338: .clone();
339: cp.field_42_shd = (ShadingDescriptor) field_42_shd.clone();
340:
341: cp._ico24 = _ico24;
342:
343: return cp;
344: }
345:
346: }
|