update credits
[LibreOffice.git] / hwpfilter / source / hwplib.h
blobda8a253c65fceb613acf01e2631c0acc2b5a324f
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 .
20 #ifndef _HWPLIB_H_
21 #define _HWPLIB_H_
22 #include "precompile.h"
24 #include <string>
26 /* hwp96ºÎÅÍ hunit°¡ 4byte°¡ µÇ¾ú´Ù. */
27 /**
28 * size of hunit is 4 since hwp96 version
30 #ifndef _HCHAR_
31 #define _HCHAR_
32 typedef unsigned short hchar;
33 typedef int hunit;
34 typedef unsigned char kchar;
35 typedef unsigned char echar;
36 #endif // _HCHAR_
38 #if !defined(WIN32)
39 #if !defined(_BOOL_T_) && !defined(OS2)
40 typedef unsigned short BOOL;
41 #endif /* _BOOL_T_ */
42 typedef unsigned short WORD;
43 typedef int SIZE;
44 typedef unsigned long DWORD;
45 typedef long LONG;
46 #endif /* WIN32 */
48 #ifndef _UTYPE_
49 #define _UTYPE_
50 typedef unsigned char uchar;
51 typedef unsigned short ushort;
52 typedef unsigned int uint;
53 typedef unsigned long ulong;
54 #endif /* _UTYPE_ */
56 typedef ::std::basic_string<hchar> hchar_string;
58 #ifndef _ZZRECT_
59 #define _ZZRECT_
60 /**
61 * @short Point
63 typedef struct
65 int x, y;
66 } ZZPoint;
68 inline void allocPoint(ZZPoint &target, ZZPoint &src)
70 target.x = src.x;
71 target.y = src.y;
74 /**
75 * @short Size
77 typedef struct
79 int w, h;
80 } ZZSize;
82 /**
83 * @short Rectangle
85 typedef struct
87 int x, y;
88 int w, h;
89 } ZZRect;
91 /**
92 * @short Parall
94 typedef struct
96 ZZPoint pt[3];
97 } ZZParall;
99 /**
100 * @short Scale
102 typedef struct
104 int mulX, divX;
105 int mulY, divY;
106 } ZZScaleXY;
107 #endif /* _ZZRECT_ */
109 #if !defined(_WIN32) && !defined(MAX_PATH)
110 # define MAX_PATH 260
111 #endif /* MAX_PATH */
113 #ifndef TRUE
114 # define TRUE 1
115 # define FALSE 0
116 #endif
118 // HWP unit information
120 * HWP unit information
122 #define ONE_POINT 25
123 #define ONE_ENG_CH_WIDTH (ONE_POINT*(10/2))
124 #define ONE_MILI (71)
125 #define ONE_DOT (19)
127 /* HWP 3.0 ¹®¼­ Á¤º¸ */
129 #define NLanguage 7
131 /* Á¦¾î ¹®ÀÚ */
133 * Control character
135 #define CH_ALIGNSPACE 0
136 #define CH_FIELD 5
137 #define CH_BOOKMARK 6
139 #define CH_DATE_FORM 7
140 #define CH_DATE_CODE 8
141 #define CH_TAB 9
142 #define CH_TEXT_BOX 10
143 #define CH_PICTURE 11
145 #define CH_END_PARA 13
146 #define CH_LINE 14
147 #define CH_HIDDEN 15
148 #define CH_HEADER_FOOTER 16
149 #define CH_FOOTNOTE 17
150 #define CH_AUTO_NUM 18 /* pgnum, footnote/endnote, picture num */
151 #define CH_NEW_NUM 19 /* pgnum, footnote/endnote, picture num */
153 #define CH_SHOW_PAGE_NUM 20
154 #define CH_PAGE_NUM_CTRL 21 /* new chapter, hide pagenum */
155 #define CH_MAIL_MERGE 22
156 #define CH_COMPOSE 23
157 #define CH_HYPHEN 24
159 #define CH_TOC_MARK 25 /* CONT_MARK, TBL_MARK, PIC_MARK */
160 #define CH_INDEX_MARK 26
162 #define CH_COL_DEF 27
163 #define CH_OUTLINE 28
164 #define CH_CROSSREF 29
166 #define CH_KEEP_SPACE 30
167 #define CH_FIXED_SPACE 31
168 #define CH_SPACE 32
170 #define HAVE_SUBPARA_MASK ((1<<CH_TEXT_BOX) | (1<<CH_PICTURE) | (1<<CH_HIDDEN) | (1<<CH_HEADER_FOOTER) | (1<<CH_FOOTNOTE))
172 #define IS_SP_SKIP_BLOCK(hch) ((hch<5) || (hch==12) || (hch==27) || (hch == 29))
174 // file tag
175 #define FILETAG_UNCOMPRESSED_BIT 0x80000000
176 #define FILETAG_END_OF_COMPRESSED 0x00000000
178 #define FILETAG_EMBEDDED_PICTURE 0x00000001
179 #define FILETAG_OLE_OBJECT 0x00000002
180 #define FILETAG_HYPERTEXT 0x00000003
181 #define FILETAG_PRESENTATION 0x00000004
183 #define FILETAG_END_OF_UNCOMPRESSED 0x80000000
184 #define FILETAG_PREVIEW_IMAGE 0x80000001
185 #define FILETAG_PREVIEW_TEXT 0x80000002
187 // user error code
188 enum ErrorCode
190 HWP_NoError,
191 // system error = errno
192 // USER_ERROR_BIT = (1 << 16),
193 HWP_InvalidFileName,
194 HWP_InvalidFileFormat,
195 HWP_BrokenFile,
196 HWP_UNSUPPORTED_VERSION,
197 HWP_EMPTY_FILE
200 // debug code
201 enum DebugMask
203 DBG_READ = 0x01,
204 DBG_DISPLAY = 0x02
207 #ifdef _WIN32
208 #ifdef HWPLIB_DLL
209 //# define DLLEXPORT __declspec(dllexport)
210 # define DLLEXPORT
211 #else
212 //# define DLLEXPORT __declspec(dllimport)
213 # define DLLEXPORT
214 #endif
215 #else
216 # define DLLEXPORT
217 #endif
219 #include <sys/stat.h>
220 #include <sys/types.h>
221 #include <fcntl.h>
223 #ifdef _WIN32
224 # include <direct.h>
225 # include <io.h>
226 # define access _access
227 # define stat _stat
228 # define mkdir(x,y) _mkdir(x)
229 # define rmdir _rmdir
230 # define open _open
231 # define write _write
232 # define close _close
233 # define unlink _unlink
234 # define DIRSEP '\\'
235 #else
236 # include <unistd.h>
237 # define DIRSEP '/'
238 #endif
239 #endif /* _HWPLIB_H_*/
241 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */