summaryrefslogtreecommitdiff
path: root/core/fpdftext/include
diff options
context:
space:
mode:
authordsinclair <dsinclair@chromium.org>2016-04-19 10:39:24 -0700
committerCommit bot <commit-bot@chromium.org>2016-04-19 10:39:24 -0700
commita28ae388f3859c52630deb6ef3d0ea468e5177e3 (patch)
tree1ab55ded754a5d1fc6ab5702e9d2244e5830ed68 /core/fpdftext/include
parent11178284eccf22306338cf0d252b8dbb946feb16 (diff)
downloadpdfium-a28ae388f3859c52630deb6ef3d0ea468e5177e3.tar.xz
Remove IPDF_TextPage, IPDF_TextPageFind and IPDF_LinkExtract interfaces.
Each was only used by one subclass. Removed and used the concrete classes. BUG=pdfium:468 Review URL: https://codereview.chromium.org/1897993002
Diffstat (limited to 'core/fpdftext/include')
-rw-r--r--core/fpdftext/include/cpdf_linkextract.h54
-rw-r--r--core/fpdftext/include/cpdf_textpage.h157
-rw-r--r--core/fpdftext/include/cpdf_textpagefind.h65
-rw-r--r--core/fpdftext/include/ipdf_linkextract.h26
-rw-r--r--core/fpdftext/include/ipdf_textpage.h70
-rw-r--r--core/fpdftext/include/ipdf_textpagefind.h29
6 files changed, 276 insertions, 125 deletions
diff --git a/core/fpdftext/include/cpdf_linkextract.h b/core/fpdftext/include/cpdf_linkextract.h
new file mode 100644
index 0000000000..263768ee5d
--- /dev/null
+++ b/core/fpdftext/include/cpdf_linkextract.h
@@ -0,0 +1,54 @@
+// 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_FPDFTEXT_INCLUDE_CPDF_LINKEXTRACT_H_
+#define CORE_FPDFTEXT_INCLUDE_CPDF_LINKEXTRACT_H_
+
+#include "core/fxcrt/include/fx_basic.h"
+#include "core/fxcrt/include/fx_coordinates.h"
+#include "core/fxcrt/include/fx_string.h"
+#include "core/fxcrt/include/fx_system.h"
+
+class CPDF_TextPage;
+
+class CPDF_LinkExt {
+ public:
+ CPDF_LinkExt() {}
+ ~CPDF_LinkExt() {}
+
+ int m_Start;
+ int m_Count;
+ CFX_WideString m_strUrl;
+};
+
+class CPDF_LinkExtract {
+ public:
+ CPDF_LinkExtract();
+ ~CPDF_LinkExtract();
+
+ FX_BOOL ExtractLinks(const CPDF_TextPage* pTextPage);
+ int CountLinks() const;
+ CFX_WideString GetURL(int index) const;
+ void GetBoundedSegment(int index, int& start, int& count) const;
+ void GetRects(int index, CFX_RectArray& rects) const;
+
+ FX_BOOL IsExtract() const { return m_bIsParsed; }
+
+ protected:
+ void ParseLink();
+ void DeleteLinkList();
+ FX_BOOL CheckWebLink(CFX_WideString& strBeCheck);
+ bool CheckMailLink(CFX_WideString& str);
+ void AppendToLinkList(int start, int count, const CFX_WideString& strUrl);
+
+ private:
+ CFX_ArrayTemplate<CPDF_LinkExt*> m_LinkList;
+ const CPDF_TextPage* m_pTextPage;
+ CFX_WideString m_strPageText;
+ bool m_bIsParsed;
+};
+
+#endif // CORE_FPDFTEXT_INCLUDE_CPDF_LINKEXTRACT_H_
diff --git a/core/fpdftext/include/cpdf_textpage.h b/core/fpdftext/include/cpdf_textpage.h
new file mode 100644
index 0000000000..19e8791b5a
--- /dev/null
+++ b/core/fpdftext/include/cpdf_textpage.h
@@ -0,0 +1,157 @@
+// Copyright 2016 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_FPDFTEXT_INCLUDE_CPDF_TEXTPAGE_H_
+#define CORE_FPDFTEXT_INCLUDE_CPDF_TEXTPAGE_H_
+
+#include <deque>
+#include <vector>
+
+#include "core/fpdfapi/fpdf_page/cpdf_pageobjectlist.h"
+#include "core/fxcrt/include/fx_basic.h"
+#include "core/fxcrt/include/fx_coordinates.h"
+#include "core/fxcrt/include/fx_string.h"
+
+class CFX_BidiChar;
+class CPDF_Font;
+class CPDF_FormObject;
+class CPDF_Page;
+class CPDF_TextObject;
+
+struct FPDF_CHAR_INFO {
+ FX_WCHAR m_Unicode;
+ FX_WCHAR m_Charcode;
+ int32_t m_Flag;
+ FX_FLOAT m_FontSize;
+ FX_FLOAT m_OriginX;
+ FX_FLOAT m_OriginY;
+ CFX_FloatRect m_CharBox;
+ CPDF_TextObject* m_pTextObj;
+ CFX_Matrix m_Matrix;
+};
+
+struct FPDF_SEGMENT {
+ int m_Start;
+ int m_nCount;
+};
+
+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_Matrix m_Matrix;
+ int m_Index;
+};
+
+struct PDFTEXT_Obj {
+ CPDF_TextObject* m_pTextObj;
+ CFX_Matrix m_formMatrix;
+};
+
+class CPDF_TextPage {
+ public:
+ CPDF_TextPage(const CPDF_Page* pPage, int flags);
+ ~CPDF_TextPage() {}
+
+ // IPDF_TextPage:
+ void ParseTextPage();
+ bool IsParsed() const { return m_bIsParsed; }
+ int CharIndexFromTextIndex(int TextIndex) const;
+ int TextIndexFromCharIndex(int CharIndex) const;
+ int CountChars() const;
+ void GetCharInfo(int index, FPDF_CHAR_INFO* info) const;
+ void GetRectArray(int start, int nCount, CFX_RectArray& rectArray) const;
+ int GetIndexAtPos(CFX_FloatPoint point,
+ FX_FLOAT xTolerance,
+ FX_FLOAT yTolerance) const;
+ int GetIndexAtPos(FX_FLOAT x,
+ FX_FLOAT y,
+ FX_FLOAT xTolerance,
+ FX_FLOAT yTolerance) const;
+ CFX_WideString GetTextByRect(const CFX_FloatRect& rect) const;
+ void GetRectsArrayByRect(const CFX_FloatRect& rect,
+ CFX_RectArray& resRectArray) const;
+ CFX_WideString GetPageText(int start = 0, int nCount = -1) const;
+ int CountRects(int start, int nCount);
+ void GetRect(int rectIndex,
+ FX_FLOAT& left,
+ FX_FLOAT& top,
+ FX_FLOAT& right,
+ FX_FLOAT& bottom) const;
+ FX_BOOL GetBaselineRotate(int rectIndex, int& Rotate);
+ FX_BOOL GetBaselineRotate(const CFX_FloatRect& rect, int& Rotate);
+ int CountBoundedSegments(FX_FLOAT left,
+ FX_FLOAT top,
+ FX_FLOAT right,
+ FX_FLOAT bottom,
+ FX_BOOL bContains = FALSE);
+ void GetBoundedSegment(int index, int& start, int& count) const;
+ int GetWordBreak(int index, int direction) const;
+
+ 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_Matrix& formMatrix);
+ void ProcessTextObject(PDFTEXT_Obj pObj);
+ void ProcessTextObject(CPDF_TextObject* pTextObj,
+ const CFX_Matrix& formMatrix,
+ const CPDF_PageObjectList* pObjList,
+ CPDF_PageObjectList::const_iterator ObjPos);
+ int ProcessInsertObject(const CPDF_TextObject* pObj,
+ const CFX_Matrix& formMatrix);
+ FX_BOOL GenerateCharInfo(FX_WCHAR unicode, PAGECHAR_INFO& info);
+ FX_BOOL IsSameAsPreTextObject(CPDF_TextObject* pTextObj,
+ const CPDF_PageObjectList* pObjList,
+ CPDF_PageObjectList::const_iterator ObjPos);
+ FX_BOOL IsSameTextObject(CPDF_TextObject* pTextObj1,
+ CPDF_TextObject* pTextObj2);
+ int GetCharWidth(uint32_t charCode, CPDF_Font* pFont) const;
+ void CloseTempLine();
+ void OnPiece(CFX_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(FX_WCHAR wChar, PAGECHAR_INFO info);
+ void AddCharInfoByRLDirection(FX_WCHAR wChar, PAGECHAR_INFO info);
+ 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;
+
+ const CPDF_Page* const m_pPage;
+ std::vector<uint16_t> m_CharIndex;
+ std::deque<PAGECHAR_INFO> m_CharList;
+ std::deque<PAGECHAR_INFO> m_TempCharList;
+ CFX_WideTextBuf m_TextBuf;
+ CFX_WideTextBuf m_TempTextBuf;
+ const int m_parserflag;
+ CPDF_TextObject* m_pPreTextObj;
+ CFX_Matrix m_perMatrix;
+ bool m_bIsParsed;
+ CFX_Matrix m_DisplayMatrix;
+ CFX_ArrayTemplate<FPDF_SEGMENT> m_Segments;
+ CFX_RectArray m_SelRects;
+ CFX_ArrayTemplate<PDFTEXT_Obj> m_LineObj;
+ int32_t m_TextlineDir;
+ CFX_FloatRect m_CurlineRect;
+};
+
+#endif // CORE_FPDFTEXT_INCLUDE_CPDF_TEXTPAGE_H_
diff --git a/core/fpdftext/include/cpdf_textpagefind.h b/core/fpdftext/include/cpdf_textpagefind.h
new file mode 100644
index 0000000000..ec739e4896
--- /dev/null
+++ b/core/fpdftext/include/cpdf_textpagefind.h
@@ -0,0 +1,65 @@
+// Copyright 2016 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_FPDFTEXT_INCLUDE_CPDF_TEXTPAGEFIND_H_
+#define CORE_FPDFTEXT_INCLUDE_CPDF_TEXTPAGEFIND_H_
+
+#include <vector>
+
+#include "core/fxcrt/include/fx_coordinates.h"
+#include "core/fxcrt/include/fx_string.h"
+#include "core/fxcrt/include/fx_system.h"
+
+class CPDF_TextPage;
+
+class CPDF_TextPageFind {
+ public:
+ explicit CPDF_TextPageFind(const CPDF_TextPage* pTextPage);
+ ~CPDF_TextPageFind() {}
+
+ FX_BOOL FindFirst(const CFX_WideString& findwhat,
+ int flags,
+ int startPos = 0);
+ FX_BOOL FindNext();
+ FX_BOOL FindPrev();
+ void GetRectArray(CFX_RectArray& rects) const;
+ int GetCurOrder() const;
+ int GetMatchedCount() const;
+
+ 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:
+ std::vector<uint16_t> m_CharIndex;
+ const CPDF_TextPage* m_pTextPage;
+ CFX_WideString m_strText;
+ CFX_WideString m_findWhat;
+ int m_flags;
+ std::vector<CFX_WideString> 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;
+};
+
+#endif // CORE_FPDFTEXT_INCLUDE_CPDF_TEXTPAGEFIND_H_
diff --git a/core/fpdftext/include/ipdf_linkextract.h b/core/fpdftext/include/ipdf_linkextract.h
deleted file mode 100644
index c1a5f2f04e..0000000000
--- a/core/fpdftext/include/ipdf_linkextract.h
+++ /dev/null
@@ -1,26 +0,0 @@
-// Copyright 2016 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_FPDFTEXT_INCLUDE_IPDF_LINKEXTRACT_H_
-#define CORE_FPDFTEXT_INCLUDE_IPDF_LINKEXTRACT_H_
-
-#include "core/fpdftext/include/ipdf_textpage.h"
-#include "core/fxcrt/include/fx_coordinates.h"
-#include "core/fxcrt/include/fx_system.h"
-
-class IPDF_LinkExtract {
- public:
- static IPDF_LinkExtract* CreateLinkExtract();
- virtual ~IPDF_LinkExtract() {}
-
- virtual FX_BOOL ExtractLinks(const IPDF_TextPage* pTextPage) = 0;
- virtual int CountLinks() const = 0;
- virtual CFX_WideString GetURL(int index) const = 0;
- virtual void GetBoundedSegment(int index, int& start, int& count) const = 0;
- virtual void GetRects(int index, CFX_RectArray& rects) const = 0;
-};
-
-#endif // CORE_FPDFTEXT_INCLUDE_IPDF_LINKEXTRACT_H_
diff --git a/core/fpdftext/include/ipdf_textpage.h b/core/fpdftext/include/ipdf_textpage.h
deleted file mode 100644
index 3849cd4004..0000000000
--- a/core/fpdftext/include/ipdf_textpage.h
+++ /dev/null
@@ -1,70 +0,0 @@
-// Copyright 2016 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_FPDFTEXT_INCLUDE_IPDF_TEXTPAGE_H_
-#define CORE_FPDFTEXT_INCLUDE_IPDF_TEXTPAGE_H_
-
-#include "core/fxcrt/include/fx_coordinates.h"
-#include "core/fxcrt/include/fx_system.h"
-
-class CPDF_TextObject;
-class CPDF_Page;
-
-struct FPDF_CHAR_INFO {
- FX_WCHAR m_Unicode;
- FX_WCHAR m_Charcode;
- int32_t m_Flag;
- FX_FLOAT m_FontSize;
- FX_FLOAT m_OriginX;
- FX_FLOAT m_OriginY;
- CFX_FloatRect m_CharBox;
- CPDF_TextObject* m_pTextObj;
- CFX_Matrix m_Matrix;
-};
-
-class IPDF_TextPage {
- public:
- static IPDF_TextPage* CreateTextPage(const CPDF_Page* pPage, int flags = 0);
- virtual ~IPDF_TextPage() {}
-
- virtual void ParseTextPage() = 0;
- virtual bool IsParsed() const = 0;
- virtual int CharIndexFromTextIndex(int TextIndex) const = 0;
- virtual int TextIndexFromCharIndex(int CharIndex) const = 0;
- virtual int CountChars() const = 0;
- virtual void GetCharInfo(int index, FPDF_CHAR_INFO* info) const = 0;
- virtual void GetRectArray(int start,
- int nCount,
- CFX_RectArray& rectArray) const = 0;
- virtual int GetIndexAtPos(CFX_FloatPoint point,
- FX_FLOAT xTolerance,
- FX_FLOAT yTolerance) const = 0;
- virtual int GetIndexAtPos(FX_FLOAT x,
- FX_FLOAT y,
- FX_FLOAT xTolerance,
- FX_FLOAT yTolerance) const = 0;
- virtual CFX_WideString GetTextByRect(const CFX_FloatRect& rect) const = 0;
- virtual void GetRectsArrayByRect(const CFX_FloatRect& rect,
- CFX_RectArray& resRectArray) const = 0;
- virtual int CountRects(int start, int nCount) = 0;
- virtual void GetRect(int rectIndex,
- FX_FLOAT& left,
- FX_FLOAT& top,
- FX_FLOAT& right,
- FX_FLOAT& bottom) const = 0;
- virtual FX_BOOL GetBaselineRotate(int rectIndex, int& Rotate) = 0;
- virtual FX_BOOL GetBaselineRotate(const CFX_FloatRect& rect, int& Rotate) = 0;
- virtual int CountBoundedSegments(FX_FLOAT left,
- FX_FLOAT top,
- FX_FLOAT right,
- FX_FLOAT bottom,
- FX_BOOL bContains = FALSE) = 0;
- virtual void GetBoundedSegment(int index, int& start, int& count) const = 0;
- virtual int GetWordBreak(int index, int direction) const = 0;
- virtual CFX_WideString GetPageText(int start = 0, int nCount = -1) const = 0;
-};
-
-#endif // CORE_FPDFTEXT_INCLUDE_IPDF_TEXTPAGE_H_
diff --git a/core/fpdftext/include/ipdf_textpagefind.h b/core/fpdftext/include/ipdf_textpagefind.h
deleted file mode 100644
index b13432b59b..0000000000
--- a/core/fpdftext/include/ipdf_textpagefind.h
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright 2016 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_FPDFTEXT_INCLUDE_IPDF_TEXTPAGEFIND_H_
-#define CORE_FPDFTEXT_INCLUDE_IPDF_TEXTPAGEFIND_H_
-
-#include "core/fpdftext/include/ipdf_textpage.h"
-#include "core/fxcrt/include/fx_coordinates.h"
-#include "core/fxcrt/include/fx_string.h"
-
-class IPDF_TextPageFind {
- public:
- static IPDF_TextPageFind* CreatePageFind(const IPDF_TextPage* pTextPage);
- virtual ~IPDF_TextPageFind() {}
-
- virtual FX_BOOL FindFirst(const CFX_WideString& findwhat,
- int flags,
- int startPos = 0) = 0;
- virtual FX_BOOL FindNext() = 0;
- virtual FX_BOOL FindPrev() = 0;
- virtual void GetRectArray(CFX_RectArray& rects) const = 0;
- virtual int GetCurOrder() const = 0;
- virtual int GetMatchedCount() const = 0;
-};
-
-#endif // CORE_FPDFTEXT_INCLUDE_IPDF_TEXTPAGEFIND_H_