ZMFCollector.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 a part of the libzmf 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 ZMF4COLLECTOR_H_INCLUDED
00011 #define ZMF4COLLECTOR_H_INCLUDED
00012 
00013 #include <librevenge/librevenge.h>
00014 #include "libzmf_utils.h"
00015 #include "ZMFTypes.h"
00016 #include <vector>
00017 
00018 namespace libzmf
00019 {
00020 
00021 class ZMFCollector
00022 {
00023   // disable copying
00024   ZMFCollector(const ZMFCollector &other);
00025   ZMFCollector &operator=(const ZMFCollector &other);
00026 
00027 public:
00028   ZMFCollector(librevenge::RVNGDrawingInterface *painter);
00029   ~ZMFCollector();
00030 
00031   void startDocument();
00032   void endDocument();
00033 
00034   void startPage(const ZMFPageSettings &pageSettings);
00035   void endPage();
00036 
00037   void startLayer();
00038   void endLayer();
00039 
00040   void startGroup();
00041   void endGroup();
00042 
00043   void setStyle(const Style &style);
00044 
00045   void collectPath(const std::vector<Curve> &curves);
00046   void collectPath(const Curve &curve);
00047 
00048   void collectEllipse(const Point &c, double rx, double ry, double rotation);
00049   void collectArc(const Point &c, double rx, double ry, double beginAngle, double endAngle, bool closed, double rotation);
00050 
00051   void collectPolygon(const Point &c, double rx, double ry, uint32_t peaksCount, const Curve &peak,
00052                       double rotation, bool mirrorHorizontal, bool mirrorVertical);
00053 
00054   void collectTextObject(const Text &text, const Point &topLeft, double width, double height,
00055                          VerticalAlignment align, double rotation);
00056 
00057   void collectTable(const Table &table);
00058 
00059   void collectImage(const librevenge::RVNGBinaryData &image, const Point &topLeft, double width, double height,
00060                     double rotation, bool mirrorHorizontal, bool mirrorVertical);
00061 
00062 private:
00063   double pageX(double canvasX);
00064   double pageY(double canvasY);
00065 
00066   void writeStyle(librevenge::RVNGPropertyList &propList, const Style &style, bool noFill = false);
00067   void writePen(librevenge::RVNGPropertyList &propList, const Pen &pen);
00068   void writeFill(librevenge::RVNGPropertyList &propList, const Fill &fill);
00069   void writeShadow(librevenge::RVNGPropertyList &propList, const Shadow &shadow);
00070 
00071   void collectText(const Text &text);
00072   void flushText(std::string &text);
00073 
00074   librevenge::RVNGDrawingInterface *m_painter;
00075 
00076   ZMFPageSettings m_pageSettings;
00077 
00078   bool m_isDocumentStarted;
00079   bool m_isPageStarted;
00080   bool m_isLayerStarted;
00081 
00082   Style m_style;
00083 };
00084 
00085 }
00086 
00087 #endif // ZMF4COLLECTOR_H_INCLUDED
00088 
00089 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */