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_CONTROLS_STDTABCONTROLLERMODEL_HXX_ 29 #define _TOOLKIT_CONTROLS_STDTABCONTROLLERMODEL_HXX_ 30 31 32 #include <com/sun/star/lang/XServiceInfo.hpp> 33 #include <com/sun/star/io/XPersistObject.hpp> 34 #include <com/sun/star/awt/XTabControllerModel.hpp> 35 #include <com/sun/star/awt/XWindow.hpp> 36 #include <com/sun/star/lang/XTypeProvider.hpp> 37 #include <com/sun/star/lang/XUnoTunnel.hpp> 38 #include <cppuhelper/weakagg.hxx> 39 #include <toolkit/helper/macros.hxx> 40 #include <toolkit/helper/servicenames.hxx> 41 #include <osl/mutex.hxx> 42 43 #include <tools/list.hxx> 44 #include <tools/gen.hxx> 45 46 struct UnoControlModelEntry; 47 48 DECLARE_LIST( UnoControlModelEntryListBase, UnoControlModelEntry* ) 49 50 class UnoControlModelEntryList : public UnoControlModelEntryListBase 51 { 52 private: 53 ::rtl::OUString maGroupName; 54 55 public: 56 UnoControlModelEntryList(); 57 ~UnoControlModelEntryList(); 58 59 const ::rtl::OUString& GetName() const { return maGroupName; } 60 void SetName( const ::rtl::OUString& rName ) { maGroupName = rName; } 61 62 void Reset(); 63 void DestroyEntry( sal_uInt32 nEntry ); 64 }; 65 66 struct UnoControlModelEntry 67 { 68 sal_Bool bGroup; 69 union 70 { 71 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >* pxControl; 72 UnoControlModelEntryList* pGroup; 73 }; 74 }; 75 76 // Keine Referenz halten, nur temporaer fuer AutoTabOrder 77 struct ComponentEntry 78 { 79 ::com::sun::star::awt::XWindow* pComponent; 80 Point aPos; 81 }; 82 83 DECLARE_LIST( ComponentEntryList, ComponentEntry* ) 84 85 #define CONTROLPOS_NOTFOUND 0xFFFFFFFF 86 87 class StdTabControllerModel : public ::com::sun::star::awt::XTabControllerModel, 88 public ::com::sun::star::lang::XServiceInfo, 89 public ::com::sun::star::io::XPersistObject, 90 public ::com::sun::star::lang::XTypeProvider, 91 public ::cppu::OWeakAggObject 92 { 93 private: 94 ::osl::Mutex maMutex; 95 UnoControlModelEntryList maControls; 96 sal_Bool mbGroupControl; 97 98 protected: 99 ::osl::Mutex& GetMutex() { return maMutex; } 100 sal_uInt32 ImplGetControlCount( const UnoControlModelEntryList& rList ) const; 101 void ImplGetControlModels( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > ** pRefs, const UnoControlModelEntryList& rList ) const; 102 void ImplSetControlModels( UnoControlModelEntryList& rList, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > >& Controls ) const; 103 sal_uInt32 ImplGetControlPos( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > xCtrl, const UnoControlModelEntryList& rList ) const; 104 105 public: 106 StdTabControllerModel(); 107 ~StdTabControllerModel(); 108 109 // ::com::sun::star::uno::XInterface 110 ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) { return OWeakAggObject::queryInterface(rType); } 111 void SAL_CALL acquire() throw() { OWeakAggObject::acquire(); } 112 void SAL_CALL release() throw() { OWeakAggObject::release(); } 113 114 ::com::sun::star::uno::Any SAL_CALL queryAggregation( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); 115 116 // ::com::sun::star::lang::XTypeProvider 117 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw(::com::sun::star::uno::RuntimeException); 118 ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw(::com::sun::star::uno::RuntimeException); 119 120 // ::com::sun::star::awt::XTabControllerModel 121 sal_Bool SAL_CALL getGroupControl( ) throw(::com::sun::star::uno::RuntimeException); 122 void SAL_CALL setGroupControl( sal_Bool GroupControl ) throw(::com::sun::star::uno::RuntimeException); 123 void SAL_CALL setControlModels( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > >& Controls ) throw(::com::sun::star::uno::RuntimeException); 124 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > > SAL_CALL getControlModels( ) throw(::com::sun::star::uno::RuntimeException); 125 void SAL_CALL setGroup( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > >& Group, const ::rtl::OUString& GroupName ) throw(::com::sun::star::uno::RuntimeException); 126 sal_Int32 SAL_CALL getGroupCount( ) throw(::com::sun::star::uno::RuntimeException); 127 void SAL_CALL getGroup( sal_Int32 nGroup, ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > >& Group, ::rtl::OUString& Name ) throw(::com::sun::star::uno::RuntimeException); 128 void SAL_CALL getGroupByName( const ::rtl::OUString& Name, ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > >& Group ) throw(::com::sun::star::uno::RuntimeException); 129 130 // ::com::sun::star::io::XPersistObject 131 ::rtl::OUString SAL_CALL getServiceName( ) throw(::com::sun::star::uno::RuntimeException); 132 void SAL_CALL write( const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectOutputStream >& OutStream ) throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); 133 void SAL_CALL read( const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectInputStream >& InStream ) throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); 134 135 // XServiceInfo 136 DECLIMPL_SERVICEINFO( StdTabControllerModel, szServiceName2_TabControllerModel ) 137 }; 138 139 140 141 #endif // _TOOLKIT_HELPER_STDTABCONTROLLERMODEL_HXX_ 142 143