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_interform.h" | 7 #include "fpdfsdk/include/cpdfsdk_interform.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <memory> | 10 #include <memory> |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 pWidget = it->second; | 93 pWidget = it->second; |
94 if (pWidget) | 94 if (pWidget) |
95 return pWidget; | 95 return pWidget; |
96 if (!createIfNeeded) | 96 if (!createIfNeeded) |
97 return nullptr; | 97 return nullptr; |
98 | 98 |
99 CPDF_Dictionary* pControlDict = pControl->GetWidget(); | 99 CPDF_Dictionary* pControlDict = pControl->GetWidget(); |
100 CPDF_Document* pDocument = m_pDocument->GetPDFDocument(); | 100 CPDF_Document* pDocument = m_pDocument->GetPDFDocument(); |
101 CPDFSDK_PageView* pPage = nullptr; | 101 CPDFSDK_PageView* pPage = nullptr; |
102 | 102 |
103 if (CPDF_Dictionary* pPageDict = pControlDict->GetDictBy("P")) { | 103 if (CPDF_Dictionary* pPageDict = pControlDict->GetDictFor("P")) { |
104 int nPageIndex = pDocument->GetPageIndex(pPageDict->GetObjNum()); | 104 int nPageIndex = pDocument->GetPageIndex(pPageDict->GetObjNum()); |
105 if (nPageIndex >= 0) | 105 if (nPageIndex >= 0) |
106 pPage = m_pDocument->GetPageView(nPageIndex); | 106 pPage = m_pDocument->GetPageView(nPageIndex); |
107 } | 107 } |
108 | 108 |
109 if (!pPage) { | 109 if (!pPage) { |
110 int nPageIndex = GetPageIndexByAnnotDict(pDocument, pControlDict); | 110 int nPageIndex = GetPageIndexByAnnotDict(pDocument, pControlDict); |
111 if (nPageIndex >= 0) | 111 if (nPageIndex >= 0) |
112 pPage = m_pDocument->GetPageView(nPageIndex); | 112 pPage = m_pDocument->GetPageView(nPageIndex); |
113 } | 113 } |
(...skipping 26 matching lines...) Expand all Loading... |
140 } | 140 } |
141 } | 141 } |
142 | 142 |
143 int CPDFSDK_InterForm::GetPageIndexByAnnotDict( | 143 int CPDFSDK_InterForm::GetPageIndexByAnnotDict( |
144 CPDF_Document* pDocument, | 144 CPDF_Document* pDocument, |
145 CPDF_Dictionary* pAnnotDict) const { | 145 CPDF_Dictionary* pAnnotDict) const { |
146 ASSERT(pAnnotDict); | 146 ASSERT(pAnnotDict); |
147 | 147 |
148 for (int i = 0, sz = pDocument->GetPageCount(); i < sz; i++) { | 148 for (int i = 0, sz = pDocument->GetPageCount(); i < sz; i++) { |
149 if (CPDF_Dictionary* pPageDict = pDocument->GetPage(i)) { | 149 if (CPDF_Dictionary* pPageDict = pDocument->GetPage(i)) { |
150 if (CPDF_Array* pAnnots = pPageDict->GetArrayBy("Annots")) { | 150 if (CPDF_Array* pAnnots = pPageDict->GetArrayFor("Annots")) { |
151 for (int j = 0, jsz = pAnnots->GetCount(); j < jsz; j++) { | 151 for (int j = 0, jsz = pAnnots->GetCount(); j < jsz; j++) { |
152 CPDF_Object* pDict = pAnnots->GetDirectObjectAt(j); | 152 CPDF_Object* pDict = pAnnots->GetDirectObjectAt(j); |
153 if (pAnnotDict == pDict) | 153 if (pAnnotDict == pDict) |
154 return i; | 154 return i; |
155 } | 155 } |
156 } | 156 } |
157 } | 157 } |
158 } | 158 } |
159 | 159 |
160 return -1; | 160 return -1; |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
477 CFX_WideString csTxtFile) { | 477 CFX_WideString csTxtFile) { |
478 return TRUE; | 478 return TRUE; |
479 } | 479 } |
480 | 480 |
481 FX_BOOL CPDFSDK_InterForm::FDFToURLEncodedData(uint8_t*& pBuf, | 481 FX_BOOL CPDFSDK_InterForm::FDFToURLEncodedData(uint8_t*& pBuf, |
482 FX_STRSIZE& nBufSize) { | 482 FX_STRSIZE& nBufSize) { |
483 CFDF_Document* pFDF = CFDF_Document::ParseMemory(pBuf, nBufSize); | 483 CFDF_Document* pFDF = CFDF_Document::ParseMemory(pBuf, nBufSize); |
484 if (!pFDF) | 484 if (!pFDF) |
485 return TRUE; | 485 return TRUE; |
486 | 486 |
487 CPDF_Dictionary* pMainDict = pFDF->GetRoot()->GetDictBy("FDF"); | 487 CPDF_Dictionary* pMainDict = pFDF->GetRoot()->GetDictFor("FDF"); |
488 if (!pMainDict) | 488 if (!pMainDict) |
489 return FALSE; | 489 return FALSE; |
490 | 490 |
491 CPDF_Array* pFields = pMainDict->GetArrayBy("Fields"); | 491 CPDF_Array* pFields = pMainDict->GetArrayFor("Fields"); |
492 if (!pFields) | 492 if (!pFields) |
493 return FALSE; | 493 return FALSE; |
494 | 494 |
495 CFX_ByteTextBuf fdfEncodedData; | 495 CFX_ByteTextBuf fdfEncodedData; |
496 for (uint32_t i = 0; i < pFields->GetCount(); i++) { | 496 for (uint32_t i = 0; i < pFields->GetCount(); i++) { |
497 CPDF_Dictionary* pField = pFields->GetDictAt(i); | 497 CPDF_Dictionary* pField = pFields->GetDictAt(i); |
498 if (!pField) | 498 if (!pField) |
499 continue; | 499 continue; |
500 CFX_WideString name; | 500 CFX_WideString name; |
501 name = pField->GetUnicodeTextBy("T"); | 501 name = pField->GetUnicodeTextFor("T"); |
502 CFX_ByteString name_b = CFX_ByteString::FromUnicode(name); | 502 CFX_ByteString name_b = CFX_ByteString::FromUnicode(name); |
503 CFX_ByteString csBValue = pField->GetStringBy("V"); | 503 CFX_ByteString csBValue = pField->GetStringFor("V"); |
504 CFX_WideString csWValue = PDF_DecodeText(csBValue); | 504 CFX_WideString csWValue = PDF_DecodeText(csBValue); |
505 CFX_ByteString csValue_b = CFX_ByteString::FromUnicode(csWValue); | 505 CFX_ByteString csValue_b = CFX_ByteString::FromUnicode(csWValue); |
506 | 506 |
507 fdfEncodedData << name_b.GetBuffer(name_b.GetLength()); | 507 fdfEncodedData << name_b.GetBuffer(name_b.GetLength()); |
508 name_b.ReleaseBuffer(); | 508 name_b.ReleaseBuffer(); |
509 fdfEncodedData << "="; | 509 fdfEncodedData << "="; |
510 fdfEncodedData << csValue_b.GetBuffer(csValue_b.GetLength()); | 510 fdfEncodedData << csValue_b.GetBuffer(csValue_b.GetLength()); |
511 csValue_b.ReleaseBuffer(); | 511 csValue_b.ReleaseBuffer(); |
512 if (i != pFields->GetCount() - 1) | 512 if (i != pFields->GetCount() - 1) |
513 fdfEncodedData << "&"; | 513 fdfEncodedData << "&"; |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
719 } | 719 } |
720 } | 720 } |
721 | 721 |
722 FX_COLORREF CPDFSDK_InterForm::GetHighlightColor(int nFieldType) { | 722 FX_COLORREF CPDFSDK_InterForm::GetHighlightColor(int nFieldType) { |
723 if (nFieldType < 0 || nFieldType > kNumFieldTypes) | 723 if (nFieldType < 0 || nFieldType > kNumFieldTypes) |
724 return FXSYS_RGB(255, 255, 255); | 724 return FXSYS_RGB(255, 255, 255); |
725 if (nFieldType == 0) | 725 if (nFieldType == 0) |
726 return m_aHighlightColor[0]; | 726 return m_aHighlightColor[0]; |
727 return m_aHighlightColor[nFieldType - 1]; | 727 return m_aHighlightColor[nFieldType - 1]; |
728 } | 728 } |
OLD | NEW |