xref: /trunk/main/idl/source/objects/object.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_idl.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include <ctype.h>
32*cdf0e10cSrcweir #include <stdio.h>
33*cdf0e10cSrcweir 
34*cdf0e10cSrcweir #include <tools/debug.hxx>
35*cdf0e10cSrcweir 
36*cdf0e10cSrcweir #include <attrib.hxx>
37*cdf0e10cSrcweir #include <object.hxx>
38*cdf0e10cSrcweir #include <globals.hxx>
39*cdf0e10cSrcweir #include <database.hxx>
40*cdf0e10cSrcweir 
41*cdf0e10cSrcweir /******************** class SvClassElement *******************************/
42*cdf0e10cSrcweir SV_IMPL_PERSIST1( SvClassElement, SvPersistBase );
43*cdf0e10cSrcweir 
44*cdf0e10cSrcweir /*************************************************************************
45*cdf0e10cSrcweir |*    SvClassElement::SvClassElement()
46*cdf0e10cSrcweir |*
47*cdf0e10cSrcweir |*    Beschreibung
48*cdf0e10cSrcweir *************************************************************************/
49*cdf0e10cSrcweir SvClassElement::SvClassElement()
50*cdf0e10cSrcweir {
51*cdf0e10cSrcweir };
52*cdf0e10cSrcweir 
53*cdf0e10cSrcweir /*************************************************************************
54*cdf0e10cSrcweir |*    SvClassElement::Load()
55*cdf0e10cSrcweir |*
56*cdf0e10cSrcweir |*    Beschreibung
57*cdf0e10cSrcweir *************************************************************************/
58*cdf0e10cSrcweir void SvClassElement::Load( SvPersistStream & rStm )
59*cdf0e10cSrcweir {
60*cdf0e10cSrcweir     sal_uInt8 nMask;
61*cdf0e10cSrcweir     rStm >> nMask;
62*cdf0e10cSrcweir     if( nMask >= 0x08 )
63*cdf0e10cSrcweir     {
64*cdf0e10cSrcweir         rStm.SetError( SVSTREAM_FILEFORMAT_ERROR );
65*cdf0e10cSrcweir         DBG_ERROR( "wrong format" );
66*cdf0e10cSrcweir         return;
67*cdf0e10cSrcweir     }
68*cdf0e10cSrcweir     if( nMask & 0x01 ) rStm >> aAutomation;
69*cdf0e10cSrcweir     if( nMask & 0x02 ) rStm.ReadByteString( aPrefix );
70*cdf0e10cSrcweir     if( nMask & 0x04 )
71*cdf0e10cSrcweir     {
72*cdf0e10cSrcweir         SvMetaClass * p;
73*cdf0e10cSrcweir         rStm >> p;
74*cdf0e10cSrcweir         xClass = p;
75*cdf0e10cSrcweir     }
76*cdf0e10cSrcweir }
77*cdf0e10cSrcweir 
78*cdf0e10cSrcweir /*************************************************************************
79*cdf0e10cSrcweir |*    SvClassElement::Save()
80*cdf0e10cSrcweir |*
81*cdf0e10cSrcweir |*    Beschreibung
82*cdf0e10cSrcweir *************************************************************************/
83*cdf0e10cSrcweir void SvClassElement::Save( SvPersistStream & rStm )
84*cdf0e10cSrcweir {
85*cdf0e10cSrcweir     // Maske erstellen
86*cdf0e10cSrcweir     sal_uInt8 nMask = 0;
87*cdf0e10cSrcweir     if( aAutomation.IsSet() )       nMask |= 0x1;
88*cdf0e10cSrcweir     if( aPrefix.Len() )             nMask |= 0x2;
89*cdf0e10cSrcweir     if( xClass.Is() )               nMask |= 0x4;
90*cdf0e10cSrcweir 
91*cdf0e10cSrcweir     // Daten schreiben
92*cdf0e10cSrcweir     rStm << nMask;
93*cdf0e10cSrcweir     if( nMask & 0x01 ) rStm << aAutomation;
94*cdf0e10cSrcweir     if( nMask & 0x02 ) rStm.WriteByteString( aPrefix );
95*cdf0e10cSrcweir     if( nMask & 0x04 ) rStm << xClass;
96*cdf0e10cSrcweir }
97*cdf0e10cSrcweir 
98*cdf0e10cSrcweir /****************** SvMetaClass ******************************************/
99*cdf0e10cSrcweir SV_IMPL_META_FACTORY1( SvMetaClass, SvMetaType );
100*cdf0e10cSrcweir /*************************************************************************
101*cdf0e10cSrcweir |*    SvMetaClass::SvMetaClass()
102*cdf0e10cSrcweir |*
103*cdf0e10cSrcweir |*    Beschreibung
104*cdf0e10cSrcweir *************************************************************************/
105*cdf0e10cSrcweir SvMetaClass::SvMetaClass()
106*cdf0e10cSrcweir     : aAutomation( sal_True, sal_False )
107*cdf0e10cSrcweir {
108*cdf0e10cSrcweir }
109*cdf0e10cSrcweir 
110*cdf0e10cSrcweir /*************************************************************************
111*cdf0e10cSrcweir |*    SvMetaClass::Load()
112*cdf0e10cSrcweir |*
113*cdf0e10cSrcweir |*    Beschreibung
114*cdf0e10cSrcweir *************************************************************************/
115*cdf0e10cSrcweir void SvMetaClass::Load( SvPersistStream & rStm )
116*cdf0e10cSrcweir {
117*cdf0e10cSrcweir     SvMetaType::Load( rStm );
118*cdf0e10cSrcweir 
119*cdf0e10cSrcweir     sal_uInt8 nMask;
120*cdf0e10cSrcweir     rStm >> nMask;
121*cdf0e10cSrcweir     if( nMask >= 0x20 )
122*cdf0e10cSrcweir     {
123*cdf0e10cSrcweir         rStm.SetError( SVSTREAM_FILEFORMAT_ERROR );
124*cdf0e10cSrcweir         DBG_ERROR( "wrong format" );
125*cdf0e10cSrcweir         return;
126*cdf0e10cSrcweir     }
127*cdf0e10cSrcweir     if( nMask & 0x01 ) rStm >> aAttrList;
128*cdf0e10cSrcweir     if( nMask & 0x02 )
129*cdf0e10cSrcweir     {
130*cdf0e10cSrcweir         SvMetaClass * pSuper;
131*cdf0e10cSrcweir          rStm >> pSuper;
132*cdf0e10cSrcweir         aSuperClass = pSuper;
133*cdf0e10cSrcweir     }
134*cdf0e10cSrcweir     if( nMask & 0x04 ) rStm >> aClassList;
135*cdf0e10cSrcweir     if( nMask & 0x8 )
136*cdf0e10cSrcweir     {
137*cdf0e10cSrcweir         SvMetaClass * p;
138*cdf0e10cSrcweir         rStm >> p;
139*cdf0e10cSrcweir         xAutomationInterface = p;
140*cdf0e10cSrcweir     }
141*cdf0e10cSrcweir     if( nMask & 0x10 ) rStm >> aAutomation;
142*cdf0e10cSrcweir }
143*cdf0e10cSrcweir 
144*cdf0e10cSrcweir /*************************************************************************
145*cdf0e10cSrcweir |*    SvMetaClass::Save()
146*cdf0e10cSrcweir |*
147*cdf0e10cSrcweir |*    Beschreibung
148*cdf0e10cSrcweir *************************************************************************/
149*cdf0e10cSrcweir void SvMetaClass::Save( SvPersistStream & rStm )
150*cdf0e10cSrcweir {
151*cdf0e10cSrcweir     SvMetaType::Save( rStm );
152*cdf0e10cSrcweir 
153*cdf0e10cSrcweir     // Maske erstellen
154*cdf0e10cSrcweir     sal_uInt8 nMask = 0;
155*cdf0e10cSrcweir     if( aAttrList.Count() )         nMask |= 0x1;
156*cdf0e10cSrcweir     if( aSuperClass.Is() )          nMask |= 0x2;
157*cdf0e10cSrcweir     if( aClassList.Count() )        nMask |= 0x4;
158*cdf0e10cSrcweir     if( xAutomationInterface.Is() ) nMask |= 0x8;
159*cdf0e10cSrcweir     if( aAutomation.IsSet() )       nMask |= 0x10;
160*cdf0e10cSrcweir 
161*cdf0e10cSrcweir     // Daten schreiben
162*cdf0e10cSrcweir     rStm << nMask;
163*cdf0e10cSrcweir     if( nMask & 0x01 ) rStm << aAttrList;
164*cdf0e10cSrcweir     if( nMask & 0x02 ) rStm << aSuperClass;
165*cdf0e10cSrcweir     if( nMask & 0x04 ) rStm << aClassList;
166*cdf0e10cSrcweir     if( nMask & 0x08 ) rStm << xAutomationInterface;
167*cdf0e10cSrcweir     if( nMask & 0x10 ) rStm << aAutomation;
168*cdf0e10cSrcweir }
169*cdf0e10cSrcweir 
170*cdf0e10cSrcweir /*************************************************************************
171*cdf0e10cSrcweir |*    SvMetaClass::FillSbxObject()
172*cdf0e10cSrcweir |*
173*cdf0e10cSrcweir |*    Beschreibung
174*cdf0e10cSrcweir *************************************************************************/
175*cdf0e10cSrcweir /*
176*cdf0e10cSrcweir void SvMetaClass::FillSbxMemberObject( SvIdlDataBase & rBase,
177*cdf0e10cSrcweir                                         SbxObject * pObj,
178*cdf0e10cSrcweir                                         StringList & rSuperList,
179*cdf0e10cSrcweir                                         sal_Bool bVariable )
180*cdf0e10cSrcweir {
181*cdf0e10cSrcweir     // alle Attribute der Klasse schreiben
182*cdf0e10cSrcweir     sal_uLong n ;
183*cdf0e10cSrcweir     for( n = 0; n < aAttrList.Count(); n++ )
184*cdf0e10cSrcweir     {
185*cdf0e10cSrcweir         SvMetaAttribute * pAttr = aAttrList.GetObject( n );
186*cdf0e10cSrcweir 
187*cdf0e10cSrcweir         ByteString aMangleName = pAttr->GetMangleName( bVariable );
188*cdf0e10cSrcweir         ByteString * pS = SvIdlDataBase::FindName( aMangleName, rSuperList );
189*cdf0e10cSrcweir 
190*cdf0e10cSrcweir         if( !pS && pAttr->GetExport() )
191*cdf0e10cSrcweir         {
192*cdf0e10cSrcweir             // nicht doppelt
193*cdf0e10cSrcweir             if( bVariable && pAttr->IsVariable() )
194*cdf0e10cSrcweir             {
195*cdf0e10cSrcweir                 rSuperList.Insert( new ByteString( aMangleName ), LIST_APPEND );
196*cdf0e10cSrcweir                 pAttr->FillSbxObject( rBase, pObj, bVariable );
197*cdf0e10cSrcweir             }
198*cdf0e10cSrcweir             else if( !bVariable && pAttr->IsMethod() )
199*cdf0e10cSrcweir             {
200*cdf0e10cSrcweir                 rSuperList.Insert( new ByteString( aMangleName ), LIST_APPEND );
201*cdf0e10cSrcweir                 pAttr->FillSbxObject( rBase, pObj, bVariable );
202*cdf0e10cSrcweir             }
203*cdf0e10cSrcweir         }
204*cdf0e10cSrcweir     }
205*cdf0e10cSrcweir     // alle Attribute der importierten Klassen schreiben
206*cdf0e10cSrcweir     for( n = 0; n < aClassList.Count(); n++ )
207*cdf0e10cSrcweir     {
208*cdf0e10cSrcweir         SvClassElement * pEle = aClassList.GetObject( n );
209*cdf0e10cSrcweir         SvMetaClass * pClass = pEle->GetClass();
210*cdf0e10cSrcweir         pClass->FillSbxMemberObject( rBase, pObj, rSuperList, bVariable );
211*cdf0e10cSrcweir     }
212*cdf0e10cSrcweir     // alle Attribute der Superklassen schreiben
213*cdf0e10cSrcweir     if( aSuperClass.Is() )
214*cdf0e10cSrcweir         aSuperClass->FillSbxMemberObject( rBase, pObj, rSuperList, bVariable );
215*cdf0e10cSrcweir }
216*cdf0e10cSrcweir */
217*cdf0e10cSrcweir /*************************************************************************
218*cdf0e10cSrcweir |*    SvMetaClass::FillSbxObject()
219*cdf0e10cSrcweir |*
220*cdf0e10cSrcweir |*    Beschreibung
221*cdf0e10cSrcweir *************************************************************************/
222*cdf0e10cSrcweir /*
223*cdf0e10cSrcweir void SvMetaClass::FillSbxObject( SvIdlDataBase & rBase, SbxObject * pObj )
224*cdf0e10cSrcweir {
225*cdf0e10cSrcweir     StringList aSuperList;
226*cdf0e10cSrcweir     FillSbxMemberObject( rBase, pObj, aSuperList, sal_True );
227*cdf0e10cSrcweir     FillSbxMemberObject( rBase, pObj, aSuperList, sal_False );
228*cdf0e10cSrcweir 
229*cdf0e10cSrcweir     ByteString * pStr = aSuperList.First();
230*cdf0e10cSrcweir     while( pStr )
231*cdf0e10cSrcweir     {
232*cdf0e10cSrcweir         delete pStr;
233*cdf0e10cSrcweir         pStr = aSuperList.Next();
234*cdf0e10cSrcweir     }
235*cdf0e10cSrcweir }
236*cdf0e10cSrcweir  */
237*cdf0e10cSrcweir #ifdef IDL_COMPILER
238*cdf0e10cSrcweir /*************************************************************************
239*cdf0e10cSrcweir |*    SvMetaClass::ReadAttributesSvIdl()
240*cdf0e10cSrcweir |*
241*cdf0e10cSrcweir |*    Beschreibung
242*cdf0e10cSrcweir *************************************************************************/
243*cdf0e10cSrcweir void SvMetaClass::ReadAttributesSvIdl( SvIdlDataBase & rBase,
244*cdf0e10cSrcweir                                         SvTokenStream & rInStm )
245*cdf0e10cSrcweir {
246*cdf0e10cSrcweir     SvMetaType::ReadAttributesSvIdl( rBase, rInStm );
247*cdf0e10cSrcweir     aAutomation.ReadSvIdl( SvHash_Automation(), rInStm );
248*cdf0e10cSrcweir }
249*cdf0e10cSrcweir 
250*cdf0e10cSrcweir /*************************************************************************
251*cdf0e10cSrcweir |*    SvMetaClass::WriteAttributesSvIdl()
252*cdf0e10cSrcweir |*
253*cdf0e10cSrcweir |*    Beschreibung
254*cdf0e10cSrcweir *************************************************************************/
255*cdf0e10cSrcweir void SvMetaClass::WriteAttributesSvIdl( SvIdlDataBase & rBase,
256*cdf0e10cSrcweir                                  SvStream & rOutStm, sal_uInt16 nTab )
257*cdf0e10cSrcweir {
258*cdf0e10cSrcweir     SvMetaType::WriteAttributesSvIdl( rBase, rOutStm, nTab );
259*cdf0e10cSrcweir 
260*cdf0e10cSrcweir     if( !aAutomation )
261*cdf0e10cSrcweir     {
262*cdf0e10cSrcweir         WriteTab( rOutStm, nTab );
263*cdf0e10cSrcweir         rOutStm << "//class SvMetaClass" << endl;
264*cdf0e10cSrcweir         if( !aAutomation )
265*cdf0e10cSrcweir         {
266*cdf0e10cSrcweir             WriteTab( rOutStm, nTab );
267*cdf0e10cSrcweir             aAutomation.WriteSvIdl( SvHash_Automation(), rOutStm );
268*cdf0e10cSrcweir             rOutStm << ';' << endl;
269*cdf0e10cSrcweir         }
270*cdf0e10cSrcweir     }
271*cdf0e10cSrcweir }
272*cdf0e10cSrcweir 
273*cdf0e10cSrcweir /*************************************************************************
274*cdf0e10cSrcweir |*    SvMetaClass::ReadContextSvIdl()
275*cdf0e10cSrcweir |*
276*cdf0e10cSrcweir |*    Beschreibung
277*cdf0e10cSrcweir *************************************************************************/
278*cdf0e10cSrcweir void SvMetaClass::ReadContextSvIdl( SvIdlDataBase & rBase,
279*cdf0e10cSrcweir                                     SvTokenStream & rInStm )
280*cdf0e10cSrcweir {
281*cdf0e10cSrcweir     sal_uInt32  nTokPos = rInStm.Tell();
282*cdf0e10cSrcweir     SvToken * pTok = rInStm.GetToken_Next();
283*cdf0e10cSrcweir 
284*cdf0e10cSrcweir     if( pTok->Is( SvHash_import() ) )
285*cdf0e10cSrcweir     {
286*cdf0e10cSrcweir         SvMetaClass * pClass = rBase.ReadKnownClass( rInStm );
287*cdf0e10cSrcweir         if( pClass )
288*cdf0e10cSrcweir         {
289*cdf0e10cSrcweir             SvClassElementRef xEle = new SvClassElement();
290*cdf0e10cSrcweir             xEle->SetClass( pClass );
291*cdf0e10cSrcweir             aClassList.Append( xEle );
292*cdf0e10cSrcweir 
293*cdf0e10cSrcweir             if( rInStm.Read( '[' ) )
294*cdf0e10cSrcweir             {
295*cdf0e10cSrcweir                 pTok = rInStm.GetToken_Next();
296*cdf0e10cSrcweir                 if( pTok->Is( SvHash_Automation() ) )
297*cdf0e10cSrcweir                 {
298*cdf0e10cSrcweir                     if( rInStm.Read( ']' ) )
299*cdf0e10cSrcweir                     {
300*cdf0e10cSrcweir                         if( xAutomationInterface.Is() )
301*cdf0e10cSrcweir                         {
302*cdf0e10cSrcweir                             // Fehler setzen
303*cdf0e10cSrcweir                             rBase.SetError( "Automation allready set",
304*cdf0e10cSrcweir                                             rInStm.GetToken() );
305*cdf0e10cSrcweir                             rBase.WriteError( rInStm );
306*cdf0e10cSrcweir                         }
307*cdf0e10cSrcweir                         xAutomationInterface = pClass;
308*cdf0e10cSrcweir                         xEle->SetAutomation( sal_True );
309*cdf0e10cSrcweir                     }
310*cdf0e10cSrcweir                     else
311*cdf0e10cSrcweir                     {
312*cdf0e10cSrcweir                         // Fehler setzen
313*cdf0e10cSrcweir                         rBase.SetError( "missing ]", rInStm.GetToken() );
314*cdf0e10cSrcweir                         rBase.WriteError( rInStm );
315*cdf0e10cSrcweir                     }
316*cdf0e10cSrcweir                 }
317*cdf0e10cSrcweir                 else
318*cdf0e10cSrcweir                 {
319*cdf0e10cSrcweir                     // Fehler setzen
320*cdf0e10cSrcweir                     rBase.SetError( "only attribute Automation allowed",
321*cdf0e10cSrcweir                                     rInStm.GetToken() );
322*cdf0e10cSrcweir                     rBase.WriteError( rInStm );
323*cdf0e10cSrcweir                 }
324*cdf0e10cSrcweir             }
325*cdf0e10cSrcweir             pTok = rInStm.GetToken();
326*cdf0e10cSrcweir             if( pTok->IsString() )
327*cdf0e10cSrcweir             {
328*cdf0e10cSrcweir                 xEle->SetPrefix( pTok->GetString() );
329*cdf0e10cSrcweir                 rInStm.GetToken_Next();
330*cdf0e10cSrcweir             }
331*cdf0e10cSrcweir             return;
332*cdf0e10cSrcweir         }
333*cdf0e10cSrcweir         else
334*cdf0e10cSrcweir         {
335*cdf0e10cSrcweir             // Fehler setzen
336*cdf0e10cSrcweir             rBase.SetError( "unknown imported interface", rInStm.GetToken() );
337*cdf0e10cSrcweir             rBase.WriteError( rInStm );
338*cdf0e10cSrcweir         }
339*cdf0e10cSrcweir     }
340*cdf0e10cSrcweir     else
341*cdf0e10cSrcweir     {
342*cdf0e10cSrcweir         rInStm.Seek( nTokPos );
343*cdf0e10cSrcweir         SvMetaType * pType = rBase.ReadKnownType( rInStm );
344*cdf0e10cSrcweir 
345*cdf0e10cSrcweir         sal_Bool bOk = sal_False;
346*cdf0e10cSrcweir         SvMetaAttributeRef xAttr;
347*cdf0e10cSrcweir         if( !pType || pType->IsItem() )
348*cdf0e10cSrcweir         {
349*cdf0e10cSrcweir             xAttr = new SvMetaSlot( pType );
350*cdf0e10cSrcweir             if( xAttr->ReadSvIdl( rBase, rInStm ) )
351*cdf0e10cSrcweir                 bOk = xAttr->Test( rBase, rInStm );
352*cdf0e10cSrcweir         }
353*cdf0e10cSrcweir         else
354*cdf0e10cSrcweir         {
355*cdf0e10cSrcweir             xAttr = new SvMetaAttribute( pType );
356*cdf0e10cSrcweir             if( xAttr->ReadSvIdl( rBase, rInStm ) )
357*cdf0e10cSrcweir                 bOk = xAttr->Test( rBase, rInStm );
358*cdf0e10cSrcweir         }
359*cdf0e10cSrcweir 
360*cdf0e10cSrcweir         if( bOk )
361*cdf0e10cSrcweir             bOk = TestAttribute( rBase, rInStm, *xAttr );
362*cdf0e10cSrcweir         if( bOk )
363*cdf0e10cSrcweir         {
364*cdf0e10cSrcweir             if( !xAttr->GetSlotId().IsSet() )
365*cdf0e10cSrcweir             {
366*cdf0e10cSrcweir                 SvNumberIdentifier aI;
367*cdf0e10cSrcweir                 aI.SetValue( rBase.GetUniqueId() );
368*cdf0e10cSrcweir                 xAttr->SetSlotId( aI );
369*cdf0e10cSrcweir             }
370*cdf0e10cSrcweir             aAttrList.Append( xAttr );
371*cdf0e10cSrcweir             return;
372*cdf0e10cSrcweir         }
373*cdf0e10cSrcweir     }
374*cdf0e10cSrcweir     rInStm.Seek( nTokPos );
375*cdf0e10cSrcweir }
376*cdf0e10cSrcweir 
377*cdf0e10cSrcweir /*************************************************************************
378*cdf0e10cSrcweir |*    SvMetaClass::WriteContextSvIdl()
379*cdf0e10cSrcweir |*
380*cdf0e10cSrcweir |*    Beschreibung
381*cdf0e10cSrcweir *************************************************************************/
382*cdf0e10cSrcweir void SvMetaClass::WriteContextSvIdl
383*cdf0e10cSrcweir (
384*cdf0e10cSrcweir     SvIdlDataBase & rBase,
385*cdf0e10cSrcweir     SvStream & rOutStm,
386*cdf0e10cSrcweir     sal_uInt16 nTab
387*cdf0e10cSrcweir )
388*cdf0e10cSrcweir {
389*cdf0e10cSrcweir     //SvMetaType::WriteContextSvIdl( rBase, rOutStm, nTab );
390*cdf0e10cSrcweir     sal_uLong n;
391*cdf0e10cSrcweir     for( n = 0; n < aAttrList.Count(); n++ )
392*cdf0e10cSrcweir     {
393*cdf0e10cSrcweir         WriteTab( rOutStm, nTab );
394*cdf0e10cSrcweir         aAttrList.GetObject( n )->WriteSvIdl( rBase, rOutStm, nTab );
395*cdf0e10cSrcweir         rOutStm << ';' << endl;
396*cdf0e10cSrcweir     }
397*cdf0e10cSrcweir     for( n = 0; n < aClassList.Count(); n++ )
398*cdf0e10cSrcweir     {
399*cdf0e10cSrcweir         SvClassElement * pEle = aClassList.GetObject( n );
400*cdf0e10cSrcweir         WriteTab( rOutStm, nTab );
401*cdf0e10cSrcweir         rOutStm << SvHash_import()->GetName().GetBuffer() << ' '
402*cdf0e10cSrcweir                 << pEle->GetPrefix().GetBuffer();
403*cdf0e10cSrcweir         if( pEle->GetAutomation() )
404*cdf0e10cSrcweir             rOutStm << " [ " << SvHash_Automation()->GetName().GetBuffer()
405*cdf0e10cSrcweir                     << " ]";
406*cdf0e10cSrcweir         if( pEle->GetPrefix().Len() )
407*cdf0e10cSrcweir             rOutStm << ' ' << pEle->GetPrefix().GetBuffer();
408*cdf0e10cSrcweir         rOutStm << ';' << endl;
409*cdf0e10cSrcweir     }
410*cdf0e10cSrcweir }
411*cdf0e10cSrcweir 
412*cdf0e10cSrcweir /*************************************************************************
413*cdf0e10cSrcweir |*    SvMetaClass::ReadSvIdl()
414*cdf0e10cSrcweir |*
415*cdf0e10cSrcweir |*    Beschreibung
416*cdf0e10cSrcweir *************************************************************************/
417*cdf0e10cSrcweir sal_Bool SvMetaClass::ReadSvIdl( SvIdlDataBase & rBase, SvTokenStream & rInStm )
418*cdf0e10cSrcweir {
419*cdf0e10cSrcweir     sal_uLong nTokPos = rInStm.Tell();
420*cdf0e10cSrcweir     if( SvMetaType::ReadHeaderSvIdl( rBase, rInStm ) && GetType() == TYPE_CLASS )
421*cdf0e10cSrcweir     {
422*cdf0e10cSrcweir         sal_Bool bOk = sal_True;
423*cdf0e10cSrcweir         if( rInStm.Read( ':' ) )
424*cdf0e10cSrcweir         {
425*cdf0e10cSrcweir             aSuperClass = rBase.ReadKnownClass( rInStm );
426*cdf0e10cSrcweir             bOk = aSuperClass.Is();
427*cdf0e10cSrcweir             if( !bOk )
428*cdf0e10cSrcweir             {
429*cdf0e10cSrcweir                 // Fehler setzen
430*cdf0e10cSrcweir                 rBase.SetError( "unknown super class",
431*cdf0e10cSrcweir                                 rInStm.GetToken() );
432*cdf0e10cSrcweir                 rBase.WriteError( rInStm );
433*cdf0e10cSrcweir             }
434*cdf0e10cSrcweir         }
435*cdf0e10cSrcweir         if( bOk )
436*cdf0e10cSrcweir         {
437*cdf0e10cSrcweir             rBase.Write( '.' );
438*cdf0e10cSrcweir             bOk = SvMetaName::ReadSvIdl( rBase, rInStm );
439*cdf0e10cSrcweir         }
440*cdf0e10cSrcweir         if( bOk )
441*cdf0e10cSrcweir             return bOk;
442*cdf0e10cSrcweir     }
443*cdf0e10cSrcweir     rInStm.Seek( nTokPos );
444*cdf0e10cSrcweir     return sal_False;
445*cdf0e10cSrcweir }
446*cdf0e10cSrcweir 
447*cdf0e10cSrcweir /*************************************************************************
448*cdf0e10cSrcweir |*    SvMetaClass::TestAttribute()
449*cdf0e10cSrcweir |*
450*cdf0e10cSrcweir |*    Beschreibung
451*cdf0e10cSrcweir *************************************************************************/
452*cdf0e10cSrcweir sal_Bool SvMetaClass::TestAttribute( SvIdlDataBase & rBase, SvTokenStream & rInStm,
453*cdf0e10cSrcweir                                  SvMetaAttribute & rAttr ) const
454*cdf0e10cSrcweir {
455*cdf0e10cSrcweir     if ( !rAttr.GetRef() && rAttr.IsA( TYPE( SvMetaSlot ) ) )
456*cdf0e10cSrcweir     {
457*cdf0e10cSrcweir         DBG_ERROR( "Neuer Slot : " );
458*cdf0e10cSrcweir         DBG_ERROR( rAttr.GetSlotId().GetBuffer() );
459*cdf0e10cSrcweir     }
460*cdf0e10cSrcweir 
461*cdf0e10cSrcweir     for( sal_uLong n = 0; n < aAttrList.Count(); n++ )
462*cdf0e10cSrcweir     {
463*cdf0e10cSrcweir         SvMetaAttribute * pS = aAttrList.GetObject( n );
464*cdf0e10cSrcweir         if( pS->GetName() == rAttr.GetName() )
465*cdf0e10cSrcweir         {
466*cdf0e10cSrcweir             // Werte muessen uebereinstimmen
467*cdf0e10cSrcweir             if( pS->GetSlotId().GetValue() != rAttr.GetSlotId().GetValue() )
468*cdf0e10cSrcweir             {
469*cdf0e10cSrcweir                 DBG_ERROR( "Gleicher Name in MetaClass : " );
470*cdf0e10cSrcweir                 DBG_ERROR( pS->GetName().GetBuffer() );
471*cdf0e10cSrcweir                 DBG_ERROR( pS->GetSlotId().GetBuffer() );
472*cdf0e10cSrcweir                 DBG_ERROR( rAttr.GetSlotId().GetBuffer() );
473*cdf0e10cSrcweir 
474*cdf0e10cSrcweir                 ByteString aStr( "Attribute's " );
475*cdf0e10cSrcweir                 aStr += pS->GetName();
476*cdf0e10cSrcweir                 aStr += " with different id's";
477*cdf0e10cSrcweir                 rBase.SetError( aStr, rInStm.GetToken() );
478*cdf0e10cSrcweir                 rBase.WriteError( rInStm );
479*cdf0e10cSrcweir                 return sal_False;
480*cdf0e10cSrcweir             }
481*cdf0e10cSrcweir         }
482*cdf0e10cSrcweir         else
483*cdf0e10cSrcweir         {
484*cdf0e10cSrcweir             sal_uInt32 nId1 = pS->GetSlotId().GetValue();
485*cdf0e10cSrcweir             sal_uInt32 nId2 = rAttr.GetSlotId().GetValue();
486*cdf0e10cSrcweir             if( nId1 == nId2 && nId1 != 0 /*&& nId2 != 0 ist ueberfluessig*/ )
487*cdf0e10cSrcweir             {
488*cdf0e10cSrcweir                 DBG_ERROR( "Gleiche Id in MetaClass : " );
489*cdf0e10cSrcweir                 DBG_ERROR( ByteString::CreateFromInt32( pS->GetSlotId().GetValue() ).GetBuffer() );
490*cdf0e10cSrcweir                 DBG_ERROR( pS->GetSlotId().GetBuffer() );
491*cdf0e10cSrcweir                 DBG_ERROR( rAttr.GetSlotId().GetBuffer() );
492*cdf0e10cSrcweir 
493*cdf0e10cSrcweir                 ByteString aStr( "Attribute " );
494*cdf0e10cSrcweir                 aStr += pS->GetName();
495*cdf0e10cSrcweir                 aStr += " and Attribute ";
496*cdf0e10cSrcweir                 aStr += rAttr.GetName();
497*cdf0e10cSrcweir                 aStr += " with equal id's";
498*cdf0e10cSrcweir                 rBase.SetError( aStr, rInStm.GetToken() );
499*cdf0e10cSrcweir                 rBase.WriteError( rInStm );
500*cdf0e10cSrcweir                 return sal_False;
501*cdf0e10cSrcweir             }
502*cdf0e10cSrcweir         }
503*cdf0e10cSrcweir     }
504*cdf0e10cSrcweir     SvMetaClass * pSC = aSuperClass;
505*cdf0e10cSrcweir     if( pSC )
506*cdf0e10cSrcweir         return pSC->TestAttribute( rBase, rInStm, rAttr );
507*cdf0e10cSrcweir     return sal_True;
508*cdf0e10cSrcweir }
509*cdf0e10cSrcweir 
510*cdf0e10cSrcweir /*************************************************************************
511*cdf0e10cSrcweir |*    SvMetaClass::WriteSvIdl()
512*cdf0e10cSrcweir |*
513*cdf0e10cSrcweir |*    Beschreibung
514*cdf0e10cSrcweir *************************************************************************/
515*cdf0e10cSrcweir void SvMetaClass::WriteSvIdl( SvIdlDataBase & rBase, SvStream & rOutStm,
516*cdf0e10cSrcweir                               sal_uInt16 nTab )
517*cdf0e10cSrcweir {
518*cdf0e10cSrcweir     WriteHeaderSvIdl( rBase, rOutStm, nTab );
519*cdf0e10cSrcweir     if( aSuperClass.Is() )
520*cdf0e10cSrcweir         rOutStm << " : " << aSuperClass->GetName().GetBuffer();
521*cdf0e10cSrcweir     rOutStm << endl;
522*cdf0e10cSrcweir     SvMetaName::WriteSvIdl( rBase, rOutStm, nTab );
523*cdf0e10cSrcweir     rOutStm << endl;
524*cdf0e10cSrcweir }
525*cdf0e10cSrcweir 
526*cdf0e10cSrcweir /*************************************************************************
527*cdf0e10cSrcweir |*    SvMetaClass::WriteOdlMember()
528*cdf0e10cSrcweir |*
529*cdf0e10cSrcweir |*    Beschreibung
530*cdf0e10cSrcweir *************************************************************************/
531*cdf0e10cSrcweir /*
532*cdf0e10cSrcweir void SvMetaClass::WriteOdlMembers( ByteStringList & rSuperList,
533*cdf0e10cSrcweir                                     sal_Bool bVariable, sal_Bool bWriteTab,
534*cdf0e10cSrcweir                                     SvIdlDataBase & rBase,
535*cdf0e10cSrcweir                                     SvStream & rOutStm, sal_uInt16 nTab )
536*cdf0e10cSrcweir {
537*cdf0e10cSrcweir     // alle Attribute schreiben
538*cdf0e10cSrcweir     sal_uLong n;
539*cdf0e10cSrcweir     for( n = 0; n < aAttrList.Count(); n++ )
540*cdf0e10cSrcweir     {
541*cdf0e10cSrcweir         SvMetaAttribute * pAttr = aAttrList.GetObject( n );
542*cdf0e10cSrcweir 
543*cdf0e10cSrcweir         ByteString aMangleName = pAttr->GetMangleName( bVariable );
544*cdf0e10cSrcweir         ByteString * pS = rBase.FindName( aMangleName, rSuperList );
545*cdf0e10cSrcweir 
546*cdf0e10cSrcweir         if( !pS && pAttr->GetExport() )
547*cdf0e10cSrcweir         {
548*cdf0e10cSrcweir             // nicht doppelt
549*cdf0e10cSrcweir             if( bVariable && pAttr->IsVariable() )
550*cdf0e10cSrcweir             {
551*cdf0e10cSrcweir                 rSuperList.Insert( new ByteString( aMangleName ), LIST_APPEND );
552*cdf0e10cSrcweir                 pAttr->Write( rBase, rOutStm, nTab +1, WRITE_ODL,
553*cdf0e10cSrcweir                                 WA_VARIABLE );
554*cdf0e10cSrcweir                 rOutStm << ';' << endl;
555*cdf0e10cSrcweir             }
556*cdf0e10cSrcweir             else if( !bVariable && pAttr->IsMethod() )
557*cdf0e10cSrcweir             {
558*cdf0e10cSrcweir                 rSuperList.Insert( new ByteString( aMangleName ), LIST_APPEND );
559*cdf0e10cSrcweir                 pAttr->Write( rBase, rOutStm, nTab +1, WRITE_ODL,
560*cdf0e10cSrcweir                                 WA_METHOD );
561*cdf0e10cSrcweir                 rOutStm << ';' << endl;
562*cdf0e10cSrcweir             }
563*cdf0e10cSrcweir         }
564*cdf0e10cSrcweir         else
565*cdf0e10cSrcweir             continue;
566*cdf0e10cSrcweir     }
567*cdf0e10cSrcweir     // alle Attribute der importierten Klassen schreiben
568*cdf0e10cSrcweir     for( n = 0; n < aClassList.Count(); n++ )
569*cdf0e10cSrcweir     {
570*cdf0e10cSrcweir         SvClassElement * pEle = aClassList.GetObject( n );
571*cdf0e10cSrcweir         SvMetaClass * pCl = pEle->GetClass();
572*cdf0e10cSrcweir         pCl->WriteOdlMembers( rSuperList, bVariable, bWriteTab,
573*cdf0e10cSrcweir                                 rBase, rOutStm, nTab );
574*cdf0e10cSrcweir     }
575*cdf0e10cSrcweir     // alle Attribute der Superklassen schreiben
576*cdf0e10cSrcweir     SvMetaClass * pSC = aSuperClass;
577*cdf0e10cSrcweir     if( pSC )
578*cdf0e10cSrcweir         pSC->WriteOdlMembers( rSuperList, bVariable, bWriteTab,
579*cdf0e10cSrcweir                             rBase, rOutStm, nTab );
580*cdf0e10cSrcweir }
581*cdf0e10cSrcweir  */
582*cdf0e10cSrcweir 
583*cdf0e10cSrcweir /*************************************************************************
584*cdf0e10cSrcweir |*    SvMetaClass::Write()
585*cdf0e10cSrcweir |*
586*cdf0e10cSrcweir |*    Beschreibung
587*cdf0e10cSrcweir *************************************************************************/
588*cdf0e10cSrcweir void SvMetaClass::Write( SvIdlDataBase & rBase, SvStream & rOutStm,
589*cdf0e10cSrcweir                         sal_uInt16 nTab,
590*cdf0e10cSrcweir                         WriteType nT, WriteAttribute )
591*cdf0e10cSrcweir {
592*cdf0e10cSrcweir     rBase.aIFaceName = GetName();
593*cdf0e10cSrcweir     switch( nT )
594*cdf0e10cSrcweir     {
595*cdf0e10cSrcweir         case WRITE_ODL:
596*cdf0e10cSrcweir         {
597*cdf0e10cSrcweir             DBG_ERROR( "Not supported anymore!" );
598*cdf0e10cSrcweir /*
599*cdf0e10cSrcweir             // Schreibt die Attribute
600*cdf0e10cSrcweir             SvMetaName::Write( rBase, rOutStm, nTab, nT, nA );
601*cdf0e10cSrcweir 
602*cdf0e10cSrcweir             WriteTab( rOutStm, nTab );
603*cdf0e10cSrcweir             rOutStm << "dispinterface " << GetName().GetBuffer() << endl;
604*cdf0e10cSrcweir             WriteTab( rOutStm, nTab );
605*cdf0e10cSrcweir             rOutStm << '{' << endl;
606*cdf0e10cSrcweir 
607*cdf0e10cSrcweir             WriteTab( rOutStm, nTab );
608*cdf0e10cSrcweir             rOutStm << "properties:";
609*cdf0e10cSrcweir             rOutStm << endl;
610*cdf0e10cSrcweir 
611*cdf0e10cSrcweir             StringList aSuperList;
612*cdf0e10cSrcweir             WriteOdlMembers( aSuperList, sal_True, sal_True, rBase, rOutStm, nTab );
613*cdf0e10cSrcweir 
614*cdf0e10cSrcweir             WriteTab( rOutStm, nTab );
615*cdf0e10cSrcweir             rOutStm << "methods:";
616*cdf0e10cSrcweir             rOutStm << endl;
617*cdf0e10cSrcweir 
618*cdf0e10cSrcweir             WriteOdlMembers( aSuperList, sal_False, sal_True, rBase, rOutStm, nTab );
619*cdf0e10cSrcweir 
620*cdf0e10cSrcweir             ByteString * pStr = aSuperList.First();
621*cdf0e10cSrcweir             while( pStr )
622*cdf0e10cSrcweir             {
623*cdf0e10cSrcweir                 delete pStr;
624*cdf0e10cSrcweir                 pStr = aSuperList.Next();
625*cdf0e10cSrcweir             }
626*cdf0e10cSrcweir 
627*cdf0e10cSrcweir             WriteTab( rOutStm, 1 );
628*cdf0e10cSrcweir             rOutStm << '}' << endl;
629*cdf0e10cSrcweir  */
630*cdf0e10cSrcweir             break;
631*cdf0e10cSrcweir         }
632*cdf0e10cSrcweir         case WRITE_C_SOURCE:
633*cdf0e10cSrcweir         case WRITE_C_HEADER:
634*cdf0e10cSrcweir         {
635*cdf0e10cSrcweir             DBG_ERROR( "Not supported anymore!" );
636*cdf0e10cSrcweir /*
637*cdf0e10cSrcweir             StringList aSuperList;
638*cdf0e10cSrcweir             if( nT == WRITE_C_SOURCE )
639*cdf0e10cSrcweir             {
640*cdf0e10cSrcweir                 rOutStm << "#pragma code_seg (\"" << GetName().GetBuffer()
641*cdf0e10cSrcweir                     << "\",\"CODE\")" << endl;
642*cdf0e10cSrcweir             }
643*cdf0e10cSrcweir             WriteCFunctions( aSuperList, rBase, rOutStm, nTab, nT );
644*cdf0e10cSrcweir  */
645*cdf0e10cSrcweir             break;
646*cdf0e10cSrcweir         }
647*cdf0e10cSrcweir         case WRITE_DOCU:
648*cdf0e10cSrcweir         {
649*cdf0e10cSrcweir             rOutStm << "<INTERFACE>" << endl
650*cdf0e10cSrcweir                     << GetName().GetBuffer();
651*cdf0e10cSrcweir             if ( GetAutomation() )
652*cdf0e10cSrcweir                 rOutStm << " ( Automation ) ";
653*cdf0e10cSrcweir             rOutStm << endl;
654*cdf0e10cSrcweir             WriteDescription( rOutStm );
655*cdf0e10cSrcweir             rOutStm << "</INTERFACE>" << endl << endl;
656*cdf0e10cSrcweir 
657*cdf0e10cSrcweir             // alle Attribute schreiben
658*cdf0e10cSrcweir             sal_uLong n;
659*cdf0e10cSrcweir             for( n = 0; n < aAttrList.Count(); n++ )
660*cdf0e10cSrcweir             {
661*cdf0e10cSrcweir                 SvMetaAttribute * pAttr = aAttrList.GetObject( n );
662*cdf0e10cSrcweir                 if( !pAttr->GetHidden() )
663*cdf0e10cSrcweir                 {
664*cdf0e10cSrcweir                     if( pAttr->IsMethod() )
665*cdf0e10cSrcweir                         pAttr->Write( rBase, rOutStm, nTab, nT, WA_METHOD );
666*cdf0e10cSrcweir 
667*cdf0e10cSrcweir                     if( pAttr->IsVariable() )
668*cdf0e10cSrcweir                         pAttr->Write( rBase, rOutStm, nTab, nT, WA_VARIABLE );
669*cdf0e10cSrcweir                 }
670*cdf0e10cSrcweir             }
671*cdf0e10cSrcweir 
672*cdf0e10cSrcweir             break;
673*cdf0e10cSrcweir         }
674*cdf0e10cSrcweir         default:
675*cdf0e10cSrcweir             break;
676*cdf0e10cSrcweir     }
677*cdf0e10cSrcweir }
678*cdf0e10cSrcweir 
679*cdf0e10cSrcweir /*************************************************************************
680*cdf0e10cSrcweir |*    SvMetaClass::WriteSlotParamArray()
681*cdf0e10cSrcweir |*
682*cdf0e10cSrcweir |*    Beschreibung
683*cdf0e10cSrcweir *************************************************************************/
684*cdf0e10cSrcweir sal_uInt16 SvMetaClass::WriteSlotParamArray( SvIdlDataBase & rBase,
685*cdf0e10cSrcweir                                         SvSlotElementList & rSlotList,
686*cdf0e10cSrcweir                                         SvStream & rOutStm )
687*cdf0e10cSrcweir {
688*cdf0e10cSrcweir     sal_uInt16 nCount = 0;
689*cdf0e10cSrcweir     for( sal_uLong n = 0; n < rSlotList.Count(); n++ )
690*cdf0e10cSrcweir     {
691*cdf0e10cSrcweir         SvSlotElement *pEle = rSlotList.GetObject( n );
692*cdf0e10cSrcweir         SvMetaSlot *pAttr = pEle->xSlot;
693*cdf0e10cSrcweir         nCount = nCount + pAttr->WriteSlotParamArray( rBase, rOutStm );
694*cdf0e10cSrcweir     }
695*cdf0e10cSrcweir 
696*cdf0e10cSrcweir     return nCount;
697*cdf0e10cSrcweir }
698*cdf0e10cSrcweir 
699*cdf0e10cSrcweir /*************************************************************************
700*cdf0e10cSrcweir |*    SvMetaClass::WriteSlots()
701*cdf0e10cSrcweir |*
702*cdf0e10cSrcweir |*    Beschreibung
703*cdf0e10cSrcweir *************************************************************************/
704*cdf0e10cSrcweir sal_uInt16 SvMetaClass::WriteSlots( const ByteString & rShellName,
705*cdf0e10cSrcweir                                 sal_uInt16 nCount, SvSlotElementList & rSlotList,
706*cdf0e10cSrcweir                                 SvIdlDataBase & rBase,
707*cdf0e10cSrcweir                                 SvStream & rOutStm )
708*cdf0e10cSrcweir {
709*cdf0e10cSrcweir     sal_uInt16 nSCount = 0;
710*cdf0e10cSrcweir     for( sal_uLong n = 0; n < rSlotList.Count(); n++ )
711*cdf0e10cSrcweir     {
712*cdf0e10cSrcweir         rSlotList.Seek(n);
713*cdf0e10cSrcweir         SvSlotElement * pEle = rSlotList.GetCurObject();
714*cdf0e10cSrcweir         SvMetaSlot * pAttr = pEle->xSlot;
715*cdf0e10cSrcweir         nSCount = nSCount + pAttr->WriteSlotMap( rShellName, nCount + nSCount,
716*cdf0e10cSrcweir                                         rSlotList, pEle->aPrefix, rBase,
717*cdf0e10cSrcweir                                         rOutStm );
718*cdf0e10cSrcweir     }
719*cdf0e10cSrcweir 
720*cdf0e10cSrcweir     return nSCount;
721*cdf0e10cSrcweir }
722*cdf0e10cSrcweir 
723*cdf0e10cSrcweir /*************************************************************************
724*cdf0e10cSrcweir |*    SvMetaClass::InsertSlots()
725*cdf0e10cSrcweir |*
726*cdf0e10cSrcweir |*    Beschreibung
727*cdf0e10cSrcweir *************************************************************************/
728*cdf0e10cSrcweir void SvMetaClass::InsertSlots( SvSlotElementList& rList, SvULongs& rSuperList,
729*cdf0e10cSrcweir                             SvMetaClassList &rClassList,
730*cdf0e10cSrcweir                             const ByteString & rPrefix, SvIdlDataBase& rBase)
731*cdf0e10cSrcweir {
732*cdf0e10cSrcweir     // Wurde diese Klasse schon geschrieben ?
733*cdf0e10cSrcweir     if ( rClassList.GetPos(this) != LIST_ENTRY_NOTFOUND )
734*cdf0e10cSrcweir         return;
735*cdf0e10cSrcweir 
736*cdf0e10cSrcweir     rClassList.Insert(this, LIST_APPEND);
737*cdf0e10cSrcweir 
738*cdf0e10cSrcweir     // alle direkten Attribute schreiben
739*cdf0e10cSrcweir     sal_uLong n;
740*cdf0e10cSrcweir     for( n = 0; n < aAttrList.Count(); n++ )
741*cdf0e10cSrcweir     {
742*cdf0e10cSrcweir         SvMetaAttribute * pAttr = aAttrList.GetObject( n );
743*cdf0e10cSrcweir 
744*cdf0e10cSrcweir         sal_uLong nId = pAttr->GetSlotId().GetValue();
745*cdf0e10cSrcweir         sal_uInt16 nPos;
746*cdf0e10cSrcweir         for ( nPos=0; nPos < rSuperList.Count(); nPos++ )
747*cdf0e10cSrcweir         {
748*cdf0e10cSrcweir             if ( rSuperList.GetObject(nPos) == nId )
749*cdf0e10cSrcweir                 break;
750*cdf0e10cSrcweir         }
751*cdf0e10cSrcweir 
752*cdf0e10cSrcweir         if( nPos == rSuperList.Count() )
753*cdf0e10cSrcweir         {
754*cdf0e10cSrcweir             // nur schreiben, wenn nicht schon bei SubClass oder
755*cdf0e10cSrcweir             // importiertem Interface geschrieben
756*cdf0e10cSrcweir             rSuperList.Insert( nId, nPos );
757*cdf0e10cSrcweir             pAttr->Insert(rList, rPrefix, rBase);
758*cdf0e10cSrcweir         }
759*cdf0e10cSrcweir     }
760*cdf0e10cSrcweir 
761*cdf0e10cSrcweir     // Alle schon von SuperShells importierten Interfaces sollen nicht
762*cdf0e10cSrcweir     // mehr geschrieben werden
763*cdf0e10cSrcweir     // Es ist also verboten, da\s Shell und SuperShell die gleiche Klasse
764*cdf0e10cSrcweir     // direkt importieren !
765*cdf0e10cSrcweir     if( IsShell() && aSuperClass.Is() )
766*cdf0e10cSrcweir         aSuperClass->FillClasses( rClassList );
767*cdf0e10cSrcweir 
768*cdf0e10cSrcweir     // alle Attribute der importierten Klassen schreiben, sofern diese nicht
769*cdf0e10cSrcweir     // schon von der Superklasse importiert wurden
770*cdf0e10cSrcweir     for( n = 0; n < aClassList.Count(); n++ )
771*cdf0e10cSrcweir     {
772*cdf0e10cSrcweir         SvClassElement * pEle = aClassList.GetObject( n );
773*cdf0e10cSrcweir         SvMetaClass * pCl = pEle->GetClass();
774*cdf0e10cSrcweir         ByteString rPre = rPrefix;
775*cdf0e10cSrcweir         if( rPre.Len() && pEle->GetPrefix().Len() )
776*cdf0e10cSrcweir             rPre += '.';
777*cdf0e10cSrcweir         rPre += pEle->GetPrefix();
778*cdf0e10cSrcweir 
779*cdf0e10cSrcweir         // Zun"achst die direkt importierten Interfaces schreiben
780*cdf0e10cSrcweir         pCl->InsertSlots( rList, rSuperList, rClassList, rPre, rBase );
781*cdf0e10cSrcweir     }
782*cdf0e10cSrcweir 
783*cdf0e10cSrcweir     // Superklassen nur schreiben, wenn keine Shell und nicht in der Liste
784*cdf0e10cSrcweir     if( !IsShell() && aSuperClass.Is() )
785*cdf0e10cSrcweir     {
786*cdf0e10cSrcweir         aSuperClass->InsertSlots( rList, rSuperList, rClassList, rPrefix, rBase );
787*cdf0e10cSrcweir     }
788*cdf0e10cSrcweir }
789*cdf0e10cSrcweir 
790*cdf0e10cSrcweir /*************************************************************************
791*cdf0e10cSrcweir |*    SvMetaClass::FillClasses()
792*cdf0e10cSrcweir |*
793*cdf0e10cSrcweir |*    Beschreibung
794*cdf0e10cSrcweir *************************************************************************/
795*cdf0e10cSrcweir void SvMetaClass::FillClasses( SvMetaClassList & rList )
796*cdf0e10cSrcweir {
797*cdf0e10cSrcweir     // Bin ich noch nicht drin ?
798*cdf0e10cSrcweir     if ( rList.GetPos(this) == LIST_ENTRY_NOTFOUND )
799*cdf0e10cSrcweir     {
800*cdf0e10cSrcweir         rList.Insert(this, LIST_APPEND);
801*cdf0e10cSrcweir 
802*cdf0e10cSrcweir         // Meine Imports
803*cdf0e10cSrcweir         for( sal_uLong n = 0; n < aClassList.Count(); n++ )
804*cdf0e10cSrcweir         {
805*cdf0e10cSrcweir             SvClassElement * pEle = aClassList.GetObject( n );
806*cdf0e10cSrcweir             SvMetaClass * pCl = pEle->GetClass();
807*cdf0e10cSrcweir             pCl->FillClasses( rList );
808*cdf0e10cSrcweir         }
809*cdf0e10cSrcweir 
810*cdf0e10cSrcweir         // Meine Superklasse
811*cdf0e10cSrcweir         if( aSuperClass.Is() )
812*cdf0e10cSrcweir             aSuperClass->FillClasses( rList );
813*cdf0e10cSrcweir     }
814*cdf0e10cSrcweir }
815*cdf0e10cSrcweir 
816*cdf0e10cSrcweir 
817*cdf0e10cSrcweir /*************************************************************************
818*cdf0e10cSrcweir |*    SvMetaClass::WriteSlotStubs()
819*cdf0e10cSrcweir |*
820*cdf0e10cSrcweir |*    Beschreibung
821*cdf0e10cSrcweir *************************************************************************/
822*cdf0e10cSrcweir void SvMetaClass::WriteSlotStubs( const ByteString & rShellName,
823*cdf0e10cSrcweir                                 SvSlotElementList & rSlotList,
824*cdf0e10cSrcweir                                 ByteStringList & rList,
825*cdf0e10cSrcweir                                 SvStream & rOutStm )
826*cdf0e10cSrcweir {
827*cdf0e10cSrcweir     // alle Attribute schreiben
828*cdf0e10cSrcweir     for( sal_uLong n = 0; n < rSlotList.Count(); n++ )
829*cdf0e10cSrcweir     {
830*cdf0e10cSrcweir         SvSlotElement *pEle = rSlotList.GetObject( n );
831*cdf0e10cSrcweir         SvMetaSlot *pAttr = pEle->xSlot;
832*cdf0e10cSrcweir         pAttr->WriteSlotStubs( rShellName, rList, rOutStm );
833*cdf0e10cSrcweir     }
834*cdf0e10cSrcweir }
835*cdf0e10cSrcweir 
836*cdf0e10cSrcweir /*************************************************************************
837*cdf0e10cSrcweir |*    SvMetaClass::WriteSfx()
838*cdf0e10cSrcweir |*
839*cdf0e10cSrcweir |*    Beschreibung
840*cdf0e10cSrcweir *************************************************************************/
841*cdf0e10cSrcweir void SvMetaClass::WriteSfx( SvIdlDataBase & rBase, SvStream & rOutStm )
842*cdf0e10cSrcweir {
843*cdf0e10cSrcweir     WriteStars( rOutStm );
844*cdf0e10cSrcweir     // Klasse definieren
845*cdf0e10cSrcweir     rOutStm << "#ifdef " << GetName().GetBuffer() << endl;
846*cdf0e10cSrcweir     rOutStm << "#undef ShellClass" << endl;
847*cdf0e10cSrcweir     rOutStm << "#undef " << GetName().GetBuffer() << endl;
848*cdf0e10cSrcweir     rOutStm << "#define ShellClass " << GetName().GetBuffer() << endl;
849*cdf0e10cSrcweir 
850*cdf0e10cSrcweir //    rOutStm << "SFX_TYPELIB(" << GetName().GetBuffer() << ',' << endl
851*cdf0e10cSrcweir //        << "\t/* library type */"
852*cdf0e10cSrcweir //        << '"' << ByteString( GetModule()->GetUUId().GetHexName(), RTL_TEXTENCODING_UTF8 ).GetBuffer() << "\"," << endl
853*cdf0e10cSrcweir //        << "\t\"" << GetModule()->GetTypeLibFileName().GetBuffer() << "\","
854*cdf0e10cSrcweir //        << ByteString::CreateFromInt32( GetModule()->GetVersion().GetMajorVersion() ).GetBuffer() << ','
855*cdf0e10cSrcweir //        << ByteString::CreateFromInt32( GetModule()->GetVersion().GetMinorVersion() ).GetBuffer() << ',' << endl
856*cdf0e10cSrcweir //        << "\t/* shell type   */"
857*cdf0e10cSrcweir //        << '"';
858*cdf0e10cSrcweir //    if( xAutomationInterface.Is() )
859*cdf0e10cSrcweir //        rOutStm << ByteString( xAutomationInterface->GetUUId().GetHexName(), RTL_TEXTENCODING_UTF8 ).GetBuffer();
860*cdf0e10cSrcweir //    else
861*cdf0e10cSrcweir //        rOutStm << ByteString( GetUUId().GetHexName(), RTL_TEXTENCODING_UTF8 ).GetBuffer();
862*cdf0e10cSrcweir //    rOutStm << "\");" << endl << endl;
863*cdf0e10cSrcweir 
864*cdf0e10cSrcweir     // Fuer Interfaces werden kein Slotmaps geschrieben
865*cdf0e10cSrcweir     if( !IsShell() )
866*cdf0e10cSrcweir     {
867*cdf0e10cSrcweir         rOutStm << "#endif" << endl << endl;
868*cdf0e10cSrcweir         return;
869*cdf0e10cSrcweir     }
870*cdf0e10cSrcweir     // Parameter Array schreiben
871*cdf0e10cSrcweir     //rOutStm << "SfxArgList " << GetName().GetBuffer() << "ArgMap[] = {" << endl;
872*cdf0e10cSrcweir     rOutStm << "SFX_ARGUMENTMAP(" << GetName().GetBuffer() << ')' << endl
873*cdf0e10cSrcweir         << '{' << endl;
874*cdf0e10cSrcweir 
875*cdf0e10cSrcweir     SvULongs aSuperList;
876*cdf0e10cSrcweir     SvMetaClassList classList;
877*cdf0e10cSrcweir     SvSlotElementList aSlotList;
878*cdf0e10cSrcweir     InsertSlots(aSlotList, aSuperList, classList, ByteString(), rBase);
879*cdf0e10cSrcweir     sal_uLong n;
880*cdf0e10cSrcweir     for ( n=0; n<aSlotList.Count(); n++ )
881*cdf0e10cSrcweir     {
882*cdf0e10cSrcweir         SvSlotElement *pEle = aSlotList.GetObject( n );
883*cdf0e10cSrcweir         SvMetaSlot *pSlot = pEle->xSlot;
884*cdf0e10cSrcweir         pSlot->SetListPos(n);
885*cdf0e10cSrcweir     }
886*cdf0e10cSrcweir 
887*cdf0e10cSrcweir     sal_uLong nSlotCount = aSlotList.Count();
888*cdf0e10cSrcweir 
889*cdf0e10cSrcweir     // alle Attribute schreiben
890*cdf0e10cSrcweir     sal_uInt16 nArgCount = WriteSlotParamArray( rBase, aSlotList, rOutStm );
891*cdf0e10cSrcweir     if( nArgCount )
892*cdf0e10cSrcweir         Back2Delemitter( rOutStm );
893*cdf0e10cSrcweir     else
894*cdf0e10cSrcweir     {
895*cdf0e10cSrcweir         // mindestens einen dummy
896*cdf0e10cSrcweir         WriteTab( rOutStm, 1 );
897*cdf0e10cSrcweir         rOutStm << "SFX_ARGUMENT( 0, 0, SfxVoidItem )" << endl;
898*cdf0e10cSrcweir     }
899*cdf0e10cSrcweir     rOutStm << endl << "};" << endl << endl;
900*cdf0e10cSrcweir 
901*cdf0e10cSrcweir     ByteStringList aStringList;
902*cdf0e10cSrcweir     WriteSlotStubs( GetName(), aSlotList, aStringList, rOutStm );
903*cdf0e10cSrcweir     ByteString * pStr = aStringList.First();
904*cdf0e10cSrcweir     while( pStr )
905*cdf0e10cSrcweir     {
906*cdf0e10cSrcweir         delete pStr;
907*cdf0e10cSrcweir         pStr = aStringList.Next();
908*cdf0e10cSrcweir     }
909*cdf0e10cSrcweir 
910*cdf0e10cSrcweir     rOutStm << endl;
911*cdf0e10cSrcweir 
912*cdf0e10cSrcweir     // Slotmap schreiben
913*cdf0e10cSrcweir     rOutStm << "SFX_SLOTMAP_ARG(" << GetName().GetBuffer() << ')' << endl
914*cdf0e10cSrcweir         << '{' << endl;
915*cdf0e10cSrcweir 
916*cdf0e10cSrcweir     // alle Attribute schreiben
917*cdf0e10cSrcweir     WriteSlots( GetName(), 0, aSlotList, rBase, rOutStm );
918*cdf0e10cSrcweir     if( nSlotCount )
919*cdf0e10cSrcweir         Back2Delemitter( rOutStm );
920*cdf0e10cSrcweir     else
921*cdf0e10cSrcweir     {
922*cdf0e10cSrcweir         // mindestens einen dummy
923*cdf0e10cSrcweir         WriteTab( rOutStm, 1 );
924*cdf0e10cSrcweir         rOutStm << "SFX_SLOT_ARG(" << GetName().GetBuffer()
925*cdf0e10cSrcweir                 << ", 0, 0, "
926*cdf0e10cSrcweir                 << "SFX_STUB_PTR_EXEC_NONE,"
927*cdf0e10cSrcweir                 << "SFX_STUB_PTR_STATE_NONE,"
928*cdf0e10cSrcweir                 << "0, SfxVoidItem, 0, 0, \"\", 0 )" << endl;
929*cdf0e10cSrcweir     }
930*cdf0e10cSrcweir     rOutStm << endl << "};" << endl << "#endif" << endl << endl;
931*cdf0e10cSrcweir 
932*cdf0e10cSrcweir     for( n=0; n<aSlotList.Count(); n++ )
933*cdf0e10cSrcweir     {
934*cdf0e10cSrcweir         aSlotList.Seek(n);
935*cdf0e10cSrcweir         SvSlotElement* pEle = aSlotList.GetCurObject();
936*cdf0e10cSrcweir         SvMetaSlot* pAttr = pEle->xSlot;
937*cdf0e10cSrcweir         pAttr->ResetSlotPointer();
938*cdf0e10cSrcweir     }
939*cdf0e10cSrcweir 
940*cdf0e10cSrcweir     for ( n=0; n<aSlotList.Count(); n++ )
941*cdf0e10cSrcweir         delete aSlotList.GetObject(n);
942*cdf0e10cSrcweir }
943*cdf0e10cSrcweir 
944*cdf0e10cSrcweir void SvMetaClass::WriteHelpIds( SvIdlDataBase & rBase, SvStream & rOutStm,
945*cdf0e10cSrcweir                             Table* pTable )
946*cdf0e10cSrcweir {
947*cdf0e10cSrcweir     for( sal_uLong n=0; n<aAttrList.Count(); n++ )
948*cdf0e10cSrcweir     {
949*cdf0e10cSrcweir         SvMetaAttribute * pAttr = aAttrList.GetObject( n );
950*cdf0e10cSrcweir         pAttr->WriteHelpId( rBase, rOutStm, pTable );
951*cdf0e10cSrcweir     }
952*cdf0e10cSrcweir }
953*cdf0e10cSrcweir 
954*cdf0e10cSrcweir /*************************************************************************
955*cdf0e10cSrcweir |*    SvMetaShell::WriteSrc()
956*cdf0e10cSrcweir *************************************************************************/
957*cdf0e10cSrcweir void SvMetaClass::WriteSrc( SvIdlDataBase & rBase, SvStream & rOutStm,
958*cdf0e10cSrcweir                              Table * pTable )
959*cdf0e10cSrcweir {
960*cdf0e10cSrcweir     for( sal_uLong n=0; n<aAttrList.Count(); n++ )
961*cdf0e10cSrcweir     {
962*cdf0e10cSrcweir         SvMetaAttribute * pAttr = aAttrList.GetObject( n );
963*cdf0e10cSrcweir         pAttr->WriteSrc( rBase, rOutStm, pTable );
964*cdf0e10cSrcweir     }
965*cdf0e10cSrcweir }
966*cdf0e10cSrcweir 
967*cdf0e10cSrcweir /*************************************************************************
968*cdf0e10cSrcweir |*    SvMetaClass::WriteHxx()
969*cdf0e10cSrcweir |*
970*cdf0e10cSrcweir |*    Beschreibung
971*cdf0e10cSrcweir *************************************************************************/
972*cdf0e10cSrcweir void SvMetaClass::WriteHxx( SvIdlDataBase &, SvStream & rOutStm, sal_uInt16 )
973*cdf0e10cSrcweir {
974*cdf0e10cSrcweir     ByteString aSuperName( "SvDispatch" );
975*cdf0e10cSrcweir     if( GetSuperClass() )
976*cdf0e10cSrcweir         aSuperName = GetSuperClass()->GetName();
977*cdf0e10cSrcweir     const char * pSup = aSuperName.GetBuffer();
978*cdf0e10cSrcweir 
979*cdf0e10cSrcweir     rOutStm
980*cdf0e10cSrcweir     << "class " << GetSvName().GetBuffer()
981*cdf0e10cSrcweir     << ": public " << pSup << endl
982*cdf0e10cSrcweir     << '{' << endl
983*cdf0e10cSrcweir     << "protected:" << endl
984*cdf0e10cSrcweir     << "\tvirtual SvGlobalName  GetTypeName() const;" << endl
985*cdf0e10cSrcweir     << "\tvirtual sal_Bool          FillTypeLibInfo( SvGlobalName *, sal_uInt16 * pMajor," << endl
986*cdf0e10cSrcweir     << "\t                                       sal_uInt16 * pMinor ) const;" << endl
987*cdf0e10cSrcweir     << "\tvirtual sal_Bool          FillTypeLibInfo( ByteString * pName, sal_uInt16 * pMajor," << endl;
988*cdf0e10cSrcweir     rOutStm
989*cdf0e10cSrcweir     << "\t                                       sal_uInt16 * pMinor ) const;" << endl
990*cdf0e10cSrcweir     << "\tvirtual void          Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) = 0;" << endl
991*cdf0e10cSrcweir     << "public:" << endl
992*cdf0e10cSrcweir     << "\t static SvGlobalName  ClassName()" << endl
993*cdf0e10cSrcweir     << "\t                      { return SvGlobalName( " << ByteString( GetUUId().GetctorName(), RTL_TEXTENCODING_UTF8 ).GetBuffer() << " ); }" << endl
994*cdf0e10cSrcweir     << "};" << endl;
995*cdf0e10cSrcweir }
996*cdf0e10cSrcweir 
997*cdf0e10cSrcweir /*************************************************************************
998*cdf0e10cSrcweir |*    SvMetaClass::WriteCxx()
999*cdf0e10cSrcweir |*
1000*cdf0e10cSrcweir |*    Beschreibung
1001*cdf0e10cSrcweir *************************************************************************/
1002*cdf0e10cSrcweir void SvMetaClass::WriteCxx( SvIdlDataBase &, SvStream & rOutStm, sal_uInt16 )
1003*cdf0e10cSrcweir {
1004*cdf0e10cSrcweir     ByteString aSuperName( "SvDispatch" );
1005*cdf0e10cSrcweir     if( GetSuperClass() )
1006*cdf0e10cSrcweir         aSuperName = GetSuperClass()->GetName();
1007*cdf0e10cSrcweir     const char * pSup = aSuperName.GetBuffer();
1008*cdf0e10cSrcweir 
1009*cdf0e10cSrcweir     ByteString name = GetSvName();
1010*cdf0e10cSrcweir     // GetTypeName
1011*cdf0e10cSrcweir     rOutStm << "SvGlobalName " << name.GetBuffer() << "::GetTypeName() const" << endl
1012*cdf0e10cSrcweir     << '{' << endl
1013*cdf0e10cSrcweir     << "\treturn ClassName();" << endl
1014*cdf0e10cSrcweir     << '}' << endl;
1015*cdf0e10cSrcweir 
1016*cdf0e10cSrcweir     SvMetaModule * pMod = GetModule();
1017*cdf0e10cSrcweir     // FillTypeLibInfo
1018*cdf0e10cSrcweir     rOutStm << "sal_Bool " << name.GetBuffer() << "::FillTypeLibInfo( SvGlobalName * pGN," << endl
1019*cdf0e10cSrcweir     << "\t                               sal_uInt16 * pMajor," << endl
1020*cdf0e10cSrcweir     << "\t                               sal_uInt16 * pMinor ) const" << endl
1021*cdf0e10cSrcweir     << '{' << endl
1022*cdf0e10cSrcweir     << "\tSvGlobalName aN( " << ByteString( pMod->GetUUId().GetctorName(), RTL_TEXTENCODING_UTF8 ).GetBuffer() << " );" << endl;
1023*cdf0e10cSrcweir     rOutStm << "\t*pGN = aN;" << endl
1024*cdf0e10cSrcweir     << "\t*pMajor = " << ByteString::CreateFromInt32(pMod->GetVersion().GetMajorVersion()).GetBuffer() << ';' << endl
1025*cdf0e10cSrcweir     << "\t*pMinor = " << ByteString::CreateFromInt32(pMod->GetVersion().GetMinorVersion()).GetBuffer() << ';' << endl
1026*cdf0e10cSrcweir     << "\treturn sal_True;" << endl
1027*cdf0e10cSrcweir     << '}' << endl;
1028*cdf0e10cSrcweir 
1029*cdf0e10cSrcweir     // FillTypeLibInfo
1030*cdf0e10cSrcweir     rOutStm << "sal_Bool " << name.GetBuffer() << "::FillTypeLibInfo( ByteString * pName,"
1031*cdf0e10cSrcweir     << "\t                               sal_uInt16 * pMajor," << endl
1032*cdf0e10cSrcweir     << "\t                               sal_uInt16 * pMinor ) const" << endl;
1033*cdf0e10cSrcweir     rOutStm << '{' << endl
1034*cdf0e10cSrcweir     << "\t*pName = \"" << pMod->GetTypeLibFileName().GetBuffer()  << "\";" << endl
1035*cdf0e10cSrcweir     << "\t*pMajor = " << ByteString::CreateFromInt32(pMod->GetVersion().GetMajorVersion()).GetBuffer() << ';' << endl
1036*cdf0e10cSrcweir     << "\t*pMinor = " << ByteString::CreateFromInt32(pMod->GetVersion().GetMinorVersion()).GetBuffer() << ';' << endl
1037*cdf0e10cSrcweir     << "\treturn sal_True;" << endl
1038*cdf0e10cSrcweir     << '}' << endl;
1039*cdf0e10cSrcweir 
1040*cdf0e10cSrcweir     rOutStm << "void " << name.GetBuffer() << "::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )" << endl
1041*cdf0e10cSrcweir     << '{' << endl
1042*cdf0e10cSrcweir     << "\t" << pSup << "::Notify( rBC, rHint );" << endl
1043*cdf0e10cSrcweir     << '}' << endl;
1044*cdf0e10cSrcweir }
1045*cdf0e10cSrcweir 
1046*cdf0e10cSrcweir #endif // IDL_COMPILER
1047*cdf0e10cSrcweir 
1048