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
25 #ifndef INCLUDED_HWPFILTER_SOURCE_HWPFILE_H
26 #define INCLUDED_HWPFILTER_SOURCE_HWPFILE_H
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 { return error_code
;}
121 * Sets the current state
123 int SetState(int errcode
);
125 * Reads one byte from HIODev
127 bool Read1b(char &out
);
128 bool Read1b(unsigned char &out
);
130 * Reads two byte from HIODev
132 bool Read2b(unsigned short &out
);
134 * Reads four byte from HIODev
136 bool Read4b(unsigned int &out
);
137 bool Read4b(int &out
);
139 * Reads nmemb byte array from HIODev
141 int Read1b( void *ptr
, size_t nmemb
);
143 * Reads nmemb short type array from HIODev
145 int Read2b( void *ptr
, size_t nmemb
);
147 * Reads nmemb long type array from HIODev
149 int Read4b( void *ptr
, size_t nmemb
);
151 * Reads some bytes from HIODev not regarding endian's way
152 * @param size Amount for reading
154 size_t ReadBlock( void *ptr
, size_t size
);
156 * Skips some bytes from HIODev
158 size_t SkipBlock( size_t size
);
160 * Reads main paragraph list
162 bool ReadParaList(std::list
<HWPPara
*> &aplist
, unsigned char flag
= 0);
164 * Sets if the stream is compressed
166 bool SetCompressed( bool );
168 * Sets current HIODev
170 HIODev
*SetIODevice( HIODev
*hiodev
);
173 * Reads all information of hwp file from stream
175 int ReadHwpFile( HStream
*);
177 * Reads document information of hwp file from HIODev
181 * Reads font list of hwp file from HIODev
185 * Reads style list of hwp file from HIODev
187 bool StyleRead(void);
189 * Reads paragraph list of hwp file from HIODev
192 /* 그림 등의 추가 정보를 읽는다. */
194 * Reads additional information like embedded image of hwp file from HIODev
212 void AddPage(){ m_nCurrentPage
++;}
213 void AddColumnInfo();
214 void SetColumnDef(ColumnDef
*coldef
);
215 void AddParaShape(ParaShape
*);
216 void AddCharShape(CharShape
*);
217 void AddFBoxStyle(FBoxStyle
*);
218 void AddDateFormat(DateCode
*);
219 void AddHeaderFooter(HeaderFooter
*);
220 void AddPageNumber(ShowPageNum
*);
221 void AddTable(Table
*);
223 ColumnDef
* GetColumnDef(int);
224 int GetPageMasterNum(int page
);
226 int getCurrentPage(){ return m_nCurrentPage
;}
227 HWPInfo
& GetHWPInfo(void) { return _hwpInfo
; }
228 HWPFont
& GetHWPFont(void) { return _hwpFont
; }
229 HWPStyle
& GetHWPStyle(void) { return _hwpStyle
; }
230 HWPPara
*GetFirstPara(void) { return plist
.front(); }
231 HWPPara
*GetLastPara(void) { return plist
.back(); }
233 EmPicture
*GetEmPicture(Picture
*pic
);
234 EmPicture
*GetEmPictureByName(char * name
);
235 HyperText
*GetHyperText();
236 FBox
*GetBoxHead (void) { return blist
.size()?blist
.front():0; }
237 ParaShape
*getParaShape(int);
238 CharShape
*getCharShape(int);
239 FBoxStyle
*getFBoxStyle(int);
240 DateCode
*getDateCode(int);
241 HeaderFooter
*getHeaderFooter(int);
242 ShowPageNum
*getPageNumber(int);
243 Table
*getTable(int);
245 int getParaShapeCount(){ return pslist
.size(); }
246 int getCharShapeCount(){ return cslist
.size(); }
247 int getFBoxStyleCount(){ return fbslist
.size(); }
248 int getDateFormatCount(){ return datecodes
.size(); }
249 int getHeaderFooterCount(){ return headerfooters
.size(); }
250 int getPageNumberCount(){ return pagenumbers
.size(); }
251 int getTableCount(){ return tables
.size(); }
252 int getColumnCount(){ return columnlist
.size(); }
254 int getMaxSettedPage(){ return m_nMaxSettedPage
; }
255 void setMaxSettedPage(){ m_nMaxSettedPage
= m_nCurrentPage
; }
258 int compareCharShape(CharShape
*shape
);
259 int compareParaShape(ParaShape
*shape
);
265 unsigned char linenumber
;
273 int m_nMaxSettedPage
;
279 std::list
<ColumnInfo
*> columnlist
;
280 // paragraph linked list
281 std::list
<HWPPara
*> plist
;
282 // floating box linked list
283 std::list
<FBox
*> blist
;
284 // embedded picture list(tag datas)
285 std::list
<EmPicture
*> emblist
;
286 std::list
<HyperText
*> hyperlist
;
288 std::list
<ParaShape
*> pslist
; /* 스타오피스의 구조상 필요 */
289 std::list
<CharShape
*> cslist
;
290 std::list
<FBoxStyle
*> fbslist
;
291 std::list
<DateCode
*> datecodes
;
292 std::list
<HeaderFooter
*> headerfooters
;
293 std::list
<ShowPageNum
*> pagenumbers
;
294 std::list
<Table
*> tables
;
296 // for global document handling
297 static HWPFile
*cur_doc
;
298 friend HWPFile
*GetCurrentDoc(void);
299 friend HWPFile
*SetCurrentDoc(HWPFile
*);
302 HWPFile
*GetCurrentDoc(void);
303 HWPFile
*SetCurrentDoc(HWPFile
*hwpfp
);
304 #endif // INCLUDED_HWPFILTER_SOURCE_HWPFILE_H
306 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */