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

Side by Side Diff: fpdfsdk/fpdfdoc.cpp

Issue 2481743004: Add FPDFDest_GetLocationInPage API (Closed)
Patch Set: Review feedback Created 4 years, 1 month 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 | « core/fpdfdoc/cpdf_dest_unittest.cpp ('k') | fpdfsdk/fpdfdoc_embeddertest.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 <set> 9 #include <set>
10 10
11 #include "core/fpdfapi/page/cpdf_page.h" 11 #include "core/fpdfapi/page/cpdf_page.h"
12 #include "core/fpdfapi/parser/cpdf_array.h" 12 #include "core/fpdfapi/parser/cpdf_array.h"
13 #include "core/fpdfapi/parser/cpdf_document.h" 13 #include "core/fpdfapi/parser/cpdf_document.h"
14 #include "core/fpdfdoc/cpdf_bookmark.h" 14 #include "core/fpdfdoc/cpdf_bookmark.h"
15 #include "core/fpdfdoc/cpdf_bookmarktree.h" 15 #include "core/fpdfdoc/cpdf_bookmarktree.h"
16 #include "core/fpdfdoc/cpdf_dest.h"
16 #include "fpdfsdk/fsdk_define.h" 17 #include "fpdfsdk/fsdk_define.h"
17 #include "third_party/base/stl_util.h" 18 #include "third_party/base/stl_util.h"
18 19
19 namespace { 20 namespace {
20 21
21 CPDF_Bookmark FindBookmark(const CPDF_BookmarkTree& tree, 22 CPDF_Bookmark FindBookmark(const CPDF_BookmarkTree& tree,
22 CPDF_Bookmark bookmark, 23 CPDF_Bookmark bookmark,
23 const CFX_WideString& title, 24 const CFX_WideString& title,
24 std::set<CPDF_Dictionary*>* visited) { 25 std::set<CPDF_Dictionary*>* visited) {
25 // Return if already checked to avoid circular calling. 26 // Return if already checked to avoid circular calling.
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 FPDF_DEST pDict) { 205 FPDF_DEST pDict) {
205 if (!pDict) 206 if (!pDict)
206 return 0; 207 return 0;
207 CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document); 208 CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document);
208 if (!pDoc) 209 if (!pDoc)
209 return 0; 210 return 0;
210 CPDF_Dest dest(static_cast<CPDF_Array*>(pDict)); 211 CPDF_Dest dest(static_cast<CPDF_Array*>(pDict));
211 return dest.GetPageIndex(pDoc); 212 return dest.GetPageIndex(pDoc);
212 } 213 }
213 214
215 DLLEXPORT FPDF_BOOL STDCALL FPDFDest_GetLocationInPage(FPDF_DEST pDict,
216 FPDF_BOOL* hasXVal,
217 FPDF_BOOL* hasYVal,
218 FPDF_BOOL* hasZoomVal,
219 FS_FLOAT* x,
220 FS_FLOAT* y,
221 FS_FLOAT* zoom) {
222 if (!pDict)
223 return false;
224
225 std::unique_ptr<CPDF_Dest> dest(
226 new CPDF_Dest(static_cast<CPDF_Object*>(pDict)));
227
228 // FPDF_BOOL is an int, GetXYZ expects bools.
229 bool bHasX;
230 bool bHasY;
231 bool bHasZoom;
232 if (!dest->GetXYZ(&bHasX, &bHasY, &bHasZoom, x, y, zoom))
233 return false;
234
235 *hasXVal = bHasX;
236 *hasYVal = bHasY;
237 *hasZoomVal = bHasZoom;
238 return true;
239 }
240
214 DLLEXPORT FPDF_LINK STDCALL FPDFLink_GetLinkAtPoint(FPDF_PAGE page, 241 DLLEXPORT FPDF_LINK STDCALL FPDFLink_GetLinkAtPoint(FPDF_PAGE page,
215 double x, 242 double x,
216 double y) { 243 double y) {
217 CPDF_Page* pPage = CPDFPageFromFPDFPage(page); 244 CPDF_Page* pPage = CPDFPageFromFPDFPage(page);
218 if (!pPage) 245 if (!pPage)
219 return nullptr; 246 return nullptr;
220 247
221 CPDF_LinkList* pLinkList = GetLinkList(pPage); 248 CPDF_LinkList* pLinkList = GetLinkList(pPage);
222 if (!pLinkList) 249 if (!pLinkList)
223 return nullptr; 250 return nullptr;
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 return 0; 385 return 0;
359 CFX_WideString text = pInfo->GetUnicodeTextFor(tag); 386 CFX_WideString text = pInfo->GetUnicodeTextFor(tag);
360 // Use UTF-16LE encoding 387 // Use UTF-16LE encoding
361 CFX_ByteString encodedText = text.UTF16LE_Encode(); 388 CFX_ByteString encodedText = text.UTF16LE_Encode();
362 unsigned long len = encodedText.GetLength(); 389 unsigned long len = encodedText.GetLength();
363 if (buffer && buflen >= len) { 390 if (buffer && buflen >= len) {
364 FXSYS_memcpy(buffer, encodedText.c_str(), len); 391 FXSYS_memcpy(buffer, encodedText.c_str(), len);
365 } 392 }
366 return len; 393 return len;
367 } 394 }
OLDNEW
« no previous file with comments | « core/fpdfdoc/cpdf_dest_unittest.cpp ('k') | fpdfsdk/fpdfdoc_embeddertest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698