1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #include <sfx2/sidebar/Theme.hxx>
21 #include "SidebarResource.hxx"
22 #include <sfx2/sidebar/Tools.hxx>
23 #include <sfx2/app.hxx>
25 #include <tools/svborder.hxx>
26 #include <tools/rc.hxx>
27 #include <vcl/svapp.hxx>
28 #include <vcl/settings.hxx>
31 using namespace css::uno
;
33 namespace sfx2
{ namespace sidebar
{
35 Theme
& Theme::GetCurrentTheme()
37 return SfxGetpApp()->GetSidebarTheme();
41 : ThemeInterfaceBase(m_aMutex
),
47 mbIsHighContrastMode(Application::GetSettings().GetStyleSettings().GetHighContrastMode()),
48 mbIsHighContrastModeSetManually(false),
49 maPropertyNameToIdMap(),
50 maPropertyIdToNameMap(),
63 Image
Theme::GetImage (const ThemeItem eItem
)
65 const PropertyType
eType (GetPropertyType(eItem
));
66 OSL_ASSERT(eType
==PT_Image
);
67 const sal_Int32
nIndex (GetIndex(eItem
, eType
));
68 const Theme
& rTheme (GetCurrentTheme());
69 return rTheme
.maImages
[nIndex
];
72 Color
Theme::GetColor (const ThemeItem eItem
)
74 const PropertyType
eType (GetPropertyType(eItem
));
75 OSL_ASSERT(eType
==PT_Color
|| eType
==PT_Paint
);
76 const sal_Int32
nIndex (GetIndex(eItem
, eType
));
77 const Theme
& rTheme (GetCurrentTheme());
78 if (eType
== PT_Color
)
79 return rTheme
.maColors
[nIndex
];
80 else if (eType
== PT_Paint
)
81 return rTheme
.maPaints
[nIndex
].GetColor();
86 const Paint
& Theme::GetPaint (const ThemeItem eItem
)
88 const PropertyType
eType (GetPropertyType(eItem
));
89 OSL_ASSERT(eType
==PT_Paint
);
90 const sal_Int32
nIndex (GetIndex(eItem
, eType
));
91 const Theme
& rTheme (GetCurrentTheme());
92 return rTheme
.maPaints
[nIndex
];
95 const Wallpaper
Theme::GetWallpaper (const ThemeItem eItem
)
97 return GetPaint(eItem
).GetWallpaper();
100 sal_Int32
Theme::GetInteger (const ThemeItem eItem
)
102 const PropertyType
eType (GetPropertyType(eItem
));
103 OSL_ASSERT(eType
==PT_Integer
);
104 const sal_Int32
nIndex (GetIndex(eItem
, eType
));
105 const Theme
& rTheme (GetCurrentTheme());
106 return rTheme
.maIntegers
[nIndex
];
109 bool Theme::GetBoolean (const ThemeItem eItem
)
111 const PropertyType
eType (GetPropertyType(eItem
));
112 OSL_ASSERT(eType
==PT_Boolean
);
113 const sal_Int32
nIndex (GetIndex(eItem
, eType
));
114 const Theme
& rTheme (GetCurrentTheme());
115 return rTheme
.maBooleans
[nIndex
];
118 bool Theme::IsHighContrastMode()
120 const Theme
& rTheme (GetCurrentTheme());
121 return rTheme
.mbIsHighContrastMode
;
124 void Theme::HandleDataChange()
126 Theme
& rTheme (GetCurrentTheme());
128 if ( ! rTheme
.mbIsHighContrastModeSetManually
)
130 // Do not modify mbIsHighContrastMode when it was manually set.
131 GetCurrentTheme().mbIsHighContrastMode
= Application::GetSettings().GetStyleSettings().GetHighContrastMode();
132 rTheme
.maRawValues
[Bool_IsHighContrastModeActive
] = Any(GetCurrentTheme().mbIsHighContrastMode
);
135 GetCurrentTheme().UpdateTheme();
138 void Theme::InitializeTheme()
141 maPropertyIdToNameMap
[Bool_UseSymphonyIcons
],
144 maPropertyIdToNameMap
[Bool_UseSystemColors
],
148 void Theme::UpdateTheme()
150 SidebarResource aLocalResource
;
154 const StyleSettings
& rStyle (Application::GetSettings().GetStyleSettings());
155 const bool bUseSystemColors (GetBoolean(Bool_UseSystemColors
));
157 #define Alternatives(n,hc,sys) (mbIsHighContrastMode ? hc : (bUseSystemColors ? sys : n))
159 Color
aBaseBackgroundColor (rStyle
.GetDialogColor());
160 // UX says this should be a little brighter, but that looks off when compared to the other windows.
161 //aBaseBackgroundColor.IncreaseLuminance(7);
162 Color
aBorderColor (aBaseBackgroundColor
);
163 aBorderColor
.DecreaseLuminance(15);
164 Color
aSecondColor (aBaseBackgroundColor
);
165 aSecondColor
.DecreaseLuminance(15);
168 maPropertyIdToNameMap
[Paint_DeckBackground
],
169 Any(sal_Int32(aBaseBackgroundColor
.GetRGBColor())));
172 maPropertyIdToNameMap
[Paint_DeckTitleBarBackground
],
173 Any(sal_Int32(aBaseBackgroundColor
.GetRGBColor())));
175 maPropertyIdToNameMap
[Int_DeckLeftPadding
],
178 maPropertyIdToNameMap
[Int_DeckTopPadding
],
181 maPropertyIdToNameMap
[Int_DeckRightPadding
],
184 maPropertyIdToNameMap
[Int_DeckBottomPadding
],
187 maPropertyIdToNameMap
[Int_DeckBorderSize
],
190 maPropertyIdToNameMap
[Int_DeckSeparatorHeight
],
193 maPropertyIdToNameMap
[Int_ButtonCornerRadius
],
196 maPropertyIdToNameMap
[Color_DeckTitleFont
],
197 Any(sal_Int32(rStyle
.GetFontColor().GetRGBColor())));
199 maPropertyIdToNameMap
[Int_DeckTitleBarHeight
],
200 Any(sal_Int32(Alternatives(
203 rStyle
.GetFloatTitleHeight()))));
205 maPropertyIdToNameMap
[Paint_PanelBackground
],
206 Any(sal_Int32(aBaseBackgroundColor
.GetRGBColor())));
209 maPropertyIdToNameMap
[Paint_PanelTitleBarBackground
],
210 Any(Tools::VclToAwtGradient(Gradient(
211 GradientStyle_LINEAR
,
212 aSecondColor
.GetRGBColor(),
213 aBaseBackgroundColor
.GetRGBColor()
216 maPropertyIdToNameMap
[Color_PanelTitleFont
],
217 Any(sal_Int32(mbIsHighContrastMode
? 0x00ff00 : 0x262626)));
219 maPropertyIdToNameMap
[Int_PanelTitleBarHeight
],
220 Any(sal_Int32(Alternatives(
223 rStyle
.GetTitleHeight()))));
225 maPropertyIdToNameMap
[Paint_TabBarBackground
],
226 Any(sal_Int32(aBaseBackgroundColor
.GetRGBColor())));
228 maPropertyIdToNameMap
[Int_TabBarLeftPadding
],
231 maPropertyIdToNameMap
[Int_TabBarTopPadding
],
234 maPropertyIdToNameMap
[Int_TabBarRightPadding
],
237 maPropertyIdToNameMap
[Int_TabBarBottomPadding
],
241 maPropertyIdToNameMap
[Int_TabMenuPadding
],
244 maPropertyIdToNameMap
[Color_TabMenuSeparator
],
245 Any(sal_Int32(aBorderColor
.GetRGBColor())));
247 maPropertyIdToNameMap
[Int_TabMenuSeparatorPadding
],
251 maPropertyIdToNameMap
[Int_TabItemWidth
],
254 maPropertyIdToNameMap
[Int_TabItemHeight
],
257 maPropertyIdToNameMap
[Color_TabItemBorder
],
258 Any(sal_Int32(rStyle
.GetActiveBorderColor().GetRGBColor())));
259 // mbIsHighContrastMode ? 0x00ff00 : 0xbfbfbf)));
262 maPropertyIdToNameMap
[Paint_DropDownBackground
],
263 Any(sal_Int32(aBaseBackgroundColor
.GetRGBColor())));
265 maPropertyIdToNameMap
[Color_DropDownBorder
],
266 Any(sal_Int32(rStyle
.GetActiveBorderColor().GetRGBColor())));
269 maPropertyIdToNameMap
[Color_Highlight
],
270 Any(sal_Int32(rStyle
.GetHighlightColor().GetRGBColor())));
272 maPropertyIdToNameMap
[Color_HighlightText
],
273 Any(sal_Int32(rStyle
.GetHighlightTextColor().GetRGBColor())));
276 maPropertyIdToNameMap
[Paint_TabItemBackgroundNormal
],
279 maPropertyIdToNameMap
[Paint_TabItemBackgroundHighlight
],
280 Any(sal_Int32(rStyle
.GetActiveTabColor().GetRGBColor())));
281 // mbIsHighContrastMode ? 0x000000 : 0x00ffffff)));
284 maPropertyIdToNameMap
[Paint_HorizontalBorder
],
285 Any(sal_Int32(aBorderColor
.GetRGBColor())));
286 // mbIsHighContrastMode ? 0x00ff00 : 0xe4e4e4)));
288 maPropertyIdToNameMap
[Paint_VerticalBorder
],
289 Any(sal_Int32(aBorderColor
.GetRGBColor())));
291 maPropertyIdToNameMap
[Image_Grip
],
292 Any(OUString("private:graphicrepository/sfx2/res/grip.png")));
294 maPropertyIdToNameMap
[Image_Expand
],
295 Any(OUString("private:graphicrepository/res/plus.png")));
297 maPropertyIdToNameMap
[Image_Collapse
],
298 Any(OUString("private:graphicrepository/res/minus.png")));
300 maPropertyIdToNameMap
[Image_TabBarMenu
],
301 Any(OUString("private:graphicrepository/sfx2/res/symphony/open_more.png")));
303 maPropertyIdToNameMap
[Image_PanelMenu
],
304 Any(OUString("private:graphicrepository/sfx2/res/symphony/morebutton.png")));
306 maPropertyIdToNameMap
[Image_Closer
],
307 Any(OUString("private:graphicrepository/sfx2/res/closedoc.png")));
309 maPropertyIdToNameMap
[Image_CloseIndicator
],
310 Any(OUString("private:graphicrepository/cmd/lc_decrementlevel.png")));
312 maPropertyIdToNameMap
[Image_ToolBoxItemSeparator
],
314 OUString("private:graphicrepository/sfx2/res/separator.png")));
321 maPropertyIdToNameMap[Paint_ToolBoxBackground],
322 Any(sal_Int32(rStyle.GetMenuColor().GetRGBColor())));
324 maPropertyIdToNameMap[Paint_ToolBoxBorderTopLeft],
327 maPropertyIdToNameMap[Paint_ToolBoxBorderCenterCorners],
330 maPropertyIdToNameMap[Paint_ToolBoxBorderBottomRight],
333 maPropertyIdToNameMap[Rect_ToolBoxPadding],
334 Any(awt::Rectangle(2,2,2,2)));
336 maPropertyIdToNameMap[Rect_ToolBoxBorder],
337 Any(awt::Rectangle(0,0,0,0)));
339 maPropertyIdToNameMap[Bool_UseToolBoxItemSeparator],
344 Color
aGradientStop2 (aBaseBackgroundColor
);
345 aGradientStop2
.IncreaseLuminance(17);
346 Color
aToolBoxBorderColor (aBaseBackgroundColor
);
347 aToolBoxBorderColor
.DecreaseLuminance(12);
349 maPropertyIdToNameMap
[Paint_ToolBoxBackground
],
350 Any(Tools::VclToAwtGradient(Gradient(
351 GradientStyle_LINEAR
,
352 aBaseBackgroundColor
.GetRGBColor(),
353 aGradientStop2
.GetRGBColor()
356 maPropertyIdToNameMap
[Paint_ToolBoxBorderTopLeft
],
358 ? Any(util::Color(sal_uInt32(0x00ff00)))
359 : Any(util::Color(aToolBoxBorderColor
.GetRGBColor())));
361 maPropertyIdToNameMap
[Paint_ToolBoxBorderCenterCorners
],
363 ? Any(util::Color(sal_uInt32(0x00ff00)))
364 : Any(util::Color(aToolBoxBorderColor
.GetRGBColor())));
366 maPropertyIdToNameMap
[Paint_ToolBoxBorderBottomRight
],
368 ? Any(util::Color(sal_uInt32(0x00ff00)))
369 : Any(util::Color(aToolBoxBorderColor
.GetRGBColor())));
371 maPropertyIdToNameMap
[Rect_ToolBoxPadding
],
372 Any(awt::Rectangle(2,2,2,2)));
374 maPropertyIdToNameMap
[Rect_ToolBoxBorder
],
375 Any(awt::Rectangle(1,1,1,1)));
377 maPropertyIdToNameMap
[Bool_UseToolBoxItemSeparator
],
380 catch(beans::UnknownPropertyException
& rException
)
382 OSL_TRACE("unknown property: %s",
385 RTL_TEXTENCODING_ASCII_US
).getStr());
390 void SAL_CALL
Theme::disposing()
392 ChangeListeners aListeners
;
393 aListeners
.swap(maChangeListeners
);
395 const lang::EventObject
aEvent (static_cast<XWeak
*>(this));
397 for (ChangeListeners::const_iterator
398 iContainer(aListeners
.begin()),
399 iContainerEnd(aListeners
.end());
400 iContainer
!= iContainerEnd
;
403 for (ChangeListenerContainer::const_iterator
404 iListener(iContainer
->second
.begin()),
405 iEnd(iContainer
->second
.end());
411 (*iListener
)->disposing(aEvent
);
413 catch(const Exception
&)
420 Reference
<beans::XPropertySet
> Theme::GetPropertySet()
422 return Reference
<beans::XPropertySet
>(static_cast<XWeak
*>(&GetCurrentTheme()), UNO_QUERY
);
425 Reference
<beans::XPropertySetInfo
> SAL_CALL
Theme::getPropertySetInfo()
426 throw(css::uno::RuntimeException
, std::exception
)
428 return Reference
<beans::XPropertySetInfo
>(this);
431 void SAL_CALL
Theme::setPropertyValue (
432 const ::rtl::OUString
& rsPropertyName
,
433 const css::uno::Any
& rValue
)
434 throw (css::beans::UnknownPropertyException
,
435 css::uno::RuntimeException
,
438 PropertyNameToIdMap::const_iterator
iId (maPropertyNameToIdMap
.find(rsPropertyName
));
439 if (iId
== maPropertyNameToIdMap
.end())
440 throw beans::UnknownPropertyException(rsPropertyName
);
442 const PropertyType
eType (GetPropertyType(iId
->second
));
443 if (eType
== PT_Invalid
)
444 throw beans::UnknownPropertyException(rsPropertyName
);
446 const ThemeItem
eItem (iId
->second
);
448 if (rValue
== maRawValues
[eItem
])
450 // Value is not different from the one in the property
451 // set => nothing to do.
455 const Any
aOldValue (maRawValues
[eItem
]);
457 const beans::PropertyChangeEvent
aEvent(
458 static_cast<XWeak
*>(this),
465 if (DoVetoableListenersVeto(GetVetoableListeners(__AnyItem
, false), aEvent
))
467 if (DoVetoableListenersVeto(GetVetoableListeners(eItem
, false), aEvent
))
470 maRawValues
[eItem
] = rValue
;
471 ProcessNewValue(rValue
, eItem
, eType
);
473 BroadcastPropertyChange(GetChangeListeners(__AnyItem
, false), aEvent
);
474 BroadcastPropertyChange(GetChangeListeners(eItem
, false), aEvent
);
477 Any SAL_CALL
Theme::getPropertyValue (
478 const ::rtl::OUString
& rsPropertyName
)
479 throw(css::beans::UnknownPropertyException
,
480 css::lang::WrappedTargetException
,
481 css::uno::RuntimeException
, std::exception
)
483 PropertyNameToIdMap::const_iterator
iId (maPropertyNameToIdMap
.find(rsPropertyName
));
484 if (iId
== maPropertyNameToIdMap
.end())
485 throw beans::UnknownPropertyException();
487 const PropertyType
eType (GetPropertyType(iId
->second
));
488 if (eType
== PT_Invalid
)
489 throw beans::UnknownPropertyException();
491 const ThemeItem
eItem (iId
->second
);
493 return maRawValues
[eItem
];
496 void SAL_CALL
Theme::addPropertyChangeListener(
497 const ::rtl::OUString
& rsPropertyName
,
498 const css::uno::Reference
<css::beans::XPropertyChangeListener
>& rxListener
)
499 throw(css::beans::UnknownPropertyException
,
500 css::lang::WrappedTargetException
,
501 css::uno::RuntimeException
, std::exception
)
503 ThemeItem
eItem (__AnyItem
);
504 if (rsPropertyName
.getLength() > 0)
506 PropertyNameToIdMap::const_iterator
iId (maPropertyNameToIdMap
.find(rsPropertyName
));
507 if (iId
== maPropertyNameToIdMap
.end())
508 throw beans::UnknownPropertyException();
510 const PropertyType
eType (GetPropertyType(iId
->second
));
511 if (eType
== PT_Invalid
)
512 throw beans::UnknownPropertyException();
516 ChangeListenerContainer
* pListeners
= GetChangeListeners(eItem
, true);
517 if (pListeners
!= NULL
)
518 pListeners
->push_back(rxListener
);
521 void SAL_CALL
Theme::removePropertyChangeListener(
522 const ::rtl::OUString
& rsPropertyName
,
523 const css::uno::Reference
<css::beans::XPropertyChangeListener
>& rxListener
)
524 throw(css::beans::UnknownPropertyException
,
525 css::lang::WrappedTargetException
,
526 css::uno::RuntimeException
, std::exception
)
528 ThemeItem
eItem (__AnyItem
);
529 if (rsPropertyName
.getLength() > 0)
531 PropertyNameToIdMap::const_iterator
iId (maPropertyNameToIdMap
.find(rsPropertyName
));
532 if (iId
== maPropertyNameToIdMap
.end())
533 throw beans::UnknownPropertyException();
535 const PropertyType
eType (GetPropertyType(iId
->second
));
536 if (eType
== PT_Invalid
)
537 throw beans::UnknownPropertyException();
541 ChangeListenerContainer
* pContainer
= GetChangeListeners(eItem
, false);
542 if (pContainer
!= NULL
)
544 ChangeListenerContainer::iterator
iListener (::std::find(pContainer
->begin(), pContainer
->end(), rxListener
));
545 if (iListener
!= pContainer
->end())
547 pContainer
->erase(iListener
);
549 // Remove the listener container when empty.
550 if (pContainer
->empty())
551 maChangeListeners
.erase(eItem
);
556 void SAL_CALL
Theme::addVetoableChangeListener(
557 const ::rtl::OUString
& rsPropertyName
,
558 const css::uno::Reference
<css::beans::XVetoableChangeListener
>& rxListener
)
559 throw(css::beans::UnknownPropertyException
,
560 css::lang::WrappedTargetException
,
561 css::uno::RuntimeException
, std::exception
)
563 ThemeItem
eItem (__AnyItem
);
564 if (rsPropertyName
.getLength() > 0)
566 PropertyNameToIdMap::const_iterator
iId (maPropertyNameToIdMap
.find(rsPropertyName
));
567 if (iId
== maPropertyNameToIdMap
.end())
568 throw beans::UnknownPropertyException();
570 const PropertyType
eType (GetPropertyType(iId
->second
));
571 if (eType
== PT_Invalid
)
572 throw beans::UnknownPropertyException();
576 VetoableListenerContainer
* pListeners
= GetVetoableListeners(eItem
, true);
577 if (pListeners
!= NULL
)
578 pListeners
->push_back(rxListener
);
581 void SAL_CALL
Theme::removeVetoableChangeListener(
582 const ::rtl::OUString
& rsPropertyName
,
583 const css::uno::Reference
<css::beans::XVetoableChangeListener
>& rxListener
)
584 throw(css::beans::UnknownPropertyException
,
585 css::lang::WrappedTargetException
,
586 css::uno::RuntimeException
, std::exception
)
588 ThemeItem
eItem (__AnyItem
);
589 if (rsPropertyName
.getLength() > 0)
591 PropertyNameToIdMap::const_iterator
iId (maPropertyNameToIdMap
.find(rsPropertyName
));
592 if (iId
== maPropertyNameToIdMap
.end())
593 throw beans::UnknownPropertyException();
595 const PropertyType
eType (GetPropertyType(iId
->second
));
596 if (eType
== PT_Invalid
)
597 throw beans::UnknownPropertyException();
601 VetoableListenerContainer
* pContainer
= GetVetoableListeners(eItem
, false);
602 if (pContainer
!= NULL
)
604 VetoableListenerContainer::iterator
iListener (::std::find(pContainer
->begin(), pContainer
->end(), rxListener
));
605 if (iListener
!= pContainer
->end())
607 pContainer
->erase(iListener
);
608 // Remove container when empty.
609 if (pContainer
->empty())
610 maVetoableListeners
.erase(eItem
);
615 css::uno::Sequence
<css::beans::Property
> SAL_CALL
Theme::getProperties()
616 throw(css::uno::RuntimeException
, std::exception
)
618 ::std::vector
<beans::Property
> aProperties
;
620 for (sal_Int32
nItem(__Begin
),nEnd(__End
); nItem
!=nEnd
; ++nItem
)
622 const ThemeItem
eItem (static_cast<ThemeItem
>(nItem
));
623 const PropertyType
eType (GetPropertyType(eItem
));
624 if (eType
== PT_Invalid
)
627 const beans::Property
aProperty(
628 maPropertyIdToNameMap
[eItem
],
632 aProperties
.push_back(aProperty
);
635 return css::uno::Sequence
<css::beans::Property
>(
636 &aProperties
.front(),
640 beans::Property SAL_CALL
Theme::getPropertyByName (const ::rtl::OUString
& rsPropertyName
)
641 throw(css::beans::UnknownPropertyException
,
642 css::uno::RuntimeException
, std::exception
)
644 PropertyNameToIdMap::const_iterator
iId (maPropertyNameToIdMap
.find(rsPropertyName
));
645 if (iId
== maPropertyNameToIdMap
.end())
646 throw beans::UnknownPropertyException();
648 const PropertyType
eType (GetPropertyType(iId
->second
));
649 if (eType
== PT_Invalid
)
650 throw beans::UnknownPropertyException();
652 const ThemeItem
eItem (iId
->second
);
654 return beans::Property(
661 sal_Bool SAL_CALL
Theme::hasPropertyByName (const ::rtl::OUString
& rsPropertyName
)
662 throw(css::uno::RuntimeException
, std::exception
)
664 PropertyNameToIdMap::const_iterator
iId (maPropertyNameToIdMap
.find(rsPropertyName
));
665 if (iId
== maPropertyNameToIdMap
.end())
668 const PropertyType
eType (GetPropertyType(iId
->second
));
669 if (eType
== PT_Invalid
)
675 void Theme::SetupPropertyMaps()
677 maPropertyIdToNameMap
.resize(__Post_Rect
);
678 maImages
.resize(__Image_Color
- __Pre_Image
- 1);
679 maColors
.resize(__Color_Paint
- __Image_Color
- 1);
680 maPaints
.resize(__Paint_Int
- __Color_Paint
- 1);
681 maIntegers
.resize(__Int_Bool
- __Paint_Int
- 1);
682 maBooleans
.resize(__Bool_Rect
- __Int_Bool
- 1);
683 maRectangles
.resize(__Post_Rect
- __Bool_Rect
- 1);
685 #define AddEntry(e) maPropertyNameToIdMap[OUString(#e)]=e; maPropertyIdToNameMap[e]=#e
687 AddEntry(Image_Grip
);
688 AddEntry(Image_Expand
);
689 AddEntry(Image_Collapse
);
690 AddEntry(Image_TabBarMenu
);
691 AddEntry(Image_PanelMenu
);
692 AddEntry(Image_ToolBoxItemSeparator
);
693 AddEntry(Image_Closer
);
694 AddEntry(Image_CloseIndicator
);
696 AddEntry(Color_DeckTitleFont
);
697 AddEntry(Color_PanelTitleFont
);
698 AddEntry(Color_TabMenuSeparator
);
699 AddEntry(Color_TabItemBorder
);
700 AddEntry(Color_DropDownBorder
);
701 AddEntry(Color_Highlight
);
702 AddEntry(Color_HighlightText
);
704 AddEntry(Paint_DeckBackground
);
705 AddEntry(Paint_DeckTitleBarBackground
);
706 AddEntry(Paint_PanelBackground
);
707 AddEntry(Paint_PanelTitleBarBackground
);
708 AddEntry(Paint_TabBarBackground
);
709 AddEntry(Paint_TabItemBackgroundNormal
);
710 AddEntry(Paint_TabItemBackgroundHighlight
);
711 AddEntry(Paint_HorizontalBorder
);
712 AddEntry(Paint_VerticalBorder
);
713 AddEntry(Paint_ToolBoxBackground
);
714 AddEntry(Paint_ToolBoxBorderTopLeft
);
715 AddEntry(Paint_ToolBoxBorderCenterCorners
);
716 AddEntry(Paint_ToolBoxBorderBottomRight
);
717 AddEntry(Paint_DropDownBackground
);
719 AddEntry(Int_DeckTitleBarHeight
);
720 AddEntry(Int_DeckBorderSize
);
721 AddEntry(Int_DeckSeparatorHeight
);
722 AddEntry(Int_PanelTitleBarHeight
);
723 AddEntry(Int_TabMenuPadding
);
724 AddEntry(Int_TabMenuSeparatorPadding
);
725 AddEntry(Int_TabItemWidth
);
726 AddEntry(Int_TabItemHeight
);
727 AddEntry(Int_DeckLeftPadding
);
728 AddEntry(Int_DeckTopPadding
);
729 AddEntry(Int_DeckRightPadding
);
730 AddEntry(Int_DeckBottomPadding
);
731 AddEntry(Int_TabBarLeftPadding
);
732 AddEntry(Int_TabBarTopPadding
);
733 AddEntry(Int_TabBarRightPadding
);
734 AddEntry(Int_TabBarBottomPadding
);
735 AddEntry(Int_ButtonCornerRadius
);
737 AddEntry(Bool_UseSymphonyIcons
);
738 AddEntry(Bool_UseSystemColors
);
739 AddEntry(Bool_UseToolBoxItemSeparator
);
740 AddEntry(Bool_IsHighContrastModeActive
);
742 AddEntry(Rect_ToolBoxPadding
);
743 AddEntry(Rect_ToolBoxBorder
);
747 maRawValues
.resize(maPropertyIdToNameMap
.size());
750 Theme::PropertyType
Theme::GetPropertyType (const ThemeItem eItem
)
757 case Image_TabBarMenu
:
758 case Image_PanelMenu
:
759 case Image_ToolBoxItemSeparator
:
761 case Image_CloseIndicator
:
764 case Color_DeckTitleFont
:
765 case Color_PanelTitleFont
:
766 case Color_TabMenuSeparator
:
767 case Color_TabItemBorder
:
768 case Color_DropDownBorder
:
769 case Color_Highlight
:
770 case Color_HighlightText
:
773 case Paint_DeckBackground
:
774 case Paint_DeckTitleBarBackground
:
775 case Paint_PanelBackground
:
776 case Paint_PanelTitleBarBackground
:
777 case Paint_TabBarBackground
:
778 case Paint_TabItemBackgroundNormal
:
779 case Paint_TabItemBackgroundHighlight
:
780 case Paint_HorizontalBorder
:
781 case Paint_VerticalBorder
:
782 case Paint_ToolBoxBackground
:
783 case Paint_ToolBoxBorderTopLeft
:
784 case Paint_ToolBoxBorderCenterCorners
:
785 case Paint_ToolBoxBorderBottomRight
:
786 case Paint_DropDownBackground
:
789 case Int_DeckTitleBarHeight
:
790 case Int_DeckBorderSize
:
791 case Int_DeckSeparatorHeight
:
792 case Int_PanelTitleBarHeight
:
793 case Int_TabMenuPadding
:
794 case Int_TabMenuSeparatorPadding
:
795 case Int_TabItemWidth
:
796 case Int_TabItemHeight
:
797 case Int_DeckLeftPadding
:
798 case Int_DeckTopPadding
:
799 case Int_DeckRightPadding
:
800 case Int_DeckBottomPadding
:
801 case Int_TabBarLeftPadding
:
802 case Int_TabBarTopPadding
:
803 case Int_TabBarRightPadding
:
804 case Int_TabBarBottomPadding
:
805 case Int_ButtonCornerRadius
:
808 case Bool_UseSymphonyIcons
:
809 case Bool_UseSystemColors
:
810 case Bool_UseToolBoxItemSeparator
:
811 case Bool_IsHighContrastModeActive
:
814 case Rect_ToolBoxBorder
:
815 case Rect_ToolBoxPadding
:
823 css::uno::Type
Theme::GetCppuType (const PropertyType eType
)
828 return cppu::UnoType
<rtl::OUString
>::get();
831 return cppu::UnoType
<sal_uInt32
>::get();
834 return cppu::UnoType
<void>::get();
837 return cppu::UnoType
<sal_Int32
>::get();
840 return cppu::UnoType
<sal_Bool
>::get();
843 return cppu::UnoType
<awt::Rectangle
>::get();
847 return cppu::UnoType
<void>::get();
851 sal_Int32
Theme::GetIndex (const ThemeItem eItem
, const PropertyType eType
)
856 return eItem
- __Pre_Image
-1;
858 return eItem
- __Image_Color
-1;
860 return eItem
- __Color_Paint
-1;
862 return eItem
- __Paint_Int
-1;
864 return eItem
- __Int_Bool
-1;
866 return eItem
- __Bool_Rect
-1;
874 Theme::VetoableListenerContainer
* Theme::GetVetoableListeners (
875 const ThemeItem eItem
,
878 VetoableListeners::iterator
iContainer (maVetoableListeners
.find(eItem
));
879 if (iContainer
!= maVetoableListeners
.end())
880 return &iContainer
->second
;
883 maVetoableListeners
[eItem
] = VetoableListenerContainer();
884 return &maVetoableListeners
[eItem
];
890 Theme::ChangeListenerContainer
* Theme::GetChangeListeners (
891 const ThemeItem eItem
,
894 ChangeListeners::iterator
iContainer (maChangeListeners
.find(eItem
));
895 if (iContainer
!= maChangeListeners
.end())
896 return &iContainer
->second
;
899 maChangeListeners
[eItem
] = ChangeListenerContainer();
900 return &maChangeListeners
[eItem
];
906 bool Theme::DoVetoableListenersVeto (
907 const VetoableListenerContainer
* pListeners
,
908 const beans::PropertyChangeEvent
& rEvent
)
910 if (pListeners
== NULL
)
913 VetoableListenerContainer
aListeners (*pListeners
);
916 for (VetoableListenerContainer::const_iterator
917 iListener(aListeners
.begin()),
918 iEnd(aListeners
.end());
922 (*iListener
)->vetoableChange(rEvent
);
925 catch(const beans::PropertyVetoException
&)
929 catch(const Exception
&)
931 // Ignore any other errors (such as disposed listeners).
936 void Theme::BroadcastPropertyChange (
937 const ChangeListenerContainer
* pListeners
,
938 const beans::PropertyChangeEvent
& rEvent
)
940 if (pListeners
== NULL
)
943 const ChangeListenerContainer
aListeners (*pListeners
);
946 for (ChangeListenerContainer::const_iterator
947 iListener(aListeners
.begin()),
948 iEnd(aListeners
.end());
952 (*iListener
)->propertyChange(rEvent
);
955 catch(const Exception
&)
957 // Ignore any errors (such as disposed listeners).
961 void Theme::ProcessNewValue (
963 const ThemeItem eItem
,
964 const PropertyType eType
)
966 const sal_Int32
nIndex (GetIndex (eItem
, eType
));
971 ::rtl::OUString sURL
;
974 maImages
[nIndex
] = Tools::GetImage(sURL
, NULL
);
980 sal_Int32
nColorValue (0);
981 if (rValue
>>= nColorValue
)
983 maColors
[nIndex
] = Color(nColorValue
);
989 maPaints
[nIndex
] = Paint::Create(rValue
);
994 sal_Int32
nValue (0);
995 if (rValue
>>= nValue
)
997 maIntegers
[nIndex
] = nValue
;
1003 bool nValue (false);
1004 if (rValue
>>= nValue
)
1006 maBooleans
[nIndex
] = nValue
;
1007 if (eItem
== Bool_IsHighContrastModeActive
)
1009 mbIsHighContrastModeSetManually
= true;
1010 mbIsHighContrastMode
= maBooleans
[nIndex
];
1013 else if (eItem
== Bool_UseSystemColors
)
1022 awt::Rectangle aBox
;
1023 if (rValue
>>= aBox
)
1025 maRectangles
[nIndex
] = Rectangle(
1034 OSL_ASSERT(eType
!= PT_Invalid
);
1035 throw RuntimeException();
1039 } } // end of namespace sfx2::sidebar
1041 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */