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 CORE_FPDFAPI_PAGE_CPDF_ALLSTATES_H_ 8 #define CORE_FPDFAPI_PAGE_CPDF_ALLSTATES_H_ 9 10 #include "core/fpdfapi/page/cpdf_graphicstates.h" 11 #include "core/fxcrt/fx_coordinates.h" 12 13 class CPDF_Array; 14 class CPDF_Dictionary; 15 class CPDF_StreamContentParser; 16 17 class CPDF_AllStates { 18 public: 19 CPDF_AllStates(); 20 CPDF_AllStates(const CPDF_AllStates& that); 21 CPDF_AllStates& operator=(const CPDF_AllStates& that); 22 ~CPDF_AllStates(); 23 24 void SetDefaultStates(); 25 26 void ProcessExtGS(const CPDF_Dictionary* pGS, 27 CPDF_StreamContentParser* pParser); 28 void SetLineDash(const CPDF_Array* pArray, float phase); 29 30 CFX_PointF GetTransformedTextPosition() const; 31 void ResetTextPosition(); 32 void MoveTextPoint(const CFX_PointF& point); 33 void MoveTextToNextLine(); 34 void IncrementTextPositionX(float value); 35 void IncrementTextPositionY(float value); 36 text_matrix()37 const CFX_Matrix& text_matrix() const { return m_TextMatrix; } set_text_matrix(const CFX_Matrix & matrix)38 void set_text_matrix(const CFX_Matrix& matrix) { m_TextMatrix = matrix; } 39 current_transformation_matrix()40 const CFX_Matrix& current_transformation_matrix() const { return m_CTM; } set_current_transformation_matrix(const CFX_Matrix & matrix)41 void set_current_transformation_matrix(const CFX_Matrix& matrix) { 42 m_CTM = matrix; 43 } prepend_to_current_transformation_matrix(const CFX_Matrix & matrix)44 void prepend_to_current_transformation_matrix(const CFX_Matrix& matrix) { 45 m_CTM = matrix * m_CTM; 46 } 47 parent_matrix()48 const CFX_Matrix& parent_matrix() const { return m_ParentMatrix; } set_parent_matrix(const CFX_Matrix & matrix)49 void set_parent_matrix(const CFX_Matrix& matrix) { m_ParentMatrix = matrix; } 50 set_text_leading(float value)51 void set_text_leading(float value) { m_TextLeading = value; } 52 set_text_rise(float value)53 void set_text_rise(float value) { m_TextRise = value; } 54 text_horz_scale()55 float text_horz_scale() const { return m_TextHorzScale; } set_text_horz_scale(float value)56 void set_text_horz_scale(float value) { m_TextHorzScale = value; } 57 clip_path()58 const CPDF_ClipPath& clip_path() const { return m_GraphicStates.clip_path(); } mutable_clip_path()59 CPDF_ClipPath& mutable_clip_path() { 60 return m_GraphicStates.mutable_clip_path(); 61 } 62 graph_state()63 const CFX_GraphState& graph_state() const { 64 return m_GraphicStates.graph_state(); 65 } mutable_graph_state()66 CFX_GraphState& mutable_graph_state() { 67 return m_GraphicStates.mutable_graph_state(); 68 } 69 color_state()70 const CPDF_ColorState& color_state() const { 71 return m_GraphicStates.color_state(); 72 } mutable_color_state()73 CPDF_ColorState& mutable_color_state() { 74 return m_GraphicStates.mutable_color_state(); 75 } 76 text_state()77 const CPDF_TextState& text_state() const { 78 return m_GraphicStates.text_state(); 79 } mutable_text_state()80 CPDF_TextState& mutable_text_state() { 81 return m_GraphicStates.mutable_text_state(); 82 } 83 general_state()84 const CPDF_GeneralState& general_state() const { 85 return m_GraphicStates.general_state(); 86 } mutable_general_state()87 CPDF_GeneralState& mutable_general_state() { 88 return m_GraphicStates.mutable_general_state(); 89 } 90 graphic_states()91 const CPDF_GraphicStates& graphic_states() const { return m_GraphicStates; } 92 93 private: 94 CPDF_GraphicStates m_GraphicStates; 95 CFX_Matrix m_TextMatrix; 96 CFX_Matrix m_CTM; 97 CFX_Matrix m_ParentMatrix; 98 CFX_PointF m_TextPos; 99 CFX_PointF m_TextLinePos; 100 float m_TextLeading = 0.0f; 101 float m_TextRise = 0.0f; 102 float m_TextHorzScale = 1.0f; 103 }; 104 105 #endif // CORE_FPDFAPI_PAGE_CPDF_ALLSTATES_H_ 106