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