| /************************************************************** |
| * |
| * Licensed to the Apache Software Foundation (ASF) under one |
| * or more contributor license agreements. See the NOTICE file |
| * distributed with this work for additional information |
| * regarding copyright ownership. The ASF licenses this file |
| * to you under the Apache License, Version 2.0 (the |
| * "License"); you may not use this file except in compliance |
| * with the License. You may obtain a copy of the License at |
| * |
| * http://www.apache.org/licenses/LICENSE-2.0 |
| * |
| * Unless required by applicable law or agreed to in writing, |
| * software distributed under the License is distributed on an |
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| * KIND, either express or implied. See the License for the |
| * specific language governing permissions and limitations |
| * under the License. |
| * |
| *************************************************************/ |
| |
| |
| |
| /* $Id: hinfo.cpp,v 1.5 2008-06-04 09:58:52 vg Exp $ */ |
| |
| #include "precompile.h" |
| |
| #include "hwplib.h" |
| #include "hinfo.h" |
| #include "hwpfile.h" |
| |
| // Info Block |
| |
| //int ParaShape::count = 0; |
| //int CharShape::count = 0; |
| |
| static bool HWPReadInfoBlock(void *ptr, int len, HWPFile & hwpf) |
| { |
| hwpf.info_block_len = len; |
| if (0 == len) |
| return true; |
| else |
| return hwpf.ReadBlock(ptr, len) ? true : false; |
| } |
| |
| |
| // Document Infomation |
| |
| HWPInfo::HWPInfo(void) |
| { |
| info_block = 0; |
| back_info.isset = false; |
| } |
| |
| |
| HWPInfo::~HWPInfo(void) |
| { |
| if (info_block) |
| delete[]info_block; |
| info_block = 0; |
| } |
| |
| |
| /** |
| * ¹®¼Á¤º¸¸¦ ÀоîµéÀÌ´Â ÇÔ¼ö ( 128 bytes ) |
| * ¹®¼Á¤º¸´Â ÆÄÀÏÀνÄÁ¤º¸( 30 bytes ) ´ÙÀ½¿¡ À§Ä¡ÇÑ Á¤º¸ÀÌ´Ù. |
| */ |
| bool HWPInfo::Read(HWPFile & hwpf) |
| { |
| hwpf.Read2b(&cur_col, 1); /* ¹®¼¸¦ ÀúÀåÇÒ ´ç½ÃÀÇ Ä¿¼°¡ À§Ä¡ÇÑ ¹®´Ü¹øÈ£ */ |
| hwpf.Read2b(&cur_row, 1); /* ¹®´Ü Ä */ |
| |
| hwpf.Read1b(&paper.paper_kind, 1); /* ¿ëÁö Á¾·ù */ |
| hwpf.Read1b(&paper.paper_direction, 1); /* ¿ëÁö ¹æÇâ */ |
| |
| // paper geometry information |
| paper.paper_height = (short) hwpf.Read2b(); /* ¿ëÁö ±æÀÌ */ |
| paper.paper_width = (short) hwpf.Read2b(); /* ¿ëÁö ³Êºñ */ |
| paper.top_margin = (short) hwpf.Read2b(); /* À§ÂÊ ¿©¹é */ |
| paper.bottom_margin = (short) hwpf.Read2b(); /* ¾Æ·¡ÂÊ ¿©¹é */ |
| paper.left_margin = (short) hwpf.Read2b(); /* ¿ÞÂÊ ¿©¹é */ |
| paper.right_margin = (short) hwpf.Read2b(); /* ¿À¸¥ÂÊ ¿©¹é */ |
| paper.header_length = (short) hwpf.Read2b(); /* ¸Ó¸®¸» ±æÀÌ */ |
| paper.footer_length = (short) hwpf.Read2b(); /* ²¿¸®¸» ±æÀÌ */ |
| paper.gutter_length = (short) hwpf.Read2b(); /* Á¦º»¿©¹é */ |
| hwpf.Read2b(&readonly, 1); /* ¿¹¾à */ |
| hwpf.Read1b(reserved1, 4); /* ¿¹¾à */ |
| hwpf.Read1b(&chain_info.chain_page_no, 1); /* ÂÊ ¹øÈ£ ¿¬°á 1-¿¬°á, 0-»õ·Î½ÃÀÛ (¿¬°áÀμ⿡¼ »ç¿ë) */ |
| hwpf.Read1b(&chain_info.chain_footnote_no, 1);/* °¢ÁÖ¹øÈ£ ¿¬°á 1-¿¬°á 0-»õ·Î½ÃÀÛ */ |
| /* ¿¬°áÀμâÇÒ ÆÄÀÏÀÇ À̸§ */ |
| hwpf.Read1b(chain_info.chain_filename, CHAIN_MAX_PATH); |
| |
| hwpf.Read1b(annotation, ANNOTATION_LEN); /* µ¡ºÙÀÌ´Â ¸» ( ÆÄÀÏ ÀúÀåÇÒ ¶§ µ¡ºÙÀÌ´Â ¸»¿¡ ÁöÁ¤ÇÑ ³»¿ë ) */ |
| hwpf.Read2b(&encrypted, 1); /* ¾ÏÈ£ ¿©ºÎ 0-º¸ÅëÆÄÀÏ, ±×¿Ü-¾ÏÈ£°É¸° ÆÄÀÏ */ |
| //hwpf.Read1b(reserved2, 6); /* ¾Æ·¡ 3°³ÀǰªÀ¸·Î ¹Ù²î¾ú´Ù. */ |
| hwpf.Read2b(&beginpagenum,1); /* ÆäÀÌÁö½ÃÀÛ¹øÈ£ */ |
| |
| // footnote |
| hwpf.Read2b(&beginfnnum,1); /* °¢ÁÖ ½ÃÀÛ¹øÈ£ */ |
| hwpf.Read2b(&countfn,1); /* °¢ÁÖ °¹¼ö */ |
| splinetext = (short) hwpf.Read2b(); |
| splinefn = (short) hwpf.Read2b(); |
| spfnfn = (short) hwpf.Read2b(); |
| hwpf.Read1b(&fnchar, 1); |
| hwpf.Read1b(&fnlinetype, 1); |
| // border layout |
| for (int ii = 0; ii < 4; ++ii) |
| bordermargin[ii] = (short) hwpf.Read2b(); |
| hwpf.Read2b(&borderline, 1); |
| |
| hwpf.Read1b(&empty_line_hide, 1); |
| hwpf.Read1b(&table_move, 1); |
| hwpf.Read1b(&compressed, 1); |
| |
| hwpf.Read1b(&reserved3, 1); |
| |
| hwpf.Read2b(&info_block_len, 1); |
| if (hwpf.State()) |
| return false; |
| |
| /* ¹®¼ ¿ä¾àÀ» Àд´Ù. */ |
| if (!summary.Read(hwpf)) |
| return false; |
| if (info_block_len > 0) |
| { |
| info_block = new unsigned char[info_block_len + 1]; |
| |
| if (0 == info_block || |
| !HWPReadInfoBlock(info_block, info_block_len, hwpf)) |
| return false; |
| } |
| |
| /* hwpfÀÇ °ªÀ» Àç¼³Á¤ ÇÑ´Ù. */ |
| hwpf.compressed = compressed ? true : false; |
| hwpf.encrypted = encrypted ? true : false; |
| hwpf.info_block_len = info_block_len; |
| hwpf.SetCompressed(hwpf.compressed); |
| |
| return (!hwpf.State()); |
| } |
| |
| |
| // Document Summary |
| |
| bool HWPSummary::Read(HWPFile & hwpf) |
| { |
| hwpf.Read2b(title, 56); |
| hwpf.Read2b(subject, 56); |
| hwpf.Read2b(author, 56); |
| hwpf.Read2b(date, 56); |
| hwpf.Read2b(keyword[0], 56); |
| hwpf.Read2b(keyword[1], 56); |
| hwpf.Read2b(etc[0], 56); |
| hwpf.Read2b(etc[1], 56); |
| hwpf.Read2b(etc[2], 56); |
| |
| return (!hwpf.State()); |
| } |
| |
| |
| // |
| |
| bool ParaShape::Read(HWPFile & hwpf) |
| { |
| pagebreak = 0; |
| left_margin = (short) hwpf.Read2b(); |
| right_margin = (short) hwpf.Read2b(); |
| indent = (short) hwpf.Read2b(); |
| lspacing = (short) hwpf.Read2b(); |
| pspacing_next = (short) hwpf.Read2b(); |
| |
| hwpf.Read1b(&condense, 1); |
| hwpf.Read1b(&arrange_type, 1); |
| for (int ii = 0; ii < MAXTABS; ii++) |
| { |
| hwpf.Read1b(&tabs[ii].type, 1); |
| hwpf.Read1b(&tabs[ii].dot_continue, 1); |
| tabs[ii].position = (short) hwpf.Read2b(); |
| } |
| hwpf.Read1b(&coldef.ncols, 1); |
| hwpf.Read1b(&coldef.separator, 1); |
| coldef.spacing = (short) hwpf.Read2b(); |
| coldef.columnlen = (short) hwpf.Read2b(); |
| coldef.columnlen0 = (short) hwpf.Read2b(); |
| hwpf.Read1b(&shade, 1); |
| hwpf.Read1b(&outline, 1); |
| hwpf.Read1b(&outline_continue, 1); |
| pspacing_prev = (short) hwpf.Read2b(); |
| |
| hwpf.Read1b(reserved, 2); |
| return (!hwpf.State()); |
| } |
| |
| |
| /* |
| CharShape::~CharShape() |
| { |
| } |
| ParaShape::~ParaShape() |
| { |
| } |
| |
| */ |
| bool CharShape::Read(HWPFile & hwpf) |
| { |
| //index = ++count; |
| size = (short) hwpf.Read2b(); |
| hwpf.Read1b(font, NLanguage); |
| hwpf.Read1b(ratio, NLanguage); |
| hwpf.Read1b(space, NLanguage); |
| hwpf.Read1b(color, 2); |
| hwpf.Read1b(&shade, 1); |
| hwpf.Read1b(&attr, 1); |
| hwpf.Read1b(reserved, 4); |
| |
| return (!hwpf.State()); |
| } |