summaryrefslogtreecommitdiff
path: root/fpdfsdk/fpdfformfill.cpp
diff options
context:
space:
mode:
authorthestig <thestig@chromium.org>2016-05-26 20:15:19 -0700
committerCommit bot <commit-bot@chromium.org>2016-05-26 20:15:19 -0700
commitbefa4506dc9d2a679c526aff96c09bcb0e9daecb (patch)
tree3c1d3e11d9802b2db95e35f4ab81ff449492ee10 /fpdfsdk/fpdfformfill.cpp
parent7aed76f53137a71491040c776ab2f8931e91061b (diff)
downloadpdfium-befa4506dc9d2a679c526aff96c09bcb0e9daecb.tar.xz
Remove default arguments from CFX_FxgeDevice.
Remove unused dithering code. Review-Url: https://codereview.chromium.org/2010813003
Diffstat (limited to 'fpdfsdk/fpdfformfill.cpp')
-rw-r--r--fpdfsdk/fpdfformfill.cpp181
1 files changed, 91 insertions, 90 deletions
diff --git a/fpdfsdk/fpdfformfill.cpp b/fpdfsdk/fpdfformfill.cpp
index 6bcb605794..2631eb3e4f 100644
--- a/fpdfsdk/fpdfformfill.cpp
+++ b/fpdfsdk/fpdfformfill.cpp
@@ -55,6 +55,94 @@ FPDF_STRINGHANDLE ToFPDFStringHandle(std::vector<CFX_ByteString>* strings) {
}
#endif // PDF_ENABLE_XFA
+void FFLCommon(FPDF_FORMHANDLE hHandle,
+ FPDF_BITMAP bitmap,
+ FPDF_RECORDER recorder,
+ FPDF_PAGE page,
+ int start_x,
+ int start_y,
+ int size_x,
+ int size_y,
+ int rotate,
+ int flags) {
+ if (!hHandle)
+ return;
+
+ UnderlyingPageType* pPage = UnderlyingFromFPDFPage(page);
+ if (!pPage)
+ return;
+
+#ifndef PDF_ENABLE_XFA
+ CPDF_RenderOptions options;
+ if (flags & FPDF_LCD_TEXT)
+ options.m_Flags |= RENDER_CLEARTYPE;
+ else
+ options.m_Flags &= ~RENDER_CLEARTYPE;
+ // Grayscale output
+ if (flags & FPDF_GRAYSCALE) {
+ options.m_ColorMode = RENDER_COLOR_GRAY;
+ options.m_ForeColor = 0;
+ options.m_BackColor = 0xffffff;
+ }
+ options.m_AddFlags = flags >> 8;
+ options.m_pOCContext =
+ new CPDF_OCContext(pPage->m_pDocument, CPDF_OCContext::View);
+#else // PDF_ENABLE_XFA
+ CPDFXFA_Document* pDocument = pPage->GetDocument();
+ if (!pDocument)
+ return;
+ CPDF_Document* pPDFDoc = pDocument->GetPDFDoc();
+ if (!pPDFDoc)
+ return;
+ CPDFDoc_Environment* pEnv = (CPDFDoc_Environment*)hHandle;
+ CPDFSDK_Document* pFXDoc = pEnv->GetSDKDocument();
+ if (!pFXDoc)
+ return;
+#endif // PDF_ENABLE_XFA
+
+ CFX_Matrix matrix;
+ pPage->GetDisplayMatrix(matrix, start_x, start_y, size_x, size_y, rotate);
+
+ FX_RECT clip(start_x, start_y, start_x + size_x, start_y + size_y);
+
+ std::unique_ptr<CFX_FxgeDevice> pDevice(new CFX_FxgeDevice);
+#ifdef _SKIA_SUPPORT_
+ pDevice->AttachRecorder(static_cast<SkPictureRecorder*>(recorder));
+#endif
+ pDevice->Attach(CFXBitmapFromFPDFBitmap(bitmap), false, nullptr, false);
+ pDevice->SaveState();
+ pDevice->SetClip_Rect(clip);
+
+#ifndef PDF_ENABLE_XFA
+ if (CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, pPage))
+ pPageView->PageView_OnDraw(pDevice.get(), &matrix, &options);
+#else // PDF_ENABLE_XFA
+ CPDF_RenderOptions options;
+ if (flags & FPDF_LCD_TEXT)
+ options.m_Flags |= RENDER_CLEARTYPE;
+ else
+ options.m_Flags &= ~RENDER_CLEARTYPE;
+
+ // Grayscale output
+ if (flags & FPDF_GRAYSCALE) {
+ options.m_ColorMode = RENDER_COLOR_GRAY;
+ options.m_ForeColor = 0;
+ options.m_BackColor = 0xffffff;
+ }
+ options.m_AddFlags = flags >> 8;
+ options.m_pOCContext = new CPDF_OCContext(pPDFDoc, CPDF_OCContext::View);
+
+ if (CPDFSDK_PageView* pPageView = pFXDoc->GetPageView(pPage))
+ pPageView->PageView_OnDraw(pDevice.get(), &matrix, &options, clip);
+#endif // PDF_ENABLE_XFA
+
+ pDevice->RestoreState(false);
+ delete options.m_pOCContext;
+#ifdef PDF_ENABLE_XFA
+ options.m_pOCContext = NULL;
+#endif // PDF_ENABLE_XFA
+}
+
} // namespace
DLLEXPORT int STDCALL FPDFPage_HasFormFieldAtPoint(FPDF_FORMHANDLE hHandle,
@@ -293,94 +381,6 @@ DLLEXPORT FPDF_BOOL STDCALL FORM_ForceToKillFocus(FPDF_FORMHANDLE hHandle) {
return pSDKDoc->KillFocusAnnot(0);
}
-static void FFLCommon(FPDF_FORMHANDLE hHandle,
- FPDF_BITMAP bitmap,
- FPDF_RECORDER recorder,
- FPDF_PAGE page,
- int start_x,
- int start_y,
- int size_x,
- int size_y,
- int rotate,
- int flags) {
- if (!hHandle)
- return;
-
- UnderlyingPageType* pPage = UnderlyingFromFPDFPage(page);
- if (!pPage)
- return;
-
-#ifndef PDF_ENABLE_XFA
- CPDF_RenderOptions options;
- if (flags & FPDF_LCD_TEXT)
- options.m_Flags |= RENDER_CLEARTYPE;
- else
- options.m_Flags &= ~RENDER_CLEARTYPE;
- // Grayscale output
- if (flags & FPDF_GRAYSCALE) {
- options.m_ColorMode = RENDER_COLOR_GRAY;
- options.m_ForeColor = 0;
- options.m_BackColor = 0xffffff;
- }
- options.m_AddFlags = flags >> 8;
- options.m_pOCContext =
- new CPDF_OCContext(pPage->m_pDocument, CPDF_OCContext::View);
-#else // PDF_ENABLE_XFA
- CPDFXFA_Document* pDocument = pPage->GetDocument();
- if (!pDocument)
- return;
- CPDF_Document* pPDFDoc = pDocument->GetPDFDoc();
- if (!pPDFDoc)
- return;
- CPDFDoc_Environment* pEnv = (CPDFDoc_Environment*)hHandle;
- CPDFSDK_Document* pFXDoc = pEnv->GetSDKDocument();
- if (!pFXDoc)
- return;
-#endif // PDF_ENABLE_XFA
-
- CFX_Matrix matrix;
- pPage->GetDisplayMatrix(matrix, start_x, start_y, size_x, size_y, rotate);
-
- FX_RECT clip(start_x, start_y, start_x + size_x, start_y + size_y);
-
- std::unique_ptr<CFX_FxgeDevice> pDevice(new CFX_FxgeDevice);
-#ifdef _SKIA_SUPPORT_
- pDevice->AttachRecorder(static_cast<SkPictureRecorder*>(recorder));
-#endif
- pDevice->Attach((CFX_DIBitmap*)bitmap);
- pDevice->SaveState();
- pDevice->SetClip_Rect(clip);
-
-#ifndef PDF_ENABLE_XFA
- if (CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, pPage))
- pPageView->PageView_OnDraw(pDevice.get(), &matrix, &options);
-#else // PDF_ENABLE_XFA
- CPDF_RenderOptions options;
- if (flags & FPDF_LCD_TEXT)
- options.m_Flags |= RENDER_CLEARTYPE;
- else
- options.m_Flags &= ~RENDER_CLEARTYPE;
-
- // Grayscale output
- if (flags & FPDF_GRAYSCALE) {
- options.m_ColorMode = RENDER_COLOR_GRAY;
- options.m_ForeColor = 0;
- options.m_BackColor = 0xffffff;
- }
- options.m_AddFlags = flags >> 8;
- options.m_pOCContext = new CPDF_OCContext(pPDFDoc, CPDF_OCContext::View);
-
- if (CPDFSDK_PageView* pPageView = pFXDoc->GetPageView(pPage))
- pPageView->PageView_OnDraw(pDevice.get(), &matrix, &options, clip);
-#endif // PDF_ENABLE_XFA
-
- pDevice->RestoreState(false);
- delete options.m_pOCContext;
-#ifdef PDF_ENABLE_XFA
- options.m_pOCContext = NULL;
-#endif // PDF_ENABLE_XFA
-}
-
DLLEXPORT void STDCALL FPDF_FFLDraw(FPDF_FORMHANDLE hHandle,
FPDF_BITMAP bitmap,
FPDF_PAGE page,
@@ -464,7 +464,7 @@ DLLEXPORT void STDCALL FPDF_Widget_Copy(FPDF_DOCUMENT document,
CFX_ByteString bsCpText = wsCpText.UTF16LE_Encode();
uint32_t len = bsCpText.GetLength() / sizeof(unsigned short);
- if (wsText == NULL) {
+ if (!wsText) {
*size = len;
return;
}
@@ -483,8 +483,9 @@ DLLEXPORT void STDCALL FPDF_Widget_Cut(FPDF_DOCUMENT document,
FPDF_WIDGET hWidget,
FPDF_WIDESTRING wsText,
FPDF_DWORD* size) {
- if (NULL == hWidget || NULL == document)
+ if (!hWidget || !document)
return;
+
CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document;
if (pDocument->GetDocType() != XFA_DOCTYPE_Dynamic &&
pDocument->GetDocType() != XFA_DOCTYPE_Static)