merge the formfield patch from ooo-build
[ooovba.git] / hwpfilter / source / hwpfile.h
blob0c17900313b69c05d17a8b321a8322d4ae905c75
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: hwpfile.h,v $
10 * $Revision: 1.5 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
32 // hwpfile.h
33 // (C) 1998 Mizi Research, All rights are reserved
35 // $Id: hwpfile.h,v 1.5 2008-06-04 10:01:33 vg Exp $
38 #ifndef _HWPFILE_H_
39 #define _HWPFILE_H_
41 #include <stdio.h>
42 #include <string.h>
43 #include <fcntl.h>
45 #include "hwplib.h"
46 #include "hfont.h"
47 #include "hstyle.h"
48 #include "hpara.h"
49 #include "list.hxx"
51 #define HWP_V20 20
52 #define HWP_V21 21
53 #define HWP_V30 30
55 struct FBox;
56 struct EmPicture;
57 struct HyperText;
58 struct FBoxStyle;
59 struct CellLine;
60 struct Cell;
61 struct OlePicture;
62 struct Picture;
63 struct HeaderFooter;
64 struct ShowPageNum;
65 struct DateCode;
66 struct Table;
68 class HIODev;
69 class HWPInfo;
70 class HWPFont;
71 class HWPStyle;
72 class HWPPara;
73 class HStream;
75 struct ColumnInfo{
76 int start_page;
77 bool bIsSet;
78 ColumnDef *coldef;
79 ColumnInfo(int num){
80 start_page = num;
81 bIsSet = false;
82 coldef = 0;
86 /**
87 * The HWPFile class is the main class of hwp for reading file
88 * information from stream
90 * The example is as below:
91 * <pre>
92 * HWPFile f;
93 * f.ReadHwpFile( stream );
94 * </pre>
96 * There are two way to read hwp information from stream, one is to read all at a time
97 * to use @ref ReadhwpFile() method like above example, other is to read partial information
98 * to use @ref Open(), @ref InfoRead(), @ref FontRead(), @ref StyleRead(), @ref ParaListRead(), @ref TagsRead(),
100 * @short HWP file management object
101 * @author Mizi Reserach
102 * @version $Id: hwpfile.h,v 1.5 2008-06-04 10:01:33 vg Exp $
104 class DLLEXPORT HWPFile
106 public:
108 * Default constructor
110 HWPFile( void );
112 ~HWPFile( void );
114 public:
116 * Initialize this object
118 void Init();
121 * Opens HStream to use it.
122 * @returns 0 if success, otherwise error code
123 * @see State()
125 int Open( HStream & );
128 * Say current state
129 * @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.
131 int State( void ) const;
133 * Sets the current state
135 int SetState(int errcode);
137 * Reads one byte from HIODev
139 int Read1b( void );
141 * Reads two byte from HIODev
143 int Read2b( void );
145 * Reads four byte from HIODev
147 long Read4b( void );
149 * Reads nmemb byte array from HIODev
151 int Read1b( void *ptr, size_t nmemb );
153 * Reads nmemb short type array from HIODev
155 int Read2b( void *ptr, size_t nmemb );
157 * Reads nmemb long type array from HIODev
159 int Read4b( void *ptr, size_t nmemb );
161 * Reads some bytes from HIODev not regarding endian's way
162 * @param size Amount for reading
164 size_t ReadBlock( void *ptr, size_t size );
166 * Skips some bytes from HIODev
168 size_t SkipBlock( size_t size );
170 * Reads main paragraph list
172 bool ReadParaList(LinkedList<HWPPara> &plist, unsigned char flag = 0);
174 * Sets if the stream is compressed
176 bool SetCompressed( bool );
178 * Sets current HIODev
180 HIODev *SetIODevice( HIODev *hiodev );
183 * Reads all information of hwp file from stream
185 int ReadHwpFile( HStream &);
187 * Reads document information of hwp file from HIODev
189 bool InfoRead(void);
191 * Reads font list of hwp file from HIODev
193 bool FontRead(void);
195 * Reads style list of hwp file from HIODev
197 bool StyleRead(void);
199 * Reads paragraph list of hwp file from HIODev
201 bool ParaListRead();
202 /* ±×¸² µîÀÇ Ãß°¡ Á¤º¸¸¦ Àд´Ù. */
204 * Reads additional information like embeded image of hwp file from HIODev
206 bool TagsRead(void);
208 enum Paper
210 UserPaper = 0,
211 Col80Paper = 1,
212 Col132Paper = 2,
213 A4Paper = 3,
214 LetterPaper = 4,
215 B5Paper = 5,
216 B4Paper = 6,
217 LegalPaper = 7,
218 A3Paper = 8
221 void AddBox(FBox *);
222 void AddPage(){ m_nCurrentPage++;}
223 void AddColumnInfo();
224 void SetColumnDef(ColumnDef *coldef);
225 void AddParaShape(ParaShape *);
226 void AddCharShape(CharShape *);
227 void AddFBoxStyle(FBoxStyle *);
228 void AddDateFormat(DateCode *);
229 void AddHeaderFooter(HeaderFooter *);
230 void AddPageNumber(ShowPageNum *);
231 void AddTable(Table *);
233 ColumnDef* GetColumnDef(int);
234 int GetPageMasterNum(int page);
236 int getCurrentPage(){ return m_nCurrentPage;}
237 HWPInfo *GetHWPInfo(void) { return &_hwpInfo; }
238 HWPFont *GetHWPFont(void) { return &_hwpFont; }
239 HWPStyle *GetHWPStyle(void) { return &_hwpStyle; }
240 HWPPara *GetFirstPara(void) { return plist.first(); }
241 HWPPara *GetLastPara(void) { return plist.last(); }
243 EmPicture *GetEmPicture(Picture *pic);
244 EmPicture *GetEmPictureByName(char * name);
245 HyperText *GetHyperText();
246 FBox *GetBoxHead (void) { return blist.count()?blist.first():0; }
247 ParaShape *getParaShape(int);
248 CharShape *getCharShape(int);
249 FBoxStyle *getFBoxStyle(int);
250 DateCode *getDateCode(int);
251 HeaderFooter *getHeaderFooter(int);
252 ShowPageNum *getPageNumber(int);
253 Table *getTable(int);
255 int getParaShapeCount(){ return pslist.count(); }
256 int getCharShapeCount(){ return cslist.count(); }
257 int getFBoxStyleCount(){ return fbslist.count(); }
258 int getDateFormatCount(){ return datecodes.count(); }
259 int getHeaderFooterCount(){ return headerfooters.count(); }
260 int getPageNumberCount(){ return pagenumbers.count(); }
261 int getTableCount(){ return tables.count(); }
262 int getColumnCount(){ return columnlist.count(); }
264 int getMaxSettedPage(){ return m_nMaxSettedPage; }
265 void setMaxSettedPage(){ m_nMaxSettedPage = m_nCurrentPage; }
267 private :
268 int compareCharShape(CharShape *shape);
269 int compareParaShape(ParaShape *shape);
271 public:
272 int version;
273 bool compressed;
274 bool encrypted;
275 unsigned char linenumber;
276 int info_block_len;
277 int error_code;
278 OlePicture *oledata;
280 private:
281 /* hwp ÆÄÀÏ À̸§ */
282 char fname[256];
283 int m_nCurrentPage;
284 int m_nMaxSettedPage;
285 HIODev *hiodev;
286 // read hwp contents
287 HWPInfo _hwpInfo;
288 HWPFont _hwpFont;
289 HWPStyle _hwpStyle;
290 LinkedList<ColumnInfo> columnlist;
291 // paragraph linked list
292 LinkedList<HWPPara> plist;
293 // floating box linked list
294 LinkedList<FBox> blist;
295 // embedded picture list(tag datas)
296 LinkedList<EmPicture> emblist;
297 LinkedList<HyperText> hyperlist;
298 int currenthyper;
299 LinkedList<ParaShape> pslist; /* ½ºÅ¸¿ÀÇǽºÀÇ ±¸Á¶»ó ÇÊ¿ä */
300 LinkedList<CharShape> cslist;
301 LinkedList<FBoxStyle> fbslist;
302 LinkedList<DateCode> datecodes;
303 LinkedList<HeaderFooter> headerfooters;
304 LinkedList<ShowPageNum> pagenumbers;
305 LinkedList<Table> tables;
307 // for global document handling
308 static HWPFile *cur_doc;
309 friend HWPFile *GetCurrentDoc(void);
310 friend HWPFile *SetCurrentDoc(HWPFile *);
313 HWPFile *GetCurrentDoc(void);
314 HWPFile *SetCurrentDoc(HWPFile *hwpfp);
315 #endif /* _HWPFILE_H_ */