1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 #include <ColorListener.hxx>
20 #include <svl/hint.hxx>
21 #include <vcl/settings.hxx>
22 #include <vcl/event.hxx>
23 
24 #include <strings.hxx>
25 
26 
27 namespace rptui
28 {
29 
OColorListener(vcl::Window * _pParent,const OUString & _sColorEntry)30 OColorListener::OColorListener(vcl::Window* _pParent ,const OUString& _sColorEntry)
31 : Window(_pParent)
32 ,m_sColorEntry(_sColorEntry)
33 ,m_nColor(COL_LIGHTBLUE)
34 ,m_bCollapsed(false)
35 ,m_bMarked(false)
36 {
37     StartListening(m_aExtendedColorConfig);
38     m_nColor = m_aExtendedColorConfig.GetColorValue(CFG_REPORTDESIGNER,m_sColorEntry).getColor();
39     m_nTextBoundaries = m_aColorConfig.GetColorValue(::svtools::DOCBOUNDARIES).nColor;
40 }
41 
~OColorListener()42 OColorListener::~OColorListener()
43 {
44     disposeOnce();
45 }
46 
dispose()47 void OColorListener::dispose()
48 {
49     EndListening(m_aExtendedColorConfig);
50     vcl::Window::dispose();
51 }
52 
Notify(SfxBroadcaster &,SfxHint const & rHint)53 void OColorListener::Notify(SfxBroadcaster & /*rBc*/, SfxHint const & rHint)
54 {
55     if (rHint.GetId() == SfxHintId::ColorsChanged)
56     {
57         m_nColor = m_aExtendedColorConfig.GetColorValue(CFG_REPORTDESIGNER,m_sColorEntry).getColor();
58         m_nTextBoundaries = m_aColorConfig.GetColorValue(::svtools::DOCBOUNDARIES).nColor;
59         Invalidate(InvalidateFlags::NoChildren|InvalidateFlags::NoErase);
60     }
61 }
62 
DataChanged(const DataChangedEvent & rDCEvt)63 void OColorListener::DataChanged( const DataChangedEvent& rDCEvt )
64 {
65     Window::DataChanged( rDCEvt );
66 
67     if ( (rDCEvt.GetType() == DataChangedEventType::SETTINGS) &&
68          (rDCEvt.GetFlags() & AllSettingsFlags::STYLE) )
69     {
70         ImplInitSettings();
71         Invalidate();
72     }
73 }
74 
setCollapsed(bool _bCollapsed)75 void OColorListener::setCollapsed(bool _bCollapsed)
76 {
77     if ( m_bCollapsed != _bCollapsed )
78     {
79         m_bCollapsed = _bCollapsed;
80         m_aCollapsedLink.Call(*this);
81     }
82 }
83 
setMarked(bool _bMark)84 void OColorListener::setMarked(bool _bMark)
85 {
86     if ( m_bMarked != _bMark)
87     {
88         m_bMarked = _bMark;
89         Invalidate(InvalidateFlags::NoChildren|InvalidateFlags::NoErase);
90     }
91 }
92 
93 }
94 
95 
96 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
97