diff options
author | Lei Zhang <thestig@chromium.org> | 2018-01-11 14:28:01 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-01-11 14:28:01 +0000 |
commit | 762502141cc93fb22fbfcf536d81752c4c6886aa (patch) | |
tree | 4157373e655fb6c3e2166ad46e45cf68ca349c7a /fpdfsdk | |
parent | 188b2e0333d161ffbac7c896f443b886b113b26a (diff) | |
download | pdfium-762502141cc93fb22fbfcf536d81752c4c6886aa.tar.xz |
Change FPDFText_GetRect() to return a boolean.
BUG=pdfium:858
Change-Id: Idc9900fe6f85b1fef06c97f5023653f77156d410
Reviewed-on: https://pdfium-review.googlesource.com/22730
Commit-Queue: dsinclair <dsinclair@chromium.org>
Reviewed-by: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'fpdfsdk')
-rw-r--r-- | fpdfsdk/fpdftext.cpp | 18 | ||||
-rw-r--r-- | fpdfsdk/fpdftext_embeddertest.cpp | 6 |
2 files changed, 13 insertions, 11 deletions
diff --git a/fpdfsdk/fpdftext.cpp b/fpdfsdk/fpdftext.cpp index 85dc6e475e..bc86c1c099 100644 --- a/fpdfsdk/fpdftext.cpp +++ b/fpdfsdk/fpdftext.cpp @@ -205,22 +205,24 @@ FPDF_EXPORT int FPDF_CALLCONV FPDFText_CountRects(FPDF_TEXTPAGE text_page, return textpage->CountRects(start, count); } -FPDF_EXPORT void FPDF_CALLCONV FPDFText_GetRect(FPDF_TEXTPAGE text_page, - int rect_index, - double* left, - double* top, - double* right, - double* bottom) { +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFText_GetRect(FPDF_TEXTPAGE text_page, + int rect_index, + double* left, + double* top, + double* right, + double* bottom) { if (!text_page) - return; + return false; CPDF_TextPage* textpage = CPDFTextPageFromFPDFTextPage(text_page); CFX_FloatRect rect; - textpage->GetRect(rect_index, rect.left, rect.top, rect.right, rect.bottom); + bool result = textpage->GetRect(rect_index, &rect); + *left = rect.left; *top = rect.top; *right = rect.right; *bottom = rect.bottom; + return result; } FPDF_EXPORT int FPDF_CALLCONV FPDFText_GetBoundedText(FPDF_TEXTPAGE text_page, diff --git a/fpdfsdk/fpdftext_embeddertest.cpp b/fpdfsdk/fpdftext_embeddertest.cpp index 6885eb0f75..a9637be5df 100644 --- a/fpdfsdk/fpdftext_embeddertest.cpp +++ b/fpdfsdk/fpdftext_embeddertest.cpp @@ -115,7 +115,7 @@ TEST_F(FPDFTextEmbeddertest, Text) { right = 0.0; bottom = 0.0; top = 0.0; - FPDFText_GetRect(textpage, 1, &left, &top, &right, &bottom); + EXPECT_TRUE(FPDFText_GetRect(textpage, 1, &left, &top, &right, &bottom)); EXPECT_NEAR(20.847, left, 0.001); EXPECT_NEAR(135.167, right, 0.001); EXPECT_NEAR(96.655, bottom, 0.001); @@ -126,7 +126,7 @@ TEST_F(FPDFTextEmbeddertest, Text) { right = -1.0; bottom = -1.0; top = -1.0; - FPDFText_GetRect(textpage, -1, &left, &top, &right, &bottom); + EXPECT_FALSE(FPDFText_GetRect(textpage, -1, &left, &top, &right, &bottom)); EXPECT_EQ(0.0, left); EXPECT_EQ(0.0, right); EXPECT_EQ(0.0, bottom); @@ -136,7 +136,7 @@ TEST_F(FPDFTextEmbeddertest, Text) { right = -2.0; bottom = -2.0; top = -2.0; - FPDFText_GetRect(textpage, 2, &left, &top, &right, &bottom); + EXPECT_FALSE(FPDFText_GetRect(textpage, 2, &left, &top, &right, &bottom)); EXPECT_EQ(0.0, left); EXPECT_EQ(0.0, right); EXPECT_EQ(0.0, bottom); |