Chromium Code Reviews| Index: fpdfsdk/fpdfdoc.cpp |
| diff --git a/fpdfsdk/fpdfdoc.cpp b/fpdfsdk/fpdfdoc.cpp |
| index 7473cb06711dce26a731c5e17bf492862e1ad4e2..aae2efe1156de552a52c3e4698968d930e060f84 100644 |
| --- a/fpdfsdk/fpdfdoc.cpp |
| +++ b/fpdfsdk/fpdfdoc.cpp |
| @@ -11,6 +11,8 @@ |
| #include "core/fpdfapi/fpdf_page/include/cpdf_page.h" |
| #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" |
| #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" |
| +#include "core/fpdfapi/fpdf_parser/include/cpdf_name.h" |
| +#include "core/fpdfapi/fpdf_parser/include/cpdf_number.h" |
| #include "fpdfsdk/include/fsdk_define.h" |
| #include "third_party/base/stl_util.h" |
| @@ -218,6 +220,34 @@ DLLEXPORT unsigned long STDCALL FPDFDest_GetPageIndex(FPDF_DOCUMENT document, |
| return dest.GetPageIndex(pDoc); |
| } |
| +DLLEXPORT FPDF_BOOL STDCALL FPDFDest_GetLocationInPage(FPDF_DEST pDict, |
| + FS_FLOAT* x, |
| + FS_FLOAT* y) { |
| + if (!pDict || !x || !y) |
| + 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.
|
| + CPDF_Array* dest = static_cast<CPDF_Array*>(pDict); |
| + if (dest->GetCount() < 4) { |
| + return FALSE; |
| + } |
|
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.
|
| + const CPDF_Object* xyz = dest->GetDirectObjectAt(1); |
| + if (!xyz->IsName() || xyz->AsName()->GetString() != "XYZ") { |
| + return FALSE; |
| + } |
| + const CPDF_Object* objX = dest->GetDirectObjectAt(2); |
| + const CPDF_Object* objY = dest->GetDirectObjectAt(3); |
| + if (!objX || !objX->IsNumber() || !objY || !objY->IsNumber()) { |
| + return FALSE; |
| + } |
|
dsinclair
2016/05/16 13:56:44
const CPDF_Number* objX = ToNumber(dest->GetDirect
hal.canary
2016/05/21 00:40:25
Done.
|
| + const CPDF_Number* numX = objX->AsNumber(); |
| + const CPDF_Number* numY = objY->AsNumber(); |
| + if (!numX || !numY) { |
| + return FALSE; |
| + } |
| + *x = numX->GetNumber(); |
| + *y = numY->GetNumber(); |
| + return TRUE; |
| +} |
| + |
| DLLEXPORT FPDF_LINK STDCALL FPDFLink_GetLinkAtPoint(FPDF_PAGE page, |
| double x, |
| double y) { |