File: HwpRecord_ParaShape.java

package info (click to toggle)
h2orestart 0.7.9-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,168 kB
  • sloc: java: 21,845; makefile: 36; xml: 19
file content (557 lines) | stat: -rw-r--r-- 23,621 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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
/* Copyright (C) 2023 ebandal
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>
 */
/* 본 제품은 한글과컴퓨터의 ᄒᆞᆫ글 문서 파일(.hwp) 공개 문서를 참고하여 개발하였습니다.
 * 개방형 워드프로세서 마크업 언어(OWPML) 문서 구조 KS X 6101:2018 문서를 참고하였습니다.
 * 작성자 : 반희수 ebandal@gmail.com  
 * 작성일 : 2022.10
 */
package HwpDoc.HwpElement;

import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;

import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

import HwpDoc.HwpDocInfo;
import HwpDoc.Exception.HwpParseException;
import HwpDoc.Exception.NotImplementedException;

public class HwpRecord_ParaShape extends HwpRecord {
	private static final Logger log = Logger.getLogger(HwpRecord_ParaShape.class.getName());
	private HwpDocInfo	parent;

	public HorizontalAlign align;								// 정렬방식 (0:양쪽정렬, 1:왼쪽정렬, 2:오른쪽정렬, 3:가운데정렬, 4:배분정렬, 5:나눔 정렬
	public byte			breakLatinWord;							// 줄 나눔 기준 영어 단위 (0:단어, 1:하이픈, 2:글자)
	public byte			breakNonLatinWord;						// 줄 나눔 기준 한글 단위 (0:어절, 1:글자)
	public boolean		snapToGrid;								// 편집 용지의 줄 격자 사용 여부
	public byte			condense;								// 공백 최소값 (0%~75%)
	public boolean 		widowOrphan;							// 외톨이줄 보호 여부
	public boolean 		keepWithNext;							// 다음 문단과 함께 여부
	public boolean 		pageBreakBefore;						// 문단 앞에서 항상 쪽 나눔 여부
	public VerticalAlign   vertAlign;							// 세로정렬 (0:글꼴기준, 1:위쪽, 2:가운데, 3:아래)
	public boolean		fontLineHeight;							// 글꼴에 어울리는 줄 높이 여부
	public HeadingType	headingType;							// 문단 머리 모양 종류 (0:없음, 1:개요, 2:번호, 3:글머리표(bullet))
	
	public byte			headingLevel;							// 문단 수준 (1수준~7수준)
	public boolean		connect;								// 문단 테두리 연결 여부
	public boolean		ignoreMargin;							// 문단 여백 무시 여부
	public boolean 		paraTailShape;							// 문단 꼬리 모양
	
	public int			indent;									// 들여쓰기/내어쓰기.
	public int			marginLeft;								// 왼쪽 여백		HWPUINT형이 아닌  INT32형이다. 7000값을 35pt, 12.3mm로 계산한다.
	public int			marginRight;							// 오른쪽 여백		HWPUINT형이 아닌  INT32형이다. 7000값을 35pt, 12.3mm로 계산한다.
	public int			marginPrev;								// 문단 간격 위		HWPUINT형이 아닌  INT32형이다. 7000값을 35pt, 12.3mm로 계산한다.
	public int			marginNext;								// 문단 간격 아래	HWPUINT형이 아닌  INT32형이다. 7000값을 35pt, 12.3mm로 계산한다.
	public int			lineSpacing;							// 줄 간격. 한글2007 이하버전(5.0.2.5 버전 미만)에서 사용.
																// 		percent일때:0%~500%, fixed일때:hpwunit또는 글자수,betweenline일때:hwpunit또는글자수  
	
	public short		tabDef;									// 탭 정의 아이디(TabDef ID) 참조 값
	public short		headingIdRef;    						// 번호 문단 ID(Numbering ID) 또는 글머리표 문단 모양 ID(Bullet ID)참조 값
	public short		borderFill;								// 테두리/배경 모양 ID(BorderFill ID) 참조 값
	public short		offsetLeft;								// 문단 테두리 왼쪽 간격
	public short		offsetRight;							// 문단 테두리 오른쪽 간격
	public short		offsetTop;								// 문단 테두리 위쪽 간격
	public short		offsetBottom;							// 문단 테두리 아래쪽 간격
																// 속성2 (5.0.1.7 버전 이상)
	public byte			lineWrap;								// 		한줄로 입력
	public boolean		autoSpaceEAsianEng;						// 		한글과 영어 간격을 자동 조절
	public boolean		autoSpaceEAsianNum;						// 		한글과 숫자 간격을 자동 조절
																// 속성3 (5.0.2.5 버전 이상)
	public int			lineSpacingType;						// 		줄간격 종류(0:Percent,1:Fixed,2:BetweenLines,4:AtLeast)
	
	public boolean      firstAfterTable;                        // 테이블 다음에 첫문단인지 여부 (리브레오피스와 한컴오피스의 테이블 차이를 극복하기 위한 속성 정의

	HwpRecord_ParaShape(int tagNum, int level, int size) {
		super(tagNum, level, size);
	}
	
	public HwpRecord_ParaShape(HwpDocInfo docInfo, int tagNum, int level, int size, byte[] buf, int off, int version) throws HwpParseException {
		super(tagNum, level, size);
		this.parent = docInfo;
		
		int offset = off;
		int typeBits 		= buf[offset+3]<<24&0xFF000000 | buf[offset+2]<<16&0x00FF0000 | buf[offset+1]<<8&0x0000FF00 | buf[offset]&0x000000FF;
		offset += 4;
		align				= HorizontalAlign.from(typeBits>>>2 & 0x07);
		breakLatinWord	 	= (byte) (typeBits>>>5 & 0x03);
		breakNonLatinWord 	= (byte) (typeBits>>>7 & 0x01);
		snapToGrid			= (typeBits&0x80)==0x80?true:false;
		condense			= (byte) (typeBits>>>9 & 0x7F);
		widowOrphan		 	= (typeBits&0x10000)==0x10000?true:false;
		keepWithNext		= (typeBits&0x20000)==0x20000?true:false;
		pageBreakBefore		= (typeBits&0x40000)==0x40000?true:false;
		vertAlign			= VerticalAlign.from(typeBits>>>20 & 0x03);
		fontLineHeight		= (typeBits&0x100000)==0x100000?true:false;
		headingType			= HeadingType.from((typeBits>>>23 & 0x03));
		headingLevel		= (byte) (typeBits>>>25 & 0x07);
		connect				= (typeBits&0x800000)==0x800000?true:false;
		ignoreMargin		= (typeBits&0x1000000)==0x1000000?true:false;
		paraTailShape		= (typeBits&0x2000000)==0x2000000?true:false;
		
		marginLeft 			= buf[offset+3]<<24&0xFF000000 | buf[offset+2]<<16&0x00FF0000 | buf[offset+1]<<8&0x0000FF00 | buf[offset]&0x000000FF;
		offset += 4;
		marginRight			= buf[offset+3]<<24&0xFF000000 | buf[offset+2]<<16&0x00FF0000 | buf[offset+1]<<8&0x0000FF00 | buf[offset]&0x000000FF;
		offset += 4;
		indent 				= buf[offset+3]<<24&0xFF000000 | buf[offset+2]<<16&0x00FF0000 | buf[offset+1]<<8&0x0000FF00 | buf[offset]&0x000000FF;
		offset += 4;
		marginPrev 			= buf[offset+3]<<24&0xFF000000 | buf[offset+2]<<16&0x00FF0000 | buf[offset+1]<<8&0x0000FF00 | buf[offset]&0x000000FF;
		offset += 4;
		marginNext	 		= buf[offset+3]<<24&0xFF000000 | buf[offset+2]<<16&0x00FF0000 | buf[offset+1]<<8&0x0000FF00 | buf[offset]&0x000000FF;
		offset += 4;
		if (version<5025) {
		    lineSpacingType = (byte) (typeBits & 0x03);
			lineSpacing 	= buf[offset+3]<<24&0xFF000000 | buf[offset+2]<<16&0x00FF0000 | buf[offset+1]<<8&0x0000FF00 | buf[offset]&0x000000FF;
			offset += 4;
		} else {
			offset += 4;
		}
		tabDef				= (short) (buf[offset+1]<<8&0xFF00 | buf[offset]&0x00FF);
		offset += 2;
		headingIdRef		= (short) (buf[offset+1]<<8&0xFF00 | buf[offset]&0x00FF);
		offset += 2;
		borderFill			= (short) (buf[offset+1]<<8&0xFF00 | buf[offset]&0x00FF);
		offset += 2;
		offsetLeft			= (short) (buf[offset+1]<<8&0xFF00 | buf[offset]&0x00FF);
		offset += 2;
		offsetRight			= (short) (buf[offset+1]<<8&0xFF00 | buf[offset]&0x00FF);
		offset += 2;
		offsetTop			= (short) (buf[offset+1]<<8&0xFF00 | buf[offset]&0x00FF);
		offset += 2;
		offsetBottom		= (short) (buf[offset+1]<<8&0xFF00 | buf[offset]&0x00FF);
		offset += 2;
		
		if (version>=5017) {
			int attrBits		= buf[offset+3]<<24&0xFF000000 | buf[offset+2]<<16&0x00FF0000 | buf[offset+1]<<8&0x0000FF00 | buf[offset]&0x000000FF;
			offset += 4;
			lineWrap			= (byte) (attrBits & 0x03);
			autoSpaceEAsianEng	=(typeBits&0x10)==0x10?true:false;
			autoSpaceEAsianNum	=(typeBits&0x20)==0x20?true:false;
		} else {
			offset += 4;
		}
		
		if (version>=5025) {
			int attrBits		= buf[offset+3]<<24&0xFF000000 | buf[offset+2]<<16&0x00FF0000 | buf[offset+1]<<8&0x0000FF00 | buf[offset]&0x000000FF;
			offset += 4;
			lineSpacingType 	= (byte) (attrBits&0x0F);
			lineSpacing			= buf[offset+3]<<24&0xFF000000 | buf[offset+2]<<16&0x00FF0000 | buf[offset+1]<<8&0x0000FF00 | buf[offset]&0x000000FF;
			offset += 4;
		} else {
			offset += 8;
		}

		log.fine("                                                  "
				+"ID="+(parent.paraShapeList.size())
				+",정렬="+align+",줄나눔="+breakNonLatinWord
				+",문단margin=("+marginLeft+","+marginRight+","+marginPrev+","+marginNext+")"
				+",문단offset=("+offsetLeft+","+offsetRight+","+offsetTop+","+offsetBottom+")"
				+",줄간격="+lineSpacingType+":"+lineSpacing
				+","+headingType+"(ID="+headingIdRef+",Level="+headingLevel+")"
				+",탭ID="+tabDef
				+",테두리ID="+borderFill
				);
		
		if (offset-off-size != 0 && offset-off!=54) {
			log.fine("[TAG]=" + tag.toString() + ", size=" + size + ", but currentSize=" + (offset-off));
			dump(buf, off, size);
			throw new HwpParseException();
		}
	}

	
	public HwpRecord_ParaShape(HwpDocInfo docInfo, Node node, int version) throws NotImplementedException {
        super(HwpTag.HWPTAG_PARA_SHAPE, 0, 0);
        this.parent = docInfo;
        
        NamedNodeMap attributes = node.getAttributes();
        
        // 초기값
        headingType = HeadingType.NONE;
        align       = HorizontalAlign.JUSTIFY;
        vertAlign   = VerticalAlign.BASELINE;
        
        // id값은 처리하지 않는다. List<HwpRecord_ParaShape>에 순차적으로 추가한다.
        // String id = attributes.getNamedItem("id").getNodeValue();
        
        String numStr = attributes.getNamedItem("tabPrIDRef").getNodeValue();
        tabDef = (short) Integer.parseInt(numStr);
        
        numStr = attributes.getNamedItem("condense").getNodeValue();
        condense = (byte) Integer.parseInt(numStr);
        
        switch(attributes.getNamedItem("fontLineHeight").getNodeValue()) {
        case "0":
            fontLineHeight = false; break;
        case "1":
            fontLineHeight = true;  break;
        }
        
        switch(attributes.getNamedItem("snapToGrid").getNodeValue()) {
        case "0":
            snapToGrid = false; break;
        case "1":
            snapToGrid = true;  break;
        }

        /*
        switch(attributes.getNamedItem("suppressLineNumbers").getNodeValue()) {
        case "0":
            suppressLineNumbers = false; break;
        case "1":
            suppressLineNumbers = true;  break;
        }
        */
        /*
        switch(attributes.getNamedItem("checked").getNodeValue()) {
        case "0":
            checked = false; break;
        case "1":
            checked = true;  break;
        }
        */
        
        NodeList nodeList = node.getChildNodes();
        for (int i=0; i<nodeList.getLength(); i++) {
            Node child = nodeList.item(i);
            recursive_ParaShape(child);
        }
        
    }
	
	private void recursive_ParaShape(Node child) throws NotImplementedException {
        String numStr;
        
        switch(child.getNodeName()) {
        case "hh:align":
            {
                NamedNodeMap childAttrs = child.getAttributes();
                align = HorizontalAlign.valueOf(childAttrs.getNamedItem("horizontal").getNodeValue());
                vertAlign = VerticalAlign.valueOf(childAttrs.getNamedItem("vertical").getNodeValue());
            }
            break;
        case "hh:heading":
            {
                NamedNodeMap childAttrs = child.getAttributes();
                headingType = HeadingType.valueOf(childAttrs.getNamedItem("type").getNodeValue());
                
                numStr = childAttrs.getNamedItem("idRef").getNodeValue();
                headingIdRef = (short)Integer.parseInt(numStr);
    
                numStr = childAttrs.getNamedItem("level").getNodeValue();
                headingLevel = (byte)Integer.parseInt(numStr);
            }
            break;
        case "hh:breakSetting":
            {
                NamedNodeMap childAttrs = child.getAttributes();
                switch(childAttrs.getNamedItem("breakLatinWord").getNodeValue()) {
                case "KEEP_WORD":
                    breakLatinWord = 0; break;     // 0:단어,1:하이픈,2:글자
                case "BREAK_WORD":
                	breakLatinWord = 1; break;
                case "HYPHENATION":
                    breakLatinWord = 1; break;
                default:
                	log.warning("Not Implemented:" + childAttrs.getNamedItem("breakLatinWord").getNodeValue());
                	if (log.isLoggable(Level.FINE)) {
                		throw new NotImplementedException("HwpRecord_ParaShape");
                	}
                	break;
                }
    
                switch(childAttrs.getNamedItem("breakNonLatinWord").getNodeValue()) {
                case "KEEP_WORD":
                    breakNonLatinWord = 0; break;     // 0:어절,1:글자
                case "BREAK_WORD":
                    breakNonLatinWord = 1; break; 
                default:
                	if (log.isLoggable(Level.FINE)) {
                		throw new NotImplementedException("HwpRecord_ParaShape");
                	}
                	break;
                }
    
                switch(childAttrs.getNamedItem("widowOrphan").getNodeValue()) {
                case "0":
                    widowOrphan = false;   break;
                case "1":
                    widowOrphan = true;    break;
                }
                
                switch(childAttrs.getNamedItem("keepWithNext").getNodeValue()) {
                case "0":
                    keepWithNext = false;   break;
                case "1":
                    keepWithNext = true;    break;
                }
                /*
                switch(childAttrs.getNamedItem("keepLines").getNodeValue()) {
                case "0":
                    keepLines = false;    break;
                case "1":
                    keepLines = true;    break;
                }
				*/
                switch(childAttrs.getNamedItem("pageBreakBefore").getNodeValue()) {
                case "0":
                    pageBreakBefore = false;   break;
                case "1":
                    pageBreakBefore = true;    break;
                }
    
                switch(childAttrs.getNamedItem("lineWrap").getNodeValue()) {
                case "BREAK":
                    lineWrap = 0;   break;
                case "SQUEEZE":
                	lineWrap = 1;	break;
                }
            }
            break;
        case "hh:lineSpacing":
            {
                NamedNodeMap childAttrs = child.getAttributes();
                switch(childAttrs.getNamedItem("type").getNodeValue()) {
                case "PERCENT":
                    lineSpacingType = 0; break;
                case "FIXED":
                    lineSpacingType = 1; break;
                case "BETWEENLINES":
                    lineSpacingType = 2; break;
                case "AT_LEAST":
                    lineSpacingType = 4; break;
                default:
                	if (log.isLoggable(Level.FINE)) {
                		throw new NotImplementedException("HwpRecord_ParaShape");
                	}
                	break;
                }
                
                numStr = childAttrs.getNamedItem("value").getNodeValue();
                lineSpacing = Integer.parseInt(numStr);
            }
            break;
        case "hh:border":
            {
                NamedNodeMap childAttrs = child.getAttributes();
                numStr = childAttrs.getNamedItem("borderFillIDRef").getNodeValue();
                borderFill = (short) Integer.parseInt(numStr);

                numStr = childAttrs.getNamedItem("offsetLeft").getNodeValue();
                offsetLeft = (short) Integer.parseInt(numStr);

                numStr = childAttrs.getNamedItem("offsetRight").getNodeValue();
                offsetRight = (short) Integer.parseInt(numStr);

                numStr = childAttrs.getNamedItem("offsetTop").getNodeValue();
                offsetTop = (short) Integer.parseInt(numStr);

                numStr = childAttrs.getNamedItem("offsetBottom").getNodeValue();
                offsetBottom = (short) Integer.parseInt(numStr);

                switch(childAttrs.getNamedItem("connect").getNodeValue()) {
                case "0":
                    connect = false; break;
                case "1":
                    connect = true;  break;
                }
                
                switch(childAttrs.getNamedItem("ignoreMargin").getNodeValue()) {
                case "0":
                    ignoreMargin = false; break;
                case "1":
                    ignoreMargin = true;  break;
                }
            }
            break;
        case "hh:autoSpacing":
            {
                NamedNodeMap childAttrs = child.getAttributes();
                switch(childAttrs.getNamedItem("eAsianEng").getNodeValue()) {
                case "0":
                    autoSpaceEAsianEng = false; break;
                case "1":
                    autoSpaceEAsianEng = true;  break;
                }
                
                switch(childAttrs.getNamedItem("eAsianNum").getNodeValue()) {
                case "0":
                    autoSpaceEAsianNum = false; break;
                case "1":
                    autoSpaceEAsianNum = true;  break;
                }
            }
            break;
        case "hc:intent":
            {
                NamedNodeMap childAttrs = child.getAttributes();
                numStr = childAttrs.getNamedItem("value").getNodeValue();
                indent = Integer.parseInt(numStr);
            }
            break;
        case "hc:left":
            {
                NamedNodeMap childAttrs = child.getAttributes();
                numStr = childAttrs.getNamedItem("value").getNodeValue();
                marginLeft = Integer.parseInt(numStr);
            }
            break;
        case "hc:right":
            {
                NamedNodeMap childAttrs = child.getAttributes();
                numStr = childAttrs.getNamedItem("value").getNodeValue();
                marginRight = Integer.parseInt(numStr);
            }
            break;
        case "hc:prev":
            {
                NamedNodeMap childAttrs = child.getAttributes();
                numStr = childAttrs.getNamedItem("value").getNodeValue();
                marginPrev = Integer.parseInt(numStr);
            }
            break;
        case "hc:next":
            {
                NamedNodeMap childAttrs = child.getAttributes();
                numStr = childAttrs.getNamedItem("value").getNodeValue();
                marginNext = Integer.parseInt(numStr);
            }
            break;
        case "hp:switch":
        case "hp:case":
        case "hp:default":
        case "hh:margin":
            {
                NodeList childNodeList = child.getChildNodes();
                for (int i=0; i<childNodeList.getLength(); i++) {
                    Node grandChild = childNodeList.item(i);
                    recursive_ParaShape(grandChild);
                }
            }
            break;
        }
	}
	
	public static HwpRecord_ParaShape clone(HwpRecord_ParaShape source) throws IOException, ClassNotFoundException {
		HwpRecord_ParaShape cloned = new HwpRecord_ParaShape(source.tag.ordinal(), source.level, source.size);

		cloned.align             = source.align;
		cloned.breakLatinWord    = source.breakLatinWord;
		cloned.breakNonLatinWord = source.breakNonLatinWord;
		cloned.snapToGrid        = source.snapToGrid;
		cloned.condense          = source.condense;
		cloned.widowOrphan       = source.widowOrphan;
		cloned.keepWithNext      = source.keepWithNext;
		cloned.pageBreakBefore   = source.pageBreakBefore;
		cloned.vertAlign 	     = source.vertAlign;
		cloned.fontLineHeight    = source.fontLineHeight;
		cloned.headingType       = source.headingType;
		cloned.headingLevel      = source.headingLevel;
		cloned.connect           = source.connect;
		cloned.ignoreMargin      = source.ignoreMargin;
		cloned.paraTailShape     = source.paraTailShape;
		
		cloned.indent            = source.indent;
		cloned.marginLeft        = source.marginLeft;
		cloned.marginRight	     = source.marginRight;
		cloned.marginPrev        = source.marginPrev;
		cloned.marginNext        = source.marginNext;
		cloned.lineSpacing       = source.lineSpacing;
		cloned.tabDef            = source.tabDef;
		cloned.headingIdRef      = source.headingIdRef;
		cloned.borderFill        = source.borderFill;
		cloned.offsetLeft        = source.offsetLeft;
		cloned.offsetRight       = source.offsetRight;
		cloned.offsetTop         = source.offsetTop;
		cloned.offsetBottom      = source.offsetBottom;
		cloned.lineWrap          = source.lineWrap;
		cloned.autoSpaceEAsianEng = source.autoSpaceEAsianEng;
		cloned.autoSpaceEAsianNum = source.autoSpaceEAsianNum;
		cloned.lineSpacingType   = source.lineSpacingType;
		
		return cloned;
	}
	
	
    public static enum HeadingType {
		NONE		(0),	// 없음
		OUTLINE		(1),	// 개요
		NUMBER		(2),	// 번호
		BULLET		(3);	// 글머리표

		private int num;
		
	    private HeadingType(int num) { 
	    	this.num = num;
	    }

	    public static HeadingType from(int num) {
	    	for (HeadingType type: values()) {
	    		if (type.num == num)
	    			return type;
	    	}
	    	return null;
	    }
	}
    
    public static enum HorizontalAlign {
        JUSTIFY          (0),   // 양쪽 정렬
        LEFT             (1),   // 왼쪽 정렬
        RIGHT            (2),   // 오른쪽 정렬
        CENTER           (3),   // 가운데 정렬
        DISTRIBUTE       (4),   // 배분 정렬
        DISTRIBUTE_SPACE (5);   // 나눔 정렬
        
        private int num;
        
        private HorizontalAlign(int num) { 
            this.num = num;
        }

        public static HorizontalAlign from(int num) {
            for (HorizontalAlign type: values()) {
                if (type.num == num)
                    return type;
            }
            return JUSTIFY;
        }
    }
    
    public static enum VerticalAlign {
        BASELINE    (0),    // 글꼴 기준
        TOP         (1),    // 위쪽
        CENTER      (2),    // 가운데
        BOTTOM      (3);    // 아래

        private int num;
        
        private VerticalAlign(int num) { 
            this.num = num;
        }

        public static VerticalAlign from(int num) {
            for (VerticalAlign type: values()) {
                if (type.num == num)
                    return type;
            }
            return BASELINE;
        }
    }
    
    
}