1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: object.cxx,v $
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"
37 #include <tools/debug.hxx>
41 #include <globals.hxx>
42 #include <database.hxx>
44 /******************** class SvClassElement *******************************/
45 SV_IMPL_PERSIST1( SvClassElement
, SvPersistBase
);
47 /*************************************************************************
48 |* SvClassElement::SvClassElement()
51 *************************************************************************/
52 SvClassElement::SvClassElement()
56 /*************************************************************************
57 |* SvClassElement::Load()
60 *************************************************************************/
61 void SvClassElement::Load( SvPersistStream
& rStm
)
67 rStm
.SetError( SVSTREAM_FILEFORMAT_ERROR
);
68 DBG_ERROR( "wrong format" );
71 if( nMask
& 0x01 ) rStm
>> aAutomation
;
72 if( nMask
& 0x02 ) rStm
.ReadByteString( aPrefix
);
81 /*************************************************************************
82 |* SvClassElement::Save()
85 *************************************************************************/
86 void SvClassElement::Save( SvPersistStream
& rStm
)
90 if( aAutomation
.IsSet() ) nMask
|= 0x1;
91 if( aPrefix
.Len() ) nMask
|= 0x2;
92 if( xClass
.Is() ) nMask
|= 0x4;
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()
107 *************************************************************************/
108 SvMetaClass::SvMetaClass()
109 : aAutomation( TRUE
, FALSE
)
113 /*************************************************************************
114 |* SvMetaClass::Load()
117 *************************************************************************/
118 void SvMetaClass::Load( SvPersistStream
& rStm
)
120 SvMetaType::Load( rStm
);
126 rStm
.SetError( SVSTREAM_FILEFORMAT_ERROR
);
127 DBG_ERROR( "wrong format" );
130 if( nMask
& 0x01 ) rStm
>> aAttrList
;
133 SvMetaClass
* pSuper
;
135 aSuperClass
= pSuper
;
137 if( nMask
& 0x04 ) rStm
>> aClassList
;
142 xAutomationInterface
= p
;
144 if( nMask
& 0x10 ) rStm
>> aAutomation
;
147 /*************************************************************************
148 |* SvMetaClass::Save()
151 *************************************************************************/
152 void SvMetaClass::Save( SvPersistStream
& rStm
)
154 SvMetaType::Save( rStm
);
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;
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()
177 *************************************************************************/
179 void SvMetaClass::FillSbxMemberObject( SvIdlDataBase & rBase,
181 StringList & rSuperList,
184 // alle Attribute der Klasse schreiben
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() )
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()
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();
236 pStr = aSuperList.Next();
241 /*************************************************************************
242 |* SvMetaClass::ReadAttributesSvIdl()
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()
257 *************************************************************************/
258 void SvMetaClass::WriteAttributesSvIdl( SvIdlDataBase
& rBase
,
259 SvStream
& rOutStm
, USHORT nTab
)
261 SvMetaType::WriteAttributesSvIdl( rBase
, rOutStm
, nTab
);
265 WriteTab( rOutStm
, nTab
);
266 rOutStm
<< "//class SvMetaClass" << endl
;
269 WriteTab( rOutStm
, nTab
);
270 aAutomation
.WriteSvIdl( SvHash_Automation(), rOutStm
);
271 rOutStm
<< ';' << endl
;
276 /*************************************************************************
277 |* SvMetaClass::ReadContextSvIdl()
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
);
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() )
306 rBase
.SetError( "Automation allready set",
308 rBase
.WriteError( rInStm
);
310 xAutomationInterface
= pClass
;
311 xEle
->SetAutomation( TRUE
);
316 rBase
.SetError( "missing ]", rInStm
.GetToken() );
317 rBase
.WriteError( rInStm
);
323 rBase
.SetError( "only attribute Automation allowed",
325 rBase
.WriteError( rInStm
);
328 pTok
= rInStm
.GetToken();
329 if( pTok
->IsString() )
331 xEle
->SetPrefix( pTok
->GetString() );
332 rInStm
.GetToken_Next();
339 rBase
.SetError( "unknown imported interface", rInStm
.GetToken() );
340 rBase
.WriteError( rInStm
);
345 rInStm
.Seek( nTokPos
);
346 SvMetaType
* pType
= rBase
.ReadKnownType( rInStm
);
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
);
358 xAttr
= new SvMetaAttribute( pType
);
359 if( xAttr
->ReadSvIdl( rBase
, rInStm
) )
360 bOk
= xAttr
->Test( rBase
, rInStm
);
364 bOk
= TestAttribute( rBase
, rInStm
, *xAttr
);
367 if( !xAttr
->GetSlotId().IsSet() )
369 SvNumberIdentifier aI
;
370 aI
.SetValue( rBase
.GetUniqueId() );
371 xAttr
->SetSlotId( aI
);
373 aAttrList
.Append( xAttr
);
377 rInStm
.Seek( nTokPos
);
380 /*************************************************************************
381 |* SvMetaClass::WriteContextSvIdl()
384 *************************************************************************/
385 void SvMetaClass::WriteContextSvIdl
387 SvIdlDataBase
& rBase
,
392 //SvMetaType::WriteContextSvIdl( rBase, rOutStm, nTab );
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()
409 if( pEle
->GetPrefix().Len() )
410 rOutStm
<< ' ' << pEle
->GetPrefix().GetBuffer();
411 rOutStm
<< ';' << endl
;
415 /*************************************************************************
416 |* SvMetaClass::ReadSvIdl()
419 *************************************************************************/
420 BOOL
SvMetaClass::ReadSvIdl( SvIdlDataBase
& rBase
, SvTokenStream
& rInStm
)
422 ULONG nTokPos
= rInStm
.Tell();
423 if( SvMetaType::ReadHeaderSvIdl( rBase
, rInStm
) && GetType() == TYPE_CLASS
)
426 if( rInStm
.Read( ':' ) )
428 aSuperClass
= rBase
.ReadKnownClass( rInStm
);
429 bOk
= aSuperClass
.Is();
433 rBase
.SetError( "unknown super class",
435 rBase
.WriteError( rInStm
);
441 bOk
= SvMetaName::ReadSvIdl( rBase
, rInStm
);
446 rInStm
.Seek( nTokPos
);
450 /*************************************************************************
451 |* SvMetaClass::TestAttribute()
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
);
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
);
507 SvMetaClass
* pSC
= aSuperClass
;
509 return pSC
->TestAttribute( rBase
, rInStm
, rAttr
);
513 /*************************************************************************
514 |* SvMetaClass::WriteSvIdl()
517 *************************************************************************/
518 void SvMetaClass::WriteSvIdl( SvIdlDataBase
& rBase
, SvStream
& rOutStm
,
521 WriteHeaderSvIdl( rBase
, rOutStm
, nTab
);
522 if( aSuperClass
.Is() )
523 rOutStm
<< " : " << aSuperClass
->GetName().GetBuffer();
525 SvMetaName::WriteSvIdl( rBase
, rOutStm
, nTab
);
529 /*************************************************************************
530 |* SvMetaClass::WriteOdlMember()
533 *************************************************************************/
535 void SvMetaClass::WriteOdlMembers( ByteStringList & rSuperList,
536 BOOL bVariable, BOOL bWriteTab,
537 SvIdlDataBase & rBase,
538 SvStream & rOutStm, USHORT nTab )
540 // alle Attribute schreiben
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() )
552 if( bVariable && pAttr->IsVariable() )
554 rSuperList.Insert( new ByteString( aMangleName ), LIST_APPEND );
555 pAttr->Write( rBase, rOutStm, nTab +1, WRITE_ODL,
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,
564 rOutStm << ';' << endl;
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;
581 pSC->WriteOdlMembers( rSuperList, bVariable, bWriteTab,
582 rBase, rOutStm, nTab );
586 /*************************************************************************
587 |* SvMetaClass::Write()
590 *************************************************************************/
591 void SvMetaClass::Write( SvIdlDataBase
& rBase
, SvStream
& rOutStm
,
593 WriteType nT
, WriteAttribute
)
595 rBase
.aIFaceName
= GetName();
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:";
614 StringList aSuperList;
615 WriteOdlMembers( aSuperList, TRUE, TRUE, rBase, rOutStm, nTab );
617 WriteTab( rOutStm, nTab );
618 rOutStm << "methods:";
621 WriteOdlMembers( aSuperList, FALSE, TRUE, rBase, rOutStm, nTab );
623 ByteString * pStr = aSuperList.First();
627 pStr = aSuperList.Next();
630 WriteTab( rOutStm, 1 );
631 rOutStm << '}' << endl;
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 );
652 rOutStm
<< "<INTERFACE>" << endl
653 << GetName().GetBuffer();
654 if ( GetAutomation() )
655 rOutStm
<< " ( Automation ) ";
657 WriteDescription( rOutStm
);
658 rOutStm
<< "</INTERFACE>" << endl
<< endl
;
660 // alle Attribute schreiben
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
);
682 /*************************************************************************
683 |* SvMetaClass::WriteSlotParamArray()
686 *************************************************************************/
687 USHORT
SvMetaClass::WriteSlotParamArray( SvIdlDataBase
& rBase
,
688 SvSlotElementList
& rSlotList
,
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
);
702 /*************************************************************************
703 |* SvMetaClass::WriteSlots()
706 *************************************************************************/
707 USHORT
SvMetaClass::WriteSlots( const ByteString
& rShellName
,
708 USHORT nCount
, SvSlotElementList
& rSlotList
,
709 SvIdlDataBase
& rBase
,
713 for( ULONG n
= 0; n
< rSlotList
.Count(); n
++ )
716 SvSlotElement
* pEle
= rSlotList
.GetCurObject();
717 SvMetaSlot
* pAttr
= pEle
->xSlot
;
718 nSCount
= nSCount
+ pAttr
->WriteSlotMap( rShellName
, nCount
+ nSCount
,
719 rSlotList
, pEle
->aPrefix
, rBase
,
726 /*************************************************************************
727 |* SvMetaClass::InsertSlots()
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
)
739 rClassList
.Insert(this, LIST_APPEND
);
741 // alle direkten Attribute schreiben
743 for( n
= 0; n
< aAttrList
.Count(); n
++ )
745 SvMetaAttribute
* pAttr
= aAttrList
.GetObject( n
);
747 ULONG nId
= pAttr
->GetSlotId().GetValue();
749 for ( nPos
=0; nPos
< rSuperList
.Count(); nPos
++ )
751 if ( rSuperList
.GetObject(nPos
) == nId
)
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() )
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()
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
);
806 for( ULONG n
= 0; n
< aClassList
.Count(); n
++ )
808 SvClassElement
* pEle
= aClassList
.GetObject( n
);
809 SvMetaClass
* pCl
= pEle
->GetClass();
810 pCl
->FillClasses( rList
);
814 if( aSuperClass
.Is() )
815 aSuperClass
->FillClasses( rList
);
820 /*************************************************************************
821 |* SvMetaClass::WriteSlotStubs()
824 *************************************************************************/
825 void SvMetaClass::WriteSlotStubs( const ByteString
& rShellName
,
826 SvSlotElementList
& rSlotList
,
827 ByteStringList
& rList
,
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()
843 *************************************************************************/
844 void SvMetaClass::WriteSfx( SvIdlDataBase
& rBase
, SvStream
& rOutStm
)
846 WriteStars( rOutStm
);
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 */"
861 // if( xAutomationInterface.Is() )
862 // rOutStm << ByteString( xAutomationInterface->GetUUId().GetHexName(), RTL_TEXTENCODING_UTF8 ).GetBuffer();
864 // rOutStm << ByteString( GetUUId().GetHexName(), RTL_TEXTENCODING_UTF8 ).GetBuffer();
865 // rOutStm << "\");" << endl << endl;
867 // Fuer Interfaces werden kein Slotmaps geschrieben
870 rOutStm
<< "#endif" << endl
<< endl
;
873 // Parameter Array schreiben
874 //rOutStm << "SfxArgList " << GetName().GetBuffer() << "ArgMap[] = {" << endl;
875 rOutStm
<< "SFX_ARGUMENTMAP(" << GetName().GetBuffer() << ')' << endl
879 SvMetaClassList classList
;
880 SvSlotElementList aSlotList
;
881 InsertSlots(aSlotList
, aSuperList
, classList
, ByteString(), rBase
);
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
);
895 Back2Delemitter( rOutStm
);
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();
910 pStr
= aStringList
.Next();
916 rOutStm
<< "SFX_SLOTMAP_ARG(" << GetName().GetBuffer() << ')' << endl
919 // alle Attribute schreiben
920 WriteSlots( GetName(), 0, aSlotList
, rBase
, rOutStm
);
922 Back2Delemitter( rOutStm
);
925 // mindestens einen dummy
926 WriteTab( rOutStm
, 1 );
927 rOutStm
<< "SFX_SLOT_ARG(" << GetName().GetBuffer()
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
++ )
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
,
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
,
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()
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();
983 << "class " << GetSvName().GetBuffer()
984 << ": public " << pSup
<< 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
;
992 << "\t USHORT * pMinor ) const;" << endl
993 << "\tvirtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) = 0;" << endl
995 << "\t static SvGlobalName ClassName()" << endl
996 << "\t { return SvGlobalName( " << ByteString( GetUUId().GetctorName(), RTL_TEXTENCODING_UTF8
).GetBuffer() << " ); }" << endl
1000 /*************************************************************************
1001 |* SvMetaClass::WriteCxx()
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();
1014 rOutStm
<< "SvGlobalName " << name
.GetBuffer() << "::GetTypeName() const" << endl
1016 << "\treturn ClassName();" << endl
1019 SvMetaModule
* pMod
= GetModule();
1021 rOutStm
<< "BOOL " << name
.GetBuffer() << "::FillTypeLibInfo( SvGlobalName * pGN," << endl
1022 << "\t USHORT * pMajor," << endl
1023 << "\t USHORT * pMinor ) const" << 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
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
1043 rOutStm
<< "void " << name
.GetBuffer() << "::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )" << endl
1045 << "\t" << pSup
<< "::Notify( rBC, rHint );" << endl
1049 #endif // IDL_COMPILER