LCOV - code coverage report
Current view: top level - hwpfilter/source - hwpread.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 2 485 0.4 %
Date: 2014-04-11 Functions: 1 43 2.3 %
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 <comphelper/newarray.hxx>
      23             : 
      24             : #include <list>
      25             : 
      26             : #include "hwpfile.h"
      27             : #include "hbox.h"
      28             : #include "hpara.h"
      29             : #include "drawing.h"
      30             : #include "htags.h"
      31             : #include "hcode.h"
      32             : 
      33             : static short fboxnum = 1;
      34             : static int zindex = 1;
      35             : static int lnnumber = 0;
      36             : 
      37          35 : bool HBox::Read(HWPFile & )
      38             : {
      39             : // already read
      40          35 :     return true;
      41             : }
      42             : 
      43             : 
      44             : // skip block
      45             : 
      46           0 : bool SkipData::Read(HWPFile & hwpf)
      47             : {
      48           0 :     hwpf.Read4b(&data_block_len, 1);
      49           0 :     hwpf.Read2b(&dummy, 1);
      50             : 
      51           0 :     if (!(IS_SP_SKIP_BLOCK(hh) && (hh == dummy))){
      52           0 :         return hwpf.SetState(HWP_InvalidFileFormat);
      53             :      }
      54             : 
      55           0 :     data_block = new char[data_block_len];
      56             : 
      57           0 :     return hwpf.Read1b(data_block, data_block_len);
      58             : }
      59             : 
      60             : 
      61             : // Field code(5)
      62           0 : bool FieldCode::Read(HWPFile & hwpf)
      63             : {
      64             :     ulong size;
      65             :     hchar dummy;
      66             :     ulong len1;       /* hcharŸÀÔÀÇ ¹®ÀÚ¿­ Å×ÀÌÅÍ #1ÀÇ ±æÀÌ */
      67             :     ulong len2;       /* hcharŸÀÔÀÇ ¹®ÀÚ¿­ Å×ÀÌÅÍ #2ÀÇ ±æÀÌ */
      68             :     ulong len3;       /* hcharŸÀÔÀÇ ¹®ÀÚ¿­ Å×ÀÌÅÍ #3ÀÇ ±æÀÌ */
      69             :     ulong binlen;     /* ÀÓÀÇ Çü½ÄÀÇ ¹ÙÀ̳ʸ® µ¥ÀÌŸ ±æÀÌ */
      70             : 
      71           0 :     hwpf.Read4b(&size, 1);
      72           0 :     hwpf.Read2b(&dummy, 1);
      73           0 :     hwpf.Read1b(&type, 2);
      74           0 :     hwpf.Read4b(reserved1, 1);
      75           0 :     hwpf.Read2b(&location_info, 1);
      76           0 :     hwpf.Read1b(reserved2, 22);
      77           0 :     hwpf.Read4b(&len1, 1);
      78           0 :     hwpf.Read4b(&len2, 1);
      79           0 :     hwpf.Read4b(&len3, 1);
      80           0 :     hwpf.Read4b(&binlen, 1);
      81             : 
      82           0 :     ulong const len1_ = ((len1 > 1024) ? 1024 : len1) / sizeof(hchar);
      83           0 :     ulong const len2_ = ((len2 > 1024) ? 1024 : len2) / sizeof(hchar);
      84           0 :     ulong const len3_ = ((len3 > 1024) ? 1024 : len3) / sizeof(hchar);
      85             : 
      86           0 :     str1 = new hchar[len1_ ? len1_ : 1];
      87           0 :     str2 = new hchar[len2_ ? len2_ : 1];
      88           0 :     str3 = new hchar[len3_ ? len3_ : 1];
      89           0 :     bin = new char[binlen];
      90             : 
      91           0 :     hwpf.Read2b(str1, len1_);
      92           0 :     hwpf.SkipBlock(len1 - (len1_ * sizeof(hchar)));
      93           0 :     str1[len1_ ? (len1_ - 1) : 0] = 0;
      94           0 :     hwpf.Read2b(str2, len2_);
      95           0 :     hwpf.SkipBlock(len2 - (len2_ * sizeof(hchar)));
      96           0 :     str2[len2_ ? (len2_ - 1) : 0] = 0;
      97           0 :     hwpf.Read2b(str3, len3_);
      98           0 :     hwpf.SkipBlock(len3 - (len3_ * sizeof(hchar)));
      99           0 :     str3[len3_ ? (len3_ - 1) : 0] = 0;
     100             : 
     101           0 :     hwpf.ReadBlock(bin, binlen);
     102             : 
     103           0 :      if( type[0] == 3 && type[1] == 2 ){ /* ¸¸µç³¯Â¥·Î¼­ Æ÷¸ËÀ» »ý¼ºÇØ¾ß ÇÑ´Ù. */
     104           0 :           DateCode *pDate = new DateCode;
     105           0 :           for (int i = 0 ; i < static_cast<int>(len3_); i++) {
     106           0 :                 if(str3[i] == 0 ) break;
     107           0 :                 if( i >= DATE_SIZE ) break;
     108           0 :                 pDate->format[i] = str3[i];
     109             :           }
     110           0 :           hwpf.AddDateFormat(pDate);
     111           0 :           m_pDate = pDate;
     112             :      }
     113             : 
     114           0 :     return true;
     115             : }
     116             : 
     117             : 
     118             : // book mark(6)
     119           0 : bool Bookmark::Read(HWPFile & hwpf)
     120             : {
     121             :     long len;
     122             : 
     123           0 :     hwpf.Read4b(&len, 1);
     124           0 :     dummy = sal::static_int_cast<hchar>(hwpf.Read2b());
     125             : 
     126           0 :     if (!(len == 34))// 2 * (BMK_COMMENT_LEN + 1) + 2
     127             :      {
     128           0 :         return hwpf.SetState(HWP_InvalidFileFormat);
     129             :      }
     130           0 :     if (!(hh == dummy && dummy == CH_BOOKMARK)){
     131           0 :         return hwpf.SetState(HWP_InvalidFileFormat);
     132             :      }
     133             : 
     134           0 :     hwpf.Read2b(id, BMK_COMMENT_LEN + 1);
     135           0 :     hwpf.Read2b(&type, 1);
     136             : //return hwpf.Read2b(&type, 1);
     137           0 :     return true;
     138             : }
     139             : 
     140             : 
     141             : // date format(7)
     142             : 
     143           0 : bool DateFormat::Read(HWPFile & hwpf)
     144             : {
     145           0 :     hwpf.Read2b(format, DATE_SIZE);
     146           0 :     dummy = sal::static_int_cast<hchar>(hwpf.Read2b());
     147           0 :     if (!(hh == dummy && CH_DATE_FORM == dummy)){
     148           0 :         return hwpf.SetState(HWP_InvalidFileFormat);
     149             :      }
     150           0 :     return true;
     151             : }
     152             : 
     153             : 
     154             : // date code(8)
     155             : 
     156           0 : bool DateCode::Read(HWPFile & hwpf)
     157             : {
     158           0 :     hwpf.Read2b(format, DATE_SIZE);
     159           0 :     hwpf.Read2b(date, 6);
     160           0 :     dummy = sal::static_int_cast<hchar>(hwpf.Read2b());
     161           0 :     if (!(hh == dummy && CH_DATE_CODE == dummy)){
     162           0 :         return hwpf.SetState(HWP_InvalidFileFormat);
     163             :      }
     164           0 :     hwpf.AddDateFormat(this);
     165           0 :     return true;
     166             : }
     167             : 
     168             : 
     169             : // tab(9)
     170             : 
     171           0 : bool Tab::Read(HWPFile & hwpf)
     172             : {
     173           0 :     width = hwpf.Read2b();
     174           0 :     leader = sal::static_int_cast<unsigned short>(hwpf.Read2b());
     175           0 :     dummy = sal::static_int_cast<hchar>(hwpf.Read2b());
     176           0 :     if (!(hh == dummy && CH_TAB == dummy)){
     177           0 :         return hwpf.SetState(HWP_InvalidFileFormat);
     178             :      }
     179           0 :     return true;
     180             : }
     181             : 
     182             : 
     183             : // tbox(10) TABLE BOX MATH BUTTON HYPERTEXT
     184             : 
     185           0 : static void UpdateBBox(FBox * fbox)
     186             : {
     187           0 :     fbox->boundsy = fbox->pgy;
     188           0 :     fbox->boundey = fbox->pgy + fbox->ys - 1;
     189           0 : }
     190             : 
     191             : 
     192           0 : void Cell::Read(HWPFile & hwpf)
     193             : {
     194           0 :     hwpf.Read2b(&p, 1);
     195           0 :     hwpf.Read2b(&color, 1);
     196           0 :     hwpf.Read2b(&x, 1);
     197           0 :     hwpf.Read2b(&y, 1);
     198           0 :     hwpf.Read2b(&w, 1);
     199           0 :     hwpf.Read2b(&h, 1);
     200           0 :     hwpf.Read2b(&txthigh, 1);
     201           0 :     hwpf.Read2b(&cellhigh, 1);
     202             : 
     203           0 :     hwpf.Read1b(&flag, 1);
     204           0 :     hwpf.Read1b(&changed, 1);
     205           0 :     hwpf.Read1b(&used, 1);
     206           0 :     hwpf.Read1b(&ver_align, 1);
     207           0 :     hwpf.Read1b(linetype, 4);
     208           0 :     hwpf.Read1b(&shade, 1);
     209           0 :     hwpf.Read1b(&diagonal, 1);
     210           0 :     hwpf.Read1b(&protect, 1);
     211           0 : }
     212             : 
     213             : 
     214           0 : bool TxtBox::Read(HWPFile & hwpf)
     215             : {
     216             :     int ii, ncell;
     217             : 
     218           0 :     hwpf.Read2b(reserved, 2);
     219           0 :     hwpf.Read2b(&dummy, 1);
     220             : 
     221           0 :     if (!(hh == dummy && CH_TEXT_BOX == dummy)){
     222           0 :         return hwpf.SetState(HWP_InvalidFileFormat);
     223             :      }
     224           0 :     hwpf.AddBox(this);
     225           0 :     hwpf.Read2b(&style.cap_len, 1);
     226           0 :     hwpf.Read2b(&dummy1, 1);
     227           0 :     hwpf.Read2b(&next, 1);
     228           0 :     hwpf.Read2b(&dummy2, 1);
     229             : 
     230           0 :     style.boxnum = fboxnum++;
     231           0 :      zorder = zindex++;
     232           0 :     hwpf.Read1b(&style.anchor_type, 1);
     233           0 :     hwpf.Read1b(&style.txtflow, 1);
     234           0 :     hwpf.Read2b(&style.xpos, 1);
     235           0 :     hwpf.Read2b(&style.ypos, 1);
     236           0 :     hwpf.Read2b(&option, 1);
     237           0 :     hwpf.Read2b(&ctrl_ch, 1);
     238           0 :     hwpf.Read2b(style.margin, 12);
     239           0 :     hwpf.AddFBoxStyle(&style);
     240           0 :     hwpf.Read2b(&box_xs, 1);
     241           0 :     hwpf.Read2b(&box_ys, 1);
     242           0 :     hwpf.Read2b(&cap_xs, 1);
     243           0 :     hwpf.Read2b(&cap_ys, 1);
     244           0 :     hwpf.Read2b(&style.cap_len, 1);
     245           0 :     hwpf.Read2b(&xs, 1);
     246           0 :     hwpf.Read2b(&ys, 1);
     247           0 :     hwpf.Read2b(&cap_margin, 1);
     248           0 :     hwpf.Read1b(&xpos_type, 1);
     249           0 :     hwpf.Read1b(&ypos_type, 1);
     250           0 :     hwpf.Read1b(&smart_linesp, 1);
     251           0 :     hwpf.Read1b(&reserved1, 1);
     252           0 :     hwpf.Read2b(&pgx, 1);
     253           0 :     hwpf.Read2b(&pgy, 1);
     254           0 :     hwpf.Read2b(&pgno, 1);
     255           0 :      if( ( pgno +1 ) != hwpf.getCurrentPage() )
     256           0 :           pgno = sal::static_int_cast<short>(hwpf.getCurrentPage() -1) ;
     257             : 
     258           0 :     hwpf.Read2b(&showpg, 1);
     259           0 :     hwpf.Read2b(&cap_pos, 1);
     260           0 :     hwpf.Read2b(&num, 1);
     261           0 :     hwpf.Read2b(&dummy3, 1);
     262           0 :     hwpf.Read2b(&baseline, 1);
     263           0 :     hwpf.Read2b(&type, 1);
     264           0 :     hwpf.Read2b(&nCell, 1);
     265           0 :     hwpf.Read2b(&protect, 1);
     266           0 :     switch (type)
     267             :     {
     268             :         case 0:                                   //table
     269           0 :             style.boxtype = 'T';
     270           0 :             break;
     271             :         case 1:                                   // text-box
     272           0 :             style.boxtype = 'X';
     273           0 :             break;
     274             :         case 2:                                   // equation
     275           0 :             style.boxtype = 'E';
     276           0 :             break;
     277             :         case 3:                                   // button
     278           0 :             style.boxtype = 'B';
     279           0 :             break;
     280             :         default:                                  // other
     281           0 :             style.boxtype = 'O';
     282           0 :             break;
     283             :     }
     284             : 
     285           0 :     UpdateBBox(this);
     286             : 
     287           0 :     ncell = NCell();
     288           0 :     if (!(ncell > 0)){
     289           0 :         return hwpf.SetState(HWP_InvalidFileFormat);
     290             :      }
     291             : 
     292           0 :     cell = ::comphelper::newArray_null<Cell>(ncell);
     293           0 :     if (!cell) {
     294           0 :         return hwpf.SetState(HWP_InvalidFileFormat);
     295             :     }
     296           0 :     for (ii = 0; ii < ncell; ii++)
     297             :     {
     298           0 :         cell[ii].Read(hwpf);
     299           0 :           cell[ii].key = sal::static_int_cast<unsigned char>(ii);
     300             :     }
     301           0 :     if (ncell == 1)
     302           0 :         style.cell = &cell[0];
     303           0 :     plists = ::comphelper::newArray_null< std::list< HWPPara* > >(ncell);
     304           0 :     if (!plists) {
     305           0 :         return hwpf.SetState(HWP_InvalidFileFormat);
     306             :     }
     307           0 :     for (ii = 0; ii < ncell; ii++)
     308           0 :         hwpf.ReadParaList(plists[ii]);
     309             :      // caption
     310           0 :     hwpf.ReadParaList(caption);
     311             : 
     312           0 :      if( type == 0 ){ // if table?
     313           0 :           TCell* *pArr = ::comphelper::newArray_null<TCell *>(ncell);
     314           0 :           if (!pArr) {
     315           0 :                 return hwpf.SetState(HWP_InvalidFileFormat);
     316             :           }
     317           0 :           Table *tbl = new Table;
     318           0 :           for( ii = 0 ; ii < ncell; ii++)
     319             :           {
     320           0 :                 tbl->columns.insert(cell[ii].x);
     321           0 :                 tbl->columns.insert(cell[ii].x + cell[ii].w);
     322           0 :                 tbl->rows.insert(cell[ii].y);
     323           0 :                 tbl->rows.insert(cell[ii].y + cell[ii].h);
     324             :           }
     325           0 :           for( ii = 0 ; ii < ncell; ii++)
     326             :           {
     327           0 :                 TCell *tcell = new TCell;
     328           0 :                 tcell->nColumnIndex = tbl->columns.getIndex(cell[ii].x);
     329           0 :                 tcell->nColumnSpan = tbl->columns.getIndex(cell[ii].x + cell[ii].w) -
     330           0 :                      tcell->nColumnIndex;
     331           0 :                 tcell->nRowIndex = tbl->rows.getIndex(cell[ii].y);
     332           0 :                 tcell->nRowSpan = tbl->rows.getIndex(cell[ii].y + cell[ii].h) -
     333           0 :                      tcell->nRowIndex;
     334           0 :                 tcell->pCell = &cell[ii];
     335           0 :                 pArr[ii] = tcell;
     336             :           }
     337             :           TCell *tmp;
     338             :           // Sort by row and column
     339           0 :           for( ii = 0 ; ii < ncell - 1; ii++ ){
     340           0 :                 for( int jj = ii ; jj < ncell ; jj++){
     341           0 :                      if( pArr[ii]->nRowIndex > pArr[jj]->nRowIndex ){
     342           0 :                           tmp = pArr[ii];
     343           0 :                           pArr[ii] = pArr[jj];
     344           0 :                           pArr[jj] = tmp;
     345             :                      }
     346             :                 }
     347           0 :                 for( int kk = ii ; kk > 0 ; kk--){
     348           0 :                      if( ( pArr[kk]->nRowIndex == pArr[kk-1]->nRowIndex ) &&
     349           0 :                             (pArr[kk]->nColumnIndex < pArr[kk-1]->nColumnIndex )){
     350           0 :                           tmp = pArr[kk];
     351           0 :                           pArr[kk] = pArr[kk-1];
     352           0 :                           pArr[kk-1] = tmp;
     353             :                      }
     354             :                 }
     355             :           }
     356           0 :           for( ii = 0 ; ii < ncell ; ii++ ){
     357           0 :                 tbl->cells.push_back(pArr[ii]);
     358             :           }
     359           0 :           tbl->box = this;
     360           0 :           hwpf.AddTable(tbl);
     361           0 :           m_pTable = tbl;
     362           0 :           delete[] pArr;
     363             :      }
     364             :      else
     365           0 :           m_pTable = 0L;
     366             : 
     367           0 :     return !hwpf.State();
     368             : }
     369             : 
     370             : 
     371             : // picture(11)
     372           0 : bool Picture::Read(HWPFile & hwpf)
     373             : {
     374           0 :     hwpf.Read2b(reserved, 2);
     375           0 :     hwpf.Read2b(&dummy, 1);
     376             : 
     377           0 :     if (!(hh == dummy && CH_PICTURE == dummy)){
     378           0 :         return hwpf.SetState(HWP_InvalidFileFormat);
     379             :      }
     380           0 :     hwpf.AddBox(this);
     381             : 
     382           0 :     hwpf.Read4b(&follow_block_size, 1);
     383           0 :     hwpf.Read2b(&dummy1, 1);                      /* ¿¹¾à 4¹ÙÀÌÆ® */
     384           0 :     hwpf.Read2b(&dummy2, 1);
     385             : 
     386           0 :     style.boxnum = fboxnum++;
     387           0 :      zorder = zindex++;
     388           0 :     hwpf.Read1b(&style.anchor_type, 1);           /* ±âÁØÀ§Ä¡ */
     389           0 :     hwpf.Read1b(&style.txtflow, 1);               /* ±×¸²ÇÇÇÔ. 0-2(ÀÚ¸®Â÷Áö,Åõ¸í,¾î¿ï¸²) */
     390           0 :     hwpf.Read2b(&style.xpos, 1);                  /* °¡·ÎÀ§Ä¡ : 1 ¿ÞÂÊ, 2¿À¸¥ÂÊ, 3 °¡¿îµ¥, ÀÌ¿Ü = ÀÓÀÇ */
     391           0 :     hwpf.Read2b(&style.ypos, 1);                  /* ¼¼·ÎÀ§Ä¡ : 1 À§, 2 ¾Æ·¡, 3 °¡¿îµ¥, ÀÌ¿Ü ÀÓÀÇ */
     392           0 :     hwpf.Read2b(&option, 1);                      /* ±âŸ¿É¼Ç : Å׵θ®,±×¸²¹ÝÀü,µî. bit·Î ÀúÀå. */
     393           0 :     hwpf.Read2b(&ctrl_ch, 1);                     /* Ç×»ó 11 */
     394           0 :     hwpf.Read2b(style.margin, 12);                /* ¿©¹é : [0-2][] out/in/¼¿,[][0-3] ¿Þ/¿À¸¥/À§/¾Æ·¡ ¿©¹é */
     395           0 :     hwpf.Read2b(&box_xs, 1);                      /* ¹Ú½ºÅ©±â °¡·Î */
     396           0 :     hwpf.Read2b(&box_ys, 1);                      /* ¼¼·Î */
     397           0 :     hwpf.Read2b(&cap_xs, 1);                      /* ĸ¼Ç Å©±â °¡·Î */
     398           0 :     hwpf.Read2b(&cap_ys, 1);                      /* ¼¼·Î */
     399           0 :     hwpf.Read2b(&style.cap_len, 1);               /* ±æÀÌ */
     400           0 :     hwpf.Read2b(&xs, 1);                          /* Àüü Å©±â(¹Ú½º Å©±â + ĸ¼Ç + ¿©¹é) °¡·Î */
     401           0 :     hwpf.Read2b(&ys, 1);                          /* ¼¼·Î */
     402           0 :     hwpf.Read2b(&cap_margin, 1);                  /* ĸ¼Ç ¿©¹é */
     403           0 :     hwpf.Read1b(&xpos_type, 1);
     404           0 :     hwpf.Read1b(&ypos_type, 1);
     405           0 :     hwpf.Read1b(&smart_linesp, 1);                /* ÁÙ°£°Ý º¸È£ : 0 ¹Ìº¸È£, 1 º¸È£ */
     406           0 :     hwpf.Read1b(&reserved1, 1);
     407           0 :     hwpf.Read2b(&pgx, 1);                         /* ½ÇÁ¦ °è»êµÈ ¹Ú½º °¡·Î */
     408           0 :     hwpf.Read2b(&pgy, 1);                         /* ¼¼·Î */
     409           0 :     hwpf.Read2b(&pgno, 1);                        /* ÆäÀÌÁö ¼ýÀÚ : 0ºÎÅÍ ½ÃÀÛ */
     410           0 :     hwpf.Read2b(&showpg, 1);                      /* ¹Ú½ºº¸¿©ÁÜ */
     411           0 :     hwpf.Read2b(&cap_pos, 1);                     /* ĸ¼ÇÀ§Ä¡ 0 - 7 ¸Þ´º¼ø¼­. */
     412           0 :     hwpf.Read2b(&num, 1);                         /* ¹Ú½º¹øÈ£ 0ºÎÅÍ ½ÃÀÛÇؼ­ ¸Å±äÀϷùøÈ£ */
     413             : 
     414           0 :     hwpf.Read1b(&pictype, 1);                     /* ±×¸²Á¾·ù */
     415             : 
     416           0 :     skip[0] = (short) hwpf.Read2b();              /* ±×¸²¿¡¼­ ½ÇÁ¦ Ç¥½Ã¸¦ ½ÃÀÛÇÒ À§Ä¡ °¡·Î */
     417           0 :     skip[1] = (short) hwpf.Read2b();              /* ¼¼·Î */
     418           0 :     scale[0] = (short) hwpf.Read2b();             /* È®´ëºñÀ² : 0 °íÁ¤, ÀÌ¿Ü ÆÛ¼¾Æ® ´ÜÀ§ °¡·Î */
     419           0 :     scale[1] = (short) hwpf.Read2b();             /* ¼¼·Î */
     420             : 
     421           0 :     hwpf.Read1b(picinfo.picun.path, 256);         /* ±×¸²ÆÄÀÏ À̸§ : Á¾·ù°¡ DrawingÀÌ ¾Æ´Ò¶§. */
     422           0 :     hwpf.Read1b(reserved3, 9);                    /* ¹à±â/¸í¾Ï/±×¸²È¿°ú µî */
     423             : 
     424           0 :     UpdateBBox(this);
     425           0 :     if( pictype != PICTYPE_DRAW )
     426           0 :         style.cell = reserved3;
     427             : 
     428           0 :     if (follow_block_size != 0)
     429             :     {
     430           0 :         follow = new unsigned char[follow_block_size];
     431             : 
     432           0 :         hwpf.Read1b(follow, follow_block_size);
     433           0 :         if (pictype == PICTYPE_DRAW)
     434             :         {
     435           0 :             hmem = new HMemIODev((char *) follow, follow_block_size);
     436           0 :             LoadDrawingObjectBlock(this);
     437           0 :             style.cell = picinfo.picdraw.hdo;
     438           0 :             delete hmem;
     439             : 
     440           0 :             hmem = 0;
     441             :         }
     442             :         else
     443             :         {
     444           0 :             if ((follow[3] << 24 | follow[2] << 16 | follow[1] << 8 | follow[0]) == 0x269)
     445             :             {
     446           0 :                 ishyper = true;
     447             :             }
     448             :         }
     449             :     }
     450             : 
     451           0 :     if( pictype != 3 )
     452           0 :         style.boxtype = 'G';
     453             :     else
     454           0 :         style.boxtype = 'D';
     455           0 :     hwpf.AddFBoxStyle(&style);
     456             : 
     457             : // cation
     458           0 :     hwpf.ReadParaList(caption);
     459             : 
     460           0 :     return !hwpf.State();
     461             : }
     462             : 
     463             : // line(15)
     464           0 : Line::Line()
     465             :     : FBox(CH_LINE)
     466             :     , dummy(0)
     467             :     , sx(0)
     468             :     , sy(0)
     469             :     , ex(0)
     470             :     , ey(0)
     471             :     , width(0)
     472             :     , shade(0)
     473           0 :     , color(0)
     474             : {
     475           0 : }
     476             : 
     477           0 : bool Line::Read(HWPFile & hwpf)
     478             : {
     479           0 :     hwpf.Read2b(reserved, 2);
     480           0 :     hwpf.Read2b(&dummy, 1);
     481             : 
     482           0 :     if (!(hh == dummy && CH_LINE == dummy)){
     483           0 :         return hwpf.SetState(HWP_InvalidFileFormat);
     484             :      }
     485           0 :     hwpf.AddBox(this);
     486             : 
     487           0 :     style.boxnum = fboxnum++;
     488           0 :      zorder = zindex++;
     489           0 :     style.boxtype = 'L';
     490           0 :     hwpf.Read1b(&reserved2, 8);
     491           0 :     hwpf.Read1b(&style.anchor_type, 1);
     492           0 :     hwpf.Read1b(&style.txtflow, 1);
     493           0 :     hwpf.Read2b(&style.xpos, 1);
     494           0 :     hwpf.Read2b(&style.ypos, 1);
     495           0 :     hwpf.Read2b(&option, 1);
     496           0 :     hwpf.Read2b(&ctrl_ch, 1);
     497           0 :     hwpf.Read2b(style.margin, 12);
     498           0 :     hwpf.AddFBoxStyle(&style);
     499           0 :     hwpf.Read2b(&box_xs, 1);
     500           0 :     hwpf.Read2b(&box_ys, 1);
     501           0 :     hwpf.Read2b(&cap_xs, 1);
     502           0 :     hwpf.Read2b(&cap_ys, 1);
     503           0 :     hwpf.Read2b(&style.cap_len, 1);
     504           0 :     hwpf.Read2b(&xs, 1);
     505           0 :     hwpf.Read2b(&ys, 1);
     506           0 :     lnnumber = style.boxnum;
     507           0 :     hwpf.linenumber = 1;
     508           0 :     hwpf.Read2b(&boundsy, 1);
     509           0 :     hwpf.Read2b(&boundey, 1);
     510           0 :     hwpf.Read1b(&boundx, 1);
     511           0 :     hwpf.Read1b(&draw, 1);
     512             : 
     513           0 :     hwpf.Read2b(&pgx, 1);
     514           0 :     hwpf.Read2b(&pgy, 1);
     515           0 :     hwpf.Read2b(&pgno, 1);
     516           0 :     hwpf.Read2b(&showpg, 1);
     517             : 
     518           0 :     hwpf.Read2b(&sx, 1);
     519           0 :     hwpf.Read2b(&sy, 1);
     520           0 :     hwpf.Read2b(&ex, 1);
     521           0 :     hwpf.Read2b(&sy, 1);
     522           0 :     hwpf.Read2b(&width, 1);
     523           0 :     hwpf.Read2b(&shade, 1);
     524           0 :     hwpf.Read2b(&color, 1);
     525           0 :     style.xpos = width;
     526             : 
     527           0 :     return !hwpf.State();
     528             : }
     529             : 
     530             : // hidden(15)
     531           0 : Hidden::Hidden()
     532             :     : HBox(CH_HIDDEN)
     533           0 :     , dummy(0)
     534             : {
     535           0 : }
     536             : 
     537           0 : bool Hidden::Read(HWPFile & hwpf)
     538             : {
     539           0 :     hwpf.Read2b(reserved, 2);
     540           0 :     hwpf.Read2b(&dummy, 1);
     541           0 :     if (!(hh == dummy && CH_HIDDEN == dummy)){
     542           0 :         return hwpf.SetState(HWP_InvalidFileFormat);
     543             :      }
     544             : 
     545           0 :     hwpf.Read1b(info, 8);
     546           0 :     hwpf.ReadParaList(plist);
     547             : 
     548           0 :     return !hwpf.State();
     549             : }
     550             : 
     551             : // header/footer(16)
     552           0 : HeaderFooter::HeaderFooter()
     553             :     : HBox(CH_HEADER_FOOTER)
     554             :     , dummy(0)
     555             :     , type(0)
     556             :     , where(0)
     557             :     , linenumber(0)
     558           0 :     , m_nPageNumber(0)
     559             : {
     560           0 : }
     561             : 
     562           0 : bool HeaderFooter::Read(HWPFile & hwpf)
     563             : {
     564           0 :     hwpf.Read2b(reserved, 2);
     565           0 :     hwpf.Read2b(&dummy, 1);
     566           0 :     if (!(hh == dummy && CH_HEADER_FOOTER == dummy)){
     567           0 :         return hwpf.SetState(HWP_InvalidFileFormat);
     568             :      }
     569             : 
     570           0 :     hwpf.Read1b(info, 8);
     571           0 :     hwpf.Read1b(&type, 1);
     572           0 :     hwpf.Read1b(&where, 1);
     573           0 :     lnnumber = 0;
     574           0 :     hwpf.ReadParaList(plist, CH_HEADER_FOOTER);
     575           0 :     linenumber = sal::static_int_cast<unsigned char>(lnnumber);
     576           0 :      m_nPageNumber = hwpf.getCurrentPage();
     577           0 :      hwpf.setMaxSettedPage();
     578           0 :      hwpf.AddHeaderFooter(this);
     579             : 
     580           0 :     return !hwpf.State();
     581             : }
     582             : 
     583             : 
     584             : // footnote(17)
     585           0 : Footnote::Footnote()
     586             :     : HBox(CH_FOOTNOTE)
     587             :     , dummy(0)
     588             :     , number(0)
     589             :     , type(0)
     590           0 :     , width(0)
     591             : {
     592           0 : }
     593             : 
     594           0 : bool Footnote::Read(HWPFile & hwpf)
     595             : {
     596           0 :     hwpf.Read2b(reserved, 2);
     597           0 :     hwpf.Read2b(&dummy, 1);
     598           0 :     if (!(hh == dummy && CH_FOOTNOTE == dummy)){
     599           0 :         return hwpf.SetState(HWP_InvalidFileFormat);
     600             :      }
     601             : 
     602           0 :     hwpf.Read1b(info, 8);
     603           0 :     hwpf.Read2b(&number, 1);
     604           0 :     hwpf.Read2b(&type, 1);
     605           0 :     width = (short) hwpf.Read2b();
     606           0 :     hwpf.ReadParaList(plist, CH_FOOTNOTE);
     607             : 
     608           0 :     return !hwpf.State();
     609             : }
     610             : 
     611             : // auto number(18)
     612           0 : AutoNum::AutoNum()
     613             :     : HBox(CH_AUTO_NUM)
     614             :     , type(0)
     615             :     , number(0)
     616           0 :     , dummy(0)
     617             : {
     618           0 : }
     619             : 
     620           0 : bool AutoNum::Read(HWPFile & hwpf)
     621             : {
     622           0 :     hwpf.Read2b(&type, 1);
     623           0 :     hwpf.Read2b(&number, 1);
     624           0 :     hwpf.Read2b(&dummy, 1);
     625             : 
     626           0 :     if (!(hh == dummy)){
     627           0 :         return hwpf.SetState(HWP_InvalidFileFormat);
     628             :      }
     629           0 :     return !hwpf.State();
     630             : }
     631             : 
     632             : 
     633             : // new number(19)
     634           0 : NewNum::NewNum()
     635             :     : HBox(CH_NEW_NUM)
     636             :     , type(0)
     637             :     , number(0)
     638           0 :     , dummy(0)
     639             : {
     640           0 : }
     641             : 
     642             : 
     643           0 : bool NewNum::Read(HWPFile & hwpf)
     644             : {
     645           0 :     hwpf.Read2b(&type, 1);
     646           0 :     hwpf.Read2b(&number, 1);
     647           0 :     hwpf.Read2b(&dummy, 1);
     648             : 
     649           0 :     if (!(hh == dummy)){
     650           0 :         return hwpf.SetState(HWP_InvalidFileFormat);
     651             :      }
     652           0 :     return !hwpf.State();
     653             : }
     654             : 
     655             : // show page number (20)
     656           0 : ShowPageNum::ShowPageNum()
     657             :     : HBox(CH_SHOW_PAGE_NUM)
     658             :     , where(0)
     659             :     , m_nPageNumber(0)
     660             :     , shape(0)
     661           0 :     , dummy(0)
     662             : {
     663           0 : }
     664             : 
     665           0 : bool ShowPageNum::Read(HWPFile & hwpf)
     666             : {
     667           0 :     hwpf.Read2b(&where, 1);
     668           0 :     hwpf.Read2b(&shape, 1);
     669           0 :     hwpf.Read2b(&dummy, 1);
     670             : 
     671           0 :     if (!(hh == dummy)){
     672           0 :         return hwpf.SetState(HWP_InvalidFileFormat);
     673             :      }
     674           0 :      m_nPageNumber = hwpf.getCurrentPage();
     675           0 :      hwpf.setMaxSettedPage();
     676           0 :     hwpf.AddPageNumber(this);
     677           0 :     return !hwpf.State();
     678             : }
     679             : 
     680             : /* Ȧ¼öÂʽÃÀÛ/°¨Ãß±â (21) */
     681           0 : PageNumCtrl::PageNumCtrl()
     682             :     : HBox(CH_PAGE_NUM_CTRL)
     683             :     , kind(0)
     684             :     , what(0)
     685           0 :     , dummy(0)
     686             : {
     687           0 : }
     688             : 
     689           0 : bool PageNumCtrl::Read(HWPFile & hwpf)
     690             : {
     691           0 :     hwpf.Read2b(&kind, 1);
     692           0 :     hwpf.Read2b(&what, 1);
     693           0 :     hwpf.Read2b(&dummy, 1);
     694             : 
     695           0 :     if (!(hh == dummy)){
     696           0 :         return hwpf.SetState(HWP_InvalidFileFormat);
     697             :      }
     698           0 :     return !hwpf.State();
     699             : }
     700             : 
     701             : 
     702             : // mail merge(22)
     703           0 : MailMerge::MailMerge():HBox(CH_MAIL_MERGE)
     704             : {
     705           0 : }
     706             : 
     707             : 
     708           0 : bool MailMerge::Read(HWPFile & hwpf)
     709             : {
     710           0 :     hwpf.Read1b(field_name, 20);
     711           0 :     hwpf.Read2b(&dummy, 1);
     712             : 
     713           0 :     if (!(hh == dummy)){
     714           0 :         return hwpf.SetState(HWP_InvalidFileFormat);
     715             :      }
     716           0 :     return !hwpf.State();
     717             : }
     718             : 
     719             : // char compositon(23)
     720           0 : Compose::Compose()
     721             :     : HBox(CH_COMPOSE)
     722           0 :     , dummy(0)
     723             : {
     724           0 : }
     725             : 
     726           0 : bool Compose::Read(HWPFile & hwpf)
     727             : {
     728           0 :     hwpf.Read2b(compose, 3);
     729           0 :     hwpf.Read2b(&dummy, 1);
     730             : 
     731           0 :     if (!(hh == dummy)){
     732           0 :         return hwpf.SetState(HWP_InvalidFileFormat);
     733             :      }
     734           0 :     return !hwpf.State();
     735             : }
     736             : 
     737             : // hyphen(24)
     738           0 : Hyphen::Hyphen()
     739             :     : HBox(CH_HYPHEN)
     740             :     , width(0)
     741           0 :     , dummy(0)
     742             : {
     743           0 : }
     744             : 
     745           0 : bool Hyphen::Read(HWPFile & hwpf)
     746             : {
     747           0 :     hwpf.Read2b(&width, 1);
     748           0 :     hwpf.Read2b(&dummy, 1);
     749             : 
     750           0 :     if (!(hh == dummy)){
     751           0 :         return hwpf.SetState(HWP_InvalidFileFormat);
     752             :      }
     753           0 :     return !hwpf.State();
     754             : }
     755             : 
     756             : 
     757             : // toc mark(25)
     758           0 : TocMark::TocMark()
     759             :     : HBox(CH_TOC_MARK)
     760             :     , kind(0)
     761           0 :     , dummy(0)
     762             : {
     763           0 : }
     764             : 
     765             : 
     766           0 : bool TocMark::Read(HWPFile & hwpf)
     767             : {
     768           0 :     hwpf.Read2b(&kind, 1);
     769           0 :     hwpf.Read2b(&dummy, 1);
     770             : 
     771           0 :     if (!(hh == dummy)){
     772           0 :         return hwpf.SetState(HWP_InvalidFileFormat);
     773             :      }
     774           0 :     return !hwpf.State();
     775             : }
     776             : 
     777             : 
     778             : // index mark(26)
     779           0 : IndexMark::IndexMark()
     780             :     : HBox(CH_INDEX_MARK)
     781           0 :     , dummy(0)
     782             : {
     783           0 : }
     784             : 
     785             : 
     786           0 : bool IndexMark::Read(HWPFile & hwpf)
     787             : {
     788           0 :     hwpf.Read2b(&keyword1, 60);
     789           0 :     hwpf.Read2b(&keyword2, 60);
     790           0 :     hwpf.Read2b(&pgno, 1);
     791           0 :     hwpf.Read2b(&dummy, 1);
     792             : 
     793           0 :     if (!(hh == dummy)){
     794           0 :         return hwpf.SetState(HWP_InvalidFileFormat);
     795             :      }
     796           0 :     return !hwpf.State();
     797             : }
     798             : 
     799             : // outline(28)
     800           0 : Outline::Outline()
     801             :     : HBox(CH_OUTLINE)
     802             :     , kind(0)
     803             :     , shape(0)
     804             :     , level(0)
     805           0 :     , dummy(0)
     806             : {
     807           0 : }
     808             : 
     809           0 : bool Outline::Read(HWPFile & hwpf)
     810             : {
     811           0 :     hwpf.Read2b(&kind, 1);
     812           0 :     hwpf.Read1b(&shape, 1);
     813           0 :     hwpf.Read1b(&level, 1);
     814           0 :     hwpf.Read2b(number, 7);
     815           0 :     hwpf.Read2b(user_shape, 7);
     816           0 :     hwpf.Read2b(deco, 14);
     817           0 :     hwpf.Read2b(&dummy, 1);
     818             : 
     819           0 :     if (!(hh == dummy)){
     820           0 :         return hwpf.SetState(HWP_InvalidFileFormat);
     821             :      }
     822           0 :     return !hwpf.State();
     823             : }
     824             : 
     825             : 
     826             : /* ¹­À½ ºóÄ­(30) */
     827           0 : KeepSpace::KeepSpace()
     828             :     : HBox(CH_KEEP_SPACE)
     829           0 :     , dummy(0)
     830             : {
     831           0 : }
     832             : 
     833             : 
     834           0 : bool KeepSpace::Read(HWPFile & hwpf)
     835             : {
     836           0 :     hwpf.Read2b(&dummy, 1);
     837             : 
     838           0 :     if (!(hh == dummy)){
     839           0 :         return hwpf.SetState(HWP_InvalidFileFormat);
     840             :      }
     841           0 :     return !hwpf.State();
     842             : }
     843             : 
     844             : 
     845             : /* °íÁ¤Æø ºóÄ­(31) */
     846           0 : FixedSpace::FixedSpace()
     847             :     : HBox(CH_FIXED_SPACE)
     848           0 :     , dummy(0)
     849             : {
     850           0 : }
     851             : 
     852             : 
     853           0 : bool FixedSpace::Read(HWPFile & hwpf)
     854             : {
     855           0 :     hwpf.Read2b(&dummy, 1);
     856             : 
     857           0 :     if (!(hh == dummy)){
     858           0 :         return hwpf.SetState(HWP_InvalidFileFormat);
     859             :      }
     860           0 :     return !hwpf.State();
     861             : }
     862             : 
     863             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10