Theme.cxx (2b6825c7) Theme.cxx (9f759e1c)
1/**************************************************************
1/**************************************************************
2 *
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
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 *
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
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.
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 *
19 *
20 *************************************************************/
21
20 *************************************************************/
21
22
23
22#include "precompiled_sfx2.hxx"
23
24#include "sfx2/sidebar/Theme.hxx"
25#include "Paint.hxx"
26#include "SidebarResource.hxx"
27#include "sfx2/sidebar/Tools.hxx"
28
29#include <tools/svborder.hxx>

--- 4 unchanged lines hidden (view full) ---

34using namespace cssu;
35
36
37namespace sfx2 { namespace sidebar {
38
39::rtl::Reference<Theme> Theme::mpInstance;
40
41
24#include "precompiled_sfx2.hxx"
25
26#include "sfx2/sidebar/Theme.hxx"
27#include "Paint.hxx"
28#include "SidebarResource.hxx"
29#include "sfx2/sidebar/Tools.hxx"
30
31#include <tools/svborder.hxx>

--- 4 unchanged lines hidden (view full) ---

36using namespace cssu;
37
38
39namespace sfx2 { namespace sidebar {
40
41::rtl::Reference<Theme> Theme::mpInstance;
42
43
42
43
44Theme& Theme::GetCurrentTheme (void)
45{
44Theme& Theme::GetCurrentTheme (void)
45{
46 if ( ! mpInstance.is())
47 {
48 mpInstance.set(new Theme());
49 mpInstance->InitializeTheme();
50 }
51 return *mpInstance;
46 if ( ! mpInstance.is())
47 {
48 mpInstance.set(new Theme());
49 mpInstance->InitializeTheme();
50 }
51 return *mpInstance;
52}
53
54
52}
53
54
55
56
57Theme::Theme (void)
55Theme::Theme (void)
58 : ThemeInterfaceBase(m_aMutex),
59 maImages(),
60 maColors(),
61 maPaints(),
62 maIntegers(),
63 maBooleans(),
64 mbIsHighContrastMode(Application::GetSettings().GetStyleSettings().GetHighContrastMode()),
65 mbIsHighContrastModeSetManually(false),
66 maPropertyNameToIdMap(),
67 maPropertyIdToNameMap(),
68 maRawValues(),
69 maChangeListeners(),
70 maVetoableListeners()
56 : ThemeInterfaceBase(m_aMutex),
57 maImages(),
58 maColors(),
59 maPaints(),
60 maIntegers(),
61 maBooleans(),
62 mbIsHighContrastMode(Application::GetSettings().GetStyleSettings().GetHighContrastMode()),
63 mbIsHighContrastModeSetManually(false),
64 maPropertyNameToIdMap(),
65 maPropertyIdToNameMap(),
66 maRawValues(),
67 maChangeListeners(),
68 maVetoableListeners()
71
72{
69
70{
73 SetupPropertyMaps();
71 SetupPropertyMaps();
74}
75
76
72}
73
74
77
78
79Theme::~Theme (void)
80{
81}
82
83
75Theme::~Theme (void)
76{
77}
78
79
84
85
86Image Theme::GetImage (const ThemeItem eItem)
87{
80Image Theme::GetImage (const ThemeItem eItem)
81{
88 const PropertyType eType (GetPropertyType(eItem));
89 OSL_ASSERT(eType==PT_Image);
90 const sal_Int32 nIndex (GetIndex(eItem, eType));
91 const Theme& rTheme (GetCurrentTheme());
92 return rTheme.maImages[nIndex];
82 const PropertyType eType (GetPropertyType(eItem));
83 OSL_ASSERT(eType==PT_Image);
84 const sal_Int32 nIndex (GetIndex(eItem, eType));
85 const Theme& rTheme (GetCurrentTheme());
86 return rTheme.maImages[nIndex];
93}
94
95
87}
88
89
96
97
98Color Theme::GetColor (const ThemeItem eItem)
99{
90Color Theme::GetColor (const ThemeItem eItem)
91{
100 const PropertyType eType (GetPropertyType(eItem));
101 OSL_ASSERT(eType==PT_Color || eType==PT_Paint);
102 const sal_Int32 nIndex (GetIndex(eItem, eType));
103 const Theme& rTheme (GetCurrentTheme());
104 if (eType == PT_Color)
105 return rTheme.maColors[nIndex];
106 else if (eType == PT_Paint)
107 return rTheme.maPaints[nIndex].GetColor();
108 else
109 return COL_WHITE;
92 const PropertyType eType (GetPropertyType(eItem));
93 OSL_ASSERT(eType==PT_Color || eType==PT_Paint);
94 const sal_Int32 nIndex (GetIndex(eItem, eType));
95 const Theme& rTheme (GetCurrentTheme());
96 if (eType == PT_Color)
97 return rTheme.maColors[nIndex];
98 else if (eType == PT_Paint)
99 return rTheme.maPaints[nIndex].GetColor();
100 else
101 return COL_WHITE;
110}
111
112
102}
103
104
113
114
115const Paint& Theme::GetPaint (const ThemeItem eItem)
116{
105const Paint& Theme::GetPaint (const ThemeItem eItem)
106{
117 const PropertyType eType (GetPropertyType(eItem));
118 OSL_ASSERT(eType==PT_Paint);
119 const sal_Int32 nIndex (GetIndex(eItem, eType));
120 const Theme& rTheme (GetCurrentTheme());
121 return rTheme.maPaints[nIndex];
107 const PropertyType eType (GetPropertyType(eItem));
108 OSL_ASSERT(eType==PT_Paint);
109 const sal_Int32 nIndex (GetIndex(eItem, eType));
110 const Theme& rTheme (GetCurrentTheme());
111 return rTheme.maPaints[nIndex];
122}
123
124
112}
113
114
125
126
127const Wallpaper Theme::GetWallpaper (const ThemeItem eItem)
128{
115const Wallpaper Theme::GetWallpaper (const ThemeItem eItem)
116{
129 return GetPaint(eItem).GetWallpaper();
117 return GetPaint(eItem).GetWallpaper();
130}
131
132
118}
119
120
133
134
135sal_Int32 Theme::GetInteger (const ThemeItem eItem)
136{
121sal_Int32 Theme::GetInteger (const ThemeItem eItem)
122{
137 const PropertyType eType (GetPropertyType(eItem));
138 OSL_ASSERT(eType==PT_Integer);
139 const sal_Int32 nIndex (GetIndex(eItem, eType));
140 const Theme& rTheme (GetCurrentTheme());
141 return rTheme.maIntegers[nIndex];
123 const PropertyType eType (GetPropertyType(eItem));
124 OSL_ASSERT(eType==PT_Integer);
125 const sal_Int32 nIndex (GetIndex(eItem, eType));
126 const Theme& rTheme (GetCurrentTheme());
127 return rTheme.maIntegers[nIndex];
142}
143
144
128}
129
130
145
146
147bool Theme::GetBoolean (const ThemeItem eItem)
148{
131bool Theme::GetBoolean (const ThemeItem eItem)
132{
149 const PropertyType eType (GetPropertyType(eItem));
150 OSL_ASSERT(eType==PT_Boolean);
151 const sal_Int32 nIndex (GetIndex(eItem, eType));
152 const Theme& rTheme (GetCurrentTheme());
153 return rTheme.maBooleans[nIndex];
133 const PropertyType eType (GetPropertyType(eItem));
134 OSL_ASSERT(eType==PT_Boolean);
135 const sal_Int32 nIndex (GetIndex(eItem, eType));
136 const Theme& rTheme (GetCurrentTheme());
137 return rTheme.maBooleans[nIndex];
154}
155
156
138}
139
140
157
158
159Rectangle Theme::GetRectangle (const ThemeItem eItem)
160{
141Rectangle Theme::GetRectangle (const ThemeItem eItem)
142{
161 const PropertyType eType (GetPropertyType(eItem));
162 OSL_ASSERT(eType==PT_Rectangle);
163 const sal_Int32 nIndex (GetIndex(eItem, eType));
164 const Theme& rTheme (GetCurrentTheme());
165 return rTheme.maRectangles[nIndex];
143 const PropertyType eType (GetPropertyType(eItem));
144 OSL_ASSERT(eType==PT_Rectangle);
145 const sal_Int32 nIndex (GetIndex(eItem, eType));
146 const Theme& rTheme (GetCurrentTheme());
147 return rTheme.maRectangles[nIndex];
166}
167
168
148}
149
150
169
170
171bool Theme::IsHighContrastMode (void)
172{
151bool Theme::IsHighContrastMode (void)
152{
173 const Theme& rTheme (GetCurrentTheme());
174 return rTheme.mbIsHighContrastMode;
153 const Theme& rTheme (GetCurrentTheme());
154 return rTheme.mbIsHighContrastMode;
175}
176
177
155}
156
157
178
179
180void Theme::HandleDataChange (void)
181{
158void Theme::HandleDataChange (void)
159{
182 Theme& rTheme (GetCurrentTheme());
160 Theme& rTheme (GetCurrentTheme());
183
161
184 if ( ! rTheme.mbIsHighContrastModeSetManually)
185 {
186 // Do not modify mbIsHighContrastMode when it was manually set.
187 GetCurrentTheme().mbIsHighContrastMode = Application::GetSettings().GetStyleSettings().GetHighContrastMode();
188 rTheme.maRawValues[Bool_IsHighContrastModeActive] = Any(GetCurrentTheme().mbIsHighContrastMode);
189 }
162 if ( ! rTheme.mbIsHighContrastModeSetManually)
163 {
164 // Do not modify mbIsHighContrastMode when it was manually set.
165 GetCurrentTheme().mbIsHighContrastMode = Application::GetSettings().GetStyleSettings().GetHighContrastMode();
166 rTheme.maRawValues[Bool_IsHighContrastModeActive] = Any(GetCurrentTheme().mbIsHighContrastMode);
167 }
190
168
191 GetCurrentTheme().UpdateTheme();
169 GetCurrentTheme().UpdateTheme();
192}
193
194
170}
171
172
195
196
197void Theme::InitializeTheme (void)
198{
173void Theme::InitializeTheme (void)
174{
199 setPropertyValue(
200 maPropertyIdToNameMap[Bool_UseSymphonyIcons],
201 Any(false));
202 setPropertyValue(
203 maPropertyIdToNameMap[Bool_UseSystemColors],
204 Any(false));
175 setPropertyValue(
176 maPropertyIdToNameMap[Bool_UseSymphonyIcons],
177 Any(false));
178 setPropertyValue(
179 maPropertyIdToNameMap[Bool_UseSystemColors],
180 Any(false));
205}
206
207
181}
182
183
208
209
210void Theme::UpdateTheme (void)
211{
184void Theme::UpdateTheme (void)
185{
212 SidebarResource aLocalResource;
186 SidebarResource aLocalResource;
213
187
214 try
215 {
216 const StyleSettings& rStyle (Application::GetSettings().GetStyleSettings());
217 const bool bUseSystemColors (GetBoolean(Bool_UseSystemColors));
188 try
189 {
190 const StyleSettings& rStyle (Application::GetSettings().GetStyleSettings());
191 const bool bUseSystemColors (GetBoolean(Bool_UseSystemColors));
218
219#define Alternatives(n,hc,sys) (mbIsHighContrastMode ? hc : (bUseSystemColors ? sys : n))
220
192
193#define Alternatives(n,hc,sys) (mbIsHighContrastMode ? hc : (bUseSystemColors ? sys : n))
194
221 Color aBaseBackgroundColor (rStyle.GetDialogColor());
222 // UX says this should be a little brighter, but that looks off when compared to the other windows.
223 //aBaseBackgroundColor.IncreaseLuminance(7);
224 Color aBorderColor (aBaseBackgroundColor);
225 aBorderColor.DecreaseLuminance(15);
226 Color aSecondColor (aBaseBackgroundColor);
227 aSecondColor.DecreaseLuminance(15);
228
229 setPropertyValue(
230 maPropertyIdToNameMap[Paint_DeckBackground],
231 Any(sal_Int32(aBaseBackgroundColor.GetRGBColor())));
195 Color aBaseBackgroundColor (rStyle.GetDialogColor());
196 // UX says this should be a little brighter, but that looks off when compared to the other windows.
197 //aBaseBackgroundColor.IncreaseLuminance(7);
198 Color aBorderColor (aBaseBackgroundColor);
199 aBorderColor.DecreaseLuminance(15);
200 Color aSecondColor (aBaseBackgroundColor);
201 aSecondColor.DecreaseLuminance(15);
232
202
233 setPropertyValue(
234 maPropertyIdToNameMap[Paint_DeckTitleBarBackground],
235 Any(sal_Int32(aBaseBackgroundColor.GetRGBColor())));
236 setPropertyValue(
237 maPropertyIdToNameMap[Int_DeckLeftPadding],
238 Any(sal_Int32(2)));
239 setPropertyValue(
240 maPropertyIdToNameMap[Int_DeckTopPadding],
241 Any(sal_Int32(2)));
242 setPropertyValue(
243 maPropertyIdToNameMap[Int_DeckRightPadding],
244 Any(sal_Int32(2)));
245 setPropertyValue(
246 maPropertyIdToNameMap[Int_DeckBottomPadding],
247 Any(sal_Int32(2)));
248 setPropertyValue(
249 maPropertyIdToNameMap[Int_DeckBorderSize],
250 Any(sal_Int32(1)));
251 setPropertyValue(
252 maPropertyIdToNameMap[Int_DeckSeparatorHeight],
253 Any(sal_Int32(1)));
254 setPropertyValue(
255 maPropertyIdToNameMap[Int_ButtonCornerRadius],
256 Any(sal_Int32(3)));
257 setPropertyValue(
258 maPropertyIdToNameMap[Color_DeckTitleFont],
259 Any(sal_Int32(rStyle.GetFontColor().GetRGBColor())));
260 setPropertyValue(
261 maPropertyIdToNameMap[Int_DeckTitleBarHeight],
262 Any(sal_Int32(Alternatives(
263 26,
264 26,
265 rStyle.GetFloatTitleHeight()))));
266 setPropertyValue(
267 maPropertyIdToNameMap[Paint_PanelBackground],
268 Any(sal_Int32(aBaseBackgroundColor.GetRGBColor())));
269
270 setPropertyValue(
271 maPropertyIdToNameMap[Paint_PanelTitleBarBackground],
272 Any(Tools::VclToAwtGradient(Gradient(
273 GRADIENT_LINEAR,
274 aSecondColor.GetRGBColor(),
275 aBaseBackgroundColor.GetRGBColor()
276 ))));
277 setPropertyValue(
278 maPropertyIdToNameMap[Color_PanelTitleFont],
279 Any(sal_Int32(mbIsHighContrastMode ? 0x00ff00 : 0x262626)));
280 setPropertyValue(
281 maPropertyIdToNameMap[Int_PanelTitleBarHeight],
282 Any(sal_Int32(Alternatives(
283 26,
284 26,
285 rStyle.GetTitleHeight()))));
286 setPropertyValue(
287 maPropertyIdToNameMap[Paint_TabBarBackground],
288 Any(sal_Int32(aBaseBackgroundColor.GetRGBColor())));
289 setPropertyValue(
290 maPropertyIdToNameMap[Int_TabBarLeftPadding],
291 Any(sal_Int32(2)));
292 setPropertyValue(
293 maPropertyIdToNameMap[Int_TabBarTopPadding],
294 Any(sal_Int32(2)));
295 setPropertyValue(
296 maPropertyIdToNameMap[Int_TabBarRightPadding],
297 Any(sal_Int32(2)));
298 setPropertyValue(
299 maPropertyIdToNameMap[Int_TabBarBottomPadding],
300 Any(sal_Int32(2)));
203 setPropertyValue(
204 maPropertyIdToNameMap[Paint_DeckBackground],
205 Any(sal_Int32(aBaseBackgroundColor.GetRGBColor())));
301
206
302 setPropertyValue(
303 maPropertyIdToNameMap[Int_TabMenuPadding],
304 Any(sal_Int32(6)));
305 setPropertyValue(
306 maPropertyIdToNameMap[Color_TabMenuSeparator],
307 Any(sal_Int32(aBorderColor.GetRGBColor())));
308 setPropertyValue(
309 maPropertyIdToNameMap[Int_TabMenuSeparatorPadding],
310 Any(sal_Int32(7)));
311
312 setPropertyValue(
313 maPropertyIdToNameMap[Int_TabItemWidth],
314 Any(sal_Int32(32)));
315 setPropertyValue(
316 maPropertyIdToNameMap[Int_TabItemHeight],
317 Any(sal_Int32(32)));
318 setPropertyValue(
319 maPropertyIdToNameMap[Color_TabItemBorder],
320 Any(sal_Int32(rStyle.GetActiveBorderColor().GetRGBColor())));
321 // mbIsHighContrastMode ? 0x00ff00 : 0xbfbfbf)));
207 setPropertyValue(
208 maPropertyIdToNameMap[Paint_DeckTitleBarBackground],
209 Any(sal_Int32(aBaseBackgroundColor.GetRGBColor())));
210 setPropertyValue(
211 maPropertyIdToNameMap[Int_DeckLeftPadding],
212 Any(sal_Int32(2)));
213 setPropertyValue(
214 maPropertyIdToNameMap[Int_DeckTopPadding],
215 Any(sal_Int32(2)));
216 setPropertyValue(
217 maPropertyIdToNameMap[Int_DeckRightPadding],
218 Any(sal_Int32(2)));
219 setPropertyValue(
220 maPropertyIdToNameMap[Int_DeckBottomPadding],
221 Any(sal_Int32(2)));
222 setPropertyValue(
223 maPropertyIdToNameMap[Int_DeckBorderSize],
224 Any(sal_Int32(1)));
225 setPropertyValue(
226 maPropertyIdToNameMap[Int_DeckSeparatorHeight],
227 Any(sal_Int32(1)));
228 setPropertyValue(
229 maPropertyIdToNameMap[Int_ButtonCornerRadius],
230 Any(sal_Int32(3)));
231 setPropertyValue(
232 maPropertyIdToNameMap[Color_DeckTitleFont],
233 Any(sal_Int32(rStyle.GetFontColor().GetRGBColor())));
234 setPropertyValue(
235 maPropertyIdToNameMap[Int_DeckTitleBarHeight],
236 Any(sal_Int32(Alternatives(
237 26,
238 26,
239 rStyle.GetFloatTitleHeight()))));
240 setPropertyValue(
241 maPropertyIdToNameMap[Paint_PanelBackground],
242 Any(sal_Int32(aBaseBackgroundColor.GetRGBColor())));
322
243
323 setPropertyValue(
324 maPropertyIdToNameMap[Paint_DropDownBackground],
325 Any(sal_Int32(aBaseBackgroundColor.GetRGBColor())));
326 setPropertyValue(
327 maPropertyIdToNameMap[Color_DropDownBorder],
328 Any(sal_Int32(rStyle.GetActiveBorderColor().GetRGBColor())));
244 setPropertyValue(
245 maPropertyIdToNameMap[Paint_PanelTitleBarBackground],
246 Any(Tools::VclToAwtGradient(Gradient(
247 GRADIENT_LINEAR,
248 aSecondColor.GetRGBColor(),
249 aBaseBackgroundColor.GetRGBColor()
250 ))));
251 setPropertyValue(
252 maPropertyIdToNameMap[Color_PanelTitleFont],
253 Any(sal_Int32(mbIsHighContrastMode ? 0x00ff00 : 0x262626)));
254 setPropertyValue(
255 maPropertyIdToNameMap[Int_PanelTitleBarHeight],
256 Any(sal_Int32(Alternatives(
257 26,
258 26,
259 rStyle.GetTitleHeight()))));
260 setPropertyValue(
261 maPropertyIdToNameMap[Paint_TabBarBackground],
262 Any(sal_Int32(aBaseBackgroundColor.GetRGBColor())));
263 setPropertyValue(
264 maPropertyIdToNameMap[Int_TabBarLeftPadding],
265 Any(sal_Int32(2)));
266 setPropertyValue(
267 maPropertyIdToNameMap[Int_TabBarTopPadding],
268 Any(sal_Int32(2)));
269 setPropertyValue(
270 maPropertyIdToNameMap[Int_TabBarRightPadding],
271 Any(sal_Int32(2)));
272 setPropertyValue(
273 maPropertyIdToNameMap[Int_TabBarBottomPadding],
274 Any(sal_Int32(2)));
329
275
330 setPropertyValue(
331 maPropertyIdToNameMap[Color_Highlight],
332 Any(sal_Int32(rStyle.GetHighlightColor().GetRGBColor())));
333 setPropertyValue(
334 maPropertyIdToNameMap[Color_HighlightText],
335 Any(sal_Int32(rStyle.GetHighlightTextColor().GetRGBColor())));
276 setPropertyValue(
277 maPropertyIdToNameMap[Int_TabMenuPadding],
278 Any(sal_Int32(6)));
279 setPropertyValue(
280 maPropertyIdToNameMap[Color_TabMenuSeparator],
281 Any(sal_Int32(aBorderColor.GetRGBColor())));
282 setPropertyValue(
283 maPropertyIdToNameMap[Int_TabMenuSeparatorPadding],
284 Any(sal_Int32(7)));
336
285
337 setPropertyValue(
338 maPropertyIdToNameMap[Paint_TabItemBackgroundNormal],
339 Any());
340 setPropertyValue(
341 maPropertyIdToNameMap[Paint_TabItemBackgroundHighlight],
342 Any(sal_Int32(rStyle.GetActiveTabColor().GetRGBColor())));
343 // mbIsHighContrastMode ? 0x000000 : 0x00ffffff)));
286 setPropertyValue(
287 maPropertyIdToNameMap[Int_TabItemWidth],
288 Any(sal_Int32(32)));
289 setPropertyValue(
290 maPropertyIdToNameMap[Int_TabItemHeight],
291 Any(sal_Int32(32)));
292 setPropertyValue(
293 maPropertyIdToNameMap[Color_TabItemBorder],
294 Any(sal_Int32(rStyle.GetActiveBorderColor().GetRGBColor())));
295 // mbIsHighContrastMode ? 0x00ff00 : 0xbfbfbf)));
344
296
345 setPropertyValue(
346 maPropertyIdToNameMap[Paint_HorizontalBorder],
347 Any(sal_Int32(aBorderColor.GetRGBColor())));
348 // mbIsHighContrastMode ? 0x00ff00 : 0xe4e4e4)));
349 setPropertyValue(
350 maPropertyIdToNameMap[Paint_VerticalBorder],
351 Any(sal_Int32(aBorderColor.GetRGBColor())));
352 // mbIsHighContrastMode ? 0x00ff00 : 0xe4e4e4)));
297 setPropertyValue(
298 maPropertyIdToNameMap[Paint_DropDownBackground],
299 Any(sal_Int32(aBaseBackgroundColor.GetRGBColor())));
300 setPropertyValue(
301 maPropertyIdToNameMap[Color_DropDownBorder],
302 Any(sal_Int32(rStyle.GetActiveBorderColor().GetRGBColor())));
353
303
354 setPropertyValue(
355 maPropertyIdToNameMap[Image_Grip],
356 Any(
357 mbIsHighContrastMode
358 ? A2S("private:graphicrepository/sfx2/res/grip_hc.png")
359 : A2S("private:graphicrepository/sfx2/res/grip.png")));
360 setPropertyValue(
361 maPropertyIdToNameMap[Image_Expand],
362 Any(
363 mbIsHighContrastMode
364 ? A2S("private:graphicrepository/res/plus_sch.png")
365 : A2S("private:graphicrepository/res/plus.png")));
366 setPropertyValue(
367 maPropertyIdToNameMap[Image_Collapse],
368 Any(
369 mbIsHighContrastMode
370 ? A2S("private:graphicrepository/res/minus_sch.png")
371 : A2S("private:graphicrepository/res/minus.png")));
372 setPropertyValue(
373 maPropertyIdToNameMap[Image_TabBarMenu],
374 Any(
375 mbIsHighContrastMode
376 ? A2S("private:graphicrepository/sfx2/res/menu_hc.png")
377 : A2S("private:graphicrepository/sfx2/res/symphony/open_more.png")));
378 setPropertyValue(
379 maPropertyIdToNameMap[Image_PanelMenu],
380 Any(
381 mbIsHighContrastMode
382 ? A2S("private:graphicrepository/sfx2/res/symphony/morebutton.png")
383 : A2S("private:graphicrepository/sfx2/res/symphony/morebutton_h.png")));
384 setPropertyValue(
385 maPropertyIdToNameMap[Image_Closer],
386 Any(A2S("private:graphicrepository/sfx2/res/closedoc.png")));
387 setPropertyValue(
388 maPropertyIdToNameMap[Image_CloseIndicator],
389 Any(
390 mbIsHighContrastMode
391 ? A2S("private:graphicrepository/res/commandimagelist/lch_decrementlevel.png")
392 : A2S("private:graphicrepository/res/commandimagelist/lc_decrementlevel.png")));
393 setPropertyValue(
394 maPropertyIdToNameMap[Image_ToolBoxItemSeparator],
395 Any(
396 A2S("private:graphicrepository/sfx2/res/separator.png")));
304 setPropertyValue(
305 maPropertyIdToNameMap[Color_Highlight],
306 Any(sal_Int32(rStyle.GetHighlightColor().GetRGBColor())));
307 setPropertyValue(
308 maPropertyIdToNameMap[Color_HighlightText],
309 Any(sal_Int32(rStyle.GetHighlightTextColor().GetRGBColor())));
397
310
398 // ToolBox
311 setPropertyValue(
312 maPropertyIdToNameMap[Paint_TabItemBackgroundNormal],
313 Any());
314 setPropertyValue(
315 maPropertyIdToNameMap[Paint_TabItemBackgroundHighlight],
316 Any(sal_Int32(rStyle.GetActiveTabColor().GetRGBColor())));
317 // mbIsHighContrastMode ? 0x000000 : 0x00ffffff)));
399
318
400 /*
401 // Separator style
402 setPropertyValue(
403 maPropertyIdToNameMap[Paint_ToolBoxBackground],
404 Any(sal_Int32(rStyle.GetMenuColor().GetRGBColor())));
405 setPropertyValue(
406 maPropertyIdToNameMap[Paint_ToolBoxBorderTopLeft],
407 Any());
408 setPropertyValue(
409 maPropertyIdToNameMap[Paint_ToolBoxBorderCenterCorners],
410 Any());
411 setPropertyValue(
412 maPropertyIdToNameMap[Paint_ToolBoxBorderBottomRight],
413 Any());
414 setPropertyValue(
415 maPropertyIdToNameMap[Rect_ToolBoxPadding],
416 Any(awt::Rectangle(2,2,2,2)));
417 setPropertyValue(
418 maPropertyIdToNameMap[Rect_ToolBoxBorder],
419 Any(awt::Rectangle(0,0,0,0)));
420 setPropertyValue(
421 maPropertyIdToNameMap[Bool_UseToolBoxItemSeparator],
422 Any(true));
319 setPropertyValue(
320 maPropertyIdToNameMap[Paint_HorizontalBorder],
321 Any(sal_Int32(aBorderColor.GetRGBColor())));
322 // mbIsHighContrastMode ? 0x00ff00 : 0xe4e4e4)));
323 setPropertyValue(
324 maPropertyIdToNameMap[Paint_VerticalBorder],
325 Any(sal_Int32(aBorderColor.GetRGBColor())));
326 // mbIsHighContrastMode ? 0x00ff00 : 0xe4e4e4)));
423
327
424 */
328 setPropertyValue(
329 maPropertyIdToNameMap[Image_Grip],
330 Any(
331 mbIsHighContrastMode
332 ? A2S("private:graphicrepository/sfx2/res/grip_hc.png")
333 : A2S("private:graphicrepository/sfx2/res/grip.png")));
334 setPropertyValue(
335 maPropertyIdToNameMap[Image_Expand],
336 Any(
337 mbIsHighContrastMode
338 ? A2S("private:graphicrepository/res/plus_sch.png")
339 : A2S("private:graphicrepository/res/plus.png")));
340 setPropertyValue(
341 maPropertyIdToNameMap[Image_Collapse],
342 Any(
343 mbIsHighContrastMode
344 ? A2S("private:graphicrepository/res/minus_sch.png")
345 : A2S("private:graphicrepository/res/minus.png")));
346 setPropertyValue(
347 maPropertyIdToNameMap[Image_TabBarMenu],
348 Any(
349 mbIsHighContrastMode
350 ? A2S("private:graphicrepository/sfx2/res/symphony/open_more_hc.png")
351 : A2S("private:graphicrepository/sfx2/res/symphony/open_more.png")));
352 setPropertyValue(
353 maPropertyIdToNameMap[Image_PanelMenu],
354 Any(
355 mbIsHighContrastMode
356 ? A2S("private:graphicrepository/sfx2/res/symphony/morebutton_h.png")
357 : A2S("private:graphicrepository/sfx2/res/symphony/morebutton.png")));
358 setPropertyValue(
359 maPropertyIdToNameMap[Image_Closer],
360 Any(
361 mbIsHighContrastMode
362 ? A2S("private:graphicrepository/sfx2/res/closedochc.png")
363 : A2S("private:graphicrepository/sfx2/res/closedoc.png")));
364 setPropertyValue(
365 maPropertyIdToNameMap[Image_CloseIndicator],
366 Any(
367 mbIsHighContrastMode
368 ? A2S("private:graphicrepository/res/commandimagelist/lch_decrementlevel.png")
369 : A2S("private:graphicrepository/res/commandimagelist/lc_decrementlevel.png")));
370 setPropertyValue(
371 maPropertyIdToNameMap[Image_ToolBoxItemSeparator],
372 Any(
373 A2S("private:graphicrepository/sfx2/res/separator.png")));
425
374
426 // Gradient style
427 Color aGradientStop2 (aBaseBackgroundColor);
428 aGradientStop2.IncreaseLuminance(17);
429 Color aToolBoxBorderColor (aBaseBackgroundColor);
430 aToolBoxBorderColor.DecreaseLuminance(12);
431 setPropertyValue(
432 maPropertyIdToNameMap[Paint_ToolBoxBackground],
433 Any(Tools::VclToAwtGradient(Gradient(
434 GRADIENT_LINEAR,
435 aBaseBackgroundColor.GetRGBColor(),
436 aGradientStop2.GetRGBColor()
437 ))));
438 setPropertyValue(
439 maPropertyIdToNameMap[Paint_ToolBoxBorderTopLeft],
440 mbIsHighContrastMode
441 ? Any(util::Color(sal_uInt32(0x00ff00)))
442 : Any(util::Color(aToolBoxBorderColor.GetRGBColor())));
443 setPropertyValue(
444 maPropertyIdToNameMap[Paint_ToolBoxBorderCenterCorners],
445 mbIsHighContrastMode
446 ? Any(util::Color(sal_uInt32(0x00ff00)))
447 : Any(util::Color(aToolBoxBorderColor.GetRGBColor())));
448 setPropertyValue(
449 maPropertyIdToNameMap[Paint_ToolBoxBorderBottomRight],
450 mbIsHighContrastMode
451 ? Any(util::Color(sal_uInt32(0x00ff00)))
452 : Any(util::Color(aToolBoxBorderColor.GetRGBColor())));
453 setPropertyValue(
454 maPropertyIdToNameMap[Rect_ToolBoxPadding],
455 Any(awt::Rectangle(2,2,2,2)));
456 setPropertyValue(
457 maPropertyIdToNameMap[Rect_ToolBoxBorder],
458 Any(awt::Rectangle(1,1,1,1)));
459 setPropertyValue(
460 maPropertyIdToNameMap[Bool_UseToolBoxItemSeparator],
461 Any(false));
462 }
463 catch(beans::UnknownPropertyException& rException)
464 {
465 OSL_TRACE("unknown property: %s",
466 OUStringToOString(
467 rException.Message,
468 RTL_TEXTENCODING_ASCII_US).getStr());
469 OSL_ASSERT(false);
470 }
471}
375 // ToolBox
472
376
377 /*
378 // Separator style
379 setPropertyValue(
380 maPropertyIdToNameMap[Paint_ToolBoxBackground],
381 Any(sal_Int32(rStyle.GetMenuColor().GetRGBColor())));
382 setPropertyValue(
383 maPropertyIdToNameMap[Paint_ToolBoxBorderTopLeft],
384 Any());
385 setPropertyValue(
386 maPropertyIdToNameMap[Paint_ToolBoxBorderCenterCorners],
387 Any());
388 setPropertyValue(
389 maPropertyIdToNameMap[Paint_ToolBoxBorderBottomRight],
390 Any());
391 setPropertyValue(
392 maPropertyIdToNameMap[Rect_ToolBoxPadding],
393 Any(awt::Rectangle(2,2,2,2)));
394 setPropertyValue(
395 maPropertyIdToNameMap[Rect_ToolBoxBorder],
396 Any(awt::Rectangle(0,0,0,0)));
397 setPropertyValue(
398 maPropertyIdToNameMap[Bool_UseToolBoxItemSeparator],
399 Any(true));
473
400
401 */
474
402
403 // Gradient style
404 Color aGradientStop2 (aBaseBackgroundColor);
405 aGradientStop2.IncreaseLuminance(17);
406 Color aToolBoxBorderColor (aBaseBackgroundColor);
407 aToolBoxBorderColor.DecreaseLuminance(12);
408 setPropertyValue(
409 maPropertyIdToNameMap[Paint_ToolBoxBackground],
410 Any(Tools::VclToAwtGradient(Gradient(
411 GRADIENT_LINEAR,
412 aBaseBackgroundColor.GetRGBColor(),
413 aGradientStop2.GetRGBColor()
414 ))));
415 setPropertyValue(
416 maPropertyIdToNameMap[Paint_ToolBoxBorderTopLeft],
417 mbIsHighContrastMode
418 ? Any(util::Color(sal_uInt32(0x00ff00)))
419 : Any(util::Color(aToolBoxBorderColor.GetRGBColor())));
420 setPropertyValue(
421 maPropertyIdToNameMap[Paint_ToolBoxBorderCenterCorners],
422 mbIsHighContrastMode
423 ? Any(util::Color(sal_uInt32(0x00ff00)))
424 : Any(util::Color(aToolBoxBorderColor.GetRGBColor())));
425 setPropertyValue(
426 maPropertyIdToNameMap[Paint_ToolBoxBorderBottomRight],
427 mbIsHighContrastMode
428 ? Any(util::Color(sal_uInt32(0x00ff00)))
429 : Any(util::Color(aToolBoxBorderColor.GetRGBColor())));
430 setPropertyValue(
431 maPropertyIdToNameMap[Rect_ToolBoxPadding],
432 Any(awt::Rectangle(2,2,2,2)));
433 setPropertyValue(
434 maPropertyIdToNameMap[Rect_ToolBoxBorder],
435 Any(awt::Rectangle(1,1,1,1)));
436 setPropertyValue(
437 maPropertyIdToNameMap[Bool_UseToolBoxItemSeparator],
438 Any(false));
439 }
440 catch(beans::UnknownPropertyException& rException)
441 {
442 OSL_TRACE("unknown property: %s",
443 OUStringToOString(
444 rException.Message,
445 RTL_TEXTENCODING_ASCII_US).getStr());
446 OSL_ASSERT(false);
447 }
448}
475
449
450
476void SAL_CALL Theme::disposing (void)
477{
451void SAL_CALL Theme::disposing (void)
452{
478 ChangeListeners aListeners;
479 maChangeListeners.swap(aListeners);
453 ChangeListeners aListeners;
454 maChangeListeners.swap(aListeners);
480
455
481 const lang::EventObject aEvent (static_cast<XWeak*>(this));
482
483 for (ChangeListeners::const_iterator
484 iContainer(maChangeListeners.begin()),
485 iContainerEnd(maChangeListeners.end());
486 iContainerEnd!=iContainerEnd;
487 ++iContainerEnd)
488 {
489 for (ChangeListenerContainer::const_iterator
490 iListener(iContainer->second.begin()),
491 iEnd(iContainer->second.end());
492 iListener!=iEnd;
493 ++iListener)
494 {
495 try
496 {
497 (*iListener)->disposing(aEvent);
498 }
499 catch(const Exception&)
500 {
501 }
502 }
503 }
456 const lang::EventObject aEvent (static_cast<XWeak*>(this));
457
458 for (ChangeListeners::const_iterator
459 iContainer(maChangeListeners.begin()),
460 iContainerEnd(maChangeListeners.end());
461 iContainerEnd!=iContainerEnd;
462 ++iContainerEnd)
463 {
464 for (ChangeListenerContainer::const_iterator
465 iListener(iContainer->second.begin()),
466 iEnd(iContainer->second.end());
467 iListener!=iEnd;
468 ++iListener)
469 {
470 try
471 {
472 (*iListener)->disposing(aEvent);
473 }
474 catch(const Exception&)
475 {
476 }
477 }
478 }
504}
505
506
479}
480
481
507
508
509Reference<beans::XPropertySet> Theme::GetPropertySet (void)
510{
482Reference<beans::XPropertySet> Theme::GetPropertySet (void)
483{
511 return Reference<beans::XPropertySet>(static_cast<XWeak*>(&GetCurrentTheme()), UNO_QUERY);
484 return Reference<beans::XPropertySet>(static_cast<XWeak*>(&GetCurrentTheme()), UNO_QUERY);
512}
513
514
485}
486
487
515
516
517Reference<beans::XPropertySetInfo> SAL_CALL Theme::getPropertySetInfo (void)
488Reference<beans::XPropertySetInfo> SAL_CALL Theme::getPropertySetInfo (void)
518 throw(cssu::RuntimeException)
489 throw(cssu::RuntimeException)
519{
490{
520 return Reference<beans::XPropertySetInfo>(this);
491 return Reference<beans::XPropertySetInfo>(this);
521}
522
523
492}
493
494
524
525
526void SAL_CALL Theme::setPropertyValue (
495void SAL_CALL Theme::setPropertyValue (
527 const ::rtl::OUString& rsPropertyName,
528 const cssu::Any& rValue)
529 throw(cssu::RuntimeException)
496 const ::rtl::OUString& rsPropertyName,
497 const cssu::Any& rValue)
498 throw(cssu::RuntimeException)
530{
499{
531 PropertyNameToIdMap::const_iterator iId (maPropertyNameToIdMap.find(rsPropertyName));
532 if (iId == maPropertyNameToIdMap.end())
533 throw beans::UnknownPropertyException(rsPropertyName, NULL);
500 PropertyNameToIdMap::const_iterator iId (maPropertyNameToIdMap.find(rsPropertyName));
501 if (iId == maPropertyNameToIdMap.end())
502 throw beans::UnknownPropertyException(rsPropertyName, NULL);
534
503
535 const PropertyType eType (GetPropertyType(iId->second));
536 if (eType == PT_Invalid)
537 throw beans::UnknownPropertyException(rsPropertyName, NULL);
504 const PropertyType eType (GetPropertyType(iId->second));
505 if (eType == PT_Invalid)
506 throw beans::UnknownPropertyException(rsPropertyName, NULL);
538
507
539 const ThemeItem eItem (iId->second);
540
541 if (rValue == maRawValues[eItem])
542 {
543 // Value is not different from the one in the property
544 // set => nothing to do.
545 return;
546 }
508 const ThemeItem eItem (iId->second);
547
509
548 const Any aOldValue (maRawValues[eItem]);
510 if (rValue == maRawValues[eItem])
511 {
512 // Value is not different from the one in the property
513 // set => nothing to do.
514 return;
515 }
549
516
550 const beans::PropertyChangeEvent aEvent(
551 static_cast<XWeak*>(this),
552 rsPropertyName,
553 sal_False,
554 eItem,
555 aOldValue,
556 rValue);
557
558 if (DoVetoableListenersVeto(GetVetoableListeners(__AnyItem, false), aEvent))
559 return;
560 if (DoVetoableListenersVeto(GetVetoableListeners(eItem, false), aEvent))
561 return;
562
563 maRawValues[eItem] = rValue;
564 ProcessNewValue(rValue, eItem, eType);
517 const Any aOldValue (maRawValues[eItem]);
565
518
566 BroadcastPropertyChange(GetChangeListeners(__AnyItem, false), aEvent);
567 BroadcastPropertyChange(GetChangeListeners(eItem, false), aEvent);
568}
519 const beans::PropertyChangeEvent aEvent(
520 static_cast<XWeak*>(this),
521 rsPropertyName,
522 sal_False,
523 eItem,
524 aOldValue,
525 rValue);
569
526
527 if (DoVetoableListenersVeto(GetVetoableListeners(__AnyItem, false), aEvent))
528 return;
529 if (DoVetoableListenersVeto(GetVetoableListeners(eItem, false), aEvent))
530 return;
570
531
532 maRawValues[eItem] = rValue;
533 ProcessNewValue(rValue, eItem, eType);
571
534
535 BroadcastPropertyChange(GetChangeListeners(__AnyItem, false), aEvent);
536 BroadcastPropertyChange(GetChangeListeners(eItem, false), aEvent);
537}
572
538
539
573Any SAL_CALL Theme::getPropertyValue (
540Any SAL_CALL Theme::getPropertyValue (
574 const ::rtl::OUString& rsPropertyName)
575 throw(css::beans::UnknownPropertyException,
576 css::lang::WrappedTargetException,
577 cssu::RuntimeException)
541 const ::rtl::OUString& rsPropertyName)
542 throw(css::beans::UnknownPropertyException,
543 css::lang::WrappedTargetException,
544 cssu::RuntimeException)
578{
545{
579 PropertyNameToIdMap::const_iterator iId (maPropertyNameToIdMap.find(rsPropertyName));
580 if (iId == maPropertyNameToIdMap.end())
581 throw beans::UnknownPropertyException();
546 PropertyNameToIdMap::const_iterator iId (maPropertyNameToIdMap.find(rsPropertyName));
547 if (iId == maPropertyNameToIdMap.end())
548 throw beans::UnknownPropertyException();
582
549
583 const PropertyType eType (GetPropertyType(iId->second));
584 if (eType == PT_Invalid)
585 throw beans::UnknownPropertyException();
550 const PropertyType eType (GetPropertyType(iId->second));
551 if (eType == PT_Invalid)
552 throw beans::UnknownPropertyException();
586
553
587 const ThemeItem eItem (iId->second);
554 const ThemeItem eItem (iId->second);
588
555
589 return maRawValues[eItem];
556 return maRawValues[eItem];
590}
591
592
557}
558
559
593
594
595void SAL_CALL Theme::addPropertyChangeListener(
560void SAL_CALL Theme::addPropertyChangeListener(
596 const ::rtl::OUString& rsPropertyName,
597 const cssu::Reference<css::beans::XPropertyChangeListener>& rxListener)
598 throw(css::beans::UnknownPropertyException,
599 css::lang::WrappedTargetException,
600 cssu::RuntimeException)
561 const ::rtl::OUString& rsPropertyName,
562 const cssu::Reference<css::beans::XPropertyChangeListener>& rxListener)
563 throw(css::beans::UnknownPropertyException,
564 css::lang::WrappedTargetException,
565 cssu::RuntimeException)
601{
566{
602 ThemeItem eItem (__AnyItem);
603 if (rsPropertyName.getLength() > 0)
604 {
605 PropertyNameToIdMap::const_iterator iId (maPropertyNameToIdMap.find(rsPropertyName));
606 if (iId == maPropertyNameToIdMap.end())
607 throw beans::UnknownPropertyException();
567 ThemeItem eItem (__AnyItem);
568 if (rsPropertyName.getLength() > 0)
569 {
570 PropertyNameToIdMap::const_iterator iId (maPropertyNameToIdMap.find(rsPropertyName));
571 if (iId == maPropertyNameToIdMap.end())
572 throw beans::UnknownPropertyException();
608
573
609 const PropertyType eType (GetPropertyType(iId->second));
610 if (eType == PT_Invalid)
611 throw beans::UnknownPropertyException();
574 const PropertyType eType (GetPropertyType(iId->second));
575 if (eType == PT_Invalid)
576 throw beans::UnknownPropertyException();
612
577
613 eItem = iId->second;
614 }
615 ChangeListenerContainer* pListeners = GetChangeListeners(eItem, true);
616 if (pListeners != NULL)
617 pListeners->push_back(rxListener);
578 eItem = iId->second;
579 }
580 ChangeListenerContainer* pListeners = GetChangeListeners(eItem, true);
581 if (pListeners != NULL)
582 pListeners->push_back(rxListener);
618}
619
620
583}
584
585
621
622
623void SAL_CALL Theme::removePropertyChangeListener(
586void SAL_CALL Theme::removePropertyChangeListener(
624 const ::rtl::OUString& rsPropertyName,
625 const cssu::Reference<css::beans::XPropertyChangeListener>& rxListener)
626 throw(css::beans::UnknownPropertyException,
627 css::lang::WrappedTargetException,
628 cssu::RuntimeException)
587 const ::rtl::OUString& rsPropertyName,
588 const cssu::Reference<css::beans::XPropertyChangeListener>& rxListener)
589 throw(css::beans::UnknownPropertyException,
590 css::lang::WrappedTargetException,
591 cssu::RuntimeException)
629{
592{
630 ThemeItem eItem (__AnyItem);
631 if (rsPropertyName.getLength() > 0)
632 {
633 PropertyNameToIdMap::const_iterator iId (maPropertyNameToIdMap.find(rsPropertyName));
634 if (iId == maPropertyNameToIdMap.end())
635 throw beans::UnknownPropertyException();
593 ThemeItem eItem (__AnyItem);
594 if (rsPropertyName.getLength() > 0)
595 {
596 PropertyNameToIdMap::const_iterator iId (maPropertyNameToIdMap.find(rsPropertyName));
597 if (iId == maPropertyNameToIdMap.end())
598 throw beans::UnknownPropertyException();
636
599
637 const PropertyType eType (GetPropertyType(iId->second));
638 if (eType == PT_Invalid)
639 throw beans::UnknownPropertyException();
600 const PropertyType eType (GetPropertyType(iId->second));
601 if (eType == PT_Invalid)
602 throw beans::UnknownPropertyException();
640
603
641 eItem = iId->second;
642 }
643 ChangeListenerContainer* pContainer = GetChangeListeners(eItem, false);
644 if (pContainer != NULL)
645 {
646 ChangeListenerContainer::iterator iListener (::std::find(pContainer->begin(), pContainer->end(), rxListener));
647 if (iListener != pContainer->end())
648 {
649 pContainer->erase(iListener);
604 eItem = iId->second;
605 }
606 ChangeListenerContainer* pContainer = GetChangeListeners(eItem, false);
607 if (pContainer != NULL)
608 {
609 ChangeListenerContainer::iterator iListener (::std::find(pContainer->begin(), pContainer->end(), rxListener));
610 if (iListener != pContainer->end())
611 {
612 pContainer->erase(iListener);
650
613
651 // Remove the listener container when empty.
652 if (pContainer->empty())
653 maChangeListeners.erase(eItem);
654 }
655 }
614 // Remove the listener container when empty.
615 if (pContainer->empty())
616 maChangeListeners.erase(eItem);
617 }
618 }
656}
657
658
619}
620
621
659
660
661void SAL_CALL Theme::addVetoableChangeListener(
622void SAL_CALL Theme::addVetoableChangeListener(
662 const ::rtl::OUString& rsPropertyName,
663 const cssu::Reference<css::beans::XVetoableChangeListener>& rxListener)
664 throw(css::beans::UnknownPropertyException,
665 css::lang::WrappedTargetException,
666 cssu::RuntimeException)
623 const ::rtl::OUString& rsPropertyName,
624 const cssu::Reference<css::beans::XVetoableChangeListener>& rxListener)
625 throw(css::beans::UnknownPropertyException,
626 css::lang::WrappedTargetException,
627 cssu::RuntimeException)
667{
628{
668 ThemeItem eItem (__AnyItem);
669 if (rsPropertyName.getLength() > 0)
670 {
671 PropertyNameToIdMap::const_iterator iId (maPropertyNameToIdMap.find(rsPropertyName));
672 if (iId == maPropertyNameToIdMap.end())
673 throw beans::UnknownPropertyException();
629 ThemeItem eItem (__AnyItem);
630 if (rsPropertyName.getLength() > 0)
631 {
632 PropertyNameToIdMap::const_iterator iId (maPropertyNameToIdMap.find(rsPropertyName));
633 if (iId == maPropertyNameToIdMap.end())
634 throw beans::UnknownPropertyException();
674
635
675 const PropertyType eType (GetPropertyType(iId->second));
676 if (eType == PT_Invalid)
677 throw beans::UnknownPropertyException();
636 const PropertyType eType (GetPropertyType(iId->second));
637 if (eType == PT_Invalid)
638 throw beans::UnknownPropertyException();
678
639
679 eItem = iId->second;
680 }
681 VetoableListenerContainer* pListeners = GetVetoableListeners(eItem, true);
682 if (pListeners != NULL)
683 pListeners->push_back(rxListener);
640 eItem = iId->second;
641 }
642 VetoableListenerContainer* pListeners = GetVetoableListeners(eItem, true);
643 if (pListeners != NULL)
644 pListeners->push_back(rxListener);
684}
685
686
645}
646
647
687
688
689void SAL_CALL Theme::removeVetoableChangeListener(
648void SAL_CALL Theme::removeVetoableChangeListener(
690 const ::rtl::OUString& rsPropertyName,
691 const cssu::Reference<css::beans::XVetoableChangeListener>& rxListener)
692 throw(css::beans::UnknownPropertyException,
693 css::lang::WrappedTargetException,
694 cssu::RuntimeException)
649 const ::rtl::OUString& rsPropertyName,
650 const cssu::Reference<css::beans::XVetoableChangeListener>& rxListener)
651 throw(css::beans::UnknownPropertyException,
652 css::lang::WrappedTargetException,
653 cssu::RuntimeException)
695{
654{
696 ThemeItem eItem (__AnyItem);
697 if (rsPropertyName.getLength() > 0)
698 {
699 PropertyNameToIdMap::const_iterator iId (maPropertyNameToIdMap.find(rsPropertyName));
700 if (iId == maPropertyNameToIdMap.end())
701 throw beans::UnknownPropertyException();
655 ThemeItem eItem (__AnyItem);
656 if (rsPropertyName.getLength() > 0)
657 {
658 PropertyNameToIdMap::const_iterator iId (maPropertyNameToIdMap.find(rsPropertyName));
659 if (iId == maPropertyNameToIdMap.end())
660 throw beans::UnknownPropertyException();
702
661
703 const PropertyType eType (GetPropertyType(iId->second));
704 if (eType == PT_Invalid)
705 throw beans::UnknownPropertyException();
662 const PropertyType eType (GetPropertyType(iId->second));
663 if (eType == PT_Invalid)
664 throw beans::UnknownPropertyException();
706
665
707 eItem = iId->second;
708 }
709 VetoableListenerContainer* pContainer = GetVetoableListeners(eItem, false);
710 if (pContainer != NULL)
711 {
712 VetoableListenerContainer::iterator iListener (::std::find(pContainer->begin(), pContainer->end(), rxListener));
713 if (iListener != pContainer->end())
714 {
715 pContainer->erase(iListener);
716 // Remove container when empty.
717 if (pContainer->empty())
718 maVetoableListeners.erase(eItem);
719 }
720 }
666 eItem = iId->second;
667 }
668 VetoableListenerContainer* pContainer = GetVetoableListeners(eItem, false);
669 if (pContainer != NULL)
670 {
671 VetoableListenerContainer::iterator iListener (::std::find(pContainer->begin(), pContainer->end(), rxListener));
672 if (iListener != pContainer->end())
673 {
674 pContainer->erase(iListener);
675 // Remove container when empty.
676 if (pContainer->empty())
677 maVetoableListeners.erase(eItem);
678 }
679 }
721}
722
723
680}
681
682
724
725
726cssu::Sequence<css::beans::Property> SAL_CALL Theme::getProperties (void)
683cssu::Sequence<css::beans::Property> SAL_CALL Theme::getProperties (void)
727 throw(cssu::RuntimeException)
684 throw(cssu::RuntimeException)
728{
685{
729 ::std::vector<beans::Property> aProperties;
686 ::std::vector<beans::Property> aProperties;
730
687
731 for (sal_Int32 nItem(__Begin),nEnd(__End); nItem!=nEnd; ++nItem)
732 {
733 const ThemeItem eItem (static_cast<ThemeItem>(nItem));
734 const PropertyType eType (GetPropertyType(eItem));
735 if (eType == PT_Invalid)
736 continue;
688 for (sal_Int32 nItem(__Begin),nEnd(__End); nItem!=nEnd; ++nItem)
689 {
690 const ThemeItem eItem (static_cast<ThemeItem>(nItem));
691 const PropertyType eType (GetPropertyType(eItem));
692 if (eType == PT_Invalid)
693 continue;
737
694
738 const beans::Property aProperty(
739 maPropertyIdToNameMap[eItem],
740 eItem,
741 GetCppuType(eType),
742 0);
743 aProperties.push_back(aProperty);
744 }
745
746 return cssu::Sequence<css::beans::Property>(
747 &aProperties.front(),
748 aProperties.size());
695 const beans::Property aProperty(
696 maPropertyIdToNameMap[eItem],
697 eItem,
698 GetCppuType(eType),
699 0);
700 aProperties.push_back(aProperty);
701 }
702
703 return cssu::Sequence<css::beans::Property>(
704 &aProperties.front(),
705 aProperties.size());
749}
750
751
706}
707
708
752
753
754beans::Property SAL_CALL Theme::getPropertyByName (const ::rtl::OUString& rsPropertyName)
709beans::Property SAL_CALL Theme::getPropertyByName (const ::rtl::OUString& rsPropertyName)
755 throw(css::beans::UnknownPropertyException,
756 cssu::RuntimeException)
710 throw(css::beans::UnknownPropertyException,
711 cssu::RuntimeException)
757{
712{
758 PropertyNameToIdMap::const_iterator iId (maPropertyNameToIdMap.find(rsPropertyName));
759 if (iId == maPropertyNameToIdMap.end())
760 throw beans::UnknownPropertyException();
713 PropertyNameToIdMap::const_iterator iId (maPropertyNameToIdMap.find(rsPropertyName));
714 if (iId == maPropertyNameToIdMap.end())
715 throw beans::UnknownPropertyException();
761
716
762 const PropertyType eType (GetPropertyType(iId->second));
763 if (eType == PT_Invalid)
764 throw beans::UnknownPropertyException();
717 const PropertyType eType (GetPropertyType(iId->second));
718 if (eType == PT_Invalid)
719 throw beans::UnknownPropertyException();
765
720
766 const ThemeItem eItem (iId->second);
721 const ThemeItem eItem (iId->second);
767
722
768 return beans::Property(
769 rsPropertyName,
770 eItem,
771 GetCppuType(eType),
772 0);
723 return beans::Property(
724 rsPropertyName,
725 eItem,
726 GetCppuType(eType),
727 0);
773}
774
775
728}
729
730
776
777
778sal_Bool SAL_CALL Theme::hasPropertyByName (const ::rtl::OUString& rsPropertyName)
731sal_Bool SAL_CALL Theme::hasPropertyByName (const ::rtl::OUString& rsPropertyName)
779 throw(cssu::RuntimeException)
732 throw(cssu::RuntimeException)
780{
733{
781 PropertyNameToIdMap::const_iterator iId (maPropertyNameToIdMap.find(rsPropertyName));
782 if (iId == maPropertyNameToIdMap.end())
783 return sal_False;
734 PropertyNameToIdMap::const_iterator iId (maPropertyNameToIdMap.find(rsPropertyName));
735 if (iId == maPropertyNameToIdMap.end())
736 return sal_False;
784
737
785 const PropertyType eType (GetPropertyType(iId->second));
786 if (eType == PT_Invalid)
787 return sal_False;
738 const PropertyType eType (GetPropertyType(iId->second));
739 if (eType == PT_Invalid)
740 return sal_False;
788
741
789 return sal_True;
742 return sal_True;
790}
791
792
743}
744
745
793
794
795void Theme::SetupPropertyMaps (void)
796{
746void Theme::SetupPropertyMaps (void)
747{
797 maPropertyIdToNameMap.resize(__Post_Rect);
798 maImages.resize(__Image_Color - __Pre_Image - 1);
799 maColors.resize(__Color_Paint - __Image_Color - 1);
800 maPaints.resize(__Paint_Int - __Color_Paint - 1);
801 maIntegers.resize(__Int_Bool - __Paint_Int - 1);
802 maBooleans.resize(__Bool_Rect - __Int_Bool - 1);
803 maRectangles.resize(__Post_Rect - __Bool_Rect - 1);
804
805 #define AddEntry(e) maPropertyNameToIdMap[A2S(#e)]=e; maPropertyIdToNameMap[e]=A2S(#e)
806
807 AddEntry(Image_Grip);
808 AddEntry(Image_Expand);
809 AddEntry(Image_Collapse);
810 AddEntry(Image_TabBarMenu);
811 AddEntry(Image_PanelMenu);
812 AddEntry(Image_ToolBoxItemSeparator);
813 AddEntry(Image_Closer);
814 AddEntry(Image_CloseIndicator);
748 maPropertyIdToNameMap.resize(__Post_Rect);
749 maImages.resize(__Image_Color - __Pre_Image - 1);
750 maColors.resize(__Color_Paint - __Image_Color - 1);
751 maPaints.resize(__Paint_Int - __Color_Paint - 1);
752 maIntegers.resize(__Int_Bool - __Paint_Int - 1);
753 maBooleans.resize(__Bool_Rect - __Int_Bool - 1);
754 maRectangles.resize(__Post_Rect - __Bool_Rect - 1);
815
755
816 AddEntry(Color_DeckTitleFont);
817 AddEntry(Color_PanelTitleFont);
818 AddEntry(Color_TabMenuSeparator);
819 AddEntry(Color_TabItemBorder);
820 AddEntry(Color_DropDownBorder);
821 AddEntry(Color_Highlight);
822 AddEntry(Color_HighlightText);
756 #define AddEntry(e) maPropertyNameToIdMap[A2S(#e)]=e; maPropertyIdToNameMap[e]=A2S(#e)
823
757
824 AddEntry(Paint_DeckBackground);
825 AddEntry(Paint_DeckTitleBarBackground);
826 AddEntry(Paint_PanelBackground);
827 AddEntry(Paint_PanelTitleBarBackground);
828 AddEntry(Paint_TabBarBackground);
829 AddEntry(Paint_TabItemBackgroundNormal);
830 AddEntry(Paint_TabItemBackgroundHighlight);
831 AddEntry(Paint_HorizontalBorder);
832 AddEntry(Paint_VerticalBorder);
833 AddEntry(Paint_ToolBoxBackground);
834 AddEntry(Paint_ToolBoxBorderTopLeft);
835 AddEntry(Paint_ToolBoxBorderCenterCorners);
836 AddEntry(Paint_ToolBoxBorderBottomRight);
837 AddEntry(Paint_DropDownBackground);
758 AddEntry(Image_Grip);
759 AddEntry(Image_Expand);
760 AddEntry(Image_Collapse);
761 AddEntry(Image_TabBarMenu);
762 AddEntry(Image_PanelMenu);
763 AddEntry(Image_ToolBoxItemSeparator);
764 AddEntry(Image_Closer);
765 AddEntry(Image_CloseIndicator);
838
766
839 AddEntry(Int_DeckTitleBarHeight);
840 AddEntry(Int_DeckBorderSize);
841 AddEntry(Int_DeckSeparatorHeight);
842 AddEntry(Int_PanelTitleBarHeight);
843 AddEntry(Int_TabMenuPadding);
844 AddEntry(Int_TabMenuSeparatorPadding);
845 AddEntry(Int_TabItemWidth);
846 AddEntry(Int_TabItemHeight);
847 AddEntry(Int_DeckLeftPadding);
848 AddEntry(Int_DeckTopPadding);
849 AddEntry(Int_DeckRightPadding);
850 AddEntry(Int_DeckBottomPadding);
851 AddEntry(Int_TabBarLeftPadding);
852 AddEntry(Int_TabBarTopPadding);
853 AddEntry(Int_TabBarRightPadding);
854 AddEntry(Int_TabBarBottomPadding);
855 AddEntry(Int_ButtonCornerRadius);
767 AddEntry(Color_DeckTitleFont);
768 AddEntry(Color_PanelTitleFont);
769 AddEntry(Color_TabMenuSeparator);
770 AddEntry(Color_TabItemBorder);
771 AddEntry(Color_DropDownBorder);
772 AddEntry(Color_Highlight);
773 AddEntry(Color_HighlightText);
856
774
857 AddEntry(Bool_UseSymphonyIcons);
858 AddEntry(Bool_UseSystemColors);
859 AddEntry(Bool_UseToolBoxItemSeparator);
860 AddEntry(Bool_IsHighContrastModeActive);
775 AddEntry(Paint_DeckBackground);
776 AddEntry(Paint_DeckTitleBarBackground);
777 AddEntry(Paint_PanelBackground);
778 AddEntry(Paint_PanelTitleBarBackground);
779 AddEntry(Paint_TabBarBackground);
780 AddEntry(Paint_TabItemBackgroundNormal);
781 AddEntry(Paint_TabItemBackgroundHighlight);
782 AddEntry(Paint_HorizontalBorder);
783 AddEntry(Paint_VerticalBorder);
784 AddEntry(Paint_ToolBoxBackground);
785 AddEntry(Paint_ToolBoxBorderTopLeft);
786 AddEntry(Paint_ToolBoxBorderCenterCorners);
787 AddEntry(Paint_ToolBoxBorderBottomRight);
788 AddEntry(Paint_DropDownBackground);
861
789
862 AddEntry(Rect_ToolBoxPadding);
863 AddEntry(Rect_ToolBoxBorder);
864
865 #undef AddEntry
790 AddEntry(Int_DeckTitleBarHeight);
791 AddEntry(Int_DeckBorderSize);
792 AddEntry(Int_DeckSeparatorHeight);
793 AddEntry(Int_PanelTitleBarHeight);
794 AddEntry(Int_TabMenuPadding);
795 AddEntry(Int_TabMenuSeparatorPadding);
796 AddEntry(Int_TabItemWidth);
797 AddEntry(Int_TabItemHeight);
798 AddEntry(Int_DeckLeftPadding);
799 AddEntry(Int_DeckTopPadding);
800 AddEntry(Int_DeckRightPadding);
801 AddEntry(Int_DeckBottomPadding);
802 AddEntry(Int_TabBarLeftPadding);
803 AddEntry(Int_TabBarTopPadding);
804 AddEntry(Int_TabBarRightPadding);
805 AddEntry(Int_TabBarBottomPadding);
806 AddEntry(Int_ButtonCornerRadius);
866
807
867 maRawValues.resize(maPropertyIdToNameMap.size());
868}
808 AddEntry(Bool_UseSymphonyIcons);
809 AddEntry(Bool_UseSystemColors);
810 AddEntry(Bool_UseToolBoxItemSeparator);
811 AddEntry(Bool_IsHighContrastModeActive);
869
812
813 AddEntry(Rect_ToolBoxPadding);
814 AddEntry(Rect_ToolBoxBorder);
870
815
816 #undef AddEntry
871
817
818 maRawValues.resize(maPropertyIdToNameMap.size());
819}
872
820
821
873Theme::PropertyType Theme::GetPropertyType (const ThemeItem eItem)
874{
822Theme::PropertyType Theme::GetPropertyType (const ThemeItem eItem)
823{
875 switch(eItem)
876 {
877 case Image_Grip:
878 case Image_Expand:
879 case Image_Collapse:
880 case Image_TabBarMenu:
881 case Image_PanelMenu:
882 case Image_ToolBoxItemSeparator:
883 case Image_Closer:
884 case Image_CloseIndicator:
885 return PT_Image;
824 switch(eItem)
825 {
826 case Image_Grip:
827 case Image_Expand:
828 case Image_Collapse:
829 case Image_TabBarMenu:
830 case Image_PanelMenu:
831 case Image_ToolBoxItemSeparator:
832 case Image_Closer:
833 case Image_CloseIndicator:
834 return PT_Image;
886
835
887 case Color_DeckTitleFont:
888 case Color_PanelTitleFont:
889 case Color_TabMenuSeparator:
890 case Color_TabItemBorder:
891 case Color_DropDownBorder:
892 case Color_Highlight:
893 case Color_HighlightText:
894 return PT_Color;
836 case Color_DeckTitleFont:
837 case Color_PanelTitleFont:
838 case Color_TabMenuSeparator:
839 case Color_TabItemBorder:
840 case Color_DropDownBorder:
841 case Color_Highlight:
842 case Color_HighlightText:
843 return PT_Color;
895
844
896 case Paint_DeckBackground:
897 case Paint_DeckTitleBarBackground:
898 case Paint_PanelBackground:
899 case Paint_PanelTitleBarBackground:
900 case Paint_TabBarBackground:
901 case Paint_TabItemBackgroundNormal:
902 case Paint_TabItemBackgroundHighlight:
903 case Paint_HorizontalBorder:
904 case Paint_VerticalBorder:
905 case Paint_ToolBoxBackground:
906 case Paint_ToolBoxBorderTopLeft:
907 case Paint_ToolBoxBorderCenterCorners:
908 case Paint_ToolBoxBorderBottomRight:
909 case Paint_DropDownBackground:
910 return PT_Paint;
845 case Paint_DeckBackground:
846 case Paint_DeckTitleBarBackground:
847 case Paint_PanelBackground:
848 case Paint_PanelTitleBarBackground:
849 case Paint_TabBarBackground:
850 case Paint_TabItemBackgroundNormal:
851 case Paint_TabItemBackgroundHighlight:
852 case Paint_HorizontalBorder:
853 case Paint_VerticalBorder:
854 case Paint_ToolBoxBackground:
855 case Paint_ToolBoxBorderTopLeft:
856 case Paint_ToolBoxBorderCenterCorners:
857 case Paint_ToolBoxBorderBottomRight:
858 case Paint_DropDownBackground:
859 return PT_Paint;
911
860
912 case Int_DeckTitleBarHeight:
913 case Int_DeckBorderSize:
914 case Int_DeckSeparatorHeight:
915 case Int_PanelTitleBarHeight:
916 case Int_TabMenuPadding:
917 case Int_TabMenuSeparatorPadding:
918 case Int_TabItemWidth:
919 case Int_TabItemHeight:
920 case Int_DeckLeftPadding:
921 case Int_DeckTopPadding:
922 case Int_DeckRightPadding:
923 case Int_DeckBottomPadding:
924 case Int_TabBarLeftPadding:
925 case Int_TabBarTopPadding:
926 case Int_TabBarRightPadding:
927 case Int_TabBarBottomPadding:
928 case Int_ButtonCornerRadius:
929 return PT_Integer;
861 case Int_DeckTitleBarHeight:
862 case Int_DeckBorderSize:
863 case Int_DeckSeparatorHeight:
864 case Int_PanelTitleBarHeight:
865 case Int_TabMenuPadding:
866 case Int_TabMenuSeparatorPadding:
867 case Int_TabItemWidth:
868 case Int_TabItemHeight:
869 case Int_DeckLeftPadding:
870 case Int_DeckTopPadding:
871 case Int_DeckRightPadding:
872 case Int_DeckBottomPadding:
873 case Int_TabBarLeftPadding:
874 case Int_TabBarTopPadding:
875 case Int_TabBarRightPadding:
876 case Int_TabBarBottomPadding:
877 case Int_ButtonCornerRadius:
878 return PT_Integer;
930
879
931 case Bool_UseSymphonyIcons:
932 case Bool_UseSystemColors:
933 case Bool_UseToolBoxItemSeparator:
934 case Bool_IsHighContrastModeActive:
935 return PT_Boolean;
880 case Bool_UseSymphonyIcons:
881 case Bool_UseSystemColors:
882 case Bool_UseToolBoxItemSeparator:
883 case Bool_IsHighContrastModeActive:
884 return PT_Boolean;
936
885
937 case Rect_ToolBoxBorder:
938 case Rect_ToolBoxPadding:
939 return PT_Rectangle;
940
941 default:
942 return PT_Invalid;
943 }
886 case Rect_ToolBoxBorder:
887 case Rect_ToolBoxPadding:
888 return PT_Rectangle;
889
890 default:
891 return PT_Invalid;
892 }
944}
945
946
893}
894
895
947
948
949cssu::Type Theme::GetCppuType (const PropertyType eType)
950{
896cssu::Type Theme::GetCppuType (const PropertyType eType)
897{
951 switch(eType)
952 {
953 case PT_Image:
954 return getCppuType((rtl::OUString*)NULL);
898 switch(eType)
899 {
900 case PT_Image:
901 return getCppuType((rtl::OUString*)NULL);
955
902
956 case PT_Color:
957 return getCppuType((sal_uInt32*)NULL);
903 case PT_Color:
904 return getCppuType((sal_uInt32*)NULL);
958
905
959 case PT_Paint:
960 return getCppuVoidType();
906 case PT_Paint:
907 return getCppuVoidType();
961
908
962 case PT_Integer:
963 return getCppuType((sal_Int32*)NULL);
909 case PT_Integer:
910 return getCppuType((sal_Int32*)NULL);
964
911
965 case PT_Boolean:
966 return getCppuType((sal_Bool*)NULL);
912 case PT_Boolean:
913 return getCppuType((sal_Bool*)NULL);
967
914
968 case PT_Rectangle:
969 return getCppuType((awt::Rectangle*)NULL);
915 case PT_Rectangle:
916 return getCppuType((awt::Rectangle*)NULL);
970
917
971 case PT_Invalid:
972 default:
973 return getCppuVoidType();
974 }
918 case PT_Invalid:
919 default:
920 return getCppuVoidType();
921 }
975}
976
977
922}
923
924
978
979
980sal_Int32 Theme::GetIndex (const ThemeItem eItem, const PropertyType eType)
981{
925sal_Int32 Theme::GetIndex (const ThemeItem eItem, const PropertyType eType)
926{
982 switch(eType)
983 {
984 case PT_Image:
985 return eItem - __Pre_Image-1;
986 case PT_Color:
987 return eItem - __Image_Color-1;
988 case PT_Paint:
989 return eItem - __Color_Paint-1;
990 case PT_Integer:
991 return eItem - __Paint_Int-1;
992 case PT_Boolean:
993 return eItem - __Int_Bool-1;
994 case PT_Rectangle:
995 return eItem - __Bool_Rect-1;
927 switch(eType)
928 {
929 case PT_Image:
930 return eItem - __Pre_Image-1;
931 case PT_Color:
932 return eItem - __Image_Color-1;
933 case PT_Paint:
934 return eItem - __Color_Paint-1;
935 case PT_Integer:
936 return eItem - __Paint_Int-1;
937 case PT_Boolean:
938 return eItem - __Int_Bool-1;
939 case PT_Rectangle:
940 return eItem - __Bool_Rect-1;
996
941
997 default:
998 OSL_ASSERT(false);
999 return 0;
1000 }
942 default:
943 OSL_ASSERT(false);
944 return 0;
945 }
1001}
1002
1003
946}
947
948
1004
1005
1006Theme::VetoableListenerContainer* Theme::GetVetoableListeners (
949Theme::VetoableListenerContainer* Theme::GetVetoableListeners (
1007 const ThemeItem eItem,
1008 const bool bCreate)
950 const ThemeItem eItem,
951 const bool bCreate)
1009{
952{
1010 VetoableListeners::iterator iContainer (maVetoableListeners.find(eItem));
1011 if (iContainer != maVetoableListeners.end())
1012 return &iContainer->second;
1013 else if (bCreate)
1014 {
1015 maVetoableListeners[eItem] = VetoableListenerContainer();
1016 return &maVetoableListeners[eItem];
1017 }
1018 else
1019 return NULL;
953 VetoableListeners::iterator iContainer (maVetoableListeners.find(eItem));
954 if (iContainer != maVetoableListeners.end())
955 return &iContainer->second;
956 else if (bCreate)
957 {
958 maVetoableListeners[eItem] = VetoableListenerContainer();
959 return &maVetoableListeners[eItem];
960 }
961 else
962 return NULL;
1020}
1021
1022
963}
964
965
1023
1024
1025Theme::ChangeListenerContainer* Theme::GetChangeListeners (
966Theme::ChangeListenerContainer* Theme::GetChangeListeners (
1026 const ThemeItem eItem,
1027 const bool bCreate)
967 const ThemeItem eItem,
968 const bool bCreate)
1028{
969{
1029 ChangeListeners::iterator iContainer (maChangeListeners.find(eItem));
1030 if (iContainer != maChangeListeners.end())
1031 return &iContainer->second;
1032 else if (bCreate)
1033 {
1034 maChangeListeners[eItem] = ChangeListenerContainer();
1035 return &maChangeListeners[eItem];
1036 }
1037 else
1038 return NULL;
970 ChangeListeners::iterator iContainer (maChangeListeners.find(eItem));
971 if (iContainer != maChangeListeners.end())
972 return &iContainer->second;
973 else if (bCreate)
974 {
975 maChangeListeners[eItem] = ChangeListenerContainer();
976 return &maChangeListeners[eItem];
977 }
978 else
979 return NULL;
1039}
1040
1041
980}
981
982
1042
1043
1044bool Theme::DoVetoableListenersVeto (
983bool Theme::DoVetoableListenersVeto (
1045 const VetoableListenerContainer* pListeners,
1046 const beans::PropertyChangeEvent& rEvent) const
984 const VetoableListenerContainer* pListeners,
985 const beans::PropertyChangeEvent& rEvent) const
1047{
986{
1048 if (pListeners == NULL)
1049 return false;
987 if (pListeners == NULL)
988 return false;
1050
989
1051 VetoableListenerContainer aListeners (*pListeners);
1052 try
1053 {
1054 for (VetoableListenerContainer::const_iterator
1055 iListener(aListeners.begin()),
1056 iEnd(aListeners.end());
1057 iListener!=iEnd;
1058 ++iListener)
1059 {
1060 (*iListener)->vetoableChange(rEvent);
1061 }
1062 }
1063 catch(const beans::PropertyVetoException&)
1064 {
1065 return true;
1066 }
1067 catch(const Exception&)
1068 {
1069 // Ignore any other errors (such as disposed listeners).
1070 }
1071 return false;
990 VetoableListenerContainer aListeners (*pListeners);
991 try
992 {
993 for (VetoableListenerContainer::const_iterator
994 iListener(aListeners.begin()),
995 iEnd(aListeners.end());
996 iListener!=iEnd;
997 ++iListener)
998 {
999 (*iListener)->vetoableChange(rEvent);
1000 }
1001 }
1002 catch(const beans::PropertyVetoException&)
1003 {
1004 return true;
1005 }
1006 catch(const Exception&)
1007 {
1008 // Ignore any other errors (such as disposed listeners).
1009 }
1010 return false;
1072}
1073
1074
1011}
1012
1013
1075
1076
1077void Theme::BroadcastPropertyChange (
1014void Theme::BroadcastPropertyChange (
1078 const ChangeListenerContainer* pListeners,
1079 const beans::PropertyChangeEvent& rEvent) const
1015 const ChangeListenerContainer* pListeners,
1016 const beans::PropertyChangeEvent& rEvent) const
1080{
1017{
1081 if (pListeners == NULL)
1082 return;
1018 if (pListeners == NULL)
1019 return;
1083
1020
1084 const ChangeListenerContainer aListeners (*pListeners);
1085 try
1086 {
1087 for (ChangeListenerContainer::const_iterator
1088 iListener(aListeners.begin()),
1089 iEnd(aListeners.end());
1090 iListener!=iEnd;
1091 ++iListener)
1092 {
1093 (*iListener)->propertyChange(rEvent);
1094 }
1095 }
1096 catch(const Exception&)
1097 {
1098 // Ignore any errors (such as disposed listeners).
1099 }
1021 const ChangeListenerContainer aListeners (*pListeners);
1022 try
1023 {
1024 for (ChangeListenerContainer::const_iterator
1025 iListener(aListeners.begin()),
1026 iEnd(aListeners.end());
1027 iListener!=iEnd;
1028 ++iListener)
1029 {
1030 (*iListener)->propertyChange(rEvent);
1031 }
1032 }
1033 catch(const Exception&)
1034 {
1035 // Ignore any errors (such as disposed listeners).
1036 }
1100}
1101
1102
1037}
1038
1039
1103
1104
1105void Theme::ProcessNewValue (
1040void Theme::ProcessNewValue (
1106 const Any& rValue,
1107 const ThemeItem eItem,
1108 const PropertyType eType)
1041 const Any& rValue,
1042 const ThemeItem eItem,
1043 const PropertyType eType)
1109{
1044{
1110 const sal_Int32 nIndex (GetIndex (eItem, eType));
1111 switch (eType)
1112 {
1113 case PT_Image:
1114 {
1115 ::rtl::OUString sURL;
1116 if (rValue >>= sURL)
1117 {
1118 maImages[nIndex] = Tools::GetImage(sURL, NULL);
1119 }
1120 break;
1121 }
1122 case PT_Color:
1123 {
1124 sal_Int32 nColorValue (0);
1125 if (rValue >>= nColorValue)
1126 {
1127 maColors[nIndex] = Color(nColorValue);
1128 }
1129 break;
1130 }
1131 case PT_Paint:
1132 {
1133 maPaints[nIndex] = Paint::Create(rValue);
1134 break;
1135 }
1136 case PT_Integer:
1137 {
1138 sal_Int32 nValue (0);
1139 if (rValue >>= nValue)
1140 {
1141 maIntegers[nIndex] = nValue;
1142 }
1143 break;
1144 }
1145 case PT_Boolean:
1146 {
1147 sal_Bool nValue (0);
1148 if (rValue >>= nValue)
1149 {
1150 maBooleans[nIndex] = (nValue==sal_True);
1151 if (eItem == Bool_IsHighContrastModeActive)
1152 {
1153 mbIsHighContrastModeSetManually = true;
1154 mbIsHighContrastMode = maBooleans[nIndex];
1155 HandleDataChange();
1156 }
1157 else if (eItem == Bool_UseSystemColors)
1158 {
1159 HandleDataChange();
1160 }
1161 }
1162 break;
1163 }
1164 case PT_Rectangle:
1165 {
1166 awt::Rectangle aBox;
1167 if (rValue >>= aBox)
1168 {
1169 maRectangles[nIndex] = Rectangle(
1170 aBox.X,
1171 aBox.Y,
1172 aBox.Width,
1173 aBox.Height);
1174 }
1175 break;
1176 }
1177 case PT_Invalid:
1178 OSL_ASSERT(eType != PT_Invalid);
1179 throw RuntimeException();
1180 }
1045 const sal_Int32 nIndex (GetIndex (eItem, eType));
1046 switch (eType)
1047 {
1048 case PT_Image:
1049 {
1050 ::rtl::OUString sURL;
1051 if (rValue >>= sURL)
1052 {
1053 maImages[nIndex] = Tools::GetImage(sURL, NULL);
1054 }
1055 break;
1056 }
1057 case PT_Color:
1058 {
1059 sal_Int32 nColorValue (0);
1060 if (rValue >>= nColorValue)
1061 {
1062 maColors[nIndex] = Color(nColorValue);
1063 }
1064 break;
1065 }
1066 case PT_Paint:
1067 {
1068 maPaints[nIndex] = Paint::Create(rValue);
1069 break;
1070 }
1071 case PT_Integer:
1072 {
1073 sal_Int32 nValue (0);
1074 if (rValue >>= nValue)
1075 {
1076 maIntegers[nIndex] = nValue;
1077 }
1078 break;
1079 }
1080 case PT_Boolean:
1081 {
1082 sal_Bool nValue (0);
1083 if (rValue >>= nValue)
1084 {
1085 maBooleans[nIndex] = (nValue==sal_True);
1086 if (eItem == Bool_IsHighContrastModeActive)
1087 {
1088 mbIsHighContrastModeSetManually = true;
1089 mbIsHighContrastMode = maBooleans[nIndex];
1090 HandleDataChange();
1091 }
1092 else if (eItem == Bool_UseSystemColors)
1093 {
1094 HandleDataChange();
1095 }
1096 }
1097 break;
1098 }
1099 case PT_Rectangle:
1100 {
1101 awt::Rectangle aBox;
1102 if (rValue >>= aBox)
1103 {
1104 maRectangles[nIndex] = Rectangle(
1105 aBox.X,
1106 aBox.Y,
1107 aBox.Width,
1108 aBox.Height);
1109 }
1110 break;
1111 }
1112 case PT_Invalid:
1113 OSL_ASSERT(eType != PT_Invalid);
1114 throw RuntimeException();
1115 }
1181}
1182
1116}
1117
1183
1184
1185
1186} } // end of namespace sfx2::sidebar
1118} } // end of namespace sfx2::sidebar