filters

asciiimport.h

00001 /* This file is part of the KDE project
00002    Copyright (C) 1998, 1999 Reginald Stadlbauer <reggie@kde.org>
00003    Copyright (C) 2000 Michael Johnson <mikej@xnet.com>
00004    Copyright (C) 2001, 2002 Nicolas GOUTTE <goutte@kde.org>
00005 
00006    This library is free software; you can redistribute it and/or
00007    modify it under the terms of the GNU Library General Public
00008    License as published by the Free Software Foundation; either
00009    version 2 of the License, or (at your option) any later version.
00010 
00011    This library is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014    Library General Public License for more details.
00015 
00016    You should have received a copy of the GNU Library General Public License
00017    along with this library; see the file COPYING.LIB.  If not, write to
00018    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00019  * Boston, MA 02110-1301, USA.
00020 */
00021 
00022 #ifndef ASCIIIMPORT_H
00023 #define ASCIIIMPORT_H
00024 
00025 #include <KoFilter.h>
00026 
00027 class QString;
00028 class QTextStream;
00029 class QDomDocument;
00030 class QDomElement;
00031 
00032 #define MAXLINES  1000
00033 #define MAXCOLUMNS 15
00034 
00035  const double ptsperline = 15.0;
00036  const double ptsperchar = 6.0;
00037  const int spacespertab = 6;
00038  const double leftmargin = 56.0;
00039 
00040  const uint shortline = 40;  // max length of a "short" line
00041 
00042  struct Tabs
00043     {
00044     int columns;
00045     int indent;
00046     QString field[MAXCOLUMNS];
00047     int width[MAXCOLUMNS];
00048     };
00049 
00050  struct Position
00051     {
00052     double top;
00053     double left;
00054     double bottom;
00055     double right;
00056     };
00057 
00058 class ASCIIImport : public KoFilter {
00059 
00060     Q_OBJECT
00061 
00062 public:
00063     ASCIIImport(KoFilter *parent, const char *name, const QStringList &);
00064     ASCIIImport();
00065     virtual ~ASCIIImport() {}
00066 
00067     virtual KoFilter::ConversionStatus convert( const QCString& from, const QCString& to );
00068 private: // not yet changed
00069 #if 0
00070     void WriteOutTableCell( int table_no, int row, int col, Position *pos,
00071                           QString &str);
00072 
00073     bool Table( QString *Line, int *linecount, int no_lines,
00074             int table_no, QString &tbl, QString &str );
00075 
00076 
00077 
00078     bool ListItem( QString *Line, int no_lines,
00079              QString &str );
00080 #endif
00081     bool IsListItem( QString FirstLine, QChar mark );
00082 
00083 private:
00084     void prepareDocument(QDomDocument& mainDocument, QDomElement& mainFramesetElement);
00085     void processParagraph(QDomDocument& mainDocument,
00086         QDomElement& mainFramesetElement, const QStringList& paragraph);
00087     void writeOutParagraph(QDomDocument& mainDocument,
00088         QDomElement& mainFramesetElement,  const QString& name,
00089         const QString& text, const int firstindent, const int secondindent);
00090     int Indent(const QString& line) const;
00091     int MultSpaces(const QString& text, const int index) const;
00092     bool IsWhiteSpace(const QChar& c) const;
00093     QString readLine(QTextStream& textstream, bool& lastCharWasCr);
00094 private: // converting functions
00095     void oldWayConvert(QTextStream& stream, QDomDocument& mainDocument,
00096         QDomElement& mainFramesetElement);
00097     void asIsConvert(QTextStream& stream, QDomDocument& mainDocument,
00098         QDomElement& mainFramesetElement);
00099     void sentenceConvert(QTextStream& stream, QDomDocument& mainDocument,
00100         QDomElement& mainFramesetElement);
00101 };
00102 #endif // ASCIIIMPORT_H
KDE Home | KDE Accessibility Home | Description of Access Keys