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 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sc.hxx"
26 
27 #include "ChartRangeSelectionListener.hxx"
28 
29 #include <com/sun/star/chart2/data/XRangeHighlighter.hpp>
30 
31 #include <sfx2/viewfrm.hxx>
32 #include "tabvwsh.hxx"
33 #include "unonames.hxx"
34 #include "miscuno.hxx"
35 
36 using namespace ::com::sun::star;
37 
38 using ::com::sun::star::uno::Reference;
39 using ::com::sun::star::uno::Sequence;
40 using ::rtl::OUString;
41 
42 SC_SIMPLE_SERVICE_INFO( ScChartRangeSelectionListener, "ScChartRangeSelectionListener",
43                         SC_SERVICENAME_CHRANGEHILIGHT )
44 
ScChartRangeSelectionListener(ScTabViewShell * pViewShell)45 ScChartRangeSelectionListener::ScChartRangeSelectionListener( ScTabViewShell * pViewShell ) :
46         ScChartRangeSelectionListener_Base( m_aMutex ),
47         m_pViewShell( pViewShell )
48 {}
49 
~ScChartRangeSelectionListener()50 ScChartRangeSelectionListener::~ScChartRangeSelectionListener()
51 {}
52 
53 // ____ XModifyListener ____
selectionChanged(const lang::EventObject & aEvent)54 void SAL_CALL ScChartRangeSelectionListener::selectionChanged( const lang::EventObject& aEvent )
55     throw (uno::RuntimeException)
56 {
57     Reference< chart2::data::XRangeHighlighter > xRangeHighlighter( aEvent.Source, uno::UNO_QUERY );
58     if( xRangeHighlighter.is())
59     {
60         Sequence< chart2::data::HighlightedRange > aRanges( xRangeHighlighter->getSelectedRanges());
61 
62         // search the view on which the chart is active
63 
64         if( m_pViewShell )
65         {
66             m_pViewShell->DoChartSelection( aRanges );
67         }
68 //         SfxViewFrame *pFrame = SfxViewFrame::GetFirst( m_pDocShell );
69 //         while (pFrame)
70 //         {
71 //             SfxViewShell* pSh = pFrame->GetViewShell();
72 //             if (pSh && pSh->ISA(ScTabViewShell))
73 //             {
74 //                 ScTabViewShell* pViewSh	= (ScTabViewShell*)pSh;
75 //             }
76 //             pFrame = SfxViewFrame::GetNext( *pFrame, m_pDocShell );
77 //         }
78     }
79 }
80 
81 // ____ XEventListener ____
disposing(const lang::EventObject &)82 void SAL_CALL ScChartRangeSelectionListener::disposing( const lang::EventObject& /*Source*/ )
83     throw (uno::RuntimeException)
84 {
85 }
86 
87 // ____ WeakComponentImplHelperBase ____
disposing()88 void SAL_CALL ScChartRangeSelectionListener::disposing()
89 {
90     m_pViewShell = 0;
91 }
92