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 --- BUILD.gn | 2 +- fpdfsdk/fpdfformfill.cpp | 76 ++------- fpdfsdk/fpdfsave.cpp | 12 +- fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp | 108 ++++++------ fpdfsdk/fsdk_annothandler.cpp | 12 +- fpdfsdk/fsdk_baseform.cpp | 292 +++++++++++++++------------------ fpdfsdk/include/fpdfxfa/fpdfxfa_doc.h | 10 +- xfa.gyp | 2 +- xfa/fwl/basewidget/fwl_editimp.cpp | 2 +- xfa/fxfa/app/xfa_ffapp.cpp | 10 +- xfa/fxfa/app/xfa_ffbarcode.cpp | 2 +- xfa/fxfa/app/xfa_ffcheckbutton.cpp | 2 +- xfa/fxfa/app/xfa_ffchoicelist.cpp | 2 +- xfa/fxfa/app/xfa_ffdoc.cpp | 2 +- xfa/fxfa/app/xfa_ffdochandler.cpp | 89 ++-------- xfa/fxfa/app/xfa_ffdocview.cpp | 2 +- xfa/fxfa/app/xfa_ffdraw.cpp | 2 +- xfa/fxfa/app/xfa_ffdraw.h | 2 +- xfa/fxfa/app/xfa_ffexclgroup.cpp | 2 +- xfa/fxfa/app/xfa_ffexclgroup.h | 2 +- xfa/fxfa/app/xfa_fffield.cpp | 2 +- xfa/fxfa/app/xfa_fffield.h | 2 +- xfa/fxfa/app/xfa_ffimage.cpp | 2 +- xfa/fxfa/app/xfa_ffimageedit.cpp | 2 +- xfa/fxfa/app/xfa_ffnotify.cpp | 2 +- xfa/fxfa/app/xfa_ffpageview.cpp | 2 +- xfa/fxfa/app/xfa_ffpath.cpp | 2 +- xfa/fxfa/app/xfa_ffpushbutton.cpp | 2 +- xfa/fxfa/app/xfa_ffsignature.cpp | 2 +- xfa/fxfa/app/xfa_ffsubform.cpp | 2 +- xfa/fxfa/app/xfa_ffsubform.h | 2 +- xfa/fxfa/app/xfa_fftext.cpp | 2 +- xfa/fxfa/app/xfa_fftextedit.cpp | 2 +- xfa/fxfa/app/xfa_ffwidget.cpp | 2 +- xfa/fxfa/app/xfa_ffwidget.h | 185 --------------------- xfa/fxfa/app/xfa_ffwidgetacc.cpp | 2 +- xfa/fxfa/app/xfa_ffwidgethandler.cpp | 240 ++++++++++----------------- xfa/fxfa/app/xfa_fwltheme.cpp | 2 +- xfa/fxfa/app/xfa_rendercontext.cpp | 2 +- xfa/include/fxfa/xfa_ffapp.h | 3 - xfa/include/fxfa/xfa_ffdochandler.h | 24 +-- xfa/include/fxfa/xfa_ffwidget.h | 185 +++++++++++++++++++++ xfa/include/fxfa/xfa_ffwidgethandler.h | 48 +----- 43 files changed, 532 insertions(+), 820 deletions(-) delete mode 100644 xfa/fxfa/app/xfa_ffwidget.h create mode 100644 xfa/include/fxfa/xfa_ffwidget.h diff --git a/BUILD.gn b/BUILD.gn index 855206e071..f056e3b1dc 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -1426,7 +1426,6 @@ if (pdf_enable_xfa) { "xfa/fxfa/app/xfa_fftextedit.cpp", "xfa/fxfa/app/xfa_fftextedit.h", "xfa/fxfa/app/xfa_ffwidget.cpp", - "xfa/fxfa/app/xfa_ffwidget.h", "xfa/fxfa/app/xfa_ffwidgetacc.cpp", "xfa/fxfa/app/xfa_ffwidgetacc.h", "xfa/fxfa/app/xfa_ffwidgethandler.cpp", @@ -1534,6 +1533,7 @@ if (pdf_enable_xfa) { "xfa/include/fxfa/xfa_ffdochandler.h", "xfa/include/fxfa/xfa_ffdocview.h", "xfa/include/fxfa/xfa_ffpageview.h", + "xfa/include/fxfa/xfa_ffwidget.h", "xfa/include/fxfa/xfa_ffwidgethandler.h", "xfa/include/fxfa/xfa_fontmgr.h", "xfa/include/fxfa/xfa_rendercontext.h", 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); } diff --git a/fpdfsdk/fpdfsave.cpp b/fpdfsdk/fpdfsave.cpp index b9d393e505..11a22ac854 100644 --- a/fpdfsdk/fpdfsave.cpp +++ b/fpdfsdk/fpdfsave.cpp @@ -91,8 +91,6 @@ bool SaveXFADocumentData(CPDFXFA_Document* pDocument, if (!pXFADocView) return true; - CXFA_FFDocHandler* pXFADocHandler = - CPDFXFA_App::GetInstance()->GetXFAApp()->GetDocHandler(); CPDF_Document* pPDFDocument = pDocument->GetPDFDoc(); if (!pDocument) return false; @@ -177,9 +175,8 @@ bool SaveXFADocumentData(CPDFXFA_Document* pDocument, // L"datasets" { ScopedFileStream pDsfileWrite(FX_CreateMemoryStream()); - if (pXFADocHandler->SavePackage(pXFADocView->GetDoc(), - CFX_WideStringC(L"datasets"), - pDsfileWrite.get()) && + if (pXFADocView->GetDoc()->SavePackage(CFX_WideStringC(L"datasets"), + pDsfileWrite.get()) && pDsfileWrite->GetSize() > 0) { // Datasets pContext->UpdateChecksum(pDsfileWrite.get()); @@ -202,9 +199,8 @@ bool SaveXFADocumentData(CPDFXFA_Document* pDocument, // L"form" { ScopedFileStream pfileWrite(FX_CreateMemoryStream()); - if (pXFADocHandler->SavePackage(pXFADocView->GetDoc(), - CFX_WideStringC(L"form"), pfileWrite.get(), - pContext.get()) && + if (pXFADocView->GetDoc()->SavePackage(CFX_WideStringC(L"form"), + pfileWrite.get(), pContext.get()) && pfileWrite->GetSize() > 0) { CPDF_Dictionary* pDataDict = new CPDF_Dictionary; if (iFormIndex != -1) { diff --git a/fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp b/fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp index 11434ae947..79147b172e 100644 --- a/fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp +++ b/fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp @@ -20,6 +20,7 @@ #include "xfa/include/fxfa/xfa_ffdoc.h" #include "xfa/include/fxfa/xfa_ffdocview.h" #include "xfa/include/fxfa/xfa_ffpageview.h" +#include "xfa/include/fxfa/xfa_ffwidget.h" #define IDS_XFA_Validate_Input \ "At least one required field was empty. Please fill in the required " \ @@ -104,22 +105,22 @@ FX_BOOL CPDFXFA_Document::LoadXFADoc() { return FALSE; } - pDocHandler->StartLoad(m_pXFADoc); - int iStatus = pDocHandler->DoLoad(m_pXFADoc, NULL); + m_pXFADoc->StartLoad(); + int iStatus = m_pXFADoc->DoLoad(nullptr); if (iStatus != XFA_PARSESTATUS_Done) { CloseXFADoc(pDocHandler); SetLastError(FPDF_ERR_XFALOAD); return FALSE; } - pDocHandler->StopLoad(m_pXFADoc); - pDocHandler->SetJSERuntime(m_pXFADoc, m_pApp->GetJSERuntime()); + m_pXFADoc->StopLoad(); + m_pXFADoc->GetXFADoc()->InitScriptContext(m_pApp->GetJSERuntime()); - if (pDocHandler->GetDocType(m_pXFADoc) == XFA_DOCTYPE_Dynamic) + if (m_pXFADoc->GetDocType() == XFA_DOCTYPE_Dynamic) m_iDocType = DOCTYPE_DYNAMIC_XFA; else m_iDocType = DOCTYPE_STATIC_XFA; - m_pXFADocView = pDocHandler->CreateDocView(m_pXFADoc, XFA_DOCVIEW_View); + m_pXFADocView = m_pXFADoc->CreateDocView(XFA_DOCVIEW_View); if (m_pXFADocView->StartLayout() < 0) { CloseXFADoc(pDocHandler); SetLastError(FPDF_ERR_XFALAYOUT); @@ -275,12 +276,12 @@ void CPDFXFA_Document::InvalidateRect(CXFA_FFWidget* hWidget, if (!pWidgetHandler) return; - CXFA_FFPageView* pPageView = pWidgetHandler->GetPageView(hWidget); + CXFA_FFPageView* pPageView = hWidget->GetPageView(); if (!pPageView) return; CFX_RectF rect; - pWidgetHandler->GetRect(hWidget, rect); + hWidget->GetRect(rect); InvalidateRect(pPageView, rect, dwFlags); } @@ -300,7 +301,7 @@ void CPDFXFA_Document::DisplayCaret(CXFA_FFWidget* hWidget, if (!pWidgetHandler) return; - CXFA_FFPageView* pPageView = pWidgetHandler->GetPageView(hWidget); + CXFA_FFPageView* pPageView = hWidget->GetPageView(); if (!pPageView) return; @@ -325,28 +326,25 @@ FX_BOOL CPDFXFA_Document::GetPopupPos(CXFA_FFWidget* hWidget, FX_FLOAT fMaxPopup, const CFX_RectF& rtAnchor, CFX_RectF& rtPopup) { - if (NULL == hWidget) { + if (!hWidget) return FALSE; - } - CXFA_FFPageView* pXFAPageView = - m_pXFADocView->GetWidgetHandler()->GetPageView(hWidget); - if (NULL == pXFAPageView) { + + CXFA_FFPageView* pXFAPageView = hWidget->GetPageView(); + if (!pXFAPageView) return FALSE; - } + CPDFXFA_Page* pPage = GetPage(pXFAPageView); - if (pPage == NULL) + if (!pPage) return FALSE; - CXFA_WidgetAcc* pWidgetAcc = - m_pXFADocView->GetWidgetHandler()->GetDataAcc(hWidget); - + CXFA_WidgetAcc* pWidgetAcc = hWidget->GetDataAcc(); int nRotate = 0; #ifdef PDF_ENABLE_XFA nRotate = pWidgetAcc->GetRotate(); #endif CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); - if (pEnv == NULL) + if (!pEnv) return FALSE; FS_RECTF pageViewRect; pEnv->FFI_GetPageViewRect(pPage, pageViewRect); @@ -457,39 +455,34 @@ FX_BOOL CPDFXFA_Document::GetPopupPos(CXFA_FFWidget* hWidget, FX_BOOL CPDFXFA_Document::PopupMenu(CXFA_FFWidget* hWidget, CFX_PointF ptPopup, const CFX_RectF* pRectExclude) { - if (NULL == hWidget) { + if (!hWidget) return FALSE; - } - CXFA_FFPageView* pXFAPageView = - m_pXFADocView->GetWidgetHandler()->GetPageView(hWidget); - if (pXFAPageView == NULL) + + CXFA_FFPageView* pXFAPageView = hWidget->GetPageView(); + if (!pXFAPageView) return FALSE; - CPDFXFA_Page* pPage = GetPage(pXFAPageView); - if (pPage == NULL) + CPDFXFA_Page* pPage = GetPage(pXFAPageView); + if (!pPage) return FALSE; int menuFlag = 0; - CXFA_FFMenuHandler* pXFAMenuHander = m_pApp->GetXFAApp()->GetMenuHandler(); - if (pXFAMenuHander->CanUndo(hWidget)) + if (hWidget->CanUndo()) menuFlag |= FXFA_MEMU_UNDO; - if (pXFAMenuHander->CanRedo(hWidget)) + if (hWidget->CanRedo()) menuFlag |= FXFA_MEMU_REDO; - if (pXFAMenuHander->CanPaste(hWidget)) + if (hWidget->CanPaste()) menuFlag |= FXFA_MEMU_PASTE; - if (pXFAMenuHander->CanCopy(hWidget)) + if (hWidget->CanCopy()) menuFlag |= FXFA_MEMU_COPY; - if (pXFAMenuHander->CanCut(hWidget)) + if (hWidget->CanCut()) menuFlag |= FXFA_MEMU_CUT; - if (pXFAMenuHander->CanSelectAll(hWidget)) + if (hWidget->CanSelectAll()) menuFlag |= FXFA_MEMU_SELECTALL; CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); - if (pEnv == NULL) - return FALSE; - - return pEnv->FFI_PopupMenu(pPage, hWidget, menuFlag, ptPopup, NULL); + return pEnv && pEnv->FFI_PopupMenu(pPage, hWidget, menuFlag, ptPopup, NULL); } void CPDFXFA_Document::PageViewEvent(CXFA_FFPageView* pPageView, @@ -540,33 +533,30 @@ void CPDFXFA_Document::WidgetEvent(CXFA_FFWidget* hWidget, if (!pEnv) return; - CXFA_FFPageView* pPageView = - m_pXFADocView->GetWidgetHandler()->GetPageView(hWidget); - if (pPageView == NULL) + CXFA_FFPageView* pPageView = hWidget->GetPageView(); + if (!pPageView) return; CPDFXFA_Page* pXFAPage = GetPage(pPageView); - if (pXFAPage == NULL) + if (!pXFAPage) return; CPDFSDK_PageView* pSdkPageView = m_pSDKDoc->GetPageView(pXFAPage); if (dwEvent == XFA_WIDGETEVENT_PostAdded) { pSdkPageView->AddAnnot(hWidget); - } else if (dwEvent == XFA_WIDGETEVENT_PreRemoved) { CPDFSDK_Annot* pAnnot = pSdkPageView->GetAnnotByXFAWidget(hWidget); - if (pAnnot) { + if (pAnnot) pSdkPageView->DeleteAnnot(pAnnot); - } } } int32_t CPDFXFA_Document::CountPages(CXFA_FFDoc* hDoc) { - if (hDoc == m_pXFADoc && m_pSDKDoc) { + if (hDoc == m_pXFADoc && m_pSDKDoc) return GetPageCount(); - } return 0; } + int32_t CPDFXFA_Document::GetCurrentPage(CXFA_FFDoc* hDoc) { if (hDoc != m_pXFADoc || !m_pSDKDoc) return -1; @@ -574,11 +564,12 @@ int32_t CPDFXFA_Document::GetCurrentPage(CXFA_FFDoc* hDoc) { return -1; CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); - if (pEnv == NULL) + if (!pEnv) return -1; return pEnv->FFI_GetCurrentPageIndex(this); } + void CPDFXFA_Document::SetCurrentPage(CXFA_FFDoc* hDoc, int32_t iCurPage) { if (hDoc != m_pXFADoc || !m_pSDKDoc || m_iDocType != DOCTYPE_DYNAMIC_XFA || iCurPage < 0 || iCurPage >= m_pSDKDoc->GetPageCount()) { @@ -662,14 +653,13 @@ void CPDFXFA_Document::ExportData(CXFA_FFDoc* hDoc, CFPDF_FileStream fileWrite(pFileHandler); - CXFA_FFDocHandler* pXFADocHander = m_pApp->GetXFAApp()->GetDocHandler(); CFX_ByteString content; if (fileType == FXFA_SAVEAS_XML) { content = "\r\n"; fileWrite.WriteBlock((const FX_CHAR*)content, fileWrite.GetSize(), content.GetLength()); CFX_WideStringC data(L"data"); - if (pXFADocHander->SavePackage(m_pXFADocView->GetDoc(), data, &fileWrite)) { + if (m_pXFADocView->GetDoc()->SavePackage(data, &fileWrite)) { // Ignoring error. } } else if (fileType == FXFA_SAVEAS_XDP) { @@ -702,11 +692,10 @@ void CPDFXFA_Document::ExportData(CXFA_FFDoc* hDoc, continue; if (pPrePDFObj->GetString() == "form") { CFX_WideStringC form(L"form"); - pXFADocHander->SavePackage(m_pXFADocView->GetDoc(), form, &fileWrite); + m_pXFADocView->GetDoc()->SavePackage(form, &fileWrite); } else if (pPrePDFObj->GetString() == "datasets") { CFX_WideStringC datasets(L"datasets"); - pXFADocHander->SavePackage(m_pXFADocView->GetDoc(), datasets, - &fileWrite); + m_pXFADocView->GetDoc()->SavePackage(datasets, &fileWrite); } else { if (i == size - 1) { CFX_WideString wPath = CFX_WideString::FromUTF16LE( @@ -953,13 +942,12 @@ FX_BOOL CPDFXFA_Document::_ExportSubmitFile(FPDF_FILEHANDLER* pFileHandler, int fileType, FPDF_DWORD encodeType, FPDF_DWORD flag) { - if (NULL == m_pXFADocView) + if (!m_pXFADocView) return FALSE; - CXFA_FFDocHandler* pDocHandler = m_pApp->GetXFAApp()->GetDocHandler(); - CFX_ByteString content; + CFX_ByteString content; CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); - if (pEnv == NULL) + if (!pEnv) return FALSE; CFPDF_FileStream fileStream(pFileHandler); @@ -969,7 +957,7 @@ FX_BOOL CPDFXFA_Document::_ExportSubmitFile(FPDF_FILEHANDLER* pFileHandler, ws.FromLocal("data"); CFX_ByteString content = "\r\n"; fileStream.WriteBlock((const FX_CHAR*)content, 0, content.GetLength()); - pDocHandler->SavePackage(m_pXFADoc, ws, &fileStream); + m_pXFADoc->SavePackage(ws, &fileStream); } else if (fileType == FXFA_SAVEAS_XDP) { if (flag == 0) flag = FXFA_CONFIG | FXFA_TEMPLATE | FXFA_LOCALESET | FXFA_DATASETS | @@ -1030,11 +1018,11 @@ FX_BOOL CPDFXFA_Document::_ExportSubmitFile(FPDF_FILEHANDLER* pFileHandler, if (pPrePDFObj->GetString() == "form") { CFX_WideString ws; ws.FromLocal("form"); - pDocHandler->SavePackage(m_pXFADoc, ws, &fileStream); + m_pXFADoc->SavePackage(ws, &fileStream); } else if (pPrePDFObj->GetString() == "datasets") { CFX_WideString ws; ws.FromLocal("datasets"); - pDocHandler->SavePackage(m_pXFADoc, ws, &fileStream); + m_pXFADoc->SavePackage(ws, &fileStream); } else { // PDF,creator. } diff --git a/fpdfsdk/fsdk_annothandler.cpp b/fpdfsdk/fsdk_annothandler.cpp index b89a63696c..5afe8e493b 100644 --- a/fpdfsdk/fsdk_annothandler.cpp +++ b/fpdfsdk/fsdk_annothandler.cpp @@ -20,6 +20,7 @@ #include "fpdfsdk/include/fpdfxfa/fpdfxfa_page.h" #include "fpdfsdk/include/fpdfxfa/fpdfxfa_util.h" #include "xfa/fxgraphics/include/cfx_graphics.h" +#include "xfa/include/fxfa/xfa_ffwidget.h" #endif // PDF_ENABLE_XFA CPDFSDK_AnnotHandlerMgr::CPDFSDK_AnnotHandlerMgr(CPDFDoc_Environment* pApp) { @@ -785,15 +786,12 @@ CFX_FloatRect CPDFSDK_XFAAnnotHandler::GetViewBBox(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot) { ASSERT(pAnnot); - CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot); CFX_RectF rcBBox; - XFA_ELEMENT eType = - pWidgetHandler->GetDataAcc(pAnnot->GetXFAWidget())->GetUIType(); + XFA_ELEMENT eType = pAnnot->GetXFAWidget()->GetDataAcc()->GetUIType(); if (eType == XFA_ELEMENT_Signature) - pWidgetHandler->GetBBox(pAnnot->GetXFAWidget(), rcBBox, - XFA_WIDGETSTATUS_Visible, TRUE); + pAnnot->GetXFAWidget()->GetBBox(rcBBox, XFA_WIDGETSTATUS_Visible, TRUE); else - pWidgetHandler->GetBBox(pAnnot->GetXFAWidget(), rcBBox, 0); + pAnnot->GetXFAWidget()->GetBBox(rcBBox, 0); CFX_FloatRect rcWidget(rcBBox.left, rcBBox.top, rcBBox.left + rcBBox.width, rcBBox.top + rcBBox.height); @@ -1004,7 +1002,7 @@ FX_BOOL CPDFSDK_XFAAnnotHandler::OnXFAChangedFocus(CPDFSDK_Annot* pOldAnnot, FX_BOOL bRet = TRUE; CXFA_FFWidget* hWidget = pNewAnnot ? pNewAnnot->GetXFAWidget() : NULL; if (hWidget) { - CXFA_FFPageView* pXFAPageView = pWidgetHandler->GetPageView(hWidget); + CXFA_FFPageView* pXFAPageView = hWidget->GetPageView(); if (pXFAPageView) { bRet = pXFAPageView->GetDocView()->SetFocus(hWidget); if (pXFAPageView->GetDocView()->GetFocusWidget() == hWidget) diff --git a/fpdfsdk/fsdk_baseform.cpp b/fpdfsdk/fsdk_baseform.cpp index f22111ce73..be92b4a7e2 100644 --- a/fpdfsdk/fsdk_baseform.cpp +++ b/fpdfsdk/fsdk_baseform.cpp @@ -27,6 +27,7 @@ #ifdef PDF_ENABLE_XFA #include "fpdfsdk/include/fpdfxfa/fpdfxfa_doc.h" #include "fpdfsdk/include/fpdfxfa/fpdfxfa_util.h" +#include "xfa/include/fxfa/xfa_ffwidget.h" #endif // PDF_ENABLE_XFA #define IsFloatZero(f) ((f) < 0.01 && (f) > -0.01) @@ -189,14 +190,14 @@ FX_BOOL CPDFSDK_Widget::HasXFAAAction(PDFSDK_XFAAActionType eXFAAAT) { if ((eEventType == XFA_EVENT_Click || eEventType == XFA_EVENT_Change) && GetFieldType() == FIELDTYPE_RADIOBUTTON) { if (CXFA_FFWidget* hGroupWidget = GetGroupMixXFAWidget()) { - CXFA_WidgetAcc* pAcc = pXFAWidgetHandler->GetDataAcc(hGroupWidget); + CXFA_WidgetAcc* pAcc = hGroupWidget->GetDataAcc(); if (pXFAWidgetHandler->HasEvent(pAcc, eEventType)) return TRUE; } } { - CXFA_WidgetAcc* pAcc = pXFAWidgetHandler->GetDataAcc(hWidget); + CXFA_WidgetAcc* pAcc = hWidget->GetDataAcc(); return pXFAWidgetHandler->HasEvent(pAcc, eEventType); } } @@ -236,7 +237,7 @@ FX_BOOL CPDFSDK_Widget::OnXFAAAction(PDFSDK_XFAAActionType eXFAAAT, if ((eEventType == XFA_EVENT_Click || eEventType == XFA_EVENT_Change) && GetFieldType() == FIELDTYPE_RADIOBUTTON) { if (CXFA_FFWidget* hGroupWidget = GetGroupMixXFAWidget()) { - CXFA_WidgetAcc* pAcc = pXFAWidgetHandler->GetDataAcc(hGroupWidget); + CXFA_WidgetAcc* pAcc = hGroupWidget->GetDataAcc(); param.m_pTarget = pAcc; if (pXFAWidgetHandler->ProcessEvent(pAcc, ¶m) != XFA_EVENTERROR_Success) { @@ -244,7 +245,7 @@ FX_BOOL CPDFSDK_Widget::OnXFAAAction(PDFSDK_XFAAActionType eXFAAAT, } } } - CXFA_WidgetAcc* pAcc = pXFAWidgetHandler->GetDataAcc(hWidget); + CXFA_WidgetAcc* pAcc = hWidget->GetDataAcc(); param.m_pTarget = pAcc; int32_t nRet = pXFAWidgetHandler->ProcessEvent(pAcc, ¶m); @@ -261,48 +262,44 @@ FX_BOOL CPDFSDK_Widget::OnXFAAAction(PDFSDK_XFAAActionType eXFAAAT, void CPDFSDK_Widget::Synchronize(FX_BOOL bSynchronizeElse) { if (CXFA_FFWidget* hWidget = GetMixXFAWidget()) { - if (CXFA_FFWidgetHandler* pXFAWidgetHandler = GetXFAWidgetHandler()) { - CPDF_FormField* pFormField = GetFormField(); - if (CXFA_WidgetAcc* pWidgetAcc = pXFAWidgetHandler->GetDataAcc(hWidget)) { - switch (GetFieldType()) { - case FIELDTYPE_CHECKBOX: - case FIELDTYPE_RADIOBUTTON: { - CPDF_FormControl* pFormCtrl = GetFormControl(); - XFA_CHECKSTATE eCheckState = - pFormCtrl->IsChecked() ? XFA_CHECKSTATE_On : XFA_CHECKSTATE_Off; - pWidgetAcc->SetCheckState(eCheckState); - } break; - case FIELDTYPE_TEXTFIELD: - pWidgetAcc->SetValue(pFormField->GetValue(), XFA_VALUEPICTURE_Edit); - break; - case FIELDTYPE_LISTBOX: { - pWidgetAcc->ClearAllSelections(); - - for (int i = 0, sz = pFormField->CountSelectedItems(); i < sz; - i++) { - int nIndex = pFormField->GetSelectedIndex(i); - if (nIndex > -1 && nIndex < pWidgetAcc->CountChoiceListItems()) - pWidgetAcc->SetItemState(nIndex, TRUE, FALSE); - } - } break; - case FIELDTYPE_COMBOBOX: { - pWidgetAcc->ClearAllSelections(); - - for (int i = 0, sz = pFormField->CountSelectedItems(); i < sz; - i++) { - int nIndex = pFormField->GetSelectedIndex(i); - if (nIndex > -1 && nIndex < pWidgetAcc->CountChoiceListItems()) - pWidgetAcc->SetItemState(nIndex, TRUE, FALSE); - } + CPDF_FormField* pFormField = GetFormField(); + if (CXFA_WidgetAcc* pWidgetAcc = hWidget->GetDataAcc()) { + switch (GetFieldType()) { + case FIELDTYPE_CHECKBOX: + case FIELDTYPE_RADIOBUTTON: { + CPDF_FormControl* pFormCtrl = GetFormControl(); + XFA_CHECKSTATE eCheckState = + pFormCtrl->IsChecked() ? XFA_CHECKSTATE_On : XFA_CHECKSTATE_Off; + pWidgetAcc->SetCheckState(eCheckState); + } break; + case FIELDTYPE_TEXTFIELD: + pWidgetAcc->SetValue(pFormField->GetValue(), XFA_VALUEPICTURE_Edit); + break; + case FIELDTYPE_LISTBOX: { + pWidgetAcc->ClearAllSelections(); + + for (int i = 0, sz = pFormField->CountSelectedItems(); i < sz; i++) { + int nIndex = pFormField->GetSelectedIndex(i); + if (nIndex > -1 && nIndex < pWidgetAcc->CountChoiceListItems()) + pWidgetAcc->SetItemState(nIndex, TRUE, FALSE); } + } break; + case FIELDTYPE_COMBOBOX: { + pWidgetAcc->ClearAllSelections(); - pWidgetAcc->SetValue(pFormField->GetValue(), XFA_VALUEPICTURE_Edit); - break; + for (int i = 0, sz = pFormField->CountSelectedItems(); i < sz; i++) { + int nIndex = pFormField->GetSelectedIndex(i); + if (nIndex > -1 && nIndex < pWidgetAcc->CountChoiceListItems()) + pWidgetAcc->SetItemState(nIndex, TRUE, FALSE); + } } - if (bSynchronizeElse) - pWidgetAcc->ProcessValueChanged(); + pWidgetAcc->SetValue(pFormField->GetValue(), XFA_VALUEPICTURE_Edit); + break; } + + if (bSynchronizeElse) + pWidgetAcc->ProcessValueChanged(); } } } @@ -340,71 +337,62 @@ void CPDFSDK_Widget::SynchronizeXFAValue(CXFA_FFDocView* pXFADocView, CPDF_FormField* pFormField, CPDF_FormControl* pFormControl) { ASSERT(hWidget); + ASSERT(pFormControl); + + switch (pFormField->GetFieldType()) { + case FIELDTYPE_CHECKBOX: { + if (CXFA_WidgetAcc* pWidgetAcc = hWidget->GetDataAcc()) { + pFormField->CheckControl( + pFormField->GetControlIndex(pFormControl), + pWidgetAcc->GetCheckState() == XFA_CHECKSTATE_On, true); + } + } break; + case FIELDTYPE_RADIOBUTTON: { + // TODO(weili): Check whether we need to handle checkbox and radio + // button differently, otherwise, merge these two cases. + if (CXFA_WidgetAcc* pWidgetAcc = hWidget->GetDataAcc()) { + pFormField->CheckControl( + pFormField->GetControlIndex(pFormControl), + pWidgetAcc->GetCheckState() == XFA_CHECKSTATE_On, true); + } + } break; + case FIELDTYPE_TEXTFIELD: { + if (CXFA_WidgetAcc* pWidgetAcc = hWidget->GetDataAcc()) { + CFX_WideString sValue; + pWidgetAcc->GetValue(sValue, XFA_VALUEPICTURE_Display); + pFormField->SetValue(sValue, TRUE); + } + } break; + case FIELDTYPE_LISTBOX: { + pFormField->ClearSelection(FALSE); - if (CXFA_FFWidgetHandler* pXFAWidgetHandler = - pXFADocView->GetWidgetHandler()) { - ASSERT(pFormControl); - - switch (pFormField->GetFieldType()) { - case FIELDTYPE_CHECKBOX: { - if (CXFA_WidgetAcc* pWidgetAcc = - pXFAWidgetHandler->GetDataAcc(hWidget)) { - pFormField->CheckControl( - pFormField->GetControlIndex(pFormControl), - pWidgetAcc->GetCheckState() == XFA_CHECKSTATE_On, true); - } - } break; - case FIELDTYPE_RADIOBUTTON: { - // TODO(weili): Check whether we need to handle checkbox and radio - // button differently, otherwise, merge these two cases. - if (CXFA_WidgetAcc* pWidgetAcc = - pXFAWidgetHandler->GetDataAcc(hWidget)) { - pFormField->CheckControl( - pFormField->GetControlIndex(pFormControl), - pWidgetAcc->GetCheckState() == XFA_CHECKSTATE_On, true); - } - } break; - case FIELDTYPE_TEXTFIELD: { - if (CXFA_WidgetAcc* pWidgetAcc = - pXFAWidgetHandler->GetDataAcc(hWidget)) { - CFX_WideString sValue; - pWidgetAcc->GetValue(sValue, XFA_VALUEPICTURE_Display); - pFormField->SetValue(sValue, TRUE); - } - } break; - case FIELDTYPE_LISTBOX: { - pFormField->ClearSelection(FALSE); - - if (CXFA_WidgetAcc* pWidgetAcc = - pXFAWidgetHandler->GetDataAcc(hWidget)) { - for (int i = 0, sz = pWidgetAcc->CountSelectedItems(); i < sz; i++) { - int nIndex = pWidgetAcc->GetSelectedItem(i); + if (CXFA_WidgetAcc* pWidgetAcc = hWidget->GetDataAcc()) { + for (int i = 0, sz = pWidgetAcc->CountSelectedItems(); i < sz; i++) { + int nIndex = pWidgetAcc->GetSelectedItem(i); - if (nIndex > -1 && nIndex < pFormField->CountOptions()) { - pFormField->SetItemSelection(nIndex, TRUE, TRUE); - } + if (nIndex > -1 && nIndex < pFormField->CountOptions()) { + pFormField->SetItemSelection(nIndex, TRUE, TRUE); } } - } break; - case FIELDTYPE_COMBOBOX: { - pFormField->ClearSelection(FALSE); + } + } break; + case FIELDTYPE_COMBOBOX: { + pFormField->ClearSelection(FALSE); - if (CXFA_WidgetAcc* pWidgetAcc = - pXFAWidgetHandler->GetDataAcc(hWidget)) { - for (int i = 0, sz = pWidgetAcc->CountSelectedItems(); i < sz; i++) { - int nIndex = pWidgetAcc->GetSelectedItem(i); + if (CXFA_WidgetAcc* pWidgetAcc = hWidget->GetDataAcc()) { + for (int i = 0, sz = pWidgetAcc->CountSelectedItems(); i < sz; i++) { + int nIndex = pWidgetAcc->GetSelectedItem(i); - if (nIndex > -1 && nIndex < pFormField->CountOptions()) { - pFormField->SetItemSelection(nIndex, TRUE, TRUE); - } + if (nIndex > -1 && nIndex < pFormField->CountOptions()) { + pFormField->SetItemSelection(nIndex, TRUE, TRUE); } - - CFX_WideString sValue; - pWidgetAcc->GetValue(sValue, XFA_VALUEPICTURE_Display); - pFormField->SetValue(sValue, TRUE); } - } break; - } + + CFX_WideString sValue; + pWidgetAcc->GetValue(sValue, XFA_VALUEPICTURE_Display); + pFormField->SetValue(sValue, TRUE); + } + } break; } } @@ -414,42 +402,35 @@ void CPDFSDK_Widget::SynchronizeXFAItems(CXFA_FFDocView* pXFADocView, CPDF_FormControl* pFormControl) { ASSERT(hWidget); - if (CXFA_FFWidgetHandler* pXFAWidgetHandler = - pXFADocView->GetWidgetHandler()) { - switch (pFormField->GetFieldType()) { - case FIELDTYPE_LISTBOX: { - pFormField->ClearSelection(FALSE); - pFormField->ClearOptions(TRUE); - - if (CXFA_WidgetAcc* pWidgetAcc = - pXFAWidgetHandler->GetDataAcc(hWidget)) { - for (int i = 0, sz = pWidgetAcc->CountChoiceListItems(); i < sz; - i++) { - CFX_WideString swText; - pWidgetAcc->GetChoiceListItem(swText, i); - - pFormField->InsertOption(swText, i, TRUE); - } + switch (pFormField->GetFieldType()) { + case FIELDTYPE_LISTBOX: { + pFormField->ClearSelection(FALSE); + pFormField->ClearOptions(TRUE); + + if (CXFA_WidgetAcc* pWidgetAcc = hWidget->GetDataAcc()) { + for (int i = 0, sz = pWidgetAcc->CountChoiceListItems(); i < sz; i++) { + CFX_WideString swText; + pWidgetAcc->GetChoiceListItem(swText, i); + + pFormField->InsertOption(swText, i, TRUE); } - } break; - case FIELDTYPE_COMBOBOX: { - pFormField->ClearSelection(FALSE); - pFormField->ClearOptions(FALSE); - - if (CXFA_WidgetAcc* pWidgetAcc = - pXFAWidgetHandler->GetDataAcc(hWidget)) { - for (int i = 0, sz = pWidgetAcc->CountChoiceListItems(); i < sz; - i++) { - CFX_WideString swText; - pWidgetAcc->GetChoiceListItem(swText, i); - - pFormField->InsertOption(swText, i, FALSE); - } + } + } break; + case FIELDTYPE_COMBOBOX: { + pFormField->ClearSelection(FALSE); + pFormField->ClearOptions(FALSE); + + if (CXFA_WidgetAcc* pWidgetAcc = hWidget->GetDataAcc()) { + for (int i = 0, sz = pWidgetAcc->CountChoiceListItems(); i < sz; i++) { + CFX_WideString swText; + pWidgetAcc->GetChoiceListItem(swText, i); + + pFormField->InsertOption(swText, i, FALSE); } + } - pFormField->SetValue(L"", TRUE); - } break; - } + pFormField->SetValue(L"", TRUE); + } break; } } #endif // PDF_ENABLE_XFA @@ -595,11 +576,9 @@ FX_FLOAT CPDFSDK_Widget::GetFontSize() const { int CPDFSDK_Widget::GetSelectedIndex(int nIndex) const { #ifdef PDF_ENABLE_XFA if (CXFA_FFWidget* hWidget = GetMixXFAWidget()) { - if (CXFA_FFWidgetHandler* pXFAWidgetHandler = GetXFAWidgetHandler()) { - if (CXFA_WidgetAcc* pWidgetAcc = pXFAWidgetHandler->GetDataAcc(hWidget)) { - if (nIndex < pWidgetAcc->CountSelectedItems()) - return pWidgetAcc->GetSelectedItem(nIndex); - } + if (CXFA_WidgetAcc* pWidgetAcc = hWidget->GetDataAcc()) { + if (nIndex < pWidgetAcc->CountSelectedItems()) + return pWidgetAcc->GetSelectedItem(nIndex); } } #endif // PDF_ENABLE_XFA @@ -610,13 +589,11 @@ int CPDFSDK_Widget::GetSelectedIndex(int nIndex) const { #ifdef PDF_ENABLE_XFA CFX_WideString CPDFSDK_Widget::GetValue(FX_BOOL bDisplay) const { if (CXFA_FFWidget* hWidget = GetMixXFAWidget()) { - if (CXFA_FFWidgetHandler* pXFAWidgetHandler = GetXFAWidgetHandler()) { - if (CXFA_WidgetAcc* pWidgetAcc = pXFAWidgetHandler->GetDataAcc(hWidget)) { - CFX_WideString sValue; - pWidgetAcc->GetValue(sValue, bDisplay ? XFA_VALUEPICTURE_Display - : XFA_VALUEPICTURE_Edit); - return sValue; - } + if (CXFA_WidgetAcc* pWidgetAcc = hWidget->GetDataAcc()) { + CFX_WideString sValue; + pWidgetAcc->GetValue( + sValue, bDisplay ? XFA_VALUEPICTURE_Display : XFA_VALUEPICTURE_Edit); + return sValue; } } #else @@ -644,13 +621,11 @@ int CPDFSDK_Widget::CountOptions() const { FX_BOOL CPDFSDK_Widget::IsOptionSelected(int nIndex) const { #ifdef PDF_ENABLE_XFA if (CXFA_FFWidget* hWidget = GetMixXFAWidget()) { - if (CXFA_FFWidgetHandler* pXFAWidgetHandler = GetXFAWidgetHandler()) { - if (CXFA_WidgetAcc* pWidgetAcc = pXFAWidgetHandler->GetDataAcc(hWidget)) { - if (nIndex > -1 && nIndex < pWidgetAcc->CountChoiceListItems()) - return pWidgetAcc->GetItemState(nIndex); + if (CXFA_WidgetAcc* pWidgetAcc = hWidget->GetDataAcc()) { + if (nIndex > -1 && nIndex < pWidgetAcc->CountChoiceListItems()) + return pWidgetAcc->GetItemState(nIndex); - return FALSE; - } + return FALSE; } } #endif // PDF_ENABLE_XFA @@ -665,11 +640,9 @@ int CPDFSDK_Widget::GetTopVisibleIndex() const { bool CPDFSDK_Widget::IsChecked() const { #ifdef PDF_ENABLE_XFA - if (CXFA_FFWidgetHandler* pXFAWidgetHandler = GetXFAWidgetHandler()) { - if (CXFA_FFWidget* hWidget = GetMixXFAWidget()) { - if (CXFA_WidgetAcc* pWidgetAcc = pXFAWidgetHandler->GetDataAcc(hWidget)) - return pWidgetAcc->GetCheckState() == XFA_CHECKSTATE_On; - } + if (CXFA_FFWidget* hWidget = GetMixXFAWidget()) { + if (CXFA_WidgetAcc* pWidgetAcc = hWidget->GetDataAcc()) + return pWidgetAcc->GetCheckState() == XFA_CHECKSTATE_On; } #endif // PDF_ENABLE_XFA CPDF_FormControl* pFormCtrl = GetFormControl(); @@ -1900,7 +1873,7 @@ FX_BOOL CPDFSDK_Widget::OnAAction(CPDF_AAction::AActionType type, param.m_wsNewText.Insert(data.nSelStart, data.sChange[i]); param.m_wsPrevText = data.sValue; - CXFA_WidgetAcc* pAcc = pXFAWidgetHandler->GetDataAcc(hWidget); + CXFA_WidgetAcc* pAcc = hWidget->GetDataAcc(); param.m_pTarget = pAcc; int32_t nRet = pXFAWidgetHandler->ProcessEvent(pAcc, ¶m); @@ -2001,15 +1974,8 @@ CFX_ByteString CPDFSDK_XFAWidget::GetType() const { } CFX_FloatRect CPDFSDK_XFAWidget::GetRect() const { - CPDFSDK_PageView* pPageView = GetPageView(); - CPDFSDK_Document* pDocument = pPageView->GetSDKDocument(); - CPDFXFA_Document* pDoc = pDocument->GetXFADocument(); - CXFA_FFDocView* pDocView = pDoc->GetXFADocView(); - CXFA_FFWidgetHandler* pWidgetHandler = pDocView->GetWidgetHandler(); - CFX_RectF rcBBox; - pWidgetHandler->GetRect(GetXFAWidget(), rcBBox); - + GetXFAWidget()->GetRect(rcBBox); return CFX_FloatRect(rcBBox.left, rcBBox.top, rcBBox.left + rcBBox.width, rcBBox.top + rcBBox.height); } diff --git a/fpdfsdk/include/fpdfxfa/fpdfxfa_doc.h b/fpdfsdk/include/fpdfxfa/fpdfxfa_doc.h index 6d501317d6..dc09c8b656 100644 --- a/fpdfsdk/include/fpdfxfa/fpdfxfa_doc.h +++ b/fpdfsdk/include/fpdfxfa/fpdfxfa_doc.h @@ -11,6 +11,7 @@ #include "public/fpdfview.h" #include "xfa/include/fxfa/fxfa.h" +#include "xfa/include/fxfa/xfa_ffdoc.h" #include "xfa/include/fxfa/xfa_ffdochandler.h" class CPDFXFA_App; @@ -212,12 +213,13 @@ class CPDFXFA_Document : public IXFA_DocProvider { FXFA_LOADSTATUS_CLOSING, FXFA_LOADSTATUS_CLOSED }; + void CloseXFADoc(CXFA_FFDocHandler* pDoc) { if (pDoc) { - pDoc->CloseDoc(m_pXFADoc); - pDoc->ReleaseDoc(m_pXFADoc); - m_pXFADoc = NULL; - m_pXFADocView = NULL; + m_pXFADoc->CloseDoc(); + delete m_pXFADoc; + m_pXFADoc = nullptr; + m_pXFADocView = nullptr; } } diff --git a/xfa.gyp b/xfa.gyp index 49ff21a7ac..1d0c828151 100644 --- a/xfa.gyp +++ b/xfa.gyp @@ -45,6 +45,7 @@ "xfa/include/fxfa/xfa_ffdochandler.h", "xfa/include/fxfa/xfa_ffdocview.h", "xfa/include/fxfa/xfa_ffpageview.h", + "xfa/include/fxfa/xfa_ffwidget.h", "xfa/include/fxfa/xfa_ffwidgethandler.h", "xfa/include/fxfa/xfa_fontmgr.h", "xfa/include/fxfa/xfa_rendercontext.h", @@ -593,7 +594,6 @@ "xfa/fxfa/app/xfa_fftextedit.cpp", "xfa/fxfa/app/xfa_fftextedit.h", "xfa/fxfa/app/xfa_ffwidget.cpp", - "xfa/fxfa/app/xfa_ffwidget.h", "xfa/fxfa/app/xfa_ffwidgetacc.cpp", "xfa/fxfa/app/xfa_ffwidgetacc.h", "xfa/fxfa/app/xfa_ffwidgethandler.cpp", diff --git a/xfa/fwl/basewidget/fwl_editimp.cpp b/xfa/fwl/basewidget/fwl_editimp.cpp index 08e44f13dd..d5aa2c0507 100644 --- a/xfa/fwl/basewidget/fwl_editimp.cpp +++ b/xfa/fwl/basewidget/fwl_editimp.cpp @@ -27,9 +27,9 @@ #include "xfa/fwl/core/fwl_widgetimp.h" #include "xfa/fwl/core/fwl_widgetmgrimp.h" #include "xfa/fwl/core/ifwl_themeprovider.h" -#include "xfa/fxfa/app/xfa_ffwidget.h" #include "xfa/fxgraphics/cfx_path.h" #include "xfa/include/fxfa/xfa_ffdoc.h" +#include "xfa/include/fxfa/xfa_ffwidget.h" // static IFWL_Edit* IFWL_Edit::Create(const CFWL_WidgetImpProperties& properties, diff --git a/xfa/fxfa/app/xfa_ffapp.cpp b/xfa/fxfa/app/xfa_ffapp.cpp index 4d3d707998..f629e408c0 100644 --- a/xfa/fxfa/app/xfa_ffapp.cpp +++ b/xfa/fxfa/app/xfa_ffapp.cpp @@ -73,7 +73,6 @@ CXFA_FFApp::CXFA_FFApp(IXFA_AppProvider* pProvider) m_pAdapterWidgetMgr(nullptr), m_pWidgetMgrDelegate(nullptr), m_pFDEFontMgr(nullptr), - m_pMenuHandler(nullptr), m_pAdapterThreadMgr(nullptr) { m_pFWLApp = IFWL_App::Create(this); FWL_SetApp(m_pFWLApp); @@ -91,7 +90,7 @@ CXFA_FFApp::~CXFA_FFApp() { m_pFWLTheme->Release(); delete m_pAdapterWidgetMgr; delete m_pAdapterThreadMgr; - delete m_pMenuHandler; + CXFA_TimeZoneProvider::Destroy(); delete m_pFontMgr; #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ @@ -101,12 +100,7 @@ CXFA_FFApp::~CXFA_FFApp() { if (m_pFDEFontMgr) m_pFDEFontMgr->Release(); } -CXFA_FFMenuHandler* CXFA_FFApp::GetMenuHandler() { - if (!m_pMenuHandler) { - m_pMenuHandler = new CXFA_FFMenuHandler; - } - return m_pMenuHandler; -} + CXFA_FFDocHandler* CXFA_FFApp::GetDocHandler() { if (!m_pDocHandler) { m_pDocHandler = new CXFA_FFDocHandler; diff --git a/xfa/fxfa/app/xfa_ffbarcode.cpp b/xfa/fxfa/app/xfa_ffbarcode.cpp index 80def6c334..b7178f0baa 100644 --- a/xfa/fxfa/app/xfa_ffbarcode.cpp +++ b/xfa/fxfa/app/xfa_ffbarcode.cpp @@ -12,9 +12,9 @@ #include "xfa/fwl/lightwidget/cfwl_barcode.h" #include "xfa/fxfa/app/xfa_fffield.h" #include "xfa/fxfa/app/xfa_fftextedit.h" -#include "xfa/fxfa/app/xfa_ffwidget.h" #include "xfa/fxfa/app/xfa_fwladapter.h" #include "xfa/include/fxfa/xfa_ffpageview.h" +#include "xfa/include/fxfa/xfa_ffwidget.h" namespace { diff --git a/xfa/fxfa/app/xfa_ffcheckbutton.cpp b/xfa/fxfa/app/xfa_ffcheckbutton.cpp index 0e56ca612c..f741f2598e 100644 --- a/xfa/fxfa/app/xfa_ffcheckbutton.cpp +++ b/xfa/fxfa/app/xfa_ffcheckbutton.cpp @@ -12,11 +12,11 @@ #include "xfa/fwl/lightwidget/cfwl_checkbox.h" #include "xfa/fxfa/app/xfa_ffexclgroup.h" #include "xfa/fxfa/app/xfa_fffield.h" -#include "xfa/fxfa/app/xfa_ffwidget.h" #include "xfa/include/fxfa/xfa_ffapp.h" #include "xfa/include/fxfa/xfa_ffdoc.h" #include "xfa/include/fxfa/xfa_ffdocview.h" #include "xfa/include/fxfa/xfa_ffpageview.h" +#include "xfa/include/fxfa/xfa_ffwidget.h" CXFA_FFCheckButton::CXFA_FFCheckButton(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc) diff --git a/xfa/fxfa/app/xfa_ffchoicelist.cpp b/xfa/fxfa/app/xfa_ffchoicelist.cpp index bba1a7ec64..44ae14264d 100644 --- a/xfa/fxfa/app/xfa_ffchoicelist.cpp +++ b/xfa/fxfa/app/xfa_ffchoicelist.cpp @@ -12,11 +12,11 @@ #include "xfa/fwl/lightwidget/cfwl_combobox.h" #include "xfa/fwl/lightwidget/cfwl_listbox.h" #include "xfa/fxfa/app/xfa_fffield.h" -#include "xfa/fxfa/app/xfa_ffwidget.h" #include "xfa/fxfa/app/xfa_fwladapter.h" #include "xfa/include/fxfa/xfa_ffdoc.h" #include "xfa/include/fxfa/xfa_ffdocview.h" #include "xfa/include/fxfa/xfa_ffpageview.h" +#include "xfa/include/fxfa/xfa_ffwidget.h" CXFA_FFListBox::CXFA_FFListBox(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc) diff --git a/xfa/fxfa/app/xfa_ffdoc.cpp b/xfa/fxfa/app/xfa_ffdoc.cpp index ed4f94cd77..ce27428b40 100644 --- a/xfa/fxfa/app/xfa_ffdoc.cpp +++ b/xfa/fxfa/app/xfa_ffdoc.cpp @@ -15,7 +15,6 @@ #include "xfa/fgas/crt/fgas_algorithm.h" #include "xfa/fwl/core/ifwl_notedriver.h" #include "xfa/fxfa/app/xfa_ffnotify.h" -#include "xfa/fxfa/app/xfa_ffwidget.h" #include "xfa/fxfa/parser/xfa_docdata.h" #include "xfa/fxfa/parser/xfa_document_serialize.h" #include "xfa/fxfa/parser/xfa_parser.h" @@ -24,6 +23,7 @@ #include "xfa/include/fxfa/xfa_checksum.h" #include "xfa/include/fxfa/xfa_ffapp.h" #include "xfa/include/fxfa/xfa_ffdocview.h" +#include "xfa/include/fxfa/xfa_ffwidget.h" #include "xfa/include/fxfa/xfa_fontmgr.h" CXFA_FFDoc::CXFA_FFDoc(CXFA_FFApp* pApp, IXFA_DocProvider* pDocProvider) diff --git a/xfa/fxfa/app/xfa_ffdochandler.cpp b/xfa/fxfa/app/xfa_ffdochandler.cpp index 949dae4a8b..6aed551fdb 100644 --- a/xfa/fxfa/app/xfa_ffdochandler.cpp +++ b/xfa/fxfa/app/xfa_ffdochandler.cpp @@ -15,100 +15,47 @@ CXFA_FFDocHandler::CXFA_FFDocHandler() {} CXFA_FFDocHandler::~CXFA_FFDocHandler() {} -void CXFA_FFDocHandler::ReleaseDoc(CXFA_FFDoc* hDoc) { - delete hDoc; // virtual dtor. -} -IXFA_DocProvider* CXFA_FFDocHandler::GetDocProvider(CXFA_FFDoc* hDoc) { - return hDoc->GetDocProvider(); -} -uint32_t CXFA_FFDocHandler::GetDocType(CXFA_FFDoc* hDoc) { - return hDoc->GetDocType(); -} -int32_t CXFA_FFDocHandler::StartLoad(CXFA_FFDoc* hDoc) { - return hDoc->StartLoad(); -} -int32_t CXFA_FFDocHandler::DoLoad(CXFA_FFDoc* hDoc, IFX_Pause* pPause) { - return hDoc->DoLoad(pPause); -} -void CXFA_FFDocHandler::StopLoad(CXFA_FFDoc* hDoc) { - hDoc->StopLoad(); -} - -CXFA_FFDocView* CXFA_FFDocHandler::CreateDocView(CXFA_FFDoc* hDoc, - uint32_t dwView) { - return hDoc->CreateDocView(dwView); -} -int32_t CXFA_FFDocHandler::CountPackages(CXFA_FFDoc* hDoc) { - return 0; -} -void CXFA_FFDocHandler::GetPackageName(CXFA_FFDoc* hDoc, - int32_t iPackage, - CFX_WideStringC& wsPackage) {} -CFDE_XMLElement* CXFA_FFDocHandler::GetPackageData( - CXFA_FFDoc* hDoc, - const CFX_WideStringC& wsPackage) { - return hDoc->GetPackageData(wsPackage); -} -FX_BOOL CXFA_FFDocHandler::SavePackage(CXFA_FFDoc* hDoc, - const CFX_WideStringC& wsPackage, - IFX_FileWrite* pFile, - CXFA_ChecksumContext* pCSContext) { - return hDoc->SavePackage(wsPackage, pFile, pCSContext); -} -FX_BOOL CXFA_FFDocHandler::CloseDoc(CXFA_FFDoc* hDoc) { - return hDoc->CloseDoc(); -} - -FX_BOOL CXFA_FFDocHandler::ImportData(CXFA_FFDoc* hDoc, - IFX_FileRead* pStream, - FX_BOOL bXDP) { - return hDoc->ImportData(pStream, bXDP); -} -void CXFA_FFDocHandler::SetJSERuntime(CXFA_FFDoc* hDoc, - FXJSE_HRUNTIME hRuntime) { - hDoc->GetXFADoc()->InitScriptContext(hRuntime); -} FXJSE_HVALUE CXFA_FFDocHandler::GetXFAScriptObject(CXFA_FFDoc* hDoc) { CXFA_Document* pXFADoc = hDoc->GetXFADoc(); - if (!pXFADoc) { - return NULL; - } + if (!pXFADoc) + return nullptr; + CXFA_ScriptContext* pScriptContext = pXFADoc->GetScriptContext(); - if (!pScriptContext) { - return NULL; - } + if (!pScriptContext) + return nullptr; return pScriptContext->GetJSValueFromMap(pXFADoc->GetRoot()); } + XFA_ATTRIBUTEENUM CXFA_FFDocHandler::GetRestoreState(CXFA_FFDoc* hDoc) { CXFA_Document* pXFADoc = hDoc->GetXFADoc(); - if (!pXFADoc) { + if (!pXFADoc) return XFA_ATTRIBUTEENUM_Unknown; - } + CXFA_Node* pForm = ToNode(pXFADoc->GetXFAObject(XFA_HASHCODE_Form)); - if (!pForm) { + if (!pForm) return XFA_ATTRIBUTEENUM_Unknown; - } + CXFA_Node* pSubForm = pForm->GetFirstChildByClass(XFA_ELEMENT_Subform); - if (!pSubForm) { + if (!pSubForm) return XFA_ATTRIBUTEENUM_Unknown; - } return pSubForm->GetEnum(XFA_ATTRIBUTE_RestoreState); } + FX_BOOL CXFA_FFDocHandler::RunDocScript(CXFA_FFDoc* hDoc, XFA_SCRIPTTYPE eScriptType, const CFX_WideStringC& wsScript, FXJSE_HVALUE hRetValue, FXJSE_HVALUE hThisObject) { CXFA_Document* pXFADoc = hDoc->GetXFADoc(); - if (!pXFADoc) { + if (!pXFADoc) return FALSE; - } + CXFA_ScriptContext* pScriptContext = pXFADoc->GetScriptContext(); - if (!pScriptContext) { + if (!pScriptContext) return FALSE; - } + return pScriptContext->RunScript( (XFA_SCRIPTLANGTYPE)eScriptType, wsScript, hRetValue, - hThisObject ? (CXFA_Object*)FXJSE_Value_ToObject(hThisObject, NULL) - : NULL); + hThisObject ? (CXFA_Object*)FXJSE_Value_ToObject(hThisObject, nullptr) + : nullptr); } diff --git a/xfa/fxfa/app/xfa_ffdocview.cpp b/xfa/fxfa/app/xfa_ffdocview.cpp index 907e2b5d22..5e8813542d 100644 --- a/xfa/fxfa/app/xfa_ffdocview.cpp +++ b/xfa/fxfa/app/xfa_ffdocview.cpp @@ -21,7 +21,6 @@ #include "xfa/fxfa/app/xfa_ffsubform.h" #include "xfa/fxfa/app/xfa_fftext.h" #include "xfa/fxfa/app/xfa_fftextedit.h" -#include "xfa/fxfa/app/xfa_ffwidget.h" #include "xfa/fxfa/app/xfa_ffwidgetacc.h" #include "xfa/fxfa/app/xfa_fwladapter.h" #include "xfa/fxfa/app/xfa_textlayout.h" @@ -31,6 +30,7 @@ #include "xfa/include/fxfa/xfa_ffapp.h" #include "xfa/include/fxfa/xfa_ffdoc.h" #include "xfa/include/fxfa/xfa_ffpageview.h" +#include "xfa/include/fxfa/xfa_ffwidget.h" #include "xfa/include/fxfa/xfa_ffwidgethandler.h" extern const XFA_ATTRIBUTEENUM gs_EventActivity[] = { diff --git a/xfa/fxfa/app/xfa_ffdraw.cpp b/xfa/fxfa/app/xfa_ffdraw.cpp index 06fc85b893..68c1d96f4a 100644 --- a/xfa/fxfa/app/xfa_ffdraw.cpp +++ b/xfa/fxfa/app/xfa_ffdraw.cpp @@ -6,10 +6,10 @@ #include "xfa/fxfa/app/xfa_ffdraw.h" -#include "xfa/fxfa/app/xfa_ffwidget.h" #include "xfa/include/fxfa/xfa_ffapp.h" #include "xfa/include/fxfa/xfa_ffdoc.h" #include "xfa/include/fxfa/xfa_ffpageview.h" +#include "xfa/include/fxfa/xfa_ffwidget.h" CXFA_FFDraw::CXFA_FFDraw(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc) : CXFA_FFWidget(pPageView, pDataAcc) {} diff --git a/xfa/fxfa/app/xfa_ffdraw.h b/xfa/fxfa/app/xfa_ffdraw.h index fb2d11e1f6..52ceb2cd0c 100644 --- a/xfa/fxfa/app/xfa_ffdraw.h +++ b/xfa/fxfa/app/xfa_ffdraw.h @@ -7,8 +7,8 @@ #ifndef XFA_FXFA_APP_XFA_FFDRAW_H_ #define XFA_FXFA_APP_XFA_FFDRAW_H_ -#include "xfa/fxfa/app/xfa_ffwidget.h" #include "xfa/include/fxfa/xfa_ffpageview.h" +#include "xfa/include/fxfa/xfa_ffwidget.h" class CXFA_FFDraw : public CXFA_FFWidget { public: diff --git a/xfa/fxfa/app/xfa_ffexclgroup.cpp b/xfa/fxfa/app/xfa_ffexclgroup.cpp index 47cc455962..177738d636 100644 --- a/xfa/fxfa/app/xfa_ffexclgroup.cpp +++ b/xfa/fxfa/app/xfa_ffexclgroup.cpp @@ -6,10 +6,10 @@ #include "xfa/fxfa/app/xfa_ffexclgroup.h" -#include "xfa/fxfa/app/xfa_ffwidget.h" #include "xfa/include/fxfa/xfa_ffapp.h" #include "xfa/include/fxfa/xfa_ffdoc.h" #include "xfa/include/fxfa/xfa_ffpageview.h" +#include "xfa/include/fxfa/xfa_ffwidget.h" CXFA_FFExclGroup::CXFA_FFExclGroup(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc) diff --git a/xfa/fxfa/app/xfa_ffexclgroup.h b/xfa/fxfa/app/xfa_ffexclgroup.h index e492cf1817..5a1fc945b7 100644 --- a/xfa/fxfa/app/xfa_ffexclgroup.h +++ b/xfa/fxfa/app/xfa_ffexclgroup.h @@ -7,8 +7,8 @@ #ifndef XFA_FXFA_APP_XFA_FFEXCLGROUP_H_ #define XFA_FXFA_APP_XFA_FFEXCLGROUP_H_ -#include "xfa/fxfa/app/xfa_ffwidget.h" #include "xfa/include/fxfa/xfa_ffpageview.h" +#include "xfa/include/fxfa/xfa_ffwidget.h" class CXFA_FFExclGroup : public CXFA_FFWidget { public: diff --git a/xfa/fxfa/app/xfa_fffield.cpp b/xfa/fxfa/app/xfa_fffield.cpp index 90bb5f39e5..a0f64e9bb0 100644 --- a/xfa/fxfa/app/xfa_fffield.cpp +++ b/xfa/fxfa/app/xfa_fffield.cpp @@ -11,7 +11,6 @@ #include "xfa/fwl/core/ifwl_widgetmgrdelegate.h" #include "xfa/fwl/lightwidget/cfwl_edit.h" #include "xfa/fwl/lightwidget/cfwl_picturebox.h" -#include "xfa/fxfa/app/xfa_ffwidget.h" #include "xfa/fxfa/app/xfa_fwltheme.h" #include "xfa/fxfa/app/xfa_textlayout.h" #include "xfa/fxgraphics/cfx_color.h" @@ -20,6 +19,7 @@ #include "xfa/include/fxfa/xfa_ffdoc.h" #include "xfa/include/fxfa/xfa_ffdocview.h" #include "xfa/include/fxfa/xfa_ffpageview.h" +#include "xfa/include/fxfa/xfa_ffwidget.h" CXFA_FFField::CXFA_FFField(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc) : CXFA_FFWidget(pPageView, pDataAcc), m_pNormalWidget(NULL) { diff --git a/xfa/fxfa/app/xfa_fffield.h b/xfa/fxfa/app/xfa_fffield.h index 51fe56be09..44ee9bb4f2 100644 --- a/xfa/fxfa/app/xfa_fffield.h +++ b/xfa/fxfa/app/xfa_fffield.h @@ -10,8 +10,8 @@ #include "xfa/fwl/core/fwl_sdadapterimp.h" #include "xfa/fwl/core/ifwl_widgetdelegate.h" #include "xfa/fwl/lightwidget/cfwl_widget.h" -#include "xfa/fxfa/app/xfa_ffwidget.h" #include "xfa/include/fxfa/xfa_ffpageview.h" +#include "xfa/include/fxfa/xfa_ffwidget.h" #define XFA_MINUI_HEIGHT 4.32f #define XFA_DEFAULTUI_HEIGHT 2.0f diff --git a/xfa/fxfa/app/xfa_ffimage.cpp b/xfa/fxfa/app/xfa_ffimage.cpp index f7f6ebbf1b..5c28682978 100644 --- a/xfa/fxfa/app/xfa_ffimage.cpp +++ b/xfa/fxfa/app/xfa_ffimage.cpp @@ -7,10 +7,10 @@ #include "xfa/fxfa/app/xfa_ffimage.h" #include "xfa/fxfa/app/xfa_ffdraw.h" -#include "xfa/fxfa/app/xfa_ffwidget.h" #include "xfa/include/fxfa/xfa_ffapp.h" #include "xfa/include/fxfa/xfa_ffdoc.h" #include "xfa/include/fxfa/xfa_ffpageview.h" +#include "xfa/include/fxfa/xfa_ffwidget.h" CXFA_FFImage::CXFA_FFImage(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc) : CXFA_FFDraw(pPageView, pDataAcc) {} diff --git a/xfa/fxfa/app/xfa_ffimageedit.cpp b/xfa/fxfa/app/xfa_ffimageedit.cpp index ba16d4d352..ce69b1242b 100644 --- a/xfa/fxfa/app/xfa_ffimageedit.cpp +++ b/xfa/fxfa/app/xfa_ffimageedit.cpp @@ -11,10 +11,10 @@ #include "xfa/fwl/core/ifwl_notedriver.h" #include "xfa/fwl/lightwidget/cfwl_picturebox.h" #include "xfa/fxfa/app/xfa_fffield.h" -#include "xfa/fxfa/app/xfa_ffwidget.h" #include "xfa/include/fxfa/xfa_ffdoc.h" #include "xfa/include/fxfa/xfa_ffdocview.h" #include "xfa/include/fxfa/xfa_ffpageview.h" +#include "xfa/include/fxfa/xfa_ffwidget.h" CXFA_FFImageEdit::CXFA_FFImageEdit(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc) diff --git a/xfa/fxfa/app/xfa_ffnotify.cpp b/xfa/fxfa/app/xfa_ffnotify.cpp index 7cb9f40b63..7851819474 100644 --- a/xfa/fxfa/app/xfa_ffnotify.cpp +++ b/xfa/fxfa/app/xfa_ffnotify.cpp @@ -20,7 +20,6 @@ #include "xfa/fxfa/app/xfa_ffsubform.h" #include "xfa/fxfa/app/xfa_fftext.h" #include "xfa/fxfa/app/xfa_fftextedit.h" -#include "xfa/fxfa/app/xfa_ffwidget.h" #include "xfa/fxfa/app/xfa_ffwidgetacc.h" #include "xfa/fxfa/app/xfa_fwladapter.h" #include "xfa/fxfa/app/xfa_textlayout.h" @@ -28,6 +27,7 @@ #include "xfa/include/fxfa/xfa_ffdoc.h" #include "xfa/include/fxfa/xfa_ffdocview.h" #include "xfa/include/fxfa/xfa_ffpageview.h" +#include "xfa/include/fxfa/xfa_ffwidget.h" #include "xfa/include/fxfa/xfa_ffwidgethandler.h" static void XFA_FFDeleteWidgetAcc(void* pData) { diff --git a/xfa/fxfa/app/xfa_ffpageview.cpp b/xfa/fxfa/app/xfa_ffpageview.cpp index 584832ed2c..e22ddc0394 100644 --- a/xfa/fxfa/app/xfa_ffpageview.cpp +++ b/xfa/fxfa/app/xfa_ffpageview.cpp @@ -13,10 +13,10 @@ #include "xfa/fxfa/app/xfa_ffimageedit.h" #include "xfa/fxfa/app/xfa_ffpushbutton.h" #include "xfa/fxfa/app/xfa_fftextedit.h" -#include "xfa/fxfa/app/xfa_ffwidget.h" #include "xfa/fxfa/app/xfa_fwladapter.h" #include "xfa/include/fxfa/xfa_ffdoc.h" #include "xfa/include/fxfa/xfa_ffdocview.h" +#include "xfa/include/fxfa/xfa_ffwidget.h" CXFA_FFPageView::CXFA_FFPageView(CXFA_FFDocView* pDocView, CXFA_Node* pPageArea) : CXFA_ContainerLayoutItem(pPageArea), diff --git a/xfa/fxfa/app/xfa_ffpath.cpp b/xfa/fxfa/app/xfa_ffpath.cpp index eddc41f471..6f30612942 100644 --- a/xfa/fxfa/app/xfa_ffpath.cpp +++ b/xfa/fxfa/app/xfa_ffpath.cpp @@ -7,12 +7,12 @@ #include "xfa/fxfa/app/xfa_ffpath.h" #include "xfa/fxfa/app/xfa_ffdraw.h" -#include "xfa/fxfa/app/xfa_ffwidget.h" #include "xfa/fxgraphics/cfx_color.h" #include "xfa/fxgraphics/cfx_path.h" #include "xfa/include/fxfa/xfa_ffapp.h" #include "xfa/include/fxfa/xfa_ffdoc.h" #include "xfa/include/fxfa/xfa_ffpageview.h" +#include "xfa/include/fxfa/xfa_ffwidget.h" CXFA_FFLine::CXFA_FFLine(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc) : CXFA_FFDraw(pPageView, pDataAcc) {} diff --git a/xfa/fxfa/app/xfa_ffpushbutton.cpp b/xfa/fxfa/app/xfa_ffpushbutton.cpp index 85843755b6..4c54868f55 100644 --- a/xfa/fxfa/app/xfa_ffpushbutton.cpp +++ b/xfa/fxfa/app/xfa_ffpushbutton.cpp @@ -10,13 +10,13 @@ #include "xfa/fwl/core/ifwl_widgetmgrdelegate.h" #include "xfa/fwl/lightwidget/cfwl_pushbutton.h" #include "xfa/fxfa/app/xfa_fffield.h" -#include "xfa/fxfa/app/xfa_ffwidget.h" #include "xfa/fxfa/app/xfa_ffwidgetacc.h" #include "xfa/fxfa/app/xfa_textlayout.h" #include "xfa/fxgraphics/cfx_color.h" #include "xfa/fxgraphics/cfx_path.h" #include "xfa/include/fxfa/xfa_ffapp.h" #include "xfa/include/fxfa/xfa_ffpageview.h" +#include "xfa/include/fxfa/xfa_ffwidget.h" CXFA_FFPushButton::CXFA_FFPushButton(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc) diff --git a/xfa/fxfa/app/xfa_ffsignature.cpp b/xfa/fxfa/app/xfa_ffsignature.cpp index 65a7be2f5c..e5dba34985 100644 --- a/xfa/fxfa/app/xfa_ffsignature.cpp +++ b/xfa/fxfa/app/xfa_ffsignature.cpp @@ -7,9 +7,9 @@ #include "xfa/fxfa/app/xfa_ffsignature.h" #include "xfa/fxfa/app/xfa_fffield.h" -#include "xfa/fxfa/app/xfa_ffwidget.h" #include "xfa/include/fxfa/xfa_ffdoc.h" #include "xfa/include/fxfa/xfa_ffpageview.h" +#include "xfa/include/fxfa/xfa_ffwidget.h" CXFA_FFSignature::CXFA_FFSignature(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc) diff --git a/xfa/fxfa/app/xfa_ffsubform.cpp b/xfa/fxfa/app/xfa_ffsubform.cpp index fd718f8158..0ba4858b72 100644 --- a/xfa/fxfa/app/xfa_ffsubform.cpp +++ b/xfa/fxfa/app/xfa_ffsubform.cpp @@ -6,10 +6,10 @@ #include "xfa/fxfa/app/xfa_ffsubform.h" -#include "xfa/fxfa/app/xfa_ffwidget.h" #include "xfa/include/fxfa/xfa_ffapp.h" #include "xfa/include/fxfa/xfa_ffdoc.h" #include "xfa/include/fxfa/xfa_ffpageview.h" +#include "xfa/include/fxfa/xfa_ffwidget.h" CXFA_FFSubForm::CXFA_FFSubForm(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc) diff --git a/xfa/fxfa/app/xfa_ffsubform.h b/xfa/fxfa/app/xfa_ffsubform.h index bae6df6ee4..5a705a6a00 100644 --- a/xfa/fxfa/app/xfa_ffsubform.h +++ b/xfa/fxfa/app/xfa_ffsubform.h @@ -7,8 +7,8 @@ #ifndef XFA_FXFA_APP_XFA_FFSUBFORM_H_ #define XFA_FXFA_APP_XFA_FFSUBFORM_H_ -#include "xfa/fxfa/app/xfa_ffwidget.h" #include "xfa/include/fxfa/xfa_ffpageview.h" +#include "xfa/include/fxfa/xfa_ffwidget.h" class CXFA_FFSubForm : public CXFA_FFWidget { public: diff --git a/xfa/fxfa/app/xfa_fftext.cpp b/xfa/fxfa/app/xfa_fftext.cpp index d93c23fcec..d4bce5419f 100644 --- a/xfa/fxfa/app/xfa_fftext.cpp +++ b/xfa/fxfa/app/xfa_fftext.cpp @@ -8,12 +8,12 @@ #include "xfa/fwl/core/fwl_widgetdef.h" #include "xfa/fxfa/app/xfa_ffdraw.h" -#include "xfa/fxfa/app/xfa_ffwidget.h" #include "xfa/fxfa/app/xfa_textlayout.h" #include "xfa/fxgraphics/include/cfx_graphics.h" #include "xfa/include/fxfa/xfa_ffapp.h" #include "xfa/include/fxfa/xfa_ffdoc.h" #include "xfa/include/fxfa/xfa_ffpageview.h" +#include "xfa/include/fxfa/xfa_ffwidget.h" CXFA_FFText::CXFA_FFText(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc) : CXFA_FFDraw(pPageView, pDataAcc) {} diff --git a/xfa/fxfa/app/xfa_fftextedit.cpp b/xfa/fxfa/app/xfa_fftextedit.cpp index e11585fab0..085ec07d9f 100644 --- a/xfa/fxfa/app/xfa_fftextedit.cpp +++ b/xfa/fxfa/app/xfa_fftextedit.cpp @@ -15,7 +15,6 @@ #include "xfa/fwl/lightwidget/cfwl_datetimepicker.h" #include "xfa/fwl/lightwidget/cfwl_edit.h" #include "xfa/fxfa/app/xfa_fffield.h" -#include "xfa/fxfa/app/xfa_ffwidget.h" #include "xfa/fxfa/app/xfa_fwladapter.h" #include "xfa/fxfa/app/xfa_textlayout.h" #include "xfa/fxfa/parser/xfa_localevalue.h" @@ -23,6 +22,7 @@ #include "xfa/include/fxfa/xfa_ffdoc.h" #include "xfa/include/fxfa/xfa_ffdocview.h" #include "xfa/include/fxfa/xfa_ffpageview.h" +#include "xfa/include/fxfa/xfa_ffwidget.h" CXFA_FFTextEdit::CXFA_FFTextEdit(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc) diff --git a/xfa/fxfa/app/xfa_ffwidget.cpp b/xfa/fxfa/app/xfa_ffwidget.cpp index 4bf5de56c7..241bae0fdf 100644 --- a/xfa/fxfa/app/xfa_ffwidget.cpp +++ b/xfa/fxfa/app/xfa_ffwidget.cpp @@ -4,7 +4,7 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#include "xfa/fxfa/app/xfa_ffwidget.h" +#include "xfa/include/fxfa/xfa_ffwidget.h" #include diff --git a/xfa/fxfa/app/xfa_ffwidget.h b/xfa/fxfa/app/xfa_ffwidget.h deleted file mode 100644 index 84ab926a39..0000000000 --- a/xfa/fxfa/app/xfa_ffwidget.h +++ /dev/null @@ -1,185 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef XFA_FXFA_APP_XFA_FFWIDGET_H_ -#define XFA_FXFA_APP_XFA_FFWIDGET_H_ - -#include - -#include "core/include/fxcodec/fx_codec_def.h" -#include "core/include/fxge/fx_ge.h" -#include "xfa/fxfa/parser/xfa_doclayout.h" -#include "xfa/include/fxfa/fxfa.h" - -class CXFA_FFPageView; -class CXFA_FFDocView; -class CXFA_FFDoc; -class CXFA_FFApp; - -inline FX_FLOAT XFA_UnitPx2Pt(FX_FLOAT fPx, FX_FLOAT fDpi) { - return fPx * 72.0f / fDpi; -} -#define XFA_FLOAT_PERCISION 0.001f -enum XFA_WIDGETITEM { - XFA_WIDGETITEM_Parent, - XFA_WIDGETITEM_FirstChild, - XFA_WIDGETITEM_NextSibling, - XFA_WIDGETITEM_PrevSibling, -}; -class CXFA_CalcData { - public: - CXFA_CalcData() : m_iRefCount(0) {} - ~CXFA_CalcData() { m_Globals.RemoveAll(); } - CFX_PtrArray m_Globals; - int32_t m_iRefCount; -}; -class CXFA_FFWidget : public CFX_PrivateData, public CXFA_ContentLayoutItem { - public: - CXFA_FFWidget(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc); - virtual ~CXFA_FFWidget(); - CXFA_FFPageView* GetPageView(); - void SetPageView(CXFA_FFPageView* pPageView); - void GetWidgetRect(CFX_RectF& rtWidget); - CFX_RectF ReCacheWidgetRect(); - uint32_t GetStatus(); - void ModifyStatus(uint32_t dwAdded, uint32_t dwRemoved); - virtual FX_BOOL GetBBox(CFX_RectF& rtBox, - uint32_t dwStatus, - FX_BOOL bDrawFocus = FALSE); - CXFA_WidgetAcc* GetDataAcc(); - FX_BOOL GetToolTip(CFX_WideString& wsToolTip); - virtual void RenderWidget(CFX_Graphics* pGS, - CFX_Matrix* pMatrix = NULL, - uint32_t dwStatus = 0, - int32_t iRotate = 0); - - virtual FX_BOOL IsLoaded(); - virtual FX_BOOL LoadWidget(); - virtual void UnloadWidget(); - virtual FX_BOOL PerformLayout(); - virtual FX_BOOL UpdateFWLData(); - virtual void UpdateWidgetProperty(); - virtual FX_BOOL OnMouseEnter(); - virtual FX_BOOL OnMouseExit(); - virtual FX_BOOL OnLButtonDown(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy); - virtual FX_BOOL OnLButtonUp(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy); - virtual FX_BOOL OnLButtonDblClk(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy); - virtual FX_BOOL OnMouseMove(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy); - virtual FX_BOOL OnMouseWheel(uint32_t dwFlags, - int16_t zDelta, - FX_FLOAT fx, - FX_FLOAT fy); - virtual FX_BOOL OnRButtonDown(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy); - virtual FX_BOOL OnRButtonUp(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy); - virtual FX_BOOL OnRButtonDblClk(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy); - - virtual FX_BOOL OnSetFocus(CXFA_FFWidget* pOldWidget); - virtual FX_BOOL OnKillFocus(CXFA_FFWidget* pNewWidget); - virtual FX_BOOL OnKeyDown(uint32_t dwKeyCode, uint32_t dwFlags); - virtual FX_BOOL OnKeyUp(uint32_t dwKeyCode, uint32_t dwFlags); - virtual FX_BOOL OnChar(uint32_t dwChar, uint32_t dwFlags); - virtual uint32_t OnHitTest(FX_FLOAT fx, FX_FLOAT fy); - virtual FX_BOOL OnSetCursor(FX_FLOAT fx, FX_FLOAT fy); - virtual FX_BOOL CanUndo() { return FALSE; } - virtual FX_BOOL CanRedo() { return FALSE; } - virtual FX_BOOL Undo() { return FALSE; } - virtual FX_BOOL Redo() { return FALSE; } - virtual FX_BOOL CanCopy() { return FALSE; } - virtual FX_BOOL CanCut() { return FALSE; } - virtual FX_BOOL CanPaste() { return FALSE; } - virtual FX_BOOL CanSelectAll() { return FALSE; } - virtual FX_BOOL CanDelete() { return CanCut(); } - virtual FX_BOOL CanDeSelect() { return CanCopy(); } - virtual FX_BOOL Copy(CFX_WideString& wsCopy) { return FALSE; } - virtual FX_BOOL Cut(CFX_WideString& wsCut) { return FALSE; } - virtual FX_BOOL Paste(const CFX_WideString& wsPaste) { return FALSE; } - virtual FX_BOOL SelectAll() { return FALSE; } - virtual FX_BOOL Delete() { return FALSE; } - virtual FX_BOOL DeSelect() { return FALSE; } - virtual FX_BOOL GetSuggestWords(CFX_PointF pointf, - std::vector& sSuggest) { - return FALSE; - } - virtual FX_BOOL ReplaceSpellCheckWord(CFX_PointF pointf, - const CFX_ByteStringC& bsReplace) { - return FALSE; - } - CXFA_FFDocView* GetDocView(); - void SetDocView(CXFA_FFDocView* pDocView) { m_pDocView = pDocView; } - CXFA_FFDoc* GetDoc(); - CXFA_FFApp* GetApp(); - IXFA_AppProvider* GetAppProvider(); - void InvalidateWidget(const CFX_RectF* pRect = NULL); - void AddInvalidateRect(const CFX_RectF* pRect = NULL); - FX_BOOL GetCaptionText(CFX_WideString& wsCap); - FX_BOOL IsFocused(); - void Rotate2Normal(FX_FLOAT& fx, FX_FLOAT& fy); - void GetRotateMatrix(CFX_Matrix& mt); - FX_BOOL IsLayoutRectEmpty(); - CXFA_FFWidget* GetParent(); - FX_BOOL IsAncestorOf(CXFA_FFWidget* pWidget); - - protected: - virtual FX_BOOL PtInActiveRect(FX_FLOAT fx, FX_FLOAT fy); - void DrawBorder(CFX_Graphics* pGS, - CXFA_Box box, - const CFX_RectF& rtBorder, - CFX_Matrix* pMatrix, - uint32_t dwFlags = 0); - void GetMinMaxWidth(FX_FLOAT fMinWidth, FX_FLOAT fMaxWidth); - void GetMinMaxHeight(FX_FLOAT fMinHeight, FX_FLOAT fMaxHeight); - void GetRectWithoutRotate(CFX_RectF& rtWidget); - FX_BOOL IsMatchVisibleStatus(uint32_t dwStatus); - - void EventKillFocus(); - FX_BOOL IsButtonDown(); - void SetButtonDown(FX_BOOL bSet); - CXFA_FFDocView* m_pDocView; - CXFA_FFPageView* m_pPageView; - CXFA_WidgetAcc* m_pDataAcc; - CFX_RectF m_rtWidget; -}; -int32_t XFA_StrokeTypeSetLineDash(CFX_Graphics* pGraphics, - int32_t iStrokeType, - int32_t iCapType); -CFX_GraphStateData::LineCap XFA_LineCapToFXGE(int32_t iLineCap); -void XFA_DrawImage(CFX_Graphics* pGS, - const CFX_RectF& rtImage, - CFX_Matrix* pMatrix, - CFX_DIBitmap* pDIBitmap, - int32_t iAspect, - int32_t iImageXDpi, - int32_t iImageYDpi, - int32_t iHorzAlign = XFA_ATTRIBUTEENUM_Left, - int32_t iVertAlign = XFA_ATTRIBUTEENUM_Top); -CFX_DIBitmap* XFA_LoadImageData(CXFA_FFDoc* pDoc, - CXFA_Image* pImage, - FX_BOOL& bNameImage, - int32_t& iImageXDpi, - int32_t& iImageYDpi); -CFX_DIBitmap* XFA_LoadImageFromBuffer(IFX_FileRead* pImageFileRead, - FXCODEC_IMAGE_TYPE type, - int32_t& iImageXDpi, - int32_t& iImageYDpi); -FXCODEC_IMAGE_TYPE XFA_GetImageType(const CFX_WideStringC& wsType); -FX_CHAR* XFA_Base64Encode(const uint8_t* buf, int32_t buf_len); -void XFA_RectWidthoutMargin(CFX_RectF& rt, - const CXFA_Margin& mg, - FX_BOOL bUI = FALSE); -FX_FLOAT XFA_GetEdgeThickness(const CXFA_StrokeArray& strokes, - FX_BOOL b3DStyle, - int32_t nIndex); -CXFA_FFWidget* XFA_GetWidgetFromLayoutItem(CXFA_LayoutItem* pLayoutItem); -FX_BOOL XFA_IsCreateWidget(XFA_ELEMENT iType); -#define XFA_DRAWBOX_ForceRound 1 -#define XFA_DRAWBOX_Lowered3D 2 -void XFA_DrawBox(CXFA_Box box, - CFX_Graphics* pGS, - const CFX_RectF& rtWidget, - CFX_Matrix* pMatrix, - uint32_t dwFlags = 0); - -#endif // XFA_FXFA_APP_XFA_FFWIDGET_H_ diff --git a/xfa/fxfa/app/xfa_ffwidgetacc.cpp b/xfa/fxfa/app/xfa_ffwidgetacc.cpp index 5c2e6c354b..271f9261f0 100644 --- a/xfa/fxfa/app/xfa_ffwidgetacc.cpp +++ b/xfa/fxfa/app/xfa_ffwidgetacc.cpp @@ -13,7 +13,6 @@ #include "xfa/fxfa/app/xfa_ffcheckbutton.h" #include "xfa/fxfa/app/xfa_ffchoicelist.h" #include "xfa/fxfa/app/xfa_fffield.h" -#include "xfa/fxfa/app/xfa_ffwidget.h" #include "xfa/fxfa/app/xfa_fwladapter.h" #include "xfa/fxfa/app/xfa_textlayout.h" #include "xfa/fxfa/parser/xfa_document_layout_imp.h" @@ -24,6 +23,7 @@ #include "xfa/include/fxfa/xfa_ffdoc.h" #include "xfa/include/fxfa/xfa_ffdocview.h" #include "xfa/include/fxfa/xfa_ffpageview.h" +#include "xfa/include/fxfa/xfa_ffwidget.h" #include "xfa/include/fxfa/xfa_fontmgr.h" static void XFA_FFDeleteCalcData(void* pData) { diff --git a/xfa/fxfa/app/xfa_ffwidgethandler.cpp b/xfa/fxfa/app/xfa_ffwidgethandler.cpp index 711d29abc2..b79082965a 100644 --- a/xfa/fxfa/app/xfa_ffwidgethandler.cpp +++ b/xfa/fxfa/app/xfa_ffwidgethandler.cpp @@ -10,56 +10,19 @@ #include "xfa/fxfa/app/xfa_ffchoicelist.h" #include "xfa/fxfa/app/xfa_fffield.h" -#include "xfa/fxfa/app/xfa_ffwidget.h" #include "xfa/fxfa/app/xfa_fwladapter.h" #include "xfa/fxfa/parser/xfa_document_layout_imp.h" #include "xfa/fxfa/parser/xfa_parser.h" #include "xfa/fxfa/parser/xfa_parser_imp.h" #include "xfa/include/fxfa/xfa_ffdoc.h" #include "xfa/include/fxfa/xfa_ffdocview.h" +#include "xfa/include/fxfa/xfa_ffwidget.h" CXFA_FFWidgetHandler::CXFA_FFWidgetHandler(CXFA_FFDocView* pDocView) : m_pDocView(pDocView) {} CXFA_FFWidgetHandler::~CXFA_FFWidgetHandler() {} -CXFA_FFPageView* CXFA_FFWidgetHandler::GetPageView(CXFA_FFWidget* hWidget) { - return hWidget->GetPageView(); -} -void CXFA_FFWidgetHandler::GetRect(CXFA_FFWidget* hWidget, CFX_RectF& rt) { - hWidget->GetWidgetRect(rt); -} -uint32_t CXFA_FFWidgetHandler::GetStatus(CXFA_FFWidget* hWidget) { - return hWidget->GetStatus(); -} -FX_BOOL CXFA_FFWidgetHandler::GetBBox(CXFA_FFWidget* hWidget, - CFX_RectF& rtBox, - uint32_t dwStatus, - FX_BOOL bDrawFocus) { - return hWidget->GetBBox(rtBox, dwStatus, bDrawFocus); -} -CXFA_WidgetAcc* CXFA_FFWidgetHandler::GetDataAcc(CXFA_FFWidget* hWidget) { - return hWidget->GetDataAcc(); -} -void CXFA_FFWidgetHandler::GetName(CXFA_FFWidget* hWidget, - CFX_WideString& wsName, - int32_t iNameType) { - hWidget->GetDataAcc()->GetName(wsName, iNameType); -} -FX_BOOL CXFA_FFWidgetHandler::GetToolTip(CXFA_FFWidget* hWidget, - CFX_WideString& wsToolTip) { - return hWidget->GetToolTip(wsToolTip); -} -void CXFA_FFWidgetHandler::SetPrivateData(CXFA_FFWidget* hWidget, - void* module_id, - void* pData, - PD_CALLBACK_FREEDATA callback) { - hWidget->SetPrivateData(module_id, pData, callback); -} -void* CXFA_FFWidgetHandler::GetPrivateData(CXFA_FFWidget* hWidget, - void* module_id) { - return hWidget->GetPrivateData(module_id); -} FX_BOOL CXFA_FFWidgetHandler::OnMouseEnter(CXFA_FFWidget* hWidget) { m_pDocView->LockUpdate(); FX_BOOL bRet = hWidget->OnMouseEnter(); @@ -67,6 +30,7 @@ FX_BOOL CXFA_FFWidgetHandler::OnMouseEnter(CXFA_FFWidget* hWidget) { m_pDocView->UpdateDocView(); return bRet; } + FX_BOOL CXFA_FFWidgetHandler::OnMouseExit(CXFA_FFWidget* hWidget) { m_pDocView->LockUpdate(); FX_BOOL bRet = hWidget->OnMouseExit(); @@ -74,6 +38,7 @@ FX_BOOL CXFA_FFWidgetHandler::OnMouseExit(CXFA_FFWidget* hWidget) { m_pDocView->UpdateDocView(); return bRet; } + FX_BOOL CXFA_FFWidgetHandler::OnLButtonDown(CXFA_FFWidget* hWidget, uint32_t dwFlags, FX_FLOAT fx, @@ -90,6 +55,7 @@ FX_BOOL CXFA_FFWidgetHandler::OnLButtonDown(CXFA_FFWidget* hWidget, m_pDocView->UpdateDocView(); return bRet; } + FX_BOOL CXFA_FFWidgetHandler::OnLButtonUp(CXFA_FFWidget* hWidget, uint32_t dwFlags, FX_FLOAT fx, @@ -102,6 +68,7 @@ FX_BOOL CXFA_FFWidgetHandler::OnLButtonUp(CXFA_FFWidget* hWidget, m_pDocView->UpdateDocView(); return bRet; } + FX_BOOL CXFA_FFWidgetHandler::OnLButtonDblClk(CXFA_FFWidget* hWidget, uint32_t dwFlags, FX_FLOAT fx, @@ -111,6 +78,7 @@ FX_BOOL CXFA_FFWidgetHandler::OnLButtonDblClk(CXFA_FFWidget* hWidget, m_pDocView->RunInvalidate(); return bRet; } + FX_BOOL CXFA_FFWidgetHandler::OnMouseMove(CXFA_FFWidget* hWidget, uint32_t dwFlags, FX_FLOAT fx, @@ -120,6 +88,7 @@ FX_BOOL CXFA_FFWidgetHandler::OnMouseMove(CXFA_FFWidget* hWidget, m_pDocView->RunInvalidate(); return bRet; } + FX_BOOL CXFA_FFWidgetHandler::OnMouseWheel(CXFA_FFWidget* hWidget, uint32_t dwFlags, int16_t zDelta, @@ -130,6 +99,7 @@ FX_BOOL CXFA_FFWidgetHandler::OnMouseWheel(CXFA_FFWidget* hWidget, m_pDocView->RunInvalidate(); return bRet; } + FX_BOOL CXFA_FFWidgetHandler::OnRButtonDown(CXFA_FFWidget* hWidget, uint32_t dwFlags, FX_FLOAT fx, @@ -144,6 +114,7 @@ FX_BOOL CXFA_FFWidgetHandler::OnRButtonDown(CXFA_FFWidget* hWidget, m_pDocView->RunInvalidate(); return bRet; } + FX_BOOL CXFA_FFWidgetHandler::OnRButtonUp(CXFA_FFWidget* hWidget, uint32_t dwFlags, FX_FLOAT fx, @@ -153,6 +124,7 @@ FX_BOOL CXFA_FFWidgetHandler::OnRButtonUp(CXFA_FFWidget* hWidget, m_pDocView->RunInvalidate(); return bRet; } + FX_BOOL CXFA_FFWidgetHandler::OnRButtonDblClk(CXFA_FFWidget* hWidget, uint32_t dwFlags, FX_FLOAT fx, @@ -162,6 +134,7 @@ FX_BOOL CXFA_FFWidgetHandler::OnRButtonDblClk(CXFA_FFWidget* hWidget, m_pDocView->RunInvalidate(); return bRet; } + FX_BOOL CXFA_FFWidgetHandler::OnKeyDown(CXFA_FFWidget* hWidget, uint32_t dwKeyCode, uint32_t dwFlags) { @@ -170,6 +143,7 @@ FX_BOOL CXFA_FFWidgetHandler::OnKeyDown(CXFA_FFWidget* hWidget, m_pDocView->UpdateDocView(); return bRet; } + FX_BOOL CXFA_FFWidgetHandler::OnKeyUp(CXFA_FFWidget* hWidget, uint32_t dwKeyCode, uint32_t dwFlags) { @@ -177,6 +151,7 @@ FX_BOOL CXFA_FFWidgetHandler::OnKeyUp(CXFA_FFWidget* hWidget, m_pDocView->RunInvalidate(); return bRet; } + FX_BOOL CXFA_FFWidgetHandler::OnChar(CXFA_FFWidget* hWidget, uint32_t dwChar, uint32_t dwFlags) { @@ -184,6 +159,7 @@ FX_BOOL CXFA_FFWidgetHandler::OnChar(CXFA_FFWidget* hWidget, m_pDocView->RunInvalidate(); return bRet; } + uint32_t CXFA_FFWidgetHandler::OnHitTest(CXFA_FFWidget* hWidget, FX_FLOAT fx, FX_FLOAT fy) { @@ -193,12 +169,14 @@ uint32_t CXFA_FFWidgetHandler::OnHitTest(CXFA_FFWidget* hWidget, hWidget->Rotate2Normal(fx, fy); return hWidget->OnHitTest(fx, fy); } + FX_BOOL CXFA_FFWidgetHandler::OnSetCursor(CXFA_FFWidget* hWidget, FX_FLOAT fx, FX_FLOAT fy) { hWidget->Rotate2Normal(fx, fy); return hWidget->OnSetCursor(fx, fy); } + void CXFA_FFWidgetHandler::RenderWidget(CXFA_FFWidget* hWidget, CFX_Graphics* pGS, CFX_Matrix* pMatrix, @@ -206,33 +184,29 @@ void CXFA_FFWidgetHandler::RenderWidget(CXFA_FFWidget* hWidget, hWidget->RenderWidget(pGS, pMatrix, bHighlight ? XFA_WIDGETSTATUS_Highlight : 0, 0); } + FX_BOOL CXFA_FFWidgetHandler::HasEvent(CXFA_WidgetAcc* pWidgetAcc, XFA_EVENTTYPE eEventType) { - if (!pWidgetAcc || eEventType == XFA_EVENT_Unknown) { + if (!pWidgetAcc || eEventType == XFA_EVENT_Unknown) return FALSE; - } - if (pWidgetAcc->GetClassID() == XFA_ELEMENT_Draw) { + if (pWidgetAcc->GetClassID() == XFA_ELEMENT_Draw) return FALSE; - } + switch (eEventType) { case XFA_EVENT_Calculate: { CXFA_Calculate calc = pWidgetAcc->GetCalculate(); - if (!calc) { + if (!calc) return FALSE; - } - if (calc.GetScript()) { + if (calc.GetScript()) return TRUE; - } return FALSE; } case XFA_EVENT_Validate: { CXFA_Validate val = pWidgetAcc->GetValidate(); - if (!val) { + if (!val) return FALSE; - } - if (val.GetScript()) { + if (val.GetScript()) return TRUE; - } return FALSE; } default: @@ -242,14 +216,14 @@ FX_BOOL CXFA_FFWidgetHandler::HasEvent(CXFA_WidgetAcc* pWidgetAcc, return pWidgetAcc->GetEventByActivity(gs_EventActivity[eEventType], eventArray); } + int32_t CXFA_FFWidgetHandler::ProcessEvent(CXFA_WidgetAcc* pWidgetAcc, CXFA_EventParam* pParam) { - if (!pParam || pParam->m_eType == XFA_EVENT_Unknown) { + if (!pParam || pParam->m_eType == XFA_EVENT_Unknown) return XFA_EVENTERROR_NotExist; - } - if (!pWidgetAcc || pWidgetAcc->GetClassID() == XFA_ELEMENT_Draw) { + if (!pWidgetAcc || pWidgetAcc->GetClassID() == XFA_ELEMENT_Draw) return XFA_EVENTERROR_NotExist; - } + switch (pParam->m_eType) { case XFA_EVENT_Calculate: return pWidgetAcc->ProcessCalculate(); @@ -262,12 +236,11 @@ int32_t CXFA_FFWidgetHandler::ProcessEvent(CXFA_WidgetAcc* pWidgetAcc, return XFA_EVENTERROR_Disabled; case XFA_EVENT_InitCalculate: { CXFA_Calculate calc = pWidgetAcc->GetCalculate(); - if (!calc) { + if (!calc) return XFA_EVENTERROR_NotExist; - } - if (pWidgetAcc->GetNode()->HasFlag(XFA_NODEFLAG_UserInteractive)) { + if (pWidgetAcc->GetNode()->HasFlag(XFA_NODEFLAG_UserInteractive)) return XFA_EVENTERROR_Disabled; - } + CXFA_Script script = calc.GetScript(); return pWidgetAcc->ExecuteScript(script, pParam); } @@ -278,6 +251,7 @@ int32_t CXFA_FFWidgetHandler::ProcessEvent(CXFA_WidgetAcc* pWidgetAcc, pWidgetAcc->ProcessEvent(gs_EventActivity[pParam->m_eType], pParam); return iRet; } + CXFA_FFWidget* CXFA_FFWidgetHandler::CreateWidget(CXFA_FFWidget* hParent, XFA_WIDGETTYPE eType, CXFA_FFWidget* hBefore) { @@ -287,9 +261,9 @@ CXFA_FFWidget* CXFA_FFWidgetHandler::CreateWidget(CXFA_FFWidget* hParent, hBefore ? hBefore->GetDataAcc()->GetNode() : nullptr; CXFA_Node* pNewFormItem = CreateWidgetFormItem(eType, pParentFormItem, pBeforeFormItem); - if (pNewFormItem == NULL) { - return NULL; - } + if (!pNewFormItem) + return nullptr; + pNewFormItem->GetTemplateNode()->SetFlag(XFA_NODEFLAG_Initialized); pNewFormItem->SetFlag(XFA_NODEFLAG_Initialized); m_pDocView->RunLayout(); @@ -297,13 +271,14 @@ CXFA_FFWidget* CXFA_FFWidgetHandler::CreateWidget(CXFA_FFWidget* hParent, m_pDocView->GetXFALayout()->GetLayoutItem(pNewFormItem); return (CXFA_FFWidget*)pLayout; } + CXFA_Node* CXFA_FFWidgetHandler::CreateWidgetFormItem( XFA_WIDGETTYPE eType, CXFA_Node* pParent, CXFA_Node* pBefore) const { switch (eType) { case XFA_WIDGETTYPE_Barcode: - return NULL; + return nullptr; case XFA_WIDGETTYPE_PushButton: return CreatePushButton(pParent, pBefore); case XFA_WIDGETTYPE_CheckButton: @@ -343,10 +318,10 @@ CXFA_Node* CXFA_FFWidgetHandler::CreateWidgetFormItem( case XFA_WIDGETTYPE_Subform: return CreateSubform(pParent, pBefore); default: - break; + return nullptr; } - return NULL; } + CXFA_Node* CXFA_FFWidgetHandler::CreatePushButton(CXFA_Node* pParent, CXFA_Node* pBefore) const { CXFA_Node* pField = CreateField(XFA_ELEMENT_Button, pParent, pBefore); @@ -354,30 +329,38 @@ CXFA_Node* CXFA_FFWidgetHandler::CreatePushButton(CXFA_Node* pParent, CXFA_Node* pValue = CreateCopyNode(XFA_ELEMENT_Value, pCaption); CXFA_Node* pText = CreateCopyNode(XFA_ELEMENT_Text, pValue); pText->SetContent(FX_WSTRC(L"Button"), FX_WSTRC(L"Button"), FALSE); + CXFA_Node* pPara = CreateCopyNode(XFA_ELEMENT_Para, pCaption); pPara->SetEnum(XFA_ATTRIBUTE_VAlign, XFA_ATTRIBUTEENUM_Middle, FALSE); pPara->SetEnum(XFA_ATTRIBUTE_HAlign, XFA_ATTRIBUTEENUM_Center, FALSE); CreateFontNode(pCaption); + CXFA_Node* pBorder = CreateCopyNode(XFA_ELEMENT_Border, pField); pBorder->SetEnum(XFA_ATTRIBUTE_Hand, XFA_ATTRIBUTEENUM_Right, FALSE); + CXFA_Node* pEdge = CreateCopyNode(XFA_ELEMENT_Edge, pBorder); pEdge->SetEnum(XFA_ATTRIBUTE_Stroke, XFA_ATTRIBUTEENUM_Raised, FALSE); + CXFA_Node* pFill = CreateCopyNode(XFA_ELEMENT_Fill, pBorder); CXFA_Node* pColor = CreateCopyNode(XFA_ELEMENT_Color, pFill); pColor->SetCData(XFA_ATTRIBUTE_Value, FX_WSTRC(L"212, 208, 200"), FALSE); + CXFA_Node* pBind = CreateCopyNode(XFA_ELEMENT_Bind, pField); pBind->SetEnum(XFA_ATTRIBUTE_Match, XFA_ATTRIBUTEENUM_None); + return pField; } + CXFA_Node* CXFA_FFWidgetHandler::CreateCheckButton(CXFA_Node* pParent, CXFA_Node* pBefore) const { - CXFA_Node* pField = CreateField(XFA_ELEMENT_CheckButton, pParent, pBefore); - return pField; + return CreateField(XFA_ELEMENT_CheckButton, pParent, pBefore); } + CXFA_Node* CXFA_FFWidgetHandler::CreateExclGroup(CXFA_Node* pParent, CXFA_Node* pBefore) const { return CreateFormItem(XFA_ELEMENT_ExclGroup, pParent, pBefore); } + CXFA_Node* CXFA_FFWidgetHandler::CreateRadioButton(CXFA_Node* pParent, CXFA_Node* pBefore) const { CXFA_Node* pField = CreateField(XFA_ELEMENT_CheckButton, pParent, pBefore); @@ -386,38 +369,41 @@ CXFA_Node* CXFA_FFWidgetHandler::CreateRadioButton(CXFA_Node* pParent, pWidget->SetEnum(XFA_ATTRIBUTE_Shape, XFA_ATTRIBUTEENUM_Round); return pField; } + CXFA_Node* CXFA_FFWidgetHandler::CreateDatetimeEdit(CXFA_Node* pParent, CXFA_Node* pBefore) const { CXFA_Node* pField = CreateField(XFA_ELEMENT_DateTimeEdit, pParent, pBefore); CreateValueNode(XFA_ELEMENT_Date, pField); return pField; } + CXFA_Node* CXFA_FFWidgetHandler::CreateDecimalField(CXFA_Node* pParent, CXFA_Node* pBefore) const { CXFA_Node* pField = CreateNumericField(pParent, pBefore); CreateValueNode(XFA_ELEMENT_Decimal, pField); return pField; } + CXFA_Node* CXFA_FFWidgetHandler::CreateNumericField(CXFA_Node* pParent, CXFA_Node* pBefore) const { - CXFA_Node* pField = CreateField(XFA_ELEMENT_NumericEdit, pParent, pBefore); - return pField; + return CreateField(XFA_ELEMENT_NumericEdit, pParent, pBefore); } + CXFA_Node* CXFA_FFWidgetHandler::CreateSignature(CXFA_Node* pParent, CXFA_Node* pBefore) const { - CXFA_Node* pField = CreateField(XFA_ELEMENT_Signature, pParent, pBefore); - return pField; + return CreateField(XFA_ELEMENT_Signature, pParent, pBefore); } + CXFA_Node* CXFA_FFWidgetHandler::CreateTextEdit(CXFA_Node* pParent, CXFA_Node* pBefore) const { - CXFA_Node* pField = CreateField(XFA_ELEMENT_TextEdit, pParent, pBefore); - return pField; + return CreateField(XFA_ELEMENT_TextEdit, pParent, pBefore); } + CXFA_Node* CXFA_FFWidgetHandler::CreateDropdownList(CXFA_Node* pParent, CXFA_Node* pBefore) const { - CXFA_Node* pField = CreateField(XFA_ELEMENT_ChoiceList, pParent, pBefore); - return pField; + return CreateField(XFA_ELEMENT_ChoiceList, pParent, pBefore); } + CXFA_Node* CXFA_FFWidgetHandler::CreateListBox(CXFA_Node* pParent, CXFA_Node* pBefore) const { CXFA_Node* pField = CreateDropdownList(pParent, pBefore); @@ -427,11 +413,12 @@ CXFA_Node* CXFA_FFWidgetHandler::CreateListBox(CXFA_Node* pParent, pListBox->SetEnum(XFA_ATTRIBUTE_CommitOn, XFA_ATTRIBUTEENUM_Exit); return pField; } + CXFA_Node* CXFA_FFWidgetHandler::CreateImageField(CXFA_Node* pParent, CXFA_Node* pBefore) const { - CXFA_Node* pField = CreateField(XFA_ELEMENT_ImageEdit, pParent, pBefore); - return pField; + return CreateField(XFA_ELEMENT_ImageEdit, pParent, pBefore); } + CXFA_Node* CXFA_FFWidgetHandler::CreatePasswordEdit(CXFA_Node* pParent, CXFA_Node* pBefore) const { CXFA_Node* pField = CreateField(XFA_ELEMENT_PasswordEdit, pParent, pBefore); @@ -439,6 +426,7 @@ CXFA_Node* CXFA_FFWidgetHandler::CreatePasswordEdit(CXFA_Node* pParent, pBind->SetEnum(XFA_ATTRIBUTE_Match, XFA_ATTRIBUTEENUM_None, FALSE); return pField; } + CXFA_Node* CXFA_FFWidgetHandler::CreateField(XFA_ELEMENT eElement, CXFA_Node* pParent, CXFA_Node* pBefore) const { @@ -447,25 +435,29 @@ CXFA_Node* CXFA_FFWidgetHandler::CreateField(XFA_ELEMENT eElement, CreateFontNode(pField); return pField; } + CXFA_Node* CXFA_FFWidgetHandler::CreateArc(CXFA_Node* pParent, CXFA_Node* pBefore) const { return CreateDraw(XFA_ELEMENT_Arc, pParent, pBefore); } + CXFA_Node* CXFA_FFWidgetHandler::CreateRectangle(CXFA_Node* pParent, CXFA_Node* pBefore) const { return CreateDraw(XFA_ELEMENT_Rectangle, pParent, pBefore); } + CXFA_Node* CXFA_FFWidgetHandler::CreateImage(CXFA_Node* pParent, CXFA_Node* pBefore) const { CXFA_Node* pField = CreateDraw(XFA_ELEMENT_Image, pParent, pBefore); CreateCopyNode(XFA_ELEMENT_ImageEdit, CreateCopyNode(XFA_ELEMENT_Ui, pField)); return pField; } + CXFA_Node* CXFA_FFWidgetHandler::CreateLine(CXFA_Node* pParent, CXFA_Node* pBefore) const { - CXFA_Node* pField = CreateDraw(XFA_ELEMENT_Line, pParent, pBefore); - return pField; + return CreateDraw(XFA_ELEMENT_Line, pParent, pBefore); } + CXFA_Node* CXFA_FFWidgetHandler::CreateText(CXFA_Node* pParent, CXFA_Node* pBefore) const { CXFA_Node* pField = CreateDraw(XFA_ELEMENT_Text, pParent, pBefore); @@ -473,6 +465,7 @@ CXFA_Node* CXFA_FFWidgetHandler::CreateText(CXFA_Node* pParent, CreateFontNode(pField); return pField; } + CXFA_Node* CXFA_FFWidgetHandler::CreateDraw(XFA_ELEMENT eElement, CXFA_Node* pParent, CXFA_Node* pBefore) const { @@ -480,11 +473,12 @@ CXFA_Node* CXFA_FFWidgetHandler::CreateDraw(XFA_ELEMENT eElement, CreateValueNode(eElement, pDraw); return pDraw; } + CXFA_Node* CXFA_FFWidgetHandler::CreateSubform(CXFA_Node* pParent, CXFA_Node* pBefore) const { - CXFA_Node* pSubform = CreateFormItem(XFA_ELEMENT_Subform, pParent, pBefore); - return pSubform; + return CreateFormItem(XFA_ELEMENT_Subform, pParent, pBefore); } + CXFA_Node* CXFA_FFWidgetHandler::CreateFormItem(XFA_ELEMENT eElement, CXFA_Node* pParent, CXFA_Node* pBefore) const { @@ -494,6 +488,7 @@ CXFA_Node* CXFA_FFWidgetHandler::CreateFormItem(XFA_ELEMENT eElement, pParent->InsertChild(pNewFormItem, pBefore); return pNewFormItem; } + CXFA_Node* CXFA_FFWidgetHandler::CreateCopyNode(XFA_ELEMENT eElement, CXFA_Node* pParent, CXFA_Node* pBefore) const { @@ -506,6 +501,7 @@ CXFA_Node* CXFA_FFWidgetHandler::CreateCopyNode(XFA_ELEMENT eElement, pParent->InsertChild(pNewNode, pBefore); return pNewNode; } + CXFA_Node* CXFA_FFWidgetHandler::CreateTemplateNode(XFA_ELEMENT eElement, CXFA_Node* pParent, CXFA_Node* pBefore) const { @@ -516,110 +512,44 @@ CXFA_Node* CXFA_FFWidgetHandler::CreateTemplateNode(XFA_ELEMENT eElement, pParent->InsertChild(pNewTemplateNode, pBefore); return pNewTemplateNode; } + CXFA_Node* CXFA_FFWidgetHandler::CreateFontNode(CXFA_Node* pParent) const { CXFA_Node* pFont = CreateCopyNode(XFA_ELEMENT_Font, pParent); pFont->SetCData(XFA_ATTRIBUTE_Typeface, FX_WSTRC(L"Myriad Pro"), FALSE); return pFont; } + CXFA_Node* CXFA_FFWidgetHandler::CreateMarginNode(CXFA_Node* pParent, uint32_t dwFlags, FX_FLOAT fInsets[4]) const { CXFA_Node* pMargin = CreateCopyNode(XFA_ELEMENT_Margin, pParent); - if (dwFlags & 0x01) { + if (dwFlags & 0x01) pMargin->SetMeasure(XFA_ATTRIBUTE_LeftInset, CXFA_Measurement(fInsets[0], XFA_UNIT_Pt), FALSE); - } - if (dwFlags & 0x02) { + if (dwFlags & 0x02) pMargin->SetMeasure(XFA_ATTRIBUTE_TopInset, CXFA_Measurement(fInsets[1], XFA_UNIT_Pt), FALSE); - } - if (dwFlags & 0x04) { + if (dwFlags & 0x04) pMargin->SetMeasure(XFA_ATTRIBUTE_RightInset, CXFA_Measurement(fInsets[2], XFA_UNIT_Pt), FALSE); - } - if (dwFlags & 0x08) { + if (dwFlags & 0x08) pMargin->SetMeasure(XFA_ATTRIBUTE_BottomInset, CXFA_Measurement(fInsets[3], XFA_UNIT_Pt), FALSE); - } return pMargin; } + CXFA_Node* CXFA_FFWidgetHandler::CreateValueNode(XFA_ELEMENT eValue, CXFA_Node* pParent) const { CXFA_Node* pValue = CreateCopyNode(XFA_ELEMENT_Value, pParent); CreateCopyNode(eValue, pValue); return pValue; } + CXFA_Document* CXFA_FFWidgetHandler::GetObjFactory() const { return GetXFADoc()->GetParser()->GetFactory(); } + CXFA_Document* CXFA_FFWidgetHandler::GetXFADoc() const { return ((CXFA_FFDoc*)(m_pDocView->GetDoc()))->GetXFADoc(); } -CXFA_FFMenuHandler::CXFA_FFMenuHandler() {} - -CXFA_FFMenuHandler::~CXFA_FFMenuHandler() {} - -FX_BOOL CXFA_FFMenuHandler::CanCopy(CXFA_FFWidget* hWidget) { - return hWidget->CanCopy(); -} -FX_BOOL CXFA_FFMenuHandler::CanCut(CXFA_FFWidget* hWidget) { - return hWidget->CanCut(); -} -FX_BOOL CXFA_FFMenuHandler::CanPaste(CXFA_FFWidget* hWidget) { - return hWidget->CanPaste(); -} -FX_BOOL CXFA_FFMenuHandler::CanSelectAll(CXFA_FFWidget* hWidget) { - return hWidget->CanSelectAll(); -} -FX_BOOL CXFA_FFMenuHandler::CanDelete(CXFA_FFWidget* hWidget) { - return hWidget->CanDelete(); -} -FX_BOOL CXFA_FFMenuHandler::CanDeSelect(CXFA_FFWidget* hWidget) { - return hWidget->CanDeSelect(); -} -FX_BOOL CXFA_FFMenuHandler::Copy(CXFA_FFWidget* hWidget, - CFX_WideString& wsText) { - return hWidget->Copy(wsText); -} -FX_BOOL CXFA_FFMenuHandler::Cut(CXFA_FFWidget* hWidget, - CFX_WideString& wsText) { - return hWidget->Cut(wsText); -} -FX_BOOL CXFA_FFMenuHandler::Paste(CXFA_FFWidget* hWidget, - const CFX_WideString& wsText) { - return hWidget->Paste(wsText); -} -FX_BOOL CXFA_FFMenuHandler::SelectAll(CXFA_FFWidget* hWidget) { - return hWidget->SelectAll(); -} -FX_BOOL CXFA_FFMenuHandler::Delete(CXFA_FFWidget* hWidget) { - return hWidget->Delete(); -} -FX_BOOL CXFA_FFMenuHandler::DeSelect(CXFA_FFWidget* hWidget) { - return hWidget->DeSelect(); -} -FX_BOOL CXFA_FFMenuHandler::CanUndo(CXFA_FFWidget* hWidget) { - return hWidget->CanUndo(); -} -FX_BOOL CXFA_FFMenuHandler::CanRedo(CXFA_FFWidget* hWidget) { - return hWidget->CanRedo(); -} -FX_BOOL CXFA_FFMenuHandler::Undo(CXFA_FFWidget* hWidget) { - return hWidget->Undo(); -} -FX_BOOL CXFA_FFMenuHandler::Redo(CXFA_FFWidget* hWidget) { - return hWidget->Redo(); -} -FX_BOOL CXFA_FFMenuHandler::GetSuggestWords( - CXFA_FFWidget* hWidget, - CFX_PointF pointf, - std::vector& sSuggest) { - return hWidget->GetSuggestWords(pointf, sSuggest); -} -FX_BOOL CXFA_FFMenuHandler::ReplaceSpellCheckWord( - CXFA_FFWidget* hWidget, - CFX_PointF pointf, - const CFX_ByteStringC& bsReplace) { - return hWidget->ReplaceSpellCheckWord(pointf, bsReplace); -} diff --git a/xfa/fxfa/app/xfa_fwltheme.cpp b/xfa/fxfa/app/xfa_fwltheme.cpp index 4c3d4de801..f36c1bcc97 100644 --- a/xfa/fxfa/app/xfa_fwltheme.cpp +++ b/xfa/fxfa/app/xfa_fwltheme.cpp @@ -21,9 +21,9 @@ #include "xfa/fwl/basewidget/ifwl_scrollbar.h" #include "xfa/fwl/core/cfwl_themebackground.h" #include "xfa/fwl/core/cfwl_themetext.h" -#include "xfa/fxfa/app/xfa_ffwidget.h" #include "xfa/fxgraphics/cfx_color.h" #include "xfa/include/fxfa/xfa_ffapp.h" +#include "xfa/include/fxfa/xfa_ffwidget.h" namespace { diff --git a/xfa/fxfa/app/xfa_rendercontext.cpp b/xfa/fxfa/app/xfa_rendercontext.cpp index a454ec0e5d..59ed31a21d 100644 --- a/xfa/fxfa/app/xfa_rendercontext.cpp +++ b/xfa/fxfa/app/xfa_rendercontext.cpp @@ -6,9 +6,9 @@ #include "xfa/include/fxfa/xfa_rendercontext.h" -#include "xfa/fxfa/app/xfa_ffwidget.h" #include "xfa/fxgraphics/include/cfx_graphics.h" #include "xfa/include/fxfa/xfa_ffpageview.h" +#include "xfa/include/fxfa/xfa_ffwidget.h" #define XFA_RENDERCONTEXT_MaxCount 30 diff --git a/xfa/include/fxfa/xfa_ffapp.h b/xfa/include/fxfa/xfa_ffapp.h index c3bae4874c..c17b9e66de 100644 --- a/xfa/include/fxfa/xfa_ffapp.h +++ b/xfa/include/fxfa/xfa_ffapp.h @@ -19,7 +19,6 @@ class CXFA_DefFontMgr; class CXFA_FWLAdapterWidgetMgr; class CXFA_FWLTheme; class CXFA_FFDocHandler; -class CXFA_FFMenuHandler; class CXFA_FontMgr; class CXFA_FileRead : public IFX_FileRead { @@ -47,7 +46,6 @@ class CXFA_FFApp : public IFWL_AdapterNative { CXFA_FFDoc* CreateDoc(IXFA_DocProvider* pProvider, CPDF_Document* pPDFDoc); IXFA_AppProvider* GetAppProvider() { return m_pProvider; } void SetDefaultFontMgr(CXFA_DefFontMgr* pFontMgr); - CXFA_FFMenuHandler* GetMenuHandler(); // IFWL_AdapterNative: IFWL_AdapterWidgetMgr* GetWidgetMgr( @@ -74,7 +72,6 @@ class CXFA_FFApp : public IFWL_AdapterNative { CXFA_FWLAdapterWidgetMgr* m_pAdapterWidgetMgr; IFWL_WidgetMgrDelegate* m_pWidgetMgrDelegate; IFX_FontMgr* m_pFDEFontMgr; - CXFA_FFMenuHandler* m_pMenuHandler; CFWL_SDAdapterThreadMgr* m_pAdapterThreadMgr; }; diff --git a/xfa/include/fxfa/xfa_ffdochandler.h b/xfa/include/fxfa/xfa_ffdochandler.h index 7eaa20b4cc..6350d65079 100644 --- a/xfa/include/fxfa/xfa_ffdochandler.h +++ b/xfa/include/fxfa/xfa_ffdochandler.h @@ -16,31 +16,9 @@ class CXFA_FFDocHandler { CXFA_FFDocHandler(); ~CXFA_FFDocHandler(); - void ReleaseDoc(CXFA_FFDoc* hDoc); - IXFA_DocProvider* GetDocProvider(CXFA_FFDoc* hDoc); - uint32_t GetDocType(CXFA_FFDoc* hDoc); - int32_t StartLoad(CXFA_FFDoc* hDoc); - int32_t DoLoad(CXFA_FFDoc* hDoc, IFX_Pause* pPause = NULL); - void StopLoad(CXFA_FFDoc* hDoc); - - CXFA_FFDocView* CreateDocView(CXFA_FFDoc* hDoc, uint32_t dwView = 0); - int32_t CountPackages(CXFA_FFDoc* hDoc); - void GetPackageName(CXFA_FFDoc* hDoc, - int32_t iPackage, - CFX_WideStringC& wsPackage); - CFDE_XMLElement* GetPackageData(CXFA_FFDoc* hDoc, - const CFX_WideStringC& wsPackage); - FX_BOOL SavePackage(CXFA_FFDoc* hDoc, - const CFX_WideStringC& wsPackage, - IFX_FileWrite* pFile, - CXFA_ChecksumContext* pCSContext = NULL); - FX_BOOL CloseDoc(CXFA_FFDoc* hDoc); - FX_BOOL ImportData(CXFA_FFDoc* hDoc, - IFX_FileRead* pStream, - FX_BOOL bXDP = TRUE); - void SetJSERuntime(CXFA_FFDoc* hDoc, FXJSE_HRUNTIME hRuntime); FXJSE_HVALUE GetXFAScriptObject(CXFA_FFDoc* hDoc); XFA_ATTRIBUTEENUM GetRestoreState(CXFA_FFDoc* hDoc); + FX_BOOL RunDocScript(CXFA_FFDoc* hDoc, XFA_SCRIPTTYPE eScriptType, const CFX_WideStringC& wsScript, diff --git a/xfa/include/fxfa/xfa_ffwidget.h b/xfa/include/fxfa/xfa_ffwidget.h new file mode 100644 index 0000000000..70ac91931a --- /dev/null +++ b/xfa/include/fxfa/xfa_ffwidget.h @@ -0,0 +1,185 @@ +// Copyright 2014 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#ifndef XFA_INCLUDE_FXFA_XFA_FFWIDGET_H_ +#define XFA_INCLUDE_FXFA_XFA_FFWIDGET_H_ + +#include + +#include "core/include/fxcodec/fx_codec_def.h" +#include "core/include/fxge/fx_ge.h" +#include "xfa/fxfa/parser/xfa_doclayout.h" +#include "xfa/include/fxfa/fxfa.h" + +class CXFA_FFPageView; +class CXFA_FFDocView; +class CXFA_FFDoc; +class CXFA_FFApp; + +inline FX_FLOAT XFA_UnitPx2Pt(FX_FLOAT fPx, FX_FLOAT fDpi) { + return fPx * 72.0f / fDpi; +} +#define XFA_FLOAT_PERCISION 0.001f +enum XFA_WIDGETITEM { + XFA_WIDGETITEM_Parent, + XFA_WIDGETITEM_FirstChild, + XFA_WIDGETITEM_NextSibling, + XFA_WIDGETITEM_PrevSibling, +}; +class CXFA_CalcData { + public: + CXFA_CalcData() : m_iRefCount(0) {} + ~CXFA_CalcData() { m_Globals.RemoveAll(); } + CFX_PtrArray m_Globals; + int32_t m_iRefCount; +}; +class CXFA_FFWidget : public CFX_PrivateData, public CXFA_ContentLayoutItem { + public: + CXFA_FFWidget(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc); + virtual ~CXFA_FFWidget(); + CXFA_FFPageView* GetPageView(); + void SetPageView(CXFA_FFPageView* pPageView); + void GetWidgetRect(CFX_RectF& rtWidget); + CFX_RectF ReCacheWidgetRect(); + uint32_t GetStatus(); + void ModifyStatus(uint32_t dwAdded, uint32_t dwRemoved); + virtual FX_BOOL GetBBox(CFX_RectF& rtBox, + uint32_t dwStatus, + FX_BOOL bDrawFocus = FALSE); + CXFA_WidgetAcc* GetDataAcc(); + FX_BOOL GetToolTip(CFX_WideString& wsToolTip); + virtual void RenderWidget(CFX_Graphics* pGS, + CFX_Matrix* pMatrix = NULL, + uint32_t dwStatus = 0, + int32_t iRotate = 0); + + virtual FX_BOOL IsLoaded(); + virtual FX_BOOL LoadWidget(); + virtual void UnloadWidget(); + virtual FX_BOOL PerformLayout(); + virtual FX_BOOL UpdateFWLData(); + virtual void UpdateWidgetProperty(); + virtual FX_BOOL OnMouseEnter(); + virtual FX_BOOL OnMouseExit(); + virtual FX_BOOL OnLButtonDown(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy); + virtual FX_BOOL OnLButtonUp(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy); + virtual FX_BOOL OnLButtonDblClk(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy); + virtual FX_BOOL OnMouseMove(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy); + virtual FX_BOOL OnMouseWheel(uint32_t dwFlags, + int16_t zDelta, + FX_FLOAT fx, + FX_FLOAT fy); + virtual FX_BOOL OnRButtonDown(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy); + virtual FX_BOOL OnRButtonUp(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy); + virtual FX_BOOL OnRButtonDblClk(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy); + + virtual FX_BOOL OnSetFocus(CXFA_FFWidget* pOldWidget); + virtual FX_BOOL OnKillFocus(CXFA_FFWidget* pNewWidget); + virtual FX_BOOL OnKeyDown(uint32_t dwKeyCode, uint32_t dwFlags); + virtual FX_BOOL OnKeyUp(uint32_t dwKeyCode, uint32_t dwFlags); + virtual FX_BOOL OnChar(uint32_t dwChar, uint32_t dwFlags); + virtual uint32_t OnHitTest(FX_FLOAT fx, FX_FLOAT fy); + virtual FX_BOOL OnSetCursor(FX_FLOAT fx, FX_FLOAT fy); + virtual FX_BOOL CanUndo() { return FALSE; } + virtual FX_BOOL CanRedo() { return FALSE; } + virtual FX_BOOL Undo() { return FALSE; } + virtual FX_BOOL Redo() { return FALSE; } + virtual FX_BOOL CanCopy() { return FALSE; } + virtual FX_BOOL CanCut() { return FALSE; } + virtual FX_BOOL CanPaste() { return FALSE; } + virtual FX_BOOL CanSelectAll() { return FALSE; } + virtual FX_BOOL CanDelete() { return CanCut(); } + virtual FX_BOOL CanDeSelect() { return CanCopy(); } + virtual FX_BOOL Copy(CFX_WideString& wsCopy) { return FALSE; } + virtual FX_BOOL Cut(CFX_WideString& wsCut) { return FALSE; } + virtual FX_BOOL Paste(const CFX_WideString& wsPaste) { return FALSE; } + virtual FX_BOOL SelectAll() { return FALSE; } + virtual FX_BOOL Delete() { return FALSE; } + virtual FX_BOOL DeSelect() { return FALSE; } + virtual FX_BOOL GetSuggestWords(CFX_PointF pointf, + std::vector& sSuggest) { + return FALSE; + } + virtual FX_BOOL ReplaceSpellCheckWord(CFX_PointF pointf, + const CFX_ByteStringC& bsReplace) { + return FALSE; + } + CXFA_FFDocView* GetDocView(); + void SetDocView(CXFA_FFDocView* pDocView) { m_pDocView = pDocView; } + CXFA_FFDoc* GetDoc(); + CXFA_FFApp* GetApp(); + IXFA_AppProvider* GetAppProvider(); + void InvalidateWidget(const CFX_RectF* pRect = NULL); + void AddInvalidateRect(const CFX_RectF* pRect = NULL); + FX_BOOL GetCaptionText(CFX_WideString& wsCap); + FX_BOOL IsFocused(); + void Rotate2Normal(FX_FLOAT& fx, FX_FLOAT& fy); + void GetRotateMatrix(CFX_Matrix& mt); + FX_BOOL IsLayoutRectEmpty(); + CXFA_FFWidget* GetParent(); + FX_BOOL IsAncestorOf(CXFA_FFWidget* pWidget); + + protected: + virtual FX_BOOL PtInActiveRect(FX_FLOAT fx, FX_FLOAT fy); + void DrawBorder(CFX_Graphics* pGS, + CXFA_Box box, + const CFX_RectF& rtBorder, + CFX_Matrix* pMatrix, + uint32_t dwFlags = 0); + void GetMinMaxWidth(FX_FLOAT fMinWidth, FX_FLOAT fMaxWidth); + void GetMinMaxHeight(FX_FLOAT fMinHeight, FX_FLOAT fMaxHeight); + void GetRectWithoutRotate(CFX_RectF& rtWidget); + FX_BOOL IsMatchVisibleStatus(uint32_t dwStatus); + + void EventKillFocus(); + FX_BOOL IsButtonDown(); + void SetButtonDown(FX_BOOL bSet); + CXFA_FFDocView* m_pDocView; + CXFA_FFPageView* m_pPageView; + CXFA_WidgetAcc* m_pDataAcc; + CFX_RectF m_rtWidget; +}; +int32_t XFA_StrokeTypeSetLineDash(CFX_Graphics* pGraphics, + int32_t iStrokeType, + int32_t iCapType); +CFX_GraphStateData::LineCap XFA_LineCapToFXGE(int32_t iLineCap); +void XFA_DrawImage(CFX_Graphics* pGS, + const CFX_RectF& rtImage, + CFX_Matrix* pMatrix, + CFX_DIBitmap* pDIBitmap, + int32_t iAspect, + int32_t iImageXDpi, + int32_t iImageYDpi, + int32_t iHorzAlign = XFA_ATTRIBUTEENUM_Left, + int32_t iVertAlign = XFA_ATTRIBUTEENUM_Top); +CFX_DIBitmap* XFA_LoadImageData(CXFA_FFDoc* pDoc, + CXFA_Image* pImage, + FX_BOOL& bNameImage, + int32_t& iImageXDpi, + int32_t& iImageYDpi); +CFX_DIBitmap* XFA_LoadImageFromBuffer(IFX_FileRead* pImageFileRead, + FXCODEC_IMAGE_TYPE type, + int32_t& iImageXDpi, + int32_t& iImageYDpi); +FXCODEC_IMAGE_TYPE XFA_GetImageType(const CFX_WideStringC& wsType); +FX_CHAR* XFA_Base64Encode(const uint8_t* buf, int32_t buf_len); +void XFA_RectWidthoutMargin(CFX_RectF& rt, + const CXFA_Margin& mg, + FX_BOOL bUI = FALSE); +FX_FLOAT XFA_GetEdgeThickness(const CXFA_StrokeArray& strokes, + FX_BOOL b3DStyle, + int32_t nIndex); +CXFA_FFWidget* XFA_GetWidgetFromLayoutItem(CXFA_LayoutItem* pLayoutItem); +FX_BOOL XFA_IsCreateWidget(XFA_ELEMENT iType); +#define XFA_DRAWBOX_ForceRound 1 +#define XFA_DRAWBOX_Lowered3D 2 +void XFA_DrawBox(CXFA_Box box, + CFX_Graphics* pGS, + const CFX_RectF& rtWidget, + CFX_Matrix* pMatrix, + uint32_t dwFlags = 0); + +#endif // XFA_INCLUDE_FXFA_XFA_FFWIDGET_H_ diff --git a/xfa/include/fxfa/xfa_ffwidgethandler.h b/xfa/include/fxfa/xfa_ffwidgethandler.h index 28c6b4b20b..5247208431 100644 --- a/xfa/include/fxfa/xfa_ffwidgethandler.h +++ b/xfa/include/fxfa/xfa_ffwidgethandler.h @@ -18,26 +18,11 @@ class CXFA_FFWidgetHandler { public: CXFA_FFWidgetHandler(CXFA_FFDocView* pDocView); ~CXFA_FFWidgetHandler(); + CXFA_FFWidget* CreateWidget(CXFA_FFWidget* hParent, XFA_WIDGETTYPE eType, CXFA_FFWidget* hBefore = NULL); - CXFA_FFPageView* GetPageView(CXFA_FFWidget* hWidget); - void GetRect(CXFA_FFWidget* hWidget, CFX_RectF& rt); - uint32_t GetStatus(CXFA_FFWidget* hWidget); - FX_BOOL GetBBox(CXFA_FFWidget* hWidget, - CFX_RectF& rtBox, - uint32_t dwStatus, - FX_BOOL bDrawFocus = FALSE); - CXFA_WidgetAcc* GetDataAcc(CXFA_FFWidget* hWidget); - void GetName(CXFA_FFWidget* hWidget, - CFX_WideString& wsName, - int32_t iNameType = 0); - FX_BOOL GetToolTip(CXFA_FFWidget* hWidget, CFX_WideString& wsToolTip); - void SetPrivateData(CXFA_FFWidget* hWidget, - void* module_id, - void* pData, - PD_CALLBACK_FREEDATA callback); - void* GetPrivateData(CXFA_FFWidget* hWidget, void* module_id); + FX_BOOL OnMouseEnter(CXFA_FFWidget* hWidget); FX_BOOL OnMouseExit(CXFA_FFWidget* hWidget); FX_BOOL OnLButtonDown(CXFA_FFWidget* hWidget, @@ -139,33 +124,4 @@ class CXFA_FFWidgetHandler { CXFA_FFDocView* m_pDocView; }; -class CXFA_FFMenuHandler { - public: - CXFA_FFMenuHandler(); - ~CXFA_FFMenuHandler(); - - FX_BOOL CanCopy(CXFA_FFWidget* hWidget); - FX_BOOL CanCut(CXFA_FFWidget* hWidget); - FX_BOOL CanPaste(CXFA_FFWidget* hWidget); - FX_BOOL CanSelectAll(CXFA_FFWidget* hWidget); - FX_BOOL CanDelete(CXFA_FFWidget* hWidget); - FX_BOOL CanDeSelect(CXFA_FFWidget* hWidget); - FX_BOOL Copy(CXFA_FFWidget* hWidget, CFX_WideString& wsText); - FX_BOOL Cut(CXFA_FFWidget* hWidget, CFX_WideString& wsText); - FX_BOOL Paste(CXFA_FFWidget* hWidget, const CFX_WideString& wsText); - FX_BOOL SelectAll(CXFA_FFWidget* hWidget); - FX_BOOL Delete(CXFA_FFWidget* hWidget); - FX_BOOL DeSelect(CXFA_FFWidget* hWidget); - FX_BOOL CanUndo(CXFA_FFWidget* hWidget); - FX_BOOL CanRedo(CXFA_FFWidget* hWidget); - FX_BOOL Undo(CXFA_FFWidget* hWidget); - FX_BOOL Redo(CXFA_FFWidget* hWidget); - FX_BOOL GetSuggestWords(CXFA_FFWidget* hWidget, - CFX_PointF pointf, - std::vector& sSuggest); - FX_BOOL ReplaceSpellCheckWord(CXFA_FFWidget* hWidget, - CFX_PointF pointf, - const CFX_ByteStringC& bsReplace); -}; - #endif // XFA_INCLUDE_FXFA_XFA_FFWIDGETHANDLER_H_ -- cgit v1.2.3