merged tag ooo/DEV300_m102
[LibreOffice.git] / idl / source / objects / object.cxx
blobe9bddda61f9a96b3ec68f1bf642334ebd8a9d0da
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_idl.hxx"
31 #include <ctype.h>
32 #include <stdio.h>
34 #include <tools/debug.hxx>
36 #include <attrib.hxx>
37 #include <object.hxx>
38 #include <globals.hxx>
39 #include <database.hxx>
41 /******************** class SvClassElement *******************************/
42 SV_IMPL_PERSIST1( SvClassElement, SvPersistBase );
44 /*************************************************************************
45 |* SvClassElement::SvClassElement()
47 |* Beschreibung
48 *************************************************************************/
49 SvClassElement::SvClassElement()
53 /*************************************************************************
54 |* SvClassElement::Load()
56 |* Beschreibung
57 *************************************************************************/
58 void SvClassElement::Load( SvPersistStream & rStm )
60 sal_uInt8 nMask;
61 rStm >> nMask;
62 if( nMask >= 0x08 )
64 rStm.SetError( SVSTREAM_FILEFORMAT_ERROR );
65 DBG_ERROR( "wrong format" );
66 return;
68 if( nMask & 0x01 ) rStm >> aAutomation;
69 if( nMask & 0x02 ) rStm.ReadByteString( aPrefix );
70 if( nMask & 0x04 )
72 SvMetaClass * p;
73 rStm >> p;
74 xClass = p;
78 /*************************************************************************
79 |* SvClassElement::Save()
81 |* Beschreibung
82 *************************************************************************/
83 void SvClassElement::Save( SvPersistStream & rStm )
85 // Maske erstellen
86 sal_uInt8 nMask = 0;
87 if( aAutomation.IsSet() ) nMask |= 0x1;
88 if( aPrefix.Len() ) nMask |= 0x2;
89 if( xClass.Is() ) nMask |= 0x4;
91 // Daten schreiben
92 rStm << nMask;
93 if( nMask & 0x01 ) rStm << aAutomation;
94 if( nMask & 0x02 ) rStm.WriteByteString( aPrefix );
95 if( nMask & 0x04 ) rStm << xClass;
98 /****************** SvMetaClass ******************************************/
99 SV_IMPL_META_FACTORY1( SvMetaClass, SvMetaType );
100 /*************************************************************************
101 |* SvMetaClass::SvMetaClass()
103 |* Beschreibung
104 *************************************************************************/
105 SvMetaClass::SvMetaClass()
106 : aAutomation( sal_True, sal_False )
110 /*************************************************************************
111 |* SvMetaClass::Load()
113 |* Beschreibung
114 *************************************************************************/
115 void SvMetaClass::Load( SvPersistStream & rStm )
117 SvMetaType::Load( rStm );
119 sal_uInt8 nMask;
120 rStm >> nMask;
121 if( nMask >= 0x20 )
123 rStm.SetError( SVSTREAM_FILEFORMAT_ERROR );
124 DBG_ERROR( "wrong format" );
125 return;
127 if( nMask & 0x01 ) rStm >> aAttrList;
128 if( nMask & 0x02 )
130 SvMetaClass * pSuper;
131 rStm >> pSuper;
132 aSuperClass = pSuper;
134 if( nMask & 0x04 ) rStm >> aClassList;
135 if( nMask & 0x8 )
137 SvMetaClass * p;
138 rStm >> p;
139 xAutomationInterface = p;
141 if( nMask & 0x10 ) rStm >> aAutomation;
144 /*************************************************************************
145 |* SvMetaClass::Save()
147 |* Beschreibung
148 *************************************************************************/
149 void SvMetaClass::Save( SvPersistStream & rStm )
151 SvMetaType::Save( rStm );
153 // Maske erstellen
154 sal_uInt8 nMask = 0;
155 if( aAttrList.Count() ) nMask |= 0x1;
156 if( aSuperClass.Is() ) nMask |= 0x2;
157 if( aClassList.Count() ) nMask |= 0x4;
158 if( xAutomationInterface.Is() ) nMask |= 0x8;
159 if( aAutomation.IsSet() ) nMask |= 0x10;
161 // Daten schreiben
162 rStm << nMask;
163 if( nMask & 0x01 ) rStm << aAttrList;
164 if( nMask & 0x02 ) rStm << aSuperClass;
165 if( nMask & 0x04 ) rStm << aClassList;
166 if( nMask & 0x08 ) rStm << xAutomationInterface;
167 if( nMask & 0x10 ) rStm << aAutomation;
170 /*************************************************************************
171 |* SvMetaClass::FillSbxObject()
173 |* Beschreibung
174 *************************************************************************/
176 void SvMetaClass::FillSbxMemberObject( SvIdlDataBase & rBase,
177 SbxObject * pObj,
178 StringList & rSuperList,
179 sal_Bool bVariable )
181 // alle Attribute der Klasse schreiben
182 sal_uLong n ;
183 for( n = 0; n < aAttrList.Count(); n++ )
185 SvMetaAttribute * pAttr = aAttrList.GetObject( n );
187 ByteString aMangleName = pAttr->GetMangleName( bVariable );
188 ByteString * pS = SvIdlDataBase::FindName( aMangleName, rSuperList );
190 if( !pS && pAttr->GetExport() )
192 // nicht doppelt
193 if( bVariable && pAttr->IsVariable() )
195 rSuperList.Insert( new ByteString( aMangleName ), LIST_APPEND );
196 pAttr->FillSbxObject( rBase, pObj, bVariable );
198 else if( !bVariable && pAttr->IsMethod() )
200 rSuperList.Insert( new ByteString( aMangleName ), LIST_APPEND );
201 pAttr->FillSbxObject( rBase, pObj, bVariable );
205 // alle Attribute der importierten Klassen schreiben
206 for( n = 0; n < aClassList.Count(); n++ )
208 SvClassElement * pEle = aClassList.GetObject( n );
209 SvMetaClass * pClass = pEle->GetClass();
210 pClass->FillSbxMemberObject( rBase, pObj, rSuperList, bVariable );
212 // alle Attribute der Superklassen schreiben
213 if( aSuperClass.Is() )
214 aSuperClass->FillSbxMemberObject( rBase, pObj, rSuperList, bVariable );
217 /*************************************************************************
218 |* SvMetaClass::FillSbxObject()
220 |* Beschreibung
221 *************************************************************************/
223 void SvMetaClass::FillSbxObject( SvIdlDataBase & rBase, SbxObject * pObj )
225 StringList aSuperList;
226 FillSbxMemberObject( rBase, pObj, aSuperList, sal_True );
227 FillSbxMemberObject( rBase, pObj, aSuperList, sal_False );
229 ByteString * pStr = aSuperList.First();
230 while( pStr )
232 delete pStr;
233 pStr = aSuperList.Next();
237 #ifdef IDL_COMPILER
238 /*************************************************************************
239 |* SvMetaClass::ReadAttributesSvIdl()
241 |* Beschreibung
242 *************************************************************************/
243 void SvMetaClass::ReadAttributesSvIdl( SvIdlDataBase & rBase,
244 SvTokenStream & rInStm )
246 SvMetaType::ReadAttributesSvIdl( rBase, rInStm );
247 aAutomation.ReadSvIdl( SvHash_Automation(), rInStm );
250 /*************************************************************************
251 |* SvMetaClass::WriteAttributesSvIdl()
253 |* Beschreibung
254 *************************************************************************/
255 void SvMetaClass::WriteAttributesSvIdl( SvIdlDataBase & rBase,
256 SvStream & rOutStm, sal_uInt16 nTab )
258 SvMetaType::WriteAttributesSvIdl( rBase, rOutStm, nTab );
260 if( !aAutomation )
262 WriteTab( rOutStm, nTab );
263 rOutStm << "//class SvMetaClass" << endl;
264 if( !aAutomation )
266 WriteTab( rOutStm, nTab );
267 aAutomation.WriteSvIdl( SvHash_Automation(), rOutStm );
268 rOutStm << ';' << endl;
273 /*************************************************************************
274 |* SvMetaClass::ReadContextSvIdl()
276 |* Beschreibung
277 *************************************************************************/
278 void SvMetaClass::ReadContextSvIdl( SvIdlDataBase & rBase,
279 SvTokenStream & rInStm )
281 sal_uInt32 nTokPos = rInStm.Tell();
282 SvToken * pTok = rInStm.GetToken_Next();
284 if( pTok->Is( SvHash_import() ) )
286 SvMetaClass * pClass = rBase.ReadKnownClass( rInStm );
287 if( pClass )
289 SvClassElementRef xEle = new SvClassElement();
290 xEle->SetClass( pClass );
291 aClassList.Append( xEle );
293 if( rInStm.Read( '[' ) )
295 pTok = rInStm.GetToken_Next();
296 if( pTok->Is( SvHash_Automation() ) )
298 if( rInStm.Read( ']' ) )
300 if( xAutomationInterface.Is() )
302 // Fehler setzen
303 rBase.SetError( "Automation allready set",
304 rInStm.GetToken() );
305 rBase.WriteError( rInStm );
307 xAutomationInterface = pClass;
308 xEle->SetAutomation( sal_True );
310 else
312 // Fehler setzen
313 rBase.SetError( "missing ]", rInStm.GetToken() );
314 rBase.WriteError( rInStm );
317 else
319 // Fehler setzen
320 rBase.SetError( "only attribute Automation allowed",
321 rInStm.GetToken() );
322 rBase.WriteError( rInStm );
325 pTok = rInStm.GetToken();
326 if( pTok->IsString() )
328 xEle->SetPrefix( pTok->GetString() );
329 rInStm.GetToken_Next();
331 return;
333 else
335 // Fehler setzen
336 rBase.SetError( "unknown imported interface", rInStm.GetToken() );
337 rBase.WriteError( rInStm );
340 else
342 rInStm.Seek( nTokPos );
343 SvMetaType * pType = rBase.ReadKnownType( rInStm );
345 sal_Bool bOk = sal_False;
346 SvMetaAttributeRef xAttr;
347 if( !pType || pType->IsItem() )
349 xAttr = new SvMetaSlot( pType );
350 if( xAttr->ReadSvIdl( rBase, rInStm ) )
351 bOk = xAttr->Test( rBase, rInStm );
353 else
355 xAttr = new SvMetaAttribute( pType );
356 if( xAttr->ReadSvIdl( rBase, rInStm ) )
357 bOk = xAttr->Test( rBase, rInStm );
360 if( bOk )
361 bOk = TestAttribute( rBase, rInStm, *xAttr );
362 if( bOk )
364 if( !xAttr->GetSlotId().IsSet() )
366 SvNumberIdentifier aI;
367 aI.SetValue( rBase.GetUniqueId() );
368 xAttr->SetSlotId( aI );
370 aAttrList.Append( xAttr );
371 return;
374 rInStm.Seek( nTokPos );
377 /*************************************************************************
378 |* SvMetaClass::WriteContextSvIdl()
380 |* Beschreibung
381 *************************************************************************/
382 void SvMetaClass::WriteContextSvIdl
384 SvIdlDataBase & rBase,
385 SvStream & rOutStm,
386 sal_uInt16 nTab
389 //SvMetaType::WriteContextSvIdl( rBase, rOutStm, nTab );
390 sal_uLong n;
391 for( n = 0; n < aAttrList.Count(); n++ )
393 WriteTab( rOutStm, nTab );
394 aAttrList.GetObject( n )->WriteSvIdl( rBase, rOutStm, nTab );
395 rOutStm << ';' << endl;
397 for( n = 0; n < aClassList.Count(); n++ )
399 SvClassElement * pEle = aClassList.GetObject( n );
400 WriteTab( rOutStm, nTab );
401 rOutStm << SvHash_import()->GetName().GetBuffer() << ' '
402 << pEle->GetPrefix().GetBuffer();
403 if( pEle->GetAutomation() )
404 rOutStm << " [ " << SvHash_Automation()->GetName().GetBuffer()
405 << " ]";
406 if( pEle->GetPrefix().Len() )
407 rOutStm << ' ' << pEle->GetPrefix().GetBuffer();
408 rOutStm << ';' << endl;
412 /*************************************************************************
413 |* SvMetaClass::ReadSvIdl()
415 |* Beschreibung
416 *************************************************************************/
417 sal_Bool SvMetaClass::ReadSvIdl( SvIdlDataBase & rBase, SvTokenStream & rInStm )
419 sal_uLong nTokPos = rInStm.Tell();
420 if( SvMetaType::ReadHeaderSvIdl( rBase, rInStm ) && GetType() == TYPE_CLASS )
422 sal_Bool bOk = sal_True;
423 if( rInStm.Read( ':' ) )
425 aSuperClass = rBase.ReadKnownClass( rInStm );
426 bOk = aSuperClass.Is();
427 if( !bOk )
429 // Fehler setzen
430 rBase.SetError( "unknown super class",
431 rInStm.GetToken() );
432 rBase.WriteError( rInStm );
435 if( bOk )
437 rBase.Write( '.' );
438 bOk = SvMetaName::ReadSvIdl( rBase, rInStm );
440 if( bOk )
441 return bOk;
443 rInStm.Seek( nTokPos );
444 return sal_False;
447 /*************************************************************************
448 |* SvMetaClass::TestAttribute()
450 |* Beschreibung
451 *************************************************************************/
452 sal_Bool SvMetaClass::TestAttribute( SvIdlDataBase & rBase, SvTokenStream & rInStm,
453 SvMetaAttribute & rAttr ) const
455 if ( !rAttr.GetRef() && rAttr.IsA( TYPE( SvMetaSlot ) ) )
457 DBG_ERROR( "Neuer Slot : " );
458 DBG_ERROR( rAttr.GetSlotId().GetBuffer() );
461 for( sal_uLong n = 0; n < aAttrList.Count(); n++ )
463 SvMetaAttribute * pS = aAttrList.GetObject( n );
464 if( pS->GetName() == rAttr.GetName() )
466 // Werte muessen uebereinstimmen
467 if( pS->GetSlotId().GetValue() != rAttr.GetSlotId().GetValue() )
469 DBG_ERROR( "Gleicher Name in MetaClass : " );
470 DBG_ERROR( pS->GetName().GetBuffer() );
471 DBG_ERROR( pS->GetSlotId().GetBuffer() );
472 DBG_ERROR( rAttr.GetSlotId().GetBuffer() );
474 ByteString aStr( "Attribute's " );
475 aStr += pS->GetName();
476 aStr += " with different id's";
477 rBase.SetError( aStr, rInStm.GetToken() );
478 rBase.WriteError( rInStm );
479 return sal_False;
482 else
484 sal_uInt32 nId1 = pS->GetSlotId().GetValue();
485 sal_uInt32 nId2 = rAttr.GetSlotId().GetValue();
486 if( nId1 == nId2 && nId1 != 0 /*&& nId2 != 0 ist ueberfluessig*/ )
488 DBG_ERROR( "Gleiche Id in MetaClass : " );
489 DBG_ERROR( ByteString::CreateFromInt32( pS->GetSlotId().GetValue() ).GetBuffer() );
490 DBG_ERROR( pS->GetSlotId().GetBuffer() );
491 DBG_ERROR( rAttr.GetSlotId().GetBuffer() );
493 ByteString aStr( "Attribute " );
494 aStr += pS->GetName();
495 aStr += " and Attribute ";
496 aStr += rAttr.GetName();
497 aStr += " with equal id's";
498 rBase.SetError( aStr, rInStm.GetToken() );
499 rBase.WriteError( rInStm );
500 return sal_False;
504 SvMetaClass * pSC = aSuperClass;
505 if( pSC )
506 return pSC->TestAttribute( rBase, rInStm, rAttr );
507 return sal_True;
510 /*************************************************************************
511 |* SvMetaClass::WriteSvIdl()
513 |* Beschreibung
514 *************************************************************************/
515 void SvMetaClass::WriteSvIdl( SvIdlDataBase & rBase, SvStream & rOutStm,
516 sal_uInt16 nTab )
518 WriteHeaderSvIdl( rBase, rOutStm, nTab );
519 if( aSuperClass.Is() )
520 rOutStm << " : " << aSuperClass->GetName().GetBuffer();
521 rOutStm << endl;
522 SvMetaName::WriteSvIdl( rBase, rOutStm, nTab );
523 rOutStm << endl;
526 /*************************************************************************
527 |* SvMetaClass::WriteOdlMember()
529 |* Beschreibung
530 *************************************************************************/
532 void SvMetaClass::WriteOdlMembers( ByteStringList & rSuperList,
533 sal_Bool bVariable, sal_Bool bWriteTab,
534 SvIdlDataBase & rBase,
535 SvStream & rOutStm, sal_uInt16 nTab )
537 // alle Attribute schreiben
538 sal_uLong n;
539 for( n = 0; n < aAttrList.Count(); n++ )
541 SvMetaAttribute * pAttr = aAttrList.GetObject( n );
543 ByteString aMangleName = pAttr->GetMangleName( bVariable );
544 ByteString * pS = rBase.FindName( aMangleName, rSuperList );
546 if( !pS && pAttr->GetExport() )
548 // nicht doppelt
549 if( bVariable && pAttr->IsVariable() )
551 rSuperList.Insert( new ByteString( aMangleName ), LIST_APPEND );
552 pAttr->Write( rBase, rOutStm, nTab +1, WRITE_ODL,
553 WA_VARIABLE );
554 rOutStm << ';' << endl;
556 else if( !bVariable && pAttr->IsMethod() )
558 rSuperList.Insert( new ByteString( aMangleName ), LIST_APPEND );
559 pAttr->Write( rBase, rOutStm, nTab +1, WRITE_ODL,
560 WA_METHOD );
561 rOutStm << ';' << endl;
564 else
565 continue;
567 // alle Attribute der importierten Klassen schreiben
568 for( n = 0; n < aClassList.Count(); n++ )
570 SvClassElement * pEle = aClassList.GetObject( n );
571 SvMetaClass * pCl = pEle->GetClass();
572 pCl->WriteOdlMembers( rSuperList, bVariable, bWriteTab,
573 rBase, rOutStm, nTab );
575 // alle Attribute der Superklassen schreiben
576 SvMetaClass * pSC = aSuperClass;
577 if( pSC )
578 pSC->WriteOdlMembers( rSuperList, bVariable, bWriteTab,
579 rBase, rOutStm, nTab );
583 /*************************************************************************
584 |* SvMetaClass::Write()
586 |* Beschreibung
587 *************************************************************************/
588 void SvMetaClass::Write( SvIdlDataBase & rBase, SvStream & rOutStm,
589 sal_uInt16 nTab,
590 WriteType nT, WriteAttribute )
592 rBase.aIFaceName = GetName();
593 switch( nT )
595 case WRITE_ODL:
597 DBG_ERROR( "Not supported anymore!" );
599 // Schreibt die Attribute
600 SvMetaName::Write( rBase, rOutStm, nTab, nT, nA );
602 WriteTab( rOutStm, nTab );
603 rOutStm << "dispinterface " << GetName().GetBuffer() << endl;
604 WriteTab( rOutStm, nTab );
605 rOutStm << '{' << endl;
607 WriteTab( rOutStm, nTab );
608 rOutStm << "properties:";
609 rOutStm << endl;
611 StringList aSuperList;
612 WriteOdlMembers( aSuperList, sal_True, sal_True, rBase, rOutStm, nTab );
614 WriteTab( rOutStm, nTab );
615 rOutStm << "methods:";
616 rOutStm << endl;
618 WriteOdlMembers( aSuperList, sal_False, sal_True, rBase, rOutStm, nTab );
620 ByteString * pStr = aSuperList.First();
621 while( pStr )
623 delete pStr;
624 pStr = aSuperList.Next();
627 WriteTab( rOutStm, 1 );
628 rOutStm << '}' << endl;
630 break;
632 case WRITE_C_SOURCE:
633 case WRITE_C_HEADER:
635 DBG_ERROR( "Not supported anymore!" );
637 StringList aSuperList;
638 if( nT == WRITE_C_SOURCE )
640 rOutStm << "#pragma code_seg (\"" << GetName().GetBuffer()
641 << "\",\"CODE\")" << endl;
643 WriteCFunctions( aSuperList, rBase, rOutStm, nTab, nT );
645 break;
647 case WRITE_DOCU:
649 rOutStm << "<INTERFACE>" << endl
650 << GetName().GetBuffer();
651 if ( GetAutomation() )
652 rOutStm << " ( Automation ) ";
653 rOutStm << endl;
654 WriteDescription( rOutStm );
655 rOutStm << "</INTERFACE>" << endl << endl;
657 // alle Attribute schreiben
658 sal_uLong n;
659 for( n = 0; n < aAttrList.Count(); n++ )
661 SvMetaAttribute * pAttr = aAttrList.GetObject( n );
662 if( !pAttr->GetHidden() )
664 if( pAttr->IsMethod() )
665 pAttr->Write( rBase, rOutStm, nTab, nT, WA_METHOD );
667 if( pAttr->IsVariable() )
668 pAttr->Write( rBase, rOutStm, nTab, nT, WA_VARIABLE );
672 break;
674 default:
675 break;
679 /*************************************************************************
680 |* SvMetaClass::WriteSlotParamArray()
682 |* Beschreibung
683 *************************************************************************/
684 sal_uInt16 SvMetaClass::WriteSlotParamArray( SvIdlDataBase & rBase,
685 SvSlotElementList & rSlotList,
686 SvStream & rOutStm )
688 sal_uInt16 nCount = 0;
689 for( sal_uLong n = 0; n < rSlotList.Count(); n++ )
691 SvSlotElement *pEle = rSlotList.GetObject( n );
692 SvMetaSlot *pAttr = pEle->xSlot;
693 nCount = nCount + pAttr->WriteSlotParamArray( rBase, rOutStm );
696 return nCount;
699 /*************************************************************************
700 |* SvMetaClass::WriteSlots()
702 |* Beschreibung
703 *************************************************************************/
704 sal_uInt16 SvMetaClass::WriteSlots( const ByteString & rShellName,
705 sal_uInt16 nCount, SvSlotElementList & rSlotList,
706 SvIdlDataBase & rBase,
707 SvStream & rOutStm )
709 sal_uInt16 nSCount = 0;
710 for( sal_uLong n = 0; n < rSlotList.Count(); n++ )
712 rSlotList.Seek(n);
713 SvSlotElement * pEle = rSlotList.GetCurObject();
714 SvMetaSlot * pAttr = pEle->xSlot;
715 nSCount = nSCount + pAttr->WriteSlotMap( rShellName, nCount + nSCount,
716 rSlotList, pEle->aPrefix, rBase,
717 rOutStm );
720 return nSCount;
723 /*************************************************************************
724 |* SvMetaClass::InsertSlots()
726 |* Beschreibung
727 *************************************************************************/
728 void SvMetaClass::InsertSlots( SvSlotElementList& rList, SvULongs& rSuperList,
729 SvMetaClassList &rClassList,
730 const ByteString & rPrefix, SvIdlDataBase& rBase)
732 // Wurde diese Klasse schon geschrieben ?
733 if ( rClassList.GetPos(this) != LIST_ENTRY_NOTFOUND )
734 return;
736 rClassList.Insert(this, LIST_APPEND);
738 // alle direkten Attribute schreiben
739 sal_uLong n;
740 for( n = 0; n < aAttrList.Count(); n++ )
742 SvMetaAttribute * pAttr = aAttrList.GetObject( n );
744 sal_uLong nId = pAttr->GetSlotId().GetValue();
745 sal_uInt16 nPos;
746 for ( nPos=0; nPos < rSuperList.Count(); nPos++ )
748 if ( rSuperList.GetObject(nPos) == nId )
749 break;
752 if( nPos == rSuperList.Count() )
754 // nur schreiben, wenn nicht schon bei SubClass oder
755 // importiertem Interface geschrieben
756 rSuperList.Insert( nId, nPos );
757 pAttr->Insert(rList, rPrefix, rBase);
761 // Alle schon von SuperShells importierten Interfaces sollen nicht
762 // mehr geschrieben werden
763 // Es ist also verboten, da\s Shell und SuperShell die gleiche Klasse
764 // direkt importieren !
765 if( IsShell() && aSuperClass.Is() )
766 aSuperClass->FillClasses( rClassList );
768 // alle Attribute der importierten Klassen schreiben, sofern diese nicht
769 // schon von der Superklasse importiert wurden
770 for( n = 0; n < aClassList.Count(); n++ )
772 SvClassElement * pEle = aClassList.GetObject( n );
773 SvMetaClass * pCl = pEle->GetClass();
774 ByteString rPre = rPrefix;
775 if( rPre.Len() && pEle->GetPrefix().Len() )
776 rPre += '.';
777 rPre += pEle->GetPrefix();
779 // Zun"achst die direkt importierten Interfaces schreiben
780 pCl->InsertSlots( rList, rSuperList, rClassList, rPre, rBase );
783 // Superklassen nur schreiben, wenn keine Shell und nicht in der Liste
784 if( !IsShell() && aSuperClass.Is() )
786 aSuperClass->InsertSlots( rList, rSuperList, rClassList, rPrefix, rBase );
790 /*************************************************************************
791 |* SvMetaClass::FillClasses()
793 |* Beschreibung
794 *************************************************************************/
795 void SvMetaClass::FillClasses( SvMetaClassList & rList )
797 // Bin ich noch nicht drin ?
798 if ( rList.GetPos(this) == LIST_ENTRY_NOTFOUND )
800 rList.Insert(this, LIST_APPEND);
802 // Meine Imports
803 for( sal_uLong n = 0; n < aClassList.Count(); n++ )
805 SvClassElement * pEle = aClassList.GetObject( n );
806 SvMetaClass * pCl = pEle->GetClass();
807 pCl->FillClasses( rList );
810 // Meine Superklasse
811 if( aSuperClass.Is() )
812 aSuperClass->FillClasses( rList );
817 /*************************************************************************
818 |* SvMetaClass::WriteSlotStubs()
820 |* Beschreibung
821 *************************************************************************/
822 void SvMetaClass::WriteSlotStubs( const ByteString & rShellName,
823 SvSlotElementList & rSlotList,
824 ByteStringList & rList,
825 SvStream & rOutStm )
827 // alle Attribute schreiben
828 for( sal_uLong n = 0; n < rSlotList.Count(); n++ )
830 SvSlotElement *pEle = rSlotList.GetObject( n );
831 SvMetaSlot *pAttr = pEle->xSlot;
832 pAttr->WriteSlotStubs( rShellName, rList, rOutStm );
836 /*************************************************************************
837 |* SvMetaClass::WriteSfx()
839 |* Beschreibung
840 *************************************************************************/
841 void SvMetaClass::WriteSfx( SvIdlDataBase & rBase, SvStream & rOutStm )
843 WriteStars( rOutStm );
844 // Klasse definieren
845 rOutStm << "#ifdef " << GetName().GetBuffer() << endl;
846 rOutStm << "#undef ShellClass" << endl;
847 rOutStm << "#undef " << GetName().GetBuffer() << endl;
848 rOutStm << "#define ShellClass " << GetName().GetBuffer() << endl;
850 // rOutStm << "SFX_TYPELIB(" << GetName().GetBuffer() << ',' << endl
851 // << "\t/* library type */"
852 // << '"' << ByteString( GetModule()->GetUUId().GetHexName(), RTL_TEXTENCODING_UTF8 ).GetBuffer() << "\"," << endl
853 // << "\t\"" << GetModule()->GetTypeLibFileName().GetBuffer() << "\","
854 // << ByteString::CreateFromInt32( GetModule()->GetVersion().GetMajorVersion() ).GetBuffer() << ','
855 // << ByteString::CreateFromInt32( GetModule()->GetVersion().GetMinorVersion() ).GetBuffer() << ',' << endl
856 // << "\t/* shell type */"
857 // << '"';
858 // if( xAutomationInterface.Is() )
859 // rOutStm << ByteString( xAutomationInterface->GetUUId().GetHexName(), RTL_TEXTENCODING_UTF8 ).GetBuffer();
860 // else
861 // rOutStm << ByteString( GetUUId().GetHexName(), RTL_TEXTENCODING_UTF8 ).GetBuffer();
862 // rOutStm << "\");" << endl << endl;
864 // Fuer Interfaces werden kein Slotmaps geschrieben
865 if( !IsShell() )
867 rOutStm << "#endif" << endl << endl;
868 return;
870 // Parameter Array schreiben
871 //rOutStm << "SfxArgList " << GetName().GetBuffer() << "ArgMap[] = {" << endl;
872 rOutStm << "SFX_ARGUMENTMAP(" << GetName().GetBuffer() << ')' << endl
873 << '{' << endl;
875 SvULongs aSuperList;
876 SvMetaClassList classList;
877 SvSlotElementList aSlotList;
878 InsertSlots(aSlotList, aSuperList, classList, ByteString(), rBase);
879 sal_uLong n;
880 for ( n=0; n<aSlotList.Count(); n++ )
882 SvSlotElement *pEle = aSlotList.GetObject( n );
883 SvMetaSlot *pSlot = pEle->xSlot;
884 pSlot->SetListPos(n);
887 sal_uLong nSlotCount = aSlotList.Count();
889 // alle Attribute schreiben
890 sal_uInt16 nArgCount = WriteSlotParamArray( rBase, aSlotList, rOutStm );
891 if( nArgCount )
892 Back2Delemitter( rOutStm );
893 else
895 // mindestens einen dummy
896 WriteTab( rOutStm, 1 );
897 rOutStm << "SFX_ARGUMENT( 0, 0, SfxVoidItem )" << endl;
899 rOutStm << endl << "};" << endl << endl;
901 ByteStringList aStringList;
902 WriteSlotStubs( GetName(), aSlotList, aStringList, rOutStm );
903 ByteString * pStr = aStringList.First();
904 while( pStr )
906 delete pStr;
907 pStr = aStringList.Next();
910 rOutStm << endl;
912 // Slotmap schreiben
913 rOutStm << "SFX_SLOTMAP_ARG(" << GetName().GetBuffer() << ')' << endl
914 << '{' << endl;
916 // alle Attribute schreiben
917 WriteSlots( GetName(), 0, aSlotList, rBase, rOutStm );
918 if( nSlotCount )
919 Back2Delemitter( rOutStm );
920 else
922 // mindestens einen dummy
923 WriteTab( rOutStm, 1 );
924 rOutStm << "SFX_SLOT_ARG(" << GetName().GetBuffer()
925 << ", 0, 0, "
926 << "SFX_STUB_PTR_EXEC_NONE,"
927 << "SFX_STUB_PTR_STATE_NONE,"
928 << "0, SfxVoidItem, 0, 0, \"\", 0 )" << endl;
930 rOutStm << endl << "};" << endl << "#endif" << endl << endl;
932 for( n=0; n<aSlotList.Count(); n++ )
934 aSlotList.Seek(n);
935 SvSlotElement* pEle = aSlotList.GetCurObject();
936 SvMetaSlot* pAttr = pEle->xSlot;
937 pAttr->ResetSlotPointer();
940 for ( n=0; n<aSlotList.Count(); n++ )
941 delete aSlotList.GetObject(n);
944 void SvMetaClass::WriteHelpIds( SvIdlDataBase & rBase, SvStream & rOutStm,
945 Table* pTable )
947 for( sal_uLong n=0; n<aAttrList.Count(); n++ )
949 SvMetaAttribute * pAttr = aAttrList.GetObject( n );
950 pAttr->WriteHelpId( rBase, rOutStm, pTable );
954 /*************************************************************************
955 |* SvMetaShell::WriteSrc()
956 *************************************************************************/
957 void SvMetaClass::WriteSrc( SvIdlDataBase & rBase, SvStream & rOutStm,
958 Table * pTable )
960 for( sal_uLong n=0; n<aAttrList.Count(); n++ )
962 SvMetaAttribute * pAttr = aAttrList.GetObject( n );
963 pAttr->WriteSrc( rBase, rOutStm, pTable );
967 /*************************************************************************
968 |* SvMetaClass::WriteHxx()
970 |* Beschreibung
971 *************************************************************************/
972 void SvMetaClass::WriteHxx( SvIdlDataBase &, SvStream & rOutStm, sal_uInt16 )
974 ByteString aSuperName( "SvDispatch" );
975 if( GetSuperClass() )
976 aSuperName = GetSuperClass()->GetName();
977 const char * pSup = aSuperName.GetBuffer();
979 rOutStm
980 << "class " << GetSvName().GetBuffer()
981 << ": public " << pSup << endl
982 << '{' << endl
983 << "protected:" << endl
984 << "\tvirtual SvGlobalName GetTypeName() const;" << endl
985 << "\tvirtual sal_Bool FillTypeLibInfo( SvGlobalName *, sal_uInt16 * pMajor," << endl
986 << "\t sal_uInt16 * pMinor ) const;" << endl
987 << "\tvirtual sal_Bool FillTypeLibInfo( ByteString * pName, sal_uInt16 * pMajor," << endl;
988 rOutStm
989 << "\t sal_uInt16 * pMinor ) const;" << endl
990 << "\tvirtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) = 0;" << endl
991 << "public:" << endl
992 << "\t static SvGlobalName ClassName()" << endl
993 << "\t { return SvGlobalName( " << ByteString( GetUUId().GetctorName(), RTL_TEXTENCODING_UTF8 ).GetBuffer() << " ); }" << endl
994 << "};" << endl;
997 /*************************************************************************
998 |* SvMetaClass::WriteCxx()
1000 |* Beschreibung
1001 *************************************************************************/
1002 void SvMetaClass::WriteCxx( SvIdlDataBase &, SvStream & rOutStm, sal_uInt16 )
1004 ByteString aSuperName( "SvDispatch" );
1005 if( GetSuperClass() )
1006 aSuperName = GetSuperClass()->GetName();
1007 const char * pSup = aSuperName.GetBuffer();
1009 ByteString name = GetSvName();
1010 // GetTypeName
1011 rOutStm << "SvGlobalName " << name.GetBuffer() << "::GetTypeName() const" << endl
1012 << '{' << endl
1013 << "\treturn ClassName();" << endl
1014 << '}' << endl;
1016 SvMetaModule * pMod = GetModule();
1017 // FillTypeLibInfo
1018 rOutStm << "sal_Bool " << name.GetBuffer() << "::FillTypeLibInfo( SvGlobalName * pGN," << endl
1019 << "\t sal_uInt16 * pMajor," << endl
1020 << "\t sal_uInt16 * pMinor ) const" << endl
1021 << '{' << endl
1022 << "\tSvGlobalName aN( " << ByteString( pMod->GetUUId().GetctorName(), RTL_TEXTENCODING_UTF8 ).GetBuffer() << " );" << endl;
1023 rOutStm << "\t*pGN = aN;" << endl
1024 << "\t*pMajor = " << ByteString::CreateFromInt32(pMod->GetVersion().GetMajorVersion()).GetBuffer() << ';' << endl
1025 << "\t*pMinor = " << ByteString::CreateFromInt32(pMod->GetVersion().GetMinorVersion()).GetBuffer() << ';' << endl
1026 << "\treturn sal_True;" << endl
1027 << '}' << endl;
1029 // FillTypeLibInfo
1030 rOutStm << "sal_Bool " << name.GetBuffer() << "::FillTypeLibInfo( ByteString * pName,"
1031 << "\t sal_uInt16 * pMajor," << endl
1032 << "\t sal_uInt16 * pMinor ) const" << endl;
1033 rOutStm << '{' << endl
1034 << "\t*pName = \"" << pMod->GetTypeLibFileName().GetBuffer() << "\";" << endl
1035 << "\t*pMajor = " << ByteString::CreateFromInt32(pMod->GetVersion().GetMajorVersion()).GetBuffer() << ';' << endl
1036 << "\t*pMinor = " << ByteString::CreateFromInt32(pMod->GetVersion().GetMinorVersion()).GetBuffer() << ';' << endl
1037 << "\treturn sal_True;" << endl
1038 << '}' << endl;
1040 rOutStm << "void " << name.GetBuffer() << "::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )" << endl
1041 << '{' << endl
1042 << "\t" << pSup << "::Notify( rBC, rHint );" << endl
1043 << '}' << endl;
1046 #endif // IDL_COMPILER