File indexing completed on 2024-04-28 04:32:47

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 "textpage.h"
0012 #include <QList>
0013 #include <QMap>
0014 #include <QPair>
0015 #include <QTransform>
0016 
0017 class SearchPoint;
0018 
0019 class RegionText;
0020 
0021 namespace Okular
0022 {
0023 class PagePrivate;
0024 class RegularAreaRect;
0025 class Page;
0026 
0027 /**
0028  * Returns whether the two strings match.
0029  * Satisfies the condition that if two strings match then their lengths are equal.
0030  */
0031 typedef bool (*TextComparisonFunction)(QStringView from, const QStringView to);
0032 
0033 /**
0034  * A list of RegionText. It keeps a bunch of TextList with their bounding rectangles
0035  */
0036 typedef QList<RegionText> RegionTextList;
0037 
0038 class TextPagePrivate
0039 {
0040 public:
0041     TextPagePrivate();
0042     ~TextPagePrivate();
0043 
0044     RegularAreaRect *findTextInternalForward(int searchID, const QString &query, TextComparisonFunction comparer, const TextEntity::List::ConstIterator start, int start_offset, const TextEntity::List::ConstIterator end);
0045     RegularAreaRect *findTextInternalBackward(int searchID, const QString &query, TextComparisonFunction comparer, const TextEntity::List::ConstIterator start, int start_offset, const TextEntity::List::ConstIterator end);
0046 
0047     /**
0048      * Copy a TextList to m_words, the pointers of list are adopted
0049      */
0050     void setWordList(const TextEntity::List &list);
0051 
0052     /**
0053      * Make necessary modifications in the TextList to make the text order correct, so
0054      * that textselection works fine
0055      */
0056     void correctTextOrder();
0057 
0058     // variables those can be accessed directly from TextPage
0059     TextEntity::List m_words;
0060     QMap<int, SearchPoint *> m_searchPoints;
0061     Page *m_page;
0062 
0063 private:
0064     RegularAreaRect *searchPointToArea(const SearchPoint *sp);
0065 };
0066 
0067 }
0068 
0069 #endif