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