Warning, file /office/calligra/libs/text/FindDirection_p.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /* This file is part of the KDE project
0002  * Copyright (C) 2008 Thorsten Zachmann <zachmann@kde.org>
0003  *
0004  * This library is free software; you can redistribute it and/or
0005  * modify it under the terms of the GNU Library General Public
0006  * License as published by the Free Software Foundation; either
0007  * version 2 of the License, or (at your option) any later version.
0008  *
0009  * This library is distributed in the hope that it will be useful,
0010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0012  * Library General Public License for more details.
0013  *
0014  * You should have received a copy of the GNU Library General Public License
0015  * along with this library; see the file COPYING.LIB.  If not, write to
0016  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0017  * Boston, MA 02110-1301, USA.
0018  */
0019 
0020 #include "FindDirection_p.h"
0021 
0022 #include <QTextCursor>
0023 #include <KoCanvasResourceManager.h>
0024 
0025 #include "KoText.h"
0026 #include "KoFind_p.h"
0027 
0028 FindDirection::FindDirection(KoCanvasResourceManager *provider)
0029         : m_provider(provider)
0030 {
0031 }
0032 
0033 FindDirection::~FindDirection()
0034 {
0035 }
0036 
0037 FindForward::FindForward(KoCanvasResourceManager *provider)
0038         : FindDirection(provider)
0039 {
0040 }
0041 
0042 FindForward::~FindForward()
0043 {
0044 }
0045 
0046 bool FindForward::positionReached(const QTextCursor &currentPos, const QTextCursor &endPos)
0047 {
0048     return currentPos > endPos;
0049 }
0050 
0051 void FindForward::positionCursor(QTextCursor &currentPos)
0052 {
0053     currentPos.movePosition(QTextCursor::Start);
0054 }
0055 
0056 void FindForward::select(const QTextCursor &cursor)
0057 {
0058     m_provider->setResource(KoText::CurrentTextPosition, cursor.position());
0059     m_provider->setResource(KoText::CurrentTextAnchor, cursor.anchor());
0060 }
0061 
0062 void FindForward::nextDocument(QTextDocument *document, KoFindPrivate *findPrivate)
0063 {
0064     findPrivate->findDocumentSetNext(document);
0065 }
0066 
0067 FindBackward::FindBackward(KoCanvasResourceManager *provider)
0068         : FindDirection(provider)
0069 {
0070 }
0071 
0072 FindBackward::~FindBackward()
0073 {
0074 }
0075 
0076 bool FindBackward::positionReached(const QTextCursor &currentPos, const QTextCursor &endPos)
0077 {
0078     return currentPos < endPos;
0079 }
0080 
0081 void FindBackward::positionCursor(QTextCursor &currentPos)
0082 {
0083     currentPos.movePosition(QTextCursor::End);
0084 }
0085 
0086 void FindBackward::select(const QTextCursor &cursor)
0087 {
0088     m_provider->setResource(KoText::CurrentTextPosition, cursor.anchor());
0089     m_provider->setResource(KoText::CurrentTextAnchor, cursor.position());
0090 }
0091 
0092 void FindBackward::nextDocument(QTextDocument *document, KoFindPrivate *findPrivate)
0093 {
0094     findPrivate->findDocumentSetPrevious(document);
0095 }
0096