xref: /AOO41X/main/sfx2/source/sidebar/Theme.cxx (revision ce6abae5386bfb6b85243a3d21754402dc24587c)
1ff12d537SAndre Fischer /**************************************************************
2ff12d537SAndre Fischer  *
3ff12d537SAndre Fischer  * Licensed to the Apache Software Foundation (ASF) under one
4ff12d537SAndre Fischer  * or more contributor license agreements.  See the NOTICE file
5ff12d537SAndre Fischer  * distributed with this work for additional information
6ff12d537SAndre Fischer  * regarding copyright ownership.  The ASF licenses this file
7ff12d537SAndre Fischer  * to you under the Apache License, Version 2.0 (the
8ff12d537SAndre Fischer  * "License"); you may not use this file except in compliance
9ff12d537SAndre Fischer  * with the License.  You may obtain a copy of the License at
10ff12d537SAndre Fischer  *
11ff12d537SAndre Fischer  *   http://www.apache.org/licenses/LICENSE-2.0
12ff12d537SAndre Fischer  *
13ff12d537SAndre Fischer  * Unless required by applicable law or agreed to in writing,
14ff12d537SAndre Fischer  * software distributed under the License is distributed on an
15ff12d537SAndre Fischer  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16ff12d537SAndre Fischer  * KIND, either express or implied.  See the License for the
17ff12d537SAndre Fischer  * specific language governing permissions and limitations
18ff12d537SAndre Fischer  * under the License.
19ff12d537SAndre Fischer  *
20ff12d537SAndre Fischer  *************************************************************/
21ff12d537SAndre Fischer 
22ed484612SMatthias Seidel 
23ed484612SMatthias Seidel 
24ff12d537SAndre Fischer #include "precompiled_sfx2.hxx"
25ff12d537SAndre Fischer 
26b9e67834SAndre Fischer #include "sfx2/sidebar/Theme.hxx"
27ff12d537SAndre Fischer #include "Paint.hxx"
28ff12d537SAndre Fischer #include "SidebarResource.hxx"
29f35c6d02SAndre Fischer #include "sfx2/sidebar/Tools.hxx"
30ff12d537SAndre Fischer 
31b9e67834SAndre Fischer #include <tools/svborder.hxx>
32ff12d537SAndre Fischer #include <tools/rc.hxx>
33ff12d537SAndre Fischer #include <vcl/svapp.hxx>
34ff12d537SAndre Fischer 
35b9e67834SAndre Fischer using namespace css;
36b9e67834SAndre Fischer using namespace cssu;
37b9e67834SAndre Fischer 
38ff12d537SAndre Fischer 
39ff12d537SAndre Fischer namespace sfx2 { namespace sidebar {
40ff12d537SAndre Fischer 
41b9e67834SAndre Fischer ::rtl::Reference<Theme> Theme::mpInstance;
42ff12d537SAndre Fischer 
43b9e67834SAndre Fischer 
GetCurrentTheme(void)44b9e67834SAndre Fischer Theme& Theme::GetCurrentTheme (void)
45ff12d537SAndre Fischer {
46b9e67834SAndre Fischer 	if ( ! mpInstance.is())
47ff12d537SAndre Fischer 	{
48b9e67834SAndre Fischer 		mpInstance.set(new Theme());
49b9e67834SAndre Fischer 		mpInstance->InitializeTheme();
50ff12d537SAndre Fischer 	}
51b9e67834SAndre Fischer 	return *mpInstance;
52ff12d537SAndre Fischer }
53ff12d537SAndre Fischer 
54ff12d537SAndre Fischer 
Theme(void)55b9e67834SAndre Fischer Theme::Theme (void)
56b9e67834SAndre Fischer 	: ThemeInterfaceBase(m_aMutex),
57b9e67834SAndre Fischer 	  maImages(),
58b9e67834SAndre Fischer 	  maColors(),
59b9e67834SAndre Fischer 	  maPaints(),
60b9e67834SAndre Fischer 	  maIntegers(),
61b9e67834SAndre Fischer 	  maBooleans(),
62b9e67834SAndre Fischer 	  mbIsHighContrastMode(Application::GetSettings().GetStyleSettings().GetHighContrastMode()),
6395a18594SAndre Fischer 	  mbIsHighContrastModeSetManually(false),
64b9e67834SAndre Fischer 	  maPropertyNameToIdMap(),
65b9e67834SAndre Fischer 	  maPropertyIdToNameMap(),
66b9e67834SAndre Fischer 	  maRawValues(),
67b9e67834SAndre Fischer 	  maChangeListeners(),
68b9e67834SAndre Fischer 	  maVetoableListeners()
69b9e67834SAndre Fischer 
70ff12d537SAndre Fischer {
71b9e67834SAndre Fischer 	SetupPropertyMaps();
72ff12d537SAndre Fischer }
73ff12d537SAndre Fischer 
74ff12d537SAndre Fischer 
~Theme(void)75b9e67834SAndre Fischer Theme::~Theme (void)
76ff12d537SAndre Fischer {
77ff12d537SAndre Fischer }
78ff12d537SAndre Fischer 
79ff12d537SAndre Fischer 
GetImage(const ThemeItem eItem)80b9e67834SAndre Fischer Image Theme::GetImage (const ThemeItem eItem)
81ff12d537SAndre Fischer {
82b9e67834SAndre Fischer 	const PropertyType eType (GetPropertyType(eItem));
83b9e67834SAndre Fischer 	OSL_ASSERT(eType==PT_Image);
84b9e67834SAndre Fischer 	const sal_Int32 nIndex (GetIndex(eItem, eType));
85b9e67834SAndre Fischer 	const Theme& rTheme (GetCurrentTheme());
86b9e67834SAndre Fischer 	return rTheme.maImages[nIndex];
87ff12d537SAndre Fischer }
88ff12d537SAndre Fischer 
89ff12d537SAndre Fischer 
GetColor(const ThemeItem eItem)90b9e67834SAndre Fischer Color Theme::GetColor (const ThemeItem eItem)
91ff12d537SAndre Fischer {
92b9e67834SAndre Fischer 	const PropertyType eType (GetPropertyType(eItem));
938dcb2a10SAndre Fischer 	OSL_ASSERT(eType==PT_Color || eType==PT_Paint);
94b9e67834SAndre Fischer 	const sal_Int32 nIndex (GetIndex(eItem, eType));
95b9e67834SAndre Fischer 	const Theme& rTheme (GetCurrentTheme());
968dcb2a10SAndre Fischer 	if (eType == PT_Color)
97b9e67834SAndre Fischer 		return rTheme.maColors[nIndex];
988dcb2a10SAndre Fischer 	else if (eType == PT_Paint)
998dcb2a10SAndre Fischer 		return rTheme.maPaints[nIndex].GetColor();
100f120fe41SAndre Fischer 	else
101f120fe41SAndre Fischer 		return COL_WHITE;
102ff12d537SAndre Fischer }
103ff12d537SAndre Fischer 
104ff12d537SAndre Fischer 
GetPaint(const ThemeItem eItem)105b9e67834SAndre Fischer const Paint& Theme::GetPaint (const ThemeItem eItem)
106ff12d537SAndre Fischer {
107b9e67834SAndre Fischer 	const PropertyType eType (GetPropertyType(eItem));
108b9e67834SAndre Fischer 	OSL_ASSERT(eType==PT_Paint);
109b9e67834SAndre Fischer 	const sal_Int32 nIndex (GetIndex(eItem, eType));
110b9e67834SAndre Fischer 	const Theme& rTheme (GetCurrentTheme());
111b9e67834SAndre Fischer 	return rTheme.maPaints[nIndex];
112ff12d537SAndre Fischer }
113ff12d537SAndre Fischer 
114ff12d537SAndre Fischer 
GetWallpaper(const ThemeItem eItem)1157a32b0c8SAndre Fischer const Wallpaper Theme::GetWallpaper (const ThemeItem eItem)
1167a32b0c8SAndre Fischer {
1177a32b0c8SAndre Fischer 	return GetPaint(eItem).GetWallpaper();
1187a32b0c8SAndre Fischer }
1197a32b0c8SAndre Fischer 
1207a32b0c8SAndre Fischer 
GetInteger(const ThemeItem eItem)121b9e67834SAndre Fischer sal_Int32 Theme::GetInteger (const ThemeItem eItem)
122ff12d537SAndre Fischer {
123b9e67834SAndre Fischer 	const PropertyType eType (GetPropertyType(eItem));
124b9e67834SAndre Fischer 	OSL_ASSERT(eType==PT_Integer);
125b9e67834SAndre Fischer 	const sal_Int32 nIndex (GetIndex(eItem, eType));
126b9e67834SAndre Fischer 	const Theme& rTheme (GetCurrentTheme());
127b9e67834SAndre Fischer 	return rTheme.maIntegers[nIndex];
128ff12d537SAndre Fischer }
129ff12d537SAndre Fischer 
130ff12d537SAndre Fischer 
GetBoolean(const ThemeItem eItem)131b9e67834SAndre Fischer bool Theme::GetBoolean (const ThemeItem eItem)
132ff12d537SAndre Fischer {
133b9e67834SAndre Fischer 	const PropertyType eType (GetPropertyType(eItem));
134b9e67834SAndre Fischer 	OSL_ASSERT(eType==PT_Boolean);
135b9e67834SAndre Fischer 	const sal_Int32 nIndex (GetIndex(eItem, eType));
136b9e67834SAndre Fischer 	const Theme& rTheme (GetCurrentTheme());
137b9e67834SAndre Fischer 	return rTheme.maBooleans[nIndex];
138ff12d537SAndre Fischer }
139ff12d537SAndre Fischer 
140ff12d537SAndre Fischer 
GetRectangle(const ThemeItem eItem)14195a18594SAndre Fischer Rectangle Theme::GetRectangle (const ThemeItem eItem)
14295a18594SAndre Fischer {
14395a18594SAndre Fischer 	const PropertyType eType (GetPropertyType(eItem));
14495a18594SAndre Fischer 	OSL_ASSERT(eType==PT_Rectangle);
14595a18594SAndre Fischer 	const sal_Int32 nIndex (GetIndex(eItem, eType));
14695a18594SAndre Fischer 	const Theme& rTheme (GetCurrentTheme());
14795a18594SAndre Fischer 	return rTheme.maRectangles[nIndex];
14895a18594SAndre Fischer }
14995a18594SAndre Fischer 
15095a18594SAndre Fischer 
IsHighContrastMode(void)151ff12d537SAndre Fischer bool Theme::IsHighContrastMode (void)
152ff12d537SAndre Fischer {
153b9e67834SAndre Fischer 	const Theme& rTheme (GetCurrentTheme());
154b9e67834SAndre Fischer 	return rTheme.mbIsHighContrastMode;
155ff12d537SAndre Fischer }
156ff12d537SAndre Fischer 
157ff12d537SAndre Fischer 
HandleDataChange(void)158ff12d537SAndre Fischer void Theme::HandleDataChange (void)
159ff12d537SAndre Fischer {
16095a18594SAndre Fischer 	Theme& rTheme (GetCurrentTheme());
16195a18594SAndre Fischer 
16295a18594SAndre Fischer 	if ( ! rTheme.mbIsHighContrastModeSetManually)
16395a18594SAndre Fischer 	{
16495a18594SAndre Fischer 		// Do not modify mbIsHighContrastMode when it was manually set.
165b9e67834SAndre Fischer 		GetCurrentTheme().mbIsHighContrastMode = Application::GetSettings().GetStyleSettings().GetHighContrastMode();
16695a18594SAndre Fischer 		rTheme.maRawValues[Bool_IsHighContrastModeActive] = Any(GetCurrentTheme().mbIsHighContrastMode);
16795a18594SAndre Fischer 	}
16895a18594SAndre Fischer 
16995a18594SAndre Fischer 	GetCurrentTheme().UpdateTheme();
170ff12d537SAndre Fischer }
171ff12d537SAndre Fischer 
172ff12d537SAndre Fischer 
InitializeTheme(void)173b9e67834SAndre Fischer void Theme::InitializeTheme (void)
174ff12d537SAndre Fischer {
17595a18594SAndre Fischer 	setPropertyValue(
17695a18594SAndre Fischer 		maPropertyIdToNameMap[Bool_UseSymphonyIcons],
1770d805bddSAndre Fischer 		Any(false));
17895a18594SAndre Fischer 	setPropertyValue(
17995a18594SAndre Fischer 		maPropertyIdToNameMap[Bool_UseSystemColors],
18095a18594SAndre Fischer 		Any(false));
18195a18594SAndre Fischer }
18295a18594SAndre Fischer 
18395a18594SAndre Fischer 
UpdateTheme(void)18495a18594SAndre Fischer void Theme::UpdateTheme (void)
18595a18594SAndre Fischer {
186ff12d537SAndre Fischer 	SidebarResource aLocalResource;
187ff12d537SAndre Fischer 
188b9e67834SAndre Fischer 	try
189b9e67834SAndre Fischer 	{
19095a18594SAndre Fischer 		const StyleSettings& rStyle (Application::GetSettings().GetStyleSettings());
19195a18594SAndre Fischer 		const bool bUseSystemColors (GetBoolean(Bool_UseSystemColors));
19295a18594SAndre Fischer 
19395a18594SAndre Fischer #define Alternatives(n,hc,sys) (mbIsHighContrastMode ? hc : (bUseSystemColors ? sys : n))
19495a18594SAndre Fischer 
195df0345d7SAndre Fischer 		Color aBaseBackgroundColor (rStyle.GetDialogColor());
196df0345d7SAndre Fischer 		// UX says this should be a little brighter, but that looks off when compared to the other windows.
197df0345d7SAndre Fischer 		//aBaseBackgroundColor.IncreaseLuminance(7);
1988dcb2a10SAndre Fischer 		Color aBorderColor (aBaseBackgroundColor);
19935c52e30Smseidel 		aBorderColor.DecreaseLuminance(80);
2008dcb2a10SAndre Fischer 		Color aSecondColor (aBaseBackgroundColor);
20135c52e30Smseidel 		aSecondColor.DecreaseLuminance(0);
2028dcb2a10SAndre Fischer 
203b9e67834SAndre Fischer 		setPropertyValue(
204b9e67834SAndre Fischer 			maPropertyIdToNameMap[Paint_DeckBackground],
205df0345d7SAndre Fischer 			Any(sal_Int32(aBaseBackgroundColor.GetRGBColor())));
20695a18594SAndre Fischer 
207b9e67834SAndre Fischer 		setPropertyValue(
208b9e67834SAndre Fischer 			maPropertyIdToNameMap[Paint_DeckTitleBarBackground],
2098dcb2a10SAndre Fischer 			Any(sal_Int32(aBaseBackgroundColor.GetRGBColor())));
210b9e67834SAndre Fischer 		setPropertyValue(
211b9e67834SAndre Fischer 			maPropertyIdToNameMap[Int_DeckLeftPadding],
212b9e67834SAndre Fischer 			Any(sal_Int32(2)));
213b9e67834SAndre Fischer 		setPropertyValue(
214b9e67834SAndre Fischer 			maPropertyIdToNameMap[Int_DeckTopPadding],
215b9e67834SAndre Fischer 			Any(sal_Int32(2)));
216b9e67834SAndre Fischer 		setPropertyValue(
217b9e67834SAndre Fischer 			maPropertyIdToNameMap[Int_DeckRightPadding],
218b9e67834SAndre Fischer 			Any(sal_Int32(2)));
219b9e67834SAndre Fischer 		setPropertyValue(
220b9e67834SAndre Fischer 			maPropertyIdToNameMap[Int_DeckBottomPadding],
221b9e67834SAndre Fischer 			Any(sal_Int32(2)));
222b9e67834SAndre Fischer 		setPropertyValue(
223b9e67834SAndre Fischer 			maPropertyIdToNameMap[Int_DeckBorderSize],
224b9e67834SAndre Fischer 			Any(sal_Int32(1)));
225b9e67834SAndre Fischer 		setPropertyValue(
226b9e67834SAndre Fischer 			maPropertyIdToNameMap[Int_DeckSeparatorHeight],
227b9e67834SAndre Fischer 			Any(sal_Int32(1)));
228b9e67834SAndre Fischer 		setPropertyValue(
22937fee4fdSAndre Fischer 			maPropertyIdToNameMap[Int_ButtonCornerRadius],
23037fee4fdSAndre Fischer 			Any(sal_Int32(3)));
23137fee4fdSAndre Fischer 		setPropertyValue(
232b9e67834SAndre Fischer 			maPropertyIdToNameMap[Color_DeckTitleFont],
233*ce6abae5Smseidel 			Any(sal_Int32(mbIsHighContrastMode ? 0xffffff : 0x262626)));
234b9e67834SAndre Fischer 		setPropertyValue(
235b9e67834SAndre Fischer 			maPropertyIdToNameMap[Int_DeckTitleBarHeight],
23695a18594SAndre Fischer 			Any(sal_Int32(Alternatives(
23795a18594SAndre Fischer 						26,
23895a18594SAndre Fischer 						26,
23995a18594SAndre Fischer 						rStyle.GetFloatTitleHeight()))));
240b9e67834SAndre Fischer 		setPropertyValue(
241b9e67834SAndre Fischer 			maPropertyIdToNameMap[Paint_PanelBackground],
242df0345d7SAndre Fischer 			Any(sal_Int32(aBaseBackgroundColor.GetRGBColor())));
2438dcb2a10SAndre Fischer 
244b9e67834SAndre Fischer 		setPropertyValue(
245b9e67834SAndre Fischer 			maPropertyIdToNameMap[Paint_PanelTitleBarBackground],
2468dcb2a10SAndre Fischer 			Any(Tools::VclToAwtGradient(Gradient(
2478dcb2a10SAndre Fischer 						GRADIENT_LINEAR,
2488dcb2a10SAndre Fischer 						aSecondColor.GetRGBColor(),
2498dcb2a10SAndre Fischer 						aBaseBackgroundColor.GetRGBColor()
2508dcb2a10SAndre Fischer 						))));
251b9e67834SAndre Fischer 		setPropertyValue(
252b9e67834SAndre Fischer 			maPropertyIdToNameMap[Color_PanelTitleFont],
253b9e67834SAndre Fischer 			Any(sal_Int32(mbIsHighContrastMode ? 0x00ff00 : 0x262626)));
254b9e67834SAndre Fischer 		setPropertyValue(
255b9e67834SAndre Fischer 			maPropertyIdToNameMap[Int_PanelTitleBarHeight],
25695a18594SAndre Fischer 			Any(sal_Int32(Alternatives(
25795a18594SAndre Fischer 						26,
25895a18594SAndre Fischer 						26,
25995a18594SAndre Fischer 						rStyle.GetTitleHeight()))));
260b9e67834SAndre Fischer 		setPropertyValue(
261b9e67834SAndre Fischer 			maPropertyIdToNameMap[Paint_TabBarBackground],
2628dcb2a10SAndre Fischer 			Any(sal_Int32(aBaseBackgroundColor.GetRGBColor())));
263b9e67834SAndre Fischer 		setPropertyValue(
264b9e67834SAndre Fischer 			maPropertyIdToNameMap[Int_TabBarLeftPadding],
265b9e67834SAndre Fischer 			Any(sal_Int32(2)));
266b9e67834SAndre Fischer 		setPropertyValue(
267b9e67834SAndre Fischer 			maPropertyIdToNameMap[Int_TabBarTopPadding],
268b9e67834SAndre Fischer 			Any(sal_Int32(2)));
269b9e67834SAndre Fischer 		setPropertyValue(
270b9e67834SAndre Fischer 			maPropertyIdToNameMap[Int_TabBarRightPadding],
271b9e67834SAndre Fischer 			Any(sal_Int32(2)));
272b9e67834SAndre Fischer 		setPropertyValue(
273b9e67834SAndre Fischer 			maPropertyIdToNameMap[Int_TabBarBottomPadding],
274b9e67834SAndre Fischer 			Any(sal_Int32(2)));
275ff12d537SAndre Fischer 
276b9e67834SAndre Fischer 		setPropertyValue(
277b9e67834SAndre Fischer 			maPropertyIdToNameMap[Int_TabMenuPadding],
278b9e67834SAndre Fischer 			Any(sal_Int32(6)));
279b9e67834SAndre Fischer 		setPropertyValue(
280b9e67834SAndre Fischer 			maPropertyIdToNameMap[Color_TabMenuSeparator],
2818dcb2a10SAndre Fischer 			Any(sal_Int32(aBorderColor.GetRGBColor())));
282b9e67834SAndre Fischer 		setPropertyValue(
283b9e67834SAndre Fischer 			maPropertyIdToNameMap[Int_TabMenuSeparatorPadding],
284b9e67834SAndre Fischer 			Any(sal_Int32(7)));
285ff12d537SAndre Fischer 
286b9e67834SAndre Fischer 		setPropertyValue(
287b9e67834SAndre Fischer 			maPropertyIdToNameMap[Int_TabItemWidth],
288b9e67834SAndre Fischer 			Any(sal_Int32(32)));
289b9e67834SAndre Fischer 		setPropertyValue(
290b9e67834SAndre Fischer 			maPropertyIdToNameMap[Int_TabItemHeight],
291b9e67834SAndre Fischer 			Any(sal_Int32(32)));
292b9e67834SAndre Fischer 		setPropertyValue(
293b9e67834SAndre Fischer 			maPropertyIdToNameMap[Color_TabItemBorder],
2948dcb2a10SAndre Fischer 			Any(sal_Int32(rStyle.GetActiveBorderColor().GetRGBColor())));
2958dcb2a10SAndre Fischer 		//					mbIsHighContrastMode ? 0x00ff00 : 0xbfbfbf)));
2968dcb2a10SAndre Fischer 
2978dcb2a10SAndre Fischer 		setPropertyValue(
2988dcb2a10SAndre Fischer 			maPropertyIdToNameMap[Paint_DropDownBackground],
2998dcb2a10SAndre Fischer 			Any(sal_Int32(aBaseBackgroundColor.GetRGBColor())));
3008dcb2a10SAndre Fischer 		setPropertyValue(
3018dcb2a10SAndre Fischer 			maPropertyIdToNameMap[Color_DropDownBorder],
3028dcb2a10SAndre Fischer 			Any(sal_Int32(rStyle.GetActiveBorderColor().GetRGBColor())));
3038dcb2a10SAndre Fischer 
304b9e67834SAndre Fischer 		setPropertyValue(
3055f1c83ffSOliver-Rainer Wittmann 			maPropertyIdToNameMap[Color_Highlight],
3065f1c83ffSOliver-Rainer Wittmann 			Any(sal_Int32(rStyle.GetHighlightColor().GetRGBColor())));
3075f1c83ffSOliver-Rainer Wittmann 		setPropertyValue(
3085f1c83ffSOliver-Rainer Wittmann 			maPropertyIdToNameMap[Color_HighlightText],
3095f1c83ffSOliver-Rainer Wittmann 			Any(sal_Int32(rStyle.GetHighlightTextColor().GetRGBColor())));
3105f1c83ffSOliver-Rainer Wittmann 
3115f1c83ffSOliver-Rainer Wittmann 		setPropertyValue(
31295a18594SAndre Fischer 			maPropertyIdToNameMap[Paint_TabItemBackgroundNormal],
31395a18594SAndre Fischer 			Any());
31495a18594SAndre Fischer 		setPropertyValue(
31595a18594SAndre Fischer 			maPropertyIdToNameMap[Paint_TabItemBackgroundHighlight],
3168dcb2a10SAndre Fischer 			Any(sal_Int32(rStyle.GetActiveTabColor().GetRGBColor())));
3178dcb2a10SAndre Fischer 		//					mbIsHighContrastMode ? 0x000000 : 0x00ffffff)));
318ff12d537SAndre Fischer 
319b9e67834SAndre Fischer 		setPropertyValue(
320b9e67834SAndre Fischer 			maPropertyIdToNameMap[Paint_HorizontalBorder],
3218dcb2a10SAndre Fischer 			Any(sal_Int32(aBorderColor.GetRGBColor())));
3228dcb2a10SAndre Fischer 		//					mbIsHighContrastMode ? 0x00ff00 : 0xe4e4e4)));
323b9e67834SAndre Fischer 		setPropertyValue(
324b9e67834SAndre Fischer 			maPropertyIdToNameMap[Paint_VerticalBorder],
3258dcb2a10SAndre Fischer 			Any(sal_Int32(aBorderColor.GetRGBColor())));
3268dcb2a10SAndre Fischer 		//					mbIsHighContrastMode ? 0x00ff00 : 0xe4e4e4)));
327ff12d537SAndre Fischer 
328b9e67834SAndre Fischer 		setPropertyValue(
329b9e67834SAndre Fischer 			maPropertyIdToNameMap[Image_Grip],
330b9e67834SAndre Fischer 			Any(
331b9e67834SAndre Fischer 				mbIsHighContrastMode
332b9e67834SAndre Fischer 					? A2S("private:graphicrepository/sfx2/res/grip_hc.png")
333b9e67834SAndre Fischer 					: A2S("private:graphicrepository/sfx2/res/grip.png")));
334b9e67834SAndre Fischer 		setPropertyValue(
335b9e67834SAndre Fischer 			maPropertyIdToNameMap[Image_Expand],
336b9e67834SAndre Fischer 			Any(
337b9e67834SAndre Fischer 				mbIsHighContrastMode
3386e6252f3SAndre Fischer 					? A2S("private:graphicrepository/res/plus_sch.png")
3396e6252f3SAndre Fischer 					: A2S("private:graphicrepository/res/plus.png")));
340b9e67834SAndre Fischer 		setPropertyValue(
341b9e67834SAndre Fischer 			maPropertyIdToNameMap[Image_Collapse],
342b9e67834SAndre Fischer 			Any(
343b9e67834SAndre Fischer 				mbIsHighContrastMode
3446e6252f3SAndre Fischer 					? A2S("private:graphicrepository/res/minus_sch.png")
3456e6252f3SAndre Fischer 					: A2S("private:graphicrepository/res/minus.png")));
346b9e67834SAndre Fischer 		setPropertyValue(
3477a32b0c8SAndre Fischer 			maPropertyIdToNameMap[Image_TabBarMenu],
348b9e67834SAndre Fischer 			Any(
349b9e67834SAndre Fischer 				mbIsHighContrastMode
350ed484612SMatthias Seidel 					? A2S("private:graphicrepository/sfx2/res/symphony/open_more_hc.png")
3516e6252f3SAndre Fischer 					: A2S("private:graphicrepository/sfx2/res/symphony/open_more.png")));
352b9e67834SAndre Fischer 		setPropertyValue(
3537a32b0c8SAndre Fischer 			maPropertyIdToNameMap[Image_PanelMenu],
3547a32b0c8SAndre Fischer 			Any(
3557a32b0c8SAndre Fischer 				mbIsHighContrastMode
3564e5e52c9SMatthias Seidel 					? A2S("private:graphicrepository/sfx2/res/symphony/morebutton_h.png")
3574e5e52c9SMatthias Seidel 					: A2S("private:graphicrepository/sfx2/res/symphony/morebutton.png")));
3587a32b0c8SAndre Fischer 		setPropertyValue(
3597a32b0c8SAndre Fischer 			maPropertyIdToNameMap[Image_Closer],
36035c52e30Smseidel 			Any(
36135c52e30Smseidel 				mbIsHighContrastMode
36235c52e30Smseidel 					? A2S("private:graphicrepository/sfx2/res/closedochc.png")
36335c52e30Smseidel 					: A2S("private:graphicrepository/sfx2/res/closedoc.png")));
3647a32b0c8SAndre Fischer 		setPropertyValue(
36513e1c3b4SAndre Fischer 			maPropertyIdToNameMap[Image_CloseIndicator],
36613e1c3b4SAndre Fischer 			Any(
36713e1c3b4SAndre Fischer 				mbIsHighContrastMode
36813e1c3b4SAndre Fischer 					? A2S("private:graphicrepository/res/commandimagelist/lch_decrementlevel.png")
36913e1c3b4SAndre Fischer 					: A2S("private:graphicrepository/res/commandimagelist/lc_decrementlevel.png")));
37013e1c3b4SAndre Fischer 		setPropertyValue(
37195a18594SAndre Fischer 			maPropertyIdToNameMap[Image_ToolBoxItemSeparator],
37295a18594SAndre Fischer 			Any(
37395a18594SAndre Fischer 				A2S("private:graphicrepository/sfx2/res/separator.png")));
37495a18594SAndre Fischer 
37595a18594SAndre Fischer 		// ToolBox
3768dcb2a10SAndre Fischer 
3778dcb2a10SAndre Fischer 		/*
3788dcb2a10SAndre Fischer 		// Separator style
3798dcb2a10SAndre Fischer 		setPropertyValue(
3808dcb2a10SAndre Fischer 			maPropertyIdToNameMap[Paint_ToolBoxBackground],
3818dcb2a10SAndre Fischer 			Any(sal_Int32(rStyle.GetMenuColor().GetRGBColor())));
3828dcb2a10SAndre Fischer 		setPropertyValue(
3838dcb2a10SAndre Fischer 			maPropertyIdToNameMap[Paint_ToolBoxBorderTopLeft],
3848dcb2a10SAndre Fischer 			Any());
3858dcb2a10SAndre Fischer 		setPropertyValue(
3868dcb2a10SAndre Fischer 			maPropertyIdToNameMap[Paint_ToolBoxBorderCenterCorners],
3878dcb2a10SAndre Fischer 			Any());
3888dcb2a10SAndre Fischer 		setPropertyValue(
3898dcb2a10SAndre Fischer 			maPropertyIdToNameMap[Paint_ToolBoxBorderBottomRight],
3908dcb2a10SAndre Fischer 			Any());
3918dcb2a10SAndre Fischer 		setPropertyValue(
3928dcb2a10SAndre Fischer 			maPropertyIdToNameMap[Rect_ToolBoxPadding],
3938dcb2a10SAndre Fischer 			Any(awt::Rectangle(2,2,2,2)));
3948dcb2a10SAndre Fischer 		setPropertyValue(
3958dcb2a10SAndre Fischer 			maPropertyIdToNameMap[Rect_ToolBoxBorder],
3968dcb2a10SAndre Fischer 			Any(awt::Rectangle(0,0,0,0)));
3978dcb2a10SAndre Fischer 		setPropertyValue(
3988dcb2a10SAndre Fischer 			maPropertyIdToNameMap[Bool_UseToolBoxItemSeparator],
3998dcb2a10SAndre Fischer 			Any(true));
4008dcb2a10SAndre Fischer 
4018dcb2a10SAndre Fischer 		*/
4028dcb2a10SAndre Fischer 
4038dcb2a10SAndre Fischer 		// Gradient style
4042b6825c7SAndre Fischer 		Color aGradientStop2 (aBaseBackgroundColor);
40535c52e30Smseidel 		aGradientStop2.IncreaseLuminance(0);
4062b6825c7SAndre Fischer 		Color aToolBoxBorderColor (aBaseBackgroundColor);
40735c52e30Smseidel 		aToolBoxBorderColor.DecreaseLuminance(40);
40895a18594SAndre Fischer 		setPropertyValue(
40995a18594SAndre Fischer 			maPropertyIdToNameMap[Paint_ToolBoxBackground],
41095a18594SAndre Fischer 			Any(Tools::VclToAwtGradient(Gradient(
41195a18594SAndre Fischer 						GRADIENT_LINEAR,
4122b6825c7SAndre Fischer 						aBaseBackgroundColor.GetRGBColor(),
4132b6825c7SAndre Fischer 						aGradientStop2.GetRGBColor()
41495a18594SAndre Fischer 						))));
41595a18594SAndre Fischer 		setPropertyValue(
41695a18594SAndre Fischer 			maPropertyIdToNameMap[Paint_ToolBoxBorderTopLeft],
41795a18594SAndre Fischer 			mbIsHighContrastMode
41895a18594SAndre Fischer 				? Any(util::Color(sal_uInt32(0x00ff00)))
4192b6825c7SAndre Fischer 				: Any(util::Color(aToolBoxBorderColor.GetRGBColor())));
42095a18594SAndre Fischer 		setPropertyValue(
42195a18594SAndre Fischer 			maPropertyIdToNameMap[Paint_ToolBoxBorderCenterCorners],
42295a18594SAndre Fischer 			mbIsHighContrastMode
42395a18594SAndre Fischer 				? Any(util::Color(sal_uInt32(0x00ff00)))
4242b6825c7SAndre Fischer 				: Any(util::Color(aToolBoxBorderColor.GetRGBColor())));
42595a18594SAndre Fischer 		setPropertyValue(
42695a18594SAndre Fischer 			maPropertyIdToNameMap[Paint_ToolBoxBorderBottomRight],
42795a18594SAndre Fischer 			mbIsHighContrastMode
42895a18594SAndre Fischer 				? Any(util::Color(sal_uInt32(0x00ff00)))
4292b6825c7SAndre Fischer 				: Any(util::Color(aToolBoxBorderColor.GetRGBColor())));
43095a18594SAndre Fischer 		setPropertyValue(
43195a18594SAndre Fischer 			maPropertyIdToNameMap[Rect_ToolBoxPadding],
43295a18594SAndre Fischer 			Any(awt::Rectangle(2,2,2,2)));
43395a18594SAndre Fischer 		setPropertyValue(
43495a18594SAndre Fischer 			maPropertyIdToNameMap[Rect_ToolBoxBorder],
43595a18594SAndre Fischer 			Any(awt::Rectangle(1,1,1,1)));
43695a18594SAndre Fischer 		setPropertyValue(
43795a18594SAndre Fischer 			maPropertyIdToNameMap[Bool_UseToolBoxItemSeparator],
43895a18594SAndre Fischer 			Any(false));
439ff12d537SAndre Fischer 	}
44095a18594SAndre Fischer 	catch(beans::UnknownPropertyException& rException)
441b9e67834SAndre Fischer 	{
44295a18594SAndre Fischer 		OSL_TRACE("unknown property: %s",
44395a18594SAndre Fischer 			OUStringToOString(
44495a18594SAndre Fischer 				rException.Message,
44595a18594SAndre Fischer 				RTL_TEXTENCODING_ASCII_US).getStr());
446b9e67834SAndre Fischer 		OSL_ASSERT(false);
447b9e67834SAndre Fischer 	}
448b9e67834SAndre Fischer }
449b9e67834SAndre Fischer 
450b9e67834SAndre Fischer 
disposing(void)451b9e67834SAndre Fischer void SAL_CALL Theme::disposing (void)
452b9e67834SAndre Fischer {
453b9e67834SAndre Fischer 	ChangeListeners aListeners;
454b9e67834SAndre Fischer 	maChangeListeners.swap(aListeners);
455b9e67834SAndre Fischer 
456b9e67834SAndre Fischer 	const lang::EventObject aEvent (static_cast<XWeak*>(this));
457b9e67834SAndre Fischer 
458b9e67834SAndre Fischer 	for (ChangeListeners::const_iterator
459b9e67834SAndre Fischer 			 iContainer(maChangeListeners.begin()),
460b9e67834SAndre Fischer 			 iContainerEnd(maChangeListeners.end());
461b9e67834SAndre Fischer 		 iContainerEnd!=iContainerEnd;
462b9e67834SAndre Fischer 		 ++iContainerEnd)
463b9e67834SAndre Fischer 	{
464b9e67834SAndre Fischer 		for (ChangeListenerContainer::const_iterator
465b9e67834SAndre Fischer 				 iListener(iContainer->second.begin()),
466b9e67834SAndre Fischer 				 iEnd(iContainer->second.end());
467b9e67834SAndre Fischer 			 iListener!=iEnd;
468b9e67834SAndre Fischer 			 ++iListener)
469b9e67834SAndre Fischer 		{
470b9e67834SAndre Fischer 			try
471b9e67834SAndre Fischer 			{
472b9e67834SAndre Fischer 				(*iListener)->disposing(aEvent);
473b9e67834SAndre Fischer 			}
474b9e67834SAndre Fischer 			catch(const Exception&)
475b9e67834SAndre Fischer 			{
476b9e67834SAndre Fischer 			}
477b9e67834SAndre Fischer 		}
478b9e67834SAndre Fischer 	}
479b9e67834SAndre Fischer }
480b9e67834SAndre Fischer 
481b9e67834SAndre Fischer 
GetPropertySet(void)482b9e67834SAndre Fischer Reference<beans::XPropertySet> Theme::GetPropertySet (void)
483b9e67834SAndre Fischer {
484b9e67834SAndre Fischer 	return Reference<beans::XPropertySet>(static_cast<XWeak*>(&GetCurrentTheme()), UNO_QUERY);
485b9e67834SAndre Fischer }
486b9e67834SAndre Fischer 
487b9e67834SAndre Fischer 
getPropertySetInfo(void)488b9e67834SAndre Fischer Reference<beans::XPropertySetInfo> SAL_CALL Theme::getPropertySetInfo (void)
489b9e67834SAndre Fischer 	throw(cssu::RuntimeException)
490b9e67834SAndre Fischer {
49195a18594SAndre Fischer 	return Reference<beans::XPropertySetInfo>(this);
492b9e67834SAndre Fischer }
493b9e67834SAndre Fischer 
494b9e67834SAndre Fischer 
setPropertyValue(const::rtl::OUString & rsPropertyName,const cssu::Any & rValue)495b9e67834SAndre Fischer void SAL_CALL Theme::setPropertyValue (
496b9e67834SAndre Fischer 	const ::rtl::OUString& rsPropertyName,
497b9e67834SAndre Fischer 	const cssu::Any& rValue)
498b9e67834SAndre Fischer 	throw(cssu::RuntimeException)
499b9e67834SAndre Fischer {
500b9e67834SAndre Fischer 	PropertyNameToIdMap::const_iterator iId (maPropertyNameToIdMap.find(rsPropertyName));
501b9e67834SAndre Fischer 	if (iId == maPropertyNameToIdMap.end())
50295a18594SAndre Fischer 		throw beans::UnknownPropertyException(rsPropertyName, NULL);
503b9e67834SAndre Fischer 
504b9e67834SAndre Fischer 	const PropertyType eType (GetPropertyType(iId->second));
505b9e67834SAndre Fischer 	if (eType == PT_Invalid)
50695a18594SAndre Fischer 		throw beans::UnknownPropertyException(rsPropertyName, NULL);
507b9e67834SAndre Fischer 
508b9e67834SAndre Fischer 	const ThemeItem eItem (iId->second);
509b9e67834SAndre Fischer 
510b9e67834SAndre Fischer 	if (rValue == maRawValues[eItem])
511b9e67834SAndre Fischer 	{
512b9e67834SAndre Fischer 		// Value is not different from the one in the property
513b9e67834SAndre Fischer 		// set => nothing to do.
514b9e67834SAndre Fischer 		return;
515b9e67834SAndre Fischer 	}
516b9e67834SAndre Fischer 
517b9e67834SAndre Fischer 	const Any aOldValue (maRawValues[eItem]);
518b9e67834SAndre Fischer 
519b9e67834SAndre Fischer 	const beans::PropertyChangeEvent aEvent(
520b9e67834SAndre Fischer 		static_cast<XWeak*>(this),
521b9e67834SAndre Fischer 		rsPropertyName,
522b9e67834SAndre Fischer 		sal_False,
523b9e67834SAndre Fischer 		eItem,
524b9e67834SAndre Fischer 		aOldValue,
525b9e67834SAndre Fischer 		rValue);
526b9e67834SAndre Fischer 
527b9e67834SAndre Fischer 	if (DoVetoableListenersVeto(GetVetoableListeners(__AnyItem, false), aEvent))
528b9e67834SAndre Fischer 		return;
529b9e67834SAndre Fischer 	if (DoVetoableListenersVeto(GetVetoableListeners(eItem, false), aEvent))
530b9e67834SAndre Fischer 		return;
531b9e67834SAndre Fischer 
532b9e67834SAndre Fischer 	maRawValues[eItem] = rValue;
533b9e67834SAndre Fischer 	ProcessNewValue(rValue, eItem, eType);
534b9e67834SAndre Fischer 
535b9e67834SAndre Fischer 	BroadcastPropertyChange(GetChangeListeners(__AnyItem, false), aEvent);
536b9e67834SAndre Fischer 	BroadcastPropertyChange(GetChangeListeners(eItem, false), aEvent);
537b9e67834SAndre Fischer }
538b9e67834SAndre Fischer 
539b9e67834SAndre Fischer 
getPropertyValue(const::rtl::OUString & rsPropertyName)540b9e67834SAndre Fischer Any SAL_CALL Theme::getPropertyValue (
541b9e67834SAndre Fischer 	const ::rtl::OUString& rsPropertyName)
542b9e67834SAndre Fischer 	throw(css::beans::UnknownPropertyException,
543b9e67834SAndre Fischer 		css::lang::WrappedTargetException,
544b9e67834SAndre Fischer 		cssu::RuntimeException)
545b9e67834SAndre Fischer {
546b9e67834SAndre Fischer 	PropertyNameToIdMap::const_iterator iId (maPropertyNameToIdMap.find(rsPropertyName));
547b9e67834SAndre Fischer 	if (iId == maPropertyNameToIdMap.end())
548b9e67834SAndre Fischer 		throw beans::UnknownPropertyException();
549b9e67834SAndre Fischer 
550b9e67834SAndre Fischer 	const PropertyType eType (GetPropertyType(iId->second));
551b9e67834SAndre Fischer 	if (eType == PT_Invalid)
552b9e67834SAndre Fischer 		throw beans::UnknownPropertyException();
553b9e67834SAndre Fischer 
554b9e67834SAndre Fischer 	const ThemeItem eItem (iId->second);
555b9e67834SAndre Fischer 
556b9e67834SAndre Fischer 	return maRawValues[eItem];
557b9e67834SAndre Fischer }
558b9e67834SAndre Fischer 
559b9e67834SAndre Fischer 
addPropertyChangeListener(const::rtl::OUString & rsPropertyName,const cssu::Reference<css::beans::XPropertyChangeListener> & rxListener)560b9e67834SAndre Fischer void SAL_CALL Theme::addPropertyChangeListener(
561b9e67834SAndre Fischer 	const ::rtl::OUString& rsPropertyName,
562b9e67834SAndre Fischer 	const cssu::Reference<css::beans::XPropertyChangeListener>& rxListener)
563b9e67834SAndre Fischer 	throw(css::beans::UnknownPropertyException,
564b9e67834SAndre Fischer 		css::lang::WrappedTargetException,
565b9e67834SAndre Fischer 		cssu::RuntimeException)
566b9e67834SAndre Fischer {
567b9e67834SAndre Fischer 	ThemeItem eItem (__AnyItem);
568b9e67834SAndre Fischer 	if (rsPropertyName.getLength() > 0)
569b9e67834SAndre Fischer 	{
570b9e67834SAndre Fischer 		PropertyNameToIdMap::const_iterator iId (maPropertyNameToIdMap.find(rsPropertyName));
571b9e67834SAndre Fischer 		if (iId == maPropertyNameToIdMap.end())
572b9e67834SAndre Fischer 			throw beans::UnknownPropertyException();
573b9e67834SAndre Fischer 
574b9e67834SAndre Fischer 		const PropertyType eType (GetPropertyType(iId->second));
575b9e67834SAndre Fischer 		if (eType == PT_Invalid)
576b9e67834SAndre Fischer 			throw beans::UnknownPropertyException();
577b9e67834SAndre Fischer 
578b9e67834SAndre Fischer 		eItem = iId->second;
579b9e67834SAndre Fischer 	}
580b9e67834SAndre Fischer 	ChangeListenerContainer* pListeners = GetChangeListeners(eItem, true);
581b9e67834SAndre Fischer 	if (pListeners != NULL)
582b9e67834SAndre Fischer 		pListeners->push_back(rxListener);
583b9e67834SAndre Fischer }
584b9e67834SAndre Fischer 
585b9e67834SAndre Fischer 
removePropertyChangeListener(const::rtl::OUString & rsPropertyName,const cssu::Reference<css::beans::XPropertyChangeListener> & rxListener)586b9e67834SAndre Fischer void SAL_CALL Theme::removePropertyChangeListener(
587b9e67834SAndre Fischer 	const ::rtl::OUString& rsPropertyName,
588b9e67834SAndre Fischer 	const cssu::Reference<css::beans::XPropertyChangeListener>& rxListener)
589b9e67834SAndre Fischer 	throw(css::beans::UnknownPropertyException,
590b9e67834SAndre Fischer 		css::lang::WrappedTargetException,
591b9e67834SAndre Fischer 		cssu::RuntimeException)
592b9e67834SAndre Fischer {
593b9e67834SAndre Fischer 	ThemeItem eItem (__AnyItem);
594b9e67834SAndre Fischer 	if (rsPropertyName.getLength() > 0)
595b9e67834SAndre Fischer 	{
596b9e67834SAndre Fischer 		PropertyNameToIdMap::const_iterator iId (maPropertyNameToIdMap.find(rsPropertyName));
597b9e67834SAndre Fischer 		if (iId == maPropertyNameToIdMap.end())
598b9e67834SAndre Fischer 			throw beans::UnknownPropertyException();
599b9e67834SAndre Fischer 
600b9e67834SAndre Fischer 		const PropertyType eType (GetPropertyType(iId->second));
601b9e67834SAndre Fischer 		if (eType == PT_Invalid)
602b9e67834SAndre Fischer 			throw beans::UnknownPropertyException();
603b9e67834SAndre Fischer 
604b9e67834SAndre Fischer 		eItem = iId->second;
605b9e67834SAndre Fischer 	}
606b9e67834SAndre Fischer 	ChangeListenerContainer* pContainer = GetChangeListeners(eItem, false);
607b9e67834SAndre Fischer 	if (pContainer != NULL)
608b9e67834SAndre Fischer 	{
609b9e67834SAndre Fischer 		ChangeListenerContainer::iterator iListener (::std::find(pContainer->begin(), pContainer->end(), rxListener));
610b9e67834SAndre Fischer 		if (iListener != pContainer->end())
611b9e67834SAndre Fischer 		{
612b9e67834SAndre Fischer 			pContainer->erase(iListener);
613b9e67834SAndre Fischer 
614b9e67834SAndre Fischer 			// Remove the listener container when empty.
615b9e67834SAndre Fischer 			if (pContainer->empty())
616b9e67834SAndre Fischer 				maChangeListeners.erase(eItem);
617b9e67834SAndre Fischer 		}
618b9e67834SAndre Fischer 	}
619b9e67834SAndre Fischer }
620b9e67834SAndre Fischer 
621b9e67834SAndre Fischer 
addVetoableChangeListener(const::rtl::OUString & rsPropertyName,const cssu::Reference<css::beans::XVetoableChangeListener> & rxListener)622b9e67834SAndre Fischer void SAL_CALL Theme::addVetoableChangeListener(
623b9e67834SAndre Fischer 	const ::rtl::OUString& rsPropertyName,
624b9e67834SAndre Fischer 	const cssu::Reference<css::beans::XVetoableChangeListener>& rxListener)
625b9e67834SAndre Fischer 	throw(css::beans::UnknownPropertyException,
626b9e67834SAndre Fischer 		css::lang::WrappedTargetException,
627b9e67834SAndre Fischer 		cssu::RuntimeException)
628b9e67834SAndre Fischer {
629b9e67834SAndre Fischer 	ThemeItem eItem (__AnyItem);
630b9e67834SAndre Fischer 	if (rsPropertyName.getLength() > 0)
631b9e67834SAndre Fischer 	{
632b9e67834SAndre Fischer 		PropertyNameToIdMap::const_iterator iId (maPropertyNameToIdMap.find(rsPropertyName));
633b9e67834SAndre Fischer 		if (iId == maPropertyNameToIdMap.end())
634b9e67834SAndre Fischer 			throw beans::UnknownPropertyException();
635b9e67834SAndre Fischer 
636b9e67834SAndre Fischer 		const PropertyType eType (GetPropertyType(iId->second));
637b9e67834SAndre Fischer 		if (eType == PT_Invalid)
638b9e67834SAndre Fischer 			throw beans::UnknownPropertyException();
639b9e67834SAndre Fischer 
640b9e67834SAndre Fischer 		eItem = iId->second;
641b9e67834SAndre Fischer 	}
642b9e67834SAndre Fischer 	VetoableListenerContainer* pListeners = GetVetoableListeners(eItem, true);
643b9e67834SAndre Fischer 	if (pListeners != NULL)
644b9e67834SAndre Fischer 		pListeners->push_back(rxListener);
645b9e67834SAndre Fischer }
646b9e67834SAndre Fischer 
647b9e67834SAndre Fischer 
removeVetoableChangeListener(const::rtl::OUString & rsPropertyName,const cssu::Reference<css::beans::XVetoableChangeListener> & rxListener)648b9e67834SAndre Fischer void SAL_CALL Theme::removeVetoableChangeListener(
649b9e67834SAndre Fischer 	const ::rtl::OUString& rsPropertyName,
650b9e67834SAndre Fischer 	const cssu::Reference<css::beans::XVetoableChangeListener>& rxListener)
651b9e67834SAndre Fischer 	throw(css::beans::UnknownPropertyException,
652b9e67834SAndre Fischer 		css::lang::WrappedTargetException,
653b9e67834SAndre Fischer 		cssu::RuntimeException)
654b9e67834SAndre Fischer {
655b9e67834SAndre Fischer 	ThemeItem eItem (__AnyItem);
656b9e67834SAndre Fischer 	if (rsPropertyName.getLength() > 0)
657b9e67834SAndre Fischer 	{
658b9e67834SAndre Fischer 		PropertyNameToIdMap::const_iterator iId (maPropertyNameToIdMap.find(rsPropertyName));
659b9e67834SAndre Fischer 		if (iId == maPropertyNameToIdMap.end())
660b9e67834SAndre Fischer 			throw beans::UnknownPropertyException();
661b9e67834SAndre Fischer 
662b9e67834SAndre Fischer 		const PropertyType eType (GetPropertyType(iId->second));
663b9e67834SAndre Fischer 		if (eType == PT_Invalid)
664b9e67834SAndre Fischer 			throw beans::UnknownPropertyException();
665b9e67834SAndre Fischer 
666b9e67834SAndre Fischer 		eItem = iId->second;
667b9e67834SAndre Fischer 	}
668b9e67834SAndre Fischer 	VetoableListenerContainer* pContainer = GetVetoableListeners(eItem, false);
669b9e67834SAndre Fischer 	if (pContainer != NULL)
670b9e67834SAndre Fischer 	{
671b9e67834SAndre Fischer 		VetoableListenerContainer::iterator iListener (::std::find(pContainer->begin(), pContainer->end(), rxListener));
672b9e67834SAndre Fischer 		if (iListener != pContainer->end())
673b9e67834SAndre Fischer 		{
674b9e67834SAndre Fischer 			pContainer->erase(iListener);
675b9e67834SAndre Fischer 			// Remove container when empty.
676b9e67834SAndre Fischer 			if (pContainer->empty())
677b9e67834SAndre Fischer 				maVetoableListeners.erase(eItem);
678b9e67834SAndre Fischer 		}
679b9e67834SAndre Fischer 	}
680b9e67834SAndre Fischer }
681b9e67834SAndre Fischer 
682b9e67834SAndre Fischer 
getProperties(void)68395a18594SAndre Fischer cssu::Sequence<css::beans::Property> SAL_CALL Theme::getProperties (void)
68495a18594SAndre Fischer 	throw(cssu::RuntimeException)
68595a18594SAndre Fischer {
68695a18594SAndre Fischer 	::std::vector<beans::Property> aProperties;
68795a18594SAndre Fischer 
68895a18594SAndre Fischer 	for (sal_Int32 nItem(__Begin),nEnd(__End); nItem!=nEnd; ++nItem)
68995a18594SAndre Fischer 	{
69095a18594SAndre Fischer 		const ThemeItem eItem (static_cast<ThemeItem>(nItem));
69195a18594SAndre Fischer 		const PropertyType eType (GetPropertyType(eItem));
69295a18594SAndre Fischer 		if (eType == PT_Invalid)
69395a18594SAndre Fischer 			continue;
69495a18594SAndre Fischer 
69595a18594SAndre Fischer 		const beans::Property aProperty(
69695a18594SAndre Fischer 			maPropertyIdToNameMap[eItem],
69795a18594SAndre Fischer 			eItem,
69895a18594SAndre Fischer 			GetCppuType(eType),
69995a18594SAndre Fischer 			0);
70095a18594SAndre Fischer 		aProperties.push_back(aProperty);
70195a18594SAndre Fischer 	}
70295a18594SAndre Fischer 
70395a18594SAndre Fischer 	return cssu::Sequence<css::beans::Property>(
70495a18594SAndre Fischer 		&aProperties.front(),
70595a18594SAndre Fischer 		aProperties.size());
70695a18594SAndre Fischer }
70795a18594SAndre Fischer 
70895a18594SAndre Fischer 
getPropertyByName(const::rtl::OUString & rsPropertyName)70995a18594SAndre Fischer beans::Property SAL_CALL Theme::getPropertyByName (const ::rtl::OUString& rsPropertyName)
71095a18594SAndre Fischer 	throw(css::beans::UnknownPropertyException,
71195a18594SAndre Fischer 		cssu::RuntimeException)
71295a18594SAndre Fischer {
71395a18594SAndre Fischer 	PropertyNameToIdMap::const_iterator iId (maPropertyNameToIdMap.find(rsPropertyName));
71495a18594SAndre Fischer 	if (iId == maPropertyNameToIdMap.end())
71595a18594SAndre Fischer 		throw beans::UnknownPropertyException();
71695a18594SAndre Fischer 
71795a18594SAndre Fischer 	const PropertyType eType (GetPropertyType(iId->second));
71895a18594SAndre Fischer 	if (eType == PT_Invalid)
71995a18594SAndre Fischer 		throw beans::UnknownPropertyException();
72095a18594SAndre Fischer 
72195a18594SAndre Fischer 	const ThemeItem eItem (iId->second);
72295a18594SAndre Fischer 
72395a18594SAndre Fischer 	return beans::Property(
72495a18594SAndre Fischer 		rsPropertyName,
72595a18594SAndre Fischer 		eItem,
72695a18594SAndre Fischer 		GetCppuType(eType),
72795a18594SAndre Fischer 		0);
72895a18594SAndre Fischer }
72995a18594SAndre Fischer 
73095a18594SAndre Fischer 
hasPropertyByName(const::rtl::OUString & rsPropertyName)73195a18594SAndre Fischer sal_Bool SAL_CALL Theme::hasPropertyByName (const ::rtl::OUString& rsPropertyName)
73295a18594SAndre Fischer 	throw(cssu::RuntimeException)
73395a18594SAndre Fischer {
73495a18594SAndre Fischer 	PropertyNameToIdMap::const_iterator iId (maPropertyNameToIdMap.find(rsPropertyName));
73595a18594SAndre Fischer 	if (iId == maPropertyNameToIdMap.end())
73695a18594SAndre Fischer 		return sal_False;
73795a18594SAndre Fischer 
73895a18594SAndre Fischer 	const PropertyType eType (GetPropertyType(iId->second));
73995a18594SAndre Fischer 	if (eType == PT_Invalid)
74095a18594SAndre Fischer 		return sal_False;
74195a18594SAndre Fischer 
74295a18594SAndre Fischer 	return sal_True;
74395a18594SAndre Fischer }
74495a18594SAndre Fischer 
74595a18594SAndre Fischer 
SetupPropertyMaps(void)746b9e67834SAndre Fischer void Theme::SetupPropertyMaps (void)
747b9e67834SAndre Fischer {
74895a18594SAndre Fischer 	maPropertyIdToNameMap.resize(__Post_Rect);
749b9e67834SAndre Fischer 	maImages.resize(__Image_Color - __Pre_Image - 1);
750b9e67834SAndre Fischer 	maColors.resize(__Color_Paint - __Image_Color - 1);
751b9e67834SAndre Fischer 	maPaints.resize(__Paint_Int - __Color_Paint - 1);
752b9e67834SAndre Fischer 	maIntegers.resize(__Int_Bool - __Paint_Int - 1);
75395a18594SAndre Fischer 	maBooleans.resize(__Bool_Rect - __Int_Bool - 1);
75495a18594SAndre Fischer 	maRectangles.resize(__Post_Rect - __Bool_Rect - 1);
755b9e67834SAndre Fischer 
756b9e67834SAndre Fischer 	#define AddEntry(e) maPropertyNameToIdMap[A2S(#e)]=e; maPropertyIdToNameMap[e]=A2S(#e)
75795a18594SAndre Fischer 
758b9e67834SAndre Fischer 	AddEntry(Image_Grip);
759b9e67834SAndre Fischer 	AddEntry(Image_Expand);
760b9e67834SAndre Fischer 	AddEntry(Image_Collapse);
7617a32b0c8SAndre Fischer 	AddEntry(Image_TabBarMenu);
7627a32b0c8SAndre Fischer 	AddEntry(Image_PanelMenu);
76395a18594SAndre Fischer 	AddEntry(Image_ToolBoxItemSeparator);
7647a32b0c8SAndre Fischer 	AddEntry(Image_Closer);
76513e1c3b4SAndre Fischer 	AddEntry(Image_CloseIndicator);
766b9e67834SAndre Fischer 
767b9e67834SAndre Fischer 	AddEntry(Color_DeckTitleFont);
768b9e67834SAndre Fischer 	AddEntry(Color_PanelTitleFont);
769b9e67834SAndre Fischer 	AddEntry(Color_TabMenuSeparator);
770b9e67834SAndre Fischer 	AddEntry(Color_TabItemBorder);
7718dcb2a10SAndre Fischer 	AddEntry(Color_DropDownBorder);
7725f1c83ffSOliver-Rainer Wittmann 	AddEntry(Color_Highlight);
7735f1c83ffSOliver-Rainer Wittmann 	AddEntry(Color_HighlightText);
774b9e67834SAndre Fischer 
775b9e67834SAndre Fischer 	AddEntry(Paint_DeckBackground);
776b9e67834SAndre Fischer 	AddEntry(Paint_DeckTitleBarBackground);
777b9e67834SAndre Fischer 	AddEntry(Paint_PanelBackground);
778b9e67834SAndre Fischer 	AddEntry(Paint_PanelTitleBarBackground);
779b9e67834SAndre Fischer 	AddEntry(Paint_TabBarBackground);
78095a18594SAndre Fischer 	AddEntry(Paint_TabItemBackgroundNormal);
78195a18594SAndre Fischer 	AddEntry(Paint_TabItemBackgroundHighlight);
782b9e67834SAndre Fischer 	AddEntry(Paint_HorizontalBorder);
783b9e67834SAndre Fischer 	AddEntry(Paint_VerticalBorder);
78495a18594SAndre Fischer 	AddEntry(Paint_ToolBoxBackground);
78595a18594SAndre Fischer 	AddEntry(Paint_ToolBoxBorderTopLeft);
78695a18594SAndre Fischer 	AddEntry(Paint_ToolBoxBorderCenterCorners);
78795a18594SAndre Fischer 	AddEntry(Paint_ToolBoxBorderBottomRight);
7888dcb2a10SAndre Fischer 	AddEntry(Paint_DropDownBackground);
789b9e67834SAndre Fischer 
790b9e67834SAndre Fischer 	AddEntry(Int_DeckTitleBarHeight);
791b9e67834SAndre Fischer 	AddEntry(Int_DeckBorderSize);
792b9e67834SAndre Fischer 	AddEntry(Int_DeckSeparatorHeight);
793b9e67834SAndre Fischer 	AddEntry(Int_PanelTitleBarHeight);
794b9e67834SAndre Fischer 	AddEntry(Int_TabMenuPadding);
795b9e67834SAndre Fischer 	AddEntry(Int_TabMenuSeparatorPadding);
796b9e67834SAndre Fischer 	AddEntry(Int_TabItemWidth);
797b9e67834SAndre Fischer 	AddEntry(Int_TabItemHeight);
798b9e67834SAndre Fischer 	AddEntry(Int_DeckLeftPadding);
799b9e67834SAndre Fischer 	AddEntry(Int_DeckTopPadding);
800b9e67834SAndre Fischer 	AddEntry(Int_DeckRightPadding);
801b9e67834SAndre Fischer 	AddEntry(Int_DeckBottomPadding);
802b9e67834SAndre Fischer 	AddEntry(Int_TabBarLeftPadding);
803b9e67834SAndre Fischer 	AddEntry(Int_TabBarTopPadding);
804b9e67834SAndre Fischer 	AddEntry(Int_TabBarRightPadding);
805b9e67834SAndre Fischer 	AddEntry(Int_TabBarBottomPadding);
80637fee4fdSAndre Fischer 	AddEntry(Int_ButtonCornerRadius);
807b9e67834SAndre Fischer 
808b9e67834SAndre Fischer 	AddEntry(Bool_UseSymphonyIcons);
80995a18594SAndre Fischer 	AddEntry(Bool_UseSystemColors);
81095a18594SAndre Fischer 	AddEntry(Bool_UseToolBoxItemSeparator);
81195a18594SAndre Fischer 	AddEntry(Bool_IsHighContrastModeActive);
81295a18594SAndre Fischer 
81395a18594SAndre Fischer 	AddEntry(Rect_ToolBoxPadding);
81495a18594SAndre Fischer 	AddEntry(Rect_ToolBoxBorder);
81595a18594SAndre Fischer 
816b9e67834SAndre Fischer 	#undef AddEntry
817b9e67834SAndre Fischer 
818b9e67834SAndre Fischer 	maRawValues.resize(maPropertyIdToNameMap.size());
819b9e67834SAndre Fischer }
820b9e67834SAndre Fischer 
821b9e67834SAndre Fischer 
GetPropertyType(const ThemeItem eItem)822b9e67834SAndre Fischer Theme::PropertyType Theme::GetPropertyType (const ThemeItem eItem)
823b9e67834SAndre Fischer {
824b9e67834SAndre Fischer 	switch(eItem)
825b9e67834SAndre Fischer 	{
826b9e67834SAndre Fischer 		case Image_Grip:
827b9e67834SAndre Fischer 		case Image_Expand:
828b9e67834SAndre Fischer 		case Image_Collapse:
8297a32b0c8SAndre Fischer 		case Image_TabBarMenu:
8307a32b0c8SAndre Fischer 		case Image_PanelMenu:
83195a18594SAndre Fischer 		case Image_ToolBoxItemSeparator:
8327a32b0c8SAndre Fischer 		case Image_Closer:
83313e1c3b4SAndre Fischer 		case Image_CloseIndicator:
834b9e67834SAndre Fischer 			return PT_Image;
835b9e67834SAndre Fischer 
836b9e67834SAndre Fischer 		case Color_DeckTitleFont:
837b9e67834SAndre Fischer 		case Color_PanelTitleFont:
838b9e67834SAndre Fischer 		case Color_TabMenuSeparator:
839b9e67834SAndre Fischer 		case Color_TabItemBorder:
8408dcb2a10SAndre Fischer 		case Color_DropDownBorder:
8415f1c83ffSOliver-Rainer Wittmann 		case Color_Highlight:
8425f1c83ffSOliver-Rainer Wittmann 		case Color_HighlightText:
843b9e67834SAndre Fischer 			return PT_Color;
844b9e67834SAndre Fischer 
845b9e67834SAndre Fischer 		case Paint_DeckBackground:
846b9e67834SAndre Fischer 		case Paint_DeckTitleBarBackground:
847b9e67834SAndre Fischer 		case Paint_PanelBackground:
848b9e67834SAndre Fischer 		case Paint_PanelTitleBarBackground:
849b9e67834SAndre Fischer 		case Paint_TabBarBackground:
85095a18594SAndre Fischer 		case Paint_TabItemBackgroundNormal:
85195a18594SAndre Fischer 		case Paint_TabItemBackgroundHighlight:
852b9e67834SAndre Fischer 		case Paint_HorizontalBorder:
853b9e67834SAndre Fischer 		case Paint_VerticalBorder:
85495a18594SAndre Fischer 		case Paint_ToolBoxBackground:
85595a18594SAndre Fischer 		case Paint_ToolBoxBorderTopLeft:
85695a18594SAndre Fischer 		case Paint_ToolBoxBorderCenterCorners:
85795a18594SAndre Fischer 		case Paint_ToolBoxBorderBottomRight:
8588dcb2a10SAndre Fischer 		case Paint_DropDownBackground:
859b9e67834SAndre Fischer 			return PT_Paint;
860b9e67834SAndre Fischer 
861b9e67834SAndre Fischer 		case Int_DeckTitleBarHeight:
862b9e67834SAndre Fischer 		case Int_DeckBorderSize:
863b9e67834SAndre Fischer 		case Int_DeckSeparatorHeight:
864b9e67834SAndre Fischer 		case Int_PanelTitleBarHeight:
865b9e67834SAndre Fischer 		case Int_TabMenuPadding:
866b9e67834SAndre Fischer 		case Int_TabMenuSeparatorPadding:
867b9e67834SAndre Fischer 		case Int_TabItemWidth:
868b9e67834SAndre Fischer 		case Int_TabItemHeight:
869b9e67834SAndre Fischer 		case Int_DeckLeftPadding:
870b9e67834SAndre Fischer 		case Int_DeckTopPadding:
871b9e67834SAndre Fischer 		case Int_DeckRightPadding:
872b9e67834SAndre Fischer 		case Int_DeckBottomPadding:
873b9e67834SAndre Fischer 		case Int_TabBarLeftPadding:
874b9e67834SAndre Fischer 		case Int_TabBarTopPadding:
875b9e67834SAndre Fischer 		case Int_TabBarRightPadding:
876b9e67834SAndre Fischer 		case Int_TabBarBottomPadding:
87737fee4fdSAndre Fischer 		case Int_ButtonCornerRadius:
878b9e67834SAndre Fischer 			return PT_Integer;
879b9e67834SAndre Fischer 
880b9e67834SAndre Fischer 		case Bool_UseSymphonyIcons:
88195a18594SAndre Fischer 		case Bool_UseSystemColors:
88295a18594SAndre Fischer 		case Bool_UseToolBoxItemSeparator:
88395a18594SAndre Fischer 		case Bool_IsHighContrastModeActive:
884b9e67834SAndre Fischer 			return PT_Boolean;
885b9e67834SAndre Fischer 
88695a18594SAndre Fischer 		case Rect_ToolBoxBorder:
88795a18594SAndre Fischer 		case Rect_ToolBoxPadding:
88895a18594SAndre Fischer 			return PT_Rectangle;
88995a18594SAndre Fischer 
890b9e67834SAndre Fischer 		default:
891b9e67834SAndre Fischer 			return PT_Invalid;
892b9e67834SAndre Fischer 	}
893b9e67834SAndre Fischer }
894b9e67834SAndre Fischer 
895b9e67834SAndre Fischer 
GetCppuType(const PropertyType eType)89695a18594SAndre Fischer cssu::Type Theme::GetCppuType (const PropertyType eType)
89795a18594SAndre Fischer {
89895a18594SAndre Fischer 	switch(eType)
89995a18594SAndre Fischer 	{
90095a18594SAndre Fischer 		case PT_Image:
90195a18594SAndre Fischer 			return getCppuType((rtl::OUString*)NULL);
90295a18594SAndre Fischer 
90395a18594SAndre Fischer 		case PT_Color:
90495a18594SAndre Fischer 			return getCppuType((sal_uInt32*)NULL);
90595a18594SAndre Fischer 
90695a18594SAndre Fischer 		case PT_Paint:
90795a18594SAndre Fischer 			return getCppuVoidType();
90895a18594SAndre Fischer 
90995a18594SAndre Fischer 		case PT_Integer:
91095a18594SAndre Fischer 			return getCppuType((sal_Int32*)NULL);
91195a18594SAndre Fischer 
91295a18594SAndre Fischer 		case PT_Boolean:
91395a18594SAndre Fischer 			return getCppuType((sal_Bool*)NULL);
91495a18594SAndre Fischer 
91595a18594SAndre Fischer 		case PT_Rectangle:
91695a18594SAndre Fischer 			return getCppuType((awt::Rectangle*)NULL);
91795a18594SAndre Fischer 
91895a18594SAndre Fischer 		case PT_Invalid:
91995a18594SAndre Fischer 		default:
92095a18594SAndre Fischer 			return getCppuVoidType();
92195a18594SAndre Fischer 	}
92295a18594SAndre Fischer }
92395a18594SAndre Fischer 
92495a18594SAndre Fischer 
GetIndex(const ThemeItem eItem,const PropertyType eType)925b9e67834SAndre Fischer sal_Int32 Theme::GetIndex (const ThemeItem eItem, const PropertyType eType)
926b9e67834SAndre Fischer {
927b9e67834SAndre Fischer 	switch(eType)
928b9e67834SAndre Fischer 	{
929b9e67834SAndre Fischer 		case PT_Image:
930b9e67834SAndre Fischer 			return eItem - __Pre_Image-1;
931b9e67834SAndre Fischer 		case PT_Color:
932b9e67834SAndre Fischer 			return eItem - __Image_Color-1;
933b9e67834SAndre Fischer 		case PT_Paint:
934b9e67834SAndre Fischer 			return eItem - __Color_Paint-1;
935b9e67834SAndre Fischer 		case PT_Integer:
936b9e67834SAndre Fischer 			return eItem - __Paint_Int-1;
937b9e67834SAndre Fischer 		case PT_Boolean:
938b9e67834SAndre Fischer 			return eItem - __Int_Bool-1;
93995a18594SAndre Fischer 		case PT_Rectangle:
94095a18594SAndre Fischer 			return eItem - __Bool_Rect-1;
941b9e67834SAndre Fischer 
942b9e67834SAndre Fischer 		default:
943b9e67834SAndre Fischer 			OSL_ASSERT(false);
944b9e67834SAndre Fischer 			return 0;
945b9e67834SAndre Fischer 	}
946b9e67834SAndre Fischer }
947b9e67834SAndre Fischer 
948b9e67834SAndre Fischer 
GetVetoableListeners(const ThemeItem eItem,const bool bCreate)949b9e67834SAndre Fischer Theme::VetoableListenerContainer* Theme::GetVetoableListeners (
950b9e67834SAndre Fischer 	const ThemeItem eItem,
951b9e67834SAndre Fischer 	const bool bCreate)
952b9e67834SAndre Fischer {
953b9e67834SAndre Fischer 	VetoableListeners::iterator iContainer (maVetoableListeners.find(eItem));
954b9e67834SAndre Fischer 	if (iContainer != maVetoableListeners.end())
955b9e67834SAndre Fischer 		return &iContainer->second;
956b9e67834SAndre Fischer 	else if (bCreate)
957b9e67834SAndre Fischer 	{
958b9e67834SAndre Fischer 		maVetoableListeners[eItem] = VetoableListenerContainer();
959b9e67834SAndre Fischer 		return &maVetoableListeners[eItem];
960b9e67834SAndre Fischer 	}
961b9e67834SAndre Fischer 	else
962b9e67834SAndre Fischer 		return NULL;
963b9e67834SAndre Fischer }
964b9e67834SAndre Fischer 
965b9e67834SAndre Fischer 
GetChangeListeners(const ThemeItem eItem,const bool bCreate)966b9e67834SAndre Fischer Theme::ChangeListenerContainer* Theme::GetChangeListeners (
967b9e67834SAndre Fischer 	const ThemeItem eItem,
968b9e67834SAndre Fischer 	const bool bCreate)
969b9e67834SAndre Fischer {
970b9e67834SAndre Fischer 	ChangeListeners::iterator iContainer (maChangeListeners.find(eItem));
971b9e67834SAndre Fischer 	if (iContainer != maChangeListeners.end())
972b9e67834SAndre Fischer 		return &iContainer->second;
973b9e67834SAndre Fischer 	else if (bCreate)
974b9e67834SAndre Fischer 	{
975b9e67834SAndre Fischer 		maChangeListeners[eItem] = ChangeListenerContainer();
976b9e67834SAndre Fischer 		return &maChangeListeners[eItem];
977b9e67834SAndre Fischer 	}
978b9e67834SAndre Fischer 	else
979b9e67834SAndre Fischer 		return NULL;
980b9e67834SAndre Fischer }
981b9e67834SAndre Fischer 
982b9e67834SAndre Fischer 
DoVetoableListenersVeto(const VetoableListenerContainer * pListeners,const beans::PropertyChangeEvent & rEvent) const983b9e67834SAndre Fischer bool Theme::DoVetoableListenersVeto (
984b9e67834SAndre Fischer 	const VetoableListenerContainer* pListeners,
985b9e67834SAndre Fischer 	const beans::PropertyChangeEvent& rEvent) const
986b9e67834SAndre Fischer {
987b9e67834SAndre Fischer 	if (pListeners == NULL)
988b9e67834SAndre Fischer 		return false;
989b9e67834SAndre Fischer 
990b9e67834SAndre Fischer 	VetoableListenerContainer aListeners (*pListeners);
991b9e67834SAndre Fischer 	try
992b9e67834SAndre Fischer 	{
993b9e67834SAndre Fischer 		for (VetoableListenerContainer::const_iterator
994b9e67834SAndre Fischer 				 iListener(aListeners.begin()),
995b9e67834SAndre Fischer 				 iEnd(aListeners.end());
996b9e67834SAndre Fischer 			 iListener!=iEnd;
997b9e67834SAndre Fischer 			 ++iListener)
998b9e67834SAndre Fischer 		{
999b9e67834SAndre Fischer 			(*iListener)->vetoableChange(rEvent);
1000b9e67834SAndre Fischer 		}
1001b9e67834SAndre Fischer 	}
1002b9e67834SAndre Fischer 	catch(const beans::PropertyVetoException&)
1003b9e67834SAndre Fischer 	{
1004b9e67834SAndre Fischer 		return true;
1005b9e67834SAndre Fischer 	}
1006b9e67834SAndre Fischer 	catch(const Exception&)
1007b9e67834SAndre Fischer 	{
1008b9e67834SAndre Fischer 		// Ignore any other errors (such as disposed listeners).
1009b9e67834SAndre Fischer 	}
1010b9e67834SAndre Fischer 	return false;
1011b9e67834SAndre Fischer }
1012b9e67834SAndre Fischer 
1013b9e67834SAndre Fischer 
BroadcastPropertyChange(const ChangeListenerContainer * pListeners,const beans::PropertyChangeEvent & rEvent) const1014b9e67834SAndre Fischer void Theme::BroadcastPropertyChange (
1015b9e67834SAndre Fischer 	const ChangeListenerContainer* pListeners,
1016b9e67834SAndre Fischer 	const beans::PropertyChangeEvent& rEvent) const
1017b9e67834SAndre Fischer {
1018b9e67834SAndre Fischer 	if (pListeners == NULL)
1019b9e67834SAndre Fischer 		return;
1020b9e67834SAndre Fischer 
1021b9e67834SAndre Fischer 	const ChangeListenerContainer aListeners (*pListeners);
1022b9e67834SAndre Fischer 	try
1023b9e67834SAndre Fischer 	{
1024b9e67834SAndre Fischer 		for (ChangeListenerContainer::const_iterator
1025b9e67834SAndre Fischer 				 iListener(aListeners.begin()),
1026b9e67834SAndre Fischer 				 iEnd(aListeners.end());
1027b9e67834SAndre Fischer 			 iListener!=iEnd;
1028b9e67834SAndre Fischer 			 ++iListener)
1029b9e67834SAndre Fischer 		{
1030b9e67834SAndre Fischer 			(*iListener)->propertyChange(rEvent);
1031b9e67834SAndre Fischer 		}
1032b9e67834SAndre Fischer 	}
1033b9e67834SAndre Fischer 	catch(const Exception&)
1034b9e67834SAndre Fischer 	{
1035b9e67834SAndre Fischer 		// Ignore any errors (such as disposed listeners).
1036b9e67834SAndre Fischer 	}
1037b9e67834SAndre Fischer }
1038b9e67834SAndre Fischer 
1039b9e67834SAndre Fischer 
ProcessNewValue(const Any & rValue,const ThemeItem eItem,const PropertyType eType)1040b9e67834SAndre Fischer void Theme::ProcessNewValue (
1041b9e67834SAndre Fischer 	const Any& rValue,
1042b9e67834SAndre Fischer 	const ThemeItem eItem,
1043b9e67834SAndre Fischer 	const PropertyType eType)
1044b9e67834SAndre Fischer {
1045b9e67834SAndre Fischer 	const sal_Int32 nIndex (GetIndex (eItem, eType));
1046b9e67834SAndre Fischer 	switch (eType)
1047b9e67834SAndre Fischer 	{
1048b9e67834SAndre Fischer 		case PT_Image:
1049b9e67834SAndre Fischer 		{
1050b9e67834SAndre Fischer 			::rtl::OUString sURL;
1051b9e67834SAndre Fischer 			if (rValue >>= sURL)
1052b9e67834SAndre Fischer 			{
1053b9e67834SAndre Fischer 				maImages[nIndex] = Tools::GetImage(sURL, NULL);
1054b9e67834SAndre Fischer 			}
1055b9e67834SAndre Fischer 			break;
1056b9e67834SAndre Fischer 		}
1057b9e67834SAndre Fischer 		case PT_Color:
1058b9e67834SAndre Fischer 		{
105995a18594SAndre Fischer 			sal_Int32 nColorValue (0);
1060b9e67834SAndre Fischer 			if (rValue >>= nColorValue)
1061b9e67834SAndre Fischer 			{
1062b9e67834SAndre Fischer 				maColors[nIndex] = Color(nColorValue);
1063b9e67834SAndre Fischer 			}
1064b9e67834SAndre Fischer 			break;
1065b9e67834SAndre Fischer 		}
1066b9e67834SAndre Fischer 		case PT_Paint:
1067b9e67834SAndre Fischer 		{
106895a18594SAndre Fischer 			maPaints[nIndex] = Paint::Create(rValue);
1069b9e67834SAndre Fischer 			break;
1070b9e67834SAndre Fischer 		}
1071b9e67834SAndre Fischer 		case PT_Integer:
1072b9e67834SAndre Fischer 		{
107395a18594SAndre Fischer 			sal_Int32 nValue (0);
1074b9e67834SAndre Fischer 			if (rValue >>= nValue)
1075b9e67834SAndre Fischer 			{
1076b9e67834SAndre Fischer 				maIntegers[nIndex] = nValue;
1077b9e67834SAndre Fischer 			}
1078b9e67834SAndre Fischer 			break;
1079b9e67834SAndre Fischer 		}
1080b9e67834SAndre Fischer 		case PT_Boolean:
1081b9e67834SAndre Fischer 		{
108295a18594SAndre Fischer 			sal_Bool nValue (0);
1083b9e67834SAndre Fischer 			if (rValue >>= nValue)
1084b9e67834SAndre Fischer 			{
1085b9e67834SAndre Fischer 				maBooleans[nIndex] = (nValue==sal_True);
108695a18594SAndre Fischer 				if (eItem == Bool_IsHighContrastModeActive)
108795a18594SAndre Fischer 				{
108895a18594SAndre Fischer 					mbIsHighContrastModeSetManually = true;
108995a18594SAndre Fischer 					mbIsHighContrastMode = maBooleans[nIndex];
109095a18594SAndre Fischer 					HandleDataChange();
109195a18594SAndre Fischer 				}
109295a18594SAndre Fischer 				else if (eItem == Bool_UseSystemColors)
109395a18594SAndre Fischer 				{
109495a18594SAndre Fischer 					HandleDataChange();
109595a18594SAndre Fischer 				}
109695a18594SAndre Fischer 			}
109795a18594SAndre Fischer 			break;
109895a18594SAndre Fischer 		}
109995a18594SAndre Fischer 		case PT_Rectangle:
110095a18594SAndre Fischer 		{
110195a18594SAndre Fischer 			awt::Rectangle aBox;
110295a18594SAndre Fischer 			if (rValue >>= aBox)
110395a18594SAndre Fischer 			{
110495a18594SAndre Fischer 				maRectangles[nIndex] = Rectangle(
110595a18594SAndre Fischer 					aBox.X,
110695a18594SAndre Fischer 					aBox.Y,
110795a18594SAndre Fischer 					aBox.Width,
110895a18594SAndre Fischer 					aBox.Height);
1109b9e67834SAndre Fischer 			}
1110b9e67834SAndre Fischer 			break;
1111b9e67834SAndre Fischer 		}
1112b9e67834SAndre Fischer 		case PT_Invalid:
1113b9e67834SAndre Fischer 			OSL_ASSERT(eType != PT_Invalid);
1114b9e67834SAndre Fischer 			throw RuntimeException();
1115b9e67834SAndre Fischer 	}
1116b9e67834SAndre Fischer }
1117b9e67834SAndre Fischer 
1118ff12d537SAndre Fischer } } // end of namespace sfx2::sidebar
111935c52e30Smseidel 
1120*ce6abae5Smseidel /* vim: set noet sw=4 ts=4: */
1121