| OLD | NEW |
| (Empty) |
| 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 XFA_SRC_FXFA_PARSER_XFA_LAYOUT_ITEMLAYOUT_H_ | |
| 8 #define XFA_SRC_FXFA_PARSER_XFA_LAYOUT_ITEMLAYOUT_H_ | |
| 9 | |
| 10 #include <float.h> | |
| 11 | |
| 12 #include <list> | |
| 13 | |
| 14 #include "core/include/fxcrt/fx_basic.h" | |
| 15 #include "xfa/src/fxfa/parser/xfa_doclayout.h" | |
| 16 #include "xfa/src/fxfa/parser/xfa_document_layout_imp.h" | |
| 17 | |
| 18 #define XFA_LAYOUT_INVALIDNODE ((CXFA_Node*)(intptr_t)-1) | |
| 19 #define XFA_LAYOUT_FLOAT_PERCISION (0.0005f) | |
| 20 #define XFA_LAYOUT_FLOAT_MAX FLT_MAX | |
| 21 | |
| 22 class CXFA_ContainerLayoutItem; | |
| 23 class CXFA_ContentLayoutItem; | |
| 24 class CXFA_ItemLayoutProcessor; | |
| 25 class CXFA_LayoutPageMgr; | |
| 26 class CXFA_Node; | |
| 27 | |
| 28 enum XFA_ItemLayoutProcessorResult { | |
| 29 XFA_ItemLayoutProcessorResult_Done, | |
| 30 XFA_ItemLayoutProcessorResult_PageFullBreak, | |
| 31 XFA_ItemLayoutProcessorResult_RowFullBreak, | |
| 32 XFA_ItemLayoutProcessorResult_ManualBreak, | |
| 33 }; | |
| 34 | |
| 35 enum XFA_ItemLayoutProcessorStages { | |
| 36 XFA_ItemLayoutProcessorStages_None, | |
| 37 XFA_ItemLayoutProcessorStages_BookendLeader, | |
| 38 XFA_ItemLayoutProcessorStages_BreakBefore, | |
| 39 XFA_ItemLayoutProcessorStages_Keep, | |
| 40 XFA_ItemLayoutProcessorStages_Container, | |
| 41 XFA_ItemLayoutProcessorStages_BreakAfter, | |
| 42 XFA_ItemLayoutProcessorStages_BookendTrailer, | |
| 43 XFA_ItemLayoutProcessorStages_Done, | |
| 44 }; | |
| 45 | |
| 46 class CXFA_LayoutContext { | |
| 47 public: | |
| 48 CXFA_LayoutContext() | |
| 49 : m_prgSpecifiedColumnWidths(NULL), | |
| 50 m_fCurColumnWidth(0), | |
| 51 m_bCurColumnWidthAvaiable(FALSE), | |
| 52 m_pOverflowProcessor(NULL), | |
| 53 m_pOverflowNode(NULL) {} | |
| 54 ~CXFA_LayoutContext() { m_pOverflowProcessor = NULL; } | |
| 55 CFX_ArrayTemplate<FX_FLOAT>* m_prgSpecifiedColumnWidths; | |
| 56 FX_FLOAT m_fCurColumnWidth; | |
| 57 FX_BOOL m_bCurColumnWidthAvaiable; | |
| 58 CXFA_ItemLayoutProcessor* m_pOverflowProcessor; | |
| 59 CXFA_Node* m_pOverflowNode; | |
| 60 }; | |
| 61 | |
| 62 class CXFA_ItemLayoutProcessor { | |
| 63 public: | |
| 64 CXFA_ItemLayoutProcessor(CXFA_Node* pNode, CXFA_LayoutPageMgr* pPageMgr); | |
| 65 | |
| 66 XFA_ItemLayoutProcessorResult DoLayout( | |
| 67 FX_BOOL bUseBreakControl, | |
| 68 FX_FLOAT fHeightLimit, | |
| 69 FX_FLOAT fRealHeight = XFA_LAYOUT_FLOAT_MAX, | |
| 70 CXFA_LayoutContext* pContext = NULL); | |
| 71 | |
| 72 void GetCurrentComponentPos(FX_FLOAT& fAbsoluteX, FX_FLOAT& fAbsoluteY); | |
| 73 | |
| 74 void GetCurrentComponentSize(FX_FLOAT& fWidth, FX_FLOAT& fHeight); | |
| 75 | |
| 76 void SetCurrentComponentPos(FX_FLOAT fAbsoluteX, FX_FLOAT fAbsoluteY); | |
| 77 | |
| 78 void SetCurrentComponentSize(FX_FLOAT fWidth, FX_FLOAT fHeight); | |
| 79 inline CXFA_Node* GetFormNode() { return m_pFormNode; } | |
| 80 inline FX_BOOL HasLayoutItem() { return m_pLayoutItem != NULL; } | |
| 81 CXFA_ContentLayoutItem* ExtractLayoutItem(); | |
| 82 | |
| 83 static FX_BOOL IncrementRelayoutNode(CXFA_LayoutProcessor* pLayoutProcessor, | |
| 84 CXFA_Node* pNode, | |
| 85 CXFA_Node* pParentNode); | |
| 86 static void CalculatePositionedContainerPos(CXFA_Node* pNode, | |
| 87 FX_FLOAT fWidth, | |
| 88 FX_FLOAT fHeight, | |
| 89 FX_FLOAT& fAbsoluteX, | |
| 90 FX_FLOAT& fAbsoluteY); | |
| 91 static FX_BOOL FindLayoutItemSplitPos(CXFA_ContentLayoutItem* pLayoutItem, | |
| 92 FX_FLOAT fCurVerticalOffset, | |
| 93 FX_FLOAT& fProposedSplitPos, | |
| 94 FX_BOOL& bAppChange, | |
| 95 FX_BOOL bCalculateMargin = TRUE); | |
| 96 FX_FLOAT FindSplitPos(FX_FLOAT fProposedSplitPos); | |
| 97 void SplitLayoutItem(CXFA_ContentLayoutItem* pLayoutItem, | |
| 98 CXFA_ContentLayoutItem* pSecondParent, | |
| 99 FX_FLOAT fSplitPos); | |
| 100 void SplitLayoutItem(FX_FLOAT fSplitPos); | |
| 101 FX_BOOL JudgePutNextPage( | |
| 102 CXFA_ContentLayoutItem* pParentLayoutItem, | |
| 103 FX_FLOAT fChildHeight, | |
| 104 CFX_ArrayTemplate<CXFA_ContentLayoutItem*>& pKeepItems); | |
| 105 FX_BOOL ProcessKeepForSplite( | |
| 106 CXFA_ItemLayoutProcessor* pParentProcessor, | |
| 107 CXFA_ItemLayoutProcessor* pChildProcessor, | |
| 108 XFA_ItemLayoutProcessorResult eRetValue, | |
| 109 CFX_ArrayTemplate<CXFA_ContentLayoutItem*>& rgCurLineLayoutItem, | |
| 110 FX_FLOAT& fContentCurRowAvailWidth, | |
| 111 FX_FLOAT& fContentCurRowHeight, | |
| 112 FX_FLOAT& fContentCurRowY, | |
| 113 FX_BOOL& bAddedItemInRow, | |
| 114 FX_BOOL& bForceEndPage, | |
| 115 XFA_ItemLayoutProcessorResult& result); | |
| 116 FX_FLOAT InsertKeepLayoutItems(); | |
| 117 void DoLayoutPageArea(CXFA_ContainerLayoutItem* pPageAreaLayoutItem); | |
| 118 FX_BOOL CalculateRowChildPosition( | |
| 119 CFX_ArrayTemplate<CXFA_ContentLayoutItem*>(&rgCurLineLayoutItems)[3], | |
| 120 XFA_ATTRIBUTEENUM eFlowStrategy, | |
| 121 FX_BOOL bContainerHeightAutoSize, | |
| 122 FX_BOOL bContainerWidthAutoSize, | |
| 123 FX_FLOAT& fContentCalculatedWidth, | |
| 124 FX_FLOAT& fContentCalculatedHeight, | |
| 125 FX_FLOAT& fContentCurRowY, | |
| 126 FX_FLOAT fContentCurRowHeight, | |
| 127 FX_FLOAT fContentWidthLimit, | |
| 128 FX_BOOL bRootForceTb = FALSE); | |
| 129 | |
| 130 void ProcessUnUseOverFlow(CXFA_Node* pLeaderNode, | |
| 131 CXFA_Node* pTrailerNode, | |
| 132 CXFA_ContentLayoutItem* pTrailerItem, | |
| 133 CXFA_Node* pFormNode); | |
| 134 void ProcessUnUseBinds(CXFA_Node* pFormNode); | |
| 135 FX_BOOL IsAddNewRowForTrailer(CXFA_ContentLayoutItem* pTrailerItem); | |
| 136 FX_BOOL JudgeLeaderOrTrailerForOccur(CXFA_Node* pFormNode); | |
| 137 CXFA_ContentLayoutItem* CreateContentLayoutItem(CXFA_Node* pFormNode); | |
| 138 | |
| 139 protected: | |
| 140 void DoLayoutPositionedContainer(CXFA_LayoutContext* pContext = NULL); | |
| 141 void DoLayoutTableContainer(CXFA_Node* pLayoutNode); | |
| 142 XFA_ItemLayoutProcessorResult DoLayoutFlowedContainer( | |
| 143 FX_BOOL bUseBreakControl, | |
| 144 XFA_ATTRIBUTEENUM eFlowStrategy, | |
| 145 FX_FLOAT fHeightLimit, | |
| 146 FX_FLOAT fRealHeight, | |
| 147 CXFA_LayoutContext* pContext = NULL, | |
| 148 FX_BOOL bRootForceTb = FALSE); | |
| 149 void DoLayoutField(); | |
| 150 void XFA_ItemLayoutProcessor_GotoNextContainerNode( | |
| 151 CXFA_Node*& pCurActionNode, | |
| 152 XFA_ItemLayoutProcessorStages& nCurStage, | |
| 153 CXFA_Node* pParentContainer, | |
| 154 FX_BOOL bUsePageBreak); | |
| 155 | |
| 156 FX_BOOL ProcessKeepNodesForCheckNext(CXFA_Node*& pCurActionNode, | |
| 157 XFA_ItemLayoutProcessorStages& nCurStage, | |
| 158 CXFA_Node*& pNextContainer, | |
| 159 FX_BOOL& bLastKeepNode); | |
| 160 | |
| 161 FX_BOOL ProcessKeepNodesForBreakBefore( | |
| 162 CXFA_Node*& pCurActionNode, | |
| 163 XFA_ItemLayoutProcessorStages& nCurStage, | |
| 164 CXFA_Node* pContainerNode); | |
| 165 | |
| 166 CXFA_Node* GetSubformSetParent(CXFA_Node* pSubformSet); | |
| 167 | |
| 168 public: | |
| 169 FX_BOOL m_bKeepBreakFinish; | |
| 170 FX_BOOL m_bIsProcessKeep; | |
| 171 CXFA_Node* m_pKeepHeadNode; | |
| 172 CXFA_Node* m_pKeepTailNode; | |
| 173 CXFA_Node* m_pFormNode; | |
| 174 CXFA_ContentLayoutItem* m_pLayoutItem; | |
| 175 CXFA_ContentLayoutItem* m_pOldLayoutItem; | |
| 176 CXFA_Node* m_pCurChildNode; | |
| 177 CXFA_ItemLayoutProcessor* m_pCurChildPreprocessor; | |
| 178 XFA_ItemLayoutProcessorStages m_nCurChildNodeStage; | |
| 179 FX_FLOAT m_fUsedSize; | |
| 180 CXFA_LayoutPageMgr* m_pPageMgr; | |
| 181 std::list<CXFA_Node*> m_PendingNodes; | |
| 182 FX_BOOL m_bBreakPending; | |
| 183 CFX_ArrayTemplate<FX_FLOAT> m_rgSpecifiedColumnWidths; | |
| 184 CFX_ArrayTemplate<CXFA_ContentLayoutItem*> m_arrayKeepItems; | |
| 185 CFX_MapPtrToPtr m_PendingNodesCount; | |
| 186 FX_FLOAT m_fLastRowWidth; | |
| 187 FX_FLOAT m_fLastRowY; | |
| 188 FX_FLOAT m_fWidthLimite; | |
| 189 FX_BOOL m_bUseInheriated; | |
| 190 XFA_ItemLayoutProcessorResult m_ePreProcessRs; | |
| 191 FX_BOOL m_bHasAvailHeight; | |
| 192 }; | |
| 193 FX_BOOL XFA_ItemLayoutProcessor_IsTakingSpace(CXFA_Node* pNode); | |
| 194 | |
| 195 #endif // XFA_SRC_FXFA_PARSER_XFA_LAYOUT_ITEMLAYOUT_H_ | |
| OLD | NEW |