| 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/fxfa/fm2js/xfa_fm2jsapi.h" | 11 #include "xfa/fxfa/fm2js/xfa_fm2jsapi.h" |
| 11 #include "xfa/fxfa/parser/xfa_docdata.h" | 12 #include "xfa/fxfa/parser/xfa_docdata.h" |
| 12 #include "xfa/fxfa/parser/xfa_doclayout.h" | 13 #include "xfa/fxfa/parser/xfa_doclayout.h" |
| 13 #include "xfa/fxfa/parser/xfa_document.h" | 14 #include "xfa/fxfa/parser/xfa_document.h" |
| 14 #include "xfa/fxfa/parser/xfa_localemgr.h" | 15 #include "xfa/fxfa/parser/xfa_localemgr.h" |
| 15 #include "xfa/fxfa/parser/xfa_localevalue.h" | 16 #include "xfa/fxfa/parser/xfa_localevalue.h" |
| 16 #include "xfa/fxfa/parser/xfa_object.h" | 17 #include "xfa/fxfa/parser/xfa_object.h" |
| 17 #include "xfa/fxfa/parser/xfa_parser.h" | 18 #include "xfa/fxfa/parser/xfa_parser.h" |
| 18 #include "xfa/fxfa/parser/xfa_script.h" | 19 #include "xfa/fxfa/parser/xfa_script.h" |
| 19 | 20 |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 case XFA_ELEMENT_Text: | 180 case XFA_ELEMENT_Text: |
| 180 iVTType = XFA_VT_TEXT; | 181 iVTType = XFA_VT_TEXT; |
| 181 break; | 182 break; |
| 182 default: | 183 default: |
| 183 iVTType = XFA_VT_NULL; | 184 iVTType = XFA_VT_NULL; |
| 184 break; | 185 break; |
| 185 } | 186 } |
| 186 return CXFA_LocaleValue(iVTType, pWidgetData->GetRawValue(), | 187 return CXFA_LocaleValue(iVTType, pWidgetData->GetRawValue(), |
| 187 pWidgetData->GetNode()->GetDocument()->GetLocalMgr()); | 188 pWidgetData->GetNode()->GetDocument()->GetLocalMgr()); |
| 188 } | 189 } |
| 189 void XFA_GetPlainTextFromRichText(IFDE_XMLNode* pXMLNode, | 190 void XFA_GetPlainTextFromRichText(CFDE_XMLNode* pXMLNode, |
| 190 CFX_WideString& wsPlainText) { | 191 CFX_WideString& wsPlainText) { |
| 191 if (pXMLNode == NULL) { | 192 if (pXMLNode == NULL) { |
| 192 return; | 193 return; |
| 193 } | 194 } |
| 194 switch (pXMLNode->GetType()) { | 195 switch (pXMLNode->GetType()) { |
| 195 case FDE_XMLNODE_Element: { | 196 case FDE_XMLNODE_Element: { |
| 196 IFDE_XMLElement* pXMLElement = (IFDE_XMLElement*)pXMLNode; | 197 CFDE_XMLElement* pXMLElement = static_cast<CFDE_XMLElement*>(pXMLNode); |
| 197 CFX_WideString wsTag; | 198 CFX_WideString wsTag; |
| 198 pXMLElement->GetLocalTagName(wsTag); | 199 pXMLElement->GetLocalTagName(wsTag); |
| 199 uint32_t uTag = FX_HashCode_String_GetW(wsTag, wsTag.GetLength(), TRUE); | 200 uint32_t uTag = FX_HashCode_String_GetW(wsTag, wsTag.GetLength(), TRUE); |
| 200 if (uTag == 0x0001f714) { | 201 if (uTag == 0x0001f714) { |
| 201 wsPlainText += L"\n"; | 202 wsPlainText += L"\n"; |
| 202 } else if (uTag == 0x00000070) { | 203 } else if (uTag == 0x00000070) { |
| 203 if (!wsPlainText.IsEmpty()) { | 204 if (!wsPlainText.IsEmpty()) { |
| 204 wsPlainText += L"\n"; | 205 wsPlainText += L"\n"; |
| 205 } | 206 } |
| 206 } else if (uTag == 0xa48ac63) { | 207 } else if (uTag == 0xa48ac63) { |
| 207 if (!wsPlainText.IsEmpty() && | 208 if (!wsPlainText.IsEmpty() && |
| 208 wsPlainText[wsPlainText.GetLength() - 1] != '\n') { | 209 wsPlainText[wsPlainText.GetLength() - 1] != '\n') { |
| 209 wsPlainText += L"\n"; | 210 wsPlainText += L"\n"; |
| 210 } | 211 } |
| 211 } | 212 } |
| 212 } break; | 213 } break; |
| 213 case FDE_XMLNODE_Text: { | 214 case FDE_XMLNODE_Text: { |
| 214 CFX_WideString wsContent; | 215 CFX_WideString wsContent; |
| 215 ((IFDE_XMLText*)pXMLNode)->GetText(wsContent); | 216 static_cast<CFDE_XMLText*>(pXMLNode)->GetText(wsContent); |
| 216 wsPlainText += wsContent; | 217 wsPlainText += wsContent; |
| 217 } break; | 218 } break; |
| 218 case FDE_XMLNODE_CharData: { | 219 case FDE_XMLNODE_CharData: { |
| 219 CFX_WideString wsCharData; | 220 CFX_WideString wsCharData; |
| 220 ((IFDE_XMLCharData*)pXMLNode)->GetCharData(wsCharData); | 221 static_cast<CFDE_XMLCharData*>(pXMLNode)->GetCharData(wsCharData); |
| 221 wsPlainText += wsCharData; | 222 wsPlainText += wsCharData; |
| 222 } break; | 223 } break; |
| 223 default: | 224 default: |
| 224 break; | 225 break; |
| 225 } | 226 } |
| 226 for (IFDE_XMLNode* pChildXML = | 227 for (CFDE_XMLNode* pChildXML = |
| 227 pXMLNode->GetNodeItem(IFDE_XMLNode::FirstChild); | 228 pXMLNode->GetNodeItem(CFDE_XMLNode::FirstChild); |
| 228 pChildXML; | 229 pChildXML; |
| 229 pChildXML = pChildXML->GetNodeItem(IFDE_XMLNode::NextSibling)) { | 230 pChildXML = pChildXML->GetNodeItem(CFDE_XMLNode::NextSibling)) { |
| 230 XFA_GetPlainTextFromRichText(pChildXML, wsPlainText); | 231 XFA_GetPlainTextFromRichText(pChildXML, wsPlainText); |
| 231 } | 232 } |
| 232 } | 233 } |
| 233 FX_BOOL XFA_FieldIsMultiListBox(CXFA_Node* pFieldNode) { | 234 FX_BOOL XFA_FieldIsMultiListBox(CXFA_Node* pFieldNode) { |
| 234 FX_BOOL bRet = FALSE; | 235 FX_BOOL bRet = FALSE; |
| 235 if (!pFieldNode) { | 236 if (!pFieldNode) { |
| 236 return bRet; | 237 return bRet; |
| 237 } | 238 } |
| 238 CXFA_Node* pUIChild = pFieldNode->GetChild(0, XFA_ELEMENT_Ui); | 239 CXFA_Node* pUIChild = pFieldNode->GetChild(0, XFA_ELEMENT_Ui); |
| 239 if (pUIChild) { | 240 if (pUIChild) { |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 394 CFX_WideString wsValue = | 395 CFX_WideString wsValue = |
| 395 CFX_WideString::FromUTF8(szStringVal.GetCStr(), szStringVal.GetLength()); | 396 CFX_WideString::FromUTF8(szStringVal.GetCStr(), szStringVal.GetLength()); |
| 396 return XFA_WideStringToDouble(wsValue); | 397 return XFA_WideStringToDouble(wsValue); |
| 397 } | 398 } |
| 398 | 399 |
| 399 int32_t XFA_MapRotation(int32_t nRotation) { | 400 int32_t XFA_MapRotation(int32_t nRotation) { |
| 400 nRotation = nRotation % 360; | 401 nRotation = nRotation % 360; |
| 401 nRotation = nRotation < 0 ? nRotation + 360 : nRotation; | 402 nRotation = nRotation < 0 ? nRotation + 360 : nRotation; |
| 402 return nRotation; | 403 return nRotation; |
| 403 } | 404 } |
| OLD | NEW |