Back to index

scribus-ng  1.3.4.dfsg+svn20071115
csvim.h
Go to the documentation of this file.
00001 /*
00002 For general Scribus (>=1.3.2) copyright and licensing information please refer
00003 to the COPYING file provided with the program. Following this notice may exist
00004 a copyright and/or license notice that predates the release of Scribus 1.3.2
00005 for which a new license (GPL+exception) is in place.
00006 */
00007 #ifndef CSVIM_H
00008 #define CSVIM_H
00009 
00010 #include "pluginapi.h"
00011 #include "csvdia.h"
00012 #include <gtwriter.h>
00013 #include <gtparagraphstyle.h>
00014 #include <qcstring.h>
00015 #include <qfile.h>
00016 #include <qfileinfo.h>
00017 #include <qstring.h>
00018 #include <qstringlist.h>
00019 #include <qtextcodec.h>
00020 
00021 extern "C" PLUGIN_API void GetText(QString filename, QString encoding, bool textOnly, gtWriter *writer);
00022 
00023 extern "C" PLUGIN_API QString FileFormatName();
00024 
00025 extern "C" PLUGIN_API QStringList FileExtensions();
00026 
00027 class CsvIm 
00028 {
00029 public:
00030        CsvIm(const QString& fname, const QString& enc, gtWriter *w, const QString& fdelim = ",",
00031           const QString& vdelim = "\"", bool header = false, bool usevdelim = true);
00032        ~CsvIm();
00033        void setFieldDelimiter(const QString& fdelim);
00034        void setValueDelimiter(const QString& vdelim);
00035        void write();
00036 private:
00037        QString fieldDelimiter;
00038        QString valueDelimiter;
00039        bool hasHeader;
00040        bool useVDelim;
00041        QString filename;
00042        QString encoding;
00043        gtWriter *writer;
00044        QString header;
00045        QString data;
00046        int rowNumber;
00047        int colIndex;
00048        int colCount;
00049        gtParagraphStyle *pstyleData;
00050        gtParagraphStyle *pstyleHeader;
00051        void loadFile();
00052        void parseLine(const QString& line, bool isHeader);
00053        QString toUnicode(const QString& text);
00054        void setupPStyles();
00055        void setupTabulators();
00056 };
00057 
00058 #endif // CSVIM_H