Home | History | Annotate | Download | only in parser
      1 // Copyright 2016 PDFium Authors. All rights reserved.
      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 <memory>
     11 #include <tuple>
     12 #include <vector>
     13 
     14 #include "core/fxcrt/fx_coordinates.h"
     15 #include "xfa/fxfa/parser/cxfa_node.h"
     16 #include "xfa/fxgraphics/cxfa_gepath.h"
     17 
     18 class CXFA_Edge;
     19 class CXFA_Fill;
     20 class CXFA_Graphics;
     21 class CXFA_Margin;
     22 class CXFA_Stroke;
     23 
     24 class CXFA_Box : public CXFA_Node {
     25  public:
     26   ~CXFA_Box() override;
     27 
     28   XFA_AttributeEnum GetPresence();
     29   std::tuple<XFA_AttributeEnum, bool, float> Get3DStyle();
     30 
     31   int32_t CountEdges();
     32   CXFA_Edge* GetEdgeIfExists(int32_t nIndex);
     33   CXFA_Fill* GetOrCreateFillIfPossible();
     34 
     35   std::vector<CXFA_Stroke*> GetStrokes();
     36 
     37   void Draw(CXFA_Graphics* pGS,
     38             const CFX_RectF& rtWidget,
     39             const CFX_Matrix& matrix,
     40             bool forceRound);
     41 
     42  protected:
     43   CXFA_Box(CXFA_Document* pDoc,
     44            XFA_PacketType ePacket,
     45            uint32_t validPackets,
     46            XFA_ObjectType oType,
     47            XFA_Element eType,
     48            const PropertyData* properties,
     49            const AttributeData* attributes,
     50            const WideStringView& elementName,
     51            std::unique_ptr<CJX_Object> js_node);
     52 
     53   XFA_AttributeEnum GetHand();
     54 
     55  private:
     56   bool IsCircular();
     57   Optional<int32_t> GetStartAngle();
     58   Optional<int32_t> GetSweepAngle();
     59 
     60   std::vector<CXFA_Stroke*> GetStrokesInternal(bool bNull);
     61   void DrawFill(const std::vector<CXFA_Stroke*>& strokes,
     62                 CXFA_Graphics* pGS,
     63                 CFX_RectF rtWidget,
     64                 const CFX_Matrix& matrix,
     65                 bool forceRound);
     66   void StrokeArcOrRounded(CXFA_Graphics* pGS,
     67                           CFX_RectF rtWidget,
     68                           const CFX_Matrix& matrix,
     69                           bool forceRound);
     70   void GetPathArcOrRounded(CFX_RectF rtDraw,
     71                            CXFA_GEPath& fillPath,
     72                            bool forceRound);
     73 };
     74 
     75 #endif  // XFA_FXFA_PARSER_CXFA_BOX_H_
     76