LibreOffice Module hwpfilter (master) 1
hwplib.h
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#ifndef INCLUDED_HWPFILTER_SOURCE_HWPLIB_H
21#define INCLUDED_HWPFILTER_SOURCE_HWPLIB_H
22#include "precompile.h"
23
24#include <limits>
25#include <new>
26#include <string>
27
28#include <o3tl/safeint.hxx>
29#include <rtl/ustring.hxx>
30#include <sal/types.h>
31
32/* hwp96부터 hunit가 4byte가 되었다. */
36typedef char16_t hchar;
37typedef int hunit;
38typedef unsigned char kchar;
39
40typedef unsigned char uchar;
41typedef unsigned short ushort;
42typedef unsigned int uint;
43
44typedef ::std::basic_string<hchar> hchar_string;
45
46inline OUString fromHcharStringToOUString(hchar_string const & s) {
47 if (s.length() > o3tl::make_unsigned(std::numeric_limits<sal_Int32>::max())) {
48 throw std::bad_alloc();
49 }
50 return {reinterpret_cast<char16_t const *>(s.c_str()), sal_Int32(s.length())};
51}
52
56typedef struct
57{
58 int x, y;
59} ZZPoint;
60
64typedef struct
65{
66 int w, h;
67} ZZSize;
68
72typedef struct
73{
74 int x, y;
75 int w, h;
76} ZZRect;
77
81typedef struct
82{
84} ZZParall;
85
89typedef struct
90{
91 int mulX, divX;
92 int mulY, divY;
93} ZZScaleXY;
94
95#if !defined(_WIN32) && !defined(MAX_PATH)
96# define MAX_PATH 260
97#endif /* MAX_PATH */
98
99#ifndef TRUE
100# define TRUE 1
101# define FALSE 0
102#endif
103
104// HWP unit information
108#define ONE_POINT 25
109#define ONE_ENG_CH_WIDTH (ONE_POINT*(10/2))
110#define ONE_MILI (71)
111#define ONE_DOT (19)
112
113/* HWP 3.0 문서 정보 */
114
115#define NLanguage 7
116
117/* 제어 문자 */
121#define CH_ALIGNSPACE 0
122#define CH_FIELD 5
123#define CH_BOOKMARK 6
124
125#define CH_DATE_FORM 7
126#define CH_DATE_CODE 8
127#define CH_TAB 9
128#define CH_TEXT_BOX 10
129#define CH_PICTURE 11
130
131#define CH_END_PARA 13
132#define CH_LINE 14
133#define CH_HIDDEN 15
134#define CH_HEADER_FOOTER 16
135#define CH_FOOTNOTE 17
136#define CH_AUTO_NUM 18 /* pgnum, footnote/endnote, picture num */
137#define CH_NEW_NUM 19 /* pgnum, footnote/endnote, picture num */
138
139#define CH_SHOW_PAGE_NUM 20
140#define CH_PAGE_NUM_CTRL 21 /* new chapter, hide pagenum */
141#define CH_MAIL_MERGE 22
142#define CH_COMPOSE 23
143#define CH_HYPHEN 24
144
145#define CH_TOC_MARK 25 /* CONT_MARK, TBL_MARK, PIC_MARK */
146#define CH_INDEX_MARK 26
147
148#define CH_COL_DEF 27
149#define CH_OUTLINE 28
150#define CH_CROSSREF 29
151
152#define CH_KEEP_SPACE 30
153#define CH_FIXED_SPACE 31
154#define CH_SPACE 32
155
156#define HAVE_SUBPARA_MASK ((1<<CH_TEXT_BOX) | (1<<CH_PICTURE) | (1<<CH_HIDDEN) | (1<<CH_HEADER_FOOTER) | (1<<CH_FOOTNOTE))
157
158#define IS_SP_SKIP_BLOCK(hch) ((hch<5) || (hch==12) || (hch==27) || (hch == 29))
159
160// file tag
161#define FILETAG_END_OF_COMPRESSED 0x00000000
162
163#define FILETAG_EMBEDDED_PICTURE 0x00000001
164#define FILETAG_OLE_OBJECT 0x00000002
165#define FILETAG_HYPERTEXT 0x00000003
166#define FILETAG_PRESENTATION 0x00000004
167
168#define FILETAG_END_OF_UNCOMPRESSED 0x80000000
169#define FILETAG_PREVIEW_IMAGE 0x80000001
170#define FILETAG_PREVIEW_TEXT 0x80000002
171
172// user error code
174{
176// system error = errno
177// USER_ERROR_BIT = (1 << 16),
184
185// debug code
187{
188 DBG_READ = 0x01,
189 DBG_DISPLAY = 0x02
191
192#ifdef _WIN32
193#ifdef HWPLIB_DLL
194//# define DLLEXPORT __declspec(dllexport)
195# define DLLEXPORT
196#else
197//# define DLLEXPORT __declspec(dllimport)
198# define DLLEXPORT
199#endif
200#else
201# define DLLEXPORT
202#endif
203
204#include <sys/stat.h>
205#include <sys/types.h>
206#include <fcntl.h>
207
208#ifdef _WIN32
209# include <direct.h>
210# include <io.h>
211# define access _access
212# define stat _stat
213# define mkdir(x,y) _mkdir(x)
214# define rmdir _rmdir
215# define open _open
216# define write _write
217# define close _close
218# define unlink _unlink
219# define DIRSEP '\\'
220#else
221# include <unistd.h>
222# define DIRSEP '/'
223#endif
224#endif // INCLUDED_HWPFILTER_SOURCE_HWPLIB_H
225
226/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
float y
unsigned char kchar
Definition: hwplib.h:38
::std::basic_string< hchar > hchar_string
Definition: hwplib.h:44
char16_t hchar
size of hunit is 4 since hwp96 version
Definition: hwplib.h:36
DebugMask
Definition: hwplib.h:187
@ DBG_READ
Definition: hwplib.h:188
@ DBG_DISPLAY
Definition: hwplib.h:189
int hunit
Definition: hwplib.h:37
ErrorCode
Definition: hwplib.h:174
@ HWP_NoError
Definition: hwplib.h:175
@ HWP_UNSUPPORTED_VERSION
Definition: hwplib.h:181
@ HWP_InvalidFileFormat
Definition: hwplib.h:179
@ HWP_BrokenFile
Definition: hwplib.h:180
@ HWP_InvalidFileName
Definition: hwplib.h:178
@ HWP_EMPTY_FILE
Definition: hwplib.h:182
unsigned char uchar
Definition: hwplib.h:40
unsigned int uint
Definition: hwplib.h:42
OUString fromHcharStringToOUString(hchar_string const &s)
Definition: hwplib.h:46
unsigned short ushort
Definition: hwplib.h:41
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
sal_Int32 w
Parall.
Definition: hwplib.h:82
Point.
Definition: hwplib.h:57
int x
Definition: hwplib.h:58
Rectangle.
Definition: hwplib.h:73
int h
Definition: hwplib.h:75
int x
Definition: hwplib.h:74
Scale.
Definition: hwplib.h:90
int divY
Definition: hwplib.h:92
int divX
Definition: hwplib.h:91
Size.
Definition: hwplib.h:65
int h
Definition: hwplib.h:66