merge the formfield patch from ooo-build
[ooovba.git] / idl / source / objects / object.cxx
blob18a5a238946fe8bf637d925a32f413728b226553
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: object.cxx,v $
10 * $Revision: 1.6 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_idl.hxx"
34 #include <ctype.h>
35 #include <stdio.h>
37 #include <tools/debug.hxx>
39 #include <attrib.hxx>
40 #include <object.hxx>
41 #include <globals.hxx>
42 #include <database.hxx>
44 /******************** class SvClassElement *******************************/
45 SV_IMPL_PERSIST1( SvClassElement, SvPersistBase );
47 /*************************************************************************
48 |* SvClassElement::SvClassElement()
50 |* Beschreibung
51 *************************************************************************/
52 SvClassElement::SvClassElement()
56 /*************************************************************************
57 |* SvClassElement::Load()
59 |* Beschreibung
60 *************************************************************************/
61 void SvClassElement::Load( SvPersistStream & rStm )
63 BYTE nMask;
64 rStm >> nMask;
65 if( nMask >= 0x08 )
67 rStm.SetError( SVSTREAM_FILEFORMAT_ERROR );
68 DBG_ERROR( "wrong format" );
69 return;
71 if( nMask & 0x01 ) rStm >> aAutomation;
72 if( nMask & 0x02 ) rStm.ReadByteString( aPrefix );
73 if( nMask & 0x04 )
75 SvMetaClass * p;
76 rStm >> p;
77 xClass = p;
81 /*************************************************************************
82 |* SvClassElement::Save()
84 |* Beschreibung
85 *************************************************************************/
86 void SvClassElement::Save( SvPersistStream & rStm )
88 // Maske erstellen
89 BYTE nMask = 0;
90 if( aAutomation.IsSet() ) nMask |= 0x1;
91 if( aPrefix.Len() ) nMask |= 0x2;
92 if( xClass.Is() ) nMask |= 0x4;
94 // Daten schreiben
95 rStm << nMask;
96 if( nMask & 0x01 ) rStm << aAutomation;
97 if( nMask & 0x02 ) rStm.WriteByteString( aPrefix );
98 if( nMask & 0x04 ) rStm << xClass;
101 /****************** SvMetaClass ******************************************/
102 SV_IMPL_META_FACTORY1( SvMetaClass, SvMetaType );
103 /*************************************************************************
104 |* SvMetaClass::SvMetaClass()
106 |* Beschreibung
107 *************************************************************************/
108 SvMetaClass::SvMetaClass()
109 : aAutomation( TRUE, FALSE )
113 /*************************************************************************
114 |* SvMetaClass::Load()
116 |* Beschreibung
117 *************************************************************************/
118 void SvMetaClass::Load( SvPersistStream & rStm )
120 SvMetaType::Load( rStm );
122 BYTE nMask;
123 rStm >> nMask;
124 if( nMask >= 0x20 )
126 rStm.SetError( SVSTREAM_FILEFORMAT_ERROR );
127 DBG_ERROR( "wrong format" );
128 return;
130 if( nMask & 0x01 ) rStm >> aAttrList;
131 if( nMask & 0x02 )
133 SvMetaClass * pSuper;
134 rStm >> pSuper;
135 aSuperClass = pSuper;
137 if( nMask & 0x04 ) rStm >> aClassList;
138 if( nMask & 0x8 )
140 SvMetaClass * p;
141 rStm >> p;
142 xAutomationInterface = p;
144 if( nMask & 0x10 ) rStm >> aAutomation;
147 /*************************************************************************
148 |* SvMetaClass::Save()
150 |* Beschreibung
151 *************************************************************************/
152 void SvMetaClass::Save( SvPersistStream & rStm )
154 SvMetaType::Save( rStm );
156 // Maske erstellen
157 BYTE nMask = 0;
158 if( aAttrList.Count() ) nMask |= 0x1;
159 if( aSuperClass.Is() ) nMask |= 0x2;
160 if( aClassList.Count() ) nMask |= 0x4;
161 if( xAutomationInterface.Is() ) nMask |= 0x8;
162 if( aAutomation.IsSet() ) nMask |= 0x10;
164 // Daten schreiben
165 rStm << nMask;
166 if( nMask & 0x01 ) rStm << aAttrList;
167 if( nMask & 0x02 ) rStm << aSuperClass;
168 if( nMask & 0x04 ) rStm << aClassList;
169 if( nMask & 0x08 ) rStm << xAutomationInterface;
170 if( nMask & 0x10 ) rStm << aAutomation;
173 /*************************************************************************
174 |* SvMetaClass::FillSbxObject()
176 |* Beschreibung
177 *************************************************************************/
179 void SvMetaClass::FillSbxMemberObject( SvIdlDataBase & rBase,
180 SbxObject * pObj,
181 StringList & rSuperList,
182 BOOL bVariable )
184 // alle Attribute der Klasse schreiben
185 ULONG n ;
186 for( n = 0; n < aAttrList.Count(); n++ )
188 SvMetaAttribute * pAttr = aAttrList.GetObject( n );
190 ByteString aMangleName = pAttr->GetMangleName( bVariable );
191 ByteString * pS = SvIdlDataBase::FindName( aMangleName, rSuperList );
193 if( !pS && pAttr->GetExport() )
195 // nicht doppelt
196 if( bVariable && pAttr->IsVariable() )
198 rSuperList.Insert( new ByteString( aMangleName ), LIST_APPEND );
199 pAttr->FillSbxObject( rBase, pObj, bVariable );
201 else if( !bVariable && pAttr->IsMethod() )
203 rSuperList.Insert( new ByteString( aMangleName ), LIST_APPEND );
204 pAttr->FillSbxObject( rBase, pObj, bVariable );
208 // alle Attribute der importierten Klassen schreiben
209 for( n = 0; n < aClassList.Count(); n++ )
211 SvClassElement * pEle = aClassList.GetObject( n );
212 SvMetaClass * pClass = pEle->GetClass();
213 pClass->FillSbxMemberObject( rBase, pObj, rSuperList, bVariable );
215 // alle Attribute der Superklassen schreiben
216 if( aSuperClass.Is() )
217 aSuperClass->FillSbxMemberObject( rBase, pObj, rSuperList, bVariable );
220 /*************************************************************************
221 |* SvMetaClass::FillSbxObject()
223 |* Beschreibung
224 *************************************************************************/
226 void SvMetaClass::FillSbxObject( SvIdlDataBase & rBase, SbxObject * pObj )
228 StringList aSuperList;
229 FillSbxMemberObject( rBase, pObj, aSuperList, TRUE );
230 FillSbxMemberObject( rBase, pObj, aSuperList, FALSE );
232 ByteString * pStr = aSuperList.First();
233 while( pStr )
235 delete pStr;
236 pStr = aSuperList.Next();
240 #ifdef IDL_COMPILER
241 /*************************************************************************
242 |* SvMetaClass::ReadAttributesSvIdl()
244 |* Beschreibung
245 *************************************************************************/
246 void SvMetaClass::ReadAttributesSvIdl( SvIdlDataBase & rBase,
247 SvTokenStream & rInStm )
249 SvMetaType::ReadAttributesSvIdl( rBase, rInStm );
250 aAutomation.ReadSvIdl( SvHash_Automation(), rInStm );
253 /*************************************************************************
254 |* SvMetaClass::WriteAttributesSvIdl()
256 |* Beschreibung
257 *************************************************************************/
258 void SvMetaClass::WriteAttributesSvIdl( SvIdlDataBase & rBase,
259 SvStream & rOutStm, USHORT nTab )
261 SvMetaType::WriteAttributesSvIdl( rBase, rOutStm, nTab );
263 if( !aAutomation )
265 WriteTab( rOutStm, nTab );
266 rOutStm << "//class SvMetaClass" << endl;
267 if( !aAutomation )
269 WriteTab( rOutStm, nTab );
270 aAutomation.WriteSvIdl( SvHash_Automation(), rOutStm );
271 rOutStm << ';' << endl;
276 /*************************************************************************
277 |* SvMetaClass::ReadContextSvIdl()
279 |* Beschreibung
280 *************************************************************************/
281 void SvMetaClass::ReadContextSvIdl( SvIdlDataBase & rBase,
282 SvTokenStream & rInStm )
284 UINT32 nTokPos = rInStm.Tell();
285 SvToken * pTok = rInStm.GetToken_Next();
287 if( pTok->Is( SvHash_import() ) )
289 SvMetaClass * pClass = rBase.ReadKnownClass( rInStm );
290 if( pClass )
292 SvClassElementRef xEle = new SvClassElement();
293 xEle->SetClass( pClass );
294 aClassList.Append( xEle );
296 if( rInStm.Read( '[' ) )
298 pTok = rInStm.GetToken_Next();
299 if( pTok->Is( SvHash_Automation() ) )
301 if( rInStm.Read( ']' ) )
303 if( xAutomationInterface.Is() )
305 // Fehler setzen
306 rBase.SetError( "Automation allready set",
307 rInStm.GetToken() );
308 rBase.WriteError( rInStm );
310 xAutomationInterface = pClass;
311 xEle->SetAutomation( TRUE );
313 else
315 // Fehler setzen
316 rBase.SetError( "missing ]", rInStm.GetToken() );
317 rBase.WriteError( rInStm );
320 else
322 // Fehler setzen
323 rBase.SetError( "only attribute Automation allowed",
324 rInStm.GetToken() );
325 rBase.WriteError( rInStm );
328 pTok = rInStm.GetToken();
329 if( pTok->IsString() )
331 xEle->SetPrefix( pTok->GetString() );
332 rInStm.GetToken_Next();
334 return;
336 else
338 // Fehler setzen
339 rBase.SetError( "unknown imported interface", rInStm.GetToken() );
340 rBase.WriteError( rInStm );
343 else
345 rInStm.Seek( nTokPos );
346 SvMetaType * pType = rBase.ReadKnownType( rInStm );
348 BOOL bOk = FALSE;
349 SvMetaAttributeRef xAttr;
350 if( !pType || pType->IsItem() )
352 xAttr = new SvMetaSlot( pType );
353 if( xAttr->ReadSvIdl( rBase, rInStm ) )
354 bOk = xAttr->Test( rBase, rInStm );
356 else
358 xAttr = new SvMetaAttribute( pType );
359 if( xAttr->ReadSvIdl( rBase, rInStm ) )
360 bOk = xAttr->Test( rBase, rInStm );
363 if( bOk )
364 bOk = TestAttribute( rBase, rInStm, *xAttr );
365 if( bOk )
367 if( !xAttr->GetSlotId().IsSet() )
369 SvNumberIdentifier aI;
370 aI.SetValue( rBase.GetUniqueId() );
371 xAttr->SetSlotId( aI );
373 aAttrList.Append( xAttr );
374 return;
377 rInStm.Seek( nTokPos );
380 /*************************************************************************
381 |* SvMetaClass::WriteContextSvIdl()
383 |* Beschreibung
384 *************************************************************************/
385 void SvMetaClass::WriteContextSvIdl
387 SvIdlDataBase & rBase,
388 SvStream & rOutStm,
389 USHORT nTab
392 //SvMetaType::WriteContextSvIdl( rBase, rOutStm, nTab );
393 ULONG n;
394 for( n = 0; n < aAttrList.Count(); n++ )
396 WriteTab( rOutStm, nTab );
397 aAttrList.GetObject( n )->WriteSvIdl( rBase, rOutStm, nTab );
398 rOutStm << ';' << endl;
400 for( n = 0; n < aClassList.Count(); n++ )
402 SvClassElement * pEle = aClassList.GetObject( n );
403 WriteTab( rOutStm, nTab );
404 rOutStm << SvHash_import()->GetName().GetBuffer() << ' '
405 << pEle->GetPrefix().GetBuffer();
406 if( pEle->GetAutomation() )
407 rOutStm << " [ " << SvHash_Automation()->GetName().GetBuffer()
408 << " ]";
409 if( pEle->GetPrefix().Len() )
410 rOutStm << ' ' << pEle->GetPrefix().GetBuffer();
411 rOutStm << ';' << endl;
415 /*************************************************************************
416 |* SvMetaClass::ReadSvIdl()
418 |* Beschreibung
419 *************************************************************************/
420 BOOL SvMetaClass::ReadSvIdl( SvIdlDataBase & rBase, SvTokenStream & rInStm )
422 ULONG nTokPos = rInStm.Tell();
423 if( SvMetaType::ReadHeaderSvIdl( rBase, rInStm ) && GetType() == TYPE_CLASS )
425 BOOL bOk = TRUE;
426 if( rInStm.Read( ':' ) )
428 aSuperClass = rBase.ReadKnownClass( rInStm );
429 bOk = aSuperClass.Is();
430 if( !bOk )
432 // Fehler setzen
433 rBase.SetError( "unknown super class",
434 rInStm.GetToken() );
435 rBase.WriteError( rInStm );
438 if( bOk )
440 rBase.Write( '.' );
441 bOk = SvMetaName::ReadSvIdl( rBase, rInStm );
443 if( bOk )
444 return bOk;
446 rInStm.Seek( nTokPos );
447 return FALSE;
450 /*************************************************************************
451 |* SvMetaClass::TestAttribute()
453 |* Beschreibung
454 *************************************************************************/
455 BOOL SvMetaClass::TestAttribute( SvIdlDataBase & rBase, SvTokenStream & rInStm,
456 SvMetaAttribute & rAttr ) const
458 if ( !rAttr.GetRef() && rAttr.IsA( TYPE( SvMetaSlot ) ) )
460 DBG_ERROR( "Neuer Slot : " );
461 DBG_ERROR( rAttr.GetSlotId().GetBuffer() );
464 for( ULONG n = 0; n < aAttrList.Count(); n++ )
466 SvMetaAttribute * pS = aAttrList.GetObject( n );
467 if( pS->GetName() == rAttr.GetName() )
469 // Werte muessen uebereinstimmen
470 if( pS->GetSlotId().GetValue() != rAttr.GetSlotId().GetValue() )
472 DBG_ERROR( "Gleicher Name in MetaClass : " );
473 DBG_ERROR( pS->GetName().GetBuffer() );
474 DBG_ERROR( pS->GetSlotId().GetBuffer() );
475 DBG_ERROR( rAttr.GetSlotId().GetBuffer() );
477 ByteString aStr( "Attribute's " );
478 aStr += pS->GetName();
479 aStr += " with different id's";
480 rBase.SetError( aStr, rInStm.GetToken() );
481 rBase.WriteError( rInStm );
482 return FALSE;
485 else
487 UINT32 nId1 = pS->GetSlotId().GetValue();
488 UINT32 nId2 = rAttr.GetSlotId().GetValue();
489 if( nId1 == nId2 && nId1 != 0 /*&& nId2 != 0 ist ueberfluessig*/ )
491 DBG_ERROR( "Gleiche Id in MetaClass : " );
492 DBG_ERROR( ByteString::CreateFromInt32( pS->GetSlotId().GetValue() ).GetBuffer() );
493 DBG_ERROR( pS->GetSlotId().GetBuffer() );
494 DBG_ERROR( rAttr.GetSlotId().GetBuffer() );
496 ByteString aStr( "Attribute " );
497 aStr += pS->GetName();
498 aStr += " and Attribute ";
499 aStr += rAttr.GetName();
500 aStr += " with equal id's";
501 rBase.SetError( aStr, rInStm.GetToken() );
502 rBase.WriteError( rInStm );
503 return FALSE;
507 SvMetaClass * pSC = aSuperClass;
508 if( pSC )
509 return pSC->TestAttribute( rBase, rInStm, rAttr );
510 return TRUE;
513 /*************************************************************************
514 |* SvMetaClass::WriteSvIdl()
516 |* Beschreibung
517 *************************************************************************/
518 void SvMetaClass::WriteSvIdl( SvIdlDataBase & rBase, SvStream & rOutStm,
519 USHORT nTab )
521 WriteHeaderSvIdl( rBase, rOutStm, nTab );
522 if( aSuperClass.Is() )
523 rOutStm << " : " << aSuperClass->GetName().GetBuffer();
524 rOutStm << endl;
525 SvMetaName::WriteSvIdl( rBase, rOutStm, nTab );
526 rOutStm << endl;
529 /*************************************************************************
530 |* SvMetaClass::WriteOdlMember()
532 |* Beschreibung
533 *************************************************************************/
535 void SvMetaClass::WriteOdlMembers( ByteStringList & rSuperList,
536 BOOL bVariable, BOOL bWriteTab,
537 SvIdlDataBase & rBase,
538 SvStream & rOutStm, USHORT nTab )
540 // alle Attribute schreiben
541 ULONG n;
542 for( n = 0; n < aAttrList.Count(); n++ )
544 SvMetaAttribute * pAttr = aAttrList.GetObject( n );
546 ByteString aMangleName = pAttr->GetMangleName( bVariable );
547 ByteString * pS = rBase.FindName( aMangleName, rSuperList );
549 if( !pS && pAttr->GetExport() )
551 // nicht doppelt
552 if( bVariable && pAttr->IsVariable() )
554 rSuperList.Insert( new ByteString( aMangleName ), LIST_APPEND );
555 pAttr->Write( rBase, rOutStm, nTab +1, WRITE_ODL,
556 WA_VARIABLE );
557 rOutStm << ';' << endl;
559 else if( !bVariable && pAttr->IsMethod() )
561 rSuperList.Insert( new ByteString( aMangleName ), LIST_APPEND );
562 pAttr->Write( rBase, rOutStm, nTab +1, WRITE_ODL,
563 WA_METHOD );
564 rOutStm << ';' << endl;
567 else
568 continue;
570 // alle Attribute der importierten Klassen schreiben
571 for( n = 0; n < aClassList.Count(); n++ )
573 SvClassElement * pEle = aClassList.GetObject( n );
574 SvMetaClass * pCl = pEle->GetClass();
575 pCl->WriteOdlMembers( rSuperList, bVariable, bWriteTab,
576 rBase, rOutStm, nTab );
578 // alle Attribute der Superklassen schreiben
579 SvMetaClass * pSC = aSuperClass;
580 if( pSC )
581 pSC->WriteOdlMembers( rSuperList, bVariable, bWriteTab,
582 rBase, rOutStm, nTab );
586 /*************************************************************************
587 |* SvMetaClass::Write()
589 |* Beschreibung
590 *************************************************************************/
591 void SvMetaClass::Write( SvIdlDataBase & rBase, SvStream & rOutStm,
592 USHORT nTab,
593 WriteType nT, WriteAttribute )
595 rBase.aIFaceName = GetName();
596 switch( nT )
598 case WRITE_ODL:
600 DBG_ERROR( "Not supported anymore!" );
602 // Schreibt die Attribute
603 SvMetaName::Write( rBase, rOutStm, nTab, nT, nA );
605 WriteTab( rOutStm, nTab );
606 rOutStm << "dispinterface " << GetName().GetBuffer() << endl;
607 WriteTab( rOutStm, nTab );
608 rOutStm << '{' << endl;
610 WriteTab( rOutStm, nTab );
611 rOutStm << "properties:";
612 rOutStm << endl;
614 StringList aSuperList;
615 WriteOdlMembers( aSuperList, TRUE, TRUE, rBase, rOutStm, nTab );
617 WriteTab( rOutStm, nTab );
618 rOutStm << "methods:";
619 rOutStm << endl;
621 WriteOdlMembers( aSuperList, FALSE, TRUE, rBase, rOutStm, nTab );
623 ByteString * pStr = aSuperList.First();
624 while( pStr )
626 delete pStr;
627 pStr = aSuperList.Next();
630 WriteTab( rOutStm, 1 );
631 rOutStm << '}' << endl;
633 break;
635 case WRITE_C_SOURCE:
636 case WRITE_C_HEADER:
638 DBG_ERROR( "Not supported anymore!" );
640 StringList aSuperList;
641 if( nT == WRITE_C_SOURCE )
643 rOutStm << "#pragma code_seg (\"" << GetName().GetBuffer()
644 << "\",\"CODE\")" << endl;
646 WriteCFunctions( aSuperList, rBase, rOutStm, nTab, nT );
648 break;
650 case WRITE_DOCU:
652 rOutStm << "<INTERFACE>" << endl
653 << GetName().GetBuffer();
654 if ( GetAutomation() )
655 rOutStm << " ( Automation ) ";
656 rOutStm << endl;
657 WriteDescription( rOutStm );
658 rOutStm << "</INTERFACE>" << endl << endl;
660 // alle Attribute schreiben
661 ULONG n;
662 for( n = 0; n < aAttrList.Count(); n++ )
664 SvMetaAttribute * pAttr = aAttrList.GetObject( n );
665 if( !pAttr->GetHidden() )
667 if( pAttr->IsMethod() )
668 pAttr->Write( rBase, rOutStm, nTab, nT, WA_METHOD );
670 if( pAttr->IsVariable() )
671 pAttr->Write( rBase, rOutStm, nTab, nT, WA_VARIABLE );
675 break;
677 default:
678 break;
682 /*************************************************************************
683 |* SvMetaClass::WriteSlotParamArray()
685 |* Beschreibung
686 *************************************************************************/
687 USHORT SvMetaClass::WriteSlotParamArray( SvIdlDataBase & rBase,
688 SvSlotElementList & rSlotList,
689 SvStream & rOutStm )
691 USHORT nCount = 0;
692 for( ULONG n = 0; n < rSlotList.Count(); n++ )
694 SvSlotElement *pEle = rSlotList.GetObject( n );
695 SvMetaSlot *pAttr = pEle->xSlot;
696 nCount = nCount + pAttr->WriteSlotParamArray( rBase, rOutStm );
699 return nCount;
702 /*************************************************************************
703 |* SvMetaClass::WriteSlots()
705 |* Beschreibung
706 *************************************************************************/
707 USHORT SvMetaClass::WriteSlots( const ByteString & rShellName,
708 USHORT nCount, SvSlotElementList & rSlotList,
709 SvIdlDataBase & rBase,
710 SvStream & rOutStm )
712 USHORT nSCount = 0;
713 for( ULONG n = 0; n < rSlotList.Count(); n++ )
715 rSlotList.Seek(n);
716 SvSlotElement * pEle = rSlotList.GetCurObject();
717 SvMetaSlot * pAttr = pEle->xSlot;
718 nSCount = nSCount + pAttr->WriteSlotMap( rShellName, nCount + nSCount,
719 rSlotList, pEle->aPrefix, rBase,
720 rOutStm );
723 return nSCount;
726 /*************************************************************************
727 |* SvMetaClass::InsertSlots()
729 |* Beschreibung
730 *************************************************************************/
731 void SvMetaClass::InsertSlots( SvSlotElementList& rList, SvULongs& rSuperList,
732 SvMetaClassList &rClassList,
733 const ByteString & rPrefix, SvIdlDataBase& rBase)
735 // Wurde diese Klasse schon geschrieben ?
736 if ( rClassList.GetPos(this) != LIST_ENTRY_NOTFOUND )
737 return;
739 rClassList.Insert(this, LIST_APPEND);
741 // alle direkten Attribute schreiben
742 ULONG n;
743 for( n = 0; n < aAttrList.Count(); n++ )
745 SvMetaAttribute * pAttr = aAttrList.GetObject( n );
747 ULONG nId = pAttr->GetSlotId().GetValue();
748 USHORT nPos;
749 for ( nPos=0; nPos < rSuperList.Count(); nPos++ )
751 if ( rSuperList.GetObject(nPos) == nId )
752 break;
755 if( nPos == rSuperList.Count() )
757 // nur schreiben, wenn nicht schon bei SubClass oder
758 // importiertem Interface geschrieben
759 rSuperList.Insert( nId, nPos );
760 pAttr->Insert(rList, rPrefix, rBase);
764 // Alle schon von SuperShells importierten Interfaces sollen nicht
765 // mehr geschrieben werden
766 // Es ist also verboten, da\s Shell und SuperShell die gleiche Klasse
767 // direkt importieren !
768 if( IsShell() && aSuperClass.Is() )
769 aSuperClass->FillClasses( rClassList );
771 // alle Attribute der importierten Klassen schreiben, sofern diese nicht
772 // schon von der Superklasse importiert wurden
773 for( n = 0; n < aClassList.Count(); n++ )
775 SvClassElement * pEle = aClassList.GetObject( n );
776 SvMetaClass * pCl = pEle->GetClass();
777 ByteString rPre = rPrefix;
778 if( rPre.Len() && pEle->GetPrefix().Len() )
779 rPre += '.';
780 rPre += pEle->GetPrefix();
782 // Zun"achst die direkt importierten Interfaces schreiben
783 pCl->InsertSlots( rList, rSuperList, rClassList, rPre, rBase );
786 // Superklassen nur schreiben, wenn keine Shell und nicht in der Liste
787 if( !IsShell() && aSuperClass.Is() )
789 aSuperClass->InsertSlots( rList, rSuperList, rClassList, rPrefix, rBase );
793 /*************************************************************************
794 |* SvMetaClass::FillClasses()
796 |* Beschreibung
797 *************************************************************************/
798 void SvMetaClass::FillClasses( SvMetaClassList & rList )
800 // Bin ich noch nicht drin ?
801 if ( rList.GetPos(this) == LIST_ENTRY_NOTFOUND )
803 rList.Insert(this, LIST_APPEND);
805 // Meine Imports
806 for( ULONG n = 0; n < aClassList.Count(); n++ )
808 SvClassElement * pEle = aClassList.GetObject( n );
809 SvMetaClass * pCl = pEle->GetClass();
810 pCl->FillClasses( rList );
813 // Meine Superklasse
814 if( aSuperClass.Is() )
815 aSuperClass->FillClasses( rList );
820 /*************************************************************************
821 |* SvMetaClass::WriteSlotStubs()
823 |* Beschreibung
824 *************************************************************************/
825 void SvMetaClass::WriteSlotStubs( const ByteString & rShellName,
826 SvSlotElementList & rSlotList,
827 ByteStringList & rList,
828 SvStream & rOutStm )
830 // alle Attribute schreiben
831 for( ULONG n = 0; n < rSlotList.Count(); n++ )
833 SvSlotElement *pEle = rSlotList.GetObject( n );
834 SvMetaSlot *pAttr = pEle->xSlot;
835 pAttr->WriteSlotStubs( rShellName, rList, rOutStm );
839 /*************************************************************************
840 |* SvMetaClass::WriteSfx()
842 |* Beschreibung
843 *************************************************************************/
844 void SvMetaClass::WriteSfx( SvIdlDataBase & rBase, SvStream & rOutStm )
846 WriteStars( rOutStm );
847 // Klasse definieren
848 rOutStm << "#ifdef " << GetName().GetBuffer() << endl;
849 rOutStm << "#undef ShellClass" << endl;
850 rOutStm << "#undef " << GetName().GetBuffer() << endl;
851 rOutStm << "#define ShellClass " << GetName().GetBuffer() << endl;
853 // rOutStm << "SFX_TYPELIB(" << GetName().GetBuffer() << ',' << endl
854 // << "\t/* library type */"
855 // << '"' << ByteString( GetModule()->GetUUId().GetHexName(), RTL_TEXTENCODING_UTF8 ).GetBuffer() << "\"," << endl
856 // << "\t\"" << GetModule()->GetTypeLibFileName().GetBuffer() << "\","
857 // << ByteString::CreateFromInt32( GetModule()->GetVersion().GetMajorVersion() ).GetBuffer() << ','
858 // << ByteString::CreateFromInt32( GetModule()->GetVersion().GetMinorVersion() ).GetBuffer() << ',' << endl
859 // << "\t/* shell type */"
860 // << '"';
861 // if( xAutomationInterface.Is() )
862 // rOutStm << ByteString( xAutomationInterface->GetUUId().GetHexName(), RTL_TEXTENCODING_UTF8 ).GetBuffer();
863 // else
864 // rOutStm << ByteString( GetUUId().GetHexName(), RTL_TEXTENCODING_UTF8 ).GetBuffer();
865 // rOutStm << "\");" << endl << endl;
867 // Fuer Interfaces werden kein Slotmaps geschrieben
868 if( !IsShell() )
870 rOutStm << "#endif" << endl << endl;
871 return;
873 // Parameter Array schreiben
874 //rOutStm << "SfxArgList " << GetName().GetBuffer() << "ArgMap[] = {" << endl;
875 rOutStm << "SFX_ARGUMENTMAP(" << GetName().GetBuffer() << ')' << endl
876 << '{' << endl;
878 SvULongs aSuperList;
879 SvMetaClassList classList;
880 SvSlotElementList aSlotList;
881 InsertSlots(aSlotList, aSuperList, classList, ByteString(), rBase);
882 ULONG n;
883 for ( n=0; n<aSlotList.Count(); n++ )
885 SvSlotElement *pEle = aSlotList.GetObject( n );
886 SvMetaSlot *pSlot = pEle->xSlot;
887 pSlot->SetListPos(n);
890 ULONG nSlotCount = aSlotList.Count();
892 // alle Attribute schreiben
893 USHORT nArgCount = WriteSlotParamArray( rBase, aSlotList, rOutStm );
894 if( nArgCount )
895 Back2Delemitter( rOutStm );
896 else
898 // mindestens einen dummy
899 WriteTab( rOutStm, 1 );
900 rOutStm << "SFX_ARGUMENT( 0, 0, SfxVoidItem )" << endl;
902 rOutStm << endl << "};" << endl << endl;
904 ByteStringList aStringList;
905 WriteSlotStubs( GetName(), aSlotList, aStringList, rOutStm );
906 ByteString * pStr = aStringList.First();
907 while( pStr )
909 delete pStr;
910 pStr = aStringList.Next();
913 rOutStm << endl;
915 // Slotmap schreiben
916 rOutStm << "SFX_SLOTMAP_ARG(" << GetName().GetBuffer() << ')' << endl
917 << '{' << endl;
919 // alle Attribute schreiben
920 WriteSlots( GetName(), 0, aSlotList, rBase, rOutStm );
921 if( nSlotCount )
922 Back2Delemitter( rOutStm );
923 else
925 // mindestens einen dummy
926 WriteTab( rOutStm, 1 );
927 rOutStm << "SFX_SLOT_ARG(" << GetName().GetBuffer()
928 << ", 0, 0, "
929 << "SFX_STUB_PTR_EXEC_NONE,"
930 << "SFX_STUB_PTR_STATE_NONE,"
931 << "0, SfxVoidItem, 0, 0, \"\", 0 )" << endl;
933 rOutStm << endl << "};" << endl << "#endif" << endl << endl;
935 for( n=0; n<aSlotList.Count(); n++ )
937 aSlotList.Seek(n);
938 SvSlotElement* pEle = aSlotList.GetCurObject();
939 SvMetaSlot* pAttr = pEle->xSlot;
940 pAttr->ResetSlotPointer();
943 for ( n=0; n<aSlotList.Count(); n++ )
944 delete aSlotList.GetObject(n);
947 void SvMetaClass::WriteHelpIds( SvIdlDataBase & rBase, SvStream & rOutStm,
948 Table* pTable )
950 for( ULONG n=0; n<aAttrList.Count(); n++ )
952 SvMetaAttribute * pAttr = aAttrList.GetObject( n );
953 pAttr->WriteHelpId( rBase, rOutStm, pTable );
957 /*************************************************************************
958 |* SvMetaShell::WriteSrc()
959 *************************************************************************/
960 void SvMetaClass::WriteSrc( SvIdlDataBase & rBase, SvStream & rOutStm,
961 Table * pTable )
963 for( ULONG n=0; n<aAttrList.Count(); n++ )
965 SvMetaAttribute * pAttr = aAttrList.GetObject( n );
966 pAttr->WriteSrc( rBase, rOutStm, pTable );
970 /*************************************************************************
971 |* SvMetaClass::WriteHxx()
973 |* Beschreibung
974 *************************************************************************/
975 void SvMetaClass::WriteHxx( SvIdlDataBase &, SvStream & rOutStm, USHORT )
977 ByteString aSuperName( "SvDispatch" );
978 if( GetSuperClass() )
979 aSuperName = GetSuperClass()->GetName();
980 const char * pSup = aSuperName.GetBuffer();
982 rOutStm
983 << "class " << GetSvName().GetBuffer()
984 << ": public " << pSup << endl
985 << '{' << endl
986 << "protected:" << endl
987 << "\tvirtual SvGlobalName GetTypeName() const;" << endl
988 << "\tvirtual BOOL FillTypeLibInfo( SvGlobalName *, USHORT * pMajor," << endl
989 << "\t USHORT * pMinor ) const;" << endl
990 << "\tvirtual BOOL FillTypeLibInfo( ByteString * pName, USHORT * pMajor," << endl;
991 rOutStm
992 << "\t USHORT * pMinor ) const;" << endl
993 << "\tvirtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) = 0;" << endl
994 << "public:" << endl
995 << "\t static SvGlobalName ClassName()" << endl
996 << "\t { return SvGlobalName( " << ByteString( GetUUId().GetctorName(), RTL_TEXTENCODING_UTF8 ).GetBuffer() << " ); }" << endl
997 << "};" << endl;
1000 /*************************************************************************
1001 |* SvMetaClass::WriteCxx()
1003 |* Beschreibung
1004 *************************************************************************/
1005 void SvMetaClass::WriteCxx( SvIdlDataBase &, SvStream & rOutStm, USHORT )
1007 ByteString aSuperName( "SvDispatch" );
1008 if( GetSuperClass() )
1009 aSuperName = GetSuperClass()->GetName();
1010 const char * pSup = aSuperName.GetBuffer();
1012 ByteString name = GetSvName();
1013 // GetTypeName
1014 rOutStm << "SvGlobalName " << name.GetBuffer() << "::GetTypeName() const" << endl
1015 << '{' << endl
1016 << "\treturn ClassName();" << endl
1017 << '}' << endl;
1019 SvMetaModule * pMod = GetModule();
1020 // FillTypeLibInfo
1021 rOutStm << "BOOL " << name.GetBuffer() << "::FillTypeLibInfo( SvGlobalName * pGN," << endl
1022 << "\t USHORT * pMajor," << endl
1023 << "\t USHORT * pMinor ) const" << endl
1024 << '{' << endl
1025 << "\tSvGlobalName aN( " << ByteString( pMod->GetUUId().GetctorName(), RTL_TEXTENCODING_UTF8 ).GetBuffer() << " );" << endl;
1026 rOutStm << "\t*pGN = aN;" << endl
1027 << "\t*pMajor = " << ByteString::CreateFromInt32(pMod->GetVersion().GetMajorVersion()).GetBuffer() << ';' << endl
1028 << "\t*pMinor = " << ByteString::CreateFromInt32(pMod->GetVersion().GetMinorVersion()).GetBuffer() << ';' << endl
1029 << "\treturn TRUE;" << endl
1030 << '}' << endl;
1032 // FillTypeLibInfo
1033 rOutStm << "BOOL " << name.GetBuffer() << "::FillTypeLibInfo( ByteString * pName,"
1034 << "\t USHORT * pMajor," << endl
1035 << "\t USHORT * pMinor ) const" << endl;
1036 rOutStm << '{' << endl
1037 << "\t*pName = \"" << pMod->GetTypeLibFileName().GetBuffer() << "\";" << endl
1038 << "\t*pMajor = " << ByteString::CreateFromInt32(pMod->GetVersion().GetMajorVersion()).GetBuffer() << ';' << endl
1039 << "\t*pMinor = " << ByteString::CreateFromInt32(pMod->GetVersion().GetMinorVersion()).GetBuffer() << ';' << endl
1040 << "\treturn TRUE;" << endl
1041 << '}' << endl;
1043 rOutStm << "void " << name.GetBuffer() << "::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )" << endl
1044 << '{' << endl
1045 << "\t" << pSup << "::Notify( rBC, rHint );" << endl
1046 << '}' << endl;
1049 #endif // IDL_COMPILER