Remove deprecated FPDFDest_GetPageIndex() API.

Use FPDFDest_GetDestPageIndex() instead.

BUG=pdfium:1041

Change-Id: I8e91ef46456a60ebd873068765b7c3ff1a991fa4
Reviewed-on: https://pdfium-review.googlesource.com/41230
Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/core/fpdfdoc/cpdf_dest.cpp b/core/fpdfdoc/cpdf_dest.cpp
index 58d0ac2..8dd58b1 100644
--- a/core/fpdfdoc/cpdf_dest.cpp
+++ b/core/fpdfdoc/cpdf_dest.cpp
@@ -38,24 +38,6 @@
 
 CPDF_Dest::~CPDF_Dest() {}
 
-int CPDF_Dest::GetPageIndexDeprecated(CPDF_Document* pDoc) const {
-  const CPDF_Array* pArray = ToArray(m_pObj.Get());
-  if (!pArray)
-    return 0;
-
-  const CPDF_Object* pPage = pArray->GetDirectObjectAt(0);
-  if (!pPage)
-    return 0;
-
-  if (pPage->IsNumber())
-    return pPage->GetInteger();
-
-  if (!pPage->IsDictionary())
-    return 0;
-
-  return pDoc->GetPageIndex(pPage->GetObjNum());
-}
-
 int CPDF_Dest::GetDestPageIndex(CPDF_Document* pDoc) const {
   const CPDF_Array* pArray = ToArray(m_pObj.Get());
   if (!pArray)
diff --git a/core/fpdfdoc/cpdf_dest.h b/core/fpdfdoc/cpdf_dest.h
index 7f4eb86c..c30db11 100644
--- a/core/fpdfdoc/cpdf_dest.h
+++ b/core/fpdfdoc/cpdf_dest.h
@@ -24,11 +24,6 @@
   const CPDF_Array* GetObject() const { return m_pObj.Get(); }
   ByteString GetRemoteName() const;
 
-  // Deprecated. Use GetDestPageIndex instead.
-  // This method is wrong. It returns 0 for errors, when it could mean the first
-  // page as well. Keeping it avoids changing the behavior of
-  // FPDFDest_GetPageIndex().
-  int GetPageIndexDeprecated(CPDF_Document* pDoc) const;
   int GetDestPageIndex(CPDF_Document* pDoc) const;
   uint32_t GetPageObjNum() const;
 
diff --git a/fpdfsdk/fpdf_doc.cpp b/fpdfsdk/fpdf_doc.cpp
index 7a2bbc4..1f0d4f2 100644
--- a/fpdfsdk/fpdf_doc.cpp
+++ b/fpdfsdk/fpdf_doc.cpp
@@ -202,19 +202,6 @@
   return len;
 }
 
-FPDF_EXPORT unsigned long FPDF_CALLCONV
-FPDFDest_GetPageIndex(FPDF_DOCUMENT document, FPDF_DEST dest) {
-  if (!dest)
-    return 0;
-
-  CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document);
-  if (!pDoc)
-    return 0;
-
-  CPDF_Dest destination(CPDFArrayFromFPDFDest(dest));
-  return destination.GetPageIndexDeprecated(pDoc);
-}
-
 FPDF_EXPORT int FPDF_CALLCONV FPDFDest_GetDestPageIndex(FPDF_DOCUMENT document,
                                                         FPDF_DEST dest) {
   if (!dest)
diff --git a/fpdfsdk/fpdf_doc_embeddertest.cpp b/fpdfsdk/fpdf_doc_embeddertest.cpp
index 5c0223e..3ba8600 100644
--- a/fpdfsdk/fpdf_doc_embeddertest.cpp
+++ b/fpdfsdk/fpdf_doc_embeddertest.cpp
@@ -43,31 +43,26 @@
   EXPECT_TRUE(OpenDocument("named_dests.pdf"));
 
   // 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));
 }
 
@@ -134,7 +129,6 @@
   EXPECT_TRUE(OpenDocument("named_dests.pdf"));
 
   // 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");
@@ -162,8 +156,6 @@
   // Page number directly in item from Dests NameTree.
   FPDF_DEST dest = FPDF_GetNamedDestByName(document(), "First");
   EXPECT_TRUE(dest);
-  EXPECT_EQ(static_cast<unsigned long>(-1),
-            FPDFDest_GetPageIndex(document(), dest));
   EXPECT_EQ(-1, FPDFDest_GetDestPageIndex(document(), dest));
 }
 
diff --git a/fpdfsdk/fpdf_view_c_api_test.c b/fpdfsdk/fpdf_view_c_api_test.c
index 799956b..393a8f6 100644
--- a/fpdfsdk/fpdf_view_c_api_test.c
+++ b/fpdfsdk/fpdf_view_c_api_test.c
@@ -111,7 +111,6 @@
     CHK(FPDFBookmark_GetTitle);
     CHK(FPDFDest_GetDestPageIndex);
     CHK(FPDFDest_GetLocationInPage);
-    CHK(FPDFDest_GetPageIndex);
     CHK(FPDFDest_GetView);
     CHK(FPDFLink_CountQuadPoints);
     CHK(FPDFLink_Enumerate);
diff --git a/public/fpdf_doc.h b/public/fpdf_doc.h
index 67a4108..4bd9d44 100644
--- a/public/fpdf_doc.h
+++ b/public/fpdf_doc.h
@@ -177,19 +177,6 @@
                       void* buffer,
                       unsigned long buflen);
 
-// Deprecated. Use FPDFDest_GetDestPageIndex() instead.
-//
-// Get the page index of |dest|.
-//
-//   document - handle to the document.
-//   dest     - handle to the destination.
-//
-// Returns the page index containing |dest|. Page indices start from 0.
-// On an error, returns 0 or -1. Note that 0 can mean the first page, hence
-// do not use this API.
-FPDF_EXPORT unsigned long FPDF_CALLCONV
-FPDFDest_GetPageIndex(FPDF_DOCUMENT document, FPDF_DEST dest);
-
 // Get the page index of |dest|.
 //
 //   document - handle to the document.