1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: hwpfile.h,v $
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 ************************************************************************/
33 // (C) 1998 Mizi Research, All rights are reserved
35 // $Id: hwpfile.h,v 1.5 2008-06-04 10:01:33 vg Exp $
87 * The HWPFile class is the main class of hwp for reading file
88 * information from stream
90 * The example is as below:
93 * f.ReadHwpFile( stream );
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
108 * Default constructor
116 * Initialize this object
121 * Opens HStream to use it.
122 * @returns 0 if success, otherwise error code
125 int Open( HStream
& );
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
141 * Reads two byte from HIODev
145 * Reads four byte from HIODev
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
191 * Reads font list of hwp file from HIODev
195 * Reads style list of hwp file from HIODev
197 bool StyleRead(void);
199 * Reads paragraph list of hwp file from HIODev
202 /* ±×¸² µîÀÇ Ãß°¡ Á¤º¸¸¦ Àд´Ù. */
204 * Reads additional information like embeded image of hwp file from HIODev
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
; }
268 int compareCharShape(CharShape
*shape
);
269 int compareParaShape(ParaShape
*shape
);
275 unsigned char linenumber
;
284 int m_nMaxSettedPage
;
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
;
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_ */