From 221caf6f6f9810cbc0e0c4c50af9b036a052ae13 Mon Sep 17 00:00:00 2001 From: dsinclair Date: Mon, 4 Apr 2016 12:08:40 -0700 Subject: Cleanup the FF Handler proxy methods. This CL removes the proxy methods from CXFA_FFWidgetHandler and CXFA_DocHandler and removes CXFA_FFMenuHandler as it was only proxy methods. The calls are made directly on the object now. Review URL: https://codereview.chromium.org/1857893002 --- fpdfsdk/fpdfformfill.cpp | 76 ++++++++++++------------------------------------ 1 file changed, 18 insertions(+), 58 deletions(-) (limited to 'fpdfsdk/fpdfformfill.cpp') diff --git a/fpdfsdk/fpdfformfill.cpp b/fpdfsdk/fpdfformfill.cpp index ea36c78da4..26bc30e07c 100644 --- a/fpdfsdk/fpdfformfill.cpp +++ b/fpdfsdk/fpdfformfill.cpp @@ -24,6 +24,7 @@ #include "xfa/include/fxfa/xfa_ffapp.h" #include "xfa/include/fxfa/xfa_ffdocview.h" #include "xfa/include/fxfa/xfa_ffpageview.h" +#include "xfa/include/fxfa/xfa_ffwidget.h" #endif // PDF_ENABLE_XFA namespace { @@ -100,7 +101,7 @@ DLLEXPORT int STDCALL FPDFPage_HasFormFieldAtPoint(FPDF_FORMHANDLE hHandle, CXFA_FFWidget* pXFAAnnot = pWidgetIterator->MoveToNext(); while (pXFAAnnot) { CFX_RectF rcBBox; - pWidgetHandler->GetBBox(pXFAAnnot, rcBBox, 0); + pXFAAnnot->GetBBox(rcBBox, 0); CFX_FloatRect rcWidget(rcBBox.left, rcBBox.top, rcBBox.left + rcBBox.width, rcBBox.top + rcBBox.height); rcWidget.left -= 1.0f; @@ -412,7 +413,7 @@ DLLEXPORT void STDCALL FPDF_FFLRecord(FPDF_FORMHANDLE hHandle, #ifdef PDF_ENABLE_XFA DLLEXPORT void STDCALL FPDF_Widget_Undo(FPDF_DOCUMENT document, FPDF_WIDGET hWidget) { - if (NULL == hWidget || NULL == document) + if (!hWidget || !document) return; CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document; @@ -420,16 +421,11 @@ DLLEXPORT void STDCALL FPDF_Widget_Undo(FPDF_DOCUMENT document, pDocument->GetDocType() != XFA_DOCTYPE_Static) return; - CXFA_FFMenuHandler* pXFAMenuHander = - CPDFXFA_App::GetInstance()->GetXFAApp()->GetMenuHandler(); - if (pXFAMenuHander == NULL) - return; - - pXFAMenuHander->Undo((CXFA_FFWidget*)hWidget); + static_cast(hWidget)->Undo(); } DLLEXPORT void STDCALL FPDF_Widget_Redo(FPDF_DOCUMENT document, FPDF_WIDGET hWidget) { - if (NULL == hWidget || NULL == document) + if (!hWidget || !document) return; CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document; @@ -437,17 +433,12 @@ DLLEXPORT void STDCALL FPDF_Widget_Redo(FPDF_DOCUMENT document, pDocument->GetDocType() != XFA_DOCTYPE_Static) return; - CXFA_FFMenuHandler* pXFAMenuHander = - CPDFXFA_App::GetInstance()->GetXFAApp()->GetMenuHandler(); - if (pXFAMenuHander == NULL) - return; - - pXFAMenuHander->Redo((CXFA_FFWidget*)hWidget); + static_cast(hWidget)->Redo(); } DLLEXPORT void STDCALL FPDF_Widget_SelectAll(FPDF_DOCUMENT document, FPDF_WIDGET hWidget) { - if (NULL == hWidget || NULL == document) + if (!hWidget || !document) return; CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document; @@ -455,18 +446,13 @@ DLLEXPORT void STDCALL FPDF_Widget_SelectAll(FPDF_DOCUMENT document, pDocument->GetDocType() != XFA_DOCTYPE_Static) return; - CXFA_FFMenuHandler* pXFAMenuHander = - CPDFXFA_App::GetInstance()->GetXFAApp()->GetMenuHandler(); - if (pXFAMenuHander == NULL) - return; - - pXFAMenuHander->SelectAll((CXFA_FFWidget*)hWidget); + static_cast(hWidget)->SelectAll(); } DLLEXPORT void STDCALL FPDF_Widget_Copy(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; @@ -474,13 +460,8 @@ DLLEXPORT void STDCALL FPDF_Widget_Copy(FPDF_DOCUMENT document, pDocument->GetDocType() != XFA_DOCTYPE_Static) return; - CXFA_FFMenuHandler* pXFAMenuHander = - CPDFXFA_App::GetInstance()->GetXFAApp()->GetMenuHandler(); - if (pXFAMenuHander == NULL) - return; - CFX_WideString wsCpText; - pXFAMenuHander->Copy((CXFA_FFWidget*)hWidget, wsCpText); + static_cast(hWidget)->Copy(wsCpText); CFX_ByteString bsCpText = wsCpText.UTF16LE_Encode(); uint32_t len = bsCpText.GetLength() / sizeof(unsigned short); @@ -510,17 +491,12 @@ DLLEXPORT void STDCALL FPDF_Widget_Cut(FPDF_DOCUMENT document, pDocument->GetDocType() != XFA_DOCTYPE_Static) return; - CXFA_FFMenuHandler* pXFAMenuHander = - CPDFXFA_App::GetInstance()->GetXFAApp()->GetMenuHandler(); - if (pXFAMenuHander == NULL) - return; - CFX_WideString wsCpText; - pXFAMenuHander->Cut((CXFA_FFWidget*)hWidget, wsCpText); + static_cast(hWidget)->Cut(wsCpText); CFX_ByteString bsCpText = wsCpText.UTF16LE_Encode(); uint32_t len = bsCpText.GetLength() / sizeof(unsigned short); - if (wsText == NULL) { + if (!wsText) { *size = len; return; } @@ -539,7 +515,7 @@ DLLEXPORT void STDCALL FPDF_Widget_Paste(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; @@ -547,13 +523,8 @@ DLLEXPORT void STDCALL FPDF_Widget_Paste(FPDF_DOCUMENT document, pDocument->GetDocType() != XFA_DOCTYPE_Static) return; - CXFA_FFMenuHandler* pXFAMenuHander = - CPDFXFA_App::GetInstance()->GetXFAApp()->GetMenuHandler(); - if (pXFAMenuHander == NULL) - return; - CFX_WideString wstr = CFX_WideString::FromUTF16LE(wsText, size); - pXFAMenuHander->Paste((CXFA_FFWidget*)hWidget, wstr); + static_cast(hWidget)->Paste(wstr); } DLLEXPORT void STDCALL @@ -562,7 +533,7 @@ FPDF_Widget_ReplaceSpellCheckWord(FPDF_DOCUMENT document, float x, float y, FPDF_BYTESTRING bsText) { - if (NULL == hWidget || NULL == document) + if (!hWidget || !document) return; CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document; @@ -570,17 +541,11 @@ FPDF_Widget_ReplaceSpellCheckWord(FPDF_DOCUMENT document, pDocument->GetDocType() != XFA_DOCTYPE_Static) return; - CXFA_FFMenuHandler* pXFAMenuHander = - CPDFXFA_App::GetInstance()->GetXFAApp()->GetMenuHandler(); - if (pXFAMenuHander == NULL) - return; - CFX_PointF ptPopup; ptPopup.x = x; ptPopup.y = y; CFX_ByteStringC bs(bsText); - pXFAMenuHander->ReplaceSpellCheckWord( - reinterpret_cast(hWidget), ptPopup, bs); + static_cast(hWidget)->ReplaceSpellCheckWord(ptPopup, bs); } DLLEXPORT void STDCALL @@ -597,17 +562,12 @@ FPDF_Widget_GetSpellCheckWords(FPDF_DOCUMENT document, pDocument->GetDocType() != XFA_DOCTYPE_Static) return; - CXFA_FFMenuHandler* pXFAMenuHander = - CPDFXFA_App::GetInstance()->GetXFAApp()->GetMenuHandler(); - if (!pXFAMenuHander) - return; - std::vector* sSuggestWords = new std::vector; CFX_PointF ptPopup; ptPopup.x = x; ptPopup.y = y; - pXFAMenuHander->GetSuggestWords(reinterpret_cast(hWidget), - ptPopup, *sSuggestWords); + static_cast(hWidget) + ->GetSuggestWords(ptPopup, *sSuggestWords); *stringHandle = ToFPDFStringHandle(sSuggestWords); } -- cgit v1.2.3