Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #ifndef MWAW_CONTENT_LISTENER_H
00035 #define MWAW_CONTENT_LISTENER_H
00036
00037 #include <vector>
00038
00039 #include <libwpd/libwpd.h>
00040
00041 #include "libmwaw_internal.hxx"
00042
00043 #include "MWAWListener.hxx"
00044
00045 class MWAWCell;
00046 class MWAWGraphicStyle;
00047 class MWAWGraphicShape;
00048 class MWAWTable;
00049
00050 namespace MWAWContentListenerInternal
00051 {
00052 struct DocumentState;
00053 struct State;
00054 }
00055
00057 class MWAWContentListener : public MWAWListener
00058 {
00059 public:
00061 MWAWContentListener(MWAWParserState &parserState, std::vector<MWAWPageSpan> const &pageList, WPXDocumentInterface *documentInterface);
00063 virtual ~MWAWContentListener();
00064
00066 void setDocumentLanguage(std::string locale);
00067
00069 void startDocument();
00071 void endDocument(bool sendDelayedSubDoc=true);
00073 bool isDocumentStarted() const;
00074
00076 void handleSubDocument(MWAWSubDocumentPtr subDocument, libmwaw::SubDocumentType subDocumentType);
00078 bool isSubDocumentOpened(libmwaw::SubDocumentType &subdocType) const;
00079
00081 bool canWriteText() const {
00082 return MWAWContentListener::isDocumentStarted();
00083 }
00084
00085
00087 bool isPageSpanOpened() const;
00091 MWAWPageSpan const &getPageSpan();
00092
00093
00095 bool insertHeader(MWAWSubDocumentPtr subDocument, WPXPropertyList const &extras);
00097 bool insertFooter(MWAWSubDocumentPtr subDocument, WPXPropertyList const &extras);
00099 bool isHeaderFooterOpened() const;
00100
00101
00102
00104 void insertChar(uint8_t character);
00107 void insertCharacter(unsigned char c);
00113 int insertCharacter(unsigned char c, MWAWInputStreamPtr &input, long endPos=-1);
00116 void insertUnicode(uint32_t character);
00118 void insertUnicodeString(WPXString const &str);
00119
00121 void insertTab();
00123 void insertEOL(bool softBreak=false);
00124
00125
00127 void setFont(MWAWFont const &font);
00129 MWAWFont const &getFont() const;
00130
00131
00133 bool isParagraphOpened() const;
00135 void setParagraph(MWAWParagraph const ¶graph);
00137 MWAWParagraph const &getParagraph() const;
00138
00139
00141 void insertField(MWAWField const &field);
00142
00143
00145 void insertNote(MWAWNote const ¬e, MWAWSubDocumentPtr &subDocument);
00146
00148 void insertComment(MWAWSubDocumentPtr &subDocument);
00149
00151 void insertPicture(MWAWPosition const &pos, const WPXBinaryData &binaryData,
00152 std::string type="image/pict",
00153 WPXPropertyList frameExtras=WPXPropertyList());
00155 void insertPicture(MWAWPosition const &pos, MWAWGraphicShape const &shape,
00156 MWAWGraphicStyle const &style);
00158 void insertTextBox(MWAWPosition const &pos, MWAWSubDocumentPtr subDocument,
00159 WPXPropertyList frameExtras=WPXPropertyList(),
00160 WPXPropertyList textboxExtras=WPXPropertyList());
00161
00162
00164 void openTable(MWAWTable const &table, WPXPropertyList tableExtras=WPXPropertyList());
00166 void closeTable();
00168 void openTableRow(float h, WPXUnit unit, bool headerRow=false);
00170 void closeTableRow();
00172 void openTableCell(MWAWCell const &cell);
00174 void closeTableCell();
00176 void addEmptyTableCell(Vec2i const &pos, Vec2i span=Vec2i(1,1));
00177
00178
00180 bool canOpenSectionAddBreak() const;
00182 bool isSectionOpened() const;
00184 MWAWSection const &getSection() const;
00186 bool openSection(MWAWSection const §ion);
00188 bool closeSection();
00190 void insertBreak(BreakType breakType);
00191
00192 protected:
00193 void _openSection();
00194 void _closeSection();
00195
00196 void _openPageSpan(bool sendHeaderFooters=true);
00197 void _closePageSpan();
00198
00199 void _startSubDocument();
00200 void _endSubDocument();
00201
00202 void _handleFrameParameters( WPXPropertyList &propList, MWAWPosition const &pos);
00203 bool openFrame(MWAWPosition const &pos, WPXPropertyList extras=WPXPropertyList());
00204 void closeFrame();
00205
00206
00207 void _openParagraph();
00208 void _closeParagraph();
00209 void _appendParagraphProperties(WPXPropertyList &propList, const bool isListElement=false);
00210 void _resetParagraphState(const bool isListElement=false);
00211
00213 void _openListElement();
00215 void _closeListElement();
00217 void _changeList();
00222 int _getListId() const;
00223
00224 void _openSpan();
00225 void _closeSpan();
00226
00227 void _flushText();
00228 void _flushDeferredTabs();
00229
00230 void _insertBreakIfNecessary(WPXPropertyList &propList);
00231
00235 shared_ptr<MWAWContentListenerInternal::State> _pushParsingState();
00237 void _popParsingState();
00238
00239 protected:
00241 shared_ptr<MWAWContentListenerInternal::DocumentState> m_ds;
00243 shared_ptr<MWAWContentListenerInternal::State> m_ps;
00245 std::vector<shared_ptr<MWAWContentListenerInternal::State> > m_psStack;
00247 MWAWParserState &m_parserState;
00249 WPXDocumentInterface *m_documentInterface;
00250
00251 private:
00252 MWAWContentListener(const MWAWContentListener &);
00253 MWAWContentListener &operator=(const MWAWContentListener &);
00254 };
00255
00256 #endif
00257