Fill.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 
00029 #ifndef __FILL_H__
00030 #define __FILL_H__
00031 
00032 #include <cstddef>
00033 
00034 #include <vector>
00035 
00036 #include <libwpd/libwpd.h>
00037 
00038 #include "ColorReference.h"
00039 
00040 namespace libmspub
00041 {
00042 class MSPUBCollector;
00043 class Fill
00044 {
00045 protected:
00046   const MSPUBCollector *m_owner;
00047 public:
00048   Fill(const MSPUBCollector *owner);
00049   virtual WPXPropertyListVector getProperties(WPXPropertyList *out) const = 0;
00050   virtual ~Fill() { }
00051 private:
00052   Fill(const Fill &) : m_owner(NULL) { }
00053   Fill &operator=(const Fill &);
00054 };
00055 
00056 class ImgFill : public Fill
00057 {
00058 protected:
00059   unsigned m_imgIndex;
00060 private:
00061   bool m_isTexture;
00062 protected:
00063   int m_rotation;
00064 public:
00065   ImgFill(unsigned imgIndex, const MSPUBCollector *owner, bool isTexture, int rotation);
00066   virtual WPXPropertyListVector getProperties(WPXPropertyList *out) const;
00067 private:
00068   ImgFill(const ImgFill &) : Fill(NULL), m_imgIndex(0), m_isTexture(false), m_rotation(0) { }
00069   ImgFill &operator=(const ImgFill &);
00070 };
00071 
00072 class PatternFill : public ImgFill
00073 {
00074   ColorReference m_fg;
00075   ColorReference m_bg;
00076 public:
00077   PatternFill(unsigned imgIndex, const MSPUBCollector *owner, ColorReference fg, ColorReference bg);
00078   WPXPropertyListVector getProperties(WPXPropertyList *out) const;
00079 private:
00080   PatternFill(const PatternFill &) : ImgFill(0, NULL, true, 0), m_fg(0x08000000), m_bg(0x08000000) { }
00081   PatternFill &operator=(const ImgFill &);
00082 };
00083 
00084 class SolidFill : public Fill
00085 {
00086   ColorReference m_color;
00087   double m_opacity;
00088 public:
00089   SolidFill(ColorReference color, double opacity, const MSPUBCollector *owner);
00090   WPXPropertyListVector getProperties(WPXPropertyList *out) const;
00091 private:
00092   SolidFill(const SolidFill &) : Fill(NULL), m_color(0x08000000), m_opacity(1) { }
00093   SolidFill &operator=(const SolidFill &);
00094 };
00095 
00096 class GradientFill : public Fill
00097 {
00098   struct StopInfo
00099   {
00100     ColorReference m_colorReference;
00101     unsigned m_offsetPercent;
00102     double m_opacity;
00103     StopInfo(ColorReference colorReference, unsigned offsetPercent, double opacity) : m_colorReference(colorReference), m_offsetPercent(offsetPercent), m_opacity(opacity) { }
00104   };
00105   std::vector<StopInfo> m_stops;
00106   double m_angle;
00107   int m_type;
00108   double m_fillLeftVal;
00109   double m_fillTopVal;
00110   double m_fillRightVal;
00111   double m_fillBottomVal;
00112 public:
00113   GradientFill(const MSPUBCollector *owner, double angle = 0, int type = 7);
00114   void setFillCenter(double left, double top, double right, double bottom);
00115   void addColor(ColorReference c, unsigned offsetPercent, double opacity);
00116   void addColorReverse(ColorReference c, unsigned offsetPercent, double opacity);
00117   void completeComplexFill();
00118   WPXPropertyListVector getProperties(WPXPropertyList *out) const;
00119 private:
00120   GradientFill(const GradientFill &) : Fill(NULL), m_stops(), m_angle(0), m_type(7), m_fillLeftVal(0.0), m_fillTopVal(0.0), m_fillRightVal(0.0), m_fillBottomVal(0.0) { }
00121   GradientFill &operator=(const GradientFill &);
00122 };
00123 }
00124 
00125 #endif /* __FILL_H__ */
00126 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */