| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
#ifndef WPSCONTENTLISTENER_H |
| 26 |
#define WPSCONTENTLISTENER_H |
| 27 |
|
| 28 |
#include <vector> |
| 29 |
|
| 30 |
#include <librevenge/librevenge.h> |
| 31 |
|
| 32 |
#include "libwps_internal.h" |
| 33 |
|
| 34 |
#include "WPSListener.h" |
| 35 |
|
| 36 |
class WPSList; |
| 37 |
class WPSPageSpan; |
| 38 |
struct WPSParagraph; |
| 39 |
struct WPSTabStop; |
| 40 |
|
| 41 |
struct WPSContentParsingState; |
| 42 |
struct WPSDocumentParsingState; |
| 43 |
|
| 44 |
class WPSContentListener final : public WPSListener |
| 45 |
{ |
| 46 |
public: |
| 47 |
WPSContentListener(std::vector<WPSPageSpan> const &pageList, librevenge::RVNGTextInterface *documentInterface); |
| 48 |
~WPSContentListener() final; |
| 49 |
|
| 50 |
void setDocumentLanguage(int lcid) final; |
| 51 |
void setMetaData(const librevenge::RVNGPropertyList &list); |
| 52 |
|
| 53 |
void startDocument(); |
| 54 |
void endDocument(); |
| 55 |
void handleSubDocument(WPSSubDocumentPtr &subDocument, libwps::SubDocumentType subDocumentType); |
| 56 |
bool isHeaderFooterOpened() const; |
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
void insertCharacter(uint8_t character) final; |
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
void insertUnicode(uint32_t character) final; |
| 66 |
|
| 67 |
void insertUnicodeString(librevenge::RVNGString const &str) final; |
| 68 |
|
| 69 |
void insertTab() final; |
| 70 |
void insertEOL(bool softBreak=false) final; |
| 71 |
void insertBreak(const uint8_t breakType) final; |
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
void setFont(const WPSFont &font) final; |
| 76 |
|
| 77 |
WPSFont const &getFont() const final; |
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
bool isParagraphOpened() const final; |
| 82 |
|
| 83 |
void setParagraph(const WPSParagraph ¶) final; |
| 84 |
|
| 85 |
WPSParagraph const &getParagraph() const final; |
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
void setCurrentList(std::shared_ptr<WPSList> list); |
| 90 |
|
| 91 |
std::shared_ptr<WPSList> getCurrentList() const; |
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
void insertField(WPSField const &field) final; |
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
enum NoteType { FOOTNOTE, ENDNOTE }; |
| 100 |
|
| 101 |
void insertNote(const NoteType noteType, WPSSubDocumentPtr &subDocument); |
| 102 |
|
| 103 |
void insertLabelNote(const NoteType noteType, librevenge::RVNGString const &label, WPSSubDocumentPtr &subDocument); |
| 104 |
|
| 105 |
void insertComment(WPSSubDocumentPtr &subDocument); |
| 106 |
|
| 107 |
|
| 108 |
void insertPicture(WPSPosition const &pos, const librevenge::RVNGBinaryData &binaryData, |
| 109 |
std::string const &type="image/pict", |
| 110 |
librevenge::RVNGPropertyList frameExtras=librevenge::RVNGPropertyList()); |
| 111 |
|
| 112 |
void insertObject(WPSPosition const &pos, const WPSEmbeddedObject &obj, |
| 113 |
librevenge::RVNGPropertyList frameExtras=librevenge::RVNGPropertyList()); |
| 114 |
|
| 115 |
|
| 116 |
void insertTextBox(WPSPosition const &pos, WPSSubDocumentPtr subDocument, |
| 117 |
librevenge::RVNGPropertyList frameExtras=librevenge::RVNGPropertyList()); |
| 118 |
|
| 119 |
bool openGroup(WPSPosition const &pos) final; |
| 120 |
|
| 121 |
void closeGroup() final; |
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
void openTable(std::vector<float> const &colWidth, librevenge::RVNGUnit unit); |
| 126 |
|
| 127 |
void closeTable(); |
| 128 |
|
| 129 |
void openTableRow(float h, librevenge::RVNGUnit unit, bool headerRow=false); |
| 130 |
|
| 131 |
void closeTableRow(); |
| 132 |
|
| 133 |
|
| 134 |
|
| 135 |
void openTableCell(WPSCell const &cell, librevenge::RVNGPropertyList const &extras=librevenge::RVNGPropertyList()); |
| 136 |
|
| 137 |
void closeTableCell(); |
| 138 |
|
| 139 |
void addEmptyTableCell(Vec2i const &pos, Vec2i span=Vec2i(1,1)); |
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
bool isSectionOpened() const; |
| 144 |
|
| 145 |
int getSectionNumColumns() const; |
| 146 |
|
| 147 |
bool openSection(std::vector<int> colsWidth=std::vector<int>(), librevenge::RVNGUnit unit=librevenge::RVNG_INCH); |
| 148 |
|
| 149 |
bool closeSection(); |
| 150 |
|
| 151 |
protected: |
| 152 |
void _openSection(); |
| 153 |
void _closeSection(); |
| 154 |
|
| 155 |
void _openPageSpan(); |
| 156 |
void _closePageSpan(); |
| 157 |
void _updatePageSpanDependent(bool set); |
| 158 |
|
| 159 |
void _startSubDocument(); |
| 160 |
void _endSubDocument(); |
| 161 |
|
| 162 |
void _handleFrameParameters(librevenge::RVNGPropertyList &propList, WPSPosition const &pos); |
| 163 |
bool _openFrame(WPSPosition const &pos, librevenge::RVNGPropertyList extras=librevenge::RVNGPropertyList()); |
| 164 |
void _closeFrame(); |
| 165 |
|
| 166 |
void _openParagraph(); |
| 167 |
void _closeParagraph(); |
| 168 |
void _appendParagraphProperties(librevenge::RVNGPropertyList &propList, const bool isListElement=false); |
| 169 |
void _resetParagraphState(const bool isListElement=false); |
| 170 |
|
| 171 |
void _openListElement(); |
| 172 |
void _closeListElement(); |
| 173 |
void _changeList(); |
| 174 |
|
| 175 |
void _openSpan(); |
| 176 |
void _closeSpan(); |
| 177 |
|
| 178 |
void _flushText(); |
| 179 |
void _flushDeferredTabs(); |
| 180 |
|
| 181 |
void _insertBreakIfNecessary(librevenge::RVNGPropertyList &propList); |
| 182 |
|
| 183 |
|
| 184 |
|
| 185 |
|
| 186 |
std::shared_ptr<WPSContentParsingState> _pushParsingState(); |
| 187 |
|
| 188 |
void _popParsingState(); |
| 189 |
|
| 190 |
protected: |
| 191 |
std::shared_ptr<WPSDocumentParsingState> m_ds; |
| 192 |
std::shared_ptr<WPSContentParsingState> m_ps; |
| 193 |
std::vector<std::shared_ptr<WPSContentParsingState> > m_psStack; |
| 194 |
librevenge::RVNGTextInterface *m_documentInterface; |
| 195 |
|
| 196 |
private: |
| 197 |
WPSContentListener(const WPSContentListener &); |
| 198 |
WPSContentListener &operator=(const WPSContentListener &); |
| 199 |
}; |
| 200 |
|
| 201 |
#endif |
| 202 |
|