2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 #include "sfx2/sidebar/Theme.hxx"
20 #include "SidebarResource.hxx"
21 #include "sfx2/sidebar/Tools.hxx"
23 #include <tools/svborder.hxx>
24 #include <tools/rc.hxx>
25 #include <vcl/svapp.hxx>
31 namespace sfx2
{ namespace sidebar
{
33 ::rtl::Reference
<Theme
> Theme::mpInstance
;
38 Theme
& Theme::GetCurrentTheme (void)
40 if ( ! mpInstance
.is())
42 mpInstance
.set(new Theme());
43 mpInstance
->InitializeTheme();
52 : ThemeInterfaceBase(m_aMutex
),
58 mbIsHighContrastMode(Application::GetSettings().GetStyleSettings().GetHighContrastMode()),
59 mbIsHighContrastModeSetManually(false),
60 maPropertyNameToIdMap(),
61 maPropertyIdToNameMap(),
80 Image
Theme::GetImage (const ThemeItem eItem
)
82 const PropertyType
eType (GetPropertyType(eItem
));
83 OSL_ASSERT(eType
==PT_Image
);
84 const sal_Int32
nIndex (GetIndex(eItem
, eType
));
85 const Theme
& rTheme (GetCurrentTheme());
86 return rTheme
.maImages
[nIndex
];
92 Color
Theme::GetColor (const ThemeItem eItem
)
94 const PropertyType
eType (GetPropertyType(eItem
));
95 OSL_ASSERT(eType
==PT_Color
|| eType
==PT_Paint
);
96 const sal_Int32
nIndex (GetIndex(eItem
, eType
));
97 const Theme
& rTheme (GetCurrentTheme());
98 if (eType
== PT_Color
)
99 return rTheme
.maColors
[nIndex
];
100 else if (eType
== PT_Paint
)
101 return rTheme
.maPaints
[nIndex
].GetColor();
109 const Paint
& Theme::GetPaint (const ThemeItem eItem
)
111 const PropertyType
eType (GetPropertyType(eItem
));
112 OSL_ASSERT(eType
==PT_Paint
);
113 const sal_Int32
nIndex (GetIndex(eItem
, eType
));
114 const Theme
& rTheme (GetCurrentTheme());
115 return rTheme
.maPaints
[nIndex
];
121 const Wallpaper
Theme::GetWallpaper (const ThemeItem eItem
)
123 return GetPaint(eItem
).GetWallpaper();
129 sal_Int32
Theme::GetInteger (const ThemeItem eItem
)
131 const PropertyType
eType (GetPropertyType(eItem
));
132 OSL_ASSERT(eType
==PT_Integer
);
133 const sal_Int32
nIndex (GetIndex(eItem
, eType
));
134 const Theme
& rTheme (GetCurrentTheme());
135 return rTheme
.maIntegers
[nIndex
];
141 bool Theme::GetBoolean (const ThemeItem eItem
)
143 const PropertyType
eType (GetPropertyType(eItem
));
144 OSL_ASSERT(eType
==PT_Boolean
);
145 const sal_Int32
nIndex (GetIndex(eItem
, eType
));
146 const Theme
& rTheme (GetCurrentTheme());
147 return rTheme
.maBooleans
[nIndex
];
153 Rectangle
Theme::GetRectangle (const ThemeItem eItem
)
155 const PropertyType
eType (GetPropertyType(eItem
));
156 OSL_ASSERT(eType
==PT_Rectangle
);
157 const sal_Int32
nIndex (GetIndex(eItem
, eType
));
158 const Theme
& rTheme (GetCurrentTheme());
159 return rTheme
.maRectangles
[nIndex
];
165 bool Theme::IsHighContrastMode (void)
167 const Theme
& rTheme (GetCurrentTheme());
168 return rTheme
.mbIsHighContrastMode
;
174 void Theme::HandleDataChange (void)
176 Theme
& rTheme (GetCurrentTheme());
178 if ( ! rTheme
.mbIsHighContrastModeSetManually
)
180 // Do not modify mbIsHighContrastMode when it was manually set.
181 GetCurrentTheme().mbIsHighContrastMode
= Application::GetSettings().GetStyleSettings().GetHighContrastMode();
182 rTheme
.maRawValues
[Bool_IsHighContrastModeActive
] = Any(GetCurrentTheme().mbIsHighContrastMode
);
185 GetCurrentTheme().UpdateTheme();
191 void Theme::InitializeTheme (void)
194 maPropertyIdToNameMap
[Bool_UseSymphonyIcons
],
197 maPropertyIdToNameMap
[Bool_UseSystemColors
],
204 void Theme::UpdateTheme (void)
206 SidebarResource aLocalResource
;
210 const StyleSettings
& rStyle (Application::GetSettings().GetStyleSettings());
211 const bool bUseSystemColors (GetBoolean(Bool_UseSystemColors
));
213 #define Alternatives(n,hc,sys) (mbIsHighContrastMode ? hc : (bUseSystemColors ? sys : n))
215 Color
aBaseBackgroundColor (rStyle
.GetDialogColor());
216 // UX says this should be a little brighter, but that looks off when compared to the other windows.
217 //aBaseBackgroundColor.IncreaseLuminance(7);
218 Color
aBorderColor (aBaseBackgroundColor
);
219 aBorderColor
.DecreaseLuminance(15);
220 Color
aSecondColor (aBaseBackgroundColor
);
221 aSecondColor
.DecreaseLuminance(15);
224 maPropertyIdToNameMap
[Paint_DeckBackground
],
225 Any(sal_Int32(aBaseBackgroundColor
.GetRGBColor())));
228 maPropertyIdToNameMap
[Paint_DeckTitleBarBackground
],
229 Any(sal_Int32(aBaseBackgroundColor
.GetRGBColor())));
231 maPropertyIdToNameMap
[Int_DeckLeftPadding
],
234 maPropertyIdToNameMap
[Int_DeckTopPadding
],
237 maPropertyIdToNameMap
[Int_DeckRightPadding
],
240 maPropertyIdToNameMap
[Int_DeckBottomPadding
],
243 maPropertyIdToNameMap
[Int_DeckBorderSize
],
246 maPropertyIdToNameMap
[Int_DeckSeparatorHeight
],
249 maPropertyIdToNameMap
[Int_ButtonCornerRadius
],
252 maPropertyIdToNameMap
[Color_DeckTitleFont
],
253 Any(sal_Int32(rStyle
.GetFontColor().GetRGBColor())));
255 maPropertyIdToNameMap
[Int_DeckTitleBarHeight
],
256 Any(sal_Int32(Alternatives(
259 rStyle
.GetFloatTitleHeight()))));
261 maPropertyIdToNameMap
[Paint_PanelBackground
],
262 Any(sal_Int32(aBaseBackgroundColor
.GetRGBColor())));
265 maPropertyIdToNameMap
[Paint_PanelTitleBarBackground
],
266 Any(Tools::VclToAwtGradient(Gradient(
267 GradientStyle_LINEAR
,
268 aSecondColor
.GetRGBColor(),
269 aBaseBackgroundColor
.GetRGBColor()
272 maPropertyIdToNameMap
[Color_PanelTitleFont
],
273 Any(sal_Int32(mbIsHighContrastMode
? 0x00ff00 : 0x262626)));
275 maPropertyIdToNameMap
[Int_PanelTitleBarHeight
],
276 Any(sal_Int32(Alternatives(
279 rStyle
.GetTitleHeight()))));
281 maPropertyIdToNameMap
[Paint_TabBarBackground
],
282 Any(sal_Int32(aBaseBackgroundColor
.GetRGBColor())));
284 maPropertyIdToNameMap
[Int_TabBarLeftPadding
],
287 maPropertyIdToNameMap
[Int_TabBarTopPadding
],
290 maPropertyIdToNameMap
[Int_TabBarRightPadding
],
293 maPropertyIdToNameMap
[Int_TabBarBottomPadding
],
297 maPropertyIdToNameMap
[Int_TabMenuPadding
],
300 maPropertyIdToNameMap
[Color_TabMenuSeparator
],
301 Any(sal_Int32(aBorderColor
.GetRGBColor())));
303 maPropertyIdToNameMap
[Int_TabMenuSeparatorPadding
],
307 maPropertyIdToNameMap
[Int_TabItemWidth
],
310 maPropertyIdToNameMap
[Int_TabItemHeight
],
313 maPropertyIdToNameMap
[Color_TabItemBorder
],
314 Any(sal_Int32(rStyle
.GetActiveBorderColor().GetRGBColor())));
315 // mbIsHighContrastMode ? 0x00ff00 : 0xbfbfbf)));
318 maPropertyIdToNameMap
[Paint_DropDownBackground
],
319 Any(sal_Int32(aBaseBackgroundColor
.GetRGBColor())));
321 maPropertyIdToNameMap
[Color_DropDownBorder
],
322 Any(sal_Int32(rStyle
.GetActiveBorderColor().GetRGBColor())));
325 maPropertyIdToNameMap
[Color_Highlight
],
326 Any(sal_Int32(rStyle
.GetHighlightColor().GetRGBColor())));
328 maPropertyIdToNameMap
[Color_HighlightText
],
329 Any(sal_Int32(rStyle
.GetHighlightTextColor().GetRGBColor())));
332 maPropertyIdToNameMap
[Paint_TabItemBackgroundNormal
],
335 maPropertyIdToNameMap
[Paint_TabItemBackgroundHighlight
],
336 Any(sal_Int32(rStyle
.GetActiveTabColor().GetRGBColor())));
337 // mbIsHighContrastMode ? 0x000000 : 0x00ffffff)));
340 maPropertyIdToNameMap
[Paint_HorizontalBorder
],
341 Any(sal_Int32(aBorderColor
.GetRGBColor())));
342 // mbIsHighContrastMode ? 0x00ff00 : 0xe4e4e4)));
344 maPropertyIdToNameMap
[Paint_VerticalBorder
],
345 Any(sal_Int32(aBorderColor
.GetRGBColor())));
347 maPropertyIdToNameMap
[Image_Grip
],
348 Any(A2S("private:graphicrepository/sfx2/res/grip.png")));
350 maPropertyIdToNameMap
[Image_Expand
],
351 Any(A2S("private:graphicrepository/res/plus.png")));
353 maPropertyIdToNameMap
[Image_Collapse
],
354 Any(A2S("private:graphicrepository/res/minus.png")));
356 maPropertyIdToNameMap
[Image_TabBarMenu
],
357 Any(A2S("private:graphicrepository/sfx2/res/symphony/open_more.png")));
359 maPropertyIdToNameMap
[Image_PanelMenu
],
360 Any(A2S("private:graphicrepository/sfx2/res/symphony/morebutton.png")));
362 maPropertyIdToNameMap
[Image_Closer
],
363 Any(A2S("private:graphicrepository/sfx2/res/closedoc.png")));
365 maPropertyIdToNameMap
[Image_CloseIndicator
],
366 Any(A2S("private:graphicrepository/cmd/lc_decrementlevel.png")));
368 maPropertyIdToNameMap
[Image_ToolBoxItemSeparator
],
370 A2S("private:graphicrepository/sfx2/res/separator.png")));
377 maPropertyIdToNameMap[Paint_ToolBoxBackground],
378 Any(sal_Int32(rStyle.GetMenuColor().GetRGBColor())));
380 maPropertyIdToNameMap[Paint_ToolBoxBorderTopLeft],
383 maPropertyIdToNameMap[Paint_ToolBoxBorderCenterCorners],
386 maPropertyIdToNameMap[Paint_ToolBoxBorderBottomRight],
389 maPropertyIdToNameMap[Rect_ToolBoxPadding],
390 Any(awt::Rectangle(2,2,2,2)));
392 maPropertyIdToNameMap[Rect_ToolBoxBorder],
393 Any(awt::Rectangle(0,0,0,0)));
395 maPropertyIdToNameMap[Bool_UseToolBoxItemSeparator],
402 maPropertyIdToNameMap
[Paint_ToolBoxBackground
],
403 Any(Tools::VclToAwtGradient(Gradient(
404 GradientStyle_LINEAR
,
409 maPropertyIdToNameMap
[Paint_ToolBoxBorderTopLeft
],
411 ? Any(util::Color(sal_uInt32(0x00ff00)))
412 : Any(util::Color(sal_uInt32(0xf2f2f2))));
414 maPropertyIdToNameMap
[Paint_ToolBoxBorderCenterCorners
],
416 ? Any(util::Color(sal_uInt32(0x00ff00)))
417 : Any(util::Color(sal_uInt32(0xf2f2f2))));
419 maPropertyIdToNameMap
[Paint_ToolBoxBorderBottomRight
],
421 ? Any(util::Color(sal_uInt32(0x00ff00)))
422 : Any(util::Color(sal_uInt32(0xf2f2f2))));
424 maPropertyIdToNameMap
[Rect_ToolBoxPadding
],
425 Any(awt::Rectangle(2,2,2,2)));
427 maPropertyIdToNameMap
[Rect_ToolBoxBorder
],
428 Any(awt::Rectangle(1,1,1,1)));
430 maPropertyIdToNameMap
[Bool_UseToolBoxItemSeparator
],
433 catch(beans::UnknownPropertyException
& rException
)
435 OSL_TRACE("unknown property: %s",
438 RTL_TEXTENCODING_ASCII_US
).getStr());
446 void SAL_CALL
Theme::disposing (void)
448 ChangeListeners aListeners
;
449 maChangeListeners
.swap(aListeners
);
451 const lang::EventObject
aEvent (static_cast<XWeak
*>(this));
453 for (ChangeListeners::const_iterator
454 iContainer(maChangeListeners
.begin()),
455 iContainerEnd(maChangeListeners
.end());
456 iContainerEnd
!=iContainerEnd
;
459 for (ChangeListenerContainer::const_iterator
460 iListener(iContainer
->second
.begin()),
461 iEnd(iContainer
->second
.end());
467 (*iListener
)->disposing(aEvent
);
469 catch(const Exception
&)
479 Reference
<beans::XPropertySet
> Theme::GetPropertySet (void)
481 return Reference
<beans::XPropertySet
>(static_cast<XWeak
*>(&GetCurrentTheme()), UNO_QUERY
);
487 Reference
<beans::XPropertySetInfo
> SAL_CALL
Theme::getPropertySetInfo (void)
488 throw(cssu::RuntimeException
)
490 return Reference
<beans::XPropertySetInfo
>(this);
496 void SAL_CALL
Theme::setPropertyValue (
497 const ::rtl::OUString
& rsPropertyName
,
498 const cssu::Any
& rValue
)
499 throw(cssu::RuntimeException
)
501 PropertyNameToIdMap::const_iterator
iId (maPropertyNameToIdMap
.find(rsPropertyName
));
502 if (iId
== maPropertyNameToIdMap
.end())
503 throw beans::UnknownPropertyException(rsPropertyName
, NULL
);
505 const PropertyType
eType (GetPropertyType(iId
->second
));
506 if (eType
== PT_Invalid
)
507 throw beans::UnknownPropertyException(rsPropertyName
, NULL
);
509 const ThemeItem
eItem (iId
->second
);
511 if (rValue
== maRawValues
[eItem
])
513 // Value is not different from the one in the property
514 // set => nothing to do.
518 const Any
aOldValue (maRawValues
[eItem
]);
520 const beans::PropertyChangeEvent
aEvent(
521 static_cast<XWeak
*>(this),
528 if (DoVetoableListenersVeto(GetVetoableListeners(__AnyItem
, false), aEvent
))
530 if (DoVetoableListenersVeto(GetVetoableListeners(eItem
, false), aEvent
))
533 maRawValues
[eItem
] = rValue
;
534 ProcessNewValue(rValue
, eItem
, eType
);
536 BroadcastPropertyChange(GetChangeListeners(__AnyItem
, false), aEvent
);
537 BroadcastPropertyChange(GetChangeListeners(eItem
, false), aEvent
);
543 Any SAL_CALL
Theme::getPropertyValue (
544 const ::rtl::OUString
& rsPropertyName
)
545 throw(css::beans::UnknownPropertyException
,
546 css::lang::WrappedTargetException
,
547 cssu::RuntimeException
)
549 PropertyNameToIdMap::const_iterator
iId (maPropertyNameToIdMap
.find(rsPropertyName
));
550 if (iId
== maPropertyNameToIdMap
.end())
551 throw beans::UnknownPropertyException();
553 const PropertyType
eType (GetPropertyType(iId
->second
));
554 if (eType
== PT_Invalid
)
555 throw beans::UnknownPropertyException();
557 const ThemeItem
eItem (iId
->second
);
559 return maRawValues
[eItem
];
565 void SAL_CALL
Theme::addPropertyChangeListener(
566 const ::rtl::OUString
& rsPropertyName
,
567 const cssu::Reference
<css::beans::XPropertyChangeListener
>& rxListener
)
568 throw(css::beans::UnknownPropertyException
,
569 css::lang::WrappedTargetException
,
570 cssu::RuntimeException
)
572 ThemeItem
eItem (__AnyItem
);
573 if (rsPropertyName
.getLength() > 0)
575 PropertyNameToIdMap::const_iterator
iId (maPropertyNameToIdMap
.find(rsPropertyName
));
576 if (iId
== maPropertyNameToIdMap
.end())
577 throw beans::UnknownPropertyException();
579 const PropertyType
eType (GetPropertyType(iId
->second
));
580 if (eType
== PT_Invalid
)
581 throw beans::UnknownPropertyException();
585 ChangeListenerContainer
* pListeners
= GetChangeListeners(eItem
, true);
586 if (pListeners
!= NULL
)
587 pListeners
->push_back(rxListener
);
593 void SAL_CALL
Theme::removePropertyChangeListener(
594 const ::rtl::OUString
& rsPropertyName
,
595 const cssu::Reference
<css::beans::XPropertyChangeListener
>& rxListener
)
596 throw(css::beans::UnknownPropertyException
,
597 css::lang::WrappedTargetException
,
598 cssu::RuntimeException
)
600 ThemeItem
eItem (__AnyItem
);
601 if (rsPropertyName
.getLength() > 0)
603 PropertyNameToIdMap::const_iterator
iId (maPropertyNameToIdMap
.find(rsPropertyName
));
604 if (iId
== maPropertyNameToIdMap
.end())
605 throw beans::UnknownPropertyException();
607 const PropertyType
eType (GetPropertyType(iId
->second
));
608 if (eType
== PT_Invalid
)
609 throw beans::UnknownPropertyException();
613 ChangeListenerContainer
* pContainer
= GetChangeListeners(eItem
, false);
614 if (pContainer
!= NULL
)
616 ChangeListenerContainer::iterator
iListener (::std::find(pContainer
->begin(), pContainer
->end(), rxListener
));
617 if (iListener
!= pContainer
->end())
619 pContainer
->erase(iListener
);
621 // Remove the listener container when empty.
622 if (pContainer
->empty())
623 maChangeListeners
.erase(eItem
);
631 void SAL_CALL
Theme::addVetoableChangeListener(
632 const ::rtl::OUString
& rsPropertyName
,
633 const cssu::Reference
<css::beans::XVetoableChangeListener
>& rxListener
)
634 throw(css::beans::UnknownPropertyException
,
635 css::lang::WrappedTargetException
,
636 cssu::RuntimeException
)
638 ThemeItem
eItem (__AnyItem
);
639 if (rsPropertyName
.getLength() > 0)
641 PropertyNameToIdMap::const_iterator
iId (maPropertyNameToIdMap
.find(rsPropertyName
));
642 if (iId
== maPropertyNameToIdMap
.end())
643 throw beans::UnknownPropertyException();
645 const PropertyType
eType (GetPropertyType(iId
->second
));
646 if (eType
== PT_Invalid
)
647 throw beans::UnknownPropertyException();
651 VetoableListenerContainer
* pListeners
= GetVetoableListeners(eItem
, true);
652 if (pListeners
!= NULL
)
653 pListeners
->push_back(rxListener
);
659 void SAL_CALL
Theme::removeVetoableChangeListener(
660 const ::rtl::OUString
& rsPropertyName
,
661 const cssu::Reference
<css::beans::XVetoableChangeListener
>& rxListener
)
662 throw(css::beans::UnknownPropertyException
,
663 css::lang::WrappedTargetException
,
664 cssu::RuntimeException
)
666 ThemeItem
eItem (__AnyItem
);
667 if (rsPropertyName
.getLength() > 0)
669 PropertyNameToIdMap::const_iterator
iId (maPropertyNameToIdMap
.find(rsPropertyName
));
670 if (iId
== maPropertyNameToIdMap
.end())
671 throw beans::UnknownPropertyException();
673 const PropertyType
eType (GetPropertyType(iId
->second
));
674 if (eType
== PT_Invalid
)
675 throw beans::UnknownPropertyException();
679 VetoableListenerContainer
* pContainer
= GetVetoableListeners(eItem
, false);
680 if (pContainer
!= NULL
)
682 VetoableListenerContainer::iterator
iListener (::std::find(pContainer
->begin(), pContainer
->end(), rxListener
));
683 if (iListener
!= pContainer
->end())
685 pContainer
->erase(iListener
);
686 // Remove container when empty.
687 if (pContainer
->empty())
688 maVetoableListeners
.erase(eItem
);
696 cssu::Sequence
<css::beans::Property
> SAL_CALL
Theme::getProperties (void)
697 throw(cssu::RuntimeException
)
699 ::std::vector
<beans::Property
> aProperties
;
701 for (sal_Int32
nItem(__Begin
),nEnd(__End
); nItem
!=nEnd
; ++nItem
)
703 const ThemeItem
eItem (static_cast<ThemeItem
>(nItem
));
704 const PropertyType
eType (GetPropertyType(eItem
));
705 if (eType
== PT_Invalid
)
708 const beans::Property
aProperty(
709 maPropertyIdToNameMap
[eItem
],
713 aProperties
.push_back(aProperty
);
716 return cssu::Sequence
<css::beans::Property
>(
717 &aProperties
.front(),
724 beans::Property SAL_CALL
Theme::getPropertyByName (const ::rtl::OUString
& rsPropertyName
)
725 throw(css::beans::UnknownPropertyException
,
726 cssu::RuntimeException
)
728 PropertyNameToIdMap::const_iterator
iId (maPropertyNameToIdMap
.find(rsPropertyName
));
729 if (iId
== maPropertyNameToIdMap
.end())
730 throw beans::UnknownPropertyException();
732 const PropertyType
eType (GetPropertyType(iId
->second
));
733 if (eType
== PT_Invalid
)
734 throw beans::UnknownPropertyException();
736 const ThemeItem
eItem (iId
->second
);
738 return beans::Property(
748 sal_Bool SAL_CALL
Theme::hasPropertyByName (const ::rtl::OUString
& rsPropertyName
)
749 throw(cssu::RuntimeException
)
751 PropertyNameToIdMap::const_iterator
iId (maPropertyNameToIdMap
.find(rsPropertyName
));
752 if (iId
== maPropertyNameToIdMap
.end())
755 const PropertyType
eType (GetPropertyType(iId
->second
));
756 if (eType
== PT_Invalid
)
765 void Theme::SetupPropertyMaps (void)
767 maPropertyIdToNameMap
.resize(__Post_Rect
);
768 maImages
.resize(__Image_Color
- __Pre_Image
- 1);
769 maColors
.resize(__Color_Paint
- __Image_Color
- 1);
770 maPaints
.resize(__Paint_Int
- __Color_Paint
- 1);
771 maIntegers
.resize(__Int_Bool
- __Paint_Int
- 1);
772 maBooleans
.resize(__Bool_Rect
- __Int_Bool
- 1);
773 maRectangles
.resize(__Post_Rect
- __Bool_Rect
- 1);
775 #define AddEntry(e) maPropertyNameToIdMap[A2S(#e)]=e; maPropertyIdToNameMap[e]=A2S(#e)
777 AddEntry(Image_Grip
);
778 AddEntry(Image_Expand
);
779 AddEntry(Image_Collapse
);
780 AddEntry(Image_TabBarMenu
);
781 AddEntry(Image_PanelMenu
);
782 AddEntry(Image_ToolBoxItemSeparator
);
783 AddEntry(Image_Closer
);
784 AddEntry(Image_CloseIndicator
);
786 AddEntry(Color_DeckTitleFont
);
787 AddEntry(Color_PanelTitleFont
);
788 AddEntry(Color_TabMenuSeparator
);
789 AddEntry(Color_TabItemBorder
);
790 AddEntry(Color_DropDownBorder
);
791 AddEntry(Color_Highlight
);
792 AddEntry(Color_HighlightText
);
794 AddEntry(Paint_DeckBackground
);
795 AddEntry(Paint_DeckTitleBarBackground
);
796 AddEntry(Paint_PanelBackground
);
797 AddEntry(Paint_PanelTitleBarBackground
);
798 AddEntry(Paint_TabBarBackground
);
799 AddEntry(Paint_TabItemBackgroundNormal
);
800 AddEntry(Paint_TabItemBackgroundHighlight
);
801 AddEntry(Paint_HorizontalBorder
);
802 AddEntry(Paint_VerticalBorder
);
803 AddEntry(Paint_ToolBoxBackground
);
804 AddEntry(Paint_ToolBoxBorderTopLeft
);
805 AddEntry(Paint_ToolBoxBorderCenterCorners
);
806 AddEntry(Paint_ToolBoxBorderBottomRight
);
807 AddEntry(Paint_DropDownBackground
);
809 AddEntry(Int_DeckTitleBarHeight
);
810 AddEntry(Int_DeckBorderSize
);
811 AddEntry(Int_DeckSeparatorHeight
);
812 AddEntry(Int_PanelTitleBarHeight
);
813 AddEntry(Int_TabMenuPadding
);
814 AddEntry(Int_TabMenuSeparatorPadding
);
815 AddEntry(Int_TabItemWidth
);
816 AddEntry(Int_TabItemHeight
);
817 AddEntry(Int_DeckLeftPadding
);
818 AddEntry(Int_DeckTopPadding
);
819 AddEntry(Int_DeckRightPadding
);
820 AddEntry(Int_DeckBottomPadding
);
821 AddEntry(Int_TabBarLeftPadding
);
822 AddEntry(Int_TabBarTopPadding
);
823 AddEntry(Int_TabBarRightPadding
);
824 AddEntry(Int_TabBarBottomPadding
);
825 AddEntry(Int_ButtonCornerRadius
);
827 AddEntry(Bool_UseSymphonyIcons
);
828 AddEntry(Bool_UseSystemColors
);
829 AddEntry(Bool_UseToolBoxItemSeparator
);
830 AddEntry(Bool_IsHighContrastModeActive
);
832 AddEntry(Rect_ToolBoxPadding
);
833 AddEntry(Rect_ToolBoxBorder
);
837 maRawValues
.resize(maPropertyIdToNameMap
.size());
843 Theme::PropertyType
Theme::GetPropertyType (const ThemeItem eItem
)
850 case Image_TabBarMenu
:
851 case Image_PanelMenu
:
852 case Image_ToolBoxItemSeparator
:
854 case Image_CloseIndicator
:
857 case Color_DeckTitleFont
:
858 case Color_PanelTitleFont
:
859 case Color_TabMenuSeparator
:
860 case Color_TabItemBorder
:
861 case Color_DropDownBorder
:
862 case Color_Highlight
:
863 case Color_HighlightText
:
866 case Paint_DeckBackground
:
867 case Paint_DeckTitleBarBackground
:
868 case Paint_PanelBackground
:
869 case Paint_PanelTitleBarBackground
:
870 case Paint_TabBarBackground
:
871 case Paint_TabItemBackgroundNormal
:
872 case Paint_TabItemBackgroundHighlight
:
873 case Paint_HorizontalBorder
:
874 case Paint_VerticalBorder
:
875 case Paint_ToolBoxBackground
:
876 case Paint_ToolBoxBorderTopLeft
:
877 case Paint_ToolBoxBorderCenterCorners
:
878 case Paint_ToolBoxBorderBottomRight
:
879 case Paint_DropDownBackground
:
882 case Int_DeckTitleBarHeight
:
883 case Int_DeckBorderSize
:
884 case Int_DeckSeparatorHeight
:
885 case Int_PanelTitleBarHeight
:
886 case Int_TabMenuPadding
:
887 case Int_TabMenuSeparatorPadding
:
888 case Int_TabItemWidth
:
889 case Int_TabItemHeight
:
890 case Int_DeckLeftPadding
:
891 case Int_DeckTopPadding
:
892 case Int_DeckRightPadding
:
893 case Int_DeckBottomPadding
:
894 case Int_TabBarLeftPadding
:
895 case Int_TabBarTopPadding
:
896 case Int_TabBarRightPadding
:
897 case Int_TabBarBottomPadding
:
898 case Int_ButtonCornerRadius
:
901 case Bool_UseSymphonyIcons
:
902 case Bool_UseSystemColors
:
903 case Bool_UseToolBoxItemSeparator
:
904 case Bool_IsHighContrastModeActive
:
907 case Rect_ToolBoxBorder
:
908 case Rect_ToolBoxPadding
:
919 cssu::Type
Theme::GetCppuType (const PropertyType eType
)
924 return getCppuType((rtl::OUString
*)NULL
);
927 return getCppuType((sal_uInt32
*)NULL
);
930 return getCppuVoidType();
933 return getCppuType((sal_Int32
*)NULL
);
936 return getCppuType((sal_Bool
*)NULL
);
939 return getCppuType((awt::Rectangle
*)NULL
);
943 return getCppuVoidType();
950 sal_Int32
Theme::GetIndex (const ThemeItem eItem
, const PropertyType eType
)
955 return eItem
- __Pre_Image
-1;
957 return eItem
- __Image_Color
-1;
959 return eItem
- __Color_Paint
-1;
961 return eItem
- __Paint_Int
-1;
963 return eItem
- __Int_Bool
-1;
965 return eItem
- __Bool_Rect
-1;
976 Theme::VetoableListenerContainer
* Theme::GetVetoableListeners (
977 const ThemeItem eItem
,
980 VetoableListeners::iterator
iContainer (maVetoableListeners
.find(eItem
));
981 if (iContainer
!= maVetoableListeners
.end())
982 return &iContainer
->second
;
985 maVetoableListeners
[eItem
] = VetoableListenerContainer();
986 return &maVetoableListeners
[eItem
];
995 Theme::ChangeListenerContainer
* Theme::GetChangeListeners (
996 const ThemeItem eItem
,
999 ChangeListeners::iterator
iContainer (maChangeListeners
.find(eItem
));
1000 if (iContainer
!= maChangeListeners
.end())
1001 return &iContainer
->second
;
1004 maChangeListeners
[eItem
] = ChangeListenerContainer();
1005 return &maChangeListeners
[eItem
];
1014 bool Theme::DoVetoableListenersVeto (
1015 const VetoableListenerContainer
* pListeners
,
1016 const beans::PropertyChangeEvent
& rEvent
) const
1018 if (pListeners
== NULL
)
1021 VetoableListenerContainer
aListeners (*pListeners
);
1024 for (VetoableListenerContainer::const_iterator
1025 iListener(aListeners
.begin()),
1026 iEnd(aListeners
.end());
1030 (*iListener
)->vetoableChange(rEvent
);
1033 catch(const beans::PropertyVetoException
&)
1037 catch(const Exception
&)
1039 // Ignore any other errors (such as disposed listeners).
1047 void Theme::BroadcastPropertyChange (
1048 const ChangeListenerContainer
* pListeners
,
1049 const beans::PropertyChangeEvent
& rEvent
) const
1051 if (pListeners
== NULL
)
1054 const ChangeListenerContainer
aListeners (*pListeners
);
1057 for (ChangeListenerContainer::const_iterator
1058 iListener(aListeners
.begin()),
1059 iEnd(aListeners
.end());
1063 (*iListener
)->propertyChange(rEvent
);
1066 catch(const Exception
&)
1068 // Ignore any errors (such as disposed listeners).
1075 void Theme::ProcessNewValue (
1077 const ThemeItem eItem
,
1078 const PropertyType eType
)
1080 const sal_Int32
nIndex (GetIndex (eItem
, eType
));
1085 ::rtl::OUString sURL
;
1086 if (rValue
>>= sURL
)
1088 maImages
[nIndex
] = Tools::GetImage(sURL
, NULL
);
1094 sal_Int32
nColorValue (0);
1095 if (rValue
>>= nColorValue
)
1097 maColors
[nIndex
] = Color(nColorValue
);
1103 maPaints
[nIndex
] = Paint::Create(rValue
);
1108 sal_Int32
nValue (0);
1109 if (rValue
>>= nValue
)
1111 maIntegers
[nIndex
] = nValue
;
1117 sal_Bool
nValue (0);
1118 if (rValue
>>= nValue
)
1120 maBooleans
[nIndex
] = (nValue
==sal_True
);
1121 if (eItem
== Bool_IsHighContrastModeActive
)
1123 mbIsHighContrastModeSetManually
= true;
1124 mbIsHighContrastMode
= maBooleans
[nIndex
];
1127 else if (eItem
== Bool_UseSystemColors
)
1136 awt::Rectangle aBox
;
1137 if (rValue
>>= aBox
)
1139 maRectangles
[nIndex
] = Rectangle(
1148 OSL_ASSERT(eType
!= PT_Invalid
);
1149 throw RuntimeException();
1153 } } // end of namespace sfx2::sidebar