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