1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #include "precompiled_rptui.hxx"
24 #include "ColorListener.hxx"
25 #include <svl/smplhint.hxx>
26 #ifndef REPORTDESIGN_SHARED_UISTRINGS_HRC
27 #include "uistrings.hrc"
28 #endif
29 
30 #define BORDERCOLORCHANGE 191
31 //=====================================================================
32 namespace rptui
33 {
34 //=====================================================================
DBG_NAME(rpt_OColorListener)35 	DBG_NAME( rpt_OColorListener )
36 OColorListener::OColorListener(Window* _pParent	,const ::rtl::OUString& _sColorEntry)
37 : Window(_pParent)
38 ,m_sColorEntry(_sColorEntry)
39 ,m_nColor(COL_LIGHTBLUE)
40 ,m_bCollapsed(sal_False)
41 ,m_bMarked(sal_False)
42 {
43 	DBG_CTOR( rpt_OColorListener,NULL);
44 	StartListening(m_aExtendedColorConfig);
45 	m_nColor = m_aExtendedColorConfig.GetColorValue(CFG_REPORTDESIGNER,m_sColorEntry).getColor();
46 	m_nTextBoundaries = m_aColorConfig.GetColorValue(::svtools::DOCBOUNDARIES).nColor;
47 }
48 // -----------------------------------------------------------------------------
~OColorListener()49 OColorListener::~OColorListener()
50 {
51 	DBG_DTOR( rpt_OColorListener,NULL);
52 	EndListening(m_aExtendedColorConfig);
53 }
54 // -----------------------------------------------------------------------
Notify(SfxBroadcaster &,SfxHint const & rHint)55 void OColorListener::Notify(SfxBroadcaster & /*rBc*/, SfxHint const & rHint)
56 {
57     if (rHint.ISA(SfxSimpleHint)
58         && (static_cast< SfxSimpleHint const & >(rHint).GetId()
59             == SFX_HINT_COLORS_CHANGED))
60     {
61 		m_nColor = m_aExtendedColorConfig.GetColorValue(CFG_REPORTDESIGNER,m_sColorEntry).getColor();
62 		m_nTextBoundaries = m_aColorConfig.GetColorValue(::svtools::DOCBOUNDARIES).nColor;
63 		Invalidate(INVALIDATE_NOCHILDREN|INVALIDATE_NOERASE);
64 	}
65 }
66 //-----------------------------------------------------------------------------
DataChanged(const DataChangedEvent & rDCEvt)67 void OColorListener::DataChanged( const DataChangedEvent& rDCEvt )
68 {
69 	Window::DataChanged( rDCEvt );
70 
71 	if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
72 		 (rDCEvt.GetFlags() & SETTINGS_STYLE) )
73 	{
74 		ImplInitSettings();
75 		Invalidate();
76 	}
77 }
78 // -----------------------------------------------------------------------------
setCollapsed(sal_Bool _bCollapsed)79 void OColorListener::setCollapsed(sal_Bool _bCollapsed)
80 {
81     if ( m_bCollapsed != _bCollapsed )
82     {
83         m_bCollapsed = _bCollapsed;
84         if ( m_aCollapsedLink.IsSet() )
85             m_aCollapsedLink.Call(this);
86     }
87 }
88 // -----------------------------------------------------------------------------
setMarked(sal_Bool _bMark)89 void OColorListener::setMarked(sal_Bool _bMark)
90 {
91     if ( m_bMarked != _bMark)
92     {
93         m_bMarked = _bMark;
94         Invalidate(INVALIDATE_NOCHILDREN|INVALIDATE_NOERASE);
95     }
96 }
97 // =======================================================================
98 }
99 // =======================================================================
100