summaryrefslogtreecommitdiff
path: root/fpdfsdk
diff options
context:
space:
mode:
Diffstat (limited to 'fpdfsdk')
-rw-r--r--fpdfsdk/fpdfdoc.cpp24
-rw-r--r--fpdfsdk/fpdfdoc_embeddertest.cpp10
2 files changed, 14 insertions, 20 deletions
diff --git a/fpdfsdk/fpdfdoc.cpp b/fpdfsdk/fpdfdoc.cpp
index 14e4361483..47ecf4223b 100644
--- a/fpdfsdk/fpdfdoc.cpp
+++ b/fpdfsdk/fpdfdoc.cpp
@@ -211,26 +211,20 @@ FPDFDest_GetPageIndex(FPDF_DOCUMENT document, FPDF_DEST pDict) {
}
FPDF_EXPORT unsigned long FPDF_CALLCONV
-FPDFDest_GetView(FPDF_DOCUMENT document,
- FPDF_DEST pDict,
- unsigned long* outNumParams,
- FS_FLOAT* outParams) {
+FPDFDest_GetView(FPDF_DEST pDict,
+ unsigned long* pNumParams,
+ FS_FLOAT* pParams) {
if (!pDict) {
- *outNumParams = 0;
- return 0;
- }
-
- CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document);
- if (!pDoc) {
- *outNumParams = 0;
+ *pNumParams = 0;
return 0;
}
CPDF_Dest dest(static_cast<CPDF_Array*>(pDict));
-
- *outNumParams = dest.GetNumParams();
- for (unsigned long i = 0; i < *outNumParams; ++i)
- outParams[i] = dest.GetParam(i);
+ unsigned long nParams = dest.GetNumParams();
+ ASSERT(nParams <= 4);
+ *pNumParams = nParams;
+ for (unsigned long i = 0; i < nParams; ++i)
+ pParams[i] = dest.GetParam(i);
return dest.GetZoomMode();
}
diff --git a/fpdfsdk/fpdfdoc_embeddertest.cpp b/fpdfsdk/fpdfdoc_embeddertest.cpp
index 24414a1c33..d346330486 100644
--- a/fpdfsdk/fpdfdoc_embeddertest.cpp
+++ b/fpdfsdk/fpdfdoc_embeddertest.cpp
@@ -51,7 +51,7 @@ TEST_F(FPDFDocEmbeddertest, DestGetView) {
numParams = 42;
std::fill_n(params, 4, 42.4242f);
EXPECT_EQ(static_cast<unsigned long>(PDFDEST_VIEW_UNKNOWN_MODE),
- FPDFDest_GetView(document(), nullptr, &numParams, params));
+ FPDFDest_GetView(nullptr, &numParams, params));
EXPECT_EQ(0U, numParams);
EXPECT_FLOAT_EQ(42.4242f, params[0]);
@@ -60,7 +60,7 @@ TEST_F(FPDFDocEmbeddertest, DestGetView) {
FPDF_DEST dest = FPDF_GetNamedDestByName(document(), "First");
EXPECT_TRUE(dest);
EXPECT_EQ(static_cast<unsigned long>(PDFDEST_VIEW_XYZ),
- FPDFDest_GetView(document(), dest, &numParams, params));
+ FPDFDest_GetView(dest, &numParams, params));
EXPECT_EQ(3U, numParams);
EXPECT_FLOAT_EQ(0, params[0]);
EXPECT_FLOAT_EQ(0, params[1]);
@@ -72,7 +72,7 @@ TEST_F(FPDFDocEmbeddertest, DestGetView) {
dest = FPDF_GetNamedDestByName(document(), "Next");
EXPECT_TRUE(dest);
EXPECT_EQ(static_cast<unsigned long>(PDFDEST_VIEW_FIT),
- FPDFDest_GetView(document(), dest, &numParams, params));
+ FPDFDest_GetView(dest, &numParams, params));
EXPECT_EQ(0U, numParams);
EXPECT_FLOAT_EQ(42.4242f, params[0]);
@@ -81,7 +81,7 @@ TEST_F(FPDFDocEmbeddertest, DestGetView) {
dest = FPDF_GetNamedDestByName(document(), "FirstAlternate");
EXPECT_TRUE(dest);
EXPECT_EQ(static_cast<unsigned long>(PDFDEST_VIEW_XYZ),
- FPDFDest_GetView(document(), dest, &numParams, params));
+ FPDFDest_GetView(dest, &numParams, params));
EXPECT_EQ(3U, numParams);
EXPECT_FLOAT_EQ(200, params[0]);
EXPECT_FLOAT_EQ(400, params[1]);
@@ -93,7 +93,7 @@ TEST_F(FPDFDocEmbeddertest, DestGetView) {
dest = FPDF_GetNamedDestByName(document(), "LastAlternate");
EXPECT_TRUE(dest);
EXPECT_EQ(static_cast<unsigned long>(PDFDEST_VIEW_XYZ),
- FPDFDest_GetView(document(), dest, &numParams, params));
+ FPDFDest_GetView(dest, &numParams, params));
EXPECT_EQ(3U, numParams);
EXPECT_FLOAT_EQ(0, params[0]);
EXPECT_FLOAT_EQ(0, params[1]);