diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2018-05-16 17:35:33 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-05-16 17:35:33 +0000 |
commit | 7675a246431600fb26d430fcd29503d8b48fe8e1 (patch) | |
tree | 62b70331a59d0f9f9f53b63b059bcd1462805899 | |
parent | 6facd15a7ecfbae24f2c356fa3b358288120a6f2 (diff) | |
download | pdfium-7675a246431600fb26d430fcd29503d8b48fe8e1.tar.xz |
Convert CJX_Object::Set* methods to return void
We never use the return values of these methods, switch to void from
bool.
Change-Id: I8b0d96e5be90ac08281bbb82d2c7205d94abea2b
Reviewed-on: https://pdfium-review.googlesource.com/32616
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
Commit-Queue: dsinclair <dsinclair@chromium.org>
-rw-r--r-- | fxjs/xfa/cjx_object.cpp | 71 | ||||
-rw-r--r-- | fxjs/xfa/cjx_object.h | 18 |
2 files changed, 44 insertions, 45 deletions
diff --git a/fxjs/xfa/cjx_object.cpp b/fxjs/xfa/cjx_object.cpp index cda4c6a45a..69c6dadddf 100644 --- a/fxjs/xfa/cjx_object.cpp +++ b/fxjs/xfa/cjx_object.cpp @@ -216,33 +216,36 @@ bool CJX_Object::HasAttribute(XFA_Attribute eAttr) { return HasMapModuleKey(pKey); } -bool CJX_Object::SetAttribute(XFA_Attribute eAttr, +void CJX_Object::SetAttribute(XFA_Attribute eAttr, const WideStringView& wsValue, bool bNotify) { switch (ToNode(GetXFAObject())->GetAttributeType(eAttr)) { case XFA_AttributeType::Enum: { Optional<XFA_AttributeEnum> item = CXFA_Node::NameToAttributeEnum(wsValue); - return SetEnum( - eAttr, - item ? *item : *(ToNode(GetXFAObject())->GetDefaultEnum(eAttr)), - bNotify); + SetEnum(eAttr, + item ? *item : *(ToNode(GetXFAObject())->GetDefaultEnum(eAttr)), + bNotify); + break; } case XFA_AttributeType::CData: - return SetCData(eAttr, WideString(wsValue), bNotify, false); + SetCData(eAttr, WideString(wsValue), bNotify, false); + break; case XFA_AttributeType::Boolean: - return SetBoolean(eAttr, wsValue != L"0", bNotify); + SetBoolean(eAttr, wsValue != L"0", bNotify); + break; case XFA_AttributeType::Integer: - return SetInteger(eAttr, - FXSYS_round(FXSYS_wcstof(wsValue.unterminated_c_str(), - wsValue.GetLength(), nullptr)), - bNotify); + SetInteger(eAttr, + FXSYS_round(FXSYS_wcstof(wsValue.unterminated_c_str(), + wsValue.GetLength(), nullptr)), + bNotify); + break; case XFA_AttributeType::Measure: - return SetMeasure(eAttr, CXFA_Measurement(wsValue), bNotify); + SetMeasure(eAttr, CXFA_Measurement(wsValue), bNotify); + break; default: break; } - return false; } void CJX_Object::SetMapModuleString(void* pKey, const WideStringView& wsValue) { @@ -250,16 +253,17 @@ void CJX_Object::SetMapModuleString(void* pKey, const WideStringView& wsValue) { wsValue.GetLength() * sizeof(wchar_t), nullptr); } -bool CJX_Object::SetAttribute(const WideStringView& wsAttr, +void CJX_Object::SetAttribute(const WideStringView& wsAttr, const WideStringView& wsValue, bool bNotify) { XFA_Attribute attr = CXFA_Node::NameToAttribute(wsValue); - if (attr != XFA_Attribute::Unknown) - return SetAttribute(attr, wsValue, bNotify); + if (attr != XFA_Attribute::Unknown) { + SetAttribute(attr, wsValue, bNotify); + return; + } void* pKey = GetMapKey_Custom(wsAttr); SetMapModuleString(pKey, wsValue); - return true; } WideString CJX_Object::GetAttribute(const WideStringView& attr) { @@ -339,26 +343,24 @@ Optional<bool> CJX_Object::TryBoolean(XFA_Attribute eAttr, bool bUseDefault) { return ToNode(GetXFAObject())->GetDefaultBoolean(eAttr); } -bool CJX_Object::SetBoolean(XFA_Attribute eAttr, bool bValue, bool bNotify) { +void CJX_Object::SetBoolean(XFA_Attribute eAttr, bool bValue, bool bNotify) { CFX_XMLElement* elem = SetValue(eAttr, XFA_AttributeType::Boolean, (void*)(uintptr_t)bValue, bNotify); if (elem) elem->SetAttribute(CXFA_Node::AttributeToName(eAttr), bValue ? L"1" : L"0"); - return true; } bool CJX_Object::GetBoolean(XFA_Attribute eAttr) { return TryBoolean(eAttr, true).value_or(false); } -bool CJX_Object::SetInteger(XFA_Attribute eAttr, int32_t iValue, bool bNotify) { +void CJX_Object::SetInteger(XFA_Attribute eAttr, int32_t iValue, bool bNotify) { CFX_XMLElement* elem = SetValue(eAttr, XFA_AttributeType::Integer, (void*)(uintptr_t)iValue, bNotify); if (elem) { elem->SetAttribute(CXFA_Node::AttributeToName(eAttr), WideString::Format(L"%d", iValue)); } - return true; } int32_t CJX_Object::GetInteger(XFA_Attribute eAttr) { @@ -391,7 +393,7 @@ Optional<XFA_AttributeEnum> CJX_Object::TryEnum(XFA_Attribute eAttr, return ToNode(GetXFAObject())->GetDefaultEnum(eAttr); } -bool CJX_Object::SetEnum(XFA_Attribute eAttr, +void CJX_Object::SetEnum(XFA_Attribute eAttr, XFA_AttributeEnum eValue, bool bNotify) { CFX_XMLElement* elem = SetValue(eAttr, XFA_AttributeType::Enum, @@ -400,21 +402,19 @@ bool CJX_Object::SetEnum(XFA_Attribute eAttr, elem->SetAttribute(CXFA_Node::AttributeToName(eAttr), CXFA_Node::AttributeEnumToName(eValue)); } - return true; } XFA_AttributeEnum CJX_Object::GetEnum(XFA_Attribute eAttr) const { return TryEnum(eAttr, true).value_or(XFA_AttributeEnum::Unknown); } -bool CJX_Object::SetMeasure(XFA_Attribute eAttr, +void CJX_Object::SetMeasure(XFA_Attribute eAttr, CXFA_Measurement mValue, bool bNotify) { void* pKey = GetMapKey_Element(GetXFAObject()->GetElementType(), eAttr); OnChanging(eAttr, bNotify); SetMapModuleBuffer(pKey, &mValue, sizeof(CXFA_Measurement), nullptr); OnChanged(eAttr, bNotify, false); - return true; } Optional<CXFA_Measurement> CJX_Object::TryMeasure(XFA_Attribute eAttr, @@ -447,7 +447,7 @@ WideString CJX_Object::GetCData(XFA_Attribute eAttr) { return TryCData(eAttr, true).value_or(WideString()); } -bool CJX_Object::SetCData(XFA_Attribute eAttr, +void CJX_Object::SetCData(XFA_Attribute eAttr, const WideString& wsValue, bool bNotify, bool bScriptModify) { @@ -466,18 +466,18 @@ bool CJX_Object::SetCData(XFA_Attribute eAttr, if (!xfaObj->IsNeedSavingXMLNode() || eAttr == XFA_Attribute::QualifiedName || eAttr == XFA_Attribute::BindingNode) { - return true; + return; } if (eAttr == XFA_Attribute::Name && (xfaObj->GetElementType() == XFA_Element::DataValue || xfaObj->GetElementType() == XFA_Element::DataGroup)) { - return true; + return; } if (eAttr == XFA_Attribute::Value) { xfaObj->SetToXML(wsValue); - return true; + return; } auto* elem = static_cast<CFX_XMLElement*>(xfaObj->GetXMLMappingNode()); @@ -488,7 +488,7 @@ bool CJX_Object::SetCData(XFA_Attribute eAttr, wsAttrName = L"xfa:" + wsAttrName; elem->SetAttribute(wsAttrName, wsValue); - return true; + return; } void CJX_Object::SetAttributeValue(const WideString& wsValue, @@ -554,7 +554,7 @@ CFX_XMLElement* CJX_Object::SetValue(XFA_Attribute eAttr, return elem; } -bool CJX_Object::SetContent(const WideString& wsContent, +void CJX_Object::SetContent(const WideString& wsContent, const WideString& wsXMLValue, bool bNotify, bool bScriptModify, @@ -692,8 +692,9 @@ bool CJX_Object::SetContent(const WideString& wsContent, : XFA_Element::Sharptext); ToNode(GetXFAObject())->InsertChild(pContentRawDataNode, nullptr); } - return pContentRawDataNode->JSObject()->SetContent( + pContentRawDataNode->JSObject()->SetContent( wsContent, wsXMLValue, bNotify, bScriptModify, bSyncData); + return; } case XFA_ObjectType::NodeC: case XFA_ObjectType::TextNode: @@ -727,7 +728,7 @@ bool CJX_Object::SetContent(const WideString& wsContent, break; } if (!pNode) - return false; + return; SetAttributeValue(wsContent, wsXMLValue, bNotify, bScriptModify); if (pBindNode && bSyncData) { @@ -736,7 +737,6 @@ bool CJX_Object::SetContent(const WideString& wsContent, bScriptModify, false); } } - return true; } WideString CJX_Object::GetContent(bool bScriptModify) { @@ -891,13 +891,12 @@ CXFA_Node* CJX_Object::GetOrCreatePropertyInternal(int32_t index, return pNewNode; } -bool CJX_Object::SetUserData( +void CJX_Object::SetUserData( void* pKey, void* pData, const XFA_MAPDATABLOCKCALLBACKINFO* pCallbackInfo) { SetMapModuleBuffer(pKey, &pData, sizeof(void*), pCallbackInfo ? pCallbackInfo : &gs_XFADefaultFreeData); - return true; } XFA_MAPMODULEDATA* CJX_Object::CreateMapModuleData() { diff --git a/fxjs/xfa/cjx_object.h b/fxjs/xfa/cjx_object.h index 88f1d8c814..1fcd753b14 100644 --- a/fxjs/xfa/cjx_object.h +++ b/fxjs/xfa/cjx_object.h @@ -74,10 +74,10 @@ class CJX_Object { const std::vector<v8::Local<v8::Value>>& params); bool HasAttribute(XFA_Attribute eAttr); - bool SetAttribute(XFA_Attribute eAttr, + void SetAttribute(XFA_Attribute eAttr, const WideStringView& wsValue, bool bNotify); - bool SetAttribute(const WideStringView& wsAttr, + void SetAttribute(const WideStringView& wsAttr, const WideStringView& wsValue, bool bNotify); void RemoveAttribute(const WideStringView& wsAttr); @@ -88,7 +88,7 @@ class CJX_Object { Optional<WideString> TryAttribute(XFA_Attribute eAttr, bool bUseDefault); Optional<WideString> TryContent(bool bScriptModify, bool bProto); - bool SetContent(const WideString& wsContent, + void SetContent(const WideString& wsContent, const WideString& wsXMLValue, bool bNotify, bool bScriptModify, @@ -177,11 +177,11 @@ class CJX_Object { Optional<WideString> TryNamespace(); Optional<int32_t> TryInteger(XFA_Attribute eAttr, bool bUseDefault); - bool SetInteger(XFA_Attribute eAttr, int32_t iValue, bool bNotify); + void SetInteger(XFA_Attribute eAttr, int32_t iValue, bool bNotify); int32_t GetInteger(XFA_Attribute eAttr); Optional<WideString> TryCData(XFA_Attribute eAttr, bool bUseDefault); - bool SetCData(XFA_Attribute eAttr, + void SetCData(XFA_Attribute eAttr, const WideString& wsValue, bool bNotify, bool bScriptModify); @@ -189,17 +189,17 @@ class CJX_Object { Optional<XFA_AttributeEnum> TryEnum(XFA_Attribute eAttr, bool bUseDefault) const; - bool SetEnum(XFA_Attribute eAttr, XFA_AttributeEnum eValue, bool bNotify); + void SetEnum(XFA_Attribute eAttr, XFA_AttributeEnum eValue, bool bNotify); XFA_AttributeEnum GetEnum(XFA_Attribute eAttr) const; Optional<bool> TryBoolean(XFA_Attribute eAttr, bool bUseDefault); - bool SetBoolean(XFA_Attribute eAttr, bool bValue, bool bNotify); + void SetBoolean(XFA_Attribute eAttr, bool bValue, bool bNotify); bool GetBoolean(XFA_Attribute eAttr); Optional<CXFA_Measurement> TryMeasure(XFA_Attribute eAttr, bool bUseDefault) const; Optional<float> TryMeasureAsFloat(XFA_Attribute attr) const; - bool SetMeasure(XFA_Attribute eAttr, CXFA_Measurement mValue, bool bNotify); + void SetMeasure(XFA_Attribute eAttr, CXFA_Measurement mValue, bool bNotify); CXFA_Measurement GetMeasure(XFA_Attribute eAttr) const; void MergeAllData(CXFA_Object* pDstModule); @@ -241,7 +241,7 @@ class CJX_Object { void OnChanged(XFA_Attribute eAttr, bool bNotify, bool bScriptModify); void OnChanging(XFA_Attribute eAttr, bool bNotify); - bool SetUserData(void* pKey, + void SetUserData(void* pKey, void* pData, const XFA_MAPDATABLOCKCALLBACKINFO* pCallbackInfo); |