LCOV - code coverage report
Current view: top level - hwpfilter/source - hinfo.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 125 159 78.6 %
Date: 2015-06-13 12:38:46 Functions: 6 7 85.7 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include "precompile.h"
      21             : 
      22             : #include "hwplib.h"
      23             : #include "hinfo.h"
      24             : #include "hwpfile.h"
      25             : 
      26             : // Info Block
      27             : 
      28             : 
      29           0 : static bool HWPReadInfoBlock(void *ptr, int len, HWPFile & hwpf)
      30             : {
      31           0 :     hwpf.info_block_len = len;
      32           0 :     if (0 == len)
      33           0 :         return true;
      34             :     else
      35           0 :         return hwpf.ReadBlock(ptr, len) != 0;
      36             : }
      37             : 
      38             : 
      39             : // Document Information
      40          86 : HWPInfo::HWPInfo()
      41             :     : cur_col(0)
      42             :     , cur_row(0)
      43             :     , readonly(0)
      44             :     , encrypted(0)
      45             :     , beginpagenum(0)
      46             :     , beginfnnum(0)
      47             :     , countfn(0)
      48             :     , splinetext(0)
      49             :     , splinefn(0)
      50             :     , spfnfn(0)
      51             :     , fnchar(0)
      52             :     , fnlinetype(0)
      53             :     , borderline(0)
      54             :     , empty_line_hide(0)
      55             :     , table_move(0)
      56             :     , compressed(0)
      57             :     , reserved3(0)
      58             :     , info_block_len(0)
      59          86 :     , info_block(NULL)
      60             : {
      61          86 :     back_info.isset = false;
      62          86 :     memset(reserved1, 0, sizeof(reserved1));
      63          86 :     memset(annotation, 0, sizeof(annotation));
      64          86 :     memset(bordermargin, 0, sizeof(bordermargin));
      65          86 : }
      66             : 
      67          86 : HWPInfo::~HWPInfo()
      68             : {
      69          86 :     delete[] info_block;
      70          86 :     info_block = 0;
      71          86 : }
      72             : 
      73             : 
      74             : /**
      75             :  * 문서정보를 읽어들이는 함수 ( 128 bytes )
      76             :  * 문서정보는 파일인식정보( 30 bytes ) 다음에 위치한 정보이다.
      77             :  */
      78           1 : bool HWPInfo::Read(HWPFile & hwpf)
      79             : {
      80           1 :     hwpf.Read2b(&cur_col, 1);                     /* 문서를 저장할 당시의 커서가 위치한 문단번호 */
      81           1 :     hwpf.Read2b(&cur_row, 1);                     /* 문단 칸 */
      82             : 
      83           1 :     hwpf.Read1b(&paper.paper_kind, 1);            /* 용지 종류 */
      84           1 :     hwpf.Read1b(&paper.paper_direction, 1);       /* 용지 방향 */
      85             : 
      86             : // paper geometry information
      87             :     unsigned short tmp16;
      88           1 :     if (!hwpf.Read2b(tmp16))
      89           0 :         return false;
      90           1 :     paper.paper_height = tmp16;                   /* 용지 길이 */
      91           1 :     if (!hwpf.Read2b(tmp16))
      92           0 :         return false;
      93           1 :     paper.paper_width = tmp16;                    /* 용지 너비 */
      94           1 :     if (!hwpf.Read2b(tmp16))
      95           0 :         return false;
      96           1 :     paper.top_margin = tmp16;                     /* 위쪽 여백 */
      97           1 :     if (!hwpf.Read2b(tmp16))
      98           0 :         return false;
      99           1 :     paper.bottom_margin = tmp16;                  /* 아래쪽 여백 */
     100           1 :     if (!hwpf.Read2b(tmp16))
     101           0 :         return false;
     102           1 :     paper.left_margin = tmp16;                    /* 왼쪽 여백 */
     103           1 :     if (!hwpf.Read2b(tmp16))
     104           0 :         return false;
     105           1 :     paper.right_margin = tmp16;                   /* 오른쪽 여백 */
     106           1 :     if (!hwpf.Read2b(tmp16))
     107           0 :         return false;
     108           1 :     paper.header_length = tmp16;                  /* 머리말 길이 */
     109           1 :     if (!hwpf.Read2b(tmp16))
     110           0 :         return false;
     111           1 :     paper.footer_length = tmp16;                  /* 꼬리말 길이 */
     112           1 :     if (!hwpf.Read2b(tmp16))
     113           0 :         return false;
     114           1 :     paper.gutter_length = tmp16;                  /* 제본여백 */
     115           1 :     hwpf.Read2b(&readonly, 1);                    /* 예약 */
     116           1 :     hwpf.Read1b(reserved1, 4);                    /* 예약 */
     117           1 :     hwpf.Read1b(&chain_info.chain_page_no, 1);    /* 쪽 번호 연결 1-연결, 0-새로시작 (연결인쇄에서 사용) */
     118           1 :     hwpf.Read1b(&chain_info.chain_footnote_no, 1);/* 각주번호 연결 1-연결 0-새로시작 */
     119             :                                                   /* 연결인쇄할 파일의 이름 */
     120           1 :     hwpf.Read1b(chain_info.chain_filename, CHAIN_MAX_PATH);
     121             : 
     122           1 :     hwpf.Read1b(annotation, ANNOTATION_LEN);      /* 덧붙이는 말 ( 파일 저장할 때 덧붙이는 말에 지정한 내용 ) */
     123           1 :     hwpf.Read2b(&encrypted, 1);                   /* 암호 여부 0-보통파일, 그외-암호걸린 파일 */
     124             : //hwpf.Read1b(reserved2, 6);                      /* 아래 3개의값으로 바뀌었다. */
     125           1 :     hwpf.Read2b(&beginpagenum,1);                 /* 페이지시작번호 */
     126             : 
     127             : // footnote
     128           1 :     hwpf.Read2b(&beginfnnum,1);                   /* 각주 시작번호 */
     129           1 :     hwpf.Read2b(&countfn,1);                      /* 각주 갯수 */
     130             : 
     131           1 :     if (!hwpf.Read2b(tmp16))
     132           0 :         return false;
     133           1 :     splinetext = tmp16;
     134           1 :     if (!hwpf.Read2b(tmp16))
     135           0 :         return false;
     136           1 :     splinefn = tmp16;
     137           1 :     if (!hwpf.Read2b(tmp16))
     138           0 :         return false;
     139           1 :     spfnfn = tmp16;
     140           1 :     hwpf.Read1b(&fnchar, 1);
     141           1 :     hwpf.Read1b(&fnlinetype, 1);
     142             : // border layout
     143           5 :     for (int ii = 0; ii < 4; ++ii)
     144             :     {
     145           4 :         if (!hwpf.Read2b(tmp16))
     146           0 :             return false;
     147           4 :         bordermargin[ii] = tmp16;
     148             :     }
     149           1 :     hwpf.Read2b(&borderline, 1);
     150             : 
     151           1 :     hwpf.Read1b(&empty_line_hide, 1);
     152           1 :     hwpf.Read1b(&table_move, 1);
     153           1 :     hwpf.Read1b(&compressed, 1);
     154             : 
     155           1 :     hwpf.Read1b(&reserved3, 1);
     156             : 
     157           1 :     hwpf.Read2b(&info_block_len, 1);
     158           1 :     if (hwpf.State())
     159           0 :         return false;
     160             : 
     161             : /* 문서 요약을 읽는다. */
     162           1 :     if (!summary.Read(hwpf))
     163           0 :         return false;
     164           1 :     if (info_block_len > 0)
     165             :     {
     166           0 :         info_block = new unsigned char[info_block_len + 1];
     167             : 
     168           0 :         if (!HWPReadInfoBlock(info_block, info_block_len, hwpf))
     169           0 :             return false;
     170             :     }
     171             : 
     172             : /* hwpf의 값을 재설정 한다. */
     173           1 :     hwpf.compressed = compressed != 0;
     174           1 :     hwpf.encrypted = encrypted != 0;
     175           1 :     hwpf.info_block_len = info_block_len;
     176           1 :     hwpf.SetCompressed(hwpf.compressed);
     177             : 
     178           1 :     return (!hwpf.State());
     179             : }
     180             : 
     181             : 
     182             : // Document Summary
     183             : 
     184           1 : bool HWPSummary::Read(HWPFile & hwpf)
     185             : {
     186           1 :     hwpf.Read2b(title, 56);
     187           1 :     hwpf.Read2b(subject, 56);
     188           1 :     hwpf.Read2b(author, 56);
     189           1 :     hwpf.Read2b(date, 56);
     190           1 :     hwpf.Read2b(keyword[0], 56);
     191           1 :     hwpf.Read2b(keyword[1], 56);
     192           1 :     hwpf.Read2b(etc[0], 56);
     193           1 :     hwpf.Read2b(etc[1], 56);
     194           1 :     hwpf.Read2b(etc[2], 56);
     195             : 
     196           1 :     return (!hwpf.State());
     197             : }
     198             : 
     199             : 
     200          14 : bool ParaShape::Read(HWPFile & hwpf)
     201             : {
     202          14 :     pagebreak = 0;
     203             :     unsigned short tmp16;
     204          14 :     if (!hwpf.Read2b(tmp16))
     205           0 :         return false;
     206          14 :     left_margin = tmp16;
     207          14 :     if (!hwpf.Read2b(tmp16))
     208           0 :         return false;
     209          14 :     right_margin = tmp16;
     210          14 :     if (!hwpf.Read2b(tmp16))
     211           0 :         return false;
     212          14 :     indent = tmp16;
     213          14 :     if (!hwpf.Read2b(tmp16))
     214           0 :         return false;
     215          14 :     lspacing = tmp16;
     216          14 :     if (!hwpf.Read2b(tmp16))
     217           0 :         return false;
     218          14 :     pspacing_next = tmp16;
     219             : 
     220          14 :     hwpf.Read1b(&condense, 1);
     221          14 :     hwpf.Read1b(&arrange_type, 1);
     222         574 :     for (int ii = 0; ii < MAXTABS; ii++)
     223             :     {
     224         560 :         hwpf.Read1b(&tabs[ii].type, 1);
     225         560 :         hwpf.Read1b(&tabs[ii].dot_continue, 1);
     226         560 :         if (!hwpf.Read2b(tmp16))
     227           0 :             return false;
     228         560 :         tabs[ii].position = tmp16;
     229             :     }
     230          14 :     hwpf.Read1b(&coldef.ncols, 1);
     231          14 :     hwpf.Read1b(&coldef.separator, 1);
     232          14 :     if (!hwpf.Read2b(tmp16))
     233           0 :         return false;
     234          14 :     coldef.spacing = tmp16;
     235          14 :     if (!hwpf.Read2b(tmp16))
     236           0 :         return false;
     237          14 :     coldef.columnlen = tmp16;
     238          14 :     if (!hwpf.Read2b(tmp16))
     239           0 :         return false;
     240          14 :     coldef.columnlen0 = tmp16;
     241          14 :     hwpf.Read1b(&shade, 1);
     242          14 :     hwpf.Read1b(&outline, 1);
     243          14 :     hwpf.Read1b(&outline_continue, 1);
     244          14 :     if (!hwpf.Read2b(tmp16))
     245           0 :         return false;
     246          14 :     pspacing_prev = tmp16;
     247             : 
     248          14 :     hwpf.Read1b(reserved, 2);
     249          14 :     return (!hwpf.State());
     250             : }
     251             : 
     252             : 
     253          17 : bool CharShape::Read(HWPFile & hwpf)
     254             : {
     255             :     unsigned short tmp16;
     256          17 :     if (!hwpf.Read2b(tmp16))
     257           0 :         return false;
     258          17 :     size = tmp16;
     259          17 :     hwpf.Read1b(font, NLanguage);
     260          17 :     hwpf.Read1b(ratio, NLanguage);
     261          17 :     hwpf.Read1b(space, NLanguage);
     262          17 :     hwpf.Read1b(color, 2);
     263          17 :     hwpf.Read1b(&shade, 1);
     264          17 :     hwpf.Read1b(&attr, 1);
     265          17 :     hwpf.Read1b(reserved, 4);
     266             : 
     267          17 :     return (!hwpf.State());
     268             : }
     269             : 
     270             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11