xref: /aoo41x/main/idl/source/objects/types.cxx (revision 79aad27f)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_idl.hxx"
26 
27 #include <ctype.h>
28 #include <stdio.h>
29 
30 #include <tools/debug.hxx>
31 
32 #include <attrib.hxx>
33 #include <types.hxx>
34 #include <globals.hxx>
35 #include <database.hxx>
36 
37 /****************** SvMetaAttribute *************************************/
38 /************************************************************************/
39 SV_IMPL_META_FACTORY1( SvMetaAttribute, SvMetaReference );
40 /*************************************************************************
41 |*    SvMetaAttribute::SvMetaAttribute()
42 |*
43 |*    Beschreibung
44 *************************************************************************/
SvMetaAttribute()45 SvMetaAttribute::SvMetaAttribute()
46 	: aAutomation( sal_True, sal_False )
47 	, aExport( sal_True, sal_False )
48 	, aIsCollection ( sal_False, sal_False )
49 	, aReadOnlyDoc ( sal_True, sal_False )
50 	, aHidden( sal_False, sal_False )
51 	, bNewAttr( sal_False )
52 {
53 }
54 
SvMetaAttribute(SvMetaType * pType)55 SvMetaAttribute::SvMetaAttribute( SvMetaType * pType )
56 	: aType( pType )
57 	, aAutomation( sal_True, sal_False )
58 	, aExport( sal_True, sal_False )
59 	, aIsCollection ( sal_False, sal_False)
60 	, aReadOnlyDoc ( sal_True, sal_False)
61 	, aHidden( sal_False, sal_False )
62 	, bNewAttr( sal_False )
63 {
64 }
65 
66 /*************************************************************************
67 |*    SvMetaAttribute::Load()
68 |*    SvMetaAttribute::Save()
69 |*
70 |*    Beschreibung
71 *************************************************************************/
Load(SvPersistStream & rStm)72 void SvMetaAttribute::Load( SvPersistStream & rStm )
73 {
74     SvMetaReference::Load( rStm );
75 
76     sal_uInt8 nMask;
77     rStm >> nMask;
78     if( nMask & 0x01 )
79     {
80         SvMetaType * pType;
81         rStm >> pType;
82         aType = pType;
83     }
84     if( nMask & 0x02 ) 	rStm >> aSlotId;
85 	if( nMask & 0x04 ) 	rStm >> aExport;
86 	if( nMask & 0x08 ) 	rStm >> aReadonly;
87 	if( nMask & 0x10 ) 	rStm >> aAutomation;
88 	if( nMask & 0x20 ) 	rStm >> aIsCollection;
89 	if( nMask & 0x40 ) 	rStm >> aReadOnlyDoc;
90 	if( nMask & 0x80 ) 	rStm >> aHidden;
91 }
92 
Save(SvPersistStream & rStm)93 void SvMetaAttribute::Save( SvPersistStream & rStm )
94 {
95     SvMetaReference::Save( rStm );
96 
97     // Maske erstellen
98     sal_uInt8 nMask = 0;
99     if( aType.Is() )    		nMask |= 0x1;
100     if( aSlotId.IsSet() ) 		nMask |= 0x2;
101 	if( aExport.IsSet() )		nMask |= 0x4;
102 	if( aReadonly.IsSet() )		nMask |= 0x8;
103 	if( aAutomation.IsSet() )	nMask |= 0x10;
104 	if( aIsCollection.IsSet() ) nMask |= 0x20;
105 	if( aReadOnlyDoc.IsSet() )  nMask |= 0x40;
106 	if( aHidden.IsSet() )  		nMask |= 0x80;
107 
108     // Daten schreiben
109     rStm << nMask;
110     if( nMask & 0x1 )	rStm << aType;
111     if( nMask & 0x2 )	rStm << aSlotId;
112 	if( nMask & 0x4 )	rStm << aExport;
113 	if( nMask & 0x8 )	rStm << aReadonly;
114 	if( nMask & 0x10 )	rStm << aAutomation;
115 	if( nMask & 0x20 )  rStm << aIsCollection;
116 	if( nMask & 0x40 )  rStm << aReadOnlyDoc;
117 	if( nMask & 0x80 )  rStm << aHidden;
118 }
119 
120 /*************************************************************************
121 |*    SvMetaAttribute::GetType()
122 |*
123 |*    Beschreibung
124 *************************************************************************/
GetType() const125 SvMetaType * SvMetaAttribute::GetType() const
126 {
127     if( aType.Is() || !GetRef() ) return aType;
128     return ((SvMetaAttribute *)GetRef())->GetType();
129 }
130 
131 /*************************************************************************
132 |*    SvMetaAttribute::GetSlotId()
133 |*
134 |*    Beschreibung
135 *************************************************************************/
GetSlotId() const136 const SvNumberIdentifier & SvMetaAttribute::GetSlotId() const
137 {
138     if( aSlotId.IsSet() || !GetRef() ) return aSlotId;
139     return ((SvMetaAttribute *)GetRef())->GetSlotId();
140 }
141 
142 /*************************************************************************
143 |*    SvMetaAttribute::GetReadonly()
144 |*
145 |*    Beschreibung
146 *************************************************************************/
GetReadonly() const147 sal_Bool SvMetaAttribute::GetReadonly() const
148 {
149     if( aReadonly.IsSet() || !GetRef() ) return aReadonly;
150     return ((SvMetaAttribute *)GetRef())->GetReadonly();
151 }
152 
153 /*************************************************************************
154 |*    SvMetaAttribute::GetExport()
155 |*
156 |*    Beschreibung
157 *************************************************************************/
GetExport() const158 sal_Bool SvMetaAttribute::GetExport() const
159 {
160 	if( aExport.IsSet() || !GetRef() ) return aExport;
161 	return ((SvMetaAttribute *)GetRef())->GetExport();
162 }
163 
164 /*************************************************************************
165 |*    SvMetaAttribute::GetHidden()
166 |*
167 |*    Beschreibung
168 *************************************************************************/
GetHidden() const169 sal_Bool SvMetaAttribute::GetHidden() const
170 {
171 	// Wenn Export gesetzt wurde, aber Hidden nicht, gilt der Default
172 	// aHidden = !aExport
173 	if ( aExport.IsSet() && !aHidden.IsSet() )
174 		return !aExport;
175 	else if( aHidden.IsSet() || !GetRef() )
176 		return aHidden;
177 	else
178 		return ((SvMetaAttribute *)GetRef())->GetHidden();
179 }
180 
181 /*************************************************************************
182 |*    SvMetaAttribute::GetAutomation()
183 |*
184 |*    Beschreibung
185 *************************************************************************/
GetAutomation() const186 sal_Bool SvMetaAttribute::GetAutomation() const
187 {
188 	if( aAutomation.IsSet() || !GetRef() ) return aAutomation;
189 	return ((SvMetaAttribute *)GetRef())->GetAutomation();
190 }
191 
GetIsCollection() const192 sal_Bool SvMetaAttribute::GetIsCollection() const
193 {
194 	sal_Bool bRet;
195 	if( aIsCollection.IsSet() || !GetRef() )
196 	{
197 		if ( aIsCollection.IsSet() )
198 		{
199 			bRet = aIsCollection;
200 			return bRet;
201 		}
202 
203 		return aIsCollection;
204 	}
205 
206 	return ((SvMetaSlot *)GetRef())->GetIsCollection();
207 }
208 
GetReadOnlyDoc() const209 sal_Bool SvMetaAttribute::GetReadOnlyDoc() const
210 {
211 	if( aReadOnlyDoc.IsSet() || !GetRef() ) return aReadOnlyDoc;
212 	return ((SvMetaSlot *)GetRef())->GetReadOnlyDoc();
213 }
214 
215 /*************************************************************************
216 |*    SvMetaAttribute::IsMethod()
217 |*    SvMetaAttribute::IsVariable()
218 |*	  SvMetaAttribute::GetMangleName()
219 |*
220 |*    Beschreibung
221 *************************************************************************/
IsMethod() const222 sal_Bool SvMetaAttribute::IsMethod() const
223 {
224 	SvMetaType * pType = GetType();
225 	DBG_ASSERT( pType, "no type for attribute" );
226     return pType->GetType() == TYPE_METHOD;
227 }
228 
IsVariable() const229 sal_Bool SvMetaAttribute::IsVariable() const
230 {
231 	SvMetaType * pType = GetType();
232     return pType->GetType() != TYPE_METHOD;
233 }
234 
GetMangleName(sal_Bool) const235 ByteString SvMetaAttribute::GetMangleName( sal_Bool ) const
236 {
237 	return GetName();
238 }
239 
240 /*************************************************************************
241 |*    SvMetaAttribute::FillSbxObject()
242 |*
243 |*    Beschreibung
244 *************************************************************************/
245 /*
246 void SvMetaAttribute::FillSbxObject( SbxInfo * pInfo, sal_uInt16 nSbxFlags )
247 {
248 	SvMetaType * pType = GetType();
249 	DBG_ASSERT( pType, "no type for attribute" );
250 	if( !nSbxFlags )
251 	{ // Flags koennen vom Aufrufer ueberschrieben werden
252 		if( pType->GetOut() )
253 		{
254 			nSbxFlags |= SBX_WRITE;
255 			if( pType->GetIn() )
256 				nSbxFlags |= SBX_READ;
257 		}
258 		else
259 			nSbxFlags |= SBX_READ;
260 	}
261 	SvMetaType * pBaseType = pType->GetBaseType();
262 	DBG_ASSERT( pBaseType, "no base type for attribute" );
263 	if( pBaseType->GetType() == TYPE_STRUCT )
264 	{
265 		const SvMetaAttributeMemberList & rList = pBaseType->GetAttrList();
266 		sal_uLong nCount = rList.Count();
267 		for( sal_uLong i = 0; i < nCount; i++ )
268 			rList.GetObject( i )->FillSbxObject( pInfo, nSbxFlags );
269 	}
270 	else
271 		//MI: pInfo->AddParam( GetName(), pBaseType->GetSbxDataType(), nSbxFlags );
272 		pInfo->AddParam( GetName(), SbxVARIANT, nSbxFlags );
273 }
274 */
275 
276 /*************************************************************************
277 |*    SvMetaAttribute::FillSbxObject()
278 |*
279 |*    Beschreibung
280 *************************************************************************/
281 /*
282 void SvMetaAttribute::FillSbxObject( SvIdlDataBase & rBase,
283 									SbxObject * pObj, sal_Bool bVariable )
284 {
285 	// keine Attribut fuer Automation
286 	if( !GetAutomation() || !GetExport() )
287 		return;
288 
289 	if( bVariable && IsVariable() )
290 	{
291 		SvMetaType * pType = GetType();
292 		DBG_ASSERT( pType, "no type for attribute" );
293 		SvMetaType * pBaseType = pType->GetBaseType();
294 		DBG_ASSERT( pBaseType, "no base type for attribute" );
295 
296 		if( pBaseType->GetType() == TYPE_STRUCT )
297 		{
298 			SvNumberIdentifier aSlotId = rBase.aStructSlotId;
299 			if ( GetSlotId().Len() )
300 				rBase.aStructSlotId = GetSlotId();
301 			const SvMetaAttributeMemberList & rList = pBaseType->GetAttrList();
302 			sal_uLong nCount = rList.Count();
303 			for( sal_uLong i = 0; i < nCount; i++ )
304 				rList.GetObject( i )->FillSbxObject( rBase, pObj, bVariable );
305 			rBase.aStructSlotId = aSlotId;
306 		}
307 		else
308 		{
309 			SbxPropertyRef xProp = new SbxProperty( GetName(), SbxVARIANT );
310 										//MI: pBaseType->GetSbxDataType() );
311 			if ( GetReadonly() || IsMethod() )
312 				xProp->ResetFlag( SBX_WRITE );
313 			xProp->SetUserData( MakeSlotValue( rBase, sal_True ) );
314 			pType->FillSbxObject( xProp, bVariable );
315 
316 			pObj->Insert( &xProp );
317 		}
318 	}
319 	else if( !bVariable && IsMethod() )
320 	{
321 		SvMetaType * pType = GetType();
322 		SvMetaType * pRetBaseType = GetType()->GetReturnType()->GetBaseType();
323 		SbxMethodRef xMeth = new SbxMethod( GetName(),
324 							pRetBaseType->GetSbxDataType() );
325 		xMeth->ResetFlag( SBX_WRITE );
326 		xMeth->SetUserData( MakeSlotValue( rBase, sal_False ) );
327 		pType->FillSbxObject( xMeth, bVariable );
328 
329 		pObj->Insert( &xMeth );
330 	}
331 }
332 */
333 #ifdef IDL_COMPILER
334 /*************************************************************************
335 |*    SvMetaAttribute::Test()
336 |*
337 |*    Beschreibung
338 *************************************************************************/
Test(SvIdlDataBase & rBase,SvTokenStream & rInStm)339 sal_Bool SvMetaAttribute::Test( SvIdlDataBase & rBase,
340 							SvTokenStream & rInStm )
341 {
342 	sal_Bool bOk = sal_True;
343 	if( GetType()->IsItem() && !GetSlotId().IsSet() )
344 	{
345         rBase.SetError( "slot without id declared", rInStm.GetToken() );
346         rBase.WriteError( rInStm );
347 		bOk = sal_False;
348 	}
349 	/*
350 	if( !GetType()->IsItem() && GetSlotId().IsSet() )
351 	{
352         rBase.SetError( "slot without item declared", rInStm.GetToken() );
353         rBase.WriteError( rInStm );
354 		bOk = sal_False;
355 	}
356 	*/
357 	return bOk;
358 }
359 
360 /*************************************************************************
361 |*    SvMetaAttribute::ReadSvIdl()
362 |*
363 |*    Beschreibung
364 *************************************************************************/
ReadSvIdl(SvIdlDataBase & rBase,SvTokenStream & rInStm)365 sal_Bool SvMetaAttribute::ReadSvIdl( SvIdlDataBase & rBase,
366                                      SvTokenStream & rInStm )
367 {
368     sal_uInt32  nTokPos     = rInStm.Tell();
369 	if( !GetType() )
370 		// Es wurde kein Typ im ctor mitgegeben
371     	aType = rBase.ReadKnownType( rInStm );
372 	sal_Bool bOk = sal_False;
373     if( GetType() )
374     {
375         ReadNameSvIdl( rBase, rInStm );
376 		aSlotId.ReadSvIdl( rBase, rInStm );
377 
378         bOk = sal_True;
379 	    SvToken * pTok  = rInStm.GetToken();
380 		if( bOk && pTok->IsChar() && pTok->GetChar() == '(' )
381 		{
382 			SvMetaTypeRef xT = new SvMetaType();
383 			xT->SetRef( GetType() );
384 			aType = xT;
385 			bOk = aType->ReadMethodArgs( rBase, rInStm );
386 		}
387 		if( bOk )
388 			bOk = SvMetaName::ReadSvIdl( rBase, rInStm );
389     }
390 	else
391 		rBase.SetError( "unknown type", rInStm.GetToken() );
392 
393 	if( !bOk )
394 		rInStm.Seek( nTokPos );
395     return bOk;
396 }
397 
398 /*************************************************************************
399 |*    SvMetaAttribute::WriteSvIdl()
400 |*
401 |*    Beschreibung
402 *************************************************************************/
WriteSvIdl(SvIdlDataBase & rBase,SvStream & rOutStm,sal_uInt16 nTab)403 void SvMetaAttribute::WriteSvIdl
404 (
405 	SvIdlDataBase & rBase,
406 	SvStream & rOutStm,
407     sal_uInt16 nTab
408 )
409 {
410 	SvMetaType * pType = GetType();
411     pType->WriteTypePrefix( rBase, rOutStm, nTab, WRITE_IDL );
412     rOutStm << ' ' << GetName().GetBuffer();
413 	if( aSlotId.IsSet() )
414         rOutStm << ' ' << aSlotId.GetBuffer();
415 	if( pType->GetType() == TYPE_METHOD )
416     	pType->WriteMethodArgs( rBase, rOutStm, nTab, WRITE_IDL );
417 	sal_uLong nPos = rOutStm.Tell();
418 	rOutStm << endl;
419 	SvMetaName::WriteSvIdl( rBase, rOutStm, nTab );
420 	TestAndSeekSpaceOnly( rOutStm, nPos );
421 }
422 
423 /*************************************************************************
424 |*    SvMetaAttribute::ReadAttributesSvIdl()
425 |*
426 |*    Beschreibung
427 *************************************************************************/
ReadAttributesSvIdl(SvIdlDataBase & rBase,SvTokenStream & rInStm)428 void SvMetaAttribute::ReadAttributesSvIdl( SvIdlDataBase & rBase,
429 											 SvTokenStream & rInStm )
430 {
431 	SvMetaReference::ReadAttributesSvIdl( rBase, rInStm );
432 	aSlotId.ReadSvIdl( rBase, SvHash_SlotId(), rInStm );
433 	aExport.ReadSvIdl( SvHash_Export(), rInStm );
434 	aHidden.ReadSvIdl( SvHash_Hidden(), rInStm );
435 	aAutomation.ReadSvIdl( SvHash_Automation(), rInStm );
436 	aIsCollection.ReadSvIdl( SvHash_IsCollection(), rInStm );
437 	aReadOnlyDoc.ReadSvIdl( SvHash_ReadOnlyDoc(), rInStm );
438 	if( aReadonly.ReadSvIdl( SvHash_Readonly(), rInStm ) )
439 	{
440 		if( GetType()->GetType() == TYPE_METHOD )
441 		{
442             // Fehler setzen
443             rBase.SetError( "Readonly in function attribute", rInStm.GetToken() );
444             rBase.WriteError( rInStm );
445 		}
446 	}
447 }
448 
449 /*************************************************************************
450 |*    SvMetaAttribute::WriteAttributesSvIdl()
451 |*
452 |*    Beschreibung
453 *************************************************************************/
WriteAttributesSvIdl(SvIdlDataBase & rBase,SvStream & rOutStm,sal_uInt16 nTab)454 void SvMetaAttribute::WriteAttributesSvIdl
455 (
456 	SvIdlDataBase & rBase,
457 	SvStream & rOutStm,
458 	sal_uInt16 nTab
459 )
460 {
461 	SvMetaReference::WriteAttributesSvIdl( rBase, rOutStm, nTab );
462 
463 	//aSlotId.WriteSvIdl( SvHash_SlotId(), rOutStm, nTab );
464 	if( !aExport || !aAutomation || aReadonly )
465 	{
466 		WriteTab( rOutStm, nTab );
467 		rOutStm << "//class SvMetaAttribute" << endl;
468 		if( !aExport )
469 		{
470 			WriteTab( rOutStm, nTab );
471 			aExport.WriteSvIdl( SvHash_Export(), rOutStm );
472 			rOutStm << ';' << endl;
473 		}
474 		if ( aHidden != aExport )
475 		{
476 			WriteTab( rOutStm, nTab );
477 			aExport.WriteSvIdl( SvHash_Hidden(), rOutStm );
478 			rOutStm << ';' << endl;
479 		}
480 		if( aReadonly )
481 		{
482 			WriteTab( rOutStm, nTab );
483 			aReadonly.WriteSvIdl( SvHash_Readonly(), rOutStm );
484 			rOutStm << ';' << endl;
485 		}
486 		if( !aAutomation )
487 		{
488 			WriteTab( rOutStm, nTab );
489 			aAutomation.WriteSvIdl( SvHash_Automation(), rOutStm );
490 			rOutStm << ';' << endl;
491 		}
492 		if( aIsCollection )
493 		{
494 			WriteTab( rOutStm, nTab );
495 			aIsCollection.WriteSvIdl( SvHash_IsCollection(), rOutStm );
496 			rOutStm << ';' << endl;
497 		}
498 		if( !aReadOnlyDoc )
499 		{
500 			WriteTab( rOutStm, nTab );
501 			aReadOnlyDoc.WriteSvIdl( SvHash_ReadOnlyDoc(), rOutStm );
502 			rOutStm << ';' << endl;
503 		}
504 	}
505 }
506 
507 /*************************************************************************
508 |*    SvMetaAttribute::WriteParam()
509 |*
510 |*    Beschreibung
511 *************************************************************************/
WriteParam(SvIdlDataBase & rBase,SvStream & rOutStm,sal_uInt16 nTab,WriteType nT)512 void SvMetaAttribute::WriteParam( SvIdlDataBase & rBase,
513 									SvStream & rOutStm,
514                                 	sal_uInt16 nTab,
515 									WriteType nT )
516 {
517 	SvMetaType * pType = GetType();
518 	DBG_ASSERT( pType, "no type for attribute" );
519 	SvMetaType * pBaseType = pType->GetBaseType();
520 	DBG_ASSERT( pBaseType, "no base type for attribute" );
521 
522 	if( nT == WRITE_ODL || nT == WRITE_DOCU
523  	  || nT == WRITE_C_HEADER || nT == WRITE_C_SOURCE )
524 	{
525 		if( pBaseType->GetType() == TYPE_STRUCT )
526 		{
527 			const SvMetaAttributeMemberList & rList = pBaseType->GetAttrList();
528 			sal_uLong nCount = rList.Count();
529 			for( sal_uLong i = 0; i < nCount; i++ )
530 			{
531 				rList.GetObject( i )->WriteParam( rBase, rOutStm, nTab, nT );
532 				if( i+1<nCount )
533 				{
534 //					if ( nT == WRITE_DOCU )
535 						rOutStm << ',';
536 //					else
537 //						rOutStm << ',' << endl;
538 				}
539 			}
540 		}
541 		else
542 		{
543 			if ( nT != WRITE_DOCU )
544 			{
545 				WriteTab( rOutStm, nTab );
546 				pBaseType->WriteTypePrefix( rBase, rOutStm, nTab, nT );
547 			}
548 
549 		    if( GetName().Len() )
550 		    {
551 		        rOutStm << ' ';
552                 rOutStm << GetName().GetBuffer();
553 		    }
554 
555 			if ( nT == WRITE_DOCU )
556 			{
557 				if( pBaseType->GetType() == TYPE_METHOD ||
558 				 	pBaseType->GetType() == TYPE_STRUCT ||
559 					pBaseType->GetType() == TYPE_ENUM )
560 				{
561 					DBG_ERROR( "Falscher Parametertyp!" );
562 				}
563 				else
564                     rOutStm << pBaseType->GetBasicPostfix().GetBuffer();
565 			}
566 		}
567 	}
568 /*
569 	else if( nT == WRITE_C_HEADER || nT == WRITE_C_SOURCE )
570 	{
571 		pBaseType->WriteTypePrefix( rBase, rOutStm, nTab, nT );
572 		rOutStm << ' ';
573         rOutStm << GetName().GetBuffer();
574 	}
575 */
576 }
577 
578 /*************************************************************************
579 |*    SvMetaSlot::WriteSlotId()
580 |*
581 |*    Beschreibung
582 *************************************************************************/
MakeSlotValue(SvIdlDataBase & rBase,sal_Bool bVar) const583 sal_uLong SvMetaAttribute::MakeSlotValue( SvIdlDataBase & rBase, sal_Bool bVar ) const
584 {
585  	const SvNumberIdentifier & rId = GetSlotId();
586 	sal_uLong n = rId.GetValue();
587 	if( rBase.aStructSlotId.Len() )
588 	{
589 		n = n << 20;
590 		n += rBase.aStructSlotId.GetValue();
591 	}
592 	if( PTR_CAST( SvMetaSlot, this ) )
593 		n |= 0x20000;
594 	if( !bVar )
595 		n += 0x10000;
596 	else if ( GetIsCollection() )
597 		n += 0x40000;
598 	return n;
599 }
600 
601 /*************************************************************************
602 |*    SvMetaSlot::WriteAttributes()
603 |*
604 |*    Beschreibung
605 *************************************************************************/
WriteAttributes(SvIdlDataBase & rBase,SvStream & rOutStm,sal_uInt16 nTab,WriteType nT,WriteAttribute nA)606 void SvMetaAttribute::WriteAttributes( SvIdlDataBase & rBase, SvStream & rOutStm,
607 				     				 sal_uInt16 nTab,
608 		 							 WriteType nT, WriteAttribute nA )
609 {
610 	if( nT == WRITE_ODL  )
611 	{
612 		const SvNumberIdentifier & rId = GetSlotId();
613 		sal_Bool bReadonly = GetReadonly() || ( nA & WA_READONLY );
614 		if( (rId.IsSet() && !(nA & WA_STRUCT)) || bReadonly )
615 		{
616 			sal_Bool bVar = IsVariable();
617 			if( nA & WA_VARIABLE )
618 				bVar = sal_True;
619 			else if( nA & WA_METHOD )
620 				bVar = sal_False;
621 
622 			WriteTab( rOutStm, nTab );
623 			rOutStm << "//class SvMetaAttribute" << endl;
624 			if( rId.IsSet() && !(nA & WA_STRUCT) )
625 			{
626 				WriteTab( rOutStm, nTab );
627 			    rOutStm << "id("
628                         << ByteString::CreateFromInt32(MakeSlotValue( rBase, bVar )).GetBuffer()
629 						<< ")," << endl;
630 			}
631 			if( bVar && (bReadonly || IsMethod()) )
632 			{
633 				WriteTab( rOutStm, nTab );
634 				rOutStm << "readonly," << endl;
635 			}
636 		}
637 	}
638 }
639 
640 /*************************************************************************
641 |*    SvMetaAttribute::WriteCSource()
642 |*
643 |*    Beschreibung
644 *************************************************************************/
WriteCSource(SvIdlDataBase & rBase,SvStream & rOutStm,sal_Bool bSet)645 void SvMetaAttribute::WriteCSource( SvIdlDataBase & rBase, SvStream & rOutStm,
646 									sal_Bool bSet )
647 {
648 	rOutStm << endl;
649 	SvMetaType * pType = GetType();
650 	SvMetaType * pBaseType = pType->GetBaseType();
651 
652 	// Bei Set ist der Return immer void
653 	sal_Bool bVoid = bSet;
654 	if( pBaseType->GetType() == TYPE_METHOD )
655 		bVoid = pBaseType->GetReturnType()->GetBaseType()->GetName() == "void";
656 
657 	// Methoden/Funktions-Body ausgeben
658 	rOutStm << '{' << endl;
659 	WriteTab( rOutStm, 1 );
660 //	rOutStm << "if( SvIPCIsConnected() )" << endl;
661 //	WriteTab( rOutStm, 1 );
662 //	rOutStm << '{' << endl;
663 //	WriteTab( rOutStm, 2 );
664 
665 	if( !bVoid )
666 	{
667 		if ( pBaseType->GetCName() == "double" )
668 		{
669 			rOutStm << "return *(double*)";
670 		}
671 		else
672 		{
673 			rOutStm << "return (";
674 			pType->WriteTypePrefix( rBase, rOutStm, 2, WRITE_C_SOURCE );
675 			rOutStm << ") ";
676 		}
677 	}
678 	rOutStm << "pODKCallFunction( "
679             << ByteString::CreateFromInt32(MakeSlotValue( rBase, IsVariable() )).GetBuffer();
680 	rOutStm << ',' << endl;
681 	WriteTab( rOutStm, 3 );
682     rOutStm << " h" << rBase.aIFaceName.GetBuffer() << " , ";
683 
684 	ByteString aParserStr;
685 	if( pBaseType->GetType() == TYPE_METHOD || bSet )
686 		aParserStr = pBaseType->GetParserString();
687 	if( aParserStr.Len() )
688 	{
689 		rOutStm << '\"';
690         rOutStm << aParserStr.GetBuffer();
691 		rOutStm << "\", ";
692 	}
693 	else
694 		rOutStm << "NULL, ";
695 
696 	if( pBaseType->GetType() == TYPE_METHOD && !bVoid )
697 	{
698 		rOutStm << "'";
699 		rOutStm << pBaseType->GetReturnType()->GetBaseType()->GetParserChar();
700 		rOutStm << "'";
701 	}
702 	else if ( !bSet )
703 	{
704 		rOutStm << "'";
705 		rOutStm << pBaseType->GetParserChar();
706 		rOutStm << "'";
707 	}
708 	else
709 		rOutStm << '0';
710 
711 	if( aParserStr.Len() )
712 	{
713 		rOutStm << ", ";
714 		if( IsMethod() )
715 			// void SetPosSize( C_Object *, C_Rectangle * pRect );
716 			pBaseType->WriteParamNames( rBase, rOutStm, ByteString() );
717 		else if( bSet )
718 			pBaseType->WriteParamNames( rBase, rOutStm, GetName() );
719 	}
720 
721 	rOutStm << " );" << endl;
722 //	WriteTab( rOutStm, 1 );
723 //	rOutStm << '}' << endl;
724 //	if( !bVoid )
725 //	{
726 //		WriteTab( rOutStm, 1 );
727 //		rOutStm << "return 0;" << endl;
728 //	}
729 	rOutStm << '}' << endl;
730 }
731 
732 /*************************************************************************
733 |*    SvMetaAttribute::WriteRecursiv_Impl()
734 |*
735 |*    Beschreibung
736 *************************************************************************/
WriteRecursiv_Impl(SvIdlDataBase & rBase,SvStream & rOutStm,sal_uInt16 nTab,WriteType nT,WriteAttribute nA)737 void SvMetaAttribute::WriteRecursiv_Impl( SvIdlDataBase & rBase,
738 							SvStream & rOutStm, sal_uInt16 nTab,
739 		 					WriteType nT, WriteAttribute nA )
740 {
741 	const SvMetaAttributeMemberList & rList = GetType()->GetBaseType()->GetAttrList();
742 	sal_uLong nCount = rList.Count();
743 
744 	SvNumberIdentifier slotId = rBase.aStructSlotId;
745 	if ( GetSlotId().Len() )
746 		rBase.aStructSlotId = GetSlotId();
747 
748 	// Offizielle Hack-Schnittstelle von MM: spezielle Schalter werden "uber
749 	// die WriteAttribute "ubergeben
750 	if ( GetReadonly() )
751 		nA |= WA_READONLY;
752 
753 	for( sal_uLong i = 0; i < nCount; i++ )
754 	{
755 		SvMetaAttribute *pAttr = rList.GetObject( i );
756 		if ( nT == WRITE_DOCU )
757 			pAttr->SetDescription( GetDescription() );
758 		pAttr->Write( rBase, rOutStm, nTab, nT, nA );
759 		if( nT == WRITE_ODL && i +1 < nCount )
760 			rOutStm << ';' << endl;
761 	}
762 
763 	rBase.aStructSlotId = slotId;
764 }
765 
766 /*************************************************************************
767 |*    SvMetaAttribute::Write()
768 |*
769 |*    Beschreibung
770 *************************************************************************/
Write(SvIdlDataBase & rBase,SvStream & rOutStm,sal_uInt16 nTab,WriteType nT,WriteAttribute nA)771 void SvMetaAttribute::Write( SvIdlDataBase & rBase, SvStream & rOutStm,
772                             sal_uInt16 nTab,
773 		 					WriteType nT, WriteAttribute nA )
774 {
775 	// keine Attribut fuer Automation
776 	if( nT == WRITE_DOCU )
777 	{
778 		if ( GetHidden() )
779 			return;
780 	}
781 	else if	( !GetAutomation() || !GetExport() )
782 		return;
783 
784 	sal_Bool bVariable;
785 	if( nA & WA_VARIABLE )
786 		bVariable = sal_True;
787 	else if( nA & WA_METHOD )
788 		bVariable = sal_False;
789 	else
790 		bVariable = IsVariable();
791 
792 	SvMetaType * pType = GetType();
793 	DBG_ASSERT( pType, "no type for attribute" );
794 	SvMetaType * pBaseType = pType->GetBaseType();
795 	DBG_ASSERT( pBaseType, "no base type for attribute" );
796 	int nBType = pBaseType->GetType();
797 
798 	if( nT == WRITE_ODL )
799 	{
800 		if( (bVariable && IsVariable()) || (!bVariable && IsMethod()) )
801 		{
802 			if( nBType == TYPE_STRUCT )
803 				WriteRecursiv_Impl( rBase, rOutStm, nTab, nT, nA );
804 			else
805 			{
806 				SvMetaReference::Write( rBase, rOutStm, nTab, nT, nA );
807 				WriteTab( rOutStm, nTab );
808 			    pBaseType->WriteTypePrefix( rBase, rOutStm, nTab, nT );
809 
810 			    if( GetName().Len() )
811 			    {
812 			        rOutStm << ' ';
813                     rOutStm << GetName().GetBuffer();
814 			    }
815 				if( pType->GetType() == TYPE_METHOD )
816 			    	pType->WriteMethodArgs( rBase, rOutStm, nTab, nT );
817 			}
818 		}
819 	}
820 	else if( nT == WRITE_C_HEADER || nT == WRITE_C_SOURCE )
821 	{
822 		if( !bVariable && IsMethod() )
823 		{
824 			ByteString name; // (rBase.GetActModulePrefix());
825 			name += rBase.aIFaceName;
826 			name += GetName();
827             const char * pName = name.GetBuffer();
828 			// Beispiel
829 			// void SetPosSize( C_Object *, C_Rectangle * );
830 			WriteTab( rOutStm, nTab );
831 			pBaseType->WriteTypePrefix( rBase, rOutStm, nTab, nT );
832 //			rOutStm << " SYSCALL";
833 			rOutStm << ' ' << pName;
834 			pType->WriteMethodArgs( rBase, rOutStm, nTab, nT );
835 			if( nT == WRITE_C_HEADER )
836 				rOutStm << ';' << endl << endl;
837 			else
838 				WriteCSource( rBase, rOutStm, sal_False );
839 		}
840 		else if ( bVariable && IsVariable() )
841 		{
842 	  		if( nBType == TYPE_STRUCT )
843 			{
844 				// Zur Hilfe den Namen des Properties als Kommentar ausgeben
845                 rOutStm << "/* " << GetName().GetBuffer() << " */" << endl;
846 
847 				WriteRecursiv_Impl( rBase, rOutStm, nTab, nT, nA );
848 			}
849 			else
850 			{
851 				// Beispiel
852 				// void SetValue( C_Object *, sal_uInt16 n );
853 				ByteString name = GetName();
854 
855 				sal_Bool bReadonly = GetReadonly() || ( nA & WA_READONLY );
856 				if ( !bReadonly && !IsMethod() )
857 				{
858 					// Zuweisung
859 					WriteTab( rOutStm, nTab );
860 					rOutStm << "void ";
861 //					rOutStm << "SYSCALL ";
862 //					if ( rBase.GetActModulePrefix().Len() )
863 //                      rOutStm << rBase.GetActModulePrefix().GetBuffer();
864                     rOutStm << rBase.aIFaceName.GetBuffer()
865                             << "Set" << name.GetBuffer() << "( " << C_PREF
866                             << "Object h" << rBase.aIFaceName.GetBuffer() << ", " << endl;
867 					WriteTab( rOutStm, nTab+1 );
868 					pBaseType->WriteTypePrefix( rBase, rOutStm, nTab, nT );
869                     rOutStm << ' ' << name.GetBuffer() << " )";
870 					if( nT == WRITE_C_HEADER )
871 						rOutStm << ';' << endl << endl;
872 					else
873 						WriteCSource( rBase, rOutStm, sal_True );
874 				}
875 
876 				// Zugriff
877 				WriteTab( rOutStm, nTab );
878 				pBaseType->WriteTypePrefix( rBase, rOutStm, nTab, nT );
879 				rOutStm << ' ';
880 //				rOutStm << "SYSCALL ";
881 //				if ( rBase.GetActModulePrefix().Len() )
882 //                  rOutStm << rBase.GetActModulePrefix().GetBuffer();
883                 rOutStm << rBase.aIFaceName.GetBuffer()
884                         << "Get" << name.GetBuffer() << "( " << C_PREF
885                         << "Object h" << rBase.aIFaceName.GetBuffer() << " )";
886 				if( nT == WRITE_C_HEADER )
887 					rOutStm << ';' << endl << endl;
888 				else
889 					WriteCSource( rBase, rOutStm, sal_False );
890 			}
891 		}
892 	}
893 	else if ( nT == WRITE_DOCU )
894 	{
895 		if( !bVariable && IsMethod() )
896 		{
897 			rOutStm << "<METHOD>" << endl
898                     << GetSlotId().GetBuffer() << endl
899                     << GetName().GetBuffer() << endl
900 					<< endl;	// readonly
901 
902 			// Returntype
903 			SvMetaType* pType2 = GetType();
904 			SvMetaType* pBaseType2 = pType2->GetBaseType();
905             rOutStm << pBaseType2->GetReturnType()->GetBaseType()->GetBasicName().GetBuffer() << endl;
906 
907 			DBG_ASSERT( pBaseType2->GetReturnType()->GetBaseType()->GetBasicName().Len(),
908 				"Leerer BasicName" );
909 
910 			// Syntax
911             rOutStm << GetName().GetBuffer();
912 			pType2->WriteMethodArgs( rBase, rOutStm, nTab, nT );
913 
914 			// C-Returntype
915 			pBaseType2->WriteTypePrefix( rBase, rOutStm, 0, WRITE_C_HEADER );
916 			rOutStm << endl;
917 
918 			// Bei Methoden auch C-Syntax
919 			rOutStm << "<C-SYNTAX>" << endl;
920 			Write( rBase, rOutStm, 0, WRITE_C_HEADER, nA );
921 			rOutStm << "</C-SYNTAX>" << endl;
922 
923 			// Description
924 			WriteDescription( rOutStm );
925 			rOutStm << "</METHOD>" << endl << endl;
926 		}
927 		else if( bVariable && IsVariable() )
928 		{
929 			if( nBType == TYPE_STRUCT )
930 			{
931 				WriteRecursiv_Impl( rBase, rOutStm, nTab, nT, nA );
932 			}
933 			else
934 			{
935 				rOutStm << "<PROPERTY>" << endl
936                         << GetSlotId().GetBuffer() << endl
937                         << GetName().GetBuffer() << endl;
938 				if ( GetReadonly() )
939 					rOutStm << "(nur lesen)" << endl;
940 				else
941 					rOutStm << endl;
942 
943 				// Bei properties Type anstelle des return value
944                 rOutStm << pBaseType->GetBasicName().GetBuffer() << endl;
945 
946 				DBG_ASSERT( pBaseType->GetBasicName().Len(),
947 					"Leerer BasicName" );
948 
949 				// Bei properties keine Syntax
950 				rOutStm << endl;
951 
952 				// C-Returntype
953 				pBaseType->WriteTypePrefix( rBase, rOutStm, 0, WRITE_C_HEADER );
954 				rOutStm << endl;
955 
956 				// Description
957 				WriteDescription( rOutStm );
958 				rOutStm	<< "</PROPERTY>" << endl << endl;
959 			}
960 		}
961 	}
962 }
963 
964 /*************************************************************************
965 |*	  SvMetaAttribute::MakeSfx()
966 |*
967 |*	  Beschreibung
968 *************************************************************************/
MakeSfx(ByteString * pAttrArray)969 sal_uLong SvMetaAttribute::MakeSfx( ByteString * pAttrArray )
970 {
971 	SvMetaType * pType = GetType();
972 	DBG_ASSERT( pType, "no type for attribute" );
973 	SvMetaType * pBaseType = pType->GetBaseType();
974 	DBG_ASSERT( pBaseType, "no base type for attribute" );
975 	if( pBaseType->GetType() == TYPE_STRUCT )
976 		return pBaseType->MakeSfx( pAttrArray );
977 	else
978 	{
979 		*pAttrArray += '{';
980 		*pAttrArray += GetSlotId();
981 		*pAttrArray +=  ",\"";
982 		*pAttrArray +=  GetName();
983 		*pAttrArray +=  "\"}";
984 		return 1;
985 	}
986 }
987 
Insert(SvSlotElementList &,const ByteString &,SvIdlDataBase &)988 void SvMetaAttribute::Insert (SvSlotElementList&, const ByteString &, SvIdlDataBase&)
989 {
990 }
991 
992 /*************************************************************************
993 |*	  SvMetaAttribute::WriteSrc()
994 |*
995 |*	  Beschreibung
996 *************************************************************************/
WriteSrc(SvIdlDataBase &,SvStream &,Table *)997 void SvMetaAttribute::WriteSrc( SvIdlDataBase &, SvStream &, Table * )
998 {
999 }
1000 
WriteHelpId(SvIdlDataBase &,SvStream &,Table *)1001 void SvMetaAttribute::WriteHelpId( SvIdlDataBase &, SvStream &, Table * )
1002 {
1003 }
1004 
1005 #endif // IDL_COMPILER
1006 
1007 /****************** SvMetaType *************************************/
1008 /************************************************************************/
1009 SV_IMPL_META_FACTORY1( SvMetaType, SvMetaExtern );
1010 /*************************************************************************
1011 |*	  SvMetaType::SvMetaType()
1012 |*
1013 |*	  Beschreibung
1014 *************************************************************************/
1015 #define CTOR							\
1016 	: aCall0( CALL_VALUE, sal_False )       \
1017 	, aCall1( CALL_VALUE, sal_False )       \
1018     , aSbxDataType( 0, sal_False )          \
1019 	, pAttrList( NULL )					\
1020 	, nType( TYPE_BASE )				\
1021 	, bIsItem( sal_False )                  \
1022 	, bIsShell( sal_False )					\
1023 	, cParserChar( 'h' )
1024 
SvMetaType()1025 SvMetaType::SvMetaType()
1026 	CTOR
1027 {
1028 }
1029 
SvMetaType(const ByteString & rName,char cPC,const ByteString & rCName)1030 SvMetaType::SvMetaType( const ByteString & rName, char cPC,
1031 						const ByteString & rCName )
1032 	CTOR
1033 {
1034 	SetName( rName );
1035 	cParserChar = cPC;
1036 	aCName = rCName;
1037 }
1038 
SvMetaType(const ByteString & rName,const ByteString & rSbxName,const ByteString & rOdlName,char cPc,const ByteString & rCName,const ByteString & rBasicName,const ByteString & rBasicPostfix)1039 SvMetaType::SvMetaType( const ByteString & rName,
1040 						const ByteString & rSbxName,
1041 						const ByteString & rOdlName,
1042 						char cPc,
1043 						const ByteString & rCName,
1044 						const ByteString & rBasicName,
1045                         const ByteString & rBasicPostfix )
1046 	CTOR
1047 {
1048 //    aSbxDataType = (int)nT;
1049 	SetName( rName );
1050 	aSbxName	= rSbxName;
1051 	aOdlName	= rOdlName;
1052 	cParserChar = cPc;
1053 	aCName		= rCName;
1054 	aBasicName	= rBasicName;
1055 	aBasicPostfix = rBasicPostfix;
1056 }
1057 
Load(SvPersistStream & rStm)1058 void SvMetaType::Load( SvPersistStream & rStm )
1059 {
1060 	SvMetaExtern::Load( rStm );
1061 
1062 	sal_uInt16 nMask;
1063 	rStm >> nMask;
1064 	if( nMask & 0x0001 ) rStm >> aIn;
1065 	if( nMask & 0x0002 ) rStm >> aOut;
1066 	if( nMask & 0x0004 ) rStm >> aCall0;
1067 	if( nMask & 0x0008 ) rStm >> aCall1;
1068 	if( nMask & 0x0010 ) rStm >> aSbxDataType;
1069 	if( nMask & 0x0020 ) rStm >> aSvName;
1070 	if( nMask & 0x0040 ) rStm >> aSbxName;
1071 	if( nMask & 0x0080 ) rStm >> aOdlName;
1072 	if( nMask & 0x0100 ) rStm >> GetAttrList();
1073 	if( nMask & 0x0200 ) bIsItem = sal_True;
1074 	if( nMask & 0x0400 ) bIsShell = sal_True;
1075 	if( nMask & 0x0800 )
1076 	{
1077 		sal_uInt16 nT;
1078 		rStm >> nT;
1079 		nType = nT;
1080 	}
1081 	if( nMask & 0x1000 ) rStm >> cParserChar;
1082 	if( nMask & 0x2000 ) rStm >> aCName;
1083 	if( nMask & 0x4000 ) rStm >> aBasicName;
1084 	if( nMask & 0x8000 ) rStm >> aBasicPostfix;
1085 }
1086 
Save(SvPersistStream & rStm)1087 void SvMetaType::Save( SvPersistStream & rStm )
1088 {
1089 	SvMetaExtern::Save( rStm );
1090 
1091 	// Maske erstellen
1092 	sal_uInt16 nMask = 0;
1093 	if( aIn.IsSet() )				nMask |= 0x0001;
1094 	if( aOut.IsSet() )				nMask |= 0x0002;
1095 	if( aCall0.IsSet() )			nMask |= 0x0004;
1096 	if( aCall1.IsSet() )			nMask |= 0x0008;
1097 	if( aSbxDataType.IsSet() )		nMask |= 0x0010;
1098 	if( aSvName.IsSet() )			nMask |= 0x0020;
1099 	if( aSbxName.IsSet() )			nMask |= 0x0040;
1100 	if( aOdlName.IsSet() )			nMask |= 0x0080;
1101 	if( GetAttrCount() ) 			nMask |= 0x0100;
1102 	if( bIsItem ) 					nMask |= 0x0200;
1103 	if( bIsShell )					nMask |= 0x0400;
1104 	if( nType != TYPE_BASE )		nMask |= 0x0800;
1105 	if( cParserChar != 'h' )		nMask |= 0x1000;
1106 	if( aCName.IsSet() )			nMask |= 0x2000;
1107 	if( aBasicName.IsSet() ) 		nMask |= 0x4000;
1108 	if( aBasicPostfix.IsSet() ) 	nMask |= 0x8000;
1109 
1110 	// Daten schreiben
1111 	rStm << nMask;
1112 	if( nMask & 0x0001 ) rStm << aIn;
1113 	if( nMask & 0x0002 ) rStm << aOut;
1114 	if( nMask & 0x0004 ) rStm << aCall0;
1115 	if( nMask & 0x0008 ) rStm << aCall1;
1116 	if( nMask & 0x0010 ) rStm << aSbxDataType;
1117 	if( nMask & 0x0020 ) rStm << aSvName;
1118 	if( nMask & 0x0040 ) rStm << aSbxName;
1119 	if( nMask & 0x0080 ) rStm << aOdlName;
1120 	if( nMask & 0x0100 ) rStm << *pAttrList;
1121 	if( nMask & 0x0800 ) rStm << (sal_uInt16)nType;
1122 	if( nMask & 0x1000 ) rStm << cParserChar;
1123 	if( nMask & 0x2000 ) rStm << aCName;
1124 	if( nMask & 0x4000 ) rStm << aBasicName;
1125 	if( nMask & 0x8000 ) rStm << aBasicPostfix;
1126 }
1127 
1128 /*************************************************************************
1129 |*	  SvMetaType::GetAttrList()
1130 |*
1131 |*	  Beschreibung
1132 *************************************************************************/
GetAttrList() const1133 SvMetaAttributeMemberList &	SvMetaType::GetAttrList() const
1134 {
1135 	if( !pAttrList )
1136 		((SvMetaType *)this)->pAttrList = new SvMetaAttributeMemberList();
1137 	return *pAttrList;
1138 }
1139 
1140 /*************************************************************************
1141 |*	  SvMetaType::SetType()
1142 |*
1143 |*	  Beschreibung
1144 *************************************************************************/
SetType(int nT)1145 void SvMetaType::SetType( int nT )
1146 {
1147 	nType = nT;
1148 	if( nType == TYPE_ENUM )
1149 	{
1150 		aOdlName = "short";
1151 //        aSbxDataType = SbxINTEGER;
1152 	}
1153 	else if( nType == TYPE_CLASS )
1154 	{
1155 		aCName = C_PREF;
1156 		aCName += "Object *";
1157 	}
1158 }
1159 
1160 /*************************************************************************
1161 |*	  SvMetaType::GetBaseType()
1162 |*
1163 |*	  Beschreibung
1164 *************************************************************************/
GetBaseType() const1165 SvMetaType * SvMetaType::GetBaseType() const
1166 {
1167 	if( GetRef() && GetType() == TYPE_BASE )
1168     	return ((SvMetaType *)GetRef())->GetBaseType();
1169 	return (SvMetaType *)this;
1170 }
1171 
1172 /*************************************************************************
1173 |*	  SvMetaType::GetReturnType()
1174 |*
1175 |*	  Beschreibung
1176 *************************************************************************/
GetReturnType() const1177 SvMetaType * SvMetaType::GetReturnType() const
1178 {
1179 	DBG_ASSERT( GetType() == TYPE_METHOD, "no method" );
1180 	DBG_ASSERT( GetRef(), "no return type" );
1181     return (SvMetaType *)GetRef();
1182 }
1183 
1184 /*************************************************************************
1185 |*	  SvMetaType::GetSbxDataType()
1186 |*
1187 |*	  Beschreibung
1188 *************************************************************************/
1189 /*
1190 SbxDataType SvMetaType::GetSbxDataType() const
1191 {
1192     if( aSbxDataType.IsSet() || !GetRef() )
1193 		return (SbxDataType)(int)aSbxDataType;
1194 	else
1195     	return ((SvMetaType *)GetRef())->GetSbxDataType();
1196 }
1197 */
1198 /*************************************************************************
1199 |*	  SvMetaType::GetBasicName()
1200 |*
1201 |*	  Beschreibung
1202 *************************************************************************/
GetBasicName() const1203 const ByteString& SvMetaType::GetBasicName() const
1204 {
1205     if( aBasicName.IsSet() || !GetRef() )
1206 		return aBasicName;
1207 	else
1208     	return ((SvMetaType*)GetRef())->GetBasicName();
1209 }
1210 
1211 /*************************************************************************
1212 |*	  SvMetaType::GetBasicPostfix()
1213 |*
1214 |*	  Beschreibung
1215 *************************************************************************/
GetBasicPostfix() const1216 ByteString SvMetaType::GetBasicPostfix() const
1217 {
1218 
1219 	ByteString aRet;
1220 
1221 	// MBN und Co wollen immer "As xxx"
1222 /*
1223     if( aBasicPostfix.IsSet() || !GetRef() )
1224 		aRet = aBasicPostfix;
1225 	else
1226     	aRet = ((SvMetaType*)GetRef())->GetBasicPostfix();
1227 
1228 	if ( !aRet.Len() && GetBasicName().Len() )
1229 */
1230 	{
1231 
1232 		aRet = " As ";
1233 		aRet += GetBasicName();
1234 	}
1235 
1236 	return aRet;
1237 }
1238 
1239 /*************************************************************************
1240 |*	  SvMetaType::GetIn()
1241 |*
1242 |*	  Beschreibung
1243 *************************************************************************/
GetIn() const1244 sal_Bool SvMetaType::GetIn() const
1245 {
1246     if( aIn.IsSet() || !GetRef() )
1247 		return aIn;
1248 	else
1249     	return ((SvMetaType *)GetRef())->GetIn();
1250 }
1251 
1252 /*************************************************************************
1253 |*	  SvMetaType::GetOut()
1254 |*
1255 |*	  Beschreibung
1256 *************************************************************************/
GetOut() const1257 sal_Bool SvMetaType::GetOut() const
1258 {
1259     if( aOut.IsSet() || !GetRef() )
1260 		return aOut;
1261 	else
1262     	return ((SvMetaType *)GetRef())->GetOut();
1263 }
1264 
1265 /*************************************************************************
1266 |*	  SvMetaType::SetCall0()
1267 |*
1268 |*	  Beschreibung
1269 *************************************************************************/
SetCall0(int e)1270 void SvMetaType::SetCall0( int e )
1271 {
1272 	aCall0 = (int)e;
1273 	if( aCall0 == CALL_VALUE && aCall1 == CALL_VALUE )
1274 	{
1275 	  	if( GetType() == TYPE_POINTER )
1276 			SetType( TYPE_BASE );
1277 	}
1278 	else
1279 	{
1280 		DBG_ASSERT( nType == TYPE_POINTER || nType == TYPE_BASE,
1281 					"set no base type to pointer" );
1282 		SetType( TYPE_POINTER );
1283 	}
1284 }
1285 
1286 /*************************************************************************
1287 |*	  SvMetaType::GetCall0()
1288 |*
1289 |*	  Beschreibung
1290 *************************************************************************/
GetCall0() const1291 int SvMetaType::GetCall0() const
1292 {
1293     if( aCall0.IsSet() || !GetRef() )
1294 		return aCall0;
1295 	else
1296     	return ((SvMetaType *)GetRef())->GetCall0();
1297 }
1298 
1299 /*************************************************************************
1300 |*	  SvMetaType::SetCall1()
1301 |*
1302 |*	  Beschreibung
1303 *************************************************************************/
SetCall1(int e)1304 void SvMetaType::SetCall1( int e )
1305 {
1306 	aCall1 = (int)e;
1307 	if( aCall0 == CALL_VALUE && aCall1 == CALL_VALUE )
1308 	{
1309 	  	if( GetType() == TYPE_POINTER )
1310 			SetType( TYPE_BASE );
1311 	}
1312 	else
1313 	{
1314 		DBG_ASSERT( nType == TYPE_POINTER || nType == TYPE_BASE,
1315 					"set no base type to pointer" );
1316 		SetType( TYPE_POINTER );
1317 	}
1318 }
1319 
1320 /*************************************************************************
1321 |*	  SvMetaType::GetCall1()
1322 |*
1323 |*	  Beschreibung
1324 *************************************************************************/
GetCall1() const1325 int SvMetaType::GetCall1() const
1326 {
1327     if( aCall1.IsSet() || !GetRef() )
1328 		return aCall1;
1329 	else
1330     	return ((SvMetaType *)GetRef())->GetCall1();
1331 }
1332 
1333 /*************************************************************************
1334 |*	  SvMetaType::GetSvName()
1335 |*
1336 |*	  Beschreibung
1337 *************************************************************************/
GetSvName() const1338 const ByteString & SvMetaType::GetSvName() const
1339 {
1340     if( aSvName.IsSet() || !GetRef() )
1341 		return aSvName;
1342 	else
1343     	return ((SvMetaType *)GetRef())->GetSvName();
1344 }
1345 
1346 /*************************************************************************
1347 |*	  SvMetaType::GetSbxName()
1348 |*
1349 |*	  Beschreibung
1350 *************************************************************************/
GetSbxName() const1351 const ByteString & SvMetaType::GetSbxName() const
1352 {
1353     if( aSbxName.IsSet() || !GetRef() )
1354 		return aSbxName;
1355 	else
1356     	return ((SvMetaType *)GetRef())->GetSbxName();
1357 }
1358 
1359 /*************************************************************************
1360 |*	  SvMetaType::GetOdlName()
1361 |*
1362 |*	  Beschreibung
1363 *************************************************************************/
GetOdlName() const1364 const ByteString & SvMetaType::GetOdlName() const
1365 {
1366     if( aOdlName.IsSet() || !GetRef() )
1367 		return aOdlName;
1368 	else
1369     	return ((SvMetaType *)GetRef())->GetOdlName();
1370 }
1371 
1372 /*************************************************************************
1373 |*	  SvMetaType::GetCName()
1374 |*
1375 |*	  Beschreibung
1376 *************************************************************************/
GetCName() const1377 const ByteString & SvMetaType::GetCName() const
1378 {
1379     if( aCName.IsSet() || !GetRef() )
1380 		return aCName;
1381 	else
1382     	return ((SvMetaType *)GetRef())->GetCName();
1383 }
1384 
1385 /*************************************************************************
1386 |*	  SvMetaType::SetName()
1387 |*
1388 |*	  Beschreibung
1389 *************************************************************************/
SetName(const ByteString & rName,SvIdlDataBase * pBase)1390 sal_Bool SvMetaType::SetName( const ByteString & rName, SvIdlDataBase * pBase )
1391 {
1392 	aSvName 	= rName;
1393 	aSbxName    = rName;
1394 	aCName    	= rName;
1395 	if( GetType() != TYPE_ENUM )
1396 		aOdlName = rName;
1397 	return SvMetaReference::SetName( rName, pBase );
1398 }
1399 
1400 /*************************************************************************
1401 |*    SvMetaType::FillSbxObject()
1402 |*
1403 |*    Beschreibung
1404 *************************************************************************/
1405 /*
1406 void SvMetaType::FillSbxObject( SbxVariable * pObj, sal_Bool bVariable )
1407 {
1408 	if( PTR_CAST( SbxMethod, pObj ) )
1409 	{
1410 		if( GetType() == TYPE_METHOD )
1411 		{
1412 			sal_uLong nCount = GetAttrCount();
1413 			if( nCount )
1414 			{
1415 				SbxInfoRef xInfo = pObj->GetInfo();
1416 				if( !xInfo.Is() )
1417 				{
1418 				    xInfo = new SbxInfo();
1419 				    pObj->SetInfo( xInfo );
1420 				}
1421 				for( sal_uLong n = nCount; n > 0; n-- )
1422 					pAttrList->GetObject( n -1 )->FillSbxObject( xInfo );
1423 			}
1424 		}
1425 	}
1426 }
1427 */
1428 #ifdef IDL_COMPILER
1429 /*************************************************************************
1430 |*	  SvMetaType::GetString()
1431 |*
1432 |*	  Beschreibung
1433 *************************************************************************/
GetCString() const1434 ByteString SvMetaType::GetCString() const
1435 {
1436 	ByteString out( GetSvName() );
1437 	if( aCall0 == (int)CALL_POINTER )
1438 		out += " *";
1439 	else if( aCall0 == (int)CALL_REFERENCE )
1440 		out += " &";
1441 	if( aCall1 == (int)CALL_POINTER )
1442 		out += '*';
1443 	else if( aCall1 == (int)CALL_REFERENCE )
1444 		out += '&';
1445 	return out;
1446 }
1447 
1448 /*************************************************************************
1449 |*	  SvMetaType::ReadHeaderSvIdl()
1450 |*
1451 |*	  Beschreibung
1452 *************************************************************************/
ReadHeaderSvIdl(SvIdlDataBase & rBase,SvTokenStream & rInStm)1453 sal_Bool SvMetaType::ReadHeaderSvIdl( SvIdlDataBase & rBase,
1454 					   	  		SvTokenStream & rInStm )
1455 {
1456 	sal_Bool bOk = sal_False;
1457     sal_uInt32  nTokPos = rInStm.Tell();
1458     SvToken * pTok = rInStm.GetToken_Next();
1459 
1460     if( pTok->Is( SvHash_interface() )
1461       || pTok->Is( SvHash_shell() ) )
1462     {
1463 	    if( pTok->Is( SvHash_shell() ) )
1464 			bIsShell = sal_True;
1465 		SetType( TYPE_CLASS );
1466         bOk = ReadNamesSvIdl( rBase, rInStm );
1467 
1468     }
1469 	else if( pTok->Is( SvHash_struct() ) )
1470     {
1471 		SetType( TYPE_STRUCT );
1472         bOk = ReadNamesSvIdl( rBase, rInStm );
1473     }
1474 	else if( pTok->Is( SvHash_union() ) )
1475     {
1476 		SetType( TYPE_UNION );
1477         if( ReadNameSvIdl( rBase, rInStm ) )
1478 			return sal_True;
1479     }
1480 	else if( pTok->Is( SvHash_enum() ) )
1481     {
1482 		SetType( TYPE_ENUM );
1483         bOk = ReadNameSvIdl( rBase, rInStm );
1484     }
1485 	else if( pTok->Is( SvHash_typedef() )
1486 	  || pTok->Is( SvHash_item() ) )
1487     {
1488 	  	if( pTok->Is( SvHash_item() ) )
1489 			bIsItem = sal_True;
1490 
1491 		SvMetaType * pType = rBase.ReadKnownType( rInStm );
1492 		if( pType )
1493 		{
1494 			SetRef( pType );
1495 	        if( ReadNameSvIdl( rBase, rInStm ) )
1496 			{
1497 			    /*   	// um aufwaertskompatibel zu bleiben
1498 						aOdlName = pType->GetOdlName();
1499 				*/
1500 				if( rInStm.Read( '(' ) )
1501 				{
1502 					//DoReadContextSvIdl( rBase, rInStm, ',' );
1503 					DoReadContextSvIdl( rBase, rInStm );
1504 					if( rInStm.Read( ')' ) )
1505 					{
1506 						SetType( TYPE_METHOD );
1507 						bOk = sal_True;
1508 					}
1509 				}
1510 				else
1511 				{
1512 					bOk = sal_True;
1513 				}
1514 			}
1515 		}
1516 		else
1517 		{
1518             ByteString aStr = "wrong typedef: ";
1519             rBase.SetError( aStr, rInStm.GetToken() );
1520             rBase.WriteError( rInStm );
1521 		}
1522     }
1523 	if( bOk )
1524 		SetModule( rBase );
1525 	else
1526     	rInStm.Seek( nTokPos );
1527     return bOk;
1528 }
1529 
1530 /*************************************************************************
1531 |*	  SvMetaType::ReadSvIdl()
1532 |*
1533 |*	  Beschreibung
1534 *************************************************************************/
ReadSvIdl(SvIdlDataBase & rBase,SvTokenStream & rInStm)1535 sal_Bool SvMetaType::ReadSvIdl( SvIdlDataBase & rBase,
1536 					   	  SvTokenStream & rInStm )
1537 {
1538 	if( ReadHeaderSvIdl( rBase, rInStm ) )
1539 	{
1540 		rBase.Write( '.' );
1541 		return SvMetaExtern::ReadSvIdl( rBase, rInStm );
1542 	}
1543 	return sal_False;
1544 }
1545 
1546 /*************************************************************************
1547 |*	  SvMetaType::WriteSvIdl()
1548 |*
1549 |*	  Beschreibung
1550 *************************************************************************/
WriteSvIdl(SvIdlDataBase & rBase,SvStream & rOutStm,sal_uInt16 nTab)1551 void SvMetaType::WriteSvIdl
1552 (
1553 	SvIdlDataBase & rBase,
1554 	SvStream & rOutStm,
1555 	sal_uInt16 nTab
1556 )
1557 {
1558 	WriteHeaderSvIdl( rBase, rOutStm, nTab );
1559 	if( GetType() == TYPE_METHOD )
1560 		WriteMethodArgs( rBase, rOutStm, nTab, WRITE_IDL );
1561 
1562     sal_uLong nOldPos = rOutStm.Tell();
1563 	rOutStm << endl;
1564 	SvMetaExtern::WriteSvIdl( rBase, rOutStm, nTab );
1565 	if( TestAndSeekSpaceOnly( rOutStm, nOldPos ) )
1566 	    // nichts geschrieben
1567         rOutStm.Seek( nOldPos );
1568 	rOutStm << ';' << endl;
1569 }
1570 
1571 /*************************************************************************
1572 |*	  SvMetaType::WriteContext()
1573 |*
1574 |*	  Beschreibung
1575 *************************************************************************/
WriteContext(SvIdlDataBase & rBase,SvStream & rOutStm,sal_uInt16 nTab,WriteType nT,WriteAttribute nA)1576 void SvMetaType::WriteContext( SvIdlDataBase & rBase, SvStream & rOutStm,
1577 				  		   	sal_uInt16 nTab,
1578 		 					WriteType nT, WriteAttribute nA )
1579 {
1580 	if( GetAttrCount() )
1581 	{
1582 		SvMetaAttribute * pAttr = pAttrList->First();
1583 		while( pAttr )
1584 		{
1585 			pAttr->Write( rBase, rOutStm, nTab, nT, nA );
1586 			if( GetType() == TYPE_METHOD )
1587 				rOutStm << ',' << endl;
1588 			else
1589 				rOutStm << ';' << endl;
1590 			pAttr = pAttrList->Next();
1591 		}
1592 	}
1593 }
1594 
1595 /*************************************************************************
1596 |*	  SvMetaType::Write()
1597 |*
1598 |*	  Beschreibung
1599 *************************************************************************/
Write(SvIdlDataBase & rBase,SvStream & rOutStm,sal_uInt16 nTab,WriteType nT,WriteAttribute nA)1600 void SvMetaType::Write( SvIdlDataBase & rBase, SvStream & rOutStm,
1601 					  	sal_uInt16 nTab,
1602 		 				WriteType nT, WriteAttribute nA )
1603 {
1604 	if( nT == WRITE_C_HEADER && nType != TYPE_ENUM )
1605 		// nur enum schreiben
1606 		return;
1607 
1608 	ByteString name = GetName();
1609 	if( nT == WRITE_ODL || nT == WRITE_C_HEADER || nT == WRITE_CXX_HEADER )
1610 	{
1611 		switch( nType )
1612 		{
1613 		case TYPE_CLASS:
1614 			{
1615 			}
1616 			break;
1617 		case TYPE_STRUCT:
1618 		case TYPE_UNION:
1619 		case TYPE_ENUM:
1620 		{
1621 			WriteStars( rOutStm );
1622 			if( nType == TYPE_STRUCT || nType == TYPE_UNION )
1623 				nA = WA_STRUCT;
1624 
1625 			if( nT == WRITE_ODL || nT == WRITE_C_HEADER)
1626 			{
1627 				if ( nT == WRITE_C_HEADER )
1628 				{
1629 					ByteString aStr = name;
1630                     aStr.ToUpperAscii();
1631                     rOutStm << "#ifndef " << C_PREF << aStr.GetBuffer() << "_DEF " << endl;
1632                     rOutStm << "#define " << C_PREF << aStr.GetBuffer() << "_DEF " << endl;
1633 				}
1634 
1635 				WriteTab( rOutStm, nTab );
1636 				rOutStm << "typedef" << endl;
1637 				if ( nT == WRITE_ODL )
1638 					SvMetaName::Write( rBase, rOutStm, nTab, nT, nA );
1639 			}
1640 			WriteTab( rOutStm, nTab );
1641 			if( nType == TYPE_STRUCT )
1642 				rOutStm << "struct";
1643 			else if( nType == TYPE_UNION )
1644 				rOutStm << "union";
1645 			else
1646 				rOutStm << "enum";
1647 			if( nT != WRITE_ODL && nT != WRITE_C_HEADER)
1648                 rOutStm << ' ' << name.GetBuffer();
1649 
1650 			rOutStm << endl;
1651 			WriteTab( rOutStm, nTab );
1652 			rOutStm << '{' << endl;
1653 			WriteContext( rBase, rOutStm, nTab +1, nT, nA );
1654 			WriteTab( rOutStm, nTab );
1655 			rOutStm << '}';
1656 			if( nT == WRITE_ODL || nT == WRITE_C_HEADER )
1657 			{
1658                 rOutStm << ' ' << C_PREF << name.GetBuffer();
1659 			}
1660 			rOutStm << ';' << endl;
1661 
1662 			if ( nT == WRITE_C_HEADER )
1663 				rOutStm << "#endif";
1664 			rOutStm << endl;
1665 		}
1666 		break;
1667 		case TYPE_POINTER:
1668 		case TYPE_BASE:
1669 		{
1670 		}
1671 		break;
1672 		case TYPE_METHOD:
1673 	    {
1674 		}
1675 		break;
1676 		}
1677     }
1678 }
1679 
1680 /*************************************************************************
1681 |*	  SvMetaType::ReadNamesSvIdl()
1682 |*
1683 |*	  Beschreibung
1684 *************************************************************************/
ReadNamesSvIdl(SvIdlDataBase & rBase,SvTokenStream & rInStm)1685 sal_Bool SvMetaType::ReadNamesSvIdl( SvIdlDataBase & rBase,
1686 					   	  		SvTokenStream & rInStm )
1687 {
1688     sal_Bool bOk = ReadNameSvIdl( rBase, rInStm );
1689 /*
1690 	if( bOk )
1691 	{
1692 	    sal_uInt32 nTokPos = rInStm.Tell();
1693 	    SvToken * pTok = rInStm.GetToken_Next();
1694 
1695 		if( pTok->IsIdentifier() )
1696 		{
1697 		    aSbxName = pTok->GetString();
1698 
1699 			nTokPos = rInStm.Tell();
1700 			pTok = rInStm.GetToken_Next();
1701 			if( pTok->IsIdentifier() )
1702 			{
1703 			    aItemName = pTok->GetString();
1704 				nTokPos = rInStm.Tell();
1705 			}
1706 		}
1707 	    rInStm.Seek( nTokPos );
1708 	}
1709 */
1710 	return bOk;
1711 }
1712 
1713 /*************************************************************************
1714 |*	  SvMetaType::WriteHeaderSvIdl()
1715 |*
1716 |*	  Beschreibung
1717 *************************************************************************/
WriteHeaderSvIdl(SvIdlDataBase & rBase,SvStream & rOutStm,sal_uInt16 nTab)1718 void SvMetaType::WriteHeaderSvIdl( SvIdlDataBase & rBase,
1719 								   SvStream & rOutStm,
1720 								   sal_uInt16 nTab )
1721 {
1722 	switch( nType )
1723 	{
1724 		case TYPE_CLASS:
1725 		{
1726 			if( IsShell() )
1727                 rOutStm << SvHash_shell()->GetName().GetBuffer();
1728 			else
1729                 rOutStm << SvHash_interface()->GetName().GetBuffer();
1730             rOutStm << ' ' << GetName().GetBuffer();
1731 		}
1732 		break;
1733 		case TYPE_STRUCT:
1734 		{
1735             rOutStm << SvHash_struct()->GetName().GetBuffer()
1736                     << ' ' << GetName().GetBuffer();
1737 		}
1738 		break;
1739 		case TYPE_UNION:
1740 		{
1741             rOutStm << SvHash_union()->GetName().GetBuffer()
1742                     << ' ' << GetName().GetBuffer();
1743 		}
1744 		break;
1745 		case TYPE_ENUM:
1746 		{
1747             rOutStm << SvHash_enum()->GetName().GetBuffer()
1748                     << ' ' << GetName().GetBuffer();
1749 		}
1750 		break;
1751 		case TYPE_POINTER:
1752 		case TYPE_BASE:
1753 		{
1754 			if( IsItem() )
1755                 rOutStm << SvHash_item()->GetName().GetBuffer() << ' ';
1756 			else
1757                 rOutStm << SvHash_typedef()->GetName().GetBuffer() << ' ';
1758 			if( GetRef() )
1759 			{
1760 		    	((SvMetaType *)GetRef())->WriteTheType( rBase, rOutStm, nTab, WRITE_IDL );
1761 				rOutStm << ' ';
1762 			}
1763             rOutStm << GetName().GetBuffer();
1764 		}
1765 		break;
1766 		case TYPE_METHOD:
1767     	{
1768             rOutStm << SvHash_typedef()->GetName().GetBuffer() << ' ';
1769 		    ((SvMetaType *)GetRef())->WriteTheType( rBase, rOutStm, nTab, WRITE_IDL );
1770             rOutStm << ' ' << GetName().GetBuffer() << "( ";
1771 			WriteContextSvIdl( rBase, rOutStm, nTab );
1772 			rOutStm << " )";
1773 		}
1774 		break;
1775     }
1776 }
1777 
1778 /*************************************************************************
1779 |*	  SvMetaType::ReadAttributesSvIdl()
1780 |*
1781 |*	  Beschreibung
1782 *************************************************************************/
ReadAttributesSvIdl(SvIdlDataBase & rBase,SvTokenStream & rInStm)1783 void SvMetaType::ReadAttributesSvIdl( SvIdlDataBase & rBase,
1784 									  SvTokenStream & rInStm )
1785 {
1786 	SvMetaExtern::ReadAttributesSvIdl( rBase, rInStm );
1787 	aSvName.ReadSvIdl( SvHash_SvName(), rInStm );
1788 	aSbxName.ReadSvIdl( SvHash_SbxName(), rInStm );
1789 	aOdlName.ReadSvIdl( SvHash_OdlName(), rInStm );
1790 }
1791 
1792 /*************************************************************************
1793 |*	  SvMetaType::WriteAttributesSvIdl()
1794 |*
1795 |*	  Beschreibung
1796 *************************************************************************/
WriteAttributesSvIdl(SvIdlDataBase & rBase,SvStream & rOutStm,sal_uInt16 nTab)1797 void SvMetaType::WriteAttributesSvIdl( SvIdlDataBase & rBase,
1798 									   SvStream & rOutStm,
1799 									   sal_uInt16 nTab )
1800 {
1801 	SvMetaExtern::WriteAttributesSvIdl( rBase, rOutStm, nTab );
1802 	ByteString name = GetName();
1803 	if( aSvName != name || aSbxName != name || aOdlName != name )
1804 	{
1805 		WriteTab( rOutStm, nTab );
1806 		rOutStm << "class SvMetaType" << endl;
1807 		if( aSvName != name )
1808 		{
1809 			WriteTab( rOutStm, nTab );
1810 			aSvName.WriteSvIdl( SvHash_SvName(), rOutStm, nTab );
1811 			rOutStm << endl;
1812 		}
1813 		if( aSbxName != name )
1814 		{
1815 			WriteTab( rOutStm, nTab );
1816 			aSbxName.WriteSvIdl( SvHash_SbxName(), rOutStm, nTab );
1817 			rOutStm << endl;
1818 		}
1819 		if( aOdlName != name )
1820 		{
1821 			WriteTab( rOutStm, nTab );
1822 			aOdlName.WriteSvIdl( SvHash_OdlName(), rOutStm, nTab );
1823 			rOutStm << endl;
1824 		}
1825 	}
1826 }
1827 
1828 /*************************************************************************
1829 |*	  SvMetaType::ReadContextSvIdl()
1830 |*
1831 |*	  Beschreibung
1832 *************************************************************************/
ReadContextSvIdl(SvIdlDataBase & rBase,SvTokenStream & rInStm)1833 void SvMetaType::ReadContextSvIdl( SvIdlDataBase & rBase,
1834 									  SvTokenStream & rInStm )
1835 {
1836 	SvMetaAttributeRef xAttr = new SvMetaAttribute();
1837 	if( xAttr->ReadSvIdl( rBase, rInStm ) )
1838 	{
1839 		if( xAttr->Test( rBase, rInStm ) )
1840 			GetAttrList().Append( xAttr );
1841 	}
1842 }
1843 
1844 /*************************************************************************
1845 |*	  SvMetaType::WriteContextSvIdl()
1846 |*
1847 |*	  Beschreibung
1848 *************************************************************************/
WriteContextSvIdl(SvIdlDataBase & rBase,SvStream & rOutStm,sal_uInt16 nTab)1849 void SvMetaType::WriteContextSvIdl
1850 (
1851 	SvIdlDataBase & rBase,
1852 	SvStream & rOutStm,
1853 	sal_uInt16 nTab
1854 )
1855 {
1856 	if( GetAttrCount() )
1857 	{
1858 		SvMetaAttribute * pAttr = pAttrList->First();
1859 		while( pAttr )
1860 		{
1861 			WriteTab( rOutStm, nTab );
1862 			pAttr->WriteSvIdl( rBase, rOutStm, nTab );
1863 			if( GetType() == TYPE_METHOD )
1864 				rOutStm << ',' << endl;
1865 			else
1866 				rOutStm << ';' << endl;
1867 			pAttr = pAttrList->Next();
1868 		}
1869 	}
1870 }
1871 
1872 /*************************************************************************
1873 |*	  SvMetaType::WriteAttributes()
1874 |*
1875 |*	  Beschreibung
1876 *************************************************************************/
WriteAttributes(SvIdlDataBase & rBase,SvStream & rOutStm,sal_uInt16 nTab,WriteType nT,WriteAttribute nA)1877 void SvMetaType::WriteAttributes( SvIdlDataBase & rBase, SvStream & rOutStm,
1878 							   	sal_uInt16 nTab,
1879 			 					WriteType nT, WriteAttribute nA )
1880 {
1881 	SvMetaExtern::WriteAttributes( rBase, rOutStm, nTab, nT, nA );
1882 }
1883 
1884 /*************************************************************************
1885 |*	  SvMetaType::MakeSfx()
1886 |*
1887 |*	  Beschreibung
1888 *************************************************************************/
MakeSfx(ByteString * pAttrArray)1889 sal_uLong SvMetaType::MakeSfx( ByteString * pAttrArray )
1890 {
1891 	sal_uLong nC = 0;
1892 
1893 	if( GetBaseType()->GetType() == TYPE_STRUCT )
1894 	{
1895 		sal_uLong nAttrCount = GetAttrCount();
1896 		// Die einzelnen Attribute schreiben
1897 		for( sal_uLong n = 0; n < nAttrCount; n++ )
1898 		{
1899 		    nC += pAttrList->GetObject( n )->MakeSfx( pAttrArray );
1900 			if( n +1 < nAttrCount )
1901 				*pAttrArray += ", ";
1902 		}
1903 	}
1904 	return nC;
1905 }
1906 
WriteSfxItem(const ByteString & rItemName,SvIdlDataBase &,SvStream & rOutStm)1907 void SvMetaType::WriteSfxItem(
1908     const ByteString & rItemName, SvIdlDataBase &, SvStream & rOutStm )
1909 {
1910 	WriteStars( rOutStm );
1911 	ByteString aVarName = " a";
1912 	aVarName += rItemName;
1913 	aVarName += "_Impl";
1914 
1915 	ByteString	aTypeName = "SfxType";
1916 	ByteString  aAttrArray;
1917 	sal_uLong	nAttrCount = MakeSfx( &aAttrArray );
1918 	//sal_uLong	nAttrCount = GetAttrCount();
1919     ByteString  aAttrCount( ByteString::CreateFromInt32( nAttrCount ) );
1920     aTypeName += aAttrCount;
1921 
1922     rOutStm << "extern " << aTypeName.GetBuffer()
1923             << aVarName.GetBuffer() << ';' << endl;
1924 
1925 	// Den Implementationsteil schreiben
1926 	rOutStm << "#ifdef SFX_TYPEMAP" << endl
1927             << aTypeName.GetBuffer() << aVarName.GetBuffer()
1928 			<< " = " << endl;
1929 	rOutStm << '{' << endl
1930             << "\tTYPE(" << rItemName.GetBuffer() << "), "
1931             << aAttrCount.GetBuffer();
1932 	if( nAttrCount )
1933 	{
1934 		rOutStm << ", { ";
1935 		// Die einzelnen Attribute schreiben
1936         rOutStm << aAttrArray.GetBuffer();
1937 		rOutStm << " }";
1938 	}
1939 	rOutStm << endl << "};" << endl
1940 			<< "#endif" << endl << endl;
1941 }
1942 
1943 /*************************************************************************
1944 |*	  SvMetaType::WriteSfx()
1945 |*
1946 |*	  Beschreibung
1947 *************************************************************************/
WriteSfx(SvIdlDataBase & rBase,SvStream & rOutStm)1948 void SvMetaType::WriteSfx( SvIdlDataBase & rBase, SvStream & rOutStm )
1949 {
1950 	if( IsItem() )
1951 	{
1952 		if( GetBaseType()->GetType() == TYPE_STRUCT )
1953 			GetBaseType()->WriteSfxItem( GetName(), rBase, rOutStm );
1954 		else
1955 			WriteSfxItem( GetName(), rBase, rOutStm );
1956 	}
1957 }
1958 
1959 /*************************************************************************
1960 |*	  SvMetaType::ReadMethodArgs()
1961 |*
1962 |*	  Beschreibung
1963 *************************************************************************/
ReadMethodArgs(SvIdlDataBase & rBase,SvTokenStream & rInStm)1964 sal_Bool SvMetaType::ReadMethodArgs( SvIdlDataBase & rBase,
1965 					   	  		 SvTokenStream & rInStm )
1966 {
1967     sal_uInt32  nTokPos = rInStm.Tell();
1968 	if( rInStm.Read( '(' ) )
1969 	{
1970 		//DoReadContextSvIdl( rBase, rInStm, ',' );
1971 		DoReadContextSvIdl( rBase, rInStm );
1972 		if( rInStm.Read( ')' ) )
1973 		{
1974 			SetType( TYPE_METHOD );
1975 			return sal_True;
1976 		}
1977 	}
1978     rInStm.Seek( nTokPos );
1979 	return sal_False;
1980 }
1981 
1982 /*************************************************************************
1983 |*	  SvMetaType::WriteMethodArgs()
1984 |*
1985 |*	  Beschreibung
1986 *************************************************************************/
WriteMethodArgs(SvIdlDataBase & rBase,SvStream & rOutStm,sal_uInt16 nTab,WriteType nT)1987 void SvMetaType::WriteMethodArgs
1988 (
1989 	SvIdlDataBase & rBase,
1990 	SvStream & rOutStm,
1991 	sal_uInt16 nTab, WriteType nT
1992 )
1993 {
1994 	if( nT == WRITE_IDL )
1995 	{
1996 		if( GetAttrCount() )
1997 		{
1998 			rOutStm << endl;
1999 			WriteTab( rOutStm, nTab );
2000 			rOutStm << '(' << endl;
2001 
2002 			SvMetaAttribute * pAttr = pAttrList->First();
2003 			while( pAttr )
2004 			{
2005 				WriteTab( rOutStm, nTab +1 );
2006 				pAttr->WriteSvIdl( rBase, rOutStm, nTab +1 );
2007 				pAttr = pAttrList->Next();
2008 				if( pAttr )
2009 				   	rOutStm << ',' << endl;
2010 			}
2011 			rOutStm << endl;
2012 			WriteTab( rOutStm, nTab );
2013 			rOutStm << ')';
2014 		}
2015 		else
2016 			rOutStm << "()";
2017 	}
2018 	else if ( nT == WRITE_DOCU )
2019 	{
2020 
2021 		rOutStm << '(';
2022 		if( GetAttrCount() )
2023 		{
2024 			SvMetaAttribute * pAttr = pAttrList->First();
2025 			while( pAttr )
2026 			{
2027 				pAttr->WriteParam( rBase, rOutStm, nTab+1, nT );
2028 				pAttr = pAttrList->Next();
2029 				if( pAttr )
2030 					rOutStm << ',';
2031 				else
2032 					rOutStm << ' ';
2033 			}
2034 		}
2035 		rOutStm << ')' << endl;
2036 	}
2037 	else
2038 	{
2039 		rOutStm << '(';
2040 		if( nT == WRITE_C_HEADER || nT == WRITE_C_SOURCE )
2041 		{
2042             rOutStm << ' ' << C_PREF << "Object h" << rBase.aIFaceName.GetBuffer();
2043 			if( GetAttrCount() )
2044 				rOutStm << ',';
2045 			else
2046 				rOutStm << ' ';
2047 		}
2048 
2049 		if( GetAttrCount() )
2050 		{
2051 			rOutStm << endl;
2052 			SvMetaAttribute * pAttr = pAttrList->First();
2053 			while( pAttr )
2054 			{
2055 				switch( nT )
2056 				{
2057 					case WRITE_C_HEADER:
2058 					case WRITE_C_SOURCE:
2059 					case WRITE_ODL:
2060 					{
2061 						pAttr->WriteParam( rBase, rOutStm, nTab +1, nT );
2062 					}
2063 					break;
2064 
2065 					default:
2066 					{
2067 						DBG_ASSERT( sal_False, "WriteType not implemented" );
2068 					}
2069 				}
2070 				pAttr = pAttrList->Next();
2071 				if( pAttr )
2072 				   	rOutStm << ',' << endl;
2073 			}
2074 			if( nT != WRITE_C_HEADER && nT != WRITE_C_SOURCE )
2075 			{
2076 				rOutStm << endl;
2077 				WriteTab( rOutStm, nTab +1 );
2078 			}
2079 			rOutStm << ' ';
2080 		}
2081 		rOutStm << ')';
2082 	}
2083 }
2084 
2085 /*************************************************************************
2086 |*	  SvMetaType::WriteTypePrefix()
2087 |*
2088 |*	  Beschreibung
2089 *************************************************************************/
WriteTypePrefix(SvIdlDataBase & rBase,SvStream & rOutStm,sal_uInt16 nTab,WriteType nT)2090 void SvMetaType::WriteTypePrefix( SvIdlDataBase & rBase, SvStream & rOutStm,
2091 							 	sal_uInt16 nTab, WriteType nT )
2092 {
2093 	switch( nT )
2094 	{
2095 		case WRITE_IDL:
2096 		{
2097 			if( GetIn() && GetOut() )
2098                 rOutStm << SvHash_inout()->GetName().GetBuffer() << ' ';
2099 			else if( GetIn() )
2100                 rOutStm << SvHash_in()->GetName().GetBuffer() << ' ';
2101 			else if( GetOut() )
2102                 rOutStm << SvHash_out()->GetName().GetBuffer() << ' ';
2103             rOutStm << GetCString().GetBuffer();
2104 		}
2105 		break;
2106 
2107 		case WRITE_ODL:
2108 		{
2109 			sal_Bool bIn = GetIn();
2110 			sal_Bool bOut = GetOut();
2111 			if( bIn || bOut )
2112 			{
2113 				if( bIn && bOut )
2114 					rOutStm << "[in,out] ";
2115 				else if( bIn )
2116 					rOutStm << "[in] ";
2117 				else if( bOut )
2118 					rOutStm << "[out] ";
2119 			}
2120 
2121 			ByteString out;
2122 			if( GetType() == TYPE_METHOD )
2123 				out = GetReturnType()->GetBaseType()->GetOdlName();
2124 			else
2125 			{
2126 				SvMetaType * pBType = GetBaseType();
2127 				out = pBType->GetOdlName();
2128 			}
2129 			if( aCall0 == (int)CALL_POINTER
2130 			  || aCall0 == (int)CALL_REFERENCE )
2131 				rOutStm << " *";
2132 			if( aCall1 == (int)CALL_POINTER
2133 			  || aCall1 == (int)CALL_REFERENCE )
2134 				rOutStm << " *";
2135             rOutStm << out.GetBuffer();
2136 		}
2137 		break;
2138 
2139 		case WRITE_C_HEADER:
2140 		case WRITE_C_SOURCE:
2141 		case WRITE_CXX_HEADER:
2142 		case WRITE_CXX_SOURCE:
2143 		{
2144 
2145 			SvMetaType * pBaseType = GetBaseType();
2146 			DBG_ASSERT( pBaseType, "no base type for attribute" );
2147 
2148 			if( pBaseType->GetType() == TYPE_METHOD )
2149 				pBaseType->GetReturnType()->WriteTypePrefix(
2150 					rBase, rOutStm, nTab, nT );
2151 			else if( nT == WRITE_C_HEADER || nT == WRITE_C_SOURCE )
2152 			{
2153 				if( TYPE_STRUCT == pBaseType->GetType() )
2154                     rOutStm << C_PREF << pBaseType->GetName().GetBuffer()
2155 							<< " *";
2156 				else
2157 				{
2158 					if ( pBaseType->GetType() == TYPE_ENUM )
2159 						rOutStm << C_PREF;
2160                     rOutStm << pBaseType->GetCName().GetBuffer();
2161 				}
2162 			}
2163 			else
2164 			{
2165 				if( TYPE_STRUCT == pBaseType->GetType() )
2166                     rOutStm << pBaseType->GetName().GetBuffer() << " *";
2167 				else
2168                     rOutStm << pBaseType->GetName().GetBuffer();
2169 			}
2170 		}
2171 		break;
2172 
2173 		case WRITE_DOCU:
2174 		{
2175 
2176 			SvMetaType * pBaseType = GetBaseType();
2177 			DBG_ASSERT( pBaseType, "no base type for attribute" );
2178 
2179 			if( pBaseType->GetType() == TYPE_METHOD )
2180 			{
2181 				pBaseType->GetReturnType()->WriteTypePrefix(
2182 					rBase, rOutStm, nTab, nT );
2183 			}
2184 			else
2185 			{
2186 				if( TYPE_STRUCT == pBaseType->GetType() )
2187                     rOutStm << "VARIANT" << pBaseType->GetName().GetBuffer();
2188 				else if ( pBaseType->GetType() == TYPE_ENUM )
2189 					rOutStm << "integer";
2190 				else
2191                     rOutStm << pBaseType->GetOdlName().GetBuffer();
2192 			}
2193 		}
2194 
2195 		default:
2196 		{
2197 			DBG_ASSERT( sal_False, "WriteType not implemented" );
2198 		}
2199 	}
2200 }
2201 
2202 /*************************************************************************
2203 |*	  SvMetaType::WriteTheType()
2204 |*
2205 |*	  Beschreibung
2206 *************************************************************************/
WriteTheType(SvIdlDataBase & rBase,SvStream & rOutStm,sal_uInt16 nTab,WriteType nT)2207 void SvMetaType::WriteTheType( SvIdlDataBase & rBase, SvStream & rOutStm,
2208 							 sal_uInt16 nTab, WriteType nT )
2209 {
2210 	WriteTypePrefix( rBase, rOutStm, nTab, nT );
2211 	if( GetType() == TYPE_METHOD )
2212 		WriteMethodArgs( rBase, rOutStm, nTab +2, nT );
2213 }
2214 
2215 /*************************************************************************
2216 |*	  SvMetaType::GetParserString()
2217 |*
2218 |*	  Beschreibung
2219 *************************************************************************/
GetParserString() const2220 ByteString SvMetaType::GetParserString() const
2221 {
2222 	SvMetaType * pBT = GetBaseType();
2223 	if( pBT != this )
2224 		return pBT->GetParserString();
2225 
2226 	int type = GetType();
2227 	ByteString aPStr;
2228 
2229 	if( TYPE_METHOD == type || TYPE_STRUCT == type )
2230 	{
2231 		sal_uLong nAttrCount = GetAttrCount();
2232 		// Die einzelnen Attribute schreiben
2233 		for( sal_uLong n = 0; n < nAttrCount; n++ )
2234 		{
2235 		    SvMetaAttribute * pT = pAttrList->GetObject( n );
2236 			aPStr += pT->GetType()->GetParserString();
2237 		}
2238 	}
2239 	else
2240 		aPStr = GetParserChar();
2241 	return aPStr;
2242 }
2243 
2244 /*************************************************************************
2245 |*    SvMetaType::WriteParamNames()
2246 |*
2247 |*    Beschreibung
2248 *************************************************************************/
WriteParamNames(SvIdlDataBase & rBase,SvStream & rOutStm,const ByteString & rChief)2249 void SvMetaType::WriteParamNames( SvIdlDataBase & rBase,
2250 			   					SvStream & rOutStm,
2251 			   					const ByteString & rChief )
2252 {
2253 	SvMetaType * pBT = GetBaseType();
2254 	if( pBT != this )
2255 		pBT->WriteParamNames( rBase, rOutStm, rChief );
2256 	else
2257 	{
2258 		int type = GetType();
2259 		ByteString aPStr;
2260 
2261 		if( TYPE_METHOD == type || TYPE_STRUCT == type )
2262 		{
2263 			sal_uLong nAttrCount = GetAttrCount();
2264 			// Die einzelnen Attribute schreiben
2265 			for( sal_uLong n = 0; n < nAttrCount; n++ )
2266 			{
2267 			    SvMetaAttribute * pA = pAttrList->GetObject( n );
2268 				// Fuer Methoden ist rChief immer ""
2269 				ByteString aStr = /*rChief;
2270 				if( aStr.Len() )
2271 					aStr += "->";
2272 				aStr += */pA->GetName();
2273 				pA->GetType()->WriteParamNames( rBase, rOutStm, aStr );
2274 				if( n +1 < nAttrCount )
2275 					rOutStm << ", ";
2276 			}
2277 		}
2278 		else
2279             rOutStm << rChief.GetBuffer();
2280 	}
2281 }
2282 
2283 #endif // IDL_COMPILER
2284 
2285 /************************************************************************/
2286 /************************************************************************/
2287 SV_IMPL_META_FACTORY1( SvMetaTypeString, SvMetaType );
2288 /*************************************************************************
2289 |*
2290 |*	  SvMetaTypeString::SvMetaTypeString()
2291 |*
2292 |*	  Beschreibung
2293 |*
2294 *************************************************************************/
SvMetaTypeString()2295 SvMetaTypeString::SvMetaTypeString()
2296     : SvMetaType( "String", "SbxSTRING", "BSTR", 's', "char *", "String", "$" )
2297 {
2298 }
2299 
Load(SvPersistStream & rStm)2300 void SvMetaTypeString::Load( SvPersistStream & rStm )
2301 {
2302 	SvMetaType::Load( rStm );
2303 }
2304 
Save(SvPersistStream & rStm)2305 void SvMetaTypeString::Save( SvPersistStream & rStm )
2306 {
2307 	SvMetaType::Save( rStm );
2308 }
2309 
2310 /************************************************************************/
2311 /************************************************************************/
2312 SV_IMPL_META_FACTORY1( SvMetaEnumValue, SvMetaName );
2313 /*************************************************************************
2314 |*
2315 |*	  SvMetaEnumValue::SvMetaEnumValue()
2316 |*
2317 |*	  Beschreibung
2318 |*
2319 *************************************************************************/
SvMetaEnumValue()2320 SvMetaEnumValue::SvMetaEnumValue()
2321 {
2322 }
2323 
Load(SvPersistStream & rStm)2324 void SvMetaEnumValue::Load( SvPersistStream & rStm )
2325 {
2326 	SvMetaName::Load( rStm );
2327 
2328 	sal_uInt8 nMask;
2329 	rStm >> nMask;
2330 	if( nMask >= 0x02 )
2331 	{
2332 		rStm.SetError( SVSTREAM_FILEFORMAT_ERROR );
2333 		DBG_ERROR( "wrong format" );
2334 		return;
2335 	}
2336     if( nMask & 0x01 ) rStm.ReadByteString( aEnumValue );
2337 }
2338 
Save(SvPersistStream & rStm)2339 void SvMetaEnumValue::Save( SvPersistStream & rStm )
2340 {
2341 	SvMetaName::Save( rStm );
2342 
2343 	// Maske erstellen
2344 	sal_uInt8 nMask = 0;
2345 	if( aEnumValue.Len() ) nMask |= 0x01;
2346 
2347 	// Daten schreiben
2348 	rStm << nMask;
2349     if( nMask & 0x01 ) rStm.WriteByteString( aEnumValue );
2350 }
2351 
2352 #ifdef IDL_COMPILER
2353 /*************************************************************************
2354 |*
2355 |*	  SvMetaEnumValue::ReadSvIdl()
2356 |*
2357 |*	  Beschreibung
2358 |*
2359 *************************************************************************/
ReadSvIdl(SvIdlDataBase & rBase,SvTokenStream & rInStm)2360 sal_Bool SvMetaEnumValue::ReadSvIdl( SvIdlDataBase & rBase,
2361 								 SvTokenStream & rInStm )
2362 {
2363 	if( !ReadNameSvIdl( rBase, rInStm ) )
2364 		return sal_False;
2365 	return sal_True;
2366 }
2367 
2368 /*************************************************************************
2369 |*
2370 |*	  SvMetaEnumValue::WriteSvIdl()
2371 |*
2372 |*	  Beschreibung
2373 |*
2374 *************************************************************************/
WriteSvIdl(SvIdlDataBase &,SvStream & rOutStm,sal_uInt16)2375 void SvMetaEnumValue::WriteSvIdl( SvIdlDataBase &, SvStream & rOutStm, sal_uInt16 )
2376 {
2377     rOutStm << GetName().GetBuffer();
2378 }
2379 
2380 /*************************************************************************
2381 |*
2382 |*	  SvMetaEnumValue::Write()
2383 |*
2384 |*	  Beschreibung
2385 |*
2386 *************************************************************************/
Write(SvIdlDataBase &,SvStream & rOutStm,sal_uInt16,WriteType nT,WriteAttribute)2387 void SvMetaEnumValue::Write( SvIdlDataBase &, SvStream & rOutStm, sal_uInt16,
2388                              WriteType nT, WriteAttribute )
2389 {
2390 	if ( nT == WRITE_C_HEADER || nT == WRITE_C_SOURCE )
2391         rOutStm << C_PREF << GetName().GetBuffer();
2392 	else
2393         rOutStm << GetName().GetBuffer();
2394 }
2395 #endif // IDL_COMPILER
2396 
2397 /************************************************************************/
2398 /************************************************************************/
2399 SV_IMPL_META_FACTORY1( SvMetaTypeEnum, SvMetaType );
2400 /*************************************************************************
2401 |*
2402 |*	  SvMetaTypeEnum::SvMetaTypeEnum()
2403 |*
2404 |*	  Beschreibung
2405 |*
2406 *************************************************************************/
SvMetaTypeEnum()2407 SvMetaTypeEnum::SvMetaTypeEnum()
2408 {
2409 	SetBasicName( "Integer" );
2410 }
2411 
Load(SvPersistStream & rStm)2412 void SvMetaTypeEnum::Load( SvPersistStream & rStm )
2413 {
2414 	SvMetaType::Load( rStm );
2415 
2416 	sal_uInt8 nMask;
2417 	rStm >> nMask;
2418 	if( nMask >= 0x04 )
2419 	{
2420 		rStm.SetError( SVSTREAM_FILEFORMAT_ERROR );
2421 		DBG_ERROR( "wrong format" );
2422 		return;
2423 	}
2424 	if( nMask & 0x01 ) rStm >> aEnumValueList;
2425     if( nMask & 0x02 ) rStm.ReadByteString( aPrefix );
2426 }
2427 
Save(SvPersistStream & rStm)2428 void SvMetaTypeEnum::Save( SvPersistStream & rStm )
2429 {
2430 	SvMetaType::Save( rStm );
2431 
2432 	// Maske erstellen
2433 	sal_uInt8 nMask = 0;
2434 	if( aEnumValueList.Count() )	nMask |= 0x01;
2435 	if( aPrefix.Len() ) 			nMask |= 0x02;
2436 
2437 	// Daten schreiben
2438 	rStm << nMask;
2439 	if( nMask & 0x01 ) rStm << aEnumValueList;
2440     if( nMask & 0x02 ) rStm.WriteByteString( aPrefix );
2441 }
2442 
2443 /*************************************************************************
2444 |*
2445 |*	  SvMetaTypeEnum::GetMaxValue()
2446 |*
2447 |*	  Beschreibung
2448 |*
2449 *************************************************************************/
2450 /*
2451 sal_uInt16 SvMetaTypeEnum::GetMaxValue() const
2452 {
2453 	sal_uInt16 nMax = 0;
2454 	for( sal_uLong n = 0; n < aEnumValueList.Count(); n++ )
2455 	{
2456 		SvMetaEnumValue * pObj = aEnumValueList.GetObject( n );
2457 		if( nMax < pObj->GetValue() )
2458 			nMax = pObj->GetValue();
2459 	}
2460 	return nMax;
2461 }
2462 */
2463 
2464 #ifdef IDL_COMPILER
2465 /*************************************************************************
2466 |*
2467 |*	  SvMetaTypeEnum::ReadContextSvIdl()
2468 |*
2469 |*	  Beschreibung
2470 |*
2471 *************************************************************************/
ReadContextSvIdl(SvIdlDataBase & rBase,SvTokenStream & rInStm)2472 void SvMetaTypeEnum::ReadContextSvIdl( SvIdlDataBase & rBase,
2473 									   SvTokenStream & rInStm )
2474 {
2475 	sal_uInt32 nTokPos = rInStm.Tell();
2476 
2477 	SvMetaEnumValueRef aEnumVal = new SvMetaEnumValue();
2478 	sal_Bool bOk = aEnumVal->ReadSvIdl( rBase, rInStm );
2479 	if( bOk )
2480 	{
2481 		if( 0 == aEnumValueList.Count() )
2482 		   // der Erste
2483 		   aPrefix = aEnumVal->GetName();
2484 		else
2485 		{
2486 			sal_uInt16 nPos = aPrefix.Match( aEnumVal->GetName() );
2487 			if( nPos != aPrefix.Len() && nPos != STRING_MATCH )
2488 				aPrefix.Erase( nPos );
2489 		}
2490 		aEnumValueList.Append( aEnumVal );
2491 	}
2492 	if( !bOk )
2493 		rInStm.Seek( nTokPos );
2494 }
2495 
2496 /*************************************************************************
2497 |*
2498 |*	  SvMetaTypeEnum::WriteSvIdl()
2499 |*
2500 |*	  Beschreibung
2501 |*
2502 *************************************************************************/
WriteContextSvIdl(SvIdlDataBase & rBase,SvStream & rOutStm,sal_uInt16 nTab)2503 void SvMetaTypeEnum::WriteContextSvIdl( SvIdlDataBase & rBase,
2504 										SvStream & rOutStm,
2505 										sal_uInt16 nTab )
2506 {
2507 	WriteTab( rOutStm, nTab +1 );
2508 	for( sal_uLong n = 0; n < aEnumValueList.Count(); n++ )
2509 	{
2510 		aEnumValueList.GetObject( n )->WriteSvIdl( rBase, rOutStm, nTab );
2511 		if( n +1 != aEnumValueList.Count() )
2512 			rOutStm << ", ";
2513 		else
2514 			rOutStm << endl;
2515 	}
2516 }
2517 
2518 /*************************************************************************
2519 |*
2520 |*	  SvMetaTypeEnum::ReadSvIdl()
2521 |*
2522 |*	  Beschreibung
2523 |*
2524 *************************************************************************/
ReadSvIdl(SvIdlDataBase & rBase,SvTokenStream & rInStm)2525 sal_Bool SvMetaTypeEnum::ReadSvIdl( SvIdlDataBase & rBase,
2526 								SvTokenStream & rInStm )
2527 {
2528 	sal_uInt32	nTokPos = rInStm.Tell();
2529 	if( SvMetaType::ReadHeaderSvIdl( rBase, rInStm )
2530 	  && GetType() == TYPE_ENUM )
2531 	{
2532 		if( SvMetaName::ReadSvIdl( rBase, rInStm ) )
2533 	 		return sal_True;
2534 	}
2535 	rInStm.Seek( nTokPos );
2536 	return sal_False;
2537 }
2538 
2539 /*************************************************************************
2540 |*
2541 |*	  SvMetaTypeEnum::WriteSvIdl()
2542 |*
2543 |*	  Beschreibung
2544 |*
2545 *************************************************************************/
WriteSvIdl(SvIdlDataBase & rBase,SvStream & rOutStm,sal_uInt16 nTab)2546 void SvMetaTypeEnum::WriteSvIdl( SvIdlDataBase & rBase, SvStream & rOutStm,
2547 								   sal_uInt16 nTab )
2548 {
2549 	WriteHeaderSvIdl( rBase, rOutStm, nTab );
2550 	rOutStm << endl;
2551     SvMetaName::WriteSvIdl( rBase, rOutStm, nTab );
2552 	rOutStm << endl;
2553 }
2554 
2555 /*************************************************************************
2556 |*
2557 |*	  SvMetaTypeEnum::Write()
2558 |*
2559 |*	  Beschreibung
2560 |*
2561 *************************************************************************/
Write(SvIdlDataBase & rBase,SvStream & rOutStm,sal_uInt16 nTab,WriteType nT,WriteAttribute nA)2562 void SvMetaTypeEnum::Write( SvIdlDataBase & rBase, SvStream & rOutStm,
2563 							sal_uInt16 nTab,
2564 		 					WriteType nT, WriteAttribute nA )
2565 {
2566 	SvMetaType::Write( rBase, rOutStm, nTab, nT, nA );
2567 }
2568 
2569 /*************************************************************************
2570 |*	  SvMetaTypeEnum::WriteContext()
2571 |*
2572 |*	  Beschreibung
2573 *************************************************************************/
WriteContext(SvIdlDataBase & rBase,SvStream & rOutStm,sal_uInt16 nTab,WriteType nT,WriteAttribute nA)2574 void SvMetaTypeEnum::WriteContext( SvIdlDataBase & rBase, SvStream & rOutStm,
2575 							   	sal_uInt16 nTab,
2576 		 						WriteType nT, WriteAttribute nA )
2577 {
2578 	WriteTab( rOutStm, nTab +1 );
2579 	for( sal_uLong n = 0; n < aEnumValueList.Count(); n++ )
2580 	{
2581 		aEnumValueList.GetObject( n )->Write( rBase, rOutStm, nTab +1, nT, nA );
2582 
2583 		if( n +1 != aEnumValueList.Count() )
2584 		{
2585 			if( 2 == n % 3 )
2586 			{
2587 				rOutStm << ',' << endl;
2588 				WriteTab( rOutStm, nTab +1 );
2589 			}
2590 			else
2591 				rOutStm << ",\t";
2592 		}
2593 		else
2594 			rOutStm << endl;
2595 	}
2596 	rOutStm << endl;
2597 }
2598 
2599 #endif // IDL_COMPILER
2600 
2601 /************************************************************************/
2602 /************************************************************************/
2603 SV_IMPL_META_FACTORY1( SvMetaTypevoid, SvMetaType );
2604 /*************************************************************************
2605 |*
2606 |*	  SvMetaTypevoid::SvMetaTypevoid()
2607 |*
2608 |*	  Beschreibung
2609 |*
2610 *************************************************************************/
SvMetaTypevoid()2611 SvMetaTypevoid::SvMetaTypevoid()
2612     : SvMetaType( "void", "SbxVOID", "void", 'v', "void", "", "" )
2613 {
2614 }
2615 
Load(SvPersistStream & rStm)2616 void SvMetaTypevoid::Load( SvPersistStream & rStm )
2617 {
2618 	SvMetaType::Load( rStm );
2619 }
2620 
Save(SvPersistStream & rStm)2621 void SvMetaTypevoid::Save( SvPersistStream & rStm )
2622 {
2623 	SvMetaType::Save( rStm );
2624 }
2625 
Compare(SvMetaAttribute * pAttr)2626 ByteString SvMetaAttribute::Compare( SvMetaAttribute* pAttr )
2627 {
2628 	ByteString aStr;
2629 
2630 	if ( aType.Is() )
2631 	{
2632 		if ( aType->GetType() == TYPE_METHOD )
2633 		{
2634 			// Nur testen, wenn das Attribut eine Methode ist, nicht wenn es
2635 			// eine hat !!
2636 			if ( !pAttr->GetType()->GetType() == TYPE_METHOD )
2637 				aStr += "    IsMethod\n";
2638 			else if ( aType->GetReturnType() &&
2639 				aType->GetReturnType()->GetType() != pAttr->GetType()->GetReturnType()->GetType() )
2640 					aStr += "    ReturnType\n";
2641 
2642 			if ( aType->GetAttrCount() )
2643 			{
2644 				sal_uLong nCount = aType->GetAttrCount();
2645 				SvMetaAttributeMemberList& rList = aType->GetAttrList();
2646 				SvMetaAttributeMemberList& rOtherList = pAttr->GetType()->GetAttrList();
2647 				if ( pAttr->GetType()->GetAttrCount() != nCount )
2648 				{
2649 					aStr += "    AttributeCount\n";
2650 				}
2651 				else
2652 				{
2653 					for ( sal_uInt16 n=0; n<nCount; n++ )
2654 					{
2655 						SvMetaAttribute *pAttr1 = rList.GetObject(n);
2656 						SvMetaAttribute *pAttr2 = rOtherList.GetObject(n);
2657 						pAttr1->Compare( pAttr2 );
2658 					}
2659 				}
2660 			}
2661 		}
2662 
2663 		if ( GetType()->GetType() != pAttr->GetType()->GetType() )
2664 			aStr += "    Type\n";
2665 
2666         if ( !GetType()->GetSvName().Equals( pAttr->GetType()->GetSvName() ) )
2667 			aStr += "    ItemType\n";
2668 	}
2669 
2670 	if ( GetExport() != pAttr->GetExport() )
2671 		aStr += "    Export\n";
2672 
2673 	if ( GetAutomation() != pAttr->GetAutomation() )
2674 		aStr += "    Automation\n";
2675 
2676 	if ( GetIsCollection() != pAttr->GetIsCollection() )
2677 		aStr += "    IsCollection\n";
2678 
2679 	if ( GetReadOnlyDoc() != pAttr->GetReadOnlyDoc() )
2680 		aStr += "    ReadOnlyDoc\n";
2681 
2682 	if ( GetExport() && GetReadonly() != pAttr->GetReadonly() )
2683 		aStr += "    Readonly\n";
2684 
2685 	return aStr;
2686 }
2687 
WriteCSV(SvIdlDataBase &,SvStream & rStrm)2688 void SvMetaAttribute::WriteCSV( SvIdlDataBase&, SvStream& rStrm )
2689 {
2690     rStrm << GetType()->GetSvName().GetBuffer() << ' ';
2691     rStrm << GetName().GetBuffer() << ' ';
2692     rStrm << GetSlotId().GetBuffer();
2693 }
2694 
2695 
2696