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 #ifndef _SVX_SIDEBAR_SELECTION_CHANGE_HANDLER_HXX_
23 #define _SVX_SIDEBAR_SELECTION_CHANGE_HANDLER_HXX_
24 
25 #include "svx/svxdllapi.h"
26 #include <sfx2/sidebar/EnumContext.hxx>
27 #include <com/sun/star/frame/XController.hpp>
28 #include <com/sun/star/view/XSelectionSupplier.hpp>
29 #include <com/sun/star/view/XSelectionChangeListener.hpp>
30 
31 #include <cppuhelper/compbase1.hxx>
32 #include <cppuhelper/basemutex.hxx>
33 
34 #include <boost/noncopyable.hpp>
35 #include <boost/function.hpp>
36 
37 namespace css = ::com::sun::star;
38 namespace cssu = ::com::sun::star::uno;
39 
40 
41 class SdrMarkView;
42 
43 
44 namespace svx { namespace sidebar {
45 
46 namespace {
47     typedef ::cppu::WeakComponentImplHelper1 <
48         css::view::XSelectionChangeListener
49         > SelectionChangeHandlerInterfaceBase;
50 }
51 
52 
53 class SVX_DLLPUBLIC SelectionChangeHandler
54     : private ::boost::noncopyable,
55       private ::cppu::BaseMutex,
56       public SelectionChangeHandlerInterfaceBase
57 {
58 public:
59     SelectionChangeHandler (
60         const boost::function<sfx2::sidebar::EnumContext::Context(void)>& rSelectionChangeCallback,
61         const cssu::Reference<css::frame::XController>& rxController,
62         const sfx2::sidebar::EnumContext::Context eDefaultContext);
63     virtual ~SelectionChangeHandler (void);
64 
65     virtual void SAL_CALL selectionChanged (const css::lang::EventObject& rEvent)
66         throw (cssu::RuntimeException);
67 
68     virtual void SAL_CALL disposing (const css::lang::EventObject& rEvent)
69         throw (cssu::RuntimeException);
70 
71     virtual void SAL_CALL disposing (void)
72         throw (cssu::RuntimeException);
73 
74     void Connect (void);
75     void Disconnect (void);
76 
77 private:
78     const boost::function<sfx2::sidebar::EnumContext::Context(void)> maSelectionChangeCallback;
79     cssu::Reference<css::frame::XController> mxController;
80     const sfx2::sidebar::EnumContext::Context meDefaultContext;
81     bool mbIsConnected;
82 };
83 
84 
85 } } // end of namespace svx::sidebar
86 
87 
88 #endif
89 
90