Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(43)

Side by Side Diff: fpdfsdk/pdfwindow/PWL_Utils.cpp

Issue 1977093002: Make CFX_ByteString(const CFX_ByteStringC&) explicit. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Rebase, nit Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « fpdfsdk/pdfwindow/PWL_Label.cpp ('k') | xfa/fwl/basewidget/fwl_editimp.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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.AsStringC(); 47 return csAP.MakeString();
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
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.AsStringC(); 188 return csAP.MakeString();
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
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.AsStringC(); 230 return csAP.MakeString();
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.AsStringC(); 241 return csAP.MakeString();
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.AsStringC(); 261 return csAP.MakeString();
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.AsStringC(); 273 return csAP.MakeString();
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
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.AsStringC(); 305 return csAP.MakeString();
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
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.AsStringC(); 340 return csAP.MakeString();
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 20 matching lines...) Expand all
371 (rcRect.top + rcRect.bottom) / 2); 371 (rcRect.top + rcRect.bottom) / 2);
372 372
373 return CFX_FloatRect( 373 return CFX_FloatRect(
374 ptCenter.x - fHalfWidth * fScale, ptCenter.y - fHalfHeight * fScale, 374 ptCenter.x - fHalfWidth * fScale, ptCenter.y - fHalfHeight * fScale,
375 ptCenter.x + fHalfWidth * fScale, ptCenter.y + fHalfHeight * fScale); 375 ptCenter.x + fHalfWidth * fScale, ptCenter.y + fHalfHeight * fScale);
376 } 376 }
377 377
378 CFX_ByteString CPWL_Utils::GetRectFillAppStream(const CFX_FloatRect& rect, 378 CFX_ByteString CPWL_Utils::GetRectFillAppStream(const CFX_FloatRect& rect,
379 const CPWL_Color& color) { 379 const CPWL_Color& color) {
380 CFX_ByteTextBuf sAppStream; 380 CFX_ByteTextBuf sAppStream;
381
382 CFX_ByteString sColor = GetColorAppStream(color, TRUE); 381 CFX_ByteString sColor = GetColorAppStream(color, TRUE);
383 if (sColor.GetLength() > 0) { 382 if (sColor.GetLength() > 0) {
384 sAppStream << "q\n" << sColor; 383 sAppStream << "q\n" << sColor;
385 sAppStream << rect.left << " " << rect.bottom << " " 384 sAppStream << rect.left << " " << rect.bottom << " "
386 << rect.right - rect.left << " " << rect.top - rect.bottom 385 << rect.right - rect.left << " " << rect.top - rect.bottom
387 << " re f\nQ\n"; 386 << " re f\nQ\n";
388 } 387 }
389 388
390 return sAppStream.AsStringC(); 389 return sAppStream.MakeString();
391 } 390 }
392 391
393 CFX_ByteString CPWL_Utils::GetCircleFillAppStream(const CFX_FloatRect& rect, 392 CFX_ByteString CPWL_Utils::GetCircleFillAppStream(const CFX_FloatRect& rect,
394 const CPWL_Color& color) { 393 const CPWL_Color& color) {
395 CFX_ByteTextBuf sAppStream; 394 CFX_ByteTextBuf sAppStream;
396
397 CFX_ByteString sColor = GetColorAppStream(color, TRUE); 395 CFX_ByteString sColor = GetColorAppStream(color, TRUE);
398 if (sColor.GetLength() > 0) { 396 if (sColor.GetLength() > 0) {
399 sAppStream << "q\n" << sColor << CPWL_Utils::GetAP_Circle(rect) << "f\nQ\n"; 397 sAppStream << "q\n" << sColor << CPWL_Utils::GetAP_Circle(rect) << "f\nQ\n";
400 } 398 }
401 399 return sAppStream.MakeString();
402 return sAppStream.AsStringC();
403 } 400 }
404 401
405 CFX_FloatRect CPWL_Utils::GetCenterSquare(const CFX_FloatRect& rect) { 402 CFX_FloatRect CPWL_Utils::GetCenterSquare(const CFX_FloatRect& rect) {
406 FX_FLOAT fWidth = rect.right - rect.left; 403 FX_FLOAT fWidth = rect.right - rect.left;
407 FX_FLOAT fHeight = rect.top - rect.bottom; 404 FX_FLOAT fHeight = rect.top - rect.bottom;
408 405
409 FX_FLOAT fCenterX = (rect.left + rect.right) / 2.0f; 406 FX_FLOAT fCenterX = (rect.left + rect.right) / 2.0f;
410 FX_FLOAT fCenterY = (rect.top + rect.bottom) / 2.0f; 407 FX_FLOAT fCenterY = (rect.top + rect.bottom) / 2.0f;
411 408
412 FX_FLOAT fRadius = (fWidth > fHeight) ? fHeight / 2 : fWidth / 2; 409 FX_FLOAT fRadius = (fWidth > fHeight) ? fHeight / 2 : fWidth / 2;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 452
456 pEdit->Initialize(); 453 pEdit->Initialize();
457 pEdit->SetText(sText.c_str()); 454 pEdit->SetText(sText.c_str());
458 455
459 CFX_ByteString sEdit = 456 CFX_ByteString sEdit =
460 CPWL_Utils::GetEditAppStream(pEdit, CFX_FloatPoint(0.0f, 0.0f)); 457 CPWL_Utils::GetEditAppStream(pEdit, CFX_FloatPoint(0.0f, 0.0f));
461 if (sEdit.GetLength() > 0) 458 if (sEdit.GetLength() > 0)
462 sRet << "BT\n" << CPWL_Utils::GetColorAppStream(crText) << sEdit << "ET\n"; 459 sRet << "BT\n" << CPWL_Utils::GetColorAppStream(crText) << sEdit << "ET\n";
463 IFX_Edit::DelEdit(pEdit); 460 IFX_Edit::DelEdit(pEdit);
464 461
465 return sRet.AsStringC(); 462 return sRet.MakeString();
466 } 463 }
467 464
468 CFX_ByteString CPWL_Utils::GetPushButtonAppStream(const CFX_FloatRect& rcBBox, 465 CFX_ByteString CPWL_Utils::GetPushButtonAppStream(const CFX_FloatRect& rcBBox,
469 IPVT_FontMap* pFontMap, 466 IPVT_FontMap* pFontMap,
470 CPDF_Stream* pIconStream, 467 CPDF_Stream* pIconStream,
471 CPDF_IconFit& IconFit, 468 CPDF_IconFit& IconFit,
472 const CFX_WideString& sLabel, 469 const CFX_WideString& sLabel,
473 const CPWL_Color& crText, 470 const CPWL_Color& crText,
474 FX_FLOAT fFontSize, 471 FX_FLOAT fFontSize,
475 int32_t nLayOut) { 472 int32_t nLayOut) {
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
671 pEdit->SetPlateRect(rcLabel); 668 pEdit->SetPlateRect(rcLabel);
672 CFX_ByteString sEdit = 669 CFX_ByteString sEdit =
673 CPWL_Utils::GetEditAppStream(pEdit, CFX_FloatPoint(0.0f, 0.0f)); 670 CPWL_Utils::GetEditAppStream(pEdit, CFX_FloatPoint(0.0f, 0.0f));
674 if (sEdit.GetLength() > 0) { 671 if (sEdit.GetLength() > 0) {
675 sTemp << "BT\n" 672 sTemp << "BT\n"
676 << CPWL_Utils::GetColorAppStream(crText) << sEdit << "ET\n"; 673 << CPWL_Utils::GetColorAppStream(crText) << sEdit << "ET\n";
677 } 674 }
678 } 675 }
679 676
680 IFX_Edit::DelEdit(pEdit); 677 IFX_Edit::DelEdit(pEdit);
681
682 if (sTemp.GetSize() > 0) { 678 if (sTemp.GetSize() > 0) {
683 sAppStream << "q\n" 679 sAppStream << "q\n"
684 << rcBBox.left << " " << rcBBox.bottom << " " 680 << rcBBox.left << " " << rcBBox.bottom << " "
685 << rcBBox.right - rcBBox.left << " " 681 << rcBBox.right - rcBBox.left << " "
686 << rcBBox.top - rcBBox.bottom << " re W n\n"; 682 << rcBBox.top - rcBBox.bottom << " re W n\n";
687 sAppStream << sTemp << "Q\n"; 683 sAppStream << sTemp << "Q\n";
688 } 684 }
689 685 return sAppStream.MakeString();
690 return sAppStream.AsStringC();
691 } 686 }
692 687
693 CFX_ByteString CPWL_Utils::GetColorAppStream(const CPWL_Color& color, 688 CFX_ByteString CPWL_Utils::GetColorAppStream(const CPWL_Color& color,
694 const FX_BOOL& bFillOrStroke) { 689 const FX_BOOL& bFillOrStroke) {
695 CFX_ByteTextBuf sColorStream; 690 CFX_ByteTextBuf sColorStream;
696 691
697 switch (color.nColorType) { 692 switch (color.nColorType) {
698 case COLORTYPE_RGB: 693 case COLORTYPE_RGB:
699 sColorStream << color.fColor1 << " " << color.fColor2 << " " 694 sColorStream << color.fColor1 << " " << color.fColor2 << " "
700 << color.fColor3 << " " << (bFillOrStroke ? "rg" : "RG") 695 << color.fColor3 << " " << (bFillOrStroke ? "rg" : "RG")
701 << "\n"; 696 << "\n";
702 break; 697 break;
703 case COLORTYPE_GRAY: 698 case COLORTYPE_GRAY:
704 sColorStream << color.fColor1 << " " << (bFillOrStroke ? "g" : "G") 699 sColorStream << color.fColor1 << " " << (bFillOrStroke ? "g" : "G")
705 << "\n"; 700 << "\n";
706 break; 701 break;
707 case COLORTYPE_CMYK: 702 case COLORTYPE_CMYK:
708 sColorStream << color.fColor1 << " " << color.fColor2 << " " 703 sColorStream << color.fColor1 << " " << color.fColor2 << " "
709 << color.fColor3 << " " << color.fColor4 << " " 704 << color.fColor3 << " " << color.fColor4 << " "
710 << (bFillOrStroke ? "k" : "K") << "\n"; 705 << (bFillOrStroke ? "k" : "K") << "\n";
711 break; 706 break;
712 } 707 }
713 708
714 return sColorStream.AsStringC(); 709 return sColorStream.MakeString();
715 } 710 }
716 711
717 CFX_ByteString CPWL_Utils::GetBorderAppStream(const CFX_FloatRect& rect, 712 CFX_ByteString CPWL_Utils::GetBorderAppStream(const CFX_FloatRect& rect,
718 FX_FLOAT fWidth, 713 FX_FLOAT fWidth,
719 const CPWL_Color& color, 714 const CPWL_Color& color,
720 const CPWL_Color& crLeftTop, 715 const CPWL_Color& crLeftTop,
721 const CPWL_Color& crRightBottom, 716 const CPWL_Color& crRightBottom,
722 int32_t nStyle, 717 int32_t nStyle,
723 const CPWL_Dash& dash) { 718 const CPWL_Dash& dash) {
724 CFX_ByteTextBuf sAppStream; 719 CFX_ByteTextBuf sAppStream;
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
820 sAppStream << fWidth << " w\n"; 815 sAppStream << fWidth << " w\n";
821 sAppStream << fLeft << " " << fBottom + fWidth / 2 << " m\n"; 816 sAppStream << fLeft << " " << fBottom + fWidth / 2 << " m\n";
822 sAppStream << fRight << " " << fBottom + fWidth / 2 << " l S\n"; 817 sAppStream << fRight << " " << fBottom + fWidth / 2 << " l S\n";
823 } 818 }
824 break; 819 break;
825 } 820 }
826 821
827 sAppStream << "Q\n"; 822 sAppStream << "Q\n";
828 } 823 }
829 824
830 return sAppStream.AsStringC(); 825 return sAppStream.MakeString();
831 } 826 }
832 827
833 CFX_ByteString CPWL_Utils::GetCircleBorderAppStream( 828 CFX_ByteString CPWL_Utils::GetCircleBorderAppStream(
834 const CFX_FloatRect& rect, 829 const CFX_FloatRect& rect,
835 FX_FLOAT fWidth, 830 FX_FLOAT fWidth,
836 const CPWL_Color& color, 831 const CPWL_Color& color,
837 const CPWL_Color& crLeftTop, 832 const CPWL_Color& crLeftTop,
838 const CPWL_Color& crRightBottom, 833 const CPWL_Color& crRightBottom,
839 int32_t nStyle, 834 int32_t nStyle,
840 const CPWL_Dash& dash) { 835 const CPWL_Dash& dash) {
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
919 CPWL_Utils::DeflateRect(rect, fHalfWidth * 0.75f), 914 CPWL_Utils::DeflateRect(rect, fHalfWidth * 0.75f),
920 FX_PI * 5 / 4.0f) 915 FX_PI * 5 / 4.0f)
921 << " S\nQ\n"; 916 << " S\nQ\n";
922 } 917 }
923 } break; 918 } break;
924 } 919 }
925 920
926 sAppStream << "Q\n"; 921 sAppStream << "Q\n";
927 } 922 }
928 923
929 return sAppStream.AsStringC(); 924 return sAppStream.MakeString();
930 } 925 }
931 926
932 CPWL_Color CPWL_Utils::SubstractColor(const CPWL_Color& sColor, 927 CPWL_Color CPWL_Utils::SubstractColor(const CPWL_Color& sColor,
933 FX_FLOAT fColorSub) { 928 FX_FLOAT fColorSub) {
934 CPWL_Color sRet; 929 CPWL_Color sRet;
935 sRet.nColorType = sColor.nColorType; 930 sRet.nColorType = sColor.nColorType;
936 931
937 switch (sColor.nColorType) { 932 switch (sColor.nColorType) {
938 case COLORTYPE_TRANSPARENT: 933 case COLORTYPE_TRANSPARENT:
939 sRet.nColorType = COLORTYPE_RGB; 934 sRet.nColorType = COLORTYPE_RGB;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
978 } 973 }
979 974
980 return sRet; 975 return sRet;
981 } 976 }
982 977
983 CFX_ByteString CPWL_Utils::GetAppStream_Check(const CFX_FloatRect& rcBBox, 978 CFX_ByteString CPWL_Utils::GetAppStream_Check(const CFX_FloatRect& rcBBox,
984 const CPWL_Color& crText) { 979 const CPWL_Color& crText) {
985 CFX_ByteTextBuf sAP; 980 CFX_ByteTextBuf sAP;
986 sAP << "q\n" << CPWL_Utils::GetColorAppStream(crText, TRUE) 981 sAP << "q\n" << CPWL_Utils::GetColorAppStream(crText, TRUE)
987 << CPWL_Utils::GetAP_Check(rcBBox) << "f\nQ\n"; 982 << CPWL_Utils::GetAP_Check(rcBBox) << "f\nQ\n";
988 return sAP.AsStringC(); 983 return sAP.MakeString();
989 } 984 }
990 985
991 CFX_ByteString CPWL_Utils::GetAppStream_Circle(const CFX_FloatRect& rcBBox, 986 CFX_ByteString CPWL_Utils::GetAppStream_Circle(const CFX_FloatRect& rcBBox,
992 const CPWL_Color& crText) { 987 const CPWL_Color& crText) {
993 CFX_ByteTextBuf sAP; 988 CFX_ByteTextBuf sAP;
994 sAP << "q\n" << CPWL_Utils::GetColorAppStream(crText, TRUE) 989 sAP << "q\n" << CPWL_Utils::GetColorAppStream(crText, TRUE)
995 << CPWL_Utils::GetAP_Circle(rcBBox) << "f\nQ\n"; 990 << CPWL_Utils::GetAP_Circle(rcBBox) << "f\nQ\n";
996 return sAP.AsStringC(); 991 return sAP.MakeString();
997 } 992 }
998 993
999 CFX_ByteString CPWL_Utils::GetAppStream_Cross(const CFX_FloatRect& rcBBox, 994 CFX_ByteString CPWL_Utils::GetAppStream_Cross(const CFX_FloatRect& rcBBox,
1000 const CPWL_Color& crText) { 995 const CPWL_Color& crText) {
1001 CFX_ByteTextBuf sAP; 996 CFX_ByteTextBuf sAP;
1002 sAP << "q\n" << CPWL_Utils::GetColorAppStream(crText, FALSE) 997 sAP << "q\n" << CPWL_Utils::GetColorAppStream(crText, FALSE)
1003 << CPWL_Utils::GetAP_Cross(rcBBox) << "S\nQ\n"; 998 << CPWL_Utils::GetAP_Cross(rcBBox) << "S\nQ\n";
1004 return sAP.AsStringC(); 999 return sAP.MakeString();
1005 } 1000 }
1006 1001
1007 CFX_ByteString CPWL_Utils::GetAppStream_Diamond(const CFX_FloatRect& rcBBox, 1002 CFX_ByteString CPWL_Utils::GetAppStream_Diamond(const CFX_FloatRect& rcBBox,
1008 const CPWL_Color& crText) { 1003 const CPWL_Color& crText) {
1009 CFX_ByteTextBuf sAP; 1004 CFX_ByteTextBuf sAP;
1010 sAP << "q\n1 w\n" << CPWL_Utils::GetColorAppStream(crText, TRUE) 1005 sAP << "q\n1 w\n" << CPWL_Utils::GetColorAppStream(crText, TRUE)
1011 << CPWL_Utils::GetAP_Diamond(rcBBox) << "f\nQ\n"; 1006 << CPWL_Utils::GetAP_Diamond(rcBBox) << "f\nQ\n";
1012 return sAP.AsStringC(); 1007 return sAP.MakeString();
1013 } 1008 }
1014 1009
1015 CFX_ByteString CPWL_Utils::GetAppStream_Square(const CFX_FloatRect& rcBBox, 1010 CFX_ByteString CPWL_Utils::GetAppStream_Square(const CFX_FloatRect& rcBBox,
1016 const CPWL_Color& crText) { 1011 const CPWL_Color& crText) {
1017 CFX_ByteTextBuf sAP; 1012 CFX_ByteTextBuf sAP;
1018 sAP << "q\n" << CPWL_Utils::GetColorAppStream(crText, TRUE) 1013 sAP << "q\n" << CPWL_Utils::GetColorAppStream(crText, TRUE)
1019 << CPWL_Utils::GetAP_Square(rcBBox) << "f\nQ\n"; 1014 << CPWL_Utils::GetAP_Square(rcBBox) << "f\nQ\n";
1020 return sAP.AsStringC(); 1015 return sAP.MakeString();
1021 } 1016 }
1022 1017
1023 CFX_ByteString CPWL_Utils::GetAppStream_Star(const CFX_FloatRect& rcBBox, 1018 CFX_ByteString CPWL_Utils::GetAppStream_Star(const CFX_FloatRect& rcBBox,
1024 const CPWL_Color& crText) { 1019 const CPWL_Color& crText) {
1025 CFX_ByteTextBuf sAP; 1020 CFX_ByteTextBuf sAP;
1026 sAP << "q\n" << CPWL_Utils::GetColorAppStream(crText, TRUE) 1021 sAP << "q\n" << CPWL_Utils::GetColorAppStream(crText, TRUE)
1027 << CPWL_Utils::GetAP_Star(rcBBox) << "f\nQ\n"; 1022 << CPWL_Utils::GetAP_Star(rcBBox) << "f\nQ\n";
1028 return sAP.AsStringC(); 1023 return sAP.MakeString();
1029 } 1024 }
1030 1025
1031 CFX_ByteString CPWL_Utils::GetCheckBoxAppStream(const CFX_FloatRect& rcBBox, 1026 CFX_ByteString CPWL_Utils::GetCheckBoxAppStream(const CFX_FloatRect& rcBBox,
1032 int32_t nStyle, 1027 int32_t nStyle,
1033 const CPWL_Color& crText) { 1028 const CPWL_Color& crText) {
1034 CFX_FloatRect rcCenter = GetCenterSquare(rcBBox); 1029 CFX_FloatRect rcCenter = GetCenterSquare(rcBBox);
1035 switch (nStyle) { 1030 switch (nStyle) {
1036 default: 1031 default:
1037 case PCS_CHECK: 1032 case PCS_CHECK:
1038 return GetAppStream_Check(rcCenter, crText); 1033 return GetAppStream_Check(rcCenter, crText);
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
1097 sAppStream << "q\n" 1092 sAppStream << "q\n"
1098 << " 0 g\n"; 1093 << " 0 g\n";
1099 sAppStream << ptCenter.x - 3 << " " << ptCenter.y + 1.5f << " m\n"; 1094 sAppStream << ptCenter.x - 3 << " " << ptCenter.y + 1.5f << " m\n";
1100 sAppStream << ptCenter.x + 3 << " " << ptCenter.y + 1.5f << " l\n"; 1095 sAppStream << ptCenter.x + 3 << " " << ptCenter.y + 1.5f << " l\n";
1101 sAppStream << ptCenter.x << " " << ptCenter.y - 1.5f << " l\n"; 1096 sAppStream << ptCenter.x << " " << ptCenter.y - 1.5f << " l\n";
1102 sAppStream << ptCenter.x - 3 << " " << ptCenter.y + 1.5f << " l f\n"; 1097 sAppStream << ptCenter.x - 3 << " " << ptCenter.y + 1.5f << " l f\n";
1103 sAppStream << "Q\n"; 1098 sAppStream << "Q\n";
1104 } 1099 }
1105 } 1100 }
1106 1101
1107 return sAppStream.AsStringC(); 1102 return sAppStream.MakeString();
1108 } 1103 }
1109 1104
1110 void CPWL_Utils::ConvertCMYK2GRAY(FX_FLOAT dC, 1105 void CPWL_Utils::ConvertCMYK2GRAY(FX_FLOAT dC,
1111 FX_FLOAT dM, 1106 FX_FLOAT dM,
1112 FX_FLOAT dY, 1107 FX_FLOAT dY,
1113 FX_FLOAT dK, 1108 FX_FLOAT dK,
1114 FX_FLOAT& dGray) { 1109 FX_FLOAT& dGray) {
1115 if (dC < 0 || dC > 1 || dM < 0 || dM > 1 || dY < 0 || dY > 1 || dK < 0 || 1110 if (dC < 0 || dC > 1 || dM < 0 || dM > 1 || dY < 0 || dY > 1 || dK < 0 ||
1116 dK > 1) 1111 dK > 1)
1117 return; 1112 return;
(...skipping 2238 matching lines...) Expand 10 before | Expand all | Expand 10 after
3356 break; 3351 break;
3357 case COLORTYPE_RGB: 3352 case COLORTYPE_RGB:
3358 CPWL_Utils::ConvertCMYK2RGB(fColor1, fColor2, fColor3, fColor4, 3353 CPWL_Utils::ConvertCMYK2RGB(fColor1, fColor2, fColor3, fColor4,
3359 fColor1, fColor2, fColor3); 3354 fColor1, fColor2, fColor3);
3360 break; 3355 break;
3361 } 3356 }
3362 break; 3357 break;
3363 } 3358 }
3364 nColorType = other_nColorType; 3359 nColorType = other_nColorType;
3365 } 3360 }
OLDNEW
« no previous file with comments | « fpdfsdk/pdfwindow/PWL_Label.cpp ('k') | xfa/fwl/basewidget/fwl_editimp.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698