summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHenrique Nakashima <hnakashima@chromium.org>2017-07-05 16:21:17 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-07-05 21:37:14 +0000
commit0ba3c6da16d4e90f0ad1fc9f326bf863860c0470 (patch)
treec627bbd82ca85988ec3e043d6a6e9cc9e0424400
parent0fdd1aea658bc65e4d136c58818451b9ddad00e0 (diff)
downloadpdfium-0ba3c6da16d4e90f0ad1fc9f326bf863860c0470.tar.xz
Converting CFX_ByteTextBuf to ostringstream in fpdfedittext.cpp.
Bug: pdfium:731 Change-Id: I8005ca2c2d4a65ad2197ba6f71ee37f1c1e5b5d8 Reviewed-on: https://pdfium-review.googlesource.com/6833 Reviewed-by: Nicolás Peña <npm@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
-rw-r--r--fpdfsdk/fpdfedittext.cpp18
1 files changed, 8 insertions, 10 deletions
diff --git a/fpdfsdk/fpdfedittext.cpp b/fpdfsdk/fpdfedittext.cpp
index 1c3b22d7f3..f15f9e4e6a 100644
--- a/fpdfsdk/fpdfedittext.cpp
+++ b/fpdfsdk/fpdfedittext.cpp
@@ -98,24 +98,24 @@ const char ToUnicodeEnd[] =
"end\n"
"end\n";
-void AddCharcode(CFX_ByteTextBuf* pBuffer, uint32_t number) {
+void AddCharcode(std::ostringstream* pBuffer, uint32_t number) {
ASSERT(number <= 0xFFFF);
*pBuffer << "<";
char ans[4];
FXSYS_IntToFourHexChars(number, ans);
for (size_t i = 0; i < 4; ++i)
- pBuffer->AppendChar(ans[i]);
+ *pBuffer << ans[i];
*pBuffer << ">";
}
// PDF spec 1.7 Section 5.9.2: "Unicode character sequences as expressed in
// UTF-16BE encoding." See https://en.wikipedia.org/wiki/UTF-16#Description
-void AddUnicode(CFX_ByteTextBuf* pBuffer, uint32_t unicode) {
+void AddUnicode(std::ostringstream* pBuffer, uint32_t unicode) {
char ans[8];
*pBuffer << "<";
size_t numChars = FXSYS_ToUTF16BE(unicode, ans);
for (size_t i = 0; i < numChars; ++i)
- pBuffer->AppendChar(ans[i]);
+ *pBuffer << ans[i];
*pBuffer << ">";
}
@@ -184,7 +184,7 @@ CPDF_Stream* LoadUnicode(CPDF_Document* pDoc,
}
map_range[std::make_pair(firstCharcode, curCharcode)] = firstUnicode;
}
- CFX_ByteTextBuf buffer;
+ std::ostringstream buffer;
buffer << ToUnicodeStart;
// Add maps to buffer
buffer << static_cast<uint32_t>(char_to_uni.size()) << " beginbfchar\n";
@@ -224,11 +224,9 @@ CPDF_Stream* LoadUnicode(CPDF_Document* pDoc,
buffer << "endbfrange\n";
buffer << ToUnicodeEnd;
// TODO(npm): Encrypt / Compress?
- uint32_t bufferSize = buffer.GetSize();
- auto pDict = pdfium::MakeUnique<CPDF_Dictionary>();
- pDict->SetNewFor<CPDF_Number>("Length", static_cast<int>(bufferSize));
- return pDoc->NewIndirect<CPDF_Stream>(buffer.DetachBuffer(), bufferSize,
- std::move(pDict));
+ CPDF_Stream* stream = pDoc->NewIndirect<CPDF_Stream>();
+ stream->SetData(&buffer);
+ return stream;
}
const uint32_t kMaxSimpleFontChar = 0xFF;