xref: /aoo42x/main/sfx2/source/sidebar/Theme.cxx (revision 33f5cc50)
1ff12d537SAndre Fischer /**************************************************************
29f759e1cSMatthias 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
109f759e1cSMatthias Seidel  *
11ff12d537SAndre Fischer  *   http://www.apache.org/licenses/LICENSE-2.0
129f759e1cSMatthias 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.
199f759e1cSMatthias Seidel  *
20ff12d537SAndre Fischer  *************************************************************/
21ff12d537SAndre Fischer 
229f759e1cSMatthias Seidel 
239f759e1cSMatthias 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 {
469f759e1cSMatthias Seidel 	if ( ! mpInstance.is())
479f759e1cSMatthias Seidel 	{
489f759e1cSMatthias Seidel 		mpInstance.set(new Theme());
499f759e1cSMatthias Seidel 		mpInstance->InitializeTheme();
509f759e1cSMatthias Seidel 	}
519f759e1cSMatthias Seidel 	return *mpInstance;
52b9e67834SAndre Fischer }
53ff12d537SAndre Fischer 
54ff12d537SAndre Fischer 
Theme(void)55b9e67834SAndre Fischer Theme::Theme (void)
569f759e1cSMatthias Seidel 	: ThemeInterfaceBase(m_aMutex),
579f759e1cSMatthias Seidel 	  maImages(),
589f759e1cSMatthias Seidel 	  maColors(),
599f759e1cSMatthias Seidel 	  maPaints(),
609f759e1cSMatthias Seidel 	  maIntegers(),
619f759e1cSMatthias Seidel 	  maBooleans(),
629f759e1cSMatthias Seidel 	  mbIsHighContrastMode(Application::GetSettings().GetStyleSettings().GetHighContrastMode()),
639f759e1cSMatthias Seidel 	  mbIsHighContrastModeSetManually(false),
649f759e1cSMatthias Seidel 	  maPropertyNameToIdMap(),
659f759e1cSMatthias Seidel 	  maPropertyIdToNameMap(),
669f759e1cSMatthias Seidel 	  maRawValues(),
679f759e1cSMatthias Seidel 	  maChangeListeners(),
689f759e1cSMatthias Seidel 	  maVetoableListeners()
69ff12d537SAndre Fischer 
70ff12d537SAndre Fischer {
719f759e1cSMatthias 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 {
829f759e1cSMatthias Seidel 	const PropertyType eType (GetPropertyType(eItem));
839f759e1cSMatthias Seidel 	OSL_ASSERT(eType==PT_Image);
849f759e1cSMatthias Seidel 	const sal_Int32 nIndex (GetIndex(eItem, eType));
859f759e1cSMatthias Seidel 	const Theme& rTheme (GetCurrentTheme());
869f759e1cSMatthias 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 {
929f759e1cSMatthias Seidel 	const PropertyType eType (GetPropertyType(eItem));
939f759e1cSMatthias Seidel 	OSL_ASSERT(eType==PT_Color || eType==PT_Paint);
949f759e1cSMatthias Seidel 	const sal_Int32 nIndex (GetIndex(eItem, eType));
959f759e1cSMatthias Seidel 	const Theme& rTheme (GetCurrentTheme());
969f759e1cSMatthias Seidel 	if (eType == PT_Color)
979f759e1cSMatthias Seidel 		return rTheme.maColors[nIndex];
989f759e1cSMatthias Seidel 	else if (eType == PT_Paint)
999f759e1cSMatthias Seidel 		return rTheme.maPaints[nIndex].GetColor();
1009f759e1cSMatthias Seidel 	else
1019f759e1cSMatthias 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 {
1079f759e1cSMatthias Seidel 	const PropertyType eType (GetPropertyType(eItem));
1089f759e1cSMatthias Seidel 	OSL_ASSERT(eType==PT_Paint);
1099f759e1cSMatthias Seidel 	const sal_Int32 nIndex (GetIndex(eItem, eType));
1109f759e1cSMatthias Seidel 	const Theme& rTheme (GetCurrentTheme());
1119f759e1cSMatthias 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 {
1179f759e1cSMatthias 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 {
1239f759e1cSMatthias Seidel 	const PropertyType eType (GetPropertyType(eItem));
1249f759e1cSMatthias Seidel 	OSL_ASSERT(eType==PT_Integer);
1259f759e1cSMatthias Seidel 	const sal_Int32 nIndex (GetIndex(eItem, eType));
1269f759e1cSMatthias Seidel 	const Theme& rTheme (GetCurrentTheme());
1279f759e1cSMatthias 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 {
1339f759e1cSMatthias Seidel 	const PropertyType eType (GetPropertyType(eItem));
1349f759e1cSMatthias Seidel 	OSL_ASSERT(eType==PT_Boolean);
1359f759e1cSMatthias Seidel 	const sal_Int32 nIndex (GetIndex(eItem, eType));
1369f759e1cSMatthias Seidel 	const Theme& rTheme (GetCurrentTheme());
1379f759e1cSMatthias 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 {
1439f759e1cSMatthias Seidel 	const PropertyType eType (GetPropertyType(eItem));
1449f759e1cSMatthias Seidel 	OSL_ASSERT(eType==PT_Rectangle);
1459f759e1cSMatthias Seidel 	const sal_Int32 nIndex (GetIndex(eItem, eType));
1469f759e1cSMatthias Seidel 	const Theme& rTheme (GetCurrentTheme());
1479f759e1cSMatthias Seidel 	return rTheme.maRectangles[nIndex];
14895a18594SAndre Fischer }
14995a18594SAndre Fischer 
15095a18594SAndre Fischer 
IsHighContrastMode(void)151b9e67834SAndre Fischer bool Theme::IsHighContrastMode (void)
152ff12d537SAndre Fischer {
1539f759e1cSMatthias Seidel 	const Theme& rTheme (GetCurrentTheme());
1549f759e1cSMatthias Seidel 	return rTheme.mbIsHighContrastMode;
155ff12d537SAndre Fischer }
156ff12d537SAndre Fischer 
157ff12d537SAndre Fischer 
HandleDataChange(void)158b9e67834SAndre Fischer void Theme::HandleDataChange (void)
159ff12d537SAndre Fischer {
1609f759e1cSMatthias Seidel 	Theme& rTheme (GetCurrentTheme());
16195a18594SAndre Fischer 
1629f759e1cSMatthias Seidel 	if ( ! rTheme.mbIsHighContrastModeSetManually)
1639f759e1cSMatthias Seidel 	{
1649f759e1cSMatthias Seidel 		// Do not modify mbIsHighContrastMode when it was manually set.
1659f759e1cSMatthias Seidel 		GetCurrentTheme().mbIsHighContrastMode = Application::GetSettings().GetStyleSettings().GetHighContrastMode();
1669f759e1cSMatthias Seidel 		rTheme.maRawValues[Bool_IsHighContrastModeActive] = Any(GetCurrentTheme().mbIsHighContrastMode);
1679f759e1cSMatthias Seidel 	}
16895a18594SAndre Fischer 
1699f759e1cSMatthias Seidel 	GetCurrentTheme().UpdateTheme();
170ff12d537SAndre Fischer }
171ff12d537SAndre Fischer 
172ff12d537SAndre Fischer 
InitializeTheme(void)173b9e67834SAndre Fischer void Theme::InitializeTheme (void)
17495a18594SAndre Fischer {
1759f759e1cSMatthias Seidel 	setPropertyValue(
1769f759e1cSMatthias Seidel 		maPropertyIdToNameMap[Bool_UseSymphonyIcons],
1779f759e1cSMatthias Seidel 		Any(false));
1789f759e1cSMatthias Seidel 	setPropertyValue(
1799f759e1cSMatthias Seidel 		maPropertyIdToNameMap[Bool_UseSystemColors],
1809f759e1cSMatthias Seidel 		Any(false));
18195a18594SAndre Fischer }
18295a18594SAndre Fischer 
18395a18594SAndre Fischer 
UpdateTheme(void)18495a18594SAndre Fischer void Theme::UpdateTheme (void)
185ff12d537SAndre Fischer {
1869f759e1cSMatthias Seidel 	SidebarResource aLocalResource;
187b9e67834SAndre Fischer 
1889f759e1cSMatthias Seidel 	try
1899f759e1cSMatthias Seidel 	{
1909f759e1cSMatthias Seidel 		const StyleSettings& rStyle (Application::GetSettings().GetStyleSettings());
1919f759e1cSMatthias Seidel 		const bool bUseSystemColors (GetBoolean(Bool_UseSystemColors));
19295a18594SAndre Fischer 
19395a18594SAndre Fischer #define Alternatives(n,hc,sys) (mbIsHighContrastMode ? hc : (bUseSystemColors ? sys : n))
19495a18594SAndre Fischer 
1959f759e1cSMatthias Seidel 		Color aBaseBackgroundColor (rStyle.GetDialogColor());
1969f759e1cSMatthias Seidel 		// UX says this should be a little brighter, but that looks off when compared to the other windows.
1979f759e1cSMatthias Seidel 		//aBaseBackgroundColor.IncreaseLuminance(7);
1989f759e1cSMatthias Seidel 		Color aBorderColor (aBaseBackgroundColor);
199629b561bSmseidel 		aBorderColor.DecreaseLuminance(80);
2009f759e1cSMatthias Seidel 		Color aSecondColor (aBaseBackgroundColor);
201629b561bSmseidel 		aSecondColor.DecreaseLuminance(0);
2029f759e1cSMatthias Seidel 
2039f759e1cSMatthias Seidel 		setPropertyValue(
2049f759e1cSMatthias Seidel 			maPropertyIdToNameMap[Paint_DeckBackground],
2059f759e1cSMatthias Seidel 			Any(sal_Int32(aBaseBackgroundColor.GetRGBColor())));
2069f759e1cSMatthias Seidel 
2079f759e1cSMatthias Seidel 		setPropertyValue(
2089f759e1cSMatthias Seidel 			maPropertyIdToNameMap[Paint_DeckTitleBarBackground],
2099f759e1cSMatthias Seidel 			Any(sal_Int32(aBaseBackgroundColor.GetRGBColor())));
2109f759e1cSMatthias Seidel 		setPropertyValue(
2119f759e1cSMatthias Seidel 			maPropertyIdToNameMap[Int_DeckLeftPadding],
2129f759e1cSMatthias Seidel 			Any(sal_Int32(2)));
2139f759e1cSMatthias Seidel 		setPropertyValue(
2149f759e1cSMatthias Seidel 			maPropertyIdToNameMap[Int_DeckTopPadding],
2159f759e1cSMatthias Seidel 			Any(sal_Int32(2)));
2169f759e1cSMatthias Seidel 		setPropertyValue(
2179f759e1cSMatthias Seidel 			maPropertyIdToNameMap[Int_DeckRightPadding],
2189f759e1cSMatthias Seidel 			Any(sal_Int32(2)));
2199f759e1cSMatthias Seidel 		setPropertyValue(
2209f759e1cSMatthias Seidel 			maPropertyIdToNameMap[Int_DeckBottomPadding],
2219f759e1cSMatthias Seidel 			Any(sal_Int32(2)));
2229f759e1cSMatthias Seidel 		setPropertyValue(
2239f759e1cSMatthias Seidel 			maPropertyIdToNameMap[Int_DeckBorderSize],
2249f759e1cSMatthias Seidel 			Any(sal_Int32(1)));
2259f759e1cSMatthias Seidel 		setPropertyValue(
2269f759e1cSMatthias Seidel 			maPropertyIdToNameMap[Int_DeckSeparatorHeight],
2279f759e1cSMatthias Seidel 			Any(sal_Int32(1)));
2289f759e1cSMatthias Seidel 		setPropertyValue(
2299f759e1cSMatthias Seidel 			maPropertyIdToNameMap[Int_ButtonCornerRadius],
2309f759e1cSMatthias Seidel 			Any(sal_Int32(3)));
2319f759e1cSMatthias Seidel 		setPropertyValue(
2329f759e1cSMatthias Seidel 			maPropertyIdToNameMap[Color_DeckTitleFont],
233*33f5cc50Smseidel 			Any(sal_Int32(mbIsHighContrastMode ? 0xffffff : 0x262626)));
2349f759e1cSMatthias Seidel 		setPropertyValue(
2359f759e1cSMatthias Seidel 			maPropertyIdToNameMap[Int_DeckTitleBarHeight],
2369f759e1cSMatthias Seidel 			Any(sal_Int32(Alternatives(
2379f759e1cSMatthias Seidel 						26,
2389f759e1cSMatthias Seidel 						26,
2399f759e1cSMatthias Seidel 						rStyle.GetFloatTitleHeight()))));
2409f759e1cSMatthias Seidel 		setPropertyValue(
2419f759e1cSMatthias Seidel 			maPropertyIdToNameMap[Paint_PanelBackground],
2429f759e1cSMatthias Seidel 			Any(sal_Int32(aBaseBackgroundColor.GetRGBColor())));
2439f759e1cSMatthias Seidel 
2449f759e1cSMatthias Seidel 		setPropertyValue(
2459f759e1cSMatthias Seidel 			maPropertyIdToNameMap[Paint_PanelTitleBarBackground],
2469f759e1cSMatthias Seidel 			Any(Tools::VclToAwtGradient(Gradient(
2479f759e1cSMatthias Seidel 						GRADIENT_LINEAR,
2489f759e1cSMatthias Seidel 						aSecondColor.GetRGBColor(),
2499f759e1cSMatthias Seidel 						aBaseBackgroundColor.GetRGBColor()
2509f759e1cSMatthias Seidel 						))));
2519f759e1cSMatthias Seidel 		setPropertyValue(
2529f759e1cSMatthias Seidel 			maPropertyIdToNameMap[Color_PanelTitleFont],
2539f759e1cSMatthias Seidel 			Any(sal_Int32(mbIsHighContrastMode ? 0x00ff00 : 0x262626)));
2549f759e1cSMatthias Seidel 		setPropertyValue(
2559f759e1cSMatthias Seidel 			maPropertyIdToNameMap[Int_PanelTitleBarHeight],
2569f759e1cSMatthias Seidel 			Any(sal_Int32(Alternatives(
2579f759e1cSMatthias Seidel 						26,
2589f759e1cSMatthias Seidel 						26,
2599f759e1cSMatthias Seidel 						rStyle.GetTitleHeight()))));
2609f759e1cSMatthias Seidel 		setPropertyValue(
2619f759e1cSMatthias Seidel 			maPropertyIdToNameMap[Paint_TabBarBackground],
2629f759e1cSMatthias Seidel 			Any(sal_Int32(aBaseBackgroundColor.GetRGBColor())));
2639f759e1cSMatthias Seidel 		setPropertyValue(
2649f759e1cSMatthias Seidel 			maPropertyIdToNameMap[Int_TabBarLeftPadding],
2659f759e1cSMatthias Seidel 			Any(sal_Int32(2)));
2669f759e1cSMatthias Seidel 		setPropertyValue(
2679f759e1cSMatthias Seidel 			maPropertyIdToNameMap[Int_TabBarTopPadding],
2689f759e1cSMatthias Seidel 			Any(sal_Int32(2)));
2699f759e1cSMatthias Seidel 		setPropertyValue(
2709f759e1cSMatthias Seidel 			maPropertyIdToNameMap[Int_TabBarRightPadding],
2719f759e1cSMatthias Seidel 			Any(sal_Int32(2)));
2729f759e1cSMatthias Seidel 		setPropertyValue(
2739f759e1cSMatthias Seidel 			maPropertyIdToNameMap[Int_TabBarBottomPadding],
2749f759e1cSMatthias Seidel 			Any(sal_Int32(2)));
2759f759e1cSMatthias Seidel 
2769f759e1cSMatthias Seidel 		setPropertyValue(
2779f759e1cSMatthias Seidel 			maPropertyIdToNameMap[Int_TabMenuPadding],
2789f759e1cSMatthias Seidel 			Any(sal_Int32(6)));
2799f759e1cSMatthias Seidel 		setPropertyValue(
2809f759e1cSMatthias Seidel 			maPropertyIdToNameMap[Color_TabMenuSeparator],
2819f759e1cSMatthias Seidel 			Any(sal_Int32(aBorderColor.GetRGBColor())));
2829f759e1cSMatthias Seidel 		setPropertyValue(
2839f759e1cSMatthias Seidel 			maPropertyIdToNameMap[Int_TabMenuSeparatorPadding],
2849f759e1cSMatthias Seidel 			Any(sal_Int32(7)));
2859f759e1cSMatthias Seidel 
2869f759e1cSMatthias Seidel 		setPropertyValue(
2879f759e1cSMatthias Seidel 			maPropertyIdToNameMap[Int_TabItemWidth],
2889f759e1cSMatthias Seidel 			Any(sal_Int32(32)));
2899f759e1cSMatthias Seidel 		setPropertyValue(
2909f759e1cSMatthias Seidel 			maPropertyIdToNameMap[Int_TabItemHeight],
2919f759e1cSMatthias Seidel 			Any(sal_Int32(32)));
2929f759e1cSMatthias Seidel 		setPropertyValue(
2939f759e1cSMatthias Seidel 			maPropertyIdToNameMap[Color_TabItemBorder],
2949f759e1cSMatthias Seidel 			Any(sal_Int32(rStyle.GetActiveBorderColor().GetRGBColor())));
2959f759e1cSMatthias Seidel 		//					mbIsHighContrastMode ? 0x00ff00 : 0xbfbfbf)));
2969f759e1cSMatthias Seidel 
2979f759e1cSMatthias Seidel 		setPropertyValue(
2989f759e1cSMatthias Seidel 			maPropertyIdToNameMap[Paint_DropDownBackground],
2999f759e1cSMatthias Seidel 			Any(sal_Int32(aBaseBackgroundColor.GetRGBColor())));
3009f759e1cSMatthias Seidel 		setPropertyValue(
3019f759e1cSMatthias Seidel 			maPropertyIdToNameMap[Color_DropDownBorder],
3029f759e1cSMatthias Seidel 			Any(sal_Int32(rStyle.GetActiveBorderColor().GetRGBColor())));
3039f759e1cSMatthias Seidel 
3049f759e1cSMatthias Seidel 		setPropertyValue(
3059f759e1cSMatthias Seidel 			maPropertyIdToNameMap[Color_Highlight],
3069f759e1cSMatthias Seidel 			Any(sal_Int32(rStyle.GetHighlightColor().GetRGBColor())));
3079f759e1cSMatthias Seidel 		setPropertyValue(
3089f759e1cSMatthias Seidel 			maPropertyIdToNameMap[Color_HighlightText],
3099f759e1cSMatthias Seidel 			Any(sal_Int32(rStyle.GetHighlightTextColor().GetRGBColor())));
3109f759e1cSMatthias Seidel 
3119f759e1cSMatthias Seidel 		setPropertyValue(
3129f759e1cSMatthias Seidel 			maPropertyIdToNameMap[Paint_TabItemBackgroundNormal],
3139f759e1cSMatthias Seidel 			Any());
3149f759e1cSMatthias Seidel 		setPropertyValue(
3159f759e1cSMatthias Seidel 			maPropertyIdToNameMap[Paint_TabItemBackgroundHighlight],
3169f759e1cSMatthias Seidel 			Any(sal_Int32(rStyle.GetActiveTabColor().GetRGBColor())));
3179f759e1cSMatthias Seidel 		//					mbIsHighContrastMode ? 0x000000 : 0x00ffffff)));
3189f759e1cSMatthias Seidel 
3199f759e1cSMatthias Seidel 		setPropertyValue(
3209f759e1cSMatthias Seidel 			maPropertyIdToNameMap[Paint_HorizontalBorder],
3219f759e1cSMatthias Seidel 			Any(sal_Int32(aBorderColor.GetRGBColor())));
3229f759e1cSMatthias Seidel 		//					mbIsHighContrastMode ? 0x00ff00 : 0xe4e4e4)));
3239f759e1cSMatthias Seidel 		setPropertyValue(
3249f759e1cSMatthias Seidel 			maPropertyIdToNameMap[Paint_VerticalBorder],
3259f759e1cSMatthias Seidel 			Any(sal_Int32(aBorderColor.GetRGBColor())));
3269f759e1cSMatthias Seidel 		//					mbIsHighContrastMode ? 0x00ff00 : 0xe4e4e4)));
3279f759e1cSMatthias Seidel 
3289f759e1cSMatthias Seidel 		setPropertyValue(
3299f759e1cSMatthias Seidel 			maPropertyIdToNameMap[Image_Grip],
3309f759e1cSMatthias Seidel 			Any(
3319f759e1cSMatthias Seidel 				mbIsHighContrastMode
3329f759e1cSMatthias Seidel 					? A2S("private:graphicrepository/sfx2/res/grip_hc.png")
3339f759e1cSMatthias Seidel 					: A2S("private:graphicrepository/sfx2/res/grip.png")));
3349f759e1cSMatthias Seidel 		setPropertyValue(
3359f759e1cSMatthias Seidel 			maPropertyIdToNameMap[Image_Expand],
3369f759e1cSMatthias Seidel 			Any(
3379f759e1cSMatthias Seidel 				mbIsHighContrastMode
3389f759e1cSMatthias Seidel 					? A2S("private:graphicrepository/res/plus_sch.png")
3399f759e1cSMatthias Seidel 					: A2S("private:graphicrepository/res/plus.png")));
3409f759e1cSMatthias Seidel 		setPropertyValue(
3419f759e1cSMatthias Seidel 			maPropertyIdToNameMap[Image_Collapse],
3429f759e1cSMatthias Seidel 			Any(
3439f759e1cSMatthias Seidel 				mbIsHighContrastMode
3449f759e1cSMatthias Seidel 					? A2S("private:graphicrepository/res/minus_sch.png")
3459f759e1cSMatthias Seidel 					: A2S("private:graphicrepository/res/minus.png")));
3469f759e1cSMatthias Seidel 		setPropertyValue(
3479f759e1cSMatthias Seidel 			maPropertyIdToNameMap[Image_TabBarMenu],
3489f759e1cSMatthias Seidel 			Any(
3499f759e1cSMatthias Seidel 				mbIsHighContrastMode
3509f759e1cSMatthias Seidel 					? A2S("private:graphicrepository/sfx2/res/symphony/open_more_hc.png")
3519f759e1cSMatthias Seidel 					: A2S("private:graphicrepository/sfx2/res/symphony/open_more.png")));
3529f759e1cSMatthias Seidel 		setPropertyValue(
3539f759e1cSMatthias Seidel 			maPropertyIdToNameMap[Image_PanelMenu],
3549f759e1cSMatthias Seidel 			Any(
3559f759e1cSMatthias Seidel 				mbIsHighContrastMode
3569f759e1cSMatthias Seidel 					? A2S("private:graphicrepository/sfx2/res/symphony/morebutton_h.png")
3579f759e1cSMatthias Seidel 					: A2S("private:graphicrepository/sfx2/res/symphony/morebutton.png")));
3589f759e1cSMatthias Seidel 		setPropertyValue(
3599f759e1cSMatthias Seidel 			maPropertyIdToNameMap[Image_Closer],
3609f759e1cSMatthias Seidel 			Any(
3619f759e1cSMatthias Seidel 				mbIsHighContrastMode
3629f759e1cSMatthias Seidel 					? A2S("private:graphicrepository/sfx2/res/closedochc.png")
3639f759e1cSMatthias Seidel 					: A2S("private:graphicrepository/sfx2/res/closedoc.png")));
3649f759e1cSMatthias Seidel 		setPropertyValue(
3659f759e1cSMatthias Seidel 			maPropertyIdToNameMap[Image_CloseIndicator],
3669f759e1cSMatthias Seidel 			Any(
3679f759e1cSMatthias Seidel 				mbIsHighContrastMode
3689f759e1cSMatthias Seidel 					? A2S("private:graphicrepository/res/commandimagelist/lch_decrementlevel.png")
3699f759e1cSMatthias Seidel 					: A2S("private:graphicrepository/res/commandimagelist/lc_decrementlevel.png")));
3709f759e1cSMatthias Seidel 		setPropertyValue(
3719f759e1cSMatthias Seidel 			maPropertyIdToNameMap[Image_ToolBoxItemSeparator],
3729f759e1cSMatthias Seidel 			Any(
3739f759e1cSMatthias Seidel 				A2S("private:graphicrepository/sfx2/res/separator.png")));
3749f759e1cSMatthias Seidel 
3759f759e1cSMatthias Seidel 		// ToolBox
3769f759e1cSMatthias Seidel 
3779f759e1cSMatthias Seidel 		/*
3789f759e1cSMatthias Seidel 		// Separator style
3799f759e1cSMatthias Seidel 		setPropertyValue(
3809f759e1cSMatthias Seidel 			maPropertyIdToNameMap[Paint_ToolBoxBackground],
3819f759e1cSMatthias Seidel 			Any(sal_Int32(rStyle.GetMenuColor().GetRGBColor())));
3829f759e1cSMatthias Seidel 		setPropertyValue(
3839f759e1cSMatthias Seidel 			maPropertyIdToNameMap[Paint_ToolBoxBorderTopLeft],
3849f759e1cSMatthias Seidel 			Any());
3859f759e1cSMatthias Seidel 		setPropertyValue(
3869f759e1cSMatthias Seidel 			maPropertyIdToNameMap[Paint_ToolBoxBorderCenterCorners],
3879f759e1cSMatthias Seidel 			Any());
3889f759e1cSMatthias Seidel 		setPropertyValue(
3899f759e1cSMatthias Seidel 			maPropertyIdToNameMap[Paint_ToolBoxBorderBottomRight],
3909f759e1cSMatthias Seidel 			Any());
3919f759e1cSMatthias Seidel 		setPropertyValue(
3929f759e1cSMatthias Seidel 			maPropertyIdToNameMap[Rect_ToolBoxPadding],
3939f759e1cSMatthias Seidel 			Any(awt::Rectangle(2,2,2,2)));
3949f759e1cSMatthias Seidel 		setPropertyValue(
3959f759e1cSMatthias Seidel 			maPropertyIdToNameMap[Rect_ToolBoxBorder],
3969f759e1cSMatthias Seidel 			Any(awt::Rectangle(0,0,0,0)));
3979f759e1cSMatthias Seidel 		setPropertyValue(
3989f759e1cSMatthias Seidel 			maPropertyIdToNameMap[Bool_UseToolBoxItemSeparator],
3999f759e1cSMatthias Seidel 			Any(true));
4009f759e1cSMatthias Seidel 
4019f759e1cSMatthias Seidel 		*/
4029f759e1cSMatthias Seidel 
4039f759e1cSMatthias Seidel 		// Gradient style
4049f759e1cSMatthias Seidel 		Color aGradientStop2 (aBaseBackgroundColor);
4050c7fe49eSmseidel 		aGradientStop2.IncreaseLuminance(0);
4069f759e1cSMatthias Seidel 		Color aToolBoxBorderColor (aBaseBackgroundColor);
407c4aa4ee9Smseidel 		aToolBoxBorderColor.DecreaseLuminance(40);
4089f759e1cSMatthias Seidel 		setPropertyValue(
4099f759e1cSMatthias Seidel 			maPropertyIdToNameMap[Paint_ToolBoxBackground],
4109f759e1cSMatthias Seidel 			Any(Tools::VclToAwtGradient(Gradient(
4119f759e1cSMatthias Seidel 						GRADIENT_LINEAR,
4129f759e1cSMatthias Seidel 						aBaseBackgroundColor.GetRGBColor(),
4139f759e1cSMatthias Seidel 						aGradientStop2.GetRGBColor()
4149f759e1cSMatthias Seidel 						))));
4159f759e1cSMatthias Seidel 		setPropertyValue(
4169f759e1cSMatthias Seidel 			maPropertyIdToNameMap[Paint_ToolBoxBorderTopLeft],
4179f759e1cSMatthias Seidel 			mbIsHighContrastMode
4189f759e1cSMatthias Seidel 				? Any(util::Color(sal_uInt32(0x00ff00)))
4199f759e1cSMatthias Seidel 				: Any(util::Color(aToolBoxBorderColor.GetRGBColor())));
4209f759e1cSMatthias Seidel 		setPropertyValue(
4219f759e1cSMatthias Seidel 			maPropertyIdToNameMap[Paint_ToolBoxBorderCenterCorners],
4229f759e1cSMatthias Seidel 			mbIsHighContrastMode
4239f759e1cSMatthias Seidel 				? Any(util::Color(sal_uInt32(0x00ff00)))
4249f759e1cSMatthias Seidel 				: Any(util::Color(aToolBoxBorderColor.GetRGBColor())));
4259f759e1cSMatthias Seidel 		setPropertyValue(
4269f759e1cSMatthias Seidel 			maPropertyIdToNameMap[Paint_ToolBoxBorderBottomRight],
4279f759e1cSMatthias Seidel 			mbIsHighContrastMode
4289f759e1cSMatthias Seidel 				? Any(util::Color(sal_uInt32(0x00ff00)))
4299f759e1cSMatthias Seidel 				: Any(util::Color(aToolBoxBorderColor.GetRGBColor())));
4309f759e1cSMatthias Seidel 		setPropertyValue(
4319f759e1cSMatthias Seidel 			maPropertyIdToNameMap[Rect_ToolBoxPadding],
4329f759e1cSMatthias Seidel 			Any(awt::Rectangle(2,2,2,2)));
4339f759e1cSMatthias Seidel 		setPropertyValue(
4349f759e1cSMatthias Seidel 			maPropertyIdToNameMap[Rect_ToolBoxBorder],
4359f759e1cSMatthias Seidel 			Any(awt::Rectangle(1,1,1,1)));
4369f759e1cSMatthias Seidel 		setPropertyValue(
4379f759e1cSMatthias Seidel 			maPropertyIdToNameMap[Bool_UseToolBoxItemSeparator],
4389f759e1cSMatthias Seidel 			Any(false));
4399f759e1cSMatthias Seidel 	}
4409f759e1cSMatthias Seidel 	catch(beans::UnknownPropertyException& rException)
4419f759e1cSMatthias Seidel 	{
4429f759e1cSMatthias Seidel 		OSL_TRACE("unknown property: %s",
4439f759e1cSMatthias Seidel 			OUStringToOString(
4449f759e1cSMatthias Seidel 				rException.Message,
4459f759e1cSMatthias Seidel 				RTL_TEXTENCODING_ASCII_US).getStr());
4469f759e1cSMatthias Seidel 		OSL_ASSERT(false);
4479f759e1cSMatthias Seidel 	}
448ff12d537SAndre Fischer }
449ff12d537SAndre Fischer 
450ff12d537SAndre Fischer 
disposing(void)451b9e67834SAndre Fischer void SAL_CALL Theme::disposing (void)
452ff12d537SAndre Fischer {
4539f759e1cSMatthias Seidel 	ChangeListeners aListeners;
4549f759e1cSMatthias Seidel 	maChangeListeners.swap(aListeners);
4559f759e1cSMatthias Seidel 
4569f759e1cSMatthias Seidel 	const lang::EventObject aEvent (static_cast<XWeak*>(this));
4579f759e1cSMatthias Seidel 
4589f759e1cSMatthias Seidel 	for (ChangeListeners::const_iterator
4599f759e1cSMatthias Seidel 			 iContainer(maChangeListeners.begin()),
4609f759e1cSMatthias Seidel 			 iContainerEnd(maChangeListeners.end());
4619f759e1cSMatthias Seidel 		 iContainerEnd!=iContainerEnd;
4629f759e1cSMatthias Seidel 		 ++iContainerEnd)
4639f759e1cSMatthias Seidel 	{
4649f759e1cSMatthias Seidel 		for (ChangeListenerContainer::const_iterator
4659f759e1cSMatthias Seidel 				 iListener(iContainer->second.begin()),
4669f759e1cSMatthias Seidel 				 iEnd(iContainer->second.end());
4679f759e1cSMatthias Seidel 			 iListener!=iEnd;
4689f759e1cSMatthias Seidel 			 ++iListener)
4699f759e1cSMatthias Seidel 		{
4709f759e1cSMatthias Seidel 			try
4719f759e1cSMatthias Seidel 			{
4729f759e1cSMatthias Seidel 				(*iListener)->disposing(aEvent);
4739f759e1cSMatthias Seidel 			}
4749f759e1cSMatthias Seidel 			catch(const Exception&)
4759f759e1cSMatthias Seidel 			{
4769f759e1cSMatthias Seidel 			}
4779f759e1cSMatthias Seidel 		}
4789f759e1cSMatthias Seidel 	}
479ff12d537SAndre Fischer }
480ff12d537SAndre Fischer 
481ff12d537SAndre Fischer 
GetPropertySet(void)482b9e67834SAndre Fischer Reference<beans::XPropertySet> Theme::GetPropertySet (void)
483ff12d537SAndre Fischer {
4849f759e1cSMatthias 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)
4899f759e1cSMatthias Seidel 	throw(cssu::RuntimeException)
490ff12d537SAndre Fischer {
4919f759e1cSMatthias 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 (
4969f759e1cSMatthias Seidel 	const ::rtl::OUString& rsPropertyName,
4979f759e1cSMatthias Seidel 	const cssu::Any& rValue)
4989f759e1cSMatthias Seidel 	throw(cssu::RuntimeException)
499ff12d537SAndre Fischer {
5009f759e1cSMatthias Seidel 	PropertyNameToIdMap::const_iterator iId (maPropertyNameToIdMap.find(rsPropertyName));
5019f759e1cSMatthias Seidel 	if (iId == maPropertyNameToIdMap.end())
5029f759e1cSMatthias Seidel 		throw beans::UnknownPropertyException(rsPropertyName, NULL);
5039f759e1cSMatthias Seidel 
5049f759e1cSMatthias Seidel 	const PropertyType eType (GetPropertyType(iId->second));
5059f759e1cSMatthias Seidel 	if (eType == PT_Invalid)
5069f759e1cSMatthias Seidel 		throw beans::UnknownPropertyException(rsPropertyName, NULL);
5079f759e1cSMatthias Seidel 
5089f759e1cSMatthias Seidel 	const ThemeItem eItem (iId->second);
5099f759e1cSMatthias Seidel 
5109f759e1cSMatthias Seidel 	if (rValue == maRawValues[eItem])
5119f759e1cSMatthias Seidel 	{
5129f759e1cSMatthias Seidel 		// Value is not different from the one in the property
5139f759e1cSMatthias Seidel 		// set => nothing to do.
5149f759e1cSMatthias Seidel 		return;
5159f759e1cSMatthias Seidel 	}
5169f759e1cSMatthias Seidel 
5179f759e1cSMatthias Seidel 	const Any aOldValue (maRawValues[eItem]);
5189f759e1cSMatthias Seidel 
5199f759e1cSMatthias Seidel 	const beans::PropertyChangeEvent aEvent(
5209f759e1cSMatthias Seidel 		static_cast<XWeak*>(this),
5219f759e1cSMatthias Seidel 		rsPropertyName,
5229f759e1cSMatthias Seidel 		sal_False,
5239f759e1cSMatthias Seidel 		eItem,
5249f759e1cSMatthias Seidel 		aOldValue,
5259f759e1cSMatthias Seidel 		rValue);
5269f759e1cSMatthias Seidel 
5279f759e1cSMatthias Seidel 	if (DoVetoableListenersVeto(GetVetoableListeners(__AnyItem, false), aEvent))
5289f759e1cSMatthias Seidel 		return;
5299f759e1cSMatthias Seidel 	if (DoVetoableListenersVeto(GetVetoableListeners(eItem, false), aEvent))
5309f759e1cSMatthias Seidel 		return;
5319f759e1cSMatthias Seidel 
5329f759e1cSMatthias Seidel 	maRawValues[eItem] = rValue;
5339f759e1cSMatthias Seidel 	ProcessNewValue(rValue, eItem, eType);
5349f759e1cSMatthias Seidel 
5359f759e1cSMatthias Seidel 	BroadcastPropertyChange(GetChangeListeners(__AnyItem, false), aEvent);
5369f759e1cSMatthias Seidel 	BroadcastPropertyChange(GetChangeListeners(eItem, false), aEvent);
537ff12d537SAndre Fischer }
538ff12d537SAndre Fischer 
539ff12d537SAndre Fischer 
getPropertyValue(const::rtl::OUString & rsPropertyName)540b9e67834SAndre Fischer Any SAL_CALL Theme::getPropertyValue (
5419f759e1cSMatthias Seidel 	const ::rtl::OUString& rsPropertyName)
5429f759e1cSMatthias Seidel 	throw(css::beans::UnknownPropertyException,
5439f759e1cSMatthias Seidel 		css::lang::WrappedTargetException,
5449f759e1cSMatthias Seidel 		cssu::RuntimeException)
545ff12d537SAndre Fischer {
5469f759e1cSMatthias Seidel 	PropertyNameToIdMap::const_iterator iId (maPropertyNameToIdMap.find(rsPropertyName));
5479f759e1cSMatthias Seidel 	if (iId == maPropertyNameToIdMap.end())
5489f759e1cSMatthias Seidel 		throw beans::UnknownPropertyException();
549b9e67834SAndre Fischer 
5509f759e1cSMatthias Seidel 	const PropertyType eType (GetPropertyType(iId->second));
5519f759e1cSMatthias Seidel 	if (eType == PT_Invalid)
5529f759e1cSMatthias Seidel 		throw beans::UnknownPropertyException();
553b9e67834SAndre Fischer 
5549f759e1cSMatthias Seidel 	const ThemeItem eItem (iId->second);
555b9e67834SAndre Fischer 
5569f759e1cSMatthias 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(
5619f759e1cSMatthias Seidel 	const ::rtl::OUString& rsPropertyName,
5629f759e1cSMatthias Seidel 	const cssu::Reference<css::beans::XPropertyChangeListener>& rxListener)
5639f759e1cSMatthias Seidel 	throw(css::beans::UnknownPropertyException,
5649f759e1cSMatthias Seidel 		css::lang::WrappedTargetException,
5659f759e1cSMatthias Seidel 		cssu::RuntimeException)
566ff12d537SAndre Fischer {
5679f759e1cSMatthias Seidel 	ThemeItem eItem (__AnyItem);
5689f759e1cSMatthias Seidel 	if (rsPropertyName.getLength() > 0)
5699f759e1cSMatthias Seidel 	{
5709f759e1cSMatthias Seidel 		PropertyNameToIdMap::const_iterator iId (maPropertyNameToIdMap.find(rsPropertyName));
5719f759e1cSMatthias Seidel 		if (iId == maPropertyNameToIdMap.end())
5729f759e1cSMatthias Seidel 			throw beans::UnknownPropertyException();
5739f759e1cSMatthias Seidel 
5749f759e1cSMatthias Seidel 		const PropertyType eType (GetPropertyType(iId->second));
5759f759e1cSMatthias Seidel 		if (eType == PT_Invalid)
5769f759e1cSMatthias Seidel 			throw beans::UnknownPropertyException();
5779f759e1cSMatthias Seidel 
5789f759e1cSMatthias Seidel 		eItem = iId->second;
5799f759e1cSMatthias Seidel 	}
5809f759e1cSMatthias Seidel 	ChangeListenerContainer* pListeners = GetChangeListeners(eItem, true);
5819f759e1cSMatthias Seidel 	if (pListeners != NULL)
5829f759e1cSMatthias 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(
5879f759e1cSMatthias Seidel 	const ::rtl::OUString& rsPropertyName,
5889f759e1cSMatthias Seidel 	const cssu::Reference<css::beans::XPropertyChangeListener>& rxListener)
5899f759e1cSMatthias Seidel 	throw(css::beans::UnknownPropertyException,
5909f759e1cSMatthias Seidel 		css::lang::WrappedTargetException,
5919f759e1cSMatthias Seidel 		cssu::RuntimeException)
592ff12d537SAndre Fischer {
5939f759e1cSMatthias Seidel 	ThemeItem eItem (__AnyItem);
5949f759e1cSMatthias Seidel 	if (rsPropertyName.getLength() > 0)
5959f759e1cSMatthias Seidel 	{
5969f759e1cSMatthias Seidel 		PropertyNameToIdMap::const_iterator iId (maPropertyNameToIdMap.find(rsPropertyName));
5979f759e1cSMatthias Seidel 		if (iId == maPropertyNameToIdMap.end())
5989f759e1cSMatthias Seidel 			throw beans::UnknownPropertyException();
5999f759e1cSMatthias Seidel 
6009f759e1cSMatthias Seidel 		const PropertyType eType (GetPropertyType(iId->second));
6019f759e1cSMatthias Seidel 		if (eType == PT_Invalid)
6029f759e1cSMatthias Seidel 			throw beans::UnknownPropertyException();
6039f759e1cSMatthias Seidel 
6049f759e1cSMatthias Seidel 		eItem = iId->second;
6059f759e1cSMatthias Seidel 	}
6069f759e1cSMatthias Seidel 	ChangeListenerContainer* pContainer = GetChangeListeners(eItem, false);
6079f759e1cSMatthias Seidel 	if (pContainer != NULL)
6089f759e1cSMatthias Seidel 	{
6099f759e1cSMatthias Seidel 		ChangeListenerContainer::iterator iListener (::std::find(pContainer->begin(), pContainer->end(), rxListener));
6109f759e1cSMatthias Seidel 		if (iListener != pContainer->end())
6119f759e1cSMatthias Seidel 		{
6129f759e1cSMatthias Seidel 			pContainer->erase(iListener);
6139f759e1cSMatthias Seidel 
6149f759e1cSMatthias Seidel 			// Remove the listener container when empty.
6159f759e1cSMatthias Seidel 			if (pContainer->empty())
6169f759e1cSMatthias Seidel 				maChangeListeners.erase(eItem);
6179f759e1cSMatthias Seidel 		}
6189f759e1cSMatthias 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(
6239f759e1cSMatthias Seidel 	const ::rtl::OUString& rsPropertyName,
6249f759e1cSMatthias Seidel 	const cssu::Reference<css::beans::XVetoableChangeListener>& rxListener)
6259f759e1cSMatthias Seidel 	throw(css::beans::UnknownPropertyException,
6269f759e1cSMatthias Seidel 		css::lang::WrappedTargetException,
6279f759e1cSMatthias Seidel 		cssu::RuntimeException)
628ff12d537SAndre Fischer {
6299f759e1cSMatthias Seidel 	ThemeItem eItem (__AnyItem);
6309f759e1cSMatthias Seidel 	if (rsPropertyName.getLength() > 0)
6319f759e1cSMatthias Seidel 	{
6329f759e1cSMatthias Seidel 		PropertyNameToIdMap::const_iterator iId (maPropertyNameToIdMap.find(rsPropertyName));
6339f759e1cSMatthias Seidel 		if (iId == maPropertyNameToIdMap.end())
6349f759e1cSMatthias Seidel 			throw beans::UnknownPropertyException();
6359f759e1cSMatthias Seidel 
6369f759e1cSMatthias Seidel 		const PropertyType eType (GetPropertyType(iId->second));
6379f759e1cSMatthias Seidel 		if (eType == PT_Invalid)
6389f759e1cSMatthias Seidel 			throw beans::UnknownPropertyException();
6399f759e1cSMatthias Seidel 
6409f759e1cSMatthias Seidel 		eItem = iId->second;
6419f759e1cSMatthias Seidel 	}
6429f759e1cSMatthias Seidel 	VetoableListenerContainer* pListeners = GetVetoableListeners(eItem, true);
6439f759e1cSMatthias Seidel 	if (pListeners != NULL)
6449f759e1cSMatthias 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(
6499f759e1cSMatthias Seidel 	const ::rtl::OUString& rsPropertyName,
6509f759e1cSMatthias Seidel 	const cssu::Reference<css::beans::XVetoableChangeListener>& rxListener)
6519f759e1cSMatthias Seidel 	throw(css::beans::UnknownPropertyException,
6529f759e1cSMatthias Seidel 		css::lang::WrappedTargetException,
6539f759e1cSMatthias Seidel 		cssu::RuntimeException)
654ff12d537SAndre Fischer {
6559f759e1cSMatthias Seidel 	ThemeItem eItem (__AnyItem);
6569f759e1cSMatthias Seidel 	if (rsPropertyName.getLength() > 0)
6579f759e1cSMatthias Seidel 	{
6589f759e1cSMatthias Seidel 		PropertyNameToIdMap::const_iterator iId (maPropertyNameToIdMap.find(rsPropertyName));
6599f759e1cSMatthias Seidel 		if (iId == maPropertyNameToIdMap.end())
6609f759e1cSMatthias Seidel 			throw beans::UnknownPropertyException();
6619f759e1cSMatthias Seidel 
6629f759e1cSMatthias Seidel 		const PropertyType eType (GetPropertyType(iId->second));
6639f759e1cSMatthias Seidel 		if (eType == PT_Invalid)
6649f759e1cSMatthias Seidel 			throw beans::UnknownPropertyException();
6659f759e1cSMatthias Seidel 
6669f759e1cSMatthias Seidel 		eItem = iId->second;
6679f759e1cSMatthias Seidel 	}
6689f759e1cSMatthias Seidel 	VetoableListenerContainer* pContainer = GetVetoableListeners(eItem, false);
6699f759e1cSMatthias Seidel 	if (pContainer != NULL)
6709f759e1cSMatthias Seidel 	{
6719f759e1cSMatthias Seidel 		VetoableListenerContainer::iterator iListener (::std::find(pContainer->begin(), pContainer->end(), rxListener));
6729f759e1cSMatthias Seidel 		if (iListener != pContainer->end())
6739f759e1cSMatthias Seidel 		{
6749f759e1cSMatthias Seidel 			pContainer->erase(iListener);
6759f759e1cSMatthias Seidel 			// Remove container when empty.
6769f759e1cSMatthias Seidel 			if (pContainer->empty())
6779f759e1cSMatthias Seidel 				maVetoableListeners.erase(eItem);
6789f759e1cSMatthias Seidel 		}
6799f759e1cSMatthias Seidel 	}
680ff12d537SAndre Fischer }
681ff12d537SAndre Fischer 
682ff12d537SAndre Fischer 
getProperties(void)68395a18594SAndre Fischer cssu::Sequence<css::beans::Property> SAL_CALL Theme::getProperties (void)
6849f759e1cSMatthias Seidel 	throw(cssu::RuntimeException)
68595a18594SAndre Fischer {
6869f759e1cSMatthias Seidel 	::std::vector<beans::Property> aProperties;
6879f759e1cSMatthias Seidel 
6889f759e1cSMatthias Seidel 	for (sal_Int32 nItem(__Begin),nEnd(__End); nItem!=nEnd; ++nItem)
6899f759e1cSMatthias Seidel 	{
6909f759e1cSMatthias Seidel 		const ThemeItem eItem (static_cast<ThemeItem>(nItem));
6919f759e1cSMatthias Seidel 		const PropertyType eType (GetPropertyType(eItem));
6929f759e1cSMatthias Seidel 		if (eType == PT_Invalid)
6939f759e1cSMatthias Seidel 			continue;
6949f759e1cSMatthias Seidel 
6959f759e1cSMatthias Seidel 		const beans::Property aProperty(
6969f759e1cSMatthias Seidel 			maPropertyIdToNameMap[eItem],
6979f759e1cSMatthias Seidel 			eItem,
6989f759e1cSMatthias Seidel 			GetCppuType(eType),
6999f759e1cSMatthias Seidel 			0);
7009f759e1cSMatthias Seidel 		aProperties.push_back(aProperty);
7019f759e1cSMatthias Seidel 	}
7029f759e1cSMatthias Seidel 
7039f759e1cSMatthias Seidel 	return cssu::Sequence<css::beans::Property>(
7049f759e1cSMatthias Seidel 		&aProperties.front(),
7059f759e1cSMatthias 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)
7109f759e1cSMatthias Seidel 	throw(css::beans::UnknownPropertyException,
7119f759e1cSMatthias Seidel 		cssu::RuntimeException)
71295a18594SAndre Fischer {
7139f759e1cSMatthias Seidel 	PropertyNameToIdMap::const_iterator iId (maPropertyNameToIdMap.find(rsPropertyName));
7149f759e1cSMatthias Seidel 	if (iId == maPropertyNameToIdMap.end())
7159f759e1cSMatthias Seidel 		throw beans::UnknownPropertyException();
71695a18594SAndre Fischer 
7179f759e1cSMatthias Seidel 	const PropertyType eType (GetPropertyType(iId->second));
7189f759e1cSMatthias Seidel 	if (eType == PT_Invalid)
7199f759e1cSMatthias Seidel 		throw beans::UnknownPropertyException();
72095a18594SAndre Fischer 
7219f759e1cSMatthias Seidel 	const ThemeItem eItem (iId->second);
72295a18594SAndre Fischer 
7239f759e1cSMatthias Seidel 	return beans::Property(
7249f759e1cSMatthias Seidel 		rsPropertyName,
7259f759e1cSMatthias Seidel 		eItem,
7269f759e1cSMatthias Seidel 		GetCppuType(eType),
7279f759e1cSMatthias 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)
7329f759e1cSMatthias Seidel 	throw(cssu::RuntimeException)
73395a18594SAndre Fischer {
7349f759e1cSMatthias Seidel 	PropertyNameToIdMap::const_iterator iId (maPropertyNameToIdMap.find(rsPropertyName));
7359f759e1cSMatthias Seidel 	if (iId == maPropertyNameToIdMap.end())
7369f759e1cSMatthias Seidel 		return sal_False;
73795a18594SAndre Fischer 
7389f759e1cSMatthias Seidel 	const PropertyType eType (GetPropertyType(iId->second));
7399f759e1cSMatthias Seidel 	if (eType == PT_Invalid)
7409f759e1cSMatthias Seidel 		return sal_False;
74195a18594SAndre Fischer 
7429f759e1cSMatthias Seidel 	return sal_True;
74395a18594SAndre Fischer }
74495a18594SAndre Fischer 
74595a18594SAndre Fischer 
SetupPropertyMaps(void)746b9e67834SAndre Fischer void Theme::SetupPropertyMaps (void)
747ff12d537SAndre Fischer {
7489f759e1cSMatthias Seidel 	maPropertyIdToNameMap.resize(__Post_Rect);
7499f759e1cSMatthias Seidel 	maImages.resize(__Image_Color - __Pre_Image - 1);
7509f759e1cSMatthias Seidel 	maColors.resize(__Color_Paint - __Image_Color - 1);
7519f759e1cSMatthias Seidel 	maPaints.resize(__Paint_Int - __Color_Paint - 1);
7529f759e1cSMatthias Seidel 	maIntegers.resize(__Int_Bool - __Paint_Int - 1);
7539f759e1cSMatthias Seidel 	maBooleans.resize(__Bool_Rect - __Int_Bool - 1);
7549f759e1cSMatthias Seidel 	maRectangles.resize(__Post_Rect - __Bool_Rect - 1);
7559f759e1cSMatthias Seidel 
7569f759e1cSMatthias Seidel 	#define AddEntry(e) maPropertyNameToIdMap[A2S(#e)]=e; maPropertyIdToNameMap[e]=A2S(#e)
7579f759e1cSMatthias Seidel 
7589f759e1cSMatthias Seidel 	AddEntry(Image_Grip);
7599f759e1cSMatthias Seidel 	AddEntry(Image_Expand);
7609f759e1cSMatthias Seidel 	AddEntry(Image_Collapse);
7619f759e1cSMatthias Seidel 	AddEntry(Image_TabBarMenu);
7629f759e1cSMatthias Seidel 	AddEntry(Image_PanelMenu);
7639f759e1cSMatthias Seidel 	AddEntry(Image_ToolBoxItemSeparator);
7649f759e1cSMatthias Seidel 	AddEntry(Image_Closer);
7659f759e1cSMatthias Seidel 	AddEntry(Image_CloseIndicator);
7669f759e1cSMatthias Seidel 
7679f759e1cSMatthias Seidel 	AddEntry(Color_DeckTitleFont);
7689f759e1cSMatthias Seidel 	AddEntry(Color_PanelTitleFont);
7699f759e1cSMatthias Seidel 	AddEntry(Color_TabMenuSeparator);
7709f759e1cSMatthias Seidel 	AddEntry(Color_TabItemBorder);
7719f759e1cSMatthias Seidel 	AddEntry(Color_DropDownBorder);
7729f759e1cSMatthias Seidel 	AddEntry(Color_Highlight);
7739f759e1cSMatthias Seidel 	AddEntry(Color_HighlightText);
7749f759e1cSMatthias Seidel 
7759f759e1cSMatthias Seidel 	AddEntry(Paint_DeckBackground);
7769f759e1cSMatthias Seidel 	AddEntry(Paint_DeckTitleBarBackground);
7779f759e1cSMatthias Seidel 	AddEntry(Paint_PanelBackground);
7789f759e1cSMatthias Seidel 	AddEntry(Paint_PanelTitleBarBackground);
7799f759e1cSMatthias Seidel 	AddEntry(Paint_TabBarBackground);
7809f759e1cSMatthias Seidel 	AddEntry(Paint_TabItemBackgroundNormal);
7819f759e1cSMatthias Seidel 	AddEntry(Paint_TabItemBackgroundHighlight);
7829f759e1cSMatthias Seidel 	AddEntry(Paint_HorizontalBorder);
7839f759e1cSMatthias Seidel 	AddEntry(Paint_VerticalBorder);
7849f759e1cSMatthias Seidel 	AddEntry(Paint_ToolBoxBackground);
7859f759e1cSMatthias Seidel 	AddEntry(Paint_ToolBoxBorderTopLeft);
7869f759e1cSMatthias Seidel 	AddEntry(Paint_ToolBoxBorderCenterCorners);
7879f759e1cSMatthias Seidel 	AddEntry(Paint_ToolBoxBorderBottomRight);
7889f759e1cSMatthias Seidel 	AddEntry(Paint_DropDownBackground);
7899f759e1cSMatthias Seidel 
7909f759e1cSMatthias Seidel 	AddEntry(Int_DeckTitleBarHeight);
7919f759e1cSMatthias Seidel 	AddEntry(Int_DeckBorderSize);
7929f759e1cSMatthias Seidel 	AddEntry(Int_DeckSeparatorHeight);
7939f759e1cSMatthias Seidel 	AddEntry(Int_PanelTitleBarHeight);
7949f759e1cSMatthias Seidel 	AddEntry(Int_TabMenuPadding);
7959f759e1cSMatthias Seidel 	AddEntry(Int_TabMenuSeparatorPadding);
7969f759e1cSMatthias Seidel 	AddEntry(Int_TabItemWidth);
7979f759e1cSMatthias Seidel 	AddEntry(Int_TabItemHeight);
7989f759e1cSMatthias Seidel 	AddEntry(Int_DeckLeftPadding);
7999f759e1cSMatthias Seidel 	AddEntry(Int_DeckTopPadding);
8009f759e1cSMatthias Seidel 	AddEntry(Int_DeckRightPadding);
8019f759e1cSMatthias Seidel 	AddEntry(Int_DeckBottomPadding);
8029f759e1cSMatthias Seidel 	AddEntry(Int_TabBarLeftPadding);
8039f759e1cSMatthias Seidel 	AddEntry(Int_TabBarTopPadding);
8049f759e1cSMatthias Seidel 	AddEntry(Int_TabBarRightPadding);
8059f759e1cSMatthias Seidel 	AddEntry(Int_TabBarBottomPadding);
8069f759e1cSMatthias Seidel 	AddEntry(Int_ButtonCornerRadius);
8079f759e1cSMatthias Seidel 
8089f759e1cSMatthias Seidel 	AddEntry(Bool_UseSymphonyIcons);
8099f759e1cSMatthias Seidel 	AddEntry(Bool_UseSystemColors);
8109f759e1cSMatthias Seidel 	AddEntry(Bool_UseToolBoxItemSeparator);
8119f759e1cSMatthias Seidel 	AddEntry(Bool_IsHighContrastModeActive);
8129f759e1cSMatthias Seidel 
8139f759e1cSMatthias Seidel 	AddEntry(Rect_ToolBoxPadding);
8149f759e1cSMatthias Seidel 	AddEntry(Rect_ToolBoxBorder);
8159f759e1cSMatthias Seidel 
8169f759e1cSMatthias Seidel 	#undef AddEntry
8179f759e1cSMatthias Seidel 
8189f759e1cSMatthias 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 {
8249f759e1cSMatthias Seidel 	switch(eItem)
8259f759e1cSMatthias Seidel 	{
8269f759e1cSMatthias Seidel 		case Image_Grip:
8279f759e1cSMatthias Seidel 		case Image_Expand:
8289f759e1cSMatthias Seidel 		case Image_Collapse:
8299f759e1cSMatthias Seidel 		case Image_TabBarMenu:
8309f759e1cSMatthias Seidel 		case Image_PanelMenu:
8319f759e1cSMatthias Seidel 		case Image_ToolBoxItemSeparator:
8329f759e1cSMatthias Seidel 		case Image_Closer:
8339f759e1cSMatthias Seidel 		case Image_CloseIndicator:
8349f759e1cSMatthias Seidel 			return PT_Image;
8359f759e1cSMatthias Seidel 
8369f759e1cSMatthias Seidel 		case Color_DeckTitleFont:
8379f759e1cSMatthias Seidel 		case Color_PanelTitleFont:
8389f759e1cSMatthias Seidel 		case Color_TabMenuSeparator:
8399f759e1cSMatthias Seidel 		case Color_TabItemBorder:
8409f759e1cSMatthias Seidel 		case Color_DropDownBorder:
8419f759e1cSMatthias Seidel 		case Color_Highlight:
8429f759e1cSMatthias Seidel 		case Color_HighlightText:
8439f759e1cSMatthias Seidel 			return PT_Color;
8449f759e1cSMatthias Seidel 
8459f759e1cSMatthias Seidel 		case Paint_DeckBackground:
8469f759e1cSMatthias Seidel 		case Paint_DeckTitleBarBackground:
8479f759e1cSMatthias Seidel 		case Paint_PanelBackground:
8489f759e1cSMatthias Seidel 		case Paint_PanelTitleBarBackground:
8499f759e1cSMatthias Seidel 		case Paint_TabBarBackground:
8509f759e1cSMatthias Seidel 		case Paint_TabItemBackgroundNormal:
8519f759e1cSMatthias Seidel 		case Paint_TabItemBackgroundHighlight:
8529f759e1cSMatthias Seidel 		case Paint_HorizontalBorder:
8539f759e1cSMatthias Seidel 		case Paint_VerticalBorder:
8549f759e1cSMatthias Seidel 		case Paint_ToolBoxBackground:
8559f759e1cSMatthias Seidel 		case Paint_ToolBoxBorderTopLeft:
8569f759e1cSMatthias Seidel 		case Paint_ToolBoxBorderCenterCorners:
8579f759e1cSMatthias Seidel 		case Paint_ToolBoxBorderBottomRight:
8589f759e1cSMatthias Seidel 		case Paint_DropDownBackground:
8599f759e1cSMatthias Seidel 			return PT_Paint;
8609f759e1cSMatthias Seidel 
8619f759e1cSMatthias Seidel 		case Int_DeckTitleBarHeight:
8629f759e1cSMatthias Seidel 		case Int_DeckBorderSize:
8639f759e1cSMatthias Seidel 		case Int_DeckSeparatorHeight:
8649f759e1cSMatthias Seidel 		case Int_PanelTitleBarHeight:
8659f759e1cSMatthias Seidel 		case Int_TabMenuPadding:
8669f759e1cSMatthias Seidel 		case Int_TabMenuSeparatorPadding:
8679f759e1cSMatthias Seidel 		case Int_TabItemWidth:
8689f759e1cSMatthias Seidel 		case Int_TabItemHeight:
8699f759e1cSMatthias Seidel 		case Int_DeckLeftPadding:
8709f759e1cSMatthias Seidel 		case Int_DeckTopPadding:
8719f759e1cSMatthias Seidel 		case Int_DeckRightPadding:
8729f759e1cSMatthias Seidel 		case Int_DeckBottomPadding:
8739f759e1cSMatthias Seidel 		case Int_TabBarLeftPadding:
8749f759e1cSMatthias Seidel 		case Int_TabBarTopPadding:
8759f759e1cSMatthias Seidel 		case Int_TabBarRightPadding:
8769f759e1cSMatthias Seidel 		case Int_TabBarBottomPadding:
8779f759e1cSMatthias Seidel 		case Int_ButtonCornerRadius:
8789f759e1cSMatthias Seidel 			return PT_Integer;
8799f759e1cSMatthias Seidel 
8809f759e1cSMatthias Seidel 		case Bool_UseSymphonyIcons:
8819f759e1cSMatthias Seidel 		case Bool_UseSystemColors:
8829f759e1cSMatthias Seidel 		case Bool_UseToolBoxItemSeparator:
8839f759e1cSMatthias Seidel 		case Bool_IsHighContrastModeActive:
8849f759e1cSMatthias Seidel 			return PT_Boolean;
8859f759e1cSMatthias Seidel 
8869f759e1cSMatthias Seidel 		case Rect_ToolBoxBorder:
8879f759e1cSMatthias Seidel 		case Rect_ToolBoxPadding:
8889f759e1cSMatthias Seidel 			return PT_Rectangle;
8899f759e1cSMatthias Seidel 
8909f759e1cSMatthias Seidel 		default:
8919f759e1cSMatthias Seidel 			return PT_Invalid;
8929f759e1cSMatthias Seidel 	}
893ff12d537SAndre Fischer }
894ff12d537SAndre Fischer 
895ff12d537SAndre Fischer 
GetCppuType(const PropertyType eType)89695a18594SAndre Fischer cssu::Type Theme::GetCppuType (const PropertyType eType)
89795a18594SAndre Fischer {
8989f759e1cSMatthias Seidel 	switch(eType)
8999f759e1cSMatthias Seidel 	{
9009f759e1cSMatthias Seidel 		case PT_Image:
9019f759e1cSMatthias Seidel 			return getCppuType((rtl::OUString*)NULL);
90295a18594SAndre Fischer 
9039f759e1cSMatthias Seidel 		case PT_Color:
9049f759e1cSMatthias Seidel 			return getCppuType((sal_uInt32*)NULL);
90595a18594SAndre Fischer 
9069f759e1cSMatthias Seidel 		case PT_Paint:
9079f759e1cSMatthias Seidel 			return getCppuVoidType();
90895a18594SAndre Fischer 
9099f759e1cSMatthias Seidel 		case PT_Integer:
9109f759e1cSMatthias Seidel 			return getCppuType((sal_Int32*)NULL);
91195a18594SAndre Fischer 
9129f759e1cSMatthias Seidel 		case PT_Boolean:
9139f759e1cSMatthias Seidel 			return getCppuType((sal_Bool*)NULL);
91495a18594SAndre Fischer 
9159f759e1cSMatthias Seidel 		case PT_Rectangle:
9169f759e1cSMatthias Seidel 			return getCppuType((awt::Rectangle*)NULL);
91795a18594SAndre Fischer 
9189f759e1cSMatthias Seidel 		case PT_Invalid:
9199f759e1cSMatthias Seidel 		default:
9209f759e1cSMatthias Seidel 			return getCppuVoidType();
9219f759e1cSMatthias 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 {
9279f759e1cSMatthias Seidel 	switch(eType)
9289f759e1cSMatthias Seidel 	{
9299f759e1cSMatthias Seidel 		case PT_Image:
9309f759e1cSMatthias Seidel 			return eItem - __Pre_Image-1;
9319f759e1cSMatthias Seidel 		case PT_Color:
9329f759e1cSMatthias Seidel 			return eItem - __Image_Color-1;
9339f759e1cSMatthias Seidel 		case PT_Paint:
9349f759e1cSMatthias Seidel 			return eItem - __Color_Paint-1;
9359f759e1cSMatthias Seidel 		case PT_Integer:
9369f759e1cSMatthias Seidel 			return eItem - __Paint_Int-1;
9379f759e1cSMatthias Seidel 		case PT_Boolean:
9389f759e1cSMatthias Seidel 			return eItem - __Int_Bool-1;
9399f759e1cSMatthias Seidel 		case PT_Rectangle:
9409f759e1cSMatthias Seidel 			return eItem - __Bool_Rect-1;
9419f759e1cSMatthias Seidel 
9429f759e1cSMatthias Seidel 		default:
9439f759e1cSMatthias Seidel 			OSL_ASSERT(false);
9449f759e1cSMatthias Seidel 			return 0;
9459f759e1cSMatthias Seidel 	}
946ff12d537SAndre Fischer }
947ff12d537SAndre Fischer 
948ff12d537SAndre Fischer 
GetVetoableListeners(const ThemeItem eItem,const bool bCreate)949b9e67834SAndre Fischer Theme::VetoableListenerContainer* Theme::GetVetoableListeners (
9509f759e1cSMatthias Seidel 	const ThemeItem eItem,
9519f759e1cSMatthias Seidel 	const bool bCreate)
952ff12d537SAndre Fischer {
9539f759e1cSMatthias Seidel 	VetoableListeners::iterator iContainer (maVetoableListeners.find(eItem));
9549f759e1cSMatthias Seidel 	if (iContainer != maVetoableListeners.end())
9559f759e1cSMatthias Seidel 		return &iContainer->second;
9569f759e1cSMatthias Seidel 	else if (bCreate)
9579f759e1cSMatthias Seidel 	{
9589f759e1cSMatthias Seidel 		maVetoableListeners[eItem] = VetoableListenerContainer();
9599f759e1cSMatthias Seidel 		return &maVetoableListeners[eItem];
9609f759e1cSMatthias Seidel 	}
9619f759e1cSMatthias Seidel 	else
9629f759e1cSMatthias Seidel 		return NULL;
963ff12d537SAndre Fischer }
964ff12d537SAndre Fischer 
965ff12d537SAndre Fischer 
GetChangeListeners(const ThemeItem eItem,const bool bCreate)966b9e67834SAndre Fischer Theme::ChangeListenerContainer* Theme::GetChangeListeners (
9679f759e1cSMatthias Seidel 	const ThemeItem eItem,
9689f759e1cSMatthias Seidel 	const bool bCreate)
969ff12d537SAndre Fischer {
9709f759e1cSMatthias Seidel 	ChangeListeners::iterator iContainer (maChangeListeners.find(eItem));
9719f759e1cSMatthias Seidel 	if (iContainer != maChangeListeners.end())
9729f759e1cSMatthias Seidel 		return &iContainer->second;
9739f759e1cSMatthias Seidel 	else if (bCreate)
9749f759e1cSMatthias Seidel 	{
9759f759e1cSMatthias Seidel 		maChangeListeners[eItem] = ChangeListenerContainer();
9769f759e1cSMatthias Seidel 		return &maChangeListeners[eItem];
9779f759e1cSMatthias Seidel 	}
9789f759e1cSMatthias Seidel 	else
9799f759e1cSMatthias Seidel 		return NULL;
980ff12d537SAndre Fischer }
981ff12d537SAndre Fischer 
982ff12d537SAndre Fischer 
DoVetoableListenersVeto(const VetoableListenerContainer * pListeners,const beans::PropertyChangeEvent & rEvent) const983b9e67834SAndre Fischer bool Theme::DoVetoableListenersVeto (
9849f759e1cSMatthias Seidel 	const VetoableListenerContainer* pListeners,
9859f759e1cSMatthias Seidel 	const beans::PropertyChangeEvent& rEvent) const
986ff12d537SAndre Fischer {
9879f759e1cSMatthias Seidel 	if (pListeners == NULL)
9889f759e1cSMatthias Seidel 		return false;
9899f759e1cSMatthias Seidel 
9909f759e1cSMatthias Seidel 	VetoableListenerContainer aListeners (*pListeners);
9919f759e1cSMatthias Seidel 	try
9929f759e1cSMatthias Seidel 	{
9939f759e1cSMatthias Seidel 		for (VetoableListenerContainer::const_iterator
9949f759e1cSMatthias Seidel 				 iListener(aListeners.begin()),
9959f759e1cSMatthias Seidel 				 iEnd(aListeners.end());
9969f759e1cSMatthias Seidel 			 iListener!=iEnd;
9979f759e1cSMatthias Seidel 			 ++iListener)
9989f759e1cSMatthias Seidel 		{
9999f759e1cSMatthias Seidel 			(*iListener)->vetoableChange(rEvent);
10009f759e1cSMatthias Seidel 		}
10019f759e1cSMatthias Seidel 	}
10029f759e1cSMatthias Seidel 	catch(const beans::PropertyVetoException&)
10039f759e1cSMatthias Seidel 	{
10049f759e1cSMatthias Seidel 		return true;
10059f759e1cSMatthias Seidel 	}
10069f759e1cSMatthias Seidel 	catch(const Exception&)
10079f759e1cSMatthias Seidel 	{
10089f759e1cSMatthias Seidel 		// Ignore any other errors (such as disposed listeners).
10099f759e1cSMatthias Seidel 	}
10109f759e1cSMatthias Seidel 	return false;
1011ff12d537SAndre Fischer }
1012ff12d537SAndre Fischer 
1013ff12d537SAndre Fischer 
BroadcastPropertyChange(const ChangeListenerContainer * pListeners,const beans::PropertyChangeEvent & rEvent) const1014b9e67834SAndre Fischer void Theme::BroadcastPropertyChange (
10159f759e1cSMatthias Seidel 	const ChangeListenerContainer* pListeners,
10169f759e1cSMatthias Seidel 	const beans::PropertyChangeEvent& rEvent) const
1017ff12d537SAndre Fischer {
10189f759e1cSMatthias Seidel 	if (pListeners == NULL)
10199f759e1cSMatthias Seidel 		return;
10209f759e1cSMatthias Seidel 
10219f759e1cSMatthias Seidel 	const ChangeListenerContainer aListeners (*pListeners);
10229f759e1cSMatthias Seidel 	try
10239f759e1cSMatthias Seidel 	{
10249f759e1cSMatthias Seidel 		for (ChangeListenerContainer::const_iterator
10259f759e1cSMatthias Seidel 				 iListener(aListeners.begin()),
10269f759e1cSMatthias Seidel 				 iEnd(aListeners.end());
10279f759e1cSMatthias Seidel 			 iListener!=iEnd;
10289f759e1cSMatthias Seidel 			 ++iListener)
10299f759e1cSMatthias Seidel 		{
10309f759e1cSMatthias Seidel 			(*iListener)->propertyChange(rEvent);
10319f759e1cSMatthias Seidel 		}
10329f759e1cSMatthias Seidel 	}
10339f759e1cSMatthias Seidel 	catch(const Exception&)
10349f759e1cSMatthias Seidel 	{
10359f759e1cSMatthias Seidel 		// Ignore any errors (such as disposed listeners).
10369f759e1cSMatthias Seidel 	}
1037ff12d537SAndre Fischer }
1038ff12d537SAndre Fischer 
1039ff12d537SAndre Fischer 
ProcessNewValue(const Any & rValue,const ThemeItem eItem,const PropertyType eType)1040b9e67834SAndre Fischer void Theme::ProcessNewValue (
10419f759e1cSMatthias Seidel 	const Any& rValue,
10429f759e1cSMatthias Seidel 	const ThemeItem eItem,
10439f759e1cSMatthias Seidel 	const PropertyType eType)
1044ff12d537SAndre Fischer {
10459f759e1cSMatthias Seidel 	const sal_Int32 nIndex (GetIndex (eItem, eType));
10469f759e1cSMatthias Seidel 	switch (eType)
10479f759e1cSMatthias Seidel 	{
10489f759e1cSMatthias Seidel 		case PT_Image:
10499f759e1cSMatthias Seidel 		{
10509f759e1cSMatthias Seidel 			::rtl::OUString sURL;
10519f759e1cSMatthias Seidel 			if (rValue >>= sURL)
10529f759e1cSMatthias Seidel 			{
10539f759e1cSMatthias Seidel 				maImages[nIndex] = Tools::GetImage(sURL, NULL);
10549f759e1cSMatthias Seidel 			}
10559f759e1cSMatthias Seidel 			break;
10569f759e1cSMatthias Seidel 		}
10579f759e1cSMatthias Seidel 		case PT_Color:
10589f759e1cSMatthias Seidel 		{
10599f759e1cSMatthias Seidel 			sal_Int32 nColorValue (0);
10609f759e1cSMatthias Seidel 			if (rValue >>= nColorValue)
10619f759e1cSMatthias Seidel 			{
10629f759e1cSMatthias Seidel 				maColors[nIndex] = Color(nColorValue);
10639f759e1cSMatthias Seidel 			}
10649f759e1cSMatthias Seidel 			break;
10659f759e1cSMatthias Seidel 		}
10669f759e1cSMatthias Seidel 		case PT_Paint:
10679f759e1cSMatthias Seidel 		{
10689f759e1cSMatthias Seidel 			maPaints[nIndex] = Paint::Create(rValue);
10699f759e1cSMatthias Seidel 			break;
10709f759e1cSMatthias Seidel 		}
10719f759e1cSMatthias Seidel 		case PT_Integer:
10729f759e1cSMatthias Seidel 		{
10739f759e1cSMatthias Seidel 			sal_Int32 nValue (0);
10749f759e1cSMatthias Seidel 			if (rValue >>= nValue)
10759f759e1cSMatthias Seidel 			{
10769f759e1cSMatthias Seidel 				maIntegers[nIndex] = nValue;
10779f759e1cSMatthias Seidel 			}
10789f759e1cSMatthias Seidel 			break;
10799f759e1cSMatthias Seidel 		}
10809f759e1cSMatthias Seidel 		case PT_Boolean:
10819f759e1cSMatthias Seidel 		{
10829f759e1cSMatthias Seidel 			sal_Bool nValue (0);
10839f759e1cSMatthias Seidel 			if (rValue >>= nValue)
10849f759e1cSMatthias Seidel 			{
10859f759e1cSMatthias Seidel 				maBooleans[nIndex] = (nValue==sal_True);
10869f759e1cSMatthias Seidel 				if (eItem == Bool_IsHighContrastModeActive)
10879f759e1cSMatthias Seidel 				{
10889f759e1cSMatthias Seidel 					mbIsHighContrastModeSetManually = true;
10899f759e1cSMatthias Seidel 					mbIsHighContrastMode = maBooleans[nIndex];
10909f759e1cSMatthias Seidel 					HandleDataChange();
10919f759e1cSMatthias Seidel 				}
10929f759e1cSMatthias Seidel 				else if (eItem == Bool_UseSystemColors)
10939f759e1cSMatthias Seidel 				{
10949f759e1cSMatthias Seidel 					HandleDataChange();
10959f759e1cSMatthias Seidel 				}
10969f759e1cSMatthias Seidel 			}
10979f759e1cSMatthias Seidel 			break;
10989f759e1cSMatthias Seidel 		}
10999f759e1cSMatthias Seidel 		case PT_Rectangle:
11009f759e1cSMatthias Seidel 		{
11019f759e1cSMatthias Seidel 			awt::Rectangle aBox;
11029f759e1cSMatthias Seidel 			if (rValue >>= aBox)
11039f759e1cSMatthias Seidel 			{
11049f759e1cSMatthias Seidel 				maRectangles[nIndex] = Rectangle(
11059f759e1cSMatthias Seidel 					aBox.X,
11069f759e1cSMatthias Seidel 					aBox.Y,
11079f759e1cSMatthias Seidel 					aBox.Width,
11089f759e1cSMatthias Seidel 					aBox.Height);
11099f759e1cSMatthias Seidel 			}
11109f759e1cSMatthias Seidel 			break;
11119f759e1cSMatthias Seidel 		}
11129f759e1cSMatthias Seidel 		case PT_Invalid:
11139f759e1cSMatthias Seidel 			OSL_ASSERT(eType != PT_Invalid);
11149f759e1cSMatthias Seidel 			throw RuntimeException();
11159f759e1cSMatthias Seidel 	}
1116ff12d537SAndre Fischer }
1117ff12d537SAndre Fischer 
1118ff12d537SAndre Fischer } } // end of namespace sfx2::sidebar
1119*33f5cc50Smseidel 
1120*33f5cc50Smseidel /* vim: set noet sw=4 ts=4: */
1121