blob: 2c9ec99dc8e43f96f2965a14b9c6648722085f42 [file] [log] [blame]
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001// Copyright 2014 PDFium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
Lei Zhanga6d9f0e2015-06-13 00:48:38 -07004
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07005// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
Lei Zhangbde53d22015-11-12 22:21:30 -08007#include "fpdfsdk/include/pdfwindow/PWL_Icon.h"
8#include "fpdfsdk/include/pdfwindow/PWL_Utils.h"
9#include "fpdfsdk/include/pdfwindow/PWL_Wnd.h"
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070010
Nico Weber9d8ec5a2015-08-04 13:00:21 -070011#define IsFloatZero(f) ((f) < 0.0001 && (f) > -0.0001)
12#define IsFloatBigger(fa, fb) ((fa) > (fb) && !IsFloatZero((fa) - (fb)))
13#define IsFloatSmaller(fa, fb) ((fa) < (fb) && !IsFloatZero((fa) - (fb)))
14#define IsFloatEqual(fa, fb) IsFloatZero((fa) - (fb))
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070015
Nico Weber9d8ec5a2015-08-04 13:00:21 -070016CFX_ByteString CPWL_Utils::GetAppStreamFromArray(const CPWL_PathData* pPathData,
17 int32_t nCount) {
18 CFX_ByteTextBuf csAP;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070019
Nico Weber9d8ec5a2015-08-04 13:00:21 -070020 for (int32_t i = 0; i < nCount; i++) {
21 switch (pPathData[i].type) {
22 case PWLPT_MOVETO:
23 csAP << pPathData[i].point.x << " " << pPathData[i].point.y << " m\n";
24 break;
25 case PWLPT_LINETO:
26 csAP << pPathData[i].point.x << " " << pPathData[i].point.y << " l\n";
27 break;
28 case PWLPT_BEZIERTO:
29 csAP << pPathData[i].point.x << " " << pPathData[i].point.y << " "
30 << pPathData[i + 1].point.x << " " << pPathData[i + 1].point.y
31 << " " << pPathData[i + 2].point.x << " "
32 << pPathData[i + 2].point.y << " c\n";
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070033
Nico Weber9d8ec5a2015-08-04 13:00:21 -070034 i += 2;
35 break;
36 default:
37 break;
38 }
39 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070040
Nico Weber9d8ec5a2015-08-04 13:00:21 -070041 return csAP.GetByteString();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070042}
43
Nico Weber9d8ec5a2015-08-04 13:00:21 -070044void CPWL_Utils::GetPathDataFromArray(CFX_PathData& path,
45 const CPWL_PathData* pPathData,
46 int32_t nCount) {
47 path.SetPointCount(nCount);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070048
Nico Weber9d8ec5a2015-08-04 13:00:21 -070049 for (int32_t i = 0; i < nCount; i++) {
50 switch (pPathData[i].type) {
51 case PWLPT_MOVETO:
52 path.SetPoint(i, pPathData[i].point.x, pPathData[i].point.y,
53 FXPT_MOVETO);
54 break;
55 case PWLPT_LINETO:
56 path.SetPoint(i, pPathData[i].point.x, pPathData[i].point.y,
57 FXPT_LINETO);
58 break;
59 case PWLPT_BEZIERTO:
60 path.SetPoint(i, pPathData[i].point.x, pPathData[i].point.y,
61 FXPT_BEZIERTO);
62 break;
63 default:
64 break;
65 }
66 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070067}
68
Nico Weber9d8ec5a2015-08-04 13:00:21 -070069CPDF_Rect CPWL_Utils::MaxRect(const CPDF_Rect& rect1, const CPDF_Rect& rect2) {
70 CPDF_Rect rcRet;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070071
Nico Weber9d8ec5a2015-08-04 13:00:21 -070072 rcRet.left = PWL_MIN(rect1.left, rect2.left);
73 rcRet.bottom = PWL_MIN(rect1.bottom, rect2.bottom);
74 rcRet.right = PWL_MAX(rect1.right, rect2.right);
75 rcRet.top = PWL_MAX(rect1.top, rect2.top);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070076
Nico Weber9d8ec5a2015-08-04 13:00:21 -070077 return rcRet;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070078}
79
Nico Weber9d8ec5a2015-08-04 13:00:21 -070080CPDF_Rect CPWL_Utils::OffsetRect(const CPDF_Rect& rect,
81 FX_FLOAT x,
82 FX_FLOAT y) {
83 return CPDF_Rect(rect.left + x, rect.bottom + y, rect.right + x,
84 rect.top + y);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070085}
86
Nico Weber9d8ec5a2015-08-04 13:00:21 -070087FX_BOOL CPWL_Utils::ContainsRect(const CPDF_Rect& rcParent,
88 const CPDF_Rect& rcChild) {
89 return rcChild.left >= rcParent.left && rcChild.bottom >= rcParent.bottom &&
90 rcChild.right <= rcParent.right && rcChild.top <= rcParent.top;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070091}
92
Nico Weber9d8ec5a2015-08-04 13:00:21 -070093FX_BOOL CPWL_Utils::IntersectRect(const CPDF_Rect& rect1,
94 const CPDF_Rect& rect2) {
95 FX_FLOAT left = rect1.left > rect2.left ? rect1.left : rect2.left;
96 FX_FLOAT right = rect1.right < rect2.right ? rect1.right : rect2.right;
97 FX_FLOAT bottom = rect1.bottom > rect2.bottom ? rect1.bottom : rect2.bottom;
98 FX_FLOAT top = rect1.top < rect2.top ? rect1.top : rect2.top;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070099
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700100 return left < right && bottom < top;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700101}
102
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700103CPDF_Point CPWL_Utils::OffsetPoint(const CPDF_Point& point,
104 FX_FLOAT x,
105 FX_FLOAT y) {
106 return CPDF_Point(point.x + x, point.y + y);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700107}
108
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700109CPVT_WordRange CPWL_Utils::OverlapWordRange(const CPVT_WordRange& wr1,
110 const CPVT_WordRange& wr2) {
111 CPVT_WordRange wrRet;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700112
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700113 if (wr2.EndPos.WordCmp(wr1.BeginPos) < 0 ||
114 wr2.BeginPos.WordCmp(wr1.EndPos) > 0)
115 return wrRet;
116 if (wr1.EndPos.WordCmp(wr2.BeginPos) < 0 ||
117 wr1.BeginPos.WordCmp(wr2.EndPos) > 0)
118 return wrRet;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700119
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700120 if (wr1.BeginPos.WordCmp(wr2.BeginPos) < 0) {
121 wrRet.BeginPos = wr2.BeginPos;
122 } else {
123 wrRet.BeginPos = wr1.BeginPos;
124 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700125
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700126 if (wr1.EndPos.WordCmp(wr2.EndPos) < 0) {
127 wrRet.EndPos = wr1.EndPos;
128 } else {
129 wrRet.EndPos = wr2.EndPos;
130 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700131
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700132 return wrRet;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700133}
134
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700135CFX_ByteString CPWL_Utils::GetAP_Check(const CPDF_Rect& crBBox) {
Lei Zhangc2fb35f2016-01-05 16:46:58 -0800136 const FX_FLOAT fWidth = crBBox.right - crBBox.left;
137 const FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700138
Lei Zhangc2fb35f2016-01-05 16:46:58 -0800139 CPWL_Point pts[8][3] = {{CPWL_Point(0.28f, 0.52f), CPWL_Point(0.27f, 0.48f),
140 CPWL_Point(0.29f, 0.40f)},
141 {CPWL_Point(0.30f, 0.33f), CPWL_Point(0.31f, 0.29f),
142 CPWL_Point(0.31f, 0.28f)},
143 {CPWL_Point(0.39f, 0.28f), CPWL_Point(0.49f, 0.29f),
144 CPWL_Point(0.77f, 0.67f)},
145 {CPWL_Point(0.76f, 0.68f), CPWL_Point(0.78f, 0.69f),
146 CPWL_Point(0.76f, 0.75f)},
147 {CPWL_Point(0.76f, 0.75f), CPWL_Point(0.73f, 0.80f),
148 CPWL_Point(0.68f, 0.75f)},
149 {CPWL_Point(0.68f, 0.74f), CPWL_Point(0.68f, 0.74f),
150 CPWL_Point(0.44f, 0.47f)},
151 {CPWL_Point(0.43f, 0.47f), CPWL_Point(0.40f, 0.47f),
152 CPWL_Point(0.41f, 0.58f)},
153 {CPWL_Point(0.40f, 0.60f), CPWL_Point(0.28f, 0.66f),
154 CPWL_Point(0.30f, 0.56f)}};
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700155
Lei Zhangc2fb35f2016-01-05 16:46:58 -0800156 for (size_t i = 0; i < FX_ArraySize(pts); ++i) {
157 for (size_t j = 0; j < FX_ArraySize(pts[0]); ++j) {
158 pts[i][j].x = pts[i][j].x * fWidth + crBBox.left;
159 pts[i][j].y *= pts[i][j].y * fHeight + crBBox.bottom;
160 }
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700161 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700162
Lei Zhangc2fb35f2016-01-05 16:46:58 -0800163 CFX_ByteTextBuf csAP;
164 csAP << pts[0][0].x << " " << pts[0][0].y << " m\n";
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700165
Lei Zhangc2fb35f2016-01-05 16:46:58 -0800166 for (size_t i = 0; i < FX_ArraySize(pts); ++i) {
167 size_t nNext = i < FX_ArraySize(pts) - 1 ? i + 1 : 0;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700168
Lei Zhangc2fb35f2016-01-05 16:46:58 -0800169 FX_FLOAT px1 = pts[i][1].x - pts[i][0].x;
170 FX_FLOAT py1 = pts[i][1].y - pts[i][0].y;
171 FX_FLOAT px2 = pts[i][2].x - pts[nNext][0].x;
172 FX_FLOAT py2 = pts[i][2].y - pts[nNext][0].y;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700173
Lei Zhangc2fb35f2016-01-05 16:46:58 -0800174 csAP << pts[i][0].x + px1 * PWL_BEZIER << " "
175 << pts[i][0].y + py1 * PWL_BEZIER << " "
176 << pts[nNext][0].x + px2 * PWL_BEZIER << " "
177 << pts[nNext][0].y + py2 * PWL_BEZIER << " " << pts[nNext][0].x << " "
178 << pts[nNext][0].y << " c\n";
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700179 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700180
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700181 return csAP.GetByteString();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700182}
183
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700184CFX_ByteString CPWL_Utils::GetAP_Circle(const CPDF_Rect& crBBox) {
185 CFX_ByteTextBuf csAP;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700186
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700187 FX_FLOAT fWidth = crBBox.right - crBBox.left;
188 FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700189
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700190 CPDF_Point pt1(crBBox.left, crBBox.bottom + fHeight / 2);
191 CPDF_Point pt2(crBBox.left + fWidth / 2, crBBox.top);
192 CPDF_Point pt3(crBBox.right, crBBox.bottom + fHeight / 2);
193 CPDF_Point pt4(crBBox.left + fWidth / 2, crBBox.bottom);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700194
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700195 csAP << pt1.x << " " << pt1.y << " m\n";
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700196
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700197 FX_FLOAT px = pt2.x - pt1.x;
198 FX_FLOAT py = pt2.y - pt1.y;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700199
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700200 csAP << pt1.x << " " << pt1.y + py * PWL_BEZIER << " "
201 << pt2.x - px * PWL_BEZIER << " " << pt2.y << " " << pt2.x << " "
202 << pt2.y << " c\n";
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700203
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700204 px = pt3.x - pt2.x;
205 py = pt2.y - pt3.y;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700206
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700207 csAP << pt2.x + px * PWL_BEZIER << " " << pt2.y << " " << pt3.x << " "
208 << pt3.y + py * PWL_BEZIER << " " << pt3.x << " " << pt3.y << " c\n";
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700209
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700210 px = pt3.x - pt4.x;
211 py = pt3.y - pt4.y;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700212
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700213 csAP << pt3.x << " " << pt3.y - py * PWL_BEZIER << " "
214 << pt4.x + px * PWL_BEZIER << " " << pt4.y << " " << pt4.x << " "
215 << pt4.y << " c\n";
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700216
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700217 px = pt4.x - pt1.x;
218 py = pt1.y - pt4.y;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700219
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700220 csAP << pt4.x - px * PWL_BEZIER << " " << pt4.y << " " << pt1.x << " "
221 << pt1.y - py * PWL_BEZIER << " " << pt1.x << " " << pt1.y << " c\n";
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700222
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700223 return csAP.GetByteString();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700224}
225
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700226CFX_ByteString CPWL_Utils::GetAP_Cross(const CPDF_Rect& crBBox) {
227 CFX_ByteTextBuf csAP;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700228
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700229 csAP << crBBox.left << " " << crBBox.top << " m\n";
230 csAP << crBBox.right << " " << crBBox.bottom << " l\n";
231 csAP << crBBox.left << " " << crBBox.bottom << " m\n";
232 csAP << crBBox.right << " " << crBBox.top << " l\n";
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700233
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700234 return csAP.GetByteString();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700235}
236
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700237CFX_ByteString CPWL_Utils::GetAP_Diamond(const CPDF_Rect& crBBox) {
238 CFX_ByteTextBuf csAP;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700239
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700240 FX_FLOAT fWidth = crBBox.right - crBBox.left;
241 FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700242
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700243 CPDF_Point pt1(crBBox.left, crBBox.bottom + fHeight / 2);
244 CPDF_Point pt2(crBBox.left + fWidth / 2, crBBox.top);
245 CPDF_Point pt3(crBBox.right, crBBox.bottom + fHeight / 2);
246 CPDF_Point pt4(crBBox.left + fWidth / 2, crBBox.bottom);
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700247
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700248 csAP << pt1.x << " " << pt1.y << " m\n";
249 csAP << pt2.x << " " << pt2.y << " l\n";
250 csAP << pt3.x << " " << pt3.y << " l\n";
251 csAP << pt4.x << " " << pt4.y << " l\n";
252 csAP << pt1.x << " " << pt1.y << " l\n";
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700253
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700254 return csAP.GetByteString();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700255}
256
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700257CFX_ByteString CPWL_Utils::GetAP_Square(const CPDF_Rect& crBBox) {
258 CFX_ByteTextBuf csAP;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700259
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700260 csAP << crBBox.left << " " << crBBox.top << " m\n";
261 csAP << crBBox.right << " " << crBBox.top << " l\n";
262 csAP << crBBox.right << " " << crBBox.bottom << " l\n";
263 csAP << crBBox.left << " " << crBBox.bottom << " l\n";
264 csAP << crBBox.left << " " << crBBox.top << " l\n";
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700265
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700266 return csAP.GetByteString();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700267}
268
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700269CFX_ByteString CPWL_Utils::GetAP_Star(const CPDF_Rect& crBBox) {
270 CFX_ByteTextBuf csAP;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700271
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700272 FX_FLOAT fRadius =
273 (crBBox.top - crBBox.bottom) / (1 + (FX_FLOAT)cos(PWL_PI / 5.0f));
274 CPDF_Point ptCenter = CPDF_Point((crBBox.left + crBBox.right) / 2.0f,
275 (crBBox.top + crBBox.bottom) / 2.0f);
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700276
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700277 FX_FLOAT px[5], py[5];
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700278
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700279 FX_FLOAT fAngel = PWL_PI / 10.0f;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700280
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700281 for (int32_t i = 0; i < 5; i++) {
282 px[i] = ptCenter.x + fRadius * (FX_FLOAT)cos(fAngel);
283 py[i] = ptCenter.y + fRadius * (FX_FLOAT)sin(fAngel);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700284
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700285 fAngel += PWL_PI * 2 / 5.0f;
286 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700287
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700288 csAP << px[0] << " " << py[0] << " m\n";
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700289
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700290 int32_t nNext = 0;
291 for (int32_t j = 0; j < 5; j++) {
292 nNext += 2;
293 if (nNext >= 5)
294 nNext -= 5;
295 csAP << px[nNext] << " " << py[nNext] << " l\n";
296 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700297
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700298 return csAP.GetByteString();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700299}
300
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700301CFX_ByteString CPWL_Utils::GetAP_HalfCircle(const CPDF_Rect& crBBox,
302 FX_FLOAT fRotate) {
303 CFX_ByteTextBuf csAP;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700304
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700305 FX_FLOAT fWidth = crBBox.right - crBBox.left;
306 FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700307
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700308 CPDF_Point pt1(-fWidth / 2, 0);
309 CPDF_Point pt2(0, fHeight / 2);
310 CPDF_Point pt3(fWidth / 2, 0);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700311
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700312 FX_FLOAT px, py;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700313
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700314 csAP << cos(fRotate) << " " << sin(fRotate) << " " << -sin(fRotate) << " "
315 << cos(fRotate) << " " << crBBox.left + fWidth / 2 << " "
316 << crBBox.bottom + fHeight / 2 << " cm\n";
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700317
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700318 csAP << pt1.x << " " << pt1.y << " m\n";
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700319
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700320 px = pt2.x - pt1.x;
321 py = pt2.y - pt1.y;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700322
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700323 csAP << pt1.x << " " << pt1.y + py * PWL_BEZIER << " "
324 << pt2.x - px * PWL_BEZIER << " " << pt2.y << " " << pt2.x << " "
325 << pt2.y << " c\n";
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700326
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700327 px = pt3.x - pt2.x;
328 py = pt2.y - pt3.y;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700329
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700330 csAP << pt2.x + px * PWL_BEZIER << " " << pt2.y << " " << pt3.x << " "
331 << pt3.y + py * PWL_BEZIER << " " << pt3.x << " " << pt3.y << " c\n";
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700332
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700333 return csAP.GetByteString();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700334}
335
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700336CPDF_Rect CPWL_Utils::InflateRect(const CPDF_Rect& rcRect, FX_FLOAT fSize) {
337 if (rcRect.IsEmpty())
338 return rcRect;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700339
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700340 CPDF_Rect rcNew(rcRect.left - fSize, rcRect.bottom - fSize,
341 rcRect.right + fSize, rcRect.top + fSize);
342 rcNew.Normalize();
343 return rcNew;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700344}
345
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700346CPDF_Rect CPWL_Utils::DeflateRect(const CPDF_Rect& rcRect, FX_FLOAT fSize) {
347 if (rcRect.IsEmpty())
348 return rcRect;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700349
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700350 CPDF_Rect rcNew(rcRect.left + fSize, rcRect.bottom + fSize,
351 rcRect.right - fSize, rcRect.top - fSize);
352 rcNew.Normalize();
353 return rcNew;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700354}
355
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700356CPDF_Rect CPWL_Utils::ScaleRect(const CPDF_Rect& rcRect, FX_FLOAT fScale) {
357 FX_FLOAT fHalfWidth = (rcRect.right - rcRect.left) / 2.0f;
358 FX_FLOAT fHalfHeight = (rcRect.top - rcRect.bottom) / 2.0f;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700359
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700360 CPDF_Point ptCenter = CPDF_Point((rcRect.left + rcRect.right) / 2,
361 (rcRect.top + rcRect.bottom) / 2);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700362
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700363 return CPDF_Rect(
364 ptCenter.x - fHalfWidth * fScale, ptCenter.y - fHalfHeight * fScale,
365 ptCenter.x + fHalfWidth * fScale, ptCenter.y + fHalfHeight * fScale);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700366}
367
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700368CFX_ByteString CPWL_Utils::GetRectFillAppStream(const CPDF_Rect& rect,
369 const CPWL_Color& color) {
370 CFX_ByteTextBuf sAppStream;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700371
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700372 CFX_ByteString sColor = GetColorAppStream(color, TRUE);
373 if (sColor.GetLength() > 0) {
374 sAppStream << "q\n" << sColor;
375 sAppStream << rect.left << " " << rect.bottom << " "
376 << rect.right - rect.left << " " << rect.top - rect.bottom
377 << " re f\nQ\n";
378 }
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700379
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700380 return sAppStream.GetByteString();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700381}
382
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700383CFX_ByteString CPWL_Utils::GetCircleFillAppStream(const CPDF_Rect& rect,
384 const CPWL_Color& color) {
385 CFX_ByteTextBuf sAppStream;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700386
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700387 CFX_ByteString sColor = GetColorAppStream(color, TRUE);
388 if (sColor.GetLength() > 0) {
389 sAppStream << "q\n" << sColor << CPWL_Utils::GetAP_Circle(rect) << "f\nQ\n";
390 }
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700391
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700392 return sAppStream.GetByteString();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700393}
394
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700395CPDF_Rect CPWL_Utils::GetCenterSquare(const CPDF_Rect& rect) {
396 FX_FLOAT fWidth = rect.right - rect.left;
397 FX_FLOAT fHeight = rect.top - rect.bottom;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700398
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700399 FX_FLOAT fCenterX = (rect.left + rect.right) / 2.0f;
400 FX_FLOAT fCenterY = (rect.top + rect.bottom) / 2.0f;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700401
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700402 FX_FLOAT fRadius = (fWidth > fHeight) ? fHeight / 2 : fWidth / 2;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700403
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700404 return CPDF_Rect(fCenterX - fRadius, fCenterY - fRadius, fCenterX + fRadius,
405 fCenterY + fRadius);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700406}
407
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700408CFX_ByteString CPWL_Utils::GetEditAppStream(IFX_Edit* pEdit,
409 const CPDF_Point& ptOffset,
410 const CPVT_WordRange* pRange,
411 FX_BOOL bContinuous,
412 FX_WORD SubWord) {
413 return IFX_Edit::GetEditAppearanceStream(pEdit, ptOffset, pRange, bContinuous,
414 SubWord);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700415}
416
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700417CFX_ByteString CPWL_Utils::GetEditSelAppStream(IFX_Edit* pEdit,
418 const CPDF_Point& ptOffset,
419 const CPVT_WordRange* pRange) {
420 return IFX_Edit::GetSelectAppearanceStream(pEdit, ptOffset, pRange);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700421}
422
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700423static CFX_ByteString GetSquigglyAppearanceStream(FX_FLOAT fStartX,
424 FX_FLOAT fEndX,
425 FX_FLOAT fY,
426 FX_FLOAT fStep) {
427 CFX_ByteTextBuf sRet;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700428
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700429 sRet << "0 w\n" << fStartX << " " << fY << " m\n";
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700430
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700431 FX_FLOAT fx;
432 int32_t i;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700433
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700434 for (i = 1, fx = fStartX + fStep; fx < fEndX; fx += fStep, i++) {
435 sRet << fx << " " << fY + (i & 1) * fStep << " l\n";
436 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700437
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700438 sRet << "S\n";
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700439
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700440 return sRet.GetByteString();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700441}
442
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700443static CFX_ByteString GetWordSpellCheckAppearanceStream(
444 IFX_Edit_Iterator* pIterator,
445 const CPDF_Point& ptOffset,
446 const CPVT_WordRange& wrWord) {
447 CFX_ByteTextBuf sRet;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700448
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700449 FX_FLOAT fStartX = 0.0f;
450 FX_FLOAT fEndX = 0.0f;
451 FX_FLOAT fY = 0.0f;
452 FX_FLOAT fStep = 0.0f;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700453
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700454 FX_BOOL bBreak = FALSE;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700455
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700456 if (pIterator) {
457 pIterator->SetAt(wrWord.BeginPos);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700458
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700459 do {
460 CPVT_WordPlace place = pIterator->GetAt();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700461
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700462 CPVT_Line line;
463 if (pIterator->GetLine(line)) {
464 fY = line.ptLine.y;
465 fStep = (line.fLineAscent - line.fLineDescent) / 16.0f;
466 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700467
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700468 if (place.LineCmp(wrWord.BeginPos) == 0) {
469 pIterator->SetAt(wrWord.BeginPos);
470 CPVT_Word word;
471 if (pIterator->GetWord(word)) {
472 fStartX = word.ptWord.x;
473 }
474 } else {
475 fStartX = line.ptLine.x;
476 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700477
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700478 if (place.LineCmp(wrWord.EndPos) == 0) {
479 pIterator->SetAt(wrWord.EndPos);
480 CPVT_Word word;
481 if (pIterator->GetWord(word)) {
482 fEndX = word.ptWord.x + word.fWidth;
483 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700484
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700485 bBreak = TRUE;
486 } else {
487 fEndX = line.ptLine.x + line.fLineWidth;
488 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700489
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700490 sRet << GetSquigglyAppearanceStream(
491 fStartX + ptOffset.x, fEndX + ptOffset.x, fY + ptOffset.y, fStep);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700492
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700493 if (bBreak)
494 break;
495 } while (pIterator->NextLine());
496 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700497
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700498 return sRet.GetByteString();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700499}
500
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700501CFX_ByteString CPWL_Utils::GetSpellCheckAppStream(
502 IFX_Edit* pEdit,
503 IPWL_SpellCheck* pSpellCheck,
504 const CPDF_Point& ptOffset,
505 const CPVT_WordRange* pRange) {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700506 CFX_ByteTextBuf sRet;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700507
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700508 if (pRange && pRange->IsExist()) {
509 if (IFX_Edit_Iterator* pIterator = pEdit->GetIterator()) {
510 pIterator->SetAt(pRange->BeginPos);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700511
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700512 FX_BOOL bLatinWord = FALSE;
513 CPVT_WordPlace wpWordStart;
514 CFX_ByteString sWord;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700515
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700516 CPVT_WordPlace oldplace;
517 while (pIterator->NextWord()) {
518 CPVT_WordPlace place = pIterator->GetAt();
519 if (pRange && place.WordCmp(pRange->EndPos) > 0)
520 break;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700521
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700522 CPVT_Word word;
523 if (pIterator->GetWord(word)) {
524 if (FX_EDIT_ISLATINWORD(word.Word)) {
525 if (!bLatinWord) {
526 wpWordStart = place;
527 bLatinWord = TRUE;
528 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700529
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700530 sWord += (char)word.Word;
531 oldplace = place;
532 } else {
533 if (bLatinWord) {
534 if (!pSpellCheck->CheckWord(sWord)) {
535 sRet << GetWordSpellCheckAppearanceStream(
536 pIterator, ptOffset, CPVT_WordRange(wpWordStart, oldplace));
537 pIterator->SetAt(place);
538 }
539 bLatinWord = FALSE;
540 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700541
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700542 sWord.Empty();
543 }
544 } else {
545 if (bLatinWord) {
546 if (!pSpellCheck->CheckWord(sWord))
547 sRet << GetWordSpellCheckAppearanceStream(
548 pIterator, ptOffset, CPVT_WordRange(wpWordStart, oldplace));
549 bLatinWord = FALSE;
550 sWord.Empty();
551 }
552 }
553 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700554
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700555 if (bLatinWord) {
556 if (!pSpellCheck->CheckWord(sWord))
557 sRet << GetWordSpellCheckAppearanceStream(
558 pIterator, ptOffset, CPVT_WordRange(wpWordStart, oldplace));
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700559
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700560 bLatinWord = FALSE;
561 sWord.Empty();
562 }
563 }
564 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700565
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700566 return sRet.GetByteString();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700567}
568
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700569CFX_ByteString CPWL_Utils::GetTextAppStream(const CPDF_Rect& rcBBox,
570 IFX_Edit_FontMap* pFontMap,
571 const CFX_WideString& sText,
572 int32_t nAlignmentH,
573 int32_t nAlignmentV,
574 FX_FLOAT fFontSize,
575 FX_BOOL bMultiLine,
576 FX_BOOL bAutoReturn,
577 const CPWL_Color& crText) {
578 CFX_ByteTextBuf sRet;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700579
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700580 if (IFX_Edit* pEdit = IFX_Edit::NewEdit()) {
581 pEdit->SetFontMap(pFontMap);
582 pEdit->SetPlateRect(rcBBox);
583 pEdit->SetAlignmentH(nAlignmentH);
584 pEdit->SetAlignmentV(nAlignmentV);
585 pEdit->SetMultiLine(bMultiLine);
586 pEdit->SetAutoReturn(bAutoReturn);
587 if (IsFloatZero(fFontSize))
588 pEdit->SetAutoFontSize(TRUE);
589 else
590 pEdit->SetFontSize(fFontSize);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700591
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700592 pEdit->Initialize();
593 pEdit->SetText(sText.c_str());
Tom Sepez4f7bc042015-04-27 12:06:58 -0700594
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700595 CFX_ByteString sEdit =
596 CPWL_Utils::GetEditAppStream(pEdit, CPDF_Point(0.0f, 0.0f));
597 if (sEdit.GetLength() > 0) {
598 sRet << "BT\n" << CPWL_Utils::GetColorAppStream(crText) << sEdit
599 << "ET\n";
600 }
601 IFX_Edit::DelEdit(pEdit);
602 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700603
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700604 return sRet.GetByteString();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700605}
606
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700607CFX_ByteString CPWL_Utils::GetPushButtonAppStream(const CPDF_Rect& rcBBox,
608 IFX_Edit_FontMap* pFontMap,
609 CPDF_Stream* pIconStream,
610 CPDF_IconFit& IconFit,
611 const CFX_WideString& sLabel,
612 const CPWL_Color& crText,
613 FX_FLOAT fFontSize,
614 int32_t nLayOut) {
615 const FX_FLOAT fAutoFontScale = 1.0f / 3.0f;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700616
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700617 if (IFX_Edit* pEdit = IFX_Edit::NewEdit()) {
618 pEdit->SetFontMap(pFontMap);
619 pEdit->SetAlignmentH(1);
620 pEdit->SetAlignmentV(1);
621 pEdit->SetMultiLine(FALSE);
622 pEdit->SetAutoReturn(FALSE);
623 if (IsFloatZero(fFontSize))
624 pEdit->SetAutoFontSize(TRUE);
625 else
626 pEdit->SetFontSize(fFontSize);
Tom Sepez4f7bc042015-04-27 12:06:58 -0700627
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700628 pEdit->Initialize();
629 pEdit->SetText(sLabel.c_str());
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700630
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700631 CPDF_Rect rcLabelContent = pEdit->GetContentRect();
632 CPWL_Icon Icon;
633 PWL_CREATEPARAM cp;
634 cp.dwFlags = PWS_VISIBLE;
635 Icon.Create(cp);
636 Icon.SetIconFit(&IconFit);
637 Icon.SetPDFStream(pIconStream);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700638
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700639 CPDF_Rect rcLabel = CPDF_Rect(0, 0, 0, 0);
640 CPDF_Rect rcIcon = CPDF_Rect(0, 0, 0, 0);
641 FX_FLOAT fWidth = 0.0f;
642 FX_FLOAT fHeight = 0.0f;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700643
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700644 switch (nLayOut) {
645 case PPBL_LABEL:
646 rcLabel = rcBBox;
647 rcIcon = CPDF_Rect(0, 0, 0, 0);
648 break;
649 case PPBL_ICON:
650 rcIcon = rcBBox;
651 rcLabel = CPDF_Rect(0, 0, 0, 0);
652 break;
653 case PPBL_ICONTOPLABELBOTTOM:
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700654
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700655 if (pIconStream) {
656 if (IsFloatZero(fFontSize)) {
657 fHeight = rcBBox.top - rcBBox.bottom;
658 rcLabel = CPDF_Rect(rcBBox.left, rcBBox.bottom, rcBBox.right,
659 rcBBox.bottom + fHeight * fAutoFontScale);
660 rcIcon =
661 CPDF_Rect(rcBBox.left, rcLabel.top, rcBBox.right, rcBBox.top);
662 } else {
663 fHeight = rcLabelContent.Height();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700664
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700665 if (rcBBox.bottom + fHeight > rcBBox.top) {
666 rcIcon = CPDF_Rect(0, 0, 0, 0);
667 rcLabel = rcBBox;
668 } else {
669 rcLabel = CPDF_Rect(rcBBox.left, rcBBox.bottom, rcBBox.right,
670 rcBBox.bottom + fHeight);
671 rcIcon =
672 CPDF_Rect(rcBBox.left, rcLabel.top, rcBBox.right, rcBBox.top);
673 }
674 }
675 } else {
676 rcLabel = rcBBox;
677 rcIcon = CPDF_Rect(0, 0, 0, 0);
678 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700679
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700680 break;
681 case PPBL_LABELTOPICONBOTTOM:
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700682
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700683 if (pIconStream) {
684 if (IsFloatZero(fFontSize)) {
685 fHeight = rcBBox.top - rcBBox.bottom;
686 rcLabel =
687 CPDF_Rect(rcBBox.left, rcBBox.top - fHeight * fAutoFontScale,
688 rcBBox.right, rcBBox.top);
689 rcIcon = CPDF_Rect(rcBBox.left, rcBBox.bottom, rcBBox.right,
690 rcLabel.bottom);
691 } else {
692 fHeight = rcLabelContent.Height();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700693
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700694 if (rcBBox.bottom + fHeight > rcBBox.top) {
695 rcIcon = CPDF_Rect(0, 0, 0, 0);
696 rcLabel = rcBBox;
697 } else {
698 rcLabel = CPDF_Rect(rcBBox.left, rcBBox.top - fHeight,
699 rcBBox.right, rcBBox.top);
700 rcIcon = CPDF_Rect(rcBBox.left, rcBBox.bottom, rcBBox.right,
701 rcLabel.bottom);
702 }
703 }
704 } else {
705 rcLabel = rcBBox;
706 rcIcon = CPDF_Rect(0, 0, 0, 0);
707 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700708
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700709 break;
710 case PPBL_ICONLEFTLABELRIGHT:
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700711
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700712 if (pIconStream) {
713 if (IsFloatZero(fFontSize)) {
714 fWidth = rcBBox.right - rcBBox.left;
715 rcLabel = CPDF_Rect(rcBBox.right - fWidth * fAutoFontScale,
716 rcBBox.bottom, rcBBox.right, rcBBox.top);
717 rcIcon =
718 CPDF_Rect(rcBBox.left, rcBBox.bottom, rcLabel.left, rcBBox.top);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700719
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700720 if (rcLabelContent.Width() < fWidth * fAutoFontScale) {
721 } else {
722 if (rcLabelContent.Width() < fWidth) {
723 rcLabel = CPDF_Rect(rcBBox.right - rcLabelContent.Width(),
724 rcBBox.bottom, rcBBox.right, rcBBox.top);
725 rcIcon = CPDF_Rect(rcBBox.left, rcBBox.bottom, rcLabel.left,
726 rcBBox.top);
727 } else {
728 rcLabel = rcBBox;
729 rcIcon = CPDF_Rect(0, 0, 0, 0);
730 }
731 }
732 } else {
733 fWidth = rcLabelContent.Width();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700734
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700735 if (rcBBox.left + fWidth > rcBBox.right) {
736 rcLabel = rcBBox;
737 rcIcon = CPDF_Rect(0, 0, 0, 0);
738 } else {
739 rcLabel = CPDF_Rect(rcBBox.right - fWidth, rcBBox.bottom,
740 rcBBox.right, rcBBox.top);
741 rcIcon = CPDF_Rect(rcBBox.left, rcBBox.bottom, rcLabel.left,
742 rcBBox.top);
743 }
744 }
745 } else {
746 rcLabel = rcBBox;
747 rcIcon = CPDF_Rect(0, 0, 0, 0);
748 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700749
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700750 break;
751 case PPBL_LABELLEFTICONRIGHT:
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700752
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700753 if (pIconStream) {
754 if (IsFloatZero(fFontSize)) {
755 fWidth = rcBBox.right - rcBBox.left;
756 rcLabel =
757 CPDF_Rect(rcBBox.left, rcBBox.bottom,
758 rcBBox.left + fWidth * fAutoFontScale, rcBBox.top);
759 rcIcon = CPDF_Rect(rcLabel.right, rcBBox.bottom, rcBBox.right,
760 rcBBox.top);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700761
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700762 if (rcLabelContent.Width() < fWidth * fAutoFontScale) {
763 } else {
764 if (rcLabelContent.Width() < fWidth) {
765 rcLabel =
766 CPDF_Rect(rcBBox.left, rcBBox.bottom,
767 rcBBox.left + rcLabelContent.Width(), rcBBox.top);
768 rcIcon = CPDF_Rect(rcLabel.right, rcBBox.bottom, rcBBox.right,
769 rcBBox.top);
770 } else {
771 rcLabel = rcBBox;
772 rcIcon = CPDF_Rect(0, 0, 0, 0);
773 }
774 }
775 } else {
776 fWidth = rcLabelContent.Width();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700777
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700778 if (rcBBox.left + fWidth > rcBBox.right) {
779 rcLabel = rcBBox;
780 rcIcon = CPDF_Rect(0, 0, 0, 0);
781 } else {
782 rcLabel = CPDF_Rect(rcBBox.left, rcBBox.bottom,
783 rcBBox.left + fWidth, rcBBox.top);
784 rcIcon = CPDF_Rect(rcLabel.right, rcBBox.bottom, rcBBox.right,
785 rcBBox.top);
786 }
787 }
788 } else {
789 rcLabel = rcBBox;
790 rcIcon = CPDF_Rect(0, 0, 0, 0);
791 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700792
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700793 break;
794 case PPBL_LABELOVERICON:
795 rcLabel = rcBBox;
796 rcIcon = rcBBox;
797 break;
798 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700799
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700800 CFX_ByteTextBuf sAppStream, sTemp;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700801
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700802 if (!rcIcon.IsEmpty()) {
803 Icon.Move(rcIcon, FALSE, FALSE);
804 sTemp << Icon.GetImageAppStream();
805 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700806
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700807 Icon.Destroy();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700808
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700809 if (!rcLabel.IsEmpty()) {
810 pEdit->SetPlateRect(rcLabel);
811 CFX_ByteString sEdit =
812 CPWL_Utils::GetEditAppStream(pEdit, CPDF_Point(0.0f, 0.0f));
813 if (sEdit.GetLength() > 0) {
814 sTemp << "BT\n" << CPWL_Utils::GetColorAppStream(crText) << sEdit
815 << "ET\n";
816 }
817 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700818
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700819 IFX_Edit::DelEdit(pEdit);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700820
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700821 if (sTemp.GetSize() > 0) {
822 sAppStream << "q\n" << rcBBox.left << " " << rcBBox.bottom << " "
823 << rcBBox.right - rcBBox.left << " "
824 << rcBBox.top - rcBBox.bottom << " re W n\n";
825 sAppStream << sTemp << "Q\n";
826 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700827
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700828 return sAppStream.GetByteString();
829 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700830
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700831 return "";
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700832}
833
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700834CFX_ByteString CPWL_Utils::GetColorAppStream(const CPWL_Color& color,
835 const FX_BOOL& bFillOrStroke) {
836 CFX_ByteTextBuf sColorStream;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700837
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700838 switch (color.nColorType) {
839 case COLORTYPE_RGB:
840 sColorStream << color.fColor1 << " " << color.fColor2 << " "
841 << color.fColor3 << " " << (bFillOrStroke ? "rg" : "RG")
842 << "\n";
843 break;
844 case COLORTYPE_GRAY:
845 sColorStream << color.fColor1 << " " << (bFillOrStroke ? "g" : "G")
846 << "\n";
847 break;
848 case COLORTYPE_CMYK:
849 sColorStream << color.fColor1 << " " << color.fColor2 << " "
850 << color.fColor3 << " " << color.fColor4 << " "
851 << (bFillOrStroke ? "k" : "K") << "\n";
852 break;
853 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700854
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700855 return sColorStream.GetByteString();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700856}
857
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700858CFX_ByteString CPWL_Utils::GetBorderAppStream(const CPDF_Rect& rect,
859 FX_FLOAT fWidth,
860 const CPWL_Color& color,
861 const CPWL_Color& crLeftTop,
862 const CPWL_Color& crRightBottom,
863 int32_t nStyle,
864 const CPWL_Dash& dash) {
865 CFX_ByteTextBuf sAppStream;
866 CFX_ByteString sColor;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700867
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700868 FX_FLOAT fLeft = rect.left;
869 FX_FLOAT fRight = rect.right;
870 FX_FLOAT fTop = rect.top;
871 FX_FLOAT fBottom = rect.bottom;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700872
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700873 if (fWidth > 0.0f) {
874 FX_FLOAT fHalfWidth = fWidth / 2.0f;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700875
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700876 sAppStream << "q\n";
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700877
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700878 switch (nStyle) {
879 default:
880 case PBS_SOLID:
881 sColor = CPWL_Utils::GetColorAppStream(color, TRUE);
882 if (sColor.GetLength() > 0) {
883 sAppStream << sColor;
884 sAppStream << fLeft << " " << fBottom << " " << fRight - fLeft << " "
885 << fTop - fBottom << " re\n";
886 sAppStream << fLeft + fWidth << " " << fBottom + fWidth << " "
887 << fRight - fLeft - fWidth * 2 << " "
888 << fTop - fBottom - fWidth * 2 << " re\n";
889 sAppStream << "f*\n";
890 }
891 break;
892 case PBS_DASH:
893 sColor = CPWL_Utils::GetColorAppStream(color, FALSE);
894 if (sColor.GetLength() > 0) {
895 sAppStream << sColor;
896 sAppStream << fWidth << " w"
897 << " [" << dash.nDash << " " << dash.nGap << "] "
898 << dash.nPhase << " d\n";
899 sAppStream << fLeft + fWidth / 2 << " " << fBottom + fWidth / 2
900 << " m\n";
901 sAppStream << fLeft + fWidth / 2 << " " << fTop - fWidth / 2
902 << " l\n";
903 sAppStream << fRight - fWidth / 2 << " " << fTop - fWidth / 2
904 << " l\n";
905 sAppStream << fRight - fWidth / 2 << " " << fBottom + fWidth / 2
906 << " l\n";
907 sAppStream << fLeft + fWidth / 2 << " " << fBottom + fWidth / 2
908 << " l S\n";
909 }
910 break;
911 case PBS_BEVELED:
912 case PBS_INSET:
913 sColor = CPWL_Utils::GetColorAppStream(crLeftTop, TRUE);
914 if (sColor.GetLength() > 0) {
915 sAppStream << sColor;
916 sAppStream << fLeft + fHalfWidth << " " << fBottom + fHalfWidth
917 << " m\n";
918 sAppStream << fLeft + fHalfWidth << " " << fTop - fHalfWidth
919 << " l\n";
920 sAppStream << fRight - fHalfWidth << " " << fTop - fHalfWidth
921 << " l\n";
922 sAppStream << fRight - fHalfWidth * 2 << " " << fTop - fHalfWidth * 2
923 << " l\n";
924 sAppStream << fLeft + fHalfWidth * 2 << " " << fTop - fHalfWidth * 2
925 << " l\n";
926 sAppStream << fLeft + fHalfWidth * 2 << " "
927 << fBottom + fHalfWidth * 2 << " l f\n";
928 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700929
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700930 sColor = CPWL_Utils::GetColorAppStream(crRightBottom, TRUE);
931 if (sColor.GetLength() > 0) {
932 sAppStream << sColor;
933 sAppStream << fRight - fHalfWidth << " " << fTop - fHalfWidth
934 << " m\n";
935 sAppStream << fRight - fHalfWidth << " " << fBottom + fHalfWidth
936 << " l\n";
937 sAppStream << fLeft + fHalfWidth << " " << fBottom + fHalfWidth
938 << " l\n";
939 sAppStream << fLeft + fHalfWidth * 2 << " "
940 << fBottom + fHalfWidth * 2 << " l\n";
941 sAppStream << fRight - fHalfWidth * 2 << " "
942 << fBottom + fHalfWidth * 2 << " l\n";
943 sAppStream << fRight - fHalfWidth * 2 << " " << fTop - fHalfWidth * 2
944 << " l f\n";
945 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700946
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700947 sColor = CPWL_Utils::GetColorAppStream(color, TRUE);
948 if (sColor.GetLength() > 0) {
949 sAppStream << sColor;
950 sAppStream << fLeft << " " << fBottom << " " << fRight - fLeft << " "
951 << fTop - fBottom << " re\n";
952 sAppStream << fLeft + fHalfWidth << " " << fBottom + fHalfWidth << " "
953 << fRight - fLeft - fHalfWidth * 2 << " "
954 << fTop - fBottom - fHalfWidth * 2 << " re f*\n";
955 }
956 break;
957 case PBS_UNDERLINED:
958 sColor = CPWL_Utils::GetColorAppStream(color, FALSE);
959 if (sColor.GetLength() > 0) {
960 sAppStream << sColor;
961 sAppStream << fWidth << " w\n";
962 sAppStream << fLeft << " " << fBottom + fWidth / 2 << " m\n";
963 sAppStream << fRight << " " << fBottom + fWidth / 2 << " l S\n";
964 }
965 break;
966 }
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700967
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700968 sAppStream << "Q\n";
969 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700970
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700971 return sAppStream.GetByteString();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700972}
973
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700974CFX_ByteString CPWL_Utils::GetCircleBorderAppStream(
975 const CPDF_Rect& rect,
976 FX_FLOAT fWidth,
977 const CPWL_Color& color,
978 const CPWL_Color& crLeftTop,
979 const CPWL_Color& crRightBottom,
980 int32_t nStyle,
981 const CPWL_Dash& dash) {
982 CFX_ByteTextBuf sAppStream;
983 CFX_ByteString sColor;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700984
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700985 if (fWidth > 0.0f) {
986 sAppStream << "q\n";
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700987
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700988 switch (nStyle) {
989 default:
990 case PBS_SOLID:
991 case PBS_UNDERLINED: {
992 sColor = CPWL_Utils::GetColorAppStream(color, FALSE);
993 if (sColor.GetLength() > 0) {
994 sAppStream << "q\n" << fWidth << " w\n" << sColor
995 << CPWL_Utils::GetAP_Circle(
996 CPWL_Utils::DeflateRect(rect, fWidth / 2.0f))
997 << " S\nQ\n";
998 }
999 } break;
1000 case PBS_DASH: {
1001 sColor = CPWL_Utils::GetColorAppStream(color, FALSE);
1002 if (sColor.GetLength() > 0) {
1003 sAppStream << "q\n" << fWidth << " w\n"
1004 << "[" << dash.nDash << " " << dash.nGap << "] "
1005 << dash.nPhase << " d\n" << sColor
1006 << CPWL_Utils::GetAP_Circle(
1007 CPWL_Utils::DeflateRect(rect, fWidth / 2.0f))
1008 << " S\nQ\n";
1009 }
1010 } break;
1011 case PBS_BEVELED: {
1012 FX_FLOAT fHalfWidth = fWidth / 2.0f;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001013
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001014 sColor = CPWL_Utils::GetColorAppStream(color, FALSE);
1015 if (sColor.GetLength() > 0) {
1016 sAppStream << "q\n" << fHalfWidth << " w\n" << sColor
1017 << CPWL_Utils::GetAP_Circle(rect) << " S\nQ\n";
1018 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001019
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001020 sColor = CPWL_Utils::GetColorAppStream(crLeftTop, FALSE);
1021 if (sColor.GetLength() > 0) {
1022 sAppStream << "q\n" << fHalfWidth << " w\n" << sColor
1023 << CPWL_Utils::GetAP_HalfCircle(
1024 CPWL_Utils::DeflateRect(rect, fHalfWidth * 0.75f),
1025 PWL_PI / 4.0f)
1026 << " S\nQ\n";
1027 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001028
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001029 sColor = CPWL_Utils::GetColorAppStream(crRightBottom, FALSE);
1030 if (sColor.GetLength() > 0) {
1031 sAppStream << "q\n" << fHalfWidth << " w\n" << sColor
1032 << CPWL_Utils::GetAP_HalfCircle(
1033 CPWL_Utils::DeflateRect(rect, fHalfWidth * 0.75f),
1034 PWL_PI * 5 / 4.0f)
1035 << " S\nQ\n";
1036 }
1037 } break;
1038 case PBS_INSET: {
1039 FX_FLOAT fHalfWidth = fWidth / 2.0f;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001040
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001041 sColor = CPWL_Utils::GetColorAppStream(color, FALSE);
1042 if (sColor.GetLength() > 0) {
1043 sAppStream << "q\n" << fHalfWidth << " w\n" << sColor
1044 << CPWL_Utils::GetAP_Circle(rect) << " S\nQ\n";
1045 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001046
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001047 sColor = CPWL_Utils::GetColorAppStream(crLeftTop, FALSE);
1048 if (sColor.GetLength() > 0) {
1049 sAppStream << "q\n" << fHalfWidth << " w\n" << sColor
1050 << CPWL_Utils::GetAP_HalfCircle(
1051 CPWL_Utils::DeflateRect(rect, fHalfWidth * 0.75f),
1052 PWL_PI / 4.0f)
1053 << " S\nQ\n";
1054 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001055
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001056 sColor = CPWL_Utils::GetColorAppStream(crRightBottom, FALSE);
1057 if (sColor.GetLength() > 0) {
1058 sAppStream << "q\n" << fHalfWidth << " w\n" << sColor
1059 << CPWL_Utils::GetAP_HalfCircle(
1060 CPWL_Utils::DeflateRect(rect, fHalfWidth * 0.75f),
1061 PWL_PI * 5 / 4.0f)
1062 << " S\nQ\n";
1063 }
1064 } break;
1065 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001066
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001067 sAppStream << "Q\n";
1068 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001069
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001070 return sAppStream.GetByteString();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001071}
1072
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001073CPWL_Color CPWL_Utils::SubstractColor(const CPWL_Color& sColor,
1074 FX_FLOAT fColorSub) {
1075 CPWL_Color sRet;
1076 sRet.nColorType = sColor.nColorType;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001077
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001078 switch (sColor.nColorType) {
1079 case COLORTYPE_TRANSPARENT:
1080 sRet.nColorType = COLORTYPE_RGB;
1081 sRet.fColor1 = PWL_MAX(1 - fColorSub, 0.0f);
1082 sRet.fColor2 = PWL_MAX(1 - fColorSub, 0.0f);
1083 sRet.fColor3 = PWL_MAX(1 - fColorSub, 0.0f);
1084 break;
1085 case COLORTYPE_RGB:
1086 case COLORTYPE_GRAY:
1087 case COLORTYPE_CMYK:
1088 sRet.fColor1 = PWL_MAX(sColor.fColor1 - fColorSub, 0.0f);
1089 sRet.fColor2 = PWL_MAX(sColor.fColor2 - fColorSub, 0.0f);
1090 sRet.fColor3 = PWL_MAX(sColor.fColor3 - fColorSub, 0.0f);
1091 sRet.fColor4 = PWL_MAX(sColor.fColor4 - fColorSub, 0.0f);
1092 break;
1093 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001094
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001095 return sRet;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001096}
1097
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001098CPWL_Color CPWL_Utils::DevideColor(const CPWL_Color& sColor,
1099 FX_FLOAT fColorDevide) {
1100 CPWL_Color sRet;
1101 sRet.nColorType = sColor.nColorType;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001102
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001103 switch (sColor.nColorType) {
1104 case COLORTYPE_TRANSPARENT:
1105 sRet.nColorType = COLORTYPE_RGB;
1106 sRet.fColor1 = 1 / fColorDevide;
1107 sRet.fColor2 = 1 / fColorDevide;
1108 sRet.fColor3 = 1 / fColorDevide;
1109 break;
1110 case COLORTYPE_RGB:
1111 case COLORTYPE_GRAY:
1112 case COLORTYPE_CMYK:
1113 sRet = sColor;
1114 sRet.fColor1 /= fColorDevide;
1115 sRet.fColor2 /= fColorDevide;
1116 sRet.fColor3 /= fColorDevide;
1117 sRet.fColor4 /= fColorDevide;
1118 break;
1119 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001120
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001121 return sRet;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001122}
1123
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001124CFX_ByteString CPWL_Utils::GetAppStream_Check(const CPDF_Rect& rcBBox,
1125 const CPWL_Color& crText) {
1126 CFX_ByteTextBuf sAP;
1127 sAP << "q\n" << CPWL_Utils::GetColorAppStream(crText, TRUE)
1128 << CPWL_Utils::GetAP_Check(rcBBox) << "f\nQ\n";
1129 return sAP.GetByteString();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001130}
1131
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001132CFX_ByteString CPWL_Utils::GetAppStream_Circle(const CPDF_Rect& rcBBox,
1133 const CPWL_Color& crText) {
1134 CFX_ByteTextBuf sAP;
1135 sAP << "q\n" << CPWL_Utils::GetColorAppStream(crText, TRUE)
1136 << CPWL_Utils::GetAP_Circle(rcBBox) << "f\nQ\n";
1137 return sAP.GetByteString();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001138}
1139
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001140CFX_ByteString CPWL_Utils::GetAppStream_Cross(const CPDF_Rect& rcBBox,
1141 const CPWL_Color& crText) {
1142 CFX_ByteTextBuf sAP;
1143 sAP << "q\n" << CPWL_Utils::GetColorAppStream(crText, FALSE)
1144 << CPWL_Utils::GetAP_Cross(rcBBox) << "S\nQ\n";
1145 return sAP.GetByteString();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001146}
1147
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001148CFX_ByteString CPWL_Utils::GetAppStream_Diamond(const CPDF_Rect& rcBBox,
1149 const CPWL_Color& crText) {
1150 CFX_ByteTextBuf sAP;
1151 sAP << "q\n1 w\n" << CPWL_Utils::GetColorAppStream(crText, TRUE)
1152 << CPWL_Utils::GetAP_Diamond(rcBBox) << "f\nQ\n";
1153 return sAP.GetByteString();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001154}
1155
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001156CFX_ByteString CPWL_Utils::GetAppStream_Square(const CPDF_Rect& rcBBox,
1157 const CPWL_Color& crText) {
1158 CFX_ByteTextBuf sAP;
1159 sAP << "q\n" << CPWL_Utils::GetColorAppStream(crText, TRUE)
1160 << CPWL_Utils::GetAP_Square(rcBBox) << "f\nQ\n";
1161 return sAP.GetByteString();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001162}
1163
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001164CFX_ByteString CPWL_Utils::GetAppStream_Star(const CPDF_Rect& rcBBox,
1165 const CPWL_Color& crText) {
1166 CFX_ByteTextBuf sAP;
1167 sAP << "q\n" << CPWL_Utils::GetColorAppStream(crText, TRUE)
1168 << CPWL_Utils::GetAP_Star(rcBBox) << "f\nQ\n";
1169 return sAP.GetByteString();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001170}
1171
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001172CFX_ByteString CPWL_Utils::GetCheckBoxAppStream(const CPDF_Rect& rcBBox,
1173 int32_t nStyle,
1174 const CPWL_Color& crText) {
1175 CPDF_Rect rcCenter = GetCenterSquare(rcBBox);
1176 switch (nStyle) {
1177 default:
1178 case PCS_CHECK:
1179 return GetAppStream_Check(rcCenter, crText);
1180 case PCS_CIRCLE:
1181 return GetAppStream_Circle(ScaleRect(rcCenter, 2.0f / 3.0f), crText);
1182 case PCS_CROSS:
1183 return GetAppStream_Cross(rcCenter, crText);
1184 case PCS_DIAMOND:
1185 return GetAppStream_Diamond(ScaleRect(rcCenter, 2.0f / 3.0f), crText);
1186 case PCS_SQUARE:
1187 return GetAppStream_Square(ScaleRect(rcCenter, 2.0f / 3.0f), crText);
1188 case PCS_STAR:
1189 return GetAppStream_Star(ScaleRect(rcCenter, 2.0f / 3.0f), crText);
1190 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001191}
1192
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001193CFX_ByteString CPWL_Utils::GetRadioButtonAppStream(const CPDF_Rect& rcBBox,
1194 int32_t nStyle,
1195 const CPWL_Color& crText) {
1196 CPDF_Rect rcCenter = GetCenterSquare(rcBBox);
1197 switch (nStyle) {
1198 default:
1199 case PCS_CHECK:
1200 return GetAppStream_Check(rcCenter, crText);
1201 case PCS_CIRCLE:
1202 return GetAppStream_Circle(ScaleRect(rcCenter, 1.0f / 2.0f), crText);
1203 case PCS_CROSS:
1204 return GetAppStream_Cross(rcCenter, crText);
1205 case PCS_DIAMOND:
1206 return GetAppStream_Diamond(ScaleRect(rcCenter, 2.0f / 3.0f), crText);
1207 case PCS_SQUARE:
1208 return GetAppStream_Square(ScaleRect(rcCenter, 2.0f / 3.0f), crText);
1209 case PCS_STAR:
1210 return GetAppStream_Star(ScaleRect(rcCenter, 2.0f / 3.0f), crText);
1211 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001212}
1213
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001214CFX_ByteString CPWL_Utils::GetDropButtonAppStream(const CPDF_Rect& rcBBox) {
1215 CFX_ByteTextBuf sAppStream;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001216
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001217 if (!rcBBox.IsEmpty()) {
1218 sAppStream << "q\n" << CPWL_Utils::GetColorAppStream(
1219 CPWL_Color(COLORTYPE_RGB, 220.0f / 255.0f,
1220 220.0f / 255.0f, 220.0f / 255.0f),
1221 TRUE);
1222 sAppStream << rcBBox.left << " " << rcBBox.bottom << " "
1223 << rcBBox.right - rcBBox.left << " "
1224 << rcBBox.top - rcBBox.bottom << " re f\n";
1225 sAppStream << "Q\n";
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001226
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001227 sAppStream << "q\n" << CPWL_Utils::GetBorderAppStream(
1228 rcBBox, 2, CPWL_Color(COLORTYPE_GRAY, 0),
1229 CPWL_Color(COLORTYPE_GRAY, 1),
1230 CPWL_Color(COLORTYPE_GRAY, 0.5), PBS_BEVELED,
1231 CPWL_Dash(3, 0, 0))
1232 << "Q\n";
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001233
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001234 CPDF_Point ptCenter = CPDF_Point((rcBBox.left + rcBBox.right) / 2,
1235 (rcBBox.top + rcBBox.bottom) / 2);
1236 if (IsFloatBigger(rcBBox.right - rcBBox.left, 6) &&
1237 IsFloatBigger(rcBBox.top - rcBBox.bottom, 6)) {
1238 sAppStream << "q\n"
1239 << " 0 g\n";
1240 sAppStream << ptCenter.x - 3 << " " << ptCenter.y + 1.5f << " m\n";
1241 sAppStream << ptCenter.x + 3 << " " << ptCenter.y + 1.5f << " l\n";
1242 sAppStream << ptCenter.x << " " << ptCenter.y - 1.5f << " l\n";
1243 sAppStream << ptCenter.x - 3 << " " << ptCenter.y + 1.5f << " l f\n";
1244 sAppStream << "Q\n";
1245 }
1246 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001247
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001248 return sAppStream.GetByteString();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001249}
1250
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001251void CPWL_Utils::ConvertCMYK2GRAY(FX_FLOAT dC,
1252 FX_FLOAT dM,
1253 FX_FLOAT dY,
1254 FX_FLOAT dK,
1255 FX_FLOAT& dGray) {
1256 if (dC < 0 || dC > 1 || dM < 0 || dM > 1 || dY < 0 || dY > 1 || dK < 0 ||
1257 dK > 1)
1258 return;
1259 dGray = 1.0f - FX_MIN(1.0f, 0.3f * dC + 0.59f * dM + 0.11f * dY + dK);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001260}
1261
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001262void CPWL_Utils::ConvertGRAY2CMYK(FX_FLOAT dGray,
1263 FX_FLOAT& dC,
1264 FX_FLOAT& dM,
1265 FX_FLOAT& dY,
1266 FX_FLOAT& dK) {
1267 if (dGray < 0 || dGray > 1)
1268 return;
1269 dC = 0.0f;
1270 dM = 0.0f;
1271 dY = 0.0f;
1272 dK = 1.0f - dGray;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001273}
1274
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001275void CPWL_Utils::ConvertGRAY2RGB(FX_FLOAT dGray,
1276 FX_FLOAT& dR,
1277 FX_FLOAT& dG,
1278 FX_FLOAT& dB) {
1279 if (dGray < 0 || dGray > 1)
1280 return;
1281 dR = dGray;
1282 dG = dGray;
1283 dB = dGray;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001284}
1285
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001286void CPWL_Utils::ConvertRGB2GRAY(FX_FLOAT dR,
1287 FX_FLOAT dG,
1288 FX_FLOAT dB,
1289 FX_FLOAT& dGray) {
1290 if (dR < 0 || dR > 1 || dG < 0 || dG > 0 || dB < 0 || dB > 1)
1291 return;
1292 dGray = 0.3f * dR + 0.59f * dG + 0.11f * dB;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001293}
1294
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001295void CPWL_Utils::ConvertCMYK2RGB(FX_FLOAT dC,
1296 FX_FLOAT dM,
1297 FX_FLOAT dY,
1298 FX_FLOAT dK,
1299 FX_FLOAT& dR,
1300 FX_FLOAT& dG,
1301 FX_FLOAT& dB) {
1302 if (dC < 0 || dC > 1 || dM < 0 || dM > 1 || dY < 0 || dY > 1 || dK < 0 ||
1303 dK > 1)
1304 return;
1305 dR = 1.0f - FX_MIN(1.0f, dC + dK);
1306 dG = 1.0f - FX_MIN(1.0f, dM + dK);
1307 dB = 1.0f - FX_MIN(1.0f, dY + dK);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001308}
1309
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001310void CPWL_Utils::ConvertRGB2CMYK(FX_FLOAT dR,
1311 FX_FLOAT dG,
1312 FX_FLOAT dB,
1313 FX_FLOAT& dC,
1314 FX_FLOAT& dM,
1315 FX_FLOAT& dY,
1316 FX_FLOAT& dK) {
1317 if (dR < 0 || dR > 1 || dG < 0 || dG > 1 || dB < 0 || dB > 1)
1318 return;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001319
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001320 dC = 1.0f - dR;
1321 dM = 1.0f - dG;
1322 dY = 1.0f - dB;
1323 dK = FX_MIN(dC, FX_MIN(dM, dY));
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001324}
1325
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001326void CPWL_Utils::PWLColorToARGB(const CPWL_Color& color,
1327 int32_t& alpha,
1328 FX_FLOAT& red,
1329 FX_FLOAT& green,
1330 FX_FLOAT& blue) {
1331 switch (color.nColorType) {
1332 case COLORTYPE_TRANSPARENT: {
1333 alpha = 0;
1334 } break;
1335 case COLORTYPE_GRAY: {
1336 ConvertGRAY2RGB(color.fColor1, red, green, blue);
1337 } break;
1338 case COLORTYPE_RGB: {
1339 red = color.fColor1;
1340 green = color.fColor2;
1341 blue = color.fColor3;
1342 } break;
1343 case COLORTYPE_CMYK: {
1344 ConvertCMYK2RGB(color.fColor1, color.fColor2, color.fColor3,
1345 color.fColor4, red, green, blue);
1346 } break;
1347 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001348}
1349
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001350FX_COLORREF CPWL_Utils::PWLColorToFXColor(const CPWL_Color& color,
1351 int32_t nTransparancy) {
1352 int32_t nAlpha = nTransparancy;
1353 FX_FLOAT dRed = 0;
1354 FX_FLOAT dGreen = 0;
1355 FX_FLOAT dBlue = 0;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001356
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001357 PWLColorToARGB(color, nAlpha, dRed, dGreen, dBlue);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001358
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001359 return ArgbEncode(nAlpha, (int32_t)(dRed * 255), (int32_t)(dGreen * 255),
1360 (int32_t)(dBlue * 255));
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001361}
1362
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001363void CPWL_Utils::DrawFillRect(CFX_RenderDevice* pDevice,
Tom Sepez60d909e2015-12-10 15:34:55 -08001364 CFX_Matrix* pUser2Device,
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001365 const CPDF_Rect& rect,
1366 const FX_COLORREF& color) {
1367 CFX_PathData path;
1368 CPDF_Rect rcTemp(rect);
1369 path.AppendRect(rcTemp.left, rcTemp.bottom, rcTemp.right, rcTemp.top);
1370 pDevice->DrawPath(&path, pUser2Device, NULL, color, 0, FXFILL_WINDING);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001371}
1372
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001373void CPWL_Utils::DrawFillArea(CFX_RenderDevice* pDevice,
Tom Sepez60d909e2015-12-10 15:34:55 -08001374 CFX_Matrix* pUser2Device,
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001375 const CPDF_Point* pPts,
1376 int32_t nCount,
1377 const FX_COLORREF& color) {
1378 CFX_PathData path;
1379 path.SetPointCount(nCount);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001380
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001381 path.SetPoint(0, pPts[0].x, pPts[0].y, FXPT_MOVETO);
1382 for (int32_t i = 1; i < nCount; i++)
1383 path.SetPoint(i, pPts[i].x, pPts[i].y, FXPT_LINETO);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001384
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001385 pDevice->DrawPath(&path, pUser2Device, NULL, color, 0, FXFILL_ALTERNATE);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001386}
1387
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001388void CPWL_Utils::DrawStrokeRect(CFX_RenderDevice* pDevice,
Tom Sepez60d909e2015-12-10 15:34:55 -08001389 CFX_Matrix* pUser2Device,
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001390 const CPDF_Rect& rect,
1391 const FX_COLORREF& color,
1392 FX_FLOAT fWidth) {
1393 CFX_PathData path;
1394 CPDF_Rect rcTemp(rect);
1395 path.AppendRect(rcTemp.left, rcTemp.bottom, rcTemp.right, rcTemp.top);
Lei Zhanga6d9f0e2015-06-13 00:48:38 -07001396
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001397 CFX_GraphStateData gsd;
1398 gsd.m_LineWidth = fWidth;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001399
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001400 pDevice->DrawPath(&path, pUser2Device, &gsd, 0, color, FXFILL_ALTERNATE);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001401}
1402
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001403void CPWL_Utils::DrawStrokeLine(CFX_RenderDevice* pDevice,
Tom Sepez60d909e2015-12-10 15:34:55 -08001404 CFX_Matrix* pUser2Device,
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001405 const CPDF_Point& ptMoveTo,
1406 const CPDF_Point& ptLineTo,
1407 const FX_COLORREF& color,
1408 FX_FLOAT fWidth) {
1409 CFX_PathData path;
1410 path.SetPointCount(2);
1411 path.SetPoint(0, ptMoveTo.x, ptMoveTo.y, FXPT_MOVETO);
1412 path.SetPoint(1, ptLineTo.x, ptLineTo.y, FXPT_LINETO);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001413
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001414 CFX_GraphStateData gsd;
1415 gsd.m_LineWidth = fWidth;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001416
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001417 pDevice->DrawPath(&path, pUser2Device, &gsd, 0, color, FXFILL_ALTERNATE);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001418}
1419
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001420void CPWL_Utils::DrawFillRect(CFX_RenderDevice* pDevice,
Tom Sepez60d909e2015-12-10 15:34:55 -08001421 CFX_Matrix* pUser2Device,
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001422 const CPDF_Rect& rect,
1423 const CPWL_Color& color,
1424 int32_t nTransparancy) {
1425 CPWL_Utils::DrawFillRect(pDevice, pUser2Device, rect,
1426 PWLColorToFXColor(color, nTransparancy));
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001427}
1428
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001429void CPWL_Utils::DrawShadow(CFX_RenderDevice* pDevice,
Tom Sepez60d909e2015-12-10 15:34:55 -08001430 CFX_Matrix* pUser2Device,
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001431 FX_BOOL bVertical,
1432 FX_BOOL bHorizontal,
1433 CPDF_Rect rect,
1434 int32_t nTransparancy,
1435 int32_t nStartGray,
1436 int32_t nEndGray) {
1437 FX_FLOAT fStepGray = 1.0f;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001438
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001439 if (bVertical) {
1440 fStepGray = (nEndGray - nStartGray) / rect.Height();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001441
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001442 for (FX_FLOAT fy = rect.bottom + 0.5f; fy <= rect.top - 0.5f; fy += 1.0f) {
1443 int32_t nGray = nStartGray + (int32_t)(fStepGray * (fy - rect.bottom));
1444 CPWL_Utils::DrawStrokeLine(
1445 pDevice, pUser2Device, CPDF_Point(rect.left, fy),
1446 CPDF_Point(rect.right, fy),
1447 ArgbEncode(nTransparancy, nGray, nGray, nGray), 1.5f);
1448 }
1449 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001450
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001451 if (bHorizontal) {
1452 fStepGray = (nEndGray - nStartGray) / rect.Width();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001453
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001454 for (FX_FLOAT fx = rect.left + 0.5f; fx <= rect.right - 0.5f; fx += 1.0f) {
1455 int32_t nGray = nStartGray + (int32_t)(fStepGray * (fx - rect.left));
1456 CPWL_Utils::DrawStrokeLine(
1457 pDevice, pUser2Device, CPDF_Point(fx, rect.bottom),
1458 CPDF_Point(fx, rect.top),
1459 ArgbEncode(nTransparancy, nGray, nGray, nGray), 1.5f);
1460 }
1461 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001462}
1463
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001464void CPWL_Utils::DrawBorder(CFX_RenderDevice* pDevice,
Tom Sepez60d909e2015-12-10 15:34:55 -08001465 CFX_Matrix* pUser2Device,
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001466 const CPDF_Rect& rect,
1467 FX_FLOAT fWidth,
1468 const CPWL_Color& color,
1469 const CPWL_Color& crLeftTop,
1470 const CPWL_Color& crRightBottom,
1471 int32_t nStyle,
1472 const CPWL_Dash& dash,
1473 int32_t nTransparancy) {
1474 FX_FLOAT fLeft = rect.left;
1475 FX_FLOAT fRight = rect.right;
1476 FX_FLOAT fTop = rect.top;
1477 FX_FLOAT fBottom = rect.bottom;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001478
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001479 if (fWidth > 0.0f) {
1480 FX_FLOAT fHalfWidth = fWidth / 2.0f;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001481
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001482 switch (nStyle) {
1483 default:
1484 case PBS_SOLID: {
1485 CFX_PathData path;
1486 path.AppendRect(fLeft, fBottom, fRight, fTop);
1487 path.AppendRect(fLeft + fWidth, fBottom + fWidth, fRight - fWidth,
1488 fTop - fWidth);
1489 pDevice->DrawPath(&path, pUser2Device, NULL,
1490 PWLColorToFXColor(color, nTransparancy), 0,
1491 FXFILL_ALTERNATE);
1492 } break;
1493 case PBS_DASH: {
1494 CFX_PathData path;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001495
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001496 path.SetPointCount(5);
1497 path.SetPoint(0, fLeft + fWidth / 2.0f, fBottom + fWidth / 2.0f,
1498 FXPT_MOVETO);
1499 path.SetPoint(1, fLeft + fWidth / 2.0f, fTop - fWidth / 2.0f,
1500 FXPT_LINETO);
1501 path.SetPoint(2, fRight - fWidth / 2.0f, fTop - fWidth / 2.0f,
1502 FXPT_LINETO);
1503 path.SetPoint(3, fRight - fWidth / 2.0f, fBottom + fWidth / 2.0f,
1504 FXPT_LINETO);
1505 path.SetPoint(4, fLeft + fWidth / 2.0f, fBottom + fWidth / 2.0f,
1506 FXPT_LINETO);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001507
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001508 CFX_GraphStateData gsd;
1509 gsd.SetDashCount(2);
1510 gsd.m_DashArray[0] = 3.0f;
1511 gsd.m_DashArray[1] = 3.0f;
1512 gsd.m_DashPhase = 0;
Lei Zhanga6d9f0e2015-06-13 00:48:38 -07001513
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001514 gsd.m_LineWidth = fWidth;
1515 pDevice->DrawPath(&path, pUser2Device, &gsd, 0,
1516 PWLColorToFXColor(color, nTransparancy),
1517 FXFILL_WINDING);
1518 } break;
1519 case PBS_BEVELED:
1520 case PBS_INSET: {
1521 CFX_GraphStateData gsd;
1522 gsd.m_LineWidth = fHalfWidth;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001523
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001524 CFX_PathData pathLT;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001525
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001526 pathLT.SetPointCount(7);
1527 pathLT.SetPoint(0, fLeft + fHalfWidth, fBottom + fHalfWidth,
1528 FXPT_MOVETO);
1529 pathLT.SetPoint(1, fLeft + fHalfWidth, fTop - fHalfWidth, FXPT_LINETO);
1530 pathLT.SetPoint(2, fRight - fHalfWidth, fTop - fHalfWidth, FXPT_LINETO);
1531 pathLT.SetPoint(3, fRight - fHalfWidth * 2, fTop - fHalfWidth * 2,
1532 FXPT_LINETO);
1533 pathLT.SetPoint(4, fLeft + fHalfWidth * 2, fTop - fHalfWidth * 2,
1534 FXPT_LINETO);
1535 pathLT.SetPoint(5, fLeft + fHalfWidth * 2, fBottom + fHalfWidth * 2,
1536 FXPT_LINETO);
1537 pathLT.SetPoint(6, fLeft + fHalfWidth, fBottom + fHalfWidth,
1538 FXPT_LINETO);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001539
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001540 pDevice->DrawPath(&pathLT, pUser2Device, &gsd,
1541 PWLColorToFXColor(crLeftTop, nTransparancy), 0,
1542 FXFILL_ALTERNATE);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001543
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001544 CFX_PathData pathRB;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001545
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001546 pathRB.SetPointCount(7);
1547 pathRB.SetPoint(0, fRight - fHalfWidth, fTop - fHalfWidth, FXPT_MOVETO);
1548 pathRB.SetPoint(1, fRight - fHalfWidth, fBottom + fHalfWidth,
1549 FXPT_LINETO);
1550 pathRB.SetPoint(2, fLeft + fHalfWidth, fBottom + fHalfWidth,
1551 FXPT_LINETO);
1552 pathRB.SetPoint(3, fLeft + fHalfWidth * 2, fBottom + fHalfWidth * 2,
1553 FXPT_LINETO);
1554 pathRB.SetPoint(4, fRight - fHalfWidth * 2, fBottom + fHalfWidth * 2,
1555 FXPT_LINETO);
1556 pathRB.SetPoint(5, fRight - fHalfWidth * 2, fTop - fHalfWidth * 2,
1557 FXPT_LINETO);
1558 pathRB.SetPoint(6, fRight - fHalfWidth, fTop - fHalfWidth, FXPT_LINETO);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001559
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001560 pDevice->DrawPath(&pathRB, pUser2Device, &gsd,
1561 PWLColorToFXColor(crRightBottom, nTransparancy), 0,
1562 FXFILL_ALTERNATE);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001563
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001564 CFX_PathData path;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001565
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001566 path.AppendRect(fLeft, fBottom, fRight, fTop);
1567 path.AppendRect(fLeft + fHalfWidth, fBottom + fHalfWidth,
1568 fRight - fHalfWidth, fTop - fHalfWidth);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001569
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001570 pDevice->DrawPath(&path, pUser2Device, &gsd,
1571 PWLColorToFXColor(color, nTransparancy), 0,
1572 FXFILL_ALTERNATE);
1573 } break;
1574 case PBS_UNDERLINED: {
1575 CFX_PathData path;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001576
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001577 path.SetPointCount(2);
1578 path.SetPoint(0, fLeft, fBottom + fWidth / 2, FXPT_MOVETO);
1579 path.SetPoint(1, fRight, fBottom + fWidth / 2, FXPT_LINETO);
Lei Zhanga6d9f0e2015-06-13 00:48:38 -07001580
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001581 CFX_GraphStateData gsd;
1582 gsd.m_LineWidth = fWidth;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001583
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001584 pDevice->DrawPath(&path, pUser2Device, &gsd, 0,
1585 PWLColorToFXColor(color, nTransparancy),
1586 FXFILL_ALTERNATE);
1587 } break;
1588 case PBS_SHADOW: {
1589 CFX_PathData path;
1590 path.AppendRect(fLeft, fBottom, fRight, fTop);
1591 path.AppendRect(fLeft + fWidth, fBottom + fWidth, fRight - fWidth,
1592 fTop - fWidth);
1593 pDevice->DrawPath(&path, pUser2Device, NULL,
1594 PWLColorToFXColor(color, nTransparancy / 2), 0,
1595 FXFILL_ALTERNATE);
1596 } break;
1597 }
1598 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001599}
1600
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001601static void AddSquigglyPath(CFX_PathData& PathData,
1602 FX_FLOAT fStartX,
1603 FX_FLOAT fEndX,
1604 FX_FLOAT fY,
1605 FX_FLOAT fStep) {
1606 PathData.AddPointCount(1);
1607 PathData.SetPoint(PathData.GetPointCount() - 1, fStartX, fY, FXPT_MOVETO);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001608
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001609 FX_FLOAT fx;
1610 int32_t i;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001611
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001612 for (i = 1, fx = fStartX + fStep; fx < fEndX; fx += fStep, i++) {
1613 PathData.AddPointCount(1);
1614 PathData.SetPoint(PathData.GetPointCount() - 1, fx, fY + (i & 1) * fStep,
1615 FXPT_LINETO);
1616 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001617}
1618
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001619static void AddSpellCheckObj(CFX_PathData& PathData,
1620 IFX_Edit* pEdit,
1621 const CPVT_WordRange& wrWord) {
1622 FX_FLOAT fStartX = 0.0f;
1623 FX_FLOAT fEndX = 0.0f;
1624 FX_FLOAT fY = 0.0f;
1625 FX_FLOAT fStep = 0.0f;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001626
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001627 FX_BOOL bBreak = FALSE;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001628
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001629 if (IFX_Edit_Iterator* pIterator = pEdit->GetIterator()) {
1630 pIterator->SetAt(wrWord.BeginPos);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001631
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001632 do {
1633 CPVT_WordPlace place = pIterator->GetAt();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001634
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001635 CPVT_Line line;
1636 if (pIterator->GetLine(line)) {
1637 fY = line.ptLine.y;
1638 fStep = (line.fLineAscent - line.fLineDescent) / 16.0f;
1639 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001640
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001641 if (place.LineCmp(wrWord.BeginPos) == 0) {
1642 pIterator->SetAt(wrWord.BeginPos);
1643 CPVT_Word word;
1644 if (pIterator->GetWord(word)) {
1645 fStartX = word.ptWord.x;
1646 }
1647 } else {
1648 fStartX = line.ptLine.x;
1649 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001650
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001651 if (place.LineCmp(wrWord.EndPos) == 0) {
1652 pIterator->SetAt(wrWord.EndPos);
1653 CPVT_Word word;
1654 if (pIterator->GetWord(word)) {
1655 fEndX = word.ptWord.x + word.fWidth;
1656 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001657
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001658 bBreak = TRUE;
1659 } else {
1660 fEndX = line.ptLine.x + line.fLineWidth;
1661 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001662
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001663 AddSquigglyPath(PathData, fStartX, fEndX, fY, fStep);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001664
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001665 if (bBreak)
1666 break;
1667 } while (pIterator->NextLine());
1668 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001669}
1670
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001671void CPWL_Utils::DrawEditSpellCheck(CFX_RenderDevice* pDevice,
Tom Sepez60d909e2015-12-10 15:34:55 -08001672 CFX_Matrix* pUser2Device,
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001673 IFX_Edit* pEdit,
1674 const CPDF_Rect& rcClip,
1675 const CPDF_Point& ptOffset,
1676 const CPVT_WordRange* pRange,
1677 IPWL_SpellCheck* pSpellCheck) {
1678 const FX_COLORREF crSpell = ArgbEncode(255, 255, 0, 0);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001679
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001680 // for spellcheck
1681 FX_BOOL bLatinWord = FALSE;
1682 CPVT_WordPlace wpWordStart;
1683 CFX_ByteString sLatinWord;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001684
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001685 CFX_PathData pathSpell;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001686
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001687 pDevice->SaveState();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001688
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001689 if (!rcClip.IsEmpty()) {
1690 CPDF_Rect rcTemp = rcClip;
1691 pUser2Device->TransformRect(rcTemp);
1692 FX_RECT rcDevClip;
1693 rcDevClip.left = (int32_t)rcTemp.left;
1694 rcDevClip.right = (int32_t)rcTemp.right;
1695 rcDevClip.top = (int32_t)rcTemp.top;
1696 rcDevClip.bottom = (int32_t)rcTemp.bottom;
1697 pDevice->SetClip_Rect(&rcDevClip);
1698 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001699
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001700 if (IFX_Edit_Iterator* pIterator = pEdit->GetIterator()) {
1701 if (pEdit->GetFontMap()) {
1702 if (pRange)
1703 pIterator->SetAt(pRange->BeginPos);
1704 else
1705 pIterator->SetAt(0);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001706
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001707 CPVT_WordPlace oldplace;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001708
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001709 while (pIterator->NextWord()) {
1710 CPVT_WordPlace place = pIterator->GetAt();
1711 if (pRange && place.WordCmp(pRange->EndPos) > 0)
1712 break;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001713
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001714 CPVT_Word word;
1715 if (pIterator->GetWord(word)) {
1716 if (FX_EDIT_ISLATINWORD(word.Word)) {
1717 if (!bLatinWord) {
1718 wpWordStart = place;
1719 bLatinWord = TRUE;
1720 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001721
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001722 sLatinWord += (char)word.Word;
1723 } else {
1724 if (bLatinWord) {
1725 if (!sLatinWord.IsEmpty()) {
1726 if (pSpellCheck && !pSpellCheck->CheckWord(sLatinWord)) {
1727 AddSpellCheckObj(pathSpell, pEdit,
1728 CPVT_WordRange(wpWordStart, oldplace));
1729 pIterator->SetAt(place);
1730 }
1731 }
1732 bLatinWord = FALSE;
1733 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001734
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001735 sLatinWord.Empty();
1736 }
Lei Zhanga6d9f0e2015-06-13 00:48:38 -07001737
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001738 oldplace = place;
1739 } else {
1740 if (bLatinWord) {
1741 if (!sLatinWord.IsEmpty()) {
1742 if (pSpellCheck && !pSpellCheck->CheckWord(sLatinWord)) {
1743 AddSpellCheckObj(pathSpell, pEdit,
1744 CPVT_WordRange(wpWordStart, oldplace));
1745 pIterator->SetAt(place);
1746 }
1747 }
1748 bLatinWord = FALSE;
1749 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001750
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001751 sLatinWord.Empty();
1752 }
1753 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001754
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001755 if (!sLatinWord.IsEmpty()) {
1756 if (pSpellCheck && !pSpellCheck->CheckWord(sLatinWord)) {
1757 AddSpellCheckObj(pathSpell, pEdit,
1758 CPVT_WordRange(wpWordStart, oldplace));
1759 }
1760 }
1761 }
1762 }
Lei Zhanga6d9f0e2015-06-13 00:48:38 -07001763
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001764 CFX_GraphStateData gsd;
1765 gsd.m_LineWidth = 0;
1766 if (pathSpell.GetPointCount() > 0)
1767 pDevice->DrawPath(&pathSpell, pUser2Device, &gsd, 0, crSpell,
1768 FXFILL_ALTERNATE);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001769
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001770 pDevice->RestoreState();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001771}
1772
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001773FX_BOOL CPWL_Utils::IsBlackOrWhite(const CPWL_Color& color) {
1774 switch (color.nColorType) {
1775 case COLORTYPE_TRANSPARENT:
1776 return FALSE;
1777 case COLORTYPE_GRAY:
1778 return color.fColor1 < 0.5f;
1779 case COLORTYPE_RGB:
1780 return color.fColor1 + color.fColor2 + color.fColor3 < 1.5f;
1781 case COLORTYPE_CMYK:
1782 return color.fColor1 + color.fColor2 + color.fColor3 + color.fColor4 >
1783 2.0f;
1784 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001785
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001786 return TRUE;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001787}
1788
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001789CPWL_Color CPWL_Utils::GetReverseColor(const CPWL_Color& color) {
1790 CPWL_Color crRet = color;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001791
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001792 switch (color.nColorType) {
1793 case COLORTYPE_GRAY:
1794 crRet.fColor1 = 1.0f - crRet.fColor1;
1795 break;
1796 case COLORTYPE_RGB:
1797 crRet.fColor1 = 1.0f - crRet.fColor1;
1798 crRet.fColor2 = 1.0f - crRet.fColor2;
1799 crRet.fColor3 = 1.0f - crRet.fColor3;
1800 break;
1801 case COLORTYPE_CMYK:
1802 crRet.fColor1 = 1.0f - crRet.fColor1;
1803 crRet.fColor2 = 1.0f - crRet.fColor2;
1804 crRet.fColor3 = 1.0f - crRet.fColor3;
1805 crRet.fColor4 = 1.0f - crRet.fColor4;
1806 break;
1807 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001808
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001809 return crRet;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001810}
1811
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001812CFX_ByteString CPWL_Utils::GetIconAppStream(int32_t nType,
1813 const CPDF_Rect& rect,
1814 const CPWL_Color& crFill,
1815 const CPWL_Color& crStroke) {
1816 CFX_ByteString sAppStream = CPWL_Utils::GetColorAppStream(crStroke, FALSE);
1817 sAppStream += CPWL_Utils::GetColorAppStream(crFill, TRUE);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001818
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001819 CFX_ByteString sPath;
1820 CFX_PathData path;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001821
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001822 switch (nType) {
1823 case PWL_ICONTYPE_CHECKMARK:
1824 GetGraphics_Checkmark(sPath, path, rect, PWLPT_STREAM);
1825 break;
1826 case PWL_ICONTYPE_CIRCLE:
1827 GetGraphics_Circle(sPath, path, rect, PWLPT_STREAM);
1828 break;
1829 case PWL_ICONTYPE_COMMENT:
1830 GetGraphics_Comment(sPath, path, rect, PWLPT_STREAM);
1831 break;
1832 case PWL_ICONTYPE_CROSS:
1833 GetGraphics_Cross(sPath, path, rect, PWLPT_STREAM);
1834 break;
1835 case PWL_ICONTYPE_HELP:
1836 GetGraphics_Help(sPath, path, rect, PWLPT_STREAM);
1837 break;
1838 case PWL_ICONTYPE_INSERTTEXT:
1839 GetGraphics_InsertText(sPath, path, rect, PWLPT_STREAM);
1840 break;
1841 case PWL_ICONTYPE_KEY:
1842 GetGraphics_Key(sPath, path, rect, PWLPT_STREAM);
1843 break;
1844 case PWL_ICONTYPE_NEWPARAGRAPH:
1845 GetGraphics_NewParagraph(sPath, path, rect, PWLPT_STREAM);
1846 break;
1847 case PWL_ICONTYPE_TEXTNOTE:
1848 GetGraphics_TextNote(sPath, path, rect, PWLPT_STREAM);
1849 break;
1850 case PWL_ICONTYPE_PARAGRAPH:
1851 GetGraphics_Paragraph(sPath, path, rect, PWLPT_STREAM);
1852 break;
1853 case PWL_ICONTYPE_RIGHTARROW:
1854 GetGraphics_RightArrow(sPath, path, rect, PWLPT_STREAM);
1855 break;
1856 case PWL_ICONTYPE_RIGHTPOINTER:
1857 GetGraphics_RightPointer(sPath, path, rect, PWLPT_STREAM);
1858 break;
1859 case PWL_ICONTYPE_STAR:
1860 GetGraphics_Star(sPath, path, rect, PWLPT_STREAM);
1861 break;
1862 case PWL_ICONTYPE_UPARROW:
1863 GetGraphics_UpArrow(sPath, path, rect, PWLPT_STREAM);
1864 break;
1865 case PWL_ICONTYPE_UPLEFTARROW:
1866 GetGraphics_UpLeftArrow(sPath, path, rect, PWLPT_STREAM);
1867 break;
1868 case PWL_ICONTYPE_GRAPH:
1869 GetGraphics_Graph(sPath, path, rect, PWLPT_STREAM);
1870 break;
1871 case PWL_ICONTYPE_PAPERCLIP:
1872 GetGraphics_Paperclip(sPath, path, rect, PWLPT_STREAM);
1873 break;
1874 case PWL_ICONTYPE_ATTACHMENT:
1875 GetGraphics_Attachment(sPath, path, rect, PWLPT_STREAM);
1876 break;
1877 case PWL_ICONTYPE_TAG:
1878 GetGraphics_Tag(sPath, path, rect, PWLPT_STREAM);
1879 break;
1880 case PWL_ICONTYPE_FOXIT:
1881 GetGraphics_Foxit(sPath, path, rect, PWLPT_STREAM);
1882 break;
1883 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001884
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001885 sAppStream += sPath;
1886 if (crStroke.nColorType != COLORTYPE_TRANSPARENT)
1887 sAppStream += "B*\n";
1888 else
1889 sAppStream += "f*\n";
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001890
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001891 return sAppStream;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001892}
1893
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001894void CPWL_Utils::DrawIconAppStream(CFX_RenderDevice* pDevice,
Tom Sepez60d909e2015-12-10 15:34:55 -08001895 CFX_Matrix* pUser2Device,
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001896 int32_t nType,
1897 const CPDF_Rect& rect,
1898 const CPWL_Color& crFill,
1899 const CPWL_Color& crStroke,
1900 const int32_t nTransparancy) {
1901 CFX_GraphStateData gsd;
1902 gsd.m_LineWidth = 1.0f;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001903
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001904 CFX_ByteString sPath;
1905 CFX_PathData path;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001906
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001907 switch (nType) {
1908 case PWL_ICONTYPE_CHECKMARK:
1909 GetGraphics_Checkmark(sPath, path, rect, PWLPT_PATHDATA);
1910 break;
1911 case PWL_ICONTYPE_CIRCLE:
1912 GetGraphics_Circle(sPath, path, rect, PWLPT_PATHDATA);
1913 break;
1914 case PWL_ICONTYPE_COMMENT:
1915 GetGraphics_Comment(sPath, path, rect, PWLPT_PATHDATA);
1916 break;
1917 case PWL_ICONTYPE_CROSS:
1918 GetGraphics_Cross(sPath, path, rect, PWLPT_PATHDATA);
1919 break;
1920 case PWL_ICONTYPE_HELP:
1921 GetGraphics_Help(sPath, path, rect, PWLPT_PATHDATA);
1922 break;
1923 case PWL_ICONTYPE_INSERTTEXT:
1924 GetGraphics_InsertText(sPath, path, rect, PWLPT_PATHDATA);
1925 break;
1926 case PWL_ICONTYPE_KEY:
1927 GetGraphics_Key(sPath, path, rect, PWLPT_PATHDATA);
1928 break;
1929 case PWL_ICONTYPE_NEWPARAGRAPH:
1930 GetGraphics_NewParagraph(sPath, path, rect, PWLPT_PATHDATA);
1931 break;
1932 case PWL_ICONTYPE_TEXTNOTE:
1933 GetGraphics_TextNote(sPath, path, rect, PWLPT_PATHDATA);
1934 break;
1935 case PWL_ICONTYPE_PARAGRAPH:
1936 GetGraphics_Paragraph(sPath, path, rect, PWLPT_PATHDATA);
1937 break;
1938 case PWL_ICONTYPE_RIGHTARROW:
1939 GetGraphics_RightArrow(sPath, path, rect, PWLPT_PATHDATA);
1940 break;
1941 case PWL_ICONTYPE_RIGHTPOINTER:
1942 GetGraphics_RightPointer(sPath, path, rect, PWLPT_PATHDATA);
1943 break;
1944 case PWL_ICONTYPE_STAR:
1945 GetGraphics_Star(sPath, path, rect, PWLPT_PATHDATA);
1946 break;
1947 case PWL_ICONTYPE_UPARROW:
1948 GetGraphics_UpArrow(sPath, path, rect, PWLPT_PATHDATA);
1949 break;
1950 case PWL_ICONTYPE_UPLEFTARROW:
1951 GetGraphics_UpLeftArrow(sPath, path, rect, PWLPT_PATHDATA);
1952 break;
1953 case PWL_ICONTYPE_GRAPH:
1954 GetGraphics_Graph(sPath, path, rect, PWLPT_PATHDATA);
1955 break;
1956 case PWL_ICONTYPE_PAPERCLIP:
1957 GetGraphics_Paperclip(sPath, path, rect, PWLPT_PATHDATA);
1958 break;
1959 case PWL_ICONTYPE_ATTACHMENT:
1960 GetGraphics_Attachment(sPath, path, rect, PWLPT_PATHDATA);
1961 break;
1962 case PWL_ICONTYPE_TAG:
1963 GetGraphics_Tag(sPath, path, rect, PWLPT_PATHDATA);
1964 break;
1965 case PWL_ICONTYPE_FOXIT:
1966 GetGraphics_Foxit(sPath, path, rect, PWLPT_PATHDATA);
1967 break;
1968 default:
1969 return;
1970 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001971
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001972 pDevice->DrawPath(
1973 &path, pUser2Device, &gsd, PWLColorToFXColor(crFill, nTransparancy),
1974 PWLColorToFXColor(crStroke, nTransparancy), FXFILL_ALTERNATE);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001975}
1976
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001977void CPWL_Utils::GetGraphics_Checkmark(CFX_ByteString& sPathData,
1978 CFX_PathData& path,
1979 const CPDF_Rect& crBBox,
1980 const PWL_PATH_TYPE type) {
1981 FX_FLOAT fWidth = crBBox.right - crBBox.left;
1982 FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001983
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001984 CPWL_PathData PathArray[] = {
1985 CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 15.0f,
1986 crBBox.bottom + fHeight * 2 / 5.0f),
1987 PWLPT_MOVETO),
1988 CPWL_PathData(
1989 CPWL_Point(
1990 crBBox.left + fWidth / 15.0f +
1991 PWL_BEZIER * (fWidth / 7.0f - fWidth / 15.0f),
1992 crBBox.bottom + fHeight * 2 / 5.0f +
1993 PWL_BEZIER * (fHeight * 2 / 7.0f - fHeight * 2 / 5.0f)),
1994 PWLPT_BEZIERTO),
1995 CPWL_PathData(
1996 CPWL_Point(crBBox.left + fWidth / 4.5f +
1997 PWL_BEZIER * (fWidth / 5.0f - fWidth / 4.5f),
1998 crBBox.bottom + fHeight / 16.0f +
1999 PWL_BEZIER * (fHeight / 5.0f - fHeight / 16.0f)),
2000 PWLPT_BEZIERTO),
2001 CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 4.5f,
2002 crBBox.bottom + fHeight / 16.0f),
2003 PWLPT_BEZIERTO),
2004 CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 4.5f +
2005 PWL_BEZIER * (fWidth / 4.4f - fWidth / 4.5f),
2006 crBBox.bottom + fHeight / 16.0f -
2007 PWL_BEZIER * fHeight / 16.0f),
2008 PWLPT_BEZIERTO),
2009 CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 3.0f +
2010 PWL_BEZIER * (fWidth / 4.0f - fWidth / 3.0f),
2011 crBBox.bottom),
2012 PWLPT_BEZIERTO),
2013 CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 3.0f, crBBox.bottom),
2014 PWLPT_BEZIERTO),
2015 CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 3.0f +
2016 PWL_BEZIER * fWidth * (1 / 7.0f + 2 / 15.0f),
2017 crBBox.bottom + PWL_BEZIER * fHeight * 4 / 5.0f),
2018 PWLPT_BEZIERTO),
2019 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 14 / 15.0f +
2020 PWL_BEZIER * fWidth * (1 / 7.0f - 7 / 15.0f),
2021 crBBox.bottom + fHeight * 15 / 16.0f +
2022 PWL_BEZIER * (fHeight * 4 / 5.0f -
2023 fHeight * 15 / 16.0f)),
2024 PWLPT_BEZIERTO),
2025 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 14 / 15.0f,
2026 crBBox.bottom + fHeight * 15 / 16.0f),
2027 PWLPT_BEZIERTO),
2028 CPWL_PathData(
2029 CPWL_Point(
2030 crBBox.left + fWidth * 14 / 15.0f +
2031 PWL_BEZIER * (fWidth * 7 / 15.0f - fWidth * 14 / 15.0f),
2032 crBBox.bottom + fHeight * 15 / 16.0f +
2033 PWL_BEZIER * (fHeight * 8 / 7.0f - fHeight * 15 / 16.0f)),
2034 PWLPT_BEZIERTO),
2035 CPWL_PathData(
2036 CPWL_Point(crBBox.left + fWidth / 3.6f +
2037 PWL_BEZIER * (fWidth / 3.4f - fWidth / 3.6f),
2038 crBBox.bottom + fHeight / 3.5f +
2039 PWL_BEZIER * (fHeight / 3.5f - fHeight / 3.5f)),
2040 PWLPT_BEZIERTO),
2041 CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 3.6f,
2042 crBBox.bottom + fHeight / 3.5f),
2043 PWLPT_BEZIERTO),
2044 CPWL_PathData(
2045 CPWL_Point(crBBox.left + fWidth / 3.6f,
2046 crBBox.bottom + fHeight / 3.5f +
2047 PWL_BEZIER * (fHeight / 4.0f - fHeight / 3.5f)),
2048 PWLPT_BEZIERTO),
2049 CPWL_PathData(
2050 CPWL_Point(
2051 crBBox.left + fWidth / 15.0f +
2052 PWL_BEZIER * (fWidth / 3.5f - fWidth / 15.0f),
2053 crBBox.bottom + fHeight * 2 / 5.0f +
2054 PWL_BEZIER * (fHeight * 3.5f / 5.0f - fHeight * 2 / 5.0f)),
2055 PWLPT_BEZIERTO),
2056 CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 15.0f,
2057 crBBox.bottom + fHeight * 2 / 5.0f),
2058 PWLPT_BEZIERTO)};
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07002059
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002060 if (type == PWLPT_STREAM)
2061 sPathData = GetAppStreamFromArray(PathArray, 16);
2062 else
2063 GetPathDataFromArray(path, PathArray, 16);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07002064}
2065
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002066void CPWL_Utils::GetGraphics_Circle(CFX_ByteString& sPathData,
2067 CFX_PathData& path,
2068 const CPDF_Rect& crBBox,
2069 const PWL_PATH_TYPE type) {
2070 FX_FLOAT fWidth = crBBox.right - crBBox.left;
2071 FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07002072
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002073 CPWL_PathData PathArray[] = {
2074 CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 15.0f,
2075 crBBox.bottom + fHeight / 2.0f),
2076 PWLPT_MOVETO),
2077 CPWL_PathData(
2078 CPWL_Point(crBBox.left + fWidth / 15.0f,
2079 crBBox.bottom + fHeight / 2.0f +
2080 PWL_BEZIER * (fHeight * 14 / 15.0f - fHeight / 2.0f)),
2081 PWLPT_BEZIERTO),
2082 CPWL_PathData(
2083 CPWL_Point(crBBox.left + fWidth / 2.0f -
2084 PWL_BEZIER * (fWidth / 2.0f - fWidth / 15.0f),
2085 crBBox.top - fHeight / 15.0f),
2086 PWLPT_BEZIERTO),
2087 CPWL_PathData(
2088 CPWL_Point(crBBox.left + fWidth / 2.0f, crBBox.top - fHeight / 15.0f),
2089 PWLPT_BEZIERTO),
2090 CPWL_PathData(
2091 CPWL_Point(crBBox.left + fWidth / 2.0f +
2092 PWL_BEZIER * (fWidth * 14 / 15.0f - fWidth / 2.0f),
2093 crBBox.top - fHeight / 15.0f),
2094 PWLPT_BEZIERTO),
2095 CPWL_PathData(
2096 CPWL_Point(crBBox.right - fWidth / 15.0f,
2097 crBBox.bottom + fHeight / 2.0f +
2098 PWL_BEZIER * (fHeight * 14 / 15.0f - fHeight / 2.0f)),
2099 PWLPT_BEZIERTO),
2100 CPWL_PathData(CPWL_Point(crBBox.right - fWidth / 15.0f,
2101 crBBox.bottom + fHeight / 2.0f),
2102 PWLPT_BEZIERTO),
2103 CPWL_PathData(
2104 CPWL_Point(crBBox.right - fWidth / 15.0f,
2105 crBBox.bottom + fHeight / 2.0f -
2106 PWL_BEZIER * (fHeight / 2.0f - fHeight / 15.0f)),
2107 PWLPT_BEZIERTO),
2108 CPWL_PathData(
2109 CPWL_Point(crBBox.left + fWidth / 2.0f +
2110 PWL_BEZIER * (fWidth * 14 / 15.0f - fWidth / 2.0f),
2111 crBBox.bottom + fHeight / 15.0f),
2112 PWLPT_BEZIERTO),
2113 CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 2.0f,
2114 crBBox.bottom + fHeight / 15.0f),
2115 PWLPT_BEZIERTO),
2116 CPWL_PathData(
2117 CPWL_Point(crBBox.left + fWidth / 2.0f -
2118 PWL_BEZIER * (fWidth / 2.0f - fWidth / 15.0f),
2119 crBBox.bottom + fHeight / 15.0f),
2120 PWLPT_BEZIERTO),
2121 CPWL_PathData(
2122 CPWL_Point(crBBox.left + fWidth / 15.0f,
2123 crBBox.bottom + fHeight / 2.0f -
2124 PWL_BEZIER * (fHeight / 2.0f - fHeight / 15.0f)),
2125 PWLPT_BEZIERTO),
2126 CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 15.0f,
2127 crBBox.bottom + fHeight / 2.0f),
2128 PWLPT_BEZIERTO),
2129 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 3 / 15.0f,
2130 crBBox.bottom + fHeight / 2.0f),
2131 PWLPT_MOVETO),
2132 CPWL_PathData(
2133 CPWL_Point(crBBox.left + fWidth * 3 / 15.0f,
2134 crBBox.bottom + fHeight / 2.0f +
2135 PWL_BEZIER * (fHeight * 4 / 5.0f - fHeight / 2.0f)),
2136 PWLPT_BEZIERTO),
2137 CPWL_PathData(
2138 CPWL_Point(crBBox.left + fWidth / 2.0f -
2139 PWL_BEZIER * (fWidth / 2.0f - fWidth * 3 / 15.0f),
2140 crBBox.top - fHeight * 3 / 15.0f),
2141 PWLPT_BEZIERTO),
2142 CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 2.0f,
2143 crBBox.top - fHeight * 3 / 15.0f),
2144 PWLPT_BEZIERTO),
2145 CPWL_PathData(
2146 CPWL_Point(crBBox.left + fWidth / 2.0f +
2147 PWL_BEZIER * (fWidth * 4 / 5.0f - fWidth / 2.0f),
2148 crBBox.top - fHeight * 3 / 15.0f),
2149 PWLPT_BEZIERTO),
2150 CPWL_PathData(
2151 CPWL_Point(crBBox.right - fWidth * 3 / 15.0f,
2152 crBBox.bottom + fHeight / 2.0f +
2153 PWL_BEZIER * (fHeight * 4 / 5.0f - fHeight / 2.0f)),
2154 PWLPT_BEZIERTO),
2155 CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 3 / 15.0f,
2156 crBBox.bottom + fHeight / 2.0f),
2157 PWLPT_BEZIERTO),
2158 CPWL_PathData(
2159 CPWL_Point(crBBox.right - fWidth * 3 / 15.0f,
2160 crBBox.bottom + fHeight / 2.0f -
2161 PWL_BEZIER * (fHeight * 4 / 5.0f - fHeight / 2.0f)),
2162 PWLPT_BEZIERTO),
2163 CPWL_PathData(
2164 CPWL_Point(crBBox.left + fWidth / 2.0f +
2165 PWL_BEZIER * (fWidth * 4 / 5.0f - fWidth / 2.0f),
2166 crBBox.bottom + fHeight * 3 / 15.0f),
2167 PWLPT_BEZIERTO),
2168 CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 2.0f,
2169 crBBox.bottom + fHeight * 3 / 15.0f),
2170 PWLPT_BEZIERTO),
2171 CPWL_PathData(
2172 CPWL_Point(crBBox.left + fWidth / 2.0f -
2173 PWL_BEZIER * (fWidth * 4 / 5.0f - fWidth / 2.0f),
2174 crBBox.bottom + fHeight * 3 / 15.0f),
2175 PWLPT_BEZIERTO),
2176 CPWL_PathData(
2177 CPWL_Point(crBBox.left + fWidth * 3 / 15.0f,
2178 crBBox.bottom + fHeight / 2.0f -
2179 PWL_BEZIER * (fHeight * 4 / 5.0f - fHeight / 2.0f)),
2180 PWLPT_BEZIERTO),
2181 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 3 / 15.0f,
2182 crBBox.bottom + fHeight / 2.0f),
2183 PWLPT_BEZIERTO)};
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07002184
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002185 if (type == PWLPT_STREAM)
2186 sPathData = GetAppStreamFromArray(PathArray, 26);
2187 else
2188 GetPathDataFromArray(path, PathArray, 26);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07002189}
2190
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002191void CPWL_Utils::GetGraphics_Comment(CFX_ByteString& sPathData,
2192 CFX_PathData& path,
2193 const CPDF_Rect& crBBox,
2194 const PWL_PATH_TYPE type) {
2195 FX_FLOAT fWidth = crBBox.right - crBBox.left;
2196 FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07002197
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002198 CPWL_PathData PathArray[] = {
2199 CPWL_PathData(
2200 CPWL_Point(crBBox.left + fWidth / 15.0f, crBBox.top - fHeight / 6.0f),
2201 PWLPT_MOVETO),
2202 CPWL_PathData(
2203 CPWL_Point(crBBox.left + fWidth / 15.0f,
2204 crBBox.top - fHeight / 6.0f +
2205 PWL_BEZIER * (fHeight / 6.0f - fHeight / 10.0f)),
2206 PWLPT_BEZIERTO),
2207 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 2 / 15.0f -
2208 PWL_BEZIER * fWidth / 15.0f,
2209 crBBox.top - fHeight / 10.0f),
2210 PWLPT_BEZIERTO),
2211 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 2 / 15.0f,
2212 crBBox.top - fHeight / 10.0f),
2213 PWLPT_BEZIERTO),
2214 CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 2 / 15.0f,
2215 crBBox.top - fHeight / 10.0f),
2216 PWLPT_LINETO),
2217 CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 2 / 15.0f +
2218 PWL_BEZIER * fWidth / 15.0f,
2219 crBBox.top - fHeight / 10.0f),
2220 PWLPT_BEZIERTO),
2221 CPWL_PathData(
2222 CPWL_Point(crBBox.right - fWidth / 15.0f,
2223 crBBox.top - fHeight / 6 +
2224 PWL_BEZIER * (fHeight / 6.0f - fHeight / 10.0f)),
2225 PWLPT_BEZIERTO),
2226 CPWL_PathData(CPWL_Point(crBBox.right - fWidth / 15.0f,
2227 crBBox.top - fHeight / 6.0f),
2228 PWLPT_BEZIERTO),
2229 CPWL_PathData(CPWL_Point(crBBox.right - fWidth / 15.0f,
2230 crBBox.bottom + fHeight / 3.0f),
2231 PWLPT_LINETO),
2232 CPWL_PathData(CPWL_Point(crBBox.right - fWidth / 15.0f,
2233 crBBox.bottom + fHeight * 4 / 15.0f +
2234 PWL_BEZIER * fHeight / 15.0f),
2235 PWLPT_BEZIERTO),
2236 CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 2 / 15.0f +
2237 PWL_BEZIER * fWidth / 15.0f,
2238 crBBox.bottom + fHeight * 4 / 15.0f),
2239 PWLPT_BEZIERTO),
2240 CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 2 / 15.0f,
2241 crBBox.bottom + fHeight * 4 / 15.0f),
2242 PWLPT_BEZIERTO),
2243 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 5 / 15.0f,
2244 crBBox.bottom + fHeight * 4 / 15.0f),
2245 PWLPT_LINETO),
2246 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 5 / 15.0f,
2247 crBBox.bottom + fHeight * 2 / 15 +
2248 PWL_BEZIER * fHeight * 2 / 15.0f),
2249 PWLPT_BEZIERTO),
2250 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 5 / 15.0f -
2251 PWL_BEZIER * fWidth * 2 / 15.0f,
2252 crBBox.bottom + fHeight * 2 / 15.0f),
2253 PWLPT_BEZIERTO),
2254 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 6 / 30.0f,
2255 crBBox.bottom + fHeight * 2 / 15.0f),
2256 PWLPT_BEZIERTO),
2257 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 7 / 30.0f +
2258 PWL_BEZIER * fWidth / 30.0f,
2259 crBBox.bottom + fHeight * 2 / 15.0f),
2260 PWLPT_BEZIERTO),
2261 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 7 / 30.0f,
2262 crBBox.bottom + fHeight * 2 / 15.0f +
2263 PWL_BEZIER * fHeight * 2 / 15.0f),
2264 PWLPT_BEZIERTO),
2265 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 7 / 30.0f,
2266 crBBox.bottom + fHeight * 4 / 15.0f),
2267 PWLPT_BEZIERTO),
2268 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 2 / 15.0f,
2269 crBBox.bottom + fHeight * 4 / 15.0f),
2270 PWLPT_LINETO),
2271 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 2 / 15.0f -
2272 PWL_BEZIER * fWidth / 15.0f,
2273 crBBox.bottom + fHeight * 4 / 15.0f),
2274 PWLPT_BEZIERTO),
2275 CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 15.0f,
2276 crBBox.bottom + fHeight / 3.0f -
2277 PWL_BEZIER * fHeight / 15.0f),
2278 PWLPT_BEZIERTO),
2279 CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 15.0f,
2280 crBBox.bottom + fHeight / 3.0f),
2281 PWLPT_BEZIERTO),
2282 CPWL_PathData(
2283 CPWL_Point(crBBox.left + fWidth / 15.0f, crBBox.top - fHeight / 6.0f),
2284 PWLPT_LINETO),
2285 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 2 / 15.0f,
2286 crBBox.top - fHeight * 8 / 30.0f),
2287 PWLPT_MOVETO),
2288 CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 2 / 15.0f,
2289 crBBox.top - fHeight * 8 / 30.0f),
2290 PWLPT_LINETO),
2291 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 2 / 15,
2292 crBBox.top - fHeight * 25 / 60.0f),
2293 PWLPT_MOVETO),
2294 CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 2 / 15.0f,
2295 crBBox.top - fHeight * 25 / 60.0f),
2296 PWLPT_LINETO),
2297 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 2 / 15.0f,
2298 crBBox.top - fHeight * 17 / 30.0f),
2299 PWLPT_MOVETO),
2300 CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 4 / 15.0f,
2301 crBBox.top - fHeight * 17 / 30.0f),
2302 PWLPT_LINETO)};
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07002303
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002304 if (type == PWLPT_STREAM)
2305 sPathData = GetAppStreamFromArray(PathArray, 30);
2306 else
2307 GetPathDataFromArray(path, PathArray, 30);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07002308}
2309
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002310void CPWL_Utils::GetGraphics_Cross(CFX_ByteString& sPathData,
2311 CFX_PathData& path,
2312 const CPDF_Rect& crBBox,
2313 const PWL_PATH_TYPE type) {
2314 FX_FLOAT fWidth = crBBox.right - crBBox.left;
2315 FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002316 CPWL_Point center_point(crBBox.left + fWidth / 2,
2317 crBBox.bottom + fHeight / 2);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07002318
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002319 CPWL_PathData PathArray[] = {
2320 CPWL_PathData(
2321 CPWL_Point(center_point.x, center_point.y + fHeight / 10.0f),
2322 PWLPT_MOVETO),
2323 CPWL_PathData(
2324 CPWL_Point(center_point.x + fWidth * 0.3f,
2325 center_point.y + fHeight / 10.0f + fWidth * 0.3f),
2326 PWLPT_LINETO),
2327 CPWL_PathData(CPWL_Point(center_point.x + fWidth / 10.0f + fWidth * 0.3f,
2328 center_point.y + fHeight * 0.3f),
2329 PWLPT_LINETO),
2330 CPWL_PathData(CPWL_Point(center_point.x + fWidth / 10.0f, center_point.y),
2331 PWLPT_LINETO),
2332 CPWL_PathData(CPWL_Point(center_point.x + fWidth / 10.0f + fWidth * 0.3f,
2333 center_point.y - fHeight * 0.3f),
2334 PWLPT_LINETO),
2335 CPWL_PathData(
2336 CPWL_Point(center_point.x + fWidth * 0.3f,
2337 center_point.y - fHeight / 10.0f - fHeight * 0.3f),
2338 PWLPT_LINETO),
2339 CPWL_PathData(
2340 CPWL_Point(center_point.x, center_point.y - fHeight / 10.0f),
2341 PWLPT_LINETO),
2342 CPWL_PathData(CPWL_Point(center_point.x - fWidth * 0.3f,
2343 center_point.y - fHeight / 10 - fHeight * 0.3f),
2344 PWLPT_LINETO),
2345 CPWL_PathData(CPWL_Point(center_point.x - fWidth / 10.0f - fWidth * 0.3f,
2346 center_point.y - fHeight * 0.3f),
2347 PWLPT_LINETO),
2348 CPWL_PathData(CPWL_Point(center_point.x - fWidth / 10, center_point.y),
2349 PWLPT_LINETO),
2350 CPWL_PathData(CPWL_Point(center_point.x - fWidth / 10 - fWidth * 0.3f,
2351 center_point.y + fHeight * 0.3f),
2352 PWLPT_LINETO),
2353 CPWL_PathData(
2354 CPWL_Point(center_point.x - fWidth * 0.3f,
2355 center_point.y + fHeight / 10.0f + fHeight * 0.3f),
2356 PWLPT_LINETO),
2357 CPWL_PathData(
2358 CPWL_Point(center_point.x, center_point.y + fHeight / 10.0f),
2359 PWLPT_LINETO)};
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07002360
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002361 if (type == PWLPT_STREAM)
2362 sPathData = GetAppStreamFromArray(PathArray, 13);
2363 else
2364 GetPathDataFromArray(path, PathArray, 13);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07002365}
2366
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002367void CPWL_Utils::GetGraphics_Help(CFX_ByteString& sPathData,
2368 CFX_PathData& path,
2369 const CPDF_Rect& crBBox,
2370 const PWL_PATH_TYPE type) {
2371 FX_FLOAT fWidth = crBBox.right - crBBox.left;
2372 FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07002373
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002374 CPWL_PathData PathArray[] = {
2375 CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 60.0f,
2376 crBBox.bottom + fHeight / 2.0f),
2377 PWLPT_MOVETO),
2378 CPWL_PathData(
2379 CPWL_Point(crBBox.left + fWidth / 60.0f,
2380 crBBox.bottom + fHeight / 2.0f +
2381 PWL_BEZIER * (fHeight / 60.0f - fHeight / 2.0f)),
2382 PWLPT_BEZIERTO),
2383 CPWL_PathData(
2384 CPWL_Point(crBBox.left + fWidth / 2.0f -
2385 PWL_BEZIER * (fWidth / 2.0f - fWidth / 60.0f),
2386 crBBox.bottom + fHeight / 60.0f),
2387 PWLPT_BEZIERTO),
2388 CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 2.0f,
2389 crBBox.bottom + fHeight / 60.0f),
2390 PWLPT_BEZIERTO),
2391 CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 2.0f +
2392 PWL_BEZIER * fWidth * 29 / 60.0f,
2393 crBBox.bottom + fHeight / 60.0f),
2394 PWLPT_BEZIERTO),
2395 CPWL_PathData(
2396 CPWL_Point(crBBox.right - fWidth / 60.0f,
2397 crBBox.bottom + fHeight / 2.0f +
2398 PWL_BEZIER * (fHeight / 60.0f - fHeight / 2.0f)),
2399 PWLPT_BEZIERTO),
2400 CPWL_PathData(CPWL_Point(crBBox.right - fWidth / 60.0f,
2401 crBBox.bottom + fHeight / 2.0f),
2402 PWLPT_BEZIERTO),
2403 CPWL_PathData(CPWL_Point(crBBox.right - fWidth / 60.0f,
2404 crBBox.bottom + fHeight / 2.0f +
2405 PWL_BEZIER * fHeight * 29 / 60.0f),
2406 PWLPT_BEZIERTO),
2407 CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 2.0f +
2408 PWL_BEZIER * fWidth * 29 / 60.0f,
2409 crBBox.top - fHeight / 60.0f),
2410 PWLPT_BEZIERTO),
2411 CPWL_PathData(
2412 CPWL_Point(crBBox.left + fWidth / 2.0f, crBBox.top - fHeight / 60.0f),
2413 PWLPT_BEZIERTO),
2414 CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 2.0f -
2415 PWL_BEZIER * fWidth * 29 / 60.0f,
2416 crBBox.top - fHeight / 60.0f),
2417 PWLPT_BEZIERTO),
2418 CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 60.0f,
2419 crBBox.bottom + fHeight / 2.0f +
2420 PWL_BEZIER * fHeight * 29 / 60.0f),
2421 PWLPT_BEZIERTO),
2422 CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 60.0f,
2423 crBBox.bottom + fHeight / 2.0f),
2424 PWLPT_BEZIERTO),
2425 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.27f,
2426 crBBox.top - fHeight * 0.36f),
2427 PWLPT_MOVETO),
2428 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.27f,
2429 crBBox.top - fHeight * 0.36f +
2430 PWL_BEZIER * fHeight * 0.23f),
2431 PWLPT_BEZIERTO),
2432 CPWL_PathData(
2433 CPWL_Point(crBBox.left + fWidth * 0.5f - PWL_BEZIER * fWidth * 0.23f,
2434 crBBox.bottom + fHeight * 0.87f),
2435 PWLPT_BEZIERTO),
2436 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.5f,
2437 crBBox.bottom + fHeight * 0.87f),
2438 PWLPT_BEZIERTO),
2439 CPWL_PathData(
2440 CPWL_Point(crBBox.left + fWidth * 0.5f + PWL_BEZIER * fWidth * 0.23f,
2441 crBBox.bottom + fHeight * 0.87f),
2442 PWLPT_BEZIERTO),
2443 CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 0.27f,
2444 crBBox.top - fHeight * 0.36f +
2445 PWL_BEZIER * fHeight * 0.23f),
2446 PWLPT_BEZIERTO),
2447 CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 0.27f,
2448 crBBox.top - fHeight * 0.36f),
2449 PWLPT_BEZIERTO),
2450 CPWL_PathData(
2451 CPWL_Point(crBBox.right - fWidth * 0.27f - fWidth * 0.08f * 0.2f,
2452 crBBox.top - fHeight * 0.36f - fHeight * 0.15f * 0.7f),
2453 PWLPT_BEZIERTO),
2454 CPWL_PathData(
2455 CPWL_Point(crBBox.right - fWidth * 0.35f + fWidth * 0.08f * 0.2f,
2456 crBBox.top - fHeight * 0.51f + fHeight * 0.15f * 0.2f),
2457 PWLPT_BEZIERTO),
2458 CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 0.35f,
2459 crBBox.top - fHeight * 0.51f),
2460 PWLPT_BEZIERTO),
2461 CPWL_PathData(
2462 CPWL_Point(crBBox.right - fWidth * 0.35f - fWidth * 0.1f * 0.5f,
2463 crBBox.top - fHeight * 0.51f - fHeight * 0.15f * 0.3f),
2464 PWLPT_BEZIERTO),
2465 CPWL_PathData(
2466 CPWL_Point(crBBox.right - fWidth * 0.45f - fWidth * 0.1f * 0.5f,
2467 crBBox.top - fHeight * 0.68f + fHeight * 0.15f * 0.5f),
2468 PWLPT_BEZIERTO),
2469 CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 0.45f,
2470 crBBox.top - fHeight * 0.68f),
2471 PWLPT_BEZIERTO),
2472 CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 0.45f,
2473 crBBox.bottom + fHeight * 0.30f),
2474 PWLPT_LINETO),
2475 CPWL_PathData(
2476 CPWL_Point(crBBox.right - fWidth * 0.45f,
2477 crBBox.bottom + fHeight * 0.30f - fWidth * 0.1f * 0.7f),
2478 PWLPT_BEZIERTO),
2479 CPWL_PathData(
2480 CPWL_Point(crBBox.right - fWidth * 0.55f,
2481 crBBox.bottom + fHeight * 0.30f - fWidth * 0.1f * 0.7f),
2482 PWLPT_BEZIERTO),
2483 CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 0.55f,
2484 crBBox.bottom + fHeight * 0.30f),
2485 PWLPT_BEZIERTO),
2486 CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 0.55f,
2487 crBBox.top - fHeight * 0.66f),
2488 PWLPT_LINETO),
2489 CPWL_PathData(
2490 CPWL_Point(crBBox.right - fWidth * 0.55f - fWidth * 0.1f * 0.05f,
2491 crBBox.top - fHeight * 0.66f + fHeight * 0.18f * 0.5f),
2492 PWLPT_BEZIERTO),
2493 CPWL_PathData(
2494 CPWL_Point(crBBox.right - fWidth * 0.45f - fWidth * 0.1f * 0.05f,
2495 crBBox.top - fHeight * 0.48f - fHeight * 0.18f * 0.3f),
2496 PWLPT_BEZIERTO),
2497 CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 0.45f,
2498 crBBox.top - fHeight * 0.48f),
2499 PWLPT_BEZIERTO),
2500 CPWL_PathData(
2501 CPWL_Point(crBBox.right - fWidth * 0.45f + fWidth * 0.08f * 0.2f,
2502 crBBox.top - fHeight * 0.48f + fHeight * 0.18f * 0.2f),
2503 PWLPT_BEZIERTO),
2504 CPWL_PathData(
2505 CPWL_Point(crBBox.right - fWidth * 0.37f - fWidth * 0.08f * 0.2f,
2506 crBBox.top - fHeight * 0.36f - fHeight * 0.18f * 0.7f),
2507 PWLPT_BEZIERTO),
2508 CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 0.37f,
2509 crBBox.top - fHeight * 0.36f),
2510 PWLPT_BEZIERTO),
2511 CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 0.37f,
2512 crBBox.top - fHeight * 0.36f +
2513 PWL_BEZIER * fHeight * 0.13f),
2514 PWLPT_BEZIERTO),
2515 CPWL_PathData(
2516 CPWL_Point(crBBox.left + fWidth * 0.5f + PWL_BEZIER * fWidth * 0.13f,
2517 crBBox.bottom + fHeight * 0.77f),
2518 PWLPT_BEZIERTO),
2519 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.5f,
2520 crBBox.bottom + fHeight * 0.77f),
2521 PWLPT_BEZIERTO),
2522 CPWL_PathData(
2523 CPWL_Point(crBBox.left + fWidth * 0.5f - PWL_BEZIER * fWidth * 0.13f,
2524 crBBox.bottom + fHeight * 0.77f),
2525 PWLPT_BEZIERTO),
2526 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.37f,
2527 crBBox.top - fHeight * 0.36f +
2528 PWL_BEZIER * fHeight * 0.13f),
2529 PWLPT_BEZIERTO),
2530 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.37f,
2531 crBBox.top - fHeight * 0.36f),
2532 PWLPT_BEZIERTO),
2533 CPWL_PathData(
2534 CPWL_Point(crBBox.left + fWidth * 0.37f,
2535 crBBox.top - fHeight * 0.36f - fWidth * 0.1f * 0.6f),
2536 PWLPT_BEZIERTO),
2537 CPWL_PathData(
2538 CPWL_Point(crBBox.left + fWidth * 0.27f,
2539 crBBox.top - fHeight * 0.36f - fWidth * 0.1f * 0.6f),
2540 PWLPT_BEZIERTO),
2541 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.27f,
2542 crBBox.top - fHeight * 0.36f),
2543 PWLPT_BEZIERTO),
2544 CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 0.56f,
2545 crBBox.bottom + fHeight * 0.13f),
2546 PWLPT_MOVETO),
2547 CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 0.56f,
2548 crBBox.bottom + fHeight * 0.13f +
2549 PWL_BEZIER * fHeight * 0.055f),
2550 PWLPT_BEZIERTO),
2551 CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 0.505f -
2552 PWL_BEZIER * fWidth * 0.095f,
2553 crBBox.bottom + fHeight * 0.185f),
2554 PWLPT_BEZIERTO),
2555 CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 0.505f,
2556 crBBox.bottom + fHeight * 0.185f),
2557 PWLPT_BEZIERTO),
2558 CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 0.505f +
2559 PWL_BEZIER * fWidth * 0.065f,
2560 crBBox.bottom + fHeight * 0.185f),
2561 PWLPT_BEZIERTO),
2562 CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 0.44f,
2563 crBBox.bottom + fHeight * 0.13f +
2564 PWL_BEZIER * fHeight * 0.055f),
2565 PWLPT_BEZIERTO),
2566 CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 0.44f,
2567 crBBox.bottom + fHeight * 0.13f),
2568 PWLPT_BEZIERTO),
2569 CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 0.44f,
2570 crBBox.bottom + fHeight * 0.13f -
2571 PWL_BEZIER * fHeight * 0.055f),
2572 PWLPT_BEZIERTO),
2573 CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 0.505f +
2574 PWL_BEZIER * fWidth * 0.065f,
2575 crBBox.bottom + fHeight * 0.075f),
2576 PWLPT_BEZIERTO),
2577 CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 0.505f,
2578 crBBox.bottom + fHeight * 0.075f),
2579 PWLPT_BEZIERTO),
2580 CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 0.505f -
2581 PWL_BEZIER * fWidth * 0.065f,
2582 crBBox.bottom + fHeight * 0.075f),
2583 PWLPT_BEZIERTO),
2584 CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 0.56f,
2585 crBBox.bottom + fHeight * 0.13f -
2586 PWL_BEZIER * fHeight * 0.055f),
2587 PWLPT_BEZIERTO),
2588 CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 0.56f,
2589 crBBox.bottom + fHeight * 0.13f),
2590 PWLPT_BEZIERTO)};
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07002591
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002592 if (type == PWLPT_STREAM)
2593 sPathData = GetAppStreamFromArray(PathArray, 59);
2594 else
2595 GetPathDataFromArray(path, PathArray, 59);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07002596}
2597
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002598void CPWL_Utils::GetGraphics_InsertText(CFX_ByteString& sPathData,
2599 CFX_PathData& path,
2600 const CPDF_Rect& crBBox,
2601 const PWL_PATH_TYPE type) {
2602 FX_FLOAT fWidth = crBBox.right - crBBox.left;
2603 FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07002604
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002605 CPWL_PathData PathArray[] = {
2606 CPWL_PathData(
2607 CPWL_Point(crBBox.left + fWidth / 10, crBBox.bottom + fHeight / 10),
2608 PWLPT_MOVETO),
2609 CPWL_PathData(
2610 CPWL_Point(crBBox.left + fWidth / 2, crBBox.top - fHeight * 2 / 15),
2611 PWLPT_LINETO),
2612 CPWL_PathData(
2613 CPWL_Point(crBBox.right - fWidth / 10, crBBox.bottom + fHeight / 10),
2614 PWLPT_LINETO),
2615 CPWL_PathData(
2616 CPWL_Point(crBBox.left + fWidth / 10, crBBox.bottom + fHeight / 10),
2617 PWLPT_LINETO)};
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07002618
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002619 if (type == PWLPT_STREAM)
2620 sPathData = GetAppStreamFromArray(PathArray, 4);
2621 else
2622 GetPathDataFromArray(path, PathArray, 4);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07002623}
2624
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002625void CPWL_Utils::GetGraphics_Key(CFX_ByteString& sPathData,
2626 CFX_PathData& path,
2627 const CPDF_Rect& crBBox,
2628 const PWL_PATH_TYPE type) {
2629 FX_FLOAT fWidth = crBBox.right - crBBox.left;
2630 FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
2631 FX_FLOAT k = -fHeight / fWidth;
2632 CPWL_Point tail;
2633 CPWL_Point CicleCenter;
2634 tail.x = crBBox.left + fWidth * 0.9f;
2635 tail.y = k * (tail.x - crBBox.right) + crBBox.bottom;
2636 CicleCenter.x = crBBox.left + fWidth * 0.15f;
2637 CicleCenter.y = k * (CicleCenter.x - crBBox.right) + crBBox.bottom;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07002638
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002639 CPWL_PathData PathArray[] = {
2640 CPWL_PathData(
2641 CPWL_Point(tail.x + fWidth / 30.0f, -fWidth / 30.0f / k + tail.y),
2642 PWLPT_MOVETO),
2643 CPWL_PathData(CPWL_Point(tail.x + fWidth / 30.0f - fWidth * 0.18f,
2644 -k * fWidth * 0.18f - fWidth / 30 / k + tail.y),
2645 PWLPT_LINETO),
2646 CPWL_PathData(
2647 CPWL_Point(tail.x + fWidth / 30 - fWidth * 0.18f + fWidth * 0.07f,
2648 -fWidth * 0.07f / k - k * fWidth * 0.18f -
2649 fWidth / 30 / k + tail.y),
2650 PWLPT_LINETO),
2651 CPWL_PathData(
2652 CPWL_Point(tail.x + fWidth / 30 - fWidth * 0.18f - fWidth / 20 +
2653 fWidth * 0.07f,
2654 -fWidth * 0.07f / k - k * fWidth / 20 -
2655 k * fWidth * 0.18f - fWidth / 30 / k + tail.y),
2656 PWLPT_LINETO),
2657 CPWL_PathData(
2658 CPWL_Point(
2659 tail.x + fWidth / 30 - fWidth * 0.18f - fWidth / 20,
2660 -k * fWidth / 20 - k * fWidth * 0.18f - fWidth / 30 / k + tail.y),
2661 PWLPT_LINETO),
2662 CPWL_PathData(
2663 CPWL_Point(
2664 tail.x + fWidth / 30 - fWidth * 0.18f - fWidth / 20 - fWidth / 15,
2665 -k * fWidth / 15 - k * fWidth / 20 - k * fWidth * 0.18f -
2666 fWidth / 30 / k + tail.y),
2667 PWLPT_LINETO),
2668 CPWL_PathData(
2669 CPWL_Point(tail.x + fWidth / 30 - fWidth * 0.18f - fWidth / 20 -
2670 fWidth / 15 + fWidth * 0.07f,
2671 -fWidth * 0.07f / k - k * fWidth / 15 - k * fWidth / 20 -
2672 k * fWidth * 0.18f - fWidth / 30 / k + tail.y),
2673 PWLPT_LINETO),
2674 CPWL_PathData(
2675 CPWL_Point(tail.x + fWidth / 30 - fWidth * 0.18f - fWidth / 20 -
2676 fWidth / 15 - fWidth / 20 + fWidth * 0.07f,
2677 -fWidth * 0.07f / k + -k * fWidth / 20 + -k * fWidth / 15 -
2678 k * fWidth / 20 - k * fWidth * 0.18f -
2679 fWidth / 30 / k + tail.y),
2680 PWLPT_LINETO),
2681 CPWL_PathData(
2682 CPWL_Point(tail.x + fWidth / 30 - fWidth * 0.18f - fWidth / 20 -
2683 fWidth / 15 - fWidth / 20,
2684 -k * fWidth / 20 + -k * fWidth / 15 - k * fWidth / 20 -
2685 k * fWidth * 0.18f - fWidth / 30 / k + tail.y),
2686 PWLPT_LINETO),
2687 CPWL_PathData(CPWL_Point(tail.x + fWidth / 30 - fWidth * 0.45f,
2688 -k * fWidth * 0.45f - fWidth / 30 / k + tail.y),
2689 PWLPT_LINETO),
2690 CPWL_PathData(
2691 CPWL_Point(tail.x + fWidth / 30 - fWidth * 0.45f + fWidth * 0.2f,
2692 -fWidth * 0.4f / k - k * fWidth * 0.45f - fWidth / 30 / k +
2693 tail.y),
2694 PWLPT_BEZIERTO),
2695 CPWL_PathData(CPWL_Point(CicleCenter.x + fWidth * 0.2f,
2696 -fWidth * 0.1f / k + CicleCenter.y),
2697 PWLPT_BEZIERTO),
2698 CPWL_PathData(CPWL_Point(CicleCenter.x, CicleCenter.y), PWLPT_BEZIERTO),
2699 CPWL_PathData(CPWL_Point(CicleCenter.x - fWidth / 60.0f,
2700 -k * fWidth / 60 + CicleCenter.y),
2701 PWLPT_BEZIERTO),
2702 CPWL_PathData(CPWL_Point(CicleCenter.x - fWidth / 60,
2703 -k * fWidth / 60 + CicleCenter.y),
2704 PWLPT_BEZIERTO),
2705 CPWL_PathData(CPWL_Point(CicleCenter.x, CicleCenter.y), PWLPT_BEZIERTO),
2706 CPWL_PathData(
2707 CPWL_Point(CicleCenter.x - fWidth * 0.22f,
2708 fWidth * 0.35f / k + CicleCenter.y - fHeight * 0.05f),
2709 PWLPT_BEZIERTO),
2710 CPWL_PathData(
2711 CPWL_Point(tail.x - fWidth / 30 - fWidth * 0.45f - fWidth * 0.18f,
2712 fWidth * 0.05f / k - k * fWidth * 0.45f + fWidth / 30 / k +
2713 tail.y - fHeight * 0.05f),
2714 PWLPT_BEZIERTO),
2715 CPWL_PathData(
2716 CPWL_Point(tail.x - fWidth / 30.0f - fWidth * 0.45f,
2717 -k * fWidth * 0.45f + fWidth / 30.0f / k + tail.y),
2718 PWLPT_BEZIERTO),
2719 CPWL_PathData(
2720 CPWL_Point(tail.x - fWidth / 30.0f, fWidth / 30.0f / k + tail.y),
2721 PWLPT_LINETO),
2722 CPWL_PathData(CPWL_Point(tail.x + fWidth / 30, -fWidth / 30 / k + tail.y),
2723 PWLPT_LINETO),
2724 CPWL_PathData(CPWL_Point(CicleCenter.x + fWidth * 0.08f,
2725 k * fWidth * 0.08f + CicleCenter.y),
2726 PWLPT_MOVETO),
2727 CPWL_PathData(
2728 CPWL_Point(CicleCenter.x + fWidth * 0.08f + fWidth * 0.1f,
2729 -fWidth * 0.1f / k + k * fWidth * 0.08f + CicleCenter.y),
2730 PWLPT_BEZIERTO),
2731 CPWL_PathData(
2732 CPWL_Point(CicleCenter.x + fWidth * 0.22f + fWidth * 0.1f,
2733 k * fWidth * 0.22f + CicleCenter.y - fWidth * 0.1f / k),
2734 PWLPT_BEZIERTO),
2735 CPWL_PathData(CPWL_Point(CicleCenter.x + fWidth * 0.22f,
2736 k * fWidth * 0.22f + CicleCenter.y),
2737 PWLPT_BEZIERTO),
2738 CPWL_PathData(
2739 CPWL_Point(CicleCenter.x + fWidth * 0.22f - fWidth * 0.1f,
2740 fWidth * 0.1f / k + k * fWidth * 0.22f + CicleCenter.y),
2741 PWLPT_BEZIERTO),
2742 CPWL_PathData(
2743 CPWL_Point(CicleCenter.x + fWidth * 0.08f - fWidth * 0.1f,
2744 fWidth * 0.1f / k + k * fWidth * 0.08f + CicleCenter.y),
2745 PWLPT_BEZIERTO),
2746 CPWL_PathData(CPWL_Point(CicleCenter.x + fWidth * 0.08f,
2747 k * fWidth * 0.08f + CicleCenter.y),
2748 PWLPT_BEZIERTO)};
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07002749
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002750 if (type == PWLPT_STREAM)
2751 sPathData = GetAppStreamFromArray(PathArray, 28);
2752 else
2753 GetPathDataFromArray(path, PathArray, 28);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07002754}
2755
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002756void CPWL_Utils::GetGraphics_NewParagraph(CFX_ByteString& sPathData,
2757 CFX_PathData& path,
2758 const CPDF_Rect& crBBox,
2759 const PWL_PATH_TYPE type) {
2760 FX_FLOAT fWidth = crBBox.right - crBBox.left;
2761 FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07002762
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002763 CPWL_PathData PathArray[] = {
2764 CPWL_PathData(
2765 CPWL_Point(crBBox.left + fWidth / 2.0f, crBBox.top - fHeight / 20.0f),
2766 PWLPT_MOVETO),
2767 CPWL_PathData(
2768 CPWL_Point(crBBox.left + fWidth / 10.0f, crBBox.top - fHeight / 2.0f),
2769 PWLPT_LINETO),
2770 CPWL_PathData(CPWL_Point(crBBox.right - fWidth / 10.0f,
2771 crBBox.top - fHeight / 2.0f),
2772 PWLPT_LINETO),
2773 CPWL_PathData(
2774 CPWL_Point(crBBox.left + fWidth / 2.0f, crBBox.top - fHeight / 20.0f),
2775 PWLPT_LINETO),
2776 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.12f,
2777 crBBox.top - fHeight * 17 / 30.0f),
2778 PWLPT_MOVETO),
2779 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.12f,
2780 crBBox.bottom + fHeight / 10.0f),
2781 PWLPT_LINETO),
2782 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.22f,
2783 crBBox.bottom + fHeight / 10.0f),
2784 PWLPT_LINETO),
2785 CPWL_PathData(
2786 CPWL_Point(crBBox.left + fWidth * 0.22f,
2787 crBBox.top - fHeight * 17 / 30.0f - fWidth * 0.14f),
2788 PWLPT_LINETO),
2789 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.38f,
2790 crBBox.bottom + fHeight / 10.0f),
2791 PWLPT_LINETO),
2792 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.48f,
2793 crBBox.bottom + fHeight / 10.0f),
2794 PWLPT_LINETO),
2795 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.48f,
2796 crBBox.top - fHeight * 17 / 30.0f),
2797 PWLPT_LINETO),
2798 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.38f,
2799 crBBox.top - fHeight * 17 / 30.0f),
2800 PWLPT_LINETO),
2801 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.38f,
2802 crBBox.bottom + fWidth * 0.24f),
2803 PWLPT_LINETO),
2804 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.22f,
2805 crBBox.top - fHeight * 17 / 30.0f),
2806 PWLPT_LINETO),
2807 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.12f,
2808 crBBox.top - fHeight * 17 / 30.0f),
2809 PWLPT_LINETO),
2810 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.6f,
2811 crBBox.bottom + fHeight / 10.0f),
2812 PWLPT_MOVETO),
2813 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.7f,
2814 crBBox.bottom + fHeight / 10.0f),
2815 PWLPT_LINETO),
2816 CPWL_PathData(
2817 CPWL_Point(crBBox.left + fWidth * 0.7f,
2818 crBBox.bottom + fHeight / 10.0f + fHeight / 7.0f),
2819 PWLPT_LINETO),
2820 CPWL_PathData(
2821 CPWL_Point(crBBox.left + fWidth * 0.97f,
2822 crBBox.bottom + fHeight / 10.0f + fHeight / 7.0f),
2823 PWLPT_BEZIERTO),
2824 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.97f,
2825 crBBox.top - fHeight * 17 / 30.0f),
2826 PWLPT_BEZIERTO),
2827 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.7f,
2828 crBBox.top - fHeight * 17 / 30.0f),
2829 PWLPT_BEZIERTO),
2830 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.6f,
2831 crBBox.top - fHeight * 17 / 30.0f),
2832 PWLPT_LINETO),
2833 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.6f,
2834 crBBox.bottom + fHeight / 10.0f),
2835 PWLPT_LINETO),
2836 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.7f,
2837 crBBox.bottom + fHeight / 7 + fHeight * 0.18f),
2838 PWLPT_MOVETO),
2839 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.85f,
2840 crBBox.bottom + fHeight / 7 + fHeight * 0.18f),
2841 PWLPT_BEZIERTO),
2842 CPWL_PathData(
2843 CPWL_Point(crBBox.left + fWidth * 0.85f,
2844 crBBox.top - fHeight * 17 / 30.0f - fHeight * 0.08f),
2845 PWLPT_BEZIERTO),
2846 CPWL_PathData(
2847 CPWL_Point(crBBox.left + fWidth * 0.7f,
2848 crBBox.top - fHeight * 17 / 30.0f - fHeight * 0.08f),
2849 PWLPT_BEZIERTO),
2850 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.7f,
2851 crBBox.bottom + fHeight / 7 + fHeight * 0.18f),
2852 PWLPT_LINETO)};
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07002853
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002854 if (type == PWLPT_STREAM)
2855 sPathData = GetAppStreamFromArray(PathArray, 28);
2856 else
2857 GetPathDataFromArray(path, PathArray, 28);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07002858}
2859
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002860void CPWL_Utils::GetGraphics_TextNote(CFX_ByteString& sPathData,
2861 CFX_PathData& path,
2862 const CPDF_Rect& crBBox,
2863 const PWL_PATH_TYPE type) {
2864 FX_FLOAT fWidth = crBBox.right - crBBox.left;
2865 FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07002866
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002867 CPWL_PathData PathArray[] = {
2868 CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 3 / 10.0f,
2869 crBBox.bottom + fHeight / 15.0f),
2870 PWLPT_MOVETO),
2871 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 7 / 10.0f,
2872 crBBox.bottom + fHeight * 4 / 15.0f),
2873 PWLPT_LINETO),
2874 CPWL_PathData(CPWL_Point(crBBox.right - fWidth / 10.0f,
2875 crBBox.bottom + fHeight * 4 / 15.0f),
2876 PWLPT_LINETO),
2877 CPWL_PathData(CPWL_Point(crBBox.right - fWidth / 10.0f,
2878 crBBox.top - fHeight / 15.0f),
2879 PWLPT_LINETO),
2880 CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 10.0f,
2881 crBBox.top - fHeight / 15.0f),
2882 PWLPT_LINETO),
2883 CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 10.0f,
2884 crBBox.bottom + fHeight / 15.0f),
2885 PWLPT_LINETO),
2886 CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 3 / 10.0f,
2887 crBBox.bottom + fHeight / 15.0f),
2888 PWLPT_LINETO),
2889 CPWL_PathData(CPWL_Point(crBBox.right - fWidth / 10.0f,
2890 crBBox.bottom + fHeight * 4 / 15.0f),
2891 PWLPT_LINETO),
2892 CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 3 / 10.0f,
2893 crBBox.bottom + fHeight / 15.0f),
2894 PWLPT_LINETO),
2895 CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 3 / 10.0f,
2896 crBBox.bottom + fHeight * 4 / 15.0f),
2897 PWLPT_LINETO),
2898 CPWL_PathData(CPWL_Point(crBBox.right - fWidth / 10.0f,
2899 crBBox.bottom + fHeight * 4 / 15.0f),
2900 PWLPT_LINETO),
2901 CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 5.0f,
2902 crBBox.top - fHeight * 4 / 15.0f),
2903 PWLPT_MOVETO),
2904 CPWL_PathData(CPWL_Point(crBBox.right - fWidth / 5.0f,
2905 crBBox.top - fHeight * 4 / 15.0f),
2906 PWLPT_LINETO),
2907 CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 5.0f,
2908 crBBox.top - fHeight * 7 / 15.0f),
2909 PWLPT_MOVETO),
2910 CPWL_PathData(CPWL_Point(crBBox.right - fWidth / 5.0f,
2911 crBBox.top - fHeight * 7 / 15.0f),
2912 PWLPT_LINETO),
2913 CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 5.0f,
2914 crBBox.top - fHeight * 10 / 15.0f),
2915 PWLPT_MOVETO),
2916 CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 3 / 10.0f,
2917 crBBox.top - fHeight * 10 / 15.0f),
2918 PWLPT_LINETO)};
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07002919
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002920 if (type == PWLPT_STREAM)
2921 sPathData = GetAppStreamFromArray(PathArray, 17);
2922 else
2923 GetPathDataFromArray(path, PathArray, 17);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07002924}
2925
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002926void CPWL_Utils::GetGraphics_Paragraph(CFX_ByteString& sPathData,
2927 CFX_PathData& path,
2928 const CPDF_Rect& crBBox,
2929 const PWL_PATH_TYPE type) {
2930 FX_FLOAT fWidth = crBBox.right - crBBox.left;
2931 FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07002932
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002933 CPWL_PathData PathArray[] = {
2934 CPWL_PathData(
2935 CPWL_Point(crBBox.left + fWidth / 2.0f, crBBox.top - fHeight / 15.0f),
2936 PWLPT_MOVETO),
2937 CPWL_PathData(
2938 CPWL_Point(crBBox.left + fWidth * 0.7f, crBBox.top - fHeight / 15.0f),
2939 PWLPT_LINETO),
2940 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.7f,
2941 crBBox.bottom + fHeight / 15.0f),
2942 PWLPT_LINETO),
2943 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.634f,
2944 crBBox.bottom + fHeight / 15.0f),
2945 PWLPT_LINETO),
2946 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.634f,
2947 crBBox.top - fHeight * 2 / 15.0f),
2948 PWLPT_LINETO),
2949 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.566f,
2950 crBBox.top - fHeight * 2 / 15.0f),
2951 PWLPT_LINETO),
2952 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.566f,
2953 crBBox.bottom + fHeight / 15.0f),
2954 PWLPT_LINETO),
2955 CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 2.0f,
2956 crBBox.bottom + fHeight / 15.0f),
2957 PWLPT_LINETO),
2958 CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 2.0f,
2959 crBBox.top - fHeight / 15.0f - fHeight * 0.4f),
2960 PWLPT_LINETO),
2961 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.2f,
2962 crBBox.top - fHeight / 15.0f - fHeight * 0.4f),
2963 PWLPT_BEZIERTO),
2964 CPWL_PathData(
2965 CPWL_Point(crBBox.left + fWidth * 0.2f, crBBox.top - fHeight / 15.0f),
2966 PWLPT_BEZIERTO),
2967 CPWL_PathData(
2968 CPWL_Point(crBBox.left + fWidth / 2.0f, crBBox.top - fHeight / 15.0f),
2969 PWLPT_BEZIERTO)};
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07002970
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002971 if (type == PWLPT_STREAM)
2972 sPathData = GetAppStreamFromArray(PathArray, 12);
2973 else
2974 GetPathDataFromArray(path, PathArray, 12);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07002975}
2976
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002977void CPWL_Utils::GetGraphics_RightArrow(CFX_ByteString& sPathData,
2978 CFX_PathData& path,
2979 const CPDF_Rect& crBBox,
2980 const PWL_PATH_TYPE type) {
2981 FX_FLOAT fWidth = crBBox.right - crBBox.left;
2982 FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07002983
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002984 CPWL_PathData PathArray[] = {
2985 CPWL_PathData(CPWL_Point(crBBox.right - fWidth / 15.0f,
2986 crBBox.top - fHeight / 2.0f),
2987 PWLPT_MOVETO),
2988 CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 2.0f + fWidth / 8.0f,
2989 crBBox.bottom + fHeight / 5.0f),
2990 PWLPT_LINETO),
2991 CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 2.0f,
2992 crBBox.bottom + fHeight / 5.0f),
2993 PWLPT_LINETO),
2994 CPWL_PathData(CPWL_Point(crBBox.right - fWidth / 15.0f - fWidth * 0.15f,
2995 crBBox.top - fHeight / 2.0f - fWidth / 25.0f),
2996 PWLPT_LINETO),
2997 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.1f,
2998 crBBox.top - fHeight / 2.0f - fWidth / 25.0f),
2999 PWLPT_LINETO),
3000 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.1f,
3001 crBBox.top - fHeight / 2.0f + fWidth / 25.0f),
3002 PWLPT_LINETO),
3003 CPWL_PathData(CPWL_Point(crBBox.right - fWidth / 15.0f - fWidth * 0.15f,
3004 crBBox.top - fHeight / 2.0f + fWidth / 25.0f),
3005 PWLPT_LINETO),
3006 CPWL_PathData(
3007 CPWL_Point(crBBox.left + fWidth / 2.0f, crBBox.top - fHeight / 5.0f),
3008 PWLPT_LINETO),
3009 CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 2.0f + fWidth / 8.0f,
3010 crBBox.top - fHeight / 5.0f),
3011 PWLPT_LINETO),
3012 CPWL_PathData(CPWL_Point(crBBox.right - fWidth / 15.0f,
3013 crBBox.top - fHeight / 2.0f),
3014 PWLPT_LINETO)};
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07003015
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003016 if (type == PWLPT_STREAM)
3017 sPathData = GetAppStreamFromArray(PathArray, 10);
3018 else
3019 GetPathDataFromArray(path, PathArray, 10);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07003020}
3021
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003022void CPWL_Utils::GetGraphics_RightPointer(CFX_ByteString& sPathData,
3023 CFX_PathData& path,
3024 const CPDF_Rect& crBBox,
3025 const PWL_PATH_TYPE type) {
3026 FX_FLOAT fWidth = crBBox.right - crBBox.left;
3027 FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07003028
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003029 CPWL_PathData PathArray[] = {
3030 CPWL_PathData(CPWL_Point(crBBox.right - fWidth / 30.0f,
3031 crBBox.top - fHeight / 2.0f),
3032 PWLPT_MOVETO),
3033 CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 30.0f,
3034 crBBox.bottom + fHeight / 6.0f),
3035 PWLPT_LINETO),
3036 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 4 / 15.0f,
3037 crBBox.top - fHeight / 2.0f),
3038 PWLPT_LINETO),
3039 CPWL_PathData(
3040 CPWL_Point(crBBox.left + fWidth / 30.0f, crBBox.top - fHeight / 6.0f),
3041 PWLPT_LINETO),
3042 CPWL_PathData(CPWL_Point(crBBox.right - fWidth / 30.0f,
3043 crBBox.top - fHeight / 2.0f),
3044 PWLPT_LINETO)};
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07003045
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003046 if (type == PWLPT_STREAM)
3047 sPathData = GetAppStreamFromArray(PathArray, 5);
3048 else
3049 GetPathDataFromArray(path, PathArray, 5);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07003050}
3051
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003052void CPWL_Utils::GetGraphics_Star(CFX_ByteString& sPathData,
3053 CFX_PathData& path,
3054 const CPDF_Rect& crBBox,
3055 const PWL_PATH_TYPE type) {
3056 FX_FLOAT fLongRadius =
3057 (crBBox.top - crBBox.bottom) / (1 + (FX_FLOAT)cos(PWL_PI / 5.0f));
3058 fLongRadius = fLongRadius * 0.7f;
3059 FX_FLOAT fShortRadius = fLongRadius * 0.55f;
3060 CPDF_Point ptCenter = CPDF_Point((crBBox.left + crBBox.right) / 2.0f,
3061 (crBBox.top + crBBox.bottom) / 2.0f);
Lei Zhanga6d9f0e2015-06-13 00:48:38 -07003062
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003063 FX_FLOAT px1[5], py1[5];
3064 FX_FLOAT px2[5], py2[5];
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07003065
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003066 FX_FLOAT fAngel = PWL_PI / 10.0f;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07003067
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003068 for (int32_t i = 0; i < 5; i++) {
3069 px1[i] = ptCenter.x + fLongRadius * (FX_FLOAT)cos(fAngel);
3070 py1[i] = ptCenter.y + fLongRadius * (FX_FLOAT)sin(fAngel);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07003071
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003072 fAngel += PWL_PI * 2 / 5.0f;
3073 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07003074
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003075 fAngel = PWL_PI / 5.0f + PWL_PI / 10.0f;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07003076
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003077 for (int32_t j = 0; j < 5; j++) {
3078 px2[j] = ptCenter.x + fShortRadius * (FX_FLOAT)cos(fAngel);
3079 py2[j] = ptCenter.y + fShortRadius * (FX_FLOAT)sin(fAngel);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07003080
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003081 fAngel += PWL_PI * 2 / 5.0f;
3082 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07003083
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003084 CPWL_PathData PathArray[11];
3085 PathArray[0] = CPWL_PathData(CPWL_Point(px1[0], py1[0]), PWLPT_MOVETO);
3086 PathArray[1] = CPWL_PathData(CPWL_Point(px2[0], py2[0]), PWLPT_LINETO);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07003087
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003088 for (int32_t k = 0; k < 4; k++) {
3089 PathArray[(k + 1) * 2] =
3090 CPWL_PathData(CPWL_Point(px1[k + 1], py1[k + 1]), PWLPT_LINETO);
3091 PathArray[(k + 1) * 2 + 1] =
3092 CPWL_PathData(CPWL_Point(px2[k + 1], py2[k + 1]), PWLPT_LINETO);
3093 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07003094
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003095 PathArray[10] = CPWL_PathData(CPWL_Point(px1[0], py1[0]), PWLPT_LINETO);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07003096
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003097 if (type == PWLPT_STREAM)
3098 sPathData = GetAppStreamFromArray(PathArray, 11);
3099 else
3100 GetPathDataFromArray(path, PathArray, 11);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07003101}
3102
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003103void CPWL_Utils::GetGraphics_UpArrow(CFX_ByteString& sPathData,
3104 CFX_PathData& path,
3105 const CPDF_Rect& crBBox,
3106 const PWL_PATH_TYPE type) {
3107 FX_FLOAT fWidth = crBBox.right - crBBox.left;
3108 FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07003109
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003110 CPWL_PathData PathArray[] = {
3111 CPWL_PathData(
3112 CPWL_Point(crBBox.left + fWidth / 2.0f, crBBox.top - fHeight / 15.0f),
3113 PWLPT_MOVETO),
3114 CPWL_PathData(CPWL_Point(crBBox.right - fWidth / 10.0f,
3115 crBBox.top - fWidth * 3 / 5.0f),
3116 PWLPT_LINETO),
3117 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.6f,
3118 crBBox.top - fWidth * 3 / 5.0f),
3119 PWLPT_LINETO),
3120 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.6f,
3121 crBBox.bottom + fHeight / 15.0f),
3122 PWLPT_LINETO),
3123 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.4f,
3124 crBBox.bottom + fHeight / 15.0f),
3125 PWLPT_LINETO),
3126 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.4f,
3127 crBBox.top - fWidth * 3 / 5.0f),
3128 PWLPT_LINETO),
3129 CPWL_PathData(
3130 CPWL_Point(crBBox.left + fWidth / 10, crBBox.top - fWidth * 3 / 5.0f),
3131 PWLPT_LINETO),
3132 CPWL_PathData(
3133 CPWL_Point(crBBox.left + fWidth / 2.0f, crBBox.top - fHeight / 15.0f),
3134 PWLPT_LINETO)};
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07003135
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003136 if (type == PWLPT_STREAM)
3137 sPathData = GetAppStreamFromArray(PathArray, 8);
3138 else
3139 GetPathDataFromArray(path, PathArray, 8);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07003140}
3141
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003142void CPWL_Utils::GetGraphics_UpLeftArrow(CFX_ByteString& sPathData,
3143 CFX_PathData& path,
3144 const CPDF_Rect& crBBox,
3145 const PWL_PATH_TYPE type) {
3146 FX_FLOAT fWidth = crBBox.right - crBBox.left;
3147 FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
3148 CPWL_Point leftup(crBBox.left, crBBox.top);
3149 CPWL_Point rightdown(crBBox.right, crBBox.bottom);
3150 FX_FLOAT k = -fHeight / fWidth;
3151 CPWL_Point tail;
3152 tail.x = crBBox.left + fWidth * 4 / 5.0f;
3153 tail.y = k * (tail.x - crBBox.right) + rightdown.y;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07003154
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003155 CPWL_PathData PathArray[] = {
3156 CPWL_PathData(
3157 CPWL_Point(
3158 crBBox.left + fWidth / 20.0f,
3159 k * (crBBox.left + fWidth / 20.0f - rightdown.x) + rightdown.y),
3160 PWLPT_MOVETO),
3161 CPWL_PathData(CPWL_Point(fHeight * 17 / 60.0f / k + tail.x +
3162 fWidth / 10.0f + fWidth / 5.0f,
3163 -fWidth / 5.0f / k + tail.y -
3164 fWidth / 10.0f / k + fHeight * 17 / 60.0f),
3165 PWLPT_LINETO),
3166 CPWL_PathData(
3167 CPWL_Point(fHeight * 17 / 60.0f / k + tail.x + fWidth / 10.0f,
3168 tail.y - fWidth / 10.0f / k + fHeight * 17 / 60.0f),
3169 PWLPT_LINETO),
3170 CPWL_PathData(
3171 CPWL_Point(tail.x + fWidth / 10.0f, tail.y - fWidth / 10.0f / k),
3172 PWLPT_LINETO),
3173 CPWL_PathData(
3174 CPWL_Point(tail.x - fWidth / 10.0f, tail.y + fWidth / 10.0f / k),
3175 PWLPT_LINETO),
3176 CPWL_PathData(
3177 CPWL_Point(fHeight * 17 / 60.0f / k + tail.x - fWidth / 10.0f,
3178 tail.y + fWidth / 10.0f / k + fHeight * 17 / 60.0f),
3179 PWLPT_LINETO),
3180 CPWL_PathData(CPWL_Point(fHeight * 17 / 60.0f / k + tail.x -
3181 fWidth / 10.0f - fWidth / 5.0f,
3182 fWidth / 5.0f / k + tail.y + fWidth / 10.0f / k +
3183 fHeight * 17 / 60.0f),
3184 PWLPT_LINETO),
3185 CPWL_PathData(
3186 CPWL_Point(
3187 crBBox.left + fWidth / 20.0f,
3188 k * (crBBox.left + fWidth / 20.0f - rightdown.x) + rightdown.y),
3189 PWLPT_LINETO)};
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07003190
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003191 if (type == PWLPT_STREAM)
3192 sPathData = GetAppStreamFromArray(PathArray, 8);
3193 else
3194 GetPathDataFromArray(path, PathArray, 8);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07003195}
3196
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003197void CPWL_Utils::GetGraphics_Graph(CFX_ByteString& sPathData,
3198 CFX_PathData& path,
3199 const CPDF_Rect& crBBox,
3200 const PWL_PATH_TYPE type) {
3201 FX_FLOAT fWidth = crBBox.right - crBBox.left;
3202 FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07003203
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003204 CPWL_PathData PathArray[] = {
3205 CPWL_PathData(
3206 CPWL_Point(crBBox.left + fWidth * 0.05f, crBBox.top - fWidth * 0.15f),
3207 PWLPT_MOVETO),
3208 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.25f,
3209 crBBox.top - fHeight * 0.15f),
3210 PWLPT_LINETO),
3211 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.275f,
3212 crBBox.bottom + fHeight * 0.08f),
3213 PWLPT_LINETO),
3214 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.05f,
3215 crBBox.bottom + fHeight * 0.08f),
3216 PWLPT_LINETO),
3217 CPWL_PathData(
3218 CPWL_Point(crBBox.left + fWidth * 0.05f, crBBox.top - fWidth * 0.15f),
3219 PWLPT_LINETO),
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07003220
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003221 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.275f,
3222 crBBox.top - fWidth * 0.45f),
3223 PWLPT_MOVETO),
3224 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.475f,
3225 crBBox.top - fWidth * 0.45f),
3226 PWLPT_LINETO),
3227 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.475f,
3228 crBBox.bottom + fHeight * 0.08f),
3229 PWLPT_LINETO),
3230 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.275f,
3231 crBBox.bottom + fHeight * 0.08f),
3232 PWLPT_LINETO),
3233 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.275f,
3234 crBBox.top - fWidth * 0.45f),
3235 PWLPT_LINETO),
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07003236
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003237 CPWL_PathData(
3238 CPWL_Point(crBBox.left + fWidth * 0.5f, crBBox.top - fHeight * 0.05f),
3239 PWLPT_MOVETO),
3240 CPWL_PathData(
3241 CPWL_Point(crBBox.left + fWidth * 0.7f, crBBox.top - fHeight * 0.05f),
3242 PWLPT_LINETO),
3243 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.7f,
3244 crBBox.bottom + fHeight * 0.08f),
3245 PWLPT_LINETO),
3246 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.5f,
3247 crBBox.bottom + fHeight * 0.08f),
3248 PWLPT_LINETO),
3249 CPWL_PathData(
3250 CPWL_Point(crBBox.left + fWidth * 0.5f, crBBox.top - fHeight * 0.05f),
3251 PWLPT_LINETO),
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07003252
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003253 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.725f,
3254 crBBox.top - fWidth * 0.35f),
3255 PWLPT_MOVETO),
3256 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.925f,
3257 crBBox.top - fWidth * 0.35f),
3258 PWLPT_LINETO),
3259 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.925f,
3260 crBBox.bottom + fHeight * 0.08f),
3261 PWLPT_LINETO),
3262 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.725f,
3263 crBBox.bottom + fHeight * 0.08f),
3264 PWLPT_LINETO),
3265 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.725f,
3266 crBBox.top - fWidth * 0.35f),
3267 PWLPT_LINETO)};
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07003268
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003269 if (type == PWLPT_STREAM)
3270 sPathData = GetAppStreamFromArray(PathArray, 20);
3271 else
3272 GetPathDataFromArray(path, PathArray, 20);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07003273}
3274
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003275void CPWL_Utils::GetGraphics_Paperclip(CFX_ByteString& sPathData,
3276 CFX_PathData& path,
3277 const CPDF_Rect& crBBox,
3278 const PWL_PATH_TYPE type) {
3279 FX_FLOAT fWidth = crBBox.right - crBBox.left;
3280 FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07003281
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003282 CPWL_PathData PathArray[] = {
3283 CPWL_PathData(
3284 CPWL_Point(crBBox.left + fWidth / 60, crBBox.top - fHeight * 0.25f),
3285 PWLPT_MOVETO),
3286 CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 60,
3287 crBBox.bottom + fHeight * 0.25f),
3288 PWLPT_LINETO),
3289 CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 60,
3290 crBBox.bottom + fHeight * 0.25f -
3291 fWidth * 57 / 60.0f * 0.35f),
3292 PWLPT_BEZIERTO),
3293 CPWL_PathData(CPWL_Point(crBBox.right - fWidth / 30,
3294 crBBox.bottom + fHeight * 0.25f -
3295 fWidth * 57 / 60.0f * 0.35f),
3296 PWLPT_BEZIERTO),
3297 CPWL_PathData(CPWL_Point(crBBox.right - fWidth / 30,
3298 crBBox.bottom + fHeight * 0.25f),
3299 PWLPT_BEZIERTO),
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07003300
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003301 CPWL_PathData(
3302 CPWL_Point(crBBox.right - fWidth / 30, crBBox.top - fHeight * 0.33f),
3303 PWLPT_LINETO),
3304 CPWL_PathData(
3305 CPWL_Point(crBBox.right - fWidth / 30,
3306 crBBox.top - fHeight * 0.33f + fHeight / 15 * 0.5f),
3307 PWLPT_BEZIERTO),
3308 CPWL_PathData(
3309 CPWL_Point(crBBox.right - fWidth / 30 - fWidth * 0.12f,
3310 crBBox.top - fHeight * 0.33f + fHeight / 15 * 0.5f),
3311 PWLPT_BEZIERTO),
3312 CPWL_PathData(CPWL_Point(crBBox.right - fWidth / 30 - fWidth * 0.12f,
3313 crBBox.top - fHeight * 0.33f),
3314 PWLPT_BEZIERTO),
Lei Zhanga6d9f0e2015-06-13 00:48:38 -07003315
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003316 CPWL_PathData(CPWL_Point(crBBox.right - fWidth / 30 - fWidth * 0.12f,
3317 crBBox.bottom + fHeight * 0.2f),
3318 PWLPT_LINETO),
3319 CPWL_PathData(
3320 CPWL_Point(crBBox.right - fWidth / 30 - fWidth * 0.12f,
3321 crBBox.bottom + fHeight * 0.2f -
3322 (fWidth * 57 / 60.0f - fWidth * 0.24f) * 0.25f),
3323 PWLPT_BEZIERTO),
3324 CPWL_PathData(
3325 CPWL_Point(crBBox.left + fWidth / 60 + fWidth * 0.12f,
3326 crBBox.bottom + fHeight * 0.2f -
3327 (fWidth * 57 / 60.0f - fWidth * 0.24f) * 0.25f),
3328 PWLPT_BEZIERTO),
3329 CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 60 + fWidth * 0.12f,
3330 crBBox.bottom + fHeight * 0.2f),
3331 PWLPT_BEZIERTO),
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07003332
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003333 CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 60 + fWidth * 0.12f,
3334 crBBox.top - fHeight * 0.2f),
3335 PWLPT_LINETO),
3336 CPWL_PathData(
3337 CPWL_Point(crBBox.left + fWidth / 60 + fWidth * 0.12f,
3338 crBBox.top - fHeight * 0.2f +
3339 (fWidth * 11 / 12.0f - fWidth * 0.36f) * 0.25f),
3340 PWLPT_BEZIERTO),
3341 CPWL_PathData(
3342 CPWL_Point(crBBox.right - fWidth / 15 - fWidth * 0.24f,
3343 crBBox.top - fHeight * 0.2f +
3344 (fWidth * 11 / 12.0f - fWidth * 0.36f) * 0.25f),
3345 PWLPT_BEZIERTO),
3346 CPWL_PathData(CPWL_Point(crBBox.right - fWidth / 15 - fWidth * 0.24f,
3347 crBBox.top - fHeight * 0.2f),
3348 PWLPT_BEZIERTO),
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07003349
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003350 CPWL_PathData(CPWL_Point(crBBox.right - fWidth / 15 - fWidth * 0.24f,
3351 crBBox.bottom + fHeight * 0.25f),
3352 PWLPT_LINETO),
3353 CPWL_PathData(
3354 CPWL_Point(crBBox.right - fWidth / 15 - fWidth * 0.24f,
3355 crBBox.bottom + fHeight * 0.25f -
3356 (fWidth * 14 / 15.0f - fWidth * 0.53f) * 0.25f),
3357 PWLPT_BEZIERTO),
3358 CPWL_PathData(
3359 CPWL_Point(crBBox.left + fWidth * 0.29f,
3360 crBBox.bottom + fHeight * 0.25f -
3361 (fWidth * 14 / 15.0f - fWidth * 0.53f) * 0.25f),
3362 PWLPT_BEZIERTO),
3363 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.29f,
3364 crBBox.bottom + fHeight * 0.25f),
3365 PWLPT_BEZIERTO),
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07003366
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003367 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.29f,
3368 crBBox.top - fHeight * 0.33f),
3369 PWLPT_LINETO),
3370 CPWL_PathData(
3371 CPWL_Point(crBBox.left + fWidth * 0.29f,
3372 crBBox.top - fHeight * 0.33f + fWidth * 0.12f * 0.35f),
3373 PWLPT_BEZIERTO),
3374 CPWL_PathData(
3375 CPWL_Point(crBBox.left + fWidth * 0.17f,
3376 crBBox.top - fHeight * 0.33f + fWidth * 0.12f * 0.35f),
3377 PWLPT_BEZIERTO),
3378 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.17f,
3379 crBBox.top - fHeight * 0.33f),
3380 PWLPT_BEZIERTO),
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07003381
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003382 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.17f,
3383 crBBox.bottom + fHeight * 0.3f),
3384 PWLPT_LINETO),
3385 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.17f,
3386 crBBox.bottom + fHeight * 0.3f -
3387 fWidth * (14 / 15.0f - 0.29f) * 0.35f),
3388 PWLPT_BEZIERTO),
3389 CPWL_PathData(CPWL_Point(crBBox.right - fWidth / 15 - fWidth * 0.12f,
3390 crBBox.bottom + fHeight * 0.3f -
3391 fWidth * (14 / 15.0f - 0.29f) * 0.35f),
3392 PWLPT_BEZIERTO),
3393 CPWL_PathData(CPWL_Point(crBBox.right - fWidth / 15 - fWidth * 0.12f,
3394 crBBox.bottom + fHeight * 0.3f),
3395 PWLPT_BEZIERTO),
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07003396
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003397 CPWL_PathData(CPWL_Point(crBBox.right - fWidth / 15 - fWidth * 0.12f,
3398 crBBox.top - fHeight * 0.25f),
3399 PWLPT_LINETO),
3400 CPWL_PathData(CPWL_Point(crBBox.right - fWidth / 15 - fWidth * 0.12f,
3401 crBBox.top - fHeight * 0.25f +
3402 fWidth * 0.35f * (11 / 12.0f - 0.12f)),
3403 PWLPT_BEZIERTO),
3404 CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 60,
3405 crBBox.top - fHeight * 0.25f +
3406 fWidth * 0.35f * (11 / 12.0f - 0.12f)),
3407 PWLPT_BEZIERTO),
3408 CPWL_PathData(
3409 CPWL_Point(crBBox.left + fWidth / 60, crBBox.top - fHeight * 0.25f),
3410 PWLPT_BEZIERTO)};
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07003411
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003412 if (type == PWLPT_STREAM)
3413 sPathData = GetAppStreamFromArray(PathArray, 33);
3414 else
3415 GetPathDataFromArray(path, PathArray, 33);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07003416}
3417
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003418void CPWL_Utils::GetGraphics_Attachment(CFX_ByteString& sPathData,
3419 CFX_PathData& path,
3420 const CPDF_Rect& crBBox,
3421 const PWL_PATH_TYPE type) {
3422 FX_FLOAT fWidth = crBBox.right - crBBox.left;
3423 FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07003424
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003425 CPWL_PathData PathArray[] = {
3426 CPWL_PathData(
3427 CPWL_Point(crBBox.left + fWidth * 0.25f, crBBox.top - fHeight * 0.1f),
3428 PWLPT_MOVETO),
3429 CPWL_PathData(
3430 CPWL_Point(crBBox.left + fWidth * 0.4f, crBBox.top - fHeight * 0.23f),
3431 PWLPT_LINETO),
3432 CPWL_PathData(
3433 CPWL_Point(crBBox.left + fWidth * 0.4f, crBBox.top - fHeight * 0.5f),
3434 PWLPT_LINETO),
3435 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.4f,
3436 crBBox.top - fHeight * 0.5f + fWidth * 0.04f),
3437 PWLPT_BEZIERTO),
3438 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.6f,
3439 crBBox.top - fHeight * 0.5f + fWidth * 0.04f),
3440 PWLPT_BEZIERTO),
3441 CPWL_PathData(
3442 CPWL_Point(crBBox.left + fWidth * 0.6f, crBBox.top - fHeight * 0.5f),
3443 PWLPT_BEZIERTO),
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07003444
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003445 CPWL_PathData(
3446 CPWL_Point(crBBox.left + fWidth * 0.6f, crBBox.top - fHeight * 0.23f),
3447 PWLPT_LINETO),
3448 CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 0.25f,
3449 crBBox.top - fHeight * 0.1f),
3450 PWLPT_LINETO),
3451 CPWL_PathData(
3452 CPWL_Point(crBBox.left + fWidth * 0.25f, crBBox.top - fHeight * 0.1f),
3453 PWLPT_LINETO),
3454 CPWL_PathData(
3455 CPWL_Point(crBBox.left + fWidth * 0.4f, crBBox.top - fHeight * 0.23f),
3456 PWLPT_LINETO),
3457 CPWL_PathData(
3458 CPWL_Point(crBBox.left + fWidth * 0.6f, crBBox.top - fHeight * 0.23f),
3459 PWLPT_LINETO),
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07003460
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003461 CPWL_PathData(
3462 CPWL_Point(crBBox.left + fWidth * 0.4f, crBBox.top - fHeight * 0.5f),
3463 PWLPT_MOVETO),
3464 CPWL_PathData(
3465 CPWL_Point(crBBox.left + fWidth * 0.4f - fWidth * 0.25f * 0.4f,
3466 crBBox.top - fHeight * 0.5f),
3467 PWLPT_BEZIERTO),
3468 CPWL_PathData(
3469 CPWL_Point(crBBox.left + fWidth * 0.15f,
3470 crBBox.top - fHeight * 0.65f + fHeight * 0.15f * 0.4f),
3471 PWLPT_BEZIERTO),
3472 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.15f,
3473 crBBox.top - fHeight * 0.65f),
3474 PWLPT_BEZIERTO),
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07003475
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003476 CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 0.15f,
3477 crBBox.top - fHeight * 0.65f),
3478 PWLPT_LINETO),
3479 CPWL_PathData(
3480 CPWL_Point(crBBox.right - fWidth * 0.15f,
3481 crBBox.top - fHeight * 0.65f + fHeight * 0.15f * 0.4f),
3482 PWLPT_BEZIERTO),
3483 CPWL_PathData(
3484 CPWL_Point(crBBox.left + fWidth * 0.6f + fWidth * 0.25f * 0.4f,
3485 crBBox.top - fHeight * 0.5f),
3486 PWLPT_BEZIERTO),
3487 CPWL_PathData(
3488 CPWL_Point(crBBox.left + fWidth * 0.6f, crBBox.top - fHeight * 0.5f),
3489 PWLPT_BEZIERTO),
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07003490
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003491 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.6f,
3492 crBBox.top - fHeight * 0.5f + fWidth * 0.04f),
3493 PWLPT_BEZIERTO),
3494 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.4f,
3495 crBBox.top - fHeight * 0.5f + fWidth * 0.04f),
3496 PWLPT_BEZIERTO),
3497 CPWL_PathData(
3498 CPWL_Point(crBBox.left + fWidth * 0.4f, crBBox.top - fHeight * 0.5f),
3499 PWLPT_BEZIERTO),
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07003500
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003501 CPWL_PathData(
3502 CPWL_Point(crBBox.left + fWidth * 0.5f, crBBox.top - fHeight * 0.65f),
3503 PWLPT_MOVETO),
3504 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.5f,
3505 crBBox.bottom + fHeight * 0.1f),
3506 PWLPT_LINETO)};
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07003507
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003508 if (type == PWLPT_STREAM)
3509 sPathData = GetAppStreamFromArray(PathArray, 24);
3510 else
3511 GetPathDataFromArray(path, PathArray, 24);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07003512}
3513
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003514void CPWL_Utils::GetGraphics_Tag(CFX_ByteString& sPathData,
3515 CFX_PathData& path,
3516 const CPDF_Rect& crBBox,
3517 const PWL_PATH_TYPE type) {
3518 FX_FLOAT fWidth = crBBox.right - crBBox.left;
3519 FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07003520
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003521 CPWL_PathData PathArray[] = {
3522 CPWL_PathData(
3523 CPWL_Point(crBBox.left + fWidth * 0.4f, crBBox.top - fHeight * 0.1f),
3524 PWLPT_MOVETO),
3525 CPWL_PathData(
3526 CPWL_Point(crBBox.left + fWidth * 0.1f, crBBox.top - fHeight * 0.5f),
3527 PWLPT_LINETO),
3528 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.3f,
3529 crBBox.bottom + fHeight * 0.1f),
3530 PWLPT_LINETO),
3531 CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 0.1f,
3532 crBBox.bottom + fHeight * 0.1f),
3533 PWLPT_LINETO),
3534 CPWL_PathData(
3535 CPWL_Point(crBBox.right - fWidth * 0.1f, crBBox.top - fHeight * 0.1f),
3536 PWLPT_LINETO),
3537 CPWL_PathData(
3538 CPWL_Point(crBBox.left + fWidth * 0.4f, crBBox.top - fHeight * 0.1f),
3539 PWLPT_LINETO),
3540 CPWL_PathData(
3541 CPWL_Point(crBBox.left + fWidth * 0.4f, crBBox.top - fHeight * 0.3f),
3542 PWLPT_MOVETO),
3543 CPWL_PathData(
3544 CPWL_Point(crBBox.right - fWidth * 0.2f, crBBox.top - fHeight * 0.3f),
3545 PWLPT_LINETO),
3546 CPWL_PathData(
3547 CPWL_Point(crBBox.left + fWidth * 0.4f, crBBox.top - fHeight * 0.5f),
3548 PWLPT_MOVETO),
3549 CPWL_PathData(
3550 CPWL_Point(crBBox.right - fWidth * 0.2f, crBBox.top - fHeight * 0.5f),
3551 PWLPT_LINETO),
3552 CPWL_PathData(
3553 CPWL_Point(crBBox.left + fWidth * 0.4f, crBBox.top - fHeight * 0.7f),
3554 PWLPT_MOVETO),
3555 CPWL_PathData(
3556 CPWL_Point(crBBox.right - fWidth * 0.2f, crBBox.top - fHeight * 0.7f),
3557 PWLPT_LINETO)};
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07003558
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003559 if (type == PWLPT_STREAM)
3560 sPathData = GetAppStreamFromArray(PathArray, 12);
3561 else
3562 GetPathDataFromArray(path, PathArray, 12);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07003563}
3564
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003565void CPWL_Utils::GetGraphics_Foxit(CFX_ByteString& sPathData,
3566 CFX_PathData& path,
3567 const CPDF_Rect& crBBox,
3568 const PWL_PATH_TYPE type) {
3569 FX_FLOAT fOutWidth = crBBox.right - crBBox.left;
3570 FX_FLOAT fOutHeight = crBBox.top - crBBox.bottom;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07003571
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003572 CPDF_Rect crInBox = crBBox;
3573 crInBox.left = crBBox.left + fOutWidth * 0.08f;
3574 crInBox.right = crBBox.right - fOutWidth * 0.08f;
3575 crInBox.top = crBBox.top - fOutHeight * 0.08f;
3576 crInBox.bottom = crBBox.bottom + fOutHeight * 0.08f;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07003577
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003578 FX_FLOAT fWidth = crInBox.right - crInBox.left;
3579 FX_FLOAT fHeight = crInBox.top - crInBox.bottom;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07003580
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003581 CPWL_PathData PathArray[] = {
3582 CPWL_PathData(CPWL_Point(crInBox.left, crInBox.top), PWLPT_MOVETO),
3583 CPWL_PathData(CPWL_Point(crInBox.left + fWidth * 0.45f, crInBox.top),
3584 PWLPT_LINETO),
3585 CPWL_PathData(CPWL_Point(crInBox.left + fWidth * 0.45f,
3586 crInBox.top - PWL_BEZIER * fHeight * 0.4f),
3587 PWLPT_BEZIERTO),
3588 CPWL_PathData(CPWL_Point(crInBox.left + fWidth * 0.45f -
3589 PWL_BEZIER * fWidth * 0.45f,
3590 crInBox.top - fHeight * 0.4f),
3591 PWLPT_BEZIERTO),
3592 CPWL_PathData(CPWL_Point(crInBox.left, crInBox.top - fHeight * 0.4f),
3593 PWLPT_BEZIERTO),
3594 CPWL_PathData(CPWL_Point(crInBox.left, crInBox.top), PWLPT_LINETO),
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07003595
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003596 CPWL_PathData(CPWL_Point(crInBox.left + fWidth * 0.60f, crInBox.top),
3597 PWLPT_MOVETO),
3598 CPWL_PathData(CPWL_Point(crInBox.left + fWidth * 0.75f, crInBox.top),
3599 PWLPT_LINETO),
3600 CPWL_PathData(CPWL_Point(crInBox.left + fWidth * 0.75f,
3601 crInBox.top - PWL_BEZIER * fHeight * 0.7f),
3602 PWLPT_BEZIERTO),
3603 CPWL_PathData(CPWL_Point(crInBox.left + fWidth * 0.75f -
3604 PWL_BEZIER * fWidth * 0.75f,
3605 crInBox.top - fHeight * 0.7f),
3606 PWLPT_BEZIERTO),
3607 CPWL_PathData(CPWL_Point(crInBox.left, crInBox.top - fHeight * 0.7f),
3608 PWLPT_BEZIERTO),
3609 CPWL_PathData(CPWL_Point(crInBox.left, crInBox.top - fHeight * 0.55f),
3610 PWLPT_LINETO),
3611 CPWL_PathData(CPWL_Point(crInBox.left + PWL_BEZIER * fWidth * 0.60f,
3612 crInBox.top - fHeight * 0.55f),
3613 PWLPT_BEZIERTO),
3614 CPWL_PathData(CPWL_Point(crInBox.left + fWidth * 0.60f,
3615 crInBox.top - PWL_BEZIER * fHeight * 0.55f),
3616 PWLPT_BEZIERTO),
3617 CPWL_PathData(CPWL_Point(crInBox.left + fWidth * 0.60f, crInBox.top),
3618 PWLPT_BEZIERTO),
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07003619
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003620 CPWL_PathData(CPWL_Point(crInBox.left + fWidth * 0.90f, crInBox.top),
3621 PWLPT_MOVETO),
3622 CPWL_PathData(CPWL_Point(crInBox.left + fWidth * 0.90f,
3623 crInBox.top - PWL_BEZIER * fHeight * 0.85f),
3624 PWLPT_BEZIERTO),
3625 CPWL_PathData(CPWL_Point(crInBox.left + fWidth * 0.90f -
3626 PWL_BEZIER * fWidth * 0.90f,
3627 crInBox.top - fHeight * 0.85f),
3628 PWLPT_BEZIERTO),
3629 CPWL_PathData(CPWL_Point(crInBox.left, crInBox.top - fHeight * 0.85f),
3630 PWLPT_BEZIERTO),
3631 CPWL_PathData(CPWL_Point(crInBox.left, crInBox.bottom), PWLPT_LINETO),
3632 CPWL_PathData(CPWL_Point(crInBox.right, crInBox.bottom), PWLPT_LINETO),
3633 CPWL_PathData(CPWL_Point(crInBox.right, crInBox.top), PWLPT_LINETO),
3634 CPWL_PathData(CPWL_Point(crInBox.left + fWidth * 0.90f, crInBox.top),
3635 PWLPT_LINETO),
3636 };
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07003637
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003638 if (type == PWLPT_STREAM)
3639 sPathData = GetAppStreamFromArray(PathArray, 23);
3640 else
3641 GetPathDataFromArray(path, PathArray, 23);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07003642}
3643
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003644void CPWL_Color::ConvertColorType(int32_t other_nColorType) {
3645 switch (other_nColorType) {
3646 case COLORTYPE_TRANSPARENT:
3647 break;
3648 case COLORTYPE_GRAY:
3649 switch (other_nColorType) {
3650 case COLORTYPE_RGB:
3651 CPWL_Utils::ConvertGRAY2RGB(fColor1, fColor1, fColor2, fColor3);
3652 break;
3653 case COLORTYPE_CMYK:
3654 CPWL_Utils::ConvertGRAY2CMYK(fColor1, fColor1, fColor2, fColor3,
3655 fColor4);
3656 break;
3657 }
3658 break;
3659 case COLORTYPE_RGB:
3660 switch (other_nColorType) {
3661 case COLORTYPE_GRAY:
3662 CPWL_Utils::ConvertRGB2GRAY(fColor1, fColor2, fColor3, fColor1);
3663 break;
3664 case COLORTYPE_CMYK:
3665 CPWL_Utils::ConvertRGB2CMYK(fColor1, fColor2, fColor3, fColor1,
3666 fColor2, fColor3, fColor4);
3667 break;
3668 }
3669 break;
3670 case COLORTYPE_CMYK:
3671 switch (other_nColorType) {
3672 case COLORTYPE_GRAY:
3673 CPWL_Utils::ConvertCMYK2GRAY(fColor1, fColor2, fColor3, fColor4,
3674 fColor1);
3675 break;
3676 case COLORTYPE_RGB:
3677 CPWL_Utils::ConvertCMYK2RGB(fColor1, fColor2, fColor3, fColor4,
3678 fColor1, fColor2, fColor3);
3679 break;
3680 }
3681 break;
3682 }
3683 nColorType = other_nColorType;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07003684}