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_DRAWDEF_H
21 #define INCLUDED_HWPFILTER_SOURCE_DRAWDEF_H
22 
23 #include "hwplib.h"
24 #include <memory>
25 
26 class HWPPara;
27 
28 /**
29  * Constant for drawing objects
30  */
31 enum objtype
32 {
33     HWPDO_CONTAINER,
34     HWPDO_LINE,
35     HWPDO_RECT,
36     HWPDO_ELLIPSE,
37     HWPDO_ARC,
38     HWPDO_FREEFORM,
39     HWPDO_TEXTBOX,
40     HWPDO_CURVE,
41     HWPDO_ADVANCED_ELLIPSE,
42     HWPDO_ADVANCED_ARC,
43     HWPDO_CLOSED_FREEFORM,
44     HWPDO_NITEMS
45 };
46 
47 #define HWPDO_PAT_TYPE_BITS 0xFF000000
48 
49 #define HWPDO_PAT_SOLID     0x00000000
50 
51 #define HWPDO_COLOR_NONE    0x10000000
52 
53 #define HWPDO_FLAG_DRAW_PIE 0x00000002
54 
55 
56 #define HWPDO_FLAG_GRADATION    0x00010000
57 #define HWPDO_FLAG_ROTATION 0x00020000
58 #define HWPDO_FLAG_BITMAP   0x00040000
59 #define HWPDO_FLAG_AS_TEXTBOX   0x00080000
60 #define HWPDO_FLAG_WATERMARK   0x00100000
61 
62 /**
63  * @short Basic properties for drawing objects
64  *
65  * The order of pstyle, hstyle and tstyle is important.
66  * @see LineObject
67  */
68 struct BAREHWPDOProperty
69 {
70     int line_pstyle;
71     int line_hstyle;
72     int line_tstyle;
73     unsigned int line_color;
74     hunit line_width;
75     unsigned int fill_color;
76     uint pattern_type;
77     unsigned int pattern_color;
78     hunit hmargin;
79     hunit vmargin;
80     uint flag;
81 };
82 
83 /**
84  * @short Gradation properties for drawing object
85  */
86 struct GradationProperty
87 {
88     int fromcolor;
89     int tocolor;
90     int gstyle;
91     int angle;
92     int center_x;
93     int center_y;
94     int nstep;
95 };
96 
97 /**
98  * @short Bitmap properties for drawing object
99  */
100 struct BitmapProperty
101 {
102     ZZPoint offset1;
103     ZZPoint offset2;
104     char szPatternFile[260 + 1];
105     char pictype;
106 };
107 
108 /**
109  * @short Rotation properties for drawing object
110  */
111 struct RotationProperty
112 {
113     int rot_originx;
114     int rot_originy;
115     ZZParall parall;
116 };
117 
118 /**
119  * @short All properties for drawing object
120  */
121 struct HWPDOProperty
122 {
123     int line_pstyle; /* Style of the middle of line */
124     int line_hstyle; /* Style of the end of line */
125     int line_tstyle; /* Style of the start of line */
126     unsigned int line_color;
127     hunit line_width;
128     unsigned int fill_color;
129     uint pattern_type;
130     unsigned int pattern_color;
131     hunit hmargin;
132     hunit vmargin;
133     uint flag;
134 
135      /* Rotation properties */
136     int rot_originx;
137     int rot_originy;
138     ZZParall parall;
139 
140      /* Gradation properties */
141 
142     int fromcolor;
143     int tocolor;
144     int gstyle;
145     int angle;
146     int center_x;
147     int center_y;
148     int nstep;
149 
150      /* Watermark */
151      int luminance;
152      int contrast;
153      int greyscale;
154 
155      /* As TextBox */
156     HWPPara *pPara;
157 
158 
159     ZZPoint offset1;
160     ZZPoint offset2;
161     char szPatternFile[260 + 1];
162     char pictype;
163 };
164 
165 /**
166  * @short Line Object
167  */
168 struct HWPDOLine
169 {
170     uint flip;
171 };
172 
173 /**
174  * @short Polygon or Polyline Object
175  */
176 struct HWPDOFreeForm
177 {
178     int npt;
179     ZZPoint *pt;
180 };
181 
182 /**
183  * @short Textbox Object
184  */
185 struct HWPDOTextBox
186 {
187     HWPPara *h;
188 };
189 
190 /**
191  * @short Arc Object
192  */
193 struct HWPDOArc
194 {
195     ZZPoint radial[2];
196 };
197 
198 /**
199  * @short Common header for drawing object
200  */
201 struct HWPDrawingObject
202 {
203 /**
204  * type of drawing object
205  */
206     int type;
207 /**
208  * offset from origin of current group
209  */
210     ZZPoint offset;
211 /**
212  * offset from origin of drawing object
213  */
214     ZZPoint offset2;
215     ZZSize extent;
216 /**
217  * rectangle with consideration of line width
218  */
219     ZZRect vrect;
220     HWPDOProperty property;
221     union
222     {
223         HWPDOLine line_arc;
224         HWPDOFreeForm freeform;
225         HWPDOTextBox textbox;
226 /**
227  * extended from hwpw96
228  */
229         HWPDOArc arc;
230     }
231     u;
232     std::unique_ptr<struct HWPDrawingObject> next;
233 /**
234  * This exists for container object
235  */
236     std::unique_ptr<struct HWPDrawingObject> child;
237     int index;
238     HWPDrawingObject();
239     ~HWPDrawingObject();
240 };
241 #endif // INCLUDED_HWPFILTER_SOURCE_DRAWDEF_H
242 
243 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
244