Fill.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* libmspub
3  * Version: MPL 1.1 / GPLv2+ / LGPLv2+
4  *
5  * The contents of this file are subject to the Mozilla Public License Version
6  * 1.1 (the "License"); you may not use this file except in compliance with
7  * the License or as specified alternatively below. You may obtain a copy of
8  * the License at http://www.mozilla.org/MPL/
9  *
10  * Software distributed under the License is distributed on an "AS IS" basis,
11  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12  * for the specific language governing rights and limitations under the
13  * License.
14  *
15  * Major Contributor(s):
16  * Copyright (C) 2012 Brennan Vincent <brennanv@email.arizona.edu>
17  *
18  * All Rights Reserved.
19  *
20  * For minor contributions see the git repository.
21  *
22  * Alternatively, the contents of this file may be used under the terms of
23  * either the GNU General Public License Version 2 or later (the "GPLv2+"), or
24  * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
25  * in which case the provisions of the GPLv2+ or the LGPLv2+ are applicable
26  * instead of those above.
27  */
28 
29 #ifndef __FILL_H__
30 #define __FILL_H__
31 
32 #include <cstddef>
33 
34 #include <vector>
35 
36 #include <libwpd/libwpd.h>
37 
38 #include "ColorReference.h"
39 
40 namespace libmspub
41 {
42 class MSPUBCollector;
43 class Fill
44 {
45 protected:
47 public:
48  Fill(const MSPUBCollector *owner);
49  virtual WPXPropertyListVector getProperties(WPXPropertyList *out) const = 0;
50  virtual ~Fill() { }
51 private:
52  Fill(const Fill &) : m_owner(NULL) { }
53  Fill &operator=(const Fill &);
54 };
55 
56 class ImgFill : public Fill
57 {
58 protected:
59  unsigned m_imgIndex;
60 private:
62 protected:
64 public:
65  ImgFill(unsigned imgIndex, const MSPUBCollector *owner, bool isTexture, int rotation);
66  virtual WPXPropertyListVector getProperties(WPXPropertyList *out) const;
67 private:
68  ImgFill(const ImgFill &) : Fill(NULL), m_imgIndex(0), m_isTexture(false), m_rotation(0) { }
69  ImgFill &operator=(const ImgFill &);
70 };
71 
72 class PatternFill : public ImgFill
73 {
76 public:
77  PatternFill(unsigned imgIndex, const MSPUBCollector *owner, ColorReference fg, ColorReference bg);
78  WPXPropertyListVector getProperties(WPXPropertyList *out) const;
79 private:
80  PatternFill(const PatternFill &) : ImgFill(0, NULL, true, 0), m_fg(0x08000000), m_bg(0x08000000) { }
81  PatternFill &operator=(const ImgFill &);
82 };
83 
84 class SolidFill : public Fill
85 {
87  double m_opacity;
88 public:
89  SolidFill(ColorReference color, double opacity, const MSPUBCollector *owner);
90  WPXPropertyListVector getProperties(WPXPropertyList *out) const;
91 private:
92  SolidFill(const SolidFill &) : Fill(NULL), m_color(0x08000000), m_opacity(1) { }
93  SolidFill &operator=(const SolidFill &);
94 };
95 
96 class GradientFill : public Fill
97 {
98  struct StopInfo
99  {
101  unsigned m_offsetPercent;
102  double m_opacity;
103  StopInfo(ColorReference colorReference, unsigned offsetPercent, double opacity) : m_colorReference(colorReference), m_offsetPercent(offsetPercent), m_opacity(opacity) { }
104  };
105  std::vector<StopInfo> m_stops;
106  double m_angle;
107  int m_type;
109  double m_fillTopVal;
112 public:
113  GradientFill(const MSPUBCollector *owner, double angle = 0, int type = 7);
114  void setFillCenter(double left, double top, double right, double bottom);
115  void addColor(ColorReference c, unsigned offsetPercent, double opacity);
116  void addColorReverse(ColorReference c, unsigned offsetPercent, double opacity);
117  void completeComplexFill();
118  WPXPropertyListVector getProperties(WPXPropertyList *out) const;
119 private:
122 };
123 }
124 
125 #endif /* __FILL_H__ */
126 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
const MSPUBCollector * m_owner
Definition: Fill.h:46
ImgFill(const ImgFill &)
Definition: Fill.h:68
std::vector< StopInfo > m_stops
Definition: Fill.h:105
SolidFill(const SolidFill &)
Definition: Fill.h:92
void addColorReverse(ColorReference c, unsigned offsetPercent, double opacity)
Definition: Fill.cpp:137
double m_opacity
Definition: Fill.h:102
ColorReference m_color
Definition: Fill.h:86
double m_fillRightVal
Definition: Fill.h:110
Fill(const MSPUBCollector *owner)
Definition: Fill.cpp:36
ImgFill(unsigned imgIndex, const MSPUBCollector *owner, bool isTexture, int rotation)
Definition: Fill.cpp:40
GradientFill(const MSPUBCollector *owner, double angle=0, int type=7)
Definition: Fill.cpp:120
ImgFill & operator=(const ImgFill &)
double m_fillBottomVal
Definition: Fill.h:111
WPXPropertyListVector getProperties(WPXPropertyList *out) const
Definition: Fill.cpp:152
Definition: Fill.h:43
int m_type
Definition: Fill.h:107
StopInfo(ColorReference colorReference, unsigned offsetPercent, double opacity)
Definition: Fill.h:103
PatternFill & operator=(const ImgFill &)
GradientFill & operator=(const GradientFill &)
double m_angle
Definition: Fill.h:106
Definition: Fill.h:56
WPXPropertyListVector getProperties(WPXPropertyList *out) const
Definition: Fill.cpp:108
bool m_isTexture
Definition: Fill.h:61
PatternFill(const PatternFill &)
Definition: Fill.h:80
void completeComplexFill()
Definition: Fill.cpp:142
ColorReference m_fg
Definition: Fill.h:74
Definition: Fill.h:72
Definition: ColorReference.h:36
ColorReference m_colorReference
Definition: Fill.h:100
virtual ~Fill()
Definition: Fill.h:50
Definition: Fill.h:96
SolidFill & operator=(const SolidFill &)
int m_rotation
Definition: Fill.h:63
void setFillCenter(double left, double top, double right, double bottom)
Definition: Fill.cpp:124
virtual WPXPropertyListVector getProperties(WPXPropertyList *out) const =0
unsigned m_offsetPercent
Definition: Fill.h:101
SolidFill(ColorReference color, double opacity, const MSPUBCollector *owner)
Definition: Fill.cpp:104
virtual WPXPropertyListVector getProperties(WPXPropertyList *out) const
Definition: Fill.cpp:44
unsigned m_imgIndex
Definition: Fill.h:59
PatternFill(unsigned imgIndex, const MSPUBCollector *owner, ColorReference fg, ColorReference bg)
Definition: Fill.cpp:67
ColorReference m_bg
Definition: Fill.h:75
double m_fillLeftVal
Definition: Fill.h:108
void addColor(ColorReference c, unsigned offsetPercent, double opacity)
Definition: Fill.cpp:132
Fill & operator=(const Fill &)
Definition: MSPUBCollector.h:66
GradientFill(const GradientFill &)
Definition: Fill.h:120
Definition: Fill.h:84
double m_fillTopVal
Definition: Fill.h:109
Fill(const Fill &)
Definition: Fill.h:52
double m_opacity
Definition: Fill.h:87
WPXPropertyListVector getProperties(WPXPropertyList *out) const
Definition: Fill.cpp:71

Generated for libmspub by doxygen 1.8.6