1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
// -*- Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil; -*-
/*
* filter.h
*
* Copyright (C) 2004 Zack Rusin <[email protected]>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA
*/
#ifndef KSPELL_FILTER_H
#define KSPELL_FILTER_H
#include <tqstring.h>
#include <tdelibs_export.h>
namespace KSpell2
{
class Settings;
/**
* Structure abstracts the word and its position in the
* parent text.
*
* @author Zack Rusin <[email protected]>
* @short struct represents word
*/
struct Word
{
Word() : start( 0 ), end( true )
{}
Word( const TQString& w, int st, bool e = false )
: word( w ), start( st ), end( e )
{}
Word( const Word& other )
: word( other.word ), start( other.start ),
end( other.end )
{}
TQString word;
uint start;
bool end;
};
/**
* Filter is used to split text into words which
* will be spell checked.
*
* @author Zack Rusin <[email protected]>
* @short used to split text into words
*/
class KDE_EXPORT Filter
{
public:
static Filter *defaultFilter();
public:
Filter();
virtual ~Filter();
static Word end();
/**
* Sets the Settings object for this Filter
*/
void setSettings( Settings* );
/**
* Returns currently used Settings object
*/
Settings *settings() const;
bool atEnd() const;
void setBuffer( const TQString& buffer );
TQString buffer() const;
void restart();
virtual Word nextWord() const;
virtual Word previousWord() const;
virtual Word wordAtPosition( unsigned int pos ) const;
virtual void setCurrentPosition( int );
virtual int currentPosition() const;
virtual void replace( const Word& w, const TQString& newWord );
/**
* Should return the sentence containing the current word
*/
virtual TQString context() const;
protected:
bool trySkipLinks() const;
bool ignore( const TQString& word ) const;
TQChar skipToLetter( uint &fromPosition ) const;
bool shouldBeSkipped( bool wordWasUppercase, bool wordWasRunTogether,
const TQString& foundWord ) const;
protected:
TQString m_buffer;
mutable uint m_currentPosition;
private:
class Private;
Private *d;
};
}
#endif
|