diff options
author | dan sinclair <dsinclair@chromium.org> | 2018-04-17 18:23:28 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-04-17 18:23:28 +0000 |
commit | ffdae5fceb4e0b37bc649d99d12c15ccd6ae1b9e (patch) | |
tree | 3a719c2bf12bf2b16f473db9e739e9de15e5fafe /xfa/fxfa/parser/xfa_utils.cpp | |
parent | bc069b7a855998ab28f487d2f09152851dddb16a (diff) | |
download | pdfium-ffdae5fceb4e0b37bc649d99d12c15ccd6ae1b9e.tar.xz |
Use IFX_SeekableStream in xfa_utils
This CL converts xfa_utils to use an IFX_SeekableStream instead of a
CFX_SeekableStreamProxy.
Change-Id: I824b477351ac29d54118df2f3c5442c503aa3671
Reviewed-on: https://pdfium-review.googlesource.com/30852
Commit-Queue: dsinclair <dsinclair@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'xfa/fxfa/parser/xfa_utils.cpp')
-rw-r--r-- | xfa/fxfa/parser/xfa_utils.cpp | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/xfa/fxfa/parser/xfa_utils.cpp b/xfa/fxfa/parser/xfa_utils.cpp index 55baf10229..de0f76b6b4 100644 --- a/xfa/fxfa/parser/xfa_utils.cpp +++ b/xfa/fxfa/parser/xfa_utils.cpp @@ -29,7 +29,7 @@ namespace { -constexpr const wchar_t kFormNS[] = L"http://www.xfa.org/schema/xfa-form/"; +constexpr const char kFormNS[] = "http://www.xfa.org/schema/xfa-form/"; const double fraction_scales[] = {0.1, 0.01, @@ -330,10 +330,9 @@ void RegenerateFormFile_Changed(CXFA_Node* pNode, } } -void RegenerateFormFile_Container( - CXFA_Node* pNode, - const RetainPtr<CFX_SeekableStreamProxy>& pStream, - bool bSaveXML) { +void RegenerateFormFile_Container(CXFA_Node* pNode, + const RetainPtr<IFX_SeekableStream>& pStream, + bool bSaveXML) { XFA_Element eType = pNode->GetElementType(); if (eType == XFA_Element::Field || eType == XFA_Element::Draw || !pNode->IsContainerNode()) { @@ -341,13 +340,13 @@ void RegenerateFormFile_Container( RegenerateFormFile_Changed(pNode, buf, bSaveXML); size_t nLen = buf.GetLength(); if (nLen > 0) - pStream->WriteString(buf.AsStringView()); + pStream->WriteString(buf.MakeString().UTF8Encode().AsStringView()); return; } - WideStringView wsElement(pNode->GetClassName()); - pStream->WriteString(L"<"); - pStream->WriteString(wsElement); + WideString wsElement(pNode->GetClassName()); + pStream->WriteString("<"); + pStream->WriteString(wsElement.UTF8Encode().AsStringView()); WideString wsOutput; SaveAttribute(pNode, XFA_Attribute::Name, L"name", true, wsOutput); @@ -366,21 +365,22 @@ void RegenerateFormFile_Container( } if (!wsOutput.IsEmpty()) - pStream->WriteString(wsOutput.AsStringView()); + pStream->WriteString(wsOutput.UTF8Encode().AsStringView()); CXFA_Node* pChildNode = pNode->GetFirstChild(); - if (pChildNode) { - pStream->WriteString(L"\n>"); - while (pChildNode) { - RegenerateFormFile_Container(pChildNode, pStream, bSaveXML); - pChildNode = pChildNode->GetNextSibling(); - } - pStream->WriteString(L"</"); - pStream->WriteString(wsElement); - pStream->WriteString(L"\n>"); - } else { - pStream->WriteString(L"\n/>"); + if (!pChildNode) { + pStream->WriteString(" />\n"); + return; + } + + pStream->WriteString(">\n"); + while (pChildNode) { + RegenerateFormFile_Container(pChildNode, pStream, bSaveXML); + pChildNode = pChildNode->GetNextSibling(); } + pStream->WriteString("</"); + pStream->WriteString(wsElement.UTF8Encode().AsStringView()); + pStream->WriteString(">\n"); } WideString RecognizeXFAVersionNumber(CXFA_Node* pTemplateRoot) { @@ -515,11 +515,11 @@ void XFA_DataExporter_DealWithDataGroupNode(CXFA_Node* pDataNode) { void XFA_DataExporter_RegenerateFormFile( CXFA_Node* pNode, - const RetainPtr<CFX_SeekableStreamProxy>& pStream, + const RetainPtr<IFX_SeekableStream>& pStream, bool bSaveXML) { if (pNode->IsModelNode()) { - pStream->WriteString(L"<form xmlns=\""); - pStream->WriteString(WideStringView(kFormNS)); + pStream->WriteString("<form xmlns=\""); + pStream->WriteString(kFormNS); WideString wsVersionNumber = RecognizeXFAVersionNumber( ToNode(pNode->GetDocument()->GetXFAObject(XFA_HASHCODE_Template))); @@ -527,14 +527,14 @@ void XFA_DataExporter_RegenerateFormFile( wsVersionNumber = L"2.8"; wsVersionNumber += L"/\"\n>"; - pStream->WriteString(wsVersionNumber.AsStringView()); + pStream->WriteString(wsVersionNumber.UTF8Encode().AsStringView()); CXFA_Node* pChildNode = pNode->GetFirstChild(); while (pChildNode) { RegenerateFormFile_Container(pChildNode, pStream, false); pChildNode = pChildNode->GetNextSibling(); } - pStream->WriteString(L"</form\n>"); + pStream->WriteString("</form\n>"); } else { RegenerateFormFile_Container(pNode, pStream, bSaveXML); } |