1*50e6b072SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*50e6b072SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*50e6b072SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*50e6b072SAndrew Rist  * distributed with this work for additional information
6*50e6b072SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*50e6b072SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*50e6b072SAndrew Rist  * "License"); you may not use this file except in compliance
9*50e6b072SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*50e6b072SAndrew Rist  *
11*50e6b072SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*50e6b072SAndrew Rist  *
13*50e6b072SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*50e6b072SAndrew Rist  * software distributed under the License is distributed on an
15*50e6b072SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*50e6b072SAndrew Rist  * KIND, either express or implied.  See the License for the
17*50e6b072SAndrew Rist  * specific language governing permissions and limitations
18*50e6b072SAndrew Rist  * under the License.
19*50e6b072SAndrew Rist  *
20*50e6b072SAndrew Rist  *************************************************************/
21*50e6b072SAndrew Rist 
22*50e6b072SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef _TOOLKIT_CONTROLS_STDTABCONTROLLERMODEL_HXX_
25cdf0e10cSrcweir #define _TOOLKIT_CONTROLS_STDTABCONTROLLERMODEL_HXX_
26cdf0e10cSrcweir 
27cdf0e10cSrcweir 
28cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp>
29cdf0e10cSrcweir #include <com/sun/star/io/XPersistObject.hpp>
30cdf0e10cSrcweir #include <com/sun/star/awt/XTabControllerModel.hpp>
31cdf0e10cSrcweir #include <com/sun/star/awt/XWindow.hpp>
32cdf0e10cSrcweir #include <com/sun/star/lang/XTypeProvider.hpp>
33cdf0e10cSrcweir #include <com/sun/star/lang/XUnoTunnel.hpp>
34cdf0e10cSrcweir #include <cppuhelper/weakagg.hxx>
35cdf0e10cSrcweir #include <toolkit/helper/macros.hxx>
36cdf0e10cSrcweir #include <toolkit/helper/servicenames.hxx>
37cdf0e10cSrcweir #include <osl/mutex.hxx>
38cdf0e10cSrcweir 
39cdf0e10cSrcweir #include <tools/list.hxx>
40cdf0e10cSrcweir #include <tools/gen.hxx>
41cdf0e10cSrcweir 
42cdf0e10cSrcweir struct UnoControlModelEntry;
43cdf0e10cSrcweir 
44cdf0e10cSrcweir DECLARE_LIST( UnoControlModelEntryListBase, UnoControlModelEntry* )
45cdf0e10cSrcweir 
46cdf0e10cSrcweir class UnoControlModelEntryList : public UnoControlModelEntryListBase
47cdf0e10cSrcweir {
48cdf0e10cSrcweir private:
49cdf0e10cSrcweir 	::rtl::OUString	maGroupName;
50cdf0e10cSrcweir 
51cdf0e10cSrcweir public:
52cdf0e10cSrcweir 					UnoControlModelEntryList();
53cdf0e10cSrcweir 					~UnoControlModelEntryList();
54cdf0e10cSrcweir 
GetName() const55cdf0e10cSrcweir 	const ::rtl::OUString&		GetName() const 						{ return maGroupName; }
SetName(const::rtl::OUString & rName)56cdf0e10cSrcweir 	void						SetName( const ::rtl::OUString& rName )	{ maGroupName = rName; }
57cdf0e10cSrcweir 
58cdf0e10cSrcweir 	void	Reset();
59cdf0e10cSrcweir 	void	DestroyEntry( sal_uInt32 nEntry );
60cdf0e10cSrcweir };
61cdf0e10cSrcweir 
62cdf0e10cSrcweir struct UnoControlModelEntry
63cdf0e10cSrcweir {
64cdf0e10cSrcweir 	sal_Bool 		bGroup;
65cdf0e10cSrcweir 	union
66cdf0e10cSrcweir 	{
67cdf0e10cSrcweir 		::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >* pxControl;
68cdf0e10cSrcweir 		UnoControlModelEntryList*	pGroup;
69cdf0e10cSrcweir 	};
70cdf0e10cSrcweir };
71cdf0e10cSrcweir 
72cdf0e10cSrcweir // Keine Referenz halten, nur temporaer fuer AutoTabOrder
73cdf0e10cSrcweir struct ComponentEntry
74cdf0e10cSrcweir {
75cdf0e10cSrcweir 	::com::sun::star::awt::XWindow*		pComponent;
76cdf0e10cSrcweir 	Point								aPos;
77cdf0e10cSrcweir };
78cdf0e10cSrcweir 
79cdf0e10cSrcweir DECLARE_LIST( ComponentEntryList, ComponentEntry* )
80cdf0e10cSrcweir 
81cdf0e10cSrcweir #define CONTROLPOS_NOTFOUND	0xFFFFFFFF
82cdf0e10cSrcweir 
83cdf0e10cSrcweir class StdTabControllerModel : 	public ::com::sun::star::awt::XTabControllerModel,
84cdf0e10cSrcweir 					            public ::com::sun::star::lang::XServiceInfo,
85cdf0e10cSrcweir 								public ::com::sun::star::io::XPersistObject,
86cdf0e10cSrcweir 								public ::com::sun::star::lang::XTypeProvider,
87cdf0e10cSrcweir 								public ::cppu::OWeakAggObject
88cdf0e10cSrcweir {
89cdf0e10cSrcweir private:
90cdf0e10cSrcweir 	::osl::Mutex				maMutex;
91cdf0e10cSrcweir 	UnoControlModelEntryList	maControls;
92cdf0e10cSrcweir 	sal_Bool					mbGroupControl;
93cdf0e10cSrcweir 
94cdf0e10cSrcweir protected:
GetMutex()95cdf0e10cSrcweir 	::osl::Mutex&			GetMutex() { return maMutex; }
96cdf0e10cSrcweir 	sal_uInt32				ImplGetControlCount( const UnoControlModelEntryList& rList ) const;
97cdf0e10cSrcweir 	void 					ImplGetControlModels( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > ** pRefs, const UnoControlModelEntryList& rList ) const;
98cdf0e10cSrcweir 	void 					ImplSetControlModels( UnoControlModelEntryList& rList, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > >& Controls ) const;
99cdf0e10cSrcweir 	sal_uInt32				ImplGetControlPos( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >  xCtrl, const UnoControlModelEntryList& rList ) const;
100cdf0e10cSrcweir 
101cdf0e10cSrcweir public:
102cdf0e10cSrcweir 							StdTabControllerModel();
103cdf0e10cSrcweir 							~StdTabControllerModel();
104cdf0e10cSrcweir 
105cdf0e10cSrcweir 	// ::com::sun::star::uno::XInterface
queryInterface(const::com::sun::star::uno::Type & rType)106cdf0e10cSrcweir 	::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); }
acquire()107cdf0e10cSrcweir 	void						SAL_CALL acquire() throw()	{ OWeakAggObject::acquire(); }
release()108cdf0e10cSrcweir 	void						SAL_CALL release() throw()	{ OWeakAggObject::release(); }
109cdf0e10cSrcweir 
110cdf0e10cSrcweir     ::com::sun::star::uno::Any	SAL_CALL queryAggregation( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
111cdf0e10cSrcweir 
112cdf0e10cSrcweir 	// ::com::sun::star::lang::XTypeProvider
113cdf0e10cSrcweir 	::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type >	SAL_CALL getTypes() throw(::com::sun::star::uno::RuntimeException);
114cdf0e10cSrcweir 	::com::sun::star::uno::Sequence< sal_Int8 >						SAL_CALL getImplementationId() throw(::com::sun::star::uno::RuntimeException);
115cdf0e10cSrcweir 
116cdf0e10cSrcweir 	// ::com::sun::star::awt::XTabControllerModel
117cdf0e10cSrcweir     sal_Bool SAL_CALL getGroupControl(  ) throw(::com::sun::star::uno::RuntimeException);
118cdf0e10cSrcweir     void SAL_CALL setGroupControl( sal_Bool GroupControl ) throw(::com::sun::star::uno::RuntimeException);
119cdf0e10cSrcweir     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);
120cdf0e10cSrcweir     ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > > SAL_CALL getControlModels(  ) throw(::com::sun::star::uno::RuntimeException);
121cdf0e10cSrcweir     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);
122cdf0e10cSrcweir     sal_Int32 SAL_CALL getGroupCount(  ) throw(::com::sun::star::uno::RuntimeException);
123cdf0e10cSrcweir     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);
124cdf0e10cSrcweir     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);
125cdf0e10cSrcweir 
126cdf0e10cSrcweir 	// ::com::sun::star::io::XPersistObject
127cdf0e10cSrcweir     ::rtl::OUString SAL_CALL getServiceName(  ) throw(::com::sun::star::uno::RuntimeException);
128cdf0e10cSrcweir     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);
129cdf0e10cSrcweir     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);
130cdf0e10cSrcweir 
131cdf0e10cSrcweir     // XServiceInfo
132cdf0e10cSrcweir 	DECLIMPL_SERVICEINFO( StdTabControllerModel, szServiceName2_TabControllerModel )
133cdf0e10cSrcweir };
134cdf0e10cSrcweir 
135cdf0e10cSrcweir 
136cdf0e10cSrcweir 
137cdf0e10cSrcweir #endif // _TOOLKIT_HELPER_STDTABCONTROLLERMODEL_HXX_
138cdf0e10cSrcweir 
139