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

Side by Side Diff: xfa/fde/xml/fde_xml_imp.cpp

Issue 1882043004: Remove implicit cast from CFX_WideString to (const wchar_t*) (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: win error #2 Created 4 years, 8 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
« no previous file with comments | « xfa/fde/tto/fde_textout.cpp ('k') | xfa/fee/fde_txtedtengine.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/fde/xml/fde_xml_imp.h" 7 #include "xfa/fde/xml/fde_xml_imp.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 ws = L"<?xml version=\"1.0\" encoding=\""; 390 ws = L"<?xml version=\"1.0\" encoding=\"";
391 uint16_t wCodePage = pXMLStream->GetCodePage(); 391 uint16_t wCodePage = pXMLStream->GetCodePage();
392 if (wCodePage == FX_CODEPAGE_UTF16LE) { 392 if (wCodePage == FX_CODEPAGE_UTF16LE) {
393 ws += L"UTF-16"; 393 ws += L"UTF-16";
394 } else if (wCodePage == FX_CODEPAGE_UTF16BE) { 394 } else if (wCodePage == FX_CODEPAGE_UTF16BE) {
395 ws += L"UTF-16be"; 395 ws += L"UTF-16be";
396 } else { 396 } else {
397 ws += L"UTF-8"; 397 ws += L"UTF-8";
398 } 398 }
399 ws += L"\"?>"; 399 ws += L"\"?>";
400 pXMLStream->WriteString(ws, ws.GetLength()); 400 pXMLStream->WriteString(ws.c_str(), ws.GetLength());
401 } else { 401 } else {
402 ws.Format(L"<?%s", (const FX_WCHAR*)pInstruction->m_wsTarget); 402 ws.Format(L"<?%s", pInstruction->m_wsTarget.c_str());
403 pXMLStream->WriteString(ws, ws.GetLength()); 403 pXMLStream->WriteString(ws.c_str(), ws.GetLength());
404 CFX_WideStringArray& attributes = pInstruction->m_Attributes; 404 CFX_WideStringArray& attributes = pInstruction->m_Attributes;
405 int32_t i, iCount = attributes.GetSize(); 405 int32_t i, iCount = attributes.GetSize();
406 CFX_WideString wsValue; 406 CFX_WideString wsValue;
407 for (i = 0; i < iCount; i += 2) { 407 for (i = 0; i < iCount; i += 2) {
408 ws = L" "; 408 ws = L" ";
409 ws += attributes[i]; 409 ws += attributes[i];
410 ws += L"=\""; 410 ws += L"=\"";
411 wsValue = attributes[i + 1]; 411 wsValue = attributes[i + 1];
412 wsValue.Replace(L"&", L"&amp;"); 412 wsValue.Replace(L"&", L"&amp;");
413 wsValue.Replace(L"<", L"&lt;"); 413 wsValue.Replace(L"<", L"&lt;");
414 wsValue.Replace(L">", L"&gt;"); 414 wsValue.Replace(L">", L"&gt;");
415 wsValue.Replace(L"\'", L"&apos;"); 415 wsValue.Replace(L"\'", L"&apos;");
416 wsValue.Replace(L"\"", L"&quot;"); 416 wsValue.Replace(L"\"", L"&quot;");
417 ws += wsValue; 417 ws += wsValue;
418 ws += L"\""; 418 ws += L"\"";
419 pXMLStream->WriteString(ws, ws.GetLength()); 419 pXMLStream->WriteString(ws.c_str(), ws.GetLength());
420 } 420 }
421 CFX_WideStringArray& targetdata = pInstruction->m_TargetData; 421 CFX_WideStringArray& targetdata = pInstruction->m_TargetData;
422 iCount = targetdata.GetSize(); 422 iCount = targetdata.GetSize();
423 for (i = 0; i < iCount; i++) { 423 for (i = 0; i < iCount; i++) {
424 ws = L" \""; 424 ws = L" \"";
425 ws += targetdata[i]; 425 ws += targetdata[i];
426 ws += L"\""; 426 ws += L"\"";
427 pXMLStream->WriteString(ws, ws.GetLength()); 427 pXMLStream->WriteString(ws.c_str(), ws.GetLength());
428 } 428 }
429 ws = L"?>"; 429 ws = L"?>";
430 pXMLStream->WriteString(ws, ws.GetLength()); 430 pXMLStream->WriteString(ws.c_str(), ws.GetLength());
431 } 431 }
432 } break; 432 } break;
433 case FDE_XMLNODE_Element: { 433 case FDE_XMLNODE_Element: {
434 CFX_WideString ws; 434 CFX_WideString ws;
435 ws = L"<"; 435 ws = L"<";
436 ws += ((CFDE_XMLElement*)pNode)->m_wsTag; 436 ws += ((CFDE_XMLElement*)pNode)->m_wsTag;
437 pXMLStream->WriteString(ws, ws.GetLength()); 437 pXMLStream->WriteString(ws.c_str(), ws.GetLength());
438 CFX_WideStringArray& attributes = ((CFDE_XMLElement*)pNode)->m_Attributes; 438 CFX_WideStringArray& attributes = ((CFDE_XMLElement*)pNode)->m_Attributes;
439 int32_t iCount = attributes.GetSize(); 439 int32_t iCount = attributes.GetSize();
440 CFX_WideString wsValue; 440 CFX_WideString wsValue;
441 for (int32_t i = 0; i < iCount; i += 2) { 441 for (int32_t i = 0; i < iCount; i += 2) {
442 ws = L" "; 442 ws = L" ";
443 ws += attributes[i]; 443 ws += attributes[i];
444 ws += L"=\""; 444 ws += L"=\"";
445 wsValue = attributes[i + 1]; 445 wsValue = attributes[i + 1];
446 wsValue.Replace(L"&", L"&amp;"); 446 wsValue.Replace(L"&", L"&amp;");
447 wsValue.Replace(L"<", L"&lt;"); 447 wsValue.Replace(L"<", L"&lt;");
448 wsValue.Replace(L">", L"&gt;"); 448 wsValue.Replace(L">", L"&gt;");
449 wsValue.Replace(L"\'", L"&apos;"); 449 wsValue.Replace(L"\'", L"&apos;");
450 wsValue.Replace(L"\"", L"&quot;"); 450 wsValue.Replace(L"\"", L"&quot;");
451 ws += wsValue; 451 ws += wsValue;
452 ws += L"\""; 452 ws += L"\"";
453 pXMLStream->WriteString(ws, ws.GetLength()); 453 pXMLStream->WriteString(ws.c_str(), ws.GetLength());
454 } 454 }
455 if (pNode->m_pChild == NULL) { 455 if (pNode->m_pChild == NULL) {
456 ws = L"\n/>"; 456 ws = L"\n/>";
457 pXMLStream->WriteString(ws, ws.GetLength()); 457 pXMLStream->WriteString(ws.c_str(), ws.GetLength());
458 } else { 458 } else {
459 ws = L"\n>"; 459 ws = L"\n>";
460 pXMLStream->WriteString(ws, ws.GetLength()); 460 pXMLStream->WriteString(ws.c_str(), ws.GetLength());
461 CFDE_XMLNode* pChild = pNode->m_pChild; 461 CFDE_XMLNode* pChild = pNode->m_pChild;
462 while (pChild != NULL) { 462 while (pChild != NULL) {
463 pChild->SaveXMLNode(pXMLStream); 463 pChild->SaveXMLNode(pXMLStream);
464 pChild = pChild->m_pNext; 464 pChild = pChild->m_pNext;
465 } 465 }
466 ws = L"</"; 466 ws = L"</";
467 ws += ((CFDE_XMLElement*)pNode)->m_wsTag; 467 ws += ((CFDE_XMLElement*)pNode)->m_wsTag;
468 ws += L"\n>"; 468 ws += L"\n>";
469 pXMLStream->WriteString(ws, ws.GetLength()); 469 pXMLStream->WriteString(ws.c_str(), ws.GetLength());
470 } 470 }
471 } break; 471 } break;
472 case FDE_XMLNODE_Text: { 472 case FDE_XMLNODE_Text: {
473 CFX_WideString ws = ((CFDE_XMLText*)pNode)->m_wsText; 473 CFX_WideString ws = ((CFDE_XMLText*)pNode)->m_wsText;
474 ws.Replace(L"&", L"&amp;"); 474 ws.Replace(L"&", L"&amp;");
475 ws.Replace(L"<", L"&lt;"); 475 ws.Replace(L"<", L"&lt;");
476 ws.Replace(L">", L"&gt;"); 476 ws.Replace(L">", L"&gt;");
477 ws.Replace(L"\'", L"&apos;"); 477 ws.Replace(L"\'", L"&apos;");
478 ws.Replace(L"\"", L"&quot;"); 478 ws.Replace(L"\"", L"&quot;");
479 pXMLStream->WriteString(ws, ws.GetLength()); 479 pXMLStream->WriteString(ws.c_str(), ws.GetLength());
480 } break; 480 } break;
481 case FDE_XMLNODE_CharData: { 481 case FDE_XMLNODE_CharData: {
482 CFX_WideString ws = L"<![CDATA["; 482 CFX_WideString ws = L"<![CDATA[";
483 ws += ((CFDE_XMLCharData*)pNode)->m_wsCharData; 483 ws += ((CFDE_XMLCharData*)pNode)->m_wsCharData;
484 ws += L"]]>"; 484 ws += L"]]>";
485 pXMLStream->WriteString(ws, ws.GetLength()); 485 pXMLStream->WriteString(ws.c_str(), ws.GetLength());
486 } break; 486 } break;
487 case FDE_XMLNODE_Unknown: 487 case FDE_XMLNODE_Unknown:
488 break; 488 break;
489 default: 489 default:
490 break; 490 break;
491 } 491 }
492 } 492 }
493 void CFDE_XMLNode::CloneChildren(CFDE_XMLNode* pClone) { 493 void CFDE_XMLNode::CloneChildren(CFDE_XMLNode* pClone) {
494 if (!m_pChild) { 494 if (!m_pChild) {
495 return; 495 return;
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
573 } 573 }
574 } 574 }
575 m_Attributes.Add(wsAttriName); 575 m_Attributes.Add(wsAttriName);
576 m_Attributes.Add(wsAttriValue); 576 m_Attributes.Add(wsAttriValue);
577 } 577 }
578 int32_t CFDE_XMLInstruction::GetInteger(const FX_WCHAR* pwsAttriName, 578 int32_t CFDE_XMLInstruction::GetInteger(const FX_WCHAR* pwsAttriName,
579 int32_t iDefValue) const { 579 int32_t iDefValue) const {
580 int32_t iCount = m_Attributes.GetSize(); 580 int32_t iCount = m_Attributes.GetSize();
581 for (int32_t i = 0; i < iCount; i += 2) { 581 for (int32_t i = 0; i < iCount; i += 2) {
582 if (m_Attributes[i].Compare(pwsAttriName) == 0) { 582 if (m_Attributes[i].Compare(pwsAttriName) == 0) {
583 return FXSYS_wtoi((const FX_WCHAR*)m_Attributes[i + 1]); 583 return FXSYS_wtoi(m_Attributes[i + 1].c_str());
584 } 584 }
585 } 585 }
586 return iDefValue; 586 return iDefValue;
587 } 587 }
588 void CFDE_XMLInstruction::SetInteger(const FX_WCHAR* pwsAttriName, 588 void CFDE_XMLInstruction::SetInteger(const FX_WCHAR* pwsAttriName,
589 int32_t iAttriValue) { 589 int32_t iAttriValue) {
590 CFX_WideString wsValue; 590 CFX_WideString wsValue;
591 wsValue.Format(L"%d", iAttriValue); 591 wsValue.Format(L"%d", iAttriValue);
592 SetString(pwsAttriName, wsValue); 592 SetString(pwsAttriName, wsValue);
593 } 593 }
594 FX_FLOAT CFDE_XMLInstruction::GetFloat(const FX_WCHAR* pwsAttriName, 594 FX_FLOAT CFDE_XMLInstruction::GetFloat(const FX_WCHAR* pwsAttriName,
595 FX_FLOAT fDefValue) const { 595 FX_FLOAT fDefValue) const {
596 int32_t iCount = m_Attributes.GetSize(); 596 int32_t iCount = m_Attributes.GetSize();
597 for (int32_t i = 0; i < iCount; i += 2) { 597 for (int32_t i = 0; i < iCount; i += 2) {
598 if (m_Attributes[i].Compare(pwsAttriName) == 0) { 598 if (m_Attributes[i].Compare(pwsAttriName) == 0) {
599 return FX_wcstof((const FX_WCHAR*)m_Attributes[i + 1]); 599 return FX_wcstof(m_Attributes[i + 1].c_str());
600 } 600 }
601 } 601 }
602 return fDefValue; 602 return fDefValue;
603 } 603 }
604 void CFDE_XMLInstruction::SetFloat(const FX_WCHAR* pwsAttriName, 604 void CFDE_XMLInstruction::SetFloat(const FX_WCHAR* pwsAttriName,
605 FX_FLOAT fAttriValue) { 605 FX_FLOAT fAttriValue) {
606 CFX_WideString wsValue; 606 CFX_WideString wsValue;
607 wsValue.Format(L"%f", fAttriValue); 607 wsValue.Format(L"%f", fAttriValue);
608 SetString(pwsAttriName, wsValue); 608 SetString(pwsAttriName, wsValue);
609 } 609 }
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
693 wsAttri += L":"; 693 wsAttri += L":";
694 wsAttri += wsPrefix; 694 wsAttri += wsPrefix;
695 } 695 }
696 wsNamespace.Empty(); 696 wsNamespace.Empty();
697 CFDE_XMLNode* pNode = (CFDE_XMLNode*)this; 697 CFDE_XMLNode* pNode = (CFDE_XMLNode*)this;
698 while (pNode != NULL) { 698 while (pNode != NULL) {
699 if (pNode->GetType() != FDE_XMLNODE_Element) { 699 if (pNode->GetType() != FDE_XMLNODE_Element) {
700 break; 700 break;
701 } 701 }
702 CFDE_XMLElement* pElement = (CFDE_XMLElement*)pNode; 702 CFDE_XMLElement* pElement = (CFDE_XMLElement*)pNode;
703 if (!pElement->HasAttribute(wsAttri)) { 703 if (!pElement->HasAttribute(wsAttri.c_str())) {
704 pNode = pNode->GetNodeItem(CFDE_XMLNode::Parent); 704 pNode = pNode->GetNodeItem(CFDE_XMLNode::Parent);
705 continue; 705 continue;
706 } 706 }
707 pElement->GetString(wsAttri, wsNamespace); 707 pElement->GetString(wsAttri.c_str(), wsNamespace);
708 break; 708 break;
709 } 709 }
710 } 710 }
711 int32_t CFDE_XMLElement::CountAttributes() const { 711 int32_t CFDE_XMLElement::CountAttributes() const {
712 return m_Attributes.GetSize() / 2; 712 return m_Attributes.GetSize() / 2;
713 } 713 }
714 FX_BOOL CFDE_XMLElement::GetAttribute(int32_t index, 714 FX_BOOL CFDE_XMLElement::GetAttribute(int32_t index,
715 CFX_WideString& wsAttriName, 715 CFX_WideString& wsAttriName,
716 CFX_WideString& wsAttriValue) const { 716 CFX_WideString& wsAttriValue) const {
717 int32_t iCount = m_Attributes.GetSize(); 717 int32_t iCount = m_Attributes.GetSize();
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
759 } 759 }
760 } 760 }
761 m_Attributes.Add(wsAttriName); 761 m_Attributes.Add(wsAttriName);
762 m_Attributes.Add(wsAttriValue); 762 m_Attributes.Add(wsAttriValue);
763 } 763 }
764 int32_t CFDE_XMLElement::GetInteger(const FX_WCHAR* pwsAttriName, 764 int32_t CFDE_XMLElement::GetInteger(const FX_WCHAR* pwsAttriName,
765 int32_t iDefValue) const { 765 int32_t iDefValue) const {
766 int32_t iCount = m_Attributes.GetSize(); 766 int32_t iCount = m_Attributes.GetSize();
767 for (int32_t i = 0; i < iCount; i += 2) { 767 for (int32_t i = 0; i < iCount; i += 2) {
768 if (m_Attributes[i].Compare(pwsAttriName) == 0) { 768 if (m_Attributes[i].Compare(pwsAttriName) == 0) {
769 return FXSYS_wtoi((const FX_WCHAR*)m_Attributes[i + 1]); 769 return FXSYS_wtoi(m_Attributes[i + 1].c_str());
770 } 770 }
771 } 771 }
772 return iDefValue; 772 return iDefValue;
773 } 773 }
774 void CFDE_XMLElement::SetInteger(const FX_WCHAR* pwsAttriName, 774 void CFDE_XMLElement::SetInteger(const FX_WCHAR* pwsAttriName,
775 int32_t iAttriValue) { 775 int32_t iAttriValue) {
776 CFX_WideString wsValue; 776 CFX_WideString wsValue;
777 wsValue.Format(L"%d", iAttriValue); 777 wsValue.Format(L"%d", iAttriValue);
778 SetString(pwsAttriName, wsValue); 778 SetString(pwsAttriName, wsValue);
779 } 779 }
780 FX_FLOAT CFDE_XMLElement::GetFloat(const FX_WCHAR* pwsAttriName, 780 FX_FLOAT CFDE_XMLElement::GetFloat(const FX_WCHAR* pwsAttriName,
781 FX_FLOAT fDefValue) const { 781 FX_FLOAT fDefValue) const {
782 int32_t iCount = m_Attributes.GetSize(); 782 int32_t iCount = m_Attributes.GetSize();
783 for (int32_t i = 0; i < iCount; i += 2) { 783 for (int32_t i = 0; i < iCount; i += 2) {
784 if (m_Attributes[i].Compare(pwsAttriName) == 0) { 784 if (m_Attributes[i].Compare(pwsAttriName) == 0) {
785 return FX_wcstof((const FX_WCHAR*)m_Attributes[i + 1]); 785 return FX_wcstof(m_Attributes[i + 1].c_str());
786 } 786 }
787 } 787 }
788 return fDefValue; 788 return fDefValue;
789 } 789 }
790 void CFDE_XMLElement::SetFloat(const FX_WCHAR* pwsAttriName, 790 void CFDE_XMLElement::SetFloat(const FX_WCHAR* pwsAttriName,
791 FX_FLOAT fAttriValue) { 791 FX_FLOAT fAttriValue) {
792 CFX_WideString wsValue; 792 CFX_WideString wsValue;
793 wsValue.Format(L"%f", fAttriValue); 793 wsValue.Format(L"%f", fAttriValue);
794 SetString(pwsAttriName, wsValue); 794 SetString(pwsAttriName, wsValue);
795 } 795 }
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
948 ws = L"<?xml version=\"1.0\" encoding=\""; 948 ws = L"<?xml version=\"1.0\" encoding=\"";
949 uint16_t wCodePage = pXMLStream->GetCodePage(); 949 uint16_t wCodePage = pXMLStream->GetCodePage();
950 if (wCodePage == FX_CODEPAGE_UTF16LE) { 950 if (wCodePage == FX_CODEPAGE_UTF16LE) {
951 ws += L"UTF-16"; 951 ws += L"UTF-16";
952 } else if (wCodePage == FX_CODEPAGE_UTF16BE) { 952 } else if (wCodePage == FX_CODEPAGE_UTF16BE) {
953 ws += L"UTF-16be"; 953 ws += L"UTF-16be";
954 } else { 954 } else {
955 ws += L"UTF-8"; 955 ws += L"UTF-8";
956 } 956 }
957 ws += L"\"?>"; 957 ws += L"\"?>";
958 pXMLStream->WriteString(ws, ws.GetLength()); 958 pXMLStream->WriteString(ws.c_str(), ws.GetLength());
959 } else { 959 } else {
960 ws.Format(L"<?%s", (const FX_WCHAR*)pInstruction->m_wsTarget); 960 ws.Format(L"<?%s", pInstruction->m_wsTarget.c_str());
961 pXMLStream->WriteString(ws, ws.GetLength()); 961 pXMLStream->WriteString(ws.c_str(), ws.GetLength());
962 CFX_WideStringArray& attributes = pInstruction->m_Attributes; 962 CFX_WideStringArray& attributes = pInstruction->m_Attributes;
963 int32_t i, iCount = attributes.GetSize(); 963 int32_t i, iCount = attributes.GetSize();
964 CFX_WideString wsValue; 964 CFX_WideString wsValue;
965 for (i = 0; i < iCount; i += 2) { 965 for (i = 0; i < iCount; i += 2) {
966 ws = L" "; 966 ws = L" ";
967 ws += attributes[i]; 967 ws += attributes[i];
968 ws += L"=\""; 968 ws += L"=\"";
969 wsValue = attributes[i + 1]; 969 wsValue = attributes[i + 1];
970 wsValue.Replace(L"&", L"&amp;"); 970 wsValue.Replace(L"&", L"&amp;");
971 wsValue.Replace(L"<", L"&lt;"); 971 wsValue.Replace(L"<", L"&lt;");
972 wsValue.Replace(L">", L"&gt;"); 972 wsValue.Replace(L">", L"&gt;");
973 wsValue.Replace(L"\'", L"&apos;"); 973 wsValue.Replace(L"\'", L"&apos;");
974 wsValue.Replace(L"\"", L"&quot;"); 974 wsValue.Replace(L"\"", L"&quot;");
975 ws += wsValue; 975 ws += wsValue;
976 ws += L"\""; 976 ws += L"\"";
977 pXMLStream->WriteString(ws, ws.GetLength()); 977 pXMLStream->WriteString(ws.c_str(), ws.GetLength());
978 } 978 }
979 CFX_WideStringArray& targetdata = pInstruction->m_TargetData; 979 CFX_WideStringArray& targetdata = pInstruction->m_TargetData;
980 iCount = targetdata.GetSize(); 980 iCount = targetdata.GetSize();
981 for (i = 0; i < iCount; i++) { 981 for (i = 0; i < iCount; i++) {
982 ws = L" \""; 982 ws = L" \"";
983 ws += targetdata[i]; 983 ws += targetdata[i];
984 ws += L"\""; 984 ws += L"\"";
985 pXMLStream->WriteString(ws, ws.GetLength()); 985 pXMLStream->WriteString(ws.c_str(), ws.GetLength());
986 } 986 }
987 ws = L"?>"; 987 ws = L"?>";
988 pXMLStream->WriteString(ws, ws.GetLength()); 988 pXMLStream->WriteString(ws.c_str(), ws.GetLength());
989 } 989 }
990 } break; 990 } break;
991 case FDE_XMLNODE_Element: { 991 case FDE_XMLNODE_Element: {
992 CFX_WideString ws; 992 CFX_WideString ws;
993 ws = L"<"; 993 ws = L"<";
994 ws += ((CFDE_XMLElement*)pNode)->m_wsTag; 994 ws += ((CFDE_XMLElement*)pNode)->m_wsTag;
995 pXMLStream->WriteString(ws, ws.GetLength()); 995 pXMLStream->WriteString(ws.c_str(), ws.GetLength());
996 CFX_WideStringArray& attributes = ((CFDE_XMLElement*)pNode)->m_Attributes; 996 CFX_WideStringArray& attributes = ((CFDE_XMLElement*)pNode)->m_Attributes;
997 int32_t iCount = attributes.GetSize(); 997 int32_t iCount = attributes.GetSize();
998 CFX_WideString wsValue; 998 CFX_WideString wsValue;
999 for (int32_t i = 0; i < iCount; i += 2) { 999 for (int32_t i = 0; i < iCount; i += 2) {
1000 ws = L" "; 1000 ws = L" ";
1001 ws += attributes[i]; 1001 ws += attributes[i];
1002 ws += L"=\""; 1002 ws += L"=\"";
1003 wsValue = attributes[i + 1]; 1003 wsValue = attributes[i + 1];
1004 wsValue.Replace(L"&", L"&amp;"); 1004 wsValue.Replace(L"&", L"&amp;");
1005 wsValue.Replace(L"<", L"&lt;"); 1005 wsValue.Replace(L"<", L"&lt;");
1006 wsValue.Replace(L">", L"&gt;"); 1006 wsValue.Replace(L">", L"&gt;");
1007 wsValue.Replace(L"\'", L"&apos;"); 1007 wsValue.Replace(L"\'", L"&apos;");
1008 wsValue.Replace(L"\"", L"&quot;"); 1008 wsValue.Replace(L"\"", L"&quot;");
1009 ws += wsValue; 1009 ws += wsValue;
1010 ws += L"\""; 1010 ws += L"\"";
1011 pXMLStream->WriteString(ws, ws.GetLength()); 1011 pXMLStream->WriteString(ws.c_str(), ws.GetLength());
1012 } 1012 }
1013 if (pNode->m_pChild == NULL) { 1013 if (pNode->m_pChild == NULL) {
1014 ws = L"\n/>"; 1014 ws = L"\n/>";
1015 pXMLStream->WriteString(ws, ws.GetLength()); 1015 pXMLStream->WriteString(ws.c_str(), ws.GetLength());
1016 } else { 1016 } else {
1017 ws = L"\n>"; 1017 ws = L"\n>";
1018 pXMLStream->WriteString(ws, ws.GetLength()); 1018 pXMLStream->WriteString(ws.c_str(), ws.GetLength());
1019 CFDE_XMLNode* pChild = pNode->m_pChild; 1019 CFDE_XMLNode* pChild = pNode->m_pChild;
1020 while (pChild != NULL) { 1020 while (pChild != NULL) {
1021 SaveXMLNode(pXMLStream, static_cast<CFDE_XMLNode*>(pChild)); 1021 SaveXMLNode(pXMLStream, static_cast<CFDE_XMLNode*>(pChild));
1022 pChild = pChild->m_pNext; 1022 pChild = pChild->m_pNext;
1023 } 1023 }
1024 ws = L"</"; 1024 ws = L"</";
1025 ws += ((CFDE_XMLElement*)pNode)->m_wsTag; 1025 ws += ((CFDE_XMLElement*)pNode)->m_wsTag;
1026 ws += L"\n>"; 1026 ws += L"\n>";
1027 pXMLStream->WriteString(ws, ws.GetLength()); 1027 pXMLStream->WriteString(ws.c_str(), ws.GetLength());
1028 } 1028 }
1029 } break; 1029 } break;
1030 case FDE_XMLNODE_Text: { 1030 case FDE_XMLNODE_Text: {
1031 CFX_WideString ws = ((CFDE_XMLText*)pNode)->m_wsText; 1031 CFX_WideString ws = ((CFDE_XMLText*)pNode)->m_wsText;
1032 ws.Replace(L"&", L"&amp;"); 1032 ws.Replace(L"&", L"&amp;");
1033 ws.Replace(L"<", L"&lt;"); 1033 ws.Replace(L"<", L"&lt;");
1034 ws.Replace(L">", L"&gt;"); 1034 ws.Replace(L">", L"&gt;");
1035 ws.Replace(L"\'", L"&apos;"); 1035 ws.Replace(L"\'", L"&apos;");
1036 ws.Replace(L"\"", L"&quot;"); 1036 ws.Replace(L"\"", L"&quot;");
1037 pXMLStream->WriteString(ws, ws.GetLength()); 1037 pXMLStream->WriteString(ws.c_str(), ws.GetLength());
1038 } break; 1038 } break;
1039 case FDE_XMLNODE_CharData: { 1039 case FDE_XMLNODE_CharData: {
1040 CFX_WideString ws = L"<![CDATA["; 1040 CFX_WideString ws = L"<![CDATA[";
1041 ws += ((CFDE_XMLCharData*)pNode)->m_wsCharData; 1041 ws += ((CFDE_XMLCharData*)pNode)->m_wsCharData;
1042 ws += L"]]>"; 1042 ws += L"]]>";
1043 pXMLStream->WriteString(ws, ws.GetLength()); 1043 pXMLStream->WriteString(ws.c_str(), ws.GetLength());
1044 } break; 1044 } break;
1045 case FDE_XMLNODE_Unknown: 1045 case FDE_XMLNODE_Unknown:
1046 break; 1046 break;
1047 default: 1047 default:
1048 break; 1048 break;
1049 } 1049 }
1050 } 1050 }
1051 void CFDE_XMLDoc::SaveXML(IFX_Stream* pXMLStream, FX_BOOL bSaveBOM) { 1051 void CFDE_XMLDoc::SaveXML(IFX_Stream* pXMLStream, FX_BOOL bSaveBOM) {
1052 if (pXMLStream == NULL || pXMLStream == m_pStream) { 1052 if (pXMLStream == NULL || pXMLStream == m_pStream) {
1053 m_pStream->Seek(FX_STREAMSEEK_Begin, 0); 1053 m_pStream->Seek(FX_STREAMSEEK_Begin, 0);
(...skipping 1020 matching lines...) Expand 10 before | Expand all | Expand 10 after
2074 m_BlockBuffer.DeleteTextChars(m_iDataLength - m_iEntityStart, FALSE); 2074 m_BlockBuffer.DeleteTextChars(m_iDataLength - m_iEntityStart, FALSE);
2075 m_pCurrentBlock = m_BlockBuffer.GetAvailableBlock(m_iIndexInBlock); 2075 m_pCurrentBlock = m_BlockBuffer.GetAvailableBlock(m_iIndexInBlock);
2076 m_iEntityStart = -1; 2076 m_iEntityStart = -1;
2077 } else { 2077 } else {
2078 if (m_iEntityStart < 0 && ch == L'&') { 2078 if (m_iEntityStart < 0 && ch == L'&') {
2079 m_iEntityStart = m_iDataLength - 1; 2079 m_iEntityStart = m_iDataLength - 1;
2080 } 2080 }
2081 } 2081 }
2082 m_pStart++; 2082 m_pStart++;
2083 } 2083 }
OLDNEW
« no previous file with comments | « xfa/fde/tto/fde_textout.cpp ('k') | xfa/fee/fde_txtedtengine.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698