From c59fa8895fa6fa8428b9b278eee6f05478ab8f56 Mon Sep 17 00:00:00 2001 From: dsinclair Date: Tue, 8 Nov 2016 06:55:40 -0800 Subject: 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 --- fpdfsdk/fpdfdoc_embeddertest.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'fpdfsdk/fpdfdoc_embeddertest.cpp') diff --git a/fpdfsdk/fpdfdoc_embeddertest.cpp b/fpdfsdk/fpdfdoc_embeddertest.cpp index 39b36c4bee..16160936e6 100644 --- a/fpdfsdk/fpdfdoc_embeddertest.cpp +++ b/fpdfsdk/fpdfdoc_embeddertest.cpp @@ -42,6 +42,31 @@ TEST_F(FPDFDocEmbeddertest, DestGetPageIndex) { EXPECT_EQ(0U, FPDFDest_GetPageIndex(document(), dest)); } +TEST_F(FPDFDocEmbeddertest, DestGetLocationInPage) { + EXPECT_TRUE(OpenDocument("named_dests.pdf")); + + // NULL FPDF_DEST case. + EXPECT_EQ(0U, FPDFDest_GetPageIndex(document(), nullptr)); + + FPDF_DEST dest = FPDF_GetNamedDestByName(document(), "First"); + EXPECT_TRUE(dest); + + FPDF_BOOL hasX; + FPDF_BOOL hasY; + FPDF_BOOL hasZoom; + FS_FLOAT x; + FS_FLOAT y; + FS_FLOAT zoom; + EXPECT_TRUE( + FPDFDest_GetLocationInPage(dest, &hasX, &hasY, &hasZoom, &x, &y, &zoom)); + EXPECT_TRUE(hasX); + EXPECT_TRUE(hasY); + EXPECT_TRUE(hasZoom); + EXPECT_EQ(0, x); + EXPECT_EQ(0, y); + EXPECT_EQ(1, zoom); +} + TEST_F(FPDFDocEmbeddertest, ActionGetFilePath) { EXPECT_TRUE(OpenDocument("launch_action.pdf")); -- cgit v1.2.3