xref: /AOO41X/main/chart2/source/controller/main/ElementSelector.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 #ifndef _CHART_ELEMENTSELECTOR_HXX
28 #define _CHART_ELEMENTSELECTOR_HXX
29 
30 #include "ServiceMacros.hxx"
31 #include "ObjectHierarchy.hxx"
32 #include <com/sun/star/lang/XServiceInfo.hpp>
33 #include <cppuhelper/implbase1.hxx>
34 #include <svtools/toolboxcontroller.hxx>
35 
36 #include <vcl/lstbox.hxx>
37 #include <cppuhelper/weakref.hxx>
38 
39 #include <memory>
40 
41 //.............................................................................
42 namespace chart
43 {
44 //.............................................................................
45 
46 struct ListBoxEntryData
47 {
48     rtl::OUString UIName;
49     ObjectHierarchy::tOID OID;
50     sal_Int32 nHierarchyDepth;
51 
52     ListBoxEntryData() : nHierarchyDepth(0)
53     {
54     }
55 };
56 
57 class SelectorListBox : public ListBox
58 {
59     public:
60         SelectorListBox( Window* pParent, WinBits nStyle );
61         virtual ~SelectorListBox();
62 
63         virtual void Select();
64         virtual long Notify( NotifyEvent& rNEvt );
65         virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible();
66 
67         void ReleaseFocus_Impl();
68 
69         void SetChartController( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController >& xChartController );
70         void UpdateChartElementsListAndSelection();
71 
72     private:
73         ::com::sun::star::uno::WeakReference<
74             ::com::sun::star::frame::XController >   m_xChartController;
75 
76         ::std::vector< ListBoxEntryData > m_aEntries;
77 
78         bool m_bReleaseFocus;
79 };
80 
81 // ------------------------------------------------------------------
82 // ------------------------------------------------------------------
83 
84 typedef ::cppu::ImplHelper1 < ::com::sun::star::lang::XServiceInfo> ElementSelectorToolbarController_BASE;
85 
86 class ElementSelectorToolbarController : public ::svt::ToolboxController
87                                                 , ElementSelectorToolbarController_BASE
88 {
89 public:
90 	ElementSelectorToolbarController( ::com::sun::star::uno::Reference<
91 			   ::com::sun::star::uno::XComponentContext > const & xContext );
92 	virtual ~ElementSelectorToolbarController();
93 
94 	// XServiceInfo
95 	APPHELPER_XSERVICEINFO_DECL()
96 	APPHELPER_SERVICE_FACTORY_HELPER(ElementSelectorToolbarController)
97 
98     // XInterface
99      virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType ) throw (::com::sun::star::uno::RuntimeException);
100      virtual void SAL_CALL acquire() throw ();
101      virtual void SAL_CALL release() throw ();
102 
103      // XInitialization
104      virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
105      // XStatusListener
106      virtual void SAL_CALL statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw ( ::com::sun::star::uno::RuntimeException );
107      // XToolbarController
108      virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > SAL_CALL createItemWindow( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow >& Parent ) throw (::com::sun::star::uno::RuntimeException);
109 
110 private:
111 	//no default constructor
112 	ElementSelectorToolbarController(){}
113 
114 private:
115 	::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext>		   m_xCC;
116     ::std::auto_ptr< SelectorListBox > m_apSelectorListBox;
117 };
118 
119 //.............................................................................
120 } //namespace chart
121 //.............................................................................
122 
123 #endif
124