asciiimport.h
1/* This file is part of the KDE project
2 Copyright (C) 1998, 1999 Reginald Stadlbauer <reggie@kde.org>
3 Copyright (C) 2000 Michael Johnson <mikej@xnet.com>
4 Copyright (C) 2001, 2002 Nicolas GOUTTE <goutte@kde.org>
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
15
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
20*/
21
22#ifndef ASCIIIMPORT_H
23#define ASCIIIMPORT_H
24
25#include <KoFilter.h>
26
27class TQString;
28class TQTextStream;
29class TQDomDocument;
30class TQDomElement;
31
32#define MAXLINES 1000
33#define MAXCOLUMNS 15
34
35 const double ptsperline = 15.0;
36 const double ptsperchar = 6.0;
37 const int spacespertab = 6;
38 const double leftmargin = 56.0;
39
40 const uint shortline = 40; // max length of a "short" line
41
42 struct Tabs
43 {
44 int columns;
45 int indent;
46 TQString field[MAXCOLUMNS];
47 int width[MAXCOLUMNS];
48 };
49
50 struct Position
51 {
52 double top;
53 double left;
54 double bottom;
55 double right;
56 };
57
58class ASCIIImport : public KoFilter {
59
60 TQ_OBJECT
61
62
63public:
64 ASCIIImport(KoFilter *parent, const char *name, const TQStringList &);
65 ASCIIImport();
66 virtual ~ASCIIImport() {}
67
68 virtual KoFilter::ConversionStatus convert( const TQCString& from, const TQCString& to );
69private: // not yet changed
70#if 0
71 void WriteOutTableCell( int table_no, int row, int col, Position *pos,
72 TQString &str);
73
74 bool Table( TQString *Line, int *linecount, int no_lines,
75 int table_no, TQString &tbl, TQString &str );
76
77
78
79 bool ListItem( TQString *Line, int no_lines,
80 TQString &str );
81#endif
82 bool IsListItem( TQString FirstLine, TQChar mark );
83
84private:
85 void prepareDocument(TQDomDocument& mainDocument, TQDomElement& mainFramesetElement);
86 void processParagraph(TQDomDocument& mainDocument,
87 TQDomElement& mainFramesetElement, const TQStringList& paragraph);
88 void writeOutParagraph(TQDomDocument& mainDocument,
89 TQDomElement& mainFramesetElement, const TQString& name,
90 const TQString& text, const int firstindent, const int secondindent);
91 int Indent(const TQString& line) const;
92 int MultSpaces(const TQString& text, const int index) const;
93 bool IsWhiteSpace(const TQChar& c) const;
94 TQString readLine(TQTextStream& textstream, bool& lastCharWasCr);
95private: // converting functions
96 void oldWayConvert(TQTextStream& stream, TQDomDocument& mainDocument,
97 TQDomElement& mainFramesetElement);
98 void asIsConvert(TQTextStream& stream, TQDomDocument& mainDocument,
99 TQDomElement& mainFramesetElement);
100 void sentenceConvert(TQTextStream& stream, TQDomDocument& mainDocument,
101 TQDomElement& mainFramesetElement);
102};
103#endif // ASCIIIMPORT_H
This class hold a table.