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