xref: /trunk/main/chart2/source/inc/RangeHighlighter.hxx (revision 91144cd0085a7583d2099b982122deb2184ab956)
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 #ifndef CHART2_RANGEHIGHLIGHTER_HXX
24 #define CHART2_RANGEHIGHLIGHTER_HXX
25 
26 #include "MutexContainer.hxx"
27 #include <cppuhelper/compbase2.hxx>
28 #include <com/sun/star/chart2/data/XRangeHighlighter.hpp>
29 #include <com/sun/star/view/XSelectionSupplier.hpp>
30 #include <com/sun/star/beans/XPropertySet.hpp>
31 
32 namespace com { namespace sun { namespace star {
33 namespace chart2 {
34     class XDiagram;
35     class XDataSeries;
36     class XAxis;
37 }}}}
38 
39 namespace chart
40 {
41 
42 namespace impl
43 {
44 typedef ::cppu::WeakComponentImplHelper2<
45         ::com::sun::star::chart2::data::XRangeHighlighter,
46         ::com::sun::star::view::XSelectionChangeListener
47     >
48     RangeHighlighter_Base;
49 }
50 
51 class RangeHighlighter :
52         public MutexContainer,
53         public impl::RangeHighlighter_Base
54 {
55 public:
56     explicit RangeHighlighter(
57         const ::com::sun::star::uno::Reference<
58             ::com::sun::star::view::XSelectionSupplier > & xSelectionSupplier );
59     virtual ~RangeHighlighter();
60 
61 protected:
62     // ____ XRangeHighlighter ____
63     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::chart2::data::HighlightedRange > SAL_CALL getSelectedRanges();
64     virtual void SAL_CALL addSelectionChangeListener(
65         const ::com::sun::star::uno::Reference< ::com::sun::star::view::XSelectionChangeListener >& xListener );
66     virtual void SAL_CALL removeSelectionChangeListener(
67         const ::com::sun::star::uno::Reference< ::com::sun::star::view::XSelectionChangeListener >& xListener );
68 
69     // ____ XSelectionChangeListener ____
70     virtual void SAL_CALL selectionChanged(
71         const ::com::sun::star::lang::EventObject& aEvent );
72 
73     // ____ XEventListener (base of XSelectionChangeListener) ____
74     virtual void SAL_CALL disposing(
75         const ::com::sun::star::lang::EventObject& Source );
76 
77     // ____ WeakComponentImplHelperBase ____
78     // is called when dispose() is called at this component
79     virtual void SAL_CALL disposing();
80 
81 private:
82     void fireSelectionEvent();
83     void startListening();
84     void stopListening();
85     void determineRanges();
86 
87     void fillRangesForDiagram( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDiagram > & xDiagram );
88     void fillRangesForDataSeries( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDataSeries > & xSeries );
89     void fillRangesForCategories( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XAxis > & xAxis );
90     void fillRangesForDataPoint( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & xDataSeries, sal_Int32 nIndex );
91     void fillRangesForErrorBars( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > & xErrorBar,
92                                  const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDataSeries > & xDataSeries );
93 
94     ::com::sun::star::uno::Reference< ::com::sun::star::view::XSelectionSupplier >
95         m_xSelectionSupplier;
96     ::com::sun::star::uno::Reference< ::com::sun::star::view::XSelectionChangeListener >
97         m_xListener;
98     ::com::sun::star::uno::Sequence< ::com::sun::star::chart2::data::HighlightedRange >
99         m_aSelectedRanges;
100     sal_Int32 m_nAddedListenerCount;
101     bool m_bIncludeHiddenCells;
102 };
103 
104 } //  namespace chart
105 
106 // CHART2_RANGEHIGHLIGHTER_HXX
107 #endif
108