1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /*
3  * This file is part of the libmspub project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  */
9 
10 #ifndef INCLUDED_FILL_H
11 #define INCLUDED_FILL_H
12 
13 #include <vector>
14 
15 #include <librevenge/librevenge.h>
16 
17 #include "ColorReference.h"
18 
19 namespace libmspub
20 {
21 class MSPUBCollector;
22 class Fill
23 {
24 protected:
25   const MSPUBCollector *m_owner;
26 public:
27   Fill(const MSPUBCollector *owner);
28   virtual void getProperties(librevenge::RVNGPropertyList *out) const = 0;
~Fill()29   virtual ~Fill() { }
30 private:
Fill(const Fill &)31   Fill(const Fill &) : m_owner(nullptr) { }
32   Fill &operator=(const Fill &);
33 };
34 
35 class ImgFill : public Fill
36 {
37 protected:
38   unsigned m_imgIndex;
39 private:
40   bool m_isTexture;
41 protected:
42   int m_rotation;
43 public:
44   ImgFill(unsigned imgIndex, const MSPUBCollector *owner, bool isTexture, int rotation);
45   void getProperties(librevenge::RVNGPropertyList *out) const override;
46 private:
ImgFill(const ImgFill &)47   ImgFill(const ImgFill &) : Fill(nullptr), m_imgIndex(0), m_isTexture(false), m_rotation(0) { }
48   ImgFill &operator=(const ImgFill &);
49 };
50 
51 class PatternFill : public ImgFill
52 {
53   ColorReference m_fg;
54   ColorReference m_bg;
55 public:
56   PatternFill(unsigned imgIndex, const MSPUBCollector *owner, ColorReference fg, ColorReference bg);
57   void getProperties(librevenge::RVNGPropertyList *out) const override;
58 private:
PatternFill(const PatternFill &)59   PatternFill(const PatternFill &) : ImgFill(0, nullptr, true, 0), m_fg(0x08000000), m_bg(0x08000000) { }
60   PatternFill &operator=(const ImgFill &);
61 };
62 
63 class SolidFill : public Fill
64 {
65   ColorReference m_color;
66   double m_opacity;
67 public:
68   SolidFill(ColorReference color, double opacity, const MSPUBCollector *owner);
69   void getProperties(librevenge::RVNGPropertyList *out) const override;
70 private:
SolidFill(const SolidFill &)71   SolidFill(const SolidFill &) : Fill(nullptr), m_color(0x08000000), m_opacity(1) { }
72   SolidFill &operator=(const SolidFill &);
73 };
74 
75 class GradientFill : public Fill
76 {
77   struct StopInfo
78   {
79     ColorReference m_colorReference;
80     unsigned m_offsetPercent;
81     double m_opacity;
StopInfoStopInfo82     StopInfo(ColorReference colorReference, unsigned offsetPercent, double opacity) : m_colorReference(colorReference), m_offsetPercent(offsetPercent), m_opacity(opacity) { }
83   };
84   std::vector<StopInfo> m_stops;
85   double m_angle;
86   int m_type;
87   double m_fillLeftVal;
88   double m_fillTopVal;
89   double m_fillRightVal;
90   double m_fillBottomVal;
91 public:
92   GradientFill(const MSPUBCollector *owner, double angle = 0, int type = 7);
93   void setFillCenter(double left, double top, double right, double bottom);
94   void addColor(ColorReference c, unsigned offsetPercent, double opacity);
95   void addColorReverse(ColorReference c, unsigned offsetPercent, double opacity);
96   void completeComplexFill();
97   void getProperties(librevenge::RVNGPropertyList *out) const override;
98 private:
GradientFill(const GradientFill &)99   GradientFill(const GradientFill &) : Fill(nullptr), m_stops(), m_angle(0), m_type(7), m_fillLeftVal(0.0), m_fillTopVal(0.0), m_fillRightVal(0.0), m_fillBottomVal(0.0) { }
100   GradientFill &operator=(const GradientFill &);
101 };
102 }
103 
104 #endif /* INCLUDED_FILL_H */
105 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
106