1 // Copyright 2016 The PDFium Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 6 7 #ifndef XFA_FXFA_PARSER_CXFA_BOX_H_ 8 #define XFA_FXFA_PARSER_CXFA_BOX_H_ 9 10 #include <tuple> 11 #include <vector> 12 13 #include "core/fxcrt/fx_coordinates.h" 14 #include "xfa/fgas/graphics/cfgas_gepath.h" 15 #include "xfa/fxfa/parser/cxfa_node.h" 16 17 class CFGAS_GEGraphics; 18 class CXFA_Edge; 19 class CXFA_Fill; 20 class CXFA_Stroke; 21 22 class CXFA_Box : public CXFA_Node { 23 public: 24 CONSTRUCT_VIA_MAKE_GARBAGE_COLLECTED; 25 ~CXFA_Box() override; 26 27 XFA_AttributeValue GetPresence(); 28 std::tuple<XFA_AttributeValue, bool, float> Get3DStyle(); 29 30 size_t CountEdges(); 31 CXFA_Edge* GetEdgeIfExists(size_t nIndex); 32 CXFA_Fill* GetOrCreateFillIfPossible(); 33 34 std::vector<CXFA_Stroke*> GetStrokes(); 35 36 void Draw(CFGAS_GEGraphics* pGS, 37 const CFX_RectF& rtWidget, 38 const CFX_Matrix& matrix, 39 bool forceRound); 40 41 protected: 42 CXFA_Box(CXFA_Document* pDoc, 43 XFA_PacketType ePacket, 44 Mask<XFA_XDPPACKET> validPackets, 45 XFA_ObjectType oType, 46 XFA_Element eType, 47 pdfium::span<const PropertyData> properties, 48 pdfium::span<const AttributeData> attributes, 49 CJX_Object* js_node); 50 51 XFA_AttributeValue GetHand(); 52 53 private: 54 bool IsCircular(); 55 absl::optional<int32_t> GetStartAngle(); 56 absl::optional<int32_t> GetSweepAngle(); 57 58 std::vector<CXFA_Stroke*> GetStrokesInternal(bool bNull); 59 void DrawFill(const std::vector<CXFA_Stroke*>& strokes, 60 CFGAS_GEGraphics* pGS, 61 CFX_RectF rtWidget, 62 const CFX_Matrix& matrix, 63 bool forceRound); 64 void StrokeArcOrRounded(CFGAS_GEGraphics* pGS, 65 CFX_RectF rtWidget, 66 const CFX_Matrix& matrix, 67 bool forceRound); 68 void GetPathArcOrRounded(CFX_RectF rtDraw, 69 bool forceRound, 70 CFGAS_GEPath* fillPath); 71 }; 72 73 #endif // XFA_FXFA_PARSER_CXFA_BOX_H_ 74