xref: /AOO41X/main/basic/source/sbx/sbxbase.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_basic.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir 
32*cdf0e10cSrcweir #include <tools/shl.hxx>
33*cdf0e10cSrcweir #include <tools/stream.hxx>
34*cdf0e10cSrcweir 
35*cdf0e10cSrcweir #include <basic/sbx.hxx>
36*cdf0e10cSrcweir #include <basic/sbxfac.hxx>
37*cdf0e10cSrcweir #include <basic/sbxbase.hxx>
38*cdf0e10cSrcweir 
39*cdf0e10cSrcweir // AppData-Struktur fuer SBX:
40*cdf0e10cSrcweir 
41*cdf0e10cSrcweir SV_IMPL_PTRARR(SbxParams,SbxParamInfo*);
42*cdf0e10cSrcweir SV_IMPL_PTRARR(SbxFacs,SbxFactory*);
43*cdf0e10cSrcweir 
44*cdf0e10cSrcweir TYPEINIT0(SbxBase)
45*cdf0e10cSrcweir 
46*cdf0e10cSrcweir // SBX-Daten anfordern oder ggf. anlegen
47*cdf0e10cSrcweir // wir legen den Bereich einfach an und verzichten auf die Freigabe!
48*cdf0e10cSrcweir 
49*cdf0e10cSrcweir SbxAppData* GetSbxData_Impl()
50*cdf0e10cSrcweir {
51*cdf0e10cSrcweir 	SbxAppData** ppData = (SbxAppData**) ::GetAppData( SHL_SBX );
52*cdf0e10cSrcweir 	SbxAppData* p = *ppData;
53*cdf0e10cSrcweir 	if( !p )
54*cdf0e10cSrcweir 		p = *ppData  = new SbxAppData;
55*cdf0e10cSrcweir 	return p;
56*cdf0e10cSrcweir }
57*cdf0e10cSrcweir 
58*cdf0e10cSrcweir SbxAppData::~SbxAppData()
59*cdf0e10cSrcweir {
60*cdf0e10cSrcweir 	if( pBasicFormater )
61*cdf0e10cSrcweir 		delete pBasicFormater;
62*cdf0e10cSrcweir }
63*cdf0e10cSrcweir 
64*cdf0e10cSrcweir 
65*cdf0e10cSrcweir //////////////////////////////// SbxBase /////////////////////////////////
66*cdf0e10cSrcweir 
67*cdf0e10cSrcweir DBG_NAME(SbxBase);
68*cdf0e10cSrcweir 
69*cdf0e10cSrcweir SbxBase::SbxBase()
70*cdf0e10cSrcweir {
71*cdf0e10cSrcweir 	DBG_CTOR( SbxBase, 0 );
72*cdf0e10cSrcweir 	nFlags  = SBX_READWRITE;
73*cdf0e10cSrcweir }
74*cdf0e10cSrcweir 
75*cdf0e10cSrcweir SbxBase::SbxBase( const SbxBase& r )
76*cdf0e10cSrcweir     : SvRefBase( r )
77*cdf0e10cSrcweir {
78*cdf0e10cSrcweir 	DBG_CTOR( SbxBase, 0 );
79*cdf0e10cSrcweir 	nFlags  = r.nFlags;
80*cdf0e10cSrcweir }
81*cdf0e10cSrcweir 
82*cdf0e10cSrcweir SbxBase::~SbxBase()
83*cdf0e10cSrcweir {
84*cdf0e10cSrcweir 	DBG_DTOR(SbxBase,0);
85*cdf0e10cSrcweir }
86*cdf0e10cSrcweir 
87*cdf0e10cSrcweir SbxBase& SbxBase::operator=( const SbxBase& r )
88*cdf0e10cSrcweir {
89*cdf0e10cSrcweir 	DBG_CHKTHIS( SbxBase, 0 );
90*cdf0e10cSrcweir 	nFlags = r.nFlags;
91*cdf0e10cSrcweir 	return *this;
92*cdf0e10cSrcweir }
93*cdf0e10cSrcweir 
94*cdf0e10cSrcweir SbxDataType SbxBase::GetType() const
95*cdf0e10cSrcweir {
96*cdf0e10cSrcweir 	DBG_CHKTHIS( SbxBase, 0 );
97*cdf0e10cSrcweir 	return SbxEMPTY;
98*cdf0e10cSrcweir }
99*cdf0e10cSrcweir 
100*cdf0e10cSrcweir SbxClassType SbxBase::GetClass() const
101*cdf0e10cSrcweir {
102*cdf0e10cSrcweir 	DBG_CHKTHIS( SbxBase, 0 );
103*cdf0e10cSrcweir 	return SbxCLASS_DONTCARE;
104*cdf0e10cSrcweir }
105*cdf0e10cSrcweir 
106*cdf0e10cSrcweir void SbxBase::Clear()
107*cdf0e10cSrcweir {
108*cdf0e10cSrcweir 	DBG_CHKTHIS( SbxBase, 0 );
109*cdf0e10cSrcweir }
110*cdf0e10cSrcweir 
111*cdf0e10cSrcweir sal_Bool SbxBase::IsFixed() const
112*cdf0e10cSrcweir {
113*cdf0e10cSrcweir 	DBG_CHKTHIS( SbxBase, 0 );
114*cdf0e10cSrcweir 	return IsSet( SBX_FIXED );
115*cdf0e10cSrcweir }
116*cdf0e10cSrcweir 
117*cdf0e10cSrcweir void SbxBase::SetModified( sal_Bool b )
118*cdf0e10cSrcweir {
119*cdf0e10cSrcweir 	DBG_CHKTHIS( SbxBase, 0 );
120*cdf0e10cSrcweir 	if( IsSet( SBX_NO_MODIFY ) )
121*cdf0e10cSrcweir 		return;
122*cdf0e10cSrcweir 	if( b )
123*cdf0e10cSrcweir 		SetFlag( SBX_MODIFIED );
124*cdf0e10cSrcweir 	else
125*cdf0e10cSrcweir 		ResetFlag( SBX_MODIFIED );
126*cdf0e10cSrcweir }
127*cdf0e10cSrcweir 
128*cdf0e10cSrcweir SbxError SbxBase::GetError()
129*cdf0e10cSrcweir {
130*cdf0e10cSrcweir 	return GetSbxData_Impl()->eSbxError;
131*cdf0e10cSrcweir }
132*cdf0e10cSrcweir 
133*cdf0e10cSrcweir void SbxBase::SetError( SbxError e )
134*cdf0e10cSrcweir {
135*cdf0e10cSrcweir 	SbxAppData* p = GetSbxData_Impl();
136*cdf0e10cSrcweir 	if( e && p->eSbxError == SbxERR_OK )
137*cdf0e10cSrcweir 		p->eSbxError = e;
138*cdf0e10cSrcweir }
139*cdf0e10cSrcweir 
140*cdf0e10cSrcweir sal_Bool SbxBase::IsError()
141*cdf0e10cSrcweir {
142*cdf0e10cSrcweir 	return sal_Bool( GetSbxData_Impl()->eSbxError != SbxERR_OK );
143*cdf0e10cSrcweir }
144*cdf0e10cSrcweir 
145*cdf0e10cSrcweir void SbxBase::ResetError()
146*cdf0e10cSrcweir {
147*cdf0e10cSrcweir 	GetSbxData_Impl()->eSbxError = SbxERR_OK;
148*cdf0e10cSrcweir }
149*cdf0e10cSrcweir 
150*cdf0e10cSrcweir void SbxBase::AddFactory( SbxFactory* pFac )
151*cdf0e10cSrcweir {
152*cdf0e10cSrcweir 	SbxAppData* p = GetSbxData_Impl();
153*cdf0e10cSrcweir 	const SbxFactory* pTemp = pFac;
154*cdf0e10cSrcweir 
155*cdf0e10cSrcweir 	// AB, 6.3.96: HandleLast-Flag beruecksichtigen
156*cdf0e10cSrcweir 	sal_uInt16 nPos = p->aFacs.Count();		// Einfuege-Position
157*cdf0e10cSrcweir 	if( !pFac->IsHandleLast() )			// Nur, wenn nicht selbst HandleLast
158*cdf0e10cSrcweir 	{
159*cdf0e10cSrcweir 		// Neue Factory vor Factories mit HandleLast einordnen
160*cdf0e10cSrcweir 		while( nPos > 0 &&
161*cdf0e10cSrcweir 				(static_cast<SbxFactory*>(p->aFacs.GetObject( nPos-1 )))->IsHandleLast() )
162*cdf0e10cSrcweir 			nPos--;
163*cdf0e10cSrcweir 	}
164*cdf0e10cSrcweir 	p->aFacs.Insert( pTemp, nPos );
165*cdf0e10cSrcweir }
166*cdf0e10cSrcweir 
167*cdf0e10cSrcweir void SbxBase::RemoveFactory( SbxFactory* pFac )
168*cdf0e10cSrcweir {
169*cdf0e10cSrcweir 	SbxAppData* p = GetSbxData_Impl();
170*cdf0e10cSrcweir 	for( sal_uInt16 i = 0; i < p->aFacs.Count(); i++ )
171*cdf0e10cSrcweir 	{
172*cdf0e10cSrcweir 		if( p->aFacs.GetObject( i ) == pFac )
173*cdf0e10cSrcweir 		{
174*cdf0e10cSrcweir 			p->aFacs.Remove( i, 1 ); break;
175*cdf0e10cSrcweir 		}
176*cdf0e10cSrcweir 	}
177*cdf0e10cSrcweir }
178*cdf0e10cSrcweir 
179*cdf0e10cSrcweir 
180*cdf0e10cSrcweir SbxBase* SbxBase::Create( sal_uInt16 nSbxId, sal_uInt32 nCreator )
181*cdf0e10cSrcweir {
182*cdf0e10cSrcweir     // #91626: Hack to skip old Basic dialogs
183*cdf0e10cSrcweir     // Problem: There does not exist a factory any more,
184*cdf0e10cSrcweir     // so we have to create a dummy SbxVariable instead
185*cdf0e10cSrcweir 	if( nSbxId == 0x65 )    // Dialog Id
186*cdf0e10cSrcweir         return new SbxVariable;
187*cdf0e10cSrcweir 
188*cdf0e10cSrcweir 	XubString aEmptyStr;
189*cdf0e10cSrcweir 	if( nCreator == SBXCR_SBX )
190*cdf0e10cSrcweir 	  switch( nSbxId )
191*cdf0e10cSrcweir 	{
192*cdf0e10cSrcweir 		case SBXID_VALUE:		return new SbxValue;
193*cdf0e10cSrcweir 		case SBXID_VARIABLE:	return new SbxVariable;
194*cdf0e10cSrcweir 		case SBXID_ARRAY:  		return new SbxArray;
195*cdf0e10cSrcweir 		case SBXID_DIMARRAY:	return new SbxDimArray;
196*cdf0e10cSrcweir 		case SBXID_OBJECT:		return new SbxObject( aEmptyStr );
197*cdf0e10cSrcweir 		case SBXID_COLLECTION:	return new SbxCollection( aEmptyStr );
198*cdf0e10cSrcweir 		case SBXID_FIXCOLLECTION:
199*cdf0e10cSrcweir 								return new SbxStdCollection( aEmptyStr, aEmptyStr );
200*cdf0e10cSrcweir 		case SBXID_METHOD:		return new SbxMethod( aEmptyStr, SbxEMPTY );
201*cdf0e10cSrcweir 		case SBXID_PROPERTY:	return new SbxProperty( aEmptyStr, SbxEMPTY );
202*cdf0e10cSrcweir 	}
203*cdf0e10cSrcweir 	// Unbekanter Typ: �ber die Factories gehen!
204*cdf0e10cSrcweir 	SbxAppData* p = GetSbxData_Impl();
205*cdf0e10cSrcweir 	SbxBase* pNew = NULL;
206*cdf0e10cSrcweir 	for( sal_uInt16 i = 0; i < p->aFacs.Count(); i++ )
207*cdf0e10cSrcweir 	{
208*cdf0e10cSrcweir 		SbxFactory* pFac = p->aFacs.GetObject( i );
209*cdf0e10cSrcweir 		pNew = pFac->Create( nSbxId, nCreator );
210*cdf0e10cSrcweir 		if( pNew )
211*cdf0e10cSrcweir 			break;
212*cdf0e10cSrcweir 	}
213*cdf0e10cSrcweir #ifdef DBG_UTIL
214*cdf0e10cSrcweir 	if( !pNew )
215*cdf0e10cSrcweir 	{
216*cdf0e10cSrcweir 		ByteString aMsg( "SBX: Keine Factory fuer SBX-ID " );
217*cdf0e10cSrcweir 		aMsg += ByteString::CreateFromInt32(nSbxId);
218*cdf0e10cSrcweir 		DbgError( aMsg.GetBuffer() );
219*cdf0e10cSrcweir 	}
220*cdf0e10cSrcweir #endif
221*cdf0e10cSrcweir 	return pNew;
222*cdf0e10cSrcweir }
223*cdf0e10cSrcweir 
224*cdf0e10cSrcweir SbxObject* SbxBase::CreateObject( const XubString& rClass )
225*cdf0e10cSrcweir {
226*cdf0e10cSrcweir 	SbxAppData* p = GetSbxData_Impl();
227*cdf0e10cSrcweir 	SbxObject* pNew = NULL;
228*cdf0e10cSrcweir 	for( sal_uInt16 i = 0; i < p->aFacs.Count(); i++ )
229*cdf0e10cSrcweir 	{
230*cdf0e10cSrcweir 		pNew = p->aFacs.GetObject( i )->CreateObject( rClass );
231*cdf0e10cSrcweir 		if( pNew )
232*cdf0e10cSrcweir 			break;
233*cdf0e10cSrcweir 	}
234*cdf0e10cSrcweir #ifdef DBG_UTIL
235*cdf0e10cSrcweir 	if( !pNew )
236*cdf0e10cSrcweir 	{
237*cdf0e10cSrcweir 		ByteString aMsg( "SBX: Keine Factory fuer Objektklasse " );
238*cdf0e10cSrcweir 		ByteString aClassStr( (const UniString&)rClass, RTL_TEXTENCODING_ASCII_US );
239*cdf0e10cSrcweir 		aMsg += aClassStr;
240*cdf0e10cSrcweir 		DbgError( (const char*)aMsg.GetBuffer() );
241*cdf0e10cSrcweir 	}
242*cdf0e10cSrcweir #endif
243*cdf0e10cSrcweir 	return pNew;
244*cdf0e10cSrcweir }
245*cdf0e10cSrcweir 
246*cdf0e10cSrcweir static sal_Bool bStaticEnableBroadcasting = sal_True;
247*cdf0e10cSrcweir 
248*cdf0e10cSrcweir // Sbx-Loesung als Ersatz fuer SfxBroadcaster::Enable()
249*cdf0e10cSrcweir void SbxBase::StaticEnableBroadcasting( sal_Bool bEnable )
250*cdf0e10cSrcweir {
251*cdf0e10cSrcweir 	bStaticEnableBroadcasting = bEnable;
252*cdf0e10cSrcweir }
253*cdf0e10cSrcweir 
254*cdf0e10cSrcweir sal_Bool SbxBase::StaticIsEnabledBroadcasting( void )
255*cdf0e10cSrcweir {
256*cdf0e10cSrcweir 	return bStaticEnableBroadcasting;
257*cdf0e10cSrcweir }
258*cdf0e10cSrcweir 
259*cdf0e10cSrcweir 
260*cdf0e10cSrcweir SbxBase* SbxBase::Load( SvStream& rStrm )
261*cdf0e10cSrcweir {
262*cdf0e10cSrcweir 	sal_uInt16 nSbxId, nFlags, nVer;
263*cdf0e10cSrcweir 	sal_uInt32 nCreator, nSize;
264*cdf0e10cSrcweir 	rStrm >> nCreator >> nSbxId >> nFlags >> nVer;
265*cdf0e10cSrcweir 
266*cdf0e10cSrcweir 	// Eine Dummheit meinerseits korrigieren:
267*cdf0e10cSrcweir 	if( nFlags & SBX_RESERVED )
268*cdf0e10cSrcweir 		nFlags = ( nFlags & ~SBX_RESERVED ) | SBX_GBLSEARCH;
269*cdf0e10cSrcweir 
270*cdf0e10cSrcweir 	sal_uIntPtr nOldPos = rStrm.Tell();
271*cdf0e10cSrcweir 	rStrm >> nSize;
272*cdf0e10cSrcweir 	SbxBase* p = Create( nSbxId, nCreator );
273*cdf0e10cSrcweir 	if( p )
274*cdf0e10cSrcweir 	{
275*cdf0e10cSrcweir 		p->nFlags = nFlags;
276*cdf0e10cSrcweir 		if( p->LoadData( rStrm, nVer ) )
277*cdf0e10cSrcweir 		{
278*cdf0e10cSrcweir 			sal_uIntPtr nNewPos = rStrm.Tell();
279*cdf0e10cSrcweir 			nOldPos += nSize;
280*cdf0e10cSrcweir 			DBG_ASSERT( nOldPos >= nNewPos, "SBX: Zu viele Daten eingelesen" );
281*cdf0e10cSrcweir 			if( nOldPos != nNewPos )
282*cdf0e10cSrcweir 				rStrm.Seek( nOldPos );
283*cdf0e10cSrcweir 			if( !p->LoadCompleted() )
284*cdf0e10cSrcweir 			{
285*cdf0e10cSrcweir 				// Loeschen des Objekts
286*cdf0e10cSrcweir 				SbxBaseRef aRef( p );
287*cdf0e10cSrcweir 				p = NULL;
288*cdf0e10cSrcweir 			}
289*cdf0e10cSrcweir 		}
290*cdf0e10cSrcweir 		else
291*cdf0e10cSrcweir 		{
292*cdf0e10cSrcweir 			rStrm.SetError( SVSTREAM_FILEFORMAT_ERROR );
293*cdf0e10cSrcweir 			// Loeschen des Objekts
294*cdf0e10cSrcweir 			SbxBaseRef aRef( p );
295*cdf0e10cSrcweir 			p = NULL;
296*cdf0e10cSrcweir 		}
297*cdf0e10cSrcweir 	}
298*cdf0e10cSrcweir 	else
299*cdf0e10cSrcweir 		rStrm.SetError( SVSTREAM_FILEFORMAT_ERROR );
300*cdf0e10cSrcweir 	return p;
301*cdf0e10cSrcweir }
302*cdf0e10cSrcweir 
303*cdf0e10cSrcweir // Sbx-Objekt im Stream ueberspringen
304*cdf0e10cSrcweir void SbxBase::Skip( SvStream& rStrm )
305*cdf0e10cSrcweir {
306*cdf0e10cSrcweir 	sal_uInt16 nSbxId, nFlags, nVer;
307*cdf0e10cSrcweir 	sal_uInt32 nCreator, nSize;
308*cdf0e10cSrcweir 	rStrm >> nCreator >> nSbxId >> nFlags >> nVer;
309*cdf0e10cSrcweir 
310*cdf0e10cSrcweir 	sal_uIntPtr nStartPos = rStrm.Tell();
311*cdf0e10cSrcweir 	rStrm >> nSize;
312*cdf0e10cSrcweir 
313*cdf0e10cSrcweir 	rStrm.Seek( nStartPos + nSize );
314*cdf0e10cSrcweir }
315*cdf0e10cSrcweir 
316*cdf0e10cSrcweir sal_Bool SbxBase::Store( SvStream& rStrm )
317*cdf0e10cSrcweir {
318*cdf0e10cSrcweir 	DBG_CHKTHIS( SbxBase, 0 );
319*cdf0e10cSrcweir 	if( !( nFlags & SBX_DONTSTORE ) )
320*cdf0e10cSrcweir 	{
321*cdf0e10cSrcweir 		rStrm << (sal_uInt32) GetCreator()
322*cdf0e10cSrcweir 			  << (sal_uInt16) GetSbxId()
323*cdf0e10cSrcweir 			  << (sal_uInt16) GetFlags()
324*cdf0e10cSrcweir 			  << (sal_uInt16) GetVersion();
325*cdf0e10cSrcweir 		sal_uIntPtr nOldPos = rStrm.Tell();
326*cdf0e10cSrcweir 		rStrm << (sal_uInt32) 0L;
327*cdf0e10cSrcweir 		sal_Bool bRes = StoreData( rStrm );
328*cdf0e10cSrcweir 		sal_uIntPtr nNewPos = rStrm.Tell();
329*cdf0e10cSrcweir 		rStrm.Seek( nOldPos );
330*cdf0e10cSrcweir 		rStrm << (sal_uInt32) ( nNewPos - nOldPos );
331*cdf0e10cSrcweir 		rStrm.Seek( nNewPos );
332*cdf0e10cSrcweir 		if( rStrm.GetError() != SVSTREAM_OK )
333*cdf0e10cSrcweir 			bRes = sal_False;
334*cdf0e10cSrcweir 		if( bRes )
335*cdf0e10cSrcweir 			bRes = StoreCompleted();
336*cdf0e10cSrcweir 		return bRes;
337*cdf0e10cSrcweir 	}
338*cdf0e10cSrcweir 	else
339*cdf0e10cSrcweir 		return sal_True;
340*cdf0e10cSrcweir }
341*cdf0e10cSrcweir 
342*cdf0e10cSrcweir sal_Bool SbxBase::LoadData( SvStream&, sal_uInt16 )
343*cdf0e10cSrcweir {
344*cdf0e10cSrcweir 	DBG_CHKTHIS( SbxBase, 0 );
345*cdf0e10cSrcweir 	return sal_False;
346*cdf0e10cSrcweir }
347*cdf0e10cSrcweir 
348*cdf0e10cSrcweir sal_Bool SbxBase::StoreData( SvStream& ) const
349*cdf0e10cSrcweir {
350*cdf0e10cSrcweir 	DBG_CHKTHIS( SbxBase, 0 );
351*cdf0e10cSrcweir 	return sal_False;
352*cdf0e10cSrcweir }
353*cdf0e10cSrcweir 
354*cdf0e10cSrcweir sal_Bool SbxBase::LoadPrivateData( SvStream&, sal_uInt16 )
355*cdf0e10cSrcweir {
356*cdf0e10cSrcweir 	DBG_CHKTHIS( SbxBase, 0 );
357*cdf0e10cSrcweir 	return sal_True;
358*cdf0e10cSrcweir }
359*cdf0e10cSrcweir 
360*cdf0e10cSrcweir sal_Bool SbxBase::StorePrivateData( SvStream& ) const
361*cdf0e10cSrcweir {
362*cdf0e10cSrcweir 	DBG_CHKTHIS( SbxBase, 0 );
363*cdf0e10cSrcweir 	return sal_True;
364*cdf0e10cSrcweir }
365*cdf0e10cSrcweir 
366*cdf0e10cSrcweir sal_Bool SbxBase::LoadCompleted()
367*cdf0e10cSrcweir {
368*cdf0e10cSrcweir 	DBG_CHKTHIS( SbxBase, 0 );
369*cdf0e10cSrcweir 	return sal_True;
370*cdf0e10cSrcweir }
371*cdf0e10cSrcweir 
372*cdf0e10cSrcweir sal_Bool SbxBase::StoreCompleted()
373*cdf0e10cSrcweir {
374*cdf0e10cSrcweir 	DBG_CHKTHIS( SbxBase, 0 );
375*cdf0e10cSrcweir 	return sal_True;
376*cdf0e10cSrcweir }
377*cdf0e10cSrcweir 
378*cdf0e10cSrcweir //////////////////////////////// SbxFactory ////////////////////////////////
379*cdf0e10cSrcweir 
380*cdf0e10cSrcweir SbxBase* SbxFactory::Create( sal_uInt16, sal_uInt32 )
381*cdf0e10cSrcweir {
382*cdf0e10cSrcweir 	return NULL;
383*cdf0e10cSrcweir }
384*cdf0e10cSrcweir 
385*cdf0e10cSrcweir SbxObject* SbxFactory::CreateObject( const XubString& )
386*cdf0e10cSrcweir {
387*cdf0e10cSrcweir 	return NULL;
388*cdf0e10cSrcweir }
389*cdf0e10cSrcweir 
390*cdf0e10cSrcweir ///////////////////////////////// SbxInfo //////////////////////////////////
391*cdf0e10cSrcweir 
392*cdf0e10cSrcweir SbxInfo::~SbxInfo()
393*cdf0e10cSrcweir {}
394*cdf0e10cSrcweir 
395*cdf0e10cSrcweir void SbxInfo::AddParam
396*cdf0e10cSrcweir 		( const XubString& rName, SbxDataType eType, sal_uInt16 nFlags )
397*cdf0e10cSrcweir {
398*cdf0e10cSrcweir 	const SbxParamInfo* p = new SbxParamInfo( rName, eType, nFlags );
399*cdf0e10cSrcweir 	aParams.Insert( p, aParams.Count() );
400*cdf0e10cSrcweir }
401*cdf0e10cSrcweir 
402*cdf0e10cSrcweir void SbxInfo::AddParam( const SbxParamInfo& r )
403*cdf0e10cSrcweir {
404*cdf0e10cSrcweir 	const SbxParamInfo* p = new SbxParamInfo
405*cdf0e10cSrcweir 		( r.aName, r.eType, r.nFlags, r.aTypeRef );
406*cdf0e10cSrcweir 	aParams.Insert( p, aParams.Count() );
407*cdf0e10cSrcweir }
408*cdf0e10cSrcweir 
409*cdf0e10cSrcweir const SbxParamInfo* SbxInfo::GetParam( sal_uInt16 n ) const
410*cdf0e10cSrcweir {
411*cdf0e10cSrcweir 	if( n < 1 || n > aParams.Count() )
412*cdf0e10cSrcweir 		return NULL;
413*cdf0e10cSrcweir 	else
414*cdf0e10cSrcweir 		return aParams.GetObject( n-1 );
415*cdf0e10cSrcweir }
416*cdf0e10cSrcweir 
417*cdf0e10cSrcweir sal_Bool SbxInfo::LoadData( SvStream& rStrm, sal_uInt16 nVer )
418*cdf0e10cSrcweir {
419*cdf0e10cSrcweir 	aParams.Remove( 0, aParams.Count() );
420*cdf0e10cSrcweir 	sal_uInt16 nParam;
421*cdf0e10cSrcweir 	rStrm.ReadByteString( aComment, RTL_TEXTENCODING_ASCII_US );
422*cdf0e10cSrcweir 	rStrm.ReadByteString( aHelpFile, RTL_TEXTENCODING_ASCII_US );
423*cdf0e10cSrcweir 	rStrm >> nHelpId >> nParam;
424*cdf0e10cSrcweir 	while( nParam-- )
425*cdf0e10cSrcweir 	{
426*cdf0e10cSrcweir 		XubString aName;
427*cdf0e10cSrcweir 		sal_uInt16 nType, nFlags;
428*cdf0e10cSrcweir 		sal_uInt32 nUserData = 0;
429*cdf0e10cSrcweir 		rStrm.ReadByteString( aName, RTL_TEXTENCODING_ASCII_US );
430*cdf0e10cSrcweir 		rStrm >> nType >> nFlags;
431*cdf0e10cSrcweir 		if( nVer > 1 )
432*cdf0e10cSrcweir 			rStrm >> nUserData;
433*cdf0e10cSrcweir 		AddParam( aName, (SbxDataType) nType, nFlags );
434*cdf0e10cSrcweir 		SbxParamInfo* p = aParams.GetObject( aParams.Count() - 1 );
435*cdf0e10cSrcweir 		p->nUserData = nUserData;
436*cdf0e10cSrcweir 	}
437*cdf0e10cSrcweir 	return sal_True;
438*cdf0e10cSrcweir }
439*cdf0e10cSrcweir 
440*cdf0e10cSrcweir sal_Bool SbxInfo::StoreData( SvStream& rStrm ) const
441*cdf0e10cSrcweir {
442*cdf0e10cSrcweir 	rStrm.WriteByteString( aComment, RTL_TEXTENCODING_ASCII_US );
443*cdf0e10cSrcweir 	rStrm.WriteByteString( aHelpFile, RTL_TEXTENCODING_ASCII_US );
444*cdf0e10cSrcweir 	rStrm << nHelpId << aParams.Count();
445*cdf0e10cSrcweir 	for( sal_uInt16 i = 0; i < aParams.Count(); i++ )
446*cdf0e10cSrcweir 	{
447*cdf0e10cSrcweir 		SbxParamInfo* p = aParams.GetObject( i );
448*cdf0e10cSrcweir 		rStrm.WriteByteString( p->aName, RTL_TEXTENCODING_ASCII_US );
449*cdf0e10cSrcweir 		rStrm << (sal_uInt16) p->eType
450*cdf0e10cSrcweir 			  << (sal_uInt16) p->nFlags
451*cdf0e10cSrcweir 			  << (sal_uInt32) p->nUserData;
452*cdf0e10cSrcweir 	}
453*cdf0e10cSrcweir 	return sal_True;
454*cdf0e10cSrcweir }
455*cdf0e10cSrcweir 
456