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