7#include "fpdfsdk/cpdfsdk_appstream.h"
16#include "constants/appearance.h"
17#include "constants/form_flags.h"
18#include "core/fpdfapi/edit/cpdf_contentstream_write_utils.h"
19#include "core/fpdfapi/font/cpdf_font.h"
20#include "core/fpdfapi/parser/cpdf_dictionary.h"
21#include "core/fpdfapi/parser/cpdf_document.h"
22#include "core/fpdfapi/parser/cpdf_name.h"
23#include "core/fpdfapi/parser/cpdf_number.h"
24#include "core/fpdfapi/parser/cpdf_reference.h"
25#include "core/fpdfapi/parser/cpdf_stream.h"
26#include "core/fpdfapi/parser/cpdf_string.h"
27#include "core/fpdfapi/parser/fpdf_parser_decode.h"
28#include "core/fpdfapi/parser/fpdf_parser_utility.h"
29#include "core/fpdfdoc/cpdf_bafontmap.h"
30#include "core/fpdfdoc/cpdf_formcontrol.h"
31#include "core/fpdfdoc/cpdf_icon.h"
32#include "core/fpdfdoc/cpvt_word.h"
33#include "core/fxcrt/fx_string_wrappers.h"
34#include "fpdfsdk/cpdfsdk_formfillenvironment.h"
35#include "fpdfsdk/cpdfsdk_interactiveform.h"
36#include "fpdfsdk/cpdfsdk_pageview.h"
37#include "fpdfsdk/cpdfsdk_widget.h"
38#include "fpdfsdk/pwl/cpwl_edit.h"
39#include "fpdfsdk/pwl/cpwl_edit_impl.h"
40#include "fpdfsdk/pwl/cpwl_wnd.h"
41#include "third_party/base/containers/span.h"
42#include "third_party/base/numerics/safe_conversions.h"
47enum class CheckStyle { kCheck = 0, kCircle, kCross, kDiamond, kSquare, kStar };
50enum class ButtonStyle {
60const char kAppendRectOperator[] =
"re";
61const char kConcatMatrixOperator[] =
"cm";
62const char kCurveToOperator[] =
"c";
63const char kEndPathNoFillOrStrokeOperator[] =
"n";
64const char kFillOperator[] =
"f";
65const char kFillEvenOddOperator[] =
"f*";
66const char kInvokeNamedXObjectOperator[] =
"Do";
67const char kLineToOperator[] =
"l";
68const char kMarkedSequenceBeginOperator[] =
"BMC";
69const char kMarkedSequenceEndOperator[] =
"EMC";
70const char kMoveTextPositionOperator[] =
"Td";
71const char kMoveToOperator[] =
"m";
72const char kSetCMYKOperator[] =
"k";
73const char kSetCMKYStrokedOperator[] =
"K";
74const char kSetDashOperator[] =
"d";
75const char kSetGrayOperator[] =
"g";
76const char kSetGrayStrokedOperator[] =
"G";
77const char kSetLineCapStyleOperator[] =
"J";
78const char kSetLineJoinStyleOperator[] =
"j";
79const char kSetLineWidthOperator[] =
"w";
80const char kSetNonZeroWindingClipOperator[] =
"W";
81const char kSetRGBOperator[] =
"rg";
82const char kSetRGBStrokedOperator[] =
"RG";
83const char kSetTextFontAndSizeOperator[] =
"Tf";
84const char kShowTextOperator[] =
"Tj";
85const char kStateRestoreOperator[] =
"Q";
86const char kStateSaveOperator[] =
"q";
87const char kStrokeOperator[] =
"S";
88const char kTextBeginOperator[] =
"BT";
89const char kTextEndOperator[] =
"ET";
91class AutoClosedCommand {
93 AutoClosedCommand(fxcrt::ostringstream* stream,
96 : stream_(stream), close_(close) {
97 *stream_ << open <<
"\n";
100 virtual ~AutoClosedCommand() { *stream_ << close_ <<
"\n"; }
103 UnownedPtr<fxcrt::ostringstream>
const stream_;
107class AutoClosedQCommand
final :
public AutoClosedCommand {
109 explicit AutoClosedQCommand(fxcrt::ostringstream* stream)
110 : AutoClosedCommand(stream, kStateSaveOperator, kStateRestoreOperator) {}
111 ~AutoClosedQCommand()
override =
default;
114void WriteMove(fxcrt::ostringstream& stream,
const CFX_PointF& point) {
115 WritePoint(stream, point) <<
" " << kMoveToOperator <<
"\n";
118void WriteLine(fxcrt::ostringstream& stream,
const CFX_PointF& point) {
119 WritePoint(stream, point) <<
" " << kLineToOperator <<
"\n";
122void WriteClosedLoop(fxcrt::ostringstream& stream,
123 pdfium::span<
const CFX_PointF> points) {
124 WriteMove(stream, points[0]);
125 for (
const auto& point : points.subspan(1))
126 WriteLine(stream, point);
127 WriteLine(stream, points[0]);
130void WriteBezierCurve(fxcrt::ostringstream& stream,
131 const CFX_PointF& point1,
132 const CFX_PointF& point2,
133 const CFX_PointF& point3) {
134 WritePoint(stream, point1) <<
" ";
135 WritePoint(stream, point2) <<
" ";
136 WritePoint(stream, point3) <<
" " << kCurveToOperator <<
"\n";
139void WriteAppendRect(fxcrt::ostringstream& stream,
const CFX_FloatRect& rect) {
140 WriteRect(stream, rect) <<
" " << kAppendRectOperator <<
"\n";
143ByteString GetStrokeColorAppStream(
const CFX_Color& color) {
144 fxcrt::ostringstream sColorStream;
149 sColorStream << color
.fColor1 <<
" " << kSetGrayStrokedOperator <<
"\n";
153 << color
.fColor3 <<
" " << kSetRGBStrokedOperator <<
"\n";
158 << kSetCMKYStrokedOperator <<
"\n";
161 return ByteString(sColorStream);
164ByteString GetFillColorAppStream(
const CFX_Color& color) {
165 fxcrt::ostringstream sColorStream;
170 sColorStream << color
.fColor1 <<
" " << kSetGrayOperator <<
"\n";
174 << color
.fColor3 <<
" " << kSetRGBOperator <<
"\n";
179 << kSetCMYKOperator <<
"\n";
182 return ByteString(sColorStream);
186 const float fWidth = crBBox
.Width();
189 CFX_PointF pts[8][3] = {{CFX_PointF(0.28f, 0.52f), CFX_PointF(0.27f, 0.48f),
190 CFX_PointF(0.29f, 0.40f)},
191 {CFX_PointF(0.30f, 0.33f), CFX_PointF(0.31f, 0.29f),
192 CFX_PointF(0.31f, 0.28f)},
193 {CFX_PointF(0.39f, 0.28f), CFX_PointF(0.49f, 0.29f),
194 CFX_PointF(0.77f, 0.67f)},
195 {CFX_PointF(0.76f, 0.68f), CFX_PointF(0.78f, 0.69f),
196 CFX_PointF(0.76f, 0.75f)},
197 {CFX_PointF(0.76f, 0.75f), CFX_PointF(0.73f, 0.80f),
198 CFX_PointF(0.68f, 0.75f)},
199 {CFX_PointF(0.68f, 0.74f), CFX_PointF(0.68f, 0.74f),
200 CFX_PointF(0.44f, 0.47f)},
201 {CFX_PointF(0.43f, 0.47f), CFX_PointF(0.40f, 0.47f),
202 CFX_PointF(0.41f, 0.58f)},
203 {CFX_PointF(0.40f, 0.60f), CFX_PointF(0.28f, 0.66f),
204 CFX_PointF(0.30f, 0.56f)}};
206 for (size_t i = 0; i <
std::size(pts); ++i) {
207 for (size_t j = 0; j <
std::size(pts[0]); ++j) {
208 pts[i][j].x = pts[i][j].x * fWidth + crBBox
.left;
209 pts[i][j].y *= pts[i][j].y * fHeight + crBBox
.bottom;
213 fxcrt::ostringstream csAP;
214 WriteMove(csAP, pts[0][0]);
216 for (size_t i = 0; i <
std::size(pts); ++i) {
217 size_t nNext = i < std::size(pts) - 1 ? i + 1 : 0;
218 const CFX_PointF& pt_next = pts[nNext][0];
220 float px1 = pts[i][1].x - pts[i][0].x;
221 float py1 = pts[i][1].y - pts[i][0].y;
222 float px2 = pts[i][2].x - pt_next.x;
223 float py2 = pts[i][2].y - pt_next.y;
232 return ByteString(csAP);
236 fxcrt::ostringstream csAP;
241 CFX_PointF pt1(crBBox.left, crBBox.bottom + fHeight / 2);
242 CFX_PointF pt2(crBBox.left + fWidth / 2, crBBox.top);
243 CFX_PointF pt3(crBBox.right, crBBox.bottom + fHeight / 2);
244 CFX_PointF pt4(crBBox.left + fWidth / 2, crBBox.bottom);
246 WriteMove(csAP, pt1);
248 float px = pt2.x - pt1.x;
249 float py = pt2.y - pt1.y;
251 WriteBezierCurve(csAP, {pt1.x, pt1.y + py *
FXSYS_BEZIER},
257 WriteBezierCurve(csAP, {pt2.x + px *
FXSYS_BEZIER, pt2.y},
263 WriteBezierCurve(csAP, {pt3.x, pt3.y - py *
FXSYS_BEZIER},
269 WriteBezierCurve(csAP, {pt4.x - px *
FXSYS_BEZIER, pt4.y},
272 return ByteString(csAP);
276 fxcrt::ostringstream csAP;
278 WriteMove(csAP, {crBBox
.left, crBBox
.top});
283 return ByteString(csAP);
287 fxcrt::ostringstream csAP;
292 const CFX_PointF points[] = {{crBBox.left, crBBox.bottom + fHeight / 2},
293 {crBBox.left + fWidth / 2, crBBox.top},
294 {crBBox.right, crBBox.bottom + fHeight / 2},
295 {crBBox.left + fWidth / 2, crBBox.bottom}};
296 WriteClosedLoop(csAP, points);
298 return ByteString(csAP);
302 fxcrt::ostringstream csAP;
304 const CFX_PointF points[] = {{crBBox.left, crBBox.top},
305 {crBBox.right, crBBox.top},
306 {crBBox.right, crBBox.bottom},
307 {crBBox.left, crBBox.bottom}};
308 WriteClosedLoop(csAP, points);
310 return ByteString(csAP);
314 fxcrt::ostringstream csAP;
317 CFX_PointF ptCenter = CFX_PointF((crBBox.left + crBBox.right) / 2.0f,
318 (crBBox.top + crBBox.bottom) / 2.0f);
320 CFX_PointF points[5];
322 for (
auto& point : points) {
324 ptCenter + CFX_PointF(fRadius * cosf(fAngle), fRadius * sinf(fAngle));
328 WriteMove(csAP, points[0]);
331 for (size_t i = 0; i <
std::size(points); ++i) {
332 next = (next + 2) %
std::size(points);
333 WriteLine(csAP, points[next]);
336 return ByteString(csAP);
339ByteString GetAP_HalfCircle(
const CFX_FloatRect& crBBox,
float fRotate) {
340 fxcrt::ostringstream csAP;
345 CFX_PointF pt1(-fWidth / 2, 0);
346 CFX_PointF pt2(0, fHeight / 2);
347 CFX_PointF pt3(fWidth / 2, 0);
349 CFX_Matrix rotate_matrix
(cos(fRotate)
, sin(fRotate)
, -sin(fRotate)
,
350 cos(fRotate)
, crBBox
.left + fWidth / 2
,
352 WriteMatrix(csAP, rotate_matrix) <<
" " << kConcatMatrixOperator <<
"\n";
354 WriteMove(csAP, pt1);
356 float px = pt2.x - pt1.x;
357 float py = pt2.y - pt1.y;
359 WriteBezierCurve(csAP, {pt1.x, pt1.y + py *
FXSYS_BEZIER},
365 WriteBezierCurve(csAP, {pt2.x + px *
FXSYS_BEZIER, pt2.y},
368 return ByteString(csAP);
373 fxcrt::ostringstream sAP;
375 AutoClosedQCommand q(&sAP);
376 sAP << GetFillColorAppStream(crText) << GetAP_Check(rcBBox) << kFillOperator
379 return ByteString(sAP);
384 fxcrt::ostringstream sAP;
386 AutoClosedQCommand q(&sAP);
387 sAP << GetFillColorAppStream(crText) << GetAP_Circle(rcBBox)
388 << kFillOperator <<
"\n";
390 return ByteString(sAP);
395 fxcrt::ostringstream sAP;
397 AutoClosedQCommand q(&sAP);
398 sAP << GetStrokeColorAppStream(crText) << GetAP_Cross(rcBBox)
399 << kStrokeOperator <<
"\n";
401 return ByteString(sAP);
406 fxcrt::ostringstream sAP;
408 AutoClosedQCommand q(&sAP);
409 sAP <<
"1 " << kSetLineWidthOperator <<
"\n"
410 << GetFillColorAppStream(crText) << GetAP_Diamond(rcBBox)
411 << kFillOperator <<
"\n";
413 return ByteString(sAP);
418 fxcrt::ostringstream sAP;
420 AutoClosedQCommand q(&sAP);
421 sAP << GetFillColorAppStream(crText) << GetAP_Square(rcBBox)
422 << kFillOperator <<
"\n";
424 return ByteString(sAP);
429 fxcrt::ostringstream sAP;
431 AutoClosedQCommand q(&sAP);
432 sAP << GetFillColorAppStream(crText) << GetAP_Star(rcBBox) << kFillOperator
435 return ByteString(sAP);
440 fxcrt::ostringstream sAppStream;
441 ByteString sColor = GetFillColorAppStream(color);
442 if (sColor.GetLength() > 0) {
443 AutoClosedQCommand q(&sAppStream);
444 sAppStream << sColor << GetAP_Circle(rect) << kFillOperator <<
"\n";
446 return ByteString(sAppStream);
449ByteString GetCircleBorderAppStream(
const CFX_FloatRect& rect,
456 fxcrt::ostringstream sAppStream;
460 AutoClosedQCommand q(&sAppStream);
462 float fHalfWidth = fWidth / 2.0f;
465 float div = fHalfWidth * 0.75f;
470 sColor
= GetStrokeColorAppStream(color);
471 if (sColor.GetLength() > 0) {
472 AutoClosedQCommand q2(&sAppStream);
473 sAppStream << fWidth <<
" " << kSetLineWidthOperator <<
"\n"
474 << sColor << GetAP_Circle(rect_by_2) <<
" "
475 << kStrokeOperator <<
"\n";
479 sColor
= GetStrokeColorAppStream(color);
480 if (sColor.GetLength() > 0) {
481 AutoClosedQCommand q2(&sAppStream);
482 sAppStream << fWidth <<
" " << kSetLineWidthOperator <<
"\n"
484 << dash
.nPhase <<
" " << kSetDashOperator <<
"\n"
485 << sColor << GetAP_Circle(rect_by_2) <<
" "
486 << kStrokeOperator <<
"\n";
490 sColor
= GetStrokeColorAppStream(color);
491 if (sColor.GetLength() > 0) {
492 AutoClosedQCommand q2(&sAppStream);
493 sAppStream << fHalfWidth <<
" " << kSetLineWidthOperator <<
"\n"
494 << sColor << GetAP_Circle(rect) <<
" " << kStrokeOperator
497 sColor
= GetStrokeColorAppStream(crLeftTop);
498 if (sColor.GetLength() > 0) {
499 AutoClosedQCommand q2(&sAppStream);
500 sAppStream << fHalfWidth <<
" " << kSetLineWidthOperator <<
"\n"
501 << sColor << GetAP_HalfCircle(rect_by_75,
FXSYS_PI / 4.0f)
502 <<
" " << kStrokeOperator <<
"\n";
504 sColor
= GetStrokeColorAppStream(crRightBottom);
505 if (sColor.GetLength() > 0) {
506 AutoClosedQCommand q2(&sAppStream);
507 sAppStream << fHalfWidth <<
" " << kSetLineWidthOperator <<
"\n"
509 << GetAP_HalfCircle(rect_by_75,
FXSYS_PI * 5 / 4.0f) <<
" "
510 << kStrokeOperator <<
"\n";
514 sColor
= GetStrokeColorAppStream(color);
515 if (sColor.GetLength() > 0) {
516 AutoClosedQCommand q2(&sAppStream);
517 sAppStream << fHalfWidth <<
" " << kSetLineWidthOperator <<
"\n"
518 << sColor << GetAP_Circle(rect) <<
" " << kStrokeOperator
521 sColor
= GetStrokeColorAppStream(crLeftTop);
522 if (sColor.GetLength() > 0) {
523 AutoClosedQCommand q2(&sAppStream);
524 sAppStream << fHalfWidth <<
" " << kSetLineWidthOperator <<
"\n"
525 << sColor << GetAP_HalfCircle(rect_by_75,
FXSYS_PI / 4.0f)
526 <<
" " << kStrokeOperator <<
"\n";
528 sColor
= GetStrokeColorAppStream(crRightBottom);
529 if (sColor.GetLength() > 0) {
530 AutoClosedQCommand q2(&sAppStream);
531 sAppStream << fHalfWidth <<
" " << kSetLineWidthOperator <<
"\n"
533 << GetAP_HalfCircle(rect_by_75,
FXSYS_PI * 5 / 4.0f) <<
" "
534 << kStrokeOperator <<
"\n";
539 return ByteString(sAppStream);
547 case CheckStyle::kCheck:
548 return GetAppStream_Check(rcCenter, crText);
549 case CheckStyle::kCircle:
551 return GetAppStream_Circle(rcCenter, crText);
552 case CheckStyle::kCross:
553 return GetAppStream_Cross(rcCenter, crText);
554 case CheckStyle::kDiamond:
556 return GetAppStream_Diamond(rcCenter, crText);
557 case CheckStyle::kSquare:
559 return GetAppStream_Square(rcCenter, crText);
560 case CheckStyle::kStar:
562 return GetAppStream_Star(rcCenter, crText);
566ByteString GetRadioButtonAppStream(
const CFX_FloatRect& rcBBox,
571 case CheckStyle::kCheck:
572 return GetAppStream_Check(rcCenter, crText);
573 case CheckStyle::kCircle:
575 return GetAppStream_Circle(rcCenter, crText);
576 case CheckStyle::kCross:
577 return GetAppStream_Cross(rcCenter, crText);
578 case CheckStyle::kDiamond:
580 return GetAppStream_Diamond(rcCenter, crText);
581 case CheckStyle::kSquare:
583 return GetAppStream_Square(rcCenter, crText);
584 case CheckStyle::kStar:
586 return GetAppStream_Star(rcCenter, crText);
597 if (sFontAlias.GetLength() <= 0 || fFontSize <= 0)
600 fxcrt::ostringstream sRet;
601 sRet <<
"/" << sFontAlias <<
" " << fFontSize <<
" "
602 << kSetTextFontAndSizeOperator <<
"\n";
603 return ByteString(sRet);
606ByteString GetWordRenderString(ByteStringView strWords) {
607 if (strWords.IsEmpty())
609 return PDF_EncodeString(strWords) +
" " + kShowTextOperator +
"\n";
613 const CFX_PointF& ptOffset,
619 fxcrt::ostringstream sEditStream;
620 int32_t nCurFontIndex = -1;
631 sEditStream << GetWordRenderString(sWords.AsStringView());
637 ptNew = CFX_PointF(word.ptWord.x + ptOffset.x,
638 word.ptWord.y + ptOffset.y);
642 ptNew = CFX_PointF(line.ptLine.x + ptOffset.x,
643 line.ptLine.y + ptOffset.y);
646 if (ptNew.x != ptOld.x || ptNew.y != ptOld.y) {
647 WritePoint(sEditStream, {ptNew.x - ptOld.x, ptNew.y - ptOld.y})
648 <<
" " << kMoveTextPositionOperator <<
"\n";
658 sEditStream << GetWordRenderString(sWords.AsStringView());
673 CFX_PointF(word.ptWord.x + ptOffset.x, word.ptWord.y + ptOffset.y);
675 if (ptNew.x != ptOld.x || ptNew.y != ptOld.y) {
676 WritePoint(sEditStream, {ptNew.x - ptOld.x, ptNew.y - ptOld.y})
677 <<
" " << kMoveTextPositionOperator <<
"\n";
685 sEditStream << GetWordRenderString(
693 sEditStream << GetWordRenderString(sWords.AsStringView());
695 fxcrt::ostringstream sAppStream;
696 if (sEditStream.tellp() > 0) {
697 sAppStream << sEditStream.str();
699 return ByteString(sAppStream);
710 auto pWnd =
std::make_unique<
CPWL_Wnd>(cp,
nullptr);
712 if (!pWnd->Move(rcIcon,
false,
false))
715 auto pPDFIcon =
std::make_unique<CPDF_Icon>(
std::move(pIconStream));
716 ByteString sAlias = pPDFIcon->GetImageAlias();
717 if (sAlias.GetLength() <= 0)
721 const CFX_SizeF image_size = pPDFIcon->GetImageSize();
722 const CFX_Matrix mt = pPDFIcon->GetImageMatrix().GetInverse();
723 const CFX_VectorF scale = fit.GetScale(image_size, rcPlate);
724 const CFX_VectorF offset = fit.GetImageOffset(image_size, scale, rcPlate);
726 fxcrt::ostringstream str;
728 AutoClosedQCommand q(&str);
729 WriteAppendRect(str, rcPlate);
730 str << kSetNonZeroWindingClipOperator <<
" "
731 << kEndPathNoFillOrStrokeOperator <<
"\n";
733 CFX_Matrix scale_matrix(scale.x, 0, 0, scale.y, rcPlate
.left + offset.x,
735 WriteMatrix(str, scale_matrix) <<
" " << kConcatMatrixOperator <<
"\n";
736 WriteMatrix(str, mt) <<
" " << kConcatMatrixOperator <<
"\n";
738 str <<
"0 " << kSetGrayOperator <<
" 0 " << kSetGrayStrokedOperator <<
" 1 "
739 << kSetLineWidthOperator <<
" /" << sAlias <<
" "
740 << kInvokeNamedXObjectOperator <<
"\n";
743 return ByteString(str);
746ByteString GetPushButtonAppStream(
const CFX_FloatRect& rcBBox,
750 const WideString& sLabel,
753 ButtonStyle nLayOut) {
754 const float fAutoFontScale = 1.0f / 3.0f;
757 pEdit->SetFontMap(pFontMap);
758 pEdit->SetAlignmentH(1);
759 pEdit->SetAlignmentV(1);
760 pEdit->SetMultiLine(
false);
761 pEdit->SetAutoReturn(
false);
763 pEdit->SetAutoFontSize(
true);
765 pEdit->SetFontSize(fFontSize);
768 pEdit->SetText(sLabel);
775 float fHeight = 0.0f;
778 case ButtonStyle::kLabel:
781 case ButtonStyle::kIcon:
784 case ButtonStyle::kIconTopLabelBottom:
789 rcBBox
.bottom + fHeight * fAutoFontScale
);
808 case ButtonStyle::kIconBottomLabelTop:
833 case ButtonStyle::kIconLeftLabelRight:
837 if (rcLabelContent
.Width() < fWidth * fAutoFontScale) {
843 if (rcLabelContent
.Width() < fWidth) {
867 case ButtonStyle::kIconRightLabelLeft:
871 if (rcLabelContent
.Width() < fWidth * fAutoFontScale) {
873 rcBBox
.left + fWidth * fAutoFontScale
,
878 if (rcLabelContent
.Width() < fWidth) {
903 case ButtonStyle::kLabelOverIcon:
909 fxcrt::ostringstream sTemp;
910 sTemp << GenerateIconAppStream(IconFit,
std::move(pIconStream), rcIcon);
913 pEdit->SetPlateRect(rcLabel);
916 GetEditAppStream(pEdit.get(), CFX_PointF(0.0f, 0.0f),
true, 0);
917 if (sEdit.GetLength() > 0) {
918 AutoClosedCommand bt(&sTemp, kTextBeginOperator, kTextEndOperator);
919 sTemp << GetFillColorAppStream(crText) << sEdit;
923 if (sTemp.tellp() <= 0)
926 fxcrt::ostringstream sAppStream;
928 AutoClosedQCommand q(&sAppStream);
929 WriteAppendRect(sAppStream, rcBBox);
930 sAppStream << kSetNonZeroWindingClipOperator <<
" "
931 << kEndPathNoFillOrStrokeOperator <<
"\n";
932 sAppStream << sTemp.str().c_str();
934 return ByteString(sAppStream);
937ByteString GetBorderAppStreamInternal(
const CFX_FloatRect& rect,
944 fxcrt::ostringstream sAppStream;
947 float fLeft = rect
.left;
948 float fRight = rect
.right;
949 float fTop = rect
.top;
953 float fHalfWidth = fWidth / 2.0f;
954 AutoClosedQCommand q(&sAppStream);
958 sColor
= GetFillColorAppStream(color);
959 if (sColor.GetLength() > 0) {
960 sAppStream << sColor;
961 WriteAppendRect(sAppStream, {fLeft, fBottom, fRight, fTop});
962 WriteAppendRect(sAppStream, {fLeft + fWidth, fBottom + fWidth,
963 fRight - fWidth, fTop - fWidth});
964 sAppStream << kFillEvenOddOperator <<
"\n";
968 sColor
= GetStrokeColorAppStream(color);
969 if (sColor.GetLength() > 0) {
970 sAppStream << sColor;
971 sAppStream << fWidth <<
" " << kSetLineWidthOperator <<
" ["
973 <<
" " << kSetDashOperator <<
"\n";
974 const CFX_PointF points[] = {
975 {fLeft + fWidth / 2, fBottom + fWidth / 2},
976 {fLeft + fWidth / 2, fTop - fWidth / 2},
977 {fRight - fWidth / 2, fTop - fWidth / 2},
978 {fRight - fWidth / 2, fBottom + fWidth / 2}};
979 WriteClosedLoop(sAppStream, points);
980 sAppStream << kStrokeOperator <<
"\n";
985 sColor
= GetFillColorAppStream(crLeftTop);
986 if (sColor.GetLength() > 0) {
987 sAppStream << sColor;
988 WriteMove(sAppStream, {fLeft + fHalfWidth, fBottom + fHalfWidth});
989 WriteLine(sAppStream, {fLeft + fHalfWidth, fTop - fHalfWidth});
990 WriteLine(sAppStream, {fRight - fHalfWidth, fTop - fHalfWidth});
991 WriteLine(sAppStream,
992 {fRight - fHalfWidth * 2, fTop - fHalfWidth * 2});
993 WriteLine(sAppStream,
994 {fLeft + fHalfWidth * 2, fTop - fHalfWidth * 2});
995 WriteLine(sAppStream,
996 {fLeft + fHalfWidth * 2, fBottom + fHalfWidth * 2});
997 sAppStream << kFillOperator <<
"\n";
999 sColor
= GetFillColorAppStream(crRightBottom);
1000 if (sColor.GetLength() > 0) {
1001 sAppStream << sColor;
1002 WriteMove(sAppStream, {fRight - fHalfWidth, fTop - fHalfWidth});
1003 WriteLine(sAppStream, {fRight - fHalfWidth, fBottom + fHalfWidth});
1004 WriteLine(sAppStream, {fLeft + fHalfWidth, fBottom + fHalfWidth});
1005 WriteLine(sAppStream,
1006 {fLeft + fHalfWidth * 2, fBottom + fHalfWidth * 2});
1007 WriteLine(sAppStream,
1008 {fRight - fHalfWidth * 2, fBottom + fHalfWidth * 2});
1009 WriteLine(sAppStream,
1010 {fRight - fHalfWidth * 2, fTop - fHalfWidth * 2});
1011 sAppStream << kFillOperator <<
"\n";
1013 sColor
= GetFillColorAppStream(color);
1014 if (sColor.GetLength() > 0) {
1015 sAppStream << sColor;
1016 WriteAppendRect(sAppStream, {fLeft, fBottom, fRight, fTop});
1017 WriteAppendRect(sAppStream, {fLeft + fHalfWidth, fBottom + fHalfWidth,
1018 fRight - fHalfWidth, fTop - fHalfWidth});
1019 sAppStream << kFillEvenOddOperator <<
"\n";
1023 sColor
= GetStrokeColorAppStream(color);
1024 if (sColor.GetLength() > 0) {
1025 sAppStream << sColor;
1026 sAppStream << fWidth <<
" " << kSetLineWidthOperator <<
"\n";
1027 WriteMove(sAppStream, {fLeft, fBottom + fWidth / 2});
1028 WriteLine(sAppStream, {fRight, fBottom + fWidth / 2});
1029 sAppStream << kStrokeOperator <<
"\n";
1034 return ByteString(sAppStream);
1037ByteString GetDropButtonAppStream(
const CFX_FloatRect& rcBBox) {
1039 return ByteString
();
1041 fxcrt::ostringstream sAppStream;
1043 AutoClosedQCommand q(&sAppStream);
1044 sAppStream << GetFillColorAppStream(
1047 WriteAppendRect(sAppStream, rcBBox);
1048 sAppStream << kFillOperator <<
"\n";
1052 AutoClosedQCommand q(&sAppStream);
1053 sAppStream << GetBorderAppStreamInternal(
1060 CFX_PointF ptCenter = CFX_PointF((rcBBox.left + rcBBox.right) / 2,
1061 (rcBBox.top + rcBBox.bottom) / 2);
1064 AutoClosedQCommand q(&sAppStream);
1065 const CFX_PointF points[] = {{ptCenter.x - 3, ptCenter.y + 1.5f},
1066 {ptCenter.x + 3, ptCenter.y + 1.5f},
1067 {ptCenter.x, ptCenter.y - 1.5f}};
1068 sAppStream <<
" 0 " << kSetGrayOperator <<
"\n";
1069 WriteClosedLoop(sAppStream, points);
1070 sAppStream << kFillOperator <<
"\n";
1073 return ByteString(sAppStream);
1078 fxcrt::ostringstream sAppStream;
1079 ByteString sColor = GetFillColorAppStream(color);
1080 if (sColor.GetLength() > 0) {
1081 AutoClosedQCommand q(&sAppStream);
1082 sAppStream << sColor;
1083 WriteAppendRect(sAppStream, rect);
1084 sAppStream << kFillOperator <<
"\n";
1087 return ByteString(sAppStream);
1090void SetDefaultIconName(CPDF_Stream* pIcon,
const char* name) {
1094 RetainPtr<CPDF_Dictionary> pImageDict = pIcon->GetMutableDict();
1098 if (pImageDict->KeyExist(
"Name"))
1101 pImageDict->SetNewFor<CPDF_String>(
"Name", name,
false);
1104absl::optional<CheckStyle> CheckStyleFromCaption(
const WideString& caption) {
1105 if (caption.IsEmpty())
1106 return absl::nullopt;
1109 switch (caption
[0
]) {
1111 return CheckStyle::kCheck;
1113 return CheckStyle::kCross;
1115 return CheckStyle::kStar;
1117 return CheckStyle::kCircle;
1119 return CheckStyle::kSquare;
1121 return CheckStyle::kDiamond;
1123 return absl::nullopt;
1130 CPDF_Dictionary* dict)
1138 ButtonStyle nLayout = ButtonStyle::kLabel;
1141 nLayout = ButtonStyle::kIcon;
1144 nLayout = ButtonStyle::kIconTopLabelBottom;
1147 nLayout = ButtonStyle::kIconBottomLabelTop;
1150 nLayout = ButtonStyle::kIconLeftLabelRight;
1153 nLayout = ButtonStyle::kIconRightLabelLeft;
1156 nLayout = ButtonStyle::kLabelOverIcon;
1159 nLayout = ButtonStyle::kLabel;
1166 float fBorderWidth =
static_cast<
float>(widget_->GetBorderWidth());
1171 BorderStyle nBorderStyle = widget_->GetBorderStyle();
1172 switch (nBorderStyle) {
1179 crRightBottom
= crBackground
/ 2.0f;
1192 absl::optional<CFX_Color> color = da.GetColor();
1193 CFX_Color crText = color.value_or(CFX_Color(CFX_Color::Type::kGray, 0));
1196 ByteString csNameTag;
1197 absl::optional<ByteString> font = da.GetFont(&fFontSize);
1198 if (font.has_value())
1199 csNameTag = font.value();
1203 WideString csWCaption;
1204 WideString csNormalCaption;
1205 WideString csRolloverCaption;
1206 WideString csDownCaption;
1220 pNormalIcon = pControl->GetNormalIcon();
1223 pRolloverIcon = pControl->GetRolloverIcon();
1226 pDownIcon = pControl->GetDownIcon();
1228 SetDefaultIconName(pNormalIcon.Get(),
"ImgA");
1229 SetDefaultIconName(pRolloverIcon.Get(),
"ImgB");
1230 SetDefaultIconName(pDownIcon.Get(),
"ImgC");
1234 CPDF_BAFontMap font_map(widget_->GetPDFPage()->GetDocument(),
1235 widget_->GetPDFAnnot()->GetMutableAnnotDict(),
"N");
1237 GetRectFillAppStream(rcWindow, crBackground)
+
1238 GetBorderAppStreamInternal(rcWindow, fBorderWidth, crBorder, crLeftTop,
1239 crRightBottom, nBorderStyle, dsBorder) +
1241 &font_map, pNormalIcon, iconFit, csNormalCaption,
1242 crText, fFontSize, nLayout);
1244 Write(
"N", csAP, ByteString
());
1246 AddImage(
"N", pNormalIcon.Get());
1255 if (csRolloverCaption
.IsEmpty() && !pRolloverIcon) {
1256 csRolloverCaption
= csNormalCaption;
1257 pRolloverIcon = pNormalIcon;
1261 CPDF_BAFontMap font_map(widget_->GetPDFPage()->GetDocument(),
1262 widget_->GetPDFAnnot()->GetMutableAnnotDict(),
"R");
1264 GetRectFillAppStream(rcWindow, crBackground)
+
1265 GetBorderAppStreamInternal(rcWindow, fBorderWidth, crBorder, crLeftTop,
1266 crRightBottom, nBorderStyle, dsBorder) +
1268 &font_map, pRolloverIcon, iconFit,
1269 csRolloverCaption, crText, fFontSize, nLayout);
1271 Write(
"R", csAP, ByteString
());
1273 AddImage(
"R", pRolloverIcon.Get());
1276 csDownCaption
= csNormalCaption;
1277 pDownIcon = pNormalIcon;
1280 switch (nBorderStyle) {
1283 crLeftTop
= crRightBottom;
1284 crRightBottom
= crTemp;
1297 CPDF_BAFontMap font_map(widget_->GetPDFPage()->GetDocument(),
1298 widget_->GetPDFAnnot()->GetMutableAnnotDict(),
"D");
1300 GetRectFillAppStream(rcWindow, crBackground
- 0.25f)
+
1301 GetBorderAppStreamInternal(rcWindow, fBorderWidth, crBorder, crLeftTop,
1302 crRightBottom, nBorderStyle, dsBorder) +
1304 &font_map, pDownIcon, iconFit, csDownCaption,
1305 crText, fFontSize, nLayout);
1307 Write(
"D", csAP, ByteString
());
1309 AddImage(
"D", pDownIcon.Get());
1317 float fBorderWidth =
static_cast<
float>(widget_->GetBorderWidth());
1322 BorderStyle nBorderStyle = widget_->GetBorderStyle();
1323 switch (nBorderStyle) {
1330 crRightBottom
= crBackground
/ 2.0f;
1343 absl::optional<CFX_Color> color = pControl->GetDefaultAppearance().GetColor();
1344 CFX_Color crText = color.value_or(CFX_Color());
1346 CheckStyle nStyle = CheckStyleFromCaption(pControl->GetNormalCaption())
1347 .value_or(CheckStyle::kCheck);
1348 ByteString csAP_N_ON =
1349 GetRectFillAppStream(rcWindow, crBackground)
+
1350 GetBorderAppStreamInternal(rcWindow, fBorderWidth, crBorder, crLeftTop,
1351 crRightBottom, nBorderStyle, dsBorder);
1353 ByteString csAP_N_OFF = csAP_N_ON;
1355 switch (nBorderStyle) {
1358 crLeftTop
= crRightBottom;
1359 crRightBottom
= crTemp;
1371 ByteString csAP_D_ON =
1372 GetRectFillAppStream(rcWindow, crBackground
- 0.25f)
+
1373 GetBorderAppStreamInternal(rcWindow, fBorderWidth, crBorder, crLeftTop,
1374 crRightBottom, nBorderStyle, dsBorder);
1376 ByteString csAP_D_OFF = csAP_D_ON;
1378 csAP_N_ON
+= GetCheckBoxAppStream(rcClient, nStyle, crText);
1379 csAP_D_ON
+= GetCheckBoxAppStream(rcClient, nStyle, crText);
1382 Write(
"N", csAP_N_OFF,
"Off");
1385 Write(
"D", csAP_D_OFF,
"Off");
1387 ByteString csAS = widget_->GetAppState();
1389 widget_->SetAppStateOff();
1396 float fBorderWidth =
static_cast<
float>(widget_->GetBorderWidth());
1401 BorderStyle nBorderStyle = widget_->GetBorderStyle();
1402 switch (nBorderStyle) {
1409 crRightBottom
= crBackground
/ 2.0f;
1422 absl::optional<CFX_Color> color = pControl->GetDefaultAppearance().GetColor();
1423 CFX_Color crText = color.value_or(CFX_Color());
1424 CheckStyle nStyle = CheckStyleFromCaption(pControl->GetNormalCaption())
1425 .value_or(CheckStyle::kCircle);
1427 ByteString csAP_N_ON;
1429 if (nStyle == CheckStyle::kCircle) {
1432 crRightBottom
= crBackground
- 0.25f;
1439 GetCircleFillAppStream(rcCenter, crBackground)
+
1440 GetCircleBorderAppStream(rcCenter, fBorderWidth, crBorder, crLeftTop,
1441 crRightBottom, nBorderStyle, dsBorder);
1444 GetRectFillAppStream(rcWindow, crBackground)
+
1445 GetBorderAppStreamInternal(rcWindow, fBorderWidth, crBorder, crLeftTop,
1446 crRightBottom, nBorderStyle, dsBorder);
1449 ByteString csAP_N_OFF = csAP_N_ON;
1451 switch (nBorderStyle) {
1454 crLeftTop
= crRightBottom;
1455 crRightBottom
= crTemp;
1467 ByteString csAP_D_ON;
1469 if (nStyle == CheckStyle::kCircle) {
1472 crLeftTop
= crBackground
- 0.25f;
1474 crBK
= crBackground;
1481 GetCircleFillAppStream(rcCenter, crBK)
+
1482 GetCircleBorderAppStream(rcCenter, fBorderWidth, crBorder, crLeftTop,
1483 crRightBottom, nBorderStyle, dsBorder);
1486 GetRectFillAppStream(rcWindow, crBackground
- 0.25f)
+
1487 GetBorderAppStreamInternal(rcWindow, fBorderWidth, crBorder, crLeftTop,
1488 crRightBottom, nBorderStyle, dsBorder);
1491 ByteString csAP_D_OFF = csAP_D_ON;
1493 ByteString app_stream = GetRadioButtonAppStream(rcClient, nStyle, crText);
1494 csAP_N_ON
+= app_stream;
1495 csAP_D_ON
+= app_stream;
1498 Write(
"N", csAP_N_OFF,
"Off");
1501 Write(
"D", csAP_D_OFF,
"Off");
1503 ByteString csAS = widget_->GetAppState();
1505 widget_->SetAppStateOff();
1509 CPDF_FormControl* pControl = widget_->GetFormControl();
1510 CPDF_FormField* pField = pControl->GetField();
1511 fxcrt::ostringstream sBody;
1513 CFX_FloatRect rcClient = widget_->GetClientRect();
1514 CFX_FloatRect rcButton = rcClient;
1515 rcButton.left = rcButton.right - 13;
1516 rcButton.Normalize();
1519 CPDF_BAFontMap font_map(widget_->GetPDFPage()->GetDocument(),
1520 widget_->GetPDFAnnot()->GetMutableAnnotDict(),
"N");
1522 auto pEdit = std::make_unique<CPWL_EditImpl>();
1523 pEdit->EnableRefresh(
false);
1524 pEdit->SetFontMap(&font_map);
1526 CFX_FloatRect rcEdit = rcClient;
1527 rcEdit.right = rcButton.left;
1530 pEdit->SetPlateRect(rcEdit);
1531 pEdit->SetAlignmentV(1);
1533 float fFontSize = widget_->GetFontSize();
1535 pEdit->SetAutoFontSize(
true);
1537 pEdit->SetFontSize(fFontSize);
1539 pEdit->Initialize();
1540 if (sValue.has_value()) {
1541 pEdit->SetText(sValue.value());
1543 int32_t nCurSel = pField->GetSelectedIndex(0);
1545 pEdit->SetText(pField->GetValue());
1547 pEdit->SetText(pField->GetOptionLabel(nCurSel));
1552 CFX_FloatRect rcContent = pEdit->GetContentRect();
1553 ByteString sEdit = GetEditAppStream(pEdit.get(), CFX_PointF(),
true, 0);
1554 if (sEdit.GetLength() > 0) {
1556 AutoClosedCommand bmc(&sBody, kMarkedSequenceBeginOperator,
1557 kMarkedSequenceEndOperator);
1558 AutoClosedQCommand q(&sBody);
1560 if (rcContent.Width() > rcEdit.Width() ||
1561 rcContent.Height() > rcEdit.Height()) {
1562 WriteAppendRect(sBody, rcEdit);
1563 sBody << kSetNonZeroWindingClipOperator <<
"\n"
1564 << kEndPathNoFillOrStrokeOperator <<
"\n";
1567 CFX_Color crText = widget_->GetTextPWLColor();
1568 AutoClosedCommand bt(&sBody, kTextBeginOperator, kTextEndOperator);
1569 sBody << GetFillColorAppStream(crText) << sEdit;
1572 sBody << GetDropButtonAppStream(rcButton);
1574 GetBackgroundAppStream() + GetBorderAppStream() + ByteString(sBody),
1582 fxcrt::ostringstream sBody;
1585 CPDF_BAFontMap font_map(widget_->GetPDFPage()->GetDocument(),
1586 widget_->GetPDFAnnot()->GetMutableAnnotDict(),
"N");
1589 pEdit->EnableRefresh(
false);
1590 pEdit->SetFontMap(&font_map);
1593 float fFontSize = widget_->GetFontSize();
1595 pEdit->Initialize();
1597 fxcrt::ostringstream sList;
1598 float fy = rcClient
.top;
1604 for (int32_t i = nTop; i < nCount; ++i) {
1605 bool bSelected =
false;
1606 for (int32_t j = 0; j < nSelCount; ++j) {
1623 AutoClosedQCommand q(&sList);
1626 WriteAppendRect(sList, rcItem);
1627 sList << kFillOperator <<
"\n";
1630 AutoClosedCommand bt(&sList, kTextBeginOperator, kTextEndOperator);
1632 << GetEditAppStream(pEdit.get(), CFX_PointF(0.0f, fy),
true, 0);
1634 CFX_Color crText = widget_->GetTextPWLColor();
1636 AutoClosedCommand bt(&sList, kTextBeginOperator, kTextEndOperator);
1637 sList << GetFillColorAppStream(crText)
1638 << GetEditAppStream(pEdit.get(), CFX_PointF(0.0f, fy),
true, 0);
1644 if (sList.tellp() > 0) {
1646 AutoClosedCommand bmc(&sBody, kMarkedSequenceBeginOperator,
1647 kMarkedSequenceEndOperator);
1648 AutoClosedQCommand q(&sBody);
1650 WriteAppendRect(sBody, rcClient);
1651 sBody << kSetNonZeroWindingClipOperator <<
"\n"
1652 << kEndPathNoFillOrStrokeOperator <<
"\n"
1656 GetBackgroundAppStream()
+ GetBorderAppStream()
+ ByteString(sBody),
1661 CPDF_FormControl* pControl = widget_->GetFormControl();
1662 CPDF_FormField* pField = pControl->GetField();
1663 fxcrt::ostringstream sBody;
1664 fxcrt::ostringstream sLines;
1667 CPDF_BAFontMap font_map(widget_->GetPDFPage()->GetDocument(),
1668 widget_->GetPDFAnnot()->GetMutableAnnotDict(),
"N");
1670 auto pEdit = std::make_unique<CPWL_EditImpl>();
1671 pEdit->EnableRefresh(
false);
1672 pEdit->SetFontMap(&font_map);
1674 CFX_FloatRect rcClient = widget_->GetClientRect();
1675 pEdit->SetPlateRect(rcClient);
1676 pEdit->SetAlignmentH(pControl->GetControlAlignment());
1678 uint32_t dwFieldFlags = pField->GetFieldFlags();
1679 bool bMultiLine = dwFieldFlags & pdfium::form_flags::kTextMultiline;
1681 pEdit->SetMultiLine(
true);
1682 pEdit->SetAutoReturn(
true);
1684 pEdit->SetAlignmentV(1);
1687 uint16_t subWord = 0;
1688 if (dwFieldFlags & pdfium::form_flags::kTextPassword) {
1690 pEdit->SetPasswordChar(subWord);
1693 int nMaxLen = pField->GetMaxLen();
1694 bool bCharArray = dwFieldFlags & pdfium::form_flags::kTextComb;
1695 float fFontSize = widget_->GetFontSize();
1697#ifdef PDF_ENABLE_XFA
1698 if (!sValue.has_value() && widget_->GetMixXFAWidget())
1699 sValue = widget_->GetValue();
1704 pEdit->SetCharArray(nMaxLen);
1706 fFontSize = CPWL_Edit::GetCharArrayAutoFontSize(
1707 font_map.GetPDFFont(0).Get(), rcClient, nMaxLen);
1710 if (sValue.has_value())
1711 nMaxLen = pdfium::base::checked_cast<
int>(sValue.value().GetLength());
1712 pEdit->SetLimitChar(nMaxLen);
1717 pEdit->SetAutoFontSize(
true);
1719 pEdit->SetFontSize(fFontSize);
1721 pEdit->Initialize();
1722 pEdit->SetText(sValue.value_or(pField->GetValue()));
1725 CFX_FloatRect rcContent = pEdit->GetContentRect();
1727 GetEditAppStream(pEdit.get(), CFX_PointF(), !bCharArray, subWord);
1729 if (sEdit.GetLength() > 0) {
1731 AutoClosedCommand bmc(&sBody, kMarkedSequenceBeginOperator,
1732 kMarkedSequenceEndOperator);
1733 AutoClosedQCommand q(&sBody);
1735 if (rcContent.Width() > rcClient.Width() ||
1736 rcContent.Height() > rcClient.Height()) {
1737 WriteAppendRect(sBody, rcClient);
1738 sBody << kSetNonZeroWindingClipOperator <<
"\n"
1739 << kEndPathNoFillOrStrokeOperator <<
"\n";
1741 CFX_Color crText = widget_->GetTextPWLColor();
1743 AutoClosedCommand bt(&sBody, kTextBeginOperator, kTextEndOperator);
1744 sBody << GetFillColorAppStream(crText) << sEdit;
1748 switch (widget_->GetBorderStyle()) {
1749 case BorderStyle::kSolid: {
1751 GetStrokeColorAppStream(widget_->GetBorderPWLColor());
1752 if (sColor.GetLength() > 0) {
1753 AutoClosedQCommand q(&sLines);
1754 sLines << widget_->GetBorderWidth() <<
" " << kSetLineWidthOperator
1756 << GetStrokeColorAppStream(widget_->GetBorderPWLColor())
1757 <<
" 2 " << kSetLineCapStyleOperator <<
" 0 "
1758 << kSetLineJoinStyleOperator <<
"\n";
1760 const float width = rcClient.right - rcClient.left;
1761 for (int32_t i = 1; i < nMaxLen; ++i) {
1762 const float left = rcClient.left + (width / nMaxLen) * i;
1763 WriteMove(sLines, {left, rcClient.bottom});
1764 WriteLine(sLines, {left, rcClient.top});
1765 sLines << kStrokeOperator <<
"\n";
1770 case BorderStyle::kDash: {
1772 GetStrokeColorAppStream(widget_->GetBorderPWLColor());
1773 if (sColor.GetLength() > 0) {
1774 CPWL_Dash dsBorder = CPWL_Dash(3, 3, 0);
1775 AutoClosedQCommand q(&sLines);
1776 sLines << widget_->GetBorderWidth() <<
" " << kSetLineWidthOperator
1778 << GetStrokeColorAppStream(widget_->GetBorderPWLColor()) <<
"["
1779 << dsBorder.nDash <<
" " << dsBorder.nGap <<
"] "
1780 << dsBorder.nPhase <<
" " << kSetDashOperator <<
"\n";
1782 const float width = rcClient.right - rcClient.left;
1783 for (int32_t i = 1; i < nMaxLen; ++i) {
1784 const float left = rcClient.left + (width / nMaxLen) * i;
1785 WriteMove(sLines, {left, rcClient.bottom});
1786 WriteLine(sLines, {left, rcClient.top});
1787 sLines << kStrokeOperator <<
"\n";
1798 GetBackgroundAppStream() + GetBorderAppStream() + ByteString(sLines) +
1804 CPDF_Stream* pImage) {
1805 RetainPtr<CPDF_Stream> pStream = dict_->GetMutableStreamFor(sAPType);
1806 RetainPtr<CPDF_Dictionary> pStreamDict = pStream->GetMutableDict();
1807 ByteString sImageAlias =
"IMG";
1809 RetainPtr<
const CPDF_Dictionary> pImageDict = pImage->GetDict();
1811 sImageAlias = pImageDict->GetByteStringFor(
"Name");
1813 RetainPtr<CPDF_Dictionary> pStreamResList =
1814 pStreamDict->GetOrCreateDictFor(
"Resources");
1815 auto pXObject = pStreamResList->SetNewFor<CPDF_Dictionary>(
"XObject");
1816 pXObject->SetNewFor<CPDF_Reference>(sImageAlias,
1817 widget_->GetPageView()->GetPDFDocument(),
1818 pImage->GetObjNum());
1822 const ByteString& sContents,
1823 const ByteString& sAPState) {
1827 pParentDict = dict_;
1830 pParentDict = dict_->GetOrCreateDictFor(sAPType);
1834 RetainPtr<CPDF_Dictionary> pOrigStreamDict;
1838 RetainPtr<CPDF_Stream> pStream = pParentDict->GetMutableStreamFor(key);
1839 CPDF_Document* doc = widget_->GetPageView()->GetPDFDocument();
1842 pOrigStreamDict = pStream->GetMutableDict();
1844 pParentDict->SetNewFor<CPDF_Reference>(key, doc, pStream->GetObjNum());
1847 RetainPtr<CPDF_Dictionary> pStreamDict = pStream->GetMutableDict();
1849 pStreamDict = doc->New<CPDF_Dictionary>();
1850 pStreamDict->SetNewFor<CPDF_Name>(
"Type",
"XObject");
1851 pStreamDict->SetNewFor<CPDF_Name>(
"Subtype",
"Form");
1852 pStreamDict->SetNewFor<CPDF_Number>(
"FormType", 1);
1854 if (pOrigStreamDict) {
1855 RetainPtr<
const CPDF_Dictionary> pResources =
1856 pOrigStreamDict->GetDictFor(
"Resources");
1858 pStreamDict->SetFor(
"Resources", pResources->Clone());
1861 pStream->InitStreamWithEmptyData(pStreamDict);
1863 pStreamDict->SetMatrixFor(
"Matrix", widget_->GetMatrix());
1864 pStreamDict->SetRectFor(
"BBox", widget_->GetRotatedRect());
1865 pStream->SetDataAndRemoveFilter(sContents.raw_span());
1869 dict_->RemoveFor(sAPType);
1873 CFX_Color crBackground = widget_->GetFillPWLColor();
1874 if (crBackground.nColorType != CFX_Color::Type::kTransparent)
1875 return GetRectFillAppStream(widget_->GetRotatedRect(), crBackground);
1877 return ByteString
();
1882 CFX_Color crBorder = widget_->GetBorderPWLColor();
1883 CFX_Color crBackground = widget_->GetFillPWLColor();
1887 float fBorderWidth =
static_cast<
float>(widget_->GetBorderWidth());
1890 BorderStyle nBorderStyle = widget_->GetBorderStyle();
1891 switch (nBorderStyle) {
1898 crRightBottom
= crBackground
/ 2.0f;
1909 return GetBorderAppStreamInternal(rcWindow, fBorderWidth, crBorder, crLeftTop,
1910 crRightBottom, nBorderStyle, dsBorder);
CFX_FloatRect GetCenterSquare() const
constexpr CFX_FloatRect(float l, float b, float r, float t)
void ScaleFromCenterPoint(float fScale)
CFX_FloatRect & operator=(const CFX_FloatRect &that)=default
CFX_FloatRect GetDeflated(float x, float y) const
CFX_Matrix(float a1, float b1, float c1, float d1, float e1, float f1)
CPDFSDK_AppStream(CPDFSDK_Widget *widget, CPDF_Dictionary *dict)
bool IsModifiedAPStream(const CPDF_Stream *stream) const
RetainPtr< CPDF_Stream > CreateModifiedAPStream()
bool GetFittingBounds() const
void SetAt(int32_t nWordIndex)
bool GetWord(CPVT_Word &word) const
bool GetLine(CPVT_Line &line) const
const CPVT_WordPlace & GetAt() const
ByteString GetPDFWordString(int32_t nFontIndex, uint16_t Word, uint16_t SubWord)
IPVT_FontMap * GetFontMap()
CreateParams(CFX_Timer::HandlerIface *timer_handler, IPWL_FillerNotify *filler_notify, ProviderIface *provider)
virtual ByteString GetPDFFontAlias(int32_t nFontIndex)=0
ByteString & operator+=(const ByteString &str)
ByteString & operator=(const ByteString &that)
ByteString & operator=(ByteString &&that) noexcept
WideString & operator=(WideString &&that) noexcept
CharType operator[](const size_t index) const
WideString & operator=(const WideString &that)
#define FXSYS_IsFloatBigger(fa, fb)
#define FXSYS_IsFloatZero(f)
ByteString operator+(const ByteString &str1, const ByteString &str2)
CFX_Color operator/(float fColorDivide) const
CFX_Color operator-(float fColorSub) const
CFX_Color & operator=(const CFX_Color &that)=default
constexpr CFX_Color(Type type=CFX_Color::Type::kTransparent, float color1=0.0f, float color2=0.0f, float color3=0.0f, float color4=0.0f)
int32_t LineCmp(const CPVT_WordPlace &wp) const
CPWL_Dash(int32_t dash, int32_t gap, int32_t phase)