File indexing completed on 2024-05-12 08:32:58

0001 /*
0002     SPDX-FileCopyrightText: 2006 Tobias Koenig <tokoe@kde.org>
0003     SPDX-FileCopyrightText: 2007 Pino Toscano <pino@kde.org>
0004 
0005     SPDX-License-Identifier: GPL-2.0-or-later
0006 */
0007 
0008 #ifndef _OKULAR_TEXTPAGE_P_H_
0009 #define _OKULAR_TEXTPAGE_P_H_
0010 
0011 #include <QList>
0012 #include <QMap>
0013 #include <QPair>
0014 #include <QTransform>
0015 
0016 class SearchPoint;
0017 
0018 /**
0019  * Memory-optimized storage of a TextEntity. Stores a string and its bounding box.
0020  *
0021  * When a generator adds a TextEntity to a TextPage, it is internally stored as TinyTextEntity.
0022  * TinyTextEntity is also internally used to get the geometry of text selections and highlight areas.
0023  *
0024  * @see TextEntity
0025  */
0026 class TinyTextEntity;
0027 class RegionText;
0028 
0029 namespace Okular
0030 {
0031 class PagePrivate;
0032 class RegularAreaRect;
0033 class Page;
0034 typedef QList<TinyTextEntity *> TextList;
0035 
0036 /**
0037  * Returns whether the two strings match.
0038  * Satisfies the condition that if two strings match then their lengths are equal.
0039  */
0040 typedef bool (*TextComparisonFunction)(QStringView from, const QStringView to);
0041 
0042 /**
0043  * A list of RegionText. It keeps a bunch of TextList with their bounding rectangles
0044  */
0045 typedef QList<RegionText> RegionTextList;
0046 
0047 class TextPagePrivate
0048 {
0049 public:
0050     TextPagePrivate();
0051     ~TextPagePrivate();
0052 
0053     RegularAreaRect *findTextInternalForward(int searchID, const QString &query, TextComparisonFunction comparer, const TextList::ConstIterator start, int start_offset, const TextList::ConstIterator end);
0054     RegularAreaRect *findTextInternalBackward(int searchID, const QString &query, TextComparisonFunction comparer, const TextList::ConstIterator start, int start_offset, const TextList::ConstIterator end);
0055 
0056     /**
0057      * Copy a TextList to m_words, the pointers of list are adopted
0058      */
0059     void setWordList(const TextList &list);
0060 
0061     /**
0062      * Make necessary modifications in the TextList to make the text order correct, so
0063      * that textselection works fine
0064      */
0065     void correctTextOrder();
0066 
0067     // variables those can be accessed directly from TextPage
0068     TextList m_words;
0069     QMap<int, SearchPoint *> m_searchPoints;
0070     Page *m_page;
0071 
0072 private:
0073     RegularAreaRect *searchPointToArea(const SearchPoint *sp);
0074 };
0075 
0076 }
0077 
0078 #endif