Svet Ganov | e6986e1 | 2015-06-04 14:52:15 -0700 | [diff] [blame] | 1 | // 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. |
| 4 | |
| 5 | // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | |
| 7 | #include "../../include/pdfwindow/PDFWindow.h" |
| 8 | #include "../../include/pdfwindow/PWL_Wnd.h" |
| 9 | #include "../../include/pdfwindow/PWL_Utils.h" |
| 10 | #include "../../include/pdfwindow/PWL_Icon.h" |
| 11 | |
| 12 | #define IsFloatZero(f) ((f) < 0.0001 && (f) > -0.0001) |
| 13 | #define IsFloatBigger(fa,fb) ((fa) > (fb) && !IsFloatZero((fa) - (fb))) |
| 14 | #define IsFloatSmaller(fa,fb) ((fa) < (fb) && !IsFloatZero((fa) - (fb))) |
| 15 | #define IsFloatEqual(fa,fb) IsFloatZero((fa)-(fb)) |
| 16 | |
| 17 | /* ---------------------------- CPWL_Utils ------------------------------ */ |
| 18 | |
| 19 | CFX_ByteString CPWL_Utils::GetAppStreamFromArray(const CPWL_PathData* pPathData, FX_INT32 nCount) |
| 20 | { |
| 21 | CFX_ByteTextBuf csAP; |
| 22 | |
| 23 | for (FX_INT32 i=0; i<nCount; i++) |
| 24 | { |
| 25 | switch (pPathData[i].type) |
| 26 | { |
| 27 | case PWLPT_MOVETO: |
| 28 | csAP << pPathData[i].point.x << " " << pPathData[i].point.y << " m\n"; |
| 29 | break; |
| 30 | case PWLPT_LINETO: |
| 31 | csAP << pPathData[i].point.x << " " << pPathData[i].point.y << " l\n"; |
| 32 | break; |
| 33 | case PWLPT_BEZIERTO: |
| 34 | csAP << pPathData[i].point.x << " " << pPathData[i].point.y << " " |
| 35 | << pPathData[i+1].point.x << " " << pPathData[i+1].point.y << " " |
| 36 | << pPathData[i+2].point.x << " " << pPathData[i+2].point.y << " c\n"; |
| 37 | |
| 38 | i += 2; |
| 39 | break; |
| 40 | default: |
| 41 | break; |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | return csAP.GetByteString(); |
| 46 | } |
| 47 | |
| 48 | void CPWL_Utils::GetPathDataFromArray(CFX_PathData& path, const CPWL_PathData* pPathData, FX_INT32 nCount) |
| 49 | { |
| 50 | path.SetPointCount(nCount); |
| 51 | |
| 52 | for (FX_INT32 i=0; i<nCount; i++) |
| 53 | { |
| 54 | switch (pPathData[i].type) |
| 55 | { |
| 56 | case PWLPT_MOVETO: |
| 57 | path.SetPoint(i, pPathData[i].point.x, pPathData[i].point.y, FXPT_MOVETO); |
| 58 | break; |
| 59 | case PWLPT_LINETO: |
| 60 | path.SetPoint(i, pPathData[i].point.x, pPathData[i].point.y, FXPT_LINETO); |
| 61 | break; |
| 62 | case PWLPT_BEZIERTO: |
| 63 | path.SetPoint(i, pPathData[i].point.x, pPathData[i].point.y, FXPT_BEZIERTO); |
| 64 | break; |
| 65 | default: |
| 66 | break; |
| 67 | } |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | |
| 72 | CPDF_Rect CPWL_Utils::MaxRect(const CPDF_Rect & rect1,const CPDF_Rect & rect2) |
| 73 | { |
| 74 | CPDF_Rect rcRet; |
| 75 | |
| 76 | rcRet.left = PWL_MIN(rect1.left,rect2.left); |
| 77 | rcRet.bottom = PWL_MIN(rect1.bottom,rect2.bottom); |
| 78 | rcRet.right = PWL_MAX(rect1.right,rect2.right); |
| 79 | rcRet.top = PWL_MAX(rect1.top,rect2.top); |
| 80 | |
| 81 | return rcRet; |
| 82 | } |
| 83 | |
| 84 | CPDF_Rect CPWL_Utils::OffsetRect(const CPDF_Rect & rect,FX_FLOAT x,FX_FLOAT y) |
| 85 | { |
| 86 | return CPDF_Rect(rect.left + x,rect.bottom + y, |
| 87 | rect.right + x,rect.top + y); |
| 88 | } |
| 89 | |
| 90 | FX_BOOL CPWL_Utils::ContainsRect(const CPDF_Rect& rcParent, const CPDF_Rect& rcChild) |
| 91 | { |
| 92 | return rcChild.left >= rcParent.left && rcChild.bottom >= rcParent.bottom && |
| 93 | rcChild.right <= rcParent.right && rcChild.top <= rcParent.top; |
| 94 | } |
| 95 | |
| 96 | FX_BOOL CPWL_Utils::IntersectRect(const CPDF_Rect& rect1, const CPDF_Rect& rect2) |
| 97 | { |
| 98 | FX_FLOAT left = rect1.left > rect2.left ? rect1.left : rect2.left; |
| 99 | FX_FLOAT right = rect1.right < rect2.right ? rect1.right : rect2.right; |
| 100 | FX_FLOAT bottom = rect1.bottom > rect2.bottom ? rect1.bottom : rect2.bottom; |
| 101 | FX_FLOAT top = rect1.top < rect2.top ? rect1.top : rect2.top; |
| 102 | |
| 103 | return left < right && bottom < top; |
| 104 | } |
| 105 | |
| 106 | CPDF_Point CPWL_Utils::OffsetPoint(const CPDF_Point& point,FX_FLOAT x,FX_FLOAT y) |
| 107 | { |
| 108 | return CPDF_Point(point.x + x,point.y + y); |
| 109 | } |
| 110 | |
| 111 | CPVT_WordRange CPWL_Utils::OverlapWordRange(const CPVT_WordRange & wr1, const CPVT_WordRange & wr2) |
| 112 | { |
| 113 | CPVT_WordRange wrRet; |
| 114 | |
| 115 | if (wr2.EndPos.WordCmp(wr1.BeginPos) < 0 || wr2.BeginPos.WordCmp(wr1.EndPos) > 0) return wrRet; |
| 116 | if (wr1.EndPos.WordCmp(wr2.BeginPos) < 0 || wr1.BeginPos.WordCmp(wr2.EndPos) > 0) return wrRet; |
| 117 | |
| 118 | if (wr1.BeginPos.WordCmp(wr2.BeginPos) < 0) |
| 119 | { |
| 120 | wrRet.BeginPos = wr2.BeginPos; |
| 121 | } |
| 122 | else |
| 123 | { |
| 124 | wrRet.BeginPos = wr1.BeginPos; |
| 125 | } |
| 126 | |
| 127 | if (wr1.EndPos.WordCmp(wr2.EndPos) < 0) |
| 128 | { |
| 129 | wrRet.EndPos = wr1.EndPos; |
| 130 | } |
| 131 | else |
| 132 | { |
| 133 | wrRet.EndPos = wr2.EndPos; |
| 134 | } |
| 135 | |
| 136 | return wrRet; |
| 137 | } |
| 138 | |
| 139 | CFX_ByteString CPWL_Utils::GetAP_Check(const CPDF_Rect & crBBox) |
| 140 | { |
| 141 | CFX_ByteTextBuf csAP; |
| 142 | |
| 143 | FX_FLOAT fWidth = crBBox.right - crBBox.left; |
| 144 | FX_FLOAT fHeight = crBBox.top - crBBox.bottom; |
| 145 | |
| 146 | const FX_INT32 num = 8; |
| 147 | |
| 148 | CPWL_Point pts[num*3] = |
| 149 | { |
| 150 | //1 |
| 151 | CPWL_Point(0.28f, 0.52f), |
| 152 | CPWL_Point(0.27f, 0.48f), |
| 153 | CPWL_Point(0.29f, 0.40f), |
| 154 | |
| 155 | //2 |
| 156 | CPWL_Point(0.30f, 0.33f), |
| 157 | CPWL_Point(0.31f, 0.29f), |
| 158 | CPWL_Point(0.31f, 0.28f), |
| 159 | |
| 160 | //3 |
| 161 | CPWL_Point(0.39f, 0.28f), |
| 162 | CPWL_Point(0.49f, 0.29f), |
| 163 | CPWL_Point(0.77f, 0.67f), |
| 164 | |
| 165 | //4 |
| 166 | CPWL_Point(0.76f, 0.68f), |
| 167 | CPWL_Point(0.78f, 0.69f), |
| 168 | CPWL_Point(0.76f, 0.75f), |
| 169 | |
| 170 | //5 |
| 171 | CPWL_Point(0.76f, 0.75f), |
| 172 | CPWL_Point(0.73f, 0.80f), |
| 173 | CPWL_Point(0.68f, 0.75f), |
| 174 | |
| 175 | //6 |
| 176 | CPWL_Point(0.68f, 0.74f), |
| 177 | CPWL_Point(0.68f, 0.74f), |
| 178 | CPWL_Point(0.44f, 0.47f), |
| 179 | |
| 180 | //7 |
| 181 | CPWL_Point(0.43f, 0.47f), |
| 182 | CPWL_Point(0.40f, 0.47f), |
| 183 | CPWL_Point(0.41f, 0.58f), |
| 184 | |
| 185 | //8 |
| 186 | CPWL_Point(0.40f, 0.60f), |
| 187 | CPWL_Point(0.28f, 0.66f), |
| 188 | CPWL_Point(0.30f, 0.56f) |
| 189 | }; |
| 190 | |
| 191 | for (FX_INT32 j=0; j<num*3; j++) |
| 192 | { |
| 193 | pts[j].x *= fWidth; |
| 194 | pts[j].x += crBBox.left; |
| 195 | |
| 196 | pts[j].y *= fHeight; |
| 197 | pts[j].y += crBBox.bottom; |
| 198 | } |
| 199 | |
| 200 | csAP << pts[0].x << " " << pts[0].y << " m\n"; |
| 201 | |
| 202 | for (FX_INT32 i=0; i<num; i++) |
| 203 | { |
| 204 | FX_INT32 nCur = i*3; |
| 205 | FX_INT32 n1 = i*3 + 1; |
| 206 | FX_INT32 n2 = i*3 + 2; |
| 207 | FX_INT32 nNext = (i < num-1 ? (i+1)*3 : 0); |
| 208 | |
| 209 | FX_FLOAT px1 = pts[n1].x - pts[nCur].x; |
| 210 | FX_FLOAT py1 = pts[n1].y - pts[nCur].y; |
| 211 | FX_FLOAT px2 = pts[n2].x - pts[nNext].x; |
| 212 | FX_FLOAT py2 = pts[n2].y - pts[nNext].y; |
| 213 | |
| 214 | csAP << pts[nCur].x + px1 * PWL_BEZIER << " " << pts[nCur].y + py1 * PWL_BEZIER << " " |
| 215 | << pts[nNext].x + px2 * PWL_BEZIER << " " << pts[nNext].y + py2 * PWL_BEZIER << " " |
| 216 | << pts[nNext].x << " " << pts[nNext].y << " c\n"; |
| 217 | } |
| 218 | |
| 219 | return csAP.GetByteString(); |
| 220 | } |
| 221 | |
| 222 | CFX_ByteString CPWL_Utils::GetAP_Circle(const CPDF_Rect & crBBox) |
| 223 | { |
| 224 | CFX_ByteTextBuf csAP; |
| 225 | |
| 226 | FX_FLOAT fWidth = crBBox.right - crBBox.left; |
| 227 | FX_FLOAT fHeight = crBBox.top - crBBox.bottom; |
| 228 | |
| 229 | CPDF_Point pt1(crBBox.left,crBBox.bottom + fHeight / 2); |
| 230 | CPDF_Point pt2(crBBox.left + fWidth / 2,crBBox.top); |
| 231 | CPDF_Point pt3(crBBox.right,crBBox.bottom + fHeight / 2); |
| 232 | CPDF_Point pt4(crBBox.left + fWidth / 2,crBBox.bottom); |
| 233 | |
| 234 | csAP << pt1.x << " " << pt1.y << " m\n"; |
| 235 | |
| 236 | FX_FLOAT px = pt2.x - pt1.x; |
| 237 | FX_FLOAT py = pt2.y - pt1.y; |
| 238 | |
| 239 | csAP << pt1.x << " " << pt1.y + py * PWL_BEZIER << " " |
| 240 | << pt2.x - px * PWL_BEZIER << " " << pt2.y << " " |
| 241 | << pt2.x << " " << pt2.y << " c\n"; |
| 242 | |
| 243 | px = pt3.x - pt2.x; |
| 244 | py = pt2.y - pt3.y; |
| 245 | |
| 246 | csAP << pt2.x + px * PWL_BEZIER << " " << pt2.y << " " |
| 247 | << pt3.x << " " << pt3.y + py * PWL_BEZIER << " " |
| 248 | << pt3.x << " " << pt3.y << " c\n"; |
| 249 | |
| 250 | px = pt3.x - pt4.x; |
| 251 | py = pt3.y - pt4.y; |
| 252 | |
| 253 | csAP << pt3.x << " " << pt3.y - py * PWL_BEZIER << " " |
| 254 | << pt4.x + px * PWL_BEZIER << " " << pt4.y << " " |
| 255 | << pt4.x << " " << pt4.y << " c\n"; |
| 256 | |
| 257 | px = pt4.x - pt1.x; |
| 258 | py = pt1.y - pt4.y; |
| 259 | |
| 260 | csAP << pt4.x - px * PWL_BEZIER << " " << pt4.y << " " |
| 261 | << pt1.x << " " << pt1.y - py * PWL_BEZIER << " " |
| 262 | << pt1.x << " " << pt1.y << " c\n"; |
| 263 | |
| 264 | return csAP.GetByteString(); |
| 265 | } |
| 266 | |
| 267 | CFX_ByteString CPWL_Utils::GetAP_Cross(const CPDF_Rect & crBBox) |
| 268 | { |
| 269 | CFX_ByteTextBuf csAP; |
| 270 | |
| 271 | csAP << crBBox.left << " " << crBBox.top << " m\n"; |
| 272 | csAP << crBBox.right << " " << crBBox.bottom << " l\n"; |
| 273 | csAP << crBBox.left << " " << crBBox.bottom << " m\n"; |
| 274 | csAP << crBBox.right << " " << crBBox.top << " l\n"; |
| 275 | |
| 276 | return csAP.GetByteString(); |
| 277 | } |
| 278 | |
| 279 | CFX_ByteString CPWL_Utils::GetAP_Diamond(const CPDF_Rect & crBBox) |
| 280 | { |
| 281 | CFX_ByteTextBuf csAP; |
| 282 | |
| 283 | FX_FLOAT fWidth = crBBox.right - crBBox.left; |
| 284 | FX_FLOAT fHeight = crBBox.top - crBBox.bottom; |
| 285 | |
| 286 | CPDF_Point pt1(crBBox.left,crBBox.bottom + fHeight / 2); |
| 287 | CPDF_Point pt2(crBBox.left + fWidth / 2,crBBox.top); |
| 288 | CPDF_Point pt3(crBBox.right,crBBox.bottom + fHeight / 2); |
| 289 | CPDF_Point pt4(crBBox.left + fWidth / 2,crBBox.bottom); |
| 290 | |
| 291 | csAP << pt1.x << " " << pt1.y << " m\n"; |
| 292 | csAP << pt2.x << " " << pt2.y << " l\n"; |
| 293 | csAP << pt3.x << " " << pt3.y << " l\n"; |
| 294 | csAP << pt4.x << " " << pt4.y << " l\n"; |
| 295 | csAP << pt1.x << " " << pt1.y << " l\n"; |
| 296 | |
| 297 | return csAP.GetByteString(); |
| 298 | } |
| 299 | |
| 300 | CFX_ByteString CPWL_Utils::GetAP_Square(const CPDF_Rect & crBBox) |
| 301 | { |
| 302 | CFX_ByteTextBuf csAP; |
| 303 | |
| 304 | csAP << crBBox.left << " " << crBBox.top << " m\n"; |
| 305 | csAP << crBBox.right << " " << crBBox.top << " l\n"; |
| 306 | csAP << crBBox.right << " " << crBBox.bottom << " l\n"; |
| 307 | csAP << crBBox.left << " " << crBBox.bottom << " l\n"; |
| 308 | csAP << crBBox.left << " " << crBBox.top << " l\n"; |
| 309 | |
| 310 | return csAP.GetByteString(); |
| 311 | } |
| 312 | |
| 313 | CFX_ByteString CPWL_Utils::GetAP_Star(const CPDF_Rect & crBBox) |
| 314 | { |
| 315 | CFX_ByteTextBuf csAP; |
| 316 | |
| 317 | FX_FLOAT fRadius = (crBBox.top - crBBox.bottom)/(1+(FX_FLOAT)cos(PWL_PI/5.0f)); |
| 318 | CPDF_Point ptCenter = CPDF_Point((crBBox.left + crBBox.right) / 2.0f,(crBBox.top + crBBox.bottom) / 2.0f); |
| 319 | |
| 320 | FX_FLOAT px[5],py[5]; |
| 321 | |
| 322 | FX_FLOAT fAngel = PWL_PI/10.0f; |
| 323 | |
| 324 | for (FX_INT32 i=0; i<5; i++) |
| 325 | { |
| 326 | px[i] = ptCenter.x + fRadius * (FX_FLOAT)cos(fAngel); |
| 327 | py[i] = ptCenter.y + fRadius * (FX_FLOAT)sin(fAngel); |
| 328 | |
| 329 | fAngel += PWL_PI * 2 / 5.0f; |
| 330 | } |
| 331 | |
| 332 | csAP << px[0] << " " << py[0] << " m\n"; |
| 333 | |
| 334 | FX_INT32 nNext = 0; |
| 335 | for (FX_INT32 j=0; j<5; j++) |
| 336 | { |
| 337 | nNext += 2; |
| 338 | if (nNext >= 5) nNext -= 5; |
| 339 | csAP << px[nNext] << " " << py[nNext] << " l\n"; |
| 340 | } |
| 341 | |
| 342 | return csAP.GetByteString(); |
| 343 | } |
| 344 | |
| 345 | CFX_ByteString CPWL_Utils::GetAP_HalfCircle(const CPDF_Rect & crBBox,FX_FLOAT fRotate) |
| 346 | { |
| 347 | CFX_ByteTextBuf csAP; |
| 348 | |
| 349 | FX_FLOAT fWidth = crBBox.right - crBBox.left; |
| 350 | FX_FLOAT fHeight = crBBox.top - crBBox.bottom; |
| 351 | |
| 352 | CPDF_Point pt1(-fWidth/2,0); |
| 353 | CPDF_Point pt2(0,fHeight/2); |
| 354 | CPDF_Point pt3(fWidth/2,0); |
| 355 | |
| 356 | FX_FLOAT px,py; |
| 357 | |
| 358 | csAP << cos(fRotate) << " " << sin(fRotate) << " " << -sin(fRotate) << " " << cos(fRotate) << " " |
| 359 | << crBBox.left + fWidth / 2 << " " << crBBox.bottom + fHeight / 2 << " cm\n"; |
| 360 | |
| 361 | |
| 362 | csAP << pt1.x << " " << pt1.y << " m\n"; |
| 363 | |
| 364 | px = pt2.x - pt1.x; |
| 365 | py = pt2.y - pt1.y; |
| 366 | |
| 367 | csAP << pt1.x << " " << pt1.y + py * PWL_BEZIER << " " |
| 368 | << pt2.x - px * PWL_BEZIER << " " << pt2.y << " " |
| 369 | << pt2.x << " " << pt2.y << " c\n"; |
| 370 | |
| 371 | px = pt3.x - pt2.x; |
| 372 | py = pt2.y - pt3.y; |
| 373 | |
| 374 | csAP << pt2.x + px * PWL_BEZIER << " " << pt2.y << " " |
| 375 | << pt3.x << " " << pt3.y + py * PWL_BEZIER << " " |
| 376 | << pt3.x << " " << pt3.y << " c\n"; |
| 377 | |
| 378 | return csAP.GetByteString(); |
| 379 | } |
| 380 | |
| 381 | |
| 382 | CPDF_Rect CPWL_Utils::InflateRect(const CPDF_Rect & rcRect, FX_FLOAT fSize) |
| 383 | { |
| 384 | if (rcRect.IsEmpty()) return rcRect; |
| 385 | |
| 386 | CPDF_Rect rcNew(rcRect.left - fSize, |
| 387 | rcRect.bottom - fSize, |
| 388 | rcRect.right + fSize, |
| 389 | rcRect.top + fSize); |
| 390 | rcNew.Normalize(); |
| 391 | return rcNew; |
| 392 | } |
| 393 | |
| 394 | CPDF_Rect CPWL_Utils::DeflateRect(const CPDF_Rect & rcRect, FX_FLOAT fSize) |
| 395 | { |
| 396 | if (rcRect.IsEmpty()) return rcRect; |
| 397 | |
| 398 | CPDF_Rect rcNew(rcRect.left + fSize, |
| 399 | rcRect.bottom + fSize, |
| 400 | rcRect.right - fSize, |
| 401 | rcRect.top - fSize); |
| 402 | rcNew.Normalize(); |
| 403 | return rcNew; |
| 404 | } |
| 405 | |
| 406 | CPDF_Rect CPWL_Utils::ScaleRect(const CPDF_Rect & rcRect,FX_FLOAT fScale) |
| 407 | { |
| 408 | FX_FLOAT fHalfWidth = (rcRect.right - rcRect.left) / 2.0f; |
| 409 | FX_FLOAT fHalfHeight = (rcRect.top - rcRect.bottom) / 2.0f; |
| 410 | |
| 411 | CPDF_Point ptCenter = CPDF_Point((rcRect.left + rcRect.right) / 2,(rcRect.top + rcRect.bottom) / 2); |
| 412 | |
| 413 | return CPDF_Rect(ptCenter.x - fHalfWidth * fScale, |
| 414 | ptCenter.y - fHalfHeight * fScale, |
| 415 | ptCenter.x + fHalfWidth * fScale, |
| 416 | ptCenter.y + fHalfHeight * fScale); |
| 417 | } |
| 418 | |
| 419 | CFX_ByteString CPWL_Utils::GetRectFillAppStream(const CPDF_Rect & rect,const CPWL_Color & color) |
| 420 | { |
| 421 | CFX_ByteTextBuf sAppStream; |
| 422 | |
| 423 | CFX_ByteString sColor = GetColorAppStream(color,TRUE); |
| 424 | if (sColor.GetLength() > 0) |
| 425 | { |
| 426 | sAppStream << "q\n" << sColor; |
| 427 | sAppStream << rect.left << " " << rect.bottom << " " |
| 428 | << rect.right - rect.left << " " << rect.top - rect.bottom << " re f\nQ\n"; |
| 429 | } |
| 430 | |
| 431 | return sAppStream.GetByteString(); |
| 432 | } |
| 433 | |
| 434 | CFX_ByteString CPWL_Utils::GetCircleFillAppStream(const CPDF_Rect & rect,const CPWL_Color & color) |
| 435 | { |
| 436 | CFX_ByteTextBuf sAppStream; |
| 437 | |
| 438 | CFX_ByteString sColor = GetColorAppStream(color,TRUE); |
| 439 | if (sColor.GetLength() > 0) |
| 440 | { |
| 441 | sAppStream << "q\n" << sColor << CPWL_Utils::GetAP_Circle(rect) << "f\nQ\n"; |
| 442 | } |
| 443 | |
| 444 | return sAppStream.GetByteString(); |
| 445 | } |
| 446 | |
| 447 | CPDF_Rect CPWL_Utils::GetCenterSquare(const CPDF_Rect & rect) |
| 448 | { |
| 449 | FX_FLOAT fWidth = rect.right - rect.left; |
| 450 | FX_FLOAT fHeight = rect.top - rect.bottom; |
| 451 | |
| 452 | FX_FLOAT fCenterX = (rect.left + rect.right)/2.0f; |
| 453 | FX_FLOAT fCenterY = (rect.top + rect.bottom)/2.0f; |
| 454 | |
| 455 | FX_FLOAT fRadius = (fWidth > fHeight) ? fHeight / 2 : fWidth / 2; |
| 456 | |
| 457 | return CPDF_Rect(fCenterX - fRadius,fCenterY - fRadius,fCenterX + fRadius,fCenterY + fRadius); |
| 458 | } |
| 459 | |
| 460 | CFX_ByteString CPWL_Utils::GetEditAppStream(IFX_Edit* pEdit, const CPDF_Point & ptOffset, const CPVT_WordRange * pRange, |
| 461 | FX_BOOL bContinuous, FX_WORD SubWord) |
| 462 | { |
| 463 | return IFX_Edit::GetEditAppearanceStream(pEdit,ptOffset,pRange,bContinuous,SubWord); |
| 464 | } |
| 465 | |
| 466 | CFX_ByteString CPWL_Utils::GetEditSelAppStream(IFX_Edit* pEdit, const CPDF_Point & ptOffset, |
| 467 | const CPVT_WordRange * pRange) |
| 468 | { |
| 469 | return IFX_Edit::GetSelectAppearanceStream(pEdit,ptOffset,pRange); |
| 470 | } |
| 471 | |
| 472 | static CFX_ByteString GetSquigglyAppearanceStream(FX_FLOAT fStartX, FX_FLOAT fEndX, FX_FLOAT fY, FX_FLOAT fStep) |
| 473 | { |
| 474 | CFX_ByteTextBuf sRet; |
| 475 | |
| 476 | sRet << "0 w\n" << fStartX << " " << fY << " m\n"; |
| 477 | |
| 478 | FX_FLOAT fx; |
| 479 | FX_INT32 i; |
| 480 | |
| 481 | for (i=1,fx=fStartX+fStep; fx<fEndX; fx+=fStep,i++) |
| 482 | { |
| 483 | sRet << fx << " " << fY + (i&1)*fStep << " l\n"; |
| 484 | } |
| 485 | |
| 486 | sRet << "S\n"; |
| 487 | |
| 488 | return sRet.GetByteString(); |
| 489 | } |
| 490 | |
| 491 | static CFX_ByteString GetWordSpellCheckAppearanceStream(IFX_Edit_Iterator* pIterator, const CPDF_Point & ptOffset, |
| 492 | const CPVT_WordRange & wrWord) |
| 493 | { |
| 494 | CFX_ByteTextBuf sRet; |
| 495 | |
| 496 | FX_FLOAT fStartX = 0.0f; |
| 497 | FX_FLOAT fEndX = 0.0f; |
| 498 | FX_FLOAT fY = 0.0f; |
| 499 | FX_FLOAT fStep = 0.0f; |
| 500 | |
| 501 | FX_BOOL bBreak = FALSE; |
| 502 | |
| 503 | if (pIterator) |
| 504 | { |
| 505 | pIterator->SetAt(wrWord.BeginPos); |
| 506 | |
| 507 | do |
| 508 | { |
| 509 | CPVT_WordPlace place = pIterator->GetAt(); |
| 510 | |
| 511 | CPVT_Line line; |
| 512 | if (pIterator->GetLine(line)) |
| 513 | { |
| 514 | fY = line.ptLine.y; |
| 515 | fStep = (line.fLineAscent - line.fLineDescent) / 16.0f; |
| 516 | } |
| 517 | |
| 518 | if (place.LineCmp(wrWord.BeginPos) == 0) |
| 519 | { |
| 520 | pIterator->SetAt(wrWord.BeginPos); |
| 521 | CPVT_Word word; |
| 522 | if (pIterator->GetWord(word)) |
| 523 | { |
| 524 | fStartX = word.ptWord.x; |
| 525 | } |
| 526 | } |
| 527 | else |
| 528 | { |
| 529 | fStartX = line.ptLine.x; |
| 530 | } |
| 531 | |
| 532 | if (place.LineCmp(wrWord.EndPos) == 0) |
| 533 | { |
| 534 | pIterator->SetAt(wrWord.EndPos); |
| 535 | CPVT_Word word; |
| 536 | if (pIterator->GetWord(word)) |
| 537 | { |
| 538 | fEndX = word.ptWord.x + word.fWidth; |
| 539 | } |
| 540 | |
| 541 | bBreak = TRUE; |
| 542 | } |
| 543 | else |
| 544 | { |
| 545 | fEndX = line.ptLine.x + line.fLineWidth; |
| 546 | } |
| 547 | |
| 548 | sRet << GetSquigglyAppearanceStream(fStartX + ptOffset.x, fEndX + ptOffset.x, fY + ptOffset.y,fStep); |
| 549 | |
| 550 | if (bBreak) break; |
| 551 | } |
| 552 | while (pIterator->NextLine()); |
| 553 | } |
| 554 | |
| 555 | return sRet.GetByteString(); |
| 556 | } |
| 557 | |
| 558 | CFX_ByteString CPWL_Utils::GetSpellCheckAppStream(IFX_Edit* pEdit, IPWL_SpellCheck* pSpellCheck, const CPDF_Point & ptOffset, |
| 559 | const CPVT_WordRange * pRange) |
| 560 | { |
| 561 | ASSERT(pEdit != NULL); |
| 562 | ASSERT(pSpellCheck != NULL); |
| 563 | |
| 564 | CFX_ByteTextBuf sRet; |
| 565 | |
| 566 | if (pRange && pRange->IsExist()) |
| 567 | { |
| 568 | if (IFX_Edit_Iterator* pIterator = pEdit->GetIterator()) |
| 569 | { |
| 570 | pIterator->SetAt(pRange->BeginPos); |
| 571 | |
| 572 | FX_BOOL bLatinWord = FALSE; |
| 573 | CPVT_WordPlace wpWordStart; |
| 574 | CFX_ByteString sWord; |
| 575 | |
| 576 | CPVT_WordPlace oldplace; |
| 577 | while (pIterator->NextWord()) |
| 578 | { |
| 579 | CPVT_WordPlace place = pIterator->GetAt(); |
| 580 | if (pRange && place.WordCmp(pRange->EndPos) > 0) break; |
| 581 | |
| 582 | CPVT_Word word; |
| 583 | if (pIterator->GetWord(word)) |
| 584 | { |
| 585 | if (FX_EDIT_ISLATINWORD(word.Word)) |
| 586 | { |
| 587 | if (!bLatinWord) |
| 588 | { |
| 589 | wpWordStart = place; |
| 590 | bLatinWord = TRUE; |
| 591 | } |
| 592 | |
| 593 | sWord += (char)word.Word; |
| 594 | oldplace = place; |
| 595 | } |
| 596 | else |
| 597 | { |
| 598 | if (bLatinWord) |
| 599 | { |
| 600 | if (!pSpellCheck->CheckWord(sWord)) |
| 601 | { |
| 602 | sRet << GetWordSpellCheckAppearanceStream(pIterator,ptOffset,CPVT_WordRange(wpWordStart,oldplace)); |
| 603 | pIterator->SetAt(place); |
| 604 | } |
| 605 | bLatinWord = FALSE; |
| 606 | } |
| 607 | |
| 608 | sWord.Empty(); |
| 609 | } |
| 610 | } |
| 611 | else |
| 612 | { |
| 613 | if (bLatinWord) |
| 614 | { |
| 615 | if (!pSpellCheck->CheckWord(sWord)) |
| 616 | sRet << GetWordSpellCheckAppearanceStream(pIterator,ptOffset,CPVT_WordRange(wpWordStart,oldplace)); |
| 617 | bLatinWord = FALSE; |
| 618 | sWord.Empty(); |
| 619 | } |
| 620 | } |
| 621 | } |
| 622 | |
| 623 | if (bLatinWord) |
| 624 | { |
| 625 | if (!pSpellCheck->CheckWord(sWord)) |
| 626 | sRet << GetWordSpellCheckAppearanceStream(pIterator,ptOffset,CPVT_WordRange(wpWordStart,oldplace)); |
| 627 | |
| 628 | bLatinWord = FALSE; |
| 629 | sWord.Empty(); |
| 630 | } |
| 631 | } |
| 632 | } |
| 633 | |
| 634 | return sRet.GetByteString(); |
| 635 | } |
| 636 | |
| 637 | CFX_ByteString CPWL_Utils::GetTextAppStream(const CPDF_Rect & rcBBox,IFX_Edit_FontMap * pFontMap, |
| 638 | const CFX_WideString & sText, FX_INT32 nAlignmentH, FX_INT32 nAlignmentV, |
| 639 | FX_FLOAT fFontSize, FX_BOOL bMultiLine, FX_BOOL bAutoReturn, const CPWL_Color & crText) |
| 640 | { |
| 641 | CFX_ByteTextBuf sRet; |
| 642 | |
| 643 | if (IFX_Edit * pEdit = IFX_Edit::NewEdit()) |
| 644 | { |
| 645 | pEdit->SetFontMap(pFontMap); |
| 646 | pEdit->SetPlateRect(rcBBox); |
| 647 | pEdit->SetAlignmentH(nAlignmentH); |
| 648 | pEdit->SetAlignmentV(nAlignmentV); |
| 649 | pEdit->SetMultiLine(bMultiLine); |
| 650 | pEdit->SetAutoReturn(bAutoReturn); |
| 651 | if (IsFloatZero(fFontSize)) |
| 652 | pEdit->SetAutoFontSize(TRUE); |
| 653 | else |
| 654 | pEdit->SetFontSize(fFontSize); |
| 655 | |
| 656 | pEdit->Initialize(); |
| 657 | pEdit->SetText(sText.c_str()); |
| 658 | |
| 659 | CFX_ByteString sEdit = CPWL_Utils::GetEditAppStream(pEdit, CPDF_Point(0.0f,0.0f)); |
| 660 | if (sEdit.GetLength() > 0) |
| 661 | { |
| 662 | sRet << "BT\n" << CPWL_Utils::GetColorAppStream(crText) << sEdit << "ET\n"; |
| 663 | } |
| 664 | IFX_Edit::DelEdit(pEdit); |
| 665 | } |
| 666 | |
| 667 | return sRet.GetByteString(); |
| 668 | } |
| 669 | |
| 670 | CFX_ByteString CPWL_Utils::GetPushButtonAppStream(const CPDF_Rect & rcBBox, |
| 671 | IFX_Edit_FontMap * pFontMap, |
| 672 | CPDF_Stream * pIconStream, |
| 673 | CPDF_IconFit & IconFit, |
| 674 | const CFX_WideString & sLabel, |
| 675 | const CPWL_Color & crText, |
| 676 | FX_FLOAT fFontSize, |
| 677 | FX_INT32 nLayOut) |
| 678 | { |
| 679 | const FX_FLOAT fAutoFontScale = 1.0f / 3.0f; |
| 680 | |
| 681 | if (IFX_Edit * pEdit = IFX_Edit::NewEdit()) |
| 682 | { |
| 683 | pEdit->SetFontMap(pFontMap); |
| 684 | pEdit->SetAlignmentH(1); |
| 685 | pEdit->SetAlignmentV(1); |
| 686 | pEdit->SetMultiLine(FALSE); |
| 687 | pEdit->SetAutoReturn(FALSE); |
| 688 | if (IsFloatZero(fFontSize)) |
| 689 | pEdit->SetAutoFontSize(TRUE); |
| 690 | else |
| 691 | pEdit->SetFontSize(fFontSize); |
| 692 | |
| 693 | pEdit->Initialize(); |
| 694 | pEdit->SetText(sLabel.c_str()); |
| 695 | |
| 696 | CPDF_Rect rcLabelContent = pEdit->GetContentRect(); |
| 697 | CPWL_Icon Icon; |
| 698 | PWL_CREATEPARAM cp; |
| 699 | cp.dwFlags = PWS_VISIBLE; |
| 700 | Icon.Create(cp); |
| 701 | Icon.SetIconFit(&IconFit); |
| 702 | Icon.SetPDFStream(pIconStream); |
| 703 | |
| 704 | CPDF_Rect rcLabel = CPDF_Rect(0,0,0,0); |
| 705 | CPDF_Rect rcIcon = CPDF_Rect(0,0,0,0); |
| 706 | FX_FLOAT fWidth = 0.0f; |
| 707 | FX_FLOAT fHeight = 0.0f; |
| 708 | |
| 709 | switch (nLayOut) |
| 710 | { |
| 711 | case PPBL_LABEL: |
| 712 | rcLabel = rcBBox; |
| 713 | rcIcon = CPDF_Rect(0,0,0,0); |
| 714 | break; |
| 715 | case PPBL_ICON: |
| 716 | rcIcon = rcBBox; |
| 717 | rcLabel = CPDF_Rect(0,0,0,0); |
| 718 | break; |
| 719 | case PPBL_ICONTOPLABELBOTTOM: |
| 720 | |
| 721 | if (pIconStream) |
| 722 | { |
| 723 | if (IsFloatZero(fFontSize)) |
| 724 | { |
| 725 | fHeight = rcBBox.top - rcBBox.bottom; |
| 726 | rcLabel = CPDF_Rect(rcBBox.left,rcBBox.bottom,rcBBox.right,rcBBox.bottom + fHeight * fAutoFontScale); |
| 727 | rcIcon = CPDF_Rect(rcBBox.left,rcLabel.top,rcBBox.right,rcBBox.top); |
| 728 | } |
| 729 | else |
| 730 | { |
| 731 | fHeight = rcLabelContent.Height(); |
| 732 | |
| 733 | if (rcBBox.bottom + fHeight > rcBBox.top) |
| 734 | { |
| 735 | rcIcon = CPDF_Rect(0,0,0,0); |
| 736 | rcLabel = rcBBox; |
| 737 | } |
| 738 | else |
| 739 | { |
| 740 | rcLabel = CPDF_Rect(rcBBox.left,rcBBox.bottom,rcBBox.right,rcBBox.bottom + fHeight); |
| 741 | rcIcon = CPDF_Rect(rcBBox.left,rcLabel.top,rcBBox.right,rcBBox.top); |
| 742 | } |
| 743 | } |
| 744 | } |
| 745 | else |
| 746 | { |
| 747 | rcLabel = rcBBox; |
| 748 | rcIcon = CPDF_Rect(0,0,0,0); |
| 749 | } |
| 750 | |
| 751 | break; |
| 752 | case PPBL_LABELTOPICONBOTTOM: |
| 753 | |
| 754 | if (pIconStream) |
| 755 | { |
| 756 | if (IsFloatZero(fFontSize)) |
| 757 | { |
| 758 | fHeight = rcBBox.top - rcBBox.bottom; |
| 759 | rcLabel = CPDF_Rect(rcBBox.left,rcBBox.top - fHeight * fAutoFontScale ,rcBBox.right,rcBBox.top); |
| 760 | rcIcon = CPDF_Rect(rcBBox.left,rcBBox.bottom,rcBBox.right,rcLabel.bottom); |
| 761 | } |
| 762 | else |
| 763 | { |
| 764 | fHeight = rcLabelContent.Height(); |
| 765 | |
| 766 | if (rcBBox.bottom + fHeight > rcBBox.top) |
| 767 | { |
| 768 | rcIcon = CPDF_Rect(0,0,0,0); |
| 769 | rcLabel = rcBBox; |
| 770 | } |
| 771 | else |
| 772 | { |
| 773 | rcLabel = CPDF_Rect(rcBBox.left,rcBBox.top - fHeight,rcBBox.right,rcBBox.top); |
| 774 | rcIcon = CPDF_Rect(rcBBox.left,rcBBox.bottom,rcBBox.right,rcLabel.bottom); |
| 775 | } |
| 776 | } |
| 777 | } |
| 778 | else |
| 779 | { |
| 780 | rcLabel = rcBBox; |
| 781 | rcIcon = CPDF_Rect(0,0,0,0); |
| 782 | } |
| 783 | |
| 784 | break; |
| 785 | case PPBL_ICONLEFTLABELRIGHT: |
| 786 | |
| 787 | if (pIconStream) |
| 788 | { |
| 789 | if (IsFloatZero(fFontSize)) |
| 790 | { |
| 791 | fWidth = rcBBox.right - rcBBox.left; |
| 792 | rcLabel = CPDF_Rect(rcBBox.right - fWidth * fAutoFontScale,rcBBox.bottom,rcBBox.right,rcBBox.top); |
| 793 | rcIcon = CPDF_Rect(rcBBox.left,rcBBox.bottom,rcLabel.left,rcBBox.top); |
| 794 | |
| 795 | if (rcLabelContent.Width() < fWidth * fAutoFontScale) |
| 796 | { |
| 797 | } |
| 798 | else |
| 799 | { |
| 800 | if (rcLabelContent.Width() < fWidth) |
| 801 | { |
| 802 | rcLabel = CPDF_Rect(rcBBox.right - rcLabelContent.Width(),rcBBox.bottom,rcBBox.right,rcBBox.top); |
| 803 | rcIcon = CPDF_Rect(rcBBox.left,rcBBox.bottom,rcLabel.left,rcBBox.top); |
| 804 | } |
| 805 | else |
| 806 | { |
| 807 | rcLabel = rcBBox; |
| 808 | rcIcon = CPDF_Rect(0,0,0,0); |
| 809 | } |
| 810 | } |
| 811 | } |
| 812 | else |
| 813 | { |
| 814 | fWidth = rcLabelContent.Width(); |
| 815 | |
| 816 | if (rcBBox.left + fWidth > rcBBox.right) |
| 817 | { |
| 818 | rcLabel = rcBBox; |
| 819 | rcIcon = CPDF_Rect(0,0,0,0); |
| 820 | } |
| 821 | else |
| 822 | { |
| 823 | rcLabel = CPDF_Rect(rcBBox.right - fWidth,rcBBox.bottom,rcBBox.right,rcBBox.top); |
| 824 | rcIcon = CPDF_Rect(rcBBox.left,rcBBox.bottom,rcLabel.left,rcBBox.top); |
| 825 | } |
| 826 | } |
| 827 | } |
| 828 | else |
| 829 | { |
| 830 | rcLabel = rcBBox; |
| 831 | rcIcon = CPDF_Rect(0,0,0,0); |
| 832 | } |
| 833 | |
| 834 | break; |
| 835 | case PPBL_LABELLEFTICONRIGHT: |
| 836 | |
| 837 | if (pIconStream) |
| 838 | { |
| 839 | if (IsFloatZero(fFontSize)) |
| 840 | { |
| 841 | fWidth = rcBBox.right - rcBBox.left; |
| 842 | rcLabel = CPDF_Rect(rcBBox.left,rcBBox.bottom,rcBBox.left + fWidth * fAutoFontScale,rcBBox.top); |
| 843 | rcIcon = CPDF_Rect(rcLabel.right,rcBBox.bottom,rcBBox.right,rcBBox.top); |
| 844 | |
| 845 | if (rcLabelContent.Width() < fWidth * fAutoFontScale) |
| 846 | { |
| 847 | } |
| 848 | else |
| 849 | { |
| 850 | if (rcLabelContent.Width() < fWidth) |
| 851 | { |
| 852 | rcLabel = CPDF_Rect(rcBBox.left,rcBBox.bottom,rcBBox.left + rcLabelContent.Width(),rcBBox.top); |
| 853 | rcIcon = CPDF_Rect(rcLabel.right,rcBBox.bottom,rcBBox.right,rcBBox.top); |
| 854 | } |
| 855 | else |
| 856 | { |
| 857 | rcLabel = rcBBox; |
| 858 | rcIcon = CPDF_Rect(0,0,0,0); |
| 859 | } |
| 860 | } |
| 861 | } |
| 862 | else |
| 863 | { |
| 864 | fWidth = rcLabelContent.Width(); |
| 865 | |
| 866 | if (rcBBox.left + fWidth > rcBBox.right) |
| 867 | { |
| 868 | rcLabel = rcBBox; |
| 869 | rcIcon = CPDF_Rect(0,0,0,0); |
| 870 | } |
| 871 | else |
| 872 | { |
| 873 | rcLabel = CPDF_Rect(rcBBox.left,rcBBox.bottom,rcBBox.left + fWidth,rcBBox.top); |
| 874 | rcIcon = CPDF_Rect(rcLabel.right,rcBBox.bottom,rcBBox.right,rcBBox.top); |
| 875 | } |
| 876 | } |
| 877 | } |
| 878 | else |
| 879 | { |
| 880 | rcLabel = rcBBox; |
| 881 | rcIcon = CPDF_Rect(0,0,0,0); |
| 882 | } |
| 883 | |
| 884 | break; |
| 885 | case PPBL_LABELOVERICON: |
| 886 | rcLabel = rcBBox; |
| 887 | rcIcon = rcBBox; |
| 888 | break; |
| 889 | } |
| 890 | |
| 891 | CFX_ByteTextBuf sAppStream,sTemp; |
| 892 | |
| 893 | if (!rcIcon.IsEmpty()) |
| 894 | { |
| 895 | Icon.Move(rcIcon, FALSE, FALSE); |
| 896 | sTemp << Icon.GetImageAppStream(); |
| 897 | } |
| 898 | |
| 899 | Icon.Destroy(); |
| 900 | |
| 901 | if (!rcLabel.IsEmpty()) |
| 902 | { |
| 903 | pEdit->SetPlateRect(rcLabel); |
| 904 | CFX_ByteString sEdit = CPWL_Utils::GetEditAppStream(pEdit,CPDF_Point(0.0f,0.0f)); |
| 905 | if (sEdit.GetLength() > 0) |
| 906 | { |
| 907 | sTemp << "BT\n" << CPWL_Utils::GetColorAppStream(crText) << sEdit << "ET\n"; |
| 908 | } |
| 909 | } |
| 910 | |
| 911 | IFX_Edit::DelEdit(pEdit); |
| 912 | |
| 913 | if (sTemp.GetSize() > 0) |
| 914 | { |
| 915 | sAppStream << "q\n" << rcBBox.left << " " << rcBBox.bottom << " " |
| 916 | << rcBBox.right - rcBBox.left << " " << rcBBox.top - rcBBox.bottom << " re W n\n"; |
| 917 | sAppStream << sTemp << "Q\n"; |
| 918 | } |
| 919 | |
| 920 | return sAppStream.GetByteString(); |
| 921 | } |
| 922 | |
| 923 | return ""; |
| 924 | } |
| 925 | |
| 926 | CFX_ByteString CPWL_Utils::GetColorAppStream(const CPWL_Color & color,const FX_BOOL & bFillOrStroke) |
| 927 | { |
| 928 | CFX_ByteTextBuf sColorStream; |
| 929 | |
| 930 | switch (color.nColorType) |
| 931 | { |
| 932 | case COLORTYPE_RGB: |
| 933 | sColorStream << color.fColor1 << " " << color.fColor2 << " " << color.fColor3 << " " |
| 934 | << (bFillOrStroke ? "rg" : "RG") << "\n"; |
| 935 | break; |
| 936 | case COLORTYPE_GRAY: |
| 937 | sColorStream << color.fColor1 << " " << (bFillOrStroke ? "g" : "G") << "\n"; |
| 938 | break; |
| 939 | case COLORTYPE_CMYK: |
| 940 | sColorStream << color.fColor1 << " " << color.fColor2 << " " << color.fColor3 << " " << color.fColor4 << " " |
| 941 | << (bFillOrStroke ? "k" : "K") << "\n"; |
| 942 | break; |
| 943 | } |
| 944 | |
| 945 | return sColorStream.GetByteString(); |
| 946 | } |
| 947 | |
| 948 | CFX_ByteString CPWL_Utils::GetBorderAppStream(const CPDF_Rect & rect, FX_FLOAT fWidth, |
| 949 | const CPWL_Color & color, const CPWL_Color & crLeftTop, const CPWL_Color & crRightBottom, |
| 950 | FX_INT32 nStyle, const CPWL_Dash & dash) |
| 951 | { |
| 952 | CFX_ByteTextBuf sAppStream; |
| 953 | CFX_ByteString sColor; |
| 954 | |
| 955 | FX_FLOAT fLeft = rect.left; |
| 956 | FX_FLOAT fRight = rect.right; |
| 957 | FX_FLOAT fTop = rect.top; |
| 958 | FX_FLOAT fBottom = rect.bottom; |
| 959 | |
| 960 | if (fWidth > 0.0f) |
| 961 | { |
| 962 | FX_FLOAT fHalfWidth = fWidth / 2.0f; |
| 963 | |
| 964 | sAppStream << "q\n"; |
| 965 | |
| 966 | switch (nStyle) |
| 967 | { |
| 968 | default: |
| 969 | case PBS_SOLID: |
| 970 | sColor = CPWL_Utils::GetColorAppStream(color,TRUE); |
| 971 | if (sColor.GetLength() > 0) |
| 972 | { |
| 973 | sAppStream << sColor; |
| 974 | sAppStream << fLeft << " " << fBottom << " " << fRight - fLeft << " " << fTop - fBottom << " re\n"; |
| 975 | sAppStream << fLeft + fWidth << " " << fBottom + fWidth << " " |
| 976 | << fRight - fLeft - fWidth * 2 << " " << fTop - fBottom - fWidth * 2 << " re\n"; |
| 977 | sAppStream << "f*\n"; |
| 978 | } |
| 979 | break; |
| 980 | case PBS_DASH: |
| 981 | sColor = CPWL_Utils::GetColorAppStream(color,FALSE); |
| 982 | if (sColor.GetLength() > 0) |
| 983 | { |
| 984 | sAppStream << sColor; |
| 985 | sAppStream << fWidth << " w" << " [" << dash.nDash << " " << dash.nGap << "] " << dash.nPhase << " d\n"; |
| 986 | sAppStream << fLeft + fWidth / 2 << " " << fBottom + fWidth / 2 << " m\n"; |
| 987 | sAppStream << fLeft + fWidth / 2 << " " << fTop - fWidth / 2 << " l\n"; |
| 988 | sAppStream << fRight - fWidth / 2 << " " << fTop - fWidth / 2 << " l\n"; |
| 989 | sAppStream << fRight - fWidth / 2 << " " << fBottom + fWidth / 2 << " l\n"; |
| 990 | sAppStream << fLeft + fWidth / 2 << " " << fBottom + fWidth / 2 << " l S\n"; |
| 991 | } |
| 992 | break; |
| 993 | case PBS_BEVELED: |
| 994 | case PBS_INSET: |
| 995 | sColor = CPWL_Utils::GetColorAppStream(crLeftTop,TRUE); |
| 996 | if (sColor.GetLength() > 0) |
| 997 | { |
| 998 | sAppStream << sColor; |
| 999 | sAppStream << fLeft + fHalfWidth << " " << fBottom + fHalfWidth << " m\n"; |
| 1000 | sAppStream << fLeft + fHalfWidth << " " << fTop - fHalfWidth << " l\n"; |
| 1001 | sAppStream << fRight - fHalfWidth << " " << fTop - fHalfWidth << " l\n"; |
| 1002 | sAppStream << fRight - fHalfWidth * 2 << " " << fTop - fHalfWidth * 2 << " l\n"; |
| 1003 | sAppStream << fLeft + fHalfWidth * 2 << " " << fTop - fHalfWidth * 2 << " l\n"; |
| 1004 | sAppStream << fLeft + fHalfWidth * 2 << " " << fBottom + fHalfWidth * 2 << " l f\n"; |
| 1005 | } |
| 1006 | |
| 1007 | sColor = CPWL_Utils::GetColorAppStream(crRightBottom,TRUE); |
| 1008 | if (sColor.GetLength() > 0) |
| 1009 | { |
| 1010 | sAppStream << sColor; |
| 1011 | sAppStream << fRight - fHalfWidth << " " << fTop - fHalfWidth << " m\n"; |
| 1012 | sAppStream << fRight - fHalfWidth << " " << fBottom + fHalfWidth << " l\n"; |
| 1013 | sAppStream << fLeft + fHalfWidth << " " << fBottom + fHalfWidth << " l\n"; |
| 1014 | sAppStream << fLeft + fHalfWidth * 2 << " " << fBottom + fHalfWidth * 2 << " l\n"; |
| 1015 | sAppStream << fRight - fHalfWidth * 2 << " " << fBottom + fHalfWidth * 2 << " l\n"; |
| 1016 | sAppStream << fRight - fHalfWidth * 2 << " " << fTop - fHalfWidth * 2 << " l f\n"; |
| 1017 | } |
| 1018 | |
| 1019 | sColor = CPWL_Utils::GetColorAppStream(color,TRUE); |
| 1020 | if (sColor.GetLength() > 0) |
| 1021 | { |
| 1022 | sAppStream << sColor; |
| 1023 | sAppStream << fLeft << " " << fBottom << " " << fRight - fLeft << " " << fTop - fBottom << " re\n"; |
| 1024 | sAppStream << fLeft + fHalfWidth << " " << fBottom + fHalfWidth << " " |
| 1025 | << fRight - fLeft - fHalfWidth * 2 << " " << fTop - fBottom - fHalfWidth * 2 << " re f*\n"; |
| 1026 | } |
| 1027 | break; |
| 1028 | case PBS_UNDERLINED: |
| 1029 | sColor = CPWL_Utils::GetColorAppStream(color,FALSE); |
| 1030 | if (sColor.GetLength() > 0) |
| 1031 | { |
| 1032 | sAppStream << sColor; |
| 1033 | sAppStream << fWidth << " w\n"; |
| 1034 | sAppStream << fLeft << " " << fBottom + fWidth / 2 << " m\n"; |
| 1035 | sAppStream << fRight << " " << fBottom + fWidth / 2 << " l S\n"; |
| 1036 | } |
| 1037 | break; |
| 1038 | } |
| 1039 | |
| 1040 | sAppStream << "Q\n"; |
| 1041 | } |
| 1042 | |
| 1043 | return sAppStream.GetByteString(); |
| 1044 | } |
| 1045 | |
| 1046 | CFX_ByteString CPWL_Utils::GetCircleBorderAppStream(const CPDF_Rect & rect, FX_FLOAT fWidth, |
| 1047 | const CPWL_Color & color, const CPWL_Color & crLeftTop, const CPWL_Color & crRightBottom, |
| 1048 | FX_INT32 nStyle, const CPWL_Dash & dash) |
| 1049 | { |
| 1050 | CFX_ByteTextBuf sAppStream; |
| 1051 | CFX_ByteString sColor; |
| 1052 | |
| 1053 | |
| 1054 | |
| 1055 | |
| 1056 | |
| 1057 | |
| 1058 | if (fWidth > 0.0f) |
| 1059 | { |
| 1060 | sAppStream << "q\n"; |
| 1061 | |
| 1062 | switch (nStyle) |
| 1063 | { |
| 1064 | default: |
| 1065 | case PBS_SOLID: |
| 1066 | case PBS_UNDERLINED: |
| 1067 | { |
| 1068 | sColor = CPWL_Utils::GetColorAppStream(color,FALSE); |
| 1069 | if (sColor.GetLength() > 0) |
| 1070 | { |
| 1071 | sAppStream << "q\n" << fWidth << " w\n" << sColor |
| 1072 | << CPWL_Utils::GetAP_Circle(CPWL_Utils::DeflateRect(rect,fWidth / 2.0f)) |
| 1073 | << " S\nQ\n"; |
| 1074 | } |
| 1075 | } |
| 1076 | break; |
| 1077 | case PBS_DASH: |
| 1078 | { |
| 1079 | sColor = CPWL_Utils::GetColorAppStream(color,FALSE); |
| 1080 | if (sColor.GetLength() > 0) |
| 1081 | { |
| 1082 | sAppStream << "q\n" << fWidth << " w\n" |
| 1083 | << "[" << dash.nDash << " " << dash.nGap << "] " << dash.nPhase << " d\n" |
| 1084 | << sColor << CPWL_Utils::GetAP_Circle(CPWL_Utils::DeflateRect(rect,fWidth / 2.0f)) |
| 1085 | << " S\nQ\n"; |
| 1086 | } |
| 1087 | } |
| 1088 | break; |
| 1089 | case PBS_BEVELED: |
| 1090 | { |
| 1091 | FX_FLOAT fHalfWidth = fWidth / 2.0f; |
| 1092 | |
| 1093 | sColor = CPWL_Utils::GetColorAppStream(color,FALSE); |
| 1094 | if (sColor.GetLength() > 0) |
| 1095 | { |
| 1096 | sAppStream << "q\n" << fHalfWidth << " w\n" |
| 1097 | << sColor << CPWL_Utils::GetAP_Circle(rect) |
| 1098 | << " S\nQ\n"; |
| 1099 | } |
| 1100 | |
| 1101 | sColor = CPWL_Utils::GetColorAppStream(crLeftTop,FALSE); |
| 1102 | if (sColor.GetLength() > 0) |
| 1103 | { |
| 1104 | sAppStream << "q\n" << fHalfWidth << " w\n" |
| 1105 | << sColor << CPWL_Utils::GetAP_HalfCircle(CPWL_Utils::DeflateRect(rect,fHalfWidth * 0.75f),PWL_PI/4.0f) |
| 1106 | << " S\nQ\n"; |
| 1107 | } |
| 1108 | |
| 1109 | sColor = CPWL_Utils::GetColorAppStream(crRightBottom,FALSE); |
| 1110 | if (sColor.GetLength() > 0) |
| 1111 | { |
| 1112 | sAppStream << "q\n" << fHalfWidth << " w\n" |
| 1113 | << sColor << CPWL_Utils::GetAP_HalfCircle(CPWL_Utils::DeflateRect(rect,fHalfWidth * 0.75f),PWL_PI*5/4.0f) |
| 1114 | << " S\nQ\n"; |
| 1115 | } |
| 1116 | } |
| 1117 | break; |
| 1118 | case PBS_INSET: |
| 1119 | { |
| 1120 | FX_FLOAT fHalfWidth = fWidth / 2.0f; |
| 1121 | |
| 1122 | sColor = CPWL_Utils::GetColorAppStream(color,FALSE); |
| 1123 | if (sColor.GetLength() > 0) |
| 1124 | { |
| 1125 | sAppStream << "q\n" << fHalfWidth << " w\n" |
| 1126 | << sColor << CPWL_Utils::GetAP_Circle(rect) |
| 1127 | << " S\nQ\n"; |
| 1128 | } |
| 1129 | |
| 1130 | sColor = CPWL_Utils::GetColorAppStream(crLeftTop,FALSE); |
| 1131 | if (sColor.GetLength() > 0) |
| 1132 | { |
| 1133 | sAppStream << "q\n" << fHalfWidth << " w\n" |
| 1134 | << sColor << CPWL_Utils::GetAP_HalfCircle(CPWL_Utils::DeflateRect(rect,fHalfWidth * 0.75f),PWL_PI/4.0f) |
| 1135 | << " S\nQ\n"; |
| 1136 | } |
| 1137 | |
| 1138 | sColor = CPWL_Utils::GetColorAppStream(crRightBottom,FALSE); |
| 1139 | if (sColor.GetLength() > 0) |
| 1140 | { |
| 1141 | sAppStream << "q\n" << fHalfWidth << " w\n" |
| 1142 | << sColor << CPWL_Utils::GetAP_HalfCircle(CPWL_Utils::DeflateRect(rect,fHalfWidth * 0.75f),PWL_PI*5/4.0f) |
| 1143 | << " S\nQ\n"; |
| 1144 | } |
| 1145 | } |
| 1146 | break; |
| 1147 | } |
| 1148 | |
| 1149 | sAppStream << "Q\n"; |
| 1150 | } |
| 1151 | |
| 1152 | return sAppStream.GetByteString(); |
| 1153 | } |
| 1154 | |
| 1155 | CPWL_Color CPWL_Utils::SubstractColor(const CPWL_Color & sColor,FX_FLOAT fColorSub) |
| 1156 | { |
| 1157 | CPWL_Color sRet; |
| 1158 | sRet.nColorType = sColor.nColorType; |
| 1159 | |
| 1160 | switch (sColor.nColorType) |
| 1161 | { |
| 1162 | case COLORTYPE_TRANSPARENT: |
| 1163 | sRet.nColorType = COLORTYPE_RGB; |
| 1164 | sRet.fColor1 = PWL_MAX(1 - fColorSub,0.0f); |
| 1165 | sRet.fColor2 = PWL_MAX(1 - fColorSub,0.0f); |
| 1166 | sRet.fColor3 = PWL_MAX(1 - fColorSub,0.0f); |
| 1167 | break; |
| 1168 | case COLORTYPE_RGB: |
| 1169 | case COLORTYPE_GRAY: |
| 1170 | case COLORTYPE_CMYK: |
| 1171 | sRet.fColor1 = PWL_MAX(sColor.fColor1 - fColorSub,0.0f); |
| 1172 | sRet.fColor2 = PWL_MAX(sColor.fColor2 - fColorSub,0.0f); |
| 1173 | sRet.fColor3 = PWL_MAX(sColor.fColor3 - fColorSub,0.0f); |
| 1174 | sRet.fColor4 = PWL_MAX(sColor.fColor4 - fColorSub,0.0f); |
| 1175 | break; |
| 1176 | } |
| 1177 | |
| 1178 | return sRet; |
| 1179 | } |
| 1180 | |
| 1181 | CPWL_Color CPWL_Utils::DevideColor(const CPWL_Color & sColor,FX_FLOAT fColorDevide) |
| 1182 | { |
| 1183 | CPWL_Color sRet; |
| 1184 | sRet.nColorType = sColor.nColorType; |
| 1185 | |
| 1186 | switch (sColor.nColorType) |
| 1187 | { |
| 1188 | case COLORTYPE_TRANSPARENT: |
| 1189 | sRet.nColorType = COLORTYPE_RGB; |
| 1190 | sRet.fColor1 = 1 / fColorDevide; |
| 1191 | sRet.fColor2 = 1 / fColorDevide; |
| 1192 | sRet.fColor3 = 1 / fColorDevide; |
| 1193 | break; |
| 1194 | case COLORTYPE_RGB: |
| 1195 | case COLORTYPE_GRAY: |
| 1196 | case COLORTYPE_CMYK: |
| 1197 | sRet = sColor; |
| 1198 | sRet.fColor1 /= fColorDevide; |
| 1199 | sRet.fColor2 /= fColorDevide; |
| 1200 | sRet.fColor3 /= fColorDevide; |
| 1201 | sRet.fColor4 /= fColorDevide; |
| 1202 | break; |
| 1203 | } |
| 1204 | |
| 1205 | return sRet; |
| 1206 | } |
| 1207 | |
| 1208 | CFX_ByteString CPWL_Utils::GetAppStream_Check(const CPDF_Rect & rcBBox, const CPWL_Color & crText) |
| 1209 | { |
| 1210 | CFX_ByteTextBuf sAP; |
| 1211 | sAP << "q\n" << CPWL_Utils::GetColorAppStream(crText,TRUE) << CPWL_Utils::GetAP_Check(rcBBox) << "f\nQ\n"; |
| 1212 | return sAP.GetByteString(); |
| 1213 | } |
| 1214 | |
| 1215 | CFX_ByteString CPWL_Utils::GetAppStream_Circle(const CPDF_Rect & rcBBox, const CPWL_Color & crText) |
| 1216 | { |
| 1217 | CFX_ByteTextBuf sAP; |
| 1218 | sAP << "q\n" << CPWL_Utils::GetColorAppStream(crText,TRUE) << CPWL_Utils::GetAP_Circle(rcBBox) << "f\nQ\n"; |
| 1219 | return sAP.GetByteString(); |
| 1220 | } |
| 1221 | |
| 1222 | CFX_ByteString CPWL_Utils::GetAppStream_Cross(const CPDF_Rect & rcBBox, const CPWL_Color & crText) |
| 1223 | { |
| 1224 | CFX_ByteTextBuf sAP; |
| 1225 | sAP << "q\n" << CPWL_Utils::GetColorAppStream(crText,FALSE) << CPWL_Utils::GetAP_Cross(rcBBox) << "S\nQ\n"; |
| 1226 | return sAP.GetByteString(); |
| 1227 | } |
| 1228 | |
| 1229 | CFX_ByteString CPWL_Utils::GetAppStream_Diamond(const CPDF_Rect & rcBBox, const CPWL_Color & crText) |
| 1230 | { |
| 1231 | CFX_ByteTextBuf sAP; |
| 1232 | sAP << "q\n1 w\n" << CPWL_Utils::GetColorAppStream(crText,TRUE) << CPWL_Utils::GetAP_Diamond(rcBBox) << "f\nQ\n"; |
| 1233 | return sAP.GetByteString(); |
| 1234 | } |
| 1235 | |
| 1236 | CFX_ByteString CPWL_Utils::GetAppStream_Square(const CPDF_Rect & rcBBox, const CPWL_Color & crText) |
| 1237 | { |
| 1238 | CFX_ByteTextBuf sAP; |
| 1239 | sAP << "q\n" << CPWL_Utils::GetColorAppStream(crText,TRUE) << CPWL_Utils::GetAP_Square(rcBBox) << "f\nQ\n"; |
| 1240 | return sAP.GetByteString(); |
| 1241 | } |
| 1242 | |
| 1243 | CFX_ByteString CPWL_Utils::GetAppStream_Star(const CPDF_Rect & rcBBox, const CPWL_Color & crText) |
| 1244 | { |
| 1245 | CFX_ByteTextBuf sAP; |
| 1246 | sAP << "q\n" << CPWL_Utils::GetColorAppStream(crText,TRUE) << CPWL_Utils::GetAP_Star(rcBBox) << "f\nQ\n"; |
| 1247 | return sAP.GetByteString(); |
| 1248 | } |
| 1249 | |
| 1250 | CFX_ByteString CPWL_Utils::GetCheckBoxAppStream(const CPDF_Rect & rcBBox, |
| 1251 | FX_INT32 nStyle, |
| 1252 | const CPWL_Color & crText) |
| 1253 | { |
| 1254 | CPDF_Rect rcCenter = GetCenterSquare(rcBBox); |
| 1255 | switch (nStyle) |
| 1256 | { |
| 1257 | default: |
| 1258 | case PCS_CHECK: |
| 1259 | return GetAppStream_Check(rcCenter,crText); |
| 1260 | case PCS_CIRCLE: |
| 1261 | return GetAppStream_Circle(ScaleRect(rcCenter,2.0f/3.0f),crText); |
| 1262 | case PCS_CROSS: |
| 1263 | return GetAppStream_Cross(rcCenter,crText); |
| 1264 | case PCS_DIAMOND: |
| 1265 | return GetAppStream_Diamond(ScaleRect(rcCenter,2.0f/3.0f),crText); |
| 1266 | case PCS_SQUARE: |
| 1267 | return GetAppStream_Square(ScaleRect(rcCenter,2.0f/3.0f),crText); |
| 1268 | case PCS_STAR: |
| 1269 | return GetAppStream_Star(ScaleRect(rcCenter,2.0f/3.0f),crText); |
| 1270 | } |
| 1271 | } |
| 1272 | |
| 1273 | CFX_ByteString CPWL_Utils::GetRadioButtonAppStream(const CPDF_Rect & rcBBox, |
| 1274 | FX_INT32 nStyle, |
| 1275 | const CPWL_Color & crText) |
| 1276 | { |
| 1277 | CPDF_Rect rcCenter = GetCenterSquare(rcBBox); |
| 1278 | switch (nStyle) |
| 1279 | { |
| 1280 | default: |
| 1281 | case PCS_CHECK: |
| 1282 | return GetAppStream_Check(rcCenter,crText); |
| 1283 | case PCS_CIRCLE: |
| 1284 | return GetAppStream_Circle(ScaleRect(rcCenter,1.0f/2.0f),crText); |
| 1285 | case PCS_CROSS: |
| 1286 | return GetAppStream_Cross(rcCenter,crText); |
| 1287 | case PCS_DIAMOND: |
| 1288 | return GetAppStream_Diamond(ScaleRect(rcCenter,2.0f/3.0f),crText); |
| 1289 | case PCS_SQUARE: |
| 1290 | return GetAppStream_Square(ScaleRect(rcCenter,2.0f/3.0f),crText); |
| 1291 | case PCS_STAR: |
| 1292 | return GetAppStream_Star(ScaleRect(rcCenter,2.0f/3.0f),crText); |
| 1293 | } |
| 1294 | } |
| 1295 | |
| 1296 | CFX_ByteString CPWL_Utils::GetDropButtonAppStream(const CPDF_Rect & rcBBox) |
| 1297 | { |
| 1298 | CFX_ByteTextBuf sAppStream; |
| 1299 | |
| 1300 | if (!rcBBox.IsEmpty()) |
| 1301 | { |
| 1302 | sAppStream << "q\n" << CPWL_Utils::GetColorAppStream(CPWL_Color(COLORTYPE_RGB,220.0f/255.0f,220.0f/255.0f,220.0f/255.0f),TRUE); |
| 1303 | sAppStream << rcBBox.left << " " << rcBBox.bottom << " " |
| 1304 | << rcBBox.right - rcBBox.left << " " << rcBBox.top - rcBBox.bottom << " re f\n"; |
| 1305 | sAppStream << "Q\n"; |
| 1306 | |
| 1307 | sAppStream << "q\n" << |
| 1308 | CPWL_Utils::GetBorderAppStream(rcBBox,2,CPWL_Color(COLORTYPE_GRAY,0),CPWL_Color(COLORTYPE_GRAY,1),CPWL_Color(COLORTYPE_GRAY,0.5),PBS_BEVELED,CPWL_Dash(3,0,0)) |
| 1309 | << "Q\n"; |
| 1310 | |
| 1311 | CPDF_Point ptCenter = CPDF_Point((rcBBox.left + rcBBox.right)/2,(rcBBox.top + rcBBox.bottom)/2); |
| 1312 | if (IsFloatBigger(rcBBox.right - rcBBox.left,6) && IsFloatBigger(rcBBox.top - rcBBox.bottom,6)) |
| 1313 | { |
| 1314 | sAppStream << "q\n" << " 0 g\n"; |
| 1315 | sAppStream << ptCenter.x - 3 << " " << ptCenter.y + 1.5f << " m\n"; |
| 1316 | sAppStream << ptCenter.x + 3 << " " << ptCenter.y + 1.5f << " l\n"; |
| 1317 | sAppStream << ptCenter.x << " " << ptCenter.y - 1.5f << " l\n"; |
| 1318 | sAppStream << ptCenter.x - 3 << " " << ptCenter.y + 1.5f << " l f\n"; |
| 1319 | sAppStream << "Q\n"; |
| 1320 | } |
| 1321 | } |
| 1322 | |
| 1323 | return sAppStream.GetByteString(); |
| 1324 | } |
| 1325 | |
| 1326 | void CPWL_Utils::ConvertCMYK2GRAY(FX_FLOAT dC,FX_FLOAT dM,FX_FLOAT dY,FX_FLOAT dK,FX_FLOAT &dGray) |
| 1327 | { |
| 1328 | if (dC<0 || dC>1 || dM<0 || dM>1 || dY < 0 || dY >1 || dK < 0 || dK >1) |
| 1329 | return; |
| 1330 | dGray = 1.0f - FX_MIN(1.0f,0.3f*dC+0.59f * dM + 0.11f*dY+dK); |
| 1331 | } |
| 1332 | |
| 1333 | void CPWL_Utils::ConvertGRAY2CMYK(FX_FLOAT dGray,FX_FLOAT &dC,FX_FLOAT &dM,FX_FLOAT &dY,FX_FLOAT &dK) |
| 1334 | { |
| 1335 | if (dGray <0 || dGray >1) |
| 1336 | return; |
| 1337 | dC = 0.0f; |
| 1338 | dM = 0.0f; |
| 1339 | dY = 0.0f; |
| 1340 | dK = 1.0f-dGray; |
| 1341 | } |
| 1342 | |
| 1343 | void CPWL_Utils::ConvertGRAY2RGB(FX_FLOAT dGray,FX_FLOAT &dR,FX_FLOAT &dG,FX_FLOAT &dB) |
| 1344 | { |
| 1345 | if (dGray <0 || dGray >1) |
| 1346 | return; |
| 1347 | dR = dGray; |
| 1348 | dG = dGray; |
| 1349 | dB = dGray; |
| 1350 | } |
| 1351 | |
| 1352 | void CPWL_Utils::ConvertRGB2GRAY(FX_FLOAT dR,FX_FLOAT dG,FX_FLOAT dB,FX_FLOAT &dGray) |
| 1353 | { |
| 1354 | if (dR<0 || dR>1 || dG<0 || dG > 0 || dB < 0 || dB >1) |
| 1355 | return; |
| 1356 | dGray = 0.3f*dR+0.59f*dG+0.11f*dB; |
| 1357 | } |
| 1358 | |
| 1359 | void CPWL_Utils::ConvertCMYK2RGB(FX_FLOAT dC,FX_FLOAT dM,FX_FLOAT dY,FX_FLOAT dK,FX_FLOAT &dR,FX_FLOAT &dG,FX_FLOAT &dB) |
| 1360 | { |
| 1361 | if (dC <0 || dC>1 || dM < 0 || dM > 1 || dY < 0 || dY > 1 || dK < 0 || dK > 1 ) |
| 1362 | return; |
| 1363 | dR = 1.0f - FX_MIN(1.0f, dC + dK); |
| 1364 | dG = 1.0f - FX_MIN(1.0f, dM + dK); |
| 1365 | dB = 1.0f - FX_MIN(1.0f, dY + dK); |
| 1366 | } |
| 1367 | |
| 1368 | void CPWL_Utils::ConvertRGB2CMYK(FX_FLOAT dR,FX_FLOAT dG,FX_FLOAT dB,FX_FLOAT &dC,FX_FLOAT &dM,FX_FLOAT &dY,FX_FLOAT &dK) |
| 1369 | { |
| 1370 | if (dR<0 || dR>1 || dG<0 || dG>1 || dB<0 || dB>1) |
| 1371 | return; |
| 1372 | |
| 1373 | dC = 1.0f - dR; |
| 1374 | dM = 1.0f - dG; |
| 1375 | dY = 1.0f - dB; |
| 1376 | dK = FX_MIN(dC, FX_MIN(dM, dY)); |
| 1377 | } |
| 1378 | |
| 1379 | void CPWL_Utils::PWLColorToARGB(const CPWL_Color& color, FX_INT32& alpha, FX_FLOAT& red, FX_FLOAT& green, FX_FLOAT& blue) |
| 1380 | { |
| 1381 | switch (color.nColorType) |
| 1382 | { |
| 1383 | case COLORTYPE_TRANSPARENT: |
| 1384 | { |
| 1385 | alpha = 0; |
| 1386 | } |
| 1387 | break; |
| 1388 | case COLORTYPE_GRAY: |
| 1389 | { |
| 1390 | ConvertGRAY2RGB(color.fColor1, red, green, blue); |
| 1391 | } |
| 1392 | break; |
| 1393 | case COLORTYPE_RGB: |
| 1394 | { |
| 1395 | red = color.fColor1; |
| 1396 | green = color.fColor2; |
| 1397 | blue = color.fColor3; |
| 1398 | } |
| 1399 | break; |
| 1400 | case COLORTYPE_CMYK: |
| 1401 | { |
| 1402 | ConvertCMYK2RGB(color.fColor1, color.fColor2, color.fColor3, color.fColor4, |
| 1403 | red, green, blue); |
| 1404 | } |
| 1405 | break; |
| 1406 | } |
| 1407 | } |
| 1408 | |
| 1409 | FX_COLORREF CPWL_Utils::PWLColorToFXColor(const CPWL_Color& color, FX_INT32 nTransparancy) |
| 1410 | { |
| 1411 | FX_INT32 nAlpha = nTransparancy; |
| 1412 | FX_FLOAT dRed = 0; |
| 1413 | FX_FLOAT dGreen = 0; |
| 1414 | FX_FLOAT dBlue = 0; |
| 1415 | |
| 1416 | PWLColorToARGB(color, nAlpha, dRed, dGreen, dBlue); |
| 1417 | |
| 1418 | return ArgbEncode(nAlpha, (FX_INT32)(dRed*255), (FX_INT32)(dGreen*255), (FX_INT32)(dBlue*255)); |
| 1419 | } |
| 1420 | |
| 1421 | void CPWL_Utils::DrawFillRect(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device,const CPDF_Rect & rect, |
| 1422 | const FX_COLORREF & color) |
| 1423 | { |
| 1424 | CFX_PathData path; |
| 1425 | CPDF_Rect rcTemp(rect); |
| 1426 | path.AppendRect(rcTemp.left,rcTemp.bottom,rcTemp.right,rcTemp.top); |
| 1427 | pDevice->DrawPath(&path, pUser2Device, NULL, color, 0, FXFILL_WINDING); |
| 1428 | } |
| 1429 | |
| 1430 | void CPWL_Utils::DrawFillArea(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device, |
| 1431 | const CPDF_Point* pPts, FX_INT32 nCount, const FX_COLORREF& color) |
| 1432 | { |
| 1433 | CFX_PathData path; |
| 1434 | path.SetPointCount(nCount); |
| 1435 | |
| 1436 | path.SetPoint(0, pPts[0].x, pPts[0].y, FXPT_MOVETO); |
| 1437 | for (FX_INT32 i=1; i<nCount; i++) |
| 1438 | path.SetPoint(i, pPts[i].x, pPts[i].y, FXPT_LINETO); |
| 1439 | |
| 1440 | pDevice->DrawPath(&path, pUser2Device, NULL, color, 0, FXFILL_ALTERNATE); |
| 1441 | } |
| 1442 | |
| 1443 | void CPWL_Utils::DrawStrokeRect(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device,const CPDF_Rect & rect, |
| 1444 | const FX_COLORREF & color, FX_FLOAT fWidth) |
| 1445 | { |
| 1446 | CFX_PathData path; |
| 1447 | CPDF_Rect rcTemp(rect); |
| 1448 | path.AppendRect(rcTemp.left,rcTemp.bottom,rcTemp.right,rcTemp.top); |
| 1449 | |
| 1450 | CFX_GraphStateData gsd; |
| 1451 | gsd.m_LineWidth = fWidth; |
| 1452 | |
| 1453 | pDevice->DrawPath(&path, pUser2Device, &gsd, 0, color, FXFILL_ALTERNATE); |
| 1454 | } |
| 1455 | |
| 1456 | void CPWL_Utils::DrawStrokeLine(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device, |
| 1457 | const CPDF_Point & ptMoveTo, const CPDF_Point & ptLineTo, const FX_COLORREF & color, FX_FLOAT fWidth) |
| 1458 | { |
| 1459 | CFX_PathData path; |
| 1460 | path.SetPointCount(2); |
| 1461 | path.SetPoint(0, ptMoveTo.x, ptMoveTo.y, FXPT_MOVETO); |
| 1462 | path.SetPoint(1, ptLineTo.x, ptLineTo.y, FXPT_LINETO); |
| 1463 | |
| 1464 | CFX_GraphStateData gsd; |
| 1465 | gsd.m_LineWidth = fWidth; |
| 1466 | |
| 1467 | pDevice->DrawPath(&path, pUser2Device, &gsd, 0, color, FXFILL_ALTERNATE); |
| 1468 | } |
| 1469 | |
| 1470 | void CPWL_Utils::DrawFillRect(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device,const CPDF_Rect & rect, |
| 1471 | const CPWL_Color & color, FX_INT32 nTransparancy) |
| 1472 | { |
| 1473 | CPWL_Utils::DrawFillRect(pDevice,pUser2Device,rect,PWLColorToFXColor(color,nTransparancy)); |
| 1474 | } |
| 1475 | |
| 1476 | void CPWL_Utils::DrawShadow(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device, |
| 1477 | FX_BOOL bVertical, FX_BOOL bHorizontal, CPDF_Rect rect, |
| 1478 | FX_INT32 nTransparancy, FX_INT32 nStartGray, FX_INT32 nEndGray) |
| 1479 | { |
| 1480 | FX_FLOAT fStepGray = 1.0f; |
| 1481 | |
| 1482 | if (bVertical) |
| 1483 | { |
| 1484 | fStepGray = (nEndGray - nStartGray) / rect.Height(); |
| 1485 | |
| 1486 | for (FX_FLOAT fy=rect.bottom+0.5f; fy<=rect.top-0.5f; fy+=1.0f) |
| 1487 | { |
| 1488 | FX_INT32 nGray = nStartGray + (FX_INT32)(fStepGray * (fy-rect.bottom)); |
| 1489 | CPWL_Utils::DrawStrokeLine(pDevice, pUser2Device, CPDF_Point(rect.left, fy), |
| 1490 | CPDF_Point(rect.right, fy), ArgbEncode(nTransparancy, nGray, nGray, nGray), 1.5f); |
| 1491 | } |
| 1492 | } |
| 1493 | |
| 1494 | if (bHorizontal) |
| 1495 | { |
| 1496 | fStepGray = (nEndGray - nStartGray) / rect.Width(); |
| 1497 | |
| 1498 | for (FX_FLOAT fx=rect.left+0.5f; fx<=rect.right-0.5f; fx+=1.0f) |
| 1499 | { |
| 1500 | FX_INT32 nGray = nStartGray + (FX_INT32)(fStepGray * (fx-rect.left)); |
| 1501 | CPWL_Utils::DrawStrokeLine(pDevice, pUser2Device, CPDF_Point(fx, rect.bottom), |
| 1502 | CPDF_Point(fx, rect.top), ArgbEncode(nTransparancy, nGray, nGray, nGray), 1.5f); |
| 1503 | } |
| 1504 | } |
| 1505 | } |
| 1506 | |
| 1507 | void CPWL_Utils::DrawBorder(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device, |
| 1508 | const CPDF_Rect & rect, FX_FLOAT fWidth, |
| 1509 | const CPWL_Color & color, const CPWL_Color & crLeftTop, const CPWL_Color & crRightBottom, |
| 1510 | FX_INT32 nStyle, const CPWL_Dash & dash, FX_INT32 nTransparancy) |
| 1511 | { |
| 1512 | FX_FLOAT fLeft = rect.left; |
| 1513 | FX_FLOAT fRight = rect.right; |
| 1514 | FX_FLOAT fTop = rect.top; |
| 1515 | FX_FLOAT fBottom = rect.bottom; |
| 1516 | |
| 1517 | if (fWidth > 0.0f) |
| 1518 | { |
| 1519 | FX_FLOAT fHalfWidth = fWidth / 2.0f; |
| 1520 | |
| 1521 | switch (nStyle) |
| 1522 | { |
| 1523 | default: |
| 1524 | case PBS_SOLID: |
| 1525 | { |
| 1526 | CFX_PathData path; |
| 1527 | path.AppendRect(fLeft, fBottom, fRight, fTop); |
| 1528 | path.AppendRect(fLeft + fWidth, fBottom + fWidth, fRight - fWidth, fTop - fWidth); |
| 1529 | pDevice->DrawPath(&path, pUser2Device, NULL, PWLColorToFXColor(color,nTransparancy), 0, FXFILL_ALTERNATE); |
| 1530 | } |
| 1531 | break; |
| 1532 | case PBS_DASH: |
| 1533 | { |
| 1534 | CFX_PathData path; |
| 1535 | |
| 1536 | path.SetPointCount(5); |
| 1537 | path.SetPoint(0, fLeft + fWidth / 2.0f, fBottom + fWidth / 2.0f, FXPT_MOVETO); |
| 1538 | path.SetPoint(1, fLeft + fWidth / 2.0f, fTop - fWidth / 2.0f, FXPT_LINETO); |
| 1539 | path.SetPoint(2, fRight - fWidth / 2.0f, fTop - fWidth / 2.0f, FXPT_LINETO); |
| 1540 | path.SetPoint(3, fRight - fWidth / 2.0f, fBottom + fWidth / 2.0f, FXPT_LINETO); |
| 1541 | path.SetPoint(4, fLeft + fWidth / 2.0f, fBottom + fWidth / 2.0f, FXPT_LINETO); |
| 1542 | |
| 1543 | CFX_GraphStateData gsd; |
| 1544 | gsd.SetDashCount(2); |
| 1545 | gsd.m_DashArray[0] = 3.0f; |
| 1546 | gsd.m_DashArray[1] = 3.0f; |
| 1547 | gsd.m_DashPhase = 0; |
| 1548 | |
| 1549 | gsd.m_LineWidth = fWidth; |
| 1550 | pDevice->DrawPath(&path, pUser2Device, &gsd, 0, PWLColorToFXColor(color,nTransparancy), FXFILL_WINDING); |
| 1551 | } |
| 1552 | break; |
| 1553 | case PBS_BEVELED: |
| 1554 | case PBS_INSET: |
| 1555 | { |
| 1556 | CFX_GraphStateData gsd; |
| 1557 | gsd.m_LineWidth = fHalfWidth; |
| 1558 | |
| 1559 | CFX_PathData pathLT; |
| 1560 | |
| 1561 | pathLT.SetPointCount(7); |
| 1562 | pathLT.SetPoint(0, fLeft + fHalfWidth, fBottom + fHalfWidth, FXPT_MOVETO); |
| 1563 | pathLT.SetPoint(1, fLeft + fHalfWidth, fTop - fHalfWidth, FXPT_LINETO); |
| 1564 | pathLT.SetPoint(2, fRight - fHalfWidth, fTop - fHalfWidth, FXPT_LINETO); |
| 1565 | pathLT.SetPoint(3, fRight - fHalfWidth * 2, fTop - fHalfWidth * 2, FXPT_LINETO); |
| 1566 | pathLT.SetPoint(4, fLeft + fHalfWidth * 2, fTop - fHalfWidth * 2, FXPT_LINETO); |
| 1567 | pathLT.SetPoint(5, fLeft + fHalfWidth * 2, fBottom + fHalfWidth * 2, FXPT_LINETO); |
| 1568 | pathLT.SetPoint(6, fLeft + fHalfWidth, fBottom + fHalfWidth, FXPT_LINETO); |
| 1569 | |
| 1570 | pDevice->DrawPath(&pathLT, pUser2Device, &gsd, PWLColorToFXColor(crLeftTop,nTransparancy), 0, FXFILL_ALTERNATE); |
| 1571 | |
| 1572 | CFX_PathData pathRB; |
| 1573 | |
| 1574 | pathRB.SetPointCount(7); |
| 1575 | pathRB.SetPoint(0, fRight - fHalfWidth, fTop - fHalfWidth, FXPT_MOVETO); |
| 1576 | pathRB.SetPoint(1, fRight - fHalfWidth, fBottom + fHalfWidth, FXPT_LINETO); |
| 1577 | pathRB.SetPoint(2, fLeft + fHalfWidth, fBottom + fHalfWidth, FXPT_LINETO); |
| 1578 | pathRB.SetPoint(3, fLeft + fHalfWidth * 2, fBottom + fHalfWidth * 2, FXPT_LINETO); |
| 1579 | pathRB.SetPoint(4, fRight - fHalfWidth * 2, fBottom + fHalfWidth * 2, FXPT_LINETO); |
| 1580 | pathRB.SetPoint(5, fRight - fHalfWidth * 2, fTop - fHalfWidth * 2, FXPT_LINETO); |
| 1581 | pathRB.SetPoint(6, fRight - fHalfWidth, fTop - fHalfWidth, FXPT_LINETO); |
| 1582 | |
| 1583 | pDevice->DrawPath(&pathRB, pUser2Device, &gsd, PWLColorToFXColor(crRightBottom,nTransparancy), 0, FXFILL_ALTERNATE); |
| 1584 | |
| 1585 | CFX_PathData path; |
| 1586 | |
| 1587 | path.AppendRect(fLeft, fBottom, fRight, fTop); |
| 1588 | path.AppendRect(fLeft + fHalfWidth, fBottom + fHalfWidth, fRight - fHalfWidth, fTop - fHalfWidth); |
| 1589 | |
| 1590 | pDevice->DrawPath(&path, pUser2Device, &gsd, PWLColorToFXColor(color,nTransparancy), 0, FXFILL_ALTERNATE); |
| 1591 | } |
| 1592 | break; |
| 1593 | case PBS_UNDERLINED: |
| 1594 | { |
| 1595 | CFX_PathData path; |
| 1596 | |
| 1597 | path.SetPointCount(2); |
| 1598 | path.SetPoint(0, fLeft, fBottom + fWidth / 2, FXPT_MOVETO); |
| 1599 | path.SetPoint(1, fRight, fBottom + fWidth / 2, FXPT_LINETO); |
| 1600 | |
| 1601 | CFX_GraphStateData gsd; |
| 1602 | gsd.m_LineWidth = fWidth; |
| 1603 | |
| 1604 | pDevice->DrawPath(&path, pUser2Device, &gsd,0, PWLColorToFXColor(color,nTransparancy), FXFILL_ALTERNATE); |
| 1605 | } |
| 1606 | break; |
| 1607 | case PBS_SHADOW: |
| 1608 | { |
| 1609 | CFX_PathData path; |
| 1610 | path.AppendRect(fLeft, fBottom, fRight, fTop); |
| 1611 | path.AppendRect(fLeft + fWidth, fBottom + fWidth, fRight - fWidth, fTop - fWidth); |
| 1612 | pDevice->DrawPath(&path, pUser2Device, NULL, PWLColorToFXColor(color,nTransparancy/2), 0, FXFILL_ALTERNATE); |
| 1613 | } |
| 1614 | break; |
| 1615 | } |
| 1616 | } |
| 1617 | } |
| 1618 | |
| 1619 | static void AddSquigglyPath(CFX_PathData & PathData, FX_FLOAT fStartX, FX_FLOAT fEndX, FX_FLOAT fY, FX_FLOAT fStep) |
| 1620 | { |
| 1621 | PathData.AddPointCount(1); |
| 1622 | PathData.SetPoint(PathData.GetPointCount() - 1, fStartX, fY, FXPT_MOVETO); |
| 1623 | |
| 1624 | FX_FLOAT fx; |
| 1625 | FX_INT32 i; |
| 1626 | |
| 1627 | for (i=1,fx=fStartX+fStep; fx<fEndX; fx+=fStep,i++) |
| 1628 | { |
| 1629 | PathData.AddPointCount(1); |
| 1630 | PathData.SetPoint(PathData.GetPointCount() - 1, fx, fY + (i&1)*fStep, FXPT_LINETO); |
| 1631 | } |
| 1632 | } |
| 1633 | |
| 1634 | static void AddSpellCheckObj(CFX_PathData & PathData, IFX_Edit* pEdit, const CPVT_WordRange& wrWord) |
| 1635 | { |
| 1636 | FX_FLOAT fStartX = 0.0f; |
| 1637 | FX_FLOAT fEndX = 0.0f; |
| 1638 | FX_FLOAT fY = 0.0f; |
| 1639 | FX_FLOAT fStep = 0.0f; |
| 1640 | |
| 1641 | FX_BOOL bBreak = FALSE; |
| 1642 | |
| 1643 | if (IFX_Edit_Iterator* pIterator = pEdit->GetIterator()) |
| 1644 | { |
| 1645 | pIterator->SetAt(wrWord.BeginPos); |
| 1646 | |
| 1647 | do |
| 1648 | { |
| 1649 | CPVT_WordPlace place = pIterator->GetAt(); |
| 1650 | |
| 1651 | CPVT_Line line; |
| 1652 | if (pIterator->GetLine(line)) |
| 1653 | { |
| 1654 | fY = line.ptLine.y; |
| 1655 | fStep = (line.fLineAscent - line.fLineDescent) / 16.0f; |
| 1656 | } |
| 1657 | |
| 1658 | if (place.LineCmp(wrWord.BeginPos) == 0) |
| 1659 | { |
| 1660 | pIterator->SetAt(wrWord.BeginPos); |
| 1661 | CPVT_Word word; |
| 1662 | if (pIterator->GetWord(word)) |
| 1663 | { |
| 1664 | fStartX = word.ptWord.x; |
| 1665 | } |
| 1666 | } |
| 1667 | else |
| 1668 | { |
| 1669 | fStartX = line.ptLine.x; |
| 1670 | } |
| 1671 | |
| 1672 | if (place.LineCmp(wrWord.EndPos) == 0) |
| 1673 | { |
| 1674 | pIterator->SetAt(wrWord.EndPos); |
| 1675 | CPVT_Word word; |
| 1676 | if (pIterator->GetWord(word)) |
| 1677 | { |
| 1678 | fEndX = word.ptWord.x + word.fWidth; |
| 1679 | } |
| 1680 | |
| 1681 | bBreak = TRUE; |
| 1682 | } |
| 1683 | else |
| 1684 | { |
| 1685 | fEndX = line.ptLine.x + line.fLineWidth; |
| 1686 | } |
| 1687 | |
| 1688 | AddSquigglyPath(PathData, fStartX, fEndX, fY, fStep); |
| 1689 | |
| 1690 | if (bBreak) break; |
| 1691 | } |
| 1692 | while (pIterator->NextLine()); |
| 1693 | } |
| 1694 | } |
| 1695 | |
| 1696 | void CPWL_Utils::DrawEditSpellCheck(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device, IFX_Edit* pEdit, |
| 1697 | const CPDF_Rect& rcClip, const CPDF_Point& ptOffset, const CPVT_WordRange* pRange, |
| 1698 | IPWL_SpellCheck * pSpellCheck) |
| 1699 | { |
| 1700 | const FX_COLORREF crSpell = ArgbEncode(255,255,0,0); |
| 1701 | |
| 1702 | //for spellcheck |
| 1703 | FX_BOOL bLatinWord = FALSE; |
| 1704 | CPVT_WordPlace wpWordStart; |
| 1705 | CFX_ByteString sLatinWord; |
| 1706 | |
| 1707 | CFX_PathData pathSpell; |
| 1708 | |
| 1709 | pDevice->SaveState(); |
| 1710 | |
| 1711 | if (!rcClip.IsEmpty()) |
| 1712 | { |
| 1713 | CPDF_Rect rcTemp = rcClip; |
| 1714 | pUser2Device->TransformRect(rcTemp); |
| 1715 | FX_RECT rcDevClip; |
| 1716 | rcDevClip.left = (FX_INT32)rcTemp.left; |
| 1717 | rcDevClip.right = (FX_INT32)rcTemp.right; |
| 1718 | rcDevClip.top = (FX_INT32)rcTemp.top; |
| 1719 | rcDevClip.bottom = (FX_INT32)rcTemp.bottom; |
| 1720 | pDevice->SetClip_Rect(&rcDevClip); |
| 1721 | } |
| 1722 | |
| 1723 | if (IFX_Edit_Iterator* pIterator = pEdit->GetIterator()) |
| 1724 | { |
| 1725 | if (pEdit->GetFontMap()) |
| 1726 | { |
| 1727 | if (pRange) |
| 1728 | pIterator->SetAt(pRange->BeginPos); |
| 1729 | else |
| 1730 | pIterator->SetAt(0); |
| 1731 | |
| 1732 | CPVT_WordPlace oldplace; |
| 1733 | |
| 1734 | while (pIterator->NextWord()) |
| 1735 | { |
| 1736 | CPVT_WordPlace place = pIterator->GetAt(); |
| 1737 | if (pRange && place.WordCmp(pRange->EndPos) > 0) break; |
| 1738 | |
| 1739 | CPVT_Word word; |
| 1740 | if (pIterator->GetWord(word)) |
| 1741 | { |
| 1742 | if (FX_EDIT_ISLATINWORD(word.Word)) |
| 1743 | { |
| 1744 | if (!bLatinWord) |
| 1745 | { |
| 1746 | wpWordStart = place; |
| 1747 | bLatinWord = TRUE; |
| 1748 | } |
| 1749 | |
| 1750 | sLatinWord += (char)word.Word; |
| 1751 | } |
| 1752 | else |
| 1753 | { |
| 1754 | if (bLatinWord) |
| 1755 | { |
| 1756 | if (!sLatinWord.IsEmpty()) |
| 1757 | { |
| 1758 | if (pSpellCheck && !pSpellCheck->CheckWord(sLatinWord)) |
| 1759 | { |
| 1760 | AddSpellCheckObj(pathSpell,pEdit,CPVT_WordRange(wpWordStart,oldplace)); |
| 1761 | pIterator->SetAt(place); |
| 1762 | } |
| 1763 | } |
| 1764 | bLatinWord = FALSE; |
| 1765 | } |
| 1766 | |
| 1767 | sLatinWord.Empty(); |
| 1768 | } |
| 1769 | |
| 1770 | oldplace = place; |
| 1771 | } |
| 1772 | else |
| 1773 | { |
| 1774 | if (bLatinWord) |
| 1775 | { |
| 1776 | if (!sLatinWord.IsEmpty()) |
| 1777 | { |
| 1778 | if (pSpellCheck && !pSpellCheck->CheckWord(sLatinWord)) |
| 1779 | { |
| 1780 | AddSpellCheckObj(pathSpell,pEdit,CPVT_WordRange(wpWordStart,oldplace)); |
| 1781 | pIterator->SetAt(place); |
| 1782 | } |
| 1783 | } |
| 1784 | bLatinWord = FALSE; |
| 1785 | } |
| 1786 | |
| 1787 | sLatinWord.Empty(); |
| 1788 | } |
| 1789 | } |
| 1790 | |
| 1791 | if (!sLatinWord.IsEmpty()) |
| 1792 | { |
| 1793 | if (pSpellCheck && !pSpellCheck->CheckWord(sLatinWord)) |
| 1794 | { |
| 1795 | AddSpellCheckObj(pathSpell,pEdit,CPVT_WordRange(wpWordStart,oldplace)); |
| 1796 | } |
| 1797 | } |
| 1798 | } |
| 1799 | } |
| 1800 | |
| 1801 | CFX_GraphStateData gsd; |
| 1802 | gsd.m_LineWidth = 0; |
| 1803 | if (pathSpell.GetPointCount() > 0) |
| 1804 | pDevice->DrawPath(&pathSpell, pUser2Device, &gsd, 0, crSpell, FXFILL_ALTERNATE); |
| 1805 | |
| 1806 | pDevice->RestoreState(); |
| 1807 | } |
| 1808 | |
| 1809 | FX_BOOL CPWL_Utils::IsBlackOrWhite(const CPWL_Color& color) |
| 1810 | { |
| 1811 | switch (color.nColorType) |
| 1812 | { |
| 1813 | case COLORTYPE_TRANSPARENT: |
| 1814 | return FALSE; |
| 1815 | case COLORTYPE_GRAY: |
| 1816 | return color.fColor1 < 0.5f; |
| 1817 | case COLORTYPE_RGB: |
| 1818 | return color.fColor1 + color.fColor2 + color.fColor3 < 1.5f; |
| 1819 | case COLORTYPE_CMYK: |
| 1820 | return color.fColor1 + color.fColor2 + color.fColor3 + color.fColor4 > 2.0f; |
| 1821 | } |
| 1822 | |
| 1823 | return TRUE; |
| 1824 | } |
| 1825 | |
| 1826 | CPWL_Color CPWL_Utils::GetReverseColor(const CPWL_Color& color) |
| 1827 | { |
| 1828 | CPWL_Color crRet = color; |
| 1829 | |
| 1830 | switch (color.nColorType) |
| 1831 | { |
| 1832 | case COLORTYPE_GRAY: |
| 1833 | crRet.fColor1 = 1.0f - crRet.fColor1; |
| 1834 | break; |
| 1835 | case COLORTYPE_RGB: |
| 1836 | crRet.fColor1 = 1.0f - crRet.fColor1; |
| 1837 | crRet.fColor2 = 1.0f - crRet.fColor2; |
| 1838 | crRet.fColor3 = 1.0f - crRet.fColor3; |
| 1839 | break; |
| 1840 | case COLORTYPE_CMYK: |
| 1841 | crRet.fColor1 = 1.0f - crRet.fColor1; |
| 1842 | crRet.fColor2 = 1.0f - crRet.fColor2; |
| 1843 | crRet.fColor3 = 1.0f - crRet.fColor3; |
| 1844 | crRet.fColor4 = 1.0f - crRet.fColor4; |
| 1845 | break; |
| 1846 | } |
| 1847 | |
| 1848 | return crRet; |
| 1849 | } |
| 1850 | |
| 1851 | CFX_ByteString CPWL_Utils::GetIconAppStream(FX_INT32 nType, const CPDF_Rect& rect, const CPWL_Color& crFill, |
| 1852 | const CPWL_Color& crStroke) |
| 1853 | { |
| 1854 | CFX_ByteString sAppStream = CPWL_Utils::GetColorAppStream(crStroke, FALSE); |
| 1855 | sAppStream += CPWL_Utils::GetColorAppStream(crFill, TRUE); |
| 1856 | |
| 1857 | CFX_ByteString sPath; |
| 1858 | CFX_PathData path; |
| 1859 | |
| 1860 | switch (nType) |
| 1861 | { |
| 1862 | case PWL_ICONTYPE_CHECKMARK: |
| 1863 | GetGraphics_Checkmark(sPath, path, rect, PWLPT_STREAM); |
| 1864 | break; |
| 1865 | case PWL_ICONTYPE_CIRCLE: |
| 1866 | GetGraphics_Circle(sPath, path, rect, PWLPT_STREAM); |
| 1867 | break; |
| 1868 | case PWL_ICONTYPE_COMMENT: |
| 1869 | GetGraphics_Comment(sPath, path, rect, PWLPT_STREAM); |
| 1870 | break; |
| 1871 | case PWL_ICONTYPE_CROSS: |
| 1872 | GetGraphics_Cross(sPath, path, rect, PWLPT_STREAM); |
| 1873 | break; |
| 1874 | case PWL_ICONTYPE_HELP: |
| 1875 | GetGraphics_Help(sPath, path, rect, PWLPT_STREAM); |
| 1876 | break; |
| 1877 | case PWL_ICONTYPE_INSERTTEXT: |
| 1878 | GetGraphics_InsertText(sPath, path, rect, PWLPT_STREAM); |
| 1879 | break; |
| 1880 | case PWL_ICONTYPE_KEY: |
| 1881 | GetGraphics_Key(sPath, path, rect, PWLPT_STREAM); |
| 1882 | break; |
| 1883 | case PWL_ICONTYPE_NEWPARAGRAPH: |
| 1884 | GetGraphics_NewParagraph(sPath, path, rect, PWLPT_STREAM); |
| 1885 | break; |
| 1886 | case PWL_ICONTYPE_TEXTNOTE: |
| 1887 | GetGraphics_TextNote(sPath, path, rect, PWLPT_STREAM); |
| 1888 | break; |
| 1889 | case PWL_ICONTYPE_PARAGRAPH: |
| 1890 | GetGraphics_Paragraph(sPath, path, rect, PWLPT_STREAM); |
| 1891 | break; |
| 1892 | case PWL_ICONTYPE_RIGHTARROW: |
| 1893 | GetGraphics_RightArrow(sPath, path, rect, PWLPT_STREAM); |
| 1894 | break; |
| 1895 | case PWL_ICONTYPE_RIGHTPOINTER: |
| 1896 | GetGraphics_RightPointer(sPath, path, rect, PWLPT_STREAM); |
| 1897 | break; |
| 1898 | case PWL_ICONTYPE_STAR: |
| 1899 | GetGraphics_Star(sPath, path, rect, PWLPT_STREAM); |
| 1900 | break; |
| 1901 | case PWL_ICONTYPE_UPARROW: |
| 1902 | GetGraphics_UpArrow(sPath, path, rect, PWLPT_STREAM); |
| 1903 | break; |
| 1904 | case PWL_ICONTYPE_UPLEFTARROW: |
| 1905 | GetGraphics_UpLeftArrow(sPath, path, rect, PWLPT_STREAM); |
| 1906 | break; |
| 1907 | case PWL_ICONTYPE_GRAPH: |
| 1908 | GetGraphics_Graph(sPath, path, rect, PWLPT_STREAM); |
| 1909 | break; |
| 1910 | case PWL_ICONTYPE_PAPERCLIP: |
| 1911 | GetGraphics_Paperclip(sPath, path, rect, PWLPT_STREAM); |
| 1912 | break; |
| 1913 | case PWL_ICONTYPE_ATTACHMENT: |
| 1914 | GetGraphics_Attachment(sPath, path, rect, PWLPT_STREAM); |
| 1915 | break; |
| 1916 | case PWL_ICONTYPE_TAG: |
| 1917 | GetGraphics_Tag(sPath, path, rect, PWLPT_STREAM); |
| 1918 | break; |
| 1919 | case PWL_ICONTYPE_FOXIT: |
| 1920 | GetGraphics_Foxit(sPath, path, rect, PWLPT_STREAM); |
| 1921 | break; |
| 1922 | } |
| 1923 | |
| 1924 | sAppStream += sPath; |
| 1925 | if (crStroke.nColorType != COLORTYPE_TRANSPARENT) |
| 1926 | sAppStream += "B*\n"; |
| 1927 | else |
| 1928 | sAppStream += "f*\n"; |
| 1929 | |
| 1930 | return sAppStream; |
| 1931 | } |
| 1932 | |
| 1933 | void CPWL_Utils::DrawIconAppStream(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device, |
| 1934 | FX_INT32 nType, const CPDF_Rect & rect, const CPWL_Color& crFill, const CPWL_Color& crStroke, const FX_INT32 nTransparancy) |
| 1935 | { |
| 1936 | CFX_GraphStateData gsd; |
| 1937 | gsd.m_LineWidth = 1.0f; |
| 1938 | |
| 1939 | CFX_ByteString sPath; |
| 1940 | CFX_PathData path; |
| 1941 | |
| 1942 | switch (nType) |
| 1943 | { |
| 1944 | case PWL_ICONTYPE_CHECKMARK: |
| 1945 | GetGraphics_Checkmark(sPath, path, rect, PWLPT_PATHDATA); |
| 1946 | break; |
| 1947 | case PWL_ICONTYPE_CIRCLE: |
| 1948 | GetGraphics_Circle(sPath, path, rect, PWLPT_PATHDATA); |
| 1949 | break; |
| 1950 | case PWL_ICONTYPE_COMMENT: |
| 1951 | GetGraphics_Comment(sPath, path, rect, PWLPT_PATHDATA); |
| 1952 | break; |
| 1953 | case PWL_ICONTYPE_CROSS: |
| 1954 | GetGraphics_Cross(sPath, path, rect, PWLPT_PATHDATA); |
| 1955 | break; |
| 1956 | case PWL_ICONTYPE_HELP: |
| 1957 | GetGraphics_Help(sPath, path, rect, PWLPT_PATHDATA); |
| 1958 | break; |
| 1959 | case PWL_ICONTYPE_INSERTTEXT: |
| 1960 | GetGraphics_InsertText(sPath, path, rect, PWLPT_PATHDATA); |
| 1961 | break; |
| 1962 | case PWL_ICONTYPE_KEY: |
| 1963 | GetGraphics_Key(sPath, path, rect, PWLPT_PATHDATA); |
| 1964 | break; |
| 1965 | case PWL_ICONTYPE_NEWPARAGRAPH: |
| 1966 | GetGraphics_NewParagraph(sPath, path, rect, PWLPT_PATHDATA); |
| 1967 | break; |
| 1968 | case PWL_ICONTYPE_TEXTNOTE: |
| 1969 | GetGraphics_TextNote(sPath, path, rect, PWLPT_PATHDATA); |
| 1970 | break; |
| 1971 | case PWL_ICONTYPE_PARAGRAPH: |
| 1972 | GetGraphics_Paragraph(sPath, path, rect, PWLPT_PATHDATA); |
| 1973 | break; |
| 1974 | case PWL_ICONTYPE_RIGHTARROW: |
| 1975 | GetGraphics_RightArrow(sPath, path, rect, PWLPT_PATHDATA); |
| 1976 | break; |
| 1977 | case PWL_ICONTYPE_RIGHTPOINTER: |
| 1978 | GetGraphics_RightPointer(sPath, path, rect, PWLPT_PATHDATA); |
| 1979 | break; |
| 1980 | case PWL_ICONTYPE_STAR: |
| 1981 | GetGraphics_Star(sPath, path, rect, PWLPT_PATHDATA); |
| 1982 | break; |
| 1983 | case PWL_ICONTYPE_UPARROW: |
| 1984 | GetGraphics_UpArrow(sPath, path, rect, PWLPT_PATHDATA); |
| 1985 | break; |
| 1986 | case PWL_ICONTYPE_UPLEFTARROW: |
| 1987 | GetGraphics_UpLeftArrow(sPath, path, rect, PWLPT_PATHDATA); |
| 1988 | break; |
| 1989 | case PWL_ICONTYPE_GRAPH: |
| 1990 | GetGraphics_Graph(sPath, path, rect, PWLPT_PATHDATA); |
| 1991 | break; |
| 1992 | case PWL_ICONTYPE_PAPERCLIP: |
| 1993 | GetGraphics_Paperclip(sPath, path, rect, PWLPT_PATHDATA); |
| 1994 | break; |
| 1995 | case PWL_ICONTYPE_ATTACHMENT: |
| 1996 | GetGraphics_Attachment(sPath, path, rect, PWLPT_PATHDATA); |
| 1997 | break; |
| 1998 | case PWL_ICONTYPE_TAG: |
| 1999 | GetGraphics_Tag(sPath, path, rect, PWLPT_PATHDATA); |
| 2000 | break; |
| 2001 | case PWL_ICONTYPE_FOXIT: |
| 2002 | GetGraphics_Foxit(sPath, path, rect, PWLPT_PATHDATA); |
| 2003 | break; |
| 2004 | default: |
| 2005 | return; |
| 2006 | } |
| 2007 | |
| 2008 | pDevice->DrawPath(&path, pUser2Device, &gsd, |
| 2009 | PWLColorToFXColor(crFill,nTransparancy), PWLColorToFXColor(crStroke,nTransparancy), FXFILL_ALTERNATE); |
| 2010 | } |
| 2011 | |
| 2012 | void CPWL_Utils::GetGraphics_Checkmark(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_Rect& crBBox, const PWL_PATH_TYPE type) |
| 2013 | { |
| 2014 | FX_FLOAT fWidth = crBBox.right - crBBox.left; |
| 2015 | FX_FLOAT fHeight = crBBox.top - crBBox.bottom; |
| 2016 | |
| 2017 | CPWL_PathData PathArray[] = |
| 2018 | { |
| 2019 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 15.0f, crBBox.bottom + fHeight * 2 / 5.0f),PWLPT_MOVETO), |
| 2020 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 15.0f + PWL_BEZIER*(fWidth / 7.0f - fWidth / 15.0f), |
| 2021 | crBBox.bottom + fHeight * 2 / 5.0f + PWL_BEZIER*(fHeight * 2 / 7.0f - fHeight * 2 / 5.0f)), PWLPT_BEZIERTO), |
| 2022 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 4.5f + PWL_BEZIER*(fWidth / 5.0f - fWidth / 4.5f), |
| 2023 | crBBox.bottom + fHeight / 16.0f + PWL_BEZIER*(fHeight / 5.0f - fHeight / 16.0f)), PWLPT_BEZIERTO), |
| 2024 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 4.5f, crBBox.bottom + fHeight / 16.0f), PWLPT_BEZIERTO), |
| 2025 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 4.5f + PWL_BEZIER*(fWidth / 4.4f - fWidth / 4.5f), |
| 2026 | crBBox.bottom + fHeight / 16.0f - PWL_BEZIER*fHeight / 16.0f), PWLPT_BEZIERTO), |
| 2027 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 3.0f + PWL_BEZIER*(fWidth / 4.0f - fWidth / 3.0f), |
| 2028 | crBBox.bottom), PWLPT_BEZIERTO), |
| 2029 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 3.0f, crBBox.bottom), PWLPT_BEZIERTO), |
| 2030 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 3.0f + PWL_BEZIER*fWidth*(1/7.0f + 2/15.0f), |
| 2031 | crBBox.bottom + PWL_BEZIER*fHeight * 4 / 5.0f), PWLPT_BEZIERTO), |
| 2032 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 14 / 15.0f + PWL_BEZIER*fWidth*(1/7.0f - 7/15.0f), |
| 2033 | crBBox.bottom + fHeight * 15/16.0f + PWL_BEZIER*(fHeight * 4/5.0f - fHeight * 15/16.0f)), PWLPT_BEZIERTO), |
| 2034 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 14 / 15.0f,crBBox.bottom + fHeight * 15 / 16.0f), PWLPT_BEZIERTO), |
| 2035 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 14 / 15.0f + PWL_BEZIER*(fWidth * 7 / 15.0f - fWidth * 14 / 15.0f), |
| 2036 | crBBox.bottom + fHeight * 15 / 16.0f + PWL_BEZIER*(fHeight * 8 / 7.0f - fHeight * 15 / 16.0f)), PWLPT_BEZIERTO), |
| 2037 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 3.6f + PWL_BEZIER*(fWidth / 3.4f - fWidth / 3.6f), |
| 2038 | crBBox.bottom + fHeight / 3.5f + PWL_BEZIER*(fHeight / 3.5f - fHeight / 3.5f)), PWLPT_BEZIERTO), |
| 2039 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 3.6f,crBBox.bottom + fHeight / 3.5f), PWLPT_BEZIERTO), |
| 2040 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 3.6f, |
| 2041 | crBBox.bottom + fHeight / 3.5f + PWL_BEZIER*(fHeight / 4.0f - fHeight / 3.5f)), PWLPT_BEZIERTO), |
| 2042 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 15.0f + PWL_BEZIER*(fWidth / 3.5f - fWidth / 15.0f), |
| 2043 | crBBox.bottom + fHeight * 2 / 5.0f + PWL_BEZIER*(fHeight * 3.5f / 5.0f - fHeight * 2 / 5.0f)), PWLPT_BEZIERTO), |
| 2044 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 15.0f,crBBox.bottom + fHeight * 2 / 5.0f), PWLPT_BEZIERTO) |
| 2045 | }; |
| 2046 | |
| 2047 | if(type == PWLPT_STREAM) |
| 2048 | sPathData = GetAppStreamFromArray(PathArray, 16); |
| 2049 | else |
| 2050 | GetPathDataFromArray(path, PathArray, 16); |
| 2051 | } |
| 2052 | |
| 2053 | void CPWL_Utils::GetGraphics_Circle(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_Rect& crBBox, const PWL_PATH_TYPE type) |
| 2054 | { |
| 2055 | FX_FLOAT fWidth = crBBox.right - crBBox.left; |
| 2056 | FX_FLOAT fHeight = crBBox.top - crBBox.bottom; |
| 2057 | |
| 2058 | CPWL_PathData PathArray[] = |
| 2059 | { |
| 2060 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth/15.0f,crBBox.bottom + fHeight/2.0f), PWLPT_MOVETO), |
| 2061 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth/15.0f, |
| 2062 | crBBox.bottom + fHeight/2.0f + PWL_BEZIER*(fHeight*14/15.0f - fHeight/2.0f)), PWLPT_BEZIERTO), |
| 2063 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth/2.0f - PWL_BEZIER*(fWidth/2.0f - fWidth/15.0f), crBBox.top - fHeight/15.0f), PWLPT_BEZIERTO), |
| 2064 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth/2.0f,crBBox.top - fHeight/15.0f), PWLPT_BEZIERTO), |
| 2065 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth/2.0f + PWL_BEZIER*(fWidth*14/15.0f - fWidth/2.0f), crBBox.top - fHeight/15.0f), PWLPT_BEZIERTO), |
| 2066 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth/15.0f, crBBox.bottom + fHeight/2.0f + PWL_BEZIER*(fHeight*14/15.0f - fHeight/2.0f)), PWLPT_BEZIERTO), |
| 2067 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth/15.0f, crBBox.bottom + fHeight/2.0f), PWLPT_BEZIERTO), |
| 2068 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth/15.0f, crBBox.bottom + fHeight/2.0f - PWL_BEZIER*(fHeight/2.0f - fHeight/15.0f)), PWLPT_BEZIERTO), |
| 2069 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth/2.0f + PWL_BEZIER*(fWidth*14/15.0f - fWidth/2.0f), crBBox.bottom + fHeight/15.0f), PWLPT_BEZIERTO), |
| 2070 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth/2.0f, crBBox.bottom + fHeight/15.0f), PWLPT_BEZIERTO), |
| 2071 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth/2.0f - PWL_BEZIER*(fWidth/2.0f - fWidth/15.0f), crBBox.bottom + fHeight/15.0f), PWLPT_BEZIERTO), |
| 2072 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth/15.0f, crBBox.bottom + fHeight/2.0f - PWL_BEZIER*(fHeight/2.0f - fHeight/15.0f)), PWLPT_BEZIERTO), |
| 2073 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth/15.0f,crBBox.bottom + fHeight/2.0f), PWLPT_BEZIERTO), |
| 2074 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*3/15.0f, crBBox.bottom + fHeight/2.0f), PWLPT_MOVETO), |
| 2075 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*3/15.0f, crBBox.bottom + fHeight/2.0f + PWL_BEZIER*(fHeight*4/5.0f - fHeight/2.0f)), PWLPT_BEZIERTO), |
| 2076 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth/2.0f - PWL_BEZIER*(fWidth/2.0f - fWidth*3/15.0f), crBBox.top - fHeight*3/15.0f), PWLPT_BEZIERTO), |
| 2077 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth/2.0f, crBBox.top - fHeight*3/15.0f), PWLPT_BEZIERTO), |
| 2078 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth/2.0f + PWL_BEZIER*(fWidth*4/5.0f - fWidth/2.0f), crBBox.top - fHeight*3/15.0f), PWLPT_BEZIERTO), |
| 2079 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth*3/15.0f, crBBox.bottom + fHeight/2.0f + PWL_BEZIER*(fHeight*4/5.0f - fHeight/2.0f)), PWLPT_BEZIERTO), |
| 2080 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth*3/15.0f, crBBox.bottom + fHeight/2.0f), PWLPT_BEZIERTO), |
| 2081 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth*3/15.0f, crBBox.bottom + fHeight/2.0f - PWL_BEZIER*(fHeight*4/5.0f - fHeight/2.0f)), PWLPT_BEZIERTO), |
| 2082 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth/2.0f + PWL_BEZIER*(fWidth*4/5.0f - fWidth/2.0f), crBBox.bottom + fHeight*3/15.0f), PWLPT_BEZIERTO), |
| 2083 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth/2.0f, crBBox.bottom + fHeight*3/15.0f), PWLPT_BEZIERTO), |
| 2084 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth/2.0f - PWL_BEZIER*(fWidth*4/5.0f - fWidth/2.0f), crBBox.bottom + fHeight*3/15.0f), PWLPT_BEZIERTO), |
| 2085 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*3/15.0f, crBBox.bottom + fHeight/2.0f - PWL_BEZIER*(fHeight*4/5.0f - fHeight/2.0f)), PWLPT_BEZIERTO), |
| 2086 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*3/15.0f, crBBox.bottom + fHeight/2.0f), PWLPT_BEZIERTO) |
| 2087 | }; |
| 2088 | |
| 2089 | if(type == PWLPT_STREAM) |
| 2090 | sPathData = GetAppStreamFromArray(PathArray, 26); |
| 2091 | else |
| 2092 | GetPathDataFromArray(path, PathArray, 26); |
| 2093 | } |
| 2094 | |
| 2095 | void CPWL_Utils::GetGraphics_Comment(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_Rect& crBBox, const PWL_PATH_TYPE type) |
| 2096 | { |
| 2097 | FX_FLOAT fWidth = crBBox.right - crBBox.left; |
| 2098 | FX_FLOAT fHeight = crBBox.top - crBBox.bottom; |
| 2099 | |
| 2100 | CPWL_PathData PathArray[] = |
| 2101 | { |
| 2102 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth/15.0f, crBBox.top - fHeight/6.0f), PWLPT_MOVETO), |
| 2103 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth/15.0f, crBBox.top - fHeight/6.0f + PWL_BEZIER*(fHeight/6.0f - fHeight/10.0f)), PWLPT_BEZIERTO), |
| 2104 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*2/15.0f - PWL_BEZIER*fWidth/15.0f, crBBox.top - fHeight/10.0f), PWLPT_BEZIERTO), |
| 2105 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*2/15.0f, crBBox.top - fHeight/10.0f), PWLPT_BEZIERTO), |
| 2106 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth*2/15.0f, crBBox.top - fHeight/10.0f), PWLPT_LINETO), |
| 2107 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth*2/15.0f + PWL_BEZIER*fWidth/15.0f, crBBox.top - fHeight/10.0f), PWLPT_BEZIERTO), |
| 2108 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth/15.0f, crBBox.top - fHeight/6 + PWL_BEZIER*(fHeight/6.0f - fHeight/10.0f)), PWLPT_BEZIERTO), |
| 2109 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth/15.0f, crBBox.top - fHeight/6.0f), PWLPT_BEZIERTO), |
| 2110 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth/15.0f, crBBox.bottom + fHeight/3.0f), PWLPT_LINETO), |
| 2111 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth/15.0f, crBBox.bottom + fHeight*4/15.0f + PWL_BEZIER*fHeight/15.0f), PWLPT_BEZIERTO), |
| 2112 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth*2/15.0f + PWL_BEZIER*fWidth/15.0f, crBBox.bottom + fHeight*4/15.0f), PWLPT_BEZIERTO), |
| 2113 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth*2/15.0f, crBBox.bottom + fHeight*4/15.0f), PWLPT_BEZIERTO), |
| 2114 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*5/15.0f, crBBox.bottom + fHeight*4/15.0f), PWLPT_LINETO), |
| 2115 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*5/15.0f, crBBox.bottom + fHeight*2/15 + PWL_BEZIER*fHeight*2/15.0f), PWLPT_BEZIERTO), |
| 2116 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*5/15.0f - PWL_BEZIER*fWidth*2/15.0f, crBBox.bottom + fHeight*2/15.0f), PWLPT_BEZIERTO), |
| 2117 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*6/30.0f, crBBox.bottom + fHeight*2/15.0f), PWLPT_BEZIERTO), |
| 2118 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*7/30.0f + PWL_BEZIER*fWidth/30.0f, crBBox.bottom + fHeight*2/15.0f), PWLPT_BEZIERTO), |
| 2119 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*7/30.0f, crBBox.bottom + fHeight*2/15.0f + PWL_BEZIER*fHeight*2/15.0f), PWLPT_BEZIERTO), |
| 2120 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*7/30.0f, crBBox.bottom + fHeight*4/15.0f), PWLPT_BEZIERTO), |
| 2121 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*2/15.0f, crBBox.bottom + fHeight*4/15.0f), PWLPT_LINETO), |
| 2122 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*2/15.0f - PWL_BEZIER*fWidth/15.0f, crBBox.bottom + fHeight*4/15.0f), PWLPT_BEZIERTO), |
| 2123 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth/15.0f, crBBox.bottom + fHeight/3.0f - PWL_BEZIER*fHeight/15.0f), PWLPT_BEZIERTO), |
| 2124 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth/15.0f, crBBox.bottom + fHeight/3.0f), PWLPT_BEZIERTO), |
| 2125 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth/15.0f, crBBox.top - fHeight/6.0f), PWLPT_LINETO), |
| 2126 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*2/15.0f, crBBox.top - fHeight*8/30.0f), PWLPT_MOVETO), |
| 2127 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth*2/15.0f, crBBox.top - fHeight*8/30.0f), PWLPT_LINETO), |
| 2128 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*2/15, crBBox.top - fHeight*25/60.0f), PWLPT_MOVETO), |
| 2129 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth*2/15.0f, crBBox.top - fHeight*25/60.0f), PWLPT_LINETO), |
| 2130 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*2/15.0f, crBBox.top - fHeight*17/30.0f), PWLPT_MOVETO), |
| 2131 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth*4/15.0f, crBBox.top - fHeight*17/30.0f), PWLPT_LINETO) |
| 2132 | }; |
| 2133 | |
| 2134 | if(type == PWLPT_STREAM) |
| 2135 | sPathData = GetAppStreamFromArray(PathArray, 30); |
| 2136 | else |
| 2137 | GetPathDataFromArray(path, PathArray, 30); |
| 2138 | } |
| 2139 | |
| 2140 | void CPWL_Utils::GetGraphics_Cross(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_Rect& crBBox, const PWL_PATH_TYPE type) |
| 2141 | { |
| 2142 | FX_FLOAT fWidth = crBBox.right - crBBox.left; |
| 2143 | FX_FLOAT fHeight = crBBox.top - crBBox.bottom; |
| 2144 | //FX_FLOAT fcatercorner = (FX_FLOAT)sqrt(fWidth*fWidth + fHeight*fHeight); |
| 2145 | CPWL_Point center_point(crBBox.left + fWidth/2, crBBox.bottom + fHeight/2); |
| 2146 | |
| 2147 | CPWL_PathData PathArray[] = |
| 2148 | { |
| 2149 | CPWL_PathData(CPWL_Point(center_point.x, center_point.y + fHeight/10.0f), PWLPT_MOVETO), |
| 2150 | CPWL_PathData(CPWL_Point(center_point.x + fWidth*0.3f, center_point.y + fHeight/10.0f + fWidth*0.3f), PWLPT_LINETO), |
| 2151 | CPWL_PathData(CPWL_Point(center_point.x + fWidth/10.0f + fWidth*0.3f, center_point.y + fHeight*0.3f), PWLPT_LINETO), |
| 2152 | CPWL_PathData(CPWL_Point(center_point.x + fWidth/10.0f, center_point.y), PWLPT_LINETO), |
| 2153 | CPWL_PathData(CPWL_Point(center_point.x + fWidth/10.0f + fWidth*0.3f, center_point.y - fHeight*0.3f), PWLPT_LINETO), |
| 2154 | CPWL_PathData(CPWL_Point(center_point.x + fWidth*0.3f, center_point.y - fHeight/10.0f - fHeight*0.3f), PWLPT_LINETO), |
| 2155 | CPWL_PathData(CPWL_Point(center_point.x, center_point.y - fHeight/10.0f), PWLPT_LINETO), |
| 2156 | CPWL_PathData(CPWL_Point(center_point.x - fWidth*0.3f, center_point.y - fHeight/10 - fHeight*0.3f), PWLPT_LINETO), |
| 2157 | CPWL_PathData(CPWL_Point(center_point.x - fWidth/10.0f - fWidth*0.3f, center_point.y - fHeight*0.3f), PWLPT_LINETO), |
| 2158 | CPWL_PathData(CPWL_Point(center_point.x - fWidth/10, center_point.y), PWLPT_LINETO), |
| 2159 | CPWL_PathData(CPWL_Point(center_point.x - fWidth/10 - fWidth*0.3f, center_point.y + fHeight*0.3f), PWLPT_LINETO), |
| 2160 | CPWL_PathData(CPWL_Point(center_point.x - fWidth*0.3f, center_point.y + fHeight/10.0f + fHeight*0.3f), PWLPT_LINETO), |
| 2161 | CPWL_PathData(CPWL_Point(center_point.x, center_point.y + fHeight/10.0f), PWLPT_LINETO) |
| 2162 | }; |
| 2163 | |
| 2164 | if(type == PWLPT_STREAM) |
| 2165 | sPathData = GetAppStreamFromArray(PathArray, 13); |
| 2166 | else |
| 2167 | GetPathDataFromArray(path, PathArray, 13); |
| 2168 | } |
| 2169 | |
| 2170 | void CPWL_Utils::GetGraphics_Help(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_Rect& crBBox, const PWL_PATH_TYPE type) |
| 2171 | { |
| 2172 | FX_FLOAT fWidth = crBBox.right - crBBox.left; |
| 2173 | FX_FLOAT fHeight = crBBox.top - crBBox.bottom; |
| 2174 | |
| 2175 | CPWL_PathData PathArray[] = |
| 2176 | { |
| 2177 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth/60.0f, crBBox.bottom + fHeight/2.0f), PWLPT_MOVETO), |
| 2178 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth/60.0f, crBBox.bottom + fHeight/2.0f + PWL_BEZIER*(fHeight/60.0f - fHeight/2.0f)), PWLPT_BEZIERTO), |
| 2179 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth/2.0f - PWL_BEZIER*(fWidth/2.0f - fWidth/60.0f), crBBox.bottom + fHeight/60.0f), PWLPT_BEZIERTO), |
| 2180 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth/2.0f, crBBox.bottom + fHeight/60.0f), PWLPT_BEZIERTO), |
| 2181 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth/2.0f + PWL_BEZIER*fWidth*29/60.0f, crBBox.bottom + fHeight/60.0f), PWLPT_BEZIERTO), |
| 2182 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth/60.0f, crBBox.bottom + fHeight/2.0f + PWL_BEZIER*(fHeight/60.0f - fHeight/2.0f)), PWLPT_BEZIERTO), |
| 2183 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth/60.0f, crBBox.bottom + fHeight/2.0f), PWLPT_BEZIERTO), |
| 2184 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth/60.0f, crBBox.bottom + fHeight/2.0f + PWL_BEZIER*fHeight*29/60.0f), PWLPT_BEZIERTO), |
| 2185 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth/2.0f + PWL_BEZIER*fWidth*29/60.0f, crBBox.top - fHeight/60.0f), PWLPT_BEZIERTO), |
| 2186 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth/2.0f, crBBox.top - fHeight/60.0f), PWLPT_BEZIERTO), |
| 2187 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth/2.0f - PWL_BEZIER*fWidth*29/60.0f, crBBox.top - fHeight/60.0f), PWLPT_BEZIERTO), |
| 2188 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth/60.0f, crBBox.bottom + fHeight/2.0f + PWL_BEZIER*fHeight*29/60.0f), PWLPT_BEZIERTO), |
| 2189 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth/60.0f, crBBox.bottom + fHeight/2.0f), PWLPT_BEZIERTO), |
| 2190 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.27f, crBBox.top - fHeight*0.36f), PWLPT_MOVETO), |
| 2191 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.27f, crBBox.top - fHeight*0.36f + PWL_BEZIER*fHeight*0.23f), PWLPT_BEZIERTO), |
| 2192 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.5f - PWL_BEZIER*fWidth*0.23f, crBBox.bottom + fHeight*0.87f), PWLPT_BEZIERTO), |
| 2193 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.5f, crBBox.bottom + fHeight*0.87f), PWLPT_BEZIERTO), |
| 2194 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.5f + PWL_BEZIER*fWidth*0.23f, crBBox.bottom + fHeight*0.87f), PWLPT_BEZIERTO), |
| 2195 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth*0.27f, crBBox.top - fHeight*0.36f + PWL_BEZIER*fHeight*0.23f), PWLPT_BEZIERTO), |
| 2196 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth*0.27f, crBBox.top - fHeight*0.36f), PWLPT_BEZIERTO), |
| 2197 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth*0.27f - fWidth*0.08f*0.2f, crBBox.top - fHeight*0.36f - fHeight*0.15f*0.7f), PWLPT_BEZIERTO), |
| 2198 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth*0.35f + fWidth*0.08f*0.2f, crBBox.top - fHeight*0.51f + fHeight*0.15f*0.2f), PWLPT_BEZIERTO), |
| 2199 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth*0.35f, crBBox.top - fHeight*0.51f), PWLPT_BEZIERTO), |
| 2200 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth*0.35f - fWidth*0.1f*0.5f, crBBox.top - fHeight*0.51f - fHeight*0.15f*0.3f), PWLPT_BEZIERTO), |
| 2201 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth*0.45f - fWidth*0.1f*0.5f, crBBox.top - fHeight*0.68f + fHeight*0.15f*0.5f), PWLPT_BEZIERTO), |
| 2202 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth*0.45f, crBBox.top - fHeight*0.68f), PWLPT_BEZIERTO), |
| 2203 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth*0.45f, crBBox.bottom + fHeight*0.30f), PWLPT_LINETO), |
| 2204 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth*0.45f, crBBox.bottom + fHeight*0.30f - fWidth*0.1f*0.7f), PWLPT_BEZIERTO), |
| 2205 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth*0.55f, crBBox.bottom + fHeight*0.30f - fWidth*0.1f*0.7f), PWLPT_BEZIERTO), |
| 2206 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth*0.55f, crBBox.bottom + fHeight*0.30f), PWLPT_BEZIERTO), |
| 2207 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth*0.55f, crBBox.top - fHeight*0.66f), PWLPT_LINETO), |
| 2208 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth*0.55f - fWidth*0.1f*0.05f, crBBox.top - fHeight*0.66f + fHeight*0.18f*0.5f), PWLPT_BEZIERTO), |
| 2209 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth*0.45f - fWidth*0.1f*0.05f, crBBox.top - fHeight*0.48f - fHeight*0.18f*0.3f), PWLPT_BEZIERTO), |
| 2210 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth*0.45f, crBBox.top - fHeight*0.48f), PWLPT_BEZIERTO), |
| 2211 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth*0.45f + fWidth*0.08f*0.2f, crBBox.top - fHeight*0.48f + fHeight*0.18f*0.2f), PWLPT_BEZIERTO), |
| 2212 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth*0.37f - fWidth*0.08f*0.2f, crBBox.top - fHeight*0.36f - fHeight*0.18f*0.7f), PWLPT_BEZIERTO), |
| 2213 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth*0.37f, crBBox.top - fHeight*0.36f), PWLPT_BEZIERTO), |
| 2214 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth*0.37f, crBBox.top - fHeight*0.36f + PWL_BEZIER*fHeight*0.13f), PWLPT_BEZIERTO), |
| 2215 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.5f + PWL_BEZIER*fWidth*0.13f, crBBox.bottom + fHeight*0.77f), PWLPT_BEZIERTO), |
| 2216 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.5f, crBBox.bottom + fHeight*0.77f), PWLPT_BEZIERTO), |
| 2217 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.5f - PWL_BEZIER*fWidth*0.13f, crBBox.bottom + fHeight*0.77f), PWLPT_BEZIERTO), |
| 2218 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.37f, crBBox.top - fHeight*0.36f + PWL_BEZIER*fHeight*0.13f), PWLPT_BEZIERTO), |
| 2219 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.37f, crBBox.top - fHeight*0.36f), PWLPT_BEZIERTO), |
| 2220 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.37f, crBBox.top - fHeight*0.36f - fWidth*0.1f*0.6f), PWLPT_BEZIERTO), |
| 2221 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.27f, crBBox.top - fHeight*0.36f - fWidth*0.1f*0.6f), PWLPT_BEZIERTO), |
| 2222 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.27f, crBBox.top - fHeight*0.36f), PWLPT_BEZIERTO), |
| 2223 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth*0.56f, crBBox.bottom + fHeight*0.13f), PWLPT_MOVETO), |
| 2224 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth*0.56f, crBBox.bottom + fHeight*0.13f + PWL_BEZIER*fHeight*0.055f), PWLPT_BEZIERTO), |
| 2225 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth*0.505f - PWL_BEZIER*fWidth*0.095f, crBBox.bottom + fHeight*0.185f), PWLPT_BEZIERTO), |
| 2226 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth*0.505f, crBBox.bottom + fHeight*0.185f), PWLPT_BEZIERTO), |
| 2227 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth*0.505f + PWL_BEZIER*fWidth*0.065f, crBBox.bottom + fHeight*0.185f), PWLPT_BEZIERTO), |
| 2228 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth*0.44f, crBBox.bottom + fHeight*0.13f + PWL_BEZIER*fHeight*0.055f), PWLPT_BEZIERTO), |
| 2229 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth*0.44f, crBBox.bottom + fHeight*0.13f), PWLPT_BEZIERTO), |
| 2230 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth*0.44f, crBBox.bottom + fHeight*0.13f - PWL_BEZIER*fHeight*0.055f), PWLPT_BEZIERTO), |
| 2231 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth*0.505f + PWL_BEZIER*fWidth*0.065f, crBBox.bottom + fHeight*0.075f), PWLPT_BEZIERTO), |
| 2232 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth*0.505f, crBBox.bottom + fHeight*0.075f), PWLPT_BEZIERTO), |
| 2233 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth*0.505f - PWL_BEZIER*fWidth*0.065f, crBBox.bottom + fHeight*0.075f), PWLPT_BEZIERTO), |
| 2234 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth*0.56f, crBBox.bottom + fHeight*0.13f - PWL_BEZIER*fHeight*0.055f), PWLPT_BEZIERTO), |
| 2235 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth*0.56f, crBBox.bottom + fHeight*0.13f), PWLPT_BEZIERTO) |
| 2236 | }; |
| 2237 | |
| 2238 | if(type == PWLPT_STREAM) |
| 2239 | sPathData = GetAppStreamFromArray(PathArray, 59); |
| 2240 | else |
| 2241 | GetPathDataFromArray(path, PathArray, 59); |
| 2242 | } |
| 2243 | |
| 2244 | void CPWL_Utils::GetGraphics_InsertText(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_Rect& crBBox, const PWL_PATH_TYPE type) |
| 2245 | { |
| 2246 | FX_FLOAT fWidth = crBBox.right - crBBox.left; |
| 2247 | FX_FLOAT fHeight = crBBox.top - crBBox.bottom; |
| 2248 | |
| 2249 | CPWL_PathData PathArray[] = |
| 2250 | { |
| 2251 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth/10, crBBox.bottom + fHeight/10), PWLPT_MOVETO), |
| 2252 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth/2, crBBox.top - fHeight*2/15), PWLPT_LINETO), |
| 2253 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth/10, crBBox.bottom + fHeight/10), PWLPT_LINETO), |
| 2254 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth/10, crBBox.bottom + fHeight/10), PWLPT_LINETO) |
| 2255 | }; |
| 2256 | |
| 2257 | if(type == PWLPT_STREAM) |
| 2258 | sPathData = GetAppStreamFromArray(PathArray, 4); |
| 2259 | else |
| 2260 | GetPathDataFromArray(path, PathArray, 4); |
| 2261 | } |
| 2262 | |
| 2263 | void CPWL_Utils::GetGraphics_Key(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_Rect& crBBox, const PWL_PATH_TYPE type) |
| 2264 | { |
| 2265 | FX_FLOAT fWidth = crBBox.right - crBBox.left; |
| 2266 | FX_FLOAT fHeight = crBBox.top - crBBox.bottom; |
| 2267 | FX_FLOAT k = -fHeight/fWidth; |
| 2268 | CPWL_Point tail; |
| 2269 | CPWL_Point CicleCenter; |
| 2270 | tail.x = crBBox.left + fWidth*0.9f; |
| 2271 | tail.y = k*(tail.x - crBBox.right) + crBBox.bottom; |
| 2272 | CicleCenter.x = crBBox.left + fWidth*0.15f; |
| 2273 | CicleCenter.y = k*(CicleCenter.x - crBBox.right) + crBBox.bottom; |
| 2274 | |
| 2275 | CPWL_PathData PathArray[] = |
| 2276 | { |
| 2277 | CPWL_PathData(CPWL_Point(tail.x + fWidth/30.0f, -fWidth/30.0f/k + tail.y), PWLPT_MOVETO), |
| 2278 | CPWL_PathData(CPWL_Point(tail.x + fWidth/30.0f - fWidth*0.18f, -k*fWidth*0.18f - fWidth/30/k + tail.y), PWLPT_LINETO), |
| 2279 | CPWL_PathData(CPWL_Point(tail.x + fWidth/30 - fWidth*0.18f + fWidth*0.07f, |
| 2280 | -fWidth*0.07f/k - k*fWidth*0.18f - fWidth/30/k + tail.y), PWLPT_LINETO), |
| 2281 | CPWL_PathData(CPWL_Point(tail.x + fWidth/30 - fWidth*0.18f - fWidth/20 + fWidth*0.07f, |
| 2282 | -fWidth*0.07f/k - k*fWidth/20 - k*fWidth*0.18f - fWidth/30/k + tail.y), PWLPT_LINETO), |
| 2283 | CPWL_PathData(CPWL_Point(tail.x + fWidth/30 - fWidth*0.18f - fWidth/20, |
| 2284 | -k*fWidth/20 - k*fWidth*0.18f - fWidth/30/k + tail.y), PWLPT_LINETO), |
| 2285 | CPWL_PathData(CPWL_Point(tail.x + fWidth/30 - fWidth*0.18f - fWidth/20 - fWidth/15, |
| 2286 | -k*fWidth/15 - k*fWidth/20 - k*fWidth*0.18f - fWidth/30/k + tail.y), PWLPT_LINETO), |
| 2287 | CPWL_PathData(CPWL_Point(tail.x + fWidth/30 - fWidth*0.18f - fWidth/20 - fWidth/15 + fWidth*0.07f, |
| 2288 | -fWidth*0.07f/k - k*fWidth/15 - k*fWidth/20 - k*fWidth*0.18f - fWidth/30/k + tail.y), PWLPT_LINETO), |
| 2289 | CPWL_PathData(CPWL_Point(tail.x + fWidth/30 - fWidth*0.18f - fWidth/20 - fWidth/15 - fWidth/20 + fWidth*0.07f, |
| 2290 | -fWidth*0.07f/k + -k*fWidth/20 + -k*fWidth/15 - k*fWidth/20 - k*fWidth*0.18f - fWidth/30/k + tail.y), PWLPT_LINETO), |
| 2291 | CPWL_PathData(CPWL_Point(tail.x + fWidth/30 - fWidth*0.18f - fWidth/20 - fWidth/15 - fWidth/20, |
| 2292 | -k*fWidth/20 + -k*fWidth/15 - k*fWidth/20 - k*fWidth*0.18f - fWidth/30/k + tail.y), PWLPT_LINETO), |
| 2293 | CPWL_PathData(CPWL_Point(tail.x + fWidth/30 - fWidth*0.45f, -k*fWidth*0.45f - fWidth/30/k + tail.y), PWLPT_LINETO), |
| 2294 | CPWL_PathData(CPWL_Point(tail.x + fWidth/30 - fWidth*0.45f + fWidth*0.2f, |
| 2295 | -fWidth*0.4f/k - k*fWidth*0.45f - fWidth/30/k + tail.y), PWLPT_BEZIERTO), |
| 2296 | CPWL_PathData(CPWL_Point(CicleCenter.x + fWidth*0.2f, - fWidth*0.1f/k + CicleCenter.y), PWLPT_BEZIERTO), |
| 2297 | CPWL_PathData(CPWL_Point(CicleCenter.x, CicleCenter.y), PWLPT_BEZIERTO), |
| 2298 | CPWL_PathData(CPWL_Point(CicleCenter.x - fWidth/60.0f, -k*fWidth/60 + CicleCenter.y), PWLPT_BEZIERTO), |
| 2299 | CPWL_PathData(CPWL_Point(CicleCenter.x - fWidth/60, -k*fWidth/60 + CicleCenter.y), PWLPT_BEZIERTO), |
| 2300 | CPWL_PathData(CPWL_Point(CicleCenter.x, CicleCenter.y), PWLPT_BEZIERTO), |
| 2301 | CPWL_PathData(CPWL_Point(CicleCenter.x - fWidth*0.22f, fWidth*0.35f/k + CicleCenter.y - fHeight*0.05f), PWLPT_BEZIERTO), |
| 2302 | CPWL_PathData(CPWL_Point(tail.x - fWidth/30 - fWidth*0.45f - fWidth*0.18f, fWidth*0.05f/k - k*fWidth*0.45f + fWidth/30/k + tail.y - fHeight*0.05f), PWLPT_BEZIERTO), |
| 2303 | CPWL_PathData(CPWL_Point(tail.x - fWidth/30.0f - fWidth*0.45f, -k*fWidth*0.45f + fWidth/30.0f/k + tail.y), PWLPT_BEZIERTO), |
| 2304 | CPWL_PathData(CPWL_Point(tail.x - fWidth/30.0f, fWidth/30.0f/k + tail.y), PWLPT_LINETO), |
| 2305 | CPWL_PathData(CPWL_Point(tail.x + fWidth/30, -fWidth/30/k + tail.y), PWLPT_LINETO), |
| 2306 | CPWL_PathData(CPWL_Point(CicleCenter.x + fWidth*0.08f, k*fWidth*0.08f + CicleCenter.y), PWLPT_MOVETO), |
| 2307 | CPWL_PathData(CPWL_Point(CicleCenter.x + fWidth*0.08f + fWidth*0.1f, -fWidth*0.1f/k + k*fWidth*0.08f + CicleCenter.y), PWLPT_BEZIERTO), |
| 2308 | CPWL_PathData(CPWL_Point(CicleCenter.x + fWidth*0.22f + fWidth*0.1f, k*fWidth*0.22f + CicleCenter.y - fWidth*0.1f/k), PWLPT_BEZIERTO), |
| 2309 | CPWL_PathData(CPWL_Point(CicleCenter.x + fWidth*0.22f, k*fWidth*0.22f + CicleCenter.y), PWLPT_BEZIERTO), |
| 2310 | CPWL_PathData(CPWL_Point(CicleCenter.x + fWidth*0.22f - fWidth*0.1f, fWidth*0.1f/k + k*fWidth*0.22f + CicleCenter.y), PWLPT_BEZIERTO), |
| 2311 | CPWL_PathData(CPWL_Point(CicleCenter.x + fWidth*0.08f - fWidth*0.1f, fWidth*0.1f/k + k*fWidth*0.08f + CicleCenter.y), PWLPT_BEZIERTO), |
| 2312 | CPWL_PathData(CPWL_Point(CicleCenter.x + fWidth*0.08f, k*fWidth*0.08f + CicleCenter.y), PWLPT_BEZIERTO) |
| 2313 | }; |
| 2314 | |
| 2315 | if(type == PWLPT_STREAM) |
| 2316 | sPathData = GetAppStreamFromArray(PathArray, 28); |
| 2317 | else |
| 2318 | GetPathDataFromArray(path, PathArray, 28); |
| 2319 | } |
| 2320 | |
| 2321 | void CPWL_Utils::GetGraphics_NewParagraph(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_Rect& crBBox, const PWL_PATH_TYPE type) |
| 2322 | { |
| 2323 | FX_FLOAT fWidth = crBBox.right - crBBox.left; |
| 2324 | FX_FLOAT fHeight = crBBox.top - crBBox.bottom; |
| 2325 | |
| 2326 | CPWL_PathData PathArray[] = |
| 2327 | { |
| 2328 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth/2.0f, crBBox.top - fHeight/20.0f), PWLPT_MOVETO), |
| 2329 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth/10.0f, crBBox.top - fHeight/2.0f), PWLPT_LINETO), |
| 2330 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth/10.0f, crBBox.top - fHeight/2.0f), PWLPT_LINETO), |
| 2331 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth/2.0f, crBBox.top - fHeight/20.0f), PWLPT_LINETO), |
| 2332 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.12f, crBBox.top - fHeight*17/30.0f), PWLPT_MOVETO), |
| 2333 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.12f, crBBox.bottom + fHeight/10.0f), PWLPT_LINETO), |
| 2334 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.22f, crBBox.bottom + fHeight/10.0f), PWLPT_LINETO), |
| 2335 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.22f, crBBox.top - fHeight*17/30.0f - fWidth*0.14f), PWLPT_LINETO), |
| 2336 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.38f, crBBox.bottom + fHeight/10.0f), PWLPT_LINETO), |
| 2337 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.48f, crBBox.bottom + fHeight/10.0f), PWLPT_LINETO), |
| 2338 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.48f, crBBox.top - fHeight*17/30.0f), PWLPT_LINETO), |
| 2339 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.38f, crBBox.top - fHeight*17/30.0f), PWLPT_LINETO), |
| 2340 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.38f, crBBox.bottom + fWidth*0.24f), PWLPT_LINETO), |
| 2341 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.22f, crBBox.top - fHeight*17/30.0f), PWLPT_LINETO), |
| 2342 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.12f, crBBox.top - fHeight*17/30.0f), PWLPT_LINETO), |
| 2343 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.6f, crBBox.bottom + fHeight/10.0f), PWLPT_MOVETO), |
| 2344 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.7f, crBBox.bottom + fHeight/10.0f), PWLPT_LINETO), |
| 2345 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.7f, crBBox.bottom + fHeight/10.0f + fHeight/7.0f), PWLPT_LINETO), |
| 2346 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.97f, crBBox.bottom + fHeight/10.0f + fHeight/7.0f), PWLPT_BEZIERTO), |
| 2347 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.97f, crBBox.top - fHeight*17/30.0f), PWLPT_BEZIERTO), |
| 2348 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.7f, crBBox.top - fHeight*17/30.0f), PWLPT_BEZIERTO), |
| 2349 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.6f, crBBox.top - fHeight*17/30.0f), PWLPT_LINETO), |
| 2350 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.6f, crBBox.bottom + fHeight/10.0f), PWLPT_LINETO), |
| 2351 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.7f, crBBox.bottom + fHeight/7 + fHeight*0.18f), PWLPT_MOVETO), |
| 2352 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.85f, crBBox.bottom + fHeight/7 + fHeight*0.18f), PWLPT_BEZIERTO), |
| 2353 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.85f, crBBox.top - fHeight*17/30.0f - fHeight*0.08f), PWLPT_BEZIERTO), |
| 2354 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.7f, crBBox.top - fHeight*17/30.0f - fHeight*0.08f), PWLPT_BEZIERTO), |
| 2355 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.7f, crBBox.bottom + fHeight/7 + fHeight*0.18f), PWLPT_LINETO) |
| 2356 | }; |
| 2357 | |
| 2358 | if(type == PWLPT_STREAM) |
| 2359 | sPathData = GetAppStreamFromArray(PathArray, 28); |
| 2360 | else |
| 2361 | GetPathDataFromArray(path, PathArray, 28); |
| 2362 | } |
| 2363 | |
| 2364 | void CPWL_Utils::GetGraphics_TextNote(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_Rect& crBBox, const PWL_PATH_TYPE type) |
| 2365 | { |
| 2366 | FX_FLOAT fWidth = crBBox.right - crBBox.left; |
| 2367 | FX_FLOAT fHeight = crBBox.top - crBBox.bottom; |
| 2368 | |
| 2369 | CPWL_PathData PathArray[] = |
| 2370 | { |
| 2371 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth*3/10.0f, crBBox.bottom + fHeight/15.0f), PWLPT_MOVETO), |
| 2372 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*7/10.0f, crBBox.bottom + fHeight*4/15.0f), PWLPT_LINETO), |
| 2373 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth/10.0f, crBBox.bottom + fHeight*4/15.0f), PWLPT_LINETO), |
| 2374 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth/10.0f, crBBox.top - fHeight/15.0f), PWLPT_LINETO), |
| 2375 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth/10.0f, crBBox.top - fHeight/15.0f), PWLPT_LINETO), |
| 2376 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth/10.0f, crBBox.bottom + fHeight/15.0f), PWLPT_LINETO), |
| 2377 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth*3/10.0f, crBBox.bottom + fHeight/15.0f), PWLPT_LINETO), |
| 2378 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth/10.0f, crBBox.bottom + fHeight*4/15.0f), PWLPT_LINETO), |
| 2379 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth*3/10.0f, crBBox.bottom + fHeight/15.0f), PWLPT_LINETO), |
| 2380 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth*3/10.0f, crBBox.bottom + fHeight*4/15.0f), PWLPT_LINETO), |
| 2381 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth/10.0f, crBBox.bottom + fHeight*4/15.0f), PWLPT_LINETO), |
| 2382 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth/5.0f, crBBox.top - fHeight*4/15.0f), PWLPT_MOVETO), |
| 2383 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth/5.0f, crBBox.top - fHeight*4/15.0f), PWLPT_LINETO), |
| 2384 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth/5.0f, crBBox.top - fHeight*7/15.0f), PWLPT_MOVETO), |
| 2385 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth/5.0f, crBBox.top - fHeight*7/15.0f), PWLPT_LINETO), |
| 2386 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth/5.0f, crBBox.top - fHeight*10/15.0f), PWLPT_MOVETO), |
| 2387 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth*3/10.0f, crBBox.top - fHeight*10/15.0f), PWLPT_LINETO) |
| 2388 | }; |
| 2389 | |
| 2390 | if(type == PWLPT_STREAM) |
| 2391 | sPathData = GetAppStreamFromArray(PathArray, 17); |
| 2392 | else |
| 2393 | GetPathDataFromArray(path, PathArray, 17); |
| 2394 | } |
| 2395 | |
| 2396 | void CPWL_Utils::GetGraphics_Paragraph(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_Rect& crBBox, const PWL_PATH_TYPE type) |
| 2397 | { |
| 2398 | FX_FLOAT fWidth = crBBox.right - crBBox.left; |
| 2399 | FX_FLOAT fHeight = crBBox.top - crBBox.bottom; |
| 2400 | |
| 2401 | CPWL_PathData PathArray[] = |
| 2402 | { |
| 2403 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth/2.0f, crBBox.top - fHeight/15.0f), PWLPT_MOVETO), |
| 2404 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.7f, crBBox.top - fHeight/15.0f), PWLPT_LINETO), |
| 2405 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.7f, crBBox.bottom + fHeight/15.0f), PWLPT_LINETO), |
| 2406 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.634f, crBBox.bottom + fHeight/15.0f), PWLPT_LINETO), |
| 2407 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.634f, crBBox.top - fHeight*2/15.0f), PWLPT_LINETO), |
| 2408 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.566f, crBBox.top - fHeight*2/15.0f), PWLPT_LINETO), |
| 2409 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.566f, crBBox.bottom + fHeight/15.0f), PWLPT_LINETO), |
| 2410 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth/2.0f, crBBox.bottom + fHeight/15.0f), PWLPT_LINETO), |
| 2411 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth/2.0f, crBBox.top - fHeight/15.0f - fHeight*0.4f), PWLPT_LINETO), |
| 2412 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.2f, crBBox.top - fHeight/15.0f - fHeight*0.4f), PWLPT_BEZIERTO), |
| 2413 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.2f, crBBox.top - fHeight/15.0f), PWLPT_BEZIERTO), |
| 2414 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth/2.0f, crBBox.top - fHeight/15.0f), PWLPT_BEZIERTO) |
| 2415 | }; |
| 2416 | |
| 2417 | if(type == PWLPT_STREAM) |
| 2418 | sPathData = GetAppStreamFromArray(PathArray, 12); |
| 2419 | else |
| 2420 | GetPathDataFromArray(path, PathArray, 12); |
| 2421 | } |
| 2422 | |
| 2423 | void CPWL_Utils::GetGraphics_RightArrow(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_Rect& crBBox, const PWL_PATH_TYPE type) |
| 2424 | { |
| 2425 | FX_FLOAT fWidth = crBBox.right - crBBox.left; |
| 2426 | FX_FLOAT fHeight = crBBox.top - crBBox.bottom; |
| 2427 | |
| 2428 | CPWL_PathData PathArray[] = |
| 2429 | { |
| 2430 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth/15.0f, crBBox.top - fHeight/2.0f), PWLPT_MOVETO), |
| 2431 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth/2.0f + fWidth/8.0f, crBBox.bottom + fHeight/5.0f), PWLPT_LINETO), |
| 2432 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth/2.0f, crBBox.bottom + fHeight/5.0f), PWLPT_LINETO), |
| 2433 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth/15.0f - fWidth*0.15f, crBBox.top - fHeight/2.0f - fWidth/25.0f), PWLPT_LINETO), |
| 2434 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.1f, crBBox.top - fHeight/2.0f - fWidth/25.0f), PWLPT_LINETO), |
| 2435 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.1f, crBBox.top - fHeight/2.0f + fWidth/25.0f), PWLPT_LINETO), |
| 2436 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth/15.0f - fWidth*0.15f, crBBox.top - fHeight/2.0f + fWidth/25.0f), PWLPT_LINETO), |
| 2437 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth/2.0f, crBBox.top - fHeight/5.0f), PWLPT_LINETO), |
| 2438 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth/2.0f + fWidth/8.0f, crBBox.top - fHeight/5.0f), PWLPT_LINETO), |
| 2439 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth/15.0f, crBBox.top - fHeight/2.0f), PWLPT_LINETO) |
| 2440 | }; |
| 2441 | |
| 2442 | if(type == PWLPT_STREAM) |
| 2443 | sPathData = GetAppStreamFromArray(PathArray, 10); |
| 2444 | else |
| 2445 | GetPathDataFromArray(path, PathArray, 10); |
| 2446 | } |
| 2447 | |
| 2448 | void CPWL_Utils::GetGraphics_RightPointer(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_Rect& crBBox, const PWL_PATH_TYPE type) |
| 2449 | { |
| 2450 | FX_FLOAT fWidth = crBBox.right - crBBox.left; |
| 2451 | FX_FLOAT fHeight = crBBox.top - crBBox.bottom; |
| 2452 | |
| 2453 | CPWL_PathData PathArray[] = |
| 2454 | { |
| 2455 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth/30.0f, crBBox.top - fHeight/2.0f), PWLPT_MOVETO), |
| 2456 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth/30.0f, crBBox.bottom + fHeight/6.0f), PWLPT_LINETO), |
| 2457 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*4/15.0f, crBBox.top - fHeight/2.0f), PWLPT_LINETO), |
| 2458 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth/30.0f, crBBox.top - fHeight/6.0f), PWLPT_LINETO), |
| 2459 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth/30.0f, crBBox.top - fHeight/2.0f), PWLPT_LINETO) |
| 2460 | }; |
| 2461 | |
| 2462 | if(type == PWLPT_STREAM) |
| 2463 | sPathData = GetAppStreamFromArray(PathArray, 5); |
| 2464 | else |
| 2465 | GetPathDataFromArray(path, PathArray, 5); |
| 2466 | } |
| 2467 | |
| 2468 | void CPWL_Utils::GetGraphics_Star(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_Rect& crBBox, const PWL_PATH_TYPE type) |
| 2469 | { |
| 2470 | FX_FLOAT fLongRadius = (crBBox.top - crBBox.bottom)/(1+(FX_FLOAT)cos(PWL_PI/5.0f)); |
| 2471 | fLongRadius = fLongRadius * 0.7f; |
| 2472 | FX_FLOAT fShortRadius = fLongRadius * 0.55f; |
| 2473 | CPDF_Point ptCenter = CPDF_Point((crBBox.left + crBBox.right) / 2.0f,(crBBox.top + crBBox.bottom) / 2.0f); |
| 2474 | |
| 2475 | FX_FLOAT px1[5], py1[5]; |
| 2476 | FX_FLOAT px2[5], py2[5]; |
| 2477 | |
| 2478 | FX_FLOAT fAngel = PWL_PI/10.0f; |
| 2479 | |
| 2480 | for (FX_INT32 i=0; i<5; i++) |
| 2481 | { |
| 2482 | px1[i] = ptCenter.x + fLongRadius * (FX_FLOAT)cos(fAngel); |
| 2483 | py1[i] = ptCenter.y + fLongRadius * (FX_FLOAT)sin(fAngel); |
| 2484 | |
| 2485 | fAngel += PWL_PI * 2 / 5.0f; |
| 2486 | } |
| 2487 | |
| 2488 | fAngel = PWL_PI/5.0f + PWL_PI/10.0f; |
| 2489 | |
| 2490 | for (FX_INT32 j=0; j<5; j++) |
| 2491 | { |
| 2492 | px2[j] = ptCenter.x + fShortRadius * (FX_FLOAT)cos(fAngel); |
| 2493 | py2[j] = ptCenter.y + fShortRadius * (FX_FLOAT)sin(fAngel); |
| 2494 | |
| 2495 | fAngel += PWL_PI * 2 / 5.0f; |
| 2496 | } |
| 2497 | |
| 2498 | CPWL_PathData PathArray[11]; |
| 2499 | PathArray[0] = CPWL_PathData(CPWL_Point(px1[0], py1[0]), PWLPT_MOVETO); |
| 2500 | PathArray[1] = CPWL_PathData(CPWL_Point(px2[0], py2[0]), PWLPT_LINETO); |
| 2501 | |
| 2502 | for(FX_INT32 k = 0; k < 4; k++) |
| 2503 | { |
| 2504 | PathArray[(k+1)*2] = CPWL_PathData(CPWL_Point(px1[k+1], py1[k+1]), PWLPT_LINETO); |
| 2505 | PathArray[(k+1)*2 + 1] = CPWL_PathData(CPWL_Point(px2[k+1], py2[k+1]), PWLPT_LINETO); |
| 2506 | } |
| 2507 | |
| 2508 | PathArray[10] = CPWL_PathData(CPWL_Point(px1[0], py1[0]), PWLPT_LINETO); |
| 2509 | |
| 2510 | if(type == PWLPT_STREAM) |
| 2511 | sPathData = GetAppStreamFromArray(PathArray, 11); |
| 2512 | else |
| 2513 | GetPathDataFromArray(path, PathArray, 11); |
| 2514 | } |
| 2515 | |
| 2516 | void CPWL_Utils::GetGraphics_UpArrow(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_Rect& crBBox, const PWL_PATH_TYPE type) |
| 2517 | { |
| 2518 | FX_FLOAT fWidth = crBBox.right - crBBox.left; |
| 2519 | FX_FLOAT fHeight = crBBox.top - crBBox.bottom; |
| 2520 | |
| 2521 | CPWL_PathData PathArray[] = |
| 2522 | { |
| 2523 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth/2.0f, crBBox.top - fHeight/15.0f), PWLPT_MOVETO), |
| 2524 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth/10.0f, crBBox.top - fWidth*3/5.0f), PWLPT_LINETO), |
| 2525 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.6f, crBBox.top - fWidth*3/5.0f), PWLPT_LINETO), |
| 2526 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.6f, crBBox.bottom + fHeight/15.0f), PWLPT_LINETO), |
| 2527 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.4f, crBBox.bottom + fHeight/15.0f), PWLPT_LINETO), |
| 2528 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.4f, crBBox.top - fWidth*3/5.0f), PWLPT_LINETO), |
| 2529 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth/10, crBBox.top - fWidth*3/5.0f), PWLPT_LINETO), |
| 2530 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth/2.0f, crBBox.top - fHeight/15.0f), PWLPT_LINETO) |
| 2531 | }; |
| 2532 | |
| 2533 | if(type == PWLPT_STREAM) |
| 2534 | sPathData = GetAppStreamFromArray(PathArray, 8); |
| 2535 | else |
| 2536 | GetPathDataFromArray(path, PathArray, 8); |
| 2537 | } |
| 2538 | |
| 2539 | void CPWL_Utils::GetGraphics_UpLeftArrow(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_Rect& crBBox, const PWL_PATH_TYPE type) |
| 2540 | { |
| 2541 | FX_FLOAT fWidth = crBBox.right - crBBox.left; |
| 2542 | FX_FLOAT fHeight = crBBox.top - crBBox.bottom; |
| 2543 | CPWL_Point leftup(crBBox.left, crBBox.top); |
| 2544 | CPWL_Point rightdown(crBBox.right, crBBox.bottom); |
| 2545 | FX_FLOAT k = -fHeight/fWidth; |
| 2546 | CPWL_Point tail; |
| 2547 | tail.x = crBBox.left + fWidth*4/5.0f; |
| 2548 | tail.y = k*(tail.x - crBBox.right) + rightdown.y; |
| 2549 | |
| 2550 | CPWL_PathData PathArray[] = |
| 2551 | { |
| 2552 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth/20.0f, k*(crBBox.left + fWidth/20.0f - rightdown.x) + rightdown.y), PWLPT_MOVETO), |
| 2553 | CPWL_PathData(CPWL_Point(fHeight*17/60.0f/k + tail.x + fWidth/10.0f + fWidth/5.0f, |
| 2554 | -fWidth/5.0f/k + tail.y - fWidth/10.0f/k + fHeight*17/60.0f), PWLPT_LINETO), |
| 2555 | CPWL_PathData(CPWL_Point(fHeight*17/60.0f/k + tail.x + fWidth/10.0f, |
| 2556 | tail.y - fWidth/10.0f/k + fHeight*17/60.0f), PWLPT_LINETO), |
| 2557 | CPWL_PathData(CPWL_Point(tail.x + fWidth/10.0f, tail.y - fWidth/10.0f/k), PWLPT_LINETO), |
| 2558 | CPWL_PathData(CPWL_Point(tail.x - fWidth/10.0f, tail.y + fWidth/10.0f/k), PWLPT_LINETO), |
| 2559 | CPWL_PathData(CPWL_Point(fHeight*17/60.0f/k + tail.x - fWidth/10.0f, tail.y + fWidth/10.0f/k + fHeight*17/60.0f), PWLPT_LINETO), |
| 2560 | CPWL_PathData(CPWL_Point(fHeight*17/60.0f/k + tail.x - fWidth/10.0f - fWidth/5.0f, |
| 2561 | fWidth/5.0f/k + tail.y + fWidth/10.0f/k + fHeight*17/60.0f), PWLPT_LINETO), |
| 2562 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth/20.0f, k*(crBBox.left + fWidth/20.0f - rightdown.x) + rightdown.y), PWLPT_LINETO) |
| 2563 | }; |
| 2564 | |
| 2565 | if(type == PWLPT_STREAM) |
| 2566 | sPathData = GetAppStreamFromArray(PathArray, 8); |
| 2567 | else |
| 2568 | GetPathDataFromArray(path, PathArray, 8); |
| 2569 | } |
| 2570 | |
| 2571 | void CPWL_Utils::GetGraphics_Graph(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_Rect& crBBox, const PWL_PATH_TYPE type) |
| 2572 | { |
| 2573 | FX_FLOAT fWidth = crBBox.right - crBBox.left; |
| 2574 | FX_FLOAT fHeight = crBBox.top - crBBox.bottom; |
| 2575 | |
| 2576 | CPWL_PathData PathArray[] = |
| 2577 | { |
| 2578 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.05f, crBBox.top - fWidth*0.15f), PWLPT_MOVETO), |
| 2579 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.25f, crBBox.top - fHeight*0.15f), PWLPT_LINETO), |
| 2580 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.275f, crBBox.bottom + fHeight*0.08f), PWLPT_LINETO), |
| 2581 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.05f, crBBox.bottom + fHeight*0.08f), PWLPT_LINETO), |
| 2582 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.05f, crBBox.top - fWidth*0.15f), PWLPT_LINETO), |
| 2583 | |
| 2584 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.275f, crBBox.top - fWidth*0.45f), PWLPT_MOVETO), |
| 2585 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.475f, crBBox.top - fWidth*0.45f), PWLPT_LINETO), |
| 2586 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.475f, crBBox.bottom + fHeight*0.08f), PWLPT_LINETO), |
| 2587 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.275f, crBBox.bottom + fHeight*0.08f), PWLPT_LINETO), |
| 2588 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.275f, crBBox.top - fWidth*0.45f), PWLPT_LINETO), |
| 2589 | |
| 2590 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.5f, crBBox.top - fHeight*0.05f), PWLPT_MOVETO), |
| 2591 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.7f, crBBox.top - fHeight*0.05f), PWLPT_LINETO), |
| 2592 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.7f, crBBox.bottom + fHeight*0.08f), PWLPT_LINETO), |
| 2593 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.5f, crBBox.bottom + fHeight*0.08f), PWLPT_LINETO), |
| 2594 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.5f, crBBox.top - fHeight*0.05f), PWLPT_LINETO), |
| 2595 | |
| 2596 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.725f, crBBox.top - fWidth*0.35f), PWLPT_MOVETO), |
| 2597 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.925f, crBBox.top - fWidth*0.35f), PWLPT_LINETO), |
| 2598 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.925f, crBBox.bottom + fHeight*0.08f), PWLPT_LINETO), |
| 2599 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.725f, crBBox.bottom + fHeight*0.08f), PWLPT_LINETO), |
| 2600 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.725f, crBBox.top - fWidth*0.35f), PWLPT_LINETO) |
| 2601 | }; |
| 2602 | |
| 2603 | if(type == PWLPT_STREAM) |
| 2604 | sPathData = GetAppStreamFromArray(PathArray, 20); |
| 2605 | else |
| 2606 | GetPathDataFromArray(path, PathArray, 20); |
| 2607 | } |
| 2608 | |
| 2609 | void CPWL_Utils::GetGraphics_Paperclip(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_Rect& crBBox, const PWL_PATH_TYPE type) |
| 2610 | { |
| 2611 | FX_FLOAT fWidth = crBBox.right - crBBox.left; |
| 2612 | FX_FLOAT fHeight = crBBox.top - crBBox.bottom; |
| 2613 | |
| 2614 | CPWL_PathData PathArray[] = |
| 2615 | { |
| 2616 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth/60, crBBox.top - fHeight*0.25f), PWLPT_MOVETO), |
| 2617 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth/60, crBBox.bottom + fHeight*0.25f), PWLPT_LINETO), |
| 2618 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth/60, crBBox.bottom + fHeight*0.25f - fWidth*57/60.0f*0.35f), PWLPT_BEZIERTO), |
| 2619 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth/30, crBBox.bottom + fHeight*0.25f - fWidth*57/60.0f*0.35f), PWLPT_BEZIERTO), |
| 2620 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth/30, crBBox.bottom + fHeight*0.25f), PWLPT_BEZIERTO), |
| 2621 | |
| 2622 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth/30, crBBox.top - fHeight*0.33f), PWLPT_LINETO), |
| 2623 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth/30, crBBox.top - fHeight*0.33f + fHeight/15*0.5f), PWLPT_BEZIERTO), |
| 2624 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth/30 - fWidth*0.12f, crBBox.top - fHeight*0.33f + fHeight/15*0.5f), PWLPT_BEZIERTO), |
| 2625 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth/30 - fWidth*0.12f, crBBox.top - fHeight*0.33f), PWLPT_BEZIERTO), |
| 2626 | |
| 2627 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth/30 - fWidth*0.12f, crBBox.bottom + fHeight*0.2f), PWLPT_LINETO), |
| 2628 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth/30 - fWidth*0.12f, crBBox.bottom + fHeight*0.2f - (fWidth*57/60.0f - fWidth*0.24f)*0.25f), PWLPT_BEZIERTO), |
| 2629 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth/60 + fWidth*0.12f, crBBox.bottom + fHeight*0.2f - (fWidth*57/60.0f - fWidth*0.24f)*0.25f), PWLPT_BEZIERTO), |
| 2630 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth/60 + fWidth*0.12f, crBBox.bottom + fHeight*0.2f), PWLPT_BEZIERTO), |
| 2631 | |
| 2632 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth/60 + fWidth*0.12f, crBBox.top - fHeight*0.2f), PWLPT_LINETO), |
| 2633 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth/60 + fWidth*0.12f, crBBox.top - fHeight*0.2f + (fWidth*11/12.0f - fWidth*0.36f)*0.25f), PWLPT_BEZIERTO), |
| 2634 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth/15 - fWidth*0.24f, crBBox.top - fHeight*0.2f + (fWidth*11/12.0f - fWidth*0.36f)*0.25f), PWLPT_BEZIERTO), |
| 2635 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth/15 - fWidth*0.24f, crBBox.top - fHeight*0.2f), PWLPT_BEZIERTO), |
| 2636 | |
| 2637 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth/15 - fWidth*0.24f, crBBox.bottom + fHeight*0.25f), PWLPT_LINETO), |
| 2638 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth/15 - fWidth*0.24f, crBBox.bottom + fHeight*0.25f - (fWidth*14/15.0f - fWidth*0.53f)*0.25f), PWLPT_BEZIERTO), |
| 2639 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.29f, crBBox.bottom + fHeight*0.25f - (fWidth*14/15.0f - fWidth*0.53f)*0.25f), PWLPT_BEZIERTO), |
| 2640 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.29f, crBBox.bottom + fHeight*0.25f), PWLPT_BEZIERTO), |
| 2641 | |
| 2642 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.29f, crBBox.top - fHeight*0.33f), PWLPT_LINETO), |
| 2643 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.29f, crBBox.top - fHeight*0.33f + fWidth*0.12f*0.35f), PWLPT_BEZIERTO), |
| 2644 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.17f, crBBox.top - fHeight*0.33f + fWidth*0.12f*0.35f), PWLPT_BEZIERTO), |
| 2645 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.17f, crBBox.top - fHeight*0.33f), PWLPT_BEZIERTO), |
| 2646 | |
| 2647 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.17f, crBBox.bottom + fHeight*0.3f), PWLPT_LINETO), |
| 2648 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.17f, crBBox.bottom + fHeight*0.3f - fWidth*(14/15.0f - 0.29f)*0.35f), PWLPT_BEZIERTO), |
| 2649 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth/15 - fWidth*0.12f, crBBox.bottom + fHeight*0.3f - fWidth*(14/15.0f - 0.29f)*0.35f), PWLPT_BEZIERTO), |
| 2650 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth/15 - fWidth*0.12f, crBBox.bottom + fHeight*0.3f), PWLPT_BEZIERTO), |
| 2651 | |
| 2652 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth/15 - fWidth*0.12f, crBBox.top - fHeight*0.25f), PWLPT_LINETO), |
| 2653 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth/15 - fWidth*0.12f, crBBox.top - fHeight*0.25f + fWidth*0.35f*(11/12.0f - 0.12f)), PWLPT_BEZIERTO), |
| 2654 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth/60, crBBox.top - fHeight*0.25f + fWidth*0.35f*(11/12.0f - 0.12f)), PWLPT_BEZIERTO), |
| 2655 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth/60, crBBox.top - fHeight*0.25f), PWLPT_BEZIERTO) |
| 2656 | }; |
| 2657 | |
| 2658 | if(type == PWLPT_STREAM) |
| 2659 | sPathData = GetAppStreamFromArray(PathArray, 33); |
| 2660 | else |
| 2661 | GetPathDataFromArray(path, PathArray, 33); |
| 2662 | } |
| 2663 | |
| 2664 | void CPWL_Utils::GetGraphics_Attachment(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_Rect& crBBox, const PWL_PATH_TYPE type) |
| 2665 | { |
| 2666 | FX_FLOAT fWidth = crBBox.right - crBBox.left; |
| 2667 | FX_FLOAT fHeight = crBBox.top - crBBox.bottom; |
| 2668 | |
| 2669 | CPWL_PathData PathArray[] = |
| 2670 | { |
| 2671 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.25f, crBBox.top - fHeight*0.1f), PWLPT_MOVETO), |
| 2672 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.4f, crBBox.top - fHeight*0.23f), PWLPT_LINETO), |
| 2673 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.4f, crBBox.top - fHeight*0.5f), PWLPT_LINETO), |
| 2674 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.4f, crBBox.top - fHeight*0.5f + fWidth*0.04f), PWLPT_BEZIERTO), |
| 2675 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.6f, crBBox.top - fHeight*0.5f + fWidth*0.04f), PWLPT_BEZIERTO), |
| 2676 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.6f, crBBox.top - fHeight*0.5f), PWLPT_BEZIERTO), |
| 2677 | |
| 2678 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.6f, crBBox.top - fHeight*0.23f), PWLPT_LINETO), |
| 2679 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth*0.25f, crBBox.top - fHeight*0.1f), PWLPT_LINETO), |
| 2680 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.25f, crBBox.top - fHeight*0.1f), PWLPT_LINETO), |
| 2681 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.4f, crBBox.top - fHeight*0.23f), PWLPT_LINETO), |
| 2682 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.6f, crBBox.top - fHeight*0.23f), PWLPT_LINETO), |
| 2683 | |
| 2684 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.4f, crBBox.top - fHeight*0.5f), PWLPT_MOVETO), |
| 2685 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.4f - fWidth*0.25f*0.4f, crBBox.top - fHeight*0.5f), PWLPT_BEZIERTO), |
| 2686 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.15f, crBBox.top - fHeight*0.65f + fHeight*0.15f*0.4f), PWLPT_BEZIERTO), |
| 2687 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.15f, crBBox.top - fHeight*0.65f), PWLPT_BEZIERTO), |
| 2688 | |
| 2689 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth*0.15f, crBBox.top - fHeight*0.65f), PWLPT_LINETO), |
| 2690 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth*0.15f, crBBox.top - fHeight*0.65f + fHeight*0.15f*0.4f), PWLPT_BEZIERTO), |
| 2691 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.6f + fWidth*0.25f*0.4f, crBBox.top - fHeight*0.5f), PWLPT_BEZIERTO), |
| 2692 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.6f, crBBox.top - fHeight*0.5f), PWLPT_BEZIERTO), |
| 2693 | |
| 2694 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.6f, crBBox.top - fHeight*0.5f + fWidth*0.04f), PWLPT_BEZIERTO), |
| 2695 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.4f, crBBox.top - fHeight*0.5f + fWidth*0.04f), PWLPT_BEZIERTO), |
| 2696 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.4f, crBBox.top - fHeight*0.5f), PWLPT_BEZIERTO), |
| 2697 | |
| 2698 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.5f, crBBox.top - fHeight*0.65f), PWLPT_MOVETO), |
| 2699 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.5f, crBBox.bottom + fHeight*0.1f), PWLPT_LINETO) |
| 2700 | }; |
| 2701 | |
| 2702 | if(type == PWLPT_STREAM) |
| 2703 | sPathData = GetAppStreamFromArray(PathArray, 24); |
| 2704 | else |
| 2705 | GetPathDataFromArray(path, PathArray, 24); |
| 2706 | } |
| 2707 | |
| 2708 | void CPWL_Utils::GetGraphics_Tag(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_Rect& crBBox, const PWL_PATH_TYPE type) |
| 2709 | { |
| 2710 | FX_FLOAT fWidth = crBBox.right - crBBox.left; |
| 2711 | FX_FLOAT fHeight = crBBox.top - crBBox.bottom; |
| 2712 | |
| 2713 | CPWL_PathData PathArray[] = |
| 2714 | { |
| 2715 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.4f, crBBox.top - fHeight*0.1f), PWLPT_MOVETO), |
| 2716 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.1f, crBBox.top - fHeight*0.5f), PWLPT_LINETO), |
| 2717 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.3f, crBBox.bottom + fHeight*0.1f), PWLPT_LINETO), |
| 2718 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth*0.1f, crBBox.bottom + fHeight*0.1f), PWLPT_LINETO), |
| 2719 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth*0.1f, crBBox.top - fHeight*0.1f), PWLPT_LINETO), |
| 2720 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.4f, crBBox.top - fHeight*0.1f), PWLPT_LINETO), |
| 2721 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.4f, crBBox.top - fHeight*0.3f), PWLPT_MOVETO), |
| 2722 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth*0.2f, crBBox.top - fHeight*0.3f), PWLPT_LINETO), |
| 2723 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.4f, crBBox.top - fHeight*0.5f), PWLPT_MOVETO), |
| 2724 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth*0.2f, crBBox.top - fHeight*0.5f), PWLPT_LINETO), |
| 2725 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.4f, crBBox.top - fHeight*0.7f), PWLPT_MOVETO), |
| 2726 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth*0.2f, crBBox.top - fHeight*0.7f), PWLPT_LINETO) |
| 2727 | }; |
| 2728 | |
| 2729 | if(type == PWLPT_STREAM) |
| 2730 | sPathData = GetAppStreamFromArray(PathArray, 12); |
| 2731 | else |
| 2732 | GetPathDataFromArray(path, PathArray, 12); |
| 2733 | } |
| 2734 | |
| 2735 | void CPWL_Utils::GetGraphics_Foxit(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_Rect& crBBox, const PWL_PATH_TYPE type) |
| 2736 | { |
| 2737 | FX_FLOAT fOutWidth = crBBox.right - crBBox.left; |
| 2738 | FX_FLOAT fOutHeight = crBBox.top - crBBox.bottom; |
| 2739 | |
| 2740 | CPDF_Rect crInBox = crBBox; |
| 2741 | crInBox.left = crBBox.left + fOutWidth*0.08f; |
| 2742 | crInBox.right = crBBox.right - fOutWidth*0.08f; |
| 2743 | crInBox.top = crBBox.top - fOutHeight*0.08f; |
| 2744 | crInBox.bottom = crBBox.bottom + fOutHeight*0.08f; |
| 2745 | |
| 2746 | FX_FLOAT fWidth = crInBox.right - crInBox.left; |
| 2747 | FX_FLOAT fHeight = crInBox.top - crInBox.bottom; |
| 2748 | |
| 2749 | CPWL_PathData PathArray[] = |
| 2750 | { |
| 2751 | CPWL_PathData(CPWL_Point(crInBox.left, crInBox.top), PWLPT_MOVETO), |
| 2752 | CPWL_PathData(CPWL_Point(crInBox.left + fWidth*0.45f, crInBox.top), PWLPT_LINETO), |
| 2753 | CPWL_PathData(CPWL_Point(crInBox.left + fWidth*0.45f, crInBox.top - PWL_BEZIER * fHeight * 0.4f), PWLPT_BEZIERTO), |
| 2754 | CPWL_PathData(CPWL_Point(crInBox.left + fWidth*0.45f - PWL_BEZIER * fWidth * 0.45f, crInBox.top - fHeight*0.4f), PWLPT_BEZIERTO), |
| 2755 | CPWL_PathData(CPWL_Point(crInBox.left, crInBox.top - fHeight*0.4f), PWLPT_BEZIERTO), |
| 2756 | CPWL_PathData(CPWL_Point(crInBox.left, crInBox.top), PWLPT_LINETO), |
| 2757 | |
| 2758 | CPWL_PathData(CPWL_Point(crInBox.left + fWidth*0.60f, crInBox.top), PWLPT_MOVETO), |
| 2759 | CPWL_PathData(CPWL_Point(crInBox.left + fWidth*0.75f, crInBox.top), PWLPT_LINETO), |
| 2760 | CPWL_PathData(CPWL_Point(crInBox.left + fWidth*0.75f, crInBox.top - PWL_BEZIER * fHeight * 0.7f), PWLPT_BEZIERTO), |
| 2761 | CPWL_PathData(CPWL_Point(crInBox.left + fWidth*0.75f - PWL_BEZIER * fWidth * 0.75f, crInBox.top - fHeight*0.7f), PWLPT_BEZIERTO), |
| 2762 | CPWL_PathData(CPWL_Point(crInBox.left, crInBox.top - fHeight*0.7f), PWLPT_BEZIERTO), |
| 2763 | CPWL_PathData(CPWL_Point(crInBox.left, crInBox.top - fHeight*0.55f), PWLPT_LINETO), |
| 2764 | CPWL_PathData(CPWL_Point(crInBox.left + PWL_BEZIER * fWidth*0.60f, crInBox.top - fHeight*0.55f), PWLPT_BEZIERTO), |
| 2765 | CPWL_PathData(CPWL_Point(crInBox.left + fWidth * 0.60f, crInBox.top - PWL_BEZIER * fHeight * 0.55f), PWLPT_BEZIERTO), |
| 2766 | CPWL_PathData(CPWL_Point(crInBox.left + fWidth * 0.60f, crInBox.top), PWLPT_BEZIERTO), |
| 2767 | |
| 2768 | CPWL_PathData(CPWL_Point(crInBox.left + fWidth*0.90f, crInBox.top), PWLPT_MOVETO), |
| 2769 | CPWL_PathData(CPWL_Point(crInBox.left + fWidth*0.90f, crInBox.top - PWL_BEZIER * fHeight * 0.85f), PWLPT_BEZIERTO), |
| 2770 | CPWL_PathData(CPWL_Point(crInBox.left + fWidth*0.90f - PWL_BEZIER * fWidth * 0.90f, crInBox.top - fHeight*0.85f), PWLPT_BEZIERTO), |
| 2771 | CPWL_PathData(CPWL_Point(crInBox.left, crInBox.top - fHeight*0.85f), PWLPT_BEZIERTO), |
| 2772 | CPWL_PathData(CPWL_Point(crInBox.left, crInBox.bottom), PWLPT_LINETO), |
| 2773 | CPWL_PathData(CPWL_Point(crInBox.right, crInBox.bottom), PWLPT_LINETO), |
| 2774 | CPWL_PathData(CPWL_Point(crInBox.right, crInBox.top), PWLPT_LINETO), |
| 2775 | CPWL_PathData(CPWL_Point(crInBox.left + fWidth*0.90f, crInBox.top), PWLPT_LINETO), |
| 2776 | |
| 2777 | /* |
| 2778 | CPWL_PathData(CPWL_Point(crBBox.left, crBBox.top), PWLPT_MOVETO), |
| 2779 | CPWL_PathData(CPWL_Point(crBBox.right, crBBox.top), PWLPT_LINETO), |
| 2780 | CPWL_PathData(CPWL_Point(crBBox.right, crBBox.bottom), PWLPT_LINETO), |
| 2781 | CPWL_PathData(CPWL_Point(crBBox.left, crBBox.bottom), PWLPT_LINETO), |
| 2782 | CPWL_PathData(CPWL_Point(crBBox.left, crBBox.top), PWLPT_LINETO), |
| 2783 | |
| 2784 | CPWL_PathData(CPWL_Point(crBBox.left+fOutWidth*0.04f, crBBox.top-fOutHeight*0.04f), PWLPT_MOVETO), |
| 2785 | CPWL_PathData(CPWL_Point(crBBox.right-fOutWidth*0.04f, crBBox.top-fOutHeight*0.04f), PWLPT_LINETO), |
| 2786 | CPWL_PathData(CPWL_Point(crBBox.right-fOutWidth*0.04f, crBBox.bottom+fOutHeight*0.04f), PWLPT_LINETO), |
| 2787 | CPWL_PathData(CPWL_Point(crBBox.left+fOutWidth*0.04f, crBBox.bottom+fOutHeight*0.04f), PWLPT_LINETO), |
| 2788 | CPWL_PathData(CPWL_Point(crBBox.left+fOutWidth*0.04f, crBBox.top-fOutHeight*0.04f), PWLPT_LINETO), |
| 2789 | */ |
| 2790 | }; |
| 2791 | |
| 2792 | if(type == PWLPT_STREAM) |
| 2793 | sPathData = GetAppStreamFromArray(PathArray, 23); |
| 2794 | else |
| 2795 | GetPathDataFromArray(path, PathArray, 23); |
| 2796 | } |
| 2797 | |
| 2798 | void CPWL_Color::ConvertColorType(FX_INT32 nColorType) |
| 2799 | { |
| 2800 | switch (this->nColorType) |
| 2801 | { |
| 2802 | case COLORTYPE_TRANSPARENT: |
| 2803 | break; |
| 2804 | case COLORTYPE_GRAY: |
| 2805 | switch (nColorType) |
| 2806 | { |
| 2807 | case COLORTYPE_RGB: |
| 2808 | CPWL_Utils::ConvertGRAY2RGB(this->fColor1, this->fColor1, this->fColor2, this->fColor3); |
| 2809 | break; |
| 2810 | case COLORTYPE_CMYK: |
| 2811 | CPWL_Utils::ConvertGRAY2CMYK(this->fColor1, this->fColor1, this->fColor2, this->fColor3, this->fColor4); |
| 2812 | break; |
| 2813 | } |
| 2814 | break; |
| 2815 | case COLORTYPE_RGB: |
| 2816 | switch (nColorType) |
| 2817 | { |
| 2818 | case COLORTYPE_GRAY: |
| 2819 | CPWL_Utils::ConvertRGB2GRAY(this->fColor1, this->fColor2, this->fColor3, this->fColor1); |
| 2820 | break; |
| 2821 | case COLORTYPE_CMYK: |
| 2822 | CPWL_Utils::ConvertRGB2CMYK(this->fColor1, this->fColor2, this->fColor3, this->fColor1, this->fColor2, this->fColor3, this->fColor4); |
| 2823 | break; |
| 2824 | } |
| 2825 | break; |
| 2826 | case COLORTYPE_CMYK: |
| 2827 | switch (nColorType) |
| 2828 | { |
| 2829 | case COLORTYPE_GRAY: |
| 2830 | CPWL_Utils::ConvertCMYK2GRAY(this->fColor1, this->fColor2, this->fColor3, this->fColor4, this->fColor1); |
| 2831 | break; |
| 2832 | case COLORTYPE_RGB: |
| 2833 | CPWL_Utils::ConvertCMYK2RGB(this->fColor1, this->fColor2, this->fColor3, this->fColor4, this->fColor1, this->fColor2, this->fColor3); |
| 2834 | break; |
| 2835 | } |
| 2836 | break; |
| 2837 | } |
| 2838 | this->nColorType = nColorType; |
| 2839 | } |
| 2840 | |
| 2841 | |