Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(212)

Side by Side Diff: fpdfsdk/src/fpdfdoc.cpp

Issue 1751753002: Remove implicit conversions and some cleanup (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: address comments Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « fpdfsdk/src/formfiller/FFL_IFormFiller.cpp ('k') | fpdfsdk/src/fpdfformfill.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "public/fpdf_doc.h" 7 #include "public/fpdf_doc.h"
8 8
9 #include "fpdfsdk/include/fsdk_define.h" 9 #include "fpdfsdk/include/fsdk_define.h"
10 10
11 namespace { 11 namespace {
12 12
13 int THISMODULE = 0; 13 int THISMODULE = 0;
14 14
15 CPDF_Bookmark FindBookmark(const CPDF_BookmarkTree& tree, 15 CPDF_Bookmark FindBookmark(const CPDF_BookmarkTree& tree,
16 CPDF_Bookmark bookmark, 16 CPDF_Bookmark bookmark,
17 const CFX_WideString& title) { 17 const CFX_WideString& title) {
18 if (bookmark && bookmark.GetTitle().CompareNoCase(title.c_str()) == 0) { 18 if (bookmark.GetDict() &&
19 bookmark.GetTitle().CompareNoCase(title.c_str()) == 0) {
19 // First check this item 20 // First check this item
20 return bookmark; 21 return bookmark;
21 } 22 }
22 // go into children items 23 // go into children items
23 CPDF_Bookmark child = tree.GetFirstChild(bookmark); 24 CPDF_Bookmark child = tree.GetFirstChild(bookmark);
24 while (child) { 25 while (child.GetDict()) {
25 // check if this item 26 // check if this item
26 CPDF_Bookmark found = FindBookmark(tree, child, title); 27 CPDF_Bookmark found = FindBookmark(tree, child, title);
27 if (found) 28 if (found.GetDict())
28 return found; 29 return found;
29 child = tree.GetNextSibling(child); 30 child = tree.GetNextSibling(child);
30 } 31 }
31 return CPDF_Bookmark(); 32 return CPDF_Bookmark();
32 } 33 }
33 34
34 void ReleaseLinkList(void* data) { 35 void ReleaseLinkList(void* data) {
35 delete (CPDF_LinkList*)data; 36 delete (CPDF_LinkList*)data;
36 } 37 }
37 38
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 106
106 DLLEXPORT FPDF_DEST STDCALL FPDFBookmark_GetDest(FPDF_DOCUMENT document, 107 DLLEXPORT FPDF_DEST STDCALL FPDFBookmark_GetDest(FPDF_DOCUMENT document,
107 FPDF_BOOKMARK pDict) { 108 FPDF_BOOKMARK pDict) {
108 if (!pDict) 109 if (!pDict)
109 return nullptr; 110 return nullptr;
110 CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document); 111 CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document);
111 if (!pDoc) 112 if (!pDoc)
112 return nullptr; 113 return nullptr;
113 CPDF_Bookmark bookmark(ToDictionary(static_cast<CPDF_Object*>(pDict))); 114 CPDF_Bookmark bookmark(ToDictionary(static_cast<CPDF_Object*>(pDict)));
114 CPDF_Dest dest = bookmark.GetDest(pDoc); 115 CPDF_Dest dest = bookmark.GetDest(pDoc);
115 if (dest) 116 if (dest.GetObject())
116 return dest.GetObject(); 117 return dest.GetObject();
117 // If this bookmark is not directly associated with a dest, we try to get 118 // If this bookmark is not directly associated with a dest, we try to get
118 // action 119 // action
119 CPDF_Action action = bookmark.GetAction(); 120 CPDF_Action action = bookmark.GetAction();
120 if (!action) 121 if (!action.GetDict())
121 return nullptr; 122 return nullptr;
122 return action.GetDest(pDoc).GetObject(); 123 return action.GetDest(pDoc).GetObject();
123 } 124 }
124 125
125 DLLEXPORT FPDF_ACTION STDCALL FPDFBookmark_GetAction(FPDF_BOOKMARK pDict) { 126 DLLEXPORT FPDF_ACTION STDCALL FPDFBookmark_GetAction(FPDF_BOOKMARK pDict) {
126 if (!pDict) 127 if (!pDict)
127 return NULL; 128 return NULL;
128 CPDF_Bookmark bookmark(ToDictionary(static_cast<CPDF_Object*>(pDict))); 129 CPDF_Bookmark bookmark(ToDictionary(static_cast<CPDF_Object*>(pDict)));
129 return bookmark.GetAction().GetDict(); 130 return bookmark.GetAction().GetDict();
130 } 131 }
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 return nullptr; 238 return nullptr;
238 CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document); 239 CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document);
239 if (!pDoc) 240 if (!pDoc)
240 return nullptr; 241 return nullptr;
241 CPDF_Link link(ToDictionary(static_cast<CPDF_Object*>(pDict))); 242 CPDF_Link link(ToDictionary(static_cast<CPDF_Object*>(pDict)));
242 FPDF_DEST dest = link.GetDest(pDoc).GetObject(); 243 FPDF_DEST dest = link.GetDest(pDoc).GetObject();
243 if (dest) 244 if (dest)
244 return dest; 245 return dest;
245 // If this link is not directly associated with a dest, we try to get action 246 // If this link is not directly associated with a dest, we try to get action
246 CPDF_Action action = link.GetAction(); 247 CPDF_Action action = link.GetAction();
247 if (!action) 248 if (!action.GetDict())
248 return nullptr; 249 return nullptr;
249 return action.GetDest(pDoc).GetObject(); 250 return action.GetDest(pDoc).GetObject();
250 } 251 }
251 252
252 DLLEXPORT FPDF_ACTION STDCALL FPDFLink_GetAction(FPDF_LINK pDict) { 253 DLLEXPORT FPDF_ACTION STDCALL FPDFLink_GetAction(FPDF_LINK pDict) {
253 if (!pDict) 254 if (!pDict)
254 return nullptr; 255 return nullptr;
255 256
256 CPDF_Link link(ToDictionary(static_cast<CPDF_Object*>(pDict))); 257 CPDF_Link link(ToDictionary(static_cast<CPDF_Object*>(pDict)));
257 return link.GetAction().GetDict(); 258 return link.GetAction().GetDict();
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 return 0; 347 return 0;
347 CFX_WideString text = pInfo->GetUnicodeTextBy(tag); 348 CFX_WideString text = pInfo->GetUnicodeTextBy(tag);
348 // Use UTF-16LE encoding 349 // Use UTF-16LE encoding
349 CFX_ByteString encodedText = text.UTF16LE_Encode(); 350 CFX_ByteString encodedText = text.UTF16LE_Encode();
350 unsigned long len = encodedText.GetLength(); 351 unsigned long len = encodedText.GetLength();
351 if (buffer && buflen >= len) { 352 if (buffer && buflen >= len) {
352 FXSYS_memcpy(buffer, encodedText.c_str(), len); 353 FXSYS_memcpy(buffer, encodedText.c_str(), len);
353 } 354 }
354 return len; 355 return len;
355 } 356 }
OLDNEW
« no previous file with comments | « fpdfsdk/src/formfiller/FFL_IFormFiller.cpp ('k') | fpdfsdk/src/fpdfformfill.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698