File indexing completed on 2024-05-19 05:41:15
0001 #ifndef OOREADER_H 0002 #define OOREADER_H 0003 #include <QDebug> 0004 #include <QNetworkAccessManager> 0005 #include <QtCore> 0006 #include <QtGui> 0007 #include <iostream> 0008 #include <stdio.h> 0009 0010 #include <QDomDocument> 0011 #include <QTextTableFormat> 0012 0013 #include "editors/noteeditor/format_OO_oasis_/FoColorName.h" 0014 #include "editors/noteeditor/format_OO_oasis_/OOFormat.h" 0015 0016 #include "rwidgets_global.h" 0017 QMap<QString, QByteArray> unzipstream(const QString file); 0018 0019 class RWIDGET_EXPORT PushDoc : public QThread 0020 { 0021 public: 0022 PushDoc(QObject* parent) : QThread(parent) { setTerminationEnabled(true); } 0023 0024 protected: 0025 void run() { exec(); } 0026 }; 0027 0028 class RWIDGET_EXPORT ChildImport : public QXmlStreamReader 0029 { 0030 public: 0031 ChildImport(QIODevice* device= 0); 0032 /* copy all subelement from reader to writer out */ 0033 void copyDeep(QIODevice* device, QXmlStreamWriter& out); 0034 }; 0035 0036 class RWIDGET_EXPORT LoadGetImage : public QObject 0037 { 0038 Q_OBJECT 0039 // 0040 public: 0041 LoadGetImage(const QString nr, QUrl url_send); 0042 void Start(); 0043 // inline int Htpp_id() { return Http_id; } 0044 inline QPixmap pics() { return resultimage; } 0045 QString cid; 0046 // int Http_id; 0047 QUrl url; 0048 QPixmap resultimage; 0049 signals: 0050 void take(QString); 0051 public slots: 0052 void ImageReady(QNetworkReply* reply); 0053 0054 private: 0055 QNetworkAccessManager* m_manager; 0056 }; 0057 0058 class RWIDGET_EXPORT Gloader : public QThread 0059 { 0060 Q_OBJECT 0061 0062 public: 0063 void Setting(QObject* parent, const QString id, QUrl url_send); 0064 0065 protected: 0066 void run(); 0067 signals: 0068 private: 0069 QString cid; 0070 QUrl url; 0071 LoadGetImage* Rhttp; 0072 QObject* receiver; 0073 }; 0074 0075 class ReadWriteBuf; 0076 class RWIDGET_EXPORT OOReader : public OOFormat 0077 { 0078 Q_OBJECT 0079 // 0080 public: 0081 enum WIDGEDEST 0082 { 0083 otextedit, 0084 ographicview, 0085 otextbrowser, 0086 opanel, 0087 ounknowwidged= 404 0088 }; 0089 0090 OOReader(const QString file= QString(), WIDGEDEST e= otextbrowser, QObject* parent= 0); 0091 QTextDocument* document() { return Qdoc->clone(); } /* only body */ 0092 #ifdef _OOREADRELEASE_ 0093 QString debugStyle() 0094 { 0095 return debugline; 0096 } 0097 #endif 0098 QMap<QString, QTextDocument*> option() 0099 { 0100 return lateral; 0101 } /* header footer fo region */ 0102 0103 enum STYLETYPE 0104 { 0105 opara= 100, /* paragraph - block */ 0106 ochar= 200, /* span fragment */ 0107 otable= 300, /* table body footer */ 0108 ocell= 400, /* table cell */ 0109 oframe= 500, /* inline frame */ 0110 oabsoluteframe= 600, /* floating absolute*/ 0111 obodypage= 1000, /* body size */ 0112 obefore= 2000, /* header */ 0113 oafter= 3000, /* footer*/ 0114 ostart= 4000, /* left area */ 0115 oend= 5000, /* right area*/ 0116 ounknow= 10000 0117 }; 0118 0119 struct StyleInfo 0120 { 0121 StyleInfo(); 0122 StyleInfo(const StyleInfo& d); 0123 StyleInfo& operator=(const StyleInfo& d); 0124 QString name; 0125 uint position; 0126 QTextFormat of; 0127 OOReader::STYLETYPE type; 0128 QByteArray chunk; 0129 QString css; 0130 bool valid; 0131 bool filled; 0132 QTextCharFormat ofchar; 0133 }; 0134 0135 protected: 0136 void openStreams(QMap<QString, QByteArray> list); /* unzipped file */ 0137 QString odtzipfile; 0138 int maxStyleCount; 0139 int styleCurrentCount; 0140 uint charsRead; 0141 bool QTWRITTELN; 0142 WIDGEDEST construct_modus; 0143 int sumOfBlocks; 0144 QString fileHash; 0145 int fontTotal; 0146 0147 QMap<int, QTextDocument*> layerlist; /* absolute layer having y,x */ 0148 QMap<QString, QTextDocument*> lateral; /* header footer fo region */ 0149 QMap<QString, StyleInfo> css2; /* all oo style name */ 0150 QMap<QString, QByteArray> filist; /* all file from zip oo */ 0151 QMap<QString, QDomElement> fontname; 0152 QFont standardFont; 0153 QDomDocument bodyStarter; 0154 bool DocInitContruct; 0155 qreal FontMaxPoint; 0156 qreal FontMinPoint; 0157 int imageCurrentCount; 0158 0159 private: 0160 void registerFontDoc(const QDomElement& element); 0161 void styleNameSetup(const QByteArray chunk, const QString label); 0162 void convertStyleNameRoot(const QDomElement& element); 0163 bool convertBody(const QDomElement& element); 0164 bool iterateElements(const QDomElement e, QTextCursor& cur, const int processing); 0165 bool convertTable(QTextCursor& cur, const QDomElement e, const int processing, bool roottable= false); 0166 bool convertCellTable(const QDomElement e, QTextCursor& cur, const int processing); 0167 bool convertBlock(QTextCursor& cur, QDomElement e, const int processing); 0168 bool convertList(QTextCursor& cur, QDomElement e, const int processing, int level= 1, 0169 const QString classname= QString("deafult")); 0170 bool convertFragment(QTextCursor& cur, const QDomElement e, QTextCharFormat parent= QTextCharFormat(), 0171 bool HandleSpace= false); 0172 bool convertSpaceTag(QTextCursor& cur, const QDomElement e, QTextCharFormat parent, bool HandleSpace= false); 0173 void insertTextLine(QTextCursor& cur, QStringList line, QTextCharFormat parent= QTextCharFormat(), 0174 bool HandleSpace= false); 0175 bool convertFrame(QTextCursor& cur, const QDomElement e, QTextCharFormat parent, bool HandleSpace); 0176 bool convertImage(QTextCursor& cur, const QDomElement e, QTextCharFormat parent, bool HandleSpace= false); 0177 QTextFrameFormat FrameFormat(const QString name); /* format from css name class */ 0178 /* read css2 format */ 0179 QTextCharFormat charFormatCss2(const QString name, QTextCharFormat parent= QTextCharFormat(), 0180 bool HandleSpace= false); 0181 QPair<QTextBlockFormat, QTextCharFormat> 0182 paraFormatCss2(const QString name, QTextBlockFormat parent= QTextBlockFormat(), bool HandleSpace= false); 0183 0184 /* formats fill */ 0185 void TextBlockFormatPaint(const QString name, const QDomElement e); 0186 void TextCharFormatPaint(const QString name, const QDomElement e); 0187 void TextListFormatPaint(const QString name, const QDomElement e); 0188 void FrameImageFormatPaint(const QString name, const QDomElement e); /* image / frame */ 0189 /* table column cell row format container + unknow */ 0190 void UnknowFormatPaint(const QString name, const QString style_name, const QDomElement e); 0191 0192 QTextBlockFormat TextBlockFormFromDom(const QDomElement e, QTextBlockFormat pf= QTextBlockFormat()); 0193 QTextCharFormat TextCharFormFromDom(const QDomElement e, QTextCharFormat pf= QTextCharFormat()); 0194 Qt::Alignment TagAlignElement(const QDomElement e); 0195 QString debugline; 0196 signals: 0197 void statusRead(int, int); 0198 void setError(QString); 0199 void ready(); 0200 0201 public slots: 0202 void reset(); /* abort or new file next */ 0203 void read(); 0204 private slots: 0205 void ReadBody(); 0206 void in_image(const QString imagename); 0207 }; 0208 0209 // 0210 #endif // OOREADER_H