summaryrefslogtreecommitdiff
path: root/fpdfsdk/pdfwindow/cpwl_edit.cpp
diff options
context:
space:
mode:
authorHenrique Nakashima <hnakashima@chromium.org>2017-06-29 11:18:49 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-06-29 15:40:59 +0000
commitf1eae2c37cb4bbf7a536cf251706147bbac51880 (patch)
tree8eead543163dddefc63a518d9d44b5ca1ee49875 /fpdfsdk/pdfwindow/cpwl_edit.cpp
parenta0b48aa8043be95e5c6b602e0e261fb163282536 (diff)
downloadpdfium-f1eae2c37cb4bbf7a536cf251706147bbac51880.tar.xz
Converted low-hanging cpwl classes in CFX_ByteTextBuf to ostringstream.
Bug: pdfium:731 Change-Id: I3faf5a4ec4b2af6145348e526f39ccbc2055e62e Reviewed-on: https://pdfium-review.googlesource.com/7050 Commit-Queue: Henrique Nakashima <hnakashima@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'fpdfsdk/pdfwindow/cpwl_edit.cpp')
-rw-r--r--fpdfsdk/pdfwindow/cpwl_edit.cpp102
1 files changed, 50 insertions, 52 deletions
diff --git a/fpdfsdk/pdfwindow/cpwl_edit.cpp b/fpdfsdk/pdfwindow/cpwl_edit.cpp
index d807f32c34..aa257b9308 100644
--- a/fpdfsdk/pdfwindow/cpwl_edit.cpp
+++ b/fpdfsdk/pdfwindow/cpwl_edit.cpp
@@ -8,6 +8,7 @@
#include <algorithm>
#include <memory>
+#include <sstream>
#include <vector>
#include "core/fpdfapi/font/cpdf_font.h"
@@ -188,54 +189,56 @@ void CPWL_Edit::SetParamByFlag() {
}
}
-void CPWL_Edit::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) {
- CPWL_Wnd::GetThisAppearanceStream(sAppStream);
+void CPWL_Edit::GetThisAppearanceStream(std::ostringstream* psAppStream) {
+ CPWL_Wnd::GetThisAppearanceStream(psAppStream);
CFX_FloatRect rcClient = GetClientRect();
- CFX_ByteTextBuf sLine;
int32_t nCharArray = m_pEdit->GetCharArray();
if (nCharArray > 0) {
switch (GetBorderStyle()) {
case BorderStyle::SOLID: {
- sLine << "q\n"
- << GetBorderWidth() << " w\n"
- << CPWL_Utils::GetColorAppStream(GetBorderColor(), false)
- .AsStringC()
- << " 2 J 0 j\n";
+ *psAppStream << "q\n"
+ << GetBorderWidth() << " w\n"
+ << CPWL_Utils::GetColorAppStream(GetBorderColor(), false)
+ << " 2 J 0 j\n";
for (int32_t i = 1; i < nCharArray; i++) {
- sLine << rcClient.left +
- ((rcClient.right - rcClient.left) / nCharArray) * i
- << " " << rcClient.bottom << " m\n"
- << rcClient.left +
- ((rcClient.right - rcClient.left) / nCharArray) * i
- << " " << rcClient.top << " l S\n";
+ *psAppStream << rcClient.left +
+ ((rcClient.right - rcClient.left) / nCharArray) *
+ i
+ << " " << rcClient.bottom << " m\n"
+ << rcClient.left +
+ ((rcClient.right - rcClient.left) / nCharArray) *
+ i
+ << " " << rcClient.top << " l S\n";
}
- sLine << "Q\n";
+ *psAppStream << "Q\n";
break;
}
case BorderStyle::DASH: {
- sLine << "q\n"
- << GetBorderWidth() << " w\n"
- << CPWL_Utils::GetColorAppStream(GetBorderColor(), false)
- .AsStringC()
- << " 2 J 0 j\n"
- << "[" << GetBorderDash().nDash << " " << GetBorderDash().nGap
- << "] " << GetBorderDash().nPhase << " d\n";
+ *psAppStream << "q\n"
+ << GetBorderWidth() << " w\n"
+ << CPWL_Utils::GetColorAppStream(GetBorderColor(), false)
+ << " 2 J 0 j\n"
+ << "[" << GetBorderDash().nDash << " "
+ << GetBorderDash().nGap << "] " << GetBorderDash().nPhase
+ << " d\n";
for (int32_t i = 1; i < nCharArray; i++) {
- sLine << rcClient.left +
- ((rcClient.right - rcClient.left) / nCharArray) * i
- << " " << rcClient.bottom << " m\n"
- << rcClient.left +
- ((rcClient.right - rcClient.left) / nCharArray) * i
- << " " << rcClient.top << " l S\n";
+ *psAppStream << rcClient.left +
+ ((rcClient.right - rcClient.left) / nCharArray) *
+ i
+ << " " << rcClient.bottom << " m\n"
+ << rcClient.left +
+ ((rcClient.right - rcClient.left) / nCharArray) *
+ i
+ << " " << rcClient.top << " l S\n";
}
- sLine << "Q\n";
+ *psAppStream << "Q\n";
break;
}
default:
@@ -243,9 +246,7 @@ void CPWL_Edit::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) {
}
}
- sAppStream << sLine;
-
- CFX_ByteTextBuf sText;
+ std::ostringstream sText;
CFX_PointF ptOffset;
CPVT_WordRange wrWhole = m_pEdit->GetWholeWordRange();
CPVT_WordRange wrSelect = GetSelectWordRange();
@@ -260,8 +261,8 @@ void CPWL_Edit::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) {
CPWL_Utils::GetEditSelAppStream(m_pEdit.get(), ptOffset, &wrTemp);
if (sEditSel.GetLength() > 0)
- sText << CPWL_Utils::GetColorAppStream(PWL_DEFAULT_SELBACKCOLOR).AsStringC()
- << sEditSel.AsStringC();
+ sText << CPWL_Utils::GetColorAppStream(PWL_DEFAULT_SELBACKCOLOR)
+ << sEditSel;
wrTemp = CPWL_Utils::OverlapWordRange(wrVisible, wrSelBefore);
CFX_ByteString sEditBefore = CPWL_Utils::GetEditAppStream(
@@ -270,8 +271,8 @@ void CPWL_Edit::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) {
if (sEditBefore.GetLength() > 0)
sText << "BT\n"
- << CPWL_Utils::GetColorAppStream(GetTextColor()).AsStringC()
- << sEditBefore.AsStringC() << "ET\n";
+ << CPWL_Utils::GetColorAppStream(GetTextColor()) << sEditBefore
+ << "ET\n";
wrTemp = CPWL_Utils::OverlapWordRange(wrVisible, wrSelect);
CFX_ByteString sEditMid = CPWL_Utils::GetEditAppStream(
@@ -281,8 +282,7 @@ void CPWL_Edit::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) {
if (sEditMid.GetLength() > 0)
sText << "BT\n"
<< CPWL_Utils::GetColorAppStream(CPWL_Color(COLORTYPE_GRAY, 1))
- .AsStringC()
- << sEditMid.AsStringC() << "ET\n";
+ << sEditMid << "ET\n";
wrTemp = CPWL_Utils::OverlapWordRange(wrVisible, wrSelAfter);
CFX_ByteString sEditAfter = CPWL_Utils::GetEditAppStream(
@@ -291,21 +291,21 @@ void CPWL_Edit::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) {
if (sEditAfter.GetLength() > 0)
sText << "BT\n"
- << CPWL_Utils::GetColorAppStream(GetTextColor()).AsStringC()
- << sEditAfter.AsStringC() << "ET\n";
+ << CPWL_Utils::GetColorAppStream(GetTextColor()) << sEditAfter
+ << "ET\n";
- if (sText.GetLength() > 0) {
+ if (sText.tellp() > 0) {
CFX_FloatRect rect = GetClientRect();
- sAppStream << "q\n/Tx BMC\n";
+ *psAppStream << "q\n/Tx BMC\n";
if (!HasFlag(PES_TEXTOVERFLOW))
- sAppStream << rect.left << " " << rect.bottom << " "
- << rect.right - rect.left << " " << rect.top - rect.bottom
- << " re W n\n";
+ *psAppStream << rect.left << " " << rect.bottom << " "
+ << rect.right - rect.left << " " << rect.top - rect.bottom
+ << " re W n\n";
- sAppStream << sText;
+ *psAppStream << sText.str();
- sAppStream << "EMC\nQ\n";
+ *psAppStream << "EMC\nQ\n";
}
}
@@ -314,7 +314,6 @@ void CPWL_Edit::DrawThisAppearance(CFX_RenderDevice* pDevice,
CPWL_Wnd::DrawThisAppearance(pDevice, pUser2Device);
CFX_FloatRect rcClient = GetClientRect();
- CFX_ByteTextBuf sLine;
int32_t nCharArray = m_pEdit->GetCharArray();
FX_SAFE_INT32 nCharArraySafe = nCharArray;
@@ -487,14 +486,13 @@ CPVT_WordRange CPWL_Edit::GetSelectWordRange() const {
CFX_ByteString CPWL_Edit::GetTextAppearanceStream(
const CFX_PointF& ptOffset) const {
- CFX_ByteTextBuf sRet;
+ std::ostringstream sRet;
CFX_ByteString sEdit = CPWL_Utils::GetEditAppStream(m_pEdit.get(), ptOffset);
if (sEdit.GetLength() > 0) {
sRet << "BT\n"
- << CPWL_Utils::GetColorAppStream(GetTextColor()).AsStringC()
- << sEdit.AsStringC() << "ET\n";
+ << CPWL_Utils::GetColorAppStream(GetTextColor()) << sEdit << "ET\n";
}
- return sRet.MakeString();
+ return CFX_ByteString(sRet);
}
CFX_ByteString CPWL_Edit::GetCaretAppearanceStream(