From 46abb66cb57d4bc6b9326efd7a0c0e776e594db2 Mon Sep 17 00:00:00 2001 From: Nicolas Pena Date: Wed, 17 May 2017 17:23:22 -0400 Subject: Use more static_cast in fpdfsdk MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Commit-Queue: Nicolás Peña --- fpdfsdk/fpdf_structtree.cpp | 4 ++-- fpdfsdk/fpdf_sysfontinfo.cpp | 2 +- fpdfsdk/fpdfedit_embeddertest.cpp | 10 +++++----- fpdfsdk/fpdfeditimg.cpp | 6 +++--- fpdfsdk/fpdfeditpage.cpp | 8 ++++---- fpdfsdk/fpdfeditpath.cpp | 18 +++++++++--------- fpdfsdk/fpdfformfill.cpp | 4 ++-- fpdfsdk/fpdfview.cpp | 2 +- public/fpdf_edit.h | 2 +- 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(struct_tree); + return static_cast(struct_tree); } CPDF_StructElement* ToStructTreeElement(FPDF_STRUCTELEMENT struct_element) { - return reinterpret_cast(struct_element); + return static_cast(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(mapper); + CFX_FontMapper* pMapper = static_cast(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(document_); + cpdf_doc_ = static_cast(document_); return document_; } @@ -562,7 +562,7 @@ TEST_F(FPDFEditEmbeddertest, LoadSimpleType1Font) { std::unique_ptr font( FPDFText_LoadFont(document(), data, size, FPDF_FONT_TYPE1, false)); ASSERT_TRUE(font.get()); - CPDF_Font* typed_font = reinterpret_cast(font.get()); + CPDF_Font* typed_font = static_cast(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 font( FPDFText_LoadFont(document(), data, size, FPDF_FONT_TRUETYPE, false)); ASSERT_TRUE(font.get()); - CPDF_Font* typed_font = reinterpret_cast(font.get()); + CPDF_Font* typed_font = static_cast(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 font( FPDFText_LoadFont(document(), data, size, FPDF_FONT_TYPE1, 1)); ASSERT_TRUE(font.get()); - CPDF_Font* typed_font = reinterpret_cast(font.get()); + CPDF_Font* typed_font = static_cast(font.get()); EXPECT_TRUE(typed_font->IsCIDFont()); // Check font dictionary entries @@ -663,7 +663,7 @@ TEST_F(FPDFEditEmbeddertest, LoadCIDType2Font) { std::unique_ptr font( FPDFText_LoadFont(document(), data, size, FPDF_FONT_TRUETYPE, 1)); ASSERT_TRUE(font.get()); - CPDF_Font* typed_font = reinterpret_cast(font.get()); + CPDF_Font* typed_font = static_cast(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 pFile = MakeSeekableReadStream(fileAccess); - CPDF_ImageObject* pImgObj = reinterpret_cast(image_object); + CPDF_ImageObject* pImgObj = static_cast(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(image_object); + CPDF_ImageObject* pImgObj = static_cast(image_object); pImgObj->set_matrix(CFX_Matrix(static_cast(a), static_cast(b), static_cast(c), static_cast(d), static_cast(e), static_cast(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(image_object); + CPDF_ImageObject* pImgObj = static_cast(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(page_obj); + CPDF_PageObject* pPageObj = static_cast(page_obj); if (!pPageObj) return; @@ -201,7 +201,7 @@ FPDFPageObj_HasTransparency(FPDF_PAGEOBJECT pageObject) { if (!pageObject) return false; - CPDF_PageObject* pPageObj = reinterpret_cast(pageObject); + CPDF_PageObject* pPageObj = static_cast(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(pageObject); + CPDF_PageObject* pPageObj = static_cast(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(page_object); + CPDF_PageObject* pPageObj = static_cast(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(path); + auto* pPathObj = static_cast(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(path); + auto* pPathObj = static_cast(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(path); + auto* pPathObj = static_cast(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(path); + auto* pPathObj = static_cast(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(path); + auto* pPathObj = static_cast(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(path); + auto* pPathObj = static_cast(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(path); + auto* pPathObj = static_cast(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(path); + auto* pPathObj = static_cast(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(path); + auto* pPathObj = static_cast(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* FromFPDFStringHandle(FPDF_STRINGHANDLE handle) { - return reinterpret_cast*>(handle); + return static_cast*>(handle); } FPDF_STRINGHANDLE ToFPDFStringHandle(std::vector* strings) { - return reinterpret_cast(strings); + return static_cast(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(buffer), size); + static_cast(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. -- cgit v1.2.3