Use override in more classes in core/
[pdfium.git] / core / src / fpdftext / text_int.h
index a0af51e..b0c79cd 100644 (file)
-// Copyright 2014 PDFium Authors. All rights reserved.\r
-// Use of this source code is governed by a BSD-style license that can be\r
-// found in the LICENSE file.\r
\r
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com\r
-\r
-#ifndef _PDF_TEXT_INT_H_\r
-#define _PDF_TEXT_INT_H_\r
-class CPDF_TextParseOptions : public CFX_Object\r
-{\r
-public:\r
-    CPDF_TextParseOptions();\r
-    FX_BOOL                    m_bCheckObjectOrder;\r
-    FX_BOOL                    m_bCheckDirection;\r
-    int                                m_nCheckSameObject;\r
-};\r
-class CPDF_TextPage;\r
-class CPDF_LinkExtract;\r
-class CPDF_TextPageFind;\r
-class CPDF_DocProgressiveSearch;\r
-#define FPDFTEXT_CHAR_ERROR                    -1\r
-#define FPDFTEXT_CHAR_NORMAL           0\r
-#define FPDFTEXT_CHAR_GENERATED                1\r
-#define FPDFTEXT_CHAR_UNUNICODE                2\r
-#define FPDFTEXT_CHAR_HYPHEN           3\r
-#define FPDFTEXT_CHAR_PIECE                    4\r
-#define FPDFTEXT_MC_PASS                       0\r
-#define FPDFTEXT_MC_DONE                       1\r
-#define FPDFTEXT_MC_DELAY                      2\r
-typedef struct _PAGECHAR_INFO: public CFX_Object {\r
-    int                                        m_CharCode;\r
-    FX_WCHAR                   m_Unicode;\r
-    FX_FLOAT                   m_OriginX;\r
-    FX_FLOAT                   m_OriginY;\r
-    FX_INT32                   m_Flag;\r
-    CFX_FloatRect              m_CharBox;\r
-    CPDF_TextObject*   m_pTextObj;\r
-    CFX_AffineMatrix   m_Matrix;\r
-    int                                        m_Index;\r
-} PAGECHAR_INFO;\r
-typedef        CFX_SegmentedArray<PAGECHAR_INFO> PAGECHAR_InfoArray;\r
-typedef struct {\r
-    int        m_Start;\r
-    int m_nCount;\r
-} FPDF_SEGMENT;\r
-typedef CFX_ArrayTemplate<FPDF_SEGMENT> SEGMENT_Array;\r
-typedef struct {\r
-    CPDF_TextObject*   m_pTextObj;\r
-    CFX_AffineMatrix   m_formMatrix;\r
-} PDFTEXT_Obj;\r
-typedef CFX_ArrayTemplate<PDFTEXT_Obj> LINEOBJ;\r
-class CPDF_TextPage: public IPDF_TextPage\r
-{\r
-public:\r
-    CPDF_TextPage(const CPDF_Page* pPage, int flags = 0);\r
-    CPDF_TextPage(const CPDF_PageObjects* pPage, int flags = 0);\r
-    CPDF_TextPage(const CPDF_Page* pPage, CPDFText_ParseOptions ParserOptions);\r
-    virtual FX_BOOL                                    ParseTextPage();\r
-    virtual void                                       NormalizeObjects(FX_BOOL bNormalize);\r
-    virtual    FX_BOOL                                 IsParsered() const\r
-    {\r
-        return m_IsParsered;\r
-    }\r
-    virtual ~CPDF_TextPage() {};\r
-public:\r
-    virtual int CharIndexFromTextIndex(int TextIndex)const ;\r
-    virtual int TextIndexFromCharIndex(int CharIndex)const;\r
-    virtual int                                                CountChars() const;\r
-    virtual    void                                    GetCharInfo(int index, FPDF_CHAR_INFO & info) const;\r
-    virtual void                                       GetRectArray(int start, int nCount, CFX_RectArray& rectArray) const;\r
-    virtual int                                                GetIndexAtPos(CPDF_Point point, FX_FLOAT xTorelance, FX_FLOAT yTorelance) const;\r
-    virtual int                                                GetIndexAtPos(FX_FLOAT x, FX_FLOAT y, FX_FLOAT xTorelance,\r
-            FX_FLOAT yTorelance) const;\r
-    virtual CFX_WideString                     GetTextByRect(CFX_FloatRect rect) const;\r
-    virtual void                                       GetRectsArrayByRect(CFX_FloatRect rect, CFX_RectArray& resRectArray) const;\r
-    virtual    int                                             GetOrderByDirection(int order, int direction) const;\r
-    virtual    CFX_WideString                  GetPageText(int start = 0, int nCount = -1) const;\r
-\r
-    virtual int                                                CountRects(int start, int nCount);\r
-    virtual    void                                    GetRect(int rectIndex, FX_FLOAT& left, FX_FLOAT& top\r
-                                            , FX_FLOAT& right, FX_FLOAT &bottom) const;\r
-    virtual FX_BOOL                                    GetBaselineRotate(int rectIndex, int& Rotate);\r
-    virtual FX_BOOL                                    GetBaselineRotate(CFX_FloatRect rect, int& Rotate);\r
-    virtual    int                                             CountBoundedSegments(FX_FLOAT left, FX_FLOAT top,\r
-            FX_FLOAT right, FX_FLOAT bottom, FX_BOOL bContains = FALSE);\r
-    virtual    void                                    GetBoundedSegment(int index, int& start, int& count) const;\r
-    virtual int                                                GetWordBreak(int index, int direction) const;\r
-public:\r
-    const      PAGECHAR_InfoArray*             GetCharList() const\r
-    {\r
-        return &m_charList;\r
-    }\r
-    static     FX_BOOL                                 IsRectIntersect(CFX_FloatRect rect1, CFX_FloatRect rect2);\r
-    static     FX_BOOL                                 IsLetter(FX_WCHAR unicode);\r
-private:\r
-    FX_BOOL                                                    IsHyphen(FX_WCHAR curChar);\r
-    FX_BOOL                                                    IsControlChar(PAGECHAR_INFO* pCharInfo);\r
-    FX_BOOL                                                    GetBaselineRotate(int start, int end, int& Rotate);\r
-    void                                                       ProcessObject();\r
-    void                                                       ProcessFormObject(CPDF_FormObject*      pFormObj, CFX_AffineMatrix formMatrix);\r
-    void                                                       ProcessTextObject(PDFTEXT_Obj pObj);\r
-    void                                                       ProcessTextObject(CPDF_TextObject*      pTextObj, CFX_AffineMatrix formMatrix, FX_POSITION ObjPos);\r
-    int                                                                ProcessInsertObject(const CPDF_TextObject* pObj, CFX_AffineMatrix formMatrix);\r
-    FX_BOOL                                                    GenerateCharInfo(FX_WCHAR unicode, PAGECHAR_INFO& info);\r
-    FX_BOOL                                                    IsSameAsPreTextObject(CPDF_TextObject* pTextObj, FX_POSITION ObjPos);\r
-    FX_BOOL                                                    IsSameTextObject(CPDF_TextObject* pTextObj1, CPDF_TextObject* pTextObj2);\r
-    int                                                                GetCharWidth(FX_DWORD charCode, CPDF_Font* pFont) const;\r
-    void                                                       CloseTempLine();\r
-    void                                                       OnPiece(IFX_BidiChar* pBidi, CFX_WideString& str);\r
-    FX_INT32   PreMarkedContent(PDFTEXT_Obj pObj);\r
-    void               ProcessMarkedContent(PDFTEXT_Obj pObj);\r
-    void               CheckMarkedContentObject(FX_INT32& start, FX_INT32& nCount) const;\r
-    void               FindPreviousTextObject(void);\r
-    void               AddCharInfoByLRDirection(CFX_WideString& str, int i);\r
-    void               AddCharInfoByRLDirection(CFX_WideString& str, int i);\r
-    FX_INT32   GetTextObjectWritingMode(const CPDF_TextObject* pTextObj);\r
-    FX_INT32   FindTextlineFlowDirection();\r
-protected:\r
-    CPDFText_ParseOptions                      m_ParseOptions;\r
-    CFX_WordArray                                      m_CharIndex;\r
-    const CPDF_PageObjects*                    m_pPage;\r
-    PAGECHAR_InfoArray                         m_charList;\r
-    CFX_WideTextBuf                                    m_TextBuf;\r
-    PAGECHAR_InfoArray                         m_TempCharList;\r
-    CFX_WideTextBuf                                    m_TempTextBuf;\r
-    int                                                                m_parserflag;\r
-    CPDF_TextObject*                           m_pPreTextObj;\r
-    CFX_AffineMatrix                           m_perMatrix;\r
-    FX_BOOL                                                    m_IsParsered;\r
-    CFX_AffineMatrix                           m_DisplayMatrix;\r
-\r
-    SEGMENT_Array                                      m_Segment;\r
-    CFX_RectArray                                      m_SelRects;\r
-    LINEOBJ                                                    m_LineObj;\r
-    FX_BOOL                                                    m_TextlineDir;\r
-    CFX_FloatRect                                      m_CurlineRect;\r
-};\r
-class CPDF_TextPageFind: public IPDF_TextPageFind\r
-{\r
-public:\r
-    CPDF_TextPageFind(const IPDF_TextPage* pTextPage);\r
-    virtual                                                    ~CPDF_TextPageFind() {};\r
-public:\r
-    virtual    FX_BOOL                                 FindFirst(CFX_WideString findwhat, int flags, int startPos = 0);\r
-    virtual    FX_BOOL                                 FindNext();\r
-    virtual    FX_BOOL                                 FindPrev();\r
-\r
-    virtual void                                       GetRectArray(CFX_RectArray& rects) const;\r
-    virtual int                                                GetCurOrder() const;\r
-    virtual int                                                GetMatchedCount()const;\r
-protected:\r
-    void                                                       ExtractFindWhat(CFX_WideString findwhat);\r
-    FX_BOOL                                                    IsMatchWholeWord(CFX_WideString csPageText, int startPos, int endPos);\r
-    FX_BOOL                                                    ExtractSubString(CFX_WideString& rString, FX_LPCWSTR lpszFullString,\r
-            int iSubString, FX_WCHAR chSep);\r
-    CFX_WideString                                     MakeReverse(const CFX_WideString str);\r
-    int                                                                ReverseFind(CFX_WideString csPageText, CFX_WideString csWord, int nStartPos, int& WordLength);\r
-    int                                                                GetCharIndex(int index) const;\r
-private:\r
-    CFX_WordArray                                      m_CharIndex;\r
-    const IPDF_TextPage*                       m_pTextPage;\r
-    CFX_WideString                                     m_strText;\r
-    CFX_WideString                                     m_findWhat;\r
-    int                                                                m_flags;\r
-    CFX_WideStringArray                                m_csFindWhatArray;\r
-    int                                                                m_findNextStart;\r
-    int                                                                m_findPreStart;\r
-    FX_BOOL                                                    m_bMatchCase;\r
-    FX_BOOL                                                    m_bMatchWholeWord;\r
-    int                                                                m_resStart;\r
-    int                                                                m_resEnd;\r
-    CFX_RectArray                                      m_resArray;\r
-    FX_BOOL                                                    m_IsFind;\r
-};\r
-class CPDF_LinkExt: public CFX_Object\r
-{\r
-public:\r
-    CPDF_LinkExt() {};\r
-    int                                                                m_Start;\r
-    int                                                                m_Count;\r
-    CFX_WideString                                     m_strUrl;\r
-    virtual                                                    ~CPDF_LinkExt() {};\r
-};\r
-typedef CFX_ArrayTemplate<CPDF_LinkExt*> LINK_InfoArray;\r
-class CPDF_LinkExtract: public IPDF_LinkExtract\r
-{\r
-public:\r
-    CPDF_LinkExtract();\r
-    virtual                                                    ~CPDF_LinkExtract();\r
-    virtual FX_BOOL                                    ExtractLinks(const IPDF_TextPage* pTextPage);\r
-    virtual    FX_BOOL                                 IsExtract() const\r
-    {\r
-        return m_IsParserd;\r
-    }\r
-public:\r
-    virtual int                                                CountLinks() const;\r
-    virtual    CFX_WideString                  GetURL(int index) const;\r
-    virtual    void                                    GetBoundedSegment(int index, int& start, int& count) const;\r
-    virtual    void                                    GetRects(int index, CFX_RectArray& rects)const;\r
-protected:\r
-    void                                                       parserLink();\r
-    void                                                       DeleteLinkList();\r
-    FX_BOOL                                                    CheckWebLink(CFX_WideString& strBeCheck);\r
-    FX_BOOL                                                    CheckMailLink(CFX_WideString& str);\r
-    FX_BOOL                                                    AppendToLinkList(int start, int count, CFX_WideString strUrl);\r
-private:\r
-    LINK_InfoArray                                     m_LinkList;\r
-    const CPDF_TextPage*                       m_pTextPage;\r
-    CFX_WideString                                     m_strPageText;\r
-    FX_BOOL                                                    m_IsParserd;\r
-};\r
-FX_STRSIZE FX_Unicode_GetNormalization(FX_WCHAR wch, FX_LPWSTR pDst);\r
-void NormalizeString(CFX_WideString& str);\r
-void NormalizeCompositeChar(FX_WCHAR wChar, CFX_WideString& sDest);\r
-#endif\r
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef CORE_SRC_FPDFTEXT_TEXT_INT_H_
+#define CORE_SRC_FPDFTEXT_TEXT_INT_H_
+
+class CPDF_LinkExtract;
+class CPDF_TextPageFind;
+class CPDF_DocProgressiveSearch;
+#define FPDFTEXT_CHAR_ERROR -1
+#define FPDFTEXT_CHAR_NORMAL 0
+#define FPDFTEXT_CHAR_GENERATED 1
+#define FPDFTEXT_CHAR_UNUNICODE 2
+#define FPDFTEXT_CHAR_HYPHEN 3
+#define FPDFTEXT_CHAR_PIECE 4
+#define FPDFTEXT_MC_PASS 0
+#define FPDFTEXT_MC_DONE 1
+#define FPDFTEXT_MC_DELAY 2
+typedef struct _PAGECHAR_INFO {
+  int m_CharCode;
+  FX_WCHAR m_Unicode;
+  FX_FLOAT m_OriginX;
+  FX_FLOAT m_OriginY;
+  int32_t m_Flag;
+  CFX_FloatRect m_CharBox;
+  CPDF_TextObject* m_pTextObj;
+  CFX_AffineMatrix m_Matrix;
+  int m_Index;
+} PAGECHAR_INFO;
+typedef CFX_SegmentedArray<PAGECHAR_INFO> PAGECHAR_InfoArray;
+typedef struct {
+  int m_Start;
+  int m_nCount;
+} FPDF_SEGMENT;
+typedef CFX_ArrayTemplate<FPDF_SEGMENT> SEGMENT_Array;
+typedef struct {
+  CPDF_TextObject* m_pTextObj;
+  CFX_AffineMatrix m_formMatrix;
+} PDFTEXT_Obj;
+typedef CFX_ArrayTemplate<PDFTEXT_Obj> LINEOBJ;
+
+class CPDF_TextPage : public IPDF_TextPage {
+ public:
+  CPDF_TextPage(const CPDF_Page* pPage, int flags = 0);
+  CPDF_TextPage(const CPDF_PageObjects* pPage, int flags = 0);
+  CPDF_TextPage(const CPDF_Page* pPage, CPDFText_ParseOptions ParserOptions);
+  ~CPDF_TextPage() override{};
+
+  // IPDF_TextPage
+  FX_BOOL ParseTextPage() override;
+  void NormalizeObjects(FX_BOOL bNormalize) override;
+  FX_BOOL IsParsered() const override { return m_IsParsered; }
+  int CharIndexFromTextIndex(int TextIndex) const override;
+  int TextIndexFromCharIndex(int CharIndex) const override;
+  int CountChars() const override;
+  void GetCharInfo(int index, FPDF_CHAR_INFO& info) const override;
+  void GetRectArray(int start,
+                    int nCount,
+                    CFX_RectArray& rectArray) const override;
+  int GetIndexAtPos(CPDF_Point point,
+                    FX_FLOAT xTolerance,
+                    FX_FLOAT yTolerance) const override;
+  int GetIndexAtPos(FX_FLOAT x,
+                    FX_FLOAT y,
+                    FX_FLOAT xTolerance,
+                    FX_FLOAT yTolerance) const override;
+  CFX_WideString GetTextByRect(const CFX_FloatRect& rect) const override;
+  void GetRectsArrayByRect(const CFX_FloatRect& rect,
+                           CFX_RectArray& resRectArray) const override;
+  CFX_WideString GetPageText(int start = 0, int nCount = -1) const override;
+  int CountRects(int start, int nCount) override;
+  void GetRect(int rectIndex,
+               FX_FLOAT& left,
+               FX_FLOAT& top,
+               FX_FLOAT& right,
+               FX_FLOAT& bottom) const override;
+  FX_BOOL GetBaselineRotate(int rectIndex, int& Rotate) override;
+  FX_BOOL GetBaselineRotate(const CFX_FloatRect& rect, int& Rotate) override;
+  int CountBoundedSegments(FX_FLOAT left,
+                           FX_FLOAT top,
+                           FX_FLOAT right,
+                           FX_FLOAT bottom,
+                           FX_BOOL bContains = FALSE) override;
+  void GetBoundedSegment(int index, int& start, int& count) const override;
+  int GetWordBreak(int index, int direction) const override;
+
+  const PAGECHAR_InfoArray* GetCharList() const { return &m_charList; }
+  static FX_BOOL IsRectIntersect(const CFX_FloatRect& rect1,
+                                 const CFX_FloatRect& rect2);
+  static FX_BOOL IsLetter(FX_WCHAR unicode);
+
+ private:
+  FX_BOOL IsHyphen(FX_WCHAR curChar);
+  bool IsControlChar(const PAGECHAR_INFO& charInfo);
+  FX_BOOL GetBaselineRotate(int start, int end, int& Rotate);
+  void ProcessObject();
+  void ProcessFormObject(CPDF_FormObject* pFormObj,
+                         const CFX_AffineMatrix& formMatrix);
+  void ProcessTextObject(PDFTEXT_Obj pObj);
+  void ProcessTextObject(CPDF_TextObject* pTextObj,
+                         const CFX_AffineMatrix& formMatrix,
+                         FX_POSITION ObjPos);
+  int ProcessInsertObject(const CPDF_TextObject* pObj,
+                          const CFX_AffineMatrix& formMatrix);
+  FX_BOOL GenerateCharInfo(FX_WCHAR unicode, PAGECHAR_INFO& info);
+  FX_BOOL IsSameAsPreTextObject(CPDF_TextObject* pTextObj, FX_POSITION ObjPos);
+  FX_BOOL IsSameTextObject(CPDF_TextObject* pTextObj1,
+                           CPDF_TextObject* pTextObj2);
+  int GetCharWidth(FX_DWORD charCode, CPDF_Font* pFont) const;
+  void CloseTempLine();
+  void OnPiece(IFX_BidiChar* pBidi, CFX_WideString& str);
+  int32_t PreMarkedContent(PDFTEXT_Obj pObj);
+  void ProcessMarkedContent(PDFTEXT_Obj pObj);
+  void CheckMarkedContentObject(int32_t& start, int32_t& nCount) const;
+  void FindPreviousTextObject(void);
+  void AddCharInfoByLRDirection(CFX_WideString& str, int i);
+  void AddCharInfoByRLDirection(CFX_WideString& str, int i);
+  int32_t GetTextObjectWritingMode(const CPDF_TextObject* pTextObj);
+  int32_t FindTextlineFlowDirection();
+  void SwapTempTextBuf(int32_t iCharListStartAppend, int32_t iBufStartAppend);
+  FX_BOOL IsRightToLeft(const CPDF_TextObject* pTextObj,
+                        const CPDF_Font* pFont,
+                        int nItems) const;
+
+ protected:
+  CPDFText_ParseOptions m_ParseOptions;
+  CFX_WordArray m_CharIndex;
+  const CPDF_PageObjects* m_pPage;
+  PAGECHAR_InfoArray m_charList;
+  CFX_WideTextBuf m_TextBuf;
+  PAGECHAR_InfoArray m_TempCharList;
+  CFX_WideTextBuf m_TempTextBuf;
+  int m_parserflag;
+  CPDF_TextObject* m_pPreTextObj;
+  CFX_AffineMatrix m_perMatrix;
+  FX_BOOL m_IsParsered;
+  CFX_AffineMatrix m_DisplayMatrix;
+
+  SEGMENT_Array m_Segment;
+  CFX_RectArray m_SelRects;
+  LINEOBJ m_LineObj;
+  int32_t m_TextlineDir;
+  CFX_FloatRect m_CurlineRect;
+};
+
+class CPDF_TextPageFind : public IPDF_TextPageFind {
+ public:
+  CPDF_TextPageFind(const IPDF_TextPage* pTextPage);
+  ~CPDF_TextPageFind() override{};
+
+  // IPDF_TextPageFind
+  FX_BOOL FindFirst(const CFX_WideString& findwhat,
+                    int flags,
+                    int startPos = 0) override;
+  FX_BOOL FindNext() override;
+  FX_BOOL FindPrev() override;
+  void GetRectArray(CFX_RectArray& rects) const override;
+  int GetCurOrder() const override;
+  int GetMatchedCount() const override;
+
+ protected:
+  void ExtractFindWhat(const CFX_WideString& findwhat);
+  FX_BOOL IsMatchWholeWord(const CFX_WideString& csPageText,
+                           int startPos,
+                           int endPos);
+  FX_BOOL ExtractSubString(CFX_WideString& rString,
+                           const FX_WCHAR* lpszFullString,
+                           int iSubString,
+                           FX_WCHAR chSep);
+  CFX_WideString MakeReverse(const CFX_WideString& str);
+  int ReverseFind(const CFX_WideString& csPageText,
+                  const CFX_WideString& csWord,
+                  int nStartPos,
+                  int& WordLength);
+  int GetCharIndex(int index) const;
+
+ private:
+  CFX_WordArray m_CharIndex;
+  const IPDF_TextPage* m_pTextPage;
+  CFX_WideString m_strText;
+  CFX_WideString m_findWhat;
+  int m_flags;
+  CFX_WideStringArray m_csFindWhatArray;
+  int m_findNextStart;
+  int m_findPreStart;
+  FX_BOOL m_bMatchCase;
+  FX_BOOL m_bMatchWholeWord;
+  int m_resStart;
+  int m_resEnd;
+  CFX_RectArray m_resArray;
+  FX_BOOL m_IsFind;
+};
+class CPDF_LinkExt {
+ public:
+  CPDF_LinkExt(){};
+  int m_Start;
+  int m_Count;
+  CFX_WideString m_strUrl;
+  virtual ~CPDF_LinkExt(){};
+};
+
+typedef CFX_ArrayTemplate<CPDF_LinkExt*> LINK_InfoArray;
+
+class CPDF_LinkExtract : public IPDF_LinkExtract {
+ public:
+  CPDF_LinkExtract();
+  ~CPDF_LinkExtract() override;
+
+  // IPDF_LinkExtract
+  FX_BOOL ExtractLinks(const IPDF_TextPage* pTextPage) override;
+  int CountLinks() const override;
+  CFX_WideString GetURL(int index) const override;
+  void GetBoundedSegment(int index, int& start, int& count) const override;
+  void GetRects(int index, CFX_RectArray& rects) const override;
+
+  FX_BOOL IsExtract() const { return m_IsParserd; }
+
+ protected:
+  void parserLink();
+  void DeleteLinkList();
+  FX_BOOL CheckWebLink(CFX_WideString& strBeCheck);
+  FX_BOOL CheckMailLink(CFX_WideString& str);
+  FX_BOOL AppendToLinkList(int start, int count, const CFX_WideString& strUrl);
+
+ private:
+  LINK_InfoArray m_LinkList;
+  const CPDF_TextPage* m_pTextPage;
+  CFX_WideString m_strPageText;
+  FX_BOOL m_IsParserd;
+};
+
+FX_STRSIZE FX_Unicode_GetNormalization(FX_WCHAR wch, FX_WCHAR* pDst);
+void NormalizeString(CFX_WideString& str);
+void NormalizeCompositeChar(FX_WCHAR wChar, CFX_WideString& sDest);
+
+#endif  // CORE_SRC_FPDFTEXT_TEXT_INT_H_