| 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 <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "../../../third_party/base/nonstd_unique_ptr.h" | 9 #include "../../../third_party/base/nonstd_unique_ptr.h" |
| 10 #include "../../include/fpdfdoc/fpdf_doc.h" | 10 #include "../../include/fpdfdoc/fpdf_doc.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 FX_DWORD CPDF_Bookmark::GetFontStyle() const { | 44 FX_DWORD CPDF_Bookmark::GetFontStyle() const { |
| 45 if (!m_pDict) { | 45 if (!m_pDict) { |
| 46 return 0; | 46 return 0; |
| 47 } | 47 } |
| 48 return m_pDict->GetInteger("F"); | 48 return m_pDict->GetInteger("F"); |
| 49 } | 49 } |
| 50 CFX_WideString CPDF_Bookmark::GetTitle() const { | 50 CFX_WideString CPDF_Bookmark::GetTitle() const { |
| 51 if (!m_pDict) { | 51 if (!m_pDict) { |
| 52 return CFX_WideString(); | 52 return CFX_WideString(); |
| 53 } | 53 } |
| 54 CPDF_String* pString = (CPDF_String*)m_pDict->GetElementValue("Title"); | 54 CPDF_String* pString = ToString(m_pDict->GetElementValue("Title")); |
| 55 if (!pString || pString->GetType() != PDFOBJ_STRING) { | 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 nonstd::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 } | 77 } |
| 78 if (pDest->GetType() == PDFOBJ_STRING || pDest->GetType() == PDFOBJ_NAME) { | 78 if (pDest->IsString() || pDest->GetType() == PDFOBJ_NAME) { |
| 79 CPDF_NameTree name_tree(pDocument, FX_BSTRC("Dests")); | 79 CPDF_NameTree name_tree(pDocument, FX_BSTRC("Dests")); |
| 80 CFX_ByteStringC name = pDest->GetString(); | 80 CFX_ByteStringC name = pDest->GetString(); |
| 81 return CPDF_Dest(name_tree.LookupNamedDest(pDocument, name)); | 81 return CPDF_Dest(name_tree.LookupNamedDest(pDocument, name)); |
| 82 } | 82 } |
| 83 if (pDest->GetType() == PDFOBJ_ARRAY) { | 83 if (pDest->GetType() == PDFOBJ_ARRAY) { |
| 84 return CPDF_Dest((CPDF_Array*)pDest); | 84 return CPDF_Dest((CPDF_Array*)pDest); |
| 85 } | 85 } |
| 86 return CPDF_Dest(); | 86 return CPDF_Dest(); |
| 87 } | 87 } |
| 88 CPDF_Action CPDF_Bookmark::GetAction() const { | 88 CPDF_Action CPDF_Bookmark::GetAction() const { |
| 89 if (!m_pDict) { | 89 if (!m_pDict) { |
| 90 return CPDF_Action(); | 90 return CPDF_Action(); |
| 91 } | 91 } |
| 92 return CPDF_Action(m_pDict->GetDict("A")); | 92 return CPDF_Action(m_pDict->GetDict("A")); |
| 93 } | 93 } |
| OLD | NEW |