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 _CHART_ELEMENTSELECTOR_HXX 24 #define _CHART_ELEMENTSELECTOR_HXX 25 26 #include "ServiceMacros.hxx" 27 #include "ObjectHierarchy.hxx" 28 #include <com/sun/star/lang/XServiceInfo.hpp> 29 #include <cppuhelper/implbase1.hxx> 30 #include <svtools/toolboxcontroller.hxx> 31 32 #include <vcl/lstbox.hxx> 33 #include <cppuhelper/weakref.hxx> 34 35 #include <memory> 36 37 //............................................................................. 38 namespace chart 39 { 40 //............................................................................. 41 42 struct ListBoxEntryData 43 { 44 rtl::OUString UIName; 45 ObjectHierarchy::tOID OID; 46 sal_Int32 nHierarchyDepth; 47 ListBoxEntryDatachart::ListBoxEntryData48 ListBoxEntryData() : nHierarchyDepth(0) 49 { 50 } 51 }; 52 53 class SelectorListBox : public ListBox 54 { 55 public: 56 SelectorListBox( Window* pParent, WinBits nStyle ); 57 virtual ~SelectorListBox(); 58 59 virtual void Select(); 60 virtual long Notify( NotifyEvent& rNEvt ); 61 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible(); 62 63 void ReleaseFocus_Impl(); 64 65 void SetChartController( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController >& xChartController ); 66 void UpdateChartElementsListAndSelection(); 67 68 private: 69 ::com::sun::star::uno::WeakReference< 70 ::com::sun::star::frame::XController > m_xChartController; 71 72 ::std::vector< ListBoxEntryData > m_aEntries; 73 74 bool m_bReleaseFocus; 75 }; 76 77 // ------------------------------------------------------------------ 78 // ------------------------------------------------------------------ 79 80 typedef ::cppu::ImplHelper1 < ::com::sun::star::lang::XServiceInfo> ElementSelectorToolbarController_BASE; 81 82 class ElementSelectorToolbarController : public ::svt::ToolboxController 83 , ElementSelectorToolbarController_BASE 84 { 85 public: 86 ElementSelectorToolbarController( ::com::sun::star::uno::Reference< 87 ::com::sun::star::uno::XComponentContext > const & xContext ); 88 virtual ~ElementSelectorToolbarController(); 89 90 // XServiceInfo 91 APPHELPER_XSERVICEINFO_DECL() 92 APPHELPER_SERVICE_FACTORY_HELPER(ElementSelectorToolbarController) 93 94 // XInterface 95 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType ) throw (::com::sun::star::uno::RuntimeException); 96 virtual void SAL_CALL acquire() throw (); 97 virtual void SAL_CALL release() throw (); 98 99 // XInitialization 100 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); 101 // XStatusListener 102 virtual void SAL_CALL statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw ( ::com::sun::star::uno::RuntimeException ); 103 // XToolbarController 104 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); 105 106 private: 107 //no default constructor ElementSelectorToolbarController()108 ElementSelectorToolbarController(){} 109 110 private: 111 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext> m_xCC; 112 ::std::auto_ptr< SelectorListBox > m_apSelectorListBox; 113 }; 114 115 //............................................................................. 116 } //namespace chart 117 //............................................................................. 118 119 #endif 120