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 public:
00063   ImgFill(unsigned imgIndex, const MSPUBCollector *owner, bool isTexture);
00064   WPXPropertyListVector getProperties(WPXPropertyList *out) const;
00065 private:
00066   ImgFill(const ImgFill &) : Fill(NULL), m_imgIndex(0), m_isTexture(false) { }
00067   ImgFill &operator=(const ImgFill &);
00068 };
00069 
00070 class PatternFill : public ImgFill
00071 {
00072   ColorReference m_fg;
00073   ColorReference m_bg;
00074 public:
00075   PatternFill(unsigned imgIndex, const MSPUBCollector *owner, ColorReference fg, ColorReference bg);
00076   WPXPropertyListVector getProperties(WPXPropertyList *out) const;
00077 private:
00078   PatternFill(const PatternFill &) : ImgFill(0, NULL, true), m_fg(0x08000000), m_bg(0x08000000) { }
00079   PatternFill &operator=(const ImgFill &);
00080 };
00081 
00082 class SolidFill : public Fill
00083 {
00084   ColorReference m_color;
00085   double m_opacity;
00086 public:
00087   SolidFill(ColorReference color, double opacity, const MSPUBCollector *owner);
00088   WPXPropertyListVector getProperties(WPXPropertyList *out) const;
00089 private:
00090   SolidFill(const SolidFill &) : Fill(NULL), m_color(0x08000000), m_opacity(1) { }
00091   SolidFill &operator=(const SolidFill &);
00092 };
00093 
00094 class GradientFill : public Fill
00095 {
00096   struct StopInfo
00097   {
00098     ColorReference m_colorReference;
00099     unsigned m_offsetPercent;
00100     double m_opacity;
00101     StopInfo(ColorReference colorReference, unsigned offsetPercent, double opacity) : m_colorReference(colorReference), m_offsetPercent(offsetPercent), m_opacity(opacity) { }
00102   };
00103   std::vector<StopInfo> m_stops;
00104   double m_angle;
00105 public:
00106   GradientFill(const MSPUBCollector *owner, double angle = 0);
00107   void addColor(ColorReference c, unsigned offsetPercent, double opacity);
00108   WPXPropertyListVector getProperties(WPXPropertyList *out) const;
00109 private:
00110   GradientFill(const GradientFill &) : Fill(NULL), m_stops(), m_angle(0) { }
00111   GradientFill &operator=(const GradientFill &);
00112 };
00113 }
00114 
00115 #endif /* __FILL_H__ */
00116 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */