| 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 <memory> |
| 7 #include <vector> | 8 #include <vector> |
| 8 | 9 |
| 9 #include "core/include/fpdfdoc/fpdf_doc.h" | 10 #include "core/include/fpdfdoc/fpdf_doc.h" |
| 10 #include "third_party/base/nonstd_unique_ptr.h" | |
| 11 | 11 |
| 12 CPDF_Bookmark CPDF_BookmarkTree::GetFirstChild( | 12 CPDF_Bookmark CPDF_BookmarkTree::GetFirstChild( |
| 13 const CPDF_Bookmark& parent) const { | 13 const CPDF_Bookmark& parent) const { |
| 14 if (!parent.m_pDict) { | 14 if (!parent.m_pDict) { |
| 15 CPDF_Dictionary* pRoot = m_pDocument->GetRoot()->GetDict("Outlines"); | 15 CPDF_Dictionary* pRoot = m_pDocument->GetRoot()->GetDict("Outlines"); |
| 16 if (!pRoot) { | 16 if (!pRoot) { |
| 17 return CPDF_Bookmark(); | 17 return CPDF_Bookmark(); |
| 18 } | 18 } |
| 19 return CPDF_Bookmark(pRoot->GetDict("First")); | 19 return CPDF_Bookmark(pRoot->GetDict("First")); |
| 20 } | 20 } |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 } | 53 } |
| 54 CPDF_String* pString = ToString(m_pDict->GetElementValue("Title")); | 54 CPDF_String* pString = ToString(m_pDict->GetElementValue("Title")); |
| 55 if (!pString) | 55 if (!pString) |
| 56 return CFX_WideString(); | 56 return CFX_WideString(); |
| 57 | 57 |
| 58 CFX_WideString title = pString->GetUnicodeText(); | 58 CFX_WideString title = pString->GetUnicodeText(); |
| 59 int len = title.GetLength(); | 59 int len = title.GetLength(); |
| 60 if (!len) { | 60 if (!len) { |
| 61 return CFX_WideString(); | 61 return CFX_WideString(); |
| 62 } | 62 } |
| 63 nonstd::unique_ptr<FX_WCHAR[]> buf(new FX_WCHAR[len]); | 63 std::unique_ptr<FX_WCHAR[]> buf(new FX_WCHAR[len]); |
| 64 for (int i = 0; i < len; i++) { | 64 for (int i = 0; i < len; i++) { |
| 65 FX_WCHAR w = title[i]; | 65 FX_WCHAR w = title[i]; |
| 66 buf[i] = w > 0x20 ? w : 0x20; | 66 buf[i] = w > 0x20 ? w : 0x20; |
| 67 } | 67 } |
| 68 return CFX_WideString(buf.get(), len); | 68 return CFX_WideString(buf.get(), len); |
| 69 } | 69 } |
| 70 CPDF_Dest CPDF_Bookmark::GetDest(CPDF_Document* pDocument) const { | 70 CPDF_Dest CPDF_Bookmark::GetDest(CPDF_Document* pDocument) const { |
| 71 if (!m_pDict) | 71 if (!m_pDict) |
| 72 return CPDF_Dest(); | 72 return CPDF_Dest(); |
| 73 | 73 |
| 74 CPDF_Object* pDest = m_pDict->GetElementValue("Dest"); | 74 CPDF_Object* pDest = m_pDict->GetElementValue("Dest"); |
| 75 if (!pDest) | 75 if (!pDest) |
| 76 return CPDF_Dest(); | 76 return CPDF_Dest(); |
| 77 if (pDest->IsString() || pDest->IsName()) { | 77 if (pDest->IsString() || pDest->IsName()) { |
| 78 CPDF_NameTree name_tree(pDocument, "Dests"); | 78 CPDF_NameTree name_tree(pDocument, "Dests"); |
| 79 CFX_ByteStringC name = pDest->GetString(); | 79 CFX_ByteStringC name = pDest->GetString(); |
| 80 return CPDF_Dest(name_tree.LookupNamedDest(pDocument, name)); | 80 return CPDF_Dest(name_tree.LookupNamedDest(pDocument, name)); |
| 81 } | 81 } |
| 82 if (CPDF_Array* pArray = pDest->AsArray()) | 82 if (CPDF_Array* pArray = pDest->AsArray()) |
| 83 return CPDF_Dest(pArray); | 83 return CPDF_Dest(pArray); |
| 84 return CPDF_Dest(); | 84 return CPDF_Dest(); |
| 85 } | 85 } |
| 86 CPDF_Action CPDF_Bookmark::GetAction() const { | 86 CPDF_Action CPDF_Bookmark::GetAction() const { |
| 87 if (!m_pDict) { | 87 if (!m_pDict) { |
| 88 return CPDF_Action(); | 88 return CPDF_Action(); |
| 89 } | 89 } |
| 90 return CPDF_Action(m_pDict->GetDict("A")); | 90 return CPDF_Action(m_pDict->GetDict("A")); |
| 91 } | 91 } |
| OLD | NEW |