xref: /aoo41x/main/sfx2/source/sidebar/Theme.cxx (revision ce6abae5)
1ff12d537SAndre Fischer /**************************************************************
24e5e52c9SMatthias Seidel  *
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
104e5e52c9SMatthias Seidel  *
11ff12d537SAndre Fischer  *   http://www.apache.org/licenses/LICENSE-2.0
124e5e52c9SMatthias Seidel  *
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.
194e5e52c9SMatthias Seidel  *
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;
37ff12d537SAndre Fischer 
38ff12d537SAndre Fischer 
39b9e67834SAndre Fischer namespace sfx2 { namespace sidebar {
40ff12d537SAndre Fischer 
41b9e67834SAndre Fischer ::rtl::Reference<Theme> Theme::mpInstance;
42ff12d537SAndre Fischer 
43ff12d537SAndre Fischer 
GetCurrentTheme(void)44b9e67834SAndre Fischer Theme& Theme::GetCurrentTheme (void)
45b9e67834SAndre Fischer {
464e5e52c9SMatthias Seidel 	if ( ! mpInstance.is())
474e5e52c9SMatthias Seidel 	{
484e5e52c9SMatthias Seidel 		mpInstance.set(new Theme());
494e5e52c9SMatthias Seidel 		mpInstance->InitializeTheme();
504e5e52c9SMatthias Seidel 	}
514e5e52c9SMatthias Seidel 	return *mpInstance;
52b9e67834SAndre Fischer }
53ff12d537SAndre Fischer 
54ff12d537SAndre Fischer 
Theme(void)55b9e67834SAndre Fischer Theme::Theme (void)
564e5e52c9SMatthias Seidel 	: ThemeInterfaceBase(m_aMutex),
574e5e52c9SMatthias Seidel 	  maImages(),
584e5e52c9SMatthias Seidel 	  maColors(),
594e5e52c9SMatthias Seidel 	  maPaints(),
604e5e52c9SMatthias Seidel 	  maIntegers(),
614e5e52c9SMatthias Seidel 	  maBooleans(),
624e5e52c9SMatthias Seidel 	  mbIsHighContrastMode(Application::GetSettings().GetStyleSettings().GetHighContrastMode()),
634e5e52c9SMatthias Seidel 	  mbIsHighContrastModeSetManually(false),
644e5e52c9SMatthias Seidel 	  maPropertyNameToIdMap(),
654e5e52c9SMatthias Seidel 	  maPropertyIdToNameMap(),
664e5e52c9SMatthias Seidel 	  maRawValues(),
674e5e52c9SMatthias Seidel 	  maChangeListeners(),
684e5e52c9SMatthias Seidel 	  maVetoableListeners()
69ff12d537SAndre Fischer 
70ff12d537SAndre Fischer {
714e5e52c9SMatthias Seidel 	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 {
824e5e52c9SMatthias Seidel 	const PropertyType eType (GetPropertyType(eItem));
834e5e52c9SMatthias Seidel 	OSL_ASSERT(eType==PT_Image);
844e5e52c9SMatthias Seidel 	const sal_Int32 nIndex (GetIndex(eItem, eType));
854e5e52c9SMatthias Seidel 	const Theme& rTheme (GetCurrentTheme());
864e5e52c9SMatthias Seidel 	return rTheme.maImages[nIndex];
87ff12d537SAndre Fischer }
88ff12d537SAndre Fischer 
89ff12d537SAndre Fischer 
GetColor(const ThemeItem eItem)90b9e67834SAndre Fischer Color Theme::GetColor (const ThemeItem eItem)
91ff12d537SAndre Fischer {
924e5e52c9SMatthias Seidel 	const PropertyType eType (GetPropertyType(eItem));
934e5e52c9SMatthias Seidel 	OSL_ASSERT(eType==PT_Color || eType==PT_Paint);
944e5e52c9SMatthias Seidel 	const sal_Int32 nIndex (GetIndex(eItem, eType));
954e5e52c9SMatthias Seidel 	const Theme& rTheme (GetCurrentTheme());
964e5e52c9SMatthias Seidel 	if (eType == PT_Color)
974e5e52c9SMatthias Seidel 		return rTheme.maColors[nIndex];
984e5e52c9SMatthias Seidel 	else if (eType == PT_Paint)
994e5e52c9SMatthias Seidel 		return rTheme.maPaints[nIndex].GetColor();
1004e5e52c9SMatthias Seidel 	else
1014e5e52c9SMatthias Seidel 		return COL_WHITE;
102ff12d537SAndre Fischer }
103ff12d537SAndre Fischer 
104ff12d537SAndre Fischer 
GetPaint(const ThemeItem eItem)105b9e67834SAndre Fischer const Paint& Theme::GetPaint (const ThemeItem eItem)
106ff12d537SAndre Fischer {
1074e5e52c9SMatthias Seidel 	const PropertyType eType (GetPropertyType(eItem));
1084e5e52c9SMatthias Seidel 	OSL_ASSERT(eType==PT_Paint);
1094e5e52c9SMatthias Seidel 	const sal_Int32 nIndex (GetIndex(eItem, eType));
1104e5e52c9SMatthias Seidel 	const Theme& rTheme (GetCurrentTheme());
1114e5e52c9SMatthias Seidel 	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 {
1174e5e52c9SMatthias Seidel 	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 {
1234e5e52c9SMatthias Seidel 	const PropertyType eType (GetPropertyType(eItem));
1244e5e52c9SMatthias Seidel 	OSL_ASSERT(eType==PT_Integer);
1254e5e52c9SMatthias Seidel 	const sal_Int32 nIndex (GetIndex(eItem, eType));
1264e5e52c9SMatthias Seidel 	const Theme& rTheme (GetCurrentTheme());
1274e5e52c9SMatthias Seidel 	return rTheme.maIntegers[nIndex];
128ff12d537SAndre Fischer }
129ff12d537SAndre Fischer 
130ff12d537SAndre Fischer 
GetBoolean(const ThemeItem eItem)131b9e67834SAndre Fischer bool Theme::GetBoolean (const ThemeItem eItem)
132ff12d537SAndre Fischer {
1334e5e52c9SMatthias Seidel 	const PropertyType eType (GetPropertyType(eItem));
1344e5e52c9SMatthias Seidel 	OSL_ASSERT(eType==PT_Boolean);
1354e5e52c9SMatthias Seidel 	const sal_Int32 nIndex (GetIndex(eItem, eType));
1364e5e52c9SMatthias Seidel 	const Theme& rTheme (GetCurrentTheme());
1374e5e52c9SMatthias Seidel 	return rTheme.maBooleans[nIndex];
138ff12d537SAndre Fischer }
139ff12d537SAndre Fischer 
140ff12d537SAndre Fischer 
GetRectangle(const ThemeItem eItem)14195a18594SAndre Fischer Rectangle Theme::GetRectangle (const ThemeItem eItem)
14295a18594SAndre Fischer {
1434e5e52c9SMatthias Seidel 	const PropertyType eType (GetPropertyType(eItem));
1444e5e52c9SMatthias Seidel 	OSL_ASSERT(eType==PT_Rectangle);
1454e5e52c9SMatthias Seidel 	const sal_Int32 nIndex (GetIndex(eItem, eType));
1464e5e52c9SMatthias Seidel 	const Theme& rTheme (GetCurrentTheme());
1474e5e52c9SMatthias Seidel 	return rTheme.maRectangles[nIndex];
14895a18594SAndre Fischer }
14995a18594SAndre Fischer 
15095a18594SAndre Fischer 
IsHighContrastMode(void)151b9e67834SAndre Fischer bool Theme::IsHighContrastMode (void)
152ff12d537SAndre Fischer {
1534e5e52c9SMatthias Seidel 	const Theme& rTheme (GetCurrentTheme());
1544e5e52c9SMatthias Seidel 	return rTheme.mbIsHighContrastMode;
155ff12d537SAndre Fischer }
156ff12d537SAndre Fischer 
157ff12d537SAndre Fischer 
HandleDataChange(void)158b9e67834SAndre Fischer void Theme::HandleDataChange (void)
159ff12d537SAndre Fischer {
1604e5e52c9SMatthias Seidel 	Theme& rTheme (GetCurrentTheme());
16195a18594SAndre Fischer 
1624e5e52c9SMatthias Seidel 	if ( ! rTheme.mbIsHighContrastModeSetManually)
1634e5e52c9SMatthias Seidel 	{
1644e5e52c9SMatthias Seidel 		// Do not modify mbIsHighContrastMode when it was manually set.
1654e5e52c9SMatthias Seidel 		GetCurrentTheme().mbIsHighContrastMode = Application::GetSettings().GetStyleSettings().GetHighContrastMode();
1664e5e52c9SMatthias Seidel 		rTheme.maRawValues[Bool_IsHighContrastModeActive] = Any(GetCurrentTheme().mbIsHighContrastMode);
1674e5e52c9SMatthias Seidel 	}
16895a18594SAndre Fischer 
1694e5e52c9SMatthias Seidel 	GetCurrentTheme().UpdateTheme();
170ff12d537SAndre Fischer }
171ff12d537SAndre Fischer 
172ff12d537SAndre Fischer 
InitializeTheme(void)173b9e67834SAndre Fischer void Theme::InitializeTheme (void)
17495a18594SAndre Fischer {
1754e5e52c9SMatthias Seidel 	setPropertyValue(
1764e5e52c9SMatthias Seidel 		maPropertyIdToNameMap[Bool_UseSymphonyIcons],
1774e5e52c9SMatthias Seidel 		Any(false));
1784e5e52c9SMatthias Seidel 	setPropertyValue(
1794e5e52c9SMatthias Seidel 		maPropertyIdToNameMap[Bool_UseSystemColors],
1804e5e52c9SMatthias Seidel 		Any(false));
18195a18594SAndre Fischer }
18295a18594SAndre Fischer 
18395a18594SAndre Fischer 
UpdateTheme(void)18495a18594SAndre Fischer void Theme::UpdateTheme (void)
185ff12d537SAndre Fischer {
1864e5e52c9SMatthias Seidel 	SidebarResource aLocalResource;
187b9e67834SAndre Fischer 
1884e5e52c9SMatthias Seidel 	try
1894e5e52c9SMatthias Seidel 	{
1904e5e52c9SMatthias Seidel 		const StyleSettings& rStyle (Application::GetSettings().GetStyleSettings());
1914e5e52c9SMatthias Seidel 		const bool bUseSystemColors (GetBoolean(Bool_UseSystemColors));
19295a18594SAndre Fischer 
19395a18594SAndre Fischer #define Alternatives(n,hc,sys) (mbIsHighContrastMode ? hc : (bUseSystemColors ? sys : n))
19495a18594SAndre Fischer 
1954e5e52c9SMatthias Seidel 		Color aBaseBackgroundColor (rStyle.GetDialogColor());
1964e5e52c9SMatthias Seidel 		// UX says this should be a little brighter, but that looks off when compared to the other windows.
1974e5e52c9SMatthias Seidel 		//aBaseBackgroundColor.IncreaseLuminance(7);
1984e5e52c9SMatthias Seidel 		Color aBorderColor (aBaseBackgroundColor);
19935c52e30Smseidel 		aBorderColor.DecreaseLuminance(80);
2004e5e52c9SMatthias Seidel 		Color aSecondColor (aBaseBackgroundColor);
20135c52e30Smseidel 		aSecondColor.DecreaseLuminance(0);
2024e5e52c9SMatthias Seidel 
2034e5e52c9SMatthias Seidel 		setPropertyValue(
2044e5e52c9SMatthias Seidel 			maPropertyIdToNameMap[Paint_DeckBackground],
2054e5e52c9SMatthias Seidel 			Any(sal_Int32(aBaseBackgroundColor.GetRGBColor())));
2064e5e52c9SMatthias Seidel 
2074e5e52c9SMatthias Seidel 		setPropertyValue(
2084e5e52c9SMatthias Seidel 			maPropertyIdToNameMap[Paint_DeckTitleBarBackground],
2094e5e52c9SMatthias Seidel 			Any(sal_Int32(aBaseBackgroundColor.GetRGBColor())));
2104e5e52c9SMatthias Seidel 		setPropertyValue(
2114e5e52c9SMatthias Seidel 			maPropertyIdToNameMap[Int_DeckLeftPadding],
2124e5e52c9SMatthias Seidel 			Any(sal_Int32(2)));
2134e5e52c9SMatthias Seidel 		setPropertyValue(
2144e5e52c9SMatthias Seidel 			maPropertyIdToNameMap[Int_DeckTopPadding],
2154e5e52c9SMatthias Seidel 			Any(sal_Int32(2)));
2164e5e52c9SMatthias Seidel 		setPropertyValue(
2174e5e52c9SMatthias Seidel 			maPropertyIdToNameMap[Int_DeckRightPadding],
2184e5e52c9SMatthias Seidel 			Any(sal_Int32(2)));
2194e5e52c9SMatthias Seidel 		setPropertyValue(
2204e5e52c9SMatthias Seidel 			maPropertyIdToNameMap[Int_DeckBottomPadding],
2214e5e52c9SMatthias Seidel 			Any(sal_Int32(2)));
2224e5e52c9SMatthias Seidel 		setPropertyValue(
2234e5e52c9SMatthias Seidel 			maPropertyIdToNameMap[Int_DeckBorderSize],
2244e5e52c9SMatthias Seidel 			Any(sal_Int32(1)));
2254e5e52c9SMatthias Seidel 		setPropertyValue(
2264e5e52c9SMatthias Seidel 			maPropertyIdToNameMap[Int_DeckSeparatorHeight],
2274e5e52c9SMatthias Seidel 			Any(sal_Int32(1)));
2284e5e52c9SMatthias Seidel 		setPropertyValue(
2294e5e52c9SMatthias Seidel 			maPropertyIdToNameMap[Int_ButtonCornerRadius],
2304e5e52c9SMatthias Seidel 			Any(sal_Int32(3)));
2314e5e52c9SMatthias Seidel 		setPropertyValue(
2324e5e52c9SMatthias Seidel 			maPropertyIdToNameMap[Color_DeckTitleFont],
233*ce6abae5Smseidel 			Any(sal_Int32(mbIsHighContrastMode ? 0xffffff : 0x262626)));
2344e5e52c9SMatthias Seidel 		setPropertyValue(
2354e5e52c9SMatthias Seidel 			maPropertyIdToNameMap[Int_DeckTitleBarHeight],
2364e5e52c9SMatthias Seidel 			Any(sal_Int32(Alternatives(
2374e5e52c9SMatthias Seidel 						26,
2384e5e52c9SMatthias Seidel 						26,
2394e5e52c9SMatthias Seidel 						rStyle.GetFloatTitleHeight()))));
2404e5e52c9SMatthias Seidel 		setPropertyValue(
2414e5e52c9SMatthias Seidel 			maPropertyIdToNameMap[Paint_PanelBackground],
2424e5e52c9SMatthias Seidel 			Any(sal_Int32(aBaseBackgroundColor.GetRGBColor())));
2434e5e52c9SMatthias Seidel 
2444e5e52c9SMatthias Seidel 		setPropertyValue(
2454e5e52c9SMatthias Seidel 			maPropertyIdToNameMap[Paint_PanelTitleBarBackground],
2464e5e52c9SMatthias Seidel 			Any(Tools::VclToAwtGradient(Gradient(
2474e5e52c9SMatthias Seidel 						GRADIENT_LINEAR,
2484e5e52c9SMatthias Seidel 						aSecondColor.GetRGBColor(),
2494e5e52c9SMatthias Seidel 						aBaseBackgroundColor.GetRGBColor()
2504e5e52c9SMatthias Seidel 						))));
2514e5e52c9SMatthias Seidel 		setPropertyValue(
2524e5e52c9SMatthias Seidel 			maPropertyIdToNameMap[Color_PanelTitleFont],
2534e5e52c9SMatthias Seidel 			Any(sal_Int32(mbIsHighContrastMode ? 0x00ff00 : 0x262626)));
2544e5e52c9SMatthias Seidel 		setPropertyValue(
2554e5e52c9SMatthias Seidel 			maPropertyIdToNameMap[Int_PanelTitleBarHeight],
2564e5e52c9SMatthias Seidel 			Any(sal_Int32(Alternatives(
2574e5e52c9SMatthias Seidel 						26,
2584e5e52c9SMatthias Seidel 						26,
2594e5e52c9SMatthias Seidel 						rStyle.GetTitleHeight()))));
2604e5e52c9SMatthias Seidel 		setPropertyValue(
2614e5e52c9SMatthias Seidel 			maPropertyIdToNameMap[Paint_TabBarBackground],
2624e5e52c9SMatthias Seidel 			Any(sal_Int32(aBaseBackgroundColor.GetRGBColor())));
2634e5e52c9SMatthias Seidel 		setPropertyValue(
2644e5e52c9SMatthias Seidel 			maPropertyIdToNameMap[Int_TabBarLeftPadding],
2654e5e52c9SMatthias Seidel 			Any(sal_Int32(2)));
2664e5e52c9SMatthias Seidel 		setPropertyValue(
2674e5e52c9SMatthias Seidel 			maPropertyIdToNameMap[Int_TabBarTopPadding],
2684e5e52c9SMatthias Seidel 			Any(sal_Int32(2)));
2694e5e52c9SMatthias Seidel 		setPropertyValue(
2704e5e52c9SMatthias Seidel 			maPropertyIdToNameMap[Int_TabBarRightPadding],
2714e5e52c9SMatthias Seidel 			Any(sal_Int32(2)));
2724e5e52c9SMatthias Seidel 		setPropertyValue(
2734e5e52c9SMatthias Seidel 			maPropertyIdToNameMap[Int_TabBarBottomPadding],
2744e5e52c9SMatthias Seidel 			Any(sal_Int32(2)));
2754e5e52c9SMatthias Seidel 
2764e5e52c9SMatthias Seidel 		setPropertyValue(
2774e5e52c9SMatthias Seidel 			maPropertyIdToNameMap[Int_TabMenuPadding],
2784e5e52c9SMatthias Seidel 			Any(sal_Int32(6)));
2794e5e52c9SMatthias Seidel 		setPropertyValue(
2804e5e52c9SMatthias Seidel 			maPropertyIdToNameMap[Color_TabMenuSeparator],
2814e5e52c9SMatthias Seidel 			Any(sal_Int32(aBorderColor.GetRGBColor())));
2824e5e52c9SMatthias Seidel 		setPropertyValue(
2834e5e52c9SMatthias Seidel 			maPropertyIdToNameMap[Int_TabMenuSeparatorPadding],
2844e5e52c9SMatthias Seidel 			Any(sal_Int32(7)));
2854e5e52c9SMatthias Seidel 
2864e5e52c9SMatthias Seidel 		setPropertyValue(
2874e5e52c9SMatthias Seidel 			maPropertyIdToNameMap[Int_TabItemWidth],
2884e5e52c9SMatthias Seidel 			Any(sal_Int32(32)));
2894e5e52c9SMatthias Seidel 		setPropertyValue(
2904e5e52c9SMatthias Seidel 			maPropertyIdToNameMap[Int_TabItemHeight],
2914e5e52c9SMatthias Seidel 			Any(sal_Int32(32)));
2924e5e52c9SMatthias Seidel 		setPropertyValue(
2934e5e52c9SMatthias Seidel 			maPropertyIdToNameMap[Color_TabItemBorder],
2944e5e52c9SMatthias Seidel 			Any(sal_Int32(rStyle.GetActiveBorderColor().GetRGBColor())));
2954e5e52c9SMatthias Seidel 		//					mbIsHighContrastMode ? 0x00ff00 : 0xbfbfbf)));
2964e5e52c9SMatthias Seidel 
2974e5e52c9SMatthias Seidel 		setPropertyValue(
2984e5e52c9SMatthias Seidel 			maPropertyIdToNameMap[Paint_DropDownBackground],
2994e5e52c9SMatthias Seidel 			Any(sal_Int32(aBaseBackgroundColor.GetRGBColor())));
3004e5e52c9SMatthias Seidel 		setPropertyValue(
3014e5e52c9SMatthias Seidel 			maPropertyIdToNameMap[Color_DropDownBorder],
3024e5e52c9SMatthias Seidel 			Any(sal_Int32(rStyle.GetActiveBorderColor().GetRGBColor())));
3034e5e52c9SMatthias Seidel 
3044e5e52c9SMatthias Seidel 		setPropertyValue(
3054e5e52c9SMatthias Seidel 			maPropertyIdToNameMap[Color_Highlight],
3064e5e52c9SMatthias Seidel 			Any(sal_Int32(rStyle.GetHighlightColor().GetRGBColor())));
3074e5e52c9SMatthias Seidel 		setPropertyValue(
3084e5e52c9SMatthias Seidel 			maPropertyIdToNameMap[Color_HighlightText],
3094e5e52c9SMatthias Seidel 			Any(sal_Int32(rStyle.GetHighlightTextColor().GetRGBColor())));
3104e5e52c9SMatthias Seidel 
3114e5e52c9SMatthias Seidel 		setPropertyValue(
3124e5e52c9SMatthias Seidel 			maPropertyIdToNameMap[Paint_TabItemBackgroundNormal],
3134e5e52c9SMatthias Seidel 			Any());
3144e5e52c9SMatthias Seidel 		setPropertyValue(
3154e5e52c9SMatthias Seidel 			maPropertyIdToNameMap[Paint_TabItemBackgroundHighlight],
3164e5e52c9SMatthias Seidel 			Any(sal_Int32(rStyle.GetActiveTabColor().GetRGBColor())));
3174e5e52c9SMatthias Seidel 		//					mbIsHighContrastMode ? 0x000000 : 0x00ffffff)));
3184e5e52c9SMatthias Seidel 
3194e5e52c9SMatthias Seidel 		setPropertyValue(
3204e5e52c9SMatthias Seidel 			maPropertyIdToNameMap[Paint_HorizontalBorder],
3214e5e52c9SMatthias Seidel 			Any(sal_Int32(aBorderColor.GetRGBColor())));
3224e5e52c9SMatthias Seidel 		//					mbIsHighContrastMode ? 0x00ff00 : 0xe4e4e4)));
3234e5e52c9SMatthias Seidel 		setPropertyValue(
3244e5e52c9SMatthias Seidel 			maPropertyIdToNameMap[Paint_VerticalBorder],
3254e5e52c9SMatthias Seidel 			Any(sal_Int32(aBorderColor.GetRGBColor())));
3264e5e52c9SMatthias Seidel 		//					mbIsHighContrastMode ? 0x00ff00 : 0xe4e4e4)));
3274e5e52c9SMatthias Seidel 
3284e5e52c9SMatthias Seidel 		setPropertyValue(
3294e5e52c9SMatthias Seidel 			maPropertyIdToNameMap[Image_Grip],
3304e5e52c9SMatthias Seidel 			Any(
3314e5e52c9SMatthias Seidel 				mbIsHighContrastMode
3324e5e52c9SMatthias Seidel 					? A2S("private:graphicrepository/sfx2/res/grip_hc.png")
3334e5e52c9SMatthias Seidel 					: A2S("private:graphicrepository/sfx2/res/grip.png")));
3344e5e52c9SMatthias Seidel 		setPropertyValue(
3354e5e52c9SMatthias Seidel 			maPropertyIdToNameMap[Image_Expand],
3364e5e52c9SMatthias Seidel 			Any(
3374e5e52c9SMatthias Seidel 				mbIsHighContrastMode
3384e5e52c9SMatthias Seidel 					? A2S("private:graphicrepository/res/plus_sch.png")
3394e5e52c9SMatthias Seidel 					: A2S("private:graphicrepository/res/plus.png")));
3404e5e52c9SMatthias Seidel 		setPropertyValue(
3414e5e52c9SMatthias Seidel 			maPropertyIdToNameMap[Image_Collapse],
3424e5e52c9SMatthias Seidel 			Any(
3434e5e52c9SMatthias Seidel 				mbIsHighContrastMode
3444e5e52c9SMatthias Seidel 					? A2S("private:graphicrepository/res/minus_sch.png")
3454e5e52c9SMatthias Seidel 					: A2S("private:graphicrepository/res/minus.png")));
3464e5e52c9SMatthias Seidel 		setPropertyValue(
3474e5e52c9SMatthias Seidel 			maPropertyIdToNameMap[Image_TabBarMenu],
3484e5e52c9SMatthias Seidel 			Any(
3494e5e52c9SMatthias Seidel 				mbIsHighContrastMode
3504e5e52c9SMatthias Seidel 					? A2S("private:graphicrepository/sfx2/res/symphony/open_more_hc.png")
3514e5e52c9SMatthias Seidel 					: A2S("private:graphicrepository/sfx2/res/symphony/open_more.png")));
3524e5e52c9SMatthias Seidel 		setPropertyValue(
3534e5e52c9SMatthias Seidel 			maPropertyIdToNameMap[Image_PanelMenu],
3544e5e52c9SMatthias Seidel 			Any(
3554e5e52c9SMatthias Seidel 				mbIsHighContrastMode
3564e5e52c9SMatthias Seidel 					? A2S("private:graphicrepository/sfx2/res/symphony/morebutton_h.png")
3574e5e52c9SMatthias Seidel 					: A2S("private:graphicrepository/sfx2/res/symphony/morebutton.png")));
3584e5e52c9SMatthias Seidel 		setPropertyValue(
3594e5e52c9SMatthias Seidel 			maPropertyIdToNameMap[Image_Closer],
36035c52e30Smseidel 			Any(
36135c52e30Smseidel 				mbIsHighContrastMode
36235c52e30Smseidel 					? A2S("private:graphicrepository/sfx2/res/closedochc.png")
36335c52e30Smseidel 					: A2S("private:graphicrepository/sfx2/res/closedoc.png")));
3644e5e52c9SMatthias Seidel 		setPropertyValue(
3654e5e52c9SMatthias Seidel 			maPropertyIdToNameMap[Image_CloseIndicator],
3664e5e52c9SMatthias Seidel 			Any(
3674e5e52c9SMatthias Seidel 				mbIsHighContrastMode
3684e5e52c9SMatthias Seidel 					? A2S("private:graphicrepository/res/commandimagelist/lch_decrementlevel.png")
3694e5e52c9SMatthias Seidel 					: A2S("private:graphicrepository/res/commandimagelist/lc_decrementlevel.png")));
3704e5e52c9SMatthias Seidel 		setPropertyValue(
3714e5e52c9SMatthias Seidel 			maPropertyIdToNameMap[Image_ToolBoxItemSeparator],
3724e5e52c9SMatthias Seidel 			Any(
3734e5e52c9SMatthias Seidel 				A2S("private:graphicrepository/sfx2/res/separator.png")));
3744e5e52c9SMatthias Seidel 
3754e5e52c9SMatthias Seidel 		// ToolBox
3764e5e52c9SMatthias Seidel 
3774e5e52c9SMatthias Seidel 		/*
3784e5e52c9SMatthias Seidel 		// Separator style
3794e5e52c9SMatthias Seidel 		setPropertyValue(
3804e5e52c9SMatthias Seidel 			maPropertyIdToNameMap[Paint_ToolBoxBackground],
3814e5e52c9SMatthias Seidel 			Any(sal_Int32(rStyle.GetMenuColor().GetRGBColor())));
3824e5e52c9SMatthias Seidel 		setPropertyValue(
3834e5e52c9SMatthias Seidel 			maPropertyIdToNameMap[Paint_ToolBoxBorderTopLeft],
3844e5e52c9SMatthias Seidel 			Any());
3854e5e52c9SMatthias Seidel 		setPropertyValue(
3864e5e52c9SMatthias Seidel 			maPropertyIdToNameMap[Paint_ToolBoxBorderCenterCorners],
3874e5e52c9SMatthias Seidel 			Any());
3884e5e52c9SMatthias Seidel 		setPropertyValue(
3894e5e52c9SMatthias Seidel 			maPropertyIdToNameMap[Paint_ToolBoxBorderBottomRight],
3904e5e52c9SMatthias Seidel 			Any());
3914e5e52c9SMatthias Seidel 		setPropertyValue(
3924e5e52c9SMatthias Seidel 			maPropertyIdToNameMap[Rect_ToolBoxPadding],
3934e5e52c9SMatthias Seidel 			Any(awt::Rectangle(2,2,2,2)));
3944e5e52c9SMatthias Seidel 		setPropertyValue(
3954e5e52c9SMatthias Seidel 			maPropertyIdToNameMap[Rect_ToolBoxBorder],
3964e5e52c9SMatthias Seidel 			Any(awt::Rectangle(0,0,0,0)));
3974e5e52c9SMatthias Seidel 		setPropertyValue(
3984e5e52c9SMatthias Seidel 			maPropertyIdToNameMap[Bool_UseToolBoxItemSeparator],
3994e5e52c9SMatthias Seidel 			Any(true));
4004e5e52c9SMatthias Seidel 
4014e5e52c9SMatthias Seidel 		*/
4024e5e52c9SMatthias Seidel 
4034e5e52c9SMatthias Seidel 		// Gradient style
4044e5e52c9SMatthias Seidel 		Color aGradientStop2 (aBaseBackgroundColor);
40535c52e30Smseidel 		aGradientStop2.IncreaseLuminance(0);
4064e5e52c9SMatthias Seidel 		Color aToolBoxBorderColor (aBaseBackgroundColor);
40735c52e30Smseidel 		aToolBoxBorderColor.DecreaseLuminance(40);
4084e5e52c9SMatthias Seidel 		setPropertyValue(
4094e5e52c9SMatthias Seidel 			maPropertyIdToNameMap[Paint_ToolBoxBackground],
4104e5e52c9SMatthias Seidel 			Any(Tools::VclToAwtGradient(Gradient(
4114e5e52c9SMatthias Seidel 						GRADIENT_LINEAR,
4124e5e52c9SMatthias Seidel 						aBaseBackgroundColor.GetRGBColor(),
4134e5e52c9SMatthias Seidel 						aGradientStop2.GetRGBColor()
4144e5e52c9SMatthias Seidel 						))));
4154e5e52c9SMatthias Seidel 		setPropertyValue(
4164e5e52c9SMatthias Seidel 			maPropertyIdToNameMap[Paint_ToolBoxBorderTopLeft],
4174e5e52c9SMatthias Seidel 			mbIsHighContrastMode
4184e5e52c9SMatthias Seidel 				? Any(util::Color(sal_uInt32(0x00ff00)))
4194e5e52c9SMatthias Seidel 				: Any(util::Color(aToolBoxBorderColor.GetRGBColor())));
4204e5e52c9SMatthias Seidel 		setPropertyValue(
4214e5e52c9SMatthias Seidel 			maPropertyIdToNameMap[Paint_ToolBoxBorderCenterCorners],
4224e5e52c9SMatthias Seidel 			mbIsHighContrastMode
4234e5e52c9SMatthias Seidel 				? Any(util::Color(sal_uInt32(0x00ff00)))
4244e5e52c9SMatthias Seidel 				: Any(util::Color(aToolBoxBorderColor.GetRGBColor())));
4254e5e52c9SMatthias Seidel 		setPropertyValue(
4264e5e52c9SMatthias Seidel 			maPropertyIdToNameMap[Paint_ToolBoxBorderBottomRight],
4274e5e52c9SMatthias Seidel 			mbIsHighContrastMode
4284e5e52c9SMatthias Seidel 				? Any(util::Color(sal_uInt32(0x00ff00)))
4294e5e52c9SMatthias Seidel 				: Any(util::Color(aToolBoxBorderColor.GetRGBColor())));
4304e5e52c9SMatthias Seidel 		setPropertyValue(
4314e5e52c9SMatthias Seidel 			maPropertyIdToNameMap[Rect_ToolBoxPadding],
4324e5e52c9SMatthias Seidel 			Any(awt::Rectangle(2,2,2,2)));
4334e5e52c9SMatthias Seidel 		setPropertyValue(
4344e5e52c9SMatthias Seidel 			maPropertyIdToNameMap[Rect_ToolBoxBorder],
4354e5e52c9SMatthias Seidel 			Any(awt::Rectangle(1,1,1,1)));
4364e5e52c9SMatthias Seidel 		setPropertyValue(
4374e5e52c9SMatthias Seidel 			maPropertyIdToNameMap[Bool_UseToolBoxItemSeparator],
4384e5e52c9SMatthias Seidel 			Any(false));
4394e5e52c9SMatthias Seidel 	}
4404e5e52c9SMatthias Seidel 	catch(beans::UnknownPropertyException& rException)
4414e5e52c9SMatthias Seidel 	{
4424e5e52c9SMatthias Seidel 		OSL_TRACE("unknown property: %s",
4434e5e52c9SMatthias Seidel 			OUStringToOString(
4444e5e52c9SMatthias Seidel 				rException.Message,
4454e5e52c9SMatthias Seidel 				RTL_TEXTENCODING_ASCII_US).getStr());
4464e5e52c9SMatthias Seidel 		OSL_ASSERT(false);
4474e5e52c9SMatthias Seidel 	}
448ff12d537SAndre Fischer }
449ff12d537SAndre Fischer 
450ff12d537SAndre Fischer 
disposing(void)451b9e67834SAndre Fischer void SAL_CALL Theme::disposing (void)
452ff12d537SAndre Fischer {
4534e5e52c9SMatthias Seidel 	ChangeListeners aListeners;
4544e5e52c9SMatthias Seidel 	maChangeListeners.swap(aListeners);
4554e5e52c9SMatthias Seidel 
4564e5e52c9SMatthias Seidel 	const lang::EventObject aEvent (static_cast<XWeak*>(this));
4574e5e52c9SMatthias Seidel 
4584e5e52c9SMatthias Seidel 	for (ChangeListeners::const_iterator
4594e5e52c9SMatthias Seidel 			 iContainer(maChangeListeners.begin()),
4604e5e52c9SMatthias Seidel 			 iContainerEnd(maChangeListeners.end());
4614e5e52c9SMatthias Seidel 		 iContainerEnd!=iContainerEnd;
4624e5e52c9SMatthias Seidel 		 ++iContainerEnd)
4634e5e52c9SMatthias Seidel 	{
4644e5e52c9SMatthias Seidel 		for (ChangeListenerContainer::const_iterator
4654e5e52c9SMatthias Seidel 				 iListener(iContainer->second.begin()),
4664e5e52c9SMatthias Seidel 				 iEnd(iContainer->second.end());
4674e5e52c9SMatthias Seidel 			 iListener!=iEnd;
4684e5e52c9SMatthias Seidel 			 ++iListener)
4694e5e52c9SMatthias Seidel 		{
4704e5e52c9SMatthias Seidel 			try
4714e5e52c9SMatthias Seidel 			{
4724e5e52c9SMatthias Seidel 				(*iListener)->disposing(aEvent);
4734e5e52c9SMatthias Seidel 			}
4744e5e52c9SMatthias Seidel 			catch(const Exception&)
4754e5e52c9SMatthias Seidel 			{
4764e5e52c9SMatthias Seidel 			}
4774e5e52c9SMatthias Seidel 		}
4784e5e52c9SMatthias Seidel 	}
479ff12d537SAndre Fischer }
480ff12d537SAndre Fischer 
481ff12d537SAndre Fischer 
GetPropertySet(void)482b9e67834SAndre Fischer Reference<beans::XPropertySet> Theme::GetPropertySet (void)
483ff12d537SAndre Fischer {
4844e5e52c9SMatthias Seidel 	return Reference<beans::XPropertySet>(static_cast<XWeak*>(&GetCurrentTheme()), UNO_QUERY);
485ff12d537SAndre Fischer }
486ff12d537SAndre Fischer 
487ff12d537SAndre Fischer 
getPropertySetInfo(void)488b9e67834SAndre Fischer Reference<beans::XPropertySetInfo> SAL_CALL Theme::getPropertySetInfo (void)
4894e5e52c9SMatthias Seidel 	throw(cssu::RuntimeException)
490ff12d537SAndre Fischer {
4914e5e52c9SMatthias Seidel 	return Reference<beans::XPropertySetInfo>(this);
492ff12d537SAndre Fischer }
493ff12d537SAndre Fischer 
494ff12d537SAndre Fischer 
setPropertyValue(const::rtl::OUString & rsPropertyName,const cssu::Any & rValue)495b9e67834SAndre Fischer void SAL_CALL Theme::setPropertyValue (
4964e5e52c9SMatthias Seidel 	const ::rtl::OUString& rsPropertyName,
4974e5e52c9SMatthias Seidel 	const cssu::Any& rValue)
4984e5e52c9SMatthias Seidel 	throw(cssu::RuntimeException)
499ff12d537SAndre Fischer {
5004e5e52c9SMatthias Seidel 	PropertyNameToIdMap::const_iterator iId (maPropertyNameToIdMap.find(rsPropertyName));
5014e5e52c9SMatthias Seidel 	if (iId == maPropertyNameToIdMap.end())
5024e5e52c9SMatthias Seidel 		throw beans::UnknownPropertyException(rsPropertyName, NULL);
5034e5e52c9SMatthias Seidel 
5044e5e52c9SMatthias Seidel 	const PropertyType eType (GetPropertyType(iId->second));
5054e5e52c9SMatthias Seidel 	if (eType == PT_Invalid)
5064e5e52c9SMatthias Seidel 		throw beans::UnknownPropertyException(rsPropertyName, NULL);
5074e5e52c9SMatthias Seidel 
5084e5e52c9SMatthias Seidel 	const ThemeItem eItem (iId->second);
5094e5e52c9SMatthias Seidel 
5104e5e52c9SMatthias Seidel 	if (rValue == maRawValues[eItem])
5114e5e52c9SMatthias Seidel 	{
5124e5e52c9SMatthias Seidel 		// Value is not different from the one in the property
5134e5e52c9SMatthias Seidel 		// set => nothing to do.
5144e5e52c9SMatthias Seidel 		return;
5154e5e52c9SMatthias Seidel 	}
5164e5e52c9SMatthias Seidel 
5174e5e52c9SMatthias Seidel 	const Any aOldValue (maRawValues[eItem]);
5184e5e52c9SMatthias Seidel 
5194e5e52c9SMatthias Seidel 	const beans::PropertyChangeEvent aEvent(
5204e5e52c9SMatthias Seidel 		static_cast<XWeak*>(this),
5214e5e52c9SMatthias Seidel 		rsPropertyName,
5224e5e52c9SMatthias Seidel 		sal_False,
5234e5e52c9SMatthias Seidel 		eItem,
5244e5e52c9SMatthias Seidel 		aOldValue,
5254e5e52c9SMatthias Seidel 		rValue);
5264e5e52c9SMatthias Seidel 
5274e5e52c9SMatthias Seidel 	if (DoVetoableListenersVeto(GetVetoableListeners(__AnyItem, false), aEvent))
5284e5e52c9SMatthias Seidel 		return;
5294e5e52c9SMatthias Seidel 	if (DoVetoableListenersVeto(GetVetoableListeners(eItem, false), aEvent))
5304e5e52c9SMatthias Seidel 		return;
5314e5e52c9SMatthias Seidel 
5324e5e52c9SMatthias Seidel 	maRawValues[eItem] = rValue;
5334e5e52c9SMatthias Seidel 	ProcessNewValue(rValue, eItem, eType);
5344e5e52c9SMatthias Seidel 
5354e5e52c9SMatthias Seidel 	BroadcastPropertyChange(GetChangeListeners(__AnyItem, false), aEvent);
5364e5e52c9SMatthias Seidel 	BroadcastPropertyChange(GetChangeListeners(eItem, false), aEvent);
537ff12d537SAndre Fischer }
538ff12d537SAndre Fischer 
539ff12d537SAndre Fischer 
getPropertyValue(const::rtl::OUString & rsPropertyName)540b9e67834SAndre Fischer Any SAL_CALL Theme::getPropertyValue (
5414e5e52c9SMatthias Seidel 	const ::rtl::OUString& rsPropertyName)
5424e5e52c9SMatthias Seidel 	throw(css::beans::UnknownPropertyException,
5434e5e52c9SMatthias Seidel 		css::lang::WrappedTargetException,
5444e5e52c9SMatthias Seidel 		cssu::RuntimeException)
545ff12d537SAndre Fischer {
5464e5e52c9SMatthias Seidel 	PropertyNameToIdMap::const_iterator iId (maPropertyNameToIdMap.find(rsPropertyName));
5474e5e52c9SMatthias Seidel 	if (iId == maPropertyNameToIdMap.end())
5484e5e52c9SMatthias Seidel 		throw beans::UnknownPropertyException();
549b9e67834SAndre Fischer 
5504e5e52c9SMatthias Seidel 	const PropertyType eType (GetPropertyType(iId->second));
5514e5e52c9SMatthias Seidel 	if (eType == PT_Invalid)
5524e5e52c9SMatthias Seidel 		throw beans::UnknownPropertyException();
553b9e67834SAndre Fischer 
5544e5e52c9SMatthias Seidel 	const ThemeItem eItem (iId->second);
555b9e67834SAndre Fischer 
5564e5e52c9SMatthias Seidel 	return maRawValues[eItem];
557ff12d537SAndre Fischer }
558ff12d537SAndre Fischer 
559ff12d537SAndre Fischer 
addPropertyChangeListener(const::rtl::OUString & rsPropertyName,const cssu::Reference<css::beans::XPropertyChangeListener> & rxListener)560b9e67834SAndre Fischer void SAL_CALL Theme::addPropertyChangeListener(
5614e5e52c9SMatthias Seidel 	const ::rtl::OUString& rsPropertyName,
5624e5e52c9SMatthias Seidel 	const cssu::Reference<css::beans::XPropertyChangeListener>& rxListener)
5634e5e52c9SMatthias Seidel 	throw(css::beans::UnknownPropertyException,
5644e5e52c9SMatthias Seidel 		css::lang::WrappedTargetException,
5654e5e52c9SMatthias Seidel 		cssu::RuntimeException)
566ff12d537SAndre Fischer {
5674e5e52c9SMatthias Seidel 	ThemeItem eItem (__AnyItem);
5684e5e52c9SMatthias Seidel 	if (rsPropertyName.getLength() > 0)
5694e5e52c9SMatthias Seidel 	{
5704e5e52c9SMatthias Seidel 		PropertyNameToIdMap::const_iterator iId (maPropertyNameToIdMap.find(rsPropertyName));
5714e5e52c9SMatthias Seidel 		if (iId == maPropertyNameToIdMap.end())
5724e5e52c9SMatthias Seidel 			throw beans::UnknownPropertyException();
5734e5e52c9SMatthias Seidel 
5744e5e52c9SMatthias Seidel 		const PropertyType eType (GetPropertyType(iId->second));
5754e5e52c9SMatthias Seidel 		if (eType == PT_Invalid)
5764e5e52c9SMatthias Seidel 			throw beans::UnknownPropertyException();
5774e5e52c9SMatthias Seidel 
5784e5e52c9SMatthias Seidel 		eItem = iId->second;
5794e5e52c9SMatthias Seidel 	}
5804e5e52c9SMatthias Seidel 	ChangeListenerContainer* pListeners = GetChangeListeners(eItem, true);
5814e5e52c9SMatthias Seidel 	if (pListeners != NULL)
5824e5e52c9SMatthias Seidel 		pListeners->push_back(rxListener);
583ff12d537SAndre Fischer }
584ff12d537SAndre Fischer 
585ff12d537SAndre Fischer 
removePropertyChangeListener(const::rtl::OUString & rsPropertyName,const cssu::Reference<css::beans::XPropertyChangeListener> & rxListener)586b9e67834SAndre Fischer void SAL_CALL Theme::removePropertyChangeListener(
5874e5e52c9SMatthias Seidel 	const ::rtl::OUString& rsPropertyName,
5884e5e52c9SMatthias Seidel 	const cssu::Reference<css::beans::XPropertyChangeListener>& rxListener)
5894e5e52c9SMatthias Seidel 	throw(css::beans::UnknownPropertyException,
5904e5e52c9SMatthias Seidel 		css::lang::WrappedTargetException,
5914e5e52c9SMatthias Seidel 		cssu::RuntimeException)
592ff12d537SAndre Fischer {
5934e5e52c9SMatthias Seidel 	ThemeItem eItem (__AnyItem);
5944e5e52c9SMatthias Seidel 	if (rsPropertyName.getLength() > 0)
5954e5e52c9SMatthias Seidel 	{
5964e5e52c9SMatthias Seidel 		PropertyNameToIdMap::const_iterator iId (maPropertyNameToIdMap.find(rsPropertyName));
5974e5e52c9SMatthias Seidel 		if (iId == maPropertyNameToIdMap.end())
5984e5e52c9SMatthias Seidel 			throw beans::UnknownPropertyException();
5994e5e52c9SMatthias Seidel 
6004e5e52c9SMatthias Seidel 		const PropertyType eType (GetPropertyType(iId->second));
6014e5e52c9SMatthias Seidel 		if (eType == PT_Invalid)
6024e5e52c9SMatthias Seidel 			throw beans::UnknownPropertyException();
6034e5e52c9SMatthias Seidel 
6044e5e52c9SMatthias Seidel 		eItem = iId->second;
6054e5e52c9SMatthias Seidel 	}
6064e5e52c9SMatthias Seidel 	ChangeListenerContainer* pContainer = GetChangeListeners(eItem, false);
6074e5e52c9SMatthias Seidel 	if (pContainer != NULL)
6084e5e52c9SMatthias Seidel 	{
6094e5e52c9SMatthias Seidel 		ChangeListenerContainer::iterator iListener (::std::find(pContainer->begin(), pContainer->end(), rxListener));
6104e5e52c9SMatthias Seidel 		if (iListener != pContainer->end())
6114e5e52c9SMatthias Seidel 		{
6124e5e52c9SMatthias Seidel 			pContainer->erase(iListener);
6134e5e52c9SMatthias Seidel 
6144e5e52c9SMatthias Seidel 			// Remove the listener container when empty.
6154e5e52c9SMatthias Seidel 			if (pContainer->empty())
6164e5e52c9SMatthias Seidel 				maChangeListeners.erase(eItem);
6174e5e52c9SMatthias Seidel 		}
6184e5e52c9SMatthias Seidel 	}
619ff12d537SAndre Fischer }
620ff12d537SAndre Fischer 
621ff12d537SAndre Fischer 
addVetoableChangeListener(const::rtl::OUString & rsPropertyName,const cssu::Reference<css::beans::XVetoableChangeListener> & rxListener)622b9e67834SAndre Fischer void SAL_CALL Theme::addVetoableChangeListener(
6234e5e52c9SMatthias Seidel 	const ::rtl::OUString& rsPropertyName,
6244e5e52c9SMatthias Seidel 	const cssu::Reference<css::beans::XVetoableChangeListener>& rxListener)
6254e5e52c9SMatthias Seidel 	throw(css::beans::UnknownPropertyException,
6264e5e52c9SMatthias Seidel 		css::lang::WrappedTargetException,
6274e5e52c9SMatthias Seidel 		cssu::RuntimeException)
628ff12d537SAndre Fischer {
6294e5e52c9SMatthias Seidel 	ThemeItem eItem (__AnyItem);
6304e5e52c9SMatthias Seidel 	if (rsPropertyName.getLength() > 0)
6314e5e52c9SMatthias Seidel 	{
6324e5e52c9SMatthias Seidel 		PropertyNameToIdMap::const_iterator iId (maPropertyNameToIdMap.find(rsPropertyName));
6334e5e52c9SMatthias Seidel 		if (iId == maPropertyNameToIdMap.end())
6344e5e52c9SMatthias Seidel 			throw beans::UnknownPropertyException();
6354e5e52c9SMatthias Seidel 
6364e5e52c9SMatthias Seidel 		const PropertyType eType (GetPropertyType(iId->second));
6374e5e52c9SMatthias Seidel 		if (eType == PT_Invalid)
6384e5e52c9SMatthias Seidel 			throw beans::UnknownPropertyException();
6394e5e52c9SMatthias Seidel 
6404e5e52c9SMatthias Seidel 		eItem = iId->second;
6414e5e52c9SMatthias Seidel 	}
6424e5e52c9SMatthias Seidel 	VetoableListenerContainer* pListeners = GetVetoableListeners(eItem, true);
6434e5e52c9SMatthias Seidel 	if (pListeners != NULL)
6444e5e52c9SMatthias Seidel 		pListeners->push_back(rxListener);
645ff12d537SAndre Fischer }
646ff12d537SAndre Fischer 
647ff12d537SAndre Fischer 
removeVetoableChangeListener(const::rtl::OUString & rsPropertyName,const cssu::Reference<css::beans::XVetoableChangeListener> & rxListener)648b9e67834SAndre Fischer void SAL_CALL Theme::removeVetoableChangeListener(
6494e5e52c9SMatthias Seidel 	const ::rtl::OUString& rsPropertyName,
6504e5e52c9SMatthias Seidel 	const cssu::Reference<css::beans::XVetoableChangeListener>& rxListener)
6514e5e52c9SMatthias Seidel 	throw(css::beans::UnknownPropertyException,
6524e5e52c9SMatthias Seidel 		css::lang::WrappedTargetException,
6534e5e52c9SMatthias Seidel 		cssu::RuntimeException)
654ff12d537SAndre Fischer {
6554e5e52c9SMatthias Seidel 	ThemeItem eItem (__AnyItem);
6564e5e52c9SMatthias Seidel 	if (rsPropertyName.getLength() > 0)
6574e5e52c9SMatthias Seidel 	{
6584e5e52c9SMatthias Seidel 		PropertyNameToIdMap::const_iterator iId (maPropertyNameToIdMap.find(rsPropertyName));
6594e5e52c9SMatthias Seidel 		if (iId == maPropertyNameToIdMap.end())
6604e5e52c9SMatthias Seidel 			throw beans::UnknownPropertyException();
6614e5e52c9SMatthias Seidel 
6624e5e52c9SMatthias Seidel 		const PropertyType eType (GetPropertyType(iId->second));
6634e5e52c9SMatthias Seidel 		if (eType == PT_Invalid)
6644e5e52c9SMatthias Seidel 			throw beans::UnknownPropertyException();
6654e5e52c9SMatthias Seidel 
6664e5e52c9SMatthias Seidel 		eItem = iId->second;
6674e5e52c9SMatthias Seidel 	}
6684e5e52c9SMatthias Seidel 	VetoableListenerContainer* pContainer = GetVetoableListeners(eItem, false);
6694e5e52c9SMatthias Seidel 	if (pContainer != NULL)
6704e5e52c9SMatthias Seidel 	{
6714e5e52c9SMatthias Seidel 		VetoableListenerContainer::iterator iListener (::std::find(pContainer->begin(), pContainer->end(), rxListener));
6724e5e52c9SMatthias Seidel 		if (iListener != pContainer->end())
6734e5e52c9SMatthias Seidel 		{
6744e5e52c9SMatthias Seidel 			pContainer->erase(iListener);
6754e5e52c9SMatthias Seidel 			// Remove container when empty.
6764e5e52c9SMatthias Seidel 			if (pContainer->empty())
6774e5e52c9SMatthias Seidel 				maVetoableListeners.erase(eItem);
6784e5e52c9SMatthias Seidel 		}
6794e5e52c9SMatthias Seidel 	}
680ff12d537SAndre Fischer }
681ff12d537SAndre Fischer 
682ff12d537SAndre Fischer 
getProperties(void)68395a18594SAndre Fischer cssu::Sequence<css::beans::Property> SAL_CALL Theme::getProperties (void)
6844e5e52c9SMatthias Seidel 	throw(cssu::RuntimeException)
68595a18594SAndre Fischer {
6864e5e52c9SMatthias Seidel 	::std::vector<beans::Property> aProperties;
6874e5e52c9SMatthias Seidel 
6884e5e52c9SMatthias Seidel 	for (sal_Int32 nItem(__Begin),nEnd(__End); nItem!=nEnd; ++nItem)
6894e5e52c9SMatthias Seidel 	{
6904e5e52c9SMatthias Seidel 		const ThemeItem eItem (static_cast<ThemeItem>(nItem));
6914e5e52c9SMatthias Seidel 		const PropertyType eType (GetPropertyType(eItem));
6924e5e52c9SMatthias Seidel 		if (eType == PT_Invalid)
6934e5e52c9SMatthias Seidel 			continue;
6944e5e52c9SMatthias Seidel 
6954e5e52c9SMatthias Seidel 		const beans::Property aProperty(
6964e5e52c9SMatthias Seidel 			maPropertyIdToNameMap[eItem],
6974e5e52c9SMatthias Seidel 			eItem,
6984e5e52c9SMatthias Seidel 			GetCppuType(eType),
6994e5e52c9SMatthias Seidel 			0);
7004e5e52c9SMatthias Seidel 		aProperties.push_back(aProperty);
7014e5e52c9SMatthias Seidel 	}
7024e5e52c9SMatthias Seidel 
7034e5e52c9SMatthias Seidel 	return cssu::Sequence<css::beans::Property>(
7044e5e52c9SMatthias Seidel 		&aProperties.front(),
7054e5e52c9SMatthias Seidel 		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)
7104e5e52c9SMatthias Seidel 	throw(css::beans::UnknownPropertyException,
7114e5e52c9SMatthias Seidel 		cssu::RuntimeException)
71295a18594SAndre Fischer {
7134e5e52c9SMatthias Seidel 	PropertyNameToIdMap::const_iterator iId (maPropertyNameToIdMap.find(rsPropertyName));
7144e5e52c9SMatthias Seidel 	if (iId == maPropertyNameToIdMap.end())
7154e5e52c9SMatthias Seidel 		throw beans::UnknownPropertyException();
71695a18594SAndre Fischer 
7174e5e52c9SMatthias Seidel 	const PropertyType eType (GetPropertyType(iId->second));
7184e5e52c9SMatthias Seidel 	if (eType == PT_Invalid)
7194e5e52c9SMatthias Seidel 		throw beans::UnknownPropertyException();
72095a18594SAndre Fischer 
7214e5e52c9SMatthias Seidel 	const ThemeItem eItem (iId->second);
72295a18594SAndre Fischer 
7234e5e52c9SMatthias Seidel 	return beans::Property(
7244e5e52c9SMatthias Seidel 		rsPropertyName,
7254e5e52c9SMatthias Seidel 		eItem,
7264e5e52c9SMatthias Seidel 		GetCppuType(eType),
7274e5e52c9SMatthias Seidel 		0);
72895a18594SAndre Fischer }
72995a18594SAndre Fischer 
73095a18594SAndre Fischer 
hasPropertyByName(const::rtl::OUString & rsPropertyName)73195a18594SAndre Fischer sal_Bool SAL_CALL Theme::hasPropertyByName (const ::rtl::OUString& rsPropertyName)
7324e5e52c9SMatthias Seidel 	throw(cssu::RuntimeException)
73395a18594SAndre Fischer {
7344e5e52c9SMatthias Seidel 	PropertyNameToIdMap::const_iterator iId (maPropertyNameToIdMap.find(rsPropertyName));
7354e5e52c9SMatthias Seidel 	if (iId == maPropertyNameToIdMap.end())
7364e5e52c9SMatthias Seidel 		return sal_False;
73795a18594SAndre Fischer 
7384e5e52c9SMatthias Seidel 	const PropertyType eType (GetPropertyType(iId->second));
7394e5e52c9SMatthias Seidel 	if (eType == PT_Invalid)
7404e5e52c9SMatthias Seidel 		return sal_False;
74195a18594SAndre Fischer 
7424e5e52c9SMatthias Seidel 	return sal_True;
74395a18594SAndre Fischer }
74495a18594SAndre Fischer 
74595a18594SAndre Fischer 
SetupPropertyMaps(void)746b9e67834SAndre Fischer void Theme::SetupPropertyMaps (void)
747ff12d537SAndre Fischer {
7484e5e52c9SMatthias Seidel 	maPropertyIdToNameMap.resize(__Post_Rect);
7494e5e52c9SMatthias Seidel 	maImages.resize(__Image_Color - __Pre_Image - 1);
7504e5e52c9SMatthias Seidel 	maColors.resize(__Color_Paint - __Image_Color - 1);
7514e5e52c9SMatthias Seidel 	maPaints.resize(__Paint_Int - __Color_Paint - 1);
7524e5e52c9SMatthias Seidel 	maIntegers.resize(__Int_Bool - __Paint_Int - 1);
7534e5e52c9SMatthias Seidel 	maBooleans.resize(__Bool_Rect - __Int_Bool - 1);
7544e5e52c9SMatthias Seidel 	maRectangles.resize(__Post_Rect - __Bool_Rect - 1);
7554e5e52c9SMatthias Seidel 
7564e5e52c9SMatthias Seidel 	#define AddEntry(e) maPropertyNameToIdMap[A2S(#e)]=e; maPropertyIdToNameMap[e]=A2S(#e)
7574e5e52c9SMatthias Seidel 
7584e5e52c9SMatthias Seidel 	AddEntry(Image_Grip);
7594e5e52c9SMatthias Seidel 	AddEntry(Image_Expand);
7604e5e52c9SMatthias Seidel 	AddEntry(Image_Collapse);
7614e5e52c9SMatthias Seidel 	AddEntry(Image_TabBarMenu);
7624e5e52c9SMatthias Seidel 	AddEntry(Image_PanelMenu);
7634e5e52c9SMatthias Seidel 	AddEntry(Image_ToolBoxItemSeparator);
7644e5e52c9SMatthias Seidel 	AddEntry(Image_Closer);
7654e5e52c9SMatthias Seidel 	AddEntry(Image_CloseIndicator);
7664e5e52c9SMatthias Seidel 
7674e5e52c9SMatthias Seidel 	AddEntry(Color_DeckTitleFont);
7684e5e52c9SMatthias Seidel 	AddEntry(Color_PanelTitleFont);
7694e5e52c9SMatthias Seidel 	AddEntry(Color_TabMenuSeparator);
7704e5e52c9SMatthias Seidel 	AddEntry(Color_TabItemBorder);
7714e5e52c9SMatthias Seidel 	AddEntry(Color_DropDownBorder);
7724e5e52c9SMatthias Seidel 	AddEntry(Color_Highlight);
7734e5e52c9SMatthias Seidel 	AddEntry(Color_HighlightText);
7744e5e52c9SMatthias Seidel 
7754e5e52c9SMatthias Seidel 	AddEntry(Paint_DeckBackground);
7764e5e52c9SMatthias Seidel 	AddEntry(Paint_DeckTitleBarBackground);
7774e5e52c9SMatthias Seidel 	AddEntry(Paint_PanelBackground);
7784e5e52c9SMatthias Seidel 	AddEntry(Paint_PanelTitleBarBackground);
7794e5e52c9SMatthias Seidel 	AddEntry(Paint_TabBarBackground);
7804e5e52c9SMatthias Seidel 	AddEntry(Paint_TabItemBackgroundNormal);
7814e5e52c9SMatthias Seidel 	AddEntry(Paint_TabItemBackgroundHighlight);
7824e5e52c9SMatthias Seidel 	AddEntry(Paint_HorizontalBorder);
7834e5e52c9SMatthias Seidel 	AddEntry(Paint_VerticalBorder);
7844e5e52c9SMatthias Seidel 	AddEntry(Paint_ToolBoxBackground);
7854e5e52c9SMatthias Seidel 	AddEntry(Paint_ToolBoxBorderTopLeft);
7864e5e52c9SMatthias Seidel 	AddEntry(Paint_ToolBoxBorderCenterCorners);
7874e5e52c9SMatthias Seidel 	AddEntry(Paint_ToolBoxBorderBottomRight);
7884e5e52c9SMatthias Seidel 	AddEntry(Paint_DropDownBackground);
7894e5e52c9SMatthias Seidel 
7904e5e52c9SMatthias Seidel 	AddEntry(Int_DeckTitleBarHeight);
7914e5e52c9SMatthias Seidel 	AddEntry(Int_DeckBorderSize);
7924e5e52c9SMatthias Seidel 	AddEntry(Int_DeckSeparatorHeight);
7934e5e52c9SMatthias Seidel 	AddEntry(Int_PanelTitleBarHeight);
7944e5e52c9SMatthias Seidel 	AddEntry(Int_TabMenuPadding);
7954e5e52c9SMatthias Seidel 	AddEntry(Int_TabMenuSeparatorPadding);
7964e5e52c9SMatthias Seidel 	AddEntry(Int_TabItemWidth);
7974e5e52c9SMatthias Seidel 	AddEntry(Int_TabItemHeight);
7984e5e52c9SMatthias Seidel 	AddEntry(Int_DeckLeftPadding);
7994e5e52c9SMatthias Seidel 	AddEntry(Int_DeckTopPadding);
8004e5e52c9SMatthias Seidel 	AddEntry(Int_DeckRightPadding);
8014e5e52c9SMatthias Seidel 	AddEntry(Int_DeckBottomPadding);
8024e5e52c9SMatthias Seidel 	AddEntry(Int_TabBarLeftPadding);
8034e5e52c9SMatthias Seidel 	AddEntry(Int_TabBarTopPadding);
8044e5e52c9SMatthias Seidel 	AddEntry(Int_TabBarRightPadding);
8054e5e52c9SMatthias Seidel 	AddEntry(Int_TabBarBottomPadding);
8064e5e52c9SMatthias Seidel 	AddEntry(Int_ButtonCornerRadius);
8074e5e52c9SMatthias Seidel 
8084e5e52c9SMatthias Seidel 	AddEntry(Bool_UseSymphonyIcons);
8094e5e52c9SMatthias Seidel 	AddEntry(Bool_UseSystemColors);
8104e5e52c9SMatthias Seidel 	AddEntry(Bool_UseToolBoxItemSeparator);
8114e5e52c9SMatthias Seidel 	AddEntry(Bool_IsHighContrastModeActive);
8124e5e52c9SMatthias Seidel 
8134e5e52c9SMatthias Seidel 	AddEntry(Rect_ToolBoxPadding);
8144e5e52c9SMatthias Seidel 	AddEntry(Rect_ToolBoxBorder);
8154e5e52c9SMatthias Seidel 
8164e5e52c9SMatthias Seidel 	#undef AddEntry
8174e5e52c9SMatthias Seidel 
8184e5e52c9SMatthias Seidel 	maRawValues.resize(maPropertyIdToNameMap.size());
819ff12d537SAndre Fischer }
820ff12d537SAndre Fischer 
821ff12d537SAndre Fischer 
GetPropertyType(const ThemeItem eItem)822b9e67834SAndre Fischer Theme::PropertyType Theme::GetPropertyType (const ThemeItem eItem)
823ff12d537SAndre Fischer {
8244e5e52c9SMatthias Seidel 	switch(eItem)
8254e5e52c9SMatthias Seidel 	{
8264e5e52c9SMatthias Seidel 		case Image_Grip:
8274e5e52c9SMatthias Seidel 		case Image_Expand:
8284e5e52c9SMatthias Seidel 		case Image_Collapse:
8294e5e52c9SMatthias Seidel 		case Image_TabBarMenu:
8304e5e52c9SMatthias Seidel 		case Image_PanelMenu:
8314e5e52c9SMatthias Seidel 		case Image_ToolBoxItemSeparator:
8324e5e52c9SMatthias Seidel 		case Image_Closer:
8334e5e52c9SMatthias Seidel 		case Image_CloseIndicator:
8344e5e52c9SMatthias Seidel 			return PT_Image;
8354e5e52c9SMatthias Seidel 
8364e5e52c9SMatthias Seidel 		case Color_DeckTitleFont:
8374e5e52c9SMatthias Seidel 		case Color_PanelTitleFont:
8384e5e52c9SMatthias Seidel 		case Color_TabMenuSeparator:
8394e5e52c9SMatthias Seidel 		case Color_TabItemBorder:
8404e5e52c9SMatthias Seidel 		case Color_DropDownBorder:
8414e5e52c9SMatthias Seidel 		case Color_Highlight:
8424e5e52c9SMatthias Seidel 		case Color_HighlightText:
8434e5e52c9SMatthias Seidel 			return PT_Color;
8444e5e52c9SMatthias Seidel 
8454e5e52c9SMatthias Seidel 		case Paint_DeckBackground:
8464e5e52c9SMatthias Seidel 		case Paint_DeckTitleBarBackground:
8474e5e52c9SMatthias Seidel 		case Paint_PanelBackground:
8484e5e52c9SMatthias Seidel 		case Paint_PanelTitleBarBackground:
8494e5e52c9SMatthias Seidel 		case Paint_TabBarBackground:
8504e5e52c9SMatthias Seidel 		case Paint_TabItemBackgroundNormal:
8514e5e52c9SMatthias Seidel 		case Paint_TabItemBackgroundHighlight:
8524e5e52c9SMatthias Seidel 		case Paint_HorizontalBorder:
8534e5e52c9SMatthias Seidel 		case Paint_VerticalBorder:
8544e5e52c9SMatthias Seidel 		case Paint_ToolBoxBackground:
8554e5e52c9SMatthias Seidel 		case Paint_ToolBoxBorderTopLeft:
8564e5e52c9SMatthias Seidel 		case Paint_ToolBoxBorderCenterCorners:
8574e5e52c9SMatthias Seidel 		case Paint_ToolBoxBorderBottomRight:
8584e5e52c9SMatthias Seidel 		case Paint_DropDownBackground:
8594e5e52c9SMatthias Seidel 			return PT_Paint;
8604e5e52c9SMatthias Seidel 
8614e5e52c9SMatthias Seidel 		case Int_DeckTitleBarHeight:
8624e5e52c9SMatthias Seidel 		case Int_DeckBorderSize:
8634e5e52c9SMatthias Seidel 		case Int_DeckSeparatorHeight:
8644e5e52c9SMatthias Seidel 		case Int_PanelTitleBarHeight:
8654e5e52c9SMatthias Seidel 		case Int_TabMenuPadding:
8664e5e52c9SMatthias Seidel 		case Int_TabMenuSeparatorPadding:
8674e5e52c9SMatthias Seidel 		case Int_TabItemWidth:
8684e5e52c9SMatthias Seidel 		case Int_TabItemHeight:
8694e5e52c9SMatthias Seidel 		case Int_DeckLeftPadding:
8704e5e52c9SMatthias Seidel 		case Int_DeckTopPadding:
8714e5e52c9SMatthias Seidel 		case Int_DeckRightPadding:
8724e5e52c9SMatthias Seidel 		case Int_DeckBottomPadding:
8734e5e52c9SMatthias Seidel 		case Int_TabBarLeftPadding:
8744e5e52c9SMatthias Seidel 		case Int_TabBarTopPadding:
8754e5e52c9SMatthias Seidel 		case Int_TabBarRightPadding:
8764e5e52c9SMatthias Seidel 		case Int_TabBarBottomPadding:
8774e5e52c9SMatthias Seidel 		case Int_ButtonCornerRadius:
8784e5e52c9SMatthias Seidel 			return PT_Integer;
8794e5e52c9SMatthias Seidel 
8804e5e52c9SMatthias Seidel 		case Bool_UseSymphonyIcons:
8814e5e52c9SMatthias Seidel 		case Bool_UseSystemColors:
8824e5e52c9SMatthias Seidel 		case Bool_UseToolBoxItemSeparator:
8834e5e52c9SMatthias Seidel 		case Bool_IsHighContrastModeActive:
8844e5e52c9SMatthias Seidel 			return PT_Boolean;
8854e5e52c9SMatthias Seidel 
8864e5e52c9SMatthias Seidel 		case Rect_ToolBoxBorder:
8874e5e52c9SMatthias Seidel 		case Rect_ToolBoxPadding:
8884e5e52c9SMatthias Seidel 			return PT_Rectangle;
8894e5e52c9SMatthias Seidel 
8904e5e52c9SMatthias Seidel 		default:
8914e5e52c9SMatthias Seidel 			return PT_Invalid;
8924e5e52c9SMatthias Seidel 	}
893ff12d537SAndre Fischer }
894ff12d537SAndre Fischer 
895ff12d537SAndre Fischer 
GetCppuType(const PropertyType eType)89695a18594SAndre Fischer cssu::Type Theme::GetCppuType (const PropertyType eType)
89795a18594SAndre Fischer {
8984e5e52c9SMatthias Seidel 	switch(eType)
8994e5e52c9SMatthias Seidel 	{
9004e5e52c9SMatthias Seidel 		case PT_Image:
9014e5e52c9SMatthias Seidel 			return getCppuType((rtl::OUString*)NULL);
90295a18594SAndre Fischer 
9034e5e52c9SMatthias Seidel 		case PT_Color:
9044e5e52c9SMatthias Seidel 			return getCppuType((sal_uInt32*)NULL);
90595a18594SAndre Fischer 
9064e5e52c9SMatthias Seidel 		case PT_Paint:
9074e5e52c9SMatthias Seidel 			return getCppuVoidType();
90895a18594SAndre Fischer 
9094e5e52c9SMatthias Seidel 		case PT_Integer:
9104e5e52c9SMatthias Seidel 			return getCppuType((sal_Int32*)NULL);
91195a18594SAndre Fischer 
9124e5e52c9SMatthias Seidel 		case PT_Boolean:
9134e5e52c9SMatthias Seidel 			return getCppuType((sal_Bool*)NULL);
91495a18594SAndre Fischer 
9154e5e52c9SMatthias Seidel 		case PT_Rectangle:
9164e5e52c9SMatthias Seidel 			return getCppuType((awt::Rectangle*)NULL);
91795a18594SAndre Fischer 
9184e5e52c9SMatthias Seidel 		case PT_Invalid:
9194e5e52c9SMatthias Seidel 		default:
9204e5e52c9SMatthias Seidel 			return getCppuVoidType();
9214e5e52c9SMatthias Seidel 	}
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)
926ff12d537SAndre Fischer {
9274e5e52c9SMatthias Seidel 	switch(eType)
9284e5e52c9SMatthias Seidel 	{
9294e5e52c9SMatthias Seidel 		case PT_Image:
9304e5e52c9SMatthias Seidel 			return eItem - __Pre_Image-1;
9314e5e52c9SMatthias Seidel 		case PT_Color:
9324e5e52c9SMatthias Seidel 			return eItem - __Image_Color-1;
9334e5e52c9SMatthias Seidel 		case PT_Paint:
9344e5e52c9SMatthias Seidel 			return eItem - __Color_Paint-1;
9354e5e52c9SMatthias Seidel 		case PT_Integer:
9364e5e52c9SMatthias Seidel 			return eItem - __Paint_Int-1;
9374e5e52c9SMatthias Seidel 		case PT_Boolean:
9384e5e52c9SMatthias Seidel 			return eItem - __Int_Bool-1;
9394e5e52c9SMatthias Seidel 		case PT_Rectangle:
9404e5e52c9SMatthias Seidel 			return eItem - __Bool_Rect-1;
9414e5e52c9SMatthias Seidel 
9424e5e52c9SMatthias Seidel 		default:
9434e5e52c9SMatthias Seidel 			OSL_ASSERT(false);
9444e5e52c9SMatthias Seidel 			return 0;
9454e5e52c9SMatthias Seidel 	}
946ff12d537SAndre Fischer }
947ff12d537SAndre Fischer 
948ff12d537SAndre Fischer 
GetVetoableListeners(const ThemeItem eItem,const bool bCreate)949b9e67834SAndre Fischer Theme::VetoableListenerContainer* Theme::GetVetoableListeners (
9504e5e52c9SMatthias Seidel 	const ThemeItem eItem,
9514e5e52c9SMatthias Seidel 	const bool bCreate)
952ff12d537SAndre Fischer {
9534e5e52c9SMatthias Seidel 	VetoableListeners::iterator iContainer (maVetoableListeners.find(eItem));
9544e5e52c9SMatthias Seidel 	if (iContainer != maVetoableListeners.end())
9554e5e52c9SMatthias Seidel 		return &iContainer->second;
9564e5e52c9SMatthias Seidel 	else if (bCreate)
9574e5e52c9SMatthias Seidel 	{
9584e5e52c9SMatthias Seidel 		maVetoableListeners[eItem] = VetoableListenerContainer();
9594e5e52c9SMatthias Seidel 		return &maVetoableListeners[eItem];
9604e5e52c9SMatthias Seidel 	}
9614e5e52c9SMatthias Seidel 	else
9624e5e52c9SMatthias Seidel 		return NULL;
963ff12d537SAndre Fischer }
964ff12d537SAndre Fischer 
965ff12d537SAndre Fischer 
GetChangeListeners(const ThemeItem eItem,const bool bCreate)966b9e67834SAndre Fischer Theme::ChangeListenerContainer* Theme::GetChangeListeners (
9674e5e52c9SMatthias Seidel 	const ThemeItem eItem,
9684e5e52c9SMatthias Seidel 	const bool bCreate)
969ff12d537SAndre Fischer {
9704e5e52c9SMatthias Seidel 	ChangeListeners::iterator iContainer (maChangeListeners.find(eItem));
9714e5e52c9SMatthias Seidel 	if (iContainer != maChangeListeners.end())
9724e5e52c9SMatthias Seidel 		return &iContainer->second;
9734e5e52c9SMatthias Seidel 	else if (bCreate)
9744e5e52c9SMatthias Seidel 	{
9754e5e52c9SMatthias Seidel 		maChangeListeners[eItem] = ChangeListenerContainer();
9764e5e52c9SMatthias Seidel 		return &maChangeListeners[eItem];
9774e5e52c9SMatthias Seidel 	}
9784e5e52c9SMatthias Seidel 	else
9794e5e52c9SMatthias Seidel 		return NULL;
980ff12d537SAndre Fischer }
981ff12d537SAndre Fischer 
982ff12d537SAndre Fischer 
DoVetoableListenersVeto(const VetoableListenerContainer * pListeners,const beans::PropertyChangeEvent & rEvent) const983b9e67834SAndre Fischer bool Theme::DoVetoableListenersVeto (
9844e5e52c9SMatthias Seidel 	const VetoableListenerContainer* pListeners,
9854e5e52c9SMatthias Seidel 	const beans::PropertyChangeEvent& rEvent) const
986ff12d537SAndre Fischer {
9874e5e52c9SMatthias Seidel 	if (pListeners == NULL)
9884e5e52c9SMatthias Seidel 		return false;
9894e5e52c9SMatthias Seidel 
9904e5e52c9SMatthias Seidel 	VetoableListenerContainer aListeners (*pListeners);
9914e5e52c9SMatthias Seidel 	try
9924e5e52c9SMatthias Seidel 	{
9934e5e52c9SMatthias Seidel 		for (VetoableListenerContainer::const_iterator
9944e5e52c9SMatthias Seidel 				 iListener(aListeners.begin()),
9954e5e52c9SMatthias Seidel 				 iEnd(aListeners.end());
9964e5e52c9SMatthias Seidel 			 iListener!=iEnd;
9974e5e52c9SMatthias Seidel 			 ++iListener)
9984e5e52c9SMatthias Seidel 		{
9994e5e52c9SMatthias Seidel 			(*iListener)->vetoableChange(rEvent);
10004e5e52c9SMatthias Seidel 		}
10014e5e52c9SMatthias Seidel 	}
10024e5e52c9SMatthias Seidel 	catch(const beans::PropertyVetoException&)
10034e5e52c9SMatthias Seidel 	{
10044e5e52c9SMatthias Seidel 		return true;
10054e5e52c9SMatthias Seidel 	}
10064e5e52c9SMatthias Seidel 	catch(const Exception&)
10074e5e52c9SMatthias Seidel 	{
10084e5e52c9SMatthias Seidel 		// Ignore any other errors (such as disposed listeners).
10094e5e52c9SMatthias Seidel 	}
10104e5e52c9SMatthias Seidel 	return false;
1011ff12d537SAndre Fischer }
1012ff12d537SAndre Fischer 
1013ff12d537SAndre Fischer 
BroadcastPropertyChange(const ChangeListenerContainer * pListeners,const beans::PropertyChangeEvent & rEvent) const1014b9e67834SAndre Fischer void Theme::BroadcastPropertyChange (
10154e5e52c9SMatthias Seidel 	const ChangeListenerContainer* pListeners,
10164e5e52c9SMatthias Seidel 	const beans::PropertyChangeEvent& rEvent) const
1017ff12d537SAndre Fischer {
10184e5e52c9SMatthias Seidel 	if (pListeners == NULL)
10194e5e52c9SMatthias Seidel 		return;
10204e5e52c9SMatthias Seidel 
10214e5e52c9SMatthias Seidel 	const ChangeListenerContainer aListeners (*pListeners);
10224e5e52c9SMatthias Seidel 	try
10234e5e52c9SMatthias Seidel 	{
10244e5e52c9SMatthias Seidel 		for (ChangeListenerContainer::const_iterator
10254e5e52c9SMatthias Seidel 				 iListener(aListeners.begin()),
10264e5e52c9SMatthias Seidel 				 iEnd(aListeners.end());
10274e5e52c9SMatthias Seidel 			 iListener!=iEnd;
10284e5e52c9SMatthias Seidel 			 ++iListener)
10294e5e52c9SMatthias Seidel 		{
10304e5e52c9SMatthias Seidel 			(*iListener)->propertyChange(rEvent);
10314e5e52c9SMatthias Seidel 		}
10324e5e52c9SMatthias Seidel 	}
10334e5e52c9SMatthias Seidel 	catch(const Exception&)
10344e5e52c9SMatthias Seidel 	{
10354e5e52c9SMatthias Seidel 		// Ignore any errors (such as disposed listeners).
10364e5e52c9SMatthias Seidel 	}
1037ff12d537SAndre Fischer }
1038ff12d537SAndre Fischer 
1039ff12d537SAndre Fischer 
ProcessNewValue(const Any & rValue,const ThemeItem eItem,const PropertyType eType)1040b9e67834SAndre Fischer void Theme::ProcessNewValue (
10414e5e52c9SMatthias Seidel 	const Any& rValue,
10424e5e52c9SMatthias Seidel 	const ThemeItem eItem,
10434e5e52c9SMatthias Seidel 	const PropertyType eType)
1044ff12d537SAndre Fischer {
10454e5e52c9SMatthias Seidel 	const sal_Int32 nIndex (GetIndex (eItem, eType));
10464e5e52c9SMatthias Seidel 	switch (eType)
10474e5e52c9SMatthias Seidel 	{
10484e5e52c9SMatthias Seidel 		case PT_Image:
10494e5e52c9SMatthias Seidel 		{
10504e5e52c9SMatthias Seidel 			::rtl::OUString sURL;
10514e5e52c9SMatthias Seidel 			if (rValue >>= sURL)
10524e5e52c9SMatthias Seidel 			{
10534e5e52c9SMatthias Seidel 				maImages[nIndex] = Tools::GetImage(sURL, NULL);
10544e5e52c9SMatthias Seidel 			}
10554e5e52c9SMatthias Seidel 			break;
10564e5e52c9SMatthias Seidel 		}
10574e5e52c9SMatthias Seidel 		case PT_Color:
10584e5e52c9SMatthias Seidel 		{
10594e5e52c9SMatthias Seidel 			sal_Int32 nColorValue (0);
10604e5e52c9SMatthias Seidel 			if (rValue >>= nColorValue)
10614e5e52c9SMatthias Seidel 			{
10624e5e52c9SMatthias Seidel 				maColors[nIndex] = Color(nColorValue);
10634e5e52c9SMatthias Seidel 			}
10644e5e52c9SMatthias Seidel 			break;
10654e5e52c9SMatthias Seidel 		}
10664e5e52c9SMatthias Seidel 		case PT_Paint:
10674e5e52c9SMatthias Seidel 		{
10684e5e52c9SMatthias Seidel 			maPaints[nIndex] = Paint::Create(rValue);
10694e5e52c9SMatthias Seidel 			break;
10704e5e52c9SMatthias Seidel 		}
10714e5e52c9SMatthias Seidel 		case PT_Integer:
10724e5e52c9SMatthias Seidel 		{
10734e5e52c9SMatthias Seidel 			sal_Int32 nValue (0);
10744e5e52c9SMatthias Seidel 			if (rValue >>= nValue)
10754e5e52c9SMatthias Seidel 			{
10764e5e52c9SMatthias Seidel 				maIntegers[nIndex] = nValue;
10774e5e52c9SMatthias Seidel 			}
10784e5e52c9SMatthias Seidel 			break;
10794e5e52c9SMatthias Seidel 		}
10804e5e52c9SMatthias Seidel 		case PT_Boolean:
10814e5e52c9SMatthias Seidel 		{
10824e5e52c9SMatthias Seidel 			sal_Bool nValue (0);
10834e5e52c9SMatthias Seidel 			if (rValue >>= nValue)
10844e5e52c9SMatthias Seidel 			{
10854e5e52c9SMatthias Seidel 				maBooleans[nIndex] = (nValue==sal_True);
10864e5e52c9SMatthias Seidel 				if (eItem == Bool_IsHighContrastModeActive)
10874e5e52c9SMatthias Seidel 				{
10884e5e52c9SMatthias Seidel 					mbIsHighContrastModeSetManually = true;
10894e5e52c9SMatthias Seidel 					mbIsHighContrastMode = maBooleans[nIndex];
10904e5e52c9SMatthias Seidel 					HandleDataChange();
10914e5e52c9SMatthias Seidel 				}
10924e5e52c9SMatthias Seidel 				else if (eItem == Bool_UseSystemColors)
10934e5e52c9SMatthias Seidel 				{
10944e5e52c9SMatthias Seidel 					HandleDataChange();
10954e5e52c9SMatthias Seidel 				}
10964e5e52c9SMatthias Seidel 			}
10974e5e52c9SMatthias Seidel 			break;
10984e5e52c9SMatthias Seidel 		}
10994e5e52c9SMatthias Seidel 		case PT_Rectangle:
11004e5e52c9SMatthias Seidel 		{
11014e5e52c9SMatthias Seidel 			awt::Rectangle aBox;
11024e5e52c9SMatthias Seidel 			if (rValue >>= aBox)
11034e5e52c9SMatthias Seidel 			{
11044e5e52c9SMatthias Seidel 				maRectangles[nIndex] = Rectangle(
11054e5e52c9SMatthias Seidel 					aBox.X,
11064e5e52c9SMatthias Seidel 					aBox.Y,
11074e5e52c9SMatthias Seidel 					aBox.Width,
11084e5e52c9SMatthias Seidel 					aBox.Height);
11094e5e52c9SMatthias Seidel 			}
11104e5e52c9SMatthias Seidel 			break;
11114e5e52c9SMatthias Seidel 		}
11124e5e52c9SMatthias Seidel 		case PT_Invalid:
11134e5e52c9SMatthias Seidel 			OSL_ASSERT(eType != PT_Invalid);
11144e5e52c9SMatthias Seidel 			throw RuntimeException();
11154e5e52c9SMatthias Seidel 	}
1116ff12d537SAndre Fischer }
1117ff12d537SAndre Fischer 
1118ff12d537SAndre Fischer } } // end of namespace sfx2::sidebar
111935c52e30Smseidel 
1120*ce6abae5Smseidel /* vim: set noet sw=4 ts=4: */
1121