00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef DOCUMENT_H
00021 #define DOCUMENT_H
00022
00023 #include "tablehandler.h"
00024
00025 #include <wv2/handlers.h>
00026 #include <wv2/functor.h>
00027
00028 #include <qstring.h>
00029 #include <qdom.h>
00030 #include <qobject.h>
00031 #include <qstringlist.h>
00032
00033 #include <queue>
00034 #include <string>
00035
00036 class KoStoreDevice;
00037 class KoSize;
00038
00039 namespace wvWare {
00040 class Parser;
00041 namespace Word97 {
00042 class BRC;
00043 }
00044 }
00045 class KoRect;
00046 class KoFilterChain;
00047 class KWordReplacementHandler;
00048 class KWordTableHandler;
00049 class KWordPictureHandler;
00050 class KWordTextHandler;
00051
00052 class Document : public QObject, public wvWare::SubDocumentHandler
00053 {
00054 Q_OBJECT
00055 public:
00056 Document( const std::string& fileName, QDomDocument& mainDocument, QDomDocument &documentInfo, QDomElement& framesetsElement, KoFilterChain* chain );
00057 virtual ~Document();
00058
00059 bool hasParser() const { return m_parser != 0L; }
00060 bool bodyFound() const { return m_bodyFound; }
00061
00062 virtual void bodyStart();
00063 virtual void bodyEnd();
00064
00065 virtual void headerStart( wvWare::HeaderData::Type type );
00066 virtual void headerEnd();
00067
00068 virtual void footnoteStart();
00069 virtual void footnoteEnd();
00070
00071 bool parse();
00072
00073 void processSubDocQueue();
00074
00075 void finishDocument();
00076
00077 typedef const wvWare::FunctorBase* FunctorPtr;
00078 struct SubDocument
00079 {
00080 SubDocument( FunctorPtr ptr, int d, const QString& n, const QString& extra )
00081 : functorPtr(ptr), data(d), name(n), extraName(extra) {}
00082 ~SubDocument() {}
00083 FunctorPtr functorPtr;
00084 int data;
00085 QString name;
00086 QString extraName;
00087 };
00088
00089
00090 KoStoreDevice* createPictureFrameSet( const KoSize& size );
00091
00092 protected slots:
00093
00094 void slotFirstSectionFound( wvWare::SharedPtr<const wvWare::Word97::SEP> );
00095
00096
00097
00098 void slotSubDocFound( const wvWare::FunctorBase* functor, int data );
00099
00100
00101 void slotTableFound( const KWord::Table& table );
00102
00103
00104 void slotPictureFound( const QString& frameName, const QString& pictureName, const wvWare::FunctorBase* );
00105
00106
00107
00108 void slotTableCellStart( int row, int column, int rowSize, int columnSize, const KoRect& cellRect, const QString& tableName, const wvWare::Word97::BRC& brcTop, const wvWare::Word97::BRC& brcBottom, const wvWare::Word97::BRC& brcLeft, const wvWare::Word97::BRC& brcRight, const wvWare::Word97::SHD& shd );
00109 void slotTableCellEnd();
00110
00111 private:
00112 void processStyles();
00113 void processAssociatedStrings();
00114 enum NewFrameBehavior { Reconnect=0, NoFollowup=1, Copy=2 };
00115 QDomElement createInitialFrame( QDomElement& parentFramesetElem, double left, double right, double top, double bottom, bool autoExtend, NewFrameBehavior nfb );
00116 void generateFrameBorder( QDomElement& frameElementOut, const wvWare::Word97::BRC& brcTop, const wvWare::Word97::BRC& brcBottom, const wvWare::Word97::BRC& brcLeft, const wvWare::Word97::BRC& brcRight, const wvWare::Word97::SHD& shd );
00117
00118 QDomDocument& m_mainDocument;
00119 QDomDocument& m_documentInfo;
00120 QDomElement& m_framesetsElement;
00121 KWordReplacementHandler* m_replacementHandler;
00122 KWordTableHandler* m_tableHandler;
00123 KWordPictureHandler* m_pictureHandler;
00124 KWordTextHandler* m_textHandler;
00125 KoFilterChain* m_chain;
00126 wvWare::SharedPtr<wvWare::Parser> m_parser;
00127 std::queue<SubDocument> m_subdocQueue;
00128 std::queue<KWord::Table> m_tableQueue;
00129 QStringList m_pictureList;
00130 unsigned char m_headerFooters;
00131 bool m_bodyFound;
00132 int m_footNoteNumber;
00133 int m_endNoteNumber;
00134 };
00135
00136 #endif // DOCUMENT_H