Home | History | Annotate | Download | only in reflow
      1 // Copyright 2014 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 CORE_SRC_REFLOW_AUTOREFLOW_H_
      8 #define CORE_SRC_REFLOW_AUTOREFLOW_H_
      9 
     10 #include "../../include/reflow/reflowengine.h"
     11 #include "reflowedpage.h"
     12 
     13 class CPDF_AutoReflowElement;
     14 class CPDF_AutoReflowLayoutProvider;
     15 typedef CFX_ArrayTemplate<CPDF_AutoReflowElement*> CAR_ElmPtrArray;
     16 typedef CFX_ArrayTemplate<CPDF_PageObject*> CAR_ObjPtrArray;
     17 class CRF_CELL
     18 {
     19 public:
     20     CRF_CELL() { };
     21     ~CRF_CELL() { };
     22     CFX_PtrList		m_ObjList;
     23     int			m_CellWritingMode;
     24     FX_RECT		m_BBox;
     25 };
     26 class CPDF_AutoReflowElement : public IPDF_LayoutElement
     27 {
     28 public:
     29     CPDF_AutoReflowElement(LayoutType layoutType = LayoutUnknown , CPDF_AutoReflowElement* pParent = NULL) ;
     30     ~CPDF_AutoReflowElement();
     31     LayoutType GetType()
     32     {
     33         return m_ElmType;
     34     }
     35     void	GetRect(CFX_FloatRect& rcRect) {};
     36 
     37     int  CountAttrValues(LayoutAttr attr_type);
     38     LayoutEnum  GetEnumAttr(LayoutAttr attr_type, int index);
     39     FX_FLOAT GetNumberAttr(LayoutAttr attr_type, int index);
     40     FX_COLORREF GetColorAttr(LayoutAttr attr_type, int index);
     41 
     42     int  CountChildren()
     43     {
     44         return m_ChildArray.GetSize();
     45     }
     46     IPDF_LayoutElement* GetChild(int index)
     47     {
     48         return m_ChildArray.GetAt(index);
     49     }
     50 
     51     IPDF_LayoutElement* GetParent()
     52     {
     53         return m_pParentElm;
     54     }
     55     int		CountObjects()
     56     {
     57         return m_ObjArray.GetSize();
     58     }
     59     CPDF_PageObject*	GetObject(int index)
     60     {
     61         return m_ObjArray.GetAt(index);
     62     }
     63     CPDF_AutoReflowElement* m_pParentElm;
     64     LayoutType		m_ElmType;
     65     CAR_ElmPtrArray m_ChildArray;
     66     CAR_ObjPtrArray m_ObjArray;
     67     FX_FLOAT		m_SpaceBefore;
     68 };
     69 #define AUTOREFLOW_STEP_GENERATELINE		1
     70 #define AUTOREFLOW_STEP_GENERATEParagraph	2
     71 #define AUTOREFLOW_STEP_CREATEELEMENT		3
     72 #define AUTOREFLOW_STEP_REMOVEDATA			4
     73 class CPDF_AutoReflowLayoutProvider : public IPDF_LayoutProvider
     74 {
     75 public:
     76     CPDF_AutoReflowLayoutProvider(CPDF_PageObjects* pPage, FX_BOOL bReadOrder);
     77     ~CPDF_AutoReflowLayoutProvider();
     78     void	SetLayoutProviderStyle(LAYOUTPROVIDER_STYLE Style)
     79     {
     80         m_Style = Style;
     81     }
     82     LayoutStatus StartLoad(IFX_Pause* pPause = NULL);
     83     LayoutStatus Continue();
     84     int	 		GetPosition();
     85     IPDF_LayoutElement* GetRoot()
     86     {
     87         return m_pRoot;
     88     }
     89     FX_FLOAT GetObjMinCell(CPDF_PageObject* pObj);
     90     void Conver2AppreceOrder(const CPDF_PageObjects* pStreamOrderObjs, CPDF_PageObjects* pAppraceOrderObjs);
     91     void	ReleaseElm(CPDF_AutoReflowElement*& pElm, FX_BOOL bReleaseChildren = TRUE);
     92     void GenerateCell();
     93     void GenerateStructTree();
     94     void GenerateLine(CFX_PtrArray& cellArray);
     95     void GenerateParagraph(CFX_PtrArray& cellArray);
     96     void CreateElement();
     97     void AddObjectArray(CPDF_AutoReflowElement* pElm, CFX_PtrList& ObjList);
     98     FX_FLOAT GetLayoutOrderHeight(CPDF_PageObject* pCurObj);
     99     FX_FLOAT GetLayoutOrderWidth(CPDF_PageObject* pCurObj);
    100     int GetWritingMode(CPDF_PageObject* pPreObj, CPDF_PageObject* pCurObj);
    101     int GetRectStart(FX_RECT rect);
    102     int GetRectEnd(FX_RECT rect);
    103     int GetRectTop(FX_RECT rect);
    104     int GetRectBottom(FX_RECT rect);
    105     int GetRectHeight(FX_RECT rect);
    106     int GetRectWidth(FX_RECT rect);
    107     void ProcessObj(CFX_PtrArray& cellArray, CPDF_PageObject* pObj, CFX_AffineMatrix matrix);
    108     FX_INT32 LogicPreObj(CPDF_PageObject* pObj);
    109 
    110     CPDF_AutoReflowElement* m_pRoot;
    111     CPDF_AutoReflowElement* m_pCurrElm;
    112     CPDF_Page*	m_pPDFPage;
    113     IFX_Pause*	m_pPause;
    114     CFX_AffineMatrix m_PDFDisplayMatrix;
    115     CPDF_PageObject* m_pPreObj;
    116     LayoutStatus m_Status;
    117     int m_WritingMode;
    118     CFX_PtrArray m_CellArray;
    119     FX_BOOL		 m_bReadOrder;
    120     LAYOUTPROVIDER_STYLE m_Style;
    121     CFX_PtrArray m_cellArray;
    122     int			m_Step;
    123 };
    124 
    125 #endif  // CORE_SRC_REFLOW_AUTOREFLOW_H_
    126