1 // Copyright 2014 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.
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
7 #include "../../include/fpdfdoc/fpdf_doc.h"
8 CPDF_Bookmark CPDF_BookmarkTree::GetFirstChild(CPDF_Bookmark Parent)
10 if (Parent.m_pDict == NULL) {
11 CPDF_Dictionary* pRoot = m_pDocument->GetRoot()->GetDict("Outlines");
15 return pRoot->GetDict("First");
17 return Parent.m_pDict->GetDict("First");
19 CPDF_Bookmark CPDF_BookmarkTree::GetNextSibling(CPDF_Bookmark This)
21 if (This.m_pDict == NULL) {
24 CPDF_Dictionary *pNext = This.m_pDict->GetDict("Next");
25 return pNext == This.m_pDict ? NULL : pNext;
27 FX_DWORD CPDF_Bookmark::GetColorRef()
32 CPDF_Array* pColor = m_pDict->GetArray("C");
34 return FXSYS_RGB(0, 0, 0);
36 int r = FXSYS_round(pColor->GetNumber(0) * 255);
37 int g = FXSYS_round(pColor->GetNumber(1) * 255);
38 int b = FXSYS_round(pColor->GetNumber(2) * 255);
39 return FXSYS_RGB(r, g, b);
41 FX_DWORD CPDF_Bookmark::GetFontStyle()
46 return m_pDict->GetInteger("F");
48 CFX_WideString CPDF_Bookmark::GetTitle()
51 return CFX_WideString();
53 CPDF_String* pString = (CPDF_String*)m_pDict->GetElementValue("Title");
54 if (pString == NULL || pString->GetType() != PDFOBJ_STRING) {
55 return CFX_WideString();
57 CFX_WideString title = pString->GetUnicodeText();
58 FX_LPWSTR buf = title.LockBuffer();
59 int len = title.GetLength(), i;
60 for (i = 0; i < len; i ++)
64 title.ReleaseBuffer(len);
67 CPDF_Dest CPDF_Bookmark::GetDest(CPDF_Document* pDocument)
72 CPDF_Object* pDest = m_pDict->GetElementValue("Dest");
76 if (pDest->GetType() == PDFOBJ_STRING || pDest->GetType() == PDFOBJ_NAME) {
77 CPDF_NameTree name_tree(pDocument, FX_BSTRC("Dests"));
78 CFX_ByteStringC name = pDest->GetString();
79 return name_tree.LookupNamedDest(pDocument, name);
80 } else if (pDest->GetType() == PDFOBJ_ARRAY) {
81 return (CPDF_Array*)pDest;
85 CPDF_Action CPDF_Bookmark::GetAction()
90 return m_pDict->GetDict("A");