summaryrefslogtreecommitdiff
path: root/fpdfsdk
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-07-20 11:07:00 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-07-20 15:33:39 +0000
commit14ddd425193946692042fcd910857963d333be3b (patch)
treef287d1e2f5e41545e29a75fd32188d02862a5b81 /fpdfsdk
parent2c4a805ac3d649caf34b125fdda1450c7ba8432f (diff)
downloadpdfium-14ddd425193946692042fcd910857963d333be3b.tar.xz
Consolidate Appearance Stream code in CPWL_AppStream.
This CL moves the remaining appearance stream code to CPWL_AppStream. The unused GetThisAppearanceStream methods have been removed. Change-Id: I0bdfbb11962ee7975394a40a1ea45d076ee9151d Reviewed-on: https://pdfium-review.googlesource.com/8312 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
Diffstat (limited to 'fpdfsdk')
-rw-r--r--fpdfsdk/cpdfsdk_interform.cpp1
-rw-r--r--fpdfsdk/cpdfsdk_widget.cpp1
-rw-r--r--fpdfsdk/formfiller/cffl_formfiller.cpp1
-rw-r--r--fpdfsdk/formfiller/cffl_interactiveformfiller.cpp1
-rw-r--r--fpdfsdk/fxedit/fxet_edit.cpp164
-rw-r--r--fpdfsdk/fxedit/fxet_edit.h8
-rw-r--r--fpdfsdk/pdfwindow/cpwl_appstream.cpp596
-rw-r--r--fpdfsdk/pdfwindow/cpwl_button.cpp1
-rw-r--r--fpdfsdk/pdfwindow/cpwl_caret.cpp1
-rw-r--r--fpdfsdk/pdfwindow/cpwl_combo_box.cpp1
-rw-r--r--fpdfsdk/pdfwindow/cpwl_edit.cpp7
-rw-r--r--fpdfsdk/pdfwindow/cpwl_edit.h2
-rw-r--r--fpdfsdk/pdfwindow/cpwl_edit_ctrl.cpp1
-rw-r--r--fpdfsdk/pdfwindow/cpwl_icon.cpp34
-rw-r--r--fpdfsdk/pdfwindow/cpwl_icon.h7
-rw-r--r--fpdfsdk/pdfwindow/cpwl_list_box.cpp1
-rw-r--r--fpdfsdk/pdfwindow/cpwl_scroll_bar.cpp1
-rw-r--r--fpdfsdk/pdfwindow/cpwl_special_button.cpp1
-rw-r--r--fpdfsdk/pdfwindow/cpwl_utils.cpp184
-rw-r--r--fpdfsdk/pdfwindow/cpwl_utils.h57
-rw-r--r--fpdfsdk/pdfwindow/cpwl_wnd.cpp1
21 files changed, 450 insertions, 621 deletions
diff --git a/fpdfsdk/cpdfsdk_interform.cpp b/fpdfsdk/cpdfsdk_interform.cpp
index 116f5f5cee..ebbe02c29b 100644
--- a/fpdfsdk/cpdfsdk_interform.cpp
+++ b/fpdfsdk/cpdfsdk_interform.cpp
@@ -32,7 +32,6 @@
#include "fpdfsdk/ipdfsdk_annothandler.h"
#include "fpdfsdk/javascript/ijs_event_context.h"
#include "fpdfsdk/javascript/ijs_runtime.h"
-#include "fpdfsdk/pdfwindow/cpwl_utils.h"
#include "third_party/base/stl_util.h"
#ifdef PDF_ENABLE_XFA
diff --git a/fpdfsdk/cpdfsdk_widget.cpp b/fpdfsdk/cpdfsdk_widget.cpp
index fed6b953da..afc83edb07 100644
--- a/fpdfsdk/cpdfsdk_widget.cpp
+++ b/fpdfsdk/cpdfsdk_widget.cpp
@@ -32,7 +32,6 @@
#include "fpdfsdk/fxedit/fxet_edit.h"
#include "fpdfsdk/pdfwindow/cpwl_appstream.h"
#include "fpdfsdk/pdfwindow/cpwl_edit.h"
-#include "fpdfsdk/pdfwindow/cpwl_utils.h"
#ifdef PDF_ENABLE_XFA
#include "fpdfsdk/fpdfxfa/cpdfxfa_context.h"
diff --git a/fpdfsdk/formfiller/cffl_formfiller.cpp b/fpdfsdk/formfiller/cffl_formfiller.cpp
index 34e1e68c13..edbd671f29 100644
--- a/fpdfsdk/formfiller/cffl_formfiller.cpp
+++ b/fpdfsdk/formfiller/cffl_formfiller.cpp
@@ -15,7 +15,6 @@
#include "fpdfsdk/cpdfsdk_widget.h"
#include "fpdfsdk/formfiller/cba_fontmap.h"
#include "fpdfsdk/fsdk_common.h"
-#include "fpdfsdk/pdfwindow/cpwl_utils.h"
namespace {
diff --git a/fpdfsdk/formfiller/cffl_interactiveformfiller.cpp b/fpdfsdk/formfiller/cffl_interactiveformfiller.cpp
index 5f5e21a274..ee74b9928b 100644
--- a/fpdfsdk/formfiller/cffl_interactiveformfiller.cpp
+++ b/fpdfsdk/formfiller/cffl_interactiveformfiller.cpp
@@ -22,7 +22,6 @@
#include "fpdfsdk/formfiller/cffl_pushbutton.h"
#include "fpdfsdk/formfiller/cffl_radiobutton.h"
#include "fpdfsdk/formfiller/cffl_textfield.h"
-#include "fpdfsdk/pdfwindow/cpwl_utils.h"
#include "third_party/base/stl_util.h"
CFFL_InteractiveFormFiller::CFFL_InteractiveFormFiller(
diff --git a/fpdfsdk/fxedit/fxet_edit.cpp b/fpdfsdk/fxedit/fxet_edit.cpp
index cf382f8426..41019b3459 100644
--- a/fpdfsdk/fxedit/fxet_edit.cpp
+++ b/fpdfsdk/fxedit/fxet_edit.cpp
@@ -38,27 +38,6 @@ namespace {
const int kEditUndoMaxItems = 10000;
-CFX_ByteString GetWordRenderString(const CFX_ByteString& strWords) {
- if (strWords.GetLength() > 0)
- return PDF_EncodeString(strWords, false) + " Tj\n";
- return CFX_ByteString();
-}
-
-CFX_ByteString GetFontSetString(IPVT_FontMap* pFontMap,
- int32_t nFontIndex,
- float fFontSize) {
- if (!pFontMap)
- return CFX_ByteString();
-
- CFX_ByteString sFontAlias = pFontMap->GetPDFFontAlias(nFontIndex);
- if (sFontAlias.GetLength() <= 0 || fFontSize <= 0)
- return CFX_ByteString();
-
- std::ostringstream sRet;
- sRet << "/" << sFontAlias << " " << fFontSize << " Tf\n";
- return CFX_ByteString(sRet);
-}
-
void DrawTextString(CFX_RenderDevice* pDevice,
const CFX_PointF& pt,
CPDF_Font* pFont,
@@ -514,149 +493,6 @@ void CFXEU_InsertText::Undo() {
}
// static
-CFX_ByteString CFX_Edit::GetEditAppearanceStream(CFX_Edit* pEdit,
- const CFX_PointF& ptOffset,
- const CPVT_WordRange* pRange,
- bool bContinuous,
- uint16_t SubWord) {
- CFX_Edit_Iterator* pIterator = pEdit->GetIterator();
- if (pRange)
- pIterator->SetAt(pRange->BeginPos);
- else
- pIterator->SetAt(0);
-
- std::ostringstream sEditStream;
- std::ostringstream sWords;
- int32_t nCurFontIndex = -1;
- CFX_PointF ptOld;
- CFX_PointF ptNew;
- CPVT_WordPlace oldplace;
-
- while (pIterator->NextWord()) {
- CPVT_WordPlace place = pIterator->GetAt();
- if (pRange && place > pRange->EndPos)
- break;
-
- if (bContinuous) {
- if (place.LineCmp(oldplace) != 0) {
- if (sWords.tellp() > 0) {
- sEditStream << GetWordRenderString(CFX_ByteString(sWords));
- sWords.str("");
- }
-
- CPVT_Word word;
- if (pIterator->GetWord(word)) {
- ptNew = CFX_PointF(word.ptWord.x + ptOffset.x,
- word.ptWord.y + ptOffset.y);
- } else {
- CPVT_Line line;
- pIterator->GetLine(line);
- ptNew = CFX_PointF(line.ptLine.x + ptOffset.x,
- line.ptLine.y + ptOffset.y);
- }
-
- if (ptNew.x != ptOld.x || ptNew.y != ptOld.y) {
- sEditStream << ptNew.x - ptOld.x << " " << ptNew.y - ptOld.y
- << " Td\n";
-
- ptOld = ptNew;
- }
- }
-
- CPVT_Word word;
- if (pIterator->GetWord(word)) {
- if (word.nFontIndex != nCurFontIndex) {
- if (sWords.tellp() > 0) {
- sEditStream << GetWordRenderString(CFX_ByteString(sWords));
- sWords.str("");
- }
- sEditStream << GetFontSetString(pEdit->GetFontMap(), word.nFontIndex,
- word.fFontSize);
- nCurFontIndex = word.nFontIndex;
- }
-
- sWords << GetPDFWordString(pEdit->GetFontMap(), nCurFontIndex,
- word.Word, SubWord);
- }
-
- oldplace = place;
- } else {
- CPVT_Word word;
- if (pIterator->GetWord(word)) {
- ptNew =
- CFX_PointF(word.ptWord.x + ptOffset.x, word.ptWord.y + ptOffset.y);
-
- if (ptNew.x != ptOld.x || ptNew.y != ptOld.y) {
- sEditStream << ptNew.x - ptOld.x << " " << ptNew.y - ptOld.y
- << " Td\n";
- ptOld = ptNew;
- }
-
- if (word.nFontIndex != nCurFontIndex) {
- sEditStream << GetFontSetString(pEdit->GetFontMap(), word.nFontIndex,
- word.fFontSize);
- nCurFontIndex = word.nFontIndex;
- }
-
- sEditStream << GetWordRenderString(GetPDFWordString(
- pEdit->GetFontMap(), nCurFontIndex, word.Word, SubWord));
- }
- }
- }
-
- if (sWords.tellp() > 0) {
- sEditStream << GetWordRenderString(CFX_ByteString(sWords));
- sWords.str("");
- }
-
- std::ostringstream sAppStream;
- if (sEditStream.tellp() > 0) {
- int32_t nHorzScale = pEdit->GetHorzScale();
- if (nHorzScale != 100) {
- sAppStream << nHorzScale << " Tz\n";
- }
-
- float fCharSpace = pEdit->GetCharSpace();
- if (!IsFloatZero(fCharSpace)) {
- sAppStream << fCharSpace << " Tc\n";
- }
-
- sAppStream << sEditStream.str();
- }
-
- return CFX_ByteString(sAppStream);
-}
-
-// static
-CFX_ByteString CFX_Edit::GetSelectAppearanceStream(
- CFX_Edit* pEdit,
- const CFX_PointF& ptOffset,
- const CPVT_WordRange* pRange) {
- if (!pRange || pRange->IsEmpty())
- return CFX_ByteString();
-
- CFX_Edit_Iterator* pIterator = pEdit->GetIterator();
- pIterator->SetAt(pRange->BeginPos);
-
- std::ostringstream sRet;
- while (pIterator->NextWord()) {
- CPVT_WordPlace place = pIterator->GetAt();
- if (place > pRange->EndPos)
- break;
-
- CPVT_Word word;
- CPVT_Line line;
- if (pIterator->GetWord(word) && pIterator->GetLine(line)) {
- sRet << word.ptWord.x + ptOffset.x << " "
- << line.ptLine.y + line.fLineDescent << " " << word.fWidth << " "
- << line.fLineAscent - line.fLineDescent << " re\nf\n";
- }
- }
-
- return CFX_ByteString(sRet);
-}
-
-// static
void CFX_Edit::DrawEdit(CFX_RenderDevice* pDevice,
CFX_Matrix* pUser2Device,
CFX_Edit* pEdit,
diff --git a/fpdfsdk/fxedit/fxet_edit.h b/fpdfsdk/fxedit/fxet_edit.h
index 01759aaba9..c0c8442d52 100644
--- a/fpdfsdk/fxedit/fxet_edit.h
+++ b/fpdfsdk/fxedit/fxet_edit.h
@@ -286,14 +286,6 @@ class CFXEU_InsertText : public CFX_Edit_UndoItem {
class CFX_Edit {
public:
- static CFX_ByteString GetEditAppearanceStream(CFX_Edit* pEdit,
- const CFX_PointF& ptOffset,
- const CPVT_WordRange* pRange,
- bool bContinuous,
- uint16_t SubWord);
- static CFX_ByteString GetSelectAppearanceStream(CFX_Edit* pEdit,
- const CFX_PointF& ptOffset,
- const CPVT_WordRange* pRange);
static void DrawEdit(CFX_RenderDevice* pDevice,
CFX_Matrix* pUser2Device,
CFX_Edit* pEdit,
diff --git a/fpdfsdk/pdfwindow/cpwl_appstream.cpp b/fpdfsdk/pdfwindow/cpwl_appstream.cpp
index 2b158cdfd0..cf291e341d 100644
--- a/fpdfsdk/pdfwindow/cpwl_appstream.cpp
+++ b/fpdfsdk/pdfwindow/cpwl_appstream.cpp
@@ -15,6 +15,8 @@
#include "core/fpdfapi/parser/cpdf_reference.h"
#include "core/fpdfapi/parser/cpdf_stream.h"
#include "core/fpdfapi/parser/cpdf_string.h"
+#include "core/fpdfapi/parser/fpdf_parser_decode.h"
+#include "core/fpdfdoc/cpvt_word.h"
#include "fpdfsdk/cpdfsdk_formfillenvironment.h"
#include "fpdfsdk/cpdfsdk_interform.h"
#include "fpdfsdk/cpdfsdk_pageview.h"
@@ -23,11 +25,48 @@
#include "fpdfsdk/fxedit/fxet_edit.h"
#include "fpdfsdk/pdfwindow/cpwl_edit.h"
#include "fpdfsdk/pdfwindow/cpwl_icon.h"
-#include "fpdfsdk/pdfwindow/cpwl_utils.h"
#include "fpdfsdk/pdfwindow/cpwl_wnd.h"
namespace {
+// Checkbox & radiobutton styles.
+enum class CheckStyle { kCheck = 0, kCircle, kCross, kDiamond, kSquare, kStar };
+
+// Pushbutton layout styles.
+enum class ButtonStyle {
+ kLabel = 0,
+ kIcon,
+ kIconTopLabelBottom,
+ kIconBottomLabelTop,
+ kIconLeftLabelRight,
+ kIconRightLabelLeft,
+ kLabelOverIcon
+};
+
+CFX_ByteString GetColorAppStream(const CFX_Color& color,
+ const bool& bFillOrStroke) {
+ std::ostringstream sColorStream;
+
+ switch (color.nColorType) {
+ case COLORTYPE_RGB:
+ sColorStream << color.fColor1 << " " << color.fColor2 << " "
+ << color.fColor3 << " " << (bFillOrStroke ? "rg" : "RG")
+ << "\n";
+ break;
+ case COLORTYPE_GRAY:
+ sColorStream << color.fColor1 << " " << (bFillOrStroke ? "g" : "G")
+ << "\n";
+ break;
+ case COLORTYPE_CMYK:
+ sColorStream << color.fColor1 << " " << color.fColor2 << " "
+ << color.fColor3 << " " << color.fColor4 << " "
+ << (bFillOrStroke ? "k" : "K") << "\n";
+ break;
+ }
+
+ return CFX_ByteString(sColorStream);
+}
+
CFX_ByteString GetAP_Check(const CFX_FloatRect& crBBox) {
const float fWidth = crBBox.right - crBBox.left;
const float fHeight = crBBox.top - crBBox.bottom;
@@ -230,8 +269,7 @@ CFX_ByteString GetAppStream_Check(const CFX_FloatRect& rcBBox,
const CFX_Color& crText) {
std::ostringstream sAP;
sAP << "q\n"
- << CPWL_Utils::GetColorAppStream(crText, true) << GetAP_Check(rcBBox)
- << "f\nQ\n";
+ << GetColorAppStream(crText, true) << GetAP_Check(rcBBox) << "f\nQ\n";
return CFX_ByteString(sAP);
}
@@ -239,8 +277,7 @@ CFX_ByteString GetAppStream_Circle(const CFX_FloatRect& rcBBox,
const CFX_Color& crText) {
std::ostringstream sAP;
sAP << "q\n"
- << CPWL_Utils::GetColorAppStream(crText, true) << GetAP_Circle(rcBBox)
- << "f\nQ\n";
+ << GetColorAppStream(crText, true) << GetAP_Circle(rcBBox) << "f\nQ\n";
return CFX_ByteString(sAP);
}
@@ -248,8 +285,7 @@ CFX_ByteString GetAppStream_Cross(const CFX_FloatRect& rcBBox,
const CFX_Color& crText) {
std::ostringstream sAP;
sAP << "q\n"
- << CPWL_Utils::GetColorAppStream(crText, false) << GetAP_Cross(rcBBox)
- << "S\nQ\n";
+ << GetColorAppStream(crText, false) << GetAP_Cross(rcBBox) << "S\nQ\n";
return CFX_ByteString(sAP);
}
@@ -257,8 +293,7 @@ CFX_ByteString GetAppStream_Diamond(const CFX_FloatRect& rcBBox,
const CFX_Color& crText) {
std::ostringstream sAP;
sAP << "q\n1 w\n"
- << CPWL_Utils::GetColorAppStream(crText, true) << GetAP_Diamond(rcBBox)
- << "f\nQ\n";
+ << GetColorAppStream(crText, true) << GetAP_Diamond(rcBBox) << "f\nQ\n";
return CFX_ByteString(sAP);
}
@@ -266,8 +301,7 @@ CFX_ByteString GetAppStream_Square(const CFX_FloatRect& rcBBox,
const CFX_Color& crText) {
std::ostringstream sAP;
sAP << "q\n"
- << CPWL_Utils::GetColorAppStream(crText, true) << GetAP_Square(rcBBox)
- << "f\nQ\n";
+ << GetColorAppStream(crText, true) << GetAP_Square(rcBBox) << "f\nQ\n";
return CFX_ByteString(sAP);
}
@@ -275,15 +309,14 @@ CFX_ByteString GetAppStream_Star(const CFX_FloatRect& rcBBox,
const CFX_Color& crText) {
std::ostringstream sAP;
sAP << "q\n"
- << CPWL_Utils::GetColorAppStream(crText, true) << GetAP_Star(rcBBox)
- << "f\nQ\n";
+ << GetColorAppStream(crText, true) << GetAP_Star(rcBBox) << "f\nQ\n";
return CFX_ByteString(sAP);
}
CFX_ByteString GetCircleFillAppStream(const CFX_FloatRect& rect,
const CFX_Color& color) {
std::ostringstream sAppStream;
- CFX_ByteString sColor = CPWL_Utils::GetColorAppStream(color, true);
+ CFX_ByteString sColor = GetColorAppStream(color, true);
if (sColor.GetLength() > 0)
sAppStream << "q\n" << sColor << GetAP_Circle(rect) << "f\nQ\n";
return CFX_ByteString(sAppStream);
@@ -311,7 +344,7 @@ CFX_ByteString GetCircleBorderAppStream(const CFX_FloatRect& rect,
default:
case BorderStyle::SOLID:
case BorderStyle::UNDERLINE: {
- sColor = CPWL_Utils::GetColorAppStream(color, false);
+ sColor = GetColorAppStream(color, false);
if (sColor.GetLength() > 0) {
sAppStream << "q\n"
<< fWidth << " w\n"
@@ -319,7 +352,7 @@ CFX_ByteString GetCircleBorderAppStream(const CFX_FloatRect& rect,
}
} break;
case BorderStyle::DASH: {
- sColor = CPWL_Utils::GetColorAppStream(color, false);
+ sColor = GetColorAppStream(color, false);
if (sColor.GetLength() > 0) {
sAppStream << "q\n"
<< fWidth << " w\n"
@@ -329,14 +362,14 @@ CFX_ByteString GetCircleBorderAppStream(const CFX_FloatRect& rect,
}
} break;
case BorderStyle::BEVELED: {
- sColor = CPWL_Utils::GetColorAppStream(color, false);
+ sColor = GetColorAppStream(color, false);
if (sColor.GetLength() > 0) {
sAppStream << "q\n"
<< fHalfWidth << " w\n"
<< sColor << GetAP_Circle(rect) << " S\nQ\n";
}
- sColor = CPWL_Utils::GetColorAppStream(crLeftTop, false);
+ sColor = GetColorAppStream(crLeftTop, false);
if (sColor.GetLength() > 0) {
sAppStream << "q\n"
<< fHalfWidth << " w\n"
@@ -344,7 +377,7 @@ CFX_ByteString GetCircleBorderAppStream(const CFX_FloatRect& rect,
<< " S\nQ\n";
}
- sColor = CPWL_Utils::GetColorAppStream(crRightBottom, false);
+ sColor = GetColorAppStream(crRightBottom, false);
if (sColor.GetLength() > 0) {
sAppStream << "q\n"
<< fHalfWidth << " w\n"
@@ -353,14 +386,14 @@ CFX_ByteString GetCircleBorderAppStream(const CFX_FloatRect& rect,
}
} break;
case BorderStyle::INSET: {
- sColor = CPWL_Utils::GetColorAppStream(color, false);
+ sColor = GetColorAppStream(color, false);
if (sColor.GetLength() > 0) {
sAppStream << "q\n"
<< fHalfWidth << " w\n"
<< sColor << GetAP_Circle(rect) << " S\nQ\n";
}
- sColor = CPWL_Utils::GetColorAppStream(crLeftTop, false);
+ sColor = GetColorAppStream(crLeftTop, false);
if (sColor.GetLength() > 0) {
sAppStream << "q\n"
<< fHalfWidth << " w\n"
@@ -368,7 +401,7 @@ CFX_ByteString GetCircleBorderAppStream(const CFX_FloatRect& rect,
<< " S\nQ\n";
}
- sColor = CPWL_Utils::GetColorAppStream(crRightBottom, false);
+ sColor = GetColorAppStream(crRightBottom, false);
if (sColor.GetLength() > 0) {
sAppStream << "q\n"
<< fHalfWidth << " w\n"
@@ -384,55 +417,182 @@ CFX_ByteString GetCircleBorderAppStream(const CFX_FloatRect& rect,
}
CFX_ByteString GetCheckBoxAppStream(const CFX_FloatRect& rcBBox,
- int32_t nStyle,
+ CheckStyle nStyle,
const CFX_Color& crText) {
CFX_FloatRect rcCenter = rcBBox.GetCenterSquare();
switch (nStyle) {
default:
- case PCS_CHECK:
+ case CheckStyle::kCheck:
return GetAppStream_Check(rcCenter, crText);
- case PCS_CIRCLE:
+ case CheckStyle::kCircle:
rcCenter.Scale(2.0f / 3.0f);
return GetAppStream_Circle(rcCenter, crText);
- case PCS_CROSS:
+ case CheckStyle::kCross:
return GetAppStream_Cross(rcCenter, crText);
- case PCS_DIAMOND:
+ case CheckStyle::kDiamond:
rcCenter.Scale(2.0f / 3.0f);
return GetAppStream_Diamond(rcCenter, crText);
- case PCS_SQUARE:
+ case CheckStyle::kSquare:
rcCenter.Scale(2.0f / 3.0f);
return GetAppStream_Square(rcCenter, crText);
- case PCS_STAR:
+ case CheckStyle::kStar:
rcCenter.Scale(2.0f / 3.0f);
return GetAppStream_Star(rcCenter, crText);
}
}
CFX_ByteString GetRadioButtonAppStream(const CFX_FloatRect& rcBBox,
- int32_t nStyle,
+ CheckStyle nStyle,
const CFX_Color& crText) {
CFX_FloatRect rcCenter = rcBBox.GetCenterSquare();
switch (nStyle) {
default:
- case PCS_CHECK:
+ case CheckStyle::kCheck:
return GetAppStream_Check(rcCenter, crText);
- case PCS_CIRCLE:
+ case CheckStyle::kCircle:
rcCenter.Scale(1.0f / 2.0f);
return GetAppStream_Circle(rcCenter, crText);
- case PCS_CROSS:
+ case CheckStyle::kCross:
return GetAppStream_Cross(rcCenter, crText);
- case PCS_DIAMOND:
+ case CheckStyle::kDiamond:
rcCenter.Scale(2.0f / 3.0f);
return GetAppStream_Diamond(rcCenter, crText);
- case PCS_SQUARE:
+ case CheckStyle::kSquare:
rcCenter.Scale(2.0f / 3.0f);
return GetAppStream_Square(rcCenter, crText);
- case PCS_STAR:
+ case CheckStyle::kStar:
rcCenter.Scale(2.0f / 3.0f);
return GetAppStream_Star(rcCenter, crText);
}
}
+CFX_ByteString GetFontSetString(IPVT_FontMap* pFontMap,
+ int32_t nFontIndex,
+ float fFontSize) {
+ if (!pFontMap)
+ return CFX_ByteString();
+
+ CFX_ByteString sFontAlias = pFontMap->GetPDFFontAlias(nFontIndex);
+ if (sFontAlias.GetLength() <= 0 || fFontSize <= 0)
+ return CFX_ByteString();
+
+ std::ostringstream sRet;
+ sRet << "/" << sFontAlias << " " << fFontSize << " Tf\n";
+ return CFX_ByteString(sRet);
+}
+
+CFX_ByteString GetWordRenderString(const CFX_ByteString& strWords) {
+ if (strWords.GetLength() > 0)
+ return PDF_EncodeString(strWords, false) + " Tj\n";
+ return CFX_ByteString();
+}
+
+CFX_ByteString GetEditAppStream(CFX_Edit* pEdit,
+ const CFX_PointF& ptOffset,
+ bool bContinuous,
+ uint16_t SubWord) {
+ CFX_Edit_Iterator* pIterator = pEdit->GetIterator();
+ pIterator->SetAt(0);
+
+ std::ostringstream sEditStream;
+ std::ostringstream sWords;
+ int32_t nCurFontIndex = -1;
+ CFX_PointF ptOld;
+ CFX_PointF ptNew;
+ CPVT_WordPlace oldplace;
+
+ while (pIterator->NextWord()) {
+ CPVT_WordPlace place = pIterator->GetAt();
+ if (bContinuous) {
+ if (place.LineCmp(oldplace) != 0) {
+ if (sWords.tellp() > 0) {
+ sEditStream << GetWordRenderString(CFX_ByteString(sWords));
+ sWords.str("");
+ }
+
+ CPVT_Word word;
+ if (pIterator->GetWord(word)) {
+ ptNew = CFX_PointF(word.ptWord.x + ptOffset.x,
+ word.ptWord.y + ptOffset.y);
+ } else {
+ CPVT_Line line;
+ pIterator->GetLine(line);
+ ptNew = CFX_PointF(line.ptLine.x + ptOffset.x,
+ line.ptLine.y + ptOffset.y);
+ }
+
+ if (ptNew.x != ptOld.x || ptNew.y != ptOld.y) {
+ sEditStream << ptNew.x - ptOld.x << " " << ptNew.y - ptOld.y
+ << " Td\n";
+
+ ptOld = ptNew;
+ }
+ }
+
+ CPVT_Word word;
+ if (pIterator->GetWord(word)) {
+ if (word.nFontIndex != nCurFontIndex) {
+ if (sWords.tellp() > 0) {
+ sEditStream << GetWordRenderString(CFX_ByteString(sWords));
+ sWords.str("");
+ }
+ sEditStream << GetFontSetString(pEdit->GetFontMap(), word.nFontIndex,
+ word.fFontSize);
+ nCurFontIndex = word.nFontIndex;
+ }
+
+ sWords << GetPDFWordString(pEdit->GetFontMap(), nCurFontIndex,
+ word.Word, SubWord);
+ }
+
+ oldplace = place;
+ } else {
+ CPVT_Word word;
+ if (pIterator->GetWord(word)) {
+ ptNew =
+ CFX_PointF(word.ptWord.x + ptOffset.x, word.ptWord.y + ptOffset.y);
+
+ if (ptNew.x != ptOld.x || ptNew.y != ptOld.y) {
+ sEditStream << ptNew.x - ptOld.x << " " << ptNew.y - ptOld.y
+ << " Td\n";
+ ptOld = ptNew;
+ }
+
+ if (word.nFontIndex != nCurFontIndex) {
+ sEditStream << GetFontSetString(pEdit->GetFontMap(), word.nFontIndex,
+ word.fFontSize);
+ nCurFontIndex = word.nFontIndex;
+ }
+
+ sEditStream << GetWordRenderString(GetPDFWordString(
+ pEdit->GetFontMap(), nCurFontIndex, word.Word, SubWord));
+ }
+ }
+ }
+
+ if (sWords.tellp() > 0) {
+ sEditStream << GetWordRenderString(CFX_ByteString(sWords));
+ sWords.str("");
+ }
+
+ std::ostringstream sAppStream;
+ if (sEditStream.tellp() > 0) {
+ int32_t nHorzScale = pEdit->GetHorzScale();
+ if (nHorzScale != 100) {
+ sAppStream << nHorzScale << " Tz\n";
+ }
+
+ float fCharSpace = pEdit->GetCharSpace();
+ if (!IsFloatZero(fCharSpace)) {
+ sAppStream << fCharSpace << " Tc\n";
+ }
+
+ sAppStream << sEditStream.str();
+ }
+
+ return CFX_ByteString(sAppStream);
+}
+
CFX_ByteString GetPushButtonAppStream(const CFX_FloatRect& rcBBox,
IPVT_FontMap* pFontMap,
CPDF_Stream* pIconStream,
@@ -440,7 +600,7 @@ CFX_ByteString GetPushButtonAppStream(const CFX_FloatRect& rcBBox,
const CFX_WideString& sLabel,
const CFX_Color& crText,
float fFontSize,
- int32_t nLayOut) {
+ ButtonStyle nLayOut) {
const float fAutoFontScale = 1.0f / 3.0f;
auto pEdit = pdfium::MakeUnique<CFX_Edit>();
@@ -458,26 +618,19 @@ CFX_ByteString GetPushButtonAppStream(const CFX_FloatRect& rcBBox,
pEdit->SetText(sLabel);
CFX_FloatRect rcLabelContent = pEdit->GetContentRect();
- CPWL_Icon Icon;
- PWL_CREATEPARAM cp;
- cp.dwFlags = PWS_VISIBLE;
- Icon.Create(cp);
- Icon.SetIconFit(&IconFit);
- Icon.SetPDFStream(pIconStream);
-
CFX_FloatRect rcLabel;
CFX_FloatRect rcIcon;
float fWidth = 0.0f;
float fHeight = 0.0f;
switch (nLayOut) {
- case PPBL_LABEL:
+ case ButtonStyle::kLabel:
rcLabel = rcBBox;
break;
- case PPBL_ICON:
+ case ButtonStyle::kIcon:
rcIcon = rcBBox;
break;
- case PPBL_ICONTOPLABELBOTTOM:
+ case ButtonStyle::kIconTopLabelBottom:
if (pIconStream) {
if (IsFloatZero(fFontSize)) {
fHeight = rcBBox.top - rcBBox.bottom;
@@ -501,7 +654,7 @@ CFX_ByteString GetPushButtonAppStream(const CFX_FloatRect& rcBBox,
rcLabel = rcBBox;
}
break;
- case PPBL_LABELTOPICONBOTTOM:
+ case ButtonStyle::kIconBottomLabelTop:
if (pIconStream) {
if (IsFloatZero(fFontSize)) {
fHeight = rcBBox.top - rcBBox.bottom;
@@ -526,7 +679,7 @@ CFX_ByteString GetPushButtonAppStream(const CFX_FloatRect& rcBBox,
rcLabel = rcBBox;
}
break;
- case PPBL_ICONLEFTLABELRIGHT:
+ case ButtonStyle::kIconLeftLabelRight:
if (pIconStream) {
if (IsFloatZero(fFontSize)) {
fWidth = rcBBox.right - rcBBox.left;
@@ -560,7 +713,7 @@ CFX_ByteString GetPushButtonAppStream(const CFX_FloatRect& rcBBox,
rcLabel = rcBBox;
}
break;
- case PPBL_LABELLEFTICONRIGHT:
+ case ButtonStyle::kIconRightLabelLeft:
if (pIconStream) {
if (IsFloatZero(fFontSize)) {
fWidth = rcBBox.right - rcBBox.left;
@@ -596,7 +749,7 @@ CFX_ByteString GetPushButtonAppStream(const CFX_FloatRect& rcBBox,
rcLabel = rcBBox;
}
break;
- case PPBL_LABELOVERICON:
+ case ButtonStyle::kLabelOverIcon:
rcLabel = rcBBox;
rcIcon = rcBBox;
break;
@@ -605,19 +758,51 @@ CFX_ByteString GetPushButtonAppStream(const CFX_FloatRect& rcBBox,
std::ostringstream sTemp;
if (!rcIcon.IsEmpty()) {
- Icon.Move(rcIcon, false, false);
- sTemp << Icon.GetImageAppStream();
+ CPWL_Icon icon;
+ PWL_CREATEPARAM cp;
+ cp.dwFlags = PWS_VISIBLE;
+ icon.Create(cp);
+ icon.SetIconFit(&IconFit);
+ icon.SetPDFStream(pIconStream);
+ icon.Move(rcIcon, false, false);
+
+ CFX_ByteString sAlias = icon.GetImageAlias();
+ if (sAlias.GetLength() > 0) {
+ CFX_FloatRect rcPlate = icon.GetClientRect();
+ CFX_Matrix mt = icon.GetImageMatrix().GetInverse();
+
+ float fHScale = 1.0f;
+ float fVScale = 1.0f;
+ icon.GetScale(fHScale, fVScale);
+
+ float fx = 0.0f;
+ float fy = 0.0f;
+ icon.GetImageOffset(fx, fy);
+
+ if (icon.GetPDFStream()) {
+ sTemp << "q\n";
+ sTemp << rcPlate.left << " " << rcPlate.bottom << " "
+ << rcPlate.right - rcPlate.left << " "
+ << rcPlate.top - rcPlate.bottom << " re W n\n";
+
+ sTemp << fHScale << " 0 0 " << fVScale << " " << rcPlate.left + fx
+ << " " << rcPlate.bottom + fy << " cm\n";
+ sTemp << mt.a << " " << mt.b << " " << mt.c << " " << mt.d << " "
+ << mt.e << " " << mt.f << " cm\n";
+
+ sTemp << "0 g 0 G 1 w /" << sAlias << " Do\n"
+ << "Q\n";
+ }
+ }
+ icon.Destroy();
}
- Icon.Destroy();
-
if (!rcLabel.IsEmpty()) {
pEdit->SetPlateRect(rcLabel);
CFX_ByteString sEdit =
- CPWL_Utils::GetEditAppStream(pEdit.get(), CFX_PointF(0.0f, 0.0f));
+ GetEditAppStream(pEdit.get(), CFX_PointF(0.0f, 0.0f), true, 0);
if (sEdit.GetLength() > 0) {
- sTemp << "BT\n"
- << CPWL_Utils::GetColorAppStream(crText) << sEdit << "ET\n";
+ sTemp << "BT\n" << GetColorAppStream(crText, true) << sEdit << "ET\n";
}
}
@@ -633,23 +818,138 @@ CFX_ByteString GetPushButtonAppStream(const CFX_FloatRect& rcBBox,
return CFX_ByteString(sAppStream);
}
+CFX_ByteString GetBorderAppStreamInternal(const CFX_FloatRect& rect,
+ float fWidth,
+ const CFX_Color& color,
+ const CFX_Color& crLeftTop,
+ const CFX_Color& crRightBottom,
+ BorderStyle nStyle,
+ const CPWL_Dash& dash) {
+ std::ostringstream sAppStream;
+ CFX_ByteString sColor;
+
+ float fLeft = rect.left;
+ float fRight = rect.right;
+ float fTop = rect.top;
+ float fBottom = rect.bottom;
+
+ if (fWidth > 0.0f) {
+ float fHalfWidth = fWidth / 2.0f;
+
+ sAppStream << "q\n";
+
+ switch (nStyle) {
+ default:
+ case BorderStyle::SOLID:
+ sColor = GetColorAppStream(color, true);
+ if (sColor.GetLength() > 0) {
+ sAppStream << sColor;
+ sAppStream << fLeft << " " << fBottom << " " << fRight - fLeft << " "
+ << fTop - fBottom << " re\n";
+ sAppStream << fLeft + fWidth << " " << fBottom + fWidth << " "
+ << fRight - fLeft - fWidth * 2 << " "
+ << fTop - fBottom - fWidth * 2 << " re\n";
+ sAppStream << "f*\n";
+ }
+ break;
+ case BorderStyle::DASH:
+ sColor = GetColorAppStream(color, false);
+ if (sColor.GetLength() > 0) {
+ sAppStream << sColor;
+ sAppStream << fWidth << " w"
+ << " [" << dash.nDash << " " << dash.nGap << "] "
+ << dash.nPhase << " d\n";
+ sAppStream << fLeft + fWidth / 2 << " " << fBottom + fWidth / 2
+ << " m\n";
+ sAppStream << fLeft + fWidth / 2 << " " << fTop - fWidth / 2
+ << " l\n";
+ sAppStream << fRight - fWidth / 2 << " " << fTop - fWidth / 2
+ << " l\n";
+ sAppStream << fRight - fWidth / 2 << " " << fBottom + fWidth / 2
+ << " l\n";
+ sAppStream << fLeft + fWidth / 2 << " " << fBottom + fWidth / 2
+ << " l S\n";
+ }
+ break;
+ case BorderStyle::BEVELED:
+ case BorderStyle::INSET:
+ sColor = GetColorAppStream(crLeftTop, true);
+ if (sColor.GetLength() > 0) {
+ sAppStream << sColor;
+ sAppStream << fLeft + fHalfWidth << " " << fBottom + fHalfWidth
+ << " m\n";
+ sAppStream << fLeft + fHalfWidth << " " << fTop - fHalfWidth
+ << " l\n";
+ sAppStream << fRight - fHalfWidth << " " << fTop - fHalfWidth
+ << " l\n";
+ sAppStream << fRight - fHalfWidth * 2 << " " << fTop - fHalfWidth * 2
+ << " l\n";
+ sAppStream << fLeft + fHalfWidth * 2 << " " << fTop - fHalfWidth * 2
+ << " l\n";
+ sAppStream << fLeft + fHalfWidth * 2 << " "
+ << fBottom + fHalfWidth * 2 << " l f\n";
+ }
+
+ sColor = GetColorAppStream(crRightBottom, true);
+ if (sColor.GetLength() > 0) {
+ sAppStream << sColor;
+ sAppStream << fRight - fHalfWidth << " " << fTop - fHalfWidth
+ << " m\n";
+ sAppStream << fRight - fHalfWidth << " " << fBottom + fHalfWidth
+ << " l\n";
+ sAppStream << fLeft + fHalfWidth << " " << fBottom + fHalfWidth
+ << " l\n";
+ sAppStream << fLeft + fHalfWidth * 2 << " "
+ << fBottom + fHalfWidth * 2 << " l\n";
+ sAppStream << fRight - fHalfWidth * 2 << " "
+ << fBottom + fHalfWidth * 2 << " l\n";
+ sAppStream << fRight - fHalfWidth * 2 << " " << fTop - fHalfWidth * 2
+ << " l f\n";
+ }
+
+ sColor = GetColorAppStream(color, true);
+ if (sColor.GetLength() > 0) {
+ sAppStream << sColor;
+ sAppStream << fLeft << " " << fBottom << " " << fRight - fLeft << " "
+ << fTop - fBottom << " re\n";
+ sAppStream << fLeft + fHalfWidth << " " << fBottom + fHalfWidth << " "
+ << fRight - fLeft - fHalfWidth * 2 << " "
+ << fTop - fBottom - fHalfWidth * 2 << " re f*\n";
+ }
+ break;
+ case BorderStyle::UNDERLINE:
+ sColor = GetColorAppStream(color, false);
+ if (sColor.GetLength() > 0) {
+ sAppStream << sColor;
+ sAppStream << fWidth << " w\n";
+ sAppStream << fLeft << " " << fBottom + fWidth / 2 << " m\n";
+ sAppStream << fRight << " " << fBottom + fWidth / 2 << " l S\n";
+ }
+ break;
+ }
+
+ sAppStream << "Q\n";
+ }
+
+ return CFX_ByteString(sAppStream);
+}
+
CFX_ByteString GetDropButtonAppStream(const CFX_FloatRect& rcBBox) {
if (rcBBox.IsEmpty())
return CFX_ByteString();
std::ostringstream sAppStream;
sAppStream << "q\n"
- << CPWL_Utils::GetColorAppStream(
- CFX_Color(COLORTYPE_RGB, 220.0f / 255.0f, 220.0f / 255.0f,
- 220.0f / 255.0f),
- true)
+ << GetColorAppStream(CFX_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(
+ << GetBorderAppStreamInternal(
rcBBox, 2, CFX_Color(COLORTYPE_GRAY, 0),
CFX_Color(COLORTYPE_GRAY, 1),
CFX_Color(COLORTYPE_GRAY, 0.5), BorderStyle::BEVELED,
@@ -672,6 +972,20 @@ CFX_ByteString GetDropButtonAppStream(const CFX_FloatRect& rcBBox) {
return CFX_ByteString(sAppStream);
}
+CFX_ByteString GetRectFillAppStream(const CFX_FloatRect& rect,
+ const CFX_Color& color) {
+ std::ostringstream sAppStream;
+ CFX_ByteString sColor = GetColorAppStream(color, true);
+ if (sColor.GetLength() > 0) {
+ sAppStream << "q\n" << sColor;
+ sAppStream << rect.left << " " << rect.bottom << " "
+ << rect.right - rect.left << " " << rect.top - rect.bottom
+ << " re f\nQ\n";
+ }
+
+ return CFX_ByteString(sAppStream);
+}
+
} // namespace
CPWL_AppStream::CPWL_AppStream(CPDFSDK_Widget* widget, CPDF_Dictionary* dict)
@@ -682,28 +996,28 @@ CPWL_AppStream::~CPWL_AppStream() {}
void CPWL_AppStream::SetAsPushButton() {
CPDF_FormControl* pControl = widget_->GetFormControl();
CFX_FloatRect rcWindow = widget_->GetRotatedRect();
- int32_t nLayout = 0;
+ ButtonStyle nLayout = ButtonStyle::kLabel;
switch (pControl->GetTextPosition()) {
case TEXTPOS_ICON:
- nLayout = PPBL_ICON;
+ nLayout = ButtonStyle::kIcon;
break;
case TEXTPOS_BELOW:
- nLayout = PPBL_ICONTOPLABELBOTTOM;
+ nLayout = ButtonStyle::kIconTopLabelBottom;
break;
case TEXTPOS_ABOVE:
- nLayout = PPBL_LABELTOPICONBOTTOM;
+ nLayout = ButtonStyle::kIconBottomLabelTop;
break;
case TEXTPOS_RIGHT:
- nLayout = PPBL_ICONLEFTLABELRIGHT;
+ nLayout = ButtonStyle::kIconLeftLabelRight;
break;
case TEXTPOS_LEFT:
- nLayout = PPBL_LABELLEFTICONRIGHT;
+ nLayout = ButtonStyle::kIconRightLabelLeft;
break;
case TEXTPOS_OVERLAID:
- nLayout = PPBL_LABELOVERICON;
+ nLayout = ButtonStyle::kLabelOverIcon;
break;
default:
- nLayout = PPBL_LABEL;
+ nLayout = ButtonStyle::kLabel;
break;
}
@@ -809,10 +1123,9 @@ void CPWL_AppStream::SetAsPushButton() {
font_map.SetAPType("N");
CFX_ByteString csAP =
- CPWL_Utils::GetRectFillAppStream(rcWindow, crBackground) +
- CPWL_Utils::GetBorderAppStream(rcWindow, fBorderWidth, crBorder,
- crLeftTop, crRightBottom, nBorderStyle,
- dsBorder) +
+ GetRectFillAppStream(rcWindow, crBackground) +
+ GetBorderAppStreamInternal(rcWindow, fBorderWidth, crBorder, crLeftTop,
+ crRightBottom, nBorderStyle, dsBorder) +
GetPushButtonAppStream(iconFit.GetFittingBounds() ? rcWindow : rcClient,
&font_map, pNormalIcon, iconFit, csNormalCaption,
crText, fFontSize, nLayout);
@@ -831,10 +1144,9 @@ void CPWL_AppStream::SetAsPushButton() {
font_map.SetAPType("R");
csAP =
- CPWL_Utils::GetRectFillAppStream(rcWindow, crBackground) +
- CPWL_Utils::GetBorderAppStream(rcWindow, fBorderWidth, crBorder,
- crLeftTop, crRightBottom, nBorderStyle,
- dsBorder) +
+ GetRectFillAppStream(rcWindow, crBackground) +
+ GetBorderAppStreamInternal(rcWindow, fBorderWidth, crBorder, crLeftTop,
+ crRightBottom, nBorderStyle, dsBorder) +
GetPushButtonAppStream(iconFit.GetFittingBounds() ? rcWindow : rcClient,
&font_map, pRolloverIcon, iconFit,
csRolloverCaption, crText, fFontSize, nLayout);
@@ -866,13 +1178,13 @@ void CPWL_AppStream::SetAsPushButton() {
font_map.SetAPType("D");
- csAP = CPWL_Utils::GetRectFillAppStream(rcWindow, crBackground - 0.25f) +
- CPWL_Utils::GetBorderAppStream(rcWindow, fBorderWidth, crBorder,
- crLeftTop, crRightBottom,
- nBorderStyle, dsBorder) +
- GetPushButtonAppStream(
- iconFit.GetFittingBounds() ? rcWindow : rcClient, &font_map,
- pDownIcon, iconFit, csDownCaption, crText, fFontSize, nLayout);
+ csAP =
+ GetRectFillAppStream(rcWindow, crBackground - 0.25f) +
+ GetBorderAppStreamInternal(rcWindow, fBorderWidth, crBorder, crLeftTop,
+ crRightBottom, nBorderStyle, dsBorder) +
+ GetPushButtonAppStream(iconFit.GetFittingBounds() ? rcWindow : rcClient,
+ &font_map, pDownIcon, iconFit, csDownCaption,
+ crText, fFontSize, nLayout);
Write("D", csAP, "");
if (pDownIcon)
@@ -928,38 +1240,35 @@ void CPWL_AppStream::SetAsCheckBox() {
crText = CFX_Color(iColorType, fc[0], fc[1], fc[2], fc[3]);
}
- int32_t nStyle = 0;
+ CheckStyle nStyle = CheckStyle::kCheck;
CFX_WideString csWCaption = pControl->GetNormalCaption();
if (csWCaption.GetLength() > 0) {
switch (csWCaption[0]) {
case L'l':
- nStyle = PCS_CIRCLE;
+ nStyle = CheckStyle::kCircle;
break;
case L'8':
- nStyle = PCS_CROSS;
+ nStyle = CheckStyle::kCross;
break;
case L'u':
- nStyle = PCS_DIAMOND;
+ nStyle = CheckStyle::kDiamond;
break;
case L'n':
- nStyle = PCS_SQUARE;
+ nStyle = CheckStyle::kSquare;
break;
case L'H':
- nStyle = PCS_STAR;
- break;
- default: // L'4'
- nStyle = PCS_CHECK;
+ nStyle = CheckStyle::kStar;
break;
+ case L'4':
+ default:
+ nStyle = CheckStyle::kCheck;
}
- } else {
- nStyle = PCS_CHECK;
}
CFX_ByteString csAP_N_ON =
- CPWL_Utils::GetRectFillAppStream(rcWindow, crBackground) +
- CPWL_Utils::GetBorderAppStream(rcWindow, fBorderWidth, crBorder,
- crLeftTop, crRightBottom, nBorderStyle,
- dsBorder);
+ GetRectFillAppStream(rcWindow, crBackground) +
+ GetBorderAppStreamInternal(rcWindow, fBorderWidth, crBorder, crLeftTop,
+ crRightBottom, nBorderStyle, dsBorder);
CFX_ByteString csAP_N_OFF = csAP_N_ON;
@@ -980,10 +1289,9 @@ void CPWL_AppStream::SetAsCheckBox() {
}
CFX_ByteString csAP_D_ON =
- CPWL_Utils::GetRectFillAppStream(rcWindow, crBackground - 0.25f) +
- CPWL_Utils::GetBorderAppStream(rcWindow, fBorderWidth, crBorder,
- crLeftTop, crRightBottom, nBorderStyle,
- dsBorder);
+ GetRectFillAppStream(rcWindow, crBackground - 0.25f) +
+ GetBorderAppStreamInternal(rcWindow, fBorderWidth, crBorder, crLeftTop,
+ crRightBottom, nBorderStyle, dsBorder);
CFX_ByteString csAP_D_OFF = csAP_D_ON;
@@ -1048,36 +1356,34 @@ void CPWL_AppStream::SetAsRadioButton() {
crText = CFX_Color(iColorType, fc[0], fc[1], fc[2], fc[3]);
}
- int32_t nStyle = 0;
+ CheckStyle nStyle = CheckStyle::kCircle;
CFX_WideString csWCaption = pControl->GetNormalCaption();
if (csWCaption.GetLength() > 0) {
switch (csWCaption[0]) {
- default: // L'l':
- nStyle = PCS_CIRCLE;
- break;
case L'8':
- nStyle = PCS_CROSS;
+ nStyle = CheckStyle::kCross;
break;
case L'u':
- nStyle = PCS_DIAMOND;
+ nStyle = CheckStyle::kDiamond;
break;
case L'n':
- nStyle = PCS_SQUARE;
+ nStyle = CheckStyle::kSquare;
break;
case L'H':
- nStyle = PCS_STAR;
+ nStyle = CheckStyle::kStar;
break;
case L'4':
- nStyle = PCS_CHECK;
+ nStyle = CheckStyle::kCheck;
break;
+ case L'l':
+ default:
+ nStyle = CheckStyle::kCircle;
}
- } else {
- nStyle = PCS_CIRCLE;
}
CFX_ByteString csAP_N_ON;
CFX_FloatRect rcCenter = rcWindow.GetCenterSquare().GetDeflated(1.0f, 1.0f);
- if (nStyle == PCS_CIRCLE) {
+ if (nStyle == CheckStyle::kCircle) {
if (nBorderStyle == BorderStyle::BEVELED) {
crLeftTop = CFX_Color(COLORTYPE_GRAY, 1);
crRightBottom = crBackground - 0.25f;
@@ -1091,10 +1397,10 @@ void CPWL_AppStream::SetAsRadioButton() {
GetCircleBorderAppStream(rcCenter, fBorderWidth, crBorder, crLeftTop,
crRightBottom, nBorderStyle, dsBorder);
} else {
- csAP_N_ON = CPWL_Utils::GetRectFillAppStream(rcWindow, crBackground) +
- CPWL_Utils::GetBorderAppStream(rcWindow, fBorderWidth, crBorder,
- crLeftTop, crRightBottom,
- nBorderStyle, dsBorder);
+ csAP_N_ON =
+ GetRectFillAppStream(rcWindow, crBackground) +
+ GetBorderAppStreamInternal(rcWindow, fBorderWidth, crBorder, crLeftTop,
+ crRightBottom, nBorderStyle, dsBorder);
}
CFX_ByteString csAP_N_OFF = csAP_N_ON;
@@ -1117,7 +1423,7 @@ void CPWL_AppStream::SetAsRadioButton() {
CFX_ByteString csAP_D_ON;
- if (nStyle == PCS_CIRCLE) {
+ if (nStyle == CheckStyle::kCircle) {
CFX_Color crBK = crBackground - 0.25f;
if (nBorderStyle == BorderStyle::BEVELED) {
crLeftTop = crBackground - 0.25f;
@@ -1134,10 +1440,9 @@ void CPWL_AppStream::SetAsRadioButton() {
crRightBottom, nBorderStyle, dsBorder);
} else {
csAP_D_ON =
- CPWL_Utils::GetRectFillAppStream(rcWindow, crBackground - 0.25f) +
- CPWL_Utils::GetBorderAppStream(rcWindow, fBorderWidth, crBorder,
- crLeftTop, crRightBottom, nBorderStyle,
- dsBorder);
+ GetRectFillAppStream(rcWindow, crBackground - 0.25f) +
+ GetBorderAppStreamInternal(rcWindow, fBorderWidth, crBorder, crLeftTop,
+ crRightBottom, nBorderStyle, dsBorder);
}
CFX_ByteString csAP_D_OFF = csAP_D_ON;
@@ -1200,8 +1505,7 @@ void CPWL_AppStream::SetAsComboBox(const CFX_WideString* sValue) {
}
CFX_FloatRect rcContent = pEdit->GetContentRect();
- CFX_ByteString sEdit =
- CPWL_Utils::GetEditAppStream(pEdit.get(), CFX_PointF());
+ CFX_ByteString sEdit = GetEditAppStream(pEdit.get(), CFX_PointF(), true, 0);
if (sEdit.GetLength() > 0) {
sBody << "/Tx BMC\n"
<< "q\n";
@@ -1213,7 +1517,7 @@ void CPWL_AppStream::SetAsComboBox(const CFX_WideString* sValue) {
CFX_Color crText = widget_->GetTextPWLColor();
sBody << "BT\n"
- << CPWL_Utils::GetColorAppStream(crText) << sEdit << "ET\n"
+ << GetColorAppStream(crText, true) << sEdit << "ET\n"
<< "Q\nEMC\n";
}
@@ -1267,7 +1571,7 @@ void CPWL_AppStream::SetAsListBox() {
CFX_FloatRect rcItem =
CFX_FloatRect(rcClient.left, fy - fItemHeight, rcClient.right, fy);
sList << "q\n"
- << CPWL_Utils::GetColorAppStream(
+ << GetColorAppStream(
CFX_Color(COLORTYPE_RGB, 0, 51.0f / 255.0f, 113.0f / 255.0f),
true)
<< rcItem.left << " " << rcItem.bottom << " " << rcItem.Width()
@@ -1275,14 +1579,14 @@ void CPWL_AppStream::SetAsListBox() {
<< "Q\n";
sList << "BT\n"
- << CPWL_Utils::GetColorAppStream(CFX_Color(COLORTYPE_GRAY, 1), true)
- << CPWL_Utils::GetEditAppStream(pEdit.get(), CFX_PointF(0.0f, fy))
+ << GetColorAppStream(CFX_Color(COLORTYPE_GRAY, 1), true)
+ << GetEditAppStream(pEdit.get(), CFX_PointF(0.0f, fy), true, 0)
<< "ET\n";
} else {
CFX_Color crText = widget_->GetTextPWLColor();
sList << "BT\n"
- << CPWL_Utils::GetColorAppStream(crText, true)
- << CPWL_Utils::GetEditAppStream(pEdit.get(), CFX_PointF(0.0f, fy))
+ << GetColorAppStream(crText, true)
+ << GetEditAppStream(pEdit.get(), CFX_PointF(0.0f, fy), true, 0)
<< "ET\n";
}
@@ -1370,8 +1674,8 @@ void CPWL_AppStream::SetAsTextField(const CFX_WideString* sValue) {
pEdit->SetText(sValue ? *sValue : pField->GetValue());
CFX_FloatRect rcContent = pEdit->GetContentRect();
- CFX_ByteString sEdit = CPWL_Utils::GetEditAppStream(
- pEdit.get(), CFX_PointF(), nullptr, !bCharArray, subWord);
+ CFX_ByteString sEdit =
+ GetEditAppStream(pEdit.get(), CFX_PointF(), !bCharArray, subWord);
if (sEdit.GetLength() > 0) {
sBody << "/Tx BMC\n"
@@ -1383,7 +1687,7 @@ void CPWL_AppStream::SetAsTextField(const CFX_WideString* sValue) {
}
CFX_Color crText = widget_->GetTextPWLColor();
sBody << "BT\n"
- << CPWL_Utils::GetColorAppStream(crText) << sEdit << "ET\n"
+ << GetColorAppStream(crText, true) << sEdit << "ET\n"
<< "Q\nEMC\n";
}
@@ -1391,12 +1695,11 @@ void CPWL_AppStream::SetAsTextField(const CFX_WideString* sValue) {
switch (widget_->GetBorderStyle()) {
case BorderStyle::SOLID: {
CFX_ByteString sColor =
- CPWL_Utils::GetColorAppStream(widget_->GetBorderPWLColor(), false);
+ GetColorAppStream(widget_->GetBorderPWLColor(), false);
if (sColor.GetLength() > 0) {
sLines << "q\n"
<< widget_->GetBorderWidth() << " w\n"
- << CPWL_Utils::GetColorAppStream(widget_->GetBorderPWLColor(),
- false)
+ << GetColorAppStream(widget_->GetBorderPWLColor(), false)
<< " 2 J 0 j\n";
for (int32_t i = 1; i < nMaxLen; ++i) {
@@ -1414,14 +1717,13 @@ void CPWL_AppStream::SetAsTextField(const CFX_WideString* sValue) {
}
case BorderStyle::DASH: {
CFX_ByteString sColor =
- CPWL_Utils::GetColorAppStream(widget_->GetBorderPWLColor(), false);
+ GetColorAppStream(widget_->GetBorderPWLColor(), false);
if (sColor.GetLength() > 0) {
CPWL_Dash dsBorder = CPWL_Dash(3, 3, 0);
sLines << "q\n"
<< widget_->GetBorderWidth() << " w\n"
- << CPWL_Utils::GetColorAppStream(widget_->GetBorderPWLColor(),
- false)
+ << GetColorAppStream(widget_->GetBorderPWLColor(), false)
<< "[" << dsBorder.nDash << " " << dsBorder.nGap << "] "
<< dsBorder.nPhase << " d\n";
@@ -1517,8 +1819,7 @@ void CPWL_AppStream::Remove(const CFX_ByteString& sAPType) {
CFX_ByteString CPWL_AppStream::GetBackgroundAppStream() const {
CFX_Color crBackground = widget_->GetFillPWLColor();
if (crBackground.nColorType != COLORTYPE_TRANSPARENT)
- return CPWL_Utils::GetRectFillAppStream(widget_->GetRotatedRect(),
- crBackground);
+ return GetRectFillAppStream(widget_->GetRotatedRect(), crBackground);
return CFX_ByteString();
}
@@ -1552,7 +1853,6 @@ CFX_ByteString CPWL_AppStream::GetBorderAppStream() const {
break;
}
- return CPWL_Utils::GetBorderAppStream(rcWindow, fBorderWidth, crBorder,
- crLeftTop, crRightBottom, nBorderStyle,
- dsBorder);
+ return GetBorderAppStreamInternal(rcWindow, fBorderWidth, crBorder, crLeftTop,
+ crRightBottom, nBorderStyle, dsBorder);
}
diff --git a/fpdfsdk/pdfwindow/cpwl_button.cpp b/fpdfsdk/pdfwindow/cpwl_button.cpp
index de9054ae32..fad3632875 100644
--- a/fpdfsdk/pdfwindow/cpwl_button.cpp
+++ b/fpdfsdk/pdfwindow/cpwl_button.cpp
@@ -5,7 +5,6 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
#include "fpdfsdk/pdfwindow/cpwl_button.h"
-#include "fpdfsdk/pdfwindow/cpwl_utils.h"
#include "fpdfsdk/pdfwindow/cpwl_wnd.h"
CPWL_Button::CPWL_Button() : m_bMouseDown(false) {}
diff --git a/fpdfsdk/pdfwindow/cpwl_caret.cpp b/fpdfsdk/pdfwindow/cpwl_caret.cpp
index 2e56450fb3..a9a5b86099 100644
--- a/fpdfsdk/pdfwindow/cpwl_caret.cpp
+++ b/fpdfsdk/pdfwindow/cpwl_caret.cpp
@@ -11,7 +11,6 @@
#include "core/fxge/cfx_graphstatedata.h"
#include "core/fxge/cfx_pathdata.h"
#include "core/fxge/cfx_renderdevice.h"
-#include "fpdfsdk/pdfwindow/cpwl_utils.h"
#include "fpdfsdk/pdfwindow/cpwl_wnd.h"
#define PWL_CARET_FLASHINTERVAL 500
diff --git a/fpdfsdk/pdfwindow/cpwl_combo_box.cpp b/fpdfsdk/pdfwindow/cpwl_combo_box.cpp
index 97ac318982..d86c9db8a9 100644
--- a/fpdfsdk/pdfwindow/cpwl_combo_box.cpp
+++ b/fpdfsdk/pdfwindow/cpwl_combo_box.cpp
@@ -15,7 +15,6 @@
#include "fpdfsdk/pdfwindow/cpwl_edit.h"
#include "fpdfsdk/pdfwindow/cpwl_edit_ctrl.h"
#include "fpdfsdk/pdfwindow/cpwl_list_box.h"
-#include "fpdfsdk/pdfwindow/cpwl_utils.h"
#include "fpdfsdk/pdfwindow/cpwl_wnd.h"
#include "public/fpdf_fwlevent.h"
diff --git a/fpdfsdk/pdfwindow/cpwl_edit.cpp b/fpdfsdk/pdfwindow/cpwl_edit.cpp
index a5105c1a74..046fb5789f 100644
--- a/fpdfsdk/pdfwindow/cpwl_edit.cpp
+++ b/fpdfsdk/pdfwindow/cpwl_edit.cpp
@@ -25,7 +25,6 @@
#include "fpdfsdk/pdfwindow/cpwl_edit_ctrl.h"
#include "fpdfsdk/pdfwindow/cpwl_font_map.h"
#include "fpdfsdk/pdfwindow/cpwl_scroll_bar.h"
-#include "fpdfsdk/pdfwindow/cpwl_utils.h"
#include "fpdfsdk/pdfwindow/cpwl_wnd.h"
#include "public/fpdf_fwlevent.h"
#include "third_party/base/stl_util.h"
@@ -357,12 +356,6 @@ void CPWL_Edit::SetCharSpace(float fCharSpace) {
m_pEdit->SetCharSpace(fCharSpace);
}
-CFX_ByteString CPWL_Edit::GetSelectAppearanceStream(
- const CFX_PointF& ptOffset) const {
- CPVT_WordRange wr = GetSelectWordRange();
- return CPWL_Utils::GetEditSelAppStream(m_pEdit.get(), ptOffset, &wr);
-}
-
CPVT_WordRange CPWL_Edit::GetSelectWordRange() const {
if (m_pEdit->IsSelected()) {
int32_t nStart = -1;
diff --git a/fpdfsdk/pdfwindow/cpwl_edit.h b/fpdfsdk/pdfwindow/cpwl_edit.h
index e3382ffd6f..366d085fdd 100644
--- a/fpdfsdk/pdfwindow/cpwl_edit.h
+++ b/fpdfsdk/pdfwindow/cpwl_edit.h
@@ -80,8 +80,6 @@ class CPWL_Edit : public CPWL_EditCtrl {
void SetText(const CFX_WideString& csText);
void ReplaceSel(const CFX_WideString& csText);
- CFX_ByteString GetSelectAppearanceStream(const CFX_PointF& ptOffset) const;
-
bool IsTextFull() const;
static float GetCharArrayAutoFontSize(CPDF_Font* pFont,
diff --git a/fpdfsdk/pdfwindow/cpwl_edit_ctrl.cpp b/fpdfsdk/pdfwindow/cpwl_edit_ctrl.cpp
index ccc214ab00..63d03929e2 100644
--- a/fpdfsdk/pdfwindow/cpwl_edit_ctrl.cpp
+++ b/fpdfsdk/pdfwindow/cpwl_edit_ctrl.cpp
@@ -13,7 +13,6 @@
#include "fpdfsdk/pdfwindow/cpwl_caret.h"
#include "fpdfsdk/pdfwindow/cpwl_font_map.h"
#include "fpdfsdk/pdfwindow/cpwl_scroll_bar.h"
-#include "fpdfsdk/pdfwindow/cpwl_utils.h"
#include "fpdfsdk/pdfwindow/cpwl_wnd.h"
#include "public/fpdf_fwlevent.h"
diff --git a/fpdfsdk/pdfwindow/cpwl_icon.cpp b/fpdfsdk/pdfwindow/cpwl_icon.cpp
index ebf3b4fc12..d2f2e5fb93 100644
--- a/fpdfsdk/pdfwindow/cpwl_icon.cpp
+++ b/fpdfsdk/pdfwindow/cpwl_icon.cpp
@@ -11,46 +11,12 @@
#include "core/fpdfapi/parser/cpdf_array.h"
#include "core/fpdfapi/parser/cpdf_stream.h"
-#include "fpdfsdk/pdfwindow/cpwl_utils.h"
#include "fpdfsdk/pdfwindow/cpwl_wnd.h"
CPWL_Image::CPWL_Image() : m_pPDFStream(nullptr) {}
CPWL_Image::~CPWL_Image() {}
-CFX_ByteString CPWL_Image::GetImageAppStream() {
- std::ostringstream sAppStream;
-
- CFX_ByteString sAlias = GetImageAlias();
- CFX_FloatRect rcPlate = GetClientRect();
- CFX_Matrix mt = GetImageMatrix().GetInverse();
-
- float fHScale = 1.0f;
- float fVScale = 1.0f;
- GetScale(fHScale, fVScale);
-
- float fx = 0.0f;
- float fy = 0.0f;
- GetImageOffset(fx, fy);
-
- if (m_pPDFStream && sAlias.GetLength() > 0) {
- sAppStream << "q\n";
- sAppStream << rcPlate.left << " " << rcPlate.bottom << " "
- << rcPlate.right - rcPlate.left << " "
- << rcPlate.top - rcPlate.bottom << " re W n\n";
-
- sAppStream << fHScale << " 0 0 " << fVScale << " " << rcPlate.left + fx
- << " " << rcPlate.bottom + fy << " cm\n";
- sAppStream << mt.a << " " << mt.b << " " << mt.c << " " << mt.d << " "
- << mt.e << " " << mt.f << " cm\n";
-
- sAppStream << "0 g 0 G 1 w /" << sAlias << " Do\n"
- << "Q\n";
- }
-
- return CFX_ByteString(sAppStream);
-}
-
void CPWL_Image::SetPDFStream(CPDF_Stream* pStream) {
m_pPDFStream = pStream;
}
diff --git a/fpdfsdk/pdfwindow/cpwl_icon.h b/fpdfsdk/pdfwindow/cpwl_icon.h
index c7b8cb4b56..0b82a4b5d6 100644
--- a/fpdfsdk/pdfwindow/cpwl_icon.h
+++ b/fpdfsdk/pdfwindow/cpwl_icon.h
@@ -16,13 +16,10 @@ class CPWL_Image : public CPWL_Wnd {
CPWL_Image();
~CPWL_Image() override;
- virtual CFX_ByteString GetImageAppStream();
-
virtual void GetScale(float& fHScale, float& fVScale);
virtual void GetImageOffset(float& x, float& y);
- virtual CPDF_Stream* GetPDFStream() const;
- public:
+ CPDF_Stream* GetPDFStream() const;
void SetPDFStream(CPDF_Stream* pStream);
void GetImageSize(float& fWidth, float& fHeight);
CFX_Matrix GetImageMatrix();
@@ -39,7 +36,7 @@ class CPWL_Icon : public CPWL_Image {
CPWL_Icon();
~CPWL_Icon() override;
- virtual CPDF_IconFit* GetIconFit() const;
+ CPDF_IconFit* GetIconFit() const;
// CPWL_Image
void GetScale(float& fHScale, float& fVScale) override;
diff --git a/fpdfsdk/pdfwindow/cpwl_list_box.cpp b/fpdfsdk/pdfwindow/cpwl_list_box.cpp
index 05aef01d99..ffa5b4780f 100644
--- a/fpdfsdk/pdfwindow/cpwl_list_box.cpp
+++ b/fpdfsdk/pdfwindow/cpwl_list_box.cpp
@@ -14,7 +14,6 @@
#include "fpdfsdk/pdfwindow/cpwl_edit.h"
#include "fpdfsdk/pdfwindow/cpwl_edit_ctrl.h"
#include "fpdfsdk/pdfwindow/cpwl_scroll_bar.h"
-#include "fpdfsdk/pdfwindow/cpwl_utils.h"
#include "fpdfsdk/pdfwindow/cpwl_wnd.h"
#include "public/fpdf_fwlevent.h"
#include "third_party/base/ptr_util.h"
diff --git a/fpdfsdk/pdfwindow/cpwl_scroll_bar.cpp b/fpdfsdk/pdfwindow/cpwl_scroll_bar.cpp
index 537e51c010..c607ee795e 100644
--- a/fpdfsdk/pdfwindow/cpwl_scroll_bar.cpp
+++ b/fpdfsdk/pdfwindow/cpwl_scroll_bar.cpp
@@ -12,7 +12,6 @@
#include "core/fxge/cfx_pathdata.h"
#include "core/fxge/cfx_renderdevice.h"
-#include "fpdfsdk/pdfwindow/cpwl_utils.h"
#include "fpdfsdk/pdfwindow/cpwl_wnd.h"
namespace {
diff --git a/fpdfsdk/pdfwindow/cpwl_special_button.cpp b/fpdfsdk/pdfwindow/cpwl_special_button.cpp
index da91da3ecb..b911d5eb00 100644
--- a/fpdfsdk/pdfwindow/cpwl_special_button.cpp
+++ b/fpdfsdk/pdfwindow/cpwl_special_button.cpp
@@ -6,7 +6,6 @@
#include "fpdfsdk/pdfwindow/cpwl_special_button.h"
#include "fpdfsdk/pdfwindow/cpwl_button.h"
-#include "fpdfsdk/pdfwindow/cpwl_utils.h"
#include "fpdfsdk/pdfwindow/cpwl_wnd.h"
CPWL_PushButton::CPWL_PushButton() {}
diff --git a/fpdfsdk/pdfwindow/cpwl_utils.cpp b/fpdfsdk/pdfwindow/cpwl_utils.cpp
deleted file mode 100644
index b628b292c9..0000000000
--- a/fpdfsdk/pdfwindow/cpwl_utils.cpp
+++ /dev/null
@@ -1,184 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#include "fpdfsdk/pdfwindow/cpwl_utils.h"
-
-#include <algorithm>
-#include <memory>
-#include <sstream>
-
-#include "core/fpdfdoc/cpvt_word.h"
-#include "fpdfsdk/fxedit/fxet_edit.h"
-#include "fpdfsdk/pdfwindow/cpwl_icon.h"
-
-CFX_ByteString CPWL_Utils::GetRectFillAppStream(const CFX_FloatRect& rect,
- const CFX_Color& color) {
- std::ostringstream sAppStream;
- CFX_ByteString sColor = GetColorAppStream(color, true);
- if (sColor.GetLength() > 0) {
- sAppStream << "q\n" << sColor;
- sAppStream << rect.left << " " << rect.bottom << " "
- << rect.right - rect.left << " " << rect.top - rect.bottom
- << " re f\nQ\n";
- }
-
- return CFX_ByteString(sAppStream);
-}
-
-CFX_ByteString CPWL_Utils::GetEditAppStream(CFX_Edit* pEdit,
- const CFX_PointF& ptOffset,
- const CPVT_WordRange* pRange,
- bool bContinuous,
- uint16_t SubWord) {
- return CFX_Edit::GetEditAppearanceStream(pEdit, ptOffset, pRange, bContinuous,
- SubWord);
-}
-
-CFX_ByteString CPWL_Utils::GetEditSelAppStream(CFX_Edit* pEdit,
- const CFX_PointF& ptOffset,
- const CPVT_WordRange* pRange) {
- return CFX_Edit::GetSelectAppearanceStream(pEdit, ptOffset, pRange);
-}
-
-CFX_ByteString CPWL_Utils::GetColorAppStream(const CFX_Color& color,
- const bool& bFillOrStroke) {
- std::ostringstream sColorStream;
-
- switch (color.nColorType) {
- case COLORTYPE_RGB:
- sColorStream << color.fColor1 << " " << color.fColor2 << " "
- << color.fColor3 << " " << (bFillOrStroke ? "rg" : "RG")
- << "\n";
- break;
- case COLORTYPE_GRAY:
- sColorStream << color.fColor1 << " " << (bFillOrStroke ? "g" : "G")
- << "\n";
- break;
- case COLORTYPE_CMYK:
- sColorStream << color.fColor1 << " " << color.fColor2 << " "
- << color.fColor3 << " " << color.fColor4 << " "
- << (bFillOrStroke ? "k" : "K") << "\n";
- break;
- }
-
- return CFX_ByteString(sColorStream);
-}
-
-CFX_ByteString CPWL_Utils::GetBorderAppStream(const CFX_FloatRect& rect,
- float fWidth,
- const CFX_Color& color,
- const CFX_Color& crLeftTop,
- const CFX_Color& crRightBottom,
- BorderStyle nStyle,
- const CPWL_Dash& dash) {
- std::ostringstream sAppStream;
- CFX_ByteString sColor;
-
- float fLeft = rect.left;
- float fRight = rect.right;
- float fTop = rect.top;
- float fBottom = rect.bottom;
-
- if (fWidth > 0.0f) {
- float fHalfWidth = fWidth / 2.0f;
-
- sAppStream << "q\n";
-
- switch (nStyle) {
- default:
- case BorderStyle::SOLID:
- sColor = CPWL_Utils::GetColorAppStream(color, true);
- if (sColor.GetLength() > 0) {
- sAppStream << sColor;
- sAppStream << fLeft << " " << fBottom << " " << fRight - fLeft << " "
- << fTop - fBottom << " re\n";
- sAppStream << fLeft + fWidth << " " << fBottom + fWidth << " "
- << fRight - fLeft - fWidth * 2 << " "
- << fTop - fBottom - fWidth * 2 << " re\n";
- sAppStream << "f*\n";
- }
- break;
- case BorderStyle::DASH:
- sColor = CPWL_Utils::GetColorAppStream(color, false);
- if (sColor.GetLength() > 0) {
- sAppStream << sColor;
- sAppStream << fWidth << " w"
- << " [" << dash.nDash << " " << dash.nGap << "] "
- << dash.nPhase << " d\n";
- sAppStream << fLeft + fWidth / 2 << " " << fBottom + fWidth / 2
- << " m\n";
- sAppStream << fLeft + fWidth / 2 << " " << fTop - fWidth / 2
- << " l\n";
- sAppStream << fRight - fWidth / 2 << " " << fTop - fWidth / 2
- << " l\n";
- sAppStream << fRight - fWidth / 2 << " " << fBottom + fWidth / 2
- << " l\n";
- sAppStream << fLeft + fWidth / 2 << " " << fBottom + fWidth / 2
- << " l S\n";
- }
- break;
- case BorderStyle::BEVELED:
- case BorderStyle::INSET:
- sColor = CPWL_Utils::GetColorAppStream(crLeftTop, true);
- if (sColor.GetLength() > 0) {
- sAppStream << sColor;
- sAppStream << fLeft + fHalfWidth << " " << fBottom + fHalfWidth
- << " m\n";
- sAppStream << fLeft + fHalfWidth << " " << fTop - fHalfWidth
- << " l\n";
- sAppStream << fRight - fHalfWidth << " " << fTop - fHalfWidth
- << " l\n";
- sAppStream << fRight - fHalfWidth * 2 << " " << fTop - fHalfWidth * 2
- << " l\n";
- sAppStream << fLeft + fHalfWidth * 2 << " " << fTop - fHalfWidth * 2
- << " l\n";
- sAppStream << fLeft + fHalfWidth * 2 << " "
- << fBottom + fHalfWidth * 2 << " l f\n";
- }
-
- sColor = CPWL_Utils::GetColorAppStream(crRightBottom, true);
- if (sColor.GetLength() > 0) {
- sAppStream << sColor;
- sAppStream << fRight - fHalfWidth << " " << fTop - fHalfWidth
- << " m\n";
- sAppStream << fRight - fHalfWidth << " " << fBottom + fHalfWidth
- << " l\n";
- sAppStream << fLeft + fHalfWidth << " " << fBottom + fHalfWidth
- << " l\n";
- sAppStream << fLeft + fHalfWidth * 2 << " "
- << fBottom + fHalfWidth * 2 << " l\n";
- sAppStream << fRight - fHalfWidth * 2 << " "
- << fBottom + fHalfWidth * 2 << " l\n";
- sAppStream << fRight - fHalfWidth * 2 << " " << fTop - fHalfWidth * 2
- << " l f\n";
- }
-
- sColor = CPWL_Utils::GetColorAppStream(color, true);
- if (sColor.GetLength() > 0) {
- sAppStream << sColor;
- sAppStream << fLeft << " " << fBottom << " " << fRight - fLeft << " "
- << fTop - fBottom << " re\n";
- sAppStream << fLeft + fHalfWidth << " " << fBottom + fHalfWidth << " "
- << fRight - fLeft - fHalfWidth * 2 << " "
- << fTop - fBottom - fHalfWidth * 2 << " re f*\n";
- }
- break;
- case BorderStyle::UNDERLINE:
- sColor = CPWL_Utils::GetColorAppStream(color, false);
- if (sColor.GetLength() > 0) {
- sAppStream << sColor;
- sAppStream << fWidth << " w\n";
- sAppStream << fLeft << " " << fBottom + fWidth / 2 << " m\n";
- sAppStream << fRight << " " << fBottom + fWidth / 2 << " l S\n";
- }
- break;
- }
-
- sAppStream << "Q\n";
- }
-
- return CFX_ByteString(sAppStream);
-}
diff --git a/fpdfsdk/pdfwindow/cpwl_utils.h b/fpdfsdk/pdfwindow/cpwl_utils.h
deleted file mode 100644
index 9445de3277..0000000000
--- a/fpdfsdk/pdfwindow/cpwl_utils.h
+++ /dev/null
@@ -1,57 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef FPDFSDK_PDFWINDOW_CPWL_UTILS_H_
-#define FPDFSDK_PDFWINDOW_CPWL_UTILS_H_
-
-#include "core/fpdfdoc/cpvt_wordrange.h"
-#include "fpdfsdk/pdfwindow/cpwl_wnd.h"
-
-class CFX_Edit;
-struct CFX_Color;
-
-// checkbox & radiobutton style
-#define PCS_CHECK 0
-#define PCS_CIRCLE 1
-#define PCS_CROSS 2
-#define PCS_DIAMOND 3
-#define PCS_SQUARE 4
-#define PCS_STAR 5
-
-// pushbutton layout style
-#define PPBL_LABEL 0
-#define PPBL_ICON 1
-#define PPBL_ICONTOPLABELBOTTOM 2
-#define PPBL_LABELTOPICONBOTTOM 3
-#define PPBL_ICONLEFTLABELRIGHT 4
-#define PPBL_LABELLEFTICONRIGHT 5
-#define PPBL_LABELOVERICON 6
-
-class CPWL_Utils {
- public:
- static CFX_ByteString GetColorAppStream(const CFX_Color& color,
- const bool& bFillOrStroke = true);
- static CFX_ByteString GetBorderAppStream(const CFX_FloatRect& rect,
- float fWidth,
- const CFX_Color& color,
- const CFX_Color& crLeftTop,
- const CFX_Color& crRightBottom,
- BorderStyle nStyle,
- const CPWL_Dash& dash);
- static CFX_ByteString GetRectFillAppStream(const CFX_FloatRect& rect,
- const CFX_Color& color);
- static CFX_ByteString GetEditAppStream(CFX_Edit* pEdit,
- const CFX_PointF& ptOffset,
- const CPVT_WordRange* pRange = nullptr,
- bool bContinuous = true,
- uint16_t SubWord = 0);
- static CFX_ByteString GetEditSelAppStream(
- CFX_Edit* pEdit,
- const CFX_PointF& ptOffset,
- const CPVT_WordRange* pRange = nullptr);
-};
-
-#endif // FPDFSDK_PDFWINDOW_CPWL_UTILS_H_
diff --git a/fpdfsdk/pdfwindow/cpwl_wnd.cpp b/fpdfsdk/pdfwindow/cpwl_wnd.cpp
index 8862fc4c8b..ce5f4ee598 100644
--- a/fpdfsdk/pdfwindow/cpwl_wnd.cpp
+++ b/fpdfsdk/pdfwindow/cpwl_wnd.cpp
@@ -12,7 +12,6 @@
#include "core/fxge/cfx_renderdevice.h"
#include "fpdfsdk/pdfwindow/cpwl_scroll_bar.h"
-#include "fpdfsdk/pdfwindow/cpwl_utils.h"
#include "third_party/base/ptr_util.h"
#include "third_party/base/stl_util.h"