diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2016-03-01 12:47:41 -0500 |
---|---|---|
committer | Dan Sinclair <dsinclair@chromium.org> | 2016-03-01 12:47:41 -0500 |
commit | 020f137064ace7b35824e5140ea97a1f56c2f533 (patch) | |
tree | 4bb8edca484e982d225f77c250a7368b850a62d7 /xfa | |
parent | c441552aa9776b9fbdecf3e17d20ba096512f388 (diff) | |
download | pdfium-020f137064ace7b35824e5140ea97a1f56c2f533.tar.xz |
Remove XFA_PARSE_HAS_LINEIDENTIFIER
This flag is always defined, remove conditional code and flag.
R=tsepez@chromium.org
Review URL: https://codereview.chromium.org/1752503004 .
Diffstat (limited to 'xfa')
-rw-r--r-- | xfa/src/fxfa/src/common/xfa_utils.h | 4 | ||||
-rw-r--r-- | xfa/src/fxfa/src/parser/xfa_objectacc_imp.cpp | 72 | ||||
-rw-r--r-- | xfa/src/fxfa/src/parser/xfa_parser_imp.cpp | 131 |
3 files changed, 57 insertions, 150 deletions
diff --git a/xfa/src/fxfa/src/common/xfa_utils.h b/xfa/src/fxfa/src/common/xfa_utils.h index 010a1aadde..1b344f85da 100644 --- a/xfa/src/fxfa/src/common/xfa_utils.h +++ b/xfa/src/fxfa/src/common/xfa_utils.h @@ -199,9 +199,7 @@ CFX_WideString XFA_NumericLimit(const CFX_WideString& wsValue, FX_DOUBLE XFA_WideStringToDouble(const CFX_WideString& wsStringVal); FX_DOUBLE XFA_ByteStringToDouble(const CFX_ByteStringC& szStringVal); int32_t XFA_MapRotation(int32_t nRotation); -#ifndef XFA_PARSE_HAS_LINEIDENTIFIER -#define XFA_PARSE_HAS_LINEIDENTIFIER -#endif + FX_BOOL XFA_RecognizeRichText(IFDE_XMLElement* pRichTextXMLNode); void XFA_GetPlainTextFromRichText(IFDE_XMLNode* pXMLNode, CFX_WideString& wsPlainText); diff --git a/xfa/src/fxfa/src/parser/xfa_objectacc_imp.cpp b/xfa/src/fxfa/src/parser/xfa_objectacc_imp.cpp index c8e00e82da..acbb521446 100644 --- a/xfa/src/fxfa/src/parser/xfa_objectacc_imp.cpp +++ b/xfa/src/fxfa/src/parser/xfa_objectacc_imp.cpp @@ -3055,69 +3055,20 @@ static FX_BOOL XFA_SplitDateTime(const CFX_WideString& wsDateTime, } return TRUE; } -#ifndef XFA_PARSE_HAS_LINEIDENTIFIER -FX_BOOL CXFA_FieldNode_IsRichTextEdit(CXFA_Node* pFieldNode, - IFDE_XMLNode*& pXMLNode) { - FX_BOOL bRichTextEdit = FALSE; - pXMLNode = NULL; - if (pFieldNode->GetClassID() == XFA_ELEMENT_Field) { - CXFA_Node* pValue = pFieldNode->GetChild(0, XFA_ELEMENT_Value); - if (!pValue) { - return bRichTextEdit; - } - CXFA_Node* pChildValue = pValue->GetNodeItem(XFA_NODEITEM_FirstChild); - if (!pChildValue) { - return bRichTextEdit; - } - if (pChildValue->GetClassID() == XFA_ELEMENT_ExData) { - CFX_WideString wsContentType; - pChildValue->GetAttribute(XFA_ATTRIBUTE_ContentType, wsContentType, - FALSE); - bRichTextEdit = wsContentType.Equal(FX_WSTRC(L"text/html")); - if (bRichTextEdit) { - FX_BOOL bXMLInData = FALSE; - CXFA_Node* pDataNode = pFieldNode->GetBindData(); - if (pDataNode) { - IFDE_XMLNode* pBindXML = pDataNode->GetXMLMappingNode(); - FXSYS_assert(pBindXML); - IFDE_XMLNode* pValueXML = - pBindXML->GetNodeItem(IFDE_XMLNode::FirstChild); - if (pValueXML && pValueXML->GetType() == FDE_XMLNODE_Element) { - pXMLNode = pValueXML; - bXMLInData = TRUE; - } - } - if (!bXMLInData) { - pXMLNode = pChildValue->GetXMLMappingNode(); - } - } - } - } - return bRichTextEdit; -} -#endif + FX_BOOL CXFA_WidgetData::GetValue(CFX_WideString& wsValue, XFA_VALUEPICTURE eValueType) { -#ifdef XFA_PARSE_HAS_LINEIDENTIFIER wsValue = m_pNode->GetContent(); -#else - IFDE_XMLNode* pXMLNode = NULL; - FX_BOOL bRichTextEdit = CXFA_FieldNode_IsRichTextEdit(m_pNode, pXMLNode); - if (bRichTextEdit) { - XFA_GetPlainTextFromRichText(pXMLNode, wsValue); - } else { - wsValue = m_pNode->GetContent(); - } -#endif - if (eValueType == XFA_VALUEPICTURE_Display) { + + if (eValueType == XFA_VALUEPICTURE_Display) GetItemLabel(wsValue, wsValue); - } + CFX_WideString wsPicture; GetPictureContent(wsPicture, eValueType); CXFA_Node* pNode = GetUIChild(); - if (!pNode) { + if (!pNode) return TRUE; - } + XFA_ELEMENT uiType = GetUIChild()->GetClassID(); switch (uiType) { case XFA_ELEMENT_ChoiceList: { @@ -3143,9 +3094,9 @@ FX_BOOL CXFA_WidgetData::GetValue(CFX_WideString& wsValue, default: break; } - if (wsPicture.IsEmpty()) { + if (wsPicture.IsEmpty()) return TRUE; - } + if (IFX_Locale* pLocale = GetLocal()) { CXFA_LocaleValue widgetValue = XFA_GetLocaleValue(this); CXFA_LocaleMgr* pLocalMgr = m_pNode->GetDocument()->GetLocalMgr(); @@ -3154,9 +3105,8 @@ FX_BOOL CXFA_WidgetData::GetValue(CFX_WideString& wsValue, CFX_WideString wsDate, wsTime; if (XFA_SplitDateTime(wsValue, wsDate, wsTime)) { CXFA_LocaleValue date(XFA_VT_DATE, wsDate, pLocalMgr); - if (date.FormatPatterns(wsValue, wsPicture, pLocale, eValueType)) { + if (date.FormatPatterns(wsValue, wsPicture, pLocale, eValueType)) return TRUE; - } } break; } @@ -3164,9 +3114,8 @@ FX_BOOL CXFA_WidgetData::GetValue(CFX_WideString& wsValue, CFX_WideString wsDate, wsTime; if (XFA_SplitDateTime(wsValue, wsDate, wsTime)) { CXFA_LocaleValue time(XFA_VT_TIME, wsTime, pLocalMgr); - if (time.FormatPatterns(wsValue, wsPicture, pLocale, eValueType)) { + if (time.FormatPatterns(wsValue, wsPicture, pLocale, eValueType)) return TRUE; - } } break; } @@ -3177,6 +3126,7 @@ FX_BOOL CXFA_WidgetData::GetValue(CFX_WideString& wsValue, } return TRUE; } + FX_BOOL CXFA_WidgetData::GetNormalizeDataValue( const CFX_WideStringC& wsValue, CFX_WideString& wsNormalizeValue) { diff --git a/xfa/src/fxfa/src/parser/xfa_parser_imp.cpp b/xfa/src/fxfa/src/parser/xfa_parser_imp.cpp index c2f15a18a6..6709c62318 100644 --- a/xfa/src/fxfa/src/parser/xfa_parser_imp.cpp +++ b/xfa/src/fxfa/src/parser/xfa_parser_imp.cpp @@ -156,6 +156,7 @@ int32_t CXFA_SimpleParser::ParseXMLData(const CFX_WideString& wsXML, pXMLNode = XFA_FDEExtension_GetDocumentNode(m_pXMLDoc); return XFA_PARSESTATUS_Done; } + void CXFA_SimpleParser::ConstructXFANode(CXFA_Node* pXFANode, IFDE_XMLNode* pXMLNode) { XFA_XDPPACKET ePacketID = (XFA_XDPPACKET)pXFANode->GetPacketID(); @@ -166,29 +167,24 @@ void CXFA_SimpleParser::ConstructXFANode(CXFA_Node* pXFANode, pXMLChild; pXMLChild = pXMLChild->GetNodeItem(IFDE_XMLNode::NextSibling)) { FDE_XMLNODETYPE eNodeType = pXMLChild->GetType(); - if (eNodeType == FDE_XMLNODE_Instruction) { + if (eNodeType == FDE_XMLNODE_Instruction) continue; - } + if (eNodeType == FDE_XMLNODE_Element) { CXFA_Node* pXFAChild = m_pFactory->CreateNode(XFA_XDPPACKET_Datasets, XFA_ELEMENT_DataValue); - if (pXFAChild == NULL) { + if (!pXFAChild) return; - } + CFX_WideString wsNodeStr; ((IFDE_XMLElement*)pXMLChild)->GetLocalTagName(wsNodeStr); pXFAChild->SetCData(XFA_ATTRIBUTE_Name, wsNodeStr); CFX_WideString wsChildValue; -#ifdef XFA_PARSE_HAS_LINEIDENTIFIER XFA_GetPlainTextFromRichText((IFDE_XMLElement*)pXMLChild, wsChildValue); -#else - XFA_ConvertRichTextToPlainText((IFDE_XMLElement*)pXMLChild, - wsChildValue); -#endif - if (!wsChildValue.IsEmpty()) { + if (!wsChildValue.IsEmpty()) pXFAChild->SetCData(XFA_ATTRIBUTE_Value, wsChildValue); - } + pXFANode->InsertChild(pXFAChild); pXFAChild->SetXMLMappingNode(pXMLChild); pXFAChild->SetFlag(XFA_NODEFLAG_Initialized, TRUE, FALSE); @@ -199,15 +195,14 @@ void CXFA_SimpleParser::ConstructXFANode(CXFA_Node* pXFANode, } else { m_pRootNode = DataLoader(pXFANode, pXMLNode, TRUE); } + } else if (pXFANode->GetObjectType() == XFA_OBJECTTYPE_ContentNode) { + ParseContentNode(pXFANode, pXMLNode, ePacketID); + m_pRootNode = pXFANode; } else { - if (pXFANode->GetObjectType() == XFA_OBJECTTYPE_ContentNode) { - ParseContentNode(pXFANode, pXMLNode, ePacketID); - m_pRootNode = pXFANode; - } else { - m_pRootNode = NormalLoader(pXFANode, pXMLNode, ePacketID); - } + m_pRootNode = NormalLoader(pXFANode, pXMLNode, ePacketID); } } + FX_BOOL XFA_FDEExtension_ResolveNamespaceQualifier( IFDE_XMLElement* pNode, const CFX_WideStringC& wsQualifier, @@ -938,32 +933,6 @@ class RichTextNodeVisitor { return pNode->GetNodeItem(IFDE_XMLNode::Parent); } }; -#ifndef XFA_PARSE_HAS_LINEIDENTIFIER -void XFA_ConvertRichTextToPlainText(IFDE_XMLElement* pRichTextXMLNode, - CFX_WideString& wsOutput) { - CXFA_NodeIteratorTemplate<IFDE_XMLNode, RichTextNodeVisitor> sIterator( - pRichTextXMLNode); - CFX_WideTextBuf wsPlainTextBuf; - for (IFDE_XMLNode* pNode = sIterator.GetCurrent(); pNode; - pNode = sIterator.MoveToNext()) { - switch (pNode->GetType()) { - case FDE_XMLNODE_Text: { - CFX_WideString wsText; - ((IFDE_XMLText*)pNode)->GetText(wsText); - wsPlainTextBuf << wsText; - } break; - case FDE_XMLNODE_CharData: { - CFX_WideString wsText; - ((IFDE_XMLCharData*)pNode)->GetCharData(wsText); - wsPlainTextBuf << wsText; - } break; - default: - break; - } - } - wsOutput = wsPlainTextBuf.GetWideString(); -} -#endif void XFA_ConvertXMLToPlainText(IFDE_XMLElement* pRootXMLNode, CFX_WideString& wsOutput) { @@ -1010,49 +979,40 @@ void CXFA_SimpleParser::ParseContentNode(CXFA_Node* pXFANode, if (pXFANode->GetClassID() == XFA_ELEMENT_ExData) { CFX_WideStringC wsContentType = pXFANode->GetCData(XFA_ATTRIBUTE_ContentType); - if (wsContentType == FX_WSTRC(L"text/html")) { + if (wsContentType == FX_WSTRC(L"text/html")) element = XFA_ELEMENT_SharpxHTML; - } else if (wsContentType == FX_WSTRC(L"text/xml")) { + else if (wsContentType == FX_WSTRC(L"text/xml")) element = XFA_ELEMENT_Sharpxml; - } } - if (element == XFA_ELEMENT_SharpxHTML) { + if (element == XFA_ELEMENT_SharpxHTML) pXFANode->SetXMLMappingNode(pXMLNode); - } + CFX_WideString wsValue; for (IFDE_XMLNode* pXMLChild = pXMLNode->GetNodeItem(IFDE_XMLNode::FirstChild); pXMLChild; pXMLChild = pXMLChild->GetNodeItem(IFDE_XMLNode::NextSibling)) { FDE_XMLNODETYPE eNodeType = pXMLChild->GetType(); - if (eNodeType == FDE_XMLNODE_Instruction) { + if (eNodeType == FDE_XMLNODE_Instruction) continue; - } + if (element == XFA_ELEMENT_SharpxHTML) { - if (eNodeType != FDE_XMLNODE_Element) { + if (eNodeType != FDE_XMLNODE_Element) break; - } - if (XFA_RecognizeRichText((IFDE_XMLElement*)pXMLChild)) { -#ifdef XFA_PARSE_HAS_LINEIDENTIFIER + + if (XFA_RecognizeRichText((IFDE_XMLElement*)pXMLChild)) XFA_GetPlainTextFromRichText((IFDE_XMLElement*)pXMLChild, wsValue); -#else - XFA_ConvertRichTextToPlainText((IFDE_XMLElement*)pXMLChild, wsValue); -#endif - } } else if (element == XFA_ELEMENT_Sharpxml) { - if (eNodeType != FDE_XMLNODE_Element) { + if (eNodeType != FDE_XMLNODE_Element) break; - } XFA_ConvertXMLToPlainText((IFDE_XMLElement*)pXMLChild, wsValue); } else { - if (eNodeType == FDE_XMLNODE_Element) { + if (eNodeType == FDE_XMLNODE_Element) break; - } - if (eNodeType == FDE_XMLNODE_Text) { + if (eNodeType == FDE_XMLNODE_Text) ((IFDE_XMLText*)pXMLChild)->GetText(wsValue); - } else if (eNodeType == FDE_XMLNODE_CharData) { + else if (eNodeType == FDE_XMLNODE_CharData) ((IFDE_XMLCharData*)pXMLChild)->GetCharData(wsValue); - } } break; } @@ -1068,6 +1028,7 @@ void CXFA_SimpleParser::ParseContentNode(CXFA_Node* pXFANode, } } } + void CXFA_SimpleParser::ParseDataGroup(CXFA_Node* pXFANode, IFDE_XMLNode* pXMLNode, XFA_XDPPACKET ePacketID) { @@ -1250,43 +1211,40 @@ void CXFA_SimpleParser::ParseDataGroup(CXFA_Node* pXFANode, } } } + void CXFA_SimpleParser::ParseDataValue(CXFA_Node* pXFANode, IFDE_XMLNode* pXMLNode, XFA_XDPPACKET ePacketID) { CFX_WideTextBuf wsValueTextBuf; CFX_WideTextBuf wsCurValueTextBuf; FX_BOOL bMarkAsCompound = FALSE; - IFDE_XMLNode* pXMLCurValueNode = NULL; + IFDE_XMLNode* pXMLCurValueNode = nullptr; for (IFDE_XMLNode* pXMLChild = pXMLNode->GetNodeItem(IFDE_XMLNode::FirstChild); pXMLChild; pXMLChild = pXMLChild->GetNodeItem(IFDE_XMLNode::NextSibling)) { FDE_XMLNODETYPE eNodeType = pXMLChild->GetType(); - if (eNodeType == FDE_XMLNODE_Instruction) { + if (eNodeType == FDE_XMLNODE_Instruction) continue; - } + CFX_WideString wsText; if (eNodeType == FDE_XMLNODE_Text) { ((IFDE_XMLText*)pXMLChild)->GetText(wsText); - if (!pXMLCurValueNode) { + if (!pXMLCurValueNode) pXMLCurValueNode = pXMLChild; - } + wsCurValueTextBuf << wsText; } else if (eNodeType == FDE_XMLNODE_CharData) { ((IFDE_XMLCharData*)pXMLChild)->GetCharData(wsText); - if (!pXMLCurValueNode) { + if (!pXMLCurValueNode) pXMLCurValueNode = pXMLChild; - } + wsCurValueTextBuf << wsText; } else if (XFA_RecognizeRichText((IFDE_XMLElement*)pXMLChild)) { -#ifdef XFA_PARSE_HAS_LINEIDENTIFIER XFA_GetPlainTextFromRichText((IFDE_XMLElement*)pXMLChild, wsText); -#else - XFA_ConvertRichTextToPlainText((IFDE_XMLElement*)pXMLChild, wsText); -#endif - if (!pXMLCurValueNode) { + if (!pXMLCurValueNode) pXMLCurValueNode = pXMLChild; - } + wsCurValueTextBuf << wsText; } else { bMarkAsCompound = TRUE; @@ -1295,9 +1253,9 @@ void CXFA_SimpleParser::ParseDataValue(CXFA_Node* pXFANode, if (!wsCurValue.IsEmpty()) { CXFA_Node* pXFAChild = m_pFactory->CreateNode(ePacketID, XFA_ELEMENT_DataValue); - if (pXFAChild == NULL) { + if (!pXFAChild) return; - } + pXFAChild->SetCData(XFA_ATTRIBUTE_Name, FX_WSTRC(L"")); pXFAChild->SetCData(XFA_ATTRIBUTE_Value, wsCurValue); pXFANode->InsertChild(pXFAChild); @@ -1306,13 +1264,13 @@ void CXFA_SimpleParser::ParseDataValue(CXFA_Node* pXFANode, wsValueTextBuf << wsCurValue; wsCurValueTextBuf.Clear(); } - pXMLCurValueNode = NULL; + pXMLCurValueNode = nullptr; } CXFA_Node* pXFAChild = m_pFactory->CreateNode(ePacketID, XFA_ELEMENT_DataValue); - if (pXFAChild == NULL) { + if (!pXFAChild) return; - } + CFX_WideString wsNodeStr; ((IFDE_XMLElement*)pXMLChild)->GetLocalTagName(wsNodeStr); pXFAChild->SetCData(XFA_ATTRIBUTE_Name, wsNodeStr); @@ -1330,9 +1288,9 @@ void CXFA_SimpleParser::ParseDataValue(CXFA_Node* pXFANode, if (bMarkAsCompound) { CXFA_Node* pXFAChild = m_pFactory->CreateNode(ePacketID, XFA_ELEMENT_DataValue); - if (pXFAChild == NULL) { + if (!pXFAChild) return; - } + pXFAChild->SetCData(XFA_ATTRIBUTE_Name, FX_WSTRC(L"")); pXFAChild->SetCData(XFA_ATTRIBUTE_Value, wsCurValue); pXFANode->InsertChild(pXFAChild); @@ -1342,11 +1300,12 @@ void CXFA_SimpleParser::ParseDataValue(CXFA_Node* pXFANode, wsValueTextBuf << wsCurValue; wsCurValueTextBuf.Clear(); } - pXMLCurValueNode = NULL; + pXMLCurValueNode = nullptr; } CFX_WideStringC wsNodeValue = wsValueTextBuf.GetWideString(); pXFANode->SetCData(XFA_ATTRIBUTE_Value, wsNodeValue); } + void CXFA_SimpleParser::ParseInstruction(CXFA_Node* pXFANode, IFDE_XMLInstruction* pXMLInstruction, XFA_XDPPACKET ePacketID) { |