PMDCollector.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /*
3 * This file is part of the libpagemaker project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
9
10 #ifndef __PMDCOLLECTOR_H__
11 #define __PMDCOLLECTOR_H__
12
13 #include <memory>
14 #include <stdint.h>
15 #include <string>
16 #include <vector>
17
18 #include <boost/optional.hpp>
19
20 #include "OutputShape.h"
21 #include "PMDExceptions.h"
22 #include "PMDPage.h"
23 #include "PMDTypes.h"
24 #include "Units.h"
25 #include "geometry.h"
26
27 namespace libpagemaker
28 {
29
30
38 class PMDCollector
39 {
40 typedef std::vector<std::shared_ptr<const OutputShape> > PageShapes_t;
41 typedef std::vector<PageShapes_t> PageShapesList_t;
42
43 /*
44 * Height and width in PMD page units.
45 * One PMD page unit is 1/20 of a point (1/720 inch)
46 */
47 boost::optional<PMDShapeUnit> m_pageWidth;
48 boost::optional<PMDShapeUnit> m_pageHeight;
49
50 std::vector<PMDPage> m_pages;
51 std::vector<PMDColor> m_color;
52 std::vector<PMDFont> m_font;
53 bool m_doubleSided;
54
55 void writePage(const PMDPage &,
56 librevenge::RVNGDrawingInterface *,
57 const std::vector<std::shared_ptr<const OutputShape> > &) const;
58
59 void paintShape(const OutputShape &shape,
60 librevenge::RVNGDrawingInterface *) const;
61
62 void fillOutputShapesByPage_OneSided(PageShapesList_t &pageShapes) const;
63 void fillOutputShapesByPage_TwoSided(PageShapesList_t &pageShapes) const;
64 void fillOutputShapesByPage(PageShapesList_t &pageShapes) const;
65 public:
66 PMDCollector();
67
68 /* State-mutating functions */
69 void setPageWidth(PMDShapeUnit);
70 void setPageHeight(PMDShapeUnit);
71 void setDoubleSided(bool);
72 void addShapeToPage(unsigned pageID, const std::shared_ptr<PMDLineSet> &shape);
73 void addColor(const PMDColor &color);
74 void addFont(const PMDFont &font);
75
76 unsigned addPage();
77
78 /* Output functions */
79 void draw(librevenge::RVNGDrawingInterface *) const;
80 };
81
82 }
83
84 #endif /* __PMDCOLLECTOR_H__ */
85 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
libpagemaker::PMDCollector::addShapeToPage
void addShapeToPage(unsigned pageID, const std::shared_ptr< PMDLineSet > &shape)
Definition: PMDCollector.cpp:173
PMDExceptions.h
libpagemaker::PMDCollector::setDoubleSided
void setDoubleSided(bool)
Definition: PMDCollector.cpp:141
libpagemaker::PMDCollector::m_color
std::vector< PMDColor > m_color
Definition: PMDCollector.h:51
PMDPage.h
libpagemaker::PMDCollector::setPageWidth
void setPageWidth(PMDShapeUnit)
Definition: PMDCollector.cpp:147
libpagemaker::PMDCollector::m_pageWidth
boost::optional< PMDShapeUnit > m_pageWidth
Definition: PMDCollector.h:47
libpagemaker::PMDCollector::PMDCollector
PMDCollector()
Definition: PMDCollector.cpp:136
libpagemaker::PMDCollector::m_doubleSided
bool m_doubleSided
Definition: PMDCollector.h:53
libpagemaker::PMDCollector::draw
void draw(librevenge::RVNGDrawingInterface *) const
Definition: PMDCollector.cpp:710
libpagemaker::PMDColor
Definition: PMDTypes.h:20
libpagemaker::PMDPage
Definition: PMDPage.h:23
libpagemaker::PMDCollector::addFont
void addFont(const PMDFont &font)
Definition: PMDCollector.cpp:168
libpagemaker::PMDCollector::m_pages
std::vector< PMDPage > m_pages
Definition: PMDCollector.h:50
OutputShape.h
libpagemaker::PMDCollector::paintShape
void paintShape(const OutputShape &shape, librevenge::RVNGDrawingInterface *) const
Definition: PMDCollector.cpp:178
libpagemaker::PMDCollector::writePage
void writePage(const PMDPage &, librevenge::RVNGDrawingInterface *, const std::vector< std::shared_ptr< const OutputShape > > &) const
Definition: PMDCollector.cpp:622
libpagemaker::PMDCollector::addColor
void addColor(const PMDColor &color)
Definition: PMDCollector.cpp:163
libpagemaker::PMDCollector::PageShapes_t
std::vector< std::shared_ptr< const OutputShape > > PageShapes_t
Definition: PMDCollector.h:40
Units.h
libpagemaker::LengthUnit
Definition: Units.h:21
libpagemaker::PMDCollector::setPageHeight
void setPageHeight(PMDShapeUnit)
Definition: PMDCollector.cpp:152
libpagemaker::PMDCollector::fillOutputShapesByPage_TwoSided
void fillOutputShapesByPage_TwoSided(PageShapesList_t &pageShapes) const
Definition: PMDCollector.cpp:645
libpagemaker::OutputShape
Definition: OutputShape.h:23
libpagemaker::PMDCollector::fillOutputShapesByPage_OneSided
void fillOutputShapesByPage_OneSided(PageShapesList_t &pageShapes) const
Definition: PMDCollector.cpp:682
libpagemaker::PMDCollector::PageShapesList_t
std::vector< PageShapes_t > PageShapesList_t
Definition: PMDCollector.h:41
libpagemaker
Definition: geometry.h:22
libpagemaker::PMDFont
Definition: PMDTypes.h:32
geometry.h
PMDTypes.h
libpagemaker::PMDCollector
Builder class for PMD Documents.
Definition: PMDCollector.h:38
libpagemaker::PMDCollector::m_font
std::vector< PMDFont > m_font
Definition: PMDCollector.h:52
libpagemaker::PMDCollector::addPage
unsigned addPage()
Definition: PMDCollector.cpp:157
libpagemaker::PMDCollector::m_pageHeight
boost::optional< PMDShapeUnit > m_pageHeight
Definition: PMDCollector.h:48
libpagemaker::PMDCollector::fillOutputShapesByPage
void fillOutputShapesByPage(PageShapesList_t &pageShapes) const
Definition: PMDCollector.cpp:701