1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
22 // (C) 1998 Mizi Research, All rights are reserved
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"
47 int detect_hwp_version(const char *str
);
81 * The HWPFile class is the main class of hwp for reading file
82 * information from stream
84 * The example is as below:
87 * f.ReadHwpFile( stream );
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
101 * Default constructor
109 * Opens HStream to use it.
110 * @returns 0 if success, otherwise error code
113 int Open( HStream
& );
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
129 * Reads two byte from HIODev
133 * Reads four byte from HIODev
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
179 * Reads font list of hwp file from HIODev
183 * Reads style list of hwp file from HIODev
185 bool StyleRead(void);
187 * Reads paragraph list of hwp file from HIODev
190 /* ±×¸² µîÀÇ Ãß°¡ Á¤º¸¸¦ Àд´Ù. */
192 * Reads additional information like embeded image of hwp file from HIODev
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
; }
256 int compareCharShape(CharShape
*shape
);
257 int compareParaShape(ParaShape
*shape
);
263 unsigned char linenumber
;
271 int m_nMaxSettedPage
;
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
;
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: */