STOFFSpreadsheetListener.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 /* libstaroffice
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 
00040 #ifndef STOFF_SPREADSHEET_LISTENER_H
00041 #define STOFF_SPREADSHEET_LISTENER_H
00042 
00043 #include <vector>
00044 
00045 #include <librevenge/librevenge.h>
00046 
00047 #include "libstaroffice_internal.hxx"
00048 
00049 #include "STOFFListener.hxx"
00050 
00051 class STOFFCell;
00052 class STOFFCellContent;
00053 class STOFFChart;
00054 class STOFFGraphicStyle;
00055 class STOFFTable;
00056 
00057 namespace STOFFSpreadsheetListenerInternal
00058 {
00059 struct DocumentState;
00060 struct State;
00061 }
00062 
00064 class STOFFSpreadsheetListener : public STOFFListener
00065 {
00066 public:
00068   STOFFSpreadsheetListener(STOFFListManagerPtr listManager, std::vector<STOFFPageSpan> const &pageList, librevenge::RVNGSpreadsheetInterface *documentInterface);
00070   virtual ~STOFFSpreadsheetListener();
00071 
00073   Type getType() const
00074   {
00075     return Spreadsheet;
00076   }
00077 
00079   void setDocumentLanguage(std::string locale);
00081   void setDocumentMetaData(const librevenge::RVNGPropertyList &list);
00082 
00084   void startDocument();
00086   void endDocument(bool sendDelayedSubDoc=true);
00088   bool isDocumentStarted() const;
00089 
00091   void handleSubDocument(STOFFSubDocumentPtr subDocument, libstoff::SubDocumentType subDocumentType);
00093   bool isSubDocumentOpened(libstoff::SubDocumentType &subdocType) const;
00095   bool openFrame(STOFFPosition const &pos, STOFFGraphicStyle const &style=STOFFGraphicStyle());
00097   void closeFrame();
00099   bool openGroup(STOFFPosition const &pos);
00101   void closeGroup();
00102 
00104   bool canWriteText() const;
00105 
00106   // ------ page --------
00108   bool isPageSpanOpened() const;
00112   STOFFPageSpan const &getPageSpan();
00113 
00114   // ------ header/footer --------
00116   bool openHeader(librevenge::RVNGPropertyList const &extras);
00118   bool openFooter(librevenge::RVNGPropertyList const &extras);
00120   bool closeHeader();
00122   bool closeFooter();
00124   bool insertHeaderRegion(STOFFSubDocumentPtr subDocument, librevenge::RVNGString const &which);
00126   bool insertFooterRegion(STOFFSubDocumentPtr subDocument, librevenge::RVNGString const &which);
00128   bool isHeaderFooterOpened() const;
00129 
00130   // ------- sheet -----------------
00132   void openSheet(std::vector<float> const &colWidth, librevenge::RVNGUnit unit,
00133                  std::vector<int> const &repeatColWidthNumber=std::vector<int>(), librevenge::RVNGString const &name="");
00135   void closeSheet();
00137   void openSheetRow(float h, librevenge::RVNGUnit unit, int numRepeated=1);
00139   void closeSheetRow();
00141   void openSheetCell(STOFFCell const &cell, STOFFCellContent const &content, int numRepeated=1);
00143   void closeSheetCell();
00144 
00145   // ------- chart -----------------
00147   void insertChart(STOFFPosition const &pos, STOFFChart &chart, STOFFGraphicStyle const &style=STOFFGraphicStyle());
00148 
00149   // ------ text data -----------
00150 
00152   void insertChar(uint8_t character);
00155   void insertUnicode(uint32_t character);
00157   void insertUnicodeString(librevenge::RVNGString const &str);
00158 
00160   void insertTab();
00162   void insertEOL(bool softBreak=false);
00163 
00164   // ------ text format -----------
00166   void setFont(STOFFFont const &font);
00168   STOFFFont const &getFont() const;
00169 
00170   // ------ paragraph format -----------
00172   bool isParagraphOpened() const;
00174   void setParagraph(STOFFParagraph const &paragraph);
00176   STOFFParagraph const &getParagraph() const;
00177 
00178   // ------ style definition -----------
00180   void defineStyle(STOFFFont const &style);
00182   bool isFontStyleDefined(librevenge::RVNGString const &name) const;
00184   void defineStyle(STOFFGraphicStyle const &style);
00186   bool isGraphicStyleDefined(librevenge::RVNGString const &name) const;
00188   void defineStyle(STOFFParagraph const &style);
00190   bool isParagraphStyleDefined(librevenge::RVNGString const &name) const;
00191 
00192   // ------- fields ----------------
00194   void insertField(STOFFField const &field);
00195 
00196   // ------- link ----------------
00198   void openLink(STOFFLink const &link);
00200   void closeLink();
00201 
00202   // ------- subdocument -----------------
00204   void insertNote(STOFFNote const &note, STOFFSubDocumentPtr &subDocument);
00206   void insertComment(STOFFSubDocumentPtr &subDocument, librevenge::RVNGString const &creator="", librevenge::RVNGString const &date="");
00207 
00209   void insertPicture(STOFFPosition const &pos, STOFFEmbeddedObject const &picture,
00210                      STOFFGraphicStyle const &style=STOFFGraphicStyle());
00212   void insertShape(STOFFGraphicShape const &shape, STOFFGraphicStyle const &style, STOFFPosition const &pos);
00214   void insertTextBox(STOFFPosition const &pos, STOFFSubDocumentPtr subDocument,
00215                      STOFFGraphicStyle const &frameStyle=STOFFGraphicStyle());
00216   // ------- table -----------------
00218   void insertTable(STOFFPosition const &pos, STOFFTable &table, STOFFGraphicStyle const &style=STOFFGraphicStyle());
00220   void openTable(STOFFTable const &table);
00222   void closeTable();
00224   void openTableRow(float h, librevenge::RVNGUnit unit, bool headerRow=false);
00226   void closeTableRow();
00228   void openTableCell(STOFFCell const &cell);
00230   void closeTableCell();
00232   void addEmptyTableCell(STOFFVec2i const &pos, STOFFVec2i span=STOFFVec2i(1,1));
00233 
00234   // ------- section ---------------
00236   bool canOpenSectionAddBreak() const
00237   {
00238     return false;
00239   }
00241   bool isSectionOpened() const
00242   {
00243     return false;
00244   }
00246   STOFFSection const &getSection() const;
00248   bool openSection(STOFFSection const &section);
00250   bool closeSection();
00252   void insertBreak(BreakType breakType);
00253 
00254 protected:
00256   void _openPageSpan(bool sendHeaderFooters=true);
00258   void _closePageSpan();
00259 
00260   void _startSubDocument();
00261   void _endSubDocument();
00262 
00263   void _handleFrameParameters(librevenge::RVNGPropertyList &propList, STOFFPosition const &pos);
00264 
00265   void _openParagraph();
00266   void _closeParagraph();
00267   void _resetParagraphState(const bool isListElement=false);
00268 
00270   void _openListElement();
00272   void _closeListElement();
00274   void _changeList();
00279   int _getListId() const;
00280 
00281   void _openSpan();
00282   void _closeSpan();
00283 
00284   void _flushText();
00285   void _flushDeferredTabs();
00286 
00290   shared_ptr<STOFFSpreadsheetListenerInternal::State> _pushParsingState();
00292   void _popParsingState();
00293 
00294 protected:
00296   shared_ptr<STOFFSpreadsheetListenerInternal::DocumentState> m_ds;
00298   shared_ptr<STOFFSpreadsheetListenerInternal::State> m_ps;
00300   std::vector<shared_ptr<STOFFSpreadsheetListenerInternal::State> > m_psStack;
00302   librevenge::RVNGSpreadsheetInterface *m_documentInterface;
00303 
00304 private:
00306   STOFFSpreadsheetListener(const STOFFSpreadsheetListener &);
00308   STOFFSpreadsheetListener &operator=(const STOFFSpreadsheetListener &);
00309 };
00310 
00311 #endif
00312 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab: