ShapeInfo.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* libmspub
00003  * Version: MPL 1.1 / GPLv2+ / LGPLv2+
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License or as specified alternatively below. You may obtain a copy of
00008  * the License at http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * Major Contributor(s):
00016  * Copyright (C) 2012 Brennan Vincent <brennanv@email.arizona.edu>
00017  *
00018  * All Rights Reserved.
00019  *
00020  * For minor contributions see the git repository.
00021  *
00022  * Alternatively, the contents of this file may be used under the terms of
00023  * either the GNU General Public License Version 2 or later (the "GPLv2+"), or
00024  * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
00025  * in which case the provisions of the GPLv2+ or the LGPLv2+ are applicable
00026  * instead of those above.
00027  */
00028 #ifndef __SHAPEINFO_H__
00029 #define __SHAPEINFO_H__
00030 #include <boost/optional.hpp>
00031 #include <boost/shared_ptr.hpp>
00032 #include <map>
00033 #include <vector>
00034 #include <boost/function.hpp>
00035 #include "ShapeType.h"
00036 #include "Coordinate.h"
00037 #include "Line.h"
00038 #include "Margins.h"
00039 #include "MSPUBTypes.h"
00040 #include "Fill.h"
00041 #include "PolygonUtils.h"
00042 #include "Dash.h"
00043 #include "TableInfo.h"
00044 #include "Arrow.h"
00045 #include "VerticalAlign.h"
00046 #include "ColorReference.h"
00047 #include "Shadow.h"
00048 
00049 namespace libmspub
00050 {
00051 void noop(const CustomShape *);
00052 struct ShapeInfo
00053 {
00054   boost::optional<ShapeType> m_type;
00055   boost::optional<ShapeType> m_cropType;
00056   boost::optional<unsigned> m_imgIndex;
00057   boost::optional<unsigned> m_borderImgIndex;
00058   boost::optional<Coordinate> m_coordinates;
00059   std::vector<Line> m_lines;
00060   boost::optional<unsigned> m_pageSeqNum;
00061   boost::optional<unsigned> m_textId;
00062   std::map<unsigned, int> m_adjustValuesByIndex;
00063   std::vector<int> m_adjustValues;
00064   boost::optional<double> m_rotation;
00065   boost::optional<std::pair<bool, bool> > m_flips;
00066   boost::optional<Margins> m_margins;
00067   boost::optional<BorderPosition> m_borderPosition; // Irrelevant except for rectangular shapes
00068   boost::shared_ptr<const Fill> m_fill;
00069   boost::optional<DynamicCustomShape> m_customShape;
00070   bool m_stretchBorderArt;
00071   boost::optional<ColorReference> m_lineBackColor;
00072   boost::optional<Dash> m_dash;
00073   boost::optional<TableInfo> m_tableInfo;
00074   boost::optional<std::vector<unsigned> > m_tableCellTextEnds;
00075   boost::optional<unsigned> m_numColumns;
00076   unsigned m_columnSpacing;
00077   boost::optional<Arrow> m_beginArrow;
00078   boost::optional<Arrow> m_endArrow;
00079   boost::optional<VerticalAlign> m_verticalAlign;
00080   boost::optional<ColorReference> m_pictureRecolor;
00081   boost::optional<Shadow> m_shadow;
00082   boost::optional<int> m_innerRotation;
00083   std::vector<libmspub::Vertex> m_clipPath;
00084   boost::optional<int> m_pictureBrightness;
00085   boost::optional<int> m_pictureContrast;
00086   ShapeInfo() : m_type(), m_cropType(), m_imgIndex(), m_borderImgIndex(),
00087     m_coordinates(), m_lines(), m_pageSeqNum(),
00088     m_textId(), m_adjustValuesByIndex(), m_adjustValues(),
00089     m_rotation(), m_flips(), m_margins(), m_borderPosition(),
00090     m_fill(), m_customShape(), m_stretchBorderArt(false),
00091     m_lineBackColor(), m_dash(), m_tableInfo(),
00092     m_tableCellTextEnds(), m_numColumns(),
00093     m_columnSpacing(0), m_beginArrow(), m_endArrow(),
00094     m_verticalAlign(), m_pictureRecolor(), m_shadow(), m_innerRotation(), m_clipPath(), m_pictureBrightness(), m_pictureContrast()
00095   {
00096   }
00097   boost::shared_ptr<const CustomShape> getCustomShape() const
00098   {
00099     if (!!m_customShape)
00100     {
00101       return getFromDynamicCustomShape(m_customShape.get());
00102     }
00103     if (!!m_cropType)
00104     {
00105       return boost::shared_ptr<const CustomShape>(
00106                libmspub::getCustomShape(m_cropType.get()),
00107                boost::function<void (const CustomShape *)>(noop));
00108     }
00109     return boost::shared_ptr<const CustomShape>(
00110              libmspub::getCustomShape(m_type.get_value_or(RECTANGLE)),
00111              boost::function<void (const CustomShape *)>(noop));
00112   }
00113 };
00114 }
00115 #endif
00116 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */