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 "../include/fsdk_define.h" | 7 #include "../include/fsdk_define.h" |
8 #include "../include/fpdfdoc.h" | 8 #include "../include/fpdfdoc.h" |
9 | 9 |
10 static int this_module = 0; | 10 static int this_module = 0; |
(...skipping 10 matching lines...) Expand all Loading... | |
21 CPDF_Bookmark Child = tree.GetFirstChild(This); | 21 CPDF_Bookmark Child = tree.GetFirstChild(This); |
22 while (Child != NULL) { | 22 while (Child != NULL) { |
23 // check if this item | 23 // check if this item |
24 CPDF_Bookmark Found = FindBookmark(tree, Child, title); | 24 CPDF_Bookmark Found = FindBookmark(tree, Child, title); |
25 if (Found) return Found; | 25 if (Found) return Found; |
26 Child = tree.GetNextSibling(Child); | 26 Child = tree.GetNextSibling(Child); |
27 } | 27 } |
28 return NULL; | 28 return NULL; |
29 } | 29 } |
30 | 30 |
31 DLLEXPORT FPDF_BOOKMARK STDCALL FPDFBookmark_GetFirstChild(FPDF_DOCUMENT documen t, FPDF_BOOKMARK bookmark) | |
32 { | |
33 if (document == NULL) return NULL; | |
Tom Sepez
2015/01/01 01:10:08
nit: or just !document.
Bo Xu
2015/01/05 22:46:52
Done.
| |
34 | |
35 CPDF_Document* pDoc = (CPDF_Document*)document; | |
36 CPDF_BookmarkTree tree(pDoc); | |
37 return (CPDF_Dictionary*)tree.GetFirstChild((CPDF_Dictionary*)bookmark); | |
Tom Sepez
2015/01/01 01:10:08
The cast of the return value doen't match the decl
Bo Xu
2015/01/01 06:40:38
This is an operator in CPDF_Bookmark class. I remo
| |
38 } | |
39 | |
40 DLLEXPORT FPDF_BOOKMARK STDCALL FPDFBookmark_GetNextSibling(FPDF_DOCUMENT docume nt, FPDF_BOOKMARK bookmark) | |
41 { | |
42 if (!document || !bookmark) return NULL; | |
43 | |
44 CPDF_Document* pDoc = (CPDF_Document*)document; | |
45 CPDF_BookmarkTree tree(pDoc); | |
46 return (CPDF_Dictionary*)tree.GetNextSibling((CPDF_Dictionary*)bookmark); | |
Tom Sepez
2015/01/01 01:10:08
ditto.
Bo Xu
2015/01/01 06:40:38
ditto
| |
47 } | |
48 | |
49 DLLEXPORT unsigned long STDCALL FPDFBookmark_GetTitle(FPDF_BOOKMARK bookmark, vo id* buffer, unsigned long buflen) | |
50 { | |
51 if (bookmark == NULL) return 0; | |
52 | |
Tom Sepez
2015/01/01 01:10:08
nit: or just !bookmark
Bo Xu
2015/01/05 22:46:52
Done.
| |
53 CPDF_Bookmark Bookmark = (CPDF_Dictionary*)bookmark; | |
Tom Sepez
2015/01/01 01:10:08
nit: maybe pBookmark to avoid starting local varia
Bo Xu
2015/01/05 22:46:52
Done.
| |
54 CFX_WideString title = Bookmark.GetTitle(); | |
55 CFX_ByteString bstr = title.UTF16LE_Encode(FALSE); | |
Tom Sepez
2015/01/01 01:10:08
nit: how about encoded_title instead of bstr (foll
| |
56 unsigned long len = bstr.GetLength(); | |
Tom Sepez
2015/01/01 01:10:08
nit: how about title_len instead of just len
| |
57 if (buffer != NULL && buflen >= len + 2) { | |
Tom Sepez
2015/01/01 01:10:08
nit: (buffer && buflen >= len + 2)
Bo Xu
2015/01/05 22:46:52
Done.
| |
58 FXSYS_memcpy(buffer, bstr.c_str(), len); | |
59 ((FX_BYTE*)buffer)[len] = ((FX_BYTE*)buffer)[len + 1] = 0; | |
Tom Sepez
2015/01/01 01:10:08
nit: two separate statements.
Bo Xu
2015/01/05 22:46:52
Done.
| |
60 } | |
61 return len + 2; | |
62 } | |
63 | |
31 DLLEXPORT FPDF_BOOKMARK STDCALL FPDFBookmark_Find(FPDF_DOCUMENT document, FPDF_W IDESTRING title) | 64 DLLEXPORT FPDF_BOOKMARK STDCALL FPDFBookmark_Find(FPDF_DOCUMENT document, FPDF_W IDESTRING title) |
32 { | 65 { |
33 if (document == NULL) return NULL; | 66 if (document == NULL) return NULL; |
34 if (title == NULL || title[0] == 0) return NULL; | 67 if (title == NULL || title[0] == 0) return NULL; |
35 | 68 |
36 CPDF_Document* pDoc = (CPDF_Document*)document; | 69 CPDF_Document* pDoc = (CPDF_Document*)document; |
37 CPDF_BookmarkTree tree(pDoc); | 70 CPDF_BookmarkTree tree(pDoc); |
38 | 71 |
39 FX_STRSIZE len = CFX_WideString::WStringLength(title); | 72 FX_STRSIZE len = CFX_WideString::WStringLength(title); |
40 CFX_WideString wstr = CFX_WideString::FromUTF16LE(title, len); | 73 CFX_WideString wstr = CFX_WideString::FromUTF16LE(title, len); |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
250 // Use UTF-16LE encoding | 283 // Use UTF-16LE encoding |
251 CFX_ByteString bstr = text.UTF16LE_Encode(); | 284 CFX_ByteString bstr = text.UTF16LE_Encode(); |
252 unsigned long len = bstr.GetLength(); | 285 unsigned long len = bstr.GetLength(); |
253 if (buffer != NULL && buflen >= len+2) { | 286 if (buffer != NULL && buflen >= len+2) { |
254 FXSYS_memcpy(buffer, bstr.c_str(), len); | 287 FXSYS_memcpy(buffer, bstr.c_str(), len); |
255 // use double zero as trailer | 288 // use double zero as trailer |
256 ((FX_BYTE*)buffer)[len] = ((FX_BYTE*)buffer)[len+1] = 0; | 289 ((FX_BYTE*)buffer)[len] = ((FX_BYTE*)buffer)[len+1] = 0; |
257 } | 290 } |
258 return len+2; | 291 return len+2; |
259 } | 292 } |
260 | |
OLD | NEW |