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->GetElementType(); | 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 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 = defValue.GetChildValueClassID(); | 28 XFA_Element eValueType = 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 eChildType = pChild->GetElementType(); | 65 XFA_Element eChildType = pChild->GetElementType(); |
66 if (eChildType == XFA_Element::Extras || | 66 if (eChildType == XFA_Element::Extras || |
67 eChildType == XFA_Element::Picture) { | 67 eChildType == XFA_Element::Picture) { |
68 continue; | 68 continue; |
69 } | 69 } |
70 const XFA_PROPERTY* pProperty = XFA_GetPropertyOfElement( | 70 const XFA_PROPERTY* pProperty = XFA_GetPropertyOfElement( |
71 XFA_Element::Ui, eChildType, XFA_XDPPACKET_Form); | 71 XFA_Element::Ui, eChildType, XFA_XDPPACKET_Form); |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 break; | 181 break; |
182 default: | 182 default: |
183 iVTType = XFA_VT_NULL; | 183 iVTType = XFA_VT_NULL; |
184 break; | 184 break; |
185 } | 185 } |
186 return CXFA_LocaleValue(iVTType, pWidgetData->GetRawValue(), | 186 return CXFA_LocaleValue(iVTType, pWidgetData->GetRawValue(), |
187 pWidgetData->GetNode()->GetDocument()->GetLocalMgr()); | 187 pWidgetData->GetNode()->GetDocument()->GetLocalMgr()); |
188 } | 188 } |
189 void XFA_GetPlainTextFromRichText(CFDE_XMLNode* pXMLNode, | 189 void XFA_GetPlainTextFromRichText(CFDE_XMLNode* pXMLNode, |
190 CFX_WideString& wsPlainText) { | 190 CFX_WideString& wsPlainText) { |
191 if (pXMLNode == NULL) { | 191 if (!pXMLNode) { |
192 return; | 192 return; |
193 } | 193 } |
194 switch (pXMLNode->GetType()) { | 194 switch (pXMLNode->GetType()) { |
195 case FDE_XMLNODE_Element: { | 195 case FDE_XMLNODE_Element: { |
196 CFDE_XMLElement* pXMLElement = static_cast<CFDE_XMLElement*>(pXMLNode); | 196 CFDE_XMLElement* pXMLElement = static_cast<CFDE_XMLElement*>(pXMLNode); |
197 CFX_WideString wsTag; | 197 CFX_WideString wsTag; |
198 pXMLElement->GetLocalTagName(wsTag); | 198 pXMLElement->GetLocalTagName(wsTag); |
199 uint32_t uTag = FX_HashCode_GetW(wsTag.AsStringC(), true); | 199 uint32_t uTag = FX_HashCode_GetW(wsTag.AsStringC(), true); |
200 if (uTag == 0x0001f714) { | 200 if (uTag == 0x0001f714) { |
201 wsPlainText += L"\n"; | 201 wsPlainText += L"\n"; |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 FX_DOUBLE XFA_ByteStringToDouble(const CFX_ByteStringC& szStringVal) { | 362 FX_DOUBLE XFA_ByteStringToDouble(const CFX_ByteStringC& szStringVal) { |
363 CFX_WideString wsValue = CFX_WideString::FromUTF8(szStringVal); | 363 CFX_WideString wsValue = CFX_WideString::FromUTF8(szStringVal); |
364 return XFA_WideStringToDouble(wsValue); | 364 return XFA_WideStringToDouble(wsValue); |
365 } | 365 } |
366 | 366 |
367 int32_t XFA_MapRotation(int32_t nRotation) { | 367 int32_t XFA_MapRotation(int32_t nRotation) { |
368 nRotation = nRotation % 360; | 368 nRotation = nRotation % 360; |
369 nRotation = nRotation < 0 ? nRotation + 360 : nRotation; | 369 nRotation = nRotation < 0 ? nRotation + 360 : nRotation; |
370 return nRotation; | 370 return nRotation; |
371 } | 371 } |
OLD | NEW |