ShapeInfo.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 libmspub 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 __SHAPEINFO_H__
00011 #define __SHAPEINFO_H__
00012 #include <boost/optional.hpp>
00013 #include <boost/shared_ptr.hpp>
00014 #include <map>
00015 #include <vector>
00016 #include <boost/function.hpp>
00017 #include "ShapeType.h"
00018 #include "Coordinate.h"
00019 #include "Line.h"
00020 #include "Margins.h"
00021 #include "MSPUBTypes.h"
00022 #include "Fill.h"
00023 #include "PolygonUtils.h"
00024 #include "Dash.h"
00025 #include "TableInfo.h"
00026 #include "Arrow.h"
00027 #include "VerticalAlign.h"
00028 #include "ColorReference.h"
00029 #include "Shadow.h"
00030 
00031 namespace libmspub
00032 {
00033 void noop(const CustomShape *);
00034 struct ShapeInfo
00035 {
00036   boost::optional<ShapeType> m_type;
00037   boost::optional<ShapeType> m_cropType;
00038   boost::optional<unsigned> m_imgIndex;
00039   boost::optional<unsigned> m_borderImgIndex;
00040   boost::optional<Coordinate> m_coordinates;
00041   std::vector<Line> m_lines;
00042   boost::optional<unsigned> m_pageSeqNum;
00043   boost::optional<unsigned> m_textId;
00044   std::map<unsigned, int> m_adjustValuesByIndex;
00045   std::vector<int> m_adjustValues;
00046   boost::optional<double> m_rotation;
00047   boost::optional<std::pair<bool, bool> > m_flips;
00048   boost::optional<Margins> m_margins;
00049   boost::optional<BorderPosition> m_borderPosition; // Irrelevant except for rectangular shapes
00050   boost::shared_ptr<const Fill> m_fill;
00051   boost::optional<DynamicCustomShape> m_customShape;
00052   bool m_stretchBorderArt;
00053   boost::optional<ColorReference> m_lineBackColor;
00054   boost::optional<Dash> m_dash;
00055   boost::optional<TableInfo> m_tableInfo;
00056   boost::optional<unsigned> m_numColumns;
00057   unsigned m_columnSpacing;
00058   boost::optional<Arrow> m_beginArrow;
00059   boost::optional<Arrow> m_endArrow;
00060   boost::optional<VerticalAlign> m_verticalAlign;
00061   boost::optional<ColorReference> m_pictureRecolor;
00062   boost::optional<Shadow> m_shadow;
00063   boost::optional<int> m_innerRotation;
00064   std::vector<libmspub::Vertex> m_clipPath;
00065   boost::optional<int> m_pictureBrightness;
00066   boost::optional<int> m_pictureContrast;
00067   ShapeInfo() : m_type(), m_cropType(), m_imgIndex(), m_borderImgIndex(),
00068     m_coordinates(), m_lines(), m_pageSeqNum(),
00069     m_textId(), m_adjustValuesByIndex(), m_adjustValues(),
00070     m_rotation(), m_flips(), m_margins(), m_borderPosition(),
00071     m_fill(), m_customShape(), m_stretchBorderArt(false),
00072     m_lineBackColor(), m_dash(), m_tableInfo(),
00073     m_numColumns(),
00074     m_columnSpacing(0), m_beginArrow(), m_endArrow(),
00075     m_verticalAlign(), m_pictureRecolor(), m_shadow(), m_innerRotation(), m_clipPath(), m_pictureBrightness(), m_pictureContrast()
00076   {
00077   }
00078   boost::shared_ptr<const CustomShape> getCustomShape() const
00079   {
00080     if (bool(m_customShape))
00081     {
00082       return getFromDynamicCustomShape(m_customShape.get());
00083     }
00084     if (bool(m_cropType))
00085     {
00086       return boost::shared_ptr<const CustomShape>(
00087                libmspub::getCustomShape(m_cropType.get()),
00088                boost::function<void (const CustomShape *)>(noop));
00089     }
00090     return boost::shared_ptr<const CustomShape>(
00091              libmspub::getCustomShape(m_type.get_value_or(RECTANGLE)),
00092              boost::function<void (const CustomShape *)>(noop));
00093   }
00094 };
00095 }
00096 #endif
00097 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */