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_parser_imp.h" | 7 #include "xfa/fxfa/parser/xfa_parser_imp.h" |
8 | 8 |
9 #include "xfa/fgas/crt/fgas_codepage.h" | 9 #include "xfa/fgas/crt/fgas_codepage.h" |
10 #include "xfa/fxfa/fm2js/xfa_fm2jsapi.h" | 10 #include "xfa/fxfa/fm2js/xfa_fm2jsapi.h" |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
224 continue; | 224 continue; |
225 } | 225 } |
226 if (pNode->HasAttribute(wsNSAttribute)) { | 226 if (pNode->HasAttribute(wsNSAttribute)) { |
227 pNode->GetString(wsNSAttribute, wsNamespaceURI); | 227 pNode->GetString(wsNSAttribute, wsNamespaceURI); |
228 return TRUE; | 228 return TRUE; |
229 } | 229 } |
230 } | 230 } |
231 wsNamespaceURI.Empty(); | 231 wsNamespaceURI.Empty(); |
232 return bRet; | 232 return bRet; |
233 } | 233 } |
234 static inline void XFA_FDEExtension_GetElementTagNamespaceURI( | 234 static inline void XFA_FDEExtension_GetObjectByTagNamespaceURI( |
dsinclair
2016/03/29 20:45:25
Do we want By here?
| |
235 IFDE_XMLElement* pElement, | 235 IFDE_XMLElement* pElement, |
236 CFX_WideString& wsNamespaceURI) { | 236 CFX_WideString& wsNamespaceURI) { |
237 CFX_WideString wsNodeStr; | 237 CFX_WideString wsNodeStr; |
238 pElement->GetNamespacePrefix(wsNodeStr); | 238 pElement->GetNamespacePrefix(wsNodeStr); |
239 if (!XFA_FDEExtension_ResolveNamespaceQualifier(pElement, wsNodeStr, | 239 if (!XFA_FDEExtension_ResolveNamespaceQualifier(pElement, wsNodeStr, |
240 wsNamespaceURI)) { | 240 wsNamespaceURI)) { |
241 wsNamespaceURI.Empty(); | 241 wsNamespaceURI.Empty(); |
242 } | 242 } |
243 } | 243 } |
244 static FX_BOOL XFA_FDEExtension_MatchNodeName( | 244 static FX_BOOL XFA_FDEExtension_MatchNodeName( |
245 IFDE_XMLNode* pNode, | 245 IFDE_XMLNode* pNode, |
246 const CFX_WideStringC& wsLocalTagName, | 246 const CFX_WideStringC& wsLocalTagName, |
247 const CFX_WideStringC& wsNamespaceURIPrefix, | 247 const CFX_WideStringC& wsNamespaceURIPrefix, |
248 uint32_t eMatchFlags = XFA_XDPPACKET_FLAGS_NOMATCH) { | 248 uint32_t eMatchFlags = XFA_XDPPACKET_FLAGS_NOMATCH) { |
249 if (!pNode || pNode->GetType() != FDE_XMLNODE_Element) { | 249 if (!pNode || pNode->GetType() != FDE_XMLNODE_Element) { |
250 return FALSE; | 250 return FALSE; |
251 } | 251 } |
252 IFDE_XMLElement* pElement = reinterpret_cast<IFDE_XMLElement*>(pNode); | 252 IFDE_XMLElement* pElement = reinterpret_cast<IFDE_XMLElement*>(pNode); |
253 CFX_WideString wsNodeStr; | 253 CFX_WideString wsNodeStr; |
254 pElement->GetLocalTagName(wsNodeStr); | 254 pElement->GetLocalTagName(wsNodeStr); |
255 if (wsNodeStr != wsLocalTagName) { | 255 if (wsNodeStr != wsLocalTagName) { |
256 return FALSE; | 256 return FALSE; |
257 } | 257 } |
258 XFA_FDEExtension_GetElementTagNamespaceURI(pElement, wsNodeStr); | 258 XFA_FDEExtension_GetObjectByTagNamespaceURI(pElement, wsNodeStr); |
259 if (eMatchFlags & XFA_XDPPACKET_FLAGS_NOMATCH) { | 259 if (eMatchFlags & XFA_XDPPACKET_FLAGS_NOMATCH) { |
260 return TRUE; | 260 return TRUE; |
261 } | 261 } |
262 if (eMatchFlags & XFA_XDPPACKET_FLAGS_PREFIXMATCH) { | 262 if (eMatchFlags & XFA_XDPPACKET_FLAGS_PREFIXMATCH) { |
263 return wsNodeStr.Left(wsNamespaceURIPrefix.GetLength()) == | 263 return wsNodeStr.Left(wsNamespaceURIPrefix.GetLength()) == |
264 wsNamespaceURIPrefix; | 264 wsNamespaceURIPrefix; |
265 } | 265 } |
266 return wsNodeStr == wsNamespaceURIPrefix; | 266 return wsNodeStr == wsNamespaceURIPrefix; |
267 } | 267 } |
268 static FX_BOOL XFA_FDEExtension_GetAttributeLocalName( | 268 static FX_BOOL XFA_FDEExtension_GetAttributeLocalName( |
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
823 FX_BOOL bUseAttribute) { | 823 FX_BOOL bUseAttribute) { |
824 FX_BOOL bOneOfPropertyFound = FALSE; | 824 FX_BOOL bOneOfPropertyFound = FALSE; |
825 for (IFDE_XMLNode* pXMLChild = pXMLDoc->GetNodeItem(IFDE_XMLNode::FirstChild); | 825 for (IFDE_XMLNode* pXMLChild = pXMLDoc->GetNodeItem(IFDE_XMLNode::FirstChild); |
826 pXMLChild; | 826 pXMLChild; |
827 pXMLChild = pXMLChild->GetNodeItem(IFDE_XMLNode::NextSibling)) { | 827 pXMLChild = pXMLChild->GetNodeItem(IFDE_XMLNode::NextSibling)) { |
828 switch (pXMLChild->GetType()) { | 828 switch (pXMLChild->GetType()) { |
829 case FDE_XMLNODE_Element: { | 829 case FDE_XMLNODE_Element: { |
830 IFDE_XMLElement* pXMLElement = (IFDE_XMLElement*)pXMLChild; | 830 IFDE_XMLElement* pXMLElement = (IFDE_XMLElement*)pXMLChild; |
831 CFX_WideString wsTagName; | 831 CFX_WideString wsTagName; |
832 pXMLElement->GetLocalTagName(wsTagName); | 832 pXMLElement->GetLocalTagName(wsTagName); |
833 const XFA_ELEMENTINFO* pElemInfo = XFA_GetElementByName(wsTagName); | 833 const XFA_ELEMENTINFO* pElemInfo = XFA_GetObjectByByName(wsTagName); |
834 if (!pElemInfo) { | 834 if (!pElemInfo) { |
835 continue; | 835 continue; |
836 } | 836 } |
837 const XFA_PROPERTY* pPropertyInfo = XFA_GetPropertyOfElement( | 837 const XFA_PROPERTY* pPropertyInfo = XFA_GetPropertyOfElement( |
838 pXFANode->GetClassID(), pElemInfo->eName, ePacketID); | 838 pXFANode->GetClassID(), pElemInfo->eName, ePacketID); |
839 if (pPropertyInfo && | 839 if (pPropertyInfo && |
840 ((pPropertyInfo->uFlags & | 840 ((pPropertyInfo->uFlags & |
841 (XFA_PROPERTYFLAG_OneOf | XFA_PROPERTYFLAG_DefaultOneOf)) != 0)) { | 841 (XFA_PROPERTYFLAG_OneOf | XFA_PROPERTYFLAG_DefaultOneOf)) != 0)) { |
842 if (bOneOfPropertyFound) { | 842 if (bOneOfPropertyFound) { |
843 break; | 843 break; |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
905 break; | 905 break; |
906 default: | 906 default: |
907 break; | 907 break; |
908 } | 908 } |
909 } | 909 } |
910 return pXFANode; | 910 return pXFANode; |
911 } | 911 } |
912 FX_BOOL XFA_RecognizeRichText(IFDE_XMLElement* pRichTextXMLNode) { | 912 FX_BOOL XFA_RecognizeRichText(IFDE_XMLElement* pRichTextXMLNode) { |
913 if (pRichTextXMLNode) { | 913 if (pRichTextXMLNode) { |
914 CFX_WideString wsNamespaceURI; | 914 CFX_WideString wsNamespaceURI; |
915 XFA_FDEExtension_GetElementTagNamespaceURI(pRichTextXMLNode, | 915 XFA_FDEExtension_GetObjectByTagNamespaceURI(pRichTextXMLNode, |
916 wsNamespaceURI); | 916 wsNamespaceURI); |
917 if (wsNamespaceURI == FX_WSTRC(L"http://www.w3.org/1999/xhtml")) { | 917 if (wsNamespaceURI == FX_WSTRC(L"http://www.w3.org/1999/xhtml")) { |
918 return TRUE; | 918 return TRUE; |
919 } | 919 } |
920 } | 920 } |
921 return FALSE; | 921 return FALSE; |
922 } | 922 } |
923 class RichTextNodeVisitor { | 923 class RichTextNodeVisitor { |
924 public: | 924 public: |
925 static inline IFDE_XMLNode* GetFirstChild(IFDE_XMLNode* pNode) { | 925 static inline IFDE_XMLNode* GetFirstChild(IFDE_XMLNode* pNode) { |
926 return pNode->GetNodeItem(IFDE_XMLNode::FirstChild); | 926 return pNode->GetNodeItem(IFDE_XMLNode::FirstChild); |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1033 XFA_XDPPACKET ePacketID) { | 1033 XFA_XDPPACKET ePacketID) { |
1034 for (IFDE_XMLNode* pXMLChild = | 1034 for (IFDE_XMLNode* pXMLChild = |
1035 pXMLNode->GetNodeItem(IFDE_XMLNode::FirstChild); | 1035 pXMLNode->GetNodeItem(IFDE_XMLNode::FirstChild); |
1036 pXMLChild; | 1036 pXMLChild; |
1037 pXMLChild = pXMLChild->GetNodeItem(IFDE_XMLNode::NextSibling)) { | 1037 pXMLChild = pXMLChild->GetNodeItem(IFDE_XMLNode::NextSibling)) { |
1038 switch (pXMLChild->GetType()) { | 1038 switch (pXMLChild->GetType()) { |
1039 case FDE_XMLNODE_Element: { | 1039 case FDE_XMLNODE_Element: { |
1040 IFDE_XMLElement* pXMLElement = (IFDE_XMLElement*)pXMLChild; | 1040 IFDE_XMLElement* pXMLElement = (IFDE_XMLElement*)pXMLChild; |
1041 { | 1041 { |
1042 CFX_WideString wsNamespaceURI; | 1042 CFX_WideString wsNamespaceURI; |
1043 XFA_FDEExtension_GetElementTagNamespaceURI(pXMLElement, | 1043 XFA_FDEExtension_GetObjectByTagNamespaceURI(pXMLElement, |
1044 wsNamespaceURI); | 1044 wsNamespaceURI); |
1045 if (wsNamespaceURI == | 1045 if (wsNamespaceURI == |
1046 FX_WSTRC(L"http://www.xfa.com/schema/xfa-package/") || | 1046 FX_WSTRC(L"http://www.xfa.com/schema/xfa-package/") || |
1047 wsNamespaceURI == | 1047 wsNamespaceURI == |
1048 FX_WSTRC(L"http://www.xfa.org/schema/xfa-package/") || | 1048 FX_WSTRC(L"http://www.xfa.org/schema/xfa-package/") || |
1049 wsNamespaceURI == | 1049 wsNamespaceURI == |
1050 FX_WSTRC(L"http://www.w3.org/2001/XMLSchema-instance")) { | 1050 FX_WSTRC(L"http://www.w3.org/2001/XMLSchema-instance")) { |
1051 continue; | 1051 continue; |
1052 } | 1052 } |
1053 if (0) { | 1053 if (0) { |
1054 continue; | 1054 continue; |
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1559 break; | 1559 break; |
1560 } | 1560 } |
1561 if (pPause && iCount > 500 && pPause->NeedToPauseNow()) { | 1561 if (pPause && iCount > 500 && pPause->NeedToPauseNow()) { |
1562 break; | 1562 break; |
1563 } | 1563 } |
1564 } | 1564 } |
1565 return (m_dwStatus == FDE_XMLSYNTAXSTATUS_Error || m_NodeStack.GetSize() != 1) | 1565 return (m_dwStatus == FDE_XMLSYNTAXSTATUS_Error || m_NodeStack.GetSize() != 1) |
1566 ? -1 | 1566 ? -1 |
1567 : m_pParser->GetStatus(); | 1567 : m_pParser->GetStatus(); |
1568 } | 1568 } |
OLD | NEW |