Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(50)

Side by Side Diff: core/src/fpdfdoc/doc_link.cpp

Issue 1737593006: Re-land "Replace CPDF_Rect and CPDF_Point with CFX types." (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Ooops. Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « core/src/fpdfdoc/doc_ap.cpp ('k') | core/src/fpdfdoc/doc_vt.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "core/include/fpdfdoc/fpdf_doc.h" 7 #include "core/include/fpdfdoc/fpdf_doc.h"
8 8
9 CPDF_LinkList::CPDF_LinkList() { 9 CPDF_LinkList::CPDF_LinkList() {
10 } 10 }
(...skipping 25 matching lines...) Expand all
36 if (!pPageLinkList) 36 if (!pPageLinkList)
37 return CPDF_Link(); 37 return CPDF_Link();
38 38
39 for (size_t i = pPageLinkList->size(); i > 0; --i) { 39 for (size_t i = pPageLinkList->size(); i > 0; --i) {
40 size_t annot_index = i - 1; 40 size_t annot_index = i - 1;
41 CPDF_Dictionary* pAnnot = (*pPageLinkList)[annot_index]; 41 CPDF_Dictionary* pAnnot = (*pPageLinkList)[annot_index];
42 if (!pAnnot) 42 if (!pAnnot)
43 continue; 43 continue;
44 44
45 CPDF_Link link(pAnnot); 45 CPDF_Link link(pAnnot);
46 CPDF_Rect rect = link.GetRect(); 46 CFX_FloatRect rect = link.GetRect();
47 if (!rect.Contains(pdf_x, pdf_y)) 47 if (!rect.Contains(pdf_x, pdf_y))
48 continue; 48 continue;
49 49
50 if (z_order) 50 if (z_order)
51 *z_order = annot_index; 51 *z_order = annot_index;
52 return link; 52 return link;
53 } 53 }
54 return CPDF_Link(); 54 return CPDF_Link();
55 } 55 }
56 56
57 void CPDF_LinkList::LoadPageLinks(CPDF_Page* pPage, 57 void CPDF_LinkList::LoadPageLinks(CPDF_Page* pPage,
58 std::vector<CPDF_Dictionary*>* pList) { 58 std::vector<CPDF_Dictionary*>* pList) {
59 CPDF_Array* pAnnotList = pPage->m_pFormDict->GetArrayBy("Annots"); 59 CPDF_Array* pAnnotList = pPage->m_pFormDict->GetArrayBy("Annots");
60 if (!pAnnotList) 60 if (!pAnnotList)
61 return; 61 return;
62 62
63 for (FX_DWORD i = 0; i < pAnnotList->GetCount(); ++i) { 63 for (FX_DWORD i = 0; i < pAnnotList->GetCount(); ++i) {
64 CPDF_Dictionary* pAnnot = pAnnotList->GetDictAt(i); 64 CPDF_Dictionary* pAnnot = pAnnotList->GetDictAt(i);
65 bool add_link = (pAnnot && pAnnot->GetStringBy("Subtype") == "Link"); 65 bool add_link = (pAnnot && pAnnot->GetStringBy("Subtype") == "Link");
66 // Add non-links as nullptrs to preserve z-order. 66 // Add non-links as nullptrs to preserve z-order.
67 pList->push_back(add_link ? pAnnot : nullptr); 67 pList->push_back(add_link ? pAnnot : nullptr);
68 } 68 }
69 } 69 }
70 70
71 CPDF_Rect CPDF_Link::GetRect() { 71 CFX_FloatRect CPDF_Link::GetRect() {
72 return m_pDict->GetRectBy("Rect"); 72 return m_pDict->GetRectBy("Rect");
73 } 73 }
74 CPDF_Dest CPDF_Link::GetDest(CPDF_Document* pDoc) { 74 CPDF_Dest CPDF_Link::GetDest(CPDF_Document* pDoc) {
75 CPDF_Object* pDest = m_pDict->GetElementValue("Dest"); 75 CPDF_Object* pDest = m_pDict->GetElementValue("Dest");
76 if (!pDest) 76 if (!pDest)
77 return CPDF_Dest(); 77 return CPDF_Dest();
78 78
79 if (pDest->IsString() || pDest->IsName()) { 79 if (pDest->IsString() || pDest->IsName()) {
80 CPDF_NameTree name_tree(pDoc, "Dests"); 80 CPDF_NameTree name_tree(pDoc, "Dests");
81 CFX_ByteStringC name = pDest->GetString(); 81 CFX_ByteStringC name = pDest->GetString();
82 return CPDF_Dest(name_tree.LookupNamedDest(pDoc, name)); 82 return CPDF_Dest(name_tree.LookupNamedDest(pDoc, name));
83 } 83 }
84 if (CPDF_Array* pArray = pDest->AsArray()) 84 if (CPDF_Array* pArray = pDest->AsArray())
85 return CPDF_Dest(pArray); 85 return CPDF_Dest(pArray);
86 return CPDF_Dest(); 86 return CPDF_Dest();
87 } 87 }
88 CPDF_Action CPDF_Link::GetAction() { 88 CPDF_Action CPDF_Link::GetAction() {
89 return CPDF_Action(m_pDict->GetDictBy("A")); 89 return CPDF_Action(m_pDict->GetDictBy("A"));
90 } 90 }
OLDNEW
« no previous file with comments | « core/src/fpdfdoc/doc_ap.cpp ('k') | core/src/fpdfdoc/doc_vt.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698