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 CORE_SRC_REFLOW_REFLOWEDTEXTPAGE_H_
8#define CORE_SRC_REFLOW_REFLOWEDTEXTPAGE_H_
9
10#include "../../include/reflow/reflowengine.h"
11#include "../../src/reflow/reflowedpage.h"
12
13typedef CFX_SegmentedArray<CRF_CharData*> CRF_CharDataPtrArray;
14typedef CFX_SegmentedArray<FX_INT32> CFX_CountBSINT32Array;
15class CRF_TextPage : public IPDF_TextPage
16{
17public:
18    CRF_TextPage(IPDF_ReflowedPage* pRefPage);
19
20    virtual ~CRF_TextPage() ;
21    FX_BOOL			ParseTextPage();
22    void			NormalizeObjects(FX_BOOL bNormalize)
23    {
24        return;
25    };
26
27    FX_BOOL			IsParsered() const;
28public:
29
30    int CharIndexFromTextIndex(int TextIndex) const;
31
32    int TextIndexFromCharIndex(int CharIndex) const;
33
34
35    int				CountChars() const;
36
37    virtual	void	GetCharInfo(int index, FPDF_CHAR_INFO & info) const;
38
39    void			GetRectArray(int start, int nCount, CFX_RectArray& rectArray) const;
40
41
42    int				GetIndexAtPos(CPDF_Point point, FX_FLOAT xTorelance, FX_FLOAT yTorelance) const;
43
44    int				GetIndexAtPos(FX_FLOAT x, FX_FLOAT y, FX_FLOAT xTorelance, FX_FLOAT yTorelance) const;
45
46    virtual	int				GetOrderByDirection(int index, int direction) const;
47
48    CFX_WideString	GetTextByRect(CFX_FloatRect rect) const;
49
50    void			GetRectsArrayByRect(CFX_FloatRect rect, CFX_RectArray& resRectArray) const;
51
52
53    int				CountRects(int start, int nCount);
54
55    virtual	void			GetRect(int rectIndex, FX_FLOAT& left, FX_FLOAT& top, FX_FLOAT& right, FX_FLOAT &bottom) const;
56    virtual	FX_BOOL			GetBaselineRotate(int rectIndex, int& Rotate);
57    virtual FX_BOOL			GetBaselineRotate(CFX_FloatRect rect, int& Rotate);
58
59    virtual	int				CountBoundedSegments(FX_FLOAT left, FX_FLOAT top, FX_FLOAT right, FX_FLOAT bottom, FX_BOOL bContains = FALSE);
60
61    virtual	void			GetBoundedSegment(int index, int& start, int& count) const;
62
63
64    int				GetWordBreak(int index, int direction) const;
65
66    CFX_WideString	GetPageText(int start, int nCount = -1 ) const;
67private:
68    CPDF_ReflowedPage*		m_pRefPage;
69    CRF_CharDataPtrArray*	m_pDataList;
70    CFX_RectArray			m_rectArray;
71    CFX_CountBSINT32Array*	m_CountBSArray;
72};
73
74#endif  // CORE_SRC_REFLOW_REFLOWEDTEXTPAGE_H_
75