2005-07-15 18:20:57 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* Copyright (C) 2005 by Piotr Szymanski <niedakh@gmail.com> *
|
|
|
|
* *
|
|
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU General Public License as published by *
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
|
|
* (at your option) any later version. *
|
|
|
|
***************************************************************************/
|
|
|
|
|
2007-07-29 14:53:31 +00:00
|
|
|
#ifndef _OKULAR_TEXTPAGE_H_
|
|
|
|
#define _OKULAR_TEXTPAGE_H_
|
2005-07-15 18:20:57 +00:00
|
|
|
|
2007-07-10 23:15:53 +00:00
|
|
|
#include <QtCore/QList>
|
|
|
|
#include <QtCore/QString>
|
|
|
|
|
2014-10-27 21:35:06 +00:00
|
|
|
#include "okularcore_export.h"
|
2011-06-25 05:11:33 +00:00
|
|
|
#include "global.h"
|
2006-09-21 08:45:36 +00:00
|
|
|
|
2012-09-08 15:06:02 +00:00
|
|
|
class QTransform;
|
2007-07-10 23:15:53 +00:00
|
|
|
|
2006-09-21 08:45:36 +00:00
|
|
|
namespace Okular {
|
|
|
|
|
2012-03-25 21:48:07 +00:00
|
|
|
class NormalizedPoint;
|
2007-07-10 23:15:53 +00:00
|
|
|
class NormalizedRect;
|
2007-09-03 19:58:30 +00:00
|
|
|
class Page;
|
|
|
|
class PagePrivate;
|
2007-09-03 19:52:46 +00:00
|
|
|
class TextPagePrivate;
|
- GIGANTIC 2700 line diff with LOTS OF FEATURES!
- 1. editor-like text selection, and I do mean it, its not pseudo-editor
(like the ones acroread and kviewshell have) it doesnt intersect the
selection area with words under it, no, it does a lot more, including
work on cursors and searching for the text area closest to the given
cursor
- 2. rotation support, change the orientation of the documents if
you need too :)
- 3. the kfaxview backend works beautifully, porting kviewshell backends
is damn easy ! djvu and dvi will be next!
- 4. Hardware Blending of selection rectangles! We now use XRender
instead of KImageEffect, makes a damn faster blend!
- 5. Overview mode - as seen in Kviewshell, but quite a bit extended,
the kviewshell is only one state, while we support it in both
continous and non-continous form
- BTW. I coded all those features myself, (apart from kfaxview backend library)
it is an impressive bit right? but oKular cant be run by only one person,
join in on the fun! i can introduce you into the code just mail niedakh@gmail.com
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=509871
2006-02-15 18:54:49 +00:00
|
|
|
class TextSelection;
|
2007-07-10 23:15:53 +00:00
|
|
|
class RegularAreaRect;
|
2005-07-15 18:20:57 +00:00
|
|
|
|
2006-11-23 17:56:03 +00:00
|
|
|
/*! @class TextEntity
|
2006-09-21 08:45:36 +00:00
|
|
|
* @short Abstract textentity of Okular
|
2005-11-04 11:59:51 +00:00
|
|
|
* @par The context
|
|
|
|
* A document can provide different forms of information about textual representation
|
2006-11-23 17:56:03 +00:00
|
|
|
* of its contents. It can include information about positions of every character on the
|
|
|
|
* page, this is the best possibility.
|
|
|
|
*
|
|
|
|
* But also it can provide information only about positions of every word on the page (not the character).
|
2005-11-04 11:59:51 +00:00
|
|
|
* Furthermore it can provide information only about the position of the whole page's text on the page.
|
2006-11-23 17:56:03 +00:00
|
|
|
*
|
|
|
|
* Also some document types have glyphes - sets of characters rendered as one, so in search they should
|
2005-11-04 11:59:51 +00:00
|
|
|
* appear as a text but are only one character when drawn on screen. We need to allow this.
|
2005-07-15 18:20:57 +00:00
|
|
|
*/
|
2014-10-27 21:35:06 +00:00
|
|
|
class OKULARCORE_EXPORT TextEntity
|
2005-07-15 18:20:57 +00:00
|
|
|
{
|
2006-11-23 17:56:03 +00:00
|
|
|
public:
|
|
|
|
typedef QList<TextEntity*> List;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a new text entity with the given @p text and the
|
|
|
|
* given @p area.
|
|
|
|
*/
|
|
|
|
TextEntity( const QString &text, NormalizedRect *area );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Destroys the text entity.
|
|
|
|
*/
|
|
|
|
~TextEntity();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the text of the text entity.
|
|
|
|
*/
|
|
|
|
QString text() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the bounding area of the text entity.
|
|
|
|
*/
|
|
|
|
NormalizedRect* area() const;
|
|
|
|
|
2006-11-23 22:14:04 +00:00
|
|
|
/**
|
|
|
|
* Returns the transformed area of the text entity.
|
|
|
|
*/
|
2012-09-08 15:06:02 +00:00
|
|
|
NormalizedRect transformedArea(const QTransform &matrix) const;
|
2006-11-23 22:14:04 +00:00
|
|
|
|
2006-11-23 17:56:03 +00:00
|
|
|
private:
|
|
|
|
QString m_text;
|
|
|
|
NormalizedRect* m_area;
|
|
|
|
|
|
|
|
class Private;
|
2007-04-15 19:11:10 +00:00
|
|
|
const Private *d;
|
2006-11-23 17:56:03 +00:00
|
|
|
|
|
|
|
Q_DISABLE_COPY( TextEntity )
|
2005-07-15 18:20:57 +00:00
|
|
|
};
|
|
|
|
|
2006-11-23 17:56:03 +00:00
|
|
|
/**
|
|
|
|
* The TextPage class represents the text of a page by
|
|
|
|
* providing @see TextEntity items for every word/character of
|
|
|
|
* the page.
|
|
|
|
*/
|
2014-10-27 21:35:06 +00:00
|
|
|
class OKULARCORE_EXPORT TextPage
|
2006-09-21 08:45:36 +00:00
|
|
|
{
|
2007-09-03 19:58:30 +00:00
|
|
|
/// @cond PRIVATE
|
|
|
|
friend class Page;
|
|
|
|
friend class PagePrivate;
|
|
|
|
/// @endcond
|
|
|
|
|
2006-11-23 17:56:03 +00:00
|
|
|
public:
|
2009-11-12 21:48:43 +00:00
|
|
|
/**
|
|
|
|
* Defines the behaviour of adding characters to text() result
|
|
|
|
* @since 0.10 (KDE 4.4)
|
|
|
|
*/
|
|
|
|
enum TextAreaInclusionBehaviour
|
|
|
|
{
|
|
|
|
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
|
|
|
|
};
|
|
|
|
|
2006-11-23 17:56:03 +00:00
|
|
|
/**
|
|
|
|
* Creates a new text page.
|
|
|
|
*/
|
|
|
|
TextPage();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a new text page with the given @p words.
|
|
|
|
*/
|
|
|
|
TextPage( const TextEntity::List &words );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Destroys the text page.
|
|
|
|
*/
|
|
|
|
~TextPage();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Appends the given @p text with the given @p area as new
|
2007-01-13 22:55:00 +00:00
|
|
|
* @ref TextEntity to the page.
|
2006-11-23 17:56:03 +00:00
|
|
|
*/
|
|
|
|
void append( const QString &text, NormalizedRect *area );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the bounding rect of the text which matches the following criteria
|
|
|
|
* or 0 if the search is not successful.
|
|
|
|
*
|
|
|
|
* @param id An unique id for this search.
|
|
|
|
* @param text The search text.
|
2007-01-13 22:55:00 +00:00
|
|
|
* @param direction The direction of the search (@ref SearchDirection)
|
2006-11-23 17:56:03 +00:00
|
|
|
* @param caseSensitivity If Qt::CaseSensitive, the search is case sensitive; otherwise
|
|
|
|
* the search is case insensitive.
|
|
|
|
* @param lastRect If 0 the search starts at the beginning of the page, otherwise
|
2008-09-25 15:05:22 +00:00
|
|
|
* right/below the coordinates of the given rect.
|
2006-11-23 17:56:03 +00:00
|
|
|
*/
|
2007-01-05 15:00:12 +00:00
|
|
|
RegularAreaRect* findText( int id, const QString &text, SearchDirection direction,
|
2006-11-23 17:56:03 +00:00
|
|
|
Qt::CaseSensitivity caseSensitivity, const RegularAreaRect *lastRect );
|
|
|
|
|
|
|
|
/**
|
2007-01-13 22:55:00 +00:00
|
|
|
* Text extraction function.
|
|
|
|
*
|
2006-11-24 21:02:38 +00:00
|
|
|
* Returns:
|
|
|
|
* - a null string if @p rect is a valid pointer to a null area
|
|
|
|
* - the whole page text if @p rect is a null pointer
|
|
|
|
* - the text which is included by rectangular area @p rect otherwise
|
2009-11-12 21:48:43 +00:00
|
|
|
* Uses AnyPixelTextAreaInclusionBehaviour
|
2006-11-23 17:56:03 +00:00
|
|
|
*/
|
2006-11-24 21:02:38 +00:00
|
|
|
QString text( const RegularAreaRect *rect = 0 ) const;
|
2006-11-23 17:56:03 +00:00
|
|
|
|
2009-11-12 21:48:43 +00:00
|
|
|
/**
|
|
|
|
* Text extraction function.
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* - a null string if @p rect is a valid pointer to a null area
|
|
|
|
* - the whole page text if @p rect is a null pointer
|
|
|
|
* - the text which is included by rectangular area @p rect otherwise
|
|
|
|
* @since 0.10 (KDE 4.4)
|
|
|
|
*/
|
|
|
|
QString text( const RegularAreaRect * rect, TextAreaInclusionBehaviour b ) const;
|
|
|
|
|
2011-10-31 15:33:03 +00:00
|
|
|
/**
|
|
|
|
* 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)
|
|
|
|
*/
|
|
|
|
TextEntity::List words( const RegularAreaRect * rect, TextAreaInclusionBehaviour b ) const;
|
|
|
|
|
2012-03-25 21:48:07 +00:00
|
|
|
/**
|
|
|
|
* 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)
|
|
|
|
*/
|
|
|
|
RegularAreaRect * wordAt( const NormalizedPoint &p, QString *word = 0 ) const;
|
|
|
|
|
2006-11-23 17:56:03 +00:00
|
|
|
/**
|
|
|
|
* Returns the rectangular area of the given @p selection.
|
|
|
|
*/
|
|
|
|
RegularAreaRect *textArea( TextSelection *selection ) const;
|
|
|
|
|
|
|
|
private:
|
2007-09-03 19:52:46 +00:00
|
|
|
TextPagePrivate* const d;
|
2006-11-23 17:56:03 +00:00
|
|
|
|
|
|
|
Q_DISABLE_COPY( TextPage )
|
2006-09-21 08:45:36 +00:00
|
|
|
};
|
- GIGANTIC 2700 line diff with LOTS OF FEATURES!
- 1. editor-like text selection, and I do mean it, its not pseudo-editor
(like the ones acroread and kviewshell have) it doesnt intersect the
selection area with words under it, no, it does a lot more, including
work on cursors and searching for the text area closest to the given
cursor
- 2. rotation support, change the orientation of the documents if
you need too :)
- 3. the kfaxview backend works beautifully, porting kviewshell backends
is damn easy ! djvu and dvi will be next!
- 4. Hardware Blending of selection rectangles! We now use XRender
instead of KImageEffect, makes a damn faster blend!
- 5. Overview mode - as seen in Kviewshell, but quite a bit extended,
the kviewshell is only one state, while we support it in both
continous and non-continous form
- BTW. I coded all those features myself, (apart from kfaxview backend library)
it is an impressive bit right? but oKular cant be run by only one person,
join in on the fun! i can introduce you into the code just mail niedakh@gmail.com
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=509871
2006-02-15 18:54:49 +00:00
|
|
|
|
2006-09-21 08:45:36 +00:00
|
|
|
}
|
- GIGANTIC 2700 line diff with LOTS OF FEATURES!
- 1. editor-like text selection, and I do mean it, its not pseudo-editor
(like the ones acroread and kviewshell have) it doesnt intersect the
selection area with words under it, no, it does a lot more, including
work on cursors and searching for the text area closest to the given
cursor
- 2. rotation support, change the orientation of the documents if
you need too :)
- 3. the kfaxview backend works beautifully, porting kviewshell backends
is damn easy ! djvu and dvi will be next!
- 4. Hardware Blending of selection rectangles! We now use XRender
instead of KImageEffect, makes a damn faster blend!
- 5. Overview mode - as seen in Kviewshell, but quite a bit extended,
the kviewshell is only one state, while we support it in both
continous and non-continous form
- BTW. I coded all those features myself, (apart from kfaxview backend library)
it is an impressive bit right? but oKular cant be run by only one person,
join in on the fun! i can introduce you into the code just mail niedakh@gmail.com
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=509871
2006-02-15 18:54:49 +00:00
|
|
|
|
2011-08-17 04:45:46 +00:00
|
|
|
#endif
|