1 // Copyright 2016 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_FXFA_LAYOUT_CXFA_LAYOUTPROCESSOR_H_ 8 #define XFA_FXFA_LAYOUT_CXFA_LAYOUTPROCESSOR_H_ 9 10 #include <memory> 11 #include <vector> 12 13 #include "core/fxcrt/fx_system.h" 14 #include "core/fxcrt/unowned_ptr.h" 15 #include "xfa/fxfa/parser/cxfa_document.h" 16 17 class CXFA_ContentLayoutProcessor; 18 class CXFA_LayoutItem; 19 class CXFA_Node; 20 class CXFA_ViewLayoutItem; 21 class CXFA_ViewLayoutProcessor; 22 23 class CXFA_LayoutProcessor : public CXFA_Document::LayoutProcessorIface { 24 public: 25 static CXFA_LayoutProcessor* FromDocument(const CXFA_Document* pXFADoc); 26 27 CXFA_LayoutProcessor(); 28 ~CXFA_LayoutProcessor() override; 29 30 // CXFA_Document::LayoutProcessorIface: 31 void SetForceRelayout(bool bForceRestart) override; 32 void AddChangedContainer(CXFA_Node* pContainer) override; 33 34 int32_t StartLayout(bool bForceRestart); 35 int32_t DoLayout(); 36 bool IncrementLayout(); 37 int32_t CountPages() const; 38 CXFA_ViewLayoutItem* GetPage(int32_t index) const; 39 CXFA_LayoutItem* GetLayoutItem(CXFA_Node* pFormItem); GetRootContentLayoutProcessor()40 CXFA_ContentLayoutProcessor* GetRootContentLayoutProcessor() const { 41 return m_pContentLayoutProcessor.get(); 42 } GetLayoutPageMgr()43 CXFA_ViewLayoutProcessor* GetLayoutPageMgr() const { 44 return m_pViewLayoutProcessor.get(); 45 } 46 47 private: 48 bool NeedLayout() const; 49 50 std::unique_ptr<CXFA_ViewLayoutProcessor> m_pViewLayoutProcessor; 51 std::unique_ptr<CXFA_ContentLayoutProcessor> m_pContentLayoutProcessor; 52 std::vector<CXFA_Node*> m_rgChangedContainers; 53 uint32_t m_nProgressCounter = 0; 54 bool m_bNeedLayout = true; 55 }; 56 57 #endif // XFA_FXFA_LAYOUT_CXFA_LAYOUTPROCESSOR_H_ 58