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

Side by Side Diff: fpdfsdk/fpdfdoc.cpp

Issue 1960193003: pdfium_test: print out some annotations Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: 2016-05-13 (Friday) 16:05:57 EDT Created 4 years, 7 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 | « no previous file | public/fpdf_doc.h » ('j') | public/fpdf_doc.h » ('J')
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 <set> 9 #include <set>
10 10
11 #include "core/fpdfapi/fpdf_page/include/cpdf_page.h" 11 #include "core/fpdfapi/fpdf_page/include/cpdf_page.h"
12 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" 12 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h"
13 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" 13 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h"
14 #include "core/fpdfapi/fpdf_parser/include/cpdf_name.h"
15 #include "core/fpdfapi/fpdf_parser/include/cpdf_number.h"
14 #include "fpdfsdk/include/fsdk_define.h" 16 #include "fpdfsdk/include/fsdk_define.h"
15 #include "third_party/base/stl_util.h" 17 #include "third_party/base/stl_util.h"
16 18
17 namespace { 19 namespace {
18 20
19 int THISMODULE = 0; 21 int THISMODULE = 0;
20 22
21 CPDF_Bookmark FindBookmark(const CPDF_BookmarkTree& tree, 23 CPDF_Bookmark FindBookmark(const CPDF_BookmarkTree& tree,
22 CPDF_Bookmark bookmark, 24 CPDF_Bookmark bookmark,
23 const CFX_WideString& title, 25 const CFX_WideString& title,
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 FPDF_DEST pDict) { 213 FPDF_DEST pDict) {
212 if (!pDict) 214 if (!pDict)
213 return 0; 215 return 0;
214 CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document); 216 CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document);
215 if (!pDoc) 217 if (!pDoc)
216 return 0; 218 return 0;
217 CPDF_Dest dest(static_cast<CPDF_Array*>(pDict)); 219 CPDF_Dest dest(static_cast<CPDF_Array*>(pDict));
218 return dest.GetPageIndex(pDoc); 220 return dest.GetPageIndex(pDoc);
219 } 221 }
220 222
223 DLLEXPORT FPDF_BOOL STDCALL FPDFDest_GetLocationInPage(FPDF_DEST pDict,
224 FS_FLOAT* x,
225 FS_FLOAT* y) {
226 if (!pDict || !x || !y)
227 return FALSE;
dsinclair 2016/05/16 13:56:44 nit: blank line after non-{}'d statement.
hal.canary 2016/05/21 00:40:25 Done.
228 CPDF_Array* dest = static_cast<CPDF_Array*>(pDict);
229 if (dest->GetCount() < 4) {
230 return FALSE;
231 }
dsinclair 2016/05/16 13:56:44 nit: no {}'s on single line bodies (and below)
hal.canary 2016/05/21 00:40:25 Done.
232 const CPDF_Object* xyz = dest->GetDirectObjectAt(1);
233 if (!xyz->IsName() || xyz->AsName()->GetString() != "XYZ") {
234 return FALSE;
235 }
236 const CPDF_Object* objX = dest->GetDirectObjectAt(2);
237 const CPDF_Object* objY = dest->GetDirectObjectAt(3);
238 if (!objX || !objX->IsNumber() || !objY || !objY->IsNumber()) {
239 return FALSE;
240 }
dsinclair 2016/05/16 13:56:44 const CPDF_Number* objX = ToNumber(dest->GetDirect
hal.canary 2016/05/21 00:40:25 Done.
241 const CPDF_Number* numX = objX->AsNumber();
242 const CPDF_Number* numY = objY->AsNumber();
243 if (!numX || !numY) {
244 return FALSE;
245 }
246 *x = numX->GetNumber();
247 *y = numY->GetNumber();
248 return TRUE;
249 }
250
221 DLLEXPORT FPDF_LINK STDCALL FPDFLink_GetLinkAtPoint(FPDF_PAGE page, 251 DLLEXPORT FPDF_LINK STDCALL FPDFLink_GetLinkAtPoint(FPDF_PAGE page,
222 double x, 252 double x,
223 double y) { 253 double y) {
224 CPDF_Page* pPage = CPDFPageFromFPDFPage(page); 254 CPDF_Page* pPage = CPDFPageFromFPDFPage(page);
225 if (!pPage) 255 if (!pPage)
226 return nullptr; 256 return nullptr;
227 257
228 CPDF_LinkList* pLinkList = GetLinkList(pPage); 258 CPDF_LinkList* pLinkList = GetLinkList(pPage);
229 if (!pLinkList) 259 if (!pLinkList)
230 return nullptr; 260 return nullptr;
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 return 0; 395 return 0;
366 CFX_WideString text = pInfo->GetUnicodeTextBy(tag); 396 CFX_WideString text = pInfo->GetUnicodeTextBy(tag);
367 // Use UTF-16LE encoding 397 // Use UTF-16LE encoding
368 CFX_ByteString encodedText = text.UTF16LE_Encode(); 398 CFX_ByteString encodedText = text.UTF16LE_Encode();
369 unsigned long len = encodedText.GetLength(); 399 unsigned long len = encodedText.GetLength();
370 if (buffer && buflen >= len) { 400 if (buffer && buflen >= len) {
371 FXSYS_memcpy(buffer, encodedText.c_str(), len); 401 FXSYS_memcpy(buffer, encodedText.c_str(), len);
372 } 402 }
373 return len; 403 return len;
374 } 404 }
OLDNEW
« no previous file with comments | « no previous file | public/fpdf_doc.h » ('j') | public/fpdf_doc.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698