| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #include "xfa/fxfa/parser/xfa_utils.h" | 7 #include "xfa/fxfa/parser/xfa_utils.h" |
| 8 | 8 |
| 9 #include "core/fxcrt/include/fx_ext.h" | 9 #include "core/fxcrt/include/fx_ext.h" |
| 10 #include "xfa/fde/xml/fde_xml_imp.h" | 10 #include "xfa/fde/xml/fde_xml_imp.h" |
| 11 #include "xfa/fxfa/parser/xfa_doclayout.h" | 11 #include "xfa/fxfa/parser/xfa_doclayout.h" |
| 12 #include "xfa/fxfa/parser/xfa_document.h" | 12 #include "xfa/fxfa/parser/xfa_document.h" |
| 13 #include "xfa/fxfa/parser/xfa_localemgr.h" | 13 #include "xfa/fxfa/parser/xfa_localemgr.h" |
| 14 #include "xfa/fxfa/parser/xfa_localevalue.h" | 14 #include "xfa/fxfa/parser/xfa_localevalue.h" |
| 15 #include "xfa/fxfa/parser/xfa_object.h" | 15 #include "xfa/fxfa/parser/xfa_object.h" |
| 16 #include "xfa/fxfa/parser/xfa_parser.h" | 16 #include "xfa/fxfa/parser/xfa_parser.h" |
| 17 #include "xfa/fxfa/parser/xfa_script.h" | 17 #include "xfa/fxfa/parser/xfa_script.h" |
| 18 | 18 |
| 19 CXFA_Node* XFA_CreateUIChild(CXFA_Node* pNode, XFA_Element& eWidgetType) { | 19 CXFA_Node* XFA_CreateUIChild(CXFA_Node* pNode, XFA_Element& eWidgetType) { |
| 20 XFA_Element eType = pNode->GetClassID(); | 20 XFA_Element eType = pNode->GetElementType(); |
| 21 eWidgetType = eType; | 21 eWidgetType = eType; |
| 22 if (eType != XFA_Element::Field && eType != XFA_Element::Draw) { | 22 if (eType != XFA_Element::Field && eType != XFA_Element::Draw) { |
| 23 return NULL; | 23 return NULL; |
| 24 } | 24 } |
| 25 eWidgetType = XFA_Element::Unknown; | 25 eWidgetType = XFA_Element::Unknown; |
| 26 XFA_Element eUIType = XFA_Element::Unknown; | 26 XFA_Element eUIType = XFA_Element::Unknown; |
| 27 CXFA_Value defValue(pNode->GetProperty(0, XFA_Element::Value, TRUE)); | 27 CXFA_Value defValue(pNode->GetProperty(0, XFA_Element::Value, TRUE)); |
| 28 XFA_Element eValueType = defValue.GetChildValueClassID(); | 28 XFA_Element eValueType = defValue.GetChildValueClassID(); |
| 29 switch (eValueType) { | 29 switch (eValueType) { |
| 30 case XFA_Element::Boolean: | 30 case XFA_Element::Boolean: |
| (...skipping 24 matching lines...) Expand all Loading... |
| 55 eUIType = XFA_Element::DefaultUi; | 55 eUIType = XFA_Element::DefaultUi; |
| 56 eWidgetType = eValueType; | 56 eWidgetType = eValueType; |
| 57 break; | 57 break; |
| 58 default: | 58 default: |
| 59 break; | 59 break; |
| 60 } | 60 } |
| 61 CXFA_Node* pUIChild = NULL; | 61 CXFA_Node* pUIChild = NULL; |
| 62 CXFA_Node* pUI = pNode->GetProperty(0, XFA_Element::Ui, TRUE); | 62 CXFA_Node* pUI = pNode->GetProperty(0, XFA_Element::Ui, TRUE); |
| 63 CXFA_Node* pChild = pUI->GetNodeItem(XFA_NODEITEM_FirstChild); | 63 CXFA_Node* pChild = pUI->GetNodeItem(XFA_NODEITEM_FirstChild); |
| 64 for (; pChild; pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling)) { | 64 for (; pChild; pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling)) { |
| 65 XFA_Element eChild = pChild->GetClassID(); | 65 XFA_Element eChild = pChild->GetElementType(); |
| 66 if (eChild == XFA_Element::Extras || eChild == XFA_Element::Picture) { | 66 if (eChild == XFA_Element::Extras || eChild == XFA_Element::Picture) { |
| 67 continue; | 67 continue; |
| 68 } | 68 } |
| 69 const XFA_PROPERTY* pProperty = | 69 const XFA_PROPERTY* pProperty = |
| 70 XFA_GetPropertyOfElement(XFA_Element::Ui, eChild, XFA_XDPPACKET_Form); | 70 XFA_GetPropertyOfElement(XFA_Element::Ui, eChild, XFA_XDPPACKET_Form); |
| 71 if (pProperty && (pProperty->uFlags & XFA_PROPERTYFLAG_OneOf)) { | 71 if (pProperty && (pProperty->uFlags & XFA_PROPERTYFLAG_OneOf)) { |
| 72 pUIChild = pChild; | 72 pUIChild = pChild; |
| 73 break; | 73 break; |
| 74 } | 74 } |
| 75 } | 75 } |
| 76 if (eType == XFA_Element::Draw) { | 76 if (eType == XFA_Element::Draw) { |
| 77 XFA_Element eDraw = | 77 XFA_Element eDraw = |
| 78 pUIChild ? pUIChild->GetClassID() : XFA_Element::Unknown; | 78 pUIChild ? pUIChild->GetElementType() : XFA_Element::Unknown; |
| 79 switch (eDraw) { | 79 switch (eDraw) { |
| 80 case XFA_Element::TextEdit: | 80 case XFA_Element::TextEdit: |
| 81 eWidgetType = XFA_Element::Text; | 81 eWidgetType = XFA_Element::Text; |
| 82 break; | 82 break; |
| 83 case XFA_Element::ImageEdit: | 83 case XFA_Element::ImageEdit: |
| 84 eWidgetType = XFA_Element::Image; | 84 eWidgetType = XFA_Element::Image; |
| 85 break; | 85 break; |
| 86 default: | 86 default: |
| 87 eWidgetType = eWidgetType == XFA_Element::Unknown ? XFA_Element::Text | 87 eWidgetType = eWidgetType == XFA_Element::Unknown ? XFA_Element::Text |
| 88 : eWidgetType; | 88 : eWidgetType; |
| 89 break; | 89 break; |
| 90 } | 90 } |
| 91 } else { | 91 } else { |
| 92 if (pUIChild && pUIChild->GetClassID() == XFA_Element::DefaultUi) { | 92 if (pUIChild && pUIChild->GetElementType() == XFA_Element::DefaultUi) { |
| 93 eWidgetType = XFA_Element::TextEdit; | 93 eWidgetType = XFA_Element::TextEdit; |
| 94 } else { | 94 } else { |
| 95 eWidgetType = | 95 eWidgetType = |
| 96 pUIChild ? pUIChild->GetClassID() | 96 pUIChild ? pUIChild->GetElementType() |
| 97 : (eUIType == XFA_Element::Unknown ? XFA_Element::TextEdit | 97 : (eUIType == XFA_Element::Unknown ? XFA_Element::TextEdit |
| 98 : eUIType); | 98 : eUIType); |
| 99 } | 99 } |
| 100 } | 100 } |
| 101 if (!pUIChild) { | 101 if (!pUIChild) { |
| 102 if (eUIType == XFA_Element::Unknown) { | 102 if (eUIType == XFA_Element::Unknown) { |
| 103 eUIType = XFA_Element::TextEdit; | 103 eUIType = XFA_Element::TextEdit; |
| 104 defValue.GetNode()->GetProperty(0, XFA_Element::Text, TRUE); | 104 defValue.GetNode()->GetProperty(0, XFA_Element::Text, TRUE); |
| 105 } | 105 } |
| 106 pUIChild = pUI->GetProperty(0, eUIType, TRUE); | 106 pUIChild = pUI->GetProperty(0, eUIType, TRUE); |
| 107 } else if (eUIType == XFA_Element::Unknown) { | 107 } else if (eUIType == XFA_Element::Unknown) { |
| 108 switch (pUIChild->GetClassID()) { | 108 switch (pUIChild->GetElementType()) { |
| 109 case XFA_Element::CheckButton: { | 109 case XFA_Element::CheckButton: { |
| 110 eValueType = XFA_Element::Text; | 110 eValueType = XFA_Element::Text; |
| 111 if (CXFA_Node* pItems = pNode->GetChild(0, XFA_Element::Items)) { | 111 if (CXFA_Node* pItems = pNode->GetChild(0, XFA_Element::Items)) { |
| 112 if (CXFA_Node* pItem = pItems->GetChild(0, XFA_Element::Unknown)) { | 112 if (CXFA_Node* pItem = pItems->GetChild(0, XFA_Element::Unknown)) { |
| 113 eValueType = pItem->GetClassID(); | 113 eValueType = pItem->GetElementType(); |
| 114 } | 114 } |
| 115 } | 115 } |
| 116 } break; | 116 } break; |
| 117 case XFA_Element::DateTimeEdit: | 117 case XFA_Element::DateTimeEdit: |
| 118 eValueType = XFA_Element::DateTime; | 118 eValueType = XFA_Element::DateTime; |
| 119 break; | 119 break; |
| 120 case XFA_Element::ImageEdit: | 120 case XFA_Element::ImageEdit: |
| 121 eValueType = XFA_Element::Image; | 121 eValueType = XFA_Element::Image; |
| 122 break; | 122 break; |
| 123 case XFA_Element::NumericEdit: | 123 case XFA_Element::NumericEdit: |
| (...skipping 22 matching lines...) Expand all Loading... |
| 146 CXFA_Node* pNodeValue = | 146 CXFA_Node* pNodeValue = |
| 147 pWidgetData->GetNode()->GetChild(0, XFA_Element::Value); | 147 pWidgetData->GetNode()->GetChild(0, XFA_Element::Value); |
| 148 if (!pNodeValue) { | 148 if (!pNodeValue) { |
| 149 return CXFA_LocaleValue(); | 149 return CXFA_LocaleValue(); |
| 150 } | 150 } |
| 151 CXFA_Node* pValueChild = pNodeValue->GetNodeItem(XFA_NODEITEM_FirstChild); | 151 CXFA_Node* pValueChild = pNodeValue->GetNodeItem(XFA_NODEITEM_FirstChild); |
| 152 if (!pValueChild) { | 152 if (!pValueChild) { |
| 153 return CXFA_LocaleValue(); | 153 return CXFA_LocaleValue(); |
| 154 } | 154 } |
| 155 int32_t iVTType = XFA_VT_NULL; | 155 int32_t iVTType = XFA_VT_NULL; |
| 156 XFA_Element eType = pValueChild->GetClassID(); | 156 XFA_Element eType = pValueChild->GetElementType(); |
| 157 switch (eType) { | 157 switch (eType) { |
| 158 case XFA_Element::Decimal: | 158 case XFA_Element::Decimal: |
| 159 iVTType = XFA_VT_DECIMAL; | 159 iVTType = XFA_VT_DECIMAL; |
| 160 break; | 160 break; |
| 161 case XFA_Element::Float: | 161 case XFA_Element::Float: |
| 162 iVTType = XFA_VT_FLOAT; | 162 iVTType = XFA_VT_FLOAT; |
| 163 break; | 163 break; |
| 164 case XFA_Element::Date: | 164 case XFA_Element::Date: |
| 165 iVTType = XFA_VT_DATE; | 165 iVTType = XFA_VT_DATE; |
| 166 break; | 166 break; |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 } | 231 } |
| 232 } | 232 } |
| 233 FX_BOOL XFA_FieldIsMultiListBox(CXFA_Node* pFieldNode) { | 233 FX_BOOL XFA_FieldIsMultiListBox(CXFA_Node* pFieldNode) { |
| 234 FX_BOOL bRet = FALSE; | 234 FX_BOOL bRet = FALSE; |
| 235 if (!pFieldNode) { | 235 if (!pFieldNode) { |
| 236 return bRet; | 236 return bRet; |
| 237 } | 237 } |
| 238 CXFA_Node* pUIChild = pFieldNode->GetChild(0, XFA_Element::Ui); | 238 CXFA_Node* pUIChild = pFieldNode->GetChild(0, XFA_Element::Ui); |
| 239 if (pUIChild) { | 239 if (pUIChild) { |
| 240 CXFA_Node* pFirstChild = pUIChild->GetNodeItem(XFA_NODEITEM_FirstChild); | 240 CXFA_Node* pFirstChild = pUIChild->GetNodeItem(XFA_NODEITEM_FirstChild); |
| 241 if (pFirstChild && pFirstChild->GetClassID() == XFA_Element::ChoiceList) { | 241 if (pFirstChild && |
| 242 pFirstChild->GetElementType() == XFA_Element::ChoiceList) { |
| 242 bRet = pFirstChild->GetEnum(XFA_ATTRIBUTE_Open) == | 243 bRet = pFirstChild->GetEnum(XFA_ATTRIBUTE_Open) == |
| 243 XFA_ATTRIBUTEENUM_MultiSelect; | 244 XFA_ATTRIBUTEENUM_MultiSelect; |
| 244 } | 245 } |
| 245 } | 246 } |
| 246 return bRet; | 247 return bRet; |
| 247 } | 248 } |
| 248 FX_BOOL XFA_IsLayoutElement(XFA_Element eElement, FX_BOOL bLayoutContainer) { | 249 FX_BOOL XFA_IsLayoutElement(XFA_Element eElement, FX_BOOL bLayoutContainer) { |
| 249 switch (eElement) { | 250 switch (eElement) { |
| 250 case XFA_Element::Draw: | 251 case XFA_Element::Draw: |
| 251 case XFA_Element::Field: | 252 case XFA_Element::Field: |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 FX_DOUBLE XFA_ByteStringToDouble(const CFX_ByteStringC& szStringVal) { | 362 FX_DOUBLE XFA_ByteStringToDouble(const CFX_ByteStringC& szStringVal) { |
| 362 CFX_WideString wsValue = CFX_WideString::FromUTF8(szStringVal); | 363 CFX_WideString wsValue = CFX_WideString::FromUTF8(szStringVal); |
| 363 return XFA_WideStringToDouble(wsValue); | 364 return XFA_WideStringToDouble(wsValue); |
| 364 } | 365 } |
| 365 | 366 |
| 366 int32_t XFA_MapRotation(int32_t nRotation) { | 367 int32_t XFA_MapRotation(int32_t nRotation) { |
| 367 nRotation = nRotation % 360; | 368 nRotation = nRotation % 360; |
| 368 nRotation = nRotation < 0 ? nRotation + 360 : nRotation; | 369 nRotation = nRotation < 0 ? nRotation + 360 : nRotation; |
| 369 return nRotation; | 370 return nRotation; |
| 370 } | 371 } |
| OLD | NEW |