00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 00002 /* 00003 * This file is part of the libpagemaker 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 __PMDCOLLECTOR_H__ 00011 #define __PMDCOLLECTOR_H__ 00012 00013 #include <stdint.h> 00014 00015 #include <vector> 00016 #include <string> 00017 00018 #include <boost/optional.hpp> 00019 #include <boost/shared_ptr.hpp> 00020 00021 00022 #include "geometry.h" 00023 #include "PMDPage.h" 00024 #include "PMDExceptions.h" 00025 #include "Units.h" 00026 #include "OutputShape.h" 00027 #include "PMDTypes.h" 00028 00029 namespace libpagemaker 00030 { 00031 00032 00040 class PMDCollector 00041 { 00042 typedef std::vector<boost::shared_ptr<const OutputShape> > PageShapes_t; 00043 typedef std::vector<PageShapes_t> PageShapesList_t; 00044 00045 /* 00046 * Height and width in PMD page units. 00047 * One PMD page unit is 1/20 of a point (1/720 inch) 00048 */ 00049 boost::optional<PMDPageUnit> m_pageWidth; 00050 boost::optional<PMDPageUnit> m_pageHeight; 00051 00052 std::vector<PMDPage> m_pages; 00053 std::vector<PMDColor> m_color; 00054 std::vector<PMDFont> m_font; 00055 bool m_doubleSided; 00056 00057 void writePage(const PMDPage &, 00058 librevenge::RVNGDrawingInterface *, 00059 const std::vector<boost::shared_ptr<const OutputShape> > &) const; 00060 00061 void paintShape(const OutputShape &shape, 00062 librevenge::RVNGDrawingInterface *) const; 00063 00064 void fillOutputShapesByPage_OneSided(PageShapesList_t &pageShapes) const; 00065 void fillOutputShapesByPage_TwoSided(PageShapesList_t &pageShapes) const; 00066 void fillOutputShapesByPage(PageShapesList_t &pageShapes) const; 00067 public: 00068 PMDCollector(); 00069 00070 /* State-mutating functions */ 00071 void setPageWidth(PMDPageUnit); 00072 void setPageHeight(PMDPageUnit); 00073 void setDoubleSided(bool); 00074 void addShapeToPage(unsigned pageID, const boost::shared_ptr<PMDLineSet> &shape); 00075 void addColor(const PMDColor &color); 00076 void addFont(const PMDFont &font); 00077 00078 unsigned addPage(); 00079 00080 /* Output functions */ 00081 void draw(librevenge::RVNGDrawingInterface *) const; 00082 }; 00083 00084 } 00085 00086 #endif /* __PMDCOLLECTOR_H__ */ 00087 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */