Line data Source code
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 _HWPPARA_H_
21 : #define _HWPPARA_H_
22 :
23 : #include <hwplib.h>
24 : #include <hwpfile.h>
25 : #include <hinfo.h>
26 :
27 : struct HBox;
28 :
29 : /**
30 : * etc flag
31 : * 0 bit : Use page columns
32 : * 1 bit : Use page lows
33 : * 2 bit : Use section break
34 : * 3 bit : Block start
35 : * 4 bit : In Block
36 : * 5 bit : Block end
37 : * 6 bit : Preserve widow orphan
38 : * 7 bit : Reserved
39 : */
40 : enum
41 : {
42 : PA_USER_COLUMN = 1,
43 : PA_USER_PAGE = 2, /* p user_page definiton */
44 : PA_SECTION_BREAK = 4,
45 : PA_BLOCK_BEGIN = 8,
46 : PA_IN_BLOCK = 16,
47 : PA_BLOCK_END = 32,
48 : PA_WIDOW_ORPHAN = 64
49 : };
50 :
51 : class HWPPara;
52 : #define FIXED_SPACING_BIT (0x8000)
53 :
54 : struct LineInfo
55 : {
56 : /* ½ÃÀÛÇÏ´Â ±ÛÀÚÀÇ À§Ä¡ : ÄÜÆ®·ÑÀº ¿©·¯ ±æÀ̸¦ °¡Áø´Ù */
57 : /**
58 : * Starting character position
59 : */
60 : unsigned short pos;
61 : hunit space_width;
62 : hunit height;
63 : hunit pgy; /* internal */
64 : hunit sx; /* internal */
65 : hunit psx; /* internal */
66 : hunit pex; /* internal */
67 : // for formatting
68 : hunit height_sp;
69 : unsigned short softbreak; // column, page, section
70 :
71 : bool Read(HWPFile &hwpf, HWPPara *para);
72 : };
73 : /**
74 : * It represents the paragraph.
75 : * @short Paragraph
76 : */
77 : class DLLEXPORT HWPPara
78 : {
79 : private:
80 : HWPPara *_next;
81 :
82 : public:
83 : // paragraph information
84 : /**
85 : * Zero is for the new paragraph style.
86 : */
87 : unsigned char reuse_shape; /* 0ÀÌ¸é »õ¸ð¾ç */
88 : unsigned short nch;
89 : unsigned short nline;
90 :
91 : // realking
92 : hunit begin_ypos;
93 : unsigned char scflag;
94 :
95 : /**
96 : * If the value is 0, all character of paragraph have same style given cshape
97 : */
98 : unsigned char contain_cshape; /* 0ÀÌ¸é ¸ðµç ±ÛÀÚ°¡ ´ëÇ¥ ±ÛÀÚ ¸ð¾ç */
99 : unsigned char etcflag;
100 : /**
101 : * Checks the special characters in the paragraph
102 : */
103 : unsigned long ctrlflag;
104 : unsigned char pstyno;
105 : CharShape cshape; /* ±ÛÀÚ°¡ ¸ðµÎ °°Àº ¸ð¾çÀ϶§ */
106 : ParaShape pshape; /* reuse flag°¡ 0À̸é */
107 : int pno; /* run-time only */
108 :
109 : LineInfo *linfo;
110 : CharShape *cshapep;
111 : /**
112 : * Box object list
113 : */
114 : HBox **hhstr;
115 :
116 : HWPPara(void);
117 : ~HWPPara(void);
118 :
119 : bool Read(HWPFile &hwpf, unsigned char flag = 0);
120 : int Write(CTextOut &txtf);
121 : int Write(CHTMLOut &html);
122 :
123 0 : void SetNext(HWPPara *n) { _next = n; };
124 :
125 : /* layoutÀ» À§ÇÑ ÇÔ¼ö */
126 : /**
127 : * Returns the character sytle of paragraph.
128 : */
129 : CharShape *GetCharShape(int pos);
130 : /**
131 : * Returns the sytle of paragraph.
132 : */
133 : ParaShape *GetParaShape(void);
134 :
135 : /**
136 : * Returns previous paragraph.
137 : */
138 : HWPPara *Prev(void);
139 : /**
140 : * Returns next paragraph.
141 : */
142 : HWPPara *Next(void);
143 :
144 : int HomePos(int line) const;
145 : int EndPos(int line) const;
146 : int LineLen(int line) const;
147 :
148 : private:
149 : HBox *readHBox(HWPFile &);
150 : };
151 :
152 : // inline functions
153 :
154 : inline int HWPPara::HomePos(int line) const
155 : {
156 : if( nline < line + 1 ) return nch;
157 : return linfo[line].pos;
158 : }
159 :
160 :
161 : inline int HWPPara::EndPos(int line) const
162 : {
163 : if( nline <= line + 1 ) return nch;
164 : else return HomePos(line + 1);
165 : }
166 :
167 :
168 : inline int HWPPara::LineLen(int line) const
169 : {
170 : return EndPos(line) - HomePos(line);
171 : }
172 : #endif /* _HWPPARA_H_ */
173 :
174 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|