summaryrefslogtreecommitdiff
path: root/xfa/fde/cfde_txtedtpage.h
blob: 8be940f556b996c95b6ae11a8b99eb997fd7eaab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
// Copyright 2014 PDFium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com

#ifndef XFA_FDE_CFDE_TXTEDTPAGE_H_
#define XFA_FDE_CFDE_TXTEDTPAGE_H_

#include "xfa/fde/ifde_txtedtpage.h"
#include "xfa/fde/ifx_chariter.h"

struct FDE_TEXTEDITPIECE {
  int32_t nStart;
  int32_t nCount;
  int32_t nBidiLevel;
  CFX_RectF rtPiece;
  uint32_t dwCharStyles;
};
typedef CFX_MassArrayTemplate<FDE_TEXTEDITPIECE> CFDE_TXTEDTPieceMassArray;

class CFDE_TxtEdtEngine;
class CFDE_TxtEdtParag;
class CFDE_TxtEdtTextSet;

class CFDE_TxtEdtPage : public IFDE_TxtEdtPage {
 public:
  CFDE_TxtEdtPage(CFDE_TxtEdtEngine* pEngine, int32_t nLineIndex);

  // IFDE_TxtEditPage:
  void Release() override;
  CFDE_TxtEdtEngine* GetEngine() const override;
  int32_t GetCharRect(int32_t nIndex,
                      CFX_RectF& rect,
                      FX_BOOL bBBox = FALSE) const override;
  int32_t GetCharIndex(const CFX_PointF& fPoint, FX_BOOL& bBefore) override;
  void CalcRangeRectArray(int32_t nStart,
                          int32_t nCount,
                          CFX_RectFArray& RectFArr) const override;
  int32_t SelectWord(const CFX_PointF& fPoint, int32_t& nCount) override;
  int32_t GetCharStart() const override;
  int32_t GetCharCount() const override;
  int32_t GetDisplayPos(const CFX_RectF& rtClip,
                        FXTEXT_CHARPOS*& pCharPos,
                        CFX_RectF* pBBox) const override;
  FX_BOOL IsLoaded(const CFX_RectF* pClipBox) override;
  int32_t LoadPage(const CFX_RectF* pClipBox, IFX_Pause* pPause) override;
  void UnloadPage(const CFX_RectF* pClipBox) override;
  const CFX_RectF& GetContentsBox() override;

  // IFDE_VisualSet:
  FDE_VISUALOBJTYPE GetType() override;
  FX_BOOL GetBBox(FDE_HVISUALOBJ hVisualObj, CFX_RectF& bbox) override;
  FX_BOOL GetMatrix(FDE_HVISUALOBJ hVisualObj, CFX_Matrix& matrix) override;
  FX_BOOL GetRect(FDE_HVISUALOBJ hVisualObj, CFX_RectF& rt) override;
  FX_BOOL GetClip(FDE_HVISUALOBJ hVisualObj, CFX_RectF& rt) override;

  // IFDE_CanvasSet:
  FX_POSITION GetFirstPosition(FDE_HVISUALOBJ hCanvas) override;
  FDE_HVISUALOBJ GetNext(FDE_HVISUALOBJ hCanvas,
                         FX_POSITION& pos,
                         IFDE_VisualSet*& pVisualSet) override;
  FDE_HVISUALOBJ GetParentCanvas(FDE_HVISUALOBJ hCanvas,
                                 IFDE_VisualSet*& pVisualSet) override;

  // IFX_TxtAccess:
  FX_WCHAR GetChar(void* pIdentity, int32_t index) const override;
  int32_t GetWidth(void* pIdentity, int32_t index) const override;

 protected:
  virtual ~CFDE_TxtEdtPage();

 private:
  void NormalizePt2Rect(CFX_PointF& ptF,
                        const CFX_RectF& rtF,
                        FX_FLOAT fTolerance) const;

  std::unique_ptr<IFX_CharIter> m_pIter;
  CFDE_TxtEdtTextSet* m_pTextSet;
  CFDE_TxtEdtEngine* m_pEditEngine;
  CFDE_TXTEDTPieceMassArray m_PieceMassArr;
  CFDE_TxtEdtParag* m_pBgnParag;
  CFDE_TxtEdtParag* m_pEndParag;
  int32_t m_nRefCount;
  int32_t m_nPageStart;
  int32_t m_nCharCount;
  int32_t m_nPageIndex;
  FX_BOOL m_bLoaded;
  CFX_RectF m_rtPage;
  CFX_RectF m_rtPageMargin;
  CFX_RectF m_rtPageContents;
  CFX_RectF m_rtPageCanvas;
  int32_t* m_pCharWidth;
};

#endif  // XFA_FDE_CFDE_TXTEDTPAGE_H_