MWAWPresentationListener.hxx
Go to the documentation of this file.
00001 /* -*- Mode: C++; c-default-style: "k&r"; indent-tabs-mode: nil; tab-width: 2; c-basic-offset: 2 -*- */
00002 
00003 /* libmwaw
00004 * Version: MPL 2.0 / LGPLv2+
00005 *
00006 * The contents of this file are subject to the Mozilla Public License Version
00007 * 2.0 (the "License"); you may not use this file except in compliance with
00008 * the License or as specified alternatively below. You may obtain a copy of
00009 * the License at http://www.mozilla.org/MPL/
00010 *
00011 * Software distributed under the License is distributed on an "AS IS" basis,
00012 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00013 * for the specific language governing rights and limitations under the
00014 * License.
00015 *
00016 * Major Contributor(s):
00017 * Copyright (C) 2002 William Lachance (wrlach@gmail.com)
00018 * Copyright (C) 2002,2004 Marc Maurer (uwog@uwog.net)
00019 * Copyright (C) 2004-2006 Fridrich Strba (fridrich.strba@bluewin.ch)
00020 * Copyright (C) 2006, 2007 Andrew Ziem
00021 * Copyright (C) 2011, 2012 Alonso Laurent (alonso@loria.fr)
00022 *
00023 *
00024 * All Rights Reserved.
00025 *
00026 * For minor contributions see the git repository.
00027 *
00028 * Alternatively, the contents of this file may be used under the terms of
00029 * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
00030 * in which case the provisions of the LGPLv2+ are applicable
00031 * instead of those above.
00032 */
00033 
00034 #ifndef MWAW_PRESENTATION_LISTENER_H
00035 #define MWAW_PRESENTATION_LISTENER_H
00036 
00037 #include <vector>
00038 
00039 #include <librevenge/librevenge.h>
00040 
00041 #include "libmwaw_internal.hxx"
00042 
00043 #include "MWAWGraphicStyle.hxx"
00044 
00045 #include "MWAWListener.hxx"
00046 
00047 class MWAWGraphicShape;
00048 
00049 namespace MWAWPresentationListenerInternal
00050 {
00051 struct GraphicState;
00052 struct State;
00053 }
00054 
00059 class MWAWPresentationListener : public MWAWListener
00060 {
00061 public:
00063   MWAWPresentationListener(MWAWParserState &parserState, std::vector<MWAWPageSpan> const &pageList, librevenge::RVNGPresentationInterface *documentInterface);
00065   virtual ~MWAWPresentationListener();
00066 
00068   Type getType() const
00069   {
00070     return Presentation;
00071   }
00072 
00074   void setDocumentLanguage(std::string locale);
00076   void startDocument();
00078   void endDocument(bool delayed=true);
00079 
00080   // ------ general information --------
00082   bool canWriteText() const;
00084   bool isDocumentStarted() const;
00085 
00087   void handleSubDocument(MWAWVec2f const &orig, MWAWSubDocumentPtr subDocument, libmwaw::SubDocumentType subDocumentType);
00089   void handleSubDocument(MWAWSubDocumentPtr subDocument, libmwaw::SubDocumentType subDocumentType)
00090   {
00091     handleSubDocument(MWAWVec2f(0,0), subDocument, subDocumentType);
00092   }
00094   bool isSubDocumentOpened(libmwaw::SubDocumentType &subdocType) const;
00096   bool openFrame(MWAWPosition const &pos, MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle());
00098   void closeFrame();
00100   bool openGroup(MWAWPosition const &pos);
00102   void closeGroup();
00104   bool openLayer(librevenge::RVNGString const &name);
00106   void closeLayer();
00107 
00108   // ------ page --------
00110   bool openMasterPage(MWAWPageSpan &masterPage);
00112   void closeMasterPage()
00113   {
00114     _closePageSpan(true);
00115   }
00117   bool isPageSpanOpened() const;
00121   MWAWPageSpan const &getPageSpan();
00122 
00123   // ------ header/footer --------
00125   bool insertHeader(MWAWSubDocumentPtr subDocument, librevenge::RVNGPropertyList const &extras);
00127   bool insertFooter(MWAWSubDocumentPtr subDocument, librevenge::RVNGPropertyList const &extras);
00129   bool isHeaderFooterOpened() const;
00130 
00131   // ------ text data -----------
00133   void insertChar(uint8_t character);
00136   void insertCharacter(unsigned char c);
00142   int insertCharacter(unsigned char c, MWAWInputStreamPtr &input, long endPos=-1);
00145   void insertUnicode(uint32_t character);
00147   void insertUnicodeString(librevenge::RVNGString const &str);
00148 
00150   void insertTab();
00152   void insertEOL(bool softBreak=false);
00153 
00154   // ------ text format -----------
00156   void setFont(MWAWFont const &font);
00158   MWAWFont const &getFont() const;
00159 
00160   // ------ paragraph format -----------
00162   bool isParagraphOpened() const;
00164   void setParagraph(MWAWParagraph const &paragraph);
00166   MWAWParagraph const &getParagraph() const;
00167 
00168   // ------- fields ----------------
00170   void insertField(MWAWField const &field);
00171 
00172   // ------- link ----------------
00174   void openLink(MWAWLink const &link);
00176   void closeLink();
00177 
00178   // ------- subdocument -----------------
00180   void insertPicture(MWAWPosition const &pos, const librevenge::RVNGBinaryData &binaryData,
00181                      std::string type="image/pict", MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle());
00183   void insertPicture(MWAWPosition const &pos, MWAWGraphicShape const &shape, MWAWGraphicStyle const &style);
00185   void insertTextBox(MWAWPosition const &pos, MWAWSubDocumentPtr subDocument, MWAWGraphicStyle const &style);
00187   void insertGroup(MWAWBox2f const &bdbox, MWAWSubDocumentPtr subDocument);
00189   void insertSlideNote(MWAWPosition const &pos, MWAWSubDocumentPtr &subDocument);
00193   void insertNote(MWAWNote const &note, MWAWSubDocumentPtr &subDocument);
00197   void insertComment(MWAWSubDocumentPtr &subDocument);
00198 
00199   // ------- table -----------------
00200 
00202   void insertTable(MWAWPosition const &pos, MWAWTable &table, MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle());
00204   void openTable(MWAWTable const &table);
00206   void openTable(MWAWPosition const &pos, MWAWTable const &table, MWAWGraphicStyle const &style);
00208   void closeTable();
00210   void openTableRow(float h, librevenge::RVNGUnit unit, bool headerRow=false);
00212   void closeTableRow();
00214   void openTableCell(MWAWCell const &cell);
00216   void closeTableCell();
00218   void addEmptyTableCell(MWAWVec2i const &pos, MWAWVec2i span=MWAWVec2i(1,1));
00219 
00220   // ------- section ---------------
00221 
00223   bool canOpenSectionAddBreak() const
00224   {
00225     return false;
00226   }
00228   bool isSectionOpened() const
00229   {
00230     return false;
00231   }
00233   MWAWSection const &getSection() const;
00235   bool openSection(MWAWSection const &section);
00237   bool closeSection()
00238   {
00239     return false;
00240   }
00242   void insertBreak(BreakType breakType);
00243 
00244 protected:
00246   void _openPageSpan(bool sendHeaderFooters=true);
00248   void _closePageSpan(bool masterPage=false);
00249 
00250   void _startSubDocument();
00251   void _endSubDocument();
00252 
00256   void _handleFrameParameters(librevenge::RVNGPropertyList &propList, MWAWPosition const &pos, MWAWGraphicStyle const &style);
00257 
00258   void _openParagraph();
00259   void _closeParagraph();
00260   void _resetParagraphState(const bool isListElement=false);
00261 
00263   void _openListElement();
00265   void _closeListElement();
00267   void _changeList();
00272   int _getListId() const;
00273 
00274   void _openSpan();
00275   void _closeSpan();
00276 
00277   void _flushText();
00278 
00282   shared_ptr<MWAWPresentationListenerInternal::State> _pushParsingState();
00284   void _popParsingState();
00285 
00286 protected:
00288   shared_ptr<MWAWPresentationListenerInternal::GraphicState> m_ds;
00290   shared_ptr<MWAWPresentationListenerInternal::State> m_ps;
00292   std::vector<shared_ptr<MWAWPresentationListenerInternal::State> > m_psStack;
00294   MWAWParserState &m_parserState;
00296   librevenge::RVNGPresentationInterface *m_documentInterface;
00297 
00298 private:
00299   MWAWPresentationListener(const MWAWPresentationListener &);
00300   MWAWPresentationListener &operator=(const MWAWPresentationListener &);
00301 };
00302 
00303 #endif
00304 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab: