OLD | NEW |
1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #ifndef CORE_FPDFAPI_FPDF_PAGE_INCLUDE_CPDF_TEXTOBJECT_H_ | 7 #ifndef CORE_FPDFAPI_FPDF_PAGE_INCLUDE_CPDF_TEXTOBJECT_H_ |
8 #define CORE_FPDFAPI_FPDF_PAGE_INCLUDE_CPDF_TEXTOBJECT_H_ | 8 #define CORE_FPDFAPI_FPDF_PAGE_INCLUDE_CPDF_TEXTOBJECT_H_ |
9 | 9 |
10 #include "core/fpdfapi/fpdf_page/include/cpdf_pageobject.h" | 10 #include "core/fpdfapi/fpdf_page/include/cpdf_pageobject.h" |
11 #include "core/fxcrt/include/fx_string.h" | 11 #include "core/fxcrt/include/fx_string.h" |
12 #include "core/fxcrt/include/fx_system.h" | 12 #include "core/fxcrt/include/fx_system.h" |
13 | 13 |
14 struct CPDF_TextObjectItem { | 14 struct CPDF_TextObjectItem { |
15 FX_DWORD m_CharCode; | 15 uint32_t m_CharCode; |
16 FX_FLOAT m_OriginX; | 16 FX_FLOAT m_OriginX; |
17 FX_FLOAT m_OriginY; | 17 FX_FLOAT m_OriginY; |
18 }; | 18 }; |
19 | 19 |
20 class CPDF_TextObject : public CPDF_PageObject { | 20 class CPDF_TextObject : public CPDF_PageObject { |
21 public: | 21 public: |
22 CPDF_TextObject(); | 22 CPDF_TextObject(); |
23 ~CPDF_TextObject() override; | 23 ~CPDF_TextObject() override; |
24 | 24 |
25 // CPDF_PageObject: | 25 // CPDF_PageObject: |
26 CPDF_TextObject* Clone() const override; | 26 CPDF_TextObject* Clone() const override; |
27 Type GetType() const override { return TEXT; }; | 27 Type GetType() const override { return TEXT; }; |
28 void Transform(const CFX_Matrix& matrix) override; | 28 void Transform(const CFX_Matrix& matrix) override; |
29 bool IsText() const override { return true; }; | 29 bool IsText() const override { return true; }; |
30 CPDF_TextObject* AsText() override { return this; }; | 30 CPDF_TextObject* AsText() override { return this; }; |
31 const CPDF_TextObject* AsText() const override { return this; }; | 31 const CPDF_TextObject* AsText() const override { return this; }; |
32 | 32 |
33 int CountItems() const { return m_nChars; } | 33 int CountItems() const { return m_nChars; } |
34 void GetItemInfo(int index, CPDF_TextObjectItem* pInfo) const; | 34 void GetItemInfo(int index, CPDF_TextObjectItem* pInfo) const; |
35 int CountChars() const; | 35 int CountChars() const; |
36 void GetCharInfo(int index, FX_DWORD& charcode, FX_FLOAT& kerning) const; | 36 void GetCharInfo(int index, uint32_t& charcode, FX_FLOAT& kerning) const; |
37 void GetCharInfo(int index, CPDF_TextObjectItem* pInfo) const; | 37 void GetCharInfo(int index, CPDF_TextObjectItem* pInfo) const; |
38 FX_FLOAT GetCharWidth(FX_DWORD charcode) const; | 38 FX_FLOAT GetCharWidth(uint32_t charcode) const; |
39 FX_FLOAT GetPosX() const { return m_PosX; } | 39 FX_FLOAT GetPosX() const { return m_PosX; } |
40 FX_FLOAT GetPosY() const { return m_PosY; } | 40 FX_FLOAT GetPosY() const { return m_PosY; } |
41 void GetTextMatrix(CFX_Matrix* pMatrix) const; | 41 void GetTextMatrix(CFX_Matrix* pMatrix) const; |
42 CPDF_Font* GetFont() const { return m_TextState.GetFont(); } | 42 CPDF_Font* GetFont() const { return m_TextState.GetFont(); } |
43 FX_FLOAT GetFontSize() const { return m_TextState.GetFontSize(); } | 43 FX_FLOAT GetFontSize() const { return m_TextState.GetFontSize(); } |
44 | 44 |
45 void SetText(const CFX_ByteString& text); | 45 void SetText(const CFX_ByteString& text); |
46 void SetPosition(FX_FLOAT x, FX_FLOAT y); | 46 void SetPosition(FX_FLOAT x, FX_FLOAT y); |
47 | 47 |
48 void RecalcPositionData() { CalcPositionData(nullptr, nullptr, 1); } | 48 void RecalcPositionData() { CalcPositionData(nullptr, nullptr, 1); } |
49 | 49 |
50 protected: | 50 protected: |
51 friend class CPDF_RenderStatus; | 51 friend class CPDF_RenderStatus; |
52 friend class CPDF_StreamContentParser; | 52 friend class CPDF_StreamContentParser; |
53 friend class CPDF_TextRenderer; | 53 friend class CPDF_TextRenderer; |
54 | 54 |
55 void SetSegments(const CFX_ByteString* pStrs, FX_FLOAT* pKerning, int nSegs); | 55 void SetSegments(const CFX_ByteString* pStrs, FX_FLOAT* pKerning, int nSegs); |
56 | 56 |
57 void CalcPositionData(FX_FLOAT* pTextAdvanceX, | 57 void CalcPositionData(FX_FLOAT* pTextAdvanceX, |
58 FX_FLOAT* pTextAdvanceY, | 58 FX_FLOAT* pTextAdvanceY, |
59 FX_FLOAT horz_scale, | 59 FX_FLOAT horz_scale, |
60 int level = 0); | 60 int level = 0); |
61 | 61 |
62 FX_FLOAT m_PosX; | 62 FX_FLOAT m_PosX; |
63 FX_FLOAT m_PosY; | 63 FX_FLOAT m_PosY; |
64 int m_nChars; | 64 int m_nChars; |
65 FX_DWORD* m_pCharCodes; | 65 uint32_t* m_pCharCodes; |
66 FX_FLOAT* m_pCharPos; | 66 FX_FLOAT* m_pCharPos; |
67 }; | 67 }; |
68 | 68 |
69 #endif // CORE_FPDFAPI_FPDF_PAGE_INCLUDE_CPDF_TEXTOBJECT_H_ | 69 #endif // CORE_FPDFAPI_FPDF_PAGE_INCLUDE_CPDF_TEXTOBJECT_H_ |
OLD | NEW |