• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2016 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 
7 #include "core/fpdfdoc/cpdf_link.h"
8 
9 #include "core/fpdfapi/parser/cpdf_array.h"
10 #include "core/fpdfapi/parser/cpdf_dictionary.h"
11 #include "core/fpdfdoc/cpdf_nametree.h"
12 
13 CPDF_Link::CPDF_Link() = default;
14 
CPDF_Link(CPDF_Dictionary * pDict)15 CPDF_Link::CPDF_Link(CPDF_Dictionary* pDict) : m_pDict(pDict) {}
16 
17 CPDF_Link::CPDF_Link(const CPDF_Link& that) = default;
18 
19 CPDF_Link::~CPDF_Link() = default;
20 
GetRect()21 CFX_FloatRect CPDF_Link::GetRect() {
22   return m_pDict->GetRectFor("Rect");
23 }
24 
GetDest(CPDF_Document * pDoc)25 CPDF_Dest CPDF_Link::GetDest(CPDF_Document* pDoc) {
26   CPDF_Object* pDest = m_pDict->GetDirectObjectFor("Dest");
27   if (!pDest)
28     return CPDF_Dest();
29 
30   if (pDest->IsString() || pDest->IsName()) {
31     CPDF_NameTree name_tree(pDoc, "Dests");
32     return CPDF_Dest(name_tree.LookupNamedDest(pDoc, pDest->GetUnicodeText()));
33   }
34   if (CPDF_Array* pArray = pDest->AsArray())
35     return CPDF_Dest(pArray);
36   return CPDF_Dest();
37 }
38 
GetAction()39 CPDF_Action CPDF_Link::GetAction() {
40   return CPDF_Action(m_pDict->GetDictFor("A"));
41 }
42