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 insertObject(WPSPosition const &pos, const WPSEmbeddedObject &obj,
00114 librevenge::RVNGPropertyList frameExtras=librevenge::RVNGPropertyList());
00115
00117 void insertTextBox(WPSPosition const &pos, WPSSubDocumentPtr subDocument,
00118 librevenge::RVNGPropertyList frameExtras=librevenge::RVNGPropertyList());
00119
00120
00121
00123 void openTable(std::vector<float> const &colWidth, librevenge::RVNGUnit unit);
00125 void closeTable();
00127 void openTableRow(float h, librevenge::RVNGUnit unit, bool headerRow=false);
00129 void closeTableRow();
00133 void openTableCell(WPSCell const &cell, librevenge::RVNGPropertyList const &extras=librevenge::RVNGPropertyList());
00135 void closeTableCell();
00137 void addEmptyTableCell(Vec2i const &pos, Vec2i span=Vec2i(1,1));
00138
00139
00141 bool isSectionOpened() const;
00143 int getSectionNumColumns() const;
00145 bool openSection(std::vector<int> colsWidth=std::vector<int>(), librevenge::RVNGUnit unit=librevenge::RVNG_INCH);
00147 bool closeSection();
00148
00149 protected:
00150 void _openSection();
00151 void _closeSection();
00152
00153 void _openPageSpan();
00154 void _closePageSpan();
00155 void _updatePageSpanDependent(bool set);
00156
00157 void _startSubDocument();
00158 void _endSubDocument();
00159
00160 void _handleFrameParameters(librevenge::RVNGPropertyList &propList, WPSPosition const &pos);
00161 bool _openFrame(WPSPosition const &pos, librevenge::RVNGPropertyList extras=librevenge::RVNGPropertyList());
00162 void _closeFrame();
00163
00164 void _openParagraph();
00165 void _closeParagraph();
00166 void _appendParagraphProperties(librevenge::RVNGPropertyList &propList, const bool isListElement=false);
00167 void _resetParagraphState(const bool isListElement=false);
00168
00169 void _openListElement();
00170 void _closeListElement();
00171 void _changeList();
00172
00173 void _openSpan();
00174 void _closeSpan();
00175
00176 void _flushText();
00177 void _flushDeferredTabs();
00178
00179 void _insertBreakIfNecessary(librevenge::RVNGPropertyList &propList);
00180
00184 shared_ptr<WPSContentParsingState> _pushParsingState();
00186 void _popParsingState();
00187
00188 protected:
00189 shared_ptr<WPSDocumentParsingState> m_ds;
00190 shared_ptr<WPSContentParsingState> m_ps;
00191 std::vector<shared_ptr<WPSContentParsingState> > m_psStack;
00192 librevenge::RVNGTextInterface *m_documentInterface;
00193
00194 private:
00195 WPSContentListener(const WPSContentListener &);
00196 WPSContentListener &operator=(const WPSContentListener &);
00197 };
00198
00199 #endif
00200