STOFFGraphicListener.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 /* libstoff
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 STOFF_GRAPHIC_LISTENER_H
00035 #define STOFF_GRAPHIC_LISTENER_H
00036 
00037 #include <vector>
00038 
00039 #include <librevenge/librevenge.h>
00040 
00041 #include "libstaroffice_internal.hxx"
00042 
00043 #include "STOFFGraphicStyle.hxx"
00044 
00045 #include "STOFFListener.hxx"
00046 
00047 class STOFFGraphicShape;
00048 
00049 namespace STOFFGraphicListenerInternal
00050 {
00051 struct GraphicState;
00052 struct State;
00053 }
00054 
00059 class STOFFGraphicListener : public STOFFListener
00060 {
00061 public:
00063   STOFFGraphicListener(STOFFListManagerPtr listManager, std::vector<STOFFPageSpan> const &pageList, librevenge::RVNGDrawingInterface *documentInterface);
00065   virtual ~STOFFGraphicListener();
00066 
00068   Type getType() const
00069   {
00070     return Graphic;
00071   }
00072 
00074   void setDocumentLanguage(std::string locale);
00076   void setDocumentMetaData(const librevenge::RVNGPropertyList &list);
00078   void startDocument();
00080   void endDocument(bool sendDelayedSubDoc=true);
00081 
00082   // ------ general information --------
00084   bool canWriteText() const;
00086   bool isDocumentStarted() const;
00087 
00089   void handleSubDocument(STOFFSubDocumentPtr subDocument, libstoff::SubDocumentType subDocumentType);
00091   bool isSubDocumentOpened(libstoff::SubDocumentType &subdocType) const;
00093   bool openFrame(STOFFPosition const &pos, STOFFGraphicStyle const &style=STOFFGraphicStyle());
00095   void closeFrame();
00097   bool openGroup(STOFFPosition const &pos);
00099   void closeGroup();
00101   bool openLayer(librevenge::RVNGString const &name);
00103   void closeLayer();
00104 
00105   // ------ page --------
00107   bool openMasterPage(STOFFPageSpan &masterPage);
00109   void closeMasterPage()
00110   {
00111     _closePageSpan(true);
00112   }
00114   bool isPageSpanOpened() const;
00118   STOFFPageSpan const &getPageSpan();
00119 
00120   // ------ header/footer --------
00122   bool openHeader(librevenge::RVNGPropertyList const &extras);
00124   bool openFooter(librevenge::RVNGPropertyList const &extras);
00126   bool closeHeader();
00128   bool closeFooter();
00130   bool insertHeaderRegion(STOFFSubDocumentPtr subDocument, librevenge::RVNGString const &which);
00132   bool insertFooterRegion(STOFFSubDocumentPtr subDocument, librevenge::RVNGString const &which);
00134   bool isHeaderFooterOpened() const;
00135 
00136   // ------ text data -----------
00138   void insertChar(uint8_t character);
00143   void insertUnicode(uint32_t character);
00145   void insertUnicodeString(librevenge::RVNGString const &str);
00146 
00148   void insertTab();
00150   void insertEOL(bool softBreak=false);
00151 
00152   // ------ text format -----------
00154   void setFont(STOFFFont const &font);
00156   STOFFFont const &getFont() const;
00157 
00158   // ------ paragraph format -----------
00160   bool isParagraphOpened() const;
00162   void setParagraph(STOFFParagraph const &paragraph);
00164   STOFFParagraph const &getParagraph() const;
00165 
00166   // ------ style definition -----------
00168   void defineStyle(STOFFFont const &style);
00170   bool isFontStyleDefined(librevenge::RVNGString const &name) const;
00172   void defineStyle(STOFFGraphicStyle const &style);
00174   bool isGraphicStyleDefined(librevenge::RVNGString const &name) const;
00176   void defineStyle(STOFFParagraph const &style);
00178   bool isParagraphStyleDefined(librevenge::RVNGString const &name) const;
00179 
00180   // ------- fields ----------------
00182   void insertField(STOFFField const &field);
00183 
00184   // ------- link ----------------
00186   void openLink(STOFFLink const &link);
00188   void closeLink();
00189 
00190   // ------- subdocument -----------------
00192   void insertShape(STOFFGraphicShape const &shape, STOFFGraphicStyle const &style, STOFFPosition const &pos);
00194   void insertTextBox(STOFFPosition const &pos, STOFFSubDocumentPtr subDocument, STOFFGraphicStyle const &style=STOFFGraphicStyle());
00196   void insertPicture(STOFFPosition const &pos, STOFFEmbeddedObject const &picture,
00197                      STOFFGraphicStyle const &style=STOFFGraphicStyle());
00201   void insertNote(STOFFNote const &note, STOFFSubDocumentPtr &subDocument);
00205   void insertComment(STOFFSubDocumentPtr &subDocument, librevenge::RVNGString const &creator="", librevenge::RVNGString const &date="");
00206 
00207   // ------- table -----------------
00208 
00210   void insertTable(STOFFPosition const &pos, STOFFTable &table, STOFFGraphicStyle const &style=STOFFGraphicStyle());
00212   void openTable(STOFFTable const &table);
00214   void openTable(STOFFPosition const &pos, STOFFTable const &table);
00216   void closeTable();
00218   void openTableRow(float h, librevenge::RVNGUnit unit, bool headerRow=false);
00220   void closeTableRow();
00222   void openTableCell(STOFFCell const &cell);
00224   void closeTableCell();
00226   void addEmptyTableCell(STOFFVec2i const &pos, STOFFVec2i span=STOFFVec2i(1,1));
00227 
00228   // ------- section ---------------
00229 
00231   bool canOpenSectionAddBreak() const
00232   {
00233     return false;
00234   }
00236   bool isSectionOpened() const
00237   {
00238     return false;
00239   }
00241   STOFFSection const &getSection() const;
00243   bool openSection(STOFFSection const &section);
00245   bool closeSection()
00246   {
00247     return false;
00248   }
00250   void insertBreak(BreakType breakType);
00251 
00252 protected:
00254   void _openPageSpan(bool sendHeaderFooters=true);
00256   void _closePageSpan(bool masterPage=false);
00257 
00258   void _startSubDocument();
00259   void _endSubDocument();
00260 
00264   void _handleFrameParameters(librevenge::RVNGPropertyList &propList, STOFFPosition const &pos, STOFFGraphicStyle const &style);
00265 
00266   void _openParagraph();
00267   void _closeParagraph();
00268   void _resetParagraphState(const bool isListElement=false);
00269 
00271   void _openListElement();
00273   void _closeListElement();
00275   void _changeList();
00280   int _getListId() const;
00281 
00282   void _openSpan();
00283   void _closeSpan();
00284 
00285   void _flushText();
00286 
00290   shared_ptr<STOFFGraphicListenerInternal::State> _pushParsingState();
00292   void _popParsingState();
00293 
00294 protected:
00296   shared_ptr<STOFFGraphicListenerInternal::GraphicState> m_ds;
00298   shared_ptr<STOFFGraphicListenerInternal::State> m_ps;
00300   std::vector<shared_ptr<STOFFGraphicListenerInternal::State> > m_psStack;
00302   librevenge::RVNGDrawingInterface *m_documentInterface;
00303 
00304 private:
00305   STOFFGraphicListener(const STOFFGraphicListener &);
00306   STOFFGraphicListener &operator=(const STOFFGraphicListener &);
00307 };
00308 
00309 #endif
00310 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab: