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 #ifndef WPSCONTENTLISTENER_H
00026 #define WPSCONTENTLISTENER_H
00027
00028 #include <vector>
00029
00030 #include <librevenge/librevenge.h>
00031
00032 #include "libwps_internal.h"
00033
00034 #include "WPSListener.h"
00035
00036 class WPSList;
00037 class WPSPageSpan;
00038 struct WPSParagraph;
00039 struct WPSTabStop;
00040
00041 struct WPSContentParsingState;
00042 struct WPSDocumentParsingState;
00043
00044 class WPSContentListener : public WPSListener
00045 {
00046 public:
00047 WPSContentListener(std::vector<WPSPageSpan> const &pageList, librevenge::RVNGTextInterface *documentInterface);
00048 virtual ~WPSContentListener();
00049
00050 void setDocumentLanguage(int lcid);
00051
00052 void startDocument();
00053 void endDocument();
00054 void handleSubDocument(WPSSubDocumentPtr &subDocument, libwps::SubDocumentType subDocumentType);
00055 bool isHeaderFooterOpened() const;
00056
00057
00058
00060 void insertCharacter(uint8_t character);
00064 void insertUnicode(uint32_t character);
00066 void insertUnicodeString(librevenge::RVNGString const &str);
00067
00068 void insertTab();
00069 void insertEOL(bool softBreak=false);
00070 void insertBreak(const uint8_t breakType);
00071
00072
00074 void setFont(const WPSFont &font);
00076 WPSFont const &getFont() const;
00077
00078
00080 bool isParagraphOpened() const;
00082 void setParagraph(const WPSParagraph ¶);
00084 WPSParagraph const &getParagraph() const;
00085
00086
00088 void setCurrentList(shared_ptr<WPSList> list);
00090 shared_ptr<WPSList> getCurrentList() const;
00091
00092
00094 void insertField(FieldType type);
00096 void insertDateTimeField(char const *format);
00097
00098
00100 enum NoteType { FOOTNOTE, ENDNOTE };
00102 void insertNote(const NoteType noteType, WPSSubDocumentPtr &subDocument);
00104 void insertLabelNote(const NoteType noteType, librevenge::RVNGString const &label, WPSSubDocumentPtr &subDocument);
00106 void insertComment(WPSSubDocumentPtr &subDocument);
00107
00109 void insertPicture(WPSPosition const &pos, const librevenge::RVNGBinaryData &binaryData,
00110 std::string type="image/pict",
00111 librevenge::RVNGPropertyList frameExtras=librevenge::RVNGPropertyList());
00113 void insertTextBox(WPSPosition const &pos, WPSSubDocumentPtr subDocument,
00114 librevenge::RVNGPropertyList frameExtras=librevenge::RVNGPropertyList());
00115
00116
00117
00119 void openTable(std::vector<float> const &colWidth, librevenge::RVNGUnit unit);
00121 void closeTable();
00123 void openTableRow(float h, librevenge::RVNGUnit unit, bool headerRow=false);
00125 void closeTableRow();
00129 void openTableCell(WPSCell const &cell, librevenge::RVNGPropertyList const &extras=librevenge::RVNGPropertyList());
00131 void closeTableCell();
00133 void addEmptyTableCell(Vec2i const &pos, Vec2i span=Vec2i(1,1));
00134
00135
00137 bool isSectionOpened() const;
00139 int getSectionNumColumns() const;
00141 bool openSection(std::vector<int> colsWidth=std::vector<int>(), librevenge::RVNGUnit unit=librevenge::RVNG_INCH);
00143 bool closeSection();
00144
00145 protected:
00146 void _openSection();
00147 void _closeSection();
00148
00149 void _openPageSpan();
00150 void _closePageSpan();
00151 void _updatePageSpanDependent(bool set);
00152
00153 void _startSubDocument();
00154 void _endSubDocument();
00155
00156 void _handleFrameParameters(librevenge::RVNGPropertyList &propList, WPSPosition const &pos);
00157 bool _openFrame(WPSPosition const &pos, librevenge::RVNGPropertyList extras=librevenge::RVNGPropertyList());
00158 void _closeFrame();
00159
00160 void _openParagraph();
00161 void _closeParagraph();
00162 void _appendParagraphProperties(librevenge::RVNGPropertyList &propList, const bool isListElement=false);
00163 void _resetParagraphState(const bool isListElement=false);
00164
00165 void _openListElement();
00166 void _closeListElement();
00167 void _changeList();
00168
00169 void _openSpan();
00170 void _closeSpan();
00171
00172 void _flushText();
00173 void _flushDeferredTabs();
00174
00175 void _insertBreakIfNecessary(librevenge::RVNGPropertyList &propList);
00176
00180 shared_ptr<WPSContentParsingState> _pushParsingState();
00182 void _popParsingState();
00183
00184 protected:
00185 shared_ptr<WPSDocumentParsingState> m_ds;
00186 shared_ptr<WPSContentParsingState> m_ps;
00187 std::vector<shared_ptr<WPSContentParsingState> > m_psStack;
00188 librevenge::RVNGTextInterface *m_documentInterface;
00189
00190 private:
00191 WPSContentListener(const WPSContentListener &);
00192 WPSContentListener &operator=(const WPSContentListener &);
00193 };
00194
00195 #endif
00196