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 24*b9e67834SAndre Fischer #include "sfx2/sidebar/Theme.hxx" 25ff12d537SAndre Fischer #include "Paint.hxx" 26ff12d537SAndre Fischer #include "SidebarResource.hxx" 27*b9e67834SAndre Fischer #include "Tools.hxx" 28ff12d537SAndre Fischer 29*b9e67834SAndre Fischer #include <tools/svborder.hxx> 30ff12d537SAndre Fischer #include <tools/rc.hxx> 31ff12d537SAndre Fischer #include <vcl/svapp.hxx> 32ff12d537SAndre Fischer 33*b9e67834SAndre Fischer using namespace css; 34*b9e67834SAndre Fischer using namespace cssu; 35*b9e67834SAndre Fischer 36ff12d537SAndre Fischer 37ff12d537SAndre Fischer namespace sfx2 { namespace sidebar { 38ff12d537SAndre Fischer 39*b9e67834SAndre Fischer ::rtl::Reference<Theme> Theme::mpInstance; 40ff12d537SAndre Fischer 41*b9e67834SAndre Fischer 42*b9e67834SAndre Fischer 43*b9e67834SAndre Fischer 44*b9e67834SAndre Fischer Theme& Theme::GetCurrentTheme (void) 45ff12d537SAndre Fischer { 46*b9e67834SAndre Fischer if ( ! mpInstance.is()) 47ff12d537SAndre Fischer { 48*b9e67834SAndre Fischer mpInstance.set(new Theme()); 49*b9e67834SAndre Fischer mpInstance->InitializeTheme(); 50ff12d537SAndre Fischer } 51*b9e67834SAndre Fischer return *mpInstance; 52ff12d537SAndre Fischer } 53ff12d537SAndre Fischer 54ff12d537SAndre Fischer 55ff12d537SAndre Fischer 56ff12d537SAndre Fischer 57*b9e67834SAndre Fischer Theme::Theme (void) 58*b9e67834SAndre Fischer : ThemeInterfaceBase(m_aMutex), 59*b9e67834SAndre Fischer maImages(), 60*b9e67834SAndre Fischer maColors(), 61*b9e67834SAndre Fischer maPaints(), 62*b9e67834SAndre Fischer maIntegers(), 63*b9e67834SAndre Fischer maBooleans(), 64*b9e67834SAndre Fischer mbIsHighContrastMode(Application::GetSettings().GetStyleSettings().GetHighContrastMode()), 65*b9e67834SAndre Fischer maPropertyNameToIdMap(), 66*b9e67834SAndre Fischer maPropertyIdToNameMap(), 67*b9e67834SAndre Fischer maRawValues(), 68*b9e67834SAndre Fischer maChangeListeners(), 69*b9e67834SAndre Fischer maVetoableListeners() 70*b9e67834SAndre Fischer 71ff12d537SAndre Fischer { 72*b9e67834SAndre Fischer SetupPropertyMaps(); 73ff12d537SAndre Fischer } 74ff12d537SAndre Fischer 75ff12d537SAndre Fischer 76ff12d537SAndre Fischer 77ff12d537SAndre Fischer 78*b9e67834SAndre Fischer Theme::~Theme (void) 79ff12d537SAndre Fischer { 80ff12d537SAndre Fischer } 81ff12d537SAndre Fischer 82ff12d537SAndre Fischer 83ff12d537SAndre Fischer 84ff12d537SAndre Fischer 85*b9e67834SAndre Fischer Image Theme::GetImage (const ThemeItem eItem) 86ff12d537SAndre Fischer { 87*b9e67834SAndre Fischer const PropertyType eType (GetPropertyType(eItem)); 88*b9e67834SAndre Fischer OSL_ASSERT(eType==PT_Image); 89*b9e67834SAndre Fischer const sal_Int32 nIndex (GetIndex(eItem, eType)); 90*b9e67834SAndre Fischer const Theme& rTheme (GetCurrentTheme()); 91*b9e67834SAndre Fischer return rTheme.maImages[nIndex]; 92ff12d537SAndre Fischer } 93ff12d537SAndre Fischer 94ff12d537SAndre Fischer 95ff12d537SAndre Fischer 96ff12d537SAndre Fischer 97*b9e67834SAndre Fischer Color Theme::GetColor (const ThemeItem eItem) 98ff12d537SAndre Fischer { 99*b9e67834SAndre Fischer const PropertyType eType (GetPropertyType(eItem)); 100*b9e67834SAndre Fischer OSL_ASSERT(eType==PT_Color); 101*b9e67834SAndre Fischer const sal_Int32 nIndex (GetIndex(eItem, eType)); 102*b9e67834SAndre Fischer const Theme& rTheme (GetCurrentTheme()); 103*b9e67834SAndre Fischer return rTheme.maColors[nIndex]; 104ff12d537SAndre Fischer } 105ff12d537SAndre Fischer 106ff12d537SAndre Fischer 107ff12d537SAndre Fischer 108ff12d537SAndre Fischer 109*b9e67834SAndre Fischer const Paint& Theme::GetPaint (const ThemeItem eItem) 110ff12d537SAndre Fischer { 111*b9e67834SAndre Fischer const PropertyType eType (GetPropertyType(eItem)); 112*b9e67834SAndre Fischer OSL_ASSERT(eType==PT_Paint); 113*b9e67834SAndre Fischer const sal_Int32 nIndex (GetIndex(eItem, eType)); 114*b9e67834SAndre Fischer const Theme& rTheme (GetCurrentTheme()); 115*b9e67834SAndre Fischer return rTheme.maPaints[nIndex]; 116ff12d537SAndre Fischer } 117ff12d537SAndre Fischer 118ff12d537SAndre Fischer 119ff12d537SAndre Fischer 120ff12d537SAndre Fischer 121*b9e67834SAndre Fischer sal_Int32 Theme::GetInteger (const ThemeItem eItem) 122ff12d537SAndre Fischer { 123*b9e67834SAndre Fischer const PropertyType eType (GetPropertyType(eItem)); 124*b9e67834SAndre Fischer OSL_ASSERT(eType==PT_Integer); 125*b9e67834SAndre Fischer const sal_Int32 nIndex (GetIndex(eItem, eType)); 126*b9e67834SAndre Fischer const Theme& rTheme (GetCurrentTheme()); 127*b9e67834SAndre Fischer return rTheme.maIntegers[nIndex]; 128ff12d537SAndre Fischer } 129ff12d537SAndre Fischer 130ff12d537SAndre Fischer 131ff12d537SAndre Fischer 132ff12d537SAndre Fischer 133*b9e67834SAndre Fischer bool Theme::GetBoolean (const ThemeItem eItem) 134ff12d537SAndre Fischer { 135*b9e67834SAndre Fischer const PropertyType eType (GetPropertyType(eItem)); 136*b9e67834SAndre Fischer OSL_ASSERT(eType==PT_Boolean); 137*b9e67834SAndre Fischer const sal_Int32 nIndex (GetIndex(eItem, eType)); 138*b9e67834SAndre Fischer const Theme& rTheme (GetCurrentTheme()); 139*b9e67834SAndre Fischer return rTheme.maBooleans[nIndex]; 140ff12d537SAndre Fischer } 141ff12d537SAndre Fischer 142ff12d537SAndre Fischer 143ff12d537SAndre Fischer 144ff12d537SAndre Fischer 145ff12d537SAndre Fischer bool Theme::IsHighContrastMode (void) 146ff12d537SAndre Fischer { 147*b9e67834SAndre Fischer const Theme& rTheme (GetCurrentTheme()); 148*b9e67834SAndre Fischer return rTheme.mbIsHighContrastMode; 149ff12d537SAndre Fischer } 150ff12d537SAndre Fischer 151ff12d537SAndre Fischer 152ff12d537SAndre Fischer 153ff12d537SAndre Fischer 154ff12d537SAndre Fischer void Theme::HandleDataChange (void) 155ff12d537SAndre Fischer { 156*b9e67834SAndre Fischer GetCurrentTheme().mbIsHighContrastMode = Application::GetSettings().GetStyleSettings().GetHighContrastMode(); 157*b9e67834SAndre Fischer GetCurrentTheme().InitializeTheme(); 158ff12d537SAndre Fischer } 159ff12d537SAndre Fischer 160ff12d537SAndre Fischer 161ff12d537SAndre Fischer 162ff12d537SAndre Fischer 163*b9e67834SAndre Fischer void Theme::InitializeTheme (void) 164ff12d537SAndre Fischer { 165ff12d537SAndre Fischer SidebarResource aLocalResource; 166ff12d537SAndre Fischer 167*b9e67834SAndre Fischer try 168*b9e67834SAndre Fischer { 169*b9e67834SAndre Fischer setPropertyValue( 170*b9e67834SAndre Fischer maPropertyIdToNameMap[Paint_DeckBackground], 171*b9e67834SAndre Fischer Any(sal_Int32(mbIsHighContrastMode ? 0x000000 : 0xf0f0f0))); 172*b9e67834SAndre Fischer setPropertyValue( 173*b9e67834SAndre Fischer maPropertyIdToNameMap[Paint_DeckTitleBarBackground], 174*b9e67834SAndre Fischer Any(sal_Int32(mbIsHighContrastMode ? 0x000000 :0xf0f0f0))); 175*b9e67834SAndre Fischer setPropertyValue( 176*b9e67834SAndre Fischer maPropertyIdToNameMap[Int_DeckLeftPadding], 177*b9e67834SAndre Fischer Any(sal_Int32(2))); 178*b9e67834SAndre Fischer setPropertyValue( 179*b9e67834SAndre Fischer maPropertyIdToNameMap[Int_DeckTopPadding], 180*b9e67834SAndre Fischer Any(sal_Int32(2))); 181*b9e67834SAndre Fischer setPropertyValue( 182*b9e67834SAndre Fischer maPropertyIdToNameMap[Int_DeckRightPadding], 183*b9e67834SAndre Fischer Any(sal_Int32(2))); 184*b9e67834SAndre Fischer setPropertyValue( 185*b9e67834SAndre Fischer maPropertyIdToNameMap[Int_DeckBottomPadding], 186*b9e67834SAndre Fischer Any(sal_Int32(2))); 187*b9e67834SAndre Fischer setPropertyValue( 188*b9e67834SAndre Fischer maPropertyIdToNameMap[Int_DeckBorderSize], 189*b9e67834SAndre Fischer Any(sal_Int32(1))); 190*b9e67834SAndre Fischer setPropertyValue( 191*b9e67834SAndre Fischer maPropertyIdToNameMap[Int_DeckSeparatorHeight], 192*b9e67834SAndre Fischer Any(sal_Int32(1))); 193*b9e67834SAndre Fischer setPropertyValue( 194*b9e67834SAndre Fischer maPropertyIdToNameMap[Color_DeckTitleFont], 195*b9e67834SAndre Fischer Any(sal_Int32(mbIsHighContrastMode ? 0x00ff00 : 0x262626))); 196*b9e67834SAndre Fischer setPropertyValue( 197*b9e67834SAndre Fischer maPropertyIdToNameMap[Int_DeckTitleBarHeight], 198*b9e67834SAndre Fischer Any(sal_Int32(26))); 199ff12d537SAndre Fischer 200*b9e67834SAndre Fischer setPropertyValue( 201*b9e67834SAndre Fischer maPropertyIdToNameMap[Paint_PanelBackground], 202*b9e67834SAndre Fischer Any(sal_Int32(mbIsHighContrastMode ? 0x000000 : 0xffffff))); 203*b9e67834SAndre Fischer setPropertyValue( 204*b9e67834SAndre Fischer maPropertyIdToNameMap[Paint_PanelTitleBarBackground], 205*b9e67834SAndre Fischer Any(sal_Int32(mbIsHighContrastMode ? 0x000000 : 0xb2b2b2))); 206*b9e67834SAndre Fischer setPropertyValue( 207*b9e67834SAndre Fischer maPropertyIdToNameMap[Color_PanelTitleFont], 208*b9e67834SAndre Fischer Any(sal_Int32(mbIsHighContrastMode ? 0x00ff00 : 0x262626))); 209*b9e67834SAndre Fischer setPropertyValue( 210*b9e67834SAndre Fischer maPropertyIdToNameMap[Int_PanelTitleBarHeight], 211*b9e67834SAndre Fischer Any(sal_Int32(26))); 212ff12d537SAndre Fischer 213*b9e67834SAndre Fischer setPropertyValue( 214*b9e67834SAndre Fischer maPropertyIdToNameMap[Paint_TabBarBackground], 215*b9e67834SAndre Fischer Any(sal_Int32(mbIsHighContrastMode ? 0x000000 : 0xf0f0f0))); 216*b9e67834SAndre Fischer setPropertyValue( 217*b9e67834SAndre Fischer maPropertyIdToNameMap[Int_TabBarLeftPadding], 218*b9e67834SAndre Fischer Any(sal_Int32(2))); 219*b9e67834SAndre Fischer setPropertyValue( 220*b9e67834SAndre Fischer maPropertyIdToNameMap[Int_TabBarTopPadding], 221*b9e67834SAndre Fischer Any(sal_Int32(2))); 222*b9e67834SAndre Fischer setPropertyValue( 223*b9e67834SAndre Fischer maPropertyIdToNameMap[Int_TabBarRightPadding], 224*b9e67834SAndre Fischer Any(sal_Int32(2))); 225*b9e67834SAndre Fischer setPropertyValue( 226*b9e67834SAndre Fischer maPropertyIdToNameMap[Int_TabBarBottomPadding], 227*b9e67834SAndre Fischer Any(sal_Int32(2))); 228ff12d537SAndre Fischer 229*b9e67834SAndre Fischer setPropertyValue( 230*b9e67834SAndre Fischer maPropertyIdToNameMap[Int_TabMenuPadding], 231*b9e67834SAndre Fischer Any(sal_Int32(6))); 232*b9e67834SAndre Fischer setPropertyValue( 233*b9e67834SAndre Fischer maPropertyIdToNameMap[Color_TabMenuSeparator], 234*b9e67834SAndre Fischer Any(sal_Int32(mbIsHighContrastMode ? 0x00ff00 : 0xbfbfbf))); 235*b9e67834SAndre Fischer setPropertyValue( 236*b9e67834SAndre Fischer maPropertyIdToNameMap[Int_TabMenuSeparatorPadding], 237*b9e67834SAndre Fischer Any(sal_Int32(7))); 238ff12d537SAndre Fischer 239*b9e67834SAndre Fischer setPropertyValue( 240*b9e67834SAndre Fischer maPropertyIdToNameMap[Int_TabItemWidth], 241*b9e67834SAndre Fischer Any(sal_Int32(32))); 242*b9e67834SAndre Fischer setPropertyValue( 243*b9e67834SAndre Fischer maPropertyIdToNameMap[Int_TabItemHeight], 244*b9e67834SAndre Fischer Any(sal_Int32(32))); 245*b9e67834SAndre Fischer setPropertyValue( 246*b9e67834SAndre Fischer maPropertyIdToNameMap[Color_TabItemBorder], 247*b9e67834SAndre Fischer Any(sal_Int32(mbIsHighContrastMode ? 0x00ff00 : 0xbfbfbf))); 248*b9e67834SAndre Fischer setPropertyValue( 249*b9e67834SAndre Fischer maPropertyIdToNameMap[Paint_TabItemBackground], 250*b9e67834SAndre Fischer Any(sal_Int32(mbIsHighContrastMode ? 0x000000 : 0xffffff))); 251ff12d537SAndre Fischer 252*b9e67834SAndre Fischer setPropertyValue( 253*b9e67834SAndre Fischer maPropertyIdToNameMap[Paint_HorizontalBorder], 254*b9e67834SAndre Fischer Any(sal_Int32(mbIsHighContrastMode ? 0xff00ff000 : 0xd9d9d9))); 255*b9e67834SAndre Fischer setPropertyValue( 256*b9e67834SAndre Fischer maPropertyIdToNameMap[Paint_VerticalBorder], 257*b9e67834SAndre Fischer Any(sal_Int32(mbIsHighContrastMode ? 0xff00ff000 : 0xd9d9d9))); 258ff12d537SAndre Fischer 259*b9e67834SAndre Fischer setPropertyValue( 260*b9e67834SAndre Fischer maPropertyIdToNameMap[Image_Grip], 261*b9e67834SAndre Fischer Any( 262*b9e67834SAndre Fischer mbIsHighContrastMode 263*b9e67834SAndre Fischer ? A2S("private:graphicrepository/sfx2/res/grip_hc.png") 264*b9e67834SAndre Fischer : A2S("private:graphicrepository/sfx2/res/grip.png"))); 265*b9e67834SAndre Fischer setPropertyValue( 266*b9e67834SAndre Fischer maPropertyIdToNameMap[Image_Expand], 267*b9e67834SAndre Fischer Any( 268*b9e67834SAndre Fischer mbIsHighContrastMode 269*b9e67834SAndre Fischer ? A2S("private:graphicrepository/res/plus_sch.png") 270*b9e67834SAndre Fischer : A2S("private:graphicrepository/res/plus.png"))); 271*b9e67834SAndre Fischer setPropertyValue( 272*b9e67834SAndre Fischer maPropertyIdToNameMap[Image_Collapse], 273*b9e67834SAndre Fischer Any( 274*b9e67834SAndre Fischer mbIsHighContrastMode 275*b9e67834SAndre Fischer ? A2S("private:graphicrepository/res/minus_sch.png") 276*b9e67834SAndre Fischer : A2S("private:graphicrepository/res/minus.png"))); 277*b9e67834SAndre Fischer setPropertyValue( 278*b9e67834SAndre Fischer maPropertyIdToNameMap[Image_Menu], 279*b9e67834SAndre Fischer Any( 280*b9e67834SAndre Fischer mbIsHighContrastMode 281*b9e67834SAndre Fischer ? A2S("private:graphicrepository/sfx2/res/menu_ch.png") 282*b9e67834SAndre Fischer : A2S("private:graphicrepository/sfx2/res/menu.png"))); 283ff12d537SAndre Fischer 284*b9e67834SAndre Fischer setPropertyValue( 285*b9e67834SAndre Fischer maPropertyIdToNameMap[Bool_UseSymphonyIcons], 286*b9e67834SAndre Fischer Any(true)); 287ff12d537SAndre Fischer } 288*b9e67834SAndre Fischer catch(beans::UnknownPropertyException&) 289*b9e67834SAndre Fischer { 290*b9e67834SAndre Fischer OSL_ASSERT(false); 291*b9e67834SAndre Fischer } 292*b9e67834SAndre Fischer } 293*b9e67834SAndre Fischer 294*b9e67834SAndre Fischer 295*b9e67834SAndre Fischer 296*b9e67834SAndre Fischer 297*b9e67834SAndre Fischer void SAL_CALL Theme::disposing (void) 298*b9e67834SAndre Fischer { 299*b9e67834SAndre Fischer ChangeListeners aListeners; 300*b9e67834SAndre Fischer maChangeListeners.swap(aListeners); 301*b9e67834SAndre Fischer 302*b9e67834SAndre Fischer const lang::EventObject aEvent (static_cast<XWeak*>(this)); 303*b9e67834SAndre Fischer 304*b9e67834SAndre Fischer for (ChangeListeners::const_iterator 305*b9e67834SAndre Fischer iContainer(maChangeListeners.begin()), 306*b9e67834SAndre Fischer iContainerEnd(maChangeListeners.end()); 307*b9e67834SAndre Fischer iContainerEnd!=iContainerEnd; 308*b9e67834SAndre Fischer ++iContainerEnd) 309*b9e67834SAndre Fischer { 310*b9e67834SAndre Fischer for (ChangeListenerContainer::const_iterator 311*b9e67834SAndre Fischer iListener(iContainer->second.begin()), 312*b9e67834SAndre Fischer iEnd(iContainer->second.end()); 313*b9e67834SAndre Fischer iListener!=iEnd; 314*b9e67834SAndre Fischer ++iListener) 315*b9e67834SAndre Fischer { 316*b9e67834SAndre Fischer try 317*b9e67834SAndre Fischer { 318*b9e67834SAndre Fischer (*iListener)->disposing(aEvent); 319*b9e67834SAndre Fischer } 320*b9e67834SAndre Fischer catch(const Exception&) 321*b9e67834SAndre Fischer { 322*b9e67834SAndre Fischer } 323*b9e67834SAndre Fischer } 324*b9e67834SAndre Fischer } 325*b9e67834SAndre Fischer } 326*b9e67834SAndre Fischer 327*b9e67834SAndre Fischer 328*b9e67834SAndre Fischer 329*b9e67834SAndre Fischer 330*b9e67834SAndre Fischer Reference<beans::XPropertySet> Theme::GetPropertySet (void) 331*b9e67834SAndre Fischer { 332*b9e67834SAndre Fischer return Reference<beans::XPropertySet>(static_cast<XWeak*>(&GetCurrentTheme()), UNO_QUERY); 333*b9e67834SAndre Fischer } 334*b9e67834SAndre Fischer 335*b9e67834SAndre Fischer 336*b9e67834SAndre Fischer 337*b9e67834SAndre Fischer 338*b9e67834SAndre Fischer Reference<beans::XPropertySetInfo> SAL_CALL Theme::getPropertySetInfo (void) 339*b9e67834SAndre Fischer throw(cssu::RuntimeException) 340*b9e67834SAndre Fischer { 341*b9e67834SAndre Fischer return Reference<beans::XPropertySetInfo>(); 342*b9e67834SAndre Fischer } 343*b9e67834SAndre Fischer 344*b9e67834SAndre Fischer 345*b9e67834SAndre Fischer 346*b9e67834SAndre Fischer 347*b9e67834SAndre Fischer void SAL_CALL Theme::setPropertyValue ( 348*b9e67834SAndre Fischer const ::rtl::OUString& rsPropertyName, 349*b9e67834SAndre Fischer const cssu::Any& rValue) 350*b9e67834SAndre Fischer throw(cssu::RuntimeException) 351*b9e67834SAndre Fischer { 352*b9e67834SAndre Fischer PropertyNameToIdMap::const_iterator iId (maPropertyNameToIdMap.find(rsPropertyName)); 353*b9e67834SAndre Fischer if (iId == maPropertyNameToIdMap.end()) 354*b9e67834SAndre Fischer throw beans::UnknownPropertyException(); 355*b9e67834SAndre Fischer 356*b9e67834SAndre Fischer const PropertyType eType (GetPropertyType(iId->second)); 357*b9e67834SAndre Fischer if (eType == PT_Invalid) 358*b9e67834SAndre Fischer throw beans::UnknownPropertyException(); 359*b9e67834SAndre Fischer 360*b9e67834SAndre Fischer const ThemeItem eItem (iId->second); 361*b9e67834SAndre Fischer 362*b9e67834SAndre Fischer if (rValue == maRawValues[eItem]) 363*b9e67834SAndre Fischer { 364*b9e67834SAndre Fischer // Value is not different from the one in the property 365*b9e67834SAndre Fischer // set => nothing to do. 366*b9e67834SAndre Fischer return; 367*b9e67834SAndre Fischer } 368*b9e67834SAndre Fischer 369*b9e67834SAndre Fischer const Any aOldValue (maRawValues[eItem]); 370*b9e67834SAndre Fischer 371*b9e67834SAndre Fischer const beans::PropertyChangeEvent aEvent( 372*b9e67834SAndre Fischer static_cast<XWeak*>(this), 373*b9e67834SAndre Fischer rsPropertyName, 374*b9e67834SAndre Fischer sal_False, 375*b9e67834SAndre Fischer eItem, 376*b9e67834SAndre Fischer aOldValue, 377*b9e67834SAndre Fischer rValue); 378*b9e67834SAndre Fischer 379*b9e67834SAndre Fischer if (DoVetoableListenersVeto(GetVetoableListeners(__AnyItem, false), aEvent)) 380*b9e67834SAndre Fischer return; 381*b9e67834SAndre Fischer if (DoVetoableListenersVeto(GetVetoableListeners(eItem, false), aEvent)) 382*b9e67834SAndre Fischer return; 383*b9e67834SAndre Fischer 384*b9e67834SAndre Fischer maRawValues[eItem] = rValue; 385*b9e67834SAndre Fischer ProcessNewValue(rValue, eItem, eType); 386*b9e67834SAndre Fischer 387*b9e67834SAndre Fischer BroadcastPropertyChange(GetChangeListeners(__AnyItem, false), aEvent); 388*b9e67834SAndre Fischer BroadcastPropertyChange(GetChangeListeners(eItem, false), aEvent); 389*b9e67834SAndre Fischer } 390*b9e67834SAndre Fischer 391*b9e67834SAndre Fischer 392*b9e67834SAndre Fischer 393*b9e67834SAndre Fischer 394*b9e67834SAndre Fischer Any SAL_CALL Theme::getPropertyValue ( 395*b9e67834SAndre Fischer const ::rtl::OUString& rsPropertyName) 396*b9e67834SAndre Fischer throw(css::beans::UnknownPropertyException, 397*b9e67834SAndre Fischer css::lang::WrappedTargetException, 398*b9e67834SAndre Fischer cssu::RuntimeException) 399*b9e67834SAndre Fischer { 400*b9e67834SAndre Fischer PropertyNameToIdMap::const_iterator iId (maPropertyNameToIdMap.find(rsPropertyName)); 401*b9e67834SAndre Fischer if (iId == maPropertyNameToIdMap.end()) 402*b9e67834SAndre Fischer throw beans::UnknownPropertyException(); 403*b9e67834SAndre Fischer 404*b9e67834SAndre Fischer const PropertyType eType (GetPropertyType(iId->second)); 405*b9e67834SAndre Fischer if (eType == PT_Invalid) 406*b9e67834SAndre Fischer throw beans::UnknownPropertyException(); 407*b9e67834SAndre Fischer 408*b9e67834SAndre Fischer const ThemeItem eItem (iId->second); 409*b9e67834SAndre Fischer 410*b9e67834SAndre Fischer return maRawValues[eItem]; 411*b9e67834SAndre Fischer } 412*b9e67834SAndre Fischer 413*b9e67834SAndre Fischer 414*b9e67834SAndre Fischer 415*b9e67834SAndre Fischer 416*b9e67834SAndre Fischer void SAL_CALL Theme::addPropertyChangeListener( 417*b9e67834SAndre Fischer const ::rtl::OUString& rsPropertyName, 418*b9e67834SAndre Fischer const cssu::Reference<css::beans::XPropertyChangeListener>& rxListener) 419*b9e67834SAndre Fischer throw(css::beans::UnknownPropertyException, 420*b9e67834SAndre Fischer css::lang::WrappedTargetException, 421*b9e67834SAndre Fischer cssu::RuntimeException) 422*b9e67834SAndre Fischer { 423*b9e67834SAndre Fischer ThemeItem eItem (__AnyItem); 424*b9e67834SAndre Fischer if (rsPropertyName.getLength() > 0) 425*b9e67834SAndre Fischer { 426*b9e67834SAndre Fischer PropertyNameToIdMap::const_iterator iId (maPropertyNameToIdMap.find(rsPropertyName)); 427*b9e67834SAndre Fischer if (iId == maPropertyNameToIdMap.end()) 428*b9e67834SAndre Fischer throw beans::UnknownPropertyException(); 429*b9e67834SAndre Fischer 430*b9e67834SAndre Fischer const PropertyType eType (GetPropertyType(iId->second)); 431*b9e67834SAndre Fischer if (eType == PT_Invalid) 432*b9e67834SAndre Fischer throw beans::UnknownPropertyException(); 433*b9e67834SAndre Fischer 434*b9e67834SAndre Fischer eItem = iId->second; 435*b9e67834SAndre Fischer } 436*b9e67834SAndre Fischer ChangeListenerContainer* pListeners = GetChangeListeners(eItem, true); 437*b9e67834SAndre Fischer if (pListeners != NULL) 438*b9e67834SAndre Fischer pListeners->push_back(rxListener); 439*b9e67834SAndre Fischer } 440*b9e67834SAndre Fischer 441*b9e67834SAndre Fischer 442*b9e67834SAndre Fischer 443*b9e67834SAndre Fischer 444*b9e67834SAndre Fischer void SAL_CALL Theme::removePropertyChangeListener( 445*b9e67834SAndre Fischer const ::rtl::OUString& rsPropertyName, 446*b9e67834SAndre Fischer const cssu::Reference<css::beans::XPropertyChangeListener>& rxListener) 447*b9e67834SAndre Fischer throw(css::beans::UnknownPropertyException, 448*b9e67834SAndre Fischer css::lang::WrappedTargetException, 449*b9e67834SAndre Fischer cssu::RuntimeException) 450*b9e67834SAndre Fischer { 451*b9e67834SAndre Fischer ThemeItem eItem (__AnyItem); 452*b9e67834SAndre Fischer if (rsPropertyName.getLength() > 0) 453*b9e67834SAndre Fischer { 454*b9e67834SAndre Fischer PropertyNameToIdMap::const_iterator iId (maPropertyNameToIdMap.find(rsPropertyName)); 455*b9e67834SAndre Fischer if (iId == maPropertyNameToIdMap.end()) 456*b9e67834SAndre Fischer throw beans::UnknownPropertyException(); 457*b9e67834SAndre Fischer 458*b9e67834SAndre Fischer const PropertyType eType (GetPropertyType(iId->second)); 459*b9e67834SAndre Fischer if (eType == PT_Invalid) 460*b9e67834SAndre Fischer throw beans::UnknownPropertyException(); 461*b9e67834SAndre Fischer 462*b9e67834SAndre Fischer eItem = iId->second; 463*b9e67834SAndre Fischer } 464*b9e67834SAndre Fischer ChangeListenerContainer* pContainer = GetChangeListeners(eItem, false); 465*b9e67834SAndre Fischer if (pContainer != NULL) 466*b9e67834SAndre Fischer { 467*b9e67834SAndre Fischer ChangeListenerContainer::iterator iListener (::std::find(pContainer->begin(), pContainer->end(), rxListener)); 468*b9e67834SAndre Fischer if (iListener != pContainer->end()) 469*b9e67834SAndre Fischer { 470*b9e67834SAndre Fischer pContainer->erase(iListener); 471*b9e67834SAndre Fischer 472*b9e67834SAndre Fischer // Remove the listener container when empty. 473*b9e67834SAndre Fischer if (pContainer->empty()) 474*b9e67834SAndre Fischer maChangeListeners.erase(eItem); 475*b9e67834SAndre Fischer } 476*b9e67834SAndre Fischer } 477*b9e67834SAndre Fischer } 478*b9e67834SAndre Fischer 479*b9e67834SAndre Fischer 480*b9e67834SAndre Fischer 481*b9e67834SAndre Fischer 482*b9e67834SAndre Fischer void SAL_CALL Theme::addVetoableChangeListener( 483*b9e67834SAndre Fischer const ::rtl::OUString& rsPropertyName, 484*b9e67834SAndre Fischer const cssu::Reference<css::beans::XVetoableChangeListener>& rxListener) 485*b9e67834SAndre Fischer throw(css::beans::UnknownPropertyException, 486*b9e67834SAndre Fischer css::lang::WrappedTargetException, 487*b9e67834SAndre Fischer cssu::RuntimeException) 488*b9e67834SAndre Fischer { 489*b9e67834SAndre Fischer ThemeItem eItem (__AnyItem); 490*b9e67834SAndre Fischer if (rsPropertyName.getLength() > 0) 491*b9e67834SAndre Fischer { 492*b9e67834SAndre Fischer PropertyNameToIdMap::const_iterator iId (maPropertyNameToIdMap.find(rsPropertyName)); 493*b9e67834SAndre Fischer if (iId == maPropertyNameToIdMap.end()) 494*b9e67834SAndre Fischer throw beans::UnknownPropertyException(); 495*b9e67834SAndre Fischer 496*b9e67834SAndre Fischer const PropertyType eType (GetPropertyType(iId->second)); 497*b9e67834SAndre Fischer if (eType == PT_Invalid) 498*b9e67834SAndre Fischer throw beans::UnknownPropertyException(); 499*b9e67834SAndre Fischer 500*b9e67834SAndre Fischer eItem = iId->second; 501*b9e67834SAndre Fischer } 502*b9e67834SAndre Fischer VetoableListenerContainer* pListeners = GetVetoableListeners(eItem, true); 503*b9e67834SAndre Fischer if (pListeners != NULL) 504*b9e67834SAndre Fischer pListeners->push_back(rxListener); 505*b9e67834SAndre Fischer } 506*b9e67834SAndre Fischer 507*b9e67834SAndre Fischer 508*b9e67834SAndre Fischer 509*b9e67834SAndre Fischer 510*b9e67834SAndre Fischer void SAL_CALL Theme::removeVetoableChangeListener( 511*b9e67834SAndre Fischer const ::rtl::OUString& rsPropertyName, 512*b9e67834SAndre Fischer const cssu::Reference<css::beans::XVetoableChangeListener>& rxListener) 513*b9e67834SAndre Fischer throw(css::beans::UnknownPropertyException, 514*b9e67834SAndre Fischer css::lang::WrappedTargetException, 515*b9e67834SAndre Fischer cssu::RuntimeException) 516*b9e67834SAndre Fischer { 517*b9e67834SAndre Fischer ThemeItem eItem (__AnyItem); 518*b9e67834SAndre Fischer if (rsPropertyName.getLength() > 0) 519*b9e67834SAndre Fischer { 520*b9e67834SAndre Fischer PropertyNameToIdMap::const_iterator iId (maPropertyNameToIdMap.find(rsPropertyName)); 521*b9e67834SAndre Fischer if (iId == maPropertyNameToIdMap.end()) 522*b9e67834SAndre Fischer throw beans::UnknownPropertyException(); 523*b9e67834SAndre Fischer 524*b9e67834SAndre Fischer const PropertyType eType (GetPropertyType(iId->second)); 525*b9e67834SAndre Fischer if (eType == PT_Invalid) 526*b9e67834SAndre Fischer throw beans::UnknownPropertyException(); 527*b9e67834SAndre Fischer 528*b9e67834SAndre Fischer eItem = iId->second; 529*b9e67834SAndre Fischer } 530*b9e67834SAndre Fischer VetoableListenerContainer* pContainer = GetVetoableListeners(eItem, false); 531*b9e67834SAndre Fischer if (pContainer != NULL) 532*b9e67834SAndre Fischer { 533*b9e67834SAndre Fischer VetoableListenerContainer::iterator iListener (::std::find(pContainer->begin(), pContainer->end(), rxListener)); 534*b9e67834SAndre Fischer if (iListener != pContainer->end()) 535*b9e67834SAndre Fischer { 536*b9e67834SAndre Fischer pContainer->erase(iListener); 537*b9e67834SAndre Fischer // Remove container when empty. 538*b9e67834SAndre Fischer if (pContainer->empty()) 539*b9e67834SAndre Fischer maVetoableListeners.erase(eItem); 540*b9e67834SAndre Fischer } 541*b9e67834SAndre Fischer } 542*b9e67834SAndre Fischer } 543*b9e67834SAndre Fischer 544*b9e67834SAndre Fischer 545*b9e67834SAndre Fischer 546*b9e67834SAndre Fischer 547*b9e67834SAndre Fischer void Theme::SetupPropertyMaps (void) 548*b9e67834SAndre Fischer { 549*b9e67834SAndre Fischer maPropertyIdToNameMap.resize(__Post_Bool); 550*b9e67834SAndre Fischer maImages.resize(__Image_Color - __Pre_Image - 1); 551*b9e67834SAndre Fischer maColors.resize(__Color_Paint - __Image_Color - 1); 552*b9e67834SAndre Fischer maPaints.resize(__Paint_Int - __Color_Paint - 1); 553*b9e67834SAndre Fischer maIntegers.resize(__Int_Bool - __Paint_Int - 1); 554*b9e67834SAndre Fischer maBooleans.resize(__Post_Bool - __Int_Bool - 1); 555*b9e67834SAndre Fischer 556*b9e67834SAndre Fischer #define AddEntry(e) maPropertyNameToIdMap[A2S(#e)]=e; maPropertyIdToNameMap[e]=A2S(#e) 557*b9e67834SAndre Fischer AddEntry(Image_Grip); 558*b9e67834SAndre Fischer AddEntry(Image_Expand); 559*b9e67834SAndre Fischer AddEntry(Image_Collapse); 560*b9e67834SAndre Fischer AddEntry(Image_Menu); 561*b9e67834SAndre Fischer 562*b9e67834SAndre Fischer AddEntry(Color_DeckTitleFont); 563*b9e67834SAndre Fischer AddEntry(Color_PanelTitleFont); 564*b9e67834SAndre Fischer AddEntry(Color_TabMenuSeparator); 565*b9e67834SAndre Fischer AddEntry(Color_TabItemBorder); 566*b9e67834SAndre Fischer 567*b9e67834SAndre Fischer AddEntry(Paint_DeckBackground); 568*b9e67834SAndre Fischer AddEntry(Paint_DeckTitleBarBackground); 569*b9e67834SAndre Fischer AddEntry(Paint_PanelBackground); 570*b9e67834SAndre Fischer AddEntry(Paint_PanelTitleBarBackground); 571*b9e67834SAndre Fischer AddEntry(Paint_TabBarBackground); 572*b9e67834SAndre Fischer AddEntry(Paint_TabItemBackground); 573*b9e67834SAndre Fischer AddEntry(Paint_HorizontalBorder); 574*b9e67834SAndre Fischer AddEntry(Paint_VerticalBorder); 575*b9e67834SAndre Fischer 576*b9e67834SAndre Fischer AddEntry(Int_DeckTitleBarHeight); 577*b9e67834SAndre Fischer AddEntry(Int_DeckBorderSize); 578*b9e67834SAndre Fischer AddEntry(Int_DeckSeparatorHeight); 579*b9e67834SAndre Fischer AddEntry(Int_PanelTitleBarHeight); 580*b9e67834SAndre Fischer AddEntry(Int_TabMenuPadding); 581*b9e67834SAndre Fischer AddEntry(Int_TabMenuSeparatorPadding); 582*b9e67834SAndre Fischer AddEntry(Int_TabItemWidth); 583*b9e67834SAndre Fischer AddEntry(Int_TabItemHeight); 584*b9e67834SAndre Fischer AddEntry(Int_DeckLeftPadding); 585*b9e67834SAndre Fischer AddEntry(Int_DeckTopPadding); 586*b9e67834SAndre Fischer AddEntry(Int_DeckRightPadding); 587*b9e67834SAndre Fischer AddEntry(Int_DeckBottomPadding); 588*b9e67834SAndre Fischer AddEntry(Int_TabBarLeftPadding); 589*b9e67834SAndre Fischer AddEntry(Int_TabBarTopPadding); 590*b9e67834SAndre Fischer AddEntry(Int_TabBarRightPadding); 591*b9e67834SAndre Fischer AddEntry(Int_TabBarBottomPadding); 592*b9e67834SAndre Fischer 593*b9e67834SAndre Fischer AddEntry(Bool_UseSymphonyIcons); 594*b9e67834SAndre Fischer #undef AddEntry 595*b9e67834SAndre Fischer 596*b9e67834SAndre Fischer maRawValues.resize(maPropertyIdToNameMap.size()); 597*b9e67834SAndre Fischer } 598*b9e67834SAndre Fischer 599*b9e67834SAndre Fischer 600*b9e67834SAndre Fischer 601*b9e67834SAndre Fischer 602*b9e67834SAndre Fischer Theme::PropertyType Theme::GetPropertyType (const ThemeItem eItem) 603*b9e67834SAndre Fischer { 604*b9e67834SAndre Fischer switch(eItem) 605*b9e67834SAndre Fischer { 606*b9e67834SAndre Fischer case Image_Grip: 607*b9e67834SAndre Fischer case Image_Expand: 608*b9e67834SAndre Fischer case Image_Collapse: 609*b9e67834SAndre Fischer case Image_Menu: 610*b9e67834SAndre Fischer return PT_Image; 611*b9e67834SAndre Fischer 612*b9e67834SAndre Fischer case Color_DeckTitleFont: 613*b9e67834SAndre Fischer case Color_PanelTitleFont: 614*b9e67834SAndre Fischer case Color_TabMenuSeparator: 615*b9e67834SAndre Fischer case Color_TabItemBorder: 616*b9e67834SAndre Fischer return PT_Color; 617*b9e67834SAndre Fischer 618*b9e67834SAndre Fischer case Paint_DeckBackground: 619*b9e67834SAndre Fischer case Paint_DeckTitleBarBackground: 620*b9e67834SAndre Fischer case Paint_PanelBackground: 621*b9e67834SAndre Fischer case Paint_PanelTitleBarBackground: 622*b9e67834SAndre Fischer case Paint_TabBarBackground: 623*b9e67834SAndre Fischer case Paint_TabItemBackground: 624*b9e67834SAndre Fischer case Paint_HorizontalBorder: 625*b9e67834SAndre Fischer case Paint_VerticalBorder: 626*b9e67834SAndre Fischer return PT_Paint; 627*b9e67834SAndre Fischer 628*b9e67834SAndre Fischer case Int_DeckTitleBarHeight: 629*b9e67834SAndre Fischer case Int_DeckBorderSize: 630*b9e67834SAndre Fischer case Int_DeckSeparatorHeight: 631*b9e67834SAndre Fischer case Int_PanelTitleBarHeight: 632*b9e67834SAndre Fischer case Int_TabMenuPadding: 633*b9e67834SAndre Fischer case Int_TabMenuSeparatorPadding: 634*b9e67834SAndre Fischer case Int_TabItemWidth: 635*b9e67834SAndre Fischer case Int_TabItemHeight: 636*b9e67834SAndre Fischer case Int_DeckLeftPadding: 637*b9e67834SAndre Fischer case Int_DeckTopPadding: 638*b9e67834SAndre Fischer case Int_DeckRightPadding: 639*b9e67834SAndre Fischer case Int_DeckBottomPadding: 640*b9e67834SAndre Fischer case Int_TabBarLeftPadding: 641*b9e67834SAndre Fischer case Int_TabBarTopPadding: 642*b9e67834SAndre Fischer case Int_TabBarRightPadding: 643*b9e67834SAndre Fischer case Int_TabBarBottomPadding: 644*b9e67834SAndre Fischer return PT_Integer; 645*b9e67834SAndre Fischer 646*b9e67834SAndre Fischer case Bool_UseSymphonyIcons: 647*b9e67834SAndre Fischer return PT_Boolean; 648*b9e67834SAndre Fischer 649*b9e67834SAndre Fischer default: 650*b9e67834SAndre Fischer return PT_Invalid; 651*b9e67834SAndre Fischer } 652*b9e67834SAndre Fischer } 653*b9e67834SAndre Fischer 654*b9e67834SAndre Fischer 655*b9e67834SAndre Fischer 656*b9e67834SAndre Fischer 657*b9e67834SAndre Fischer sal_Int32 Theme::GetIndex (const ThemeItem eItem, const PropertyType eType) 658*b9e67834SAndre Fischer { 659*b9e67834SAndre Fischer switch(eType) 660*b9e67834SAndre Fischer { 661*b9e67834SAndre Fischer case PT_Image: 662*b9e67834SAndre Fischer return eItem - __Pre_Image-1; 663*b9e67834SAndre Fischer case PT_Color: 664*b9e67834SAndre Fischer return eItem - __Image_Color-1; 665*b9e67834SAndre Fischer case PT_Paint: 666*b9e67834SAndre Fischer return eItem - __Color_Paint-1; 667*b9e67834SAndre Fischer case PT_Integer: 668*b9e67834SAndre Fischer return eItem - __Paint_Int-1; 669*b9e67834SAndre Fischer case PT_Boolean: 670*b9e67834SAndre Fischer return eItem - __Int_Bool-1; 671*b9e67834SAndre Fischer 672*b9e67834SAndre Fischer default: 673*b9e67834SAndre Fischer OSL_ASSERT(false); 674*b9e67834SAndre Fischer return 0; 675*b9e67834SAndre Fischer } 676*b9e67834SAndre Fischer } 677*b9e67834SAndre Fischer 678*b9e67834SAndre Fischer 679*b9e67834SAndre Fischer 680*b9e67834SAndre Fischer 681*b9e67834SAndre Fischer Theme::VetoableListenerContainer* Theme::GetVetoableListeners ( 682*b9e67834SAndre Fischer const ThemeItem eItem, 683*b9e67834SAndre Fischer const bool bCreate) 684*b9e67834SAndre Fischer { 685*b9e67834SAndre Fischer VetoableListeners::iterator iContainer (maVetoableListeners.find(eItem)); 686*b9e67834SAndre Fischer if (iContainer != maVetoableListeners.end()) 687*b9e67834SAndre Fischer return &iContainer->second; 688*b9e67834SAndre Fischer else if (bCreate) 689*b9e67834SAndre Fischer { 690*b9e67834SAndre Fischer maVetoableListeners[eItem] = VetoableListenerContainer(); 691*b9e67834SAndre Fischer return &maVetoableListeners[eItem]; 692*b9e67834SAndre Fischer } 693*b9e67834SAndre Fischer else 694*b9e67834SAndre Fischer return NULL; 695*b9e67834SAndre Fischer } 696*b9e67834SAndre Fischer 697*b9e67834SAndre Fischer 698*b9e67834SAndre Fischer 699*b9e67834SAndre Fischer 700*b9e67834SAndre Fischer Theme::ChangeListenerContainer* Theme::GetChangeListeners ( 701*b9e67834SAndre Fischer const ThemeItem eItem, 702*b9e67834SAndre Fischer const bool bCreate) 703*b9e67834SAndre Fischer { 704*b9e67834SAndre Fischer ChangeListeners::iterator iContainer (maChangeListeners.find(eItem)); 705*b9e67834SAndre Fischer if (iContainer != maChangeListeners.end()) 706*b9e67834SAndre Fischer return &iContainer->second; 707*b9e67834SAndre Fischer else if (bCreate) 708*b9e67834SAndre Fischer { 709*b9e67834SAndre Fischer maChangeListeners[eItem] = ChangeListenerContainer(); 710*b9e67834SAndre Fischer return &maChangeListeners[eItem]; 711*b9e67834SAndre Fischer } 712*b9e67834SAndre Fischer else 713*b9e67834SAndre Fischer return NULL; 714*b9e67834SAndre Fischer } 715*b9e67834SAndre Fischer 716*b9e67834SAndre Fischer 717*b9e67834SAndre Fischer 718*b9e67834SAndre Fischer 719*b9e67834SAndre Fischer bool Theme::DoVetoableListenersVeto ( 720*b9e67834SAndre Fischer const VetoableListenerContainer* pListeners, 721*b9e67834SAndre Fischer const beans::PropertyChangeEvent& rEvent) const 722*b9e67834SAndre Fischer { 723*b9e67834SAndre Fischer if (pListeners == NULL) 724*b9e67834SAndre Fischer return false; 725*b9e67834SAndre Fischer 726*b9e67834SAndre Fischer VetoableListenerContainer aListeners (*pListeners); 727*b9e67834SAndre Fischer try 728*b9e67834SAndre Fischer { 729*b9e67834SAndre Fischer for (VetoableListenerContainer::const_iterator 730*b9e67834SAndre Fischer iListener(aListeners.begin()), 731*b9e67834SAndre Fischer iEnd(aListeners.end()); 732*b9e67834SAndre Fischer iListener!=iEnd; 733*b9e67834SAndre Fischer ++iListener) 734*b9e67834SAndre Fischer { 735*b9e67834SAndre Fischer (*iListener)->vetoableChange(rEvent); 736*b9e67834SAndre Fischer } 737*b9e67834SAndre Fischer } 738*b9e67834SAndre Fischer catch(const beans::PropertyVetoException&) 739*b9e67834SAndre Fischer { 740*b9e67834SAndre Fischer return true; 741*b9e67834SAndre Fischer } 742*b9e67834SAndre Fischer catch(const Exception&) 743*b9e67834SAndre Fischer { 744*b9e67834SAndre Fischer // Ignore any other errors (such as disposed listeners). 745*b9e67834SAndre Fischer } 746*b9e67834SAndre Fischer return false; 747*b9e67834SAndre Fischer } 748*b9e67834SAndre Fischer 749*b9e67834SAndre Fischer 750*b9e67834SAndre Fischer 751*b9e67834SAndre Fischer 752*b9e67834SAndre Fischer void Theme::BroadcastPropertyChange ( 753*b9e67834SAndre Fischer const ChangeListenerContainer* pListeners, 754*b9e67834SAndre Fischer const beans::PropertyChangeEvent& rEvent) const 755*b9e67834SAndre Fischer { 756*b9e67834SAndre Fischer if (pListeners == NULL) 757*b9e67834SAndre Fischer return; 758*b9e67834SAndre Fischer 759*b9e67834SAndre Fischer const ChangeListenerContainer aListeners (*pListeners); 760*b9e67834SAndre Fischer try 761*b9e67834SAndre Fischer { 762*b9e67834SAndre Fischer for (ChangeListenerContainer::const_iterator 763*b9e67834SAndre Fischer iListener(aListeners.begin()), 764*b9e67834SAndre Fischer iEnd(aListeners.end()); 765*b9e67834SAndre Fischer iListener!=iEnd; 766*b9e67834SAndre Fischer ++iListener) 767*b9e67834SAndre Fischer { 768*b9e67834SAndre Fischer (*iListener)->propertyChange(rEvent); 769*b9e67834SAndre Fischer } 770*b9e67834SAndre Fischer } 771*b9e67834SAndre Fischer catch(const Exception&) 772*b9e67834SAndre Fischer { 773*b9e67834SAndre Fischer // Ignore any errors (such as disposed listeners). 774*b9e67834SAndre Fischer } 775*b9e67834SAndre Fischer } 776*b9e67834SAndre Fischer 777*b9e67834SAndre Fischer 778*b9e67834SAndre Fischer 779*b9e67834SAndre Fischer 780*b9e67834SAndre Fischer void Theme::ProcessNewValue ( 781*b9e67834SAndre Fischer const Any& rValue, 782*b9e67834SAndre Fischer const ThemeItem eItem, 783*b9e67834SAndre Fischer const PropertyType eType) 784*b9e67834SAndre Fischer { 785*b9e67834SAndre Fischer const sal_Int32 nIndex (GetIndex (eItem, eType)); 786*b9e67834SAndre Fischer switch (eType) 787*b9e67834SAndre Fischer { 788*b9e67834SAndre Fischer case PT_Image: 789*b9e67834SAndre Fischer { 790*b9e67834SAndre Fischer ::rtl::OUString sURL; 791*b9e67834SAndre Fischer if (rValue >>= sURL) 792*b9e67834SAndre Fischer { 793*b9e67834SAndre Fischer maImages[nIndex] = Tools::GetImage(sURL, NULL); 794*b9e67834SAndre Fischer } 795*b9e67834SAndre Fischer break; 796*b9e67834SAndre Fischer } 797*b9e67834SAndre Fischer case PT_Color: 798*b9e67834SAndre Fischer { 799*b9e67834SAndre Fischer sal_Int32 nColorValue; 800*b9e67834SAndre Fischer if (rValue >>= nColorValue) 801*b9e67834SAndre Fischer { 802*b9e67834SAndre Fischer maColors[nIndex] = Color(nColorValue); 803*b9e67834SAndre Fischer } 804*b9e67834SAndre Fischer break; 805*b9e67834SAndre Fischer } 806*b9e67834SAndre Fischer case PT_Paint: 807*b9e67834SAndre Fischer { 808*b9e67834SAndre Fischer sal_Int32 nColorValue; 809*b9e67834SAndre Fischer if (rValue >>= nColorValue) 810*b9e67834SAndre Fischer { 811*b9e67834SAndre Fischer maPaints[nIndex] = Paint(Color(nColorValue)); 812*b9e67834SAndre Fischer } 813*b9e67834SAndre Fischer break; 814*b9e67834SAndre Fischer } 815*b9e67834SAndre Fischer case PT_Integer: 816*b9e67834SAndre Fischer { 817*b9e67834SAndre Fischer sal_Int32 nValue; 818*b9e67834SAndre Fischer if (rValue >>= nValue) 819*b9e67834SAndre Fischer { 820*b9e67834SAndre Fischer maIntegers[nIndex] = nValue; 821*b9e67834SAndre Fischer } 822*b9e67834SAndre Fischer break; 823*b9e67834SAndre Fischer } 824*b9e67834SAndre Fischer case PT_Boolean: 825*b9e67834SAndre Fischer { 826*b9e67834SAndre Fischer sal_Bool nValue; 827*b9e67834SAndre Fischer if (rValue >>= nValue) 828*b9e67834SAndre Fischer { 829*b9e67834SAndre Fischer maBooleans[nIndex] = (nValue==sal_True); 830*b9e67834SAndre Fischer } 831*b9e67834SAndre Fischer break; 832*b9e67834SAndre Fischer } 833*b9e67834SAndre Fischer case PT_Invalid: 834*b9e67834SAndre Fischer OSL_ASSERT(eType != PT_Invalid); 835*b9e67834SAndre Fischer throw RuntimeException(); 836*b9e67834SAndre Fischer } 837*b9e67834SAndre Fischer } 838*b9e67834SAndre Fischer 839*b9e67834SAndre Fischer 840*b9e67834SAndre Fischer 841ff12d537SAndre Fischer 842ff12d537SAndre Fischer } } // end of namespace sfx2::sidebar 843