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

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

Issue 1821043003: Remove FX_WORD in favor of uint16_t. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Use stdint.h directly, bitfield minefield. Created 4 years, 9 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/css/fde_csssyntax.cpp ('k') | xfa/fee/fx_wordbreak/fx_wordbreak_impl.h » ('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 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 } 381 }
382 void CFDE_XMLNode::SaveXMLNode(IFX_Stream* pXMLStream) { 382 void CFDE_XMLNode::SaveXMLNode(IFX_Stream* pXMLStream) {
383 CFDE_XMLNode* pNode = (CFDE_XMLNode*)this; 383 CFDE_XMLNode* pNode = (CFDE_XMLNode*)this;
384 FXSYS_assert(pXMLStream != NULL && pNode != NULL); 384 FXSYS_assert(pXMLStream != NULL && pNode != NULL);
385 switch (pNode->GetType()) { 385 switch (pNode->GetType()) {
386 case FDE_XMLNODE_Instruction: { 386 case FDE_XMLNODE_Instruction: {
387 CFX_WideString ws; 387 CFX_WideString ws;
388 CFDE_XMLInstruction* pInstruction = (CFDE_XMLInstruction*)pNode; 388 CFDE_XMLInstruction* pInstruction = (CFDE_XMLInstruction*)pNode;
389 if (pInstruction->m_wsTarget.CompareNoCase(L"xml") == 0) { 389 if (pInstruction->m_wsTarget.CompareNoCase(L"xml") == 0) {
390 ws = L"<?xml version=\"1.0\" encoding=\""; 390 ws = L"<?xml version=\"1.0\" encoding=\"";
391 FX_WORD 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, ws.GetLength());
401 } else { 401 } else {
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after
907 } 907 }
908 iTextDataSize = iTextDataSize / 128; 908 iTextDataSize = iTextDataSize / 128;
909 if (iTextDataSize < 1) { 909 if (iTextDataSize < 1) {
910 iTextDataSize = 1; 910 iTextDataSize = 1;
911 } 911 }
912 iTextDataSize *= 128; 912 iTextDataSize *= 128;
913 if (iTextDataSize < 128) { 913 if (iTextDataSize < 128) {
914 iTextDataSize = 128; 914 iTextDataSize = 128;
915 } 915 }
916 m_pStream = pXMLStream; 916 m_pStream = pXMLStream;
917 FX_WORD wCodePage = m_pStream->GetCodePage(); 917 uint16_t wCodePage = m_pStream->GetCodePage();
918 if (wCodePage != FX_CODEPAGE_UTF16LE && wCodePage != FX_CODEPAGE_UTF16BE && 918 if (wCodePage != FX_CODEPAGE_UTF16LE && wCodePage != FX_CODEPAGE_UTF16BE &&
919 wCodePage != FX_CODEPAGE_UTF8) { 919 wCodePage != FX_CODEPAGE_UTF8) {
920 m_pStream->SetCodePage(FX_CODEPAGE_UTF8); 920 m_pStream->SetCodePage(FX_CODEPAGE_UTF8);
921 } 921 }
922 m_pSyntaxParser = IFDE_XMLSyntaxParser::Create(); 922 m_pSyntaxParser = IFDE_XMLSyntaxParser::Create();
923 if (m_pSyntaxParser == NULL) { 923 if (m_pSyntaxParser == NULL) {
924 return FALSE; 924 return FALSE;
925 } 925 }
926 m_pSyntaxParser->Init(m_pStream, iXMLPlaneSize, iTextDataSize); 926 m_pSyntaxParser->Init(m_pStream, iXMLPlaneSize, iTextDataSize);
927 if (pHandler == NULL) { 927 if (pHandler == NULL) {
(...skipping 23 matching lines...) Expand all
951 } 951 }
952 void CFDE_XMLDoc::SaveXMLNode(IFX_Stream* pXMLStream, IFDE_XMLNode* pINode) { 952 void CFDE_XMLDoc::SaveXMLNode(IFX_Stream* pXMLStream, IFDE_XMLNode* pINode) {
953 CFDE_XMLNode* pNode = (CFDE_XMLNode*)pINode; 953 CFDE_XMLNode* pNode = (CFDE_XMLNode*)pINode;
954 FXSYS_assert(pXMLStream != NULL && pNode != NULL); 954 FXSYS_assert(pXMLStream != NULL && pNode != NULL);
955 switch (pNode->GetType()) { 955 switch (pNode->GetType()) {
956 case FDE_XMLNODE_Instruction: { 956 case FDE_XMLNODE_Instruction: {
957 CFX_WideString ws; 957 CFX_WideString ws;
958 CFDE_XMLInstruction* pInstruction = (CFDE_XMLInstruction*)pNode; 958 CFDE_XMLInstruction* pInstruction = (CFDE_XMLInstruction*)pNode;
959 if (pInstruction->m_wsTarget.CompareNoCase(L"xml") == 0) { 959 if (pInstruction->m_wsTarget.CompareNoCase(L"xml") == 0) {
960 ws = L"<?xml version=\"1.0\" encoding=\""; 960 ws = L"<?xml version=\"1.0\" encoding=\"";
961 FX_WORD wCodePage = pXMLStream->GetCodePage(); 961 uint16_t wCodePage = pXMLStream->GetCodePage();
962 if (wCodePage == FX_CODEPAGE_UTF16LE) { 962 if (wCodePage == FX_CODEPAGE_UTF16LE) {
963 ws += L"UTF-16"; 963 ws += L"UTF-16";
964 } else if (wCodePage == FX_CODEPAGE_UTF16BE) { 964 } else if (wCodePage == FX_CODEPAGE_UTF16BE) {
965 ws += L"UTF-16be"; 965 ws += L"UTF-16be";
966 } else { 966 } else {
967 ws += L"UTF-8"; 967 ws += L"UTF-8";
968 } 968 }
969 ws += L"\"?>"; 969 ws += L"\"?>";
970 pXMLStream->WriteString(ws, ws.GetLength()); 970 pXMLStream->WriteString(ws, ws.GetLength());
971 } else { 971 } else {
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
1060 break; 1060 break;
1061 } 1061 }
1062 } 1062 }
1063 void CFDE_XMLDoc::SaveXML(IFX_Stream* pXMLStream, FX_BOOL bSaveBOM) { 1063 void CFDE_XMLDoc::SaveXML(IFX_Stream* pXMLStream, FX_BOOL bSaveBOM) {
1064 if (pXMLStream == NULL || pXMLStream == m_pStream) { 1064 if (pXMLStream == NULL || pXMLStream == m_pStream) {
1065 m_pStream->Seek(FX_STREAMSEEK_Begin, 0); 1065 m_pStream->Seek(FX_STREAMSEEK_Begin, 0);
1066 pXMLStream = m_pStream; 1066 pXMLStream = m_pStream;
1067 } 1067 }
1068 FXSYS_assert((pXMLStream->GetAccessModes() & FX_STREAMACCESS_Text) != 0); 1068 FXSYS_assert((pXMLStream->GetAccessModes() & FX_STREAMACCESS_Text) != 0);
1069 FXSYS_assert((pXMLStream->GetAccessModes() & FX_STREAMACCESS_Write) != 0); 1069 FXSYS_assert((pXMLStream->GetAccessModes() & FX_STREAMACCESS_Write) != 0);
1070 FX_WORD wCodePage = pXMLStream->GetCodePage(); 1070 uint16_t wCodePage = pXMLStream->GetCodePage();
1071 if (wCodePage != FX_CODEPAGE_UTF16LE && wCodePage != FX_CODEPAGE_UTF16BE && 1071 if (wCodePage != FX_CODEPAGE_UTF16LE && wCodePage != FX_CODEPAGE_UTF16BE &&
1072 wCodePage != FX_CODEPAGE_UTF8) { 1072 wCodePage != FX_CODEPAGE_UTF8) {
1073 wCodePage = FX_CODEPAGE_UTF8; 1073 wCodePage = FX_CODEPAGE_UTF8;
1074 pXMLStream->SetCodePage(wCodePage); 1074 pXMLStream->SetCodePage(wCodePage);
1075 } 1075 }
1076 if (bSaveBOM) { 1076 if (bSaveBOM) {
1077 pXMLStream->WriteString(L"\xFEFF", 1); 1077 pXMLStream->WriteString(L"\xFEFF", 1);
1078 } 1078 }
1079 CFDE_XMLNode* pNode = m_pRoot->m_pChild; 1079 CFDE_XMLNode* pNode = m_pRoot->m_pChild;
1080 while (pNode != NULL) { 1080 while (pNode != NULL) {
(...skipping 1009 matching lines...) Expand 10 before | Expand all | Expand 10 after
2090 m_BlockBuffer.DeleteTextChars(m_iDataLength - m_iEntityStart, FALSE); 2090 m_BlockBuffer.DeleteTextChars(m_iDataLength - m_iEntityStart, FALSE);
2091 m_pCurrentBlock = m_BlockBuffer.GetAvailableBlock(m_iIndexInBlock); 2091 m_pCurrentBlock = m_BlockBuffer.GetAvailableBlock(m_iIndexInBlock);
2092 m_iEntityStart = -1; 2092 m_iEntityStart = -1;
2093 } else { 2093 } else {
2094 if (m_iEntityStart < 0 && ch == L'&') { 2094 if (m_iEntityStart < 0 && ch == L'&') {
2095 m_iEntityStart = m_iDataLength - 1; 2095 m_iEntityStart = m_iDataLength - 1;
2096 } 2096 }
2097 } 2097 }
2098 m_pStart++; 2098 m_pStart++;
2099 } 2099 }
OLDNEW
« no previous file with comments | « xfa/fde/css/fde_csssyntax.cpp ('k') | xfa/fee/fx_wordbreak/fx_wordbreak_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698