LCOV - code coverage report
Current view: top level - hwpfilter/source - hwpfile.h (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 20 22 90.9 %
Date: 2014-11-03 Functions: 16 18 88.9 %
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             : 
      21             : // hwpfile.h
      22             : // (C) 1998 Mizi Research, All rights are reserved
      23             : 
      24             : 
      25             : #ifndef INCLUDED_HWPFILTER_SOURCE_HWPFILE_H
      26             : #define INCLUDED_HWPFILTER_SOURCE_HWPFILE_H
      27             : 
      28             : #include <list>
      29             : #include <stdio.h>
      30             : #include <string.h>
      31             : #include <fcntl.h>
      32             : 
      33             : #include "hwplib.h"
      34             : #include "hfont.h"
      35             : #include "hstyle.h"
      36             : #include "hpara.h"
      37             : 
      38             : #define HWPIDLen    30
      39             : #define V20SIGNATURE    "HWP Document File V2.00 \032\1\2\3\4\5"
      40             : #define V21SIGNATURE    "HWP Document File V2.10 \032\1\2\3\4\5"
      41             : #define V30SIGNATURE    "HWP Document File V3.00 \032\1\2\3\4\5"
      42             : 
      43             : #define HWP_V20 20
      44             : #define HWP_V21 21
      45             : #define HWP_V30 30
      46             : 
      47             : int detect_hwp_version(const char *str);
      48             : 
      49             : struct  FBox;
      50             : struct  EmPicture;
      51             : struct  HyperText;
      52             : struct  FBoxStyle;
      53             : struct  CellLine;
      54             : struct  Cell;
      55             : struct  OlePicture;
      56             : struct  Picture;
      57             : struct  HeaderFooter;
      58             : struct  ShowPageNum;
      59             : struct  DateCode;
      60             : struct  Table;
      61             : 
      62             : class   HIODev;
      63             : class   HWPInfo;
      64             : class   HWPFont;
      65             : class   HWPStyle;
      66             : class   HWPPara;
      67             : class   HStream;
      68             : 
      69             : struct ColumnInfo{
      70             :     int start_page;
      71             :     bool bIsSet;
      72             :     ColumnDef *coldef;
      73           2 :     ColumnInfo(int num){
      74           2 :         start_page = num;
      75           2 :         bIsSet = false;
      76           2 :         coldef = 0;
      77           2 :     }
      78             : };
      79             : 
      80             : /**
      81             :  * The HWPFile class is the main class of hwp for reading file
      82             :  * information from stream
      83             :  *
      84             :  * The example is as below:
      85             :  * <pre>
      86             :  * HWPFile f;
      87             :  * f.ReadHwpFile( stream );
      88             :  * </pre>
      89             :  *
      90             :  * There are two way to read hwp information from stream, one is to read all at a time
      91             :  * to use @ref ReadhwpFile() method like above example, other is to read partial information
      92             :  * to use @ref Open(), @ref InfoRead(), @ref FontRead(), @ref StyleRead(), @ref ParaListRead(), @ref TagsRead(),
      93             :  *
      94             :  * @short HWP file management object
      95             :  * @author Mizi Reserach
      96             :  */
      97             : class DLLEXPORT HWPFile
      98             : {
      99             :     public:
     100             : /**
     101             :  * Default constructor
     102             :  */
     103             :         HWPFile();
     104             :         ~HWPFile();
     105             : 
     106             :     public:
     107             : 
     108             : /**
     109             :  * Opens HStream to use it.
     110             :  * @returns 0 if success, otherwise error code
     111             :  * @see State()
     112             :  */
     113             :         int Open( HStream * );
     114             : 
     115             : /**
     116             :  * Say current state
     117             :  * @returns 0 if normal, otherwise error code. If it's  bigger than USER_ERROR_BIT, it is internally using error, otherwise it's system error which is able to get the message @ref strerror() method.
     118             :  */
     119         176 :         int State( void ) const { return error_code;}
     120             : /**
     121             :  * Sets the current state
     122             :  */
     123             :         int SetState(int errcode);
     124             : /**
     125             :  * Reads one byte from HIODev
     126             :  */
     127             :         int Read1b( void );
     128             : /**
     129             :  * Reads two byte from HIODev
     130             :  */
     131             :         int Read2b( void );
     132             : /**
     133             :  * Reads four byte from HIODev
     134             :  */
     135             :         long Read4b( void );
     136             : /**
     137             :  * Reads nmemb byte array from HIODev
     138             :  */
     139             :         int Read1b( void *ptr, size_t nmemb );
     140             : /**
     141             :  * Reads nmemb short type array from HIODev
     142             :  */
     143             :         int Read2b( void *ptr, size_t nmemb );
     144             : /**
     145             :  * Reads nmemb long type array from HIODev
     146             :  */
     147             :         int Read4b( void *ptr, size_t nmemb );
     148             : /**
     149             :  * Reads some bytes from HIODev not regarding endian's way
     150             :  * @param size Amount for reading
     151             :  */
     152             :         size_t ReadBlock( void *ptr, size_t size );
     153             : /**
     154             :  * Skips some bytes from HIODev
     155             :  */
     156             :         size_t SkipBlock( size_t size );
     157             : /**
     158             :  * Reads main paragraph list
     159             :  */
     160             :         bool ReadParaList(std::list<HWPPara*> &aplist, unsigned char flag = 0);
     161             : /**
     162             :  * Sets if the stream is compressed
     163             :  */
     164             :         bool SetCompressed( bool );
     165             : /**
     166             :  * Sets current HIODev
     167             :  */
     168             :         HIODev *SetIODevice( HIODev *hiodev );
     169             : 
     170             : /**
     171             :  * Reads all information of hwp file from stream
     172             :  */
     173             :         int ReadHwpFile( HStream *);
     174             : /**
     175             :  * Reads document information of hwp file from HIODev
     176             :  */
     177             :         bool InfoRead(void);
     178             : /**
     179             :  * Reads font list of hwp file from HIODev
     180             :  */
     181             :         bool FontRead(void);
     182             : /**
     183             :  * Reads style list of hwp file from HIODev
     184             :  */
     185             :         bool StyleRead(void);
     186             : /**
     187             :  * Reads paragraph list of hwp file from HIODev
     188             :  */
     189             :         bool ParaListRead();
     190             : /* 그림 등의 추가 정보를 읽는다. */
     191             : /**
     192             :  * Reads additional information like embedded image of hwp file from HIODev
     193             :  */
     194             :         bool TagsRead(void);
     195             : 
     196             :         enum Paper
     197             :         {
     198             :             UserPaper = 0,
     199             :             Col80Paper = 1,
     200             :             Col132Paper = 2,
     201             :             A4Paper = 3,
     202             :             LetterPaper = 4,
     203             :             B5Paper = 5,
     204             :             B4Paper = 6,
     205             :             LegalPaper = 7,
     206             :             A3Paper = 8
     207             :         };
     208             : 
     209             :         void AddBox(FBox *);
     210           0 :         void AddPage(){ m_nCurrentPage++;}
     211             :         void AddColumnInfo();
     212             :         void SetColumnDef(ColumnDef *coldef);
     213             :         void AddParaShape(ParaShape *);
     214             :         void AddCharShape(CharShape *);
     215             :         void AddFBoxStyle(FBoxStyle *);
     216             :         void AddDateFormat(DateCode *);
     217             :         void AddHeaderFooter(HeaderFooter *);
     218             :         void AddPageNumber(ShowPageNum *);
     219             :         void AddTable(Table *);
     220             : 
     221             :         ColumnDef* GetColumnDef(int);
     222             :           int GetPageMasterNum(int page);
     223             : 
     224           0 :           int getCurrentPage(){ return m_nCurrentPage;}
     225           6 :         HWPInfo& GetHWPInfo(void) { return _hwpInfo; }
     226          28 :         HWPFont& GetHWPFont(void) { return _hwpFont; }
     227           2 :         HWPStyle& GetHWPStyle(void) { return _hwpStyle; }
     228           2 :         HWPPara *GetFirstPara(void) { return plist.front(); }
     229             :         HWPPara *GetLastPara(void) { return plist.back(); }
     230             : 
     231             :         EmPicture *GetEmPicture(Picture *pic);
     232             :         EmPicture *GetEmPictureByName(char * name);
     233             :         HyperText *GetHyperText();
     234             :         FBox *GetBoxHead (void) { return blist.size()?blist.front():0; }
     235             :         ParaShape *getParaShape(int);
     236             :         CharShape *getCharShape(int);
     237             :         FBoxStyle *getFBoxStyle(int);
     238             :         DateCode *getDateCode(int);
     239             :           HeaderFooter *getHeaderFooter(int);
     240             :         ShowPageNum *getPageNumber(int);
     241             :           Table *getTable(int);
     242             : 
     243           4 :         int getParaShapeCount(){ return pslist.size(); }
     244           4 :         int getCharShapeCount(){ return cslist.size(); }
     245           4 :         int getFBoxStyleCount(){ return fbslist.size(); }
     246           2 :         int getDateFormatCount(){ return datecodes.size(); }
     247           2 :         int getHeaderFooterCount(){ return headerfooters.size(); }
     248           4 :         int getPageNumberCount(){ return pagenumbers.size(); }
     249           2 :         int getTableCount(){ return tables.size(); }
     250           2 :         int getColumnCount(){ return columnlist.size(); }
     251             : 
     252           2 :           int getMaxSettedPage(){ return m_nMaxSettedPage; }
     253           2 :           void setMaxSettedPage(){ m_nMaxSettedPage = m_nCurrentPage; }
     254             : 
     255             :     private :
     256             :         int compareCharShape(CharShape *shape);
     257             :         int compareParaShape(ParaShape *shape);
     258             : 
     259             :     public:
     260             :         int   version;
     261             :         bool  compressed;
     262             :         bool  encrypted;
     263             :         unsigned char linenumber;
     264             :         int   info_block_len;
     265             :         int   error_code;
     266             :         OlePicture *oledata;
     267             : 
     268             :     private:
     269             : /* hwp 파일 이름 */
     270             :           int           m_nCurrentPage;
     271             :           int m_nMaxSettedPage;
     272             :         HIODev    *hiodev;
     273             : // read hwp contents
     274             :         HWPInfo   _hwpInfo;
     275             :         HWPFont   _hwpFont;
     276             :         HWPStyle  _hwpStyle;
     277             :         std::list<ColumnInfo*> columnlist;
     278             :           // paragraph linked list
     279             :         std::list<HWPPara*> plist;
     280             :           // floating box linked list
     281             :         std::list<FBox*> blist;
     282             :           // embedded picture list(tag datas)
     283             :         std::list<EmPicture*> emblist;
     284             :         std::list<HyperText*> hyperlist;
     285             :         int currenthyper;
     286             :         std::list<ParaShape*> pslist;             /* 스타오피스의 구조상 필요 */
     287             :         std::list<CharShape*> cslist;
     288             :         std::list<FBoxStyle*> fbslist;
     289             :         std::list<DateCode*> datecodes;
     290             :         std::list<HeaderFooter*> headerfooters;
     291             :         std::list<ShowPageNum*> pagenumbers;
     292             :         std::list<Table*> tables;
     293             : 
     294             : // for global document handling
     295             :         static HWPFile *cur_doc;
     296             :         friend HWPFile *GetCurrentDoc(void);
     297             :         friend HWPFile *SetCurrentDoc(HWPFile *);
     298             : };
     299             : 
     300             : HWPFile *GetCurrentDoc(void);
     301             : HWPFile *SetCurrentDoc(HWPFile *hwpfp);
     302             : #endif // INCLUDED_HWPFILTER_SOURCE_HWPFILE_H
     303             : 
     304             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10