okular
#include <textpage.h>
Public Types | |
enum | TextAreaInclusionBehaviour { AnyPixelTextAreaInclusionBehaviour, CentralPixelTextAreaInclusionBehaviour } |
Public Member Functions | |
TextPage () | |
TextPage (const TextEntity::List &words) | |
~TextPage () | |
void | append (const QString &text, NormalizedRect *area) |
RegularAreaRect * | findText (int id, const QString &text, SearchDirection direction, Qt::CaseSensitivity caseSensitivity, const RegularAreaRect *lastRect) |
QString | text (const RegularAreaRect *rect=0) const |
QString | text (const RegularAreaRect *rect, TextAreaInclusionBehaviour b) const |
RegularAreaRect * | textArea (TextSelection *selection) const |
RegularAreaRect * | wordAt (const NormalizedPoint &p, QString *word=0) const |
TextEntity::List | words (const RegularAreaRect *rect, TextAreaInclusionBehaviour b) const |
Detailed Description
The TextPage class represents the text of a page by providing.
- See also
- TextEntity items for every word/character of the page.
Definition at line 90 of file textpage.h.
Member Enumeration Documentation
Defines the behaviour of adding characters to text() result.
- Since
- 0.10 (KDE 4.4)
Enumerator | |
---|---|
AnyPixelTextAreaInclusionBehaviour |
A character is included into text() result if any pixel of his bounding box is in the given area. |
CentralPixelTextAreaInclusionBehaviour |
A character is included into text() result if the central pixel of his bounding box is in the given area. |
Definition at line 102 of file textpage.h.
Constructor & Destructor Documentation
TextPage::TextPage | ( | ) |
Creates a new text page.
Definition at line 228 of file textpage.cpp.
TextPage::TextPage | ( | const TextEntity::List & | words | ) |
Creates a new text page with the given words
.
Definition at line 233 of file textpage.cpp.
TextPage::~TextPage | ( | ) |
Destroys the text page.
Definition at line 246 of file textpage.cpp.
Member Function Documentation
void TextPage::append | ( | const QString & | text, |
NormalizedRect * | area | ||
) |
Appends the given text
with the given area
as new TextEntity to the page.
Definition at line 251 of file textpage.cpp.
RegularAreaRect * TextPage::findText | ( | int | id, |
const QString & | text, | ||
SearchDirection | direction, | ||
Qt::CaseSensitivity | caseSensitivity, | ||
const RegularAreaRect * | lastRect | ||
) |
Returns the bounding rect of the text which matches the following criteria or 0 if the search is not successful.
- Parameters
-
id An unique id for this search. text The search text. direction The direction of the search (SearchDirection) caseSensitivity If Qt::CaseSensitive, the search is case sensitive; otherwise the search is case insensitive. lastRect If 0 the search starts at the beginning of the page, otherwise right/below the coordinates of the given rect.
Definition at line 715 of file textpage.cpp.
QString TextPage::text | ( | const RegularAreaRect * | rect = 0 | ) | const |
Text extraction function.
Returns:
- a null string if
rect
is a valid pointer to a null area - the whole page text if
rect
is a null pointer - the text which is included by rectangular area
rect
otherwise Uses AnyPixelTextAreaInclusionBehaviour
Definition at line 1068 of file textpage.cpp.
QString TextPage::text | ( | const RegularAreaRect * | rect, |
TextAreaInclusionBehaviour | b | ||
) | const |
Text extraction function.
Returns:
- a null string if
rect
is a valid pointer to a null area - the whole page text if
rect
is a null pointer - the text which is included by rectangular area
rect
otherwise- Since
- 0.10 (KDE 4.4)
Definition at line 1073 of file textpage.cpp.
RegularAreaRect * TextPage::textArea | ( | TextSelection * | selection | ) | const |
Returns the rectangular area of the given selection
.
It works like this: There are two cursors, we need to select all the text between them. The coordinates are normalised, leftTop is (0,0) rightBottom is (1,1), so for cursors start (sx,sy) and end (ex,ey) we start with finding text rectangles under those points, if not we search for the first that is to the right to it in the same baseline, if none found, then we search for the first rectangle with a baseline under the cursor, having two points that are the best rectangles to both of the cursors: (rx,ry)x(tx,ty) for start and (ux,uy)x(vx,vy) for end, we do a
- (rx,ry)x(1,ty)
- (0,ty)x(1,uy)
- (0,uy)x(vx,vy)
To find the closest rectangle to cursor (cx,cy) we search for a rectangle that either contains the cursor or that has a left border >= cx and bottom border >= cy.
We will now find out the TinyTextEntity for the startRectangle and TinyTextEntity for the endRectangle. We have four cases:
Case 1(a): both startpoint and endpoint are out of the bounding Rectangle and at one side, so the rectangle made of start and endPoint are outof the bounding rect (do not intersect)
Case 1(b): both startpoint and endpoint are out of bounding rect, but they are in different side, so is their rectangle
Case 2(a): find the rectangle which contains start and endpoint and having some TextEntity
Case 2(b): if 2(a) fails (if startPoint and endPoint both are unchanged), then we check whether there is any TextEntity within the rect made by startPoint and endPoint
Case 3: Now, we may have two type of selection.
- startpoint is left-top of start_end and endpoint is right-bottom
- startpoint is left-bottom of start_end and endpoint is top-right
Also, as 2(b) is passed, we might have it,itEnd or both unchanged, but the fact is that we have text within them. so, we need to search for the best suitable textposition for start and end.
Case 3(a): We search the nearest rectangle consisting of some TinyTextEntity right to or bottom of the startPoint for selection 01. And, for selection 02, we have to search for right and top
Case 3(b): For endpoint, we have to find the point top of or left to endpoint if we have selection 01. Otherwise, the search will be left and bottom
note that, after swapping of start and end, we know that, start is always left to end. but, we cannot say start is positioned upper than end.
Definition at line 331 of file textpage.cpp.
RegularAreaRect * TextPage::wordAt | ( | const NormalizedPoint & | p, |
QString * | word = 0 |
||
) | const |
Returns the area and text of the word at the given point Note that ownership of the returned area belongs to the caller.
- Since
- 0.15 (KDE 4.9)
Definition at line 1957 of file textpage.cpp.
TextEntity::List TextPage::words | ( | const RegularAreaRect * | rect, |
TextAreaInclusionBehaviour | b | ||
) | const |
Text entity extraction function.
Similar to text() but returns the words including their bounding rectangles. Note that ownership of the contents of the returned list belongs to the caller.
- Since
- 0.14 (KDE 4.8)
Definition at line 1920 of file textpage.cpp.
The documentation for this class was generated from the following files:
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:19:26 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.