| 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->GetClassID(); |
| 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 nullptr; |
| 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 = (XFA_ELEMENT)defValue.GetChildValueClassID(); | 28 XFA_ELEMENT eValueType = (XFA_ELEMENT)defValue.GetChildValueClassID(); |
| 29 switch (eValueType) { | 29 switch (eValueType) { |
| 30 case XFA_ELEMENT_Boolean: | 30 case XFA_ELEMENT_Boolean: |
| 31 eUIType = XFA_ELEMENT_CheckButton; | 31 eUIType = XFA_ELEMENT_CheckButton; |
| 32 break; | 32 break; |
| 33 case XFA_ELEMENT_Integer: | 33 case XFA_ELEMENT_Integer: |
| (...skipping 17 matching lines...) Expand all Loading... |
| 51 break; | 51 break; |
| 52 case XFA_ELEMENT_Arc: | 52 case XFA_ELEMENT_Arc: |
| 53 case XFA_ELEMENT_Line: | 53 case XFA_ELEMENT_Line: |
| 54 case XFA_ELEMENT_Rectangle: | 54 case XFA_ELEMENT_Rectangle: |
| 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 = nullptr; |
| 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->GetClassID(); |
| 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)) { |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 break; | 180 break; |
| 181 default: | 181 default: |
| 182 iVTType = XFA_VT_NULL; | 182 iVTType = XFA_VT_NULL; |
| 183 break; | 183 break; |
| 184 } | 184 } |
| 185 return CXFA_LocaleValue(iVTType, pWidgetData->GetRawValue(), | 185 return CXFA_LocaleValue(iVTType, pWidgetData->GetRawValue(), |
| 186 pWidgetData->GetNode()->GetDocument()->GetLocalMgr()); | 186 pWidgetData->GetNode()->GetDocument()->GetLocalMgr()); |
| 187 } | 187 } |
| 188 void XFA_GetPlainTextFromRichText(CFDE_XMLNode* pXMLNode, | 188 void XFA_GetPlainTextFromRichText(CFDE_XMLNode* pXMLNode, |
| 189 CFX_WideString& wsPlainText) { | 189 CFX_WideString& wsPlainText) { |
| 190 if (pXMLNode == NULL) { | 190 if (!pXMLNode) |
| 191 return; | 191 return; |
| 192 } | 192 |
| 193 switch (pXMLNode->GetType()) { | 193 switch (pXMLNode->GetType()) { |
| 194 case FDE_XMLNODE_Element: { | 194 case FDE_XMLNODE_Element: { |
| 195 CFDE_XMLElement* pXMLElement = static_cast<CFDE_XMLElement*>(pXMLNode); | 195 CFDE_XMLElement* pXMLElement = static_cast<CFDE_XMLElement*>(pXMLNode); |
| 196 CFX_WideString wsTag; | 196 CFX_WideString wsTag; |
| 197 pXMLElement->GetLocalTagName(wsTag); | 197 pXMLElement->GetLocalTagName(wsTag); |
| 198 uint32_t uTag = FX_HashCode_GetW(wsTag.AsStringC(), true); | 198 uint32_t uTag = FX_HashCode_GetW(wsTag.AsStringC(), true); |
| 199 if (uTag == 0x0001f714) { | 199 if (uTag == 0x0001f714) { |
| 200 wsPlainText += L"\n"; | 200 wsPlainText += L"\n"; |
| 201 } else if (uTag == 0x00000070) { | 201 } else if (uTag == 0x00000070) { |
| 202 if (!wsPlainText.IsEmpty()) { | 202 if (!wsPlainText.IsEmpty()) { |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 FX_DOUBLE XFA_ByteStringToDouble(const CFX_ByteStringC& szStringVal) { | 360 FX_DOUBLE XFA_ByteStringToDouble(const CFX_ByteStringC& szStringVal) { |
| 361 CFX_WideString wsValue = CFX_WideString::FromUTF8(szStringVal); | 361 CFX_WideString wsValue = CFX_WideString::FromUTF8(szStringVal); |
| 362 return XFA_WideStringToDouble(wsValue); | 362 return XFA_WideStringToDouble(wsValue); |
| 363 } | 363 } |
| 364 | 364 |
| 365 int32_t XFA_MapRotation(int32_t nRotation) { | 365 int32_t XFA_MapRotation(int32_t nRotation) { |
| 366 nRotation = nRotation % 360; | 366 nRotation = nRotation % 360; |
| 367 nRotation = nRotation < 0 ? nRotation + 360 : nRotation; | 367 nRotation = nRotation < 0 ? nRotation + 360 : nRotation; |
| 368 return nRotation; | 368 return nRotation; |
| 369 } | 369 } |
| OLD | NEW |