summaryrefslogtreecommitdiff
path: root/fpdfsdk
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2018-04-26 18:33:58 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-04-26 18:33:58 +0000
commitea3a2529a7aa0199b385b7caa2e465c124eac8aa (patch)
treecf8beb27054209ef2b71222c3cdc81bd39192651 /fpdfsdk
parentf9666864254bf84ef878630bbdaaaabbecab8ba5 (diff)
downloadpdfium-ea3a2529a7aa0199b385b7caa2e465c124eac8aa.tar.xz
Replace some c-style cast with static_cast<>
Change-Id: I9dd6a36770f77f3df6c4395572785d37402eadc2 Reviewed-on: https://pdfium-review.googlesource.com/31350 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'fpdfsdk')
-rw-r--r--fpdfsdk/formfiller/cffl_combobox.cpp9
-rw-r--r--fpdfsdk/formfiller/cffl_formfiller.cpp2
-rw-r--r--fpdfsdk/formfiller/cffl_listbox.cpp7
-rw-r--r--fpdfsdk/fpdf_save.cpp10
-rw-r--r--fpdfsdk/fpdf_sysfontinfo.cpp2
-rw-r--r--fpdfsdk/fpdf_text.cpp2
-rw-r--r--fpdfsdk/fpdf_transformpage.cpp5
-rw-r--r--fpdfsdk/pwl/cpwl_combo_box.cpp3
8 files changed, 19 insertions, 21 deletions
diff --git a/fpdfsdk/formfiller/cffl_combobox.cpp b/fpdfsdk/formfiller/cffl_combobox.cpp
index 055b697669..8aa656b856 100644
--- a/fpdfsdk/formfiller/cffl_combobox.cpp
+++ b/fpdfsdk/formfiller/cffl_combobox.cpp
@@ -74,7 +74,7 @@ bool CFFL_ComboBox::OnChar(CPDFSDK_Annot* pAnnot,
}
bool CFFL_ComboBox::IsDataChanged(CPDFSDK_PageView* pPageView) {
- CPWL_ComboBox* pWnd = (CPWL_ComboBox*)GetPDFWindow(pPageView, false);
+ auto* pWnd = static_cast<CPWL_ComboBox*>(GetPDFWindow(pPageView, false));
if (!pWnd)
return false;
@@ -250,12 +250,9 @@ void CFFL_ComboBox::OnSetFocus(CPWL_Edit* pEdit) {
WideString CFFL_ComboBox::GetSelectExportText() {
WideString swRet;
- int nExport = -1;
CPDFSDK_PageView* pPageView = GetCurPageView(true);
- if (CPWL_ComboBox* pComboBox =
- (CPWL_ComboBox*)GetPDFWindow(pPageView, false)) {
- nExport = pComboBox->GetSelect();
- }
+ auto* pComboBox = static_cast<CPWL_ComboBox*>(GetPDFWindow(pPageView, false));
+ int nExport = pComboBox ? pComboBox->GetSelect() : -1;
if (nExport >= 0) {
if (CPDF_FormField* pFormField = m_pWidget->GetFormField()) {
diff --git a/fpdfsdk/formfiller/cffl_formfiller.cpp b/fpdfsdk/formfiller/cffl_formfiller.cpp
index ac82e3ed47..261cb653e5 100644
--- a/fpdfsdk/formfiller/cffl_formfiller.cpp
+++ b/fpdfsdk/formfiller/cffl_formfiller.cpp
@@ -301,7 +301,7 @@ bool CFFL_FormFiller::Redo(CPDFSDK_Annot* pAnnot) {
}
void CFFL_FormFiller::SetFocusForAnnot(CPDFSDK_Annot* pAnnot, uint32_t nFlag) {
- CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
+ auto* pWidget = static_cast<CPDFSDK_Widget*>(pAnnot);
UnderlyingPageType* pPage = pWidget->GetUnderlyingPage();
CPDFSDK_PageView* pPageView = m_pFormFillEnv->GetPageView(pPage, true);
if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, true))
diff --git a/fpdfsdk/formfiller/cffl_listbox.cpp b/fpdfsdk/formfiller/cffl_listbox.cpp
index 943412d509..bf24e116e5 100644
--- a/fpdfsdk/formfiller/cffl_listbox.cpp
+++ b/fpdfsdk/formfiller/cffl_listbox.cpp
@@ -81,7 +81,7 @@ bool CFFL_ListBox::OnChar(CPDFSDK_Annot* pAnnot,
}
bool CFFL_ListBox::IsDataChanged(CPDFSDK_PageView* pPageView) {
- CPWL_ListBox* pListBox = (CPWL_ListBox*)GetPDFWindow(pPageView, false);
+ auto* pListBox = static_cast<CPWL_ListBox*>(GetPDFWindow(pPageView, false));
if (!pListBox)
return false;
@@ -140,8 +140,9 @@ void CFFL_ListBox::GetActionData(CPDFSDK_PageView* pPageView,
if (m_pWidget->GetFieldFlags() & FIELDFLAG_MULTISELECT) {
fa.sValue = L"";
} else {
- if (CPWL_ListBox* pListBox =
- (CPWL_ListBox*)GetPDFWindow(pPageView, false)) {
+ auto* pListBox =
+ static_cast<CPWL_ListBox*>(GetPDFWindow(pPageView, false));
+ if (pListBox) {
int32_t nCurSel = pListBox->GetCurSel();
if (nCurSel >= 0)
fa.sValue = m_pWidget->GetOptionLabel(nCurSel);
diff --git a/fpdfsdk/fpdf_save.cpp b/fpdfsdk/fpdf_save.cpp
index cd1889e005..7da48f375d 100644
--- a/fpdfsdk/fpdf_save.cpp
+++ b/fpdfsdk/fpdf_save.cpp
@@ -97,10 +97,10 @@ bool SaveXFADocumentData(CPDFXFA_Context* pContext,
if (pFormPDFObj->IsReference()) {
CPDF_Object* pFormDirectObj = pFormPDFObj->GetDirect();
if (pFormDirectObj && pFormDirectObj->IsStream()) {
- pFormStream = (CPDF_Stream*)pFormDirectObj;
+ pFormStream = pFormDirectObj->AsStream();
}
} else if (pFormPDFObj->IsStream()) {
- pFormStream = (CPDF_Stream*)pFormPDFObj;
+ pFormStream = pFormPDFObj->AsStream();
}
}
@@ -108,13 +108,13 @@ bool SaveXFADocumentData(CPDFXFA_Context* pContext,
// Get datasets CPDF_Stream
CPDF_Object* pDataSetsPDFObj = pArray->GetObjectAt(iDataSetsIndex);
if (pDataSetsPDFObj->IsReference()) {
- CPDF_Reference* pDataSetsRefObj = (CPDF_Reference*)pDataSetsPDFObj;
+ CPDF_Reference* pDataSetsRefObj = pDataSetsPDFObj->AsReference();
CPDF_Object* pDataSetsDirectObj = pDataSetsRefObj->GetDirect();
if (pDataSetsDirectObj && pDataSetsDirectObj->IsStream()) {
- pDataSetsStream = (CPDF_Stream*)pDataSetsDirectObj;
+ pDataSetsStream = pDataSetsDirectObj->AsStream();
}
} else if (pDataSetsPDFObj->IsStream()) {
- pDataSetsStream = (CPDF_Stream*)pDataSetsPDFObj;
+ pDataSetsStream = pDataSetsPDFObj->AsStream();
}
}
// L"datasets"
diff --git a/fpdfsdk/fpdf_sysfontinfo.cpp b/fpdfsdk/fpdf_sysfontinfo.cpp
index e310e4d6f7..3a3f9e1257 100644
--- a/fpdfsdk/fpdf_sysfontinfo.cpp
+++ b/fpdfsdk/fpdf_sysfontinfo.cpp
@@ -136,7 +136,7 @@ static void DefaultRelease(struct _FPDF_SYSFONTINFO* pThis) {
static void DefaultEnumFonts(struct _FPDF_SYSFONTINFO* pThis, void* pMapper) {
auto* pDefault = static_cast<FPDF_SYSFONTINFO_DEFAULT*>(pThis);
- pDefault->m_pFontInfo->EnumFontList((CFX_FontMapper*)pMapper);
+ pDefault->m_pFontInfo->EnumFontList(static_cast<CFX_FontMapper*>(pMapper));
}
static void* DefaultMapFont(struct _FPDF_SYSFONTINFO* pThis,
diff --git a/fpdfsdk/fpdf_text.cpp b/fpdfsdk/fpdf_text.cpp
index c5906acef0..dade84a005 100644
--- a/fpdfsdk/fpdf_text.cpp
+++ b/fpdfsdk/fpdf_text.cpp
@@ -51,7 +51,7 @@ FPDF_EXPORT FPDF_TEXTPAGE FPDF_CALLCONV FPDFText_LoadPage(FPDF_PAGE page) {
return nullptr;
#ifdef PDF_ENABLE_XFA
- CPDFXFA_Page* pPage = (CPDFXFA_Page*)page;
+ CPDFXFA_Page* pPage = UnderlyingFromFPDFPage(page);
CPDFXFA_Context* pContext = pPage->GetContext();
CPDF_ViewerPreferences viewRef(pContext->GetPDFDoc());
#else // PDF_ENABLE_XFA
diff --git a/fpdfsdk/fpdf_transformpage.cpp b/fpdfsdk/fpdf_transformpage.cpp
index 860ba42c96..d2d9f8dbc4 100644
--- a/fpdfsdk/fpdf_transformpage.cpp
+++ b/fpdfsdk/fpdf_transformpage.cpp
@@ -189,9 +189,10 @@ FPDFPageObj_TransformClipPath(FPDF_PAGEOBJECT page_object,
double d,
double e,
double f) {
- CPDF_PageObject* pPageObj = (CPDF_PageObject*)page_object;
+ CPDF_PageObject* pPageObj = CPDFPageObjectFromFPDFPageObject(page_object);
if (!pPageObj)
return;
+
CFX_Matrix matrix((float)a, (float)b, (float)c, (float)d, (float)e, (float)f);
// Special treatment to shading object, because the ClipPath for shading
@@ -267,7 +268,7 @@ FPDF_EXPORT void FPDF_CALLCONV FPDFPage_InsertClipPath(FPDF_PAGE page,
return;
std::ostringstream strClip;
- CPDF_ClipPath* pClipPath = (CPDF_ClipPath*)clipPath;
+ auto* pClipPath = static_cast<CPDF_ClipPath*>(clipPath);
for (size_t i = 0; i < pClipPath->GetPathCount(); ++i) {
CPDF_Path path = pClipPath->GetPath(i);
if (path.GetPoints().empty()) {
diff --git a/fpdfsdk/pwl/cpwl_combo_box.cpp b/fpdfsdk/pwl/cpwl_combo_box.cpp
index 2e6e56c52b..a69dd7418f 100644
--- a/fpdfsdk/pwl/cpwl_combo_box.cpp
+++ b/fpdfsdk/pwl/cpwl_combo_box.cpp
@@ -88,7 +88,7 @@ bool CPWL_CBListBox::IsChar(uint16_t nChar, uint32_t nFlag) const {
}
bool CPWL_CBListBox::OnCharNotify(uint16_t nChar, uint32_t nFlag) {
- if (CPWL_ComboBox* pComboBox = (CPWL_ComboBox*)GetParentWindow())
+ if (auto* pComboBox = static_cast<CPWL_ComboBox*>(GetParentWindow()))
pComboBox->SetSelectText();
return OnNotifySelectionChanged(true, nFlag);
@@ -99,7 +99,6 @@ void CPWL_CBButton::DrawThisAppearance(CFX_RenderDevice* pDevice,
CPWL_Wnd::DrawThisAppearance(pDevice, mtUser2Device);
CFX_FloatRect rectWnd = CPWL_Wnd::GetWindowRect();
-
if (!IsVisible() || rectWnd.IsEmpty())
return;