| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #ifndef XFA_FXFA_PARSER_XFA_LAYOUT_ITEMLAYOUT_H_ | 7 #ifndef XFA_FXFA_PARSER_XFA_LAYOUT_ITEMLAYOUT_H_ |
| 8 #define XFA_FXFA_PARSER_XFA_LAYOUT_ITEMLAYOUT_H_ | 8 #define XFA_FXFA_PARSER_XFA_LAYOUT_ITEMLAYOUT_H_ |
| 9 | 9 |
| 10 #include <float.h> | 10 #include <float.h> |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 XFA_ItemLayoutProcessorStages_BreakAfter, | 42 XFA_ItemLayoutProcessorStages_BreakAfter, |
| 43 XFA_ItemLayoutProcessorStages_BookendTrailer, | 43 XFA_ItemLayoutProcessorStages_BookendTrailer, |
| 44 XFA_ItemLayoutProcessorStages_Done, | 44 XFA_ItemLayoutProcessorStages_Done, |
| 45 }; | 45 }; |
| 46 | 46 |
| 47 class CXFA_LayoutContext { | 47 class CXFA_LayoutContext { |
| 48 public: | 48 public: |
| 49 CXFA_LayoutContext() | 49 CXFA_LayoutContext() |
| 50 : m_prgSpecifiedColumnWidths(nullptr), | 50 : m_prgSpecifiedColumnWidths(nullptr), |
| 51 m_fCurColumnWidth(0), | 51 m_fCurColumnWidth(0), |
| 52 m_bCurColumnWidthAvaiable(FALSE), | 52 m_bCurColumnWidthAvaiable(false), |
| 53 m_pOverflowProcessor(nullptr), | 53 m_pOverflowProcessor(nullptr), |
| 54 m_pOverflowNode(nullptr) {} | 54 m_pOverflowNode(nullptr) {} |
| 55 ~CXFA_LayoutContext() { m_pOverflowProcessor = nullptr; } | 55 ~CXFA_LayoutContext() { m_pOverflowProcessor = nullptr; } |
| 56 CFX_ArrayTemplate<FX_FLOAT>* m_prgSpecifiedColumnWidths; | 56 CFX_ArrayTemplate<FX_FLOAT>* m_prgSpecifiedColumnWidths; |
| 57 FX_FLOAT m_fCurColumnWidth; | 57 FX_FLOAT m_fCurColumnWidth; |
| 58 FX_BOOL m_bCurColumnWidthAvaiable; | 58 bool m_bCurColumnWidthAvaiable; |
| 59 CXFA_ItemLayoutProcessor* m_pOverflowProcessor; | 59 CXFA_ItemLayoutProcessor* m_pOverflowProcessor; |
| 60 CXFA_Node* m_pOverflowNode; | 60 CXFA_Node* m_pOverflowNode; |
| 61 }; | 61 }; |
| 62 | 62 |
| 63 class CXFA_ItemLayoutProcessor { | 63 class CXFA_ItemLayoutProcessor { |
| 64 public: | 64 public: |
| 65 CXFA_ItemLayoutProcessor(CXFA_Node* pNode, CXFA_LayoutPageMgr* pPageMgr); | 65 CXFA_ItemLayoutProcessor(CXFA_Node* pNode, CXFA_LayoutPageMgr* pPageMgr); |
| 66 ~CXFA_ItemLayoutProcessor(); | 66 ~CXFA_ItemLayoutProcessor(); |
| 67 | 67 |
| 68 XFA_ItemLayoutProcessorResult DoLayout( | 68 XFA_ItemLayoutProcessorResult DoLayout( |
| 69 FX_BOOL bUseBreakControl, | 69 bool bUseBreakControl, |
| 70 FX_FLOAT fHeightLimit, | 70 FX_FLOAT fHeightLimit, |
| 71 FX_FLOAT fRealHeight = XFA_LAYOUT_FLOAT_MAX, | 71 FX_FLOAT fRealHeight = XFA_LAYOUT_FLOAT_MAX, |
| 72 CXFA_LayoutContext* pContext = nullptr); | 72 CXFA_LayoutContext* pContext = nullptr); |
| 73 | 73 |
| 74 void GetCurrentComponentPos(FX_FLOAT& fAbsoluteX, FX_FLOAT& fAbsoluteY); | 74 void GetCurrentComponentPos(FX_FLOAT& fAbsoluteX, FX_FLOAT& fAbsoluteY); |
| 75 | 75 |
| 76 void GetCurrentComponentSize(FX_FLOAT& fWidth, FX_FLOAT& fHeight); | 76 void GetCurrentComponentSize(FX_FLOAT& fWidth, FX_FLOAT& fHeight); |
| 77 | 77 |
| 78 void SetCurrentComponentPos(FX_FLOAT fAbsoluteX, FX_FLOAT fAbsoluteY); | 78 void SetCurrentComponentPos(FX_FLOAT fAbsoluteX, FX_FLOAT fAbsoluteY); |
| 79 | 79 |
| 80 void SetCurrentComponentSize(FX_FLOAT fWidth, FX_FLOAT fHeight); | 80 void SetCurrentComponentSize(FX_FLOAT fWidth, FX_FLOAT fHeight); |
| 81 CXFA_Node* GetFormNode() { return m_pFormNode; } | 81 CXFA_Node* GetFormNode() { return m_pFormNode; } |
| 82 FX_BOOL HasLayoutItem() { return !!m_pLayoutItem; } | 82 bool HasLayoutItem() { return !!m_pLayoutItem; } |
| 83 CXFA_ContentLayoutItem* ExtractLayoutItem(); | 83 CXFA_ContentLayoutItem* ExtractLayoutItem(); |
| 84 | 84 |
| 85 static FX_BOOL IncrementRelayoutNode(CXFA_LayoutProcessor* pLayoutProcessor, | 85 static bool IncrementRelayoutNode(CXFA_LayoutProcessor* pLayoutProcessor, |
| 86 CXFA_Node* pNode, | 86 CXFA_Node* pNode, |
| 87 CXFA_Node* pParentNode); | 87 CXFA_Node* pParentNode); |
| 88 static void CalculatePositionedContainerPos(CXFA_Node* pNode, | 88 static void CalculatePositionedContainerPos(CXFA_Node* pNode, |
| 89 FX_FLOAT fWidth, | 89 FX_FLOAT fWidth, |
| 90 FX_FLOAT fHeight, | 90 FX_FLOAT fHeight, |
| 91 FX_FLOAT& fAbsoluteX, | 91 FX_FLOAT& fAbsoluteX, |
| 92 FX_FLOAT& fAbsoluteY); | 92 FX_FLOAT& fAbsoluteY); |
| 93 static FX_BOOL FindLayoutItemSplitPos(CXFA_ContentLayoutItem* pLayoutItem, | 93 static bool FindLayoutItemSplitPos(CXFA_ContentLayoutItem* pLayoutItem, |
| 94 FX_FLOAT fCurVerticalOffset, | 94 FX_FLOAT fCurVerticalOffset, |
| 95 FX_FLOAT& fProposedSplitPos, | 95 FX_FLOAT& fProposedSplitPos, |
| 96 FX_BOOL& bAppChange, | 96 bool& bAppChange, |
| 97 FX_BOOL bCalculateMargin = TRUE); | 97 bool bCalculateMargin = true); |
| 98 FX_FLOAT FindSplitPos(FX_FLOAT fProposedSplitPos); | 98 FX_FLOAT FindSplitPos(FX_FLOAT fProposedSplitPos); |
| 99 void SplitLayoutItem(CXFA_ContentLayoutItem* pLayoutItem, | 99 void SplitLayoutItem(CXFA_ContentLayoutItem* pLayoutItem, |
| 100 CXFA_ContentLayoutItem* pSecondParent, | 100 CXFA_ContentLayoutItem* pSecondParent, |
| 101 FX_FLOAT fSplitPos); | 101 FX_FLOAT fSplitPos); |
| 102 void SplitLayoutItem(FX_FLOAT fSplitPos); | 102 void SplitLayoutItem(FX_FLOAT fSplitPos); |
| 103 FX_BOOL JudgePutNextPage( | 103 bool JudgePutNextPage(CXFA_ContentLayoutItem* pParentLayoutItem, |
| 104 CXFA_ContentLayoutItem* pParentLayoutItem, | 104 FX_FLOAT fChildHeight, |
| 105 FX_FLOAT fChildHeight, | 105 CFX_ArrayTemplate<CXFA_ContentLayoutItem*>& pKeepItems); |
| 106 CFX_ArrayTemplate<CXFA_ContentLayoutItem*>& pKeepItems); | 106 bool ProcessKeepForSplite( |
| 107 FX_BOOL ProcessKeepForSplite( | |
| 108 CXFA_ItemLayoutProcessor* pParentProcessor, | 107 CXFA_ItemLayoutProcessor* pParentProcessor, |
| 109 CXFA_ItemLayoutProcessor* pChildProcessor, | 108 CXFA_ItemLayoutProcessor* pChildProcessor, |
| 110 XFA_ItemLayoutProcessorResult eRetValue, | 109 XFA_ItemLayoutProcessorResult eRetValue, |
| 111 CFX_ArrayTemplate<CXFA_ContentLayoutItem*>& rgCurLineLayoutItem, | 110 CFX_ArrayTemplate<CXFA_ContentLayoutItem*>& rgCurLineLayoutItem, |
| 112 FX_FLOAT& fContentCurRowAvailWidth, | 111 FX_FLOAT& fContentCurRowAvailWidth, |
| 113 FX_FLOAT& fContentCurRowHeight, | 112 FX_FLOAT& fContentCurRowHeight, |
| 114 FX_FLOAT& fContentCurRowY, | 113 FX_FLOAT& fContentCurRowY, |
| 115 FX_BOOL& bAddedItemInRow, | 114 bool& bAddedItemInRow, |
| 116 FX_BOOL& bForceEndPage, | 115 bool& bForceEndPage, |
| 117 XFA_ItemLayoutProcessorResult& result); | 116 XFA_ItemLayoutProcessorResult& result); |
| 118 FX_FLOAT InsertKeepLayoutItems(); | 117 FX_FLOAT InsertKeepLayoutItems(); |
| 119 void DoLayoutPageArea(CXFA_ContainerLayoutItem* pPageAreaLayoutItem); | 118 void DoLayoutPageArea(CXFA_ContainerLayoutItem* pPageAreaLayoutItem); |
| 120 FX_BOOL CalculateRowChildPosition( | 119 bool CalculateRowChildPosition( |
| 121 CFX_ArrayTemplate<CXFA_ContentLayoutItem*>(&rgCurLineLayoutItems)[3], | 120 CFX_ArrayTemplate<CXFA_ContentLayoutItem*> (&rgCurLineLayoutItems)[3], |
| 122 XFA_ATTRIBUTEENUM eFlowStrategy, | 121 XFA_ATTRIBUTEENUM eFlowStrategy, |
| 123 FX_BOOL bContainerHeightAutoSize, | 122 bool bContainerHeightAutoSize, |
| 124 FX_BOOL bContainerWidthAutoSize, | 123 bool bContainerWidthAutoSize, |
| 125 FX_FLOAT& fContentCalculatedWidth, | 124 FX_FLOAT& fContentCalculatedWidth, |
| 126 FX_FLOAT& fContentCalculatedHeight, | 125 FX_FLOAT& fContentCalculatedHeight, |
| 127 FX_FLOAT& fContentCurRowY, | 126 FX_FLOAT& fContentCurRowY, |
| 128 FX_FLOAT fContentCurRowHeight, | 127 FX_FLOAT fContentCurRowHeight, |
| 129 FX_FLOAT fContentWidthLimit, | 128 FX_FLOAT fContentWidthLimit, |
| 130 FX_BOOL bRootForceTb = FALSE); | 129 bool bRootForceTb = false); |
| 131 | 130 |
| 132 void ProcessUnUseOverFlow(CXFA_Node* pLeaderNode, | 131 void ProcessUnUseOverFlow(CXFA_Node* pLeaderNode, |
| 133 CXFA_Node* pTrailerNode, | 132 CXFA_Node* pTrailerNode, |
| 134 CXFA_ContentLayoutItem* pTrailerItem, | 133 CXFA_ContentLayoutItem* pTrailerItem, |
| 135 CXFA_Node* pFormNode); | 134 CXFA_Node* pFormNode); |
| 136 void ProcessUnUseBinds(CXFA_Node* pFormNode); | 135 void ProcessUnUseBinds(CXFA_Node* pFormNode); |
| 137 FX_BOOL IsAddNewRowForTrailer(CXFA_ContentLayoutItem* pTrailerItem); | 136 bool IsAddNewRowForTrailer(CXFA_ContentLayoutItem* pTrailerItem); |
| 138 FX_BOOL JudgeLeaderOrTrailerForOccur(CXFA_Node* pFormNode); | 137 bool JudgeLeaderOrTrailerForOccur(CXFA_Node* pFormNode); |
| 139 CXFA_ContentLayoutItem* CreateContentLayoutItem(CXFA_Node* pFormNode); | 138 CXFA_ContentLayoutItem* CreateContentLayoutItem(CXFA_Node* pFormNode); |
| 140 | 139 |
| 141 protected: | 140 protected: |
| 142 void DoLayoutPositionedContainer(CXFA_LayoutContext* pContext = nullptr); | 141 void DoLayoutPositionedContainer(CXFA_LayoutContext* pContext = nullptr); |
| 143 void DoLayoutTableContainer(CXFA_Node* pLayoutNode); | 142 void DoLayoutTableContainer(CXFA_Node* pLayoutNode); |
| 144 XFA_ItemLayoutProcessorResult DoLayoutFlowedContainer( | 143 XFA_ItemLayoutProcessorResult DoLayoutFlowedContainer( |
| 145 FX_BOOL bUseBreakControl, | 144 bool bUseBreakControl, |
| 146 XFA_ATTRIBUTEENUM eFlowStrategy, | 145 XFA_ATTRIBUTEENUM eFlowStrategy, |
| 147 FX_FLOAT fHeightLimit, | 146 FX_FLOAT fHeightLimit, |
| 148 FX_FLOAT fRealHeight, | 147 FX_FLOAT fRealHeight, |
| 149 CXFA_LayoutContext* pContext = nullptr, | 148 CXFA_LayoutContext* pContext = nullptr, |
| 150 FX_BOOL bRootForceTb = FALSE); | 149 bool bRootForceTb = false); |
| 151 void DoLayoutField(); | 150 void DoLayoutField(); |
| 152 void XFA_ItemLayoutProcessor_GotoNextContainerNode( | 151 void XFA_ItemLayoutProcessor_GotoNextContainerNode( |
| 153 CXFA_Node*& pCurActionNode, | 152 CXFA_Node*& pCurActionNode, |
| 154 XFA_ItemLayoutProcessorStages& nCurStage, | 153 XFA_ItemLayoutProcessorStages& nCurStage, |
| 155 CXFA_Node* pParentContainer, | 154 CXFA_Node* pParentContainer, |
| 156 FX_BOOL bUsePageBreak); | 155 bool bUsePageBreak); |
| 157 | 156 |
| 158 FX_BOOL ProcessKeepNodesForCheckNext(CXFA_Node*& pCurActionNode, | 157 bool ProcessKeepNodesForCheckNext(CXFA_Node*& pCurActionNode, |
| 159 XFA_ItemLayoutProcessorStages& nCurStage, | 158 XFA_ItemLayoutProcessorStages& nCurStage, |
| 160 CXFA_Node*& pNextContainer, | 159 CXFA_Node*& pNextContainer, |
| 161 FX_BOOL& bLastKeepNode); | 160 bool& bLastKeepNode); |
| 162 | 161 |
| 163 FX_BOOL ProcessKeepNodesForBreakBefore( | 162 bool ProcessKeepNodesForBreakBefore(CXFA_Node*& pCurActionNode, |
| 164 CXFA_Node*& pCurActionNode, | 163 XFA_ItemLayoutProcessorStages& nCurStage, |
| 165 XFA_ItemLayoutProcessorStages& nCurStage, | 164 CXFA_Node* pContainerNode); |
| 166 CXFA_Node* pContainerNode); | |
| 167 | 165 |
| 168 CXFA_Node* GetSubformSetParent(CXFA_Node* pSubformSet); | 166 CXFA_Node* GetSubformSetParent(CXFA_Node* pSubformSet); |
| 169 | 167 |
| 170 public: | 168 public: |
| 171 FX_BOOL m_bKeepBreakFinish; | 169 bool m_bKeepBreakFinish; |
| 172 FX_BOOL m_bIsProcessKeep; | 170 bool m_bIsProcessKeep; |
| 173 CXFA_Node* m_pKeepHeadNode; | 171 CXFA_Node* m_pKeepHeadNode; |
| 174 CXFA_Node* m_pKeepTailNode; | 172 CXFA_Node* m_pKeepTailNode; |
| 175 CXFA_Node* m_pFormNode; | 173 CXFA_Node* m_pFormNode; |
| 176 CXFA_ContentLayoutItem* m_pLayoutItem; | 174 CXFA_ContentLayoutItem* m_pLayoutItem; |
| 177 CXFA_ContentLayoutItem* m_pOldLayoutItem; | 175 CXFA_ContentLayoutItem* m_pOldLayoutItem; |
| 178 CXFA_Node* m_pCurChildNode; | 176 CXFA_Node* m_pCurChildNode; |
| 179 CXFA_ItemLayoutProcessor* m_pCurChildPreprocessor; | 177 CXFA_ItemLayoutProcessor* m_pCurChildPreprocessor; |
| 180 XFA_ItemLayoutProcessorStages m_nCurChildNodeStage; | 178 XFA_ItemLayoutProcessorStages m_nCurChildNodeStage; |
| 181 FX_FLOAT m_fUsedSize; | 179 FX_FLOAT m_fUsedSize; |
| 182 CXFA_LayoutPageMgr* m_pPageMgr; | 180 CXFA_LayoutPageMgr* m_pPageMgr; |
| 183 std::list<CXFA_Node*> m_PendingNodes; | 181 std::list<CXFA_Node*> m_PendingNodes; |
| 184 FX_BOOL m_bBreakPending; | 182 bool m_bBreakPending; |
| 185 CFX_ArrayTemplate<FX_FLOAT> m_rgSpecifiedColumnWidths; | 183 CFX_ArrayTemplate<FX_FLOAT> m_rgSpecifiedColumnWidths; |
| 186 CFX_ArrayTemplate<CXFA_ContentLayoutItem*> m_arrayKeepItems; | 184 CFX_ArrayTemplate<CXFA_ContentLayoutItem*> m_arrayKeepItems; |
| 187 std::map<CXFA_Node*, int32_t> m_PendingNodesCount; | 185 std::map<CXFA_Node*, int32_t> m_PendingNodesCount; |
| 188 FX_FLOAT m_fLastRowWidth; | 186 FX_FLOAT m_fLastRowWidth; |
| 189 FX_FLOAT m_fLastRowY; | 187 FX_FLOAT m_fLastRowY; |
| 190 FX_FLOAT m_fWidthLimite; | 188 FX_FLOAT m_fWidthLimite; |
| 191 FX_BOOL m_bUseInheriated; | 189 bool m_bUseInheriated; |
| 192 XFA_ItemLayoutProcessorResult m_ePreProcessRs; | 190 XFA_ItemLayoutProcessorResult m_ePreProcessRs; |
| 193 FX_BOOL m_bHasAvailHeight; | 191 bool m_bHasAvailHeight; |
| 194 }; | 192 }; |
| 195 FX_BOOL XFA_ItemLayoutProcessor_IsTakingSpace(CXFA_Node* pNode); | 193 bool XFA_ItemLayoutProcessor_IsTakingSpace(CXFA_Node* pNode); |
| 196 | 194 |
| 197 #endif // XFA_FXFA_PARSER_XFA_LAYOUT_ITEMLAYOUT_H_ | 195 #endif // XFA_FXFA_PARSER_XFA_LAYOUT_ITEMLAYOUT_H_ |
| OLD | NEW |