-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathPDFViewBookmarks.cpp
More file actions
75 lines (67 loc) · 2.05 KB
/
PDFViewBookmarks.cpp
File metadata and controls
75 lines (67 loc) · 2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/////////////////////////////////////////////////////////////////////////////
// Name: src/PDFViewBookmarks.cpp
// Purpose: wxPDFViewBookmarks implementation
// Author: Tobias Taschner
// Created: 2014-08-07
// Copyright: (c) 2014 Tobias Taschner
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#include "private/PDFViewBookmarks.h"
#include "private/PDFViewImpl.h"
class wxPDFViewBookmarkImpl: public wxPDFViewBookmark
{
public:
wxPDFViewBookmarkImpl(FPDF_DOCUMENT doc, FPDF_BOOKMARK bookmark):
m_bookmark(bookmark)
{
unsigned long length = FPDFBookmark_GetTitle(bookmark, NULL, 0);
if (length > 0)
{
char * buffer = new char[length];
length = FPDFBookmark_GetTitle(bookmark, buffer, length);
m_title = wxString(buffer, wxCSConv(wxFONTENCODING_UTF16LE), length);
delete [] buffer;
}
FPDF_BOOKMARK child = FPDFBookmark_GetFirstChild(doc, bookmark);
while (child)
{
wxSharedPtr<wxPDFViewBookmark> newBM(new wxPDFViewBookmarkImpl(doc, child));
push_back(newBM);
child = FPDFBookmark_GetNextSibling(doc, child);
}
}
virtual wxString GetTitle() const
{
return m_title;
}
virtual void Navigate(wxPDFView* pdfView)
{
FPDF_DOCUMENT doc = static_cast<FPDF_DOCUMENT>(pdfView->GetImpl()->GetDocument());
FPDF_ACTION action = FPDFBookmark_GetAction(m_bookmark);
FPDF_DEST dest = NULL;
if (action)
{
if (FPDFAction_GetType(action) == PDFACTION_GOTO)
{
dest = FPDFBookmark_GetDest(doc, m_bookmark);
}
} else {
dest = FPDFBookmark_GetDest(doc, m_bookmark);
}
if (dest)
{
unsigned long pageIndex = FPDFDest_GetDestPageIndex(doc, dest);
pdfView->GoToPage(pageIndex);
}
}
private:
wxString m_title;
FPDF_BOOKMARK m_bookmark;
};
wxPDFViewBookmarks::wxPDFViewBookmarks(FPDF_DOCUMENT doc)
{
FPDF_BOOKMARK emptyBM = NULL;
FPDF_BOOKMARK rootBM = FPDFBookmark_GetFirstChild(doc, emptyBM);
if (rootBM)
m_root.reset(new wxPDFViewBookmarkImpl(doc, emptyBM));
}