From 94ed4456bfe64ea045be24c66966d814b73fa7ac Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Wed, 13 Dec 2017 01:20:24 +0000 Subject: Move remaining Script_ methods to CJX_Object The CJX_Node isn't the root of the CJX hierarchy. This causes issues now that CJX_Object has child objects which don't inherit from CJX_Node. This CL moves Script_* from CJX_Node to CJX_Object. Change-Id: I9f063c9d796896ba34be802a8ef8f108911ed56c Reviewed-on: https://pdfium-review.googlesource.com/20972 Reviewed-by: Henrique Nakashima Commit-Queue: dsinclair --- fxjs/xfa/cjx_node.cpp | 509 +----------------------------------------------- fxjs/xfa/cjx_node.h | 117 ----------- fxjs/xfa/cjx_object.cpp | 488 ++++++++++++++++++++++++++++++++++++++++++++++ fxjs/xfa/cjx_object.h | 114 +++++++++++ 4 files changed, 605 insertions(+), 623 deletions(-) (limited to 'fxjs') diff --git a/fxjs/xfa/cjx_node.cpp b/fxjs/xfa/cjx_node.cpp index 9d416ea4d1..cceaa208fc 100644 --- a/fxjs/xfa/cjx_node.cpp +++ b/fxjs/xfa/cjx_node.cpp @@ -6,26 +6,15 @@ #include "fxjs/xfa/cjx_node.h" -#include -#include - -#include "core/fxcrt/cfx_decimal.h" #include "core/fxcrt/cfx_memorystream.h" #include "core/fxcrt/fx_codepage.h" -#include "core/fxcrt/fx_extension.h" -#include "core/fxcrt/xml/cfx_xmlelement.h" -#include "core/fxcrt/xml/cfx_xmlnode.h" -#include "core/fxcrt/xml/cfx_xmltext.h" #include "fxjs/cfxjse_engine.h" #include "fxjs/js_resources.h" +#include "third_party/base/ptr_util.h" +#include "xfa/fxfa/cxfa_eventparam.h" #include "xfa/fxfa/cxfa_ffnotify.h" -#include "xfa/fxfa/cxfa_ffwidget.h" -#include "xfa/fxfa/parser/cxfa_arraynodelist.h" -#include "xfa/fxfa/parser/cxfa_attachnodelist.h" -#include "xfa/fxfa/parser/cxfa_layoutprocessor.h" -#include "xfa/fxfa/parser/cxfa_measurement.h" +#include "xfa/fxfa/parser/cxfa_document.h" #include "xfa/fxfa/parser/cxfa_node.h" -#include "xfa/fxfa/parser/cxfa_occurdata.h" #include "xfa/fxfa/parser/cxfa_simple_parser.h" #include "xfa/fxfa/parser/xfa_utils.h" @@ -119,90 +108,6 @@ const CXFA_Node* CJX_Node::GetXFANode() const { return static_cast(GetXFAObject()); } -int32_t CJX_Node::InstanceManager_SetInstances(int32_t iDesired) { - CXFA_OccurData occurData(GetXFANode()->GetOccurNode()); - if (iDesired < occurData.GetMin()) { - ThrowTooManyOccurancesException(L"min"); - return 1; - } - - int32_t iMax = occurData.GetMax(); - if (iMax >= 0 && iDesired > iMax) { - ThrowTooManyOccurancesException(L"max"); - return 2; - } - - int32_t iCount = GetXFANode()->GetCount(); - if (iDesired == iCount) - return 0; - - if (iDesired < iCount) { - WideString wsInstManagerName = GetCData(XFA_Attribute::Name); - WideString wsInstanceName = WideString( - wsInstManagerName.IsEmpty() - ? wsInstManagerName - : wsInstManagerName.Right(wsInstManagerName.GetLength() - 1)); - uint32_t dInstanceNameHash = - FX_HashCode_GetW(wsInstanceName.AsStringView(), false); - CXFA_Node* pPrevSibling = - iDesired == 0 ? GetXFANode() : GetXFANode()->GetItem(iDesired - 1); - while (iCount > iDesired) { - CXFA_Node* pRemoveInstance = - pPrevSibling->GetNodeItem(XFA_NODEITEM_NextSibling); - if (pRemoveInstance->GetElementType() != XFA_Element::Subform && - pRemoveInstance->GetElementType() != XFA_Element::SubformSet) { - continue; - } - if (pRemoveInstance->GetElementType() == XFA_Element::InstanceManager) { - NOTREACHED(); - break; - } - if (pRemoveInstance->GetNameHash() == dInstanceNameHash) { - GetXFANode()->RemoveItem(pRemoveInstance, true); - iCount--; - } - } - } else { - while (iCount < iDesired) { - CXFA_Node* pNewInstance = GetXFANode()->CreateInstance(true); - GetXFANode()->InsertItem(pNewInstance, iCount, iCount, false); - iCount++; - CXFA_FFNotify* pNotify = GetDocument()->GetNotify(); - if (!pNotify) - return 0; - - pNotify->RunNodeInitialize(pNewInstance); - } - } - - CXFA_LayoutProcessor* pLayoutPro = GetDocument()->GetLayoutProcessor(); - if (pLayoutPro) { - pLayoutPro->AddChangedContainer( - ToNode(GetDocument()->GetXFAObject(XFA_HASHCODE_Form))); - } - return 0; -} - -int32_t CJX_Node::InstanceManager_MoveInstance(int32_t iTo, int32_t iFrom) { - int32_t iCount = GetXFANode()->GetCount(); - if (iFrom > iCount || iTo > iCount - 1) { - ThrowIndexOutOfBoundsException(); - return 1; - } - if (iFrom < 0 || iTo < 0 || iFrom == iTo) - return 0; - - CXFA_Node* pMoveInstance = GetXFANode()->GetItem(iFrom); - GetXFANode()->RemoveItem(pMoveInstance, false); - GetXFANode()->InsertItem(pMoveInstance, iTo, iCount - 1, true); - CXFA_LayoutProcessor* pLayoutPro = GetDocument()->GetLayoutProcessor(); - if (pLayoutPro) { - pLayoutPro->AddChangedContainer( - ToNode(GetDocument()->GetXFAObject(XFA_HASHCODE_Form))); - } - return 0; -} - CJS_Return CJX_Node::applyXSL(CJS_V8* runtime, const std::vector>& params) { if (params.size() != 1) @@ -478,402 +383,6 @@ CJS_Return CJX_Node::setElement( return CJS_Return(true); } -void CJX_Node::Script_NodeClass_Ns(CFXJSE_Value* pValue, - bool bSetting, - XFA_Attribute eAttribute) { - if (bSetting) { - ThrowInvalidPropertyException(); - return; - } - pValue->SetString( - TryNamespace().value_or(WideString()).UTF8Encode().AsStringView()); -} - -void CJX_Node::Script_NodeClass_Model(CFXJSE_Value* pValue, - bool bSetting, - XFA_Attribute eAttribute) { - if (bSetting) { - ThrowInvalidPropertyException(); - return; - } - - pValue->Assign(GetDocument()->GetScriptContext()->GetJSValueFromMap( - GetXFANode()->GetModelNode())); -} - -void CJX_Node::Script_NodeClass_IsContainer(CFXJSE_Value* pValue, - bool bSetting, - XFA_Attribute eAttribute) { - if (bSetting) { - ThrowInvalidPropertyException(); - return; - } - - pValue->SetBoolean(GetXFANode()->IsContainerNode()); -} - -void CJX_Node::Script_NodeClass_IsNull(CFXJSE_Value* pValue, - bool bSetting, - XFA_Attribute eAttribute) { - if (bSetting) { - ThrowInvalidPropertyException(); - return; - } - if (GetXFANode()->GetElementType() == XFA_Element::Subform) { - pValue->SetBoolean(false); - return; - } - pValue->SetBoolean(GetContent(false).IsEmpty()); -} - -void CJX_Node::Script_NodeClass_OneOfChild(CFXJSE_Value* pValue, - bool bSetting, - XFA_Attribute eAttribute) { - if (bSetting) { - ThrowInvalidPropertyException(); - return; - } - - std::vector properties = GetXFANode()->GetNodeList( - XFA_NODEFILTER_OneOfProperty, XFA_Element::Unknown); - if (!properties.empty()) { - pValue->Assign(GetDocument()->GetScriptContext()->GetJSValueFromMap( - properties.front())); - } -} - -void CJX_Node::Script_ModelClass_Context(CFXJSE_Value* pValue, - bool bSetting, - XFA_Attribute eAttribute) {} - -void CJX_Node::Script_ModelClass_AliasNode(CFXJSE_Value* pValue, - bool bSetting, - XFA_Attribute eAttribute) {} - -void CJX_Node::Script_Delta_CurrentValue(CFXJSE_Value* pValue, - bool bSetting, - XFA_Attribute eAttribute) {} - -void CJX_Node::Script_Delta_SavedValue(CFXJSE_Value* pValue, - bool bSetting, - XFA_Attribute eAttribute) {} - -void CJX_Node::Script_Delta_Target(CFXJSE_Value* pValue, - bool bSetting, - XFA_Attribute eAttribute) {} - -void CJX_Node::Script_Field_Length(CFXJSE_Value* pValue, - bool bSetting, - XFA_Attribute eAttribute) { - if (bSetting) { - ThrowInvalidPropertyException(); - return; - } - - CXFA_WidgetData* pWidgetData = GetXFANode()->GetWidgetData(); - if (!pWidgetData) { - pValue->SetInteger(0); - return; - } - pValue->SetInteger(pWidgetData->CountChoiceListItems(true)); -} - -void CJX_Node::Script_Field_EditValue(CFXJSE_Value* pValue, - bool bSetting, - XFA_Attribute eAttribute) { - CXFA_WidgetData* pWidgetData = GetXFANode()->GetWidgetData(); - if (!pWidgetData) - return; - - if (bSetting) { - pWidgetData->SetValue(XFA_VALUEPICTURE_Edit, pValue->ToWideString()); - return; - } - pValue->SetString( - pWidgetData->GetValue(XFA_VALUEPICTURE_Edit).UTF8Encode().AsStringView()); -} - -void CJX_Node::Script_Field_FormattedValue(CFXJSE_Value* pValue, - bool bSetting, - XFA_Attribute eAttribute) { - CXFA_WidgetData* pWidgetData = GetXFANode()->GetWidgetData(); - if (!pWidgetData) - return; - - if (bSetting) { - pWidgetData->SetValue(XFA_VALUEPICTURE_Display, pValue->ToWideString()); - return; - } - pValue->SetString(pWidgetData->GetValue(XFA_VALUEPICTURE_Display) - .UTF8Encode() - .AsStringView()); -} - -void CJX_Node::Script_Field_ParentSubform(CFXJSE_Value* pValue, - bool bSetting, - XFA_Attribute eAttribute) { - if (bSetting) { - ThrowInvalidPropertyException(); - return; - } - pValue->SetNull(); -} - -void CJX_Node::Script_Field_SelectedIndex(CFXJSE_Value* pValue, - bool bSetting, - XFA_Attribute eAttribute) { - CXFA_WidgetData* pWidgetData = GetXFANode()->GetWidgetData(); - if (!pWidgetData) - return; - - if (!bSetting) { - pValue->SetInteger(pWidgetData->GetSelectedItem(0)); - return; - } - - int32_t iIndex = pValue->ToInteger(); - if (iIndex == -1) { - pWidgetData->ClearAllSelections(); - return; - } - - pWidgetData->SetItemState(iIndex, true, true, true, true); -} - -void CJX_Node::Script_ExclGroup_ErrorText(CFXJSE_Value* pValue, - bool bSetting, - XFA_Attribute eAttribute) { - if (bSetting) - ThrowInvalidPropertyException(); -} - -void CJX_Node::Script_ExclGroup_DefaultAndRawValue(CFXJSE_Value* pValue, - bool bSetting, - XFA_Attribute eAttribute) { - CXFA_WidgetData* pWidgetData = GetXFANode()->GetWidgetData(); - if (!pWidgetData) - return; - - if (bSetting) { - pWidgetData->SetSelectedMemberByValue(pValue->ToWideString().AsStringView(), - true, true, true); - return; - } - - WideString wsValue = GetContent(true); - XFA_VERSION curVersion = GetDocument()->GetCurVersionMode(); - if (wsValue.IsEmpty() && curVersion >= XFA_VERSION_300) { - pValue->SetNull(); - return; - } - pValue->SetString(wsValue.UTF8Encode().AsStringView()); -} - -void CJX_Node::Script_ExclGroup_Transient(CFXJSE_Value* pValue, - bool bSetting, - XFA_Attribute eAttribute) {} - -void CJX_Node::Script_Subform_InstanceManager(CFXJSE_Value* pValue, - bool bSetting, - XFA_Attribute eAttribute) { - if (bSetting) { - ThrowInvalidPropertyException(); - return; - } - - WideString wsName = GetCData(XFA_Attribute::Name); - CXFA_Node* pInstanceMgr = nullptr; - for (CXFA_Node* pNode = GetXFANode()->GetNodeItem(XFA_NODEITEM_PrevSibling); - pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_PrevSibling)) { - if (pNode->GetElementType() == XFA_Element::InstanceManager) { - WideString wsInstMgrName = pNode->JSNode()->GetCData(XFA_Attribute::Name); - if (wsInstMgrName.GetLength() >= 1 && wsInstMgrName[0] == '_' && - wsInstMgrName.Right(wsInstMgrName.GetLength() - 1) == wsName) { - pInstanceMgr = pNode; - } - break; - } - } - if (!pInstanceMgr) { - pValue->SetNull(); - return; - } - - pValue->Assign( - GetDocument()->GetScriptContext()->GetJSValueFromMap(pInstanceMgr)); -} - -void CJX_Node::Script_Subform_Locale(CFXJSE_Value* pValue, - bool bSetting, - XFA_Attribute eAttribute) { - if (bSetting) { - SetCData(XFA_Attribute::Locale, pValue->ToWideString(), true, true); - return; - } - - WideString wsLocaleName; - GetXFANode()->GetLocaleName(wsLocaleName); - pValue->SetString(wsLocaleName.UTF8Encode().AsStringView()); -} - -void CJX_Node::Script_InstanceManager_Max(CFXJSE_Value* pValue, - bool bSetting, - XFA_Attribute eAttribute) { - if (bSetting) { - ThrowInvalidPropertyException(); - return; - } - pValue->SetInteger(CXFA_OccurData(GetXFANode()->GetOccurNode()).GetMax()); -} - -void CJX_Node::Script_InstanceManager_Min(CFXJSE_Value* pValue, - bool bSetting, - XFA_Attribute eAttribute) { - if (bSetting) { - ThrowInvalidPropertyException(); - return; - } - pValue->SetInteger(CXFA_OccurData(GetXFANode()->GetOccurNode()).GetMin()); -} - -void CJX_Node::Script_InstanceManager_Count(CFXJSE_Value* pValue, - bool bSetting, - XFA_Attribute eAttribute) { - if (bSetting) { - pValue->SetInteger(GetXFANode()->GetCount()); - return; - } - InstanceManager_SetInstances(pValue->ToInteger()); -} - -void CJX_Node::Script_Occur_Max(CFXJSE_Value* pValue, - bool bSetting, - XFA_Attribute eAttribute) { - CXFA_OccurData occurData(GetXFANode()); - if (!bSetting) { - pValue->SetInteger(occurData.GetMax()); - return; - } - occurData.SetMax(pValue->ToInteger()); -} - -void CJX_Node::Script_Occur_Min(CFXJSE_Value* pValue, - bool bSetting, - XFA_Attribute eAttribute) { - CXFA_OccurData occurData(GetXFANode()); - if (!bSetting) { - pValue->SetInteger(occurData.GetMin()); - return; - } - occurData.SetMin(pValue->ToInteger()); -} - -void CJX_Node::Script_Form_Checksum(CFXJSE_Value* pValue, - bool bSetting, - XFA_Attribute eAttribute) { - if (bSetting) { - SetAttribute(XFA_Attribute::Checksum, pValue->ToWideString().AsStringView(), - false); - return; - } - - pdfium::Optional checksum = - TryAttribute(XFA_Attribute::Checksum, false); - pValue->SetString(checksum ? checksum->UTF8Encode().AsStringView() : ""); -} - -void CJX_Node::Script_Packet_Content(CFXJSE_Value* pValue, - bool bSetting, - XFA_Attribute eAttribute) { - CFX_XMLNode* pXMLNode = GetXFANode()->GetXMLMappingNode(); - if (bSetting) { - if (pXMLNode && pXMLNode->GetType() == FX_XMLNODE_Element) { - CFX_XMLElement* pXMLElement = static_cast(pXMLNode); - pXMLElement->SetTextData(pValue->ToWideString()); - } - return; - } - - WideString wsTextData; - if (pXMLNode && pXMLNode->GetType() == FX_XMLNODE_Element) { - CFX_XMLElement* pXMLElement = static_cast(pXMLNode); - wsTextData = pXMLElement->GetTextData(); - } - - pValue->SetString(wsTextData.UTF8Encode().AsStringView()); -} - -void CJX_Node::Script_Source_Db(CFXJSE_Value* pValue, - bool bSetting, - XFA_Attribute eAttribute) {} - -void CJX_Node::Script_Xfa_This(CFXJSE_Value* pValue, - bool bSetting, - XFA_Attribute eAttribute) { - if (bSetting) - return; - - CXFA_Object* pThis = GetDocument()->GetScriptContext()->GetThisObject(); - ASSERT(pThis); - pValue->Assign(GetDocument()->GetScriptContext()->GetJSValueFromMap(pThis)); -} - -void CJX_Node::Script_Handler_Version(CFXJSE_Value* pValue, - bool bSetting, - XFA_Attribute eAttribute) {} - -void CJX_Node::Script_SubmitFormat_Mode(CFXJSE_Value* pValue, - bool bSetting, - XFA_Attribute eAttribute) {} - -void CJX_Node::Script_Extras_Type(CFXJSE_Value* pValue, - bool bSetting, - XFA_Attribute eAttribute) {} - -void CJX_Node::Script_Script_Stateless(CFXJSE_Value* pValue, - bool bSetting, - XFA_Attribute eAttribute) { - if (bSetting) { - ThrowInvalidPropertyException(); - return; - } - pValue->SetString(FX_UTF8Encode(WideStringView(L"0", 1)).AsStringView()); -} - -void CJX_Node::Script_Encrypt_Format(CFXJSE_Value* pValue, - bool bSetting, - XFA_Attribute eAttribute) {} - -pdfium::Optional CJX_Node::TryNamespace() { - if (GetXFANode()->IsModelNode() || - GetXFANode()->GetElementType() == XFA_Element::Packet) { - CFX_XMLNode* pXMLNode = GetXFANode()->GetXMLMappingNode(); - if (!pXMLNode || pXMLNode->GetType() != FX_XMLNODE_Element) - return {}; - - return {static_cast(pXMLNode)->GetNamespaceURI()}; - } - - if (GetXFANode()->GetPacketType() != XFA_PacketType::Datasets) - return GetXFANode()->GetModelNode()->JSNode()->TryNamespace(); - - CFX_XMLNode* pXMLNode = GetXFANode()->GetXMLMappingNode(); - if (!pXMLNode || pXMLNode->GetType() != FX_XMLNODE_Element) - return {}; - - if (GetXFANode()->GetElementType() == XFA_Element::DataValue && - GetEnum(XFA_Attribute::Contains) == XFA_AttributeEnum::MetaData) { - WideString wsNamespace; - bool ret = XFA_FDEExtension_ResolveNamespaceQualifier( - static_cast(pXMLNode), - GetCData(XFA_Attribute::QualifiedName), &wsNamespace); - if (!ret) - return {}; - return {wsNamespace}; - } - return {static_cast(pXMLNode)->GetNamespaceURI()}; -} - int32_t CJX_Node::execSingleEventByName(const WideStringView& wsEventName, XFA_Element eType) { CXFA_FFNotify* pNotify = GetDocument()->GetNotify(); @@ -947,15 +456,3 @@ int32_t CJX_Node::execSingleEventByName(const WideStringView& wsEventName, } return XFA_EVENTERROR_NotExist; } - -void CJX_Node::ThrowMissingPropertyException(const WideString& obj, - const WideString& prop) const { - ThrowException(L"'%ls' doesn't have property '%ls'.", obj.c_str(), - prop.c_str()); -} - -void CJX_Node::ThrowTooManyOccurancesException(const WideString& obj) const { - ThrowException( - L"The element [%ls] has violated its allowable number of occurrences.", - obj.c_str()); -} diff --git a/fxjs/xfa/cjx_node.h b/fxjs/xfa/cjx_node.h index f2ff49217e..9d16d852bf 100644 --- a/fxjs/xfa/cjx_node.h +++ b/fxjs/xfa/cjx_node.h @@ -34,15 +34,6 @@ class CJX_Node : public CJX_Tree { void SetCalcRecursionCount(size_t count) { calc_recursion_count_ = count; } size_t GetCalcRecursionCount() const { return calc_recursion_count_; } - pdfium::Optional TryNamespace(); - - void ThrowMissingPropertyException(const WideString& obj, - const WideString& prop) const; - void ThrowTooManyOccurancesException(const WideString& obj) const; - - int32_t InstanceManager_SetInstances(int32_t iDesired); - int32_t InstanceManager_MoveInstance(int32_t iTo, int32_t iFrom); - JS_METHOD(applyXSL, CJX_Node); JS_METHOD(assignNode, CJX_Node); JS_METHOD(clone, CJX_Node); @@ -55,114 +46,6 @@ class CJX_Node : public CJX_Tree { JS_METHOD(setAttribute, CJX_Node); JS_METHOD(setElement, CJX_Node); - void Script_NodeClass_Ns(CFXJSE_Value* pValue, - bool bSetting, - XFA_Attribute eAttribute); - void Script_NodeClass_Model(CFXJSE_Value* pValue, - bool bSetting, - XFA_Attribute eAttribute); - void Script_NodeClass_IsContainer(CFXJSE_Value* pValue, - bool bSetting, - XFA_Attribute eAttribute); - void Script_NodeClass_IsNull(CFXJSE_Value* pValue, - bool bSetting, - XFA_Attribute eAttribute); - void Script_NodeClass_OneOfChild(CFXJSE_Value* pValue, - bool bSetting, - XFA_Attribute eAttribute); - void Script_ModelClass_Context(CFXJSE_Value* pValue, - bool bSetting, - XFA_Attribute eAttribute); - void Script_ModelClass_AliasNode(CFXJSE_Value* pValue, - bool bSetting, - XFA_Attribute eAttribute); - void Script_Delta_CurrentValue(CFXJSE_Value* pValue, - bool bSetting, - XFA_Attribute eAttribute); - void Script_Delta_SavedValue(CFXJSE_Value* pValue, - bool bSetting, - XFA_Attribute eAttribute); - void Script_Delta_Target(CFXJSE_Value* pValue, - bool bSetting, - XFA_Attribute eAttribute); - void Script_Field_Length(CFXJSE_Value* pValue, - bool bSetting, - XFA_Attribute eAttribute); - void Script_Field_EditValue(CFXJSE_Value* pValue, - bool bSetting, - XFA_Attribute eAttribute); - void Script_Field_FormattedValue(CFXJSE_Value* pValue, - bool bSetting, - XFA_Attribute eAttribute); - void Script_Field_ParentSubform(CFXJSE_Value* pValue, - bool bSetting, - XFA_Attribute eAttribute); - void Script_Field_SelectedIndex(CFXJSE_Value* pValue, - bool bSetting, - XFA_Attribute eAttribute); - void Script_ExclGroup_DefaultAndRawValue(CFXJSE_Value* pValue, - bool bSetting, - XFA_Attribute eAttribute); - void Script_ExclGroup_ErrorText(CFXJSE_Value* pValue, - bool bSetting, - XFA_Attribute eAttribute); - void Script_ExclGroup_Transient(CFXJSE_Value* pValue, - bool bSetting, - XFA_Attribute eAttribute); - - void Script_Subform_InstanceManager(CFXJSE_Value* pValue, - bool bSetting, - XFA_Attribute eAttribute); - void Script_Subform_Locale(CFXJSE_Value* pValue, - bool bSetting, - XFA_Attribute eAttribute); - void Script_InstanceManager_Count(CFXJSE_Value* pValue, - bool bSetting, - XFA_Attribute eAttribute); - void Script_InstanceManager_Max(CFXJSE_Value* pValue, - bool bSetting, - XFA_Attribute eAttribute); - void Script_InstanceManager_Min(CFXJSE_Value* pValue, - bool bSetting, - XFA_Attribute eAttribute); - - void Script_Occur_Max(CFXJSE_Value* pValue, - bool bSetting, - XFA_Attribute eAttribute); - void Script_Occur_Min(CFXJSE_Value* pValue, - bool bSetting, - XFA_Attribute eAttribute); - - void Script_Form_Checksum(CFXJSE_Value* pValue, - bool bSetting, - XFA_Attribute eAttribute); - - void Script_Packet_Content(CFXJSE_Value* pValue, - bool bSetting, - XFA_Attribute eAttribute); - - void Script_Source_Db(CFXJSE_Value* pValue, - bool bSetting, - XFA_Attribute eAttribute); - void Script_Xfa_This(CFXJSE_Value* pValue, - bool bSetting, - XFA_Attribute eAttribute); - void Script_Handler_Version(CFXJSE_Value* pValue, - bool bSetting, - XFA_Attribute eAttribute); - void Script_SubmitFormat_Mode(CFXJSE_Value* pValue, - bool bSetting, - XFA_Attribute eAttribute); - void Script_Extras_Type(CFXJSE_Value* pValue, - bool bSetting, - XFA_Attribute eAttribute); - void Script_Encrypt_Format(CFXJSE_Value* pValue, - bool bSetting, - XFA_Attribute eAttribute); - void Script_Script_Stateless(CFXJSE_Value* pValue, - bool bSetting, - XFA_Attribute eAttribute); - protected: int32_t execSingleEventByName(const WideStringView& wsEventName, XFA_Element eType); diff --git a/fxjs/xfa/cjx_object.cpp b/fxjs/xfa/cjx_object.cpp index 2c6588824f..04d053ce38 100644 --- a/fxjs/xfa/cjx_object.cpp +++ b/fxjs/xfa/cjx_object.cpp @@ -18,9 +18,11 @@ #include "xfa/fxfa/cxfa_ffnotify.h" #include "xfa/fxfa/cxfa_ffwidget.h" #include "xfa/fxfa/parser/cxfa_document.h" +#include "xfa/fxfa/parser/cxfa_layoutprocessor.h" #include "xfa/fxfa/parser/cxfa_measurement.h" #include "xfa/fxfa/parser/cxfa_node.h" #include "xfa/fxfa/parser/cxfa_object.h" +#include "xfa/fxfa/parser/cxfa_occurdata.h" #include "xfa/fxfa/parser/xfa_utils.h" namespace { @@ -148,6 +150,12 @@ CJS_Return CJX_Object::RunMethod( params); } +void CJX_Object::ThrowTooManyOccurancesException(const WideString& obj) const { + ThrowException( + L"The element [%ls] has violated its allowable number of occurrences.", + obj.c_str()); +} + void CJX_Object::ThrowInvalidPropertyException() const { ThrowException(L"Invalid property set operation."); } @@ -1688,3 +1696,483 @@ int32_t CJX_Object::Subform_and_SubformSet_InstanceIndex() { } return index; } + +void CJX_Object::Script_NodeClass_Ns(CFXJSE_Value* pValue, + bool bSetting, + XFA_Attribute eAttribute) { + if (bSetting) { + ThrowInvalidPropertyException(); + return; + } + pValue->SetString( + TryNamespace().value_or(WideString()).UTF8Encode().AsStringView()); +} + +void CJX_Object::Script_NodeClass_Model(CFXJSE_Value* pValue, + bool bSetting, + XFA_Attribute eAttribute) { + if (bSetting) { + ThrowInvalidPropertyException(); + return; + } + + pValue->Assign(GetDocument()->GetScriptContext()->GetJSValueFromMap( + ToNode(GetXFAObject())->GetModelNode())); +} + +void CJX_Object::Script_NodeClass_IsContainer(CFXJSE_Value* pValue, + bool bSetting, + XFA_Attribute eAttribute) { + if (bSetting) { + ThrowInvalidPropertyException(); + return; + } + + pValue->SetBoolean(GetXFAObject()->IsContainerNode()); +} + +void CJX_Object::Script_NodeClass_IsNull(CFXJSE_Value* pValue, + bool bSetting, + XFA_Attribute eAttribute) { + if (bSetting) { + ThrowInvalidPropertyException(); + return; + } + if (ToNode(GetXFAObject())->GetElementType() == XFA_Element::Subform) { + pValue->SetBoolean(false); + return; + } + pValue->SetBoolean(GetContent(false).IsEmpty()); +} + +void CJX_Object::Script_NodeClass_OneOfChild(CFXJSE_Value* pValue, + bool bSetting, + XFA_Attribute eAttribute) { + if (bSetting) { + ThrowInvalidPropertyException(); + return; + } + + std::vector properties = + ToNode(GetXFAObject()) + ->GetNodeList(XFA_NODEFILTER_OneOfProperty, XFA_Element::Unknown); + if (!properties.empty()) { + pValue->Assign(GetDocument()->GetScriptContext()->GetJSValueFromMap( + properties.front())); + } +} + +void CJX_Object::Script_ModelClass_Context(CFXJSE_Value* pValue, + bool bSetting, + XFA_Attribute eAttribute) {} + +void CJX_Object::Script_ModelClass_AliasNode(CFXJSE_Value* pValue, + bool bSetting, + XFA_Attribute eAttribute) {} + +void CJX_Object::Script_Delta_CurrentValue(CFXJSE_Value* pValue, + bool bSetting, + XFA_Attribute eAttribute) {} + +void CJX_Object::Script_Delta_SavedValue(CFXJSE_Value* pValue, + bool bSetting, + XFA_Attribute eAttribute) {} + +void CJX_Object::Script_Delta_Target(CFXJSE_Value* pValue, + bool bSetting, + XFA_Attribute eAttribute) {} + +void CJX_Object::Script_Field_Length(CFXJSE_Value* pValue, + bool bSetting, + XFA_Attribute eAttribute) { + if (bSetting) { + ThrowInvalidPropertyException(); + return; + } + if (!widget_data_) { + pValue->SetInteger(0); + return; + } + pValue->SetInteger(widget_data_->CountChoiceListItems(true)); +} + +void CJX_Object::Script_Field_EditValue(CFXJSE_Value* pValue, + bool bSetting, + XFA_Attribute eAttribute) { + if (!widget_data_) + return; + + if (bSetting) { + widget_data_->SetValue(XFA_VALUEPICTURE_Edit, pValue->ToWideString()); + return; + } + pValue->SetString(widget_data_->GetValue(XFA_VALUEPICTURE_Edit) + .UTF8Encode() + .AsStringView()); +} + +void CJX_Object::Script_Field_FormattedValue(CFXJSE_Value* pValue, + bool bSetting, + XFA_Attribute eAttribute) { + if (!widget_data_) + return; + + if (bSetting) { + widget_data_->SetValue(XFA_VALUEPICTURE_Display, pValue->ToWideString()); + return; + } + pValue->SetString(widget_data_->GetValue(XFA_VALUEPICTURE_Display) + .UTF8Encode() + .AsStringView()); +} + +void CJX_Object::Script_Field_ParentSubform(CFXJSE_Value* pValue, + bool bSetting, + XFA_Attribute eAttribute) { + if (bSetting) { + ThrowInvalidPropertyException(); + return; + } + pValue->SetNull(); +} + +void CJX_Object::Script_Field_SelectedIndex(CFXJSE_Value* pValue, + bool bSetting, + XFA_Attribute eAttribute) { + if (!widget_data_) + return; + + if (!bSetting) { + pValue->SetInteger(widget_data_->GetSelectedItem(0)); + return; + } + + int32_t iIndex = pValue->ToInteger(); + if (iIndex == -1) { + widget_data_->ClearAllSelections(); + return; + } + + widget_data_->SetItemState(iIndex, true, true, true, true); +} + +void CJX_Object::Script_ExclGroup_ErrorText(CFXJSE_Value* pValue, + bool bSetting, + XFA_Attribute eAttribute) { + if (bSetting) + ThrowInvalidPropertyException(); +} + +void CJX_Object::Script_ExclGroup_DefaultAndRawValue(CFXJSE_Value* pValue, + bool bSetting, + XFA_Attribute eAttribute) { + if (!widget_data_) + return; + + if (bSetting) { + widget_data_->SetSelectedMemberByValue( + pValue->ToWideString().AsStringView(), true, true, true); + return; + } + + WideString wsValue = GetContent(true); + XFA_VERSION curVersion = GetDocument()->GetCurVersionMode(); + if (wsValue.IsEmpty() && curVersion >= XFA_VERSION_300) { + pValue->SetNull(); + return; + } + pValue->SetString(wsValue.UTF8Encode().AsStringView()); +} + +void CJX_Object::Script_ExclGroup_Transient(CFXJSE_Value* pValue, + bool bSetting, + XFA_Attribute eAttribute) {} + +void CJX_Object::Script_Subform_InstanceManager(CFXJSE_Value* pValue, + bool bSetting, + XFA_Attribute eAttribute) { + if (bSetting) { + ThrowInvalidPropertyException(); + return; + } + + WideString wsName = GetCData(XFA_Attribute::Name); + CXFA_Node* pInstanceMgr = nullptr; + for (CXFA_Node* pNode = + ToNode(GetXFAObject())->GetNodeItem(XFA_NODEITEM_PrevSibling); + pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_PrevSibling)) { + if (pNode->GetElementType() == XFA_Element::InstanceManager) { + WideString wsInstMgrName = pNode->JSNode()->GetCData(XFA_Attribute::Name); + if (wsInstMgrName.GetLength() >= 1 && wsInstMgrName[0] == '_' && + wsInstMgrName.Right(wsInstMgrName.GetLength() - 1) == wsName) { + pInstanceMgr = pNode; + } + break; + } + } + if (!pInstanceMgr) { + pValue->SetNull(); + return; + } + + pValue->Assign( + GetDocument()->GetScriptContext()->GetJSValueFromMap(pInstanceMgr)); +} + +void CJX_Object::Script_Subform_Locale(CFXJSE_Value* pValue, + bool bSetting, + XFA_Attribute eAttribute) { + if (bSetting) { + SetCData(XFA_Attribute::Locale, pValue->ToWideString(), true, true); + return; + } + + WideString wsLocaleName; + ToNode(GetXFAObject())->GetLocaleName(wsLocaleName); + pValue->SetString(wsLocaleName.UTF8Encode().AsStringView()); +} + +void CJX_Object::Script_InstanceManager_Max(CFXJSE_Value* pValue, + bool bSetting, + XFA_Attribute eAttribute) { + if (bSetting) { + ThrowInvalidPropertyException(); + return; + } + pValue->SetInteger( + CXFA_OccurData(ToNode(GetXFAObject())->GetOccurNode()).GetMax()); +} + +void CJX_Object::Script_InstanceManager_Min(CFXJSE_Value* pValue, + bool bSetting, + XFA_Attribute eAttribute) { + if (bSetting) { + ThrowInvalidPropertyException(); + return; + } + pValue->SetInteger( + CXFA_OccurData(ToNode(GetXFAObject())->GetOccurNode()).GetMin()); +} + +void CJX_Object::Script_InstanceManager_Count(CFXJSE_Value* pValue, + bool bSetting, + XFA_Attribute eAttribute) { + if (bSetting) { + pValue->SetInteger(ToNode(GetXFAObject())->GetCount()); + return; + } + InstanceManager_SetInstances(pValue->ToInteger()); +} + +void CJX_Object::Script_Occur_Max(CFXJSE_Value* pValue, + bool bSetting, + XFA_Attribute eAttribute) { + CXFA_OccurData occurData(ToNode(GetXFAObject())); + if (!bSetting) { + pValue->SetInteger(occurData.GetMax()); + return; + } + occurData.SetMax(pValue->ToInteger()); +} + +void CJX_Object::Script_Occur_Min(CFXJSE_Value* pValue, + bool bSetting, + XFA_Attribute eAttribute) { + CXFA_OccurData occurData(ToNode(GetXFAObject())); + if (!bSetting) { + pValue->SetInteger(occurData.GetMin()); + return; + } + occurData.SetMin(pValue->ToInteger()); +} + +void CJX_Object::Script_Form_Checksum(CFXJSE_Value* pValue, + bool bSetting, + XFA_Attribute eAttribute) { + if (bSetting) { + SetAttribute(XFA_Attribute::Checksum, pValue->ToWideString().AsStringView(), + false); + return; + } + + pdfium::Optional checksum = + TryAttribute(XFA_Attribute::Checksum, false); + pValue->SetString(checksum ? checksum->UTF8Encode().AsStringView() : ""); +} + +void CJX_Object::Script_Packet_Content(CFXJSE_Value* pValue, + bool bSetting, + XFA_Attribute eAttribute) { + CFX_XMLNode* pXMLNode = ToNode(GetXFAObject())->GetXMLMappingNode(); + if (bSetting) { + if (pXMLNode && pXMLNode->GetType() == FX_XMLNODE_Element) { + CFX_XMLElement* pXMLElement = static_cast(pXMLNode); + pXMLElement->SetTextData(pValue->ToWideString()); + } + return; + } + + WideString wsTextData; + if (pXMLNode && pXMLNode->GetType() == FX_XMLNODE_Element) { + CFX_XMLElement* pXMLElement = static_cast(pXMLNode); + wsTextData = pXMLElement->GetTextData(); + } + + pValue->SetString(wsTextData.UTF8Encode().AsStringView()); +} + +void CJX_Object::Script_Source_Db(CFXJSE_Value* pValue, + bool bSetting, + XFA_Attribute eAttribute) {} + +void CJX_Object::Script_Xfa_This(CFXJSE_Value* pValue, + bool bSetting, + XFA_Attribute eAttribute) { + if (bSetting) + return; + + CXFA_Object* pThis = GetDocument()->GetScriptContext()->GetThisObject(); + ASSERT(pThis); + pValue->Assign(GetDocument()->GetScriptContext()->GetJSValueFromMap(pThis)); +} + +void CJX_Object::Script_Handler_Version(CFXJSE_Value* pValue, + bool bSetting, + XFA_Attribute eAttribute) {} + +void CJX_Object::Script_SubmitFormat_Mode(CFXJSE_Value* pValue, + bool bSetting, + XFA_Attribute eAttribute) {} + +void CJX_Object::Script_Extras_Type(CFXJSE_Value* pValue, + bool bSetting, + XFA_Attribute eAttribute) {} + +void CJX_Object::Script_Script_Stateless(CFXJSE_Value* pValue, + bool bSetting, + XFA_Attribute eAttribute) { + if (bSetting) { + ThrowInvalidPropertyException(); + return; + } + pValue->SetString(FX_UTF8Encode(WideStringView(L"0", 1)).AsStringView()); +} + +void CJX_Object::Script_Encrypt_Format(CFXJSE_Value* pValue, + bool bSetting, + XFA_Attribute eAttribute) {} + +pdfium::Optional CJX_Object::TryNamespace() { + if (ToNode(GetXFAObject())->IsModelNode() || + ToNode(GetXFAObject())->GetElementType() == XFA_Element::Packet) { + CFX_XMLNode* pXMLNode = ToNode(GetXFAObject())->GetXMLMappingNode(); + if (!pXMLNode || pXMLNode->GetType() != FX_XMLNODE_Element) + return {}; + + return {static_cast(pXMLNode)->GetNamespaceURI()}; + } + + if (ToNode(GetXFAObject())->GetPacketType() != XFA_PacketType::Datasets) + return ToNode(GetXFAObject())->GetModelNode()->JSNode()->TryNamespace(); + + CFX_XMLNode* pXMLNode = ToNode(GetXFAObject())->GetXMLMappingNode(); + if (!pXMLNode || pXMLNode->GetType() != FX_XMLNODE_Element) + return {}; + + if (ToNode(GetXFAObject())->GetElementType() == XFA_Element::DataValue && + GetEnum(XFA_Attribute::Contains) == XFA_AttributeEnum::MetaData) { + WideString wsNamespace; + bool ret = XFA_FDEExtension_ResolveNamespaceQualifier( + static_cast(pXMLNode), + GetCData(XFA_Attribute::QualifiedName), &wsNamespace); + if (!ret) + return {}; + return {wsNamespace}; + } + return {static_cast(pXMLNode)->GetNamespaceURI()}; +} + +int32_t CJX_Object::InstanceManager_SetInstances(int32_t iDesired) { + CXFA_OccurData occurData(ToNode(GetXFAObject())->GetOccurNode()); + if (iDesired < occurData.GetMin()) { + ThrowTooManyOccurancesException(L"min"); + return 1; + } + + int32_t iMax = occurData.GetMax(); + if (iMax >= 0 && iDesired > iMax) { + ThrowTooManyOccurancesException(L"max"); + return 2; + } + + int32_t iCount = ToNode(GetXFAObject())->GetCount(); + if (iDesired == iCount) + return 0; + + if (iDesired < iCount) { + WideString wsInstManagerName = GetCData(XFA_Attribute::Name); + WideString wsInstanceName = WideString( + wsInstManagerName.IsEmpty() + ? wsInstManagerName + : wsInstManagerName.Right(wsInstManagerName.GetLength() - 1)); + uint32_t dInstanceNameHash = + FX_HashCode_GetW(wsInstanceName.AsStringView(), false); + CXFA_Node* pPrevSibling = + iDesired == 0 ? ToNode(GetXFAObject()) + : ToNode(GetXFAObject())->GetItem(iDesired - 1); + while (iCount > iDesired) { + CXFA_Node* pRemoveInstance = + pPrevSibling->GetNodeItem(XFA_NODEITEM_NextSibling); + if (pRemoveInstance->GetElementType() != XFA_Element::Subform && + pRemoveInstance->GetElementType() != XFA_Element::SubformSet) { + continue; + } + if (pRemoveInstance->GetElementType() == XFA_Element::InstanceManager) { + NOTREACHED(); + break; + } + if (pRemoveInstance->GetNameHash() == dInstanceNameHash) { + ToNode(GetXFAObject())->RemoveItem(pRemoveInstance, true); + iCount--; + } + } + } else { + while (iCount < iDesired) { + CXFA_Node* pNewInstance = ToNode(GetXFAObject())->CreateInstance(true); + ToNode(GetXFAObject())->InsertItem(pNewInstance, iCount, iCount, false); + iCount++; + CXFA_FFNotify* pNotify = GetDocument()->GetNotify(); + if (!pNotify) + return 0; + + pNotify->RunNodeInitialize(pNewInstance); + } + } + + CXFA_LayoutProcessor* pLayoutPro = GetDocument()->GetLayoutProcessor(); + if (pLayoutPro) { + pLayoutPro->AddChangedContainer( + ToNode(GetDocument()->GetXFAObject(XFA_HASHCODE_Form))); + } + return 0; +} + +int32_t CJX_Object::InstanceManager_MoveInstance(int32_t iTo, int32_t iFrom) { + int32_t iCount = ToNode(GetXFAObject())->GetCount(); + if (iFrom > iCount || iTo > iCount - 1) { + ThrowIndexOutOfBoundsException(); + return 1; + } + if (iFrom < 0 || iTo < 0 || iFrom == iTo) + return 0; + + CXFA_Node* pMoveInstance = ToNode(GetXFAObject())->GetItem(iFrom); + ToNode(GetXFAObject())->RemoveItem(pMoveInstance, false); + ToNode(GetXFAObject())->InsertItem(pMoveInstance, iTo, iCount - 1, true); + CXFA_LayoutProcessor* pLayoutPro = GetDocument()->GetLayoutProcessor(); + if (pLayoutPro) { + pLayoutPro->AddChangedContainer( + ToNode(GetDocument()->GetXFAObject(XFA_HASHCODE_Form))); + } + return 0; +} diff --git a/fxjs/xfa/cjx_object.h b/fxjs/xfa/cjx_object.h index 10146f4ef9..cb1fef62da 100644 --- a/fxjs/xfa/cjx_object.h +++ b/fxjs/xfa/cjx_object.h @@ -141,6 +141,116 @@ class CJX_Object { bool bSetting, XFA_Attribute eAttribute); + void Script_NodeClass_Ns(CFXJSE_Value* pValue, + bool bSetting, + XFA_Attribute eAttribute); + void Script_NodeClass_Model(CFXJSE_Value* pValue, + bool bSetting, + XFA_Attribute eAttribute); + void Script_NodeClass_IsContainer(CFXJSE_Value* pValue, + bool bSetting, + XFA_Attribute eAttribute); + void Script_NodeClass_IsNull(CFXJSE_Value* pValue, + bool bSetting, + XFA_Attribute eAttribute); + void Script_NodeClass_OneOfChild(CFXJSE_Value* pValue, + bool bSetting, + XFA_Attribute eAttribute); + void Script_ModelClass_Context(CFXJSE_Value* pValue, + bool bSetting, + XFA_Attribute eAttribute); + void Script_ModelClass_AliasNode(CFXJSE_Value* pValue, + bool bSetting, + XFA_Attribute eAttribute); + void Script_Delta_CurrentValue(CFXJSE_Value* pValue, + bool bSetting, + XFA_Attribute eAttribute); + void Script_Delta_SavedValue(CFXJSE_Value* pValue, + bool bSetting, + XFA_Attribute eAttribute); + void Script_Delta_Target(CFXJSE_Value* pValue, + bool bSetting, + XFA_Attribute eAttribute); + void Script_Field_Length(CFXJSE_Value* pValue, + bool bSetting, + XFA_Attribute eAttribute); + void Script_Field_EditValue(CFXJSE_Value* pValue, + bool bSetting, + XFA_Attribute eAttribute); + void Script_Field_FormattedValue(CFXJSE_Value* pValue, + bool bSetting, + XFA_Attribute eAttribute); + void Script_Field_ParentSubform(CFXJSE_Value* pValue, + bool bSetting, + XFA_Attribute eAttribute); + void Script_Field_SelectedIndex(CFXJSE_Value* pValue, + bool bSetting, + XFA_Attribute eAttribute); + void Script_ExclGroup_DefaultAndRawValue(CFXJSE_Value* pValue, + bool bSetting, + XFA_Attribute eAttribute); + void Script_ExclGroup_ErrorText(CFXJSE_Value* pValue, + bool bSetting, + XFA_Attribute eAttribute); + void Script_ExclGroup_Transient(CFXJSE_Value* pValue, + bool bSetting, + XFA_Attribute eAttribute); + + void Script_Subform_InstanceManager(CFXJSE_Value* pValue, + bool bSetting, + XFA_Attribute eAttribute); + void Script_Subform_Locale(CFXJSE_Value* pValue, + bool bSetting, + XFA_Attribute eAttribute); + void Script_InstanceManager_Count(CFXJSE_Value* pValue, + bool bSetting, + XFA_Attribute eAttribute); + void Script_InstanceManager_Max(CFXJSE_Value* pValue, + bool bSetting, + XFA_Attribute eAttribute); + void Script_InstanceManager_Min(CFXJSE_Value* pValue, + bool bSetting, + XFA_Attribute eAttribute); + + void Script_Occur_Max(CFXJSE_Value* pValue, + bool bSetting, + XFA_Attribute eAttribute); + void Script_Occur_Min(CFXJSE_Value* pValue, + bool bSetting, + XFA_Attribute eAttribute); + + void Script_Form_Checksum(CFXJSE_Value* pValue, + bool bSetting, + XFA_Attribute eAttribute); + + void Script_Packet_Content(CFXJSE_Value* pValue, + bool bSetting, + XFA_Attribute eAttribute); + + void Script_Source_Db(CFXJSE_Value* pValue, + bool bSetting, + XFA_Attribute eAttribute); + void Script_Xfa_This(CFXJSE_Value* pValue, + bool bSetting, + XFA_Attribute eAttribute); + void Script_Handler_Version(CFXJSE_Value* pValue, + bool bSetting, + XFA_Attribute eAttribute); + void Script_SubmitFormat_Mode(CFXJSE_Value* pValue, + bool bSetting, + XFA_Attribute eAttribute); + void Script_Extras_Type(CFXJSE_Value* pValue, + bool bSetting, + XFA_Attribute eAttribute); + void Script_Encrypt_Format(CFXJSE_Value* pValue, + bool bSetting, + XFA_Attribute eAttribute); + void Script_Script_Stateless(CFXJSE_Value* pValue, + bool bSetting, + XFA_Attribute eAttribute); + + pdfium::Optional TryNamespace(); + pdfium::Optional TryInteger(XFA_Attribute eAttr, bool bUseDefault); bool SetInteger(XFA_Attribute eAttr, int32_t iValue, bool bNotify); int32_t GetInteger(XFA_Attribute eAttr); @@ -176,10 +286,14 @@ class CJX_Object { CXFA_CalcData* GetCalcData() const { return calc_data_.get(); } std::unique_ptr ReleaseCalcData(); + int32_t InstanceManager_SetInstances(int32_t iDesired); + int32_t InstanceManager_MoveInstance(int32_t iTo, int32_t iFrom); + void ThrowInvalidPropertyException() const; void ThrowArgumentMismatchException() const; void ThrowIndexOutOfBoundsException() const; void ThrowParamCountMismatchException(const WideString& method) const; + void ThrowTooManyOccurancesException(const WideString& obj) const; protected: void DefineMethods(const CJX_MethodSpec method_specs[], size_t count); -- cgit v1.2.3