summaryrefslogtreecommitdiff
path: root/fpdfsdk/pdfwindow
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
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')
-rw-r--r--fpdfsdk/pdfwindow/cpwl_caret.cpp96
-rw-r--r--fpdfsdk/pdfwindow/cpwl_caret.h4
-rw-r--r--fpdfsdk/pdfwindow/cpwl_combo_box.cpp99
-rw-r--r--fpdfsdk/pdfwindow/cpwl_combo_box.h2
-rw-r--r--fpdfsdk/pdfwindow/cpwl_edit.cpp102
-rw-r--r--fpdfsdk/pdfwindow/cpwl_edit.h2
-rw-r--r--fpdfsdk/pdfwindow/cpwl_icon.cpp7
-rw-r--r--fpdfsdk/pdfwindow/cpwl_list_box.cpp40
-rw-r--r--fpdfsdk/pdfwindow/cpwl_list_box.h2
-rw-r--r--fpdfsdk/pdfwindow/cpwl_scroll_bar.cpp83
-rw-r--r--fpdfsdk/pdfwindow/cpwl_scroll_bar.h4
-rw-r--r--fpdfsdk/pdfwindow/cpwl_utils.cpp160
-rw-r--r--fpdfsdk/pdfwindow/cpwl_wnd.cpp22
-rw-r--r--fpdfsdk/pdfwindow/cpwl_wnd.h6
14 files changed, 306 insertions, 323 deletions
diff --git a/fpdfsdk/pdfwindow/cpwl_caret.cpp b/fpdfsdk/pdfwindow/cpwl_caret.cpp
index 3275dd1b33..a6a165f9a0 100644
--- a/fpdfsdk/pdfwindow/cpwl_caret.cpp
+++ b/fpdfsdk/pdfwindow/cpwl_caret.cpp
@@ -6,6 +6,8 @@
#include "fpdfsdk/pdfwindow/cpwl_caret.h"
+#include <sstream>
+
#include "core/fxge/cfx_graphstatedata.h"
#include "core/fxge/cfx_pathdata.h"
#include "core/fxge/cfx_renderdevice.h"
@@ -24,70 +26,68 @@ CFX_ByteString CPWL_Caret::GetClassName() const {
return "CPWL_Caret";
}
-void CPWL_Caret::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) {
- GetCaretApp(sAppStream, CFX_PointF());
+void CPWL_Caret::GetThisAppearanceStream(std::ostringstream* psAppStream) {
+ GetCaretApp(CFX_PointF(), psAppStream);
}
void CPWL_Caret::DrawThisAppearance(CFX_RenderDevice* pDevice,
CFX_Matrix* pUser2Device) {
- if (IsVisible() && m_bFlash) {
- CFX_FloatRect rcRect = GetCaretRect();
- CFX_FloatRect rcClip = GetClipRect();
- CFX_PathData path;
-
- float fCaretX = rcRect.left + m_fWidth * 0.5f;
- float fCaretTop = rcRect.top;
- float fCaretBottom = rcRect.bottom;
- if (!rcClip.IsEmpty()) {
- rcRect.Intersect(rcClip);
- if (rcRect.IsEmpty())
- return;
-
- fCaretTop = rcRect.top;
- fCaretBottom = rcRect.bottom;
- }
+ if (!IsVisible() || !m_bFlash)
+ return;
+
+ CFX_FloatRect rcRect = GetCaretRect();
+ CFX_FloatRect rcClip = GetClipRect();
+ CFX_PathData path;
+
+ float fCaretX = rcRect.left + m_fWidth * 0.5f;
+ float fCaretTop = rcRect.top;
+ float fCaretBottom = rcRect.bottom;
+ if (!rcClip.IsEmpty()) {
+ rcRect.Intersect(rcClip);
+ if (rcRect.IsEmpty())
+ return;
+
+ fCaretTop = rcRect.top;
+ fCaretBottom = rcRect.bottom;
+ }
- path.AppendPoint(CFX_PointF(fCaretX, fCaretBottom), FXPT_TYPE::MoveTo,
- false);
- path.AppendPoint(CFX_PointF(fCaretX, fCaretTop), FXPT_TYPE::LineTo, false);
+ path.AppendPoint(CFX_PointF(fCaretX, fCaretBottom), FXPT_TYPE::MoveTo, false);
+ path.AppendPoint(CFX_PointF(fCaretX, fCaretTop), FXPT_TYPE::LineTo, false);
- CFX_GraphStateData gsd;
- gsd.m_LineWidth = m_fWidth;
- pDevice->DrawPath(&path, pUser2Device, &gsd, 0, ArgbEncode(255, 0, 0, 0),
- FXFILL_ALTERNATE);
- }
+ CFX_GraphStateData gsd;
+ gsd.m_LineWidth = m_fWidth;
+ pDevice->DrawPath(&path, pUser2Device, &gsd, 0, ArgbEncode(255, 0, 0, 0),
+ FXFILL_ALTERNATE);
}
-void CPWL_Caret::GetCaretApp(CFX_ByteTextBuf& sAppStream,
- const CFX_PointF& ptOffset) {
- if (IsVisible() && m_bFlash) {
- CFX_ByteTextBuf sCaret;
-
- CFX_FloatRect rcRect = GetCaretRect();
- CFX_FloatRect rcClip = GetClipRect();
+void CPWL_Caret::GetCaretApp(const CFX_PointF& ptOffset,
+ std::ostringstream* psAppStream) {
+ if (!IsVisible() || !m_bFlash)
+ return;
- rcRect = CPWL_Utils::OffsetRect(rcRect, ptOffset.x, ptOffset.y);
- rcClip = CPWL_Utils::OffsetRect(rcClip, ptOffset.x, ptOffset.y);
+ CFX_FloatRect rcRect = GetCaretRect();
+ CFX_FloatRect rcClip = GetClipRect();
- sCaret << "q\n";
- if (!rcClip.IsEmpty()) {
- sCaret << rcClip.left << " " << rcClip.bottom + 2.5f << " "
- << rcClip.right - rcClip.left << " "
- << rcClip.top - rcClip.bottom - 4.5f << " re W n\n";
- }
- sCaret << m_fWidth << " w\n0 G\n";
- sCaret << rcRect.left + m_fWidth / 2 << " " << rcRect.bottom << " m\n";
- sCaret << rcRect.left + m_fWidth / 2 << " " << rcRect.top << " l S\nQ\n";
+ rcRect = CPWL_Utils::OffsetRect(rcRect, ptOffset.x, ptOffset.y);
+ rcClip = CPWL_Utils::OffsetRect(rcClip, ptOffset.x, ptOffset.y);
- sAppStream << sCaret;
+ *psAppStream << "q\n";
+ if (!rcClip.IsEmpty()) {
+ *psAppStream << rcClip.left << " " << rcClip.bottom + 2.5f << " "
+ << rcClip.right - rcClip.left << " "
+ << rcClip.top - rcClip.bottom - 4.5f << " re W n\n";
}
+ *psAppStream << m_fWidth << " w\n0 G\n"
+ << rcRect.left + m_fWidth / 2 << " " << rcRect.bottom << " m\n"
+ << rcRect.left + m_fWidth / 2 << " " << rcRect.top
+ << " l S\nQ\n";
}
CFX_ByteString CPWL_Caret::GetCaretAppearanceStream(
const CFX_PointF& ptOffset) {
- CFX_ByteTextBuf sCaret;
- GetCaretApp(sCaret, ptOffset);
- return sCaret.MakeString();
+ std::ostringstream sCaret;
+ GetCaretApp(ptOffset, &sCaret);
+ return CFX_ByteString(sCaret);
}
void CPWL_Caret::TimerProc() {
diff --git a/fpdfsdk/pdfwindow/cpwl_caret.h b/fpdfsdk/pdfwindow/cpwl_caret.h
index 325f13b7eb..7c723b96b3 100644
--- a/fpdfsdk/pdfwindow/cpwl_caret.h
+++ b/fpdfsdk/pdfwindow/cpwl_caret.h
@@ -25,7 +25,7 @@ class CPWL_Caret : public CPWL_Wnd {
// CPWL_Wnd
CFX_ByteString GetClassName() const override;
- void GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) override;
+ void GetThisAppearanceStream(std::ostringstream* psAppStream) override;
void DrawThisAppearance(CFX_RenderDevice* pDevice,
CFX_Matrix* pUser2Device) override;
void InvalidateRect(CFX_FloatRect* pRect = nullptr) override;
@@ -39,7 +39,7 @@ class CPWL_Caret : public CPWL_Wnd {
void SetInvalidRect(CFX_FloatRect rc) { m_rcInvalid = rc; }
private:
- void GetCaretApp(CFX_ByteTextBuf& sAppStream, const CFX_PointF& ptOffset);
+ void GetCaretApp(const CFX_PointF& ptOffset, std::ostringstream* psAppStream);
CFX_FloatRect GetCaretRect() const;
bool m_bFlash;
diff --git a/fpdfsdk/pdfwindow/cpwl_combo_box.cpp b/fpdfsdk/pdfwindow/cpwl_combo_box.cpp
index 2929aac90f..3a6f08c6cd 100644
--- a/fpdfsdk/pdfwindow/cpwl_combo_box.cpp
+++ b/fpdfsdk/pdfwindow/cpwl_combo_box.cpp
@@ -7,6 +7,7 @@
#include "fpdfsdk/pdfwindow/cpwl_combo_box.h"
#include <algorithm>
+#include <sstream>
#include "core/fxge/cfx_pathdata.h"
#include "core/fxge/cfx_renderdevice.h"
@@ -96,35 +97,33 @@ bool CPWL_CBListBox::OnCharWithExit(uint16_t nChar,
return true;
}
-void CPWL_CBButton::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) {
- CPWL_Wnd::GetThisAppearanceStream(sAppStream);
+void CPWL_CBButton::GetThisAppearanceStream(std::ostringstream* psAppStream) {
+ CPWL_Wnd::GetThisAppearanceStream(psAppStream);
CFX_FloatRect rectWnd = CPWL_Wnd::GetWindowRect();
- if (IsVisible() && !rectWnd.IsEmpty()) {
- CFX_ByteTextBuf sButton;
-
- CFX_PointF ptCenter = GetCenterPoint();
-
- CFX_PointF pt1(ptCenter.x - PWL_CBBUTTON_TRIANGLE_HALFLEN,
- ptCenter.y + PWL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f);
- CFX_PointF pt2(ptCenter.x + PWL_CBBUTTON_TRIANGLE_HALFLEN,
- ptCenter.y + PWL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f);
- CFX_PointF pt3(ptCenter.x,
- ptCenter.y - PWL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f);
-
- if (IsFloatBigger(rectWnd.right - rectWnd.left,
- PWL_CBBUTTON_TRIANGLE_HALFLEN * 2) &&
- IsFloatBigger(rectWnd.top - rectWnd.bottom,
- PWL_CBBUTTON_TRIANGLE_HALFLEN)) {
- sButton << "0 g\n";
- sButton << pt1.x << " " << pt1.y << " m\n";
- sButton << pt2.x << " " << pt2.y << " l\n";
- sButton << pt3.x << " " << pt3.y << " l\n";
- sButton << pt1.x << " " << pt1.y << " l f\n";
-
- sAppStream << "q\n" << sButton << "Q\n";
- }
+ if (!IsVisible() || rectWnd.IsEmpty())
+ return;
+
+ CFX_PointF ptCenter = GetCenterPoint();
+
+ CFX_PointF pt1(ptCenter.x - PWL_CBBUTTON_TRIANGLE_HALFLEN,
+ ptCenter.y + PWL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f);
+ CFX_PointF pt2(ptCenter.x + PWL_CBBUTTON_TRIANGLE_HALFLEN,
+ ptCenter.y + PWL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f);
+ CFX_PointF pt3(ptCenter.x, ptCenter.y - PWL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f);
+
+ if (IsFloatBigger(rectWnd.right - rectWnd.left,
+ PWL_CBBUTTON_TRIANGLE_HALFLEN * 2) &&
+ IsFloatBigger(rectWnd.top - rectWnd.bottom,
+ PWL_CBBUTTON_TRIANGLE_HALFLEN)) {
+ *psAppStream << "q\n"
+ << "0 g\n"
+ << pt1.x << " " << pt1.y << " m\n"
+ << pt2.x << " " << pt2.y << " l\n"
+ << pt3.x << " " << pt3.y << " l\n"
+ << pt1.x << " " << pt1.y << " l f\n"
+ << "Q\n";
}
}
@@ -134,30 +133,30 @@ void CPWL_CBButton::DrawThisAppearance(CFX_RenderDevice* pDevice,
CFX_FloatRect rectWnd = CPWL_Wnd::GetWindowRect();
- if (IsVisible() && !rectWnd.IsEmpty()) {
- CFX_PointF ptCenter = GetCenterPoint();
-
- CFX_PointF pt1(ptCenter.x - PWL_CBBUTTON_TRIANGLE_HALFLEN,
- ptCenter.y + PWL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f);
- CFX_PointF pt2(ptCenter.x + PWL_CBBUTTON_TRIANGLE_HALFLEN,
- ptCenter.y + PWL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f);
- CFX_PointF pt3(ptCenter.x,
- ptCenter.y - PWL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f);
-
- if (IsFloatBigger(rectWnd.right - rectWnd.left,
- PWL_CBBUTTON_TRIANGLE_HALFLEN * 2) &&
- IsFloatBigger(rectWnd.top - rectWnd.bottom,
- PWL_CBBUTTON_TRIANGLE_HALFLEN)) {
- CFX_PathData path;
- path.AppendPoint(pt1, FXPT_TYPE::MoveTo, false);
- path.AppendPoint(pt2, FXPT_TYPE::LineTo, false);
- path.AppendPoint(pt3, FXPT_TYPE::LineTo, false);
- path.AppendPoint(pt1, FXPT_TYPE::LineTo, false);
-
- pDevice->DrawPath(&path, pUser2Device, nullptr,
- PWL_DEFAULT_BLACKCOLOR.ToFXColor(GetTransparency()), 0,
- FXFILL_ALTERNATE);
- }
+ if (!IsVisible() || rectWnd.IsEmpty())
+ return;
+
+ CFX_PointF ptCenter = GetCenterPoint();
+
+ CFX_PointF pt1(ptCenter.x - PWL_CBBUTTON_TRIANGLE_HALFLEN,
+ ptCenter.y + PWL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f);
+ CFX_PointF pt2(ptCenter.x + PWL_CBBUTTON_TRIANGLE_HALFLEN,
+ ptCenter.y + PWL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f);
+ CFX_PointF pt3(ptCenter.x, ptCenter.y - PWL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f);
+
+ if (IsFloatBigger(rectWnd.right - rectWnd.left,
+ PWL_CBBUTTON_TRIANGLE_HALFLEN * 2) &&
+ IsFloatBigger(rectWnd.top - rectWnd.bottom,
+ PWL_CBBUTTON_TRIANGLE_HALFLEN)) {
+ CFX_PathData path;
+ path.AppendPoint(pt1, FXPT_TYPE::MoveTo, false);
+ path.AppendPoint(pt2, FXPT_TYPE::LineTo, false);
+ path.AppendPoint(pt3, FXPT_TYPE::LineTo, false);
+ path.AppendPoint(pt1, FXPT_TYPE::LineTo, false);
+
+ pDevice->DrawPath(&path, pUser2Device, nullptr,
+ PWL_DEFAULT_BLACKCOLOR.ToFXColor(GetTransparency()), 0,
+ FXFILL_ALTERNATE);
}
}
diff --git a/fpdfsdk/pdfwindow/cpwl_combo_box.h b/fpdfsdk/pdfwindow/cpwl_combo_box.h
index 549374f3e8..f8da84ad2e 100644
--- a/fpdfsdk/pdfwindow/cpwl_combo_box.h
+++ b/fpdfsdk/pdfwindow/cpwl_combo_box.h
@@ -40,7 +40,7 @@ class CPWL_CBButton : public CPWL_Wnd {
~CPWL_CBButton() override {}
// CPWL_Wnd
- void GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) override;
+ void GetThisAppearanceStream(std::ostringstream* psAppStream) override;
void DrawThisAppearance(CFX_RenderDevice* pDevice,
CFX_Matrix* pUser2Device) override;
bool OnLButtonDown(const CFX_PointF& point, uint32_t nFlag) override;
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(
diff --git a/fpdfsdk/pdfwindow/cpwl_edit.h b/fpdfsdk/pdfwindow/cpwl_edit.h
index 5e82a5746b..31296f664a 100644
--- a/fpdfsdk/pdfwindow/cpwl_edit.h
+++ b/fpdfsdk/pdfwindow/cpwl_edit.h
@@ -51,7 +51,7 @@ class CPWL_Edit : public CPWL_EditCtrl {
void OnCreated() override;
void RePosChildWnd() override;
CFX_FloatRect GetClientRect() const override;
- void GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) override;
+ void GetThisAppearanceStream(std::ostringstream* psAppStream) override;
void DrawThisAppearance(CFX_RenderDevice* pDevice,
CFX_Matrix* pUser2Device) override;
bool OnLButtonDown(const CFX_PointF& point, uint32_t nFlag) override;
diff --git a/fpdfsdk/pdfwindow/cpwl_icon.cpp b/fpdfsdk/pdfwindow/cpwl_icon.cpp
index 1464a09348..6650311915 100644
--- a/fpdfsdk/pdfwindow/cpwl_icon.cpp
+++ b/fpdfsdk/pdfwindow/cpwl_icon.cpp
@@ -7,6 +7,7 @@
#include "fpdfsdk/pdfwindow/cpwl_icon.h"
#include <algorithm>
+#include <sstream>
#include "core/fpdfapi/parser/cpdf_array.h"
#include "core/fpdfapi/parser/cpdf_stream.h"
@@ -18,7 +19,7 @@ CPWL_Image::CPWL_Image() : m_pPDFStream(nullptr) {}
CPWL_Image::~CPWL_Image() {}
CFX_ByteString CPWL_Image::GetImageAppStream() {
- CFX_ByteTextBuf sAppStream;
+ std::ostringstream sAppStream;
CFX_ByteString sAlias = GetImageAlias();
CFX_FloatRect rcPlate = GetClientRect();
@@ -44,11 +45,11 @@ CFX_ByteString CPWL_Image::GetImageAppStream() {
sAppStream << mt.a << " " << mt.b << " " << mt.c << " " << mt.d << " "
<< mt.e << " " << mt.f << " cm\n";
- sAppStream << "0 g 0 G 1 w /" << sAlias.AsStringC() << " Do\n"
+ sAppStream << "0 g 0 G 1 w /" << sAlias << " Do\n"
<< "Q\n";
}
- return sAppStream.MakeString();
+ return CFX_ByteString(sAppStream);
}
void CPWL_Image::SetPDFStream(CPDF_Stream* pStream) {
diff --git a/fpdfsdk/pdfwindow/cpwl_list_box.cpp b/fpdfsdk/pdfwindow/cpwl_list_box.cpp
index 5c161bfdda..f612c2945b 100644
--- a/fpdfsdk/pdfwindow/cpwl_list_box.cpp
+++ b/fpdfsdk/pdfwindow/cpwl_list_box.cpp
@@ -6,6 +6,8 @@
#include "fpdfsdk/pdfwindow/cpwl_list_box.h"
+#include <sstream>
+
#include "fpdfsdk/fxedit/fxet_edit.h"
#include "fpdfsdk/fxedit/fxet_list.h"
#include "fpdfsdk/pdfwindow/cpwl_edit.h"
@@ -95,10 +97,10 @@ void CPWL_ListBox::OnDestroy() {
m_pListNotify.reset();
}
-void CPWL_ListBox::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) {
- CPWL_Wnd::GetThisAppearanceStream(sAppStream);
+void CPWL_ListBox::GetThisAppearanceStream(std::ostringstream* psAppStream) {
+ CPWL_Wnd::GetThisAppearanceStream(psAppStream);
- CFX_ByteTextBuf sListItems;
+ std::ostringstream sListItems;
CFX_FloatRect rcPlate = m_pList->GetPlateRect();
for (int32_t i = 0, sz = m_pList->GetCount(); i < sz; i++) {
@@ -110,40 +112,36 @@ void CPWL_ListBox::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) {
CFX_PointF ptOffset(rcItem.left, (rcItem.top + rcItem.bottom) * 0.5f);
if (m_pList->IsItemSelected(i)) {
sListItems << CPWL_Utils::GetRectFillAppStream(rcItem,
- PWL_DEFAULT_SELBACKCOLOR)
- .AsStringC();
+ PWL_DEFAULT_SELBACKCOLOR);
CFX_ByteString sItem =
CPWL_Utils::GetEditAppStream(m_pList->GetItemEdit(i), ptOffset);
if (sItem.GetLength() > 0) {
sListItems << "BT\n"
<< CPWL_Utils::GetColorAppStream(PWL_DEFAULT_SELTEXTCOLOR)
- .AsStringC()
- << sItem.AsStringC() << "ET\n";
+ << sItem << "ET\n";
}
} else {
CFX_ByteString sItem =
CPWL_Utils::GetEditAppStream(m_pList->GetItemEdit(i), ptOffset);
if (sItem.GetLength() > 0) {
sListItems << "BT\n"
- << CPWL_Utils::GetColorAppStream(GetTextColor()).AsStringC()
- << sItem.AsStringC() << "ET\n";
+ << CPWL_Utils::GetColorAppStream(GetTextColor()) << sItem
+ << "ET\n";
}
}
}
- if (sListItems.GetLength() > 0) {
- CFX_ByteTextBuf sClip;
- CFX_FloatRect rcClient = GetClientRect();
-
- sClip << "q\n";
- sClip << rcClient.left << " " << rcClient.bottom << " "
- << rcClient.right - rcClient.left << " "
- << rcClient.top - rcClient.bottom << " re W n\n";
-
- sClip << sListItems << "Q\n";
+ if (sListItems.tellp() <= 0)
+ return;
- sAppStream << "/Tx BMC\n" << sClip << "EMC\n";
- }
+ CFX_FloatRect rcClient = GetClientRect();
+ *psAppStream << "/Tx BMC\n"
+ << "q\n"
+ << rcClient.left << " " << rcClient.bottom << " "
+ << rcClient.right - rcClient.left << " "
+ << rcClient.top - rcClient.bottom << " re W n\n"
+ << sListItems.str() << "Q\n"
+ << "EMC\n";
}
void CPWL_ListBox::DrawThisAppearance(CFX_RenderDevice* pDevice,
diff --git a/fpdfsdk/pdfwindow/cpwl_list_box.h b/fpdfsdk/pdfwindow/cpwl_list_box.h
index 6cf37ae40c..3eeed0d641 100644
--- a/fpdfsdk/pdfwindow/cpwl_list_box.h
+++ b/fpdfsdk/pdfwindow/cpwl_list_box.h
@@ -53,7 +53,7 @@ class CPWL_ListBox : public CPWL_Wnd {
CFX_ByteString GetClassName() const override;
void OnCreated() override;
void OnDestroy() override;
- void GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) override;
+ void GetThisAppearanceStream(std::ostringstream* psAppStream) override;
void DrawThisAppearance(CFX_RenderDevice* pDevice,
CFX_Matrix* pUser2Device) override;
bool OnKeyDown(uint16_t nChar, uint32_t nFlag) override;
diff --git a/fpdfsdk/pdfwindow/cpwl_scroll_bar.cpp b/fpdfsdk/pdfwindow/cpwl_scroll_bar.cpp
index 2f234b2432..33bdedbf2f 100644
--- a/fpdfsdk/pdfwindow/cpwl_scroll_bar.cpp
+++ b/fpdfsdk/pdfwindow/cpwl_scroll_bar.cpp
@@ -6,6 +6,8 @@
#include "fpdfsdk/pdfwindow/cpwl_scroll_bar.h"
+#include <sstream>
+
#include "core/fxge/cfx_pathdata.h"
#include "core/fxge/cfx_renderdevice.h"
#include "fpdfsdk/pdfwindow/cpwl_utils.h"
@@ -122,20 +124,17 @@ void CPWL_SBButton::OnCreate(PWL_CREATEPARAM& cp) {
cp.eCursorType = FXCT_ARROW;
}
-void CPWL_SBButton::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) {
- CPWL_Wnd::GetThisAppearanceStream(sAppStream);
+void CPWL_SBButton::GetThisAppearanceStream(std::ostringstream* psAppStream) {
+ CPWL_Wnd::GetThisAppearanceStream(psAppStream);
if (!IsVisible())
return;
- CFX_ByteTextBuf sButton;
-
CFX_FloatRect rectWnd = GetWindowRect();
-
if (rectWnd.IsEmpty())
return;
- sAppStream << "q\n";
+ *psAppStream << "q\n";
CFX_PointF ptCenter = GetCenterPoint();
@@ -151,13 +150,11 @@ void CPWL_SBButton::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) {
if (rectWnd.right - rectWnd.left > PWL_TRIANGLE_HALFLEN * 2 &&
rectWnd.top - rectWnd.bottom > PWL_TRIANGLE_HALFLEN) {
- sButton << "0 g\n";
- sButton << pt1.x << " " << pt1.y << " m\n";
- sButton << pt2.x << " " << pt2.y << " l\n";
- sButton << pt3.x << " " << pt3.y << " l\n";
- sButton << pt1.x << " " << pt1.y << " l f\n";
-
- sAppStream << sButton;
+ *psAppStream << "0 g\n"
+ << pt1.x << " " << pt1.y << " m\n"
+ << pt2.x << " " << pt2.y << " l\n"
+ << pt3.x << " " << pt3.y << " l\n"
+ << pt1.x << " " << pt1.y << " l f\n";
}
} break;
case PSBT_MAX: {
@@ -169,13 +166,11 @@ void CPWL_SBButton::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) {
if (rectWnd.right - rectWnd.left > PWL_TRIANGLE_HALFLEN * 2 &&
rectWnd.top - rectWnd.bottom > PWL_TRIANGLE_HALFLEN) {
- sButton << "0 g\n";
- sButton << pt1.x << " " << pt1.y << " m\n";
- sButton << pt2.x << " " << pt2.y << " l\n";
- sButton << pt3.x << " " << pt3.y << " l\n";
- sButton << pt1.x << " " << pt1.y << " l f\n";
-
- sAppStream << sButton;
+ *psAppStream << "0 g\n"
+ << pt1.x << " " << pt1.y << " m\n"
+ << pt2.x << " " << pt2.y << " l\n"
+ << pt3.x << " " << pt3.y << " l\n"
+ << pt1.x << " " << pt1.y << " l f\n";
}
} break;
default:
@@ -193,13 +188,11 @@ void CPWL_SBButton::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) {
if (rectWnd.right - rectWnd.left > PWL_TRIANGLE_HALFLEN * 2 &&
rectWnd.top - rectWnd.bottom > PWL_TRIANGLE_HALFLEN) {
- sButton << "0 g\n";
- sButton << pt1.x << " " << pt1.y << " m\n";
- sButton << pt2.x << " " << pt2.y << " l\n";
- sButton << pt3.x << " " << pt3.y << " l\n";
- sButton << pt1.x << " " << pt1.y << " l f\n";
-
- sAppStream << sButton;
+ *psAppStream << "0 g\n"
+ << pt1.x << " " << pt1.y << " m\n"
+ << pt2.x << " " << pt2.y << " l\n"
+ << pt3.x << " " << pt3.y << " l\n"
+ << pt1.x << " " << pt1.y << " l f\n";
}
} break;
case PSBT_MAX: {
@@ -211,13 +204,11 @@ void CPWL_SBButton::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) {
if (rectWnd.right - rectWnd.left > PWL_TRIANGLE_HALFLEN * 2 &&
rectWnd.top - rectWnd.bottom > PWL_TRIANGLE_HALFLEN) {
- sButton << "0 g\n";
- sButton << pt1.x << " " << pt1.y << " m\n";
- sButton << pt2.x << " " << pt2.y << " l\n";
- sButton << pt3.x << " " << pt3.y << " l\n";
- sButton << pt1.x << " " << pt1.y << " l f\n";
-
- sAppStream << sButton;
+ *psAppStream << "0 g\n"
+ << pt1.x << " " << pt1.y << " m\n"
+ << pt2.x << " " << pt2.y << " l\n"
+ << pt3.x << " " << pt3.y << " l\n"
+ << pt1.x << " " << pt1.y << " l f\n";
}
} break;
default:
@@ -228,7 +219,7 @@ void CPWL_SBButton::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) {
break;
}
- sAppStream << "Q\n";
+ *psAppStream << "Q\n";
}
void CPWL_SBButton::DrawThisAppearance(CFX_RenderDevice* pDevice,
@@ -652,22 +643,18 @@ void CPWL_ScrollBar::RePosChildWnd() {
MovePosButton(false);
}
-void CPWL_ScrollBar::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) {
+void CPWL_ScrollBar::GetThisAppearanceStream(std::ostringstream* psAppStream) {
CFX_FloatRect rectWnd = GetWindowRect();
- if (IsVisible() && !rectWnd.IsEmpty()) {
- CFX_ByteTextBuf sButton;
-
- sButton << "q\n";
- sButton << "0 w\n"
- << CPWL_Utils::GetColorAppStream(GetBackgroundColor(), true)
- .AsStringC();
- sButton << rectWnd.left << " " << rectWnd.bottom << " "
- << rectWnd.right - rectWnd.left << " "
- << rectWnd.top - rectWnd.bottom << " re b Q\n";
+ if (!IsVisible() || rectWnd.IsEmpty())
+ return;
- sAppStream << sButton;
- }
+ *psAppStream << "q\n"
+ << "0 w\n"
+ << CPWL_Utils::GetColorAppStream(GetBackgroundColor(), true)
+ << rectWnd.left << " " << rectWnd.bottom << " "
+ << rectWnd.right - rectWnd.left << " "
+ << rectWnd.top - rectWnd.bottom << " re b Q\n";
}
void CPWL_ScrollBar::DrawThisAppearance(CFX_RenderDevice* pDevice,
diff --git a/fpdfsdk/pdfwindow/cpwl_scroll_bar.h b/fpdfsdk/pdfwindow/cpwl_scroll_bar.h
index 0ab2928f2a..c67109fe39 100644
--- a/fpdfsdk/pdfwindow/cpwl_scroll_bar.h
+++ b/fpdfsdk/pdfwindow/cpwl_scroll_bar.h
@@ -51,7 +51,7 @@ class CPWL_SBButton : public CPWL_Wnd {
// CPWL_Wnd
CFX_ByteString GetClassName() const override;
void OnCreate(PWL_CREATEPARAM& cp) override;
- void GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) override;
+ void GetThisAppearanceStream(std::ostringstream* psAppStream) override;
void DrawThisAppearance(CFX_RenderDevice* pDevice,
CFX_Matrix* pUser2Device) override;
bool OnLButtonDown(const CFX_PointF& point, uint32_t nFlag) override;
@@ -126,7 +126,7 @@ class CPWL_ScrollBar : public CPWL_Wnd {
void OnCreate(PWL_CREATEPARAM& cp) override;
void OnDestroy() override;
void RePosChildWnd() override;
- void GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) override;
+ void GetThisAppearanceStream(std::ostringstream* psAppStream) override;
void DrawThisAppearance(CFX_RenderDevice* pDevice,
CFX_Matrix* pUser2Device) override;
bool OnLButtonDown(const CFX_PointF& point, uint32_t nFlag) override;
diff --git a/fpdfsdk/pdfwindow/cpwl_utils.cpp b/fpdfsdk/pdfwindow/cpwl_utils.cpp
index 0a3591923a..ce263eff8b 100644
--- a/fpdfsdk/pdfwindow/cpwl_utils.cpp
+++ b/fpdfsdk/pdfwindow/cpwl_utils.cpp
@@ -8,6 +8,7 @@
#include <algorithm>
#include <memory>
+#include <sstream>
#include "core/fpdfdoc/cpvt_word.h"
#include "core/fxge/cfx_graphstatedata.h"
@@ -63,7 +64,7 @@ CFX_ByteString CPWL_Utils::GetAP_Check(const CFX_FloatRect& crBBox) {
}
}
- CFX_ByteTextBuf csAP;
+ std::ostringstream csAP;
csAP << pts[0][0].x << " " << pts[0][0].y << " m\n";
for (size_t i = 0; i < FX_ArraySize(pts); ++i) {
@@ -81,11 +82,11 @@ CFX_ByteString CPWL_Utils::GetAP_Check(const CFX_FloatRect& crBBox) {
<< pts[nNext][0].y << " c\n";
}
- return csAP.MakeString();
+ return CFX_ByteString(csAP);
}
CFX_ByteString CPWL_Utils::GetAP_Circle(const CFX_FloatRect& crBBox) {
- CFX_ByteTextBuf csAP;
+ std::ostringstream csAP;
float fWidth = crBBox.right - crBBox.left;
float fHeight = crBBox.top - crBBox.bottom;
@@ -123,22 +124,22 @@ CFX_ByteString CPWL_Utils::GetAP_Circle(const CFX_FloatRect& crBBox) {
csAP << pt4.x - px * FX_BEZIER << " " << pt4.y << " " << pt1.x << " "
<< pt1.y - py * FX_BEZIER << " " << pt1.x << " " << pt1.y << " c\n";
- return csAP.MakeString();
+ return CFX_ByteString(csAP);
}
CFX_ByteString CPWL_Utils::GetAP_Cross(const CFX_FloatRect& crBBox) {
- CFX_ByteTextBuf csAP;
+ std::ostringstream csAP;
csAP << crBBox.left << " " << crBBox.top << " m\n";
csAP << crBBox.right << " " << crBBox.bottom << " l\n";
csAP << crBBox.left << " " << crBBox.bottom << " m\n";
csAP << crBBox.right << " " << crBBox.top << " l\n";
- return csAP.MakeString();
+ return CFX_ByteString(csAP);
}
CFX_ByteString CPWL_Utils::GetAP_Diamond(const CFX_FloatRect& crBBox) {
- CFX_ByteTextBuf csAP;
+ std::ostringstream csAP;
float fWidth = crBBox.right - crBBox.left;
float fHeight = crBBox.top - crBBox.bottom;
@@ -154,11 +155,11 @@ CFX_ByteString CPWL_Utils::GetAP_Diamond(const CFX_FloatRect& crBBox) {
csAP << pt4.x << " " << pt4.y << " l\n";
csAP << pt1.x << " " << pt1.y << " l\n";
- return csAP.MakeString();
+ return CFX_ByteString(csAP);
}
CFX_ByteString CPWL_Utils::GetAP_Square(const CFX_FloatRect& crBBox) {
- CFX_ByteTextBuf csAP;
+ std::ostringstream csAP;
csAP << crBBox.left << " " << crBBox.top << " m\n";
csAP << crBBox.right << " " << crBBox.top << " l\n";
@@ -166,11 +167,11 @@ CFX_ByteString CPWL_Utils::GetAP_Square(const CFX_FloatRect& crBBox) {
csAP << crBBox.left << " " << crBBox.bottom << " l\n";
csAP << crBBox.left << " " << crBBox.top << " l\n";
- return csAP.MakeString();
+ return CFX_ByteString(csAP);
}
CFX_ByteString CPWL_Utils::GetAP_Star(const CFX_FloatRect& crBBox) {
- CFX_ByteTextBuf csAP;
+ std::ostringstream csAP;
float fRadius = (crBBox.top - crBBox.bottom) / (1 + (float)cos(FX_PI / 5.0f));
CFX_PointF ptCenter = CFX_PointF((crBBox.left + crBBox.right) / 2.0f,
@@ -197,12 +198,12 @@ CFX_ByteString CPWL_Utils::GetAP_Star(const CFX_FloatRect& crBBox) {
csAP << px[nNext] << " " << py[nNext] << " l\n";
}
- return csAP.MakeString();
+ return CFX_ByteString(csAP);
}
CFX_ByteString CPWL_Utils::GetAP_HalfCircle(const CFX_FloatRect& crBBox,
float fRotate) {
- CFX_ByteTextBuf csAP;
+ std::ostringstream csAP;
float fWidth = crBBox.right - crBBox.left;
float fHeight = crBBox.top - crBBox.bottom;
@@ -232,7 +233,7 @@ CFX_ByteString CPWL_Utils::GetAP_HalfCircle(const CFX_FloatRect& crBBox,
csAP << pt2.x + px * FX_BEZIER << " " << pt2.y << " " << pt3.x << " "
<< pt3.y + py * FX_BEZIER << " " << pt3.x << " " << pt3.y << " c\n";
- return csAP.MakeString();
+ return CFX_ByteString(csAP);
}
CFX_FloatRect CPWL_Utils::InflateRect(const CFX_FloatRect& rcRect,
@@ -271,7 +272,7 @@ CFX_FloatRect CPWL_Utils::ScaleRect(const CFX_FloatRect& rcRect, float fScale) {
CFX_ByteString CPWL_Utils::GetRectFillAppStream(const CFX_FloatRect& rect,
const CPWL_Color& color) {
- CFX_ByteTextBuf sAppStream;
+ std::ostringstream sAppStream;
CFX_ByteString sColor = GetColorAppStream(color, true);
if (sColor.GetLength() > 0) {
sAppStream << "q\n" << sColor;
@@ -280,17 +281,16 @@ CFX_ByteString CPWL_Utils::GetRectFillAppStream(const CFX_FloatRect& rect,
<< " re f\nQ\n";
}
- return sAppStream.MakeString();
+ return CFX_ByteString(sAppStream);
}
CFX_ByteString CPWL_Utils::GetCircleFillAppStream(const CFX_FloatRect& rect,
const CPWL_Color& color) {
- CFX_ByteTextBuf sAppStream;
+ std::ostringstream sAppStream;
CFX_ByteString sColor = GetColorAppStream(color, true);
- if (sColor.GetLength() > 0) {
+ if (sColor.GetLength() > 0)
sAppStream << "q\n" << sColor << CPWL_Utils::GetAP_Circle(rect) << "f\nQ\n";
- }
- return sAppStream.MakeString();
+ return CFX_ByteString(sAppStream);
}
CFX_FloatRect CPWL_Utils::GetCenterSquare(const CFX_FloatRect& rect) {
@@ -514,7 +514,7 @@ CFX_ByteString CPWL_Utils::GetPushButtonAppStream(const CFX_FloatRect& rcBBox,
break;
}
- CFX_ByteTextBuf sAppStream, sTemp;
+ std::ostringstream sTemp;
if (!rcIcon.IsEmpty()) {
Icon.Move(rcIcon, false, false);
@@ -533,19 +533,21 @@ CFX_ByteString CPWL_Utils::GetPushButtonAppStream(const CFX_FloatRect& rcBBox,
}
}
- if (sTemp.GetSize() > 0) {
- sAppStream << "q\n"
- << rcBBox.left << " " << rcBBox.bottom << " "
- << rcBBox.right - rcBBox.left << " "
- << rcBBox.top - rcBBox.bottom << " re W n\n";
- sAppStream << sTemp << "Q\n";
- }
- return sAppStream.MakeString();
+ if (sTemp.tellp() <= 0)
+ return CFX_ByteString();
+
+ std::ostringstream sAppStream;
+ sAppStream << "q\n"
+ << rcBBox.left << " " << rcBBox.bottom << " "
+ << rcBBox.right - rcBBox.left << " " << rcBBox.top - rcBBox.bottom
+ << " re W n\n";
+ sAppStream << sTemp.str().c_str() << "Q\n";
+ return CFX_ByteString(sAppStream);
}
CFX_ByteString CPWL_Utils::GetColorAppStream(const CPWL_Color& color,
const bool& bFillOrStroke) {
- CFX_ByteTextBuf sColorStream;
+ std::ostringstream sColorStream;
switch (color.nColorType) {
case COLORTYPE_RGB:
@@ -564,7 +566,7 @@ CFX_ByteString CPWL_Utils::GetColorAppStream(const CPWL_Color& color,
break;
}
- return sColorStream.MakeString();
+ return CFX_ByteString(sColorStream);
}
CFX_ByteString CPWL_Utils::GetBorderAppStream(const CFX_FloatRect& rect,
@@ -574,7 +576,7 @@ CFX_ByteString CPWL_Utils::GetBorderAppStream(const CFX_FloatRect& rect,
const CPWL_Color& crRightBottom,
BorderStyle nStyle,
const CPWL_Dash& dash) {
- CFX_ByteTextBuf sAppStream;
+ std::ostringstream sAppStream;
CFX_ByteString sColor;
float fLeft = rect.left;
@@ -680,7 +682,7 @@ CFX_ByteString CPWL_Utils::GetBorderAppStream(const CFX_FloatRect& rect,
sAppStream << "Q\n";
}
- return sAppStream.MakeString();
+ return CFX_ByteString(sAppStream);
}
CFX_ByteString CPWL_Utils::GetCircleBorderAppStream(
@@ -691,7 +693,7 @@ CFX_ByteString CPWL_Utils::GetCircleBorderAppStream(
const CPWL_Color& crRightBottom,
BorderStyle nStyle,
const CPWL_Dash& dash) {
- CFX_ByteTextBuf sAppStream;
+ std::ostringstream sAppStream;
CFX_ByteString sColor;
if (fWidth > 0.0f) {
@@ -793,61 +795,61 @@ CFX_ByteString CPWL_Utils::GetCircleBorderAppStream(
sAppStream << "Q\n";
}
- return sAppStream.MakeString();
+ return CFX_ByteString(sAppStream);
}
CFX_ByteString CPWL_Utils::GetAppStream_Check(const CFX_FloatRect& rcBBox,
const CPWL_Color& crText) {
- CFX_ByteTextBuf sAP;
+ std::ostringstream sAP;
sAP << "q\n"
<< CPWL_Utils::GetColorAppStream(crText, true)
<< CPWL_Utils::GetAP_Check(rcBBox) << "f\nQ\n";
- return sAP.MakeString();
+ return CFX_ByteString(sAP);
}
CFX_ByteString CPWL_Utils::GetAppStream_Circle(const CFX_FloatRect& rcBBox,
const CPWL_Color& crText) {
- CFX_ByteTextBuf sAP;
+ std::ostringstream sAP;
sAP << "q\n"
<< CPWL_Utils::GetColorAppStream(crText, true)
<< CPWL_Utils::GetAP_Circle(rcBBox) << "f\nQ\n";
- return sAP.MakeString();
+ return CFX_ByteString(sAP);
}
CFX_ByteString CPWL_Utils::GetAppStream_Cross(const CFX_FloatRect& rcBBox,
const CPWL_Color& crText) {
- CFX_ByteTextBuf sAP;
+ std::ostringstream sAP;
sAP << "q\n"
<< CPWL_Utils::GetColorAppStream(crText, false)
<< CPWL_Utils::GetAP_Cross(rcBBox) << "S\nQ\n";
- return sAP.MakeString();
+ return CFX_ByteString(sAP);
}
CFX_ByteString CPWL_Utils::GetAppStream_Diamond(const CFX_FloatRect& rcBBox,
const CPWL_Color& crText) {
- CFX_ByteTextBuf sAP;
+ std::ostringstream sAP;
sAP << "q\n1 w\n"
<< CPWL_Utils::GetColorAppStream(crText, true)
<< CPWL_Utils::GetAP_Diamond(rcBBox) << "f\nQ\n";
- return sAP.MakeString();
+ return CFX_ByteString(sAP);
}
CFX_ByteString CPWL_Utils::GetAppStream_Square(const CFX_FloatRect& rcBBox,
const CPWL_Color& crText) {
- CFX_ByteTextBuf sAP;
+ std::ostringstream sAP;
sAP << "q\n"
<< CPWL_Utils::GetColorAppStream(crText, true)
<< CPWL_Utils::GetAP_Square(rcBBox) << "f\nQ\n";
- return sAP.MakeString();
+ return CFX_ByteString(sAP);
}
CFX_ByteString CPWL_Utils::GetAppStream_Star(const CFX_FloatRect& rcBBox,
const CPWL_Color& crText) {
- CFX_ByteTextBuf sAP;
+ std::ostringstream sAP;
sAP << "q\n"
<< CPWL_Utils::GetColorAppStream(crText, true)
<< CPWL_Utils::GetAP_Star(rcBBox) << "f\nQ\n";
- return sAP.MakeString();
+ return CFX_ByteString(sAP);
}
CFX_ByteString CPWL_Utils::GetCheckBoxAppStream(const CFX_FloatRect& rcBBox,
@@ -893,42 +895,42 @@ CFX_ByteString CPWL_Utils::GetRadioButtonAppStream(const CFX_FloatRect& rcBBox,
}
CFX_ByteString CPWL_Utils::GetDropButtonAppStream(const CFX_FloatRect& rcBBox) {
- CFX_ByteTextBuf sAppStream;
-
- if (!rcBBox.IsEmpty()) {
+ if (rcBBox.IsEmpty())
+ return CFX_ByteString();
+
+ std::ostringstream sAppStream;
+ sAppStream << "q\n"
+ << CPWL_Utils::GetColorAppStream(
+ CPWL_Color(COLORTYPE_RGB, 220.0f / 255.0f, 220.0f / 255.0f,
+ 220.0f / 255.0f),
+ true)
+ << rcBBox.left << " " << rcBBox.bottom << " "
+ << rcBBox.right - rcBBox.left << " " << rcBBox.top - rcBBox.bottom
+ << " re f\n"
+ << "Q\n";
+
+ sAppStream << "q\n"
+ << CPWL_Utils::GetBorderAppStream(
+ rcBBox, 2, CPWL_Color(COLORTYPE_GRAY, 0),
+ CPWL_Color(COLORTYPE_GRAY, 1),
+ CPWL_Color(COLORTYPE_GRAY, 0.5), BorderStyle::BEVELED,
+ CPWL_Dash(3, 0, 0))
+ << "Q\n";
+
+ CFX_PointF ptCenter = CFX_PointF((rcBBox.left + rcBBox.right) / 2,
+ (rcBBox.top + rcBBox.bottom) / 2);
+ if (IsFloatBigger(rcBBox.right - rcBBox.left, 6) &&
+ IsFloatBigger(rcBBox.top - rcBBox.bottom, 6)) {
sAppStream << "q\n"
- << CPWL_Utils::GetColorAppStream(
- CPWL_Color(COLORTYPE_RGB, 220.0f / 255.0f,
- 220.0f / 255.0f, 220.0f / 255.0f),
- true);
- sAppStream << rcBBox.left << " " << rcBBox.bottom << " "
- << rcBBox.right - rcBBox.left << " "
- << rcBBox.top - rcBBox.bottom << " re f\n";
- sAppStream << "Q\n";
-
- sAppStream << "q\n"
- << CPWL_Utils::GetBorderAppStream(
- rcBBox, 2, CPWL_Color(COLORTYPE_GRAY, 0),
- CPWL_Color(COLORTYPE_GRAY, 1),
- CPWL_Color(COLORTYPE_GRAY, 0.5), BorderStyle::BEVELED,
- CPWL_Dash(3, 0, 0))
+ << " 0 g\n"
+ << ptCenter.x - 3 << " " << ptCenter.y + 1.5f << " m\n"
+ << ptCenter.x + 3 << " " << ptCenter.y + 1.5f << " l\n"
+ << ptCenter.x << " " << ptCenter.y - 1.5f << " l\n"
+ << ptCenter.x - 3 << " " << ptCenter.y + 1.5f << " l f\n"
<< "Q\n";
-
- CFX_PointF ptCenter = CFX_PointF((rcBBox.left + rcBBox.right) / 2,
- (rcBBox.top + rcBBox.bottom) / 2);
- if (IsFloatBigger(rcBBox.right - rcBBox.left, 6) &&
- IsFloatBigger(rcBBox.top - rcBBox.bottom, 6)) {
- sAppStream << "q\n"
- << " 0 g\n";
- sAppStream << ptCenter.x - 3 << " " << ptCenter.y + 1.5f << " m\n";
- sAppStream << ptCenter.x + 3 << " " << ptCenter.y + 1.5f << " l\n";
- sAppStream << ptCenter.x << " " << ptCenter.y - 1.5f << " l\n";
- sAppStream << ptCenter.x - 3 << " " << ptCenter.y + 1.5f << " l f\n";
- sAppStream << "Q\n";
- }
}
- return sAppStream.MakeString();
+ return CFX_ByteString(sAppStream);
}
void CPWL_Utils::DrawFillRect(CFX_RenderDevice* pDevice,
diff --git a/fpdfsdk/pdfwindow/cpwl_wnd.cpp b/fpdfsdk/pdfwindow/cpwl_wnd.cpp
index d44b219110..a8b5c31254 100644
--- a/fpdfsdk/pdfwindow/cpwl_wnd.cpp
+++ b/fpdfsdk/pdfwindow/cpwl_wnd.cpp
@@ -7,6 +7,7 @@
#include "fpdfsdk/pdfwindow/cpwl_wnd.h"
#include <map>
+#include <sstream>
#include <vector>
#include "fpdfsdk/pdfwindow/cpwl_scroll_bar.h"
@@ -232,39 +233,36 @@ void CPWL_Wnd::InvalidateRectMove(const CFX_FloatRect& rcOld,
InvalidateRect(&rcUnion);
}
-void CPWL_Wnd::GetAppearanceStream(CFX_ByteTextBuf& sAppStream) {
+void CPWL_Wnd::GetAppearanceStream(std::ostringstream* psAppStream) {
if (IsValid() && IsVisible()) {
- GetThisAppearanceStream(sAppStream);
- GetChildAppearanceStream(sAppStream);
+ GetThisAppearanceStream(psAppStream);
+ GetChildAppearanceStream(psAppStream);
}
}
// if don't set,Get default apperance stream
-void CPWL_Wnd::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) {
+void CPWL_Wnd::GetThisAppearanceStream(std::ostringstream* psAppStream) {
CFX_FloatRect rectWnd = GetWindowRect();
if (rectWnd.IsEmpty())
return;
- CFX_ByteTextBuf sThis;
-
if (HasFlag(PWS_BACKGROUND))
- sThis << CPWL_Utils::GetRectFillAppStream(rectWnd, GetBackgroundColor());
+ *psAppStream << CPWL_Utils::GetRectFillAppStream(rectWnd,
+ GetBackgroundColor());
if (HasFlag(PWS_BORDER)) {
- sThis << CPWL_Utils::GetBorderAppStream(
+ *psAppStream << CPWL_Utils::GetBorderAppStream(
rectWnd, (float)GetBorderWidth(), GetBorderColor(),
GetBorderLeftTopColor(GetBorderStyle()),
GetBorderRightBottomColor(GetBorderStyle()), GetBorderStyle(),
GetBorderDash());
}
-
- sAppStream << sThis;
}
-void CPWL_Wnd::GetChildAppearanceStream(CFX_ByteTextBuf& sAppStream) {
+void CPWL_Wnd::GetChildAppearanceStream(std::ostringstream* psAppStream) {
for (CPWL_Wnd* pChild : m_Children) {
if (pChild)
- pChild->GetAppearanceStream(sAppStream);
+ pChild->GetAppearanceStream(psAppStream);
}
}
diff --git a/fpdfsdk/pdfwindow/cpwl_wnd.h b/fpdfsdk/pdfwindow/cpwl_wnd.h
index 704984932b..8d7cc32ec8 100644
--- a/fpdfsdk/pdfwindow/cpwl_wnd.h
+++ b/fpdfsdk/pdfwindow/cpwl_wnd.h
@@ -303,7 +303,7 @@ class CPWL_Wnd : public CPWL_TimerHandler {
virtual void CreateChildWnd(const PWL_CREATEPARAM& cp);
virtual void RePosChildWnd();
- virtual void GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream);
+ virtual void GetThisAppearanceStream(std::ostringstream* psAppStream);
virtual void DrawThisAppearance(CFX_RenderDevice* pDevice,
CFX_Matrix* pUser2Device);
@@ -315,7 +315,7 @@ class CPWL_Wnd : public CPWL_TimerHandler {
virtual void OnSetFocus();
virtual void OnKillFocus();
- void GetAppearanceStream(CFX_ByteTextBuf& sAppStream);
+ void GetAppearanceStream(std::ostringstream* psAppStream);
void SetNotifyFlag(bool bNotifying = true) { m_bNotifying = bNotifying; }
bool IsValid() const;
@@ -337,7 +337,7 @@ class CPWL_Wnd : public CPWL_TimerHandler {
CFX_PointF ParentToChild(const CFX_PointF& point) const;
CFX_FloatRect ParentToChild(const CFX_FloatRect& rect) const;
- void GetChildAppearanceStream(CFX_ByteTextBuf& sAppStream);
+ void GetChildAppearanceStream(std::ostringstream* psAppStream);
void DrawChildAppearance(CFX_RenderDevice* pDevice, CFX_Matrix* pUser2Device);
FX_RECT PWLtoWnd(const CFX_FloatRect& rect) const;