Home | History | Annotate | Download | only in parser
      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_PARSER_CXFA_LAYOUTPROCESSOR_H_
      8 #define XFA_FXFA_PARSER_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 
     16 class CXFA_ContainerLayoutItem;
     17 class CXFA_Document;
     18 class CXFA_ItemLayoutProcessor;
     19 class CXFA_LayoutItem;
     20 class CXFA_LayoutPageMgr;
     21 class CXFA_Node;
     22 
     23 class CXFA_LayoutProcessor {
     24  public:
     25   explicit CXFA_LayoutProcessor(CXFA_Document* pDocument);
     26   ~CXFA_LayoutProcessor();
     27 
     28   CXFA_Document* GetDocument() const;
     29   int32_t StartLayout(bool bForceRestart = false);
     30   int32_t DoLayout();
     31   bool IncrementLayout();
     32   int32_t CountPages() const;
     33   CXFA_ContainerLayoutItem* GetPage(int32_t index) const;
     34   CXFA_LayoutItem* GetLayoutItem(CXFA_Node* pFormItem);
     35   void AddChangedContainer(CXFA_Node* pContainer);
     36   void SetForceReLayout(bool bForceRestart) { m_bNeedLayout = bForceRestart; }
     37   CXFA_ContainerLayoutItem* GetRootLayoutItem() const;
     38   CXFA_ItemLayoutProcessor* GetRootRootItemLayoutProcessor() const {
     39     return m_pRootItemLayoutProcessor.get();
     40   }
     41   CXFA_LayoutPageMgr* GetLayoutPageMgr() const {
     42     return m_pLayoutPageMgr.get();
     43   }
     44 
     45  private:
     46   bool IsNeedLayout();
     47 
     48   UnownedPtr<CXFA_Document> const m_pDocument;
     49   std::unique_ptr<CXFA_ItemLayoutProcessor> m_pRootItemLayoutProcessor;
     50   std::unique_ptr<CXFA_LayoutPageMgr> m_pLayoutPageMgr;
     51   std::vector<CXFA_Node*> m_rgChangedContainers;
     52   uint32_t m_nProgressCounter;
     53   bool m_bNeedLayout;
     54 };
     55 
     56 #endif  // XFA_FXFA_PARSER_CXFA_LAYOUTPROCESSOR_H_
     57