textpage_p.h 4.17 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
/***************************************************************************
 *   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_

14
#include <QtCore/QList>
15
16
17
18
#include <QtCore/QMap>
#include <QtGui/QMatrix>

class SearchPoint;
19
class TinyTextEntity;
20
class RegionText;
21
22
23
24

namespace Okular
{

25
class PagePrivate;
26
typedef QList< TinyTextEntity* > TextList;
27

28
29
30
typedef bool ( *TextComparisonFunction )( const QStringRef & from, const QStringRef & to,
                                          int *fromLength, int *toLength );

31
/**
32
33
 * Make a line of TextList and store the bounding rectangle of line
 */
34
35
36
typedef QList<TextList> SortedTextList;
typedef QList<QRect> LineRect;

37
38
39
/**
 * A list of RegionText. It keeps a bunch of TextList with their bounding rectangles
 */
40
typedef QList<RegionText> RegionTextList;
41

42
43
44
class TextPagePrivate
{
    public:
45
        TextPagePrivate();
46
47
48
49
        ~TextPagePrivate();

        RegularAreaRect * findTextInternalForward( int searchID, const QString &query,
                                                   Qt::CaseSensitivity caseSensitivity,
50
                                                   TextComparisonFunction comparer,
51
52
                                                   const TextList::ConstIterator &start,
                                                   const TextList::ConstIterator &end );
53
54
        RegularAreaRect * findTextInternalBackward( int searchID, const QString &query,
                                                    Qt::CaseSensitivity caseSensitivity,
55
                                                    TextComparisonFunction comparer,
56
57
                                                    const TextList::ConstIterator &start,
                                                    const TextList::ConstIterator &end );
58

59
60
61
        /**
         * Copy a TextList to m_words
         */
62
63
        void copyTo(TextList &list);

64
65
66
        /**
         * Copy m_words to a TextList
         */
67
        void copyFrom(TextList &list);
68

69
        /**
70
71
         * Remove odd spaces which are much bigger than normal spaces from m_words
         */
72
73
74
        void removeSpace();

        /**
75
76
         * Create words from characters
         */
77
78
79
        void makeWordFromCharacters();

        /**
80
81
         * Create lines from TextList and sort them according to their position
         */
82
        void makeAndSortLines(TextList &words,SortedTextList &lines,LineRect &line_rects);
83
84

        /**
85
86
87
         * Caluclate statistical info like, word spacing, column spacing, line spacing from the Lines
         * we made
         */
88
89
        void calculateStatisticalInformation(SortedTextList &lines, LineRect line_rects,int& word_spacing,
                                             int& line_spacing, int& column_spacing);
90
91

        /**
92
93
94
         * Functions necessary for document file segmentation into text regions for document layout
         * analysis.
         */
95
96
        void XYCutForBoundingBoxes(int tcx,int tcy);

97
        /**
98
99
100
         * Add additional spaces between words, if necessary, which can make the words valuable
         * while copying after selection
         */
101
102
103
        void addNecessarySpace();

        /**
104
105
         * Break the words into characters, so the text selection wors fine
         */
106
107
108
        void breakWordIntoCharacters();

        // variables those can be accessed directly from TextPage
109
        QMap<int, RegionText> m_word_chars_map;
110
        RegionTextList m_XY_cut_tree;
111
        TextList m_spaces;
112
        TextList m_words;
113
        QMap< int, SearchPoint* > m_searchPoints;
114
        PagePrivate *m_page;
115
116
        SortedTextList m_lines;
        LineRect m_line_rects;
117
118
119
120
121
};

}

#endif