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

Side by Side Diff: fpdfsdk/fpdfformfill.cpp

Issue 2010813003: Remove default arguments from CFX_FxgeDevice. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@fxgeclean2_textrenderer
Patch Set: rebase Created 4 years, 6 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/fpdf_progressive.cpp ('k') | fpdfsdk/fpdfview.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 "public/fpdf_formfill.h" 7 #include "public/fpdf_formfill.h"
8 8
9 #include <memory> 9 #include <memory>
10 #include <vector> 10 #include <vector>
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 #ifdef PDF_ENABLE_XFA 48 #ifdef PDF_ENABLE_XFA
49 std::vector<CFX_ByteString>* FromFPDFStringHandle(FPDF_STRINGHANDLE handle) { 49 std::vector<CFX_ByteString>* FromFPDFStringHandle(FPDF_STRINGHANDLE handle) {
50 return reinterpret_cast<std::vector<CFX_ByteString>*>(handle); 50 return reinterpret_cast<std::vector<CFX_ByteString>*>(handle);
51 } 51 }
52 52
53 FPDF_STRINGHANDLE ToFPDFStringHandle(std::vector<CFX_ByteString>* strings) { 53 FPDF_STRINGHANDLE ToFPDFStringHandle(std::vector<CFX_ByteString>* strings) {
54 return reinterpret_cast<FPDF_STRINGHANDLE>(strings); 54 return reinterpret_cast<FPDF_STRINGHANDLE>(strings);
55 } 55 }
56 #endif // PDF_ENABLE_XFA 56 #endif // PDF_ENABLE_XFA
57 57
58 void FFLCommon(FPDF_FORMHANDLE hHandle,
59 FPDF_BITMAP bitmap,
60 FPDF_RECORDER recorder,
61 FPDF_PAGE page,
62 int start_x,
63 int start_y,
64 int size_x,
65 int size_y,
66 int rotate,
67 int flags) {
68 if (!hHandle)
69 return;
70
71 UnderlyingPageType* pPage = UnderlyingFromFPDFPage(page);
72 if (!pPage)
73 return;
74
75 #ifndef PDF_ENABLE_XFA
76 CPDF_RenderOptions options;
77 if (flags & FPDF_LCD_TEXT)
78 options.m_Flags |= RENDER_CLEARTYPE;
79 else
80 options.m_Flags &= ~RENDER_CLEARTYPE;
81 // Grayscale output
82 if (flags & FPDF_GRAYSCALE) {
83 options.m_ColorMode = RENDER_COLOR_GRAY;
84 options.m_ForeColor = 0;
85 options.m_BackColor = 0xffffff;
86 }
87 options.m_AddFlags = flags >> 8;
88 options.m_pOCContext =
89 new CPDF_OCContext(pPage->m_pDocument, CPDF_OCContext::View);
90 #else // PDF_ENABLE_XFA
91 CPDFXFA_Document* pDocument = pPage->GetDocument();
92 if (!pDocument)
93 return;
94 CPDF_Document* pPDFDoc = pDocument->GetPDFDoc();
95 if (!pPDFDoc)
96 return;
97 CPDFDoc_Environment* pEnv = (CPDFDoc_Environment*)hHandle;
98 CPDFSDK_Document* pFXDoc = pEnv->GetSDKDocument();
99 if (!pFXDoc)
100 return;
101 #endif // PDF_ENABLE_XFA
102
103 CFX_Matrix matrix;
104 pPage->GetDisplayMatrix(matrix, start_x, start_y, size_x, size_y, rotate);
105
106 FX_RECT clip(start_x, start_y, start_x + size_x, start_y + size_y);
107
108 std::unique_ptr<CFX_FxgeDevice> pDevice(new CFX_FxgeDevice);
109 #ifdef _SKIA_SUPPORT_
110 pDevice->AttachRecorder(static_cast<SkPictureRecorder*>(recorder));
111 #endif
112 pDevice->Attach(CFXBitmapFromFPDFBitmap(bitmap), false, nullptr, false);
113 pDevice->SaveState();
114 pDevice->SetClip_Rect(clip);
115
116 #ifndef PDF_ENABLE_XFA
117 if (CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, pPage))
118 pPageView->PageView_OnDraw(pDevice.get(), &matrix, &options);
119 #else // PDF_ENABLE_XFA
120 CPDF_RenderOptions options;
121 if (flags & FPDF_LCD_TEXT)
122 options.m_Flags |= RENDER_CLEARTYPE;
123 else
124 options.m_Flags &= ~RENDER_CLEARTYPE;
125
126 // Grayscale output
127 if (flags & FPDF_GRAYSCALE) {
128 options.m_ColorMode = RENDER_COLOR_GRAY;
129 options.m_ForeColor = 0;
130 options.m_BackColor = 0xffffff;
131 }
132 options.m_AddFlags = flags >> 8;
133 options.m_pOCContext = new CPDF_OCContext(pPDFDoc, CPDF_OCContext::View);
134
135 if (CPDFSDK_PageView* pPageView = pFXDoc->GetPageView(pPage))
136 pPageView->PageView_OnDraw(pDevice.get(), &matrix, &options, clip);
137 #endif // PDF_ENABLE_XFA
138
139 pDevice->RestoreState(false);
140 delete options.m_pOCContext;
141 #ifdef PDF_ENABLE_XFA
142 options.m_pOCContext = NULL;
143 #endif // PDF_ENABLE_XFA
144 }
145
58 } // namespace 146 } // namespace
59 147
60 DLLEXPORT int STDCALL FPDFPage_HasFormFieldAtPoint(FPDF_FORMHANDLE hHandle, 148 DLLEXPORT int STDCALL FPDFPage_HasFormFieldAtPoint(FPDF_FORMHANDLE hHandle,
61 FPDF_PAGE page, 149 FPDF_PAGE page,
62 double page_x, 150 double page_x,
63 double page_y) { 151 double page_y) {
64 if (!hHandle) 152 if (!hHandle)
65 return -1; 153 return -1;
66 CPDF_Page* pPage = CPDFPageFromFPDFPage(page); 154 CPDF_Page* pPage = CPDFPageFromFPDFPage(page);
67 if (pPage) { 155 if (pPage) {
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 } 374 }
287 375
288 DLLEXPORT FPDF_BOOL STDCALL FORM_ForceToKillFocus(FPDF_FORMHANDLE hHandle) { 376 DLLEXPORT FPDF_BOOL STDCALL FORM_ForceToKillFocus(FPDF_FORMHANDLE hHandle) {
289 CPDFSDK_Document* pSDKDoc = CPDFSDK_Document::FromFPDFFormHandle(hHandle); 377 CPDFSDK_Document* pSDKDoc = CPDFSDK_Document::FromFPDFFormHandle(hHandle);
290 if (!pSDKDoc) 378 if (!pSDKDoc)
291 return FALSE; 379 return FALSE;
292 380
293 return pSDKDoc->KillFocusAnnot(0); 381 return pSDKDoc->KillFocusAnnot(0);
294 } 382 }
295 383
296 static void FFLCommon(FPDF_FORMHANDLE hHandle,
297 FPDF_BITMAP bitmap,
298 FPDF_RECORDER recorder,
299 FPDF_PAGE page,
300 int start_x,
301 int start_y,
302 int size_x,
303 int size_y,
304 int rotate,
305 int flags) {
306 if (!hHandle)
307 return;
308
309 UnderlyingPageType* pPage = UnderlyingFromFPDFPage(page);
310 if (!pPage)
311 return;
312
313 #ifndef PDF_ENABLE_XFA
314 CPDF_RenderOptions options;
315 if (flags & FPDF_LCD_TEXT)
316 options.m_Flags |= RENDER_CLEARTYPE;
317 else
318 options.m_Flags &= ~RENDER_CLEARTYPE;
319 // Grayscale output
320 if (flags & FPDF_GRAYSCALE) {
321 options.m_ColorMode = RENDER_COLOR_GRAY;
322 options.m_ForeColor = 0;
323 options.m_BackColor = 0xffffff;
324 }
325 options.m_AddFlags = flags >> 8;
326 options.m_pOCContext =
327 new CPDF_OCContext(pPage->m_pDocument, CPDF_OCContext::View);
328 #else // PDF_ENABLE_XFA
329 CPDFXFA_Document* pDocument = pPage->GetDocument();
330 if (!pDocument)
331 return;
332 CPDF_Document* pPDFDoc = pDocument->GetPDFDoc();
333 if (!pPDFDoc)
334 return;
335 CPDFDoc_Environment* pEnv = (CPDFDoc_Environment*)hHandle;
336 CPDFSDK_Document* pFXDoc = pEnv->GetSDKDocument();
337 if (!pFXDoc)
338 return;
339 #endif // PDF_ENABLE_XFA
340
341 CFX_Matrix matrix;
342 pPage->GetDisplayMatrix(matrix, start_x, start_y, size_x, size_y, rotate);
343
344 FX_RECT clip(start_x, start_y, start_x + size_x, start_y + size_y);
345
346 std::unique_ptr<CFX_FxgeDevice> pDevice(new CFX_FxgeDevice);
347 #ifdef _SKIA_SUPPORT_
348 pDevice->AttachRecorder(static_cast<SkPictureRecorder*>(recorder));
349 #endif
350 pDevice->Attach((CFX_DIBitmap*)bitmap);
351 pDevice->SaveState();
352 pDevice->SetClip_Rect(clip);
353
354 #ifndef PDF_ENABLE_XFA
355 if (CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, pPage))
356 pPageView->PageView_OnDraw(pDevice.get(), &matrix, &options);
357 #else // PDF_ENABLE_XFA
358 CPDF_RenderOptions options;
359 if (flags & FPDF_LCD_TEXT)
360 options.m_Flags |= RENDER_CLEARTYPE;
361 else
362 options.m_Flags &= ~RENDER_CLEARTYPE;
363
364 // Grayscale output
365 if (flags & FPDF_GRAYSCALE) {
366 options.m_ColorMode = RENDER_COLOR_GRAY;
367 options.m_ForeColor = 0;
368 options.m_BackColor = 0xffffff;
369 }
370 options.m_AddFlags = flags >> 8;
371 options.m_pOCContext = new CPDF_OCContext(pPDFDoc, CPDF_OCContext::View);
372
373 if (CPDFSDK_PageView* pPageView = pFXDoc->GetPageView(pPage))
374 pPageView->PageView_OnDraw(pDevice.get(), &matrix, &options, clip);
375 #endif // PDF_ENABLE_XFA
376
377 pDevice->RestoreState(false);
378 delete options.m_pOCContext;
379 #ifdef PDF_ENABLE_XFA
380 options.m_pOCContext = NULL;
381 #endif // PDF_ENABLE_XFA
382 }
383
384 DLLEXPORT void STDCALL FPDF_FFLDraw(FPDF_FORMHANDLE hHandle, 384 DLLEXPORT void STDCALL FPDF_FFLDraw(FPDF_FORMHANDLE hHandle,
385 FPDF_BITMAP bitmap, 385 FPDF_BITMAP bitmap,
386 FPDF_PAGE page, 386 FPDF_PAGE page,
387 int start_x, 387 int start_x,
388 int start_y, 388 int start_y,
389 int size_x, 389 int size_x,
390 int size_y, 390 int size_y,
391 int rotate, 391 int rotate,
392 int flags) { 392 int flags) {
393 FFLCommon(hHandle, bitmap, nullptr, page, start_x, start_y, size_x, size_y, 393 FFLCommon(hHandle, bitmap, nullptr, page, start_x, start_y, size_x, size_y,
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document; 457 CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document;
458 if (pDocument->GetDocType() != XFA_DOCTYPE_Dynamic && 458 if (pDocument->GetDocType() != XFA_DOCTYPE_Dynamic &&
459 pDocument->GetDocType() != XFA_DOCTYPE_Static) 459 pDocument->GetDocType() != XFA_DOCTYPE_Static)
460 return; 460 return;
461 461
462 CFX_WideString wsCpText; 462 CFX_WideString wsCpText;
463 static_cast<CXFA_FFWidget*>(hWidget)->Copy(wsCpText); 463 static_cast<CXFA_FFWidget*>(hWidget)->Copy(wsCpText);
464 464
465 CFX_ByteString bsCpText = wsCpText.UTF16LE_Encode(); 465 CFX_ByteString bsCpText = wsCpText.UTF16LE_Encode();
466 uint32_t len = bsCpText.GetLength() / sizeof(unsigned short); 466 uint32_t len = bsCpText.GetLength() / sizeof(unsigned short);
467 if (wsText == NULL) { 467 if (!wsText) {
468 *size = len; 468 *size = len;
469 return; 469 return;
470 } 470 }
471 471
472 uint32_t real_size = len < *size ? len : *size; 472 uint32_t real_size = len < *size ? len : *size;
473 if (real_size > 0) { 473 if (real_size > 0) {
474 FXSYS_memcpy((void*)wsText, 474 FXSYS_memcpy((void*)wsText,
475 bsCpText.GetBuffer(real_size * sizeof(unsigned short)), 475 bsCpText.GetBuffer(real_size * sizeof(unsigned short)),
476 real_size * sizeof(unsigned short)); 476 real_size * sizeof(unsigned short));
477 bsCpText.ReleaseBuffer(real_size * sizeof(unsigned short)); 477 bsCpText.ReleaseBuffer(real_size * sizeof(unsigned short));
478 } 478 }
479 *size = real_size; 479 *size = real_size;
480 } 480 }
481 481
482 DLLEXPORT void STDCALL FPDF_Widget_Cut(FPDF_DOCUMENT document, 482 DLLEXPORT void STDCALL FPDF_Widget_Cut(FPDF_DOCUMENT document,
483 FPDF_WIDGET hWidget, 483 FPDF_WIDGET hWidget,
484 FPDF_WIDESTRING wsText, 484 FPDF_WIDESTRING wsText,
485 FPDF_DWORD* size) { 485 FPDF_DWORD* size) {
486 if (NULL == hWidget || NULL == document) 486 if (!hWidget || !document)
487 return; 487 return;
488
488 CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document; 489 CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document;
489 if (pDocument->GetDocType() != XFA_DOCTYPE_Dynamic && 490 if (pDocument->GetDocType() != XFA_DOCTYPE_Dynamic &&
490 pDocument->GetDocType() != XFA_DOCTYPE_Static) 491 pDocument->GetDocType() != XFA_DOCTYPE_Static)
491 return; 492 return;
492 493
493 CFX_WideString wsCpText; 494 CFX_WideString wsCpText;
494 static_cast<CXFA_FFWidget*>(hWidget)->Cut(wsCpText); 495 static_cast<CXFA_FFWidget*>(hWidget)->Cut(wsCpText);
495 496
496 CFX_ByteString bsCpText = wsCpText.UTF16LE_Encode(); 497 CFX_ByteString bsCpText = wsCpText.UTF16LE_Encode();
497 uint32_t len = bsCpText.GetLength() / sizeof(unsigned short); 498 uint32_t len = bsCpText.GetLength() / sizeof(unsigned short);
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
717 pActionHandler->DoAction_Page(action, CPDF_AAction::OpenPage, pSDKDoc); 718 pActionHandler->DoAction_Page(action, CPDF_AAction::OpenPage, pSDKDoc);
718 } 719 }
719 } else { 720 } else {
720 if (aa.ActionExist(CPDF_AAction::ClosePage)) { 721 if (aa.ActionExist(CPDF_AAction::ClosePage)) {
721 CPDF_Action action = aa.GetAction(CPDF_AAction::ClosePage); 722 CPDF_Action action = aa.GetAction(CPDF_AAction::ClosePage);
722 pActionHandler->DoAction_Page(action, CPDF_AAction::ClosePage, pSDKDoc); 723 pActionHandler->DoAction_Page(action, CPDF_AAction::ClosePage, pSDKDoc);
723 } 724 }
724 } 725 }
725 } 726 }
726 } 727 }
OLDNEW
« no previous file with comments | « fpdfsdk/fpdf_progressive.cpp ('k') | fpdfsdk/fpdfview.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698