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

Generated by: LCOV version 1.10