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
00040 #ifndef MWAW_TEXT_LISTENER_H
00041 #define MWAW_TEXT_LISTENER_H
00042
00043 #include <vector>
00044
00045 #include <librevenge/librevenge.h>
00046
00047 #include "libmwaw_internal.hxx"
00048 #include "MWAWGraphicStyle.hxx"
00049
00050 #include "MWAWListener.hxx"
00051
00052 class MWAWCell;
00053 class MWAWGraphicStyle;
00054 class MWAWGraphicShape;
00055 class MWAWTable;
00056
00057 namespace MWAWTextListenerInternal
00058 {
00059 struct DocumentState;
00060 struct State;
00061 }
00062
00064 class MWAWTextListener : public MWAWListener
00065 {
00066 public:
00068 MWAWTextListener(MWAWParserState &parserState, std::vector<MWAWPageSpan> const &pageList, librevenge::RVNGTextInterface *documentInterface);
00070 virtual ~MWAWTextListener();
00071
00073 Type getType() const
00074 {
00075 return Text;
00076 }
00077
00079 void setDocumentLanguage(std::string locale);
00080
00082 void startDocument();
00084 void endDocument(bool sendDelayedSubDoc=true);
00086 bool isDocumentStarted() const;
00087
00089 void handleSubDocument(MWAWSubDocumentPtr subDocument, libmwaw::SubDocumentType subDocumentType);
00091 bool isSubDocumentOpened(libmwaw::SubDocumentType &subdocType) const;
00093 bool openFrame(MWAWPosition const &pos, MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle());
00095 void closeFrame();
00096
00098 bool canWriteText() const
00099 {
00100 return MWAWTextListener::isDocumentStarted();
00101 }
00102
00103
00105 bool isPageSpanOpened() const;
00109 MWAWPageSpan const &getPageSpan();
00110
00111
00113 bool insertHeader(MWAWSubDocumentPtr subDocument, librevenge::RVNGPropertyList const &extras);
00115 bool insertFooter(MWAWSubDocumentPtr subDocument, librevenge::RVNGPropertyList const &extras);
00117 bool isHeaderFooterOpened() const;
00118
00119
00120
00122 void insertChar(uint8_t character);
00125 void insertCharacter(unsigned char c);
00131 int insertCharacter(unsigned char c, MWAWInputStreamPtr &input, long endPos=-1);
00134 void insertUnicode(uint32_t character);
00136 void insertUnicodeString(librevenge::RVNGString const &str);
00137
00139 void insertTab();
00141 void insertEOL(bool softBreak=false);
00142
00143
00145 void setFont(MWAWFont const &font);
00147 MWAWFont const &getFont() const;
00148
00149
00151 bool isParagraphOpened() const;
00153 void setParagraph(MWAWParagraph const ¶graph);
00155 MWAWParagraph const &getParagraph() const;
00156
00157
00159 void insertField(MWAWField const &field);
00160
00161
00163 void openLink(MWAWLink const &link);
00165 void closeLink();
00166
00167
00169 void insertNote(MWAWNote const ¬e, MWAWSubDocumentPtr &subDocument);
00170
00172 void insertComment(MWAWSubDocumentPtr &subDocument);
00173
00175 void insertPicture(MWAWPosition const &pos, const librevenge::RVNGBinaryData &binaryData,
00176 std::string type="image/pict", MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle());
00178 void insertPicture(MWAWPosition const &pos, MWAWGraphicShape const &shape,
00179 MWAWGraphicStyle const &style);
00181 void insertTextBox(MWAWPosition const &pos, MWAWSubDocumentPtr subDocument,
00182 MWAWGraphicStyle const &frameStyle=MWAWGraphicStyle::emptyStyle());
00183
00184
00186 void openTable(MWAWTable const &table);
00188 void closeTable();
00190 void openTableRow(float h, librevenge::RVNGUnit unit, bool headerRow=false);
00192 void closeTableRow();
00194 void openTableCell(MWAWCell const &cell);
00196 void closeTableCell();
00198 void addEmptyTableCell(MWAWVec2i const &pos, MWAWVec2i span=MWAWVec2i(1,1));
00199
00200
00202 bool canOpenSectionAddBreak() const;
00204 bool isSectionOpened() const;
00206 MWAWSection const &getSection() const;
00208 bool openSection(MWAWSection const §ion);
00210 bool closeSection();
00212 void insertBreak(BreakType breakType);
00213
00214 protected:
00216 void _openSection();
00218 void _closeSection();
00220 void _openPageSpan(bool sendHeaderFooters=true);
00222 void _closePageSpan();
00223
00224 void _startSubDocument();
00225 void _endSubDocument();
00226
00227 void _handleFrameParameters(librevenge::RVNGPropertyList &propList, MWAWPosition const &pos);
00228
00229 void _openParagraph();
00230 void _closeParagraph();
00231 void _appendParagraphProperties(librevenge::RVNGPropertyList &propList, const bool isListElement=false);
00232 void _resetParagraphState(const bool isListElement=false);
00233
00235 void _openListElement();
00237 void _closeListElement();
00239 void _changeList();
00244 int _getListId() const;
00245
00247 void _openSpan();
00249 void _closeSpan();
00250
00252 void _flushText();
00254 void _flushDeferredTabs();
00255
00256 void _insertBreakIfNecessary(librevenge::RVNGPropertyList &propList);
00257
00261 shared_ptr<MWAWTextListenerInternal::State> _pushParsingState();
00263 void _popParsingState();
00264
00265 protected:
00267 shared_ptr<MWAWTextListenerInternal::DocumentState> m_ds;
00269 shared_ptr<MWAWTextListenerInternal::State> m_ps;
00271 std::vector<shared_ptr<MWAWTextListenerInternal::State> > m_psStack;
00273 MWAWParserState &m_parserState;
00275 librevenge::RVNGTextInterface *m_documentInterface;
00276
00277 private:
00279 MWAWTextListener(const MWAWTextListener &);
00281 MWAWTextListener &operator=(const MWAWTextListener &);
00282 };
00283
00284 #endif
00285