| OLD | NEW |
| 1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #include "fpdfsdk/cpdfsdk_widget.h" | 7 #include "fpdfsdk/cpdfsdk_widget.h" |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| 11 #include "core/fpdfapi/parser/cpdf_dictionary.h" | 11 #include "core/fpdfapi/parser/cpdf_dictionary.h" |
| 12 #include "core/fpdfapi/parser/cpdf_document.h" | 12 #include "core/fpdfapi/parser/cpdf_document.h" |
| 13 #include "core/fpdfapi/parser/cpdf_stream.h" | 13 #include "core/fpdfapi/parser/cpdf_stream.h" |
| 14 #include "core/fpdfdoc/cpdf_defaultappearance.h" | 14 #include "core/fpdfdoc/cpdf_defaultappearance.h" |
| 15 #include "core/fpdfdoc/cpdf_formcontrol.h" | 15 #include "core/fpdfdoc/cpdf_formcontrol.h" |
| 16 #include "core/fpdfdoc/cpdf_formfield.h" | 16 #include "core/fpdfdoc/cpdf_formfield.h" |
| 17 #include "core/fpdfdoc/cpdf_iconfit.h" | 17 #include "core/fpdfdoc/cpdf_iconfit.h" |
| 18 #include "core/fpdfdoc/cpdf_interform.h" | 18 #include "core/fpdfdoc/cpdf_interform.h" |
| 19 #include "core/fxge/cfx_graphstatedata.h" | 19 #include "core/fxge/cfx_graphstatedata.h" |
| 20 #include "core/fxge/cfx_pathdata.h" | 20 #include "core/fxge/cfx_pathdata.h" |
| 21 #include "core/fxge/cfx_renderdevice.h" | 21 #include "core/fxge/cfx_renderdevice.h" |
| 22 #include "fpdfsdk/cpdfsdk_document.h" | 22 #include "fpdfsdk/cpdfsdk_document.h" |
| 23 #include "fpdfsdk/cpdfsdk_environment.h" | 23 #include "fpdfsdk/cpdfsdk_formfillenvironment.h" |
| 24 #include "fpdfsdk/cpdfsdk_interform.h" | 24 #include "fpdfsdk/cpdfsdk_interform.h" |
| 25 #include "fpdfsdk/cpdfsdk_pageview.h" | 25 #include "fpdfsdk/cpdfsdk_pageview.h" |
| 26 #include "fpdfsdk/formfiller/cba_fontmap.h" | 26 #include "fpdfsdk/formfiller/cba_fontmap.h" |
| 27 #include "fpdfsdk/fsdk_actionhandler.h" | 27 #include "fpdfsdk/fsdk_actionhandler.h" |
| 28 #include "fpdfsdk/fsdk_define.h" | 28 #include "fpdfsdk/fsdk_define.h" |
| 29 #include "fpdfsdk/fxedit/fxet_edit.h" | 29 #include "fpdfsdk/fxedit/fxet_edit.h" |
| 30 #include "fpdfsdk/pdfwindow/PWL_Edit.h" | 30 #include "fpdfsdk/pdfwindow/PWL_Edit.h" |
| 31 #include "fpdfsdk/pdfwindow/PWL_Utils.h" | 31 #include "fpdfsdk/pdfwindow/PWL_Utils.h" |
| 32 | 32 |
| 33 #ifdef PDF_ENABLE_XFA | 33 #ifdef PDF_ENABLE_XFA |
| (...skipping 812 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 846 int nFieldType = GetFieldType(); | 846 int nFieldType = GetFieldType(); |
| 847 if (!m_pInterForm->IsNeedHighLight(nFieldType)) | 847 if (!m_pInterForm->IsNeedHighLight(nFieldType)) |
| 848 return; | 848 return; |
| 849 | 849 |
| 850 CFX_FloatRect rc = GetRect(); | 850 CFX_FloatRect rc = GetRect(); |
| 851 FX_COLORREF color = m_pInterForm->GetHighlightColor(nFieldType); | 851 FX_COLORREF color = m_pInterForm->GetHighlightColor(nFieldType); |
| 852 uint8_t alpha = m_pInterForm->GetHighlightAlpha(); | 852 uint8_t alpha = m_pInterForm->GetHighlightAlpha(); |
| 853 | 853 |
| 854 CFX_FloatRect rcDevice; | 854 CFX_FloatRect rcDevice; |
| 855 ASSERT(m_pInterForm->GetDocument()); | 855 ASSERT(m_pInterForm->GetDocument()); |
| 856 CPDFSDK_Environment* pEnv = m_pInterForm->GetDocument()->GetEnv(); | 856 CPDFSDK_FormFillEnvironment* pEnv = m_pInterForm->GetDocument()->GetEnv(); |
| 857 if (!pEnv) | 857 if (!pEnv) |
| 858 return; | 858 return; |
| 859 CFX_Matrix page2device; | 859 CFX_Matrix page2device; |
| 860 pPageView->GetCurrentMatrix(page2device); | 860 pPageView->GetCurrentMatrix(page2device); |
| 861 page2device.Transform(((FX_FLOAT)rc.left), ((FX_FLOAT)rc.bottom), | 861 page2device.Transform(((FX_FLOAT)rc.left), ((FX_FLOAT)rc.bottom), |
| 862 rcDevice.left, rcDevice.bottom); | 862 rcDevice.left, rcDevice.bottom); |
| 863 page2device.Transform(((FX_FLOAT)rc.right), ((FX_FLOAT)rc.top), | 863 page2device.Transform(((FX_FLOAT)rc.right), ((FX_FLOAT)rc.top), |
| 864 rcDevice.right, rcDevice.top); | 864 rcDevice.right, rcDevice.top); |
| 865 | 865 |
| 866 rcDevice.Normalize(); | 866 rcDevice.Normalize(); |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 993 if (pDownIcon) { | 993 if (pDownIcon) { |
| 994 if (CPDF_Dictionary* pImageDict = pDownIcon->GetDict()) { | 994 if (CPDF_Dictionary* pImageDict = pDownIcon->GetDict()) { |
| 995 if (pImageDict->GetStringFor("Name").IsEmpty()) | 995 if (pImageDict->GetStringFor("Name").IsEmpty()) |
| 996 pImageDict->SetStringFor("Name", "ImgC"); | 996 pImageDict->SetStringFor("Name", "ImgC"); |
| 997 } | 997 } |
| 998 } | 998 } |
| 999 | 999 |
| 1000 CPDF_IconFit iconFit = pControl->GetIconFit(); | 1000 CPDF_IconFit iconFit = pControl->GetIconFit(); |
| 1001 | 1001 |
| 1002 CPDFSDK_Document* pDoc = m_pInterForm->GetDocument(); | 1002 CPDFSDK_Document* pDoc = m_pInterForm->GetDocument(); |
| 1003 CPDFSDK_Environment* pEnv = pDoc->GetEnv(); | 1003 CPDFSDK_FormFillEnvironment* pEnv = pDoc->GetEnv(); |
| 1004 | 1004 |
| 1005 CBA_FontMap font_map(this, pEnv->GetSysHandler()); | 1005 CBA_FontMap font_map(this, pEnv->GetSysHandler()); |
| 1006 font_map.SetAPType("N"); | 1006 font_map.SetAPType("N"); |
| 1007 | 1007 |
| 1008 CFX_ByteString csAP = | 1008 CFX_ByteString csAP = |
| 1009 CPWL_Utils::GetRectFillAppStream(rcWindow, crBackground) + | 1009 CPWL_Utils::GetRectFillAppStream(rcWindow, crBackground) + |
| 1010 CPWL_Utils::GetBorderAppStream(rcWindow, fBorderWidth, crBorder, | 1010 CPWL_Utils::GetBorderAppStream(rcWindow, fBorderWidth, crBorder, |
| 1011 crLeftTop, crRightBottom, nBorderStyle, | 1011 crLeftTop, crRightBottom, nBorderStyle, |
| 1012 dsBorder) + | 1012 dsBorder) + |
| 1013 CPWL_Utils::GetPushButtonAppStream( | 1013 CPWL_Utils::GetPushButtonAppStream( |
| (...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1371 | 1371 |
| 1372 CFX_FloatRect rcClient = GetClientRect(); | 1372 CFX_FloatRect rcClient = GetClientRect(); |
| 1373 CFX_FloatRect rcButton = rcClient; | 1373 CFX_FloatRect rcButton = rcClient; |
| 1374 rcButton.left = rcButton.right - 13; | 1374 rcButton.left = rcButton.right - 13; |
| 1375 rcButton.Normalize(); | 1375 rcButton.Normalize(); |
| 1376 | 1376 |
| 1377 std::unique_ptr<CFX_Edit> pEdit(new CFX_Edit); | 1377 std::unique_ptr<CFX_Edit> pEdit(new CFX_Edit); |
| 1378 pEdit->EnableRefresh(FALSE); | 1378 pEdit->EnableRefresh(FALSE); |
| 1379 | 1379 |
| 1380 CPDFSDK_Document* pDoc = m_pInterForm->GetDocument(); | 1380 CPDFSDK_Document* pDoc = m_pInterForm->GetDocument(); |
| 1381 CPDFSDK_Environment* pEnv = pDoc->GetEnv(); | 1381 CPDFSDK_FormFillEnvironment* pEnv = pDoc->GetEnv(); |
| 1382 CBA_FontMap font_map(this, pEnv->GetSysHandler()); | 1382 CBA_FontMap font_map(this, pEnv->GetSysHandler()); |
| 1383 pEdit->SetFontMap(&font_map); | 1383 pEdit->SetFontMap(&font_map); |
| 1384 | 1384 |
| 1385 CFX_FloatRect rcEdit = rcClient; | 1385 CFX_FloatRect rcEdit = rcClient; |
| 1386 rcEdit.right = rcButton.left; | 1386 rcEdit.right = rcButton.left; |
| 1387 rcEdit.Normalize(); | 1387 rcEdit.Normalize(); |
| 1388 | 1388 |
| 1389 pEdit->SetPlateRect(rcEdit); | 1389 pEdit->SetPlateRect(rcEdit); |
| 1390 pEdit->SetAlignmentV(1, TRUE); | 1390 pEdit->SetAlignmentV(1, TRUE); |
| 1391 | 1391 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1437 void CPDFSDK_Widget::ResetAppearance_ListBox() { | 1437 void CPDFSDK_Widget::ResetAppearance_ListBox() { |
| 1438 CPDF_FormControl* pControl = GetFormControl(); | 1438 CPDF_FormControl* pControl = GetFormControl(); |
| 1439 CPDF_FormField* pField = pControl->GetField(); | 1439 CPDF_FormField* pField = pControl->GetField(); |
| 1440 CFX_FloatRect rcClient = GetClientRect(); | 1440 CFX_FloatRect rcClient = GetClientRect(); |
| 1441 CFX_ByteTextBuf sBody, sLines; | 1441 CFX_ByteTextBuf sBody, sLines; |
| 1442 | 1442 |
| 1443 std::unique_ptr<CFX_Edit> pEdit(new CFX_Edit); | 1443 std::unique_ptr<CFX_Edit> pEdit(new CFX_Edit); |
| 1444 pEdit->EnableRefresh(FALSE); | 1444 pEdit->EnableRefresh(FALSE); |
| 1445 | 1445 |
| 1446 CPDFSDK_Document* pDoc = m_pInterForm->GetDocument(); | 1446 CPDFSDK_Document* pDoc = m_pInterForm->GetDocument(); |
| 1447 CPDFSDK_Environment* pEnv = pDoc->GetEnv(); | 1447 CPDFSDK_FormFillEnvironment* pEnv = pDoc->GetEnv(); |
| 1448 | 1448 |
| 1449 CBA_FontMap font_map(this, pEnv->GetSysHandler()); | 1449 CBA_FontMap font_map(this, pEnv->GetSysHandler()); |
| 1450 pEdit->SetFontMap(&font_map); | 1450 pEdit->SetFontMap(&font_map); |
| 1451 | 1451 |
| 1452 pEdit->SetPlateRect(CFX_FloatRect(rcClient.left, 0.0f, rcClient.right, 0.0f)); | 1452 pEdit->SetPlateRect(CFX_FloatRect(rcClient.left, 0.0f, rcClient.right, 0.0f)); |
| 1453 | 1453 |
| 1454 FX_FLOAT fFontSize = GetFontSize(); | 1454 FX_FLOAT fFontSize = GetFontSize(); |
| 1455 | 1455 |
| 1456 pEdit->SetFontSize(IsFloatZero(fFontSize) ? 12.0f : fFontSize); | 1456 pEdit->SetFontSize(IsFloatZero(fFontSize) ? 12.0f : fFontSize); |
| 1457 | 1457 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1524 | 1524 |
| 1525 void CPDFSDK_Widget::ResetAppearance_TextField(const CFX_WideString* sValue) { | 1525 void CPDFSDK_Widget::ResetAppearance_TextField(const CFX_WideString* sValue) { |
| 1526 CPDF_FormControl* pControl = GetFormControl(); | 1526 CPDF_FormControl* pControl = GetFormControl(); |
| 1527 CPDF_FormField* pField = pControl->GetField(); | 1527 CPDF_FormField* pField = pControl->GetField(); |
| 1528 CFX_ByteTextBuf sBody, sLines; | 1528 CFX_ByteTextBuf sBody, sLines; |
| 1529 | 1529 |
| 1530 std::unique_ptr<CFX_Edit> pEdit(new CFX_Edit); | 1530 std::unique_ptr<CFX_Edit> pEdit(new CFX_Edit); |
| 1531 pEdit->EnableRefresh(FALSE); | 1531 pEdit->EnableRefresh(FALSE); |
| 1532 | 1532 |
| 1533 CPDFSDK_Document* pDoc = m_pInterForm->GetDocument(); | 1533 CPDFSDK_Document* pDoc = m_pInterForm->GetDocument(); |
| 1534 CPDFSDK_Environment* pEnv = pDoc->GetEnv(); | 1534 CPDFSDK_FormFillEnvironment* pEnv = pDoc->GetEnv(); |
| 1535 | 1535 |
| 1536 CBA_FontMap font_map(this, pEnv->GetSysHandler()); | 1536 CBA_FontMap font_map(this, pEnv->GetSysHandler()); |
| 1537 pEdit->SetFontMap(&font_map); | 1537 pEdit->SetFontMap(&font_map); |
| 1538 | 1538 |
| 1539 CFX_FloatRect rcClient = GetClientRect(); | 1539 CFX_FloatRect rcClient = GetClientRect(); |
| 1540 pEdit->SetPlateRect(rcClient); | 1540 pEdit->SetPlateRect(rcClient); |
| 1541 pEdit->SetAlignmentH(pControl->GetControlAlignment(), TRUE); | 1541 pEdit->SetAlignmentH(pControl->GetControlAlignment(), TRUE); |
| 1542 | 1542 |
| 1543 uint32_t dwFieldFlags = pField->GetFieldFlags(); | 1543 uint32_t dwFieldFlags = pField->GetFieldFlags(); |
| 1544 FX_BOOL bMultiLine = (dwFieldFlags >> 12) & 1; | 1544 FX_BOOL bMultiLine = (dwFieldFlags >> 12) & 1; |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1840 | 1840 |
| 1841 void CPDFSDK_Widget::RemoveAppearance(const CFX_ByteString& sAPType) { | 1841 void CPDFSDK_Widget::RemoveAppearance(const CFX_ByteString& sAPType) { |
| 1842 if (CPDF_Dictionary* pAPDict = m_pAnnot->GetAnnotDict()->GetDictFor("AP")) | 1842 if (CPDF_Dictionary* pAPDict = m_pAnnot->GetAnnotDict()->GetDictFor("AP")) |
| 1843 pAPDict->RemoveFor(sAPType); | 1843 pAPDict->RemoveFor(sAPType); |
| 1844 } | 1844 } |
| 1845 | 1845 |
| 1846 FX_BOOL CPDFSDK_Widget::OnAAction(CPDF_AAction::AActionType type, | 1846 FX_BOOL CPDFSDK_Widget::OnAAction(CPDF_AAction::AActionType type, |
| 1847 PDFSDK_FieldAction& data, | 1847 PDFSDK_FieldAction& data, |
| 1848 CPDFSDK_PageView* pPageView) { | 1848 CPDFSDK_PageView* pPageView) { |
| 1849 CPDFSDK_Document* pDocument = pPageView->GetSDKDocument(); | 1849 CPDFSDK_Document* pDocument = pPageView->GetSDKDocument(); |
| 1850 CPDFSDK_Environment* pEnv = pDocument->GetEnv(); | 1850 CPDFSDK_FormFillEnvironment* pEnv = pDocument->GetEnv(); |
| 1851 | 1851 |
| 1852 #ifdef PDF_ENABLE_XFA | 1852 #ifdef PDF_ENABLE_XFA |
| 1853 CPDFXFA_Document* pDoc = pDocument->GetXFADocument(); | 1853 CPDFXFA_Document* pDoc = pDocument->GetXFADocument(); |
| 1854 if (CXFA_FFWidget* hWidget = GetMixXFAWidget()) { | 1854 if (CXFA_FFWidget* hWidget = GetMixXFAWidget()) { |
| 1855 XFA_EVENTTYPE eEventType = GetXFAEventType(type, data.bWillCommit); | 1855 XFA_EVENTTYPE eEventType = GetXFAEventType(type, data.bWillCommit); |
| 1856 | 1856 |
| 1857 if (eEventType != XFA_EVENT_Unknown) { | 1857 if (eEventType != XFA_EVENT_Unknown) { |
| 1858 if (CXFA_FFWidgetHandler* pXFAWidgetHandler = GetXFAWidgetHandler()) { | 1858 if (CXFA_FFWidgetHandler* pXFAWidgetHandler = GetXFAWidgetHandler()) { |
| 1859 CXFA_EventParam param; | 1859 CXFA_EventParam param; |
| 1860 param.m_eType = eEventType; | 1860 param.m_eType = eEventType; |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1947 return FALSE; | 1947 return FALSE; |
| 1948 | 1948 |
| 1949 if (!IsVisible()) | 1949 if (!IsVisible()) |
| 1950 return FALSE; | 1950 return FALSE; |
| 1951 | 1951 |
| 1952 if ((GetFieldFlags() & FIELDFLAG_READONLY) == FIELDFLAG_READONLY) | 1952 if ((GetFieldFlags() & FIELDFLAG_READONLY) == FIELDFLAG_READONLY) |
| 1953 return FALSE; | 1953 return FALSE; |
| 1954 | 1954 |
| 1955 return TRUE; | 1955 return TRUE; |
| 1956 } | 1956 } |
| OLD | NEW |