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/include/cpdfsdk_widget.h" | 7 #include "fpdfsdk/include/cpdfsdk_widget.h" |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
11 #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" | 11 #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" |
12 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" | 12 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" |
13 #include "core/fpdfapi/fpdf_parser/include/cpdf_stream.h" | 13 #include "core/fpdfapi/fpdf_parser/include/cpdf_stream.h" |
14 #include "core/fpdfdoc/include/cpdf_defaultappearance.h" | 14 #include "core/fpdfdoc/include/cpdf_defaultappearance.h" |
15 #include "core/fpdfdoc/include/cpdf_formcontrol.h" | 15 #include "core/fpdfdoc/include/cpdf_formcontrol.h" |
16 #include "core/fpdfdoc/include/cpdf_formfield.h" | 16 #include "core/fpdfdoc/include/cpdf_formfield.h" |
17 #include "core/fpdfdoc/include/cpdf_iconfit.h" | 17 #include "core/fpdfdoc/include/cpdf_iconfit.h" |
18 #include "core/fpdfdoc/include/cpdf_interform.h" | 18 #include "core/fpdfdoc/include/cpdf_interform.h" |
19 #include "core/fxge/include/cfx_graphstatedata.h" | 19 #include "core/fxge/include/cfx_graphstatedata.h" |
20 #include "core/fxge/include/cfx_pathdata.h" | 20 #include "core/fxge/include/cfx_pathdata.h" |
21 #include "core/fxge/include/cfx_renderdevice.h" | 21 #include "core/fxge/include/cfx_renderdevice.h" |
22 #include "fpdfsdk/formfiller/cba_fontmap.h" | 22 #include "fpdfsdk/formfiller/cba_fontmap.h" |
23 #include "fpdfsdk/fxedit/include/fxet_edit.h" | 23 #include "fpdfsdk/fxedit/include/fxet_edit.h" |
24 #include "fpdfsdk/include/cpdfdoc_environment.h" | |
25 #include "fpdfsdk/include/cpdfsdk_document.h" | 24 #include "fpdfsdk/include/cpdfsdk_document.h" |
| 25 #include "fpdfsdk/include/cpdfsdk_environment.h" |
26 #include "fpdfsdk/include/cpdfsdk_interform.h" | 26 #include "fpdfsdk/include/cpdfsdk_interform.h" |
27 #include "fpdfsdk/include/cpdfsdk_pageview.h" | 27 #include "fpdfsdk/include/cpdfsdk_pageview.h" |
28 #include "fpdfsdk/include/fsdk_actionhandler.h" | 28 #include "fpdfsdk/include/fsdk_actionhandler.h" |
29 #include "fpdfsdk/include/fsdk_define.h" | 29 #include "fpdfsdk/include/fsdk_define.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 |
34 #include "fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h" | 34 #include "fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h" |
35 #include "xfa/fxfa/include/cxfa_eventparam.h" | 35 #include "xfa/fxfa/include/cxfa_eventparam.h" |
(...skipping 802 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
838 int nFieldType = GetFieldType(); | 838 int nFieldType = GetFieldType(); |
839 if (!m_pInterForm->IsNeedHighLight(nFieldType)) | 839 if (!m_pInterForm->IsNeedHighLight(nFieldType)) |
840 return; | 840 return; |
841 | 841 |
842 CFX_FloatRect rc = GetRect(); | 842 CFX_FloatRect rc = GetRect(); |
843 FX_COLORREF color = m_pInterForm->GetHighlightColor(nFieldType); | 843 FX_COLORREF color = m_pInterForm->GetHighlightColor(nFieldType); |
844 uint8_t alpha = m_pInterForm->GetHighlightAlpha(); | 844 uint8_t alpha = m_pInterForm->GetHighlightAlpha(); |
845 | 845 |
846 CFX_FloatRect rcDevice; | 846 CFX_FloatRect rcDevice; |
847 ASSERT(m_pInterForm->GetDocument()); | 847 ASSERT(m_pInterForm->GetDocument()); |
848 CPDFDoc_Environment* pEnv = m_pInterForm->GetDocument()->GetEnv(); | 848 CPDFSDK_Environment* pEnv = m_pInterForm->GetDocument()->GetEnv(); |
849 if (!pEnv) | 849 if (!pEnv) |
850 return; | 850 return; |
851 CFX_Matrix page2device; | 851 CFX_Matrix page2device; |
852 pPageView->GetCurrentMatrix(page2device); | 852 pPageView->GetCurrentMatrix(page2device); |
853 page2device.Transform(((FX_FLOAT)rc.left), ((FX_FLOAT)rc.bottom), | 853 page2device.Transform(((FX_FLOAT)rc.left), ((FX_FLOAT)rc.bottom), |
854 rcDevice.left, rcDevice.bottom); | 854 rcDevice.left, rcDevice.bottom); |
855 page2device.Transform(((FX_FLOAT)rc.right), ((FX_FLOAT)rc.top), | 855 page2device.Transform(((FX_FLOAT)rc.right), ((FX_FLOAT)rc.top), |
856 rcDevice.right, rcDevice.top); | 856 rcDevice.right, rcDevice.top); |
857 | 857 |
858 rcDevice.Normalize(); | 858 rcDevice.Normalize(); |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
985 if (pDownIcon) { | 985 if (pDownIcon) { |
986 if (CPDF_Dictionary* pImageDict = pDownIcon->GetDict()) { | 986 if (CPDF_Dictionary* pImageDict = pDownIcon->GetDict()) { |
987 if (pImageDict->GetStringBy("Name").IsEmpty()) | 987 if (pImageDict->GetStringBy("Name").IsEmpty()) |
988 pImageDict->SetAtString("Name", "ImgC"); | 988 pImageDict->SetAtString("Name", "ImgC"); |
989 } | 989 } |
990 } | 990 } |
991 | 991 |
992 CPDF_IconFit iconFit = pControl->GetIconFit(); | 992 CPDF_IconFit iconFit = pControl->GetIconFit(); |
993 | 993 |
994 CPDFSDK_Document* pDoc = m_pInterForm->GetDocument(); | 994 CPDFSDK_Document* pDoc = m_pInterForm->GetDocument(); |
995 CPDFDoc_Environment* pEnv = pDoc->GetEnv(); | 995 CPDFSDK_Environment* pEnv = pDoc->GetEnv(); |
996 | 996 |
997 CBA_FontMap font_map(this, pEnv->GetSysHandler()); | 997 CBA_FontMap font_map(this, pEnv->GetSysHandler()); |
998 font_map.SetAPType("N"); | 998 font_map.SetAPType("N"); |
999 | 999 |
1000 CFX_ByteString csAP = | 1000 CFX_ByteString csAP = |
1001 CPWL_Utils::GetRectFillAppStream(rcWindow, crBackground) + | 1001 CPWL_Utils::GetRectFillAppStream(rcWindow, crBackground) + |
1002 CPWL_Utils::GetBorderAppStream(rcWindow, fBorderWidth, crBorder, | 1002 CPWL_Utils::GetBorderAppStream(rcWindow, fBorderWidth, crBorder, |
1003 crLeftTop, crRightBottom, nBorderStyle, | 1003 crLeftTop, crRightBottom, nBorderStyle, |
1004 dsBorder) + | 1004 dsBorder) + |
1005 CPWL_Utils::GetPushButtonAppStream( | 1005 CPWL_Utils::GetPushButtonAppStream( |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1363 | 1363 |
1364 CFX_FloatRect rcClient = GetClientRect(); | 1364 CFX_FloatRect rcClient = GetClientRect(); |
1365 CFX_FloatRect rcButton = rcClient; | 1365 CFX_FloatRect rcButton = rcClient; |
1366 rcButton.left = rcButton.right - 13; | 1366 rcButton.left = rcButton.right - 13; |
1367 rcButton.Normalize(); | 1367 rcButton.Normalize(); |
1368 | 1368 |
1369 std::unique_ptr<CFX_Edit> pEdit(new CFX_Edit); | 1369 std::unique_ptr<CFX_Edit> pEdit(new CFX_Edit); |
1370 pEdit->EnableRefresh(FALSE); | 1370 pEdit->EnableRefresh(FALSE); |
1371 | 1371 |
1372 CPDFSDK_Document* pDoc = m_pInterForm->GetDocument(); | 1372 CPDFSDK_Document* pDoc = m_pInterForm->GetDocument(); |
1373 CPDFDoc_Environment* pEnv = pDoc->GetEnv(); | 1373 CPDFSDK_Environment* pEnv = pDoc->GetEnv(); |
1374 CBA_FontMap font_map(this, pEnv->GetSysHandler()); | 1374 CBA_FontMap font_map(this, pEnv->GetSysHandler()); |
1375 pEdit->SetFontMap(&font_map); | 1375 pEdit->SetFontMap(&font_map); |
1376 | 1376 |
1377 CFX_FloatRect rcEdit = rcClient; | 1377 CFX_FloatRect rcEdit = rcClient; |
1378 rcEdit.right = rcButton.left; | 1378 rcEdit.right = rcButton.left; |
1379 rcEdit.Normalize(); | 1379 rcEdit.Normalize(); |
1380 | 1380 |
1381 pEdit->SetPlateRect(rcEdit); | 1381 pEdit->SetPlateRect(rcEdit); |
1382 pEdit->SetAlignmentV(1, TRUE); | 1382 pEdit->SetAlignmentV(1, TRUE); |
1383 | 1383 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1429 void CPDFSDK_Widget::ResetAppearance_ListBox() { | 1429 void CPDFSDK_Widget::ResetAppearance_ListBox() { |
1430 CPDF_FormControl* pControl = GetFormControl(); | 1430 CPDF_FormControl* pControl = GetFormControl(); |
1431 CPDF_FormField* pField = pControl->GetField(); | 1431 CPDF_FormField* pField = pControl->GetField(); |
1432 CFX_FloatRect rcClient = GetClientRect(); | 1432 CFX_FloatRect rcClient = GetClientRect(); |
1433 CFX_ByteTextBuf sBody, sLines; | 1433 CFX_ByteTextBuf sBody, sLines; |
1434 | 1434 |
1435 std::unique_ptr<CFX_Edit> pEdit(new CFX_Edit); | 1435 std::unique_ptr<CFX_Edit> pEdit(new CFX_Edit); |
1436 pEdit->EnableRefresh(FALSE); | 1436 pEdit->EnableRefresh(FALSE); |
1437 | 1437 |
1438 CPDFSDK_Document* pDoc = m_pInterForm->GetDocument(); | 1438 CPDFSDK_Document* pDoc = m_pInterForm->GetDocument(); |
1439 CPDFDoc_Environment* pEnv = pDoc->GetEnv(); | 1439 CPDFSDK_Environment* pEnv = pDoc->GetEnv(); |
1440 | 1440 |
1441 CBA_FontMap font_map(this, pEnv->GetSysHandler()); | 1441 CBA_FontMap font_map(this, pEnv->GetSysHandler()); |
1442 pEdit->SetFontMap(&font_map); | 1442 pEdit->SetFontMap(&font_map); |
1443 | 1443 |
1444 pEdit->SetPlateRect(CFX_FloatRect(rcClient.left, 0.0f, rcClient.right, 0.0f)); | 1444 pEdit->SetPlateRect(CFX_FloatRect(rcClient.left, 0.0f, rcClient.right, 0.0f)); |
1445 | 1445 |
1446 FX_FLOAT fFontSize = GetFontSize(); | 1446 FX_FLOAT fFontSize = GetFontSize(); |
1447 | 1447 |
1448 pEdit->SetFontSize(IsFloatZero(fFontSize) ? 12.0f : fFontSize); | 1448 pEdit->SetFontSize(IsFloatZero(fFontSize) ? 12.0f : fFontSize); |
1449 | 1449 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1516 | 1516 |
1517 void CPDFSDK_Widget::ResetAppearance_TextField(const CFX_WideString* sValue) { | 1517 void CPDFSDK_Widget::ResetAppearance_TextField(const CFX_WideString* sValue) { |
1518 CPDF_FormControl* pControl = GetFormControl(); | 1518 CPDF_FormControl* pControl = GetFormControl(); |
1519 CPDF_FormField* pField = pControl->GetField(); | 1519 CPDF_FormField* pField = pControl->GetField(); |
1520 CFX_ByteTextBuf sBody, sLines; | 1520 CFX_ByteTextBuf sBody, sLines; |
1521 | 1521 |
1522 std::unique_ptr<CFX_Edit> pEdit(new CFX_Edit); | 1522 std::unique_ptr<CFX_Edit> pEdit(new CFX_Edit); |
1523 pEdit->EnableRefresh(FALSE); | 1523 pEdit->EnableRefresh(FALSE); |
1524 | 1524 |
1525 CPDFSDK_Document* pDoc = m_pInterForm->GetDocument(); | 1525 CPDFSDK_Document* pDoc = m_pInterForm->GetDocument(); |
1526 CPDFDoc_Environment* pEnv = pDoc->GetEnv(); | 1526 CPDFSDK_Environment* pEnv = pDoc->GetEnv(); |
1527 | 1527 |
1528 CBA_FontMap font_map(this, pEnv->GetSysHandler()); | 1528 CBA_FontMap font_map(this, pEnv->GetSysHandler()); |
1529 pEdit->SetFontMap(&font_map); | 1529 pEdit->SetFontMap(&font_map); |
1530 | 1530 |
1531 CFX_FloatRect rcClient = GetClientRect(); | 1531 CFX_FloatRect rcClient = GetClientRect(); |
1532 pEdit->SetPlateRect(rcClient); | 1532 pEdit->SetPlateRect(rcClient); |
1533 pEdit->SetAlignmentH(pControl->GetControlAlignment(), TRUE); | 1533 pEdit->SetAlignmentH(pControl->GetControlAlignment(), TRUE); |
1534 | 1534 |
1535 uint32_t dwFieldFlags = pField->GetFieldFlags(); | 1535 uint32_t dwFieldFlags = pField->GetFieldFlags(); |
1536 FX_BOOL bMultiLine = (dwFieldFlags >> 12) & 1; | 1536 FX_BOOL bMultiLine = (dwFieldFlags >> 12) & 1; |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1836 | 1836 |
1837 void CPDFSDK_Widget::RemoveAppearance(const CFX_ByteString& sAPType) { | 1837 void CPDFSDK_Widget::RemoveAppearance(const CFX_ByteString& sAPType) { |
1838 if (CPDF_Dictionary* pAPDict = m_pAnnot->GetAnnotDict()->GetDictBy("AP")) | 1838 if (CPDF_Dictionary* pAPDict = m_pAnnot->GetAnnotDict()->GetDictBy("AP")) |
1839 pAPDict->RemoveAt(sAPType); | 1839 pAPDict->RemoveAt(sAPType); |
1840 } | 1840 } |
1841 | 1841 |
1842 FX_BOOL CPDFSDK_Widget::OnAAction(CPDF_AAction::AActionType type, | 1842 FX_BOOL CPDFSDK_Widget::OnAAction(CPDF_AAction::AActionType type, |
1843 PDFSDK_FieldAction& data, | 1843 PDFSDK_FieldAction& data, |
1844 CPDFSDK_PageView* pPageView) { | 1844 CPDFSDK_PageView* pPageView) { |
1845 CPDFSDK_Document* pDocument = pPageView->GetSDKDocument(); | 1845 CPDFSDK_Document* pDocument = pPageView->GetSDKDocument(); |
1846 CPDFDoc_Environment* pEnv = pDocument->GetEnv(); | 1846 CPDFSDK_Environment* pEnv = pDocument->GetEnv(); |
1847 | 1847 |
1848 #ifdef PDF_ENABLE_XFA | 1848 #ifdef PDF_ENABLE_XFA |
1849 CPDFXFA_Document* pDoc = pDocument->GetXFADocument(); | 1849 CPDFXFA_Document* pDoc = pDocument->GetXFADocument(); |
1850 if (CXFA_FFWidget* hWidget = GetMixXFAWidget()) { | 1850 if (CXFA_FFWidget* hWidget = GetMixXFAWidget()) { |
1851 XFA_EVENTTYPE eEventType = GetXFAEventType(type, data.bWillCommit); | 1851 XFA_EVENTTYPE eEventType = GetXFAEventType(type, data.bWillCommit); |
1852 | 1852 |
1853 if (eEventType != XFA_EVENT_Unknown) { | 1853 if (eEventType != XFA_EVENT_Unknown) { |
1854 if (CXFA_FFWidgetHandler* pXFAWidgetHandler = GetXFAWidgetHandler()) { | 1854 if (CXFA_FFWidgetHandler* pXFAWidgetHandler = GetXFAWidgetHandler()) { |
1855 CXFA_EventParam param; | 1855 CXFA_EventParam param; |
1856 param.m_eType = eEventType; | 1856 param.m_eType = eEventType; |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1943 return FALSE; | 1943 return FALSE; |
1944 | 1944 |
1945 if (!IsVisible()) | 1945 if (!IsVisible()) |
1946 return FALSE; | 1946 return FALSE; |
1947 | 1947 |
1948 if ((GetFieldFlags() & FIELDFLAG_READONLY) == FIELDFLAG_READONLY) | 1948 if ((GetFieldFlags() & FIELDFLAG_READONLY) == FIELDFLAG_READONLY) |
1949 return FALSE; | 1949 return FALSE; |
1950 | 1950 |
1951 return TRUE; | 1951 return TRUE; |
1952 } | 1952 } |
OLD | NEW |