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_FPDFTEXT_TXTPROC_H_ 8 #define CORE_SRC_FPDFTEXT_TXTPROC_H_ 9 10 class CTextColumn { 11 public: 12 FX_FLOAT m_AvgPos; 13 int m_Count; 14 int m_TextPos; 15 }; 16 class CTextBox { 17 public: 18 CFX_WideString m_Text; 19 FX_FLOAT m_Left; 20 FX_FLOAT m_Right; 21 FX_FLOAT m_SpaceWidth; 22 FX_FLOAT m_Top; 23 FX_FLOAT m_Bottom; 24 FX_FLOAT m_FontSizeV; 25 CTextColumn* m_pColumn; 26 }; 27 class CTextBaseLine { 28 public: 29 CTextBaseLine(); 30 ~CTextBaseLine(); 31 void InsertTextBox(FX_FLOAT leftx, 32 FX_FLOAT rightx, 33 FX_FLOAT topy, 34 FX_FLOAT bottomy, 35 FX_FLOAT spacew, 36 FX_FLOAT fontsize_v, 37 const CFX_WideString& str); 38 FX_BOOL GetWidth(FX_FLOAT& leftx, FX_FLOAT& rightx); 39 FX_BOOL CanMerge(CTextBaseLine* pOther); 40 void Merge(CTextBaseLine* pOther); 41 void MergeBoxes(); 42 void CountChars(int& count, FX_FLOAT& width, int& minchars); 43 void WriteOutput(CFX_WideString& str, 44 FX_FLOAT leftx, 45 FX_FLOAT width, 46 int iWidth); 47 FX_FLOAT m_BaseLine; 48 FX_FLOAT m_Top; 49 FX_FLOAT m_Bottom; 50 FX_FLOAT m_MaxFontSizeV; 51 CFX_ArrayTemplate<CTextBox*> m_TextList; 52 }; 53 class CPDF_PageObject; 54 class CPDF_TextObject; 55 class CTextPage { 56 public: 57 CTextPage(); 58 ~CTextPage(); 59 void ProcessObject(CPDF_PageObject* pObj); 60 CTextBaseLine* InsertTextBox(CTextBaseLine* pBaseLine, 61 FX_FLOAT basey, 62 FX_FLOAT leftx, 63 FX_FLOAT rightx, 64 FX_FLOAT topy, 65 FX_FLOAT bottomy, 66 FX_FLOAT spacew, 67 FX_FLOAT fontsize_v, 68 CFX_ByteString& str, 69 CPDF_Font* pFont); 70 void WriteOutput(CFX_WideStringArray& lines, int iMinWidth); 71 FX_BOOL m_bAutoWidth; 72 FX_BOOL m_bKeepColumn; 73 FX_BOOL m_bBreakSpace; 74 75 private: 76 void FindColumns(); 77 CTextColumn* FindColumn(FX_FLOAT xpos); 78 void BreakSpace(CPDF_TextObject* pTextObj); 79 80 CFX_ArrayTemplate<CTextBaseLine*> m_BaseLines; 81 CFX_ArrayTemplate<CTextColumn*> m_TextColumns; 82 }; 83 84 #endif // CORE_SRC_FPDFTEXT_TXTPROC_H_ 85