xref: /aoo42x/main/idl/source/objects/module.cxx (revision 79aad27f)
1*724893d4SAndrew Rist /**************************************************************
2*724893d4SAndrew Rist  *
3*724893d4SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*724893d4SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*724893d4SAndrew Rist  * distributed with this work for additional information
6*724893d4SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*724893d4SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*724893d4SAndrew Rist  * "License"); you may not use this file except in compliance
9*724893d4SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*724893d4SAndrew Rist  *
11*724893d4SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*724893d4SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*724893d4SAndrew Rist  * software distributed under the License is distributed on an
15*724893d4SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*724893d4SAndrew Rist  * KIND, either express or implied.  See the License for the
17*724893d4SAndrew Rist  * specific language governing permissions and limitations
18*724893d4SAndrew Rist  * under the License.
19*724893d4SAndrew Rist  *
20*724893d4SAndrew Rist  *************************************************************/
21*724893d4SAndrew Rist 
22*724893d4SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_idl.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <ctype.h>
28cdf0e10cSrcweir #include <stdio.h>
29cdf0e10cSrcweir 
30cdf0e10cSrcweir #include <attrib.hxx>
31cdf0e10cSrcweir #include <module.hxx>
32cdf0e10cSrcweir #include <globals.hxx>
33cdf0e10cSrcweir #include <database.hxx>
34cdf0e10cSrcweir #include <tools/fsys.hxx>
35cdf0e10cSrcweir #include <tools/debug.hxx>
36cdf0e10cSrcweir 
37cdf0e10cSrcweir /****************** SvMetaModule ******************************************/
38cdf0e10cSrcweir SV_IMPL_META_FACTORY1( SvMetaModule, SvMetaExtern );
39cdf0e10cSrcweir 
40cdf0e10cSrcweir /*************************************************************************
41cdf0e10cSrcweir |*
42cdf0e10cSrcweir |*    SvMetaModule::SvMetaModule()
43cdf0e10cSrcweir |*
44cdf0e10cSrcweir |*    Beschreibung
45cdf0e10cSrcweir |*    Ersterstellung    MM 12.12.94
46cdf0e10cSrcweir |*    Letzte Aenderung  MM 12.12.94
47cdf0e10cSrcweir |*
48cdf0e10cSrcweir *************************************************************************/
SvMetaModule()49cdf0e10cSrcweir SvMetaModule::SvMetaModule()
50cdf0e10cSrcweir #ifdef IDL_COMPILER
51cdf0e10cSrcweir     : bImported( sal_False )
52cdf0e10cSrcweir     , bIsModified( sal_False )
53cdf0e10cSrcweir #endif
54cdf0e10cSrcweir {
55cdf0e10cSrcweir }
56cdf0e10cSrcweir 
57cdf0e10cSrcweir #ifdef IDL_COMPILER
SvMetaModule(const String & rIdlFileName,sal_Bool bImp)58cdf0e10cSrcweir SvMetaModule::SvMetaModule( const String & rIdlFileName, sal_Bool bImp )
59cdf0e10cSrcweir     : aIdlFileName( rIdlFileName )
60cdf0e10cSrcweir     , bImported( bImp ), bIsModified( sal_False )
61cdf0e10cSrcweir {
62cdf0e10cSrcweir }
63cdf0e10cSrcweir #endif
64cdf0e10cSrcweir 
65cdf0e10cSrcweir /*************************************************************************
66cdf0e10cSrcweir |*
67cdf0e10cSrcweir |*    SvMetaModule::Load()
68cdf0e10cSrcweir |*
69cdf0e10cSrcweir |*    Beschreibung
70cdf0e10cSrcweir |*    Ersterstellung    MM 12.12.94
71cdf0e10cSrcweir |*    Letzte Aenderung  MM 12.12.94
72cdf0e10cSrcweir |*
73cdf0e10cSrcweir *************************************************************************/
74cdf0e10cSrcweir #define MODULE_VER      0x0001
Load(SvPersistStream & rStm)75cdf0e10cSrcweir void SvMetaModule::Load( SvPersistStream & rStm )
76cdf0e10cSrcweir {
77cdf0e10cSrcweir     bImported = sal_True; // immer importiert
78cdf0e10cSrcweir     SvMetaExtern::Load( rStm );
79cdf0e10cSrcweir 
80cdf0e10cSrcweir     sal_uInt16 nVer;
81cdf0e10cSrcweir 
82cdf0e10cSrcweir     rStm >> nVer; // Version
83cdf0e10cSrcweir     DBG_ASSERT( (nVer & ~IDL_WRITE_MASK) == MODULE_VER, "false version" );
84cdf0e10cSrcweir 
85cdf0e10cSrcweir     rStm >> aClassList;
86cdf0e10cSrcweir     rStm >> aTypeList;
87cdf0e10cSrcweir     rStm >> aAttrList;
88cdf0e10cSrcweir     // Browser
89cdf0e10cSrcweir     rStm.ReadByteString( aIdlFileName );
90cdf0e10cSrcweir     rStm.ReadByteString( aHelpFileName );
91cdf0e10cSrcweir     rStm.ReadByteString( aSlotIdFile );
92cdf0e10cSrcweir     rStm.ReadByteString( aModulePrefix );
93cdf0e10cSrcweir 
94cdf0e10cSrcweir     // Compiler Daten lesen
95cdf0e10cSrcweir     sal_uInt16 nCmpLen;
96cdf0e10cSrcweir     rStm >> nCmpLen;
97cdf0e10cSrcweir #ifdef IDL_COMPILER
98cdf0e10cSrcweir     DBG_ASSERT( (nVer & IDL_WRITE_MASK) == IDL_WRITE_COMPILER,
99cdf0e10cSrcweir                 "no idl compiler format" );
100cdf0e10cSrcweir     rStm >> aBeginName;
101cdf0e10cSrcweir     rStm >> aEndName;
102cdf0e10cSrcweir     rStm >> aNextName;
103cdf0e10cSrcweir #else
104cdf0e10cSrcweir     rStm->SeekRel( nCmpLen );
105cdf0e10cSrcweir #endif
106cdf0e10cSrcweir }
107cdf0e10cSrcweir 
108cdf0e10cSrcweir /*************************************************************************
109cdf0e10cSrcweir |*
110cdf0e10cSrcweir |*    SvMetaModule::Save()
111cdf0e10cSrcweir |*
112cdf0e10cSrcweir |*    Beschreibung
113cdf0e10cSrcweir |*    Ersterstellung    MM 12.12.94
114cdf0e10cSrcweir |*    Letzte Aenderung  MM 12.12.94
115cdf0e10cSrcweir |*
116cdf0e10cSrcweir *************************************************************************/
Save(SvPersistStream & rStm)117cdf0e10cSrcweir void SvMetaModule::Save( SvPersistStream & rStm )
118cdf0e10cSrcweir {
119cdf0e10cSrcweir     SvMetaExtern::Save( rStm );
120cdf0e10cSrcweir 
121cdf0e10cSrcweir     rStm << (sal_uInt16)(MODULE_VER | IDL_WRITE_COMPILER); // Version
122cdf0e10cSrcweir 
123cdf0e10cSrcweir     rStm << aClassList;
124cdf0e10cSrcweir     rStm << aTypeList;
125cdf0e10cSrcweir     rStm << aAttrList;
126cdf0e10cSrcweir     // Browser
127cdf0e10cSrcweir     rStm.WriteByteString( aIdlFileName );
128cdf0e10cSrcweir     rStm.WriteByteString( aHelpFileName );
129cdf0e10cSrcweir     rStm.WriteByteString( aSlotIdFile );
130cdf0e10cSrcweir     rStm.WriteByteString( aModulePrefix );
131cdf0e10cSrcweir 
132cdf0e10cSrcweir     // Compiler Daten schreiben
133cdf0e10cSrcweir     sal_uInt16 nCmpLen = 0;
134cdf0e10cSrcweir     sal_uLong nLenPos = rStm.Tell();
135cdf0e10cSrcweir     rStm << nCmpLen;
136cdf0e10cSrcweir #ifdef IDL_COMPILER
137cdf0e10cSrcweir     rStm << aBeginName;
138cdf0e10cSrcweir     rStm << aEndName;
139cdf0e10cSrcweir     rStm << aNextName;
140cdf0e10cSrcweir     // Laenge der Compiler Daten schreiben
141cdf0e10cSrcweir     sal_uLong nPos = rStm.Tell();
142cdf0e10cSrcweir     rStm.Seek( nLenPos );
143cdf0e10cSrcweir     rStm << (sal_uInt16)( nPos - nLenPos - sizeof( sal_uInt16 ) );
144cdf0e10cSrcweir     rStm.Seek( nPos );
145cdf0e10cSrcweir #endif
146cdf0e10cSrcweir }
147cdf0e10cSrcweir 
148cdf0e10cSrcweir /*************************************************************************
149cdf0e10cSrcweir |*
150cdf0e10cSrcweir |*    SvMetaModule::SetName()
151cdf0e10cSrcweir |*
152cdf0e10cSrcweir |*    Beschreibung
153cdf0e10cSrcweir |*    Ersterstellung    MM 12.12.94
154cdf0e10cSrcweir |*    Letzte Aenderung  MM 12.12.94
155cdf0e10cSrcweir |*
156cdf0e10cSrcweir *************************************************************************/
SetName(const ByteString & rName,SvIdlDataBase * pBase)157cdf0e10cSrcweir sal_Bool SvMetaModule::SetName( const ByteString & rName, SvIdlDataBase * pBase )
158cdf0e10cSrcweir {
159cdf0e10cSrcweir     if( pBase )
160cdf0e10cSrcweir     {
161cdf0e10cSrcweir         if( pBase->GetModule( rName ) )
162cdf0e10cSrcweir             return sal_False;
163cdf0e10cSrcweir     }
164cdf0e10cSrcweir     return SvMetaExtern::SetName( rName );
165cdf0e10cSrcweir }
166cdf0e10cSrcweir 
167cdf0e10cSrcweir #ifdef IDL_COMPILER
168cdf0e10cSrcweir /*************************************************************************
169cdf0e10cSrcweir |*    SvMetaModule::GetNextName()
170cdf0e10cSrcweir |*
171cdf0e10cSrcweir |*    Beschreibung
172cdf0e10cSrcweir *************************************************************************/
FillNextName(SvGlobalName * pName)173cdf0e10cSrcweir sal_Bool SvMetaModule::FillNextName( SvGlobalName * pName )
174cdf0e10cSrcweir {
175cdf0e10cSrcweir     *pName = aNextName;
176cdf0e10cSrcweir 
177cdf0e10cSrcweir     if( aNextName < aEndName )
178cdf0e10cSrcweir     {
179cdf0e10cSrcweir         ++aNextName;
180cdf0e10cSrcweir         bIsModified = sal_True;
181cdf0e10cSrcweir         return sal_True;
182cdf0e10cSrcweir     }
183cdf0e10cSrcweir     return sal_False;
184cdf0e10cSrcweir }
185cdf0e10cSrcweir 
186cdf0e10cSrcweir /*************************************************************************
187cdf0e10cSrcweir |*    SvMetaModule::ReadSvIdl()
188cdf0e10cSrcweir |*
189cdf0e10cSrcweir |*    Beschreibung
190cdf0e10cSrcweir *************************************************************************/
ReadAttributesSvIdl(SvIdlDataBase & rBase,SvTokenStream & rInStm)191cdf0e10cSrcweir void SvMetaModule::ReadAttributesSvIdl( SvIdlDataBase & rBase,
192cdf0e10cSrcweir                                         SvTokenStream & rInStm )
193cdf0e10cSrcweir {
194cdf0e10cSrcweir     SvMetaExtern::ReadAttributesSvIdl( rBase, rInStm );
195cdf0e10cSrcweir 
196cdf0e10cSrcweir     aHelpFileName.ReadSvIdl( SvHash_HelpFile(), rInStm );
197cdf0e10cSrcweir     if( aSlotIdFile.ReadSvIdl( SvHash_SlotIdFile(), rInStm ) )
198cdf0e10cSrcweir     {
199cdf0e10cSrcweir 	    sal_uInt32 nTokPos = rInStm.Tell();
200cdf0e10cSrcweir         if( !rBase.ReadIdFile( String::CreateFromAscii( aSlotIdFile.GetBuffer() ) ) )
201cdf0e10cSrcweir         {
202cdf0e10cSrcweir             ByteString aStr = "cannot read file: ";
203cdf0e10cSrcweir             aStr += aSlotIdFile;
204cdf0e10cSrcweir             rBase.SetError( aStr, rInStm.GetToken() );
205cdf0e10cSrcweir             rBase.WriteError( rInStm );
206cdf0e10cSrcweir 
207cdf0e10cSrcweir             rInStm.Seek( nTokPos );
208cdf0e10cSrcweir         }
209cdf0e10cSrcweir     }
210cdf0e10cSrcweir     aTypeLibFile.ReadSvIdl( SvHash_TypeLibFile(), rInStm );
211cdf0e10cSrcweir 	aModulePrefix.ReadSvIdl( SvHash_ModulePrefix(), rInStm );
212cdf0e10cSrcweir }
213cdf0e10cSrcweir 
214cdf0e10cSrcweir /*************************************************************************
215cdf0e10cSrcweir |*    SvMetaModule::WriteAttributesSvIdl()
216cdf0e10cSrcweir |*
217cdf0e10cSrcweir |*    Beschreibung
218cdf0e10cSrcweir *************************************************************************/
WriteAttributesSvIdl(SvIdlDataBase & rBase,SvStream & rOutStm,sal_uInt16 nTab)219cdf0e10cSrcweir void SvMetaModule::WriteAttributesSvIdl( SvIdlDataBase & rBase,
220cdf0e10cSrcweir                                          SvStream & rOutStm,
221cdf0e10cSrcweir                                          sal_uInt16 nTab )
222cdf0e10cSrcweir {
223cdf0e10cSrcweir     SvMetaExtern::WriteAttributesSvIdl( rBase, rOutStm, nTab );
224cdf0e10cSrcweir     if( aTypeLibFile.Len() || aSlotIdFile.Len() || aTypeLibFile.Len() )
225cdf0e10cSrcweir 	{
226cdf0e10cSrcweir 	    if( aHelpFileName.Len() )
227cdf0e10cSrcweir 	    {
228cdf0e10cSrcweir 		    WriteTab( rOutStm, nTab );
229cdf0e10cSrcweir 	        aHelpFileName.WriteSvIdl( SvHash_HelpFile(), rOutStm, nTab +1 );
230cdf0e10cSrcweir 	        rOutStm << ';' << endl;
231cdf0e10cSrcweir 	    }
232cdf0e10cSrcweir 	    if( aSlotIdFile.Len() )
233cdf0e10cSrcweir 	    {
234cdf0e10cSrcweir 	        WriteTab( rOutStm, nTab );
235cdf0e10cSrcweir 	        aSlotIdFile.WriteSvIdl( SvHash_SlotIdFile(), rOutStm, nTab +1 );
236cdf0e10cSrcweir 	        rOutStm << ';' << endl;
237cdf0e10cSrcweir 	    }
238cdf0e10cSrcweir 	    if( aTypeLibFile.Len() )
239cdf0e10cSrcweir 	    {
240cdf0e10cSrcweir 	        WriteTab( rOutStm, nTab );
241cdf0e10cSrcweir 	        aTypeLibFile.WriteSvIdl( SvHash_TypeLibFile(), rOutStm, nTab +1 );
242cdf0e10cSrcweir 	        rOutStm << ';' << endl;
243cdf0e10cSrcweir 	    }
244cdf0e10cSrcweir 	}
245cdf0e10cSrcweir }
246cdf0e10cSrcweir 
247cdf0e10cSrcweir /*************************************************************************
248cdf0e10cSrcweir |*    SvMetaModule::ReadContextSvIdl()
249cdf0e10cSrcweir |*
250cdf0e10cSrcweir |*    Beschreibung
251cdf0e10cSrcweir *************************************************************************/
ReadContextSvIdl(SvIdlDataBase & rBase,SvTokenStream & rInStm)252cdf0e10cSrcweir void SvMetaModule::ReadContextSvIdl( SvIdlDataBase & rBase,
253cdf0e10cSrcweir                                      SvTokenStream & rInStm )
254cdf0e10cSrcweir {
255cdf0e10cSrcweir     sal_uInt32  nTokPos = rInStm.Tell();
256cdf0e10cSrcweir     if( rInStm.GetToken()->Is( SvHash_interface() )
257cdf0e10cSrcweir       || rInStm.GetToken()->Is( SvHash_shell() ) )
258cdf0e10cSrcweir     {
259cdf0e10cSrcweir         SvMetaClassRef aClass = new SvMetaClass();
260cdf0e10cSrcweir         if( aClass->ReadSvIdl( rBase, rInStm ) )
261cdf0e10cSrcweir         {
262cdf0e10cSrcweir             aClassList.Append( aClass );
263cdf0e10cSrcweir             // Global bekanntgeben
264cdf0e10cSrcweir             rBase.GetClassList().Append( aClass );
265cdf0e10cSrcweir         }
266cdf0e10cSrcweir     }
267cdf0e10cSrcweir     else if( rInStm.GetToken()->Is( SvHash_enum() ) )
268cdf0e10cSrcweir     {
269cdf0e10cSrcweir         SvMetaTypeEnumRef aEnum = new SvMetaTypeEnum();
270cdf0e10cSrcweir 
271cdf0e10cSrcweir         if( aEnum->ReadSvIdl( rBase, rInStm ) )
272cdf0e10cSrcweir         {
273cdf0e10cSrcweir             // Im Modul deklariert
274cdf0e10cSrcweir             aTypeList.Append( aEnum );
275cdf0e10cSrcweir             // Global bekanntgeben
276cdf0e10cSrcweir             rBase.GetTypeList().Append( aEnum );
277cdf0e10cSrcweir         }
278cdf0e10cSrcweir     }
279cdf0e10cSrcweir     else if( rInStm.GetToken()->Is( SvHash_item() )
280cdf0e10cSrcweir       || rInStm.GetToken()->Is( SvHash_struct() )
281cdf0e10cSrcweir       || rInStm.GetToken()->Is( SvHash_typedef() ) )
282cdf0e10cSrcweir     {
283cdf0e10cSrcweir         SvMetaTypeRef xItem = new SvMetaType();
284cdf0e10cSrcweir 
285cdf0e10cSrcweir         if( xItem->ReadSvIdl( rBase, rInStm ) )
286cdf0e10cSrcweir         {
287cdf0e10cSrcweir             // Im Modul deklariert
288cdf0e10cSrcweir             aTypeList.Append( xItem );
289cdf0e10cSrcweir             // Global bekanntgeben
290cdf0e10cSrcweir             rBase.GetTypeList().Append( xItem );
291cdf0e10cSrcweir         }
292cdf0e10cSrcweir     }
293cdf0e10cSrcweir     else if( rInStm.GetToken()->Is( SvHash_include() ) )
294cdf0e10cSrcweir     {
295cdf0e10cSrcweir         sal_Bool bOk = sal_False;
296cdf0e10cSrcweir         rInStm.GetToken_Next();
297cdf0e10cSrcweir         SvToken * pTok = rInStm.GetToken_Next();
298cdf0e10cSrcweir         if( pTok->IsString() )
299cdf0e10cSrcweir         {
300cdf0e10cSrcweir             DirEntry aFullName( String::CreateFromAscii( pTok->GetString().GetBuffer() ) );
301cdf0e10cSrcweir 			rBase.StartNewFile( aFullName.GetFull() );
302cdf0e10cSrcweir             if( aFullName.Find( rBase.GetPath() ) )
303cdf0e10cSrcweir             {
304cdf0e10cSrcweir                 SvTokenStream aTokStm( aFullName.GetFull() );
305cdf0e10cSrcweir                 if( SVSTREAM_OK == aTokStm.GetStream().GetError() )
306cdf0e10cSrcweir                 {
307cdf0e10cSrcweir 					// Fehler aus alter Datei retten
308cdf0e10cSrcweir 					SvIdlError aOldErr = rBase.GetError();
309cdf0e10cSrcweir 					// Fehler zuruecksetzen
310cdf0e10cSrcweir 					rBase.SetError( SvIdlError() );
311cdf0e10cSrcweir 
312cdf0e10cSrcweir                     sal_uInt32 nBeginPos = 0xFFFFFFFF; // kann mit Tell nicht vorkommen
313cdf0e10cSrcweir                     while( nBeginPos != aTokStm.Tell() )
314cdf0e10cSrcweir                     {
315cdf0e10cSrcweir                         nBeginPos = aTokStm.Tell();
316cdf0e10cSrcweir                         ReadContextSvIdl( rBase, aTokStm );
317cdf0e10cSrcweir                         aTokStm.ReadDelemiter();
318cdf0e10cSrcweir                     }
319cdf0e10cSrcweir                     bOk = aTokStm.GetToken()->IsEof();
320cdf0e10cSrcweir                     if( !bOk )
321cdf0e10cSrcweir                     {
322cdf0e10cSrcweir                         rBase.WriteError( aTokStm );
323cdf0e10cSrcweir                     }
324cdf0e10cSrcweir 					// Fehler aus alter Datei wieder herstellen
325cdf0e10cSrcweir 					rBase.SetError( aOldErr );
326cdf0e10cSrcweir                 }
327cdf0e10cSrcweir                 else
328cdf0e10cSrcweir                 {
329cdf0e10cSrcweir                     ByteString aStr = "cannot open file: ";
330cdf0e10cSrcweir                     aStr += ByteString( aFullName.GetFull(), RTL_TEXTENCODING_UTF8 );
331cdf0e10cSrcweir                     rBase.SetError( aStr, pTok );
332cdf0e10cSrcweir                 }
333cdf0e10cSrcweir             }
334cdf0e10cSrcweir             else
335cdf0e10cSrcweir             {
336cdf0e10cSrcweir                 ByteString aStr = "cannot find file: ";
337cdf0e10cSrcweir                 aStr += ByteString( aFullName.GetFull(), RTL_TEXTENCODING_UTF8 );
338cdf0e10cSrcweir                 rBase.SetError( aStr, pTok );
339cdf0e10cSrcweir             }
340cdf0e10cSrcweir         }
341cdf0e10cSrcweir         if( !bOk )
342cdf0e10cSrcweir             rInStm.Seek( nTokPos );
343cdf0e10cSrcweir     }
344cdf0e10cSrcweir     else
345cdf0e10cSrcweir     {
346cdf0e10cSrcweir         SvMetaSlotRef xSlot = new SvMetaSlot();
347cdf0e10cSrcweir 
348cdf0e10cSrcweir         if( xSlot->ReadSvIdl( rBase, rInStm ) )
349cdf0e10cSrcweir         {
350cdf0e10cSrcweir 	    	if( xSlot->Test( rBase, rInStm ) )
351cdf0e10cSrcweir 			{
352cdf0e10cSrcweir 	            // Im Modul deklariert
353cdf0e10cSrcweir 	            aAttrList.Append( xSlot );
354cdf0e10cSrcweir 	            // Global bekanntgeben
355cdf0e10cSrcweir 	            rBase.AppendAttr( xSlot );
356cdf0e10cSrcweir 			}
357cdf0e10cSrcweir         }
358cdf0e10cSrcweir     }
359cdf0e10cSrcweir }
360cdf0e10cSrcweir 
361cdf0e10cSrcweir /*************************************************************************
362cdf0e10cSrcweir |*    SvMetaModule::WriteContextSvIdl()
363cdf0e10cSrcweir |*
364cdf0e10cSrcweir |*    Beschreibung
365cdf0e10cSrcweir *************************************************************************/
WriteContextSvIdl(SvIdlDataBase & rBase,SvStream & rOutStm,sal_uInt16 nTab)366cdf0e10cSrcweir void SvMetaModule::WriteContextSvIdl( SvIdlDataBase & rBase,
367cdf0e10cSrcweir                                       SvStream & rOutStm,
368cdf0e10cSrcweir                                       sal_uInt16 nTab )
369cdf0e10cSrcweir {
370cdf0e10cSrcweir     SvMetaExtern::WriteContextSvIdl( rBase, rOutStm, nTab );
371cdf0e10cSrcweir 	sal_uLong n;
372cdf0e10cSrcweir     for( n = 0; n < aTypeList.Count(); n++ )
373cdf0e10cSrcweir     {
374cdf0e10cSrcweir         WriteTab( rOutStm, nTab );
375cdf0e10cSrcweir         aTypeList.GetObject( n )->WriteSvIdl( rBase, rOutStm, nTab );
376cdf0e10cSrcweir     }
377cdf0e10cSrcweir 	rOutStm << endl;
378cdf0e10cSrcweir     for( n = 0; n < aAttrList.Count(); n++ )
379cdf0e10cSrcweir     {
380cdf0e10cSrcweir         WriteTab( rOutStm, nTab );
381cdf0e10cSrcweir         aAttrList.GetObject( n )->WriteSvIdl( rBase, rOutStm, nTab );
382cdf0e10cSrcweir     }
383cdf0e10cSrcweir 	rOutStm << endl;
384cdf0e10cSrcweir     for( n = 0; n < aClassList.Count(); n++ )
385cdf0e10cSrcweir     {
386cdf0e10cSrcweir         WriteTab( rOutStm, nTab );
387cdf0e10cSrcweir         aClassList.GetObject( n )->WriteSvIdl( rBase, rOutStm, nTab );
388cdf0e10cSrcweir     }
389cdf0e10cSrcweir }
390cdf0e10cSrcweir 
391cdf0e10cSrcweir /*************************************************************************
392cdf0e10cSrcweir |*
393cdf0e10cSrcweir |*    SvMetaModule::ReadSvIdl()
394cdf0e10cSrcweir |*
395cdf0e10cSrcweir |*    Beschreibung
396cdf0e10cSrcweir |*
397cdf0e10cSrcweir *************************************************************************/
ReadSvIdl(SvIdlDataBase & rBase,SvTokenStream & rInStm)398cdf0e10cSrcweir sal_Bool SvMetaModule::ReadSvIdl( SvIdlDataBase & rBase, SvTokenStream & rInStm )
399cdf0e10cSrcweir {
400cdf0e10cSrcweir     bIsModified = sal_True; // bisher immer wenn Compiler laueft
401cdf0e10cSrcweir 
402cdf0e10cSrcweir     sal_uInt32  nTokPos = rInStm.Tell();
403cdf0e10cSrcweir     SvToken * pTok  = rInStm.GetToken_Next();
404cdf0e10cSrcweir     sal_Bool bOk        = sal_False;
405cdf0e10cSrcweir     bOk = pTok->Is( SvHash_module() );
406cdf0e10cSrcweir     if( bOk )
407cdf0e10cSrcweir     {
408cdf0e10cSrcweir         pTok = rInStm.GetToken_Next();
409cdf0e10cSrcweir         if( pTok->IsString() )
410cdf0e10cSrcweir              bOk = aBeginName.MakeId( String::CreateFromAscii( pTok->GetString().GetBuffer() ) );
411cdf0e10cSrcweir     }
412cdf0e10cSrcweir     rInStm.ReadDelemiter();
413cdf0e10cSrcweir     if( bOk )
414cdf0e10cSrcweir     {
415cdf0e10cSrcweir         pTok = rInStm.GetToken_Next();
416cdf0e10cSrcweir         if( pTok->IsString() )
417cdf0e10cSrcweir              bOk = aEndName.MakeId( String::CreateFromAscii( pTok->GetString().GetBuffer() ) );
418cdf0e10cSrcweir     }
419cdf0e10cSrcweir     rInStm.ReadDelemiter();
420cdf0e10cSrcweir     if( bOk )
421cdf0e10cSrcweir     {
422cdf0e10cSrcweir         aNextName = aBeginName;
423cdf0e10cSrcweir 
424cdf0e10cSrcweir         rBase.Push( this ); // auf den Context Stack
425cdf0e10cSrcweir 
426cdf0e10cSrcweir         if( ReadNameSvIdl( rBase, rInStm ) )
427cdf0e10cSrcweir         {
428cdf0e10cSrcweir             // Zeiger auf sich selbst setzen
429cdf0e10cSrcweir 			SetModule( rBase );
430cdf0e10cSrcweir             bOk = SvMetaName::ReadSvIdl( rBase, rInStm );
431cdf0e10cSrcweir         }
432cdf0e10cSrcweir         rBase.GetStack().Pop(); // und runter
433cdf0e10cSrcweir     }
434cdf0e10cSrcweir     if( !bOk )
435cdf0e10cSrcweir         rInStm.Seek( nTokPos );
436cdf0e10cSrcweir     return bOk;
437cdf0e10cSrcweir }
438cdf0e10cSrcweir 
439cdf0e10cSrcweir /*************************************************************************
440cdf0e10cSrcweir |*
441cdf0e10cSrcweir |*    SvMetaModule::WriteSvIdl()
442cdf0e10cSrcweir |*
443cdf0e10cSrcweir |*    Beschreibung
444cdf0e10cSrcweir |*
445cdf0e10cSrcweir *************************************************************************/
WriteSvIdl(SvIdlDataBase & rBase,SvStream & rOutStm,sal_uInt16 nTab)446cdf0e10cSrcweir void SvMetaModule::WriteSvIdl( SvIdlDataBase & rBase, SvStream & rOutStm,
447cdf0e10cSrcweir                                sal_uInt16 nTab )
448cdf0e10cSrcweir {
449cdf0e10cSrcweir     rOutStm << SvHash_module()->GetName().GetBuffer() << endl
450cdf0e10cSrcweir             << '\"';
451cdf0e10cSrcweir     rOutStm.WriteByteString( aBeginName.GetHexName() );
452cdf0e10cSrcweir     rOutStm << '\"' << endl << '\"';
453cdf0e10cSrcweir     rOutStm.WriteByteString( aEndName.GetHexName() );
454cdf0e10cSrcweir     rOutStm << '\"' << endl;
455cdf0e10cSrcweir     SvMetaExtern::WriteSvIdl( rBase, rOutStm, nTab );
456cdf0e10cSrcweir }
457cdf0e10cSrcweir 
458cdf0e10cSrcweir /*************************************************************************
459cdf0e10cSrcweir |*    SvMetaModule::WriteSfx()
460cdf0e10cSrcweir *************************************************************************/
WriteSfx(SvIdlDataBase & rBase,SvStream & rOutStm)461cdf0e10cSrcweir void SvMetaModule::WriteSfx( SvIdlDataBase & rBase, SvStream & rOutStm )
462cdf0e10cSrcweir {
463cdf0e10cSrcweir     for( sal_uLong n = 0; n < aClassList.Count(); n++ )
464cdf0e10cSrcweir 	{
465cdf0e10cSrcweir         SvMetaClass * pClass = aClassList.GetObject( n );
466cdf0e10cSrcweir 		pClass->WriteSfx( rBase, rOutStm );
467cdf0e10cSrcweir 	}
468cdf0e10cSrcweir }
469cdf0e10cSrcweir 
WriteHelpIds(SvIdlDataBase & rBase,SvStream & rOutStm,Table * pTable)470cdf0e10cSrcweir void SvMetaModule::WriteHelpIds( SvIdlDataBase & rBase, SvStream & rOutStm,
471cdf0e10cSrcweir 							Table* pTable )
472cdf0e10cSrcweir {
473cdf0e10cSrcweir     for( sal_uLong n = 0; n < aClassList.Count(); n++ )
474cdf0e10cSrcweir 	{
475cdf0e10cSrcweir         SvMetaClass * pClass = aClassList.GetObject( n );
476cdf0e10cSrcweir 		pClass->WriteHelpIds( rBase, rOutStm, pTable );
477cdf0e10cSrcweir 	}
478cdf0e10cSrcweir }
479cdf0e10cSrcweir 
480cdf0e10cSrcweir /*************************************************************************
481cdf0e10cSrcweir |*    SvMetaModule::WriteAttributes()
482cdf0e10cSrcweir *************************************************************************/
WriteAttributes(SvIdlDataBase & rBase,SvStream & rOutStm,sal_uInt16 nTab,WriteType nT,WriteAttribute nA)483cdf0e10cSrcweir void SvMetaModule::WriteAttributes( SvIdlDataBase & rBase,
484cdf0e10cSrcweir 									SvStream & rOutStm,
485cdf0e10cSrcweir                              		sal_uInt16 nTab,
486cdf0e10cSrcweir 		 						    WriteType nT, WriteAttribute nA )
487cdf0e10cSrcweir {
488cdf0e10cSrcweir 	SvMetaExtern::WriteAttributes( rBase, rOutStm, nTab, nT, nA );
489cdf0e10cSrcweir     if( aHelpFileName.Len() )
490cdf0e10cSrcweir 	{
491cdf0e10cSrcweir 		WriteTab( rOutStm, nTab );
492cdf0e10cSrcweir 		rOutStm << "// class SvMetaModule" << endl;
493cdf0e10cSrcweir 		WriteTab( rOutStm, nTab );
494cdf0e10cSrcweir         rOutStm << "helpfile(\"" << aHelpFileName.GetBuffer() << "\");" << endl;
495cdf0e10cSrcweir 	}
496cdf0e10cSrcweir }
497cdf0e10cSrcweir 
498cdf0e10cSrcweir /*************************************************************************
499cdf0e10cSrcweir |*    SvMetaModule::WriteSbx()
500cdf0e10cSrcweir *************************************************************************/
501cdf0e10cSrcweir /*
502cdf0e10cSrcweir void SvMetaModule::WriteSbx( SvIdlDataBase & rBase, SvStream & rOutStm,
503cdf0e10cSrcweir 								SvNamePosList & rList )
504cdf0e10cSrcweir {
505cdf0e10cSrcweir 	for( sal_uLong n = 0; n < aClassList.Count(); n++ )
506cdf0e10cSrcweir 	{
507cdf0e10cSrcweir 	    SvMetaClass * pClass = aClassList.GetObject( n );
508cdf0e10cSrcweir 		if( !pClass->IsShell() && pClass->GetAutomation() )
509cdf0e10cSrcweir 		{
510cdf0e10cSrcweir 			rList.Insert( new SvNamePos( pClass->GetUUId(), rOutStm.Tell() ),
511cdf0e10cSrcweir 						LIST_APPEND );
512cdf0e10cSrcweir 			SbxObjectRef xSbxObj = new SbxObject( pClass->GetName() );
513cdf0e10cSrcweir 			pClass->FillSbxObject( rBase, xSbxObj );
514cdf0e10cSrcweir 			xSbxObj->Store( rOutStm );
515cdf0e10cSrcweir 		}
516cdf0e10cSrcweir 	}
517cdf0e10cSrcweir }
518cdf0e10cSrcweir  */
519cdf0e10cSrcweir 
520cdf0e10cSrcweir /*************************************************************************
521cdf0e10cSrcweir |*    SvMetaModule::Write()
522cdf0e10cSrcweir *************************************************************************/
Write(SvIdlDataBase & rBase,SvStream & rOutStm,sal_uInt16 nTab,WriteType nT,WriteAttribute nA)523cdf0e10cSrcweir void SvMetaModule::Write( SvIdlDataBase & rBase, SvStream & rOutStm,
524cdf0e10cSrcweir                           	sal_uInt16 nTab,
525cdf0e10cSrcweir 		 					WriteType nT, WriteAttribute nA )
526cdf0e10cSrcweir {
527cdf0e10cSrcweir 	switch ( nT )
528cdf0e10cSrcweir 	{
529cdf0e10cSrcweir 	case WRITE_ODL:
530cdf0e10cSrcweir 	{
531cdf0e10cSrcweir 	    if( aSlotIdFile.Len() )
532cdf0e10cSrcweir 		{
533cdf0e10cSrcweir 			WriteTab( rOutStm, nTab );
534cdf0e10cSrcweir             rOutStm << "#include \"" << aSlotIdFile.GetBuffer() << '"' << endl << endl;
535cdf0e10cSrcweir 	    }
536cdf0e10cSrcweir 		SvMetaExtern::Write( rBase, rOutStm, nTab, nT, nA );
537cdf0e10cSrcweir 		rOutStm << endl;
538cdf0e10cSrcweir 		WriteTab( rOutStm, nTab );
539cdf0e10cSrcweir         rOutStm << "library " << GetName().GetBuffer() << endl;
540cdf0e10cSrcweir 		WriteTab( rOutStm, nTab );
541cdf0e10cSrcweir 	    rOutStm << '{' << endl;
542cdf0e10cSrcweir 		WriteTab( rOutStm, nTab );
543cdf0e10cSrcweir 		rOutStm << "importlib(\"STDOLE.TLB\");" << endl;
544cdf0e10cSrcweir 
545cdf0e10cSrcweir 	/*
546cdf0e10cSrcweir 	    for( sal_uLong n = 0; n < aTypeList.Count(); n++ )
547cdf0e10cSrcweir 	    {
548cdf0e10cSrcweir 	        SvMetaType * pType = aTypeList.GetObject( n );
549cdf0e10cSrcweir 	        if( !pType ->Write( rBase, rOutStm, nTab +1, nT, nA ) )
550cdf0e10cSrcweir 	            return sal_False;
551cdf0e10cSrcweir 	    }
552cdf0e10cSrcweir 	*/
553cdf0e10cSrcweir 		/*
554cdf0e10cSrcweir 	    for( sal_uLong n = 0; n < rBase.GetModuleList().Count(); n++ )
555cdf0e10cSrcweir 	    {
556cdf0e10cSrcweir 	        SvMetaModule * pModule = rBase.GetModuleList().GetObject( n );
557cdf0e10cSrcweir 	        const SvMetaTypeMemberList &rTypeList = pModule->GetTypeList();
558cdf0e10cSrcweir 	        for( sal_uLong n = 0; n < rTypeList.Count(); n++ )
559cdf0e10cSrcweir 	        {
560cdf0e10cSrcweir 	            SvMetaType * pType = rTypeList.GetObject( n );
561cdf0e10cSrcweir 	            pType->Write( rBase, rOutStm, nTab +1, nT, nA );
562cdf0e10cSrcweir 	        }
563cdf0e10cSrcweir 	    }
564cdf0e10cSrcweir 		*/
565cdf0e10cSrcweir 
566cdf0e10cSrcweir 	    for( sal_uLong n = 0; n < aClassList.Count(); n++ )
567cdf0e10cSrcweir 	    {
568cdf0e10cSrcweir 	        SvMetaClass * pClass = aClassList.GetObject( n );
569cdf0e10cSrcweir 			if( !pClass->IsShell() && pClass->GetAutomation() )
570cdf0e10cSrcweir 			{
571cdf0e10cSrcweir 				WriteTab( rOutStm, nTab );
572cdf0e10cSrcweir 				WriteStars( rOutStm );
573cdf0e10cSrcweir 		        pClass->Write( rBase, rOutStm, nTab +1, nT, nA );
574cdf0e10cSrcweir 			    if( n +1 < aClassList.Count() )
575cdf0e10cSrcweir 					rOutStm << endl;
576cdf0e10cSrcweir 			}
577cdf0e10cSrcweir 	    }
578cdf0e10cSrcweir 
579cdf0e10cSrcweir 	    rOutStm << '}' << endl;
580cdf0e10cSrcweir 	}
581cdf0e10cSrcweir 	break;
582cdf0e10cSrcweir 	case WRITE_DOCU:
583cdf0e10cSrcweir 	{
584cdf0e10cSrcweir 		rOutStm << "SvIDL interface documentation" << endl << endl;
585cdf0e10cSrcweir         rOutStm << "<MODULE>" << endl << GetName().GetBuffer() << endl;
586cdf0e10cSrcweir 		WriteDescription( rOutStm );
587cdf0e10cSrcweir 		rOutStm	<< "</MODULE>" << endl << endl;
588cdf0e10cSrcweir 
589cdf0e10cSrcweir 		rOutStm << "<CLASSES>" << endl;
590cdf0e10cSrcweir 	    for( sal_uLong n = 0; n < aClassList.Count(); n++ )
591cdf0e10cSrcweir 	    {
592cdf0e10cSrcweir 	        SvMetaClass * pClass = aClassList.GetObject( n );
593cdf0e10cSrcweir 			if( !pClass->IsShell() )
594cdf0e10cSrcweir 			{
595cdf0e10cSrcweir                 rOutStm << pClass->GetName().GetBuffer();
596cdf0e10cSrcweir 				SvMetaClass* pSC = pClass->GetSuperClass();
597cdf0e10cSrcweir 			    if( pSC )
598cdf0e10cSrcweir                     rOutStm << " : " << pSC->GetName().GetBuffer();
599cdf0e10cSrcweir 
600cdf0e10cSrcweir 				// Importierte Klassen
601cdf0e10cSrcweir 				const SvClassElementMemberList& rClassList = pClass->GetClassList();
602cdf0e10cSrcweir 				if ( rClassList.Count() )
603cdf0e10cSrcweir 				{
604cdf0e10cSrcweir 					rOutStm << " ( ";
605cdf0e10cSrcweir 
606cdf0e10cSrcweir 					for( sal_uLong m=0; m<rClassList.Count(); m++ )
607cdf0e10cSrcweir 					{
608cdf0e10cSrcweir 						SvClassElement *pEle = rClassList.GetObject(m);
609cdf0e10cSrcweir 						SvMetaClass *pCl = pEle->GetClass();
610cdf0e10cSrcweir                         rOutStm << pCl->GetName().GetBuffer();
611cdf0e10cSrcweir 						if ( m+1 == rClassList.Count() )
612cdf0e10cSrcweir 							rOutStm << " )";
613cdf0e10cSrcweir 						else
614cdf0e10cSrcweir 							rOutStm << " , ";
615cdf0e10cSrcweir 					}
616cdf0e10cSrcweir 				}
617cdf0e10cSrcweir 
618cdf0e10cSrcweir 				rOutStm << endl;
619cdf0e10cSrcweir 			}
620cdf0e10cSrcweir 		}
621cdf0e10cSrcweir 		rOutStm << "</CLASSES>" << endl << endl;
622cdf0e10cSrcweir 		// kein Break!
623cdf0e10cSrcweir 	}
624cdf0e10cSrcweir 
625cdf0e10cSrcweir 	case WRITE_C_SOURCE:
626cdf0e10cSrcweir 	case WRITE_C_HEADER:
627cdf0e10cSrcweir 	{
628cdf0e10cSrcweir 	    for( sal_uLong n = 0; n < aClassList.Count(); n++ )
629cdf0e10cSrcweir 	    {
630cdf0e10cSrcweir 	        SvMetaClass * pClass = aClassList.GetObject( n );
631cdf0e10cSrcweir 			if( !pClass->IsShell() /* && pClass->GetAutomation() */ )
632cdf0e10cSrcweir 	        	pClass->Write( rBase, rOutStm, nTab, nT, nA );
633cdf0e10cSrcweir 	    }
634cdf0e10cSrcweir 	}
635cdf0e10cSrcweir 	break;
636cdf0e10cSrcweir 
637cdf0e10cSrcweir     default:
638cdf0e10cSrcweir         break;
639cdf0e10cSrcweir 	}
640cdf0e10cSrcweir }
641cdf0e10cSrcweir 
642cdf0e10cSrcweir /*************************************************************************
643cdf0e10cSrcweir |*    SvMetaModule::WriteSrc()
644cdf0e10cSrcweir *************************************************************************/
WriteSrc(SvIdlDataBase & rBase,SvStream & rOutStm,Table * pTable)645cdf0e10cSrcweir void SvMetaModule::WriteSrc( SvIdlDataBase & rBase, SvStream & rOutStm,
646cdf0e10cSrcweir                              Table * pTable )
647cdf0e10cSrcweir {
648cdf0e10cSrcweir //	rOutStm << "#pragma CHARSET IBMPC" << endl;
649cdf0e10cSrcweir     if( aSlotIdFile.Len() )
650cdf0e10cSrcweir         rOutStm << "//#include <" << aSlotIdFile.GetBuffer() << '>' << endl;
651cdf0e10cSrcweir     for( sal_uLong n = 0; n < aClassList.Count(); n++ )
652cdf0e10cSrcweir     {
653cdf0e10cSrcweir         aClassList.GetObject( n )->WriteSrc( rBase, rOutStm, pTable );
654cdf0e10cSrcweir     }
655cdf0e10cSrcweir }
656cdf0e10cSrcweir 
657cdf0e10cSrcweir /*************************************************************************
658cdf0e10cSrcweir |*    SvMetaModule::WriteHxx()
659cdf0e10cSrcweir *************************************************************************/
WriteHxx(SvIdlDataBase & rBase,SvStream & rOutStm,sal_uInt16 nTab)660cdf0e10cSrcweir void SvMetaModule::WriteHxx( SvIdlDataBase & rBase, SvStream & rOutStm,
661cdf0e10cSrcweir                              sal_uInt16 nTab )
662cdf0e10cSrcweir {
663cdf0e10cSrcweir     for( sal_uLong n = 0; n < aClassList.Count(); n++ )
664cdf0e10cSrcweir     {
665cdf0e10cSrcweir         SvMetaClass * pClass = aClassList.GetObject( n );
666cdf0e10cSrcweir         pClass->WriteHxx( rBase, rOutStm, nTab );
667cdf0e10cSrcweir     }
668cdf0e10cSrcweir }
669cdf0e10cSrcweir 
670cdf0e10cSrcweir /*************************************************************************
671cdf0e10cSrcweir |*    SvMetaModule::WriteCxx()
672cdf0e10cSrcweir *************************************************************************/
WriteCxx(SvIdlDataBase & rBase,SvStream & rOutStm,sal_uInt16 nTab)673cdf0e10cSrcweir void SvMetaModule::WriteCxx( SvIdlDataBase & rBase, SvStream & rOutStm,
674cdf0e10cSrcweir                              sal_uInt16 nTab )
675cdf0e10cSrcweir {
676cdf0e10cSrcweir     for( sal_uLong n = 0; n < aClassList.Count(); n++ )
677cdf0e10cSrcweir     {
678cdf0e10cSrcweir         SvMetaClass * pClass = aClassList.GetObject( n );
679cdf0e10cSrcweir         pClass->WriteCxx( rBase, rOutStm, nTab );
680cdf0e10cSrcweir     }
681cdf0e10cSrcweir }
682cdf0e10cSrcweir 
683cdf0e10cSrcweir #endif // IDL_COMPILER
684cdf0e10cSrcweir 
685