summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Pena <npm@chromium.org>2017-05-17 17:23:22 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-05-17 21:40:41 +0000
commit46abb66cb57d4bc6b9326efd7a0c0e776e594db2 (patch)
treed0e3b8bada3ff24ac3cff44f4ae0ed990232448d
parent26853181af1b28ba8070b955d90fb7a17fec2713 (diff)
downloadpdfium-46abb66cb57d4bc6b9326efd7a0c0e776e594db2.tar.xz
Use more static_cast in fpdfsdk
This CL replaces some reinterpret_cast with static_cast in fpdfsdk. It also removes an obsolete comment in fpdfedit.h Change-Id: I36c29bfcd6382490a8c955b50ccfa4c93ab351c7 Reviewed-on: https://pdfium-review.googlesource.com/5632 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Nicolás Peña <npm@chromium.org>
-rw-r--r--fpdfsdk/fpdf_structtree.cpp4
-rw-r--r--fpdfsdk/fpdf_sysfontinfo.cpp2
-rw-r--r--fpdfsdk/fpdfedit_embeddertest.cpp10
-rw-r--r--fpdfsdk/fpdfeditimg.cpp6
-rw-r--r--fpdfsdk/fpdfeditpage.cpp8
-rw-r--r--fpdfsdk/fpdfeditpath.cpp18
-rw-r--r--fpdfsdk/fpdfformfill.cpp4
-rw-r--r--fpdfsdk/fpdfview.cpp2
-rw-r--r--public/fpdf_edit.h2
9 files changed, 28 insertions, 28 deletions
diff --git a/fpdfsdk/fpdf_structtree.cpp b/fpdfsdk/fpdf_structtree.cpp
index 74c44f8083..0c1cc0f6b8 100644
--- a/fpdfsdk/fpdf_structtree.cpp
+++ b/fpdfsdk/fpdf_structtree.cpp
@@ -15,11 +15,11 @@
namespace {
CPDF_StructTree* ToStructTree(FPDF_STRUCTTREE struct_tree) {
- return reinterpret_cast<CPDF_StructTree*>(struct_tree);
+ return static_cast<CPDF_StructTree*>(struct_tree);
}
CPDF_StructElement* ToStructTreeElement(FPDF_STRUCTELEMENT struct_element) {
- return reinterpret_cast<CPDF_StructElement*>(struct_element);
+ return static_cast<CPDF_StructElement*>(struct_element);
}
unsigned long WideStringToBuffer(const CFX_WideString& str,
diff --git a/fpdfsdk/fpdf_sysfontinfo.cpp b/fpdfsdk/fpdf_sysfontinfo.cpp
index 1b98b94358..1f73887532 100644
--- a/fpdfsdk/fpdf_sysfontinfo.cpp
+++ b/fpdfsdk/fpdf_sysfontinfo.cpp
@@ -106,7 +106,7 @@ class CFX_ExternalFontInfo final : public IFX_SystemFontInfo {
DLLEXPORT void STDCALL FPDF_AddInstalledFont(void* mapper,
const char* name,
int charset) {
- CFX_FontMapper* pMapper = reinterpret_cast<CFX_FontMapper*>(mapper);
+ CFX_FontMapper* pMapper = static_cast<CFX_FontMapper*>(mapper);
pMapper->AddInstalledFont(name, charset);
}
diff --git a/fpdfsdk/fpdfedit_embeddertest.cpp b/fpdfsdk/fpdfedit_embeddertest.cpp
index ed5fe3e7f8..4559ee3f19 100644
--- a/fpdfsdk/fpdfedit_embeddertest.cpp
+++ b/fpdfsdk/fpdfedit_embeddertest.cpp
@@ -26,7 +26,7 @@ class FPDFEditEmbeddertest : public EmbedderTest, public TestSaver {
protected:
FPDF_DOCUMENT CreateNewDocument() {
document_ = FPDF_CreateNewDocument();
- cpdf_doc_ = reinterpret_cast<CPDF_Document*>(document_);
+ cpdf_doc_ = static_cast<CPDF_Document*>(document_);
return document_;
}
@@ -562,7 +562,7 @@ TEST_F(FPDFEditEmbeddertest, LoadSimpleType1Font) {
std::unique_ptr<void, FPDFFontDeleter> font(
FPDFText_LoadFont(document(), data, size, FPDF_FONT_TYPE1, false));
ASSERT_TRUE(font.get());
- CPDF_Font* typed_font = reinterpret_cast<CPDF_Font*>(font.get());
+ CPDF_Font* typed_font = static_cast<CPDF_Font*>(font.get());
EXPECT_TRUE(typed_font->IsType1Font());
CPDF_Dictionary* font_dict = typed_font->GetFontDict();
@@ -591,7 +591,7 @@ TEST_F(FPDFEditEmbeddertest, LoadSimpleTrueTypeFont) {
std::unique_ptr<void, FPDFFontDeleter> font(
FPDFText_LoadFont(document(), data, size, FPDF_FONT_TRUETYPE, false));
ASSERT_TRUE(font.get());
- CPDF_Font* typed_font = reinterpret_cast<CPDF_Font*>(font.get());
+ CPDF_Font* typed_font = static_cast<CPDF_Font*>(font.get());
EXPECT_TRUE(typed_font->IsTrueTypeFont());
CPDF_Dictionary* font_dict = typed_font->GetFontDict();
@@ -621,7 +621,7 @@ TEST_F(FPDFEditEmbeddertest, LoadCIDType0Font) {
std::unique_ptr<void, FPDFFontDeleter> font(
FPDFText_LoadFont(document(), data, size, FPDF_FONT_TYPE1, 1));
ASSERT_TRUE(font.get());
- CPDF_Font* typed_font = reinterpret_cast<CPDF_Font*>(font.get());
+ CPDF_Font* typed_font = static_cast<CPDF_Font*>(font.get());
EXPECT_TRUE(typed_font->IsCIDFont());
// Check font dictionary entries
@@ -663,7 +663,7 @@ TEST_F(FPDFEditEmbeddertest, LoadCIDType2Font) {
std::unique_ptr<void, FPDFFontDeleter> font(
FPDFText_LoadFont(document(), data, size, FPDF_FONT_TRUETYPE, 1));
ASSERT_TRUE(font.get());
- CPDF_Font* typed_font = reinterpret_cast<CPDF_Font*>(font.get());
+ CPDF_Font* typed_font = static_cast<CPDF_Font*>(font.get());
EXPECT_TRUE(typed_font->IsCIDFont());
// Check font dictionary entries
diff --git a/fpdfsdk/fpdfeditimg.cpp b/fpdfsdk/fpdfeditimg.cpp
index 6a300c9e62..9f4b2968ee 100644
--- a/fpdfsdk/fpdfeditimg.cpp
+++ b/fpdfsdk/fpdfeditimg.cpp
@@ -25,7 +25,7 @@ bool LoadJpegHelper(FPDF_PAGE* pages,
CFX_RetainPtr<IFX_SeekableReadStream> pFile =
MakeSeekableReadStream(fileAccess);
- CPDF_ImageObject* pImgObj = reinterpret_cast<CPDF_ImageObject*>(image_object);
+ CPDF_ImageObject* pImgObj = static_cast<CPDF_ImageObject*>(image_object);
if (pages) {
for (int index = 0; index < nCount; index++) {
@@ -82,7 +82,7 @@ DLLEXPORT FPDF_BOOL STDCALL FPDFImageObj_SetMatrix(FPDF_PAGEOBJECT image_object,
if (!image_object)
return false;
- CPDF_ImageObject* pImgObj = reinterpret_cast<CPDF_ImageObject*>(image_object);
+ CPDF_ImageObject* pImgObj = static_cast<CPDF_ImageObject*>(image_object);
pImgObj->set_matrix(CFX_Matrix(static_cast<float>(a), static_cast<float>(b),
static_cast<float>(c), static_cast<float>(d),
static_cast<float>(e), static_cast<float>(f)));
@@ -97,7 +97,7 @@ DLLEXPORT FPDF_BOOL STDCALL FPDFImageObj_SetBitmap(FPDF_PAGE* pages,
if (!image_object || !bitmap || !pages)
return false;
- CPDF_ImageObject* pImgObj = reinterpret_cast<CPDF_ImageObject*>(image_object);
+ CPDF_ImageObject* pImgObj = static_cast<CPDF_ImageObject*>(image_object);
for (int index = 0; index < nCount; index++) {
CPDF_Page* pPage = CPDFPageFromFPDFPage(pages[index]);
if (pPage)
diff --git a/fpdfsdk/fpdfeditpage.cpp b/fpdfsdk/fpdfeditpage.cpp
index df752d4029..431adcaa95 100644
--- a/fpdfsdk/fpdfeditpage.cpp
+++ b/fpdfsdk/fpdfeditpage.cpp
@@ -135,7 +135,7 @@ DLLEXPORT int STDCALL FPDFPage_GetRotation(FPDF_PAGE page) {
DLLEXPORT void STDCALL FPDFPage_InsertObject(FPDF_PAGE page,
FPDF_PAGEOBJECT page_obj) {
- CPDF_PageObject* pPageObj = reinterpret_cast<CPDF_PageObject*>(page_obj);
+ CPDF_PageObject* pPageObj = static_cast<CPDF_PageObject*>(page_obj);
if (!pPageObj)
return;
@@ -201,7 +201,7 @@ FPDFPageObj_HasTransparency(FPDF_PAGEOBJECT pageObject) {
if (!pageObject)
return false;
- CPDF_PageObject* pPageObj = reinterpret_cast<CPDF_PageObject*>(pageObject);
+ CPDF_PageObject* pPageObj = static_cast<CPDF_PageObject*>(pageObject);
int blend_type = pPageObj->m_GeneralState.GetBlendType();
if (blend_type != FXDIB_BLEND_NORMAL)
return true;
@@ -234,7 +234,7 @@ DLLEXPORT int STDCALL FPDFPageObj_GetType(FPDF_PAGEOBJECT pageObject) {
if (!pageObject)
return FPDF_PAGEOBJ_UNKNOWN;
- CPDF_PageObject* pPageObj = reinterpret_cast<CPDF_PageObject*>(pageObject);
+ CPDF_PageObject* pPageObj = static_cast<CPDF_PageObject*>(pageObject);
return pPageObj->GetType();
}
@@ -255,7 +255,7 @@ DLLEXPORT void STDCALL FPDFPageObj_Transform(FPDF_PAGEOBJECT page_object,
double d,
double e,
double f) {
- CPDF_PageObject* pPageObj = reinterpret_cast<CPDF_PageObject*>(page_object);
+ CPDF_PageObject* pPageObj = static_cast<CPDF_PageObject*>(page_object);
if (!pPageObj)
return;
diff --git a/fpdfsdk/fpdfeditpath.cpp b/fpdfsdk/fpdfeditpath.cpp
index a26ca5186e..60117cad32 100644
--- a/fpdfsdk/fpdfeditpath.cpp
+++ b/fpdfsdk/fpdfeditpath.cpp
@@ -35,7 +35,7 @@ DLLEXPORT FPDF_BOOL FPDFPath_SetStrokeColor(FPDF_PAGEOBJECT path,
return false;
float rgb[3] = {R / 255.f, G / 255.f, B / 255.f};
- auto* pPathObj = reinterpret_cast<CPDF_PathObject*>(path);
+ auto* pPathObj = static_cast<CPDF_PathObject*>(path);
pPathObj->m_GeneralState.SetStrokeAlpha(A / 255.f);
pPathObj->m_ColorState.SetStrokeColor(
CPDF_ColorSpace::GetStockCS(PDFCS_DEVICERGB), rgb, 3);
@@ -46,7 +46,7 @@ DLLEXPORT FPDF_BOOL FPDFPath_SetStrokeWidth(FPDF_PAGEOBJECT path, float width) {
if (!path || width < 0.0f)
return false;
- auto* pPathObj = reinterpret_cast<CPDF_PathObject*>(path);
+ auto* pPathObj = static_cast<CPDF_PathObject*>(path);
pPathObj->m_GraphState.SetLineWidth(width);
return true;
}
@@ -60,7 +60,7 @@ DLLEXPORT FPDF_BOOL FPDFPath_SetFillColor(FPDF_PAGEOBJECT path,
return false;
float rgb[3] = {R / 255.f, G / 255.f, B / 255.f};
- auto* pPathObj = reinterpret_cast<CPDF_PathObject*>(path);
+ auto* pPathObj = static_cast<CPDF_PathObject*>(path);
pPathObj->m_GeneralState.SetFillAlpha(A / 255.f);
pPathObj->m_ColorState.SetFillColor(
CPDF_ColorSpace::GetStockCS(PDFCS_DEVICERGB), rgb, 3);
@@ -75,7 +75,7 @@ DLLEXPORT FPDF_BOOL FPDFPath_GetFillColor(FPDF_PAGEOBJECT path,
if (!path || !R || !G || !B || !A)
return false;
- auto* pPathObj = reinterpret_cast<CPDF_PathObject*>(path);
+ auto* pPathObj = static_cast<CPDF_PathObject*>(path);
uint32_t fillRGB = pPathObj->m_ColorState.GetFillRGB();
*R = FXSYS_GetRValue(fillRGB);
*G = FXSYS_GetGValue(fillRGB);
@@ -89,7 +89,7 @@ DLLEXPORT FPDF_BOOL FPDFPath_MoveTo(FPDF_PAGEOBJECT path, float x, float y) {
if (!path)
return false;
- auto* pPathObj = reinterpret_cast<CPDF_PathObject*>(path);
+ auto* pPathObj = static_cast<CPDF_PathObject*>(path);
pPathObj->m_Path.AppendPoint(CFX_PointF(x, y), FXPT_TYPE::MoveTo, false);
return true;
}
@@ -98,7 +98,7 @@ DLLEXPORT FPDF_BOOL FPDFPath_LineTo(FPDF_PAGEOBJECT path, float x, float y) {
if (!path)
return false;
- auto* pPathObj = reinterpret_cast<CPDF_PathObject*>(path);
+ auto* pPathObj = static_cast<CPDF_PathObject*>(path);
pPathObj->m_Path.AppendPoint(CFX_PointF(x, y), FXPT_TYPE::LineTo, false);
return true;
}
@@ -113,7 +113,7 @@ DLLEXPORT FPDF_BOOL FPDFPath_BezierTo(FPDF_PAGEOBJECT path,
if (!path)
return false;
- auto* pPathObj = reinterpret_cast<CPDF_PathObject*>(path);
+ auto* pPathObj = static_cast<CPDF_PathObject*>(path);
pPathObj->m_Path.AppendPoint(CFX_PointF(x1, y1), FXPT_TYPE::BezierTo, false);
pPathObj->m_Path.AppendPoint(CFX_PointF(x2, y2), FXPT_TYPE::BezierTo, false);
pPathObj->m_Path.AppendPoint(CFX_PointF(x3, y3), FXPT_TYPE::BezierTo, false);
@@ -124,7 +124,7 @@ DLLEXPORT FPDF_BOOL FPDFPath_Close(FPDF_PAGEOBJECT path) {
if (!path)
return false;
- auto* pPathObj = reinterpret_cast<CPDF_PathObject*>(path);
+ auto* pPathObj = static_cast<CPDF_PathObject*>(path);
if (pPathObj->m_Path.GetPoints().empty())
return false;
@@ -138,7 +138,7 @@ DLLEXPORT FPDF_BOOL FPDFPath_SetDrawMode(FPDF_PAGEOBJECT path,
if (!path)
return false;
- auto* pPathObj = reinterpret_cast<CPDF_PathObject*>(path);
+ auto* pPathObj = static_cast<CPDF_PathObject*>(path);
if (fillmode == FPDF_FILLMODE_ALTERNATE)
pPathObj->m_FillType = FXFILL_ALTERNATE;
diff --git a/fpdfsdk/fpdfformfill.cpp b/fpdfsdk/fpdfformfill.cpp
index a466e73abb..121e1a9c8e 100644
--- a/fpdfsdk/fpdfformfill.cpp
+++ b/fpdfsdk/fpdfformfill.cpp
@@ -67,11 +67,11 @@ CPDFSDK_PageView* FormHandleToPageView(FPDF_FORMHANDLE hHandle,
#ifdef PDF_ENABLE_XFA
std::vector<CFX_ByteString>* FromFPDFStringHandle(FPDF_STRINGHANDLE handle) {
- return reinterpret_cast<std::vector<CFX_ByteString>*>(handle);
+ return static_cast<std::vector<CFX_ByteString>*>(handle);
}
FPDF_STRINGHANDLE ToFPDFStringHandle(std::vector<CFX_ByteString>* strings) {
- return reinterpret_cast<FPDF_STRINGHANDLE>(strings);
+ return static_cast<FPDF_STRINGHANDLE>(strings);
}
#endif // PDF_ENABLE_XFA
diff --git a/fpdfsdk/fpdfview.cpp b/fpdfsdk/fpdfview.cpp
index f8078073b7..2bf6dfca74 100644
--- a/fpdfsdk/fpdfview.cpp
+++ b/fpdfsdk/fpdfview.cpp
@@ -156,7 +156,7 @@ bool CPDF_CustomAccess::ReadBlock(void* buffer,
return false;
}
return !!m_FileAccess.m_GetBlock(m_FileAccess.m_Param, offset,
- reinterpret_cast<uint8_t*>(buffer), size);
+ static_cast<uint8_t*>(buffer), size);
}
#ifdef PDF_ENABLE_XFA
diff --git a/public/fpdf_edit.h b/public/fpdf_edit.h
index f9edfa3426..a84b42ab05 100644
--- a/public/fpdf_edit.h
+++ b/public/fpdf_edit.h
@@ -434,7 +434,7 @@ DLLEXPORT FPDF_BOOL STDCALL FPDFText_SetText(FPDF_PAGEOBJECT text_object,
FPDF_WIDESTRING text);
// Returns a font object loaded from a stream of data. The font is loaded
-// into the document. The caller does not need to free the returned object.
+// into the document.
//
// document - handle to the document.
// data - the stream of data, which will be copied by the font object.