spellingfilter.h
00001 /* 00002 * spellingfilter.h 00003 * 00004 * Copyright (c) 2002 Dave Corrie <kde@davecorrie.com> 00005 * 00006 * This file is part of KMail. 00007 * 00008 * KMail is free software; you can redistribute it and/or modify 00009 * it under the terms of the GNU General Public License as published by 00010 * the Free Software Foundation; either version 2 of the License, or 00011 * (at your option) any later version. 00012 * 00013 * This program is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 * GNU General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU General Public License 00019 * along with this program; if not, write to the Free Software 00020 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00021 */ 00022 00023 #ifndef SPELLINGFILTER_H_INCLUDED 00024 #define SPELLINGFILTER_H_INCLUDED 00025 00026 #include <tqstring.h> 00027 #include <tqstringlist.h> 00028 #include "linklocator.h" 00029 00030 #include <kdepimmacros.h> 00031 00032 class KDE_EXPORT SpellingFilter 00033 { 00034 public: 00035 enum UrlFiltering { DontFilterUrls, FilterUrls }; 00036 enum EmailAddressFiltering { DontFilterEmailAddresses, FilterEmailAddresses }; 00037 00038 SpellingFilter(const TQString& text, const TQString& quotePrefix, 00039 UrlFiltering filterUrls = FilterUrls, 00040 EmailAddressFiltering filterEmailAddresses = FilterEmailAddresses, 00041 const TQStringList& filterStrings = TQStringList()); 00042 00043 TQString originalText() const; 00044 TQString filteredText() const; 00045 00046 class TextCensor; 00047 00048 private: 00049 const TQString mOriginal; 00050 TQString mFiltered; 00051 }; 00052 00053 class SpellingFilter::TextCensor : public LinkLocator 00054 { 00055 public: 00056 TextCensor(const TQString& s); 00057 00058 void censorQuotations(const TQString& quotePrefix); 00059 void censorUrls(); 00060 void censorEmailAddresses(); 00061 void censorString(const TQString& s); 00062 00063 TQString censoredText() const; 00064 00065 private: 00066 bool atLineStart() const; 00067 void skipLine(); 00068 00069 bool atQuotation(const TQString& quotePrefix) const; 00070 void skipQuotation(const TQString& quotePrefix); 00071 void findQuotation(const TQString& quotePrefix); 00072 00073 void findEmailAddress(); 00074 }; 00075 00076 #endif // SPELLINGFILTER_H_INCLUDED 00077