summaryrefslogtreecommitdiff
path: root/fpdfsdk
diff options
context:
space:
mode:
Diffstat (limited to 'fpdfsdk')
-rw-r--r--fpdfsdk/include/fsdk_baseannot.h14
-rw-r--r--fpdfsdk/include/fxedit/fxet_list.h6
-rw-r--r--fpdfsdk/include/pdfwindow/PWL_Wnd.h6
-rw-r--r--fpdfsdk/src/formfiller/FFL_CBA_Fontmap.cpp4
-rw-r--r--fpdfsdk/src/fsdk_baseannot.cpp48
-rw-r--r--fpdfsdk/src/fsdk_baseform.cpp6
-rw-r--r--fpdfsdk/src/fxedit/fxet_pageobjs.cpp6
-rw-r--r--fpdfsdk/src/javascript/Document.cpp3
8 files changed, 31 insertions, 62 deletions
diff --git a/fpdfsdk/include/fsdk_baseannot.h b/fpdfsdk/include/fsdk_baseannot.h
index c0ed529782..8cee331f64 100644
--- a/fpdfsdk/include/fsdk_baseannot.h
+++ b/fpdfsdk/include/fsdk_baseannot.h
@@ -36,19 +36,19 @@ class CPDFSDK_DateTime {
CPDFSDK_DateTime& operator=(const CPDFSDK_DateTime& datetime);
CPDFSDK_DateTime& operator=(const FX_SYSTEMTIME& st);
- FX_BOOL operator==(CPDFSDK_DateTime& datetime);
- FX_BOOL operator!=(CPDFSDK_DateTime& datetime);
- FX_BOOL operator>(CPDFSDK_DateTime& datetime);
- FX_BOOL operator>=(CPDFSDK_DateTime& datetime);
- FX_BOOL operator<(CPDFSDK_DateTime& datetime);
- FX_BOOL operator<=(CPDFSDK_DateTime& datetime);
+ bool operator==(const CPDFSDK_DateTime& datetime) const;
+ bool operator!=(const CPDFSDK_DateTime& datetime) const;
+ bool operator>(const CPDFSDK_DateTime& datetime) const;
+ bool operator>=(const CPDFSDK_DateTime& datetime) const;
+ bool operator<(const CPDFSDK_DateTime& datetime) const;
+ bool operator<=(const CPDFSDK_DateTime& datetime) const;
operator time_t();
CPDFSDK_DateTime& FromPDFDateTimeString(const CFX_ByteString& dtStr);
CFX_ByteString ToCommonDateTimeString();
CFX_ByteString ToPDFDateTimeString();
void ToSystemTime(FX_SYSTEMTIME& st);
- CPDFSDK_DateTime ToGMT();
+ CPDFSDK_DateTime ToGMT() const;
CPDFSDK_DateTime& AddDays(short days);
CPDFSDK_DateTime& AddSeconds(int seconds);
diff --git a/fpdfsdk/include/fxedit/fxet_list.h b/fpdfsdk/include/fxedit/fxet_list.h
index 88d57c4928..a02cd8a45e 100644
--- a/fpdfsdk/include/fxedit/fxet_list.h
+++ b/fpdfsdk/include/fxedit/fxet_list.h
@@ -67,13 +67,11 @@ class CLST_Rect : public CFX_FloatRect {
return *this;
}
- FX_BOOL operator==(const CLST_Rect& rect) const {
+ bool operator==(const CLST_Rect& rect) const {
return FXSYS_memcmp(this, &rect, sizeof(CLST_Rect)) == 0;
}
- FX_BOOL operator!=(const CLST_Rect& rect) const {
- return FXSYS_memcmp(this, &rect, sizeof(CLST_Rect)) != 0;
- }
+ bool operator!=(const CLST_Rect& rect) const { return !(*this == rect); }
FX_FLOAT Width() const { return right - left; }
diff --git a/fpdfsdk/include/pdfwindow/PWL_Wnd.h b/fpdfsdk/include/pdfwindow/PWL_Wnd.h
index 19046e6c9c..493cdc0874 100644
--- a/fpdfsdk/include/pdfwindow/PWL_Wnd.h
+++ b/fpdfsdk/include/pdfwindow/PWL_Wnd.h
@@ -134,7 +134,7 @@ struct CPWL_Color {
FX_FLOAT fColor1, fColor2, fColor3, fColor4;
};
-inline FX_BOOL operator==(const CPWL_Color& c1, const CPWL_Color& c2) {
+inline bool operator==(const CPWL_Color& c1, const CPWL_Color& c2) {
return c1.nColorType == c2.nColorType && c1.fColor1 - c2.fColor1 < 0.0001 &&
c1.fColor1 - c2.fColor1 > -0.0001 &&
c1.fColor2 - c2.fColor2 < 0.0001 &&
@@ -144,8 +144,8 @@ inline FX_BOOL operator==(const CPWL_Color& c1, const CPWL_Color& c2) {
c1.fColor4 - c2.fColor4 < 0.0001 && c1.fColor4 - c2.fColor4 > -0.0001;
}
-inline FX_BOOL operator!=(const CPWL_Color& c1, const CPWL_Color& c2) {
- return !operator==(c1, c2);
+inline bool operator!=(const CPWL_Color& c1, const CPWL_Color& c2) {
+ return !(c1 == c2);
}
#define PWL_SCROLLBAR_WIDTH 12.0f
diff --git a/fpdfsdk/src/formfiller/FFL_CBA_Fontmap.cpp b/fpdfsdk/src/formfiller/FFL_CBA_Fontmap.cpp
index bba44ab639..b28cdf7749 100644
--- a/fpdfsdk/src/formfiller/FFL_CBA_Fontmap.cpp
+++ b/fpdfsdk/src/formfiller/FFL_CBA_Fontmap.cpp
@@ -196,9 +196,7 @@ void CBA_FontMap::AddFontToAnnotDict(CPDF_Font* pFont,
CPDF_Font* CBA_FontMap::GetAnnotDefaultFont(CFX_ByteString& sAlias) {
CPDF_Dictionary* pAcroFormDict = NULL;
-
- FX_BOOL bWidget = (m_pAnnotDict->GetStringBy("Subtype") == "Widget");
-
+ const bool bWidget = (m_pAnnotDict->GetStringBy("Subtype") == "Widget");
if (bWidget) {
if (CPDF_Dictionary* pRootDict = m_pDocument->GetRoot())
pAcroFormDict = pRootDict->GetDictBy("AcroForm");
diff --git a/fpdfsdk/src/fsdk_baseannot.cpp b/fpdfsdk/src/fsdk_baseannot.cpp
index 705205f1e2..132d30b857 100644
--- a/fpdfsdk/src/fsdk_baseannot.cpp
+++ b/fpdfsdk/src/fsdk_baseannot.cpp
@@ -85,9 +85,7 @@ void CPDFSDK_DateTime::ResetDateTime() {
time_t curTime;
time(&curTime);
- struct tm* newtime;
- // newtime = gmtime(&curTime);
- newtime = localtime(&curTime);
+ struct tm* newtime = localtime(&curTime);
dt.year = newtime->tm_year + 1900;
dt.month = newtime->tm_mon + 1;
@@ -95,8 +93,6 @@ void CPDFSDK_DateTime::ResetDateTime() {
dt.hour = newtime->tm_hour;
dt.minute = newtime->tm_min;
dt.second = newtime->tm_sec;
- // dt.tzHour = _timezone / 3600 * -1;
- // dt.tzMinute = (abs(_timezone) % 3600) / 60;
}
CPDFSDK_DateTime& CPDFSDK_DateTime::operator=(
@@ -114,20 +110,18 @@ CPDFSDK_DateTime& CPDFSDK_DateTime::operator=(const FX_SYSTEMTIME& st) {
dt.hour = (uint8_t)st.wHour;
dt.minute = (uint8_t)st.wMinute;
dt.second = (uint8_t)st.wSecond;
- // dt.tzHour = _timezone / 3600 * -1;
- // dt.tzMinute = (abs(_timezone) % 3600) / 60;
return *this;
}
-FX_BOOL CPDFSDK_DateTime::operator==(CPDFSDK_DateTime& datetime) {
+bool CPDFSDK_DateTime::operator==(const CPDFSDK_DateTime& datetime) const {
return (FXSYS_memcmp(&dt, &datetime.dt, sizeof(FX_DATETIME)) == 0);
}
-FX_BOOL CPDFSDK_DateTime::operator!=(CPDFSDK_DateTime& datetime) {
- return (FXSYS_memcmp(&dt, &datetime.dt, sizeof(FX_DATETIME)) != 0);
+bool CPDFSDK_DateTime::operator!=(const CPDFSDK_DateTime& datetime) const {
+ return !(*this == datetime);
}
-FX_BOOL CPDFSDK_DateTime::operator>(CPDFSDK_DateTime& datetime) {
+bool CPDFSDK_DateTime::operator>(const CPDFSDK_DateTime& datetime) const {
CPDFSDK_DateTime dt1 = ToGMT();
CPDFSDK_DateTime dt2 = datetime.ToGMT();
int d1 =
@@ -139,14 +133,10 @@ FX_BOOL CPDFSDK_DateTime::operator>(CPDFSDK_DateTime& datetime) {
int d4 = (((int)dt2.dt.hour) << 16) | (((int)dt2.dt.minute) << 8) |
(int)dt2.dt.second;
- if (d1 > d3)
- return TRUE;
- if (d2 > d4)
- return TRUE;
- return FALSE;
+ return d1 > d3 || d2 > d4;
}
-FX_BOOL CPDFSDK_DateTime::operator>=(CPDFSDK_DateTime& datetime) {
+bool CPDFSDK_DateTime::operator>=(const CPDFSDK_DateTime& datetime) const {
CPDFSDK_DateTime dt1 = ToGMT();
CPDFSDK_DateTime dt2 = datetime.ToGMT();
int d1 =
@@ -158,14 +148,10 @@ FX_BOOL CPDFSDK_DateTime::operator>=(CPDFSDK_DateTime& datetime) {
int d4 = (((int)dt2.dt.hour) << 16) | (((int)dt2.dt.minute) << 8) |
(int)dt2.dt.second;
- if (d1 >= d3)
- return TRUE;
- if (d2 >= d4)
- return TRUE;
- return FALSE;
+ return d1 >= d3 || d2 >= d4;
}
-FX_BOOL CPDFSDK_DateTime::operator<(CPDFSDK_DateTime& datetime) {
+bool CPDFSDK_DateTime::operator<(const CPDFSDK_DateTime& datetime) const {
CPDFSDK_DateTime dt1 = ToGMT();
CPDFSDK_DateTime dt2 = datetime.ToGMT();
int d1 =
@@ -177,14 +163,10 @@ FX_BOOL CPDFSDK_DateTime::operator<(CPDFSDK_DateTime& datetime) {
int d4 = (((int)dt2.dt.hour) << 16) | (((int)dt2.dt.minute) << 8) |
(int)dt2.dt.second;
- if (d1 < d3)
- return TRUE;
- if (d2 < d4)
- return TRUE;
- return FALSE;
+ return d1 < d3 || d2 < d4;
}
-FX_BOOL CPDFSDK_DateTime::operator<=(CPDFSDK_DateTime& datetime) {
+bool CPDFSDK_DateTime::operator<=(const CPDFSDK_DateTime& datetime) const {
CPDFSDK_DateTime dt1 = ToGMT();
CPDFSDK_DateTime dt2 = datetime.ToGMT();
int d1 =
@@ -196,11 +178,7 @@ FX_BOOL CPDFSDK_DateTime::operator<=(CPDFSDK_DateTime& datetime) {
int d4 = (((int)dt2.dt.hour) << 16) | (((int)dt2.dt.minute) << 8) |
(int)dt2.dt.second;
- if (d1 <= d3)
- return TRUE;
- if (d2 <= d4)
- return TRUE;
- return FALSE;
+ return d1 <= d3 || d2 <= d4;
}
CPDFSDK_DateTime::operator time_t() {
@@ -402,7 +380,7 @@ void CPDFSDK_DateTime::ToSystemTime(FX_SYSTEMTIME& st) {
}
}
-CPDFSDK_DateTime CPDFSDK_DateTime::ToGMT() {
+CPDFSDK_DateTime CPDFSDK_DateTime::ToGMT() const {
CPDFSDK_DateTime dt = *this;
dt.AddSeconds(-gAfxGetTimeZoneInSeconds(dt.dt.tzHour, dt.dt.tzMinute));
dt.dt.tzHour = 0;
diff --git a/fpdfsdk/src/fsdk_baseform.cpp b/fpdfsdk/src/fsdk_baseform.cpp
index 0359c0bc9f..79180324f7 100644
--- a/fpdfsdk/src/fsdk_baseform.cpp
+++ b/fpdfsdk/src/fsdk_baseform.cpp
@@ -662,10 +662,8 @@ FX_BOOL CPDFSDK_Widget::IsChecked() const {
#ifdef PDF_ENABLE_XFA
if (IXFA_WidgetHandler* pXFAWidgetHandler = GetXFAWidgetHandler()) {
if (IXFA_Widget* hWidget = GetMixXFAWidget()) {
- if (CXFA_WidgetAcc* pWidgetAcc = pXFAWidgetHandler->GetDataAcc(hWidget)) {
- FX_BOOL bChecked = pWidgetAcc->GetCheckState() == XFA_CHECKSTATE_On;
- return bChecked;
- }
+ if (CXFA_WidgetAcc* pWidgetAcc = pXFAWidgetHandler->GetDataAcc(hWidget))
+ return pWidgetAcc->GetCheckState() == XFA_CHECKSTATE_On;
}
}
#endif // PDF_ENABLE_XFA
diff --git a/fpdfsdk/src/fxedit/fxet_pageobjs.cpp b/fpdfsdk/src/fxedit/fxet_pageobjs.cpp
index 752e537099..d7803311a5 100644
--- a/fpdfsdk/src/fxedit/fxet_pageobjs.cpp
+++ b/fpdfsdk/src/fxedit/fxet_pageobjs.cpp
@@ -151,10 +151,8 @@ void IFX_Edit::DrawEdit(CFX_RenderDevice* pDevice,
const CPVT_WordRange* pRange,
IFX_SystemHandler* pSystemHandler,
void* pFFLData) {
- FX_BOOL bContinuous = pEdit->GetCharArray() == 0;
- if (pEdit->GetCharSpace() > 0.0f)
- bContinuous = FALSE;
-
+ const bool bContinuous =
+ pEdit->GetCharArray() == 0 && pEdit->GetCharSpace() <= 0.0f;
FX_WORD SubWord = pEdit->GetPasswordChar();
FX_FLOAT fFontSize = pEdit->GetFontSize();
CPVT_WordRange wrSelect = pEdit->GetSelectWordRange();
diff --git a/fpdfsdk/src/javascript/Document.cpp b/fpdfsdk/src/javascript/Document.cpp
index 8b2b315ae8..4d774426f0 100644
--- a/fpdfsdk/src/javascript/Document.cpp
+++ b/fpdfsdk/src/javascript/Document.cpp
@@ -622,8 +622,7 @@ FX_BOOL Document::submitForm(IJS_Context* cc,
CPDFSDK_InterForm* pInterForm =
(CPDFSDK_InterForm*)m_pDocument->GetInterForm();
CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm();
- FX_BOOL bAll = (aFields.GetLength() == 0);
- if (bAll && bEmpty) {
+ if (aFields.GetLength() == 0 && bEmpty) {
if (pPDFInterForm->CheckRequiredFields(nullptr, true)) {
pRuntime->BeginBlock();
pInterForm->SubmitForm(strURL, FALSE);