bump product version to 4.1.6.2
[LibreOffice.git] / hwpfilter / source / hwpfile.h
blobd6f9738f32cb6724cb4be133a311942cd108ebcb
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 // hwpfile.h
22 // (C) 1998 Mizi Research, All rights are reserved
25 #ifndef _HWPFILE_H_
26 #define _HWPFILE_H_
28 #include <list>
29 #include <stdio.h>
30 #include <string.h>
31 #include <fcntl.h>
33 #include "hwplib.h"
34 #include "hfont.h"
35 #include "hstyle.h"
36 #include "hpara.h"
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"
43 #define HWP_V20 20
44 #define HWP_V21 21
45 #define HWP_V30 30
47 int detect_hwp_version(const char *str);
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;
62 class HIODev;
63 class HWPInfo;
64 class HWPFont;
65 class HWPStyle;
66 class HWPPara;
67 class HStream;
69 struct ColumnInfo{
70 int start_page;
71 bool bIsSet;
72 ColumnDef *coldef;
73 ColumnInfo(int num){
74 start_page = num;
75 bIsSet = false;
76 coldef = 0;
80 /**
81 * The HWPFile class is the main class of hwp for reading file
82 * information from stream
84 * The example is as below:
85 * <pre>
86 * HWPFile f;
87 * f.ReadHwpFile( stream );
88 * </pre>
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(),
94 * @short HWP file management object
95 * @author Mizi Reserach
97 class DLLEXPORT HWPFile
99 public:
101 * Default constructor
103 HWPFile();
104 ~HWPFile();
106 public:
109 * Opens HStream to use it.
110 * @returns 0 if success, otherwise error code
111 * @see State()
113 int Open( HStream & );
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.
119 int State( void ) const;
121 * Sets the current state
123 int SetState(int errcode);
125 * Reads one byte from HIODev
127 int Read1b( void );
129 * Reads two byte from HIODev
131 int Read2b( void );
133 * Reads four byte from HIODev
135 long Read4b( void );
137 * Reads nmemb byte array from HIODev
139 int Read1b( void *ptr, size_t nmemb );
141 * Reads nmemb short type array from HIODev
143 int Read2b( void *ptr, size_t nmemb );
145 * Reads nmemb long type array from HIODev
147 int Read4b( void *ptr, size_t nmemb );
149 * Reads some bytes from HIODev not regarding endian's way
150 * @param size Amount for reading
152 size_t ReadBlock( void *ptr, size_t size );
154 * Skips some bytes from HIODev
156 size_t SkipBlock( size_t size );
158 * Reads main paragraph list
160 bool ReadParaList(std::list<HWPPara*> &aplist, unsigned char flag = 0);
162 * Sets if the stream is compressed
164 bool SetCompressed( bool );
166 * Sets current HIODev
168 HIODev *SetIODevice( HIODev *hiodev );
171 * Reads all information of hwp file from stream
173 int ReadHwpFile( HStream &);
175 * Reads document information of hwp file from HIODev
177 bool InfoRead(void);
179 * Reads font list of hwp file from HIODev
181 bool FontRead(void);
183 * Reads style list of hwp file from HIODev
185 bool StyleRead(void);
187 * Reads paragraph list of hwp file from HIODev
189 bool ParaListRead();
190 /* ±×¸² µîÀÇ Ãß°¡ Á¤º¸¸¦ Àд´Ù. */
192 * Reads additional information like embeded image of hwp file from HIODev
194 bool TagsRead(void);
196 enum Paper
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
209 void AddBox(FBox *);
210 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 *);
221 ColumnDef* GetColumnDef(int);
222 int GetPageMasterNum(int page);
224 int getCurrentPage(){ return m_nCurrentPage;}
225 HWPInfo *GetHWPInfo(void) { return &_hwpInfo; }
226 HWPFont *GetHWPFont(void) { return &_hwpFont; }
227 HWPStyle *GetHWPStyle(void) { return &_hwpStyle; }
228 HWPPara *GetFirstPara(void) { return plist.front(); }
229 HWPPara *GetLastPara(void) { return plist.back(); }
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);
243 int getParaShapeCount(){ return pslist.size(); }
244 int getCharShapeCount(){ return cslist.size(); }
245 int getFBoxStyleCount(){ return fbslist.size(); }
246 int getDateFormatCount(){ return datecodes.size(); }
247 int getHeaderFooterCount(){ return headerfooters.size(); }
248 int getPageNumberCount(){ return pagenumbers.size(); }
249 int getTableCount(){ return tables.size(); }
250 int getColumnCount(){ return columnlist.size(); }
252 int getMaxSettedPage(){ return m_nMaxSettedPage; }
253 void setMaxSettedPage(){ m_nMaxSettedPage = m_nCurrentPage; }
255 private :
256 int compareCharShape(CharShape *shape);
257 int compareParaShape(ParaShape *shape);
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;
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;
294 // for global document handling
295 static HWPFile *cur_doc;
296 friend HWPFile *GetCurrentDoc(void);
297 friend HWPFile *SetCurrentDoc(HWPFile *);
300 HWPFile *GetCurrentDoc(void);
301 HWPFile *SetCurrentDoc(HWPFile *hwpfp);
302 #endif /* _HWPFILE_H_ */
304 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */