LCOV - code coverage report
Current view: top level - libreoffice/hwpfilter/source - hwpfile.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 183 333 55.0 %
Date: 2012-12-27 Functions: 31 49 63.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 <stdio.h>
      23             : #include <stdlib.h>
      24             : #include <string.h>
      25             : #include <errno.h>
      26             : #include "hwplib.h"
      27             : #include "hwpfile.h"
      28             : #include "hiodev.h"
      29             : #include "hfont.h"
      30             : #include "hstyle.h"
      31             : #include "hbox.h"
      32             : #include "hpara.h"
      33             : #include "htags.h"
      34             : #include "hcode.h"
      35             : #include "hstream.h"
      36             : 
      37             : #include <osl/diagnose.h>
      38             : 
      39             : #define HWPHeadLen  128
      40             : #define HWPSummaryLen   1008
      41             : 
      42             : #define FILESTG_SIGNATURE       0xF8995567
      43             : #define FILESTG_SIGNATURE_NORMAL    0xF8995568
      44             : 
      45             : HWPFile *HWPFile::cur_doc = 0;
      46             : static int ccount = 0;
      47             : static int pcount = 0;
      48             : static int datecodecount = 0;
      49             : 
      50           1 : HWPFile::HWPFile()
      51             :     : version(HWP_V30)
      52             :     , compressed(false)
      53             :     , encrypted(false)
      54             :     , linenumber(0)
      55             :     , info_block_len(0)
      56             :     , error_code(HWP_NoError)
      57             :     , oledata(0)
      58             :     , m_nCurrentPage(1)
      59             :     , m_nMaxSettedPage(0)
      60             :     , hiodev(0)
      61           1 :     , currenthyper(0)
      62             : {
      63           1 :     SetCurrentDoc(this);
      64           1 : }
      65             : 
      66           2 : HWPFile::~HWPFile()
      67             : {
      68           1 :     delete oledata;
      69           1 :     delete hiodev;
      70             : 
      71           1 :     std::list < ColumnInfo* >::iterator it_column = columnlist.begin();
      72           2 :     for (; it_column != columnlist.end(); ++it_column)
      73           1 :         delete *it_column;
      74             : 
      75           1 :     std::list < HWPPara* >::iterator it = plist.begin();
      76           3 :     for (; it != plist.end(); ++it)
      77           2 :         delete *it;
      78             : 
      79           1 :     std::list < Table* >::iterator tbl = tables.begin();
      80           1 :     for (; tbl != tables.end(); ++tbl)
      81           0 :         delete *tbl;
      82             : 
      83           1 :     std::list < HyperText* >::iterator hyp = hyperlist.begin();
      84           1 :     for (; hyp != hyperlist.end(); ++hyp)
      85             :     {
      86           0 :         delete *hyp;
      87             :     }
      88           1 : }
      89             : 
      90           2 : int HWPFile::ReadHwpFile(HStream & stream)
      91             : {
      92           2 :     if (Open(stream) != HWP_NoError)
      93           1 :         return State();
      94           1 :     InfoRead();
      95           1 :     FontRead();
      96           1 :     StyleRead();
      97           1 :     AddColumnInfo();
      98           1 :     ParaListRead();
      99           1 :     TagsRead();
     100             : 
     101           1 :     return State();
     102             : }
     103             : 
     104           2 : int detect_hwp_version(const char *str)
     105             : {
     106           2 :     if (memcmp(V20SIGNATURE, str, HWPIDLen) == 0)
     107           0 :         return HWP_V20;
     108           2 :     else if (memcmp(V21SIGNATURE, str, HWPIDLen) == 0)
     109           0 :         return HWP_V21;
     110           2 :     else if (memcmp(V30SIGNATURE, str, HWPIDLen) == 0)
     111           1 :         return HWP_V30;
     112           1 :     return 0;
     113             : }
     114             : 
     115             : // HIODev wrapper
     116             : 
     117           2 : int HWPFile::Open(HStream & stream)
     118             : {
     119           2 :     HStreamIODev *hstreamio = new HStreamIODev(stream);
     120             : 
     121           2 :     if (!hstreamio->open())
     122             :     {
     123           0 :         delete hstreamio;
     124             : 
     125           0 :         return SetState(HWP_EMPTY_FILE);
     126             :     }
     127             : 
     128           2 :     HIODev *pPrev = SetIODevice(hstreamio);
     129           2 :     delete pPrev;
     130             : 
     131             :     char idstr[HWPIDLen];
     132             : 
     133           4 :     if (ReadBlock(idstr, HWPIDLen) <= 0
     134           2 :         || HWP_V30 != (version = detect_hwp_version(idstr)))
     135             :     {
     136           1 :         return SetState(HWP_UNSUPPORTED_VERSION);
     137             :     }
     138           1 :     return HWP_NoError;
     139             : }
     140             : 
     141             : 
     142          88 : int HWPFile::State(void) const
     143             : {
     144          88 :     return error_code;
     145             : }
     146             : 
     147             : 
     148           1 : int HWPFile::SetState(int errcode)
     149             : {
     150           1 :     error_code = errcode;
     151           1 :     return error_code;
     152             : }
     153             : 
     154             : 
     155           0 : int HWPFile::Read1b(void)
     156             : {
     157           0 :     return hiodev ? hiodev->read1b() : -1;
     158             : }
     159             : 
     160             : 
     161         768 : int HWPFile::Read2b(void)
     162             : {
     163         768 :     return hiodev ? hiodev->read2b() : -1;
     164             : }
     165             : 
     166             : 
     167           2 : long HWPFile::Read4b(void)
     168             : {
     169           2 :     return hiodev ? hiodev->read4b() : -1;
     170             : }
     171             : 
     172             : 
     173        1411 : int HWPFile::Read1b(void *ptr, size_t nmemb)
     174             : {
     175        1411 :     return hiodev ? hiodev->read1b(ptr, nmemb) : 0;
     176             : }
     177             : 
     178             : 
     179          32 : int HWPFile::Read2b(void *ptr, size_t nmemb)
     180             : {
     181          32 :     return hiodev ? hiodev->read2b(ptr, nmemb) : 0;
     182             : }
     183             : 
     184             : 
     185           3 : int HWPFile::Read4b(void *ptr, size_t nmemb)
     186             : {
     187           3 :     return hiodev ? hiodev->read4b(ptr, nmemb) : 0;
     188             : }
     189             : 
     190             : 
     191         717 : size_t HWPFile::ReadBlock(void *ptr, size_t size)
     192             : {
     193         717 :     return hiodev ? hiodev->readBlock(ptr, size) : 0;
     194             : }
     195             : 
     196             : 
     197           0 : size_t HWPFile::SkipBlock(size_t size)
     198             : {
     199           0 :     return hiodev ? hiodev->skipBlock(size) : 0;
     200             : }
     201             : 
     202             : 
     203           1 : bool HWPFile::SetCompressed(bool flag)
     204             : {
     205           1 :     return hiodev ? hiodev->setCompressed(flag) : false;
     206             : }
     207             : 
     208             : 
     209           2 : HIODev *HWPFile::SetIODevice(HIODev * new_hiodev)
     210             : {
     211           2 :     HIODev *old_hiodev = hiodev;
     212             : 
     213           2 :     hiodev = new_hiodev;
     214             : 
     215           2 :     return old_hiodev;
     216             : }
     217             : 
     218             : 
     219             : // end of HIODev wrapper
     220             : 
     221           1 : bool HWPFile::InfoRead(void)
     222             : {
     223           1 :     return _hwpInfo.Read(*this);
     224             : }
     225             : 
     226             : 
     227           1 : bool HWPFile::FontRead(void)
     228             : {
     229           1 :     return _hwpFont.Read(*this);
     230             : }
     231             : 
     232             : 
     233           1 : bool HWPFile::StyleRead(void)
     234             : {
     235           1 :     return _hwpStyle.Read(*this);
     236             : }
     237             : 
     238             : 
     239           1 : bool HWPFile::ParaListRead(void)
     240             : {
     241           1 :     return ReadParaList(plist);
     242             : }
     243             : 
     244           1 : bool HWPFile::ReadParaList(std::list < HWPPara* > &aplist, unsigned char flag)
     245             : {
     246           1 :     HWPPara *spNode = new HWPPara;
     247             :      unsigned char tmp_etcflag;
     248           1 :      unsigned char prev_etcflag = 0;
     249           4 :     while (spNode->Read(*this, flag))
     250             :     {
     251           2 :          if( !(spNode->etcflag & 0x04) ){
     252           2 :           tmp_etcflag = spNode->etcflag;
     253           2 :           spNode->etcflag = prev_etcflag;
     254           2 :           prev_etcflag = tmp_etcflag;
     255             :          }
     256           2 :         if (spNode->nch && spNode->reuse_shape)
     257             :         {
     258           0 :             if (!aplist.empty()){
     259           0 :                      spNode->pshape = aplist.back()->pshape;
     260             :                 }
     261             :                 else{
     262           0 :                      spNode->nch = 0;
     263           0 :                      spNode->reuse_shape = 0;
     264             :                 }
     265             :         }
     266           2 :           spNode->pshape.pagebreak = spNode->etcflag;
     267           2 :           if( spNode->nch )
     268           2 :                 AddParaShape( &spNode->pshape );
     269             : 
     270           2 :         if (!aplist.empty())
     271           1 :             aplist.back()->SetNext(spNode);
     272           2 :         aplist.push_back(spNode);
     273           2 :         spNode = new HWPPara;
     274             :     }
     275           1 :     delete spNode;
     276             : 
     277           1 :     return true;
     278             : }
     279             : 
     280             : 
     281           1 : bool HWPFile::TagsRead(void)
     282             : {
     283             :     ulong tag;
     284             :     long size;
     285             : 
     286           0 :     while (1)
     287             :     {
     288           1 :         tag = Read4b();
     289           1 :         size = Read4b();
     290           1 :         if (size <= 0 && tag > 0){
     291           0 :             continue;
     292             :           }
     293             : 
     294           1 :         if (tag == FILETAG_END_OF_COMPRESSED ||
     295             :             tag == FILETAG_END_OF_UNCOMPRESSED)
     296           2 :             return true;
     297           0 :         switch (tag)
     298             :         {
     299             :             case FILETAG_EMBEDDED_PICTURE:
     300             :             {
     301           0 :                 EmPicture *emb = new EmPicture(size);
     302             : 
     303           0 :                 if (true == emb->Read(*this))
     304           0 :                     emblist.push_back(emb);
     305             :                 else
     306           0 :                     delete emb;
     307             :             }
     308           0 :             break;
     309             :             case FILETAG_OLE_OBJECT:
     310           0 :                 if (oledata)
     311           0 :                     delete oledata;
     312           0 :                 oledata = new OlePicture(size);
     313           0 :                 oledata->Read(*this);
     314           0 :                 break;
     315             :             case FILETAG_HYPERTEXT:
     316             :             {
     317           0 :                 if( (size % 617) != 0 )
     318           0 :                     SkipBlock( size );
     319             :                 else
     320           0 :                     for( int i = 0 ; i < size/617 ; i++)
     321             :                 {
     322           0 :                     HyperText *hypert = new HyperText;
     323           0 :                     hypert->Read(*this);
     324           0 :                     hyperlist.push_back(hypert);
     325             :                 }
     326           0 :                 break;
     327             :             }
     328             :                 case 6:
     329             :                 {
     330           0 :                      ReadBlock(_hwpInfo.back_info.reserved1, 8);
     331           0 :                      _hwpInfo.back_info.luminance = Read4b();
     332           0 :                      _hwpInfo.back_info.contrast = Read4b();
     333           0 :                      _hwpInfo.back_info.effect = sal::static_int_cast<char>(Read1b());
     334           0 :                      ReadBlock(_hwpInfo.back_info.reserved2, 7);
     335           0 :                      ReadBlock(_hwpInfo.back_info.filename, 260);
     336           0 :                      ReadBlock(_hwpInfo.back_info.color, 3);
     337           0 :                      unsigned short nFlag = sal::static_int_cast<unsigned short>(Read2b());
     338           0 :                      _hwpInfo.back_info.flag = nFlag >> 8 ;
     339           0 :                      int nRange = Read4b();
     340           0 :                      _hwpInfo.back_info.range = nRange >> 24;
     341           0 :                      ReadBlock(_hwpInfo.back_info.reserved3, 27);
     342           0 :                      _hwpInfo.back_info.size = Read4b();
     343             : 
     344           0 :                      _hwpInfo.back_info.data = new char[(unsigned int)_hwpInfo.back_info.size];
     345           0 :                      ReadBlock(_hwpInfo.back_info.data, _hwpInfo.back_info.size);
     346             : 
     347           0 :                      if( _hwpInfo.back_info.size > 0 )
     348           0 :                           _hwpInfo.back_info.type = 2;
     349           0 :                      else if( _hwpInfo.back_info.filename[0] )
     350           0 :                           _hwpInfo.back_info.type = 1;
     351             :                      else
     352           0 :                           _hwpInfo.back_info.type = 0;
     353             : 
     354             : 
     355           0 :                      _hwpInfo.back_info.isset = true;
     356             : 
     357           0 :                      break;
     358             :                 }
     359             :             case FILETAG_PRESENTATION:
     360             :             case FILETAG_PREVIEW_IMAGE:
     361             :             case FILETAG_PREVIEW_TEXT:
     362             :             default:
     363           0 :                 SkipBlock(size);
     364             :         }
     365             :     }
     366             : }
     367             : 
     368             : 
     369           1 : ColumnDef *HWPFile::GetColumnDef(int num)
     370             : {
     371           1 :     std::list<ColumnInfo*>::iterator it = columnlist.begin();
     372             : 
     373           1 :     for(int i = 0; it != columnlist.end() ; ++it, i++){
     374           1 :         if( i == num )
     375           1 :           break;
     376             :     }
     377             : 
     378           1 :     if( it != columnlist.end() )
     379           1 :         return (*it)->coldef;
     380             :     else
     381           0 :         return 0;
     382             : }
     383             : /* @return À妽º´Â 1ºÎÅÍ ½ÃÀÛÇÑ´Ù. */
     384           1 : int HWPFile::GetPageMasterNum(int page)
     385             : {
     386           1 :     std::list<ColumnInfo*>::iterator it = columnlist.begin();
     387           1 :     ColumnInfo *now = 0;
     388             :     int i;
     389             : 
     390           2 :     for( i = 1 ; it != columnlist.end() ; ++it, i++){
     391           1 :         now = *it;
     392           1 :         if( page < now->start_page )
     393           0 :             return i-1;
     394             :     }
     395           1 :     return i-1;
     396             : }
     397             : 
     398           0 : HyperText *HWPFile::GetHyperText()
     399             : {
     400           0 :     std::list<HyperText*>::iterator it = hyperlist.begin();
     401             : 
     402           0 :     for( int i = 0; it != hyperlist.end(); ++it, i++ ){
     403           0 :         if( i == currenthyper )
     404           0 :           break;
     405             :     }
     406             : 
     407           0 :     currenthyper++;
     408           0 :     return *it;
     409             : }
     410             : 
     411           0 : EmPicture *HWPFile::GetEmPicture(Picture * pic)
     412             : {
     413           0 :     char *name = pic->picinfo.picembed.embname;
     414             : 
     415           0 :     name[0] = 'H';
     416           0 :     name[1] = 'W';
     417           0 :     name[2] = 'P';
     418             : 
     419           0 :     std::list < EmPicture* >::iterator it = emblist.begin();
     420           0 :     for (; it != emblist.end(); ++it)
     421           0 :         if (strcmp(name, (*it)->name) == 0)
     422           0 :             return *it;
     423           0 :     return 0;
     424             : }
     425             : 
     426           0 : EmPicture *HWPFile::GetEmPictureByName(char * name)
     427             : {
     428           0 :     name[0] = 'H';
     429           0 :     name[1] = 'W';
     430           0 :     name[2] = 'P';
     431             : 
     432           0 :     std::list < EmPicture* >::iterator it = emblist.begin();
     433           0 :     for (; it != emblist.end(); ++it)
     434           0 :         if (strcmp(name, (*it)->name) == 0)
     435           0 :             return *it;
     436           0 :     return 0;
     437             : }
     438             : 
     439             : 
     440           0 : void HWPFile::AddBox(FBox * box)
     441             : {
     442             : // LATER if we don't use box->next(),
     443             : // AddBox() and GetBoxHead() are useless;
     444           0 :     if (!blist.empty())
     445             :     {
     446           0 :         box->prev = blist.back();
     447           0 :         box->prev->next = box;
     448             :     }
     449             :     else
     450           0 :         box->prev = 0;
     451           0 :     blist.push_back(box);
     452           0 : }
     453             : 
     454             : 
     455           2 : ParaShape *HWPFile::getParaShape(int index)
     456             : {
     457           2 :     std::list<ParaShape*>::iterator it = pslist.begin();
     458             : 
     459           2 :     for( int i = 0; it != pslist.end(); ++it, i++ ){
     460           2 :         if( i == index )
     461           2 :           break;
     462             :     }
     463             : 
     464           2 :     return *it;
     465             : }
     466             : 
     467             : 
     468           4 : CharShape *HWPFile::getCharShape(int index)
     469             : {
     470           4 :     std::list<CharShape*>::iterator it = cslist.begin();
     471             : 
     472           4 :     for( int i = 0; it != cslist.end(); ++it, i++ ){
     473           4 :         if( i == index )
     474           4 :           break;
     475             :     }
     476             : 
     477           4 :     return *it;
     478             : }
     479             : 
     480             : 
     481           0 : FBoxStyle *HWPFile::getFBoxStyle(int index)
     482             : {
     483           0 :     std::list<FBoxStyle*>::iterator it = fbslist.begin();
     484             : 
     485           0 :     for( int i = 0; it != fbslist.end(); ++it, i++ ){
     486           0 :         if( i == index )
     487           0 :           break;
     488             :     }
     489             : 
     490           0 :     return *it;
     491             : }
     492             : 
     493           0 : DateCode *HWPFile::getDateCode(int index)
     494             : {
     495           0 :     std::list<DateCode*>::iterator it = datecodes.begin();
     496             : 
     497           0 :     for( int i = 0; it != datecodes.end(); ++it, i++ ){
     498           0 :         if( i == index )
     499           0 :           break;
     500             :     }
     501             : 
     502           0 :     return *it;
     503             : }
     504             : 
     505           0 : HeaderFooter *HWPFile::getHeaderFooter(int index)
     506             : {
     507           0 :     std::list<HeaderFooter*>::iterator it = headerfooters.begin();
     508             : 
     509           0 :     for( int i = 0; it != headerfooters.end(); ++it, i++ ){
     510           0 :         if( i == index )
     511           0 :           break;
     512             :     }
     513             : 
     514           0 :     return *it;
     515             : }
     516             : 
     517           0 : ShowPageNum *HWPFile::getPageNumber(int index)
     518             : {
     519           0 :     std::list<ShowPageNum*>::iterator it = pagenumbers.begin();
     520             : 
     521           0 :     for( int i = 0; it != pagenumbers.end(); ++it, i++ ){
     522           0 :         if( i == index )
     523           0 :           break;
     524             :     }
     525             : 
     526           0 :     return *it;
     527             : 
     528             : }
     529             : 
     530           0 : Table *HWPFile::getTable(int index)
     531             : {
     532           0 :     std::list<Table*>::iterator it = tables.begin();
     533             : 
     534           0 :     for( int i = 0; it != tables.end(); ++it, i++ ){
     535           0 :         if( i == index )
     536           0 :           break;
     537             :     }
     538             : 
     539           0 :     return *it;
     540             : }
     541             : 
     542           2 : void HWPFile::AddParaShape(ParaShape * pshape)
     543             : {
     544           2 :     int nscount = 0;
     545          68 :     for(int j = 0 ; j < MAXTABS-1 ; j++)
     546             :     {
     547          68 :           if( j > 0 && pshape->tabs[j].position == 0 )
     548           2 :                 break;
     549          66 :           if( pshape->tabs[0].position == 0 ){
     550          66 :                 if( pshape->tabs[j].type || pshape->tabs[j].dot_continue ||
     551             :                      (pshape->tabs[j].position != 1000 *j) )
     552           0 :                           nscount = j;
     553             :           }
     554             :           else{
     555           0 :                 if( pshape->tabs[j].type || pshape->tabs[j].dot_continue ||
     556             :                      (pshape->tabs[j].position != 1000 * (j + 1)) )
     557           0 :                           nscount = j;
     558             :           }
     559             :     }
     560           2 :     if( nscount )
     561           0 :         pshape->tabs[MAXTABS-1].type = sal::static_int_cast<char>(nscount);
     562           2 :      int value = compareParaShape(pshape);
     563           2 :     if( value == 0 || nscount )
     564             :     {
     565           1 :         pshape->index = ++pcount;
     566           1 :         pslist.push_back(pshape);
     567             :     }
     568             :     else
     569           1 :         pshape->index = value;
     570           2 : }
     571             : 
     572             : 
     573           4 : void HWPFile::AddCharShape(CharShape * cshape)
     574             : {
     575           4 :     int value = compareCharShape(cshape);
     576           4 :     if( value == 0 )
     577             :     {
     578           1 :         cshape->index = ++ccount;
     579           1 :         cslist.push_back(cshape);
     580             :     }
     581             :     else
     582           3 :         cshape->index = value;
     583           4 : }
     584             : 
     585           1 : void HWPFile::AddColumnInfo()
     586             : {
     587           1 :     ColumnInfo *cinfo = new ColumnInfo(m_nCurrentPage);
     588           1 :     columnlist.push_back(cinfo);
     589           1 :     setMaxSettedPage();
     590           1 : }
     591             : 
     592           0 : void HWPFile::SetColumnDef(ColumnDef *coldef)
     593             : {
     594           0 :     ColumnInfo *cinfo = columnlist.back();
     595           0 :     if( cinfo->bIsSet )
     596           0 :         return;
     597           0 :     cinfo->coldef = coldef;
     598           0 :     cinfo->bIsSet = true;
     599             : }
     600             : 
     601           0 : void HWPFile::AddDateFormat(DateCode * hbox)
     602             : {
     603           0 :     hbox->key = sal::static_int_cast<char>(++datecodecount);
     604           0 :     datecodes.push_back(hbox);
     605           0 : }
     606             : 
     607           0 : void HWPFile::AddPageNumber(ShowPageNum * hbox)
     608             : {
     609           0 :     pagenumbers.push_back(hbox);
     610           0 : }
     611             : 
     612           0 : void HWPFile::AddHeaderFooter(HeaderFooter * hbox)
     613             : {
     614           0 :     headerfooters.push_back(hbox);
     615           0 : }
     616             : 
     617           0 : void HWPFile::AddTable(Table * hbox)
     618             : {
     619           0 :     tables.push_back(hbox);
     620           0 : }
     621             : 
     622           0 : void HWPFile::AddFBoxStyle(FBoxStyle * fbstyle)
     623             : {
     624           0 :     fbslist.push_back(fbstyle);
     625           0 : }
     626             : 
     627           4 : int HWPFile::compareCharShape(CharShape *shape)
     628             : {
     629           4 :     int count = cslist.size();
     630           4 :     if( count > 0 )
     631             :     {
     632           3 :         CharShape *cshape=0;
     633           3 :         for(int i = 0; i< count; i++)
     634             :         {
     635           3 :             cshape = getCharShape(i);
     636             : 
     637          18 :             if( shape->size == cshape->size &&
     638           3 :                 shape->font[0] == cshape->font[0] &&
     639           3 :                 shape->ratio[0] == cshape->ratio[0] &&
     640           3 :                 shape->space[0] == cshape->space[0] &&
     641           3 :                 shape->color[1] == cshape->color[1] &&
     642           3 :                 shape->color[0] == cshape->color[0] &&
     643             :                 shape->shade == cshape->shade &&
     644             :                 shape->attr == cshape->attr )
     645             :             {
     646           3 :                 return cshape->index;
     647             :             }
     648             :         }
     649             :     }
     650           1 :     return 0;
     651             : }
     652             : 
     653             : 
     654           2 : int HWPFile::compareParaShape(ParaShape *shape)
     655             : {
     656           2 :     int count = pslist.size();
     657           2 :     if( count > 0 )
     658             :     {
     659           1 :         ParaShape *pshape=0;
     660           1 :         for(int i = 0; i< count; i++)
     661             :         {
     662           1 :             pshape = getParaShape(i);
     663           1 :             if( shape->left_margin == pshape->left_margin &&
     664             :                 shape->right_margin == pshape->right_margin &&
     665             :                 shape->pspacing_prev == pshape->pspacing_prev &&
     666             :                 shape->pspacing_next == pshape->pspacing_next &&
     667             :                 shape->indent == pshape->indent &&
     668             :                 shape->lspacing == pshape->lspacing &&
     669             :                 shape->arrange_type == pshape->arrange_type &&
     670             :                 shape->outline == pshape->outline  &&
     671             :                      shape->pagebreak == pshape->pagebreak)
     672             :             {
     673           6 :                     if( shape->cshape->size == pshape->cshape->size &&
     674           1 :                          shape->cshape->font[0] == pshape->cshape->font[0] &&
     675           1 :                          shape->cshape->ratio[0] == pshape->cshape->ratio[0] &&
     676           1 :                          shape->cshape->space[0] == pshape->cshape->space[0] &&
     677           1 :                          shape->cshape->color[1] == pshape->cshape->color[1] &&
     678           1 :                          shape->cshape->color[0] == pshape->cshape->color[0] &&
     679             :                          shape->cshape->shade == pshape->cshape->shade &&
     680             :                          shape->cshape->attr == pshape->cshape->attr )
     681             :                     {
     682           1 :                          return pshape->index;
     683             :                     }
     684             :             }
     685             :         }
     686             :     }
     687           1 :     return 0;
     688             : }
     689             : 
     690             : 
     691           0 : HWPFile *GetCurrentDoc(void)
     692             : {
     693           0 :     return HWPFile::cur_doc;
     694             : }
     695             : 
     696             : 
     697           1 : HWPFile *SetCurrentDoc(HWPFile * hwpfp)
     698             : {
     699           1 :     HWPFile *org = HWPFile::cur_doc;
     700             : 
     701           1 :     HWPFile::cur_doc = hwpfp;
     702           1 :     return org;
     703             : }
     704             : 
     705             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10