xref: /aoo41x/main/sfx2/source/sidebar/Paint.cxx (revision ff12d537)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 #include "precompiled_sfx2.hxx"
23 
24 #include "Paint.hxx"
25 
26 namespace sfx2 { namespace sidebar {
27 
28 Paint::Paint (void)
29     : meType(NoPaint)
30 {
31 }
32 
33 
34 
35 
36 Paint::Paint (const Color& rColor)
37     : meType(ColorPaint),
38       maValue(rColor)
39 {
40 }
41 
42 
43 
44 
45 Paint::Paint (const Gradient& rGradient)
46     : meType(GradientPaint),
47       maValue(rGradient)
48 {
49 }
50 
51 
52 
53 
54 void Paint::Set (const Paint& rOther)
55 {
56     meType = rOther.meType;
57     maValue = rOther.maValue;
58 }
59 
60 
61 
62 
63 Paint::Type Paint::GetType (void) const
64 {
65     return meType;
66 }
67 
68 
69 
70 
71 const Color& Paint::GetColor (void) const
72 {
73     if (meType != ColorPaint)
74     {
75         assert(meType==ColorPaint);
76         static Color aErrorColor;
77         return aErrorColor;
78     }
79     else
80         return ::boost::get<Color>(maValue);
81 }
82 
83 
84 
85 
86 const Gradient& Paint::GetGradient (void) const
87 {
88     if (meType != GradientPaint)
89     {
90         assert(meType==GradientPaint);
91         static Gradient aErrorGradient;
92         return aErrorGradient;
93     }
94     else
95         return ::boost::get<Gradient>(maValue);
96 }
97 
98 
99 
100 
101 Wallpaper Paint::GetWallpaper (void) const
102 {
103     switch (meType)
104     {
105         case Paint::NoPaint:
106         default:
107             return Wallpaper();
108             break;
109 
110         case Paint::ColorPaint:
111             return Wallpaper(GetColor());
112             break;
113 
114         case Paint::GradientPaint:
115             return Wallpaper(GetGradient());
116             break;
117     }
118 }
119 
120 
121 } } // end of namespace sfx2::sidebar
122