Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
cpdf_bookmark.cpp
Go to the documentation of this file.
1// Copyright 2016 The PDFium Authors
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_bookmark.h"
8
9#include <utility>
10
11#include "core/fpdfapi/parser/cpdf_array.h"
12#include "core/fpdfapi/parser/cpdf_dictionary.h"
13#include "core/fpdfapi/parser/cpdf_string.h"
14#include "core/fxcrt/data_vector.h"
15#include "core/fxge/dib/fx_dib.h"
16
17CPDF_Bookmark::CPDF_Bookmark() = default;
18
19CPDF_Bookmark::CPDF_Bookmark(const CPDF_Bookmark& that) = default;
20
21CPDF_Bookmark::CPDF_Bookmark(RetainPtr<const CPDF_Dictionary> pDict)
22 : m_pDict(std::move(pDict)) {}
23
24CPDF_Bookmark::~CPDF_Bookmark() = default;
25
26WideString CPDF_Bookmark::GetTitle() const {
27 if (!m_pDict)
28 return WideString();
29
30 RetainPtr<const CPDF_String> pString =
31 ToString(m_pDict->GetDirectObjectFor("Title"));
32 if (!pString)
33 return WideString();
34
35 WideString title = pString->GetUnicodeText();
36 size_t len = title.GetLength();
37 if (!len)
38 return WideString();
39
40 DataVector<wchar_t> buf(len);
41 for (size_t i = 0; i < len; i++) {
42 wchar_t w = title[i];
43 buf[i] = w > 0x20 ? w : 0x20;
44 }
45 return WideString(buf.data(), len);
46}
47
49 if (!m_pDict)
50 return CPDF_Dest(nullptr);
51 return CPDF_Dest::Create(pDocument, m_pDict->GetDirectObjectFor("Dest"));
52}
53
55 return CPDF_Action(m_pDict ? m_pDict->GetDictFor("A") : nullptr);
56}
57
58int CPDF_Bookmark::GetCount() const {
59 return m_pDict->GetIntegerFor("Count");
60}
int GetCount() const
WideString GetTitle() const
CPDF_Bookmark(RetainPtr< const CPDF_Dictionary > pDict)
CPDF_Action GetAction() const
CPDF_Bookmark(const CPDF_Bookmark &that)
CPDF_Dest GetDest(CPDF_Document *pDocument) const