Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(176)

Side by Side Diff: xfa/fxfa/parser/xfa_document_serialize.cpp

Issue 1979723003: Make CFX_WideString(const CFX_WideString&) explicit. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Override Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_document_serialize.h" 7 #include "xfa/fxfa/parser/xfa_document_serialize.h"
8 8
9 #include "xfa/fde/xml/fde_xml_imp.h" 9 #include "xfa/fde/xml/fde_xml_imp.h"
10 #include "xfa/fgas/crt/fgas_codepage.h" 10 #include "xfa/fgas/crt/fgas_codepage.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 case '\'': 86 case '\'':
87 textBuf << FX_WSTRC(L"&apos;"); 87 textBuf << FX_WSTRC(L"&apos;");
88 break; 88 break;
89 case '\"': 89 case '\"':
90 textBuf << FX_WSTRC(L"&quot;"); 90 textBuf << FX_WSTRC(L"&quot;");
91 break; 91 break;
92 default: 92 default:
93 textBuf.AppendChar(str[i]); 93 textBuf.AppendChar(str[i]);
94 } 94 }
95 } 95 }
96 return textBuf.AsStringC(); 96 return textBuf.MakeString();
97 } 97 }
98 CFX_WideString XFA_ExportEncodeContent(const CFX_WideStringC& str) { 98 CFX_WideString XFA_ExportEncodeContent(const CFX_WideStringC& str) {
99 CFX_WideTextBuf textBuf; 99 CFX_WideTextBuf textBuf;
100 int32_t iLen = str.GetLength(); 100 int32_t iLen = str.GetLength();
101 for (int32_t i = 0; i < iLen; i++) { 101 for (int32_t i = 0; i < iLen; i++) {
102 FX_WCHAR ch = str.GetAt(i); 102 FX_WCHAR ch = str.GetAt(i);
103 if (!FDE_IsXMLValidChar(ch)) { 103 if (!FDE_IsXMLValidChar(ch)) {
104 continue; 104 continue;
105 } 105 }
106 if (ch == '&') { 106 if (ch == '&') {
107 textBuf << FX_WSTRC(L"&amp;"); 107 textBuf << FX_WSTRC(L"&amp;");
108 } else if (ch == '<') { 108 } else if (ch == '<') {
109 textBuf << FX_WSTRC(L"&lt;"); 109 textBuf << FX_WSTRC(L"&lt;");
110 } else if (ch == '>') { 110 } else if (ch == '>') {
111 textBuf << FX_WSTRC(L"&gt;"); 111 textBuf << FX_WSTRC(L"&gt;");
112 } else if (ch == '\'') { 112 } else if (ch == '\'') {
113 textBuf << FX_WSTRC(L"&apos;"); 113 textBuf << FX_WSTRC(L"&apos;");
114 } else if (ch == '\"') { 114 } else if (ch == '\"') {
115 textBuf << FX_WSTRC(L"&quot;"); 115 textBuf << FX_WSTRC(L"&quot;");
116 } else if (ch == ' ') { 116 } else if (ch == ' ') {
117 if (i && str.GetAt(i - 1) != ' ') { 117 if (i && str.GetAt(i - 1) != ' ') {
118 textBuf.AppendChar(' '); 118 textBuf.AppendChar(' ');
119 } else { 119 } else {
120 textBuf << FX_WSTRC(L"&#x20;"); 120 textBuf << FX_WSTRC(L"&#x20;");
121 } 121 }
122 } else { 122 } else {
123 textBuf.AppendChar(str.GetAt(i)); 123 textBuf.AppendChar(str.GetAt(i));
124 } 124 }
125 } 125 }
126 return textBuf.AsStringC(); 126 return textBuf.MakeString();
127 } 127 }
128 static void XFA_SaveAttribute(CXFA_Node* pNode, 128 static void XFA_SaveAttribute(CXFA_Node* pNode,
129 XFA_ATTRIBUTE eName, 129 XFA_ATTRIBUTE eName,
130 const CFX_WideStringC& wsName, 130 const CFX_WideStringC& wsName,
131 FX_BOOL bProto, 131 FX_BOOL bProto,
132 CFX_WideString& wsOutput) { 132 CFX_WideString& wsOutput) {
133 CFX_WideString wsValue; 133 CFX_WideString wsValue;
134 if ((!bProto && !pNode->HasAttribute((XFA_ATTRIBUTE)eName, bProto)) || 134 if ((!bProto && !pNode->HasAttribute((XFA_ATTRIBUTE)eName, bProto)) ||
135 !pNode->GetAttribute((XFA_ATTRIBUTE)eName, wsValue, FALSE)) { 135 !pNode->GetAttribute((XFA_ATTRIBUTE)eName, wsValue, FALSE)) {
136 return; 136 return;
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 pExportNode = pDataNode; 540 pExportNode = pDataNode;
541 break; 541 break;
542 } 542 }
543 } 543 }
544 CFDE_XMLElement* pElement = 544 CFDE_XMLElement* pElement =
545 static_cast<CFDE_XMLElement*>(pExportNode->GetXMLMappingNode()); 545 static_cast<CFDE_XMLElement*>(pExportNode->GetXMLMappingNode());
546 if (!pElement || pElement->GetType() != FDE_XMLNODE_Element) { 546 if (!pElement || pElement->GetType() != FDE_XMLNODE_Element) {
547 return FALSE; 547 return FALSE;
548 } 548 }
549 XFA_DataExporter_DealWithDataGroupNode(pExportNode); 549 XFA_DataExporter_DealWithDataGroupNode(pExportNode);
550 pElement->SetString(FX_WSTRC(L"xmlns:xfa"), 550 pElement->SetString(L"xmlns:xfa",
551 FX_WSTRC(L"http://www.xfa.org/schema/xfa-data/1.0/")); 551 L"http://www.xfa.org/schema/xfa-data/1.0/");
552 pXMLDoc->SaveXMLNode(pStream, pElement); 552 pXMLDoc->SaveXMLNode(pStream, pElement);
553 pElement->RemoveAttribute(L"xmlns:xfa"); 553 pElement->RemoveAttribute(L"xmlns:xfa");
554 } 554 }
555 return TRUE; 555 return TRUE;
556 } 556 }
557 void XFA_DataExporter_DealWithDataGroupNode(CXFA_Node* pDataNode) { 557 void XFA_DataExporter_DealWithDataGroupNode(CXFA_Node* pDataNode) {
558 if (!pDataNode || pDataNode->GetClassID() == XFA_ELEMENT_DataValue) { 558 if (!pDataNode || pDataNode->GetClassID() == XFA_ELEMENT_DataValue) {
559 return; 559 return;
560 } 560 }
561 int32_t iChildNum = 0; 561 int32_t iChildNum = 0;
562 for (CXFA_Node* pChildNode = pDataNode->GetNodeItem(XFA_NODEITEM_FirstChild); 562 for (CXFA_Node* pChildNode = pDataNode->GetNodeItem(XFA_NODEITEM_FirstChild);
563 pChildNode; 563 pChildNode;
564 pChildNode = pChildNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { 564 pChildNode = pChildNode->GetNodeItem(XFA_NODEITEM_NextSibling)) {
565 iChildNum++; 565 iChildNum++;
566 XFA_DataExporter_DealWithDataGroupNode(pChildNode); 566 XFA_DataExporter_DealWithDataGroupNode(pChildNode);
567 } 567 }
568 if (pDataNode->GetClassID() == XFA_ELEMENT_DataGroup) { 568 if (pDataNode->GetClassID() == XFA_ELEMENT_DataGroup) {
569 if (iChildNum > 0) { 569 if (iChildNum > 0) {
570 CFDE_XMLNode* pXMLNode = pDataNode->GetXMLMappingNode(); 570 CFDE_XMLNode* pXMLNode = pDataNode->GetXMLMappingNode();
571 ASSERT(pXMLNode->GetType() == FDE_XMLNODE_Element); 571 ASSERT(pXMLNode->GetType() == FDE_XMLNODE_Element);
572 CFDE_XMLElement* pXMLElement = static_cast<CFDE_XMLElement*>(pXMLNode); 572 CFDE_XMLElement* pXMLElement = static_cast<CFDE_XMLElement*>(pXMLNode);
573 if (pXMLElement->HasAttribute(L"xfa:dataNode")) { 573 if (pXMLElement->HasAttribute(L"xfa:dataNode")) {
574 pXMLElement->RemoveAttribute(L"xfa:dataNode"); 574 pXMLElement->RemoveAttribute(L"xfa:dataNode");
575 } 575 }
576 } else { 576 } else {
577 CFDE_XMLNode* pXMLNode = pDataNode->GetXMLMappingNode(); 577 CFDE_XMLNode* pXMLNode = pDataNode->GetXMLMappingNode();
578 ASSERT(pXMLNode->GetType() == FDE_XMLNODE_Element); 578 ASSERT(pXMLNode->GetType() == FDE_XMLNODE_Element);
579 static_cast<CFDE_XMLElement*>(pXMLNode) 579 static_cast<CFDE_XMLElement*>(pXMLNode)->SetString(L"xfa:dataNode",
580 ->SetString(FX_WSTRC(L"xfa:dataNode"), FX_WSTRC(L"dataGroup")); 580 L"dataGroup");
581 } 581 }
582 } 582 }
583 } 583 }
OLDNEW
« no previous file with comments | « xfa/fxfa/parser/xfa_document_datamerger_imp.cpp ('k') | xfa/fxfa/parser/xfa_layout_pagemgr_new.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698