Use strict types in FPDF API, try #3
Rather than messing with actual inheritence, add type-checking wrappers
and just blatantly cast to incomplete types. Along the way, this points
out places where we would downcast without checking, which I fix.
Change-Id: Ieb303eb46ad8522dfe082454f1f10f247ffd52d5
Reviewed-on: https://pdfium-review.googlesource.com/32030
Reviewed-by: dsinclair <dsinclair@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/fpdfsdk/fpdf_searchex.cpp b/fpdfsdk/fpdf_searchex.cpp
index 9d48ceb..dbc2d2a 100644
--- a/fpdfsdk/fpdf_searchex.cpp
+++ b/fpdfsdk/fpdf_searchex.cpp
@@ -7,19 +7,20 @@
#include "public/fpdf_searchex.h"
#include "core/fpdftext/cpdf_textpage.h"
+#include "fpdfsdk/cpdfsdk_helpers.h"
FPDF_EXPORT int FPDF_CALLCONV
FPDFText_GetCharIndexFromTextIndex(FPDF_TEXTPAGE text_page, int nTextIndex) {
if (!text_page)
return -1;
- return static_cast<CPDF_TextPage*>(text_page)
- ->CharIndexFromTextIndex(nTextIndex);
+ return CPDFTextPageFromFPDFTextPage(text_page)->CharIndexFromTextIndex(
+ nTextIndex);
}
FPDF_EXPORT int FPDF_CALLCONV
FPDFText_GetTextIndexFromCharIndex(FPDF_TEXTPAGE text_page, int nCharIndex) {
if (!text_page)
return -1;
- return static_cast<CPDF_TextPage*>(text_page)->TextIndexFromCharIndex(
+ return CPDFTextPageFromFPDFTextPage(text_page)->TextIndexFromCharIndex(
nCharIndex);
}