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_FDE_CFDE_TXTEDTPAGE_H_ 8 #define XFA_FDE_CFDE_TXTEDTPAGE_H_ 9 10 #include <deque> 11 #include <memory> 12 #include <vector> 13 14 #include "xfa/fde/ifde_txtedtpage.h" 15 #include "xfa/fde/ifx_chariter.h" 16 17 class CFDE_TxtEdtEngine; 18 class CFDE_TxtEdtParag; 19 class CFDE_TxtEdtTextSet; 20 21 class CFDE_TxtEdtPage : public IFDE_TxtEdtPage { 22 public: 23 CFDE_TxtEdtPage(CFDE_TxtEdtEngine* pEngine, int32_t nLineIndex); 24 ~CFDE_TxtEdtPage() override; 25 26 // IFDE_TxtEditPage: 27 CFDE_TxtEdtEngine* GetEngine() const override; 28 int32_t GetCharRect(int32_t nIndex, 29 CFX_RectF& rect, 30 bool bBBox = false) const override; 31 int32_t GetCharIndex(const CFX_PointF& fPoint, bool& bBefore) override; 32 void CalcRangeRectArray(int32_t nStart, 33 int32_t nCount, 34 std::vector<CFX_RectF>* RectFArr) const override; 35 int32_t SelectWord(const CFX_PointF& fPoint, int32_t& nCount) override; 36 int32_t GetCharStart() const override; 37 int32_t GetCharCount() const override; 38 int32_t GetDisplayPos(const CFX_RectF& rtClip, 39 FXTEXT_CHARPOS*& pCharPos, 40 CFX_RectF* pBBox) const override; 41 bool IsLoaded(const CFX_RectF* pClipBox) override; 42 int32_t LoadPage(const CFX_RectF* pClipBox, IFX_Pause* pPause) override; 43 void UnloadPage(const CFX_RectF* pClipBox) override; 44 const CFX_RectF& GetContentsBox() override; 45 46 // IFDE_VisualSet: 47 FDE_VISUALOBJTYPE GetType() override; 48 CFX_RectF GetRect(const FDE_TEXTEDITPIECE& pPiece) override; 49 50 // IFDE_CanvasSet: 51 FX_POSITION GetFirstPosition() override; 52 FDE_TEXTEDITPIECE* GetNext(FX_POSITION& pos, 53 IFDE_VisualSet*& pVisualSet) override; 54 55 // IFX_TxtAccess: 56 FX_WCHAR GetChar(const FDE_TEXTEDITPIECE* pIdentity, 57 int32_t index) const override; 58 int32_t GetWidth(const FDE_TEXTEDITPIECE* pIdentity, 59 int32_t index) const override; 60 61 private: 62 void NormalizePt2Rect(CFX_PointF& ptF, 63 const CFX_RectF& rtF, 64 FX_FLOAT fTolerance) const; 65 66 std::unique_ptr<IFX_CharIter> m_pIter; 67 std::unique_ptr<CFDE_TxtEdtTextSet> m_pTextSet; 68 CFDE_TxtEdtEngine* const m_pEditEngine; 69 std::deque<FDE_TEXTEDITPIECE> m_Pieces; 70 CFDE_TxtEdtParag* m_pBgnParag; 71 CFDE_TxtEdtParag* m_pEndParag; 72 int32_t m_nRefCount; 73 int32_t m_nPageStart; 74 int32_t m_nCharCount; 75 int32_t m_nPageIndex; 76 bool m_bLoaded; 77 CFX_RectF m_rtPage; 78 CFX_RectF m_rtPageMargin; 79 CFX_RectF m_rtPageContents; 80 CFX_RectF m_rtPageCanvas; 81 std::vector<int32_t> m_CharWidths; 82 }; 83 84 #endif // XFA_FDE_CFDE_TXTEDTPAGE_H_ 85