diff options
author | dsinclair <dsinclair@chromium.org> | 2016-11-08 06:55:40 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-11-08 06:55:40 -0800 |
commit | c59fa8895fa6fa8428b9b278eee6f05478ab8f56 (patch) | |
tree | 3216ee06e894144d578c07e5c655b7637bb6c59c /fpdfsdk/fpdfdoc.cpp | |
parent | 3c669a7fb05dfb602992a5d2333081daef6f002f (diff) | |
download | pdfium-c59fa8895fa6fa8428b9b278eee6f05478ab8f56.tar.xz |
Add FPDFDest_GetLocationInPage API
Add an API to get the value of the /XYZ destination parameter.
This CL was originally from https://codereview.chromium.org/1960193003/ by
halcanary@.
Review-Url: https://codereview.chromium.org/2481743004
Diffstat (limited to 'fpdfsdk/fpdfdoc.cpp')
-rw-r--r-- | fpdfsdk/fpdfdoc.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/fpdfsdk/fpdfdoc.cpp b/fpdfsdk/fpdfdoc.cpp index 5d113596bc..401b3e478b 100644 --- a/fpdfsdk/fpdfdoc.cpp +++ b/fpdfsdk/fpdfdoc.cpp @@ -13,6 +13,7 @@ #include "core/fpdfapi/parser/cpdf_document.h" #include "core/fpdfdoc/cpdf_bookmark.h" #include "core/fpdfdoc/cpdf_bookmarktree.h" +#include "core/fpdfdoc/cpdf_dest.h" #include "fpdfsdk/fsdk_define.h" #include "third_party/base/stl_util.h" @@ -211,6 +212,32 @@ DLLEXPORT unsigned long STDCALL FPDFDest_GetPageIndex(FPDF_DOCUMENT document, return dest.GetPageIndex(pDoc); } +DLLEXPORT FPDF_BOOL STDCALL FPDFDest_GetLocationInPage(FPDF_DEST pDict, + FPDF_BOOL* hasXVal, + FPDF_BOOL* hasYVal, + FPDF_BOOL* hasZoomVal, + FS_FLOAT* x, + FS_FLOAT* y, + FS_FLOAT* zoom) { + if (!pDict) + return false; + + std::unique_ptr<CPDF_Dest> dest( + new CPDF_Dest(static_cast<CPDF_Object*>(pDict))); + + // FPDF_BOOL is an int, GetXYZ expects bools. + bool bHasX; + bool bHasY; + bool bHasZoom; + if (!dest->GetXYZ(&bHasX, &bHasY, &bHasZoom, x, y, zoom)) + return false; + + *hasXVal = bHasX; + *hasYVal = bHasY; + *hasZoomVal = bHasZoom; + return true; +} + DLLEXPORT FPDF_LINK STDCALL FPDFLink_GetLinkAtPoint(FPDF_PAGE page, double x, double y) { |