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 .
19 #ifndef INCLUDED_SFX2_SIDEBAR_THEME_HXX
20 #define INCLUDED_SFX2_SIDEBAR_THEME_HXX
22 #include <sfx2/dllapi.h>
24 #include <tools/color.hxx>
25 #include <vcl/image.hxx>
26 #include <cppuhelper/compbase2.hxx>
27 #include <cppuhelper/basemutex.hxx>
28 #include <tools/gen.hxx>
29 #include <rtl/ref.hxx>
30 #include <vcl/wall.hxx>
32 #include <com/sun/star/beans/XPropertySet.hpp>
35 #include <unordered_map>
40 namespace sfx2
{ namespace sidebar
{
45 typedef ::cppu::WeakComponentImplHelper2
<
46 css::beans::XPropertySet
,
47 css::beans::XPropertySetInfo
53 /** Simple collection of colors, gradients, fonts that define the
54 look of the sidebar and its controls.
56 class SFX2_DLLPUBLIC Theme
57 : private ::cppu::BaseMutex
,
58 public ThemeInterfaceBase
66 AnyItem_
= Pre_Image_
,
80 Color_TabMenuSeparator
,
89 Paint_DeckTitleBarBackground
,
90 Paint_PanelBackground
,
91 Paint_PanelTitleBarBackground
,
92 Paint_TabBarBackground
,
93 Paint_TabItemBackgroundNormal
,
94 Paint_TabItemBackgroundHighlight
,
95 Paint_HorizontalBorder
,
97 Paint_ToolBoxBackground
,
98 Paint_ToolBoxBorderTopLeft
,
99 Paint_ToolBoxBorderCenterCorners
,
100 Paint_ToolBoxBorderBottomRight
,
101 Paint_DropDownBackground
,
105 Int_DeckTitleBarHeight
,
107 Int_DeckSeparatorHeight
,
108 Int_PanelTitleBarHeight
,
110 Int_TabMenuSeparatorPadding
,
115 Int_DeckRightPadding
,
116 Int_DeckBottomPadding
,
117 Int_TabBarLeftPadding
,
118 Int_TabBarTopPadding
,
119 Int_TabBarRightPadding
,
120 Int_TabBarBottomPadding
,
121 Int_ButtonCornerRadius
,
125 Bool_UseSystemColors
,
126 Bool_IsHighContrastModeActive
,
137 static Image
GetImage (const ThemeItem eItem
);
138 static Color
GetColor (const ThemeItem eItem
);
139 static const Paint
& GetPaint (const ThemeItem eItem
);
140 static const Wallpaper
GetWallpaper (const ThemeItem eItem
);
141 static sal_Int32
GetInteger (const ThemeItem eItem
);
142 static bool GetBoolean (const ThemeItem eItem
);
144 static bool IsHighContrastMode();
146 static void HandleDataChange();
148 void InitializeTheme();
152 Theme(const Theme
&) = delete;
153 Theme
& operator=( const Theme
& ) = delete;
155 virtual void SAL_CALL
disposing() override
;
157 static css::uno::Reference
<css::beans::XPropertySet
> GetPropertySet();
159 // beans::XPropertySet
160 virtual css::uno::Reference
<css::beans::XPropertySetInfo
> SAL_CALL
getPropertySetInfo()
161 throw(css::uno::RuntimeException
, std::exception
) override
;
162 virtual void SAL_CALL
setPropertyValue (
163 const ::rtl::OUString
& rsPropertyName
,
164 const css::uno::Any
& rValue
)
165 throw (css::beans::UnknownPropertyException
,
166 css::uno::RuntimeException
,
167 std::exception
) override
;
168 virtual css::uno::Any SAL_CALL
getPropertyValue (
169 const ::rtl::OUString
& rsPropertyName
)
170 throw(css::beans::UnknownPropertyException
,
171 css::lang::WrappedTargetException
,
172 css::uno::RuntimeException
, std::exception
) override
;
173 virtual void SAL_CALL
addPropertyChangeListener(
174 const ::rtl::OUString
& rsPropertyName
,
175 const css::uno::Reference
<css::beans::XPropertyChangeListener
>& rxListener
)
176 throw(css::beans::UnknownPropertyException
,
177 css::lang::WrappedTargetException
,
178 css::uno::RuntimeException
, std::exception
) override
;
179 virtual void SAL_CALL
removePropertyChangeListener(
180 const ::rtl::OUString
& rsPropertyName
,
181 const css::uno::Reference
<css::beans::XPropertyChangeListener
>& rxListener
)
182 throw(css::beans::UnknownPropertyException
,
183 css::lang::WrappedTargetException
,
184 css::uno::RuntimeException
, std::exception
) override
;
185 virtual void SAL_CALL
addVetoableChangeListener(
186 const ::rtl::OUString
& rsPropertyName
,
187 const css::uno::Reference
<css::beans::XVetoableChangeListener
>& rxListener
)
188 throw(css::beans::UnknownPropertyException
,
189 css::lang::WrappedTargetException
,
190 css::uno::RuntimeException
, std::exception
) override
;
191 virtual void SAL_CALL
removeVetoableChangeListener(
192 const ::rtl::OUString
& rsPropertyName
,
193 const css::uno::Reference
<css::beans::XVetoableChangeListener
>& rxListener
)
194 throw(css::beans::UnknownPropertyException
,
195 css::lang::WrappedTargetException
,
196 css::uno::RuntimeException
, std::exception
) override
;
198 // beans::XPropertySetInfo
199 virtual css::uno::Sequence
<css::beans::Property
> SAL_CALL
getProperties()
200 throw(css::uno::RuntimeException
, std::exception
) override
;
201 virtual css::beans::Property SAL_CALL
getPropertyByName (const ::rtl::OUString
& rsName
)
202 throw(css::beans::UnknownPropertyException
,
203 css::uno::RuntimeException
, std::exception
) override
;
204 virtual sal_Bool SAL_CALL
hasPropertyByName (const ::rtl::OUString
& rsName
)
205 throw(css::uno::RuntimeException
, std::exception
) override
;
208 static Theme
& GetCurrentTheme();
210 std::vector
<Image
> maImages
;
211 std::vector
<Color
> maColors
;
212 std::vector
<Paint
> maPaints
;
213 std::vector
<sal_Int32
> maIntegers
;
214 std::vector
<bool> maBooleans
;
215 std::vector
<Rectangle
> maRectangles
;
216 bool mbIsHighContrastMode
;
217 bool mbIsHighContrastModeSetManually
;
219 typedef std::unordered_map
<rtl::OUString
,ThemeItem
, rtl::OUStringHash
> PropertyNameToIdMap
;
220 PropertyNameToIdMap maPropertyNameToIdMap
;
221 typedef std::vector
<rtl::OUString
> PropertyIdToNameMap
;
222 PropertyIdToNameMap maPropertyIdToNameMap
;
223 typedef ::std::vector
<css::uno::Any
> RawValueContainer
;
224 RawValueContainer maRawValues
;
226 typedef std::vector
<css::uno::Reference
<css::beans::XPropertyChangeListener
> > ChangeListenerContainer
;
227 typedef std::map
<ThemeItem
,ChangeListenerContainer
> ChangeListeners
;
228 ChangeListeners maChangeListeners
;
229 typedef std::vector
<css::uno::Reference
<css::beans::XVetoableChangeListener
> > VetoableListenerContainer
;
230 typedef std::map
<ThemeItem
,VetoableListenerContainer
> VetoableListeners
;
231 VetoableListeners maVetoableListeners
;
244 void SetupPropertyMaps();
246 static PropertyType
GetPropertyType (const ThemeItem eItem
);
247 static css::uno::Type
GetCppuType (const PropertyType eType
);
248 static sal_Int32
GetIndex (
249 const ThemeItem eItem
,
250 const PropertyType eType
);
252 VetoableListenerContainer
* GetVetoableListeners (
253 const ThemeItem eItem
,
255 ChangeListenerContainer
* GetChangeListeners (
256 const ThemeItem eItem
,
258 static bool DoVetoableListenersVeto (
259 const VetoableListenerContainer
* pListeners
,
260 const css::beans::PropertyChangeEvent
& rEvent
);
261 static void BroadcastPropertyChange (
262 const ChangeListenerContainer
* pListeners
,
263 const css::beans::PropertyChangeEvent
& rEvent
);
264 void ProcessNewValue (
265 const css::uno::Any
& rValue
,
266 const ThemeItem eItem
,
267 const PropertyType eType
);
271 } } // end of namespace sfx2::sidebar
275 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */