summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorthestig <thestig@chromium.org>2016-05-23 17:54:02 -0700
committerCommit bot <commit-bot@chromium.org>2016-05-23 17:54:02 -0700
commitded3634145b214b11212a7c53faa8ba15a1789ca (patch)
treefe715734e07dc73b3b63d9223d59e7a2799b557e
parenta2d699f1462050833f959ebcf24853c2a6a10f72 (diff)
downloadpdfium-ded3634145b214b11212a7c53faa8ba15a1789ca.tar.xz
Change CPDF_Boolean to use bool instead of FX_BOOL.
Review-Url: https://codereview.chromium.org/1999313002
-rw-r--r--core/fpdfapi/fpdf_parser/cpdf_boolean.cpp2
-rw-r--r--core/fpdfapi/fpdf_parser/cpdf_boolean.h4
-rw-r--r--core/fpdfapi/fpdf_parser/cpdf_dictionary.cpp8
-rw-r--r--core/fpdfapi/fpdf_parser/cpdf_security_handler.cpp7
-rw-r--r--core/fpdfapi/fpdf_parser/cpdf_security_handler.h2
-rw-r--r--core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h5
-rw-r--r--core/fpdfdoc/doc_action.cpp39
-rw-r--r--core/fpdfdoc/doc_utils.cpp8
-rw-r--r--core/fpdfdoc/include/fpdf_doc.h14
-rw-r--r--fpdfsdk/fpdfview.cpp9
-rw-r--r--fpdfsdk/fsdk_baseform.cpp2
-rw-r--r--fpdfsdk/javascript/Field.cpp3
-rw-r--r--fpdfsdk/pdfwindow/PWL_Icon.cpp7
-rw-r--r--fpdfsdk/pdfwindow/PWL_Icon.h1
14 files changed, 24 insertions, 87 deletions
diff --git a/core/fpdfapi/fpdf_parser/cpdf_boolean.cpp b/core/fpdfapi/fpdf_parser/cpdf_boolean.cpp
index cd7ed32a96..c5fd277d74 100644
--- a/core/fpdfapi/fpdf_parser/cpdf_boolean.cpp
+++ b/core/fpdfapi/fpdf_parser/cpdf_boolean.cpp
@@ -8,7 +8,7 @@
CPDF_Boolean::CPDF_Boolean() : m_bValue(false) {}
-CPDF_Boolean::CPDF_Boolean(FX_BOOL value) : m_bValue(value) {}
+CPDF_Boolean::CPDF_Boolean(bool value) : m_bValue(value) {}
CPDF_Boolean::~CPDF_Boolean() {}
diff --git a/core/fpdfapi/fpdf_parser/cpdf_boolean.h b/core/fpdfapi/fpdf_parser/cpdf_boolean.h
index c92bf41b86..adbb721f35 100644
--- a/core/fpdfapi/fpdf_parser/cpdf_boolean.h
+++ b/core/fpdfapi/fpdf_parser/cpdf_boolean.h
@@ -14,7 +14,7 @@
class CPDF_Boolean : public CPDF_Object {
public:
CPDF_Boolean();
- explicit CPDF_Boolean(FX_BOOL value);
+ explicit CPDF_Boolean(bool value);
// CPDF_Object.
Type GetType() const override;
@@ -29,7 +29,7 @@ class CPDF_Boolean : public CPDF_Object {
protected:
~CPDF_Boolean() override;
- FX_BOOL m_bValue;
+ bool m_bValue;
};
#endif // CORE_FPDFAPI_FPDF_PARSER_CPDF_BOOLEAN_H_
diff --git a/core/fpdfapi/fpdf_parser/cpdf_dictionary.cpp b/core/fpdfapi/fpdf_parser/cpdf_dictionary.cpp
index 27b866a65b..4ea8f438bd 100644
--- a/core/fpdfapi/fpdf_parser/cpdf_dictionary.cpp
+++ b/core/fpdfapi/fpdf_parser/cpdf_dictionary.cpp
@@ -96,10 +96,10 @@ FX_FLOAT CPDF_Dictionary::GetNumberBy(const CFX_ByteString& key) const {
return p ? p->GetNumber() : 0;
}
-FX_BOOL CPDF_Dictionary::GetBooleanBy(const CFX_ByteString& key,
- FX_BOOL bDefault) const {
+bool CPDF_Dictionary::GetBooleanBy(const CFX_ByteString& key,
+ bool bDefault) const {
CPDF_Object* p = GetObjectBy(key);
- return ToBoolean(p) ? p->GetInteger() : bDefault;
+ return ToBoolean(p) ? p->GetInteger() != 0 : bDefault;
}
CPDF_Dictionary* CPDF_Dictionary::GetDictBy(const CFX_ByteString& key) const {
@@ -224,7 +224,7 @@ void CPDF_Dictionary::SetAtNumber(const CFX_ByteString& key, FX_FLOAT f) {
SetAt(key, new CPDF_Number(f));
}
-void CPDF_Dictionary::SetAtBoolean(const CFX_ByteString& key, FX_BOOL bValue) {
+void CPDF_Dictionary::SetAtBoolean(const CFX_ByteString& key, bool bValue) {
SetAt(key, new CPDF_Boolean(bValue));
}
diff --git a/core/fpdfapi/fpdf_parser/cpdf_security_handler.cpp b/core/fpdfapi/fpdf_parser/cpdf_security_handler.cpp
index 94ef042bc0..054266765a 100644
--- a/core/fpdfapi/fpdf_parser/cpdf_security_handler.cpp
+++ b/core/fpdfapi/fpdf_parser/cpdf_security_handler.cpp
@@ -512,8 +512,9 @@ FX_BOOL CPDF_SecurityHandler::CheckOwnerPassword(const uint8_t* password,
return CheckUserPassword(user_pass.raw_str(), user_pass.GetLength(), TRUE,
key, key_len);
}
-FX_BOOL CPDF_SecurityHandler::IsMetadataEncrypted() {
- return m_pEncryptDict->GetBooleanBy("EncryptMetadata", TRUE);
+
+bool CPDF_SecurityHandler::IsMetadataEncrypted() const {
+ return m_pEncryptDict->GetBooleanBy("EncryptMetadata", true);
}
void CPDF_SecurityHandler::OnCreate(CPDF_Dictionary* pEncryptDict,
@@ -545,7 +546,7 @@ void CPDF_SecurityHandler::OnCreate(CPDF_Dictionary* pEncryptDict,
AES256_SetPassword(pEncryptDict, owner_pass, owner_size, TRUE,
m_EncryptKey);
AES256_SetPerms(pEncryptDict, m_Permissions,
- pEncryptDict->GetBooleanBy("EncryptMetadata", TRUE),
+ pEncryptDict->GetBooleanBy("EncryptMetadata", true),
m_EncryptKey);
}
return;
diff --git a/core/fpdfapi/fpdf_parser/cpdf_security_handler.h b/core/fpdfapi/fpdf_parser/cpdf_security_handler.h
index d342c1484e..3cf4d2cd19 100644
--- a/core/fpdfapi/fpdf_parser/cpdf_security_handler.h
+++ b/core/fpdfapi/fpdf_parser/cpdf_security_handler.h
@@ -30,7 +30,7 @@ class CPDF_SecurityHandler {
FX_BOOL OnInit(CPDF_Parser* pParser, CPDF_Dictionary* pEncryptDict);
uint32_t GetPermissions();
FX_BOOL GetCryptInfo(int& cipher, const uint8_t*& buffer, int& keylen);
- FX_BOOL IsMetadataEncrypted();
+ bool IsMetadataEncrypted() const;
CPDF_CryptoHandler* CreateCryptoHandler();
void OnCreate(CPDF_Dictionary* pEncryptDict,
diff --git a/core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h b/core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h
index e3b7496da7..41cec0cda2 100644
--- a/core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h
+++ b/core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h
@@ -39,8 +39,7 @@ class CPDF_Dictionary : public CPDF_Object {
CFX_WideString GetUnicodeTextBy(const CFX_ByteString& key) const;
int GetIntegerBy(const CFX_ByteString& key) const;
int GetIntegerBy(const CFX_ByteString& key, int default_int) const;
- FX_BOOL GetBooleanBy(const CFX_ByteString& key,
- FX_BOOL bDefault = FALSE) const;
+ bool GetBooleanBy(const CFX_ByteString& key, bool bDefault = false) const;
FX_FLOAT GetNumberBy(const CFX_ByteString& key) const;
CPDF_Dictionary* GetDictBy(const CFX_ByteString& key) const;
CPDF_Stream* GetStreamBy(const CFX_ByteString& key) const;
@@ -70,7 +69,7 @@ class CPDF_Dictionary : public CPDF_Object {
}
void SetAtRect(const CFX_ByteString& key, const CFX_FloatRect& rect);
void SetAtMatrix(const CFX_ByteString& key, const CFX_Matrix& matrix);
- void SetAtBoolean(const CFX_ByteString& key, FX_BOOL bValue);
+ void SetAtBoolean(const CFX_ByteString& key, bool bValue);
void AddReference(const CFX_ByteString& key,
CPDF_IndirectObjectHolder* pDoc,
diff --git a/core/fpdfdoc/doc_action.cpp b/core/fpdfdoc/doc_action.cpp
index 6f3e2945fa..e646df2b4c 100644
--- a/core/fpdfdoc/doc_action.cpp
+++ b/core/fpdfdoc/doc_action.cpp
@@ -193,44 +193,7 @@ CFX_WideString CPDF_Action::GetJavaScript() const {
CPDF_Object* pJS = m_pDict->GetDirectObjectBy("JS");
return pJS ? pJS->GetUnicodeText() : csJS;
}
-CPDF_Dictionary* CPDF_Action::GetAnnot() const {
- if (!m_pDict) {
- return nullptr;
- }
- CFX_ByteString csType = m_pDict->GetStringBy("S");
- if (csType == "Rendition") {
- return m_pDict->GetDictBy("AN");
- }
- if (csType == "Movie") {
- return m_pDict->GetDictBy("Annotation");
- }
- return nullptr;
-}
-int32_t CPDF_Action::GetOperationType() const {
- if (!m_pDict) {
- return 0;
- }
- CFX_ByteString csType = m_pDict->GetStringBy("S");
- if (csType == "Rendition") {
- return m_pDict->GetIntegerBy("OP");
- }
- if (csType == "Movie") {
- CFX_ByteString csOP = m_pDict->GetStringBy("Operation");
- if (csOP == "Play") {
- return 0;
- }
- if (csOP == "Stop") {
- return 1;
- }
- if (csOP == "Pause") {
- return 2;
- }
- if (csOP == "Resume") {
- return 3;
- }
- }
- return 0;
-}
+
size_t CPDF_Action::GetSubActionsCount() const {
if (!m_pDict || !m_pDict->KeyExist("Next"))
return 0;
diff --git a/core/fpdfdoc/doc_utils.cpp b/core/fpdfdoc/doc_utils.cpp
index 408f0065e2..6c61c3d75e 100644
--- a/core/fpdfdoc/doc_utils.cpp
+++ b/core/fpdfdoc/doc_utils.cpp
@@ -716,11 +716,9 @@ void CPDF_IconFit::GetIconPosition(FX_FLOAT& fLeft, FX_FLOAT& fBottom) {
}
}
}
-FX_BOOL CPDF_IconFit::GetFittingBounds() {
- if (!m_pDict) {
- return FALSE;
- }
- return m_pDict->GetBooleanBy("FB");
+
+bool CPDF_IconFit::GetFittingBounds() {
+ return m_pDict ? m_pDict->GetBooleanBy("FB") : false;
}
std::vector<bool> SaveCheckedFieldStatus(CPDF_FormField* pField) {
diff --git a/core/fpdfdoc/include/fpdf_doc.h b/core/fpdfdoc/include/fpdf_doc.h
index 4fc5b5232b..3ee583d778 100644
--- a/core/fpdfdoc/include/fpdf_doc.h
+++ b/core/fpdfdoc/include/fpdf_doc.h
@@ -188,24 +188,14 @@ class CPDF_Action {
explicit CPDF_Action(CPDF_Dictionary* pDict) : m_pDict(pDict) {}
CPDF_Dictionary* GetDict() const { return m_pDict; }
- CFX_ByteString GetTypeName() const { return m_pDict->GetStringBy("S"); }
ActionType GetType() const;
CPDF_Dest GetDest(CPDF_Document* pDoc) const;
CFX_WideString GetFilePath() const;
- FX_BOOL GetNewWindow() const { return m_pDict->GetBooleanBy("NewWindow"); }
CFX_ByteString GetURI(CPDF_Document* pDoc) const;
- FX_BOOL GetMouseMap() const { return m_pDict->GetBooleanBy("IsMap"); }
- FX_BOOL GetHideStatus() const { return m_pDict->GetBooleanBy("H", TRUE); }
+ bool GetHideStatus() const { return m_pDict->GetBooleanBy("H", true); }
CFX_ByteString GetNamedAction() const { return m_pDict->GetStringBy("N"); }
uint32_t GetFlags() const { return m_pDict->GetIntegerBy("Flags"); }
CFX_WideString GetJavaScript() const;
- CPDF_Dictionary* GetAnnot() const;
- int32_t GetOperationType() const;
- CPDF_Stream* GetSoundStream() const { return m_pDict->GetStreamBy("Sound"); }
- FX_FLOAT GetVolume() const { return m_pDict->GetNumberBy("Volume"); }
- FX_BOOL IsSynchronous() const { return m_pDict->GetBooleanBy("Synchronous"); }
- FX_BOOL IsRepeat() const { return m_pDict->GetBooleanBy("Repeat"); }
- FX_BOOL IsMixPlay() const { return m_pDict->GetBooleanBy("Mix"); }
size_t GetSubActionsCount() const;
CPDF_Action GetSubAction(size_t iIndex) const;
@@ -794,7 +784,7 @@ class CPDF_IconFit {
ScaleMethod GetScaleMethod();
FX_BOOL IsProportionalScale();
void GetIconPosition(FX_FLOAT& fLeft, FX_FLOAT& fBottom);
- FX_BOOL GetFittingBounds();
+ bool GetFittingBounds();
const CPDF_Dictionary* GetDict() const { return m_pDict; }
protected:
diff --git a/fpdfsdk/fpdfview.cpp b/fpdfsdk/fpdfview.cpp
index e7b3a96b0b..cdcaba4318 100644
--- a/fpdfsdk/fpdfview.cpp
+++ b/fpdfsdk/fpdfview.cpp
@@ -364,13 +364,8 @@ DLLEXPORT FPDF_BOOL STDCALL FPDF_HasXFAField(FPDF_DOCUMENT document,
if (!pXFA)
return FALSE;
- FX_BOOL bDynamicXFA = pRoot->GetBooleanBy("NeedsRendering", FALSE);
-
- if (bDynamicXFA)
- *docType = DOCTYPE_DYNAMIC_XFA;
- else
- *docType = DOCTYPE_STATIC_XFA;
-
+ bool bDynamicXFA = pRoot->GetBooleanBy("NeedsRendering", false);
+ *docType = bDynamicXFA ? DOCTYPE_DYNAMIC_XFA : DOCTYPE_STATIC_XFA;
return TRUE;
}
diff --git a/fpdfsdk/fsdk_baseform.cpp b/fpdfsdk/fsdk_baseform.cpp
index dbef4a9b67..6461221552 100644
--- a/fpdfsdk/fsdk_baseform.cpp
+++ b/fpdfsdk/fsdk_baseform.cpp
@@ -2312,7 +2312,7 @@ FX_BOOL CPDFSDK_InterForm::DoAction_Hide(const CPDF_Action& action) {
std::vector<CPDF_Object*> fieldObjects = af.GetAllFields();
std::vector<CPDF_FormField*> fields = GetFieldFromObjects(fieldObjects);
- FX_BOOL bHide = action.GetHideStatus();
+ bool bHide = action.GetHideStatus();
FX_BOOL bChanged = FALSE;
for (CPDF_FormField* pField : fields) {
diff --git a/fpdfsdk/javascript/Field.cpp b/fpdfsdk/javascript/Field.cpp
index c1838332ba..2a739deed0 100644
--- a/fpdfsdk/javascript/Field.cpp
+++ b/fpdfsdk/javascript/Field.cpp
@@ -601,8 +601,7 @@ FX_BOOL Field::buttonFitBounds(IJS_Context* cc,
if (!pFormControl)
return FALSE;
- CPDF_IconFit IconFit = pFormControl->GetIconFit();
- vp << IconFit.GetFittingBounds();
+ vp << pFormControl->GetIconFit().GetFittingBounds();
}
return TRUE;
diff --git a/fpdfsdk/pdfwindow/PWL_Icon.cpp b/fpdfsdk/pdfwindow/PWL_Icon.cpp
index cfd62dfcd9..18111ac358 100644
--- a/fpdfsdk/pdfwindow/PWL_Icon.cpp
+++ b/fpdfsdk/pdfwindow/PWL_Icon.cpp
@@ -145,13 +145,6 @@ void CPWL_Icon::GetIconPosition(FX_FLOAT& fLeft, FX_FLOAT& fBottom) {
}
}
-FX_BOOL CPWL_Icon::GetFittingBounds() {
- if (m_pIconFit)
- return m_pIconFit->GetFittingBounds();
-
- return FALSE;
-}
-
void CPWL_Icon::GetScale(FX_FLOAT& fHScale, FX_FLOAT& fVScale) {
fHScale = 1.0f;
fVScale = 1.0f;
diff --git a/fpdfsdk/pdfwindow/PWL_Icon.h b/fpdfsdk/pdfwindow/PWL_Icon.h
index 5abf9c26cc..a5bd907012 100644
--- a/fpdfsdk/pdfwindow/PWL_Icon.h
+++ b/fpdfsdk/pdfwindow/PWL_Icon.h
@@ -47,7 +47,6 @@ class CPWL_Icon : public CPWL_Image {
int32_t GetScaleMethod();
FX_BOOL IsProportionalScale();
void GetIconPosition(FX_FLOAT& fLeft, FX_FLOAT& fBottom);
- FX_BOOL GetFittingBounds();
void SetIconFit(CPDF_IconFit* pIconFit) { m_pIconFit = pIconFit; }