| 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 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 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" |
| 36 #include "xfa/fxfa/include/fxfa_widget.h" | 36 #include "xfa/fxfa/include/fxfa_widget.h" |
| 37 #include "xfa/fxfa/include/xfa_ffdocview.h" | 37 #include "xfa/fxfa/include/xfa_ffdocview.h" |
| 38 #include "xfa/fxfa/include/xfa_ffwidget.h" | 38 #include "xfa/fxfa/include/xfa_ffwidget.h" |
| 39 #include "xfa/fxfa/include/xfa_ffwidgethandler.h" | 39 #include "xfa/fxfa/include/xfa_ffwidgethandler.h" |
| 40 #endif // PDF_ENABLE_XFA | 40 #endif // PDF_ENABLE_XFA |
| 41 | 41 |
| 42 namespace { |
| 43 |
| 44 // Convert a FX_ARGB to a FX_COLORREF. |
| 45 FX_COLORREF ARGBToColorRef(FX_ARGB argb) { |
| 46 return (((static_cast<uint32_t>(argb) & 0x00FF0000) >> 16) | |
| 47 (static_cast<uint32_t>(argb) & 0x0000FF00) | |
| 48 ((static_cast<uint32_t>(argb) & 0x000000FF) << 16)); |
| 49 } |
| 50 |
| 51 } // namespace |
| 52 |
| 42 CPDFSDK_Widget::CPDFSDK_Widget(CPDF_Annot* pAnnot, | 53 CPDFSDK_Widget::CPDFSDK_Widget(CPDF_Annot* pAnnot, |
| 43 CPDFSDK_PageView* pPageView, | 54 CPDFSDK_PageView* pPageView, |
| 44 CPDFSDK_InterForm* pInterForm) | 55 CPDFSDK_InterForm* pInterForm) |
| 45 : CPDFSDK_BAAnnot(pAnnot, pPageView), | 56 : CPDFSDK_BAAnnot(pAnnot, pPageView), |
| 46 m_pInterForm(pInterForm), | 57 m_pInterForm(pInterForm), |
| 47 m_nAppAge(0), | 58 m_nAppAge(0), |
| 48 m_nValueAge(0) | 59 m_nValueAge(0) |
| 49 #ifdef PDF_ENABLE_XFA | 60 #ifdef PDF_ENABLE_XFA |
| 50 , | 61 , |
| 51 m_hMixXFAWidget(nullptr), | 62 m_hMixXFAWidget(nullptr), |
| (...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 548 #ifdef PDF_ENABLE_XFA | 559 #ifdef PDF_ENABLE_XFA |
| 549 CFX_WideString CPDFSDK_Widget::GetName() const { | 560 CFX_WideString CPDFSDK_Widget::GetName() const { |
| 550 CPDF_FormField* pFormField = GetFormField(); | 561 CPDF_FormField* pFormField = GetFormField(); |
| 551 return pFormField->GetFullName(); | 562 return pFormField->GetFullName(); |
| 552 } | 563 } |
| 553 #endif // PDF_ENABLE_XFA | 564 #endif // PDF_ENABLE_XFA |
| 554 | 565 |
| 555 FX_BOOL CPDFSDK_Widget::GetFillColor(FX_COLORREF& color) const { | 566 FX_BOOL CPDFSDK_Widget::GetFillColor(FX_COLORREF& color) const { |
| 556 CPDF_FormControl* pFormCtrl = GetFormControl(); | 567 CPDF_FormControl* pFormCtrl = GetFormControl(); |
| 557 int iColorType = 0; | 568 int iColorType = 0; |
| 558 color = FX_ARGBTOCOLORREF(pFormCtrl->GetBackgroundColor(iColorType)); | 569 color = ARGBToColorRef(pFormCtrl->GetBackgroundColor(iColorType)); |
| 559 | |
| 560 return iColorType != COLORTYPE_TRANSPARENT; | 570 return iColorType != COLORTYPE_TRANSPARENT; |
| 561 } | 571 } |
| 562 | 572 |
| 563 FX_BOOL CPDFSDK_Widget::GetBorderColor(FX_COLORREF& color) const { | 573 FX_BOOL CPDFSDK_Widget::GetBorderColor(FX_COLORREF& color) const { |
| 564 CPDF_FormControl* pFormCtrl = GetFormControl(); | 574 CPDF_FormControl* pFormCtrl = GetFormControl(); |
| 565 int iColorType = 0; | 575 int iColorType = 0; |
| 566 color = FX_ARGBTOCOLORREF(pFormCtrl->GetBorderColor(iColorType)); | 576 color = ARGBToColorRef(pFormCtrl->GetBorderColor(iColorType)); |
| 567 | |
| 568 return iColorType != COLORTYPE_TRANSPARENT; | 577 return iColorType != COLORTYPE_TRANSPARENT; |
| 569 } | 578 } |
| 570 | 579 |
| 571 FX_BOOL CPDFSDK_Widget::GetTextColor(FX_COLORREF& color) const { | 580 FX_BOOL CPDFSDK_Widget::GetTextColor(FX_COLORREF& color) const { |
| 572 CPDF_FormControl* pFormCtrl = GetFormControl(); | 581 CPDF_FormControl* pFormCtrl = GetFormControl(); |
| 573 CPDF_DefaultAppearance da = pFormCtrl->GetDefaultAppearance(); | 582 CPDF_DefaultAppearance da = pFormCtrl->GetDefaultAppearance(); |
| 574 if (!da.HasColor()) | 583 if (!da.HasColor()) |
| 575 return FALSE; | 584 return FALSE; |
| 576 | 585 |
| 577 FX_ARGB argb; | 586 FX_ARGB argb; |
| 578 int iColorType = COLORTYPE_TRANSPARENT; | 587 int iColorType = COLORTYPE_TRANSPARENT; |
| 579 da.GetColor(argb, iColorType); | 588 da.GetColor(argb, iColorType); |
| 580 color = FX_ARGBTOCOLORREF(argb); | 589 color = ARGBToColorRef(argb); |
| 581 | |
| 582 return iColorType != COLORTYPE_TRANSPARENT; | 590 return iColorType != COLORTYPE_TRANSPARENT; |
| 583 } | 591 } |
| 584 | 592 |
| 585 FX_FLOAT CPDFSDK_Widget::GetFontSize() const { | 593 FX_FLOAT CPDFSDK_Widget::GetFontSize() const { |
| 586 CPDF_FormControl* pFormCtrl = GetFormControl(); | 594 CPDF_FormControl* pFormCtrl = GetFormControl(); |
| 587 CPDF_DefaultAppearance pDa = pFormCtrl->GetDefaultAppearance(); | 595 CPDF_DefaultAppearance pDa = pFormCtrl->GetDefaultAppearance(); |
| 588 CFX_ByteString csFont = ""; | 596 CFX_ByteString csFont = ""; |
| 589 FX_FLOAT fFontSize = 0.0f; | 597 FX_FLOAT fFontSize = 0.0f; |
| 590 pDa.GetFont(csFont, fFontSize); | 598 pDa.GetFont(csFont, fFontSize); |
| 591 | 599 |
| (...skipping 1351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1943 return FALSE; | 1951 return FALSE; |
| 1944 | 1952 |
| 1945 if (!IsVisible()) | 1953 if (!IsVisible()) |
| 1946 return FALSE; | 1954 return FALSE; |
| 1947 | 1955 |
| 1948 if ((GetFieldFlags() & FIELDFLAG_READONLY) == FIELDFLAG_READONLY) | 1956 if ((GetFieldFlags() & FIELDFLAG_READONLY) == FIELDFLAG_READONLY) |
| 1949 return FALSE; | 1957 return FALSE; |
| 1950 | 1958 |
| 1951 return TRUE; | 1959 return TRUE; |
| 1952 } | 1960 } |
| OLD | NEW |