summaryrefslogtreecommitdiff
path: root/fpdfsdk
diff options
context:
space:
mode:
Diffstat (limited to 'fpdfsdk')
-rw-r--r--fpdfsdk/fpdfdoc.cpp23
-rw-r--r--fpdfsdk/fpdfdoc_embeddertest.cpp7
-rw-r--r--fpdfsdk/fpdfview_c_api_test.c1
-rw-r--r--fpdfsdk/fsdk_actionhandler.cpp2
4 files changed, 28 insertions, 5 deletions
diff --git a/fpdfsdk/fpdfdoc.cpp b/fpdfsdk/fpdfdoc.cpp
index 47ecf4223b..4b51d6391d 100644
--- a/fpdfsdk/fpdfdoc.cpp
+++ b/fpdfsdk/fpdfdoc.cpp
@@ -200,14 +200,29 @@ FPDFAction_GetURIPath(FPDF_DOCUMENT document,
}
FPDF_EXPORT unsigned long FPDF_CALLCONV
-FPDFDest_GetPageIndex(FPDF_DOCUMENT document, FPDF_DEST pDict) {
- if (!pDict)
+FPDFDest_GetPageIndex(FPDF_DOCUMENT document, FPDF_DEST pDest) {
+ if (!pDest)
return 0;
+
CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document);
if (!pDoc)
return 0;
- CPDF_Dest dest(static_cast<CPDF_Array*>(pDict));
- return dest.GetPageIndex(pDoc);
+
+ CPDF_Dest dest(static_cast<CPDF_Array*>(pDest));
+ return dest.GetPageIndexDeprecated(pDoc);
+}
+
+FPDF_EXPORT long FPDF_CALLCONV FPDFDest_GetDestPageIndex(FPDF_DOCUMENT document,
+ FPDF_DEST pDest) {
+ if (!pDest)
+ return -1;
+
+ CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document);
+ if (!pDoc)
+ return -1;
+
+ CPDF_Dest dest(static_cast<CPDF_Array*>(pDest));
+ return dest.GetDestPageIndex(pDoc);
}
FPDF_EXPORT unsigned long FPDF_CALLCONV
diff --git a/fpdfsdk/fpdfdoc_embeddertest.cpp b/fpdfsdk/fpdfdoc_embeddertest.cpp
index d346330486..abe3d8c646 100644
--- a/fpdfsdk/fpdfdoc_embeddertest.cpp
+++ b/fpdfsdk/fpdfdoc_embeddertest.cpp
@@ -20,26 +20,31 @@ TEST_F(FPDFDocEmbeddertest, DestGetPageIndex) {
// NULL FPDF_DEST case.
EXPECT_EQ(0U, FPDFDest_GetPageIndex(document(), nullptr));
+ EXPECT_EQ(-1, FPDFDest_GetDestPageIndex(document(), nullptr));
// Page number directly in item from Dests NameTree.
FPDF_DEST dest = FPDF_GetNamedDestByName(document(), "First");
EXPECT_TRUE(dest);
EXPECT_EQ(1U, FPDFDest_GetPageIndex(document(), dest));
+ EXPECT_EQ(1, FPDFDest_GetDestPageIndex(document(), dest));
// Page number via object reference in item from Dests NameTree.
dest = FPDF_GetNamedDestByName(document(), "Next");
EXPECT_TRUE(dest);
EXPECT_EQ(1U, FPDFDest_GetPageIndex(document(), dest));
+ EXPECT_EQ(1, FPDFDest_GetDestPageIndex(document(), dest));
// Page number directly in item from Dests dictionary.
dest = FPDF_GetNamedDestByName(document(), "FirstAlternate");
EXPECT_TRUE(dest);
EXPECT_EQ(11U, FPDFDest_GetPageIndex(document(), dest));
+ EXPECT_EQ(11, FPDFDest_GetDestPageIndex(document(), dest));
// Invalid object reference in item from Dests NameTree.
dest = FPDF_GetNamedDestByName(document(), "LastAlternate");
EXPECT_TRUE(dest);
EXPECT_EQ(0U, FPDFDest_GetPageIndex(document(), dest));
+ EXPECT_EQ(-1, FPDFDest_GetDestPageIndex(document(), dest));
}
TEST_F(FPDFDocEmbeddertest, DestGetView) {
@@ -106,6 +111,7 @@ TEST_F(FPDFDocEmbeddertest, DestGetLocationInPage) {
// NULL FPDF_DEST case.
EXPECT_EQ(0U, FPDFDest_GetPageIndex(document(), nullptr));
+ EXPECT_EQ(-1, FPDFDest_GetDestPageIndex(document(), nullptr));
FPDF_DEST dest = FPDF_GetNamedDestByName(document(), "First");
EXPECT_TRUE(dest);
@@ -134,6 +140,7 @@ TEST_F(FPDFDocEmbeddertest, BUG_680376) {
EXPECT_TRUE(dest);
EXPECT_EQ(static_cast<unsigned long>(-1),
FPDFDest_GetPageIndex(document(), dest));
+ EXPECT_EQ(-1, FPDFDest_GetDestPageIndex(document(), dest));
}
TEST_F(FPDFDocEmbeddertest, ActionGetFilePath) {
diff --git a/fpdfsdk/fpdfview_c_api_test.c b/fpdfsdk/fpdfview_c_api_test.c
index abffb7676f..193050e84a 100644
--- a/fpdfsdk/fpdfview_c_api_test.c
+++ b/fpdfsdk/fpdfview_c_api_test.c
@@ -107,6 +107,7 @@ int CheckPDFiumCApi() {
CHK(FPDFAction_GetDest);
CHK(FPDFAction_GetFilePath);
CHK(FPDFAction_GetURIPath);
+ CHK(FPDFDest_GetDestPageIndex);
CHK(FPDFDest_GetPageIndex);
CHK(FPDFDest_GetLocationInPage);
CHK(FPDFDest_GetView);
diff --git a/fpdfsdk/fsdk_actionhandler.cpp b/fpdfsdk/fsdk_actionhandler.cpp
index 0059bb919c..49e00411b8 100644
--- a/fpdfsdk/fsdk_actionhandler.cpp
+++ b/fpdfsdk/fsdk_actionhandler.cpp
@@ -362,7 +362,7 @@ void CPDFSDK_ActionHandler::DoAction_GoTo(
ASSERT(pPDFDocument);
CPDF_Dest MyDest = action.GetDest(pPDFDocument);
- int nPageIndex = MyDest.GetPageIndex(pPDFDocument);
+ int nPageIndex = MyDest.GetPageIndexDeprecated(pPDFDocument);
int nFitType = MyDest.GetZoomMode();
const CPDF_Array* pMyArray = ToArray(MyDest.GetObject());
std::vector<float> posArray;