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

Unified Diff: xfa/src/fxfa/src/parser/xfa_object_imp.cpp

Issue 1672153002: Tidy fpdfsave.cpp (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
« fpdfsdk/src/fpdfsave.cpp ('K') | « xfa/src/fxfa/src/app/xfa_ffdoc.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: xfa/src/fxfa/src/parser/xfa_object_imp.cpp
diff --git a/xfa/src/fxfa/src/parser/xfa_object_imp.cpp b/xfa/src/fxfa/src/parser/xfa_object_imp.cpp
index 10d5e24abf29cb85b78a2619724822ed53b86d46..278ad85324611f7f2d608998bbaa6b083f852a4a 100644
--- a/xfa/src/fxfa/src/parser/xfa_object_imp.cpp
+++ b/xfa/src/fxfa/src/parser/xfa_object_imp.cpp
@@ -1056,6 +1056,7 @@ void CXFA_Node::Script_NodeClass_LoadXML(CFXJSE_Arguments* pArguments) {
}
void CXFA_Node::Script_NodeClass_SaveFilteredXML(CFXJSE_Arguments* pArguments) {
}
+
void CXFA_Node::Script_NodeClass_SaveXML(CFXJSE_Arguments* pArguments) {
int32_t iLength = pArguments->GetLength();
if (iLength < 0 || iLength > 1) {
@@ -1065,20 +1066,15 @@ void CXFA_Node::Script_NodeClass_SaveXML(CFXJSE_Arguments* pArguments) {
FX_BOOL bPrettyMode = FALSE;
if (iLength == 1) {
CFX_ByteString bsPretty = pArguments->GetUTF8String(0);
- if (bsPretty.Equal("pretty")) {
- bPrettyMode = TRUE;
- } else {
+ if (!bsPretty.Equal("pretty")) {
ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH);
return;
}
+ bPrettyMode = TRUE;
}
CFX_ByteStringC bsXMLHeader = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
if (GetPacketID() == XFA_XDPPACKET_Form) {
IFX_MemoryStream* pMemoryStream = FX_CreateMemoryStream(TRUE);
- if (!pMemoryStream) {
- FXJSE_Value_SetUTF8String(pArguments->GetReturnValue(), bsXMLHeader);
- return;
- }
IFX_Stream* pStream = IFX_Stream::CreateStream(
(IFX_FileWrite*)pMemoryStream,
FX_STREAMACCESS_Text | FX_STREAMACCESS_Write | FX_STREAMACCESS_Append);
@@ -1101,7 +1097,8 @@ void CXFA_Node::Script_NodeClass_SaveXML(CFXJSE_Arguments* pArguments) {
pMemoryStream = NULL;
}
return;
- } else if (GetPacketID() == XFA_XDPPACKET_Datasets) {
+ }
+ if (GetPacketID() == XFA_XDPPACKET_Datasets) {
IFDE_XMLNode* pElement = this->GetXMLMappingNode();
if (!pElement || pElement->GetType() != FDE_XMLNODE_Element) {
FXJSE_Value_SetUTF8String(pArguments->GetReturnValue(), bsXMLHeader);
@@ -1109,35 +1106,28 @@ void CXFA_Node::Script_NodeClass_SaveXML(CFXJSE_Arguments* pArguments) {
}
XFA_DataExporter_DealWithDataGroupNode(this);
IFX_MemoryStream* pMemoryStream = FX_CreateMemoryStream(TRUE);
- if (!pMemoryStream) {
- FXJSE_Value_SetUTF8String(pArguments->GetReturnValue(), bsXMLHeader);
- return;
+ IFX_Stream* pStream = IFX_Stream::CreateStream(
+ (IFX_FileWrite*)pMemoryStream,
+ FX_STREAMACCESS_Text | FX_STREAMACCESS_Write | FX_STREAMACCESS_Append);
+ if (pStream) {
+ pStream->SetCodePage(FX_CODEPAGE_UTF8);
+ pStream->WriteData(bsXMLHeader.GetPtr(), bsXMLHeader.GetLength());
+ pElement->SaveXMLNode(pStream);
+ FXJSE_Value_SetUTF8String(pArguments->GetReturnValue(),
+ CFX_ByteStringC(pMemoryStream->GetBuffer(),
+ pMemoryStream->GetSize()));
+ pStream->Release();
+ pStream = NULL;
}
if (pMemoryStream) {
Tom Sepez 2016/02/05 22:49:45 Good thing we test the complement of line 1112 ...
- IFX_Stream* pStream = IFX_Stream::CreateStream(
- (IFX_FileWrite*)pMemoryStream, FX_STREAMACCESS_Text |
- FX_STREAMACCESS_Write |
- FX_STREAMACCESS_Append);
- if (pStream) {
- pStream->SetCodePage(FX_CODEPAGE_UTF8);
- pStream->WriteData(bsXMLHeader.GetPtr(), bsXMLHeader.GetLength());
- pElement->SaveXMLNode(pStream);
- FXJSE_Value_SetUTF8String(pArguments->GetReturnValue(),
- CFX_ByteStringC(pMemoryStream->GetBuffer(),
- pMemoryStream->GetSize()));
- pStream->Release();
- pStream = NULL;
- }
- if (pMemoryStream) {
- pMemoryStream->Release();
- pMemoryStream = NULL;
- }
- return;
+ pMemoryStream->Release();
+ pMemoryStream = NULL;
}
- } else {
- FXJSE_Value_SetUTF8String(pArguments->GetReturnValue(), "");
+ return;
}
+ FXJSE_Value_SetUTF8String(pArguments->GetReturnValue(), "");
}
+
void CXFA_Node::Script_NodeClass_SetAttribute(CFXJSE_Arguments* pArguments) {
int32_t iLength = pArguments->GetLength();
if (iLength != 2) {
« fpdfsdk/src/fpdfsave.cpp ('K') | « xfa/src/fxfa/src/app/xfa_ffdoc.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698