PAGCollector.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /*
00003  * This file is part of the libetonyek project.
00004  *
00005  * This Source Code Form is subject to the terms of the Mozilla Public
00006  * License, v. 2.0. If a copy of the MPL was not distributed with this
00007  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
00008  */
00009 
00010 #ifndef PAGCOLLECTOR_H_INCLUDED
00011 #define PAGCOLLECTOR_H_INCLUDED
00012 
00013 #include <map>
00014 
00015 #include "IWORKCollector.h"
00016 #include "PAGTypes.h"
00017 
00018 namespace libetonyek
00019 {
00020 
00021 class IWORKDocumentInterface;
00022 
00023 class PAGCollector : public IWORKCollector
00024 {
00025   struct Section
00026   {
00027     Section();
00028 
00029     void clear();
00030 
00031     IWORKStylePtr_t m_style;
00032     boost::optional<double> m_width;
00033     boost::optional<double> m_height;
00034     boost::optional<double> m_horizontalMargin;
00035     boost::optional<double> m_verticalMargin;
00036   };
00037 
00038   typedef std::map<unsigned, IWORKOutputID_t> PageGroupsMap_t;
00039 
00040 public:
00041   explicit PAGCollector(IWORKDocumentInterface *document);
00042 
00043   // collector functions
00044 
00045   void collectPublicationInfo(const PAGPublicationInfo &pubInfo);
00046 
00047   void collectTextBody();
00048 
00049   void collectAttachment(const IWORKOutputID_t &id, bool block);
00050   void collectAttachmentPosition(const IWORKPosition &position);
00051 
00052   void openPageGroup(const boost::optional<int> &page);
00053   void closePageGroup();
00054 
00055   // helper functions
00056 
00057   void openSection(const std::string &style, double width, double height, double horizontalMargin, double verticalMargin);
00058   void closeSection();
00059 
00060   void openAttachments();
00061   void closeAttachments();
00062 
00063   PAGFootnoteKind getFootnoteKind() const;
00064 
00065 private:
00066   virtual void drawTable();
00067   virtual void drawMedia(double x, double y, double w, double h, const std::string &mimetype, const librevenge::RVNGBinaryData &data);
00068   virtual void fillShapeProperties(librevenge::RVNGPropertyList &props);
00069   virtual void drawTextBox(const IWORKTextPtr_t &text, const glm::dmat3 &trafo, const IWORKGeometryPtr_t &boundingBox);
00070 
00071   void flushPageSpan(bool writeEmpty = true);
00072   void writePageGroupsObjects();
00073 
00074 private:
00075   Section m_currentSection;
00076   bool m_firstPageSpan;
00077 
00078   PAGPublicationInfo m_pubInfo;
00079 
00080   PageGroupsMap_t m_pageGroups;
00081   int m_page;
00082 
00083   // FIXME: This is a clumsy workaround.
00084   boost::optional<IWORKPosition> m_attachmentPosition;
00085   bool m_inAttachments;
00086 };
00087 
00088 } // namespace libetonyek
00089 
00090 #endif //  PAGCOLLECTOR_H_INCLUDED
00091 
00092 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */