7#include "xfa/fxfa/parser/cxfa_rectangle.h"
13#include "core/fxcrt/check.h"
14#include "core/fxcrt/notreached.h"
15#include "fxjs/xfa/cjx_node.h"
16#include "xfa/fgas/graphics/cfgas_gegraphics.h"
17#include "xfa/fxfa/parser/cxfa_corner.h"
18#include "xfa/fxfa/parser/cxfa_document.h"
19#include "xfa/fxfa/parser/cxfa_stroke.h"
63 pdfium::span<
const PropertyData> properties,
64 pdfium::span<
const AttributeData> attributes,
79 CFGAS_GEPath* fillPath) {
80 bool bSameStyles =
true;
82 for (int32_t i = 1; i < 8; i++) {
93 for (int32_t i = 2; i < 8; i += 2) {
104 stroke1 = strokes[0];
117 for (int32_t i = 0; i < 8; i += 2) {
137 cp1 = rtWidget.TopLeft();
138 cp2 = rtWidget.TopRight();
151 cp1 = rtWidget.TopRight();
152 cp2 = rtWidget.BottomRight();
165 cp1 = rtWidget.BottomRight();
166 cp2 = rtWidget.BottomLeft();
172 sx = bInverted ?
FXSYS_PI * 3 / 2 : 0;
179 cp1 = rtWidget.BottomLeft();
180 cp2 = rtWidget.TopLeft();
202 CFX_RectF rtRadius(cp1.x, cp1.y, fRadius1 * 2 * vx, fRadius1 * 2 * vy);
205 rtRadius
.Offset(-fRadius1 * vx
, -fRadius1 * vy
);
207 fillPath
->ArcTo(rtRadius.TopLeft()
, rtRadius.Size()
, sx
, sy
);
211 cp.x = cp1.x + fRadius1 * vx;
212 cp.y = cp1.y + fRadius1 * vy;
218 CFX_PointF(cp1.x + fRadius1 * sx, cp1.y + fRadius1 * sy)
);
228 bool bVisible =
false;
229 for (int32_t j = 0; j < 4; j++) {
230 if (strokes[j * 2 + 1]->IsVisible()) {
238 for (int32_t i = 1; i < 8; i += 2) {
239 float fThickness = fmax(0.0, strokes[i]->GetThickness());
240 float fHalf = fThickness / 2;
245 rtWidget
.top -= fHalf;
248 rtWidget
.top += fHalf;
268 rtWidget
.left -= fHalf;
271 rtWidget
.left += fHalf;
277 Stroke(strokes, pGS, rtWidget, matrix);
284 auto [i3DType, bVisible, fThickness] =
Get3DStyle();
285 if (i3DType != XFA_AttributeValue::Unknown) {
286 if (!bVisible || fThickness < 0.001f)
290 case XFA_AttributeValue::Lowered:
293 case XFA_AttributeValue::Raised:
296 case XFA_AttributeValue::Etched:
299 case XFA_AttributeValue::Embossed:
309 bool bSameStyles =
true;
311 for (int32_t i = 1; i < 8; i++) {
320 stroke1 = strokes[0];
322 for (int32_t i = 2; i < 8; i += 2) {
333 stroke1 = strokes[0];
343 for (int32_t i = 0; i < 8; i++) {
355 GetPath(strokes, rtWidget, path, i, bStart, !bSameStyles);
370 strokes[7]->Stroke(pGS, path, matrix);
386 pathLT
.LineTo(CFX_PointF(fRight - fLineWidth, rt
.top + fLineWidth)
);
388 pathLT
.LineTo(CFX_PointF(rt
.left + fLineWidth, fBottom - fLineWidth)
);
395 pathRB
.LineTo(CFX_PointF(fRight, fBottom)
);
397 pathRB
.LineTo(CFX_PointF(rt
.left + fLineWidth, fBottom - fLineWidth)
);
398 pathRB
.LineTo(CFX_PointF(fRight - fLineWidth, fBottom - fLineWidth)
);
399 pathRB
.LineTo(CFX_PointF(fRight - fLineWidth, rt
.top + fLineWidth)
);
409 float fHalfWidth = fThickness / 2.0f;
425 float fHalfWidth = fThickness / 2.0f;
441 float fHalfWidth = fThickness / 2.0f;
453 float fHalfWidth = fThickness / 2.0f;
470 int32_t n = (nIndex & 1) ? nIndex - 1 : nIndex;
476 float offsetY = 0.0f;
477 float offsetX = 0.0f;
479 float halfAfter = 0.0f;
480 float halfBefore = 0.0f;
484 CXFA_Stroke* strokeBefore = strokes[(nIndex + 1 * 8 - 1) % 8];
493 CXFA_Stroke* strokeBefore = strokes[(nIndex + 8 - 2) % 8];
494 CXFA_Stroke* strokeAfter = strokes[(nIndex + 2) % 8];
495 if (!bRound && !bInverted) {
501 float offsetEX = 0.0f;
502 float offsetEY = 0.0f;
518 cp1 = rtWidget.TopLeft();
519 cp2 = rtWidget.TopRight();
521 cpStart.x = cp1.x - halfBefore;
522 cpStart.y = cp1.y + fRadius1;
523 offsetY = -halfAfter;
525 cpStart.x = cp1.x + fRadius1 - halfBefore;
527 offsetEX = halfAfter;
542 cp1 = rtWidget.TopRight();
543 cp2 = rtWidget.BottomRight();
545 cpStart.x = cp1.x - fRadius1;
546 cpStart.y = cp1.y - halfBefore;
550 cpStart.y = cp1.y + fRadius1 - halfBefore;
551 offsetEY = halfAfter;
566 cp1 = rtWidget.BottomRight();
567 cp2 = rtWidget.BottomLeft();
569 cpStart.x = cp1.x + halfBefore;
570 cpStart.y = cp1.y - fRadius1;
573 cpStart.x = cp1.x - fRadius1 + halfBefore;
575 offsetEX = -halfAfter;
582 sx = bInverted ?
FXSYS_PI * 3 / 2 : 0;
590 cp1 = rtWidget.BottomLeft();
591 cp2 = rtWidget.TopLeft();
593 cpStart.x = cp1.x + fRadius1;
594 cpStart.y = cp1.y + halfBefore;
595 offsetX = -halfAfter;
598 cpStart.y = cp1.y - fRadius1 + halfBefore;
599 offsetEY = -halfAfter;
618 cp2.y + fRadius2 * ny + offsetEY)
);
627 CFX_RectF rtRadius(cp1.x + offsetX * 2, cp1.y + offsetY * 2,
628 fRadius1 * 2 * vx - offsetX * 2,
629 fRadius1 * 2 * vy - offsetY * 2);
632 rtRadius
.Offset(-fRadius1 * vx
, -fRadius1 * vy
);
634 path
.ArcTo(rtRadius.TopLeft()
, rtRadius.Size()
, sx
, sy
);
638 cp.x = cp1.x + fRadius1 * vx;
639 cp.y = cp1.y + fRadius1 * vy;
645 cp1.y + fRadius1 * sy + offsetY)
);
CFGAS_GEColor(FX_ARGB argb)
void FillPath(const CFGAS_GEPath &path, CFX_FillRenderOptions::FillType fill_type, const CFX_Matrix &matrix)
void SetFillColor(const CFGAS_GEColor &color)
void MoveTo(const CFX_PointF &point)
void ArcTo(const CFX_PointF &pos, const CFX_SizeF &size, float startAngle, float sweepAngle)
void AddRectangle(float left, float top, float width, float height)
void LineTo(const CFX_PointF &point)
CFX_RectF(const CFX_RectF &other)=default
void Offset(float dx, float dy)
void Deflate(float x, float y)
std::tuple< XFA_AttributeValue, bool, float > Get3DStyle()
XFA_AttributeValue GetHand()
XFA_Element GetElementType() const
void GetFillPath(const std::vector< CXFA_Stroke * > &strokes, const CFX_RectF &rtWidget, CFGAS_GEPath *fillPath)
void StrokeLowered(CFGAS_GEGraphics *pGS, CFX_RectF rt, float fThickness, const CFX_Matrix &matrix)
CXFA_Rectangle(CXFA_Document *pDoc, XFA_PacketType ePacket, Mask< XFA_XDPPACKET > validPackets, XFA_ObjectType oType, XFA_Element eType, pdfium::span< const PropertyData > properties, pdfium::span< const AttributeData > attributes, CJX_Object *js_node)
~CXFA_Rectangle() override
void GetPath(const std::vector< CXFA_Stroke * > &strokes, CFX_RectF rtWidget, CFGAS_GEPath &path, int32_t nIndex, bool bStart, bool bCorner)
static CXFA_Rectangle * FromNode(CXFA_Node *pNode)
void Stroke(const std::vector< CXFA_Stroke * > &strokes, CFGAS_GEGraphics *pGS, CFX_RectF rtWidget, const CFX_Matrix &matrix)
void StrokeRaised(CFGAS_GEGraphics *pGS, CFX_RectF rt, float fThickness, const CFX_Matrix &matrix)
void Draw(const std::vector< CXFA_Stroke * > &strokes, CFGAS_GEGraphics *pGS, CFX_RectF rtWidget, const CFX_Matrix &matrix)
void StrokeEtched(CFGAS_GEGraphics *pGS, CFX_RectF rt, float fThickness, const CFX_Matrix &matrix)
void StrokeEmbossed(CFGAS_GEGraphics *pGS, CFX_RectF rt, float fThickness, const CFX_Matrix &matrix)
CXFA_Rectangle(CXFA_Document *doc, XFA_PacketType packet)
void StrokeRect(CFGAS_GEGraphics *pGraphic, const CFX_RectF &rt, float fLineWidth, const CFX_Matrix &matrix, FX_ARGB argbTopLeft, FX_ARGB argbBottomRight)
XFA_AttributeValue GetJoinType()
void Stroke(CFGAS_GEGraphics *pGS, const CFGAS_GEPath &pPath, const CFX_Matrix &matrix)
bool SameStyles(CXFA_Stroke *stroke, Mask< SameStyleOption > dwFlags)
float GetThickness() const
CFX_PTemplate< float > CFX_PointF
#define NOTREACHED_NORETURN()