merge the formfield patch from ooo-build
[ooovba.git] / hwpfilter / source / hinfo.cpp
blob1f626f0440da72f37b2b8d22efe70133e4ea56ea
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: hinfo.cpp,v $
10 * $Revision: 1.5 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 /* $Id: hinfo.cpp,v 1.5 2008-06-04 09:58:52 vg Exp $ */
33 #include "precompile.h"
35 #include "hwplib.h"
36 #include "hinfo.h"
37 #include "hwpfile.h"
39 // Info Block
41 //int ParaShape::count = 0;
42 //int CharShape::count = 0;
44 static bool HWPReadInfoBlock(void *ptr, int len, HWPFile & hwpf)
46 hwpf.info_block_len = len;
47 if (0 == len)
48 return true;
49 else
50 return hwpf.ReadBlock(ptr, len) ? true : false;
54 // Document Infomation
56 HWPInfo::HWPInfo(void)
58 info_block = 0;
59 back_info.isset = false;
63 HWPInfo::~HWPInfo(void)
65 if (info_block)
66 delete[]info_block;
67 info_block = 0;
71 /**
72 * ¹®¼­Á¤º¸¸¦ ÀоîµéÀÌ´Â ÇÔ¼ö ( 128 bytes )
73 * ¹®¼­Á¤º¸´Â ÆÄÀÏÀνÄÁ¤º¸( 30 bytes ) ´ÙÀ½¿¡ À§Ä¡ÇÑ Á¤º¸ÀÌ´Ù.
75 bool HWPInfo::Read(HWPFile & hwpf)
77 hwpf.Read2b(&cur_col, 1); /* ¹®¼­¸¦ ÀúÀåÇÒ ´ç½ÃÀÇ Ä¿¼­°¡ À§Ä¡ÇÑ ¹®´Ü¹øÈ£ */
78 hwpf.Read2b(&cur_row, 1); /* ¹®´Ü Ä­ */
80 hwpf.Read1b(&paper.paper_kind, 1); /* ¿ëÁö Á¾·ù */
81 hwpf.Read1b(&paper.paper_direction, 1); /* ¿ëÁö ¹æÇâ */
83 // paper geometry information
84 paper.paper_height = (short) hwpf.Read2b(); /* ¿ëÁö ±æÀÌ */
85 paper.paper_width = (short) hwpf.Read2b(); /* ¿ëÁö ³Êºñ */
86 paper.top_margin = (short) hwpf.Read2b(); /* À§ÂÊ ¿©¹é */
87 paper.bottom_margin = (short) hwpf.Read2b(); /* ¾Æ·¡ÂÊ ¿©¹é */
88 paper.left_margin = (short) hwpf.Read2b(); /* ¿ÞÂÊ ¿©¹é */
89 paper.right_margin = (short) hwpf.Read2b(); /* ¿À¸¥ÂÊ ¿©¹é */
90 paper.header_length = (short) hwpf.Read2b(); /* ¸Ó¸®¸» ±æÀÌ */
91 paper.footer_length = (short) hwpf.Read2b(); /* ²¿¸®¸» ±æÀÌ */
92 paper.gutter_length = (short) hwpf.Read2b(); /* Á¦º»¿©¹é */
93 hwpf.Read2b(&readonly, 1); /* ¿¹¾à */
94 hwpf.Read1b(reserved1, 4); /* ¿¹¾à */
95 hwpf.Read1b(&chain_info.chain_page_no, 1); /* ÂÊ ¹øÈ£ ¿¬°á 1-¿¬°á, 0-»õ·Î½ÃÀÛ (¿¬°áÀμ⿡¼­ »ç¿ë) */
96 hwpf.Read1b(&chain_info.chain_footnote_no, 1);/* °¢ÁÖ¹øÈ£ ¿¬°á 1-¿¬°á 0-»õ·Î½ÃÀÛ */
97 /* ¿¬°áÀμâÇÒ ÆÄÀÏÀÇ À̸§ */
98 hwpf.Read1b(chain_info.chain_filename, CHAIN_MAX_PATH);
100 hwpf.Read1b(annotation, ANNOTATION_LEN); /* µ¡ºÙÀÌ´Â ¸» ( ÆÄÀÏ ÀúÀåÇÒ ¶§ µ¡ºÙÀÌ´Â ¸»¿¡ ÁöÁ¤ÇÑ ³»¿ë ) */
101 hwpf.Read2b(&encrypted, 1); /* ¾ÏÈ£ ¿©ºÎ 0-º¸ÅëÆÄÀÏ, ±×¿Ü-¾ÏÈ£°É¸° ÆÄÀÏ */
102 //hwpf.Read1b(reserved2, 6); /* ¾Æ·¡ 3°³ÀÇ°ªÀ¸·Î ¹Ù²î¾ú´Ù. */
103 hwpf.Read2b(&beginpagenum,1); /* ÆäÀÌÁö½ÃÀÛ¹øÈ£ */
105 // footnote
106 hwpf.Read2b(&beginfnnum,1); /* °¢ÁÖ ½ÃÀÛ¹øÈ£ */
107 hwpf.Read2b(&countfn,1); /* °¢ÁÖ °¹¼ö */
108 splinetext = (short) hwpf.Read2b();
109 splinefn = (short) hwpf.Read2b();
110 spfnfn = (short) hwpf.Read2b();
111 hwpf.Read1b(&fnchar, 1);
112 hwpf.Read1b(&fnlinetype, 1);
113 // border layout
114 for (int ii = 0; ii < 4; ++ii)
115 bordermargin[ii] = (short) hwpf.Read2b();
116 hwpf.Read2b(&borderline, 1);
118 hwpf.Read1b(&empty_line_hide, 1);
119 hwpf.Read1b(&table_move, 1);
120 hwpf.Read1b(&compressed, 1);
122 hwpf.Read1b(&reserved3, 1);
124 hwpf.Read2b(&info_block_len, 1);
125 if (hwpf.State())
126 return false;
128 /* ¹®¼­ ¿ä¾àÀ» Àд´Ù. */
129 if (!summary.Read(hwpf))
130 return false;
131 if (info_block_len > 0)
133 info_block = new unsigned char[info_block_len + 1];
135 if (0 == info_block ||
136 !HWPReadInfoBlock(info_block, info_block_len, hwpf))
137 return false;
140 /* hwpfÀÇ °ªÀ» Àç¼³Á¤ ÇÑ´Ù. */
141 hwpf.compressed = compressed ? true : false;
142 hwpf.encrypted = encrypted ? true : false;
143 hwpf.info_block_len = info_block_len;
144 hwpf.SetCompressed(hwpf.compressed);
146 return (!hwpf.State());
150 // Document Summary
152 bool HWPSummary::Read(HWPFile & hwpf)
154 hwpf.Read2b(title, 56);
155 hwpf.Read2b(subject, 56);
156 hwpf.Read2b(author, 56);
157 hwpf.Read2b(date, 56);
158 hwpf.Read2b(keyword[0], 56);
159 hwpf.Read2b(keyword[1], 56);
160 hwpf.Read2b(etc[0], 56);
161 hwpf.Read2b(etc[1], 56);
162 hwpf.Read2b(etc[2], 56);
164 return (!hwpf.State());
170 bool ParaShape::Read(HWPFile & hwpf)
172 pagebreak = 0;
173 left_margin = (short) hwpf.Read2b();
174 right_margin = (short) hwpf.Read2b();
175 indent = (short) hwpf.Read2b();
176 lspacing = (short) hwpf.Read2b();
177 pspacing_next = (short) hwpf.Read2b();
179 hwpf.Read1b(&condense, 1);
180 hwpf.Read1b(&arrange_type, 1);
181 for (int ii = 0; ii < MAXTABS; ii++)
183 hwpf.Read1b(&tabs[ii].type, 1);
184 hwpf.Read1b(&tabs[ii].dot_continue, 1);
185 tabs[ii].position = (short) hwpf.Read2b();
187 hwpf.Read1b(&coldef.ncols, 1);
188 hwpf.Read1b(&coldef.separator, 1);
189 coldef.spacing = (short) hwpf.Read2b();
190 coldef.columnlen = (short) hwpf.Read2b();
191 coldef.columnlen0 = (short) hwpf.Read2b();
192 hwpf.Read1b(&shade, 1);
193 hwpf.Read1b(&outline, 1);
194 hwpf.Read1b(&outline_continue, 1);
195 pspacing_prev = (short) hwpf.Read2b();
197 hwpf.Read1b(reserved, 2);
198 return (!hwpf.State());
203 CharShape::~CharShape()
206 ParaShape::~ParaShape()
211 bool CharShape::Read(HWPFile & hwpf)
213 //index = ++count;
214 size = (short) hwpf.Read2b();
215 hwpf.Read1b(font, NLanguage);
216 hwpf.Read1b(ratio, NLanguage);
217 hwpf.Read1b(space, NLanguage);
218 hwpf.Read1b(color, 2);
219 hwpf.Read1b(&shade, 1);
220 hwpf.Read1b(&attr, 1);
221 hwpf.Read1b(reserved, 4);
223 return (!hwpf.State());