xref: /AOO41X/main/toolkit/source/controls/stdtabcontrollermodel.cxx (revision b0724fc6948542b2496e16ea247f985ee5987cfe)
1*b0724fc6SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*b0724fc6SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*b0724fc6SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*b0724fc6SAndrew Rist  * distributed with this work for additional information
6*b0724fc6SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*b0724fc6SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*b0724fc6SAndrew Rist  * "License"); you may not use this file except in compliance
9*b0724fc6SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*b0724fc6SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*b0724fc6SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*b0724fc6SAndrew Rist  * software distributed under the License is distributed on an
15*b0724fc6SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*b0724fc6SAndrew Rist  * KIND, either express or implied.  See the License for the
17*b0724fc6SAndrew Rist  * specific language governing permissions and limitations
18*b0724fc6SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*b0724fc6SAndrew Rist  *************************************************************/
21*b0724fc6SAndrew Rist 
22*b0724fc6SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_toolkit.hxx"
26cdf0e10cSrcweir #include <com/sun/star/io/XMarkableStream.hpp>
27cdf0e10cSrcweir 
28cdf0e10cSrcweir #include <toolkit/controls/stdtabcontrollermodel.hxx>
29cdf0e10cSrcweir #include <toolkit/helper/macros.hxx>
30cdf0e10cSrcweir #include <toolkit/helper/servicenames.hxx>
31cdf0e10cSrcweir #include <toolkit/helper/property.hxx>
32cdf0e10cSrcweir #include <cppuhelper/typeprovider.hxx>
33cdf0e10cSrcweir #include <rtl/memory.h>
34cdf0e10cSrcweir #include <rtl/uuid.h>
35cdf0e10cSrcweir 
36cdf0e10cSrcweir #include <tools/debug.hxx>
37cdf0e10cSrcweir 
38cdf0e10cSrcweir #define UNOCONTROL_STREAMVERSION	(short)2
39cdf0e10cSrcweir 
40cdf0e10cSrcweir //	----------------------------------------------------
41cdf0e10cSrcweir //	class UnoControlModelEntryList
42cdf0e10cSrcweir //	----------------------------------------------------
UnoControlModelEntryList()43cdf0e10cSrcweir UnoControlModelEntryList::UnoControlModelEntryList()
44cdf0e10cSrcweir {
45cdf0e10cSrcweir }
46cdf0e10cSrcweir 
~UnoControlModelEntryList()47cdf0e10cSrcweir UnoControlModelEntryList::~UnoControlModelEntryList()
48cdf0e10cSrcweir {
49cdf0e10cSrcweir 	Reset();
50cdf0e10cSrcweir }
51cdf0e10cSrcweir 
Reset()52cdf0e10cSrcweir void UnoControlModelEntryList::Reset()
53cdf0e10cSrcweir {
54cdf0e10cSrcweir 	for ( sal_uInt32 n = Count(); n; )
55cdf0e10cSrcweir 		DestroyEntry( --n );
56cdf0e10cSrcweir }
57cdf0e10cSrcweir 
DestroyEntry(sal_uInt32 nEntry)58cdf0e10cSrcweir void UnoControlModelEntryList::DestroyEntry( sal_uInt32 nEntry )
59cdf0e10cSrcweir {
60cdf0e10cSrcweir 	UnoControlModelEntry* pEntry = GetObject( nEntry );
61cdf0e10cSrcweir 
62cdf0e10cSrcweir 	if ( pEntry->bGroup )
63cdf0e10cSrcweir 		delete pEntry->pGroup;
64cdf0e10cSrcweir 	else
65cdf0e10cSrcweir 		delete pEntry->pxControl;
66cdf0e10cSrcweir 
67cdf0e10cSrcweir 	Remove( nEntry );
68cdf0e10cSrcweir 	delete pEntry;
69cdf0e10cSrcweir }
70cdf0e10cSrcweir 
71cdf0e10cSrcweir //	----------------------------------------------------
72cdf0e10cSrcweir //	class StdTabControllerModel
73cdf0e10cSrcweir //	----------------------------------------------------
StdTabControllerModel()74cdf0e10cSrcweir StdTabControllerModel::StdTabControllerModel()
75cdf0e10cSrcweir {
76cdf0e10cSrcweir 	mbGroupControl = sal_True;
77cdf0e10cSrcweir }
78cdf0e10cSrcweir 
~StdTabControllerModel()79cdf0e10cSrcweir StdTabControllerModel::~StdTabControllerModel()
80cdf0e10cSrcweir {
81cdf0e10cSrcweir }
82cdf0e10cSrcweir 
ImplGetControlCount(const UnoControlModelEntryList & rList) const83cdf0e10cSrcweir sal_uInt32 StdTabControllerModel::ImplGetControlCount( const UnoControlModelEntryList& rList ) const
84cdf0e10cSrcweir {
85cdf0e10cSrcweir 	sal_uInt32 nCount = 0;
86cdf0e10cSrcweir 	sal_uInt32 nEntries = rList.Count();
87cdf0e10cSrcweir 	for ( sal_uInt32 n = 0; n < nEntries; n++ )
88cdf0e10cSrcweir 	{
89cdf0e10cSrcweir 		UnoControlModelEntry* pEntry = rList.GetObject( n );
90cdf0e10cSrcweir 		if ( pEntry->bGroup )
91cdf0e10cSrcweir 			nCount += ImplGetControlCount( *pEntry->pGroup );
92cdf0e10cSrcweir 		else
93cdf0e10cSrcweir 			nCount++;
94cdf0e10cSrcweir 	}
95cdf0e10cSrcweir 	return nCount;
96cdf0e10cSrcweir }
97cdf0e10cSrcweir 
ImplGetControlModels(::com::sun::star::uno::Reference<::com::sun::star::awt::XControlModel> ** ppRefs,const UnoControlModelEntryList & rList) const98cdf0e10cSrcweir void StdTabControllerModel::ImplGetControlModels( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > ** ppRefs, const UnoControlModelEntryList& rList ) const
99cdf0e10cSrcweir {
100cdf0e10cSrcweir 	sal_uInt32 nEntries = rList.Count();
101cdf0e10cSrcweir 	for ( sal_uInt32 n = 0; n < nEntries; n++ )
102cdf0e10cSrcweir 	{
103cdf0e10cSrcweir 		UnoControlModelEntry* pEntry = rList.GetObject( n );
104cdf0e10cSrcweir 		if ( pEntry->bGroup )
105cdf0e10cSrcweir 			ImplGetControlModels( ppRefs, *pEntry->pGroup );
106cdf0e10cSrcweir 		else
107cdf0e10cSrcweir 		{
108cdf0e10cSrcweir 			**ppRefs = *pEntry->pxControl;
109cdf0e10cSrcweir 			(*ppRefs)++;
110cdf0e10cSrcweir 		}
111cdf0e10cSrcweir 	}
112cdf0e10cSrcweir }
113cdf0e10cSrcweir 
ImplSetControlModels(UnoControlModelEntryList & rList,const::com::sun::star::uno::Sequence<::com::sun::star::uno::Reference<::com::sun::star::awt::XControlModel>> & Controls) const114cdf0e10cSrcweir void StdTabControllerModel::ImplSetControlModels( UnoControlModelEntryList& rList, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > >& Controls ) const
115cdf0e10cSrcweir {
116cdf0e10cSrcweir 	const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > * pRefs = Controls.getConstArray();
117cdf0e10cSrcweir 	sal_uInt32 nControls = Controls.getLength();
118cdf0e10cSrcweir 	for ( sal_uInt32 n = 0; n < nControls; n++ )
119cdf0e10cSrcweir 	{
120cdf0e10cSrcweir 		UnoControlModelEntry* pNewEntry = new UnoControlModelEntry;
121cdf0e10cSrcweir 		pNewEntry->bGroup = sal_False;
122cdf0e10cSrcweir 		pNewEntry->pxControl = new ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > ;
123cdf0e10cSrcweir 		*pNewEntry->pxControl = pRefs[n];
124cdf0e10cSrcweir 		rList.Insert( pNewEntry, LIST_APPEND );
125cdf0e10cSrcweir 	}
126cdf0e10cSrcweir }
127cdf0e10cSrcweir 
ImplGetControlPos(const::com::sun::star::uno::Reference<::com::sun::star::awt::XControlModel> xCtrl,const UnoControlModelEntryList & rList) const128cdf0e10cSrcweir sal_uInt32 StdTabControllerModel::ImplGetControlPos( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >  xCtrl, const UnoControlModelEntryList& rList ) const
129cdf0e10cSrcweir {
130cdf0e10cSrcweir 	for ( sal_uInt32 n = rList.Count(); n; )
131cdf0e10cSrcweir 	{
132cdf0e10cSrcweir 		UnoControlModelEntry* pEntry = rList.GetObject( --n );
133cdf0e10cSrcweir 		if ( !pEntry->bGroup && ( *pEntry->pxControl == xCtrl ) )
134cdf0e10cSrcweir 			return n;
135cdf0e10cSrcweir 	}
136cdf0e10cSrcweir 	return CONTROLPOS_NOTFOUND;
137cdf0e10cSrcweir }
138cdf0e10cSrcweir 
ImplWriteControls(const::com::sun::star::uno::Reference<::com::sun::star::io::XObjectOutputStream> & OutStream,const::com::sun::star::uno::Sequence<::com::sun::star::uno::Reference<::com::sun::star::awt::XControlModel>> & rCtrls)139cdf0e10cSrcweir void ImplWriteControls( const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectOutputStream > & OutStream, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > >& rCtrls )
140cdf0e10cSrcweir {
141cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::io::XMarkableStream >  xMark( OutStream, ::com::sun::star::uno::UNO_QUERY );
142cdf0e10cSrcweir 	DBG_ASSERT( xMark.is(), "write: no XMarkableStream!" );
143cdf0e10cSrcweir 
144cdf0e10cSrcweir 	sal_uInt32 nStoredControls = 0;
145cdf0e10cSrcweir 	sal_Int32 nDataBeginMark = xMark->createMark();
146cdf0e10cSrcweir 
147cdf0e10cSrcweir 	OutStream->writeLong( 0L );	// DataLen
148cdf0e10cSrcweir 	OutStream->writeLong( 0L );	// nStoredControls
149cdf0e10cSrcweir 
150cdf0e10cSrcweir 	sal_uInt32 nCtrls = rCtrls.getLength();
151cdf0e10cSrcweir 	for ( sal_uInt32 n = 0; n < nCtrls; n++ )
152cdf0e10cSrcweir 	{
153cdf0e10cSrcweir 		const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >  xI = rCtrls.getConstArray()[n];
154cdf0e10cSrcweir 		::com::sun::star::uno::Reference< ::com::sun::star::io::XPersistObject >  xPO( xI, ::com::sun::star::uno::UNO_QUERY );
155cdf0e10cSrcweir 		DBG_ASSERT( xPO.is(), "write: Control doesn't support XPersistObject" );
156cdf0e10cSrcweir 		if ( xPO.is() )
157cdf0e10cSrcweir 		{
158cdf0e10cSrcweir 			OutStream->writeObject( xPO );
159cdf0e10cSrcweir 			nStoredControls++;
160cdf0e10cSrcweir 		}
161cdf0e10cSrcweir 	}
162cdf0e10cSrcweir 	sal_Int32 nDataLen = xMark->offsetToMark( nDataBeginMark );
163cdf0e10cSrcweir 	xMark->jumpToMark( nDataBeginMark );
164cdf0e10cSrcweir 	OutStream->writeLong( nDataLen );
165cdf0e10cSrcweir 	OutStream->writeLong( nStoredControls );
166cdf0e10cSrcweir 	xMark->jumpToFurthest();
167cdf0e10cSrcweir 	xMark->deleteMark(nDataBeginMark);
168cdf0e10cSrcweir }
169cdf0e10cSrcweir 
ImplReadControls(const::com::sun::star::uno::Reference<::com::sun::star::io::XObjectInputStream> & InStream)170cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > > ImplReadControls( const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectInputStream > & InStream )
171cdf0e10cSrcweir {
172cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::io::XMarkableStream >  xMark( InStream, ::com::sun::star::uno::UNO_QUERY );
173cdf0e10cSrcweir 	DBG_ASSERT( xMark.is(), "write: no XMarkableStream!" );
174cdf0e10cSrcweir 
175cdf0e10cSrcweir 	sal_Int32 nDataBeginMark = xMark->createMark();
176cdf0e10cSrcweir 
177cdf0e10cSrcweir 	sal_Int32 nDataLen = InStream->readLong();
178cdf0e10cSrcweir 	sal_uInt32 nCtrls = InStream->readLong();
179cdf0e10cSrcweir 
180cdf0e10cSrcweir 	::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > > aSeq( nCtrls );
181cdf0e10cSrcweir 	for ( sal_uInt32 n = 0; n < nCtrls; n++ )
182cdf0e10cSrcweir 	{
183cdf0e10cSrcweir 		::com::sun::star::uno::Reference< ::com::sun::star::io::XPersistObject >  xObj = InStream->readObject();
184cdf0e10cSrcweir 		::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >  xI( xObj, ::com::sun::star::uno::UNO_QUERY );
185cdf0e10cSrcweir 		aSeq.getArray()[n] = xI;
186cdf0e10cSrcweir 	}
187cdf0e10cSrcweir 
188cdf0e10cSrcweir 	// Falls bereits mehr drinsteht als diese Version kennt:
189cdf0e10cSrcweir 	xMark->jumpToMark( nDataBeginMark );
190cdf0e10cSrcweir 	InStream->skipBytes( nDataLen );
191cdf0e10cSrcweir 	xMark->deleteMark(nDataBeginMark);
192cdf0e10cSrcweir 	return aSeq;
193cdf0e10cSrcweir }
194cdf0e10cSrcweir 
195cdf0e10cSrcweir 
196cdf0e10cSrcweir // ::com::sun::star::uno::XInterface
queryAggregation(const::com::sun::star::uno::Type & rType)197cdf0e10cSrcweir ::com::sun::star::uno::Any StdTabControllerModel::queryAggregation( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException)
198cdf0e10cSrcweir {
199cdf0e10cSrcweir 	::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
200cdf0e10cSrcweir 										SAL_STATIC_CAST( ::com::sun::star::awt::XTabControllerModel*, this ),
201cdf0e10cSrcweir 										SAL_STATIC_CAST( ::com::sun::star::lang::XServiceInfo*, this ),
202cdf0e10cSrcweir 										SAL_STATIC_CAST( ::com::sun::star::io::XPersistObject*, this ),
203cdf0e10cSrcweir 										SAL_STATIC_CAST( ::com::sun::star::lang::XTypeProvider*, this ) );
204cdf0e10cSrcweir 	return (aRet.hasValue() ? aRet : OWeakAggObject::queryAggregation( rType ));
205cdf0e10cSrcweir }
206cdf0e10cSrcweir 
207cdf0e10cSrcweir // ::com::sun::star::lang::XTypeProvider
208cdf0e10cSrcweir IMPL_XTYPEPROVIDER_START( StdTabControllerModel )
209cdf0e10cSrcweir 	getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTabControllerModel>* ) NULL ),
210cdf0e10cSrcweir 	getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::lang::XServiceInfo>* ) NULL ),
211cdf0e10cSrcweir 	getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::io::XPersistObject>* ) NULL )
212cdf0e10cSrcweir IMPL_XTYPEPROVIDER_END
213cdf0e10cSrcweir 
214cdf0e10cSrcweir sal_Bool StdTabControllerModel::getGroupControl(  ) throw(::com::sun::star::uno::RuntimeException)
215cdf0e10cSrcweir {
216cdf0e10cSrcweir 	::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
217cdf0e10cSrcweir 
218cdf0e10cSrcweir 	return mbGroupControl;
219cdf0e10cSrcweir }
220cdf0e10cSrcweir 
setGroupControl(sal_Bool GroupControl)221cdf0e10cSrcweir void StdTabControllerModel::setGroupControl( sal_Bool GroupControl ) throw(::com::sun::star::uno::RuntimeException)
222cdf0e10cSrcweir {
223cdf0e10cSrcweir 	::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
224cdf0e10cSrcweir 
225cdf0e10cSrcweir 	mbGroupControl = GroupControl;
226cdf0e10cSrcweir }
227cdf0e10cSrcweir 
setControlModels(const::com::sun::star::uno::Sequence<::com::sun::star::uno::Reference<::com::sun::star::awt::XControlModel>> & Controls)228cdf0e10cSrcweir void StdTabControllerModel::setControlModels( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > >& Controls ) throw(::com::sun::star::uno::RuntimeException)
229cdf0e10cSrcweir {
230cdf0e10cSrcweir 	::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
231cdf0e10cSrcweir 
232cdf0e10cSrcweir 	maControls.Reset();
233cdf0e10cSrcweir 	ImplSetControlModels( maControls, Controls );
234cdf0e10cSrcweir }
235cdf0e10cSrcweir 
getControlModels()236cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > > StdTabControllerModel::getControlModels(  ) throw(::com::sun::star::uno::RuntimeException)
237cdf0e10cSrcweir {
238cdf0e10cSrcweir 	::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
239cdf0e10cSrcweir 
240cdf0e10cSrcweir 	::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > > aSeq( ImplGetControlCount( maControls ) );
241cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > * pRefs = aSeq.getArray();
242cdf0e10cSrcweir 	ImplGetControlModels( &pRefs, maControls );
243cdf0e10cSrcweir 	return aSeq;
244cdf0e10cSrcweir }
245cdf0e10cSrcweir 
setGroup(const::com::sun::star::uno::Sequence<::com::sun::star::uno::Reference<::com::sun::star::awt::XControlModel>> & Group,const::rtl::OUString & GroupName)246cdf0e10cSrcweir void StdTabControllerModel::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)
247cdf0e10cSrcweir {
248cdf0e10cSrcweir 	::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
249cdf0e10cSrcweir 
250cdf0e10cSrcweir 	// Die Controls stehen eventuel flach in der Liste und werden jetzt gruppiert.
251cdf0e10cSrcweir 	// Verschachtelte Gruppen sind erstmal nicht moeglich...
252cdf0e10cSrcweir 	// Das erste Element der Gruppe welches auch schon in der flachen Liste
253cdf0e10cSrcweir 	// stand bestimmt die Position der Gruppe.
254cdf0e10cSrcweir 
255cdf0e10cSrcweir 	UnoControlModelEntry* pNewEntry = new UnoControlModelEntry;
256cdf0e10cSrcweir 	pNewEntry->bGroup = sal_True;
257cdf0e10cSrcweir 	pNewEntry->pGroup = new UnoControlModelEntryList;
258cdf0e10cSrcweir 	pNewEntry->pGroup->SetName( GroupName );
259cdf0e10cSrcweir 	ImplSetControlModels( *pNewEntry->pGroup, Group );
260cdf0e10cSrcweir 
261cdf0e10cSrcweir 	sal_Bool bInserted = sal_False;
262cdf0e10cSrcweir 	sal_uInt32 nElements = pNewEntry->pGroup->Count();
263cdf0e10cSrcweir 	for ( sal_uInt32 n = 0; n < nElements; n++ )
264cdf0e10cSrcweir 	{
265cdf0e10cSrcweir 		UnoControlModelEntry* pEntry = pNewEntry->pGroup->GetObject( n );
266cdf0e10cSrcweir 		if ( !pEntry->bGroup )
267cdf0e10cSrcweir 		{
268cdf0e10cSrcweir 			sal_uInt32 nPos = ImplGetControlPos( *pEntry->pxControl, maControls );
269cdf0e10cSrcweir 			// Eigentlich sollten alle Controls vorher in der flachen Liste stehen
270cdf0e10cSrcweir 			DBG_ASSERT( nPos != CONTROLPOS_NOTFOUND, "setGroup - Element not found" );
271cdf0e10cSrcweir 			if ( nPos != CONTROLPOS_NOTFOUND )
272cdf0e10cSrcweir 			{
273cdf0e10cSrcweir 				maControls.DestroyEntry( nPos );
274cdf0e10cSrcweir 				if ( !bInserted )
275cdf0e10cSrcweir 				{
276cdf0e10cSrcweir 					maControls.Insert( pNewEntry, nPos );
277cdf0e10cSrcweir 					bInserted = sal_True;
278cdf0e10cSrcweir 				}
279cdf0e10cSrcweir 			}
280cdf0e10cSrcweir 		}
281cdf0e10cSrcweir 	}
282cdf0e10cSrcweir 	if ( !bInserted )
283cdf0e10cSrcweir 		maControls.Insert( pNewEntry, LIST_APPEND );
284cdf0e10cSrcweir }
285cdf0e10cSrcweir 
getGroupCount()286cdf0e10cSrcweir sal_Int32 StdTabControllerModel::getGroupCount(  ) throw(::com::sun::star::uno::RuntimeException)
287cdf0e10cSrcweir {
288cdf0e10cSrcweir 	::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
289cdf0e10cSrcweir 
290cdf0e10cSrcweir 	// erstmal nur eine Ebene...
291cdf0e10cSrcweir 	// Das Model und die Impl-Methoden arbeiten zwar rekursiv, aber das wird
292cdf0e10cSrcweir 	// erstmal nich nach aussen gegeben.
293cdf0e10cSrcweir 
294cdf0e10cSrcweir 	sal_Int32 nGroups = 0;
295cdf0e10cSrcweir 	sal_uInt32 nEntries = maControls.Count();
296cdf0e10cSrcweir 	for ( sal_uInt32 n = 0; n < nEntries; n++ )
297cdf0e10cSrcweir 	{
298cdf0e10cSrcweir 		UnoControlModelEntry* pEntry = maControls.GetObject( n );
299cdf0e10cSrcweir 		if ( pEntry->bGroup )
300cdf0e10cSrcweir 			nGroups++;
301cdf0e10cSrcweir 	}
302cdf0e10cSrcweir 	return nGroups;
303cdf0e10cSrcweir }
304cdf0e10cSrcweir 
getGroup(sal_Int32 nGroup,::com::sun::star::uno::Sequence<::com::sun::star::uno::Reference<::com::sun::star::awt::XControlModel>> & rGroup,::rtl::OUString & rName)305cdf0e10cSrcweir void StdTabControllerModel::getGroup( sal_Int32 nGroup, ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > >& rGroup, ::rtl::OUString& rName ) throw(::com::sun::star::uno::RuntimeException)
306cdf0e10cSrcweir {
307cdf0e10cSrcweir 	::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
308cdf0e10cSrcweir 
309cdf0e10cSrcweir 	::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > > aSeq;
310cdf0e10cSrcweir 	sal_uInt32 nG = 0;
311cdf0e10cSrcweir 	sal_uInt32 nEntries = maControls.Count();
312cdf0e10cSrcweir 	for ( sal_uInt32 n = 0; n < nEntries; n++ )
313cdf0e10cSrcweir 	{
314cdf0e10cSrcweir 		UnoControlModelEntry* pEntry = maControls.GetObject( n );
315cdf0e10cSrcweir 		if ( pEntry->bGroup )
316cdf0e10cSrcweir 		{
317cdf0e10cSrcweir 			if ( nG == (sal_uInt32)nGroup )
318cdf0e10cSrcweir 			{
319cdf0e10cSrcweir 				sal_uInt32 nCount = ImplGetControlCount( *pEntry->pGroup );
320cdf0e10cSrcweir 				aSeq = ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > >( nCount );
321cdf0e10cSrcweir 				::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > * pRefs = aSeq.getArray();
322cdf0e10cSrcweir 				ImplGetControlModels( &pRefs, *pEntry->pGroup );
323cdf0e10cSrcweir 				rName = pEntry->pGroup->GetName();
324cdf0e10cSrcweir 				break;
325cdf0e10cSrcweir 			}
326cdf0e10cSrcweir 			nG++;
327cdf0e10cSrcweir 		}
328cdf0e10cSrcweir 	}
329cdf0e10cSrcweir 	rGroup = aSeq;
330cdf0e10cSrcweir }
331cdf0e10cSrcweir 
getGroupByName(const::rtl::OUString & rName,::com::sun::star::uno::Sequence<::com::sun::star::uno::Reference<::com::sun::star::awt::XControlModel>> & rGroup)332cdf0e10cSrcweir void StdTabControllerModel::getGroupByName( const ::rtl::OUString& rName, ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > >& rGroup ) throw(::com::sun::star::uno::RuntimeException)
333cdf0e10cSrcweir {
334cdf0e10cSrcweir 	::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
335cdf0e10cSrcweir 
336cdf0e10cSrcweir 	sal_uInt32 nGroup = 0;
337cdf0e10cSrcweir 	sal_uInt32 nEntries = maControls.Count();
338cdf0e10cSrcweir 	for ( sal_uInt32 n = 0; n < nEntries; n++ )
339cdf0e10cSrcweir 	{
340cdf0e10cSrcweir 		UnoControlModelEntry* pEntry = maControls.GetObject( n );
341cdf0e10cSrcweir 		if ( pEntry->bGroup )
342cdf0e10cSrcweir 		{
343cdf0e10cSrcweir 			if ( pEntry->pGroup->GetName() == rName )
344cdf0e10cSrcweir 			{
345cdf0e10cSrcweir 				::rtl::OUString Dummy;
346cdf0e10cSrcweir 				getGroup( nGroup, rGroup, Dummy );
347cdf0e10cSrcweir 				break;
348cdf0e10cSrcweir 			}
349cdf0e10cSrcweir 			nGroup++;
350cdf0e10cSrcweir 		}
351cdf0e10cSrcweir 	}
352cdf0e10cSrcweir }
353cdf0e10cSrcweir 
354cdf0e10cSrcweir 
355cdf0e10cSrcweir // ::com::sun::star::io::XPersistObject
getServiceName()356cdf0e10cSrcweir ::rtl::OUString StdTabControllerModel::getServiceName(  ) throw(::com::sun::star::uno::RuntimeException)
357cdf0e10cSrcweir {
358cdf0e10cSrcweir 	return ::rtl::OUString::createFromAscii( szServiceName_TabControllerModel );
359cdf0e10cSrcweir }
360cdf0e10cSrcweir 
write(const::com::sun::star::uno::Reference<::com::sun::star::io::XObjectOutputStream> & OutStream)361cdf0e10cSrcweir void StdTabControllerModel::write( const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectOutputStream >& OutStream ) throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException)
362cdf0e10cSrcweir {
363cdf0e10cSrcweir 	::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
364cdf0e10cSrcweir 
365cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::io::XMarkableStream >  xMark( OutStream, ::com::sun::star::uno::UNO_QUERY );
366cdf0e10cSrcweir 	DBG_ASSERT( xMark.is(), "write: no XMarkableStream!" );
367cdf0e10cSrcweir 
368cdf0e10cSrcweir 	OutStream->writeShort( UNOCONTROL_STREAMVERSION );
369cdf0e10cSrcweir 
370cdf0e10cSrcweir 	::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > > aCtrls = getControlModels();
371cdf0e10cSrcweir 	ImplWriteControls( OutStream, aCtrls );
372cdf0e10cSrcweir 
373cdf0e10cSrcweir 	sal_uInt32 nGroups = getGroupCount();
374cdf0e10cSrcweir 	OutStream->writeLong( nGroups );
375cdf0e10cSrcweir 	for ( sal_uInt32 n = 0; n < nGroups; n++ )
376cdf0e10cSrcweir 	{
377cdf0e10cSrcweir 		::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > > aGroupCtrls;
378cdf0e10cSrcweir 		::rtl::OUString aGroupName;
379cdf0e10cSrcweir 		getGroup( n, aGroupCtrls, aGroupName );
380cdf0e10cSrcweir 		OutStream->writeUTF( aGroupName );
381cdf0e10cSrcweir 		ImplWriteControls( OutStream, aGroupCtrls );
382cdf0e10cSrcweir 	}
383cdf0e10cSrcweir }
384cdf0e10cSrcweir 
read(const::com::sun::star::uno::Reference<::com::sun::star::io::XObjectInputStream> & InStream)385cdf0e10cSrcweir void StdTabControllerModel::read( const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectInputStream >& InStream ) throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException)
386cdf0e10cSrcweir {
387cdf0e10cSrcweir 	::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
388cdf0e10cSrcweir 
389cdf0e10cSrcweir 	::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > > aSeq = ImplReadControls( InStream );
390cdf0e10cSrcweir 	setControlModels( aSeq );
391cdf0e10cSrcweir 
392cdf0e10cSrcweir 	sal_uInt32 nGroups = InStream->readLong();
393cdf0e10cSrcweir 	for ( sal_uInt32 n = 0; n < nGroups; n++ )
394cdf0e10cSrcweir 	{
395cdf0e10cSrcweir 		::rtl::OUString aGroupName = InStream->readUTF();
396cdf0e10cSrcweir 		::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > > aCtrlSeq = ImplReadControls( InStream );
397cdf0e10cSrcweir 		setGroup( aCtrlSeq, aGroupName );
398cdf0e10cSrcweir 	}
399cdf0e10cSrcweir }
400cdf0e10cSrcweir 
401cdf0e10cSrcweir 
402cdf0e10cSrcweir 
403cdf0e10cSrcweir 
404cdf0e10cSrcweir 
405