| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #include "fpdfsdk/pdfwindow/PWL_Utils.h" | 7 #include "fpdfsdk/pdfwindow/PWL_Utils.h" |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 << " " << pPathData[i + 2].point.x << " " | 37 << " " << pPathData[i + 2].point.x << " " |
| 38 << pPathData[i + 2].point.y << " c\n"; | 38 << pPathData[i + 2].point.y << " c\n"; |
| 39 | 39 |
| 40 i += 2; | 40 i += 2; |
| 41 break; | 41 break; |
| 42 default: | 42 default: |
| 43 break; | 43 break; |
| 44 } | 44 } |
| 45 } | 45 } |
| 46 | 46 |
| 47 return csAP.GetByteString(); | 47 return csAP.AsStringC(); |
| 48 } | 48 } |
| 49 | 49 |
| 50 void CPWL_Utils::GetPathDataFromArray(CFX_PathData& path, | 50 void CPWL_Utils::GetPathDataFromArray(CFX_PathData& path, |
| 51 const CPWL_PathData* pPathData, | 51 const CPWL_PathData* pPathData, |
| 52 int32_t nCount) { | 52 int32_t nCount) { |
| 53 path.SetPointCount(nCount); | 53 path.SetPointCount(nCount); |
| 54 | 54 |
| 55 for (int32_t i = 0; i < nCount; i++) { | 55 for (int32_t i = 0; i < nCount; i++) { |
| 56 switch (pPathData[i].type) { | 56 switch (pPathData[i].type) { |
| 57 case PWLPT_MOVETO: | 57 case PWLPT_MOVETO: |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 FX_FLOAT px2 = pts[i][2].x - pts[nNext][0].x; | 178 FX_FLOAT px2 = pts[i][2].x - pts[nNext][0].x; |
| 179 FX_FLOAT py2 = pts[i][2].y - pts[nNext][0].y; | 179 FX_FLOAT py2 = pts[i][2].y - pts[nNext][0].y; |
| 180 | 180 |
| 181 csAP << pts[i][0].x + px1 * FX_BEZIER << " " | 181 csAP << pts[i][0].x + px1 * FX_BEZIER << " " |
| 182 << pts[i][0].y + py1 * FX_BEZIER << " " | 182 << pts[i][0].y + py1 * FX_BEZIER << " " |
| 183 << pts[nNext][0].x + px2 * FX_BEZIER << " " | 183 << pts[nNext][0].x + px2 * FX_BEZIER << " " |
| 184 << pts[nNext][0].y + py2 * FX_BEZIER << " " << pts[nNext][0].x << " " | 184 << pts[nNext][0].y + py2 * FX_BEZIER << " " << pts[nNext][0].x << " " |
| 185 << pts[nNext][0].y << " c\n"; | 185 << pts[nNext][0].y << " c\n"; |
| 186 } | 186 } |
| 187 | 187 |
| 188 return csAP.GetByteString(); | 188 return csAP.AsStringC(); |
| 189 } | 189 } |
| 190 | 190 |
| 191 CFX_ByteString CPWL_Utils::GetAP_Circle(const CFX_FloatRect& crBBox) { | 191 CFX_ByteString CPWL_Utils::GetAP_Circle(const CFX_FloatRect& crBBox) { |
| 192 CFX_ByteTextBuf csAP; | 192 CFX_ByteTextBuf csAP; |
| 193 | 193 |
| 194 FX_FLOAT fWidth = crBBox.right - crBBox.left; | 194 FX_FLOAT fWidth = crBBox.right - crBBox.left; |
| 195 FX_FLOAT fHeight = crBBox.top - crBBox.bottom; | 195 FX_FLOAT fHeight = crBBox.top - crBBox.bottom; |
| 196 | 196 |
| 197 CFX_FloatPoint pt1(crBBox.left, crBBox.bottom + fHeight / 2); | 197 CFX_FloatPoint pt1(crBBox.left, crBBox.bottom + fHeight / 2); |
| 198 CFX_FloatPoint pt2(crBBox.left + fWidth / 2, crBBox.top); | 198 CFX_FloatPoint pt2(crBBox.left + fWidth / 2, crBBox.top); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 220 csAP << pt3.x << " " << pt3.y - py * FX_BEZIER << " " | 220 csAP << pt3.x << " " << pt3.y - py * FX_BEZIER << " " |
| 221 << pt4.x + px * FX_BEZIER << " " << pt4.y << " " << pt4.x << " " << pt4.y | 221 << pt4.x + px * FX_BEZIER << " " << pt4.y << " " << pt4.x << " " << pt4.y |
| 222 << " c\n"; | 222 << " c\n"; |
| 223 | 223 |
| 224 px = pt4.x - pt1.x; | 224 px = pt4.x - pt1.x; |
| 225 py = pt1.y - pt4.y; | 225 py = pt1.y - pt4.y; |
| 226 | 226 |
| 227 csAP << pt4.x - px * FX_BEZIER << " " << pt4.y << " " << pt1.x << " " | 227 csAP << pt4.x - px * FX_BEZIER << " " << pt4.y << " " << pt1.x << " " |
| 228 << pt1.y - py * FX_BEZIER << " " << pt1.x << " " << pt1.y << " c\n"; | 228 << pt1.y - py * FX_BEZIER << " " << pt1.x << " " << pt1.y << " c\n"; |
| 229 | 229 |
| 230 return csAP.GetByteString(); | 230 return csAP.AsStringC(); |
| 231 } | 231 } |
| 232 | 232 |
| 233 CFX_ByteString CPWL_Utils::GetAP_Cross(const CFX_FloatRect& crBBox) { | 233 CFX_ByteString CPWL_Utils::GetAP_Cross(const CFX_FloatRect& crBBox) { |
| 234 CFX_ByteTextBuf csAP; | 234 CFX_ByteTextBuf csAP; |
| 235 | 235 |
| 236 csAP << crBBox.left << " " << crBBox.top << " m\n"; | 236 csAP << crBBox.left << " " << crBBox.top << " m\n"; |
| 237 csAP << crBBox.right << " " << crBBox.bottom << " l\n"; | 237 csAP << crBBox.right << " " << crBBox.bottom << " l\n"; |
| 238 csAP << crBBox.left << " " << crBBox.bottom << " m\n"; | 238 csAP << crBBox.left << " " << crBBox.bottom << " m\n"; |
| 239 csAP << crBBox.right << " " << crBBox.top << " l\n"; | 239 csAP << crBBox.right << " " << crBBox.top << " l\n"; |
| 240 | 240 |
| 241 return csAP.GetByteString(); | 241 return csAP.AsStringC(); |
| 242 } | 242 } |
| 243 | 243 |
| 244 CFX_ByteString CPWL_Utils::GetAP_Diamond(const CFX_FloatRect& crBBox) { | 244 CFX_ByteString CPWL_Utils::GetAP_Diamond(const CFX_FloatRect& crBBox) { |
| 245 CFX_ByteTextBuf csAP; | 245 CFX_ByteTextBuf csAP; |
| 246 | 246 |
| 247 FX_FLOAT fWidth = crBBox.right - crBBox.left; | 247 FX_FLOAT fWidth = crBBox.right - crBBox.left; |
| 248 FX_FLOAT fHeight = crBBox.top - crBBox.bottom; | 248 FX_FLOAT fHeight = crBBox.top - crBBox.bottom; |
| 249 | 249 |
| 250 CFX_FloatPoint pt1(crBBox.left, crBBox.bottom + fHeight / 2); | 250 CFX_FloatPoint pt1(crBBox.left, crBBox.bottom + fHeight / 2); |
| 251 CFX_FloatPoint pt2(crBBox.left + fWidth / 2, crBBox.top); | 251 CFX_FloatPoint pt2(crBBox.left + fWidth / 2, crBBox.top); |
| 252 CFX_FloatPoint pt3(crBBox.right, crBBox.bottom + fHeight / 2); | 252 CFX_FloatPoint pt3(crBBox.right, crBBox.bottom + fHeight / 2); |
| 253 CFX_FloatPoint pt4(crBBox.left + fWidth / 2, crBBox.bottom); | 253 CFX_FloatPoint pt4(crBBox.left + fWidth / 2, crBBox.bottom); |
| 254 | 254 |
| 255 csAP << pt1.x << " " << pt1.y << " m\n"; | 255 csAP << pt1.x << " " << pt1.y << " m\n"; |
| 256 csAP << pt2.x << " " << pt2.y << " l\n"; | 256 csAP << pt2.x << " " << pt2.y << " l\n"; |
| 257 csAP << pt3.x << " " << pt3.y << " l\n"; | 257 csAP << pt3.x << " " << pt3.y << " l\n"; |
| 258 csAP << pt4.x << " " << pt4.y << " l\n"; | 258 csAP << pt4.x << " " << pt4.y << " l\n"; |
| 259 csAP << pt1.x << " " << pt1.y << " l\n"; | 259 csAP << pt1.x << " " << pt1.y << " l\n"; |
| 260 | 260 |
| 261 return csAP.GetByteString(); | 261 return csAP.AsStringC(); |
| 262 } | 262 } |
| 263 | 263 |
| 264 CFX_ByteString CPWL_Utils::GetAP_Square(const CFX_FloatRect& crBBox) { | 264 CFX_ByteString CPWL_Utils::GetAP_Square(const CFX_FloatRect& crBBox) { |
| 265 CFX_ByteTextBuf csAP; | 265 CFX_ByteTextBuf csAP; |
| 266 | 266 |
| 267 csAP << crBBox.left << " " << crBBox.top << " m\n"; | 267 csAP << crBBox.left << " " << crBBox.top << " m\n"; |
| 268 csAP << crBBox.right << " " << crBBox.top << " l\n"; | 268 csAP << crBBox.right << " " << crBBox.top << " l\n"; |
| 269 csAP << crBBox.right << " " << crBBox.bottom << " l\n"; | 269 csAP << crBBox.right << " " << crBBox.bottom << " l\n"; |
| 270 csAP << crBBox.left << " " << crBBox.bottom << " l\n"; | 270 csAP << crBBox.left << " " << crBBox.bottom << " l\n"; |
| 271 csAP << crBBox.left << " " << crBBox.top << " l\n"; | 271 csAP << crBBox.left << " " << crBBox.top << " l\n"; |
| 272 | 272 |
| 273 return csAP.GetByteString(); | 273 return csAP.AsStringC(); |
| 274 } | 274 } |
| 275 | 275 |
| 276 CFX_ByteString CPWL_Utils::GetAP_Star(const CFX_FloatRect& crBBox) { | 276 CFX_ByteString CPWL_Utils::GetAP_Star(const CFX_FloatRect& crBBox) { |
| 277 CFX_ByteTextBuf csAP; | 277 CFX_ByteTextBuf csAP; |
| 278 | 278 |
| 279 FX_FLOAT fRadius = | 279 FX_FLOAT fRadius = |
| 280 (crBBox.top - crBBox.bottom) / (1 + (FX_FLOAT)cos(FX_PI / 5.0f)); | 280 (crBBox.top - crBBox.bottom) / (1 + (FX_FLOAT)cos(FX_PI / 5.0f)); |
| 281 CFX_FloatPoint ptCenter = CFX_FloatPoint((crBBox.left + crBBox.right) / 2.0f, | 281 CFX_FloatPoint ptCenter = CFX_FloatPoint((crBBox.left + crBBox.right) / 2.0f, |
| 282 (crBBox.top + crBBox.bottom) / 2.0f); | 282 (crBBox.top + crBBox.bottom) / 2.0f); |
| 283 | 283 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 295 csAP << px[0] << " " << py[0] << " m\n"; | 295 csAP << px[0] << " " << py[0] << " m\n"; |
| 296 | 296 |
| 297 int32_t nNext = 0; | 297 int32_t nNext = 0; |
| 298 for (int32_t j = 0; j < 5; j++) { | 298 for (int32_t j = 0; j < 5; j++) { |
| 299 nNext += 2; | 299 nNext += 2; |
| 300 if (nNext >= 5) | 300 if (nNext >= 5) |
| 301 nNext -= 5; | 301 nNext -= 5; |
| 302 csAP << px[nNext] << " " << py[nNext] << " l\n"; | 302 csAP << px[nNext] << " " << py[nNext] << " l\n"; |
| 303 } | 303 } |
| 304 | 304 |
| 305 return csAP.GetByteString(); | 305 return csAP.AsStringC(); |
| 306 } | 306 } |
| 307 | 307 |
| 308 CFX_ByteString CPWL_Utils::GetAP_HalfCircle(const CFX_FloatRect& crBBox, | 308 CFX_ByteString CPWL_Utils::GetAP_HalfCircle(const CFX_FloatRect& crBBox, |
| 309 FX_FLOAT fRotate) { | 309 FX_FLOAT fRotate) { |
| 310 CFX_ByteTextBuf csAP; | 310 CFX_ByteTextBuf csAP; |
| 311 | 311 |
| 312 FX_FLOAT fWidth = crBBox.right - crBBox.left; | 312 FX_FLOAT fWidth = crBBox.right - crBBox.left; |
| 313 FX_FLOAT fHeight = crBBox.top - crBBox.bottom; | 313 FX_FLOAT fHeight = crBBox.top - crBBox.bottom; |
| 314 | 314 |
| 315 CFX_FloatPoint pt1(-fWidth / 2, 0); | 315 CFX_FloatPoint pt1(-fWidth / 2, 0); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 330 csAP << pt1.x << " " << pt1.y + py * FX_BEZIER << " " | 330 csAP << pt1.x << " " << pt1.y + py * FX_BEZIER << " " |
| 331 << pt2.x - px * FX_BEZIER << " " << pt2.y << " " << pt2.x << " " << pt2.y | 331 << pt2.x - px * FX_BEZIER << " " << pt2.y << " " << pt2.x << " " << pt2.y |
| 332 << " c\n"; | 332 << " c\n"; |
| 333 | 333 |
| 334 px = pt3.x - pt2.x; | 334 px = pt3.x - pt2.x; |
| 335 py = pt2.y - pt3.y; | 335 py = pt2.y - pt3.y; |
| 336 | 336 |
| 337 csAP << pt2.x + px * FX_BEZIER << " " << pt2.y << " " << pt3.x << " " | 337 csAP << pt2.x + px * FX_BEZIER << " " << pt2.y << " " << pt3.x << " " |
| 338 << pt3.y + py * FX_BEZIER << " " << pt3.x << " " << pt3.y << " c\n"; | 338 << pt3.y + py * FX_BEZIER << " " << pt3.x << " " << pt3.y << " c\n"; |
| 339 | 339 |
| 340 return csAP.GetByteString(); | 340 return csAP.AsStringC(); |
| 341 } | 341 } |
| 342 | 342 |
| 343 CFX_FloatRect CPWL_Utils::InflateRect(const CFX_FloatRect& rcRect, | 343 CFX_FloatRect CPWL_Utils::InflateRect(const CFX_FloatRect& rcRect, |
| 344 FX_FLOAT fSize) { | 344 FX_FLOAT fSize) { |
| 345 if (rcRect.IsEmpty()) | 345 if (rcRect.IsEmpty()) |
| 346 return rcRect; | 346 return rcRect; |
| 347 | 347 |
| 348 CFX_FloatRect rcNew(rcRect.left - fSize, rcRect.bottom - fSize, | 348 CFX_FloatRect rcNew(rcRect.left - fSize, rcRect.bottom - fSize, |
| 349 rcRect.right + fSize, rcRect.top + fSize); | 349 rcRect.right + fSize, rcRect.top + fSize); |
| 350 rcNew.Normalize(); | 350 rcNew.Normalize(); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 380 CFX_ByteTextBuf sAppStream; | 380 CFX_ByteTextBuf sAppStream; |
| 381 | 381 |
| 382 CFX_ByteString sColor = GetColorAppStream(color, TRUE); | 382 CFX_ByteString sColor = GetColorAppStream(color, TRUE); |
| 383 if (sColor.GetLength() > 0) { | 383 if (sColor.GetLength() > 0) { |
| 384 sAppStream << "q\n" << sColor; | 384 sAppStream << "q\n" << sColor; |
| 385 sAppStream << rect.left << " " << rect.bottom << " " | 385 sAppStream << rect.left << " " << rect.bottom << " " |
| 386 << rect.right - rect.left << " " << rect.top - rect.bottom | 386 << rect.right - rect.left << " " << rect.top - rect.bottom |
| 387 << " re f\nQ\n"; | 387 << " re f\nQ\n"; |
| 388 } | 388 } |
| 389 | 389 |
| 390 return sAppStream.GetByteString(); | 390 return sAppStream.AsStringC(); |
| 391 } | 391 } |
| 392 | 392 |
| 393 CFX_ByteString CPWL_Utils::GetCircleFillAppStream(const CFX_FloatRect& rect, | 393 CFX_ByteString CPWL_Utils::GetCircleFillAppStream(const CFX_FloatRect& rect, |
| 394 const CPWL_Color& color) { | 394 const CPWL_Color& color) { |
| 395 CFX_ByteTextBuf sAppStream; | 395 CFX_ByteTextBuf sAppStream; |
| 396 | 396 |
| 397 CFX_ByteString sColor = GetColorAppStream(color, TRUE); | 397 CFX_ByteString sColor = GetColorAppStream(color, TRUE); |
| 398 if (sColor.GetLength() > 0) { | 398 if (sColor.GetLength() > 0) { |
| 399 sAppStream << "q\n" << sColor << CPWL_Utils::GetAP_Circle(rect) << "f\nQ\n"; | 399 sAppStream << "q\n" << sColor << CPWL_Utils::GetAP_Circle(rect) << "f\nQ\n"; |
| 400 } | 400 } |
| 401 | 401 |
| 402 return sAppStream.GetByteString(); | 402 return sAppStream.AsStringC(); |
| 403 } | 403 } |
| 404 | 404 |
| 405 CFX_FloatRect CPWL_Utils::GetCenterSquare(const CFX_FloatRect& rect) { | 405 CFX_FloatRect CPWL_Utils::GetCenterSquare(const CFX_FloatRect& rect) { |
| 406 FX_FLOAT fWidth = rect.right - rect.left; | 406 FX_FLOAT fWidth = rect.right - rect.left; |
| 407 FX_FLOAT fHeight = rect.top - rect.bottom; | 407 FX_FLOAT fHeight = rect.top - rect.bottom; |
| 408 | 408 |
| 409 FX_FLOAT fCenterX = (rect.left + rect.right) / 2.0f; | 409 FX_FLOAT fCenterX = (rect.left + rect.right) / 2.0f; |
| 410 FX_FLOAT fCenterY = (rect.top + rect.bottom) / 2.0f; | 410 FX_FLOAT fCenterY = (rect.top + rect.bottom) / 2.0f; |
| 411 | 411 |
| 412 FX_FLOAT fRadius = (fWidth > fHeight) ? fHeight / 2 : fWidth / 2; | 412 FX_FLOAT fRadius = (fWidth > fHeight) ? fHeight / 2 : fWidth / 2; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 458 | 458 |
| 459 CFX_ByteString sEdit = | 459 CFX_ByteString sEdit = |
| 460 CPWL_Utils::GetEditAppStream(pEdit, CFX_FloatPoint(0.0f, 0.0f)); | 460 CPWL_Utils::GetEditAppStream(pEdit, CFX_FloatPoint(0.0f, 0.0f)); |
| 461 if (sEdit.GetLength() > 0) { | 461 if (sEdit.GetLength() > 0) { |
| 462 sRet << "BT\n" << CPWL_Utils::GetColorAppStream(crText) << sEdit | 462 sRet << "BT\n" << CPWL_Utils::GetColorAppStream(crText) << sEdit |
| 463 << "ET\n"; | 463 << "ET\n"; |
| 464 } | 464 } |
| 465 IFX_Edit::DelEdit(pEdit); | 465 IFX_Edit::DelEdit(pEdit); |
| 466 } | 466 } |
| 467 | 467 |
| 468 return sRet.GetByteString(); | 468 return sRet.AsStringC(); |
| 469 } | 469 } |
| 470 | 470 |
| 471 CFX_ByteString CPWL_Utils::GetPushButtonAppStream(const CFX_FloatRect& rcBBox, | 471 CFX_ByteString CPWL_Utils::GetPushButtonAppStream(const CFX_FloatRect& rcBBox, |
| 472 IPVT_FontMap* pFontMap, | 472 IPVT_FontMap* pFontMap, |
| 473 CPDF_Stream* pIconStream, | 473 CPDF_Stream* pIconStream, |
| 474 CPDF_IconFit& IconFit, | 474 CPDF_IconFit& IconFit, |
| 475 const CFX_WideString& sLabel, | 475 const CFX_WideString& sLabel, |
| 476 const CPWL_Color& crText, | 476 const CPWL_Color& crText, |
| 477 FX_FLOAT fFontSize, | 477 FX_FLOAT fFontSize, |
| 478 int32_t nLayOut) { | 478 int32_t nLayOut) { |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 683 | 683 |
| 684 IFX_Edit::DelEdit(pEdit); | 684 IFX_Edit::DelEdit(pEdit); |
| 685 | 685 |
| 686 if (sTemp.GetSize() > 0) { | 686 if (sTemp.GetSize() > 0) { |
| 687 sAppStream << "q\n" << rcBBox.left << " " << rcBBox.bottom << " " | 687 sAppStream << "q\n" << rcBBox.left << " " << rcBBox.bottom << " " |
| 688 << rcBBox.right - rcBBox.left << " " | 688 << rcBBox.right - rcBBox.left << " " |
| 689 << rcBBox.top - rcBBox.bottom << " re W n\n"; | 689 << rcBBox.top - rcBBox.bottom << " re W n\n"; |
| 690 sAppStream << sTemp << "Q\n"; | 690 sAppStream << sTemp << "Q\n"; |
| 691 } | 691 } |
| 692 | 692 |
| 693 return sAppStream.GetByteString(); | 693 return sAppStream.AsStringC(); |
| 694 } | 694 } |
| 695 | 695 |
| 696 return ""; | 696 return ""; |
| 697 } | 697 } |
| 698 | 698 |
| 699 CFX_ByteString CPWL_Utils::GetColorAppStream(const CPWL_Color& color, | 699 CFX_ByteString CPWL_Utils::GetColorAppStream(const CPWL_Color& color, |
| 700 const FX_BOOL& bFillOrStroke) { | 700 const FX_BOOL& bFillOrStroke) { |
| 701 CFX_ByteTextBuf sColorStream; | 701 CFX_ByteTextBuf sColorStream; |
| 702 | 702 |
| 703 switch (color.nColorType) { | 703 switch (color.nColorType) { |
| 704 case COLORTYPE_RGB: | 704 case COLORTYPE_RGB: |
| 705 sColorStream << color.fColor1 << " " << color.fColor2 << " " | 705 sColorStream << color.fColor1 << " " << color.fColor2 << " " |
| 706 << color.fColor3 << " " << (bFillOrStroke ? "rg" : "RG") | 706 << color.fColor3 << " " << (bFillOrStroke ? "rg" : "RG") |
| 707 << "\n"; | 707 << "\n"; |
| 708 break; | 708 break; |
| 709 case COLORTYPE_GRAY: | 709 case COLORTYPE_GRAY: |
| 710 sColorStream << color.fColor1 << " " << (bFillOrStroke ? "g" : "G") | 710 sColorStream << color.fColor1 << " " << (bFillOrStroke ? "g" : "G") |
| 711 << "\n"; | 711 << "\n"; |
| 712 break; | 712 break; |
| 713 case COLORTYPE_CMYK: | 713 case COLORTYPE_CMYK: |
| 714 sColorStream << color.fColor1 << " " << color.fColor2 << " " | 714 sColorStream << color.fColor1 << " " << color.fColor2 << " " |
| 715 << color.fColor3 << " " << color.fColor4 << " " | 715 << color.fColor3 << " " << color.fColor4 << " " |
| 716 << (bFillOrStroke ? "k" : "K") << "\n"; | 716 << (bFillOrStroke ? "k" : "K") << "\n"; |
| 717 break; | 717 break; |
| 718 } | 718 } |
| 719 | 719 |
| 720 return sColorStream.GetByteString(); | 720 return sColorStream.AsStringC(); |
| 721 } | 721 } |
| 722 | 722 |
| 723 CFX_ByteString CPWL_Utils::GetBorderAppStream(const CFX_FloatRect& rect, | 723 CFX_ByteString CPWL_Utils::GetBorderAppStream(const CFX_FloatRect& rect, |
| 724 FX_FLOAT fWidth, | 724 FX_FLOAT fWidth, |
| 725 const CPWL_Color& color, | 725 const CPWL_Color& color, |
| 726 const CPWL_Color& crLeftTop, | 726 const CPWL_Color& crLeftTop, |
| 727 const CPWL_Color& crRightBottom, | 727 const CPWL_Color& crRightBottom, |
| 728 int32_t nStyle, | 728 int32_t nStyle, |
| 729 const CPWL_Dash& dash) { | 729 const CPWL_Dash& dash) { |
| 730 CFX_ByteTextBuf sAppStream; | 730 CFX_ByteTextBuf sAppStream; |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 826 sAppStream << fWidth << " w\n"; | 826 sAppStream << fWidth << " w\n"; |
| 827 sAppStream << fLeft << " " << fBottom + fWidth / 2 << " m\n"; | 827 sAppStream << fLeft << " " << fBottom + fWidth / 2 << " m\n"; |
| 828 sAppStream << fRight << " " << fBottom + fWidth / 2 << " l S\n"; | 828 sAppStream << fRight << " " << fBottom + fWidth / 2 << " l S\n"; |
| 829 } | 829 } |
| 830 break; | 830 break; |
| 831 } | 831 } |
| 832 | 832 |
| 833 sAppStream << "Q\n"; | 833 sAppStream << "Q\n"; |
| 834 } | 834 } |
| 835 | 835 |
| 836 return sAppStream.GetByteString(); | 836 return sAppStream.AsStringC(); |
| 837 } | 837 } |
| 838 | 838 |
| 839 CFX_ByteString CPWL_Utils::GetCircleBorderAppStream( | 839 CFX_ByteString CPWL_Utils::GetCircleBorderAppStream( |
| 840 const CFX_FloatRect& rect, | 840 const CFX_FloatRect& rect, |
| 841 FX_FLOAT fWidth, | 841 FX_FLOAT fWidth, |
| 842 const CPWL_Color& color, | 842 const CPWL_Color& color, |
| 843 const CPWL_Color& crLeftTop, | 843 const CPWL_Color& crLeftTop, |
| 844 const CPWL_Color& crRightBottom, | 844 const CPWL_Color& crRightBottom, |
| 845 int32_t nStyle, | 845 int32_t nStyle, |
| 846 const CPWL_Dash& dash) { | 846 const CPWL_Dash& dash) { |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 925 CPWL_Utils::DeflateRect(rect, fHalfWidth * 0.75f), | 925 CPWL_Utils::DeflateRect(rect, fHalfWidth * 0.75f), |
| 926 FX_PI * 5 / 4.0f) | 926 FX_PI * 5 / 4.0f) |
| 927 << " S\nQ\n"; | 927 << " S\nQ\n"; |
| 928 } | 928 } |
| 929 } break; | 929 } break; |
| 930 } | 930 } |
| 931 | 931 |
| 932 sAppStream << "Q\n"; | 932 sAppStream << "Q\n"; |
| 933 } | 933 } |
| 934 | 934 |
| 935 return sAppStream.GetByteString(); | 935 return sAppStream.AsStringC(); |
| 936 } | 936 } |
| 937 | 937 |
| 938 CPWL_Color CPWL_Utils::SubstractColor(const CPWL_Color& sColor, | 938 CPWL_Color CPWL_Utils::SubstractColor(const CPWL_Color& sColor, |
| 939 FX_FLOAT fColorSub) { | 939 FX_FLOAT fColorSub) { |
| 940 CPWL_Color sRet; | 940 CPWL_Color sRet; |
| 941 sRet.nColorType = sColor.nColorType; | 941 sRet.nColorType = sColor.nColorType; |
| 942 | 942 |
| 943 switch (sColor.nColorType) { | 943 switch (sColor.nColorType) { |
| 944 case COLORTYPE_TRANSPARENT: | 944 case COLORTYPE_TRANSPARENT: |
| 945 sRet.nColorType = COLORTYPE_RGB; | 945 sRet.nColorType = COLORTYPE_RGB; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 984 } | 984 } |
| 985 | 985 |
| 986 return sRet; | 986 return sRet; |
| 987 } | 987 } |
| 988 | 988 |
| 989 CFX_ByteString CPWL_Utils::GetAppStream_Check(const CFX_FloatRect& rcBBox, | 989 CFX_ByteString CPWL_Utils::GetAppStream_Check(const CFX_FloatRect& rcBBox, |
| 990 const CPWL_Color& crText) { | 990 const CPWL_Color& crText) { |
| 991 CFX_ByteTextBuf sAP; | 991 CFX_ByteTextBuf sAP; |
| 992 sAP << "q\n" << CPWL_Utils::GetColorAppStream(crText, TRUE) | 992 sAP << "q\n" << CPWL_Utils::GetColorAppStream(crText, TRUE) |
| 993 << CPWL_Utils::GetAP_Check(rcBBox) << "f\nQ\n"; | 993 << CPWL_Utils::GetAP_Check(rcBBox) << "f\nQ\n"; |
| 994 return sAP.GetByteString(); | 994 return sAP.AsStringC(); |
| 995 } | 995 } |
| 996 | 996 |
| 997 CFX_ByteString CPWL_Utils::GetAppStream_Circle(const CFX_FloatRect& rcBBox, | 997 CFX_ByteString CPWL_Utils::GetAppStream_Circle(const CFX_FloatRect& rcBBox, |
| 998 const CPWL_Color& crText) { | 998 const CPWL_Color& crText) { |
| 999 CFX_ByteTextBuf sAP; | 999 CFX_ByteTextBuf sAP; |
| 1000 sAP << "q\n" << CPWL_Utils::GetColorAppStream(crText, TRUE) | 1000 sAP << "q\n" << CPWL_Utils::GetColorAppStream(crText, TRUE) |
| 1001 << CPWL_Utils::GetAP_Circle(rcBBox) << "f\nQ\n"; | 1001 << CPWL_Utils::GetAP_Circle(rcBBox) << "f\nQ\n"; |
| 1002 return sAP.GetByteString(); | 1002 return sAP.AsStringC(); |
| 1003 } | 1003 } |
| 1004 | 1004 |
| 1005 CFX_ByteString CPWL_Utils::GetAppStream_Cross(const CFX_FloatRect& rcBBox, | 1005 CFX_ByteString CPWL_Utils::GetAppStream_Cross(const CFX_FloatRect& rcBBox, |
| 1006 const CPWL_Color& crText) { | 1006 const CPWL_Color& crText) { |
| 1007 CFX_ByteTextBuf sAP; | 1007 CFX_ByteTextBuf sAP; |
| 1008 sAP << "q\n" << CPWL_Utils::GetColorAppStream(crText, FALSE) | 1008 sAP << "q\n" << CPWL_Utils::GetColorAppStream(crText, FALSE) |
| 1009 << CPWL_Utils::GetAP_Cross(rcBBox) << "S\nQ\n"; | 1009 << CPWL_Utils::GetAP_Cross(rcBBox) << "S\nQ\n"; |
| 1010 return sAP.GetByteString(); | 1010 return sAP.AsStringC(); |
| 1011 } | 1011 } |
| 1012 | 1012 |
| 1013 CFX_ByteString CPWL_Utils::GetAppStream_Diamond(const CFX_FloatRect& rcBBox, | 1013 CFX_ByteString CPWL_Utils::GetAppStream_Diamond(const CFX_FloatRect& rcBBox, |
| 1014 const CPWL_Color& crText) { | 1014 const CPWL_Color& crText) { |
| 1015 CFX_ByteTextBuf sAP; | 1015 CFX_ByteTextBuf sAP; |
| 1016 sAP << "q\n1 w\n" << CPWL_Utils::GetColorAppStream(crText, TRUE) | 1016 sAP << "q\n1 w\n" << CPWL_Utils::GetColorAppStream(crText, TRUE) |
| 1017 << CPWL_Utils::GetAP_Diamond(rcBBox) << "f\nQ\n"; | 1017 << CPWL_Utils::GetAP_Diamond(rcBBox) << "f\nQ\n"; |
| 1018 return sAP.GetByteString(); | 1018 return sAP.AsStringC(); |
| 1019 } | 1019 } |
| 1020 | 1020 |
| 1021 CFX_ByteString CPWL_Utils::GetAppStream_Square(const CFX_FloatRect& rcBBox, | 1021 CFX_ByteString CPWL_Utils::GetAppStream_Square(const CFX_FloatRect& rcBBox, |
| 1022 const CPWL_Color& crText) { | 1022 const CPWL_Color& crText) { |
| 1023 CFX_ByteTextBuf sAP; | 1023 CFX_ByteTextBuf sAP; |
| 1024 sAP << "q\n" << CPWL_Utils::GetColorAppStream(crText, TRUE) | 1024 sAP << "q\n" << CPWL_Utils::GetColorAppStream(crText, TRUE) |
| 1025 << CPWL_Utils::GetAP_Square(rcBBox) << "f\nQ\n"; | 1025 << CPWL_Utils::GetAP_Square(rcBBox) << "f\nQ\n"; |
| 1026 return sAP.GetByteString(); | 1026 return sAP.AsStringC(); |
| 1027 } | 1027 } |
| 1028 | 1028 |
| 1029 CFX_ByteString CPWL_Utils::GetAppStream_Star(const CFX_FloatRect& rcBBox, | 1029 CFX_ByteString CPWL_Utils::GetAppStream_Star(const CFX_FloatRect& rcBBox, |
| 1030 const CPWL_Color& crText) { | 1030 const CPWL_Color& crText) { |
| 1031 CFX_ByteTextBuf sAP; | 1031 CFX_ByteTextBuf sAP; |
| 1032 sAP << "q\n" << CPWL_Utils::GetColorAppStream(crText, TRUE) | 1032 sAP << "q\n" << CPWL_Utils::GetColorAppStream(crText, TRUE) |
| 1033 << CPWL_Utils::GetAP_Star(rcBBox) << "f\nQ\n"; | 1033 << CPWL_Utils::GetAP_Star(rcBBox) << "f\nQ\n"; |
| 1034 return sAP.GetByteString(); | 1034 return sAP.AsStringC(); |
| 1035 } | 1035 } |
| 1036 | 1036 |
| 1037 CFX_ByteString CPWL_Utils::GetCheckBoxAppStream(const CFX_FloatRect& rcBBox, | 1037 CFX_ByteString CPWL_Utils::GetCheckBoxAppStream(const CFX_FloatRect& rcBBox, |
| 1038 int32_t nStyle, | 1038 int32_t nStyle, |
| 1039 const CPWL_Color& crText) { | 1039 const CPWL_Color& crText) { |
| 1040 CFX_FloatRect rcCenter = GetCenterSquare(rcBBox); | 1040 CFX_FloatRect rcCenter = GetCenterSquare(rcBBox); |
| 1041 switch (nStyle) { | 1041 switch (nStyle) { |
| 1042 default: | 1042 default: |
| 1043 case PCS_CHECK: | 1043 case PCS_CHECK: |
| 1044 return GetAppStream_Check(rcCenter, crText); | 1044 return GetAppStream_Check(rcCenter, crText); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1103 sAppStream << "q\n" | 1103 sAppStream << "q\n" |
| 1104 << " 0 g\n"; | 1104 << " 0 g\n"; |
| 1105 sAppStream << ptCenter.x - 3 << " " << ptCenter.y + 1.5f << " m\n"; | 1105 sAppStream << ptCenter.x - 3 << " " << ptCenter.y + 1.5f << " m\n"; |
| 1106 sAppStream << ptCenter.x + 3 << " " << ptCenter.y + 1.5f << " l\n"; | 1106 sAppStream << ptCenter.x + 3 << " " << ptCenter.y + 1.5f << " l\n"; |
| 1107 sAppStream << ptCenter.x << " " << ptCenter.y - 1.5f << " l\n"; | 1107 sAppStream << ptCenter.x << " " << ptCenter.y - 1.5f << " l\n"; |
| 1108 sAppStream << ptCenter.x - 3 << " " << ptCenter.y + 1.5f << " l f\n"; | 1108 sAppStream << ptCenter.x - 3 << " " << ptCenter.y + 1.5f << " l f\n"; |
| 1109 sAppStream << "Q\n"; | 1109 sAppStream << "Q\n"; |
| 1110 } | 1110 } |
| 1111 } | 1111 } |
| 1112 | 1112 |
| 1113 return sAppStream.GetByteString(); | 1113 return sAppStream.AsStringC(); |
| 1114 } | 1114 } |
| 1115 | 1115 |
| 1116 void CPWL_Utils::ConvertCMYK2GRAY(FX_FLOAT dC, | 1116 void CPWL_Utils::ConvertCMYK2GRAY(FX_FLOAT dC, |
| 1117 FX_FLOAT dM, | 1117 FX_FLOAT dM, |
| 1118 FX_FLOAT dY, | 1118 FX_FLOAT dY, |
| 1119 FX_FLOAT dK, | 1119 FX_FLOAT dK, |
| 1120 FX_FLOAT& dGray) { | 1120 FX_FLOAT& dGray) { |
| 1121 if (dC < 0 || dC > 1 || dM < 0 || dM > 1 || dY < 0 || dY > 1 || dK < 0 || | 1121 if (dC < 0 || dC > 1 || dM < 0 || dM > 1 || dY < 0 || dY > 1 || dK < 0 || |
| 1122 dK > 1) | 1122 dK > 1) |
| 1123 return; | 1123 return; |
| (...skipping 2238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3362 break; | 3362 break; |
| 3363 case COLORTYPE_RGB: | 3363 case COLORTYPE_RGB: |
| 3364 CPWL_Utils::ConvertCMYK2RGB(fColor1, fColor2, fColor3, fColor4, | 3364 CPWL_Utils::ConvertCMYK2RGB(fColor1, fColor2, fColor3, fColor4, |
| 3365 fColor1, fColor2, fColor3); | 3365 fColor1, fColor2, fColor3); |
| 3366 break; | 3366 break; |
| 3367 } | 3367 } |
| 3368 break; | 3368 break; |
| 3369 } | 3369 } |
| 3370 nColorType = other_nColorType; | 3370 nColorType = other_nColorType; |
| 3371 } | 3371 } |
| OLD | NEW |