| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 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 <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" | 9 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" |
| 10 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" | 10 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" |
| (...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 732 } | 732 } |
| 733 | 733 |
| 734 void CPDFSDK_BAAnnot::SetBorderDash(const CFX_IntArray& array) { | 734 void CPDFSDK_BAAnnot::SetBorderDash(const CFX_IntArray& array) { |
| 735 CPDF_Dictionary* pBSDict = m_pAnnot->GetAnnotDict()->GetDictBy("BS"); | 735 CPDF_Dictionary* pBSDict = m_pAnnot->GetAnnotDict()->GetDictBy("BS"); |
| 736 if (!pBSDict) { | 736 if (!pBSDict) { |
| 737 pBSDict = new CPDF_Dictionary; | 737 pBSDict = new CPDF_Dictionary; |
| 738 m_pAnnot->GetAnnotDict()->SetAt("BS", pBSDict); | 738 m_pAnnot->GetAnnotDict()->SetAt("BS", pBSDict); |
| 739 } | 739 } |
| 740 | 740 |
| 741 CPDF_Array* pArray = new CPDF_Array; | 741 CPDF_Array* pArray = new CPDF_Array; |
| 742 for (int i = 0, sz = array.GetSize(); i < sz; i++) { | 742 for (size_t i = 0, sz = array.GetSize(); i < sz; i++) |
| 743 pArray->AddInteger(array[i]); | 743 pArray->AddInteger(array[i]); |
| 744 } | |
| 745 | 744 |
| 746 pBSDict->SetAt("D", pArray); | 745 pBSDict->SetAt("D", pArray); |
| 747 } | 746 } |
| 748 | 747 |
| 749 void CPDFSDK_BAAnnot::GetBorderDash(CFX_IntArray& array) const { | 748 void CPDFSDK_BAAnnot::GetBorderDash(CFX_IntArray& array) const { |
| 750 CPDF_Array* pDash = NULL; | 749 CPDF_Array* pDash = NULL; |
| 751 | 750 |
| 752 CPDF_Array* pBorder = m_pAnnot->GetAnnotDict()->GetArrayBy("Border"); | 751 CPDF_Array* pBorder = m_pAnnot->GetAnnotDict()->GetArrayBy("Border"); |
| 753 if (pBorder) { | 752 if (pBorder) { |
| 754 pDash = pBorder->GetArrayAt(3); | 753 pDash = pBorder->GetArrayAt(3); |
| 755 } else { | 754 } else { |
| 756 CPDF_Dictionary* pBSDict = m_pAnnot->GetAnnotDict()->GetDictBy("BS"); | 755 CPDF_Dictionary* pBSDict = m_pAnnot->GetAnnotDict()->GetDictBy("BS"); |
| 757 if (pBSDict) { | 756 if (pBSDict) { |
| 758 pDash = pBSDict->GetArrayBy("D"); | 757 pDash = pBSDict->GetArrayBy("D"); |
| 759 } | 758 } |
| 760 } | 759 } |
| 761 | 760 |
| 762 if (pDash) { | 761 if (pDash) { |
| 763 for (int i = 0, sz = pDash->GetCount(); i < sz; i++) { | 762 for (size_t i = 0, sz = pDash->GetCount(); i < sz; i++) |
| 764 array.Add(pDash->GetIntegerAt(i)); | 763 array.Add(pDash->GetIntegerAt(i)); |
| 765 } | |
| 766 } | 764 } |
| 767 } | 765 } |
| 768 | 766 |
| 769 void CPDFSDK_BAAnnot::SetColor(FX_COLORREF color) { | 767 void CPDFSDK_BAAnnot::SetColor(FX_COLORREF color) { |
| 770 CPDF_Array* pArray = new CPDF_Array; | 768 CPDF_Array* pArray = new CPDF_Array; |
| 771 pArray->AddNumber((FX_FLOAT)FXSYS_GetRValue(color) / 255.0f); | 769 pArray->AddNumber((FX_FLOAT)FXSYS_GetRValue(color) / 255.0f); |
| 772 pArray->AddNumber((FX_FLOAT)FXSYS_GetGValue(color) / 255.0f); | 770 pArray->AddNumber((FX_FLOAT)FXSYS_GetGValue(color) / 255.0f); |
| 773 pArray->AddNumber((FX_FLOAT)FXSYS_GetBValue(color) / 255.0f); | 771 pArray->AddNumber((FX_FLOAT)FXSYS_GetBValue(color) / 255.0f); |
| 774 m_pAnnot->GetAnnotDict()->SetAt("C", pArray); | 772 m_pAnnot->GetAnnotDict()->SetAt("C", pArray); |
| 775 } | 773 } |
| 776 | 774 |
| 777 void CPDFSDK_BAAnnot::RemoveColor() { | 775 void CPDFSDK_BAAnnot::RemoveColor() { |
| 778 m_pAnnot->GetAnnotDict()->RemoveAt("C"); | 776 m_pAnnot->GetAnnotDict()->RemoveAt("C"); |
| 779 } | 777 } |
| 780 | 778 |
| 781 FX_BOOL CPDFSDK_BAAnnot::GetColor(FX_COLORREF& color) const { | 779 FX_BOOL CPDFSDK_BAAnnot::GetColor(FX_COLORREF& color) const { |
| 782 if (CPDF_Array* pEntry = m_pAnnot->GetAnnotDict()->GetArrayBy("C")) { | 780 if (CPDF_Array* pEntry = m_pAnnot->GetAnnotDict()->GetArrayBy("C")) { |
| 783 int nCount = pEntry->GetCount(); | 781 size_t nCount = pEntry->GetCount(); |
| 784 if (nCount == 1) { | 782 if (nCount == 1) { |
| 785 FX_FLOAT g = pEntry->GetNumberAt(0) * 255; | 783 FX_FLOAT g = pEntry->GetNumberAt(0) * 255; |
| 786 | 784 |
| 787 color = FXSYS_RGB((int)g, (int)g, (int)g); | 785 color = FXSYS_RGB((int)g, (int)g, (int)g); |
| 788 | 786 |
| 789 return TRUE; | 787 return TRUE; |
| 790 } else if (nCount == 3) { | 788 } else if (nCount == 3) { |
| 791 FX_FLOAT r = pEntry->GetNumberAt(0) * 255; | 789 FX_FLOAT r = pEntry->GetNumberAt(0) * 255; |
| 792 FX_FLOAT g = pEntry->GetNumberAt(1) * 255; | 790 FX_FLOAT g = pEntry->GetNumberAt(1) * 255; |
| 793 FX_FLOAT b = pEntry->GetNumberAt(2) * 255; | 791 FX_FLOAT b = pEntry->GetNumberAt(2) * 255; |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 956 | 954 |
| 957 CPDF_Page* CPDFSDK_Annot::GetPDFPage() { | 955 CPDF_Page* CPDFSDK_Annot::GetPDFPage() { |
| 958 return m_pPageView ? m_pPageView->GetPDFPage() : nullptr; | 956 return m_pPageView ? m_pPageView->GetPDFPage() : nullptr; |
| 959 } | 957 } |
| 960 | 958 |
| 961 #ifdef PDF_ENABLE_XFA | 959 #ifdef PDF_ENABLE_XFA |
| 962 CPDFXFA_Page* CPDFSDK_Annot::GetPDFXFAPage() { | 960 CPDFXFA_Page* CPDFSDK_Annot::GetPDFXFAPage() { |
| 963 return m_pPageView ? m_pPageView->GetPDFXFAPage() : nullptr; | 961 return m_pPageView ? m_pPageView->GetPDFXFAPage() : nullptr; |
| 964 } | 962 } |
| 965 #endif // PDF_ENABLE_XFA | 963 #endif // PDF_ENABLE_XFA |
| OLD | NEW |