1 /***************************************************************************
2 * Copyright (C) 2005 by Piotr Szymanski <niedakh@gmail.com> *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 ***************************************************************************/
10 #ifndef _OKULAR_TEXTPAGE_H_
11 #define _OKULAR_TEXTPAGE_H_
13 #include <QtCore/QList>
14 #include <QtCore/QString>
16 #include <okular/core/okular_export.h>
17 #include <okular/core/global.h>
26 class TextPagePrivate
;
28 class RegularAreaRect
;
31 * @short Abstract textentity of Okular
33 * A document can provide different forms of information about textual representation
34 * of its contents. It can include information about positions of every character on the
35 * page, this is the best possibility.
37 * But also it can provide information only about positions of every word on the page (not the character).
38 * Furthermore it can provide information only about the position of the whole page's text on the page.
40 * Also some document types have glyphes - sets of characters rendered as one, so in search they should
41 * appear as a text but are only one character when drawn on screen. We need to allow this.
43 class OKULAR_EXPORT TextEntity
46 typedef QList
<TextEntity
*> List
;
49 * Creates a new text entity with the given @p text and the
52 TextEntity( const QString
&text
, NormalizedRect
*area
);
55 * Destroys the text entity.
60 * Returns the text of the text entity.
65 * Returns the bounding area of the text entity.
67 NormalizedRect
* area() const;
70 * Returns the transformed area of the text entity.
72 NormalizedRect
transformedArea(const QMatrix
&matrix
) const;
76 NormalizedRect
* m_area
;
81 Q_DISABLE_COPY( TextEntity
)
85 * The TextPage class represents the text of a page by
86 * providing @see TextEntity items for every word/character of
89 class OKULAR_EXPORT TextPage
93 friend class PagePrivate
;
98 * Creates a new text page.
103 * Creates a new text page with the given @p words.
105 TextPage( const TextEntity::List
&words
);
108 * Destroys the text page.
113 * Appends the given @p text with the given @p area as new
114 * @ref TextEntity to the page.
116 void append( const QString
&text
, NormalizedRect
*area
);
119 * Returns the bounding rect of the text which matches the following criteria
120 * or 0 if the search is not successful.
122 * @param id An unique id for this search.
123 * @param text The search text.
124 * @param direction The direction of the search (@ref SearchDirection)
125 * @param caseSensitivity If Qt::CaseSensitive, the search is case sensitive; otherwise
126 * the search is case insensitive.
127 * @param lastRect If 0 the search starts at the beginning of the page, otherwise
128 * right/below the coordinates of the the given rect.
130 RegularAreaRect
* findText( int id
, const QString
&text
, SearchDirection direction
,
131 Qt::CaseSensitivity caseSensitivity
, const RegularAreaRect
*lastRect
);
134 * Text extraction function.
137 * - a null string if @p rect is a valid pointer to a null area
138 * - the whole page text if @p rect is a null pointer
139 * - the text which is included by rectangular area @p rect otherwise
141 QString
text( const RegularAreaRect
*rect
= 0 ) const;
144 * Returns the rectangular area of the given @p selection.
146 RegularAreaRect
*textArea( TextSelection
*selection
) const;
149 TextPagePrivate
* const d
;
151 Q_DISABLE_COPY( TextPage
)