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 "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 Loading... |
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; |
| 228 |
| 229 CPDF_Array* dest = static_cast<CPDF_Array*>(pDict); |
| 230 if (dest->GetCount() < 4) |
| 231 return FALSE; |
| 232 |
| 233 const CPDF_Name* xyz = ToName(dest->GetDirectObjectAt(1)); |
| 234 const CPDF_Number* numX = ToNumber(dest->GetDirectObjectAt(2)); |
| 235 const CPDF_Number* numY = ToNumber(dest->GetDirectObjectAt(3)); |
| 236 if (!xyz || xyz->GetString() != "XYZ" || !numX || !numY) |
| 237 return FALSE; |
| 238 |
| 239 *x = numX->GetNumber(); |
| 240 *y = numY->GetNumber(); |
| 241 return TRUE; |
| 242 } |
| 243 |
221 DLLEXPORT FPDF_LINK STDCALL FPDFLink_GetLinkAtPoint(FPDF_PAGE page, | 244 DLLEXPORT FPDF_LINK STDCALL FPDFLink_GetLinkAtPoint(FPDF_PAGE page, |
222 double x, | 245 double x, |
223 double y) { | 246 double y) { |
224 CPDF_Page* pPage = CPDFPageFromFPDFPage(page); | 247 CPDF_Page* pPage = CPDFPageFromFPDFPage(page); |
225 if (!pPage) | 248 if (!pPage) |
226 return nullptr; | 249 return nullptr; |
227 | 250 |
228 CPDF_LinkList* pLinkList = GetLinkList(pPage); | 251 CPDF_LinkList* pLinkList = GetLinkList(pPage); |
229 if (!pLinkList) | 252 if (!pLinkList) |
230 return nullptr; | 253 return nullptr; |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 return 0; | 388 return 0; |
366 CFX_WideString text = pInfo->GetUnicodeTextBy(tag); | 389 CFX_WideString text = pInfo->GetUnicodeTextBy(tag); |
367 // Use UTF-16LE encoding | 390 // Use UTF-16LE encoding |
368 CFX_ByteString encodedText = text.UTF16LE_Encode(); | 391 CFX_ByteString encodedText = text.UTF16LE_Encode(); |
369 unsigned long len = encodedText.GetLength(); | 392 unsigned long len = encodedText.GetLength(); |
370 if (buffer && buflen >= len) { | 393 if (buffer && buflen >= len) { |
371 FXSYS_memcpy(buffer, encodedText.c_str(), len); | 394 FXSYS_memcpy(buffer, encodedText.c_str(), len); |
372 } | 395 } |
373 return len; | 396 return len; |
374 } | 397 } |
OLD | NEW |