2007-09-03 19:52:46 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* Copyright (C) 2006 by Tobias Koenig <tokoe@kde.org> *
|
|
|
|
* Copyright (C) 2007 by Pino Toscano <pino@kde.org> *
|
|
|
|
* *
|
|
|
|
* 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. *
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
#ifndef _OKULAR_TEXTPAGE_P_H_
|
|
|
|
#define _OKULAR_TEXTPAGE_P_H_
|
|
|
|
|
2008-05-01 19:03:02 +00:00
|
|
|
#include <QtCore/QList>
|
2007-09-03 19:52:46 +00:00
|
|
|
#include <QtCore/QMap>
|
|
|
|
#include <QtGui/QMatrix>
|
|
|
|
|
|
|
|
class SearchPoint;
|
2008-05-01 19:03:02 +00:00
|
|
|
class TinyTextEntity;
|
2011-07-08 18:12:39 +00:00
|
|
|
class RegionText;
|
2007-09-03 19:52:46 +00:00
|
|
|
|
|
|
|
namespace Okular
|
|
|
|
{
|
|
|
|
|
2007-09-04 22:37:39 +00:00
|
|
|
class PagePrivate;
|
2008-05-01 19:03:02 +00:00
|
|
|
typedef QList< TinyTextEntity* > TextList;
|
2007-09-04 22:37:39 +00:00
|
|
|
|
2009-12-27 14:22:13 +00:00
|
|
|
typedef bool ( *TextComparisonFunction )( const QStringRef & from, const QStringRef & to,
|
|
|
|
int *fromLength, int *toLength );
|
|
|
|
|
2011-06-29 12:17:15 +00:00
|
|
|
//mamun.nightcrawler@gmail.com
|
|
|
|
|
|
|
|
/**
|
|
|
|
We will make a line of TextList and also store the bounding rectangle of line
|
|
|
|
**/
|
|
|
|
typedef QList<TextList> SortedTextList;
|
|
|
|
typedef QList<QRect> LineRect;
|
|
|
|
|
2011-07-13 11:16:03 +00:00
|
|
|
/** list of RegionText -- keeps a bunch of TextList with their bounding rectangles **/
|
|
|
|
typedef QList<RegionText> RegionTextList;
|
2011-06-29 12:17:15 +00:00
|
|
|
|
2007-09-03 19:52:46 +00:00
|
|
|
class TextPagePrivate
|
|
|
|
{
|
|
|
|
public:
|
2008-04-18 09:57:55 +00:00
|
|
|
TextPagePrivate();
|
2007-09-03 19:52:46 +00:00
|
|
|
~TextPagePrivate();
|
|
|
|
|
|
|
|
RegularAreaRect * findTextInternalForward( int searchID, const QString &query,
|
|
|
|
Qt::CaseSensitivity caseSensitivity,
|
2009-12-27 14:22:13 +00:00
|
|
|
TextComparisonFunction comparer,
|
2008-05-01 19:03:02 +00:00
|
|
|
const TextList::ConstIterator &start,
|
|
|
|
const TextList::ConstIterator &end );
|
2008-03-14 14:14:06 +00:00
|
|
|
RegularAreaRect * findTextInternalBackward( int searchID, const QString &query,
|
|
|
|
Qt::CaseSensitivity caseSensitivity,
|
2009-12-27 14:22:13 +00:00
|
|
|
TextComparisonFunction comparer,
|
2008-05-01 19:03:02 +00:00
|
|
|
const TextList::ConstIterator &start,
|
|
|
|
const TextList::ConstIterator &end );
|
2011-07-10 14:54:38 +00:00
|
|
|
/** prints a line from m_lines **/
|
2011-07-01 10:41:55 +00:00
|
|
|
void printTextList(int i, TextList list);
|
2007-09-03 19:52:46 +00:00
|
|
|
|
2011-07-10 14:54:38 +00:00
|
|
|
/** copy a TextList to m_words **/
|
|
|
|
void copy(TextList &list);
|
|
|
|
|
2011-07-13 13:27:04 +00:00
|
|
|
/**
|
|
|
|
print the textpage contents with area (text and bounding rect)
|
|
|
|
**/
|
|
|
|
void printTextPageContent();
|
|
|
|
|
|
|
|
/**
|
|
|
|
remove odd spaces which are much bigger than normal spaces from m_words
|
|
|
|
**/
|
|
|
|
void removeSpace();
|
|
|
|
|
|
|
|
/**
|
|
|
|
create words from characters
|
|
|
|
**/
|
|
|
|
void makeWordFromCharacters();
|
|
|
|
|
|
|
|
/**
|
|
|
|
Create lines from TextList and sort them according to their position
|
|
|
|
**/
|
2011-07-14 13:23:39 +00:00
|
|
|
void makeAndSortLines(TextList &words,SortedTextList &lines,LineRect &line_rects);
|
2011-07-13 13:27:04 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Caluclate statistical info like, word spacing, column spacing, line spacing from the Lines
|
|
|
|
we made
|
|
|
|
**/
|
2011-07-15 11:29:59 +00:00
|
|
|
void calculateStatisticalInformation(SortedTextList &lines, LineRect line_rects,int& word_spacing,
|
|
|
|
int& line_spacing, int& column_spacing);
|
2011-07-13 13:27:04 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Functions necessary for document file segmentation into text regions for document layout
|
|
|
|
analysis.
|
|
|
|
**/
|
|
|
|
void XYCutForBoundingBoxes(int tcx,int tcy);
|
|
|
|
|
|
|
|
|
2011-07-12 14:24:17 +00:00
|
|
|
/**
|
|
|
|
add additional spaces between words, if necessary, which can make the words valuable
|
|
|
|
while copying after selection
|
|
|
|
**/
|
2011-07-13 13:27:04 +00:00
|
|
|
void addNecessarySpace();
|
|
|
|
|
|
|
|
/**
|
|
|
|
break the words into characters, so the text selection wors fine
|
|
|
|
**/
|
|
|
|
void breakWordIntoCharacters();
|
|
|
|
|
2011-07-12 14:24:17 +00:00
|
|
|
|
2011-07-13 11:16:03 +00:00
|
|
|
|
2011-07-13 13:27:04 +00:00
|
|
|
// variables those can be accessed directly from TextPage
|
2011-07-13 11:16:03 +00:00
|
|
|
QMap<int, RegionText> m_word_chars_map;
|
2011-07-13 13:27:04 +00:00
|
|
|
RegionTextList m_XY_cut_tree;
|
2011-07-12 14:24:17 +00:00
|
|
|
TextList m_spaces;
|
2008-05-01 19:03:02 +00:00
|
|
|
TextList m_words;
|
2011-07-13 13:27:04 +00:00
|
|
|
// TextList m_tmp_words;
|
2007-09-03 19:52:46 +00:00
|
|
|
QMap< int, SearchPoint* > m_searchPoints;
|
2007-09-04 22:37:39 +00:00
|
|
|
PagePrivate *m_page;
|
2011-06-29 12:17:15 +00:00
|
|
|
SortedTextList m_lines;
|
|
|
|
LineRect m_line_rects;
|
2007-09-03 19:52:46 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|