1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <sfx2/sidebar/Tools.hxx>
21 #include <com/sun/star/awt/Gradient.hpp>
25 namespace sfx2
{ namespace sidebar
{
32 Paint::Paint (const Color
& rColor
)
38 Paint::Paint (const Gradient
& rGradient
)
39 : meType(GradientPaint
),
44 Paint
Paint::Create (const css::uno::Any
& rValue
)
47 if (rValue
>>= aColor
)
48 return Paint(Color(aColor
));
50 awt::Gradient aAwtGradient
;
51 if (rValue
>>= aAwtGradient
)
52 return Paint(Tools::AwtToVclGradient(aAwtGradient
));
57 const Color
& Paint::GetColor() const
59 if (meType
!= ColorPaint
)
61 assert(meType
==ColorPaint
);
62 static Color aErrorColor
;
66 return ::boost::get
<Color
>(maValue
);
69 const Gradient
& Paint::GetGradient() const
71 if (meType
!= GradientPaint
)
73 assert(meType
==GradientPaint
);
74 static Gradient aErrorGradient
;
75 return aErrorGradient
;
78 return ::boost::get
<Gradient
>(maValue
);
81 Wallpaper
Paint::GetWallpaper() const
90 case Paint::ColorPaint
:
91 return Wallpaper(GetColor());
94 case Paint::GradientPaint
:
95 return Wallpaper(GetGradient());
100 } } // end of namespace sfx2::sidebar
102 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */