LibreOffice Module sfx2 (master) 1
Theme.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice 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 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19#pragma once
20
21#include <sfx2/dllapi.h>
22
23#include <tools/color.hxx>
25
26#include <com/sun/star/beans/XPropertySet.hpp>
27
28#include <map>
29#include <unordered_map>
30
31
32namespace sfx2::sidebar {
33
35 css::beans::XPropertySet,
36 css::beans::XPropertySetInfo
38
43 : public ThemeInterfaceBase
44{
45public:
47 {
49 Pre_Color_ = Begin_,
50
51 AnyItem_ = Pre_Color_,
52
54
62
64
71
73
76
78 End_=Post_Bool_
79 };
80
81 static Color GetColor (const ThemeItem eItem);
82 static sal_Int32 GetInteger (const ThemeItem eItem);
83
84 static bool IsHighContrastMode();
85
86 static void HandleDataChange();
87
88 void InitializeTheme();
89
90 Theme();
91 virtual ~Theme() override;
92 Theme(const Theme&) = delete;
93 Theme& operator=( const Theme& ) = delete;
94
95 virtual void disposing(std::unique_lock<std::mutex>&) override;
96
97 static css::uno::Reference<css::beans::XPropertySet> GetPropertySet();
98
99 // beans::XPropertySet
100 virtual css::uno::Reference<css::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() override;
101 virtual void SAL_CALL setPropertyValue (
102 const OUString& rsPropertyName,
103 const css::uno::Any& rValue) override;
104 virtual css::uno::Any SAL_CALL getPropertyValue (
105 const OUString& rsPropertyName) override;
106 virtual void SAL_CALL addPropertyChangeListener(
107 const OUString& rsPropertyName,
108 const css::uno::Reference<css::beans::XPropertyChangeListener>& rxListener) override;
109 virtual void SAL_CALL removePropertyChangeListener(
110 const OUString& rsPropertyName,
111 const css::uno::Reference<css::beans::XPropertyChangeListener>& rxListener) override;
112 virtual void SAL_CALL addVetoableChangeListener(
113 const OUString& rsPropertyName,
114 const css::uno::Reference<css::beans::XVetoableChangeListener>& rxListener) override;
115 virtual void SAL_CALL removeVetoableChangeListener(
116 const OUString& rsPropertyName,
117 const css::uno::Reference<css::beans::XVetoableChangeListener>& rxListener) override;
118
119 // beans::XPropertySetInfo
120 virtual css::uno::Sequence<css::beans::Property> SAL_CALL getProperties() override;
121 virtual css::beans::Property SAL_CALL getPropertyByName (const OUString& rsName) override;
122 virtual sal_Bool SAL_CALL hasPropertyByName (const OUString& rsName) override;
123
124private:
125 static Theme& GetCurrentTheme();
126
127 std::vector<Color> maColors;
128 std::vector<sal_Int32> maIntegers;
129 std::vector<bool> maBooleans;
132
133 typedef std::unordered_map<OUString,ThemeItem> PropertyNameToIdMap;
135 typedef std::vector<OUString> PropertyIdToNameMap;
137 typedef ::std::vector<css::uno::Any> RawValueContainer;
139
140 typedef std::vector<css::uno::Reference<css::beans::XPropertyChangeListener> > ChangeListenerContainer;
141 typedef std::map<ThemeItem,ChangeListenerContainer> ChangeListeners;
143 typedef std::vector<css::uno::Reference<css::beans::XVetoableChangeListener> > VetoableListenerContainer;
144 typedef std::map<ThemeItem,VetoableListenerContainer> VetoableListeners;
146
148 {
152 PT_Invalid
153 };
154
155 void SetupPropertyMaps();
156 void UpdateTheme();
157 static PropertyType GetPropertyType (const ThemeItem eItem);
158 static css::uno::Type const & GetCppuType (const PropertyType eType);
159 static sal_Int32 GetIndex (
160 const ThemeItem eItem,
161 const PropertyType eType);
162
163 VetoableListenerContainer* GetVetoableListeners (
164 const ThemeItem eItem,
165 const bool bCreate);
166 ChangeListenerContainer* GetChangeListeners (
167 const ThemeItem eItem,
168 const bool bCreate);
169 static bool DoVetoableListenersVeto (
170 const VetoableListenerContainer* pListeners,
171 const css::beans::PropertyChangeEvent& rEvent);
172 static void BroadcastPropertyChange (
173 const ChangeListenerContainer* pListeners,
174 const css::beans::PropertyChangeEvent& rEvent);
175 void ProcessNewValue (
176 const css::uno::Any& rValue,
177 const ThemeItem eItem,
178 const PropertyType eType);
179};
180
181
182} // end of namespace sfx2::sidebar
183
184/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Simple collection of colors, gradients, fonts that define the look of the sidebar and its controls.
Definition: Theme.hxx:44
std::map< ThemeItem, VetoableListenerContainer > VetoableListeners
Definition: Theme.hxx:144
std::vector< OUString > PropertyIdToNameMap
Definition: Theme.hxx:135
bool mbIsHighContrastMode
Definition: Theme.hxx:130
std::vector< sal_Int32 > maIntegers
Definition: Theme.hxx:128
std::unordered_map< OUString, ThemeItem > PropertyNameToIdMap
Definition: Theme.hxx:133
std::vector< Color > maColors
Definition: Theme.hxx:127
ChangeListeners maChangeListeners
Definition: Theme.hxx:142
PropertyIdToNameMap maPropertyIdToNameMap
Definition: Theme.hxx:136
std::vector< css::uno::Reference< css::beans::XVetoableChangeListener > > VetoableListenerContainer
Definition: Theme.hxx:143
::std::vector< css::uno::Any > RawValueContainer
Definition: Theme.hxx:137
@ Color_DeckTitleBarBackground
Definition: Theme.hxx:58
@ Color_PanelTitleBarBackground
Definition: Theme.hxx:60
@ Bool_IsHighContrastModeActive
Definition: Theme.hxx:75
std::vector< bool > maBooleans
Definition: Theme.hxx:129
VetoableListeners maVetoableListeners
Definition: Theme.hxx:145
std::map< ThemeItem, ChangeListenerContainer > ChangeListeners
Definition: Theme.hxx:141
Theme & operator=(const Theme &)=delete
PropertyNameToIdMap maPropertyNameToIdMap
Definition: Theme.hxx:134
std::vector< css::uno::Reference< css::beans::XPropertyChangeListener > > ChangeListenerContainer
Definition: Theme.hxx:140
bool mbIsHighContrastModeSetManually
Definition: Theme.hxx:131
Theme(const Theme &)=delete
RawValueContainer maRawValues
Definition: Theme.hxx:138
#define SFX2_DLLPUBLIC
Definition: dllapi.h:29
PropertyType
VBAHELPER_DLLPUBLIC bool setPropertyValue(css::uno::Sequence< css::beans::PropertyValue > &aProp, const OUString &aName, const css::uno::Any &aValue)
comphelper::WeakComponentImplHelper< css::beans::XPropertySet, css::beans::XPropertySetInfo > ThemeInterfaceBase
Definition: Theme.hxx:37
bool getPropertyValue(ValueType &rValue, css::uno::Reference< css::beans::XPropertySet > const &xPropSet, OUString const &propName)
const css::uno::Type * GetPropertyType(sal_uInt16 nPropertyId)
#define End_(_nam)
unsigned char sal_Bool