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 28 #ifndef TOOLKIT_ROADMAP_CONTROL_HXX 29 #define TOOLKIT_ROADMAP_CONTROL_HXX 30 31 32 #include <toolkit/controls/unocontrols.hxx> 33 #include <toolkit/controls/unocontrolmodel.hxx> 34 #include <toolkit/helper/servicenames.hxx> 35 #include <toolkit/controls/roadmapentry.hxx> 36 #include <com/sun/star/container/XContainer.hpp> 37 #include <com/sun/star/lang/XSingleServiceFactory.hpp> 38 #include <com/sun/star/beans/XPropertyChangeListener.hpp> 39 #include <com/sun/star/container/XIndexContainer.hpp> 40 #include <com/sun/star/container/XContainerListener.hpp> 41 #include <com/sun/star/awt/XItemListener.hpp> 42 #include <com/sun/star/awt/XItemEventBroadcaster.hpp> 43 #include <cppuhelper/implbase2.hxx> 44 #include <cppuhelper/implbase3.hxx> 45 #include <cppuhelper/implbase4.hxx> 46 47 48 #include <comphelper/uno3.hxx> 49 50 //........................................................................ 51 namespace toolkit 52 { 53 //........................................................................ 54 55 typedef GraphicControlModel UnoControlRoadmapModel_Base; 56 57 58 typedef ::cppu::ImplHelper3 < ::com::sun::star::lang::XSingleServiceFactory 59 , ::com::sun::star::container::XContainer 60 , ::com::sun::star::container::XIndexContainer 61 > UnoControlRoadmapModel_IBase; 62 63 64 65 typedef UnoControlBase UnoControlRoadmap_Base; 66 typedef ::cppu::ImplHelper4 < ::com::sun::star::awt::XItemEventBroadcaster 67 , ::com::sun::star::container::XContainerListener 68 , ::com::sun::star::awt::XItemListener 69 , ::com::sun::star::beans::XPropertyChangeListener 70 > UnoControlRoadmap_IBase; 71 72 73 74 75 typedef ::cppu::ImplHelper2< ::com::sun::star::container::XContainerListener, 76 ::com::sun::star::awt::XItemEventBroadcaster> SVTXRoadmap_Base; 77 78 79 using namespace ::com::sun::star::uno; 80 using namespace ::com::sun::star::awt; 81 using namespace ::com::sun::star::lang; 82 using namespace ::com::sun::star::beans; 83 using namespace ::com::sun::star::container; 84 85 86 // =================================================================== 87 // = UnoControlRoadmapModel 88 // =================================================================== 89 class UnoControlRoadmapModel : public UnoControlRoadmapModel_Base, 90 public UnoControlRoadmapModel_IBase 91 92 { 93 private: 94 // PropertyChangeListenerMultiplexer maPropertyListeners; 95 96 typedef ::std::vector< Reference< XInterface > > RoadmapItemHolderList; 97 98 ContainerListenerMultiplexer maContainerListeners; 99 RoadmapItemHolderList maRoadmapItems; 100 101 void MakeRMItemValidation( sal_Int32 Index, Reference< XInterface > xRoadmapItem ); 102 ContainerEvent GetContainerEvent(sal_Int32 Index, Reference< XInterface > ); 103 void SetRMItemDefaultProperties( const sal_Int32 _Index, Reference< XInterface > ); 104 sal_Int16 GetCurrentItemID( Reference< XPropertySet > xPropertySet ); 105 sal_Int32 GetUniqueID(); 106 107 108 protected: 109 ::com::sun::star::uno::Any ImplGetDefaultValue( sal_uInt16 nPropId ) const; 110 ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); 111 112 public: 113 UnoControlRoadmapModel( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory ); 114 UnoControlRoadmapModel( const UnoControlRoadmapModel& rModel ) : 115 UnoControlRoadmapModel_Base( rModel ), 116 UnoControlRoadmapModel_IBase( rModel ), 117 maContainerListeners( *this ) {} 118 UnoControlModel* Clone() const { return new UnoControlRoadmapModel( *this ); } 119 120 121 // XTypeProvider 122 DECLARE_XTYPEPROVIDER( ) 123 124 125 // ::com::sun::star::io::XPersistObject 126 ::rtl::OUString SAL_CALL getServiceName() throw(::com::sun::star::uno::RuntimeException); 127 128 // ::com::sun::star::lang::XServiceInfo 129 DECLIMPL_SERVICEINFO_DERIVED( UnoControlRoadmapModel, UnoControlRoadmapModel_Base, szServiceName2_UnoControlRoadmapModel ) 130 131 sal_Int32 SAL_CALL getCount() throw (RuntimeException); 132 virtual Any SAL_CALL getByIndex( sal_Int32 Index ) throw (IndexOutOfBoundsException, WrappedTargetException, RuntimeException ); 133 134 virtual void SAL_CALL insertByIndex( sal_Int32 Index, const Any & _Element) throw (IllegalArgumentException, IndexOutOfBoundsException, WrappedTargetException, RuntimeException ); 135 virtual void SAL_CALL removeByIndex( sal_Int32 Index ) throw (IndexOutOfBoundsException, WrappedTargetException, RuntimeException ); 136 virtual void SAL_CALL replaceByIndex( sal_Int32 Index, const Any & _Element) throw (IllegalArgumentException, IndexOutOfBoundsException, WrappedTargetException, RuntimeException ); 137 138 virtual void SAL_CALL addContainerListener( const Reference< XContainerListener >& xListener ) throw (RuntimeException); 139 virtual void SAL_CALL removeContainerListener( const Reference< XContainerListener >& xListener ) throw (RuntimeException); 140 141 ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) { return UnoControlRoadmapModel_Base::queryInterface(rType); } 142 ::com::sun::star::uno::Any SAL_CALL queryAggregation( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); 143 void SAL_CALL acquire() throw() { UnoControlRoadmapModel_Base::acquire(); } 144 void SAL_CALL release() throw() { UnoControlRoadmapModel_Base::release(); } 145 146 147 // ::com::sun::star::beans::XPropertySet 148 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw (::com::sun::star::uno::RuntimeException); 149 150 151 virtual Reference< XInterface > SAL_CALL createInstance( ) throw (Exception, RuntimeException); 152 virtual Reference< XInterface > SAL_CALL createInstanceWithArguments( const Sequence< Any >& aArguments ) throw (Exception, RuntimeException); 153 154 virtual Type SAL_CALL getElementType() throw (RuntimeException); 155 156 virtual sal_Bool SAL_CALL hasElements() throw (RuntimeException); 157 158 }; 159 160 161 // =================================================================== 162 // = UnoRoadmapControl 163 // =================================================================== 164 class UnoRoadmapControl : public UnoControlRoadmap_Base, 165 public UnoControlRoadmap_IBase 166 { 167 private: 168 ItemListenerMultiplexer maItemListeners; 169 public: 170 UnoRoadmapControl( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory ); 171 ::rtl::OUString GetComponentServiceName(); 172 173 void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException) { UnoControlBase::disposing( Source ); } 174 175 void SAL_CALL dispose( ) throw(::com::sun::star::uno::RuntimeException); 176 177 178 sal_Bool SAL_CALL setModel(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& Model) throw ( ::com::sun::star::uno::RuntimeException ); 179 180 void SAL_CALL elementInserted( const ::com::sun::star::container::ContainerEvent& rEvent )throw(::com::sun::star::uno::RuntimeException); 181 void SAL_CALL elementRemoved( const ::com::sun::star::container::ContainerEvent& rEvent )throw(::com::sun::star::uno::RuntimeException); 182 void SAL_CALL elementReplaced( const ::com::sun::star::container::ContainerEvent& rEvent )throw(::com::sun::star::uno::RuntimeException); 183 184 virtual void SAL_CALL addItemListener( const Reference< XItemListener >& l ) throw (RuntimeException); 185 virtual void SAL_CALL removeItemListener( const Reference< XItemListener >& l ) throw (RuntimeException); 186 187 188 virtual void SAL_CALL itemStateChanged( const ItemEvent& rEvent ) throw (RuntimeException); 189 190 virtual void SAL_CALL propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& evt ) throw (::com::sun::star::uno::RuntimeException); 191 192 // XTypeProvider 193 DECLARE_XTYPEPROVIDER( ) 194 DECLARE_XINTERFACE() 195 196 // ::com::sun::star::lang::XServiceInfo 197 DECLIMPL_SERVICEINFO_DERIVED( UnoRoadmapControl, UnoControlBase, szServiceName2_UnoControlRoadmap ) 198 }; 199 200 //........................................................................ 201 } // toolkit 202 //........................................................................ 203 204 205 206 #endif // _TOOLKIT_ROADMAP_CONTROL_HXX 207