1*724893d4SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
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
12*724893d4SAndrew Rist *
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 #include <stdlib.h>
30cdf0e10cSrcweir #include <tools/fsys.hxx>
31cdf0e10cSrcweir #include <tools/debug.hxx>
32cdf0e10cSrcweir #include <database.hxx>
33cdf0e10cSrcweir #include <globals.hxx>
34cdf0e10cSrcweir
35cdf0e10cSrcweir /****************** SvIdlDataBase ****************************************/
36cdf0e10cSrcweir /*************************************************************************
37cdf0e10cSrcweir |* SvIdlDataBase::SvIdlDataBase()
38cdf0e10cSrcweir |*
39cdf0e10cSrcweir |* Beschreibung
40cdf0e10cSrcweir *************************************************************************/
41cdf0e10cSrcweir /*
42cdf0e10cSrcweir void PrimeNumber(){
43cdf0e10cSrcweir sal_uInt16 i, n;
44cdf0e10cSrcweir for( i = 5001; i < 5500; i += 2 ){
45cdf0e10cSrcweir for( n = 2; n < i && ((i % n) != 0); n++ );
46cdf0e10cSrcweir if( n == i ){
47cdf0e10cSrcweir printf( "\nPrimzahl: %d\n", i );
48cdf0e10cSrcweir return;
49cdf0e10cSrcweir }
50cdf0e10cSrcweir }
51cdf0e10cSrcweir }
52cdf0e10cSrcweir */
53cdf0e10cSrcweir
SvIdlDataBase(const SvCommand & rCmd)54cdf0e10cSrcweir SvIdlDataBase::SvIdlDataBase( const SvCommand& rCmd )
55cdf0e10cSrcweir : bExport( sal_False )
56cdf0e10cSrcweir , nUniqueId( 0 )
57cdf0e10cSrcweir , nVerbosity( rCmd.nVerbosity )
58cdf0e10cSrcweir , bIsModified( sal_False )
59cdf0e10cSrcweir , aPersStream( *IDLAPP->pClassMgr, NULL )
60cdf0e10cSrcweir , pIdTable( NULL )
61cdf0e10cSrcweir {
62cdf0e10cSrcweir //PrimeNumber();
63cdf0e10cSrcweir }
64cdf0e10cSrcweir
65cdf0e10cSrcweir /*************************************************************************
66cdf0e10cSrcweir |* SvIdlDataBase::~SvIdlDataBase()
67cdf0e10cSrcweir |*
68cdf0e10cSrcweir |* Beschreibung
69cdf0e10cSrcweir *************************************************************************/
~SvIdlDataBase()70cdf0e10cSrcweir SvIdlDataBase::~SvIdlDataBase()
71cdf0e10cSrcweir {
72cdf0e10cSrcweir String * pStr = aIdFileList.First();
73cdf0e10cSrcweir while( pStr )
74cdf0e10cSrcweir {
75cdf0e10cSrcweir delete pStr;
76cdf0e10cSrcweir pStr = aIdFileList.Next();
77cdf0e10cSrcweir }
78cdf0e10cSrcweir delete pIdTable;
79cdf0e10cSrcweir }
80cdf0e10cSrcweir
81cdf0e10cSrcweir /*************************************************************************
82cdf0e10cSrcweir |* SvIdlDataBase::GetTypeList()
83cdf0e10cSrcweir |*
84cdf0e10cSrcweir |* Beschreibung
85cdf0e10cSrcweir *************************************************************************/
86cdf0e10cSrcweir #define ADD_TYPE( Name, OdlName, ParserChar, CName, BasName, BasPost ) \
87cdf0e10cSrcweir aTypeList.Append( new SvMetaType( SvHash_##Name()->GetName(), \
88cdf0e10cSrcweir BasName, OdlName, ParserChar, CName, BasName, BasPost ) );
89cdf0e10cSrcweir
GetTypeList()90cdf0e10cSrcweir SvMetaTypeMemberList & SvIdlDataBase::GetTypeList()
91cdf0e10cSrcweir {
92cdf0e10cSrcweir if( aTypeList.Count() == 0 )
93cdf0e10cSrcweir { // Initial fuellen
94cdf0e10cSrcweir aTypeList.Append( new SvMetaTypeString() );
95cdf0e10cSrcweir aTypeList.Append( new SvMetaTypevoid() );
96cdf0e10cSrcweir
97cdf0e10cSrcweir // MI: IDispatch::Invoke kann keine unsigned
98cdf0e10cSrcweir ADD_TYPE( UINT16, "long", 'h', "unsigned short", "Long", "&" );
99cdf0e10cSrcweir ADD_TYPE( INT16, "short", 'h', "short", "Integer", "%" );
100cdf0e10cSrcweir ADD_TYPE( UINT32, "long", 'l', "unsigned long", "Long", "&" );
101cdf0e10cSrcweir ADD_TYPE( INT32, "long", 'l', "long", "Long", "&" );
102cdf0e10cSrcweir ADD_TYPE( int, "int", 'i', "int", "Integer", "%" );
103cdf0e10cSrcweir ADD_TYPE( BOOL, "boolean", 'b', "unsigned char", "Boolean", "" );
104cdf0e10cSrcweir ADD_TYPE( char, "char", 'c', "char", "Integer", "%" );
105cdf0e10cSrcweir ADD_TYPE( BYTE, "char", 'c', "unsigned char", "Integer", "%" );
106cdf0e10cSrcweir ADD_TYPE( float, "float", 'f', "float", "Single", "!" );
107cdf0e10cSrcweir ADD_TYPE( double, "double", 'F', "double", "Double", "#" );
108cdf0e10cSrcweir ADD_TYPE( SbxObject, "VARIANT", 'o', "C_Object", "Object", "" );
109cdf0e10cSrcweir
110cdf0e10cSrcweir
111cdf0e10cSrcweir // A c h t u n g !!!, bei hinzufuegen von Typen werden alle
112cdf0e10cSrcweir // bin�ren Datenbasen inkompatibel
113cdf0e10cSrcweir
114cdf0e10cSrcweir /*
115cdf0e10cSrcweir // So tun als ob die Init-Daten auf einem Stream gelesen wurden
116cdf0e10cSrcweir SvMemoryStream aStm;
117cdf0e10cSrcweir aPersStream.SetStream( &aStm );
118cdf0e10cSrcweir // Alle Init-Daten Streamen
119cdf0e10cSrcweir aPersStream << aTypeList;
120cdf0e10cSrcweir // Nur die Id-Zuordnung merken
121cdf0e10cSrcweir aPersStream.SetStream( NULL );
122cdf0e10cSrcweir */
123cdf0e10cSrcweir }
124cdf0e10cSrcweir return aTypeList;
125cdf0e10cSrcweir }
126cdf0e10cSrcweir
127cdf0e10cSrcweir /*************************************************************************
128cdf0e10cSrcweir |*
129cdf0e10cSrcweir |* SvIdlDataBase::GetModuleInfo()
130cdf0e10cSrcweir |*
131cdf0e10cSrcweir |* Beschreibung
132cdf0e10cSrcweir |* Ersterstellung MM 13.12.94
133cdf0e10cSrcweir |* Letzte Aenderung MM 13.12.94
134cdf0e10cSrcweir |*
135cdf0e10cSrcweir *************************************************************************/
GetModule(const ByteString & rName)136cdf0e10cSrcweir SvMetaModule * SvIdlDataBase::GetModule( const ByteString & rName )
137cdf0e10cSrcweir {
138cdf0e10cSrcweir for( sal_uLong n = 0; n < aModuleList.Count(); n++ )
139cdf0e10cSrcweir if( aModuleList.GetObject( n )->GetName() == rName )
140cdf0e10cSrcweir return aModuleList.GetObject( n );
141cdf0e10cSrcweir return NULL;
142cdf0e10cSrcweir }
143cdf0e10cSrcweir
144cdf0e10cSrcweir /*************************************************************************
145cdf0e10cSrcweir |*
146cdf0e10cSrcweir |* SvIdlDataBase::IsBinaryFormat()
147cdf0e10cSrcweir |*
148cdf0e10cSrcweir |* Beschreibung
149cdf0e10cSrcweir |*
150cdf0e10cSrcweir *************************************************************************/
151cdf0e10cSrcweir #define DATABASE_SIGNATURE (sal_uInt32)0x13B799F2
152cdf0e10cSrcweir #define DATABASE_VER 0x0006
IsBinaryFormat(SvStream & rStm)153cdf0e10cSrcweir sal_Bool SvIdlDataBase::IsBinaryFormat( SvStream & rStm )
154cdf0e10cSrcweir {
155cdf0e10cSrcweir sal_uInt32 nSig = 0;
156cdf0e10cSrcweir sal_uLong nPos = rStm.Tell();
157cdf0e10cSrcweir rStm >> nSig;
158cdf0e10cSrcweir rStm.Seek( nPos );
159cdf0e10cSrcweir
160cdf0e10cSrcweir return nSig == DATABASE_SIGNATURE;
161cdf0e10cSrcweir }
162cdf0e10cSrcweir
163cdf0e10cSrcweir /*************************************************************************
164cdf0e10cSrcweir |*
165cdf0e10cSrcweir |* SvIdlDataBase::Load()
166cdf0e10cSrcweir |*
167cdf0e10cSrcweir |* Beschreibung
168cdf0e10cSrcweir |*
169cdf0e10cSrcweir *************************************************************************/
Load(SvStream & rStm)170cdf0e10cSrcweir void SvIdlDataBase::Load( SvStream & rStm )
171cdf0e10cSrcweir {
172cdf0e10cSrcweir DBG_ASSERT( aTypeList.Count() == 0, "type list already initialized" );
173cdf0e10cSrcweir SvPersistStream aPStm( *IDLAPP->pClassMgr, &rStm );
174cdf0e10cSrcweir
175cdf0e10cSrcweir sal_uInt16 nVersion = 0;
176cdf0e10cSrcweir sal_uInt32 nSig = 0;
177cdf0e10cSrcweir
178cdf0e10cSrcweir aPStm >> nSig;
179cdf0e10cSrcweir aPStm >> nVersion;
180cdf0e10cSrcweir if( nSig != DATABASE_SIGNATURE )
181cdf0e10cSrcweir {
182cdf0e10cSrcweir aPStm.SetError( SVSTREAM_FILEFORMAT_ERROR );
183cdf0e10cSrcweir return;
184cdf0e10cSrcweir }
185cdf0e10cSrcweir if( nVersion != DATABASE_VER )
186cdf0e10cSrcweir {
187cdf0e10cSrcweir aPStm.SetError( SVSTREAM_WRONGVERSION );
188cdf0e10cSrcweir return;
189cdf0e10cSrcweir }
190cdf0e10cSrcweir aPStm >> aClassList;
191cdf0e10cSrcweir aPStm >> aTypeList;
192cdf0e10cSrcweir aPStm >> aAttrList;
193cdf0e10cSrcweir aPStm >> aModuleList;
194cdf0e10cSrcweir aPStm >> nUniqueId;
195cdf0e10cSrcweir
196cdf0e10cSrcweir if( aPStm.IsEof() )
197cdf0e10cSrcweir aPStm.SetError( SVSTREAM_GENERALERROR );
198cdf0e10cSrcweir }
199cdf0e10cSrcweir
200cdf0e10cSrcweir /*************************************************************************
201cdf0e10cSrcweir |* SvIdlDataBase::Save()
202cdf0e10cSrcweir |*
203cdf0e10cSrcweir |* Beschreibung
204cdf0e10cSrcweir *************************************************************************/
Save(SvStream & rStm,sal_uInt32 nFlags)205cdf0e10cSrcweir void SvIdlDataBase::Save( SvStream & rStm, sal_uInt32 nFlags )
206cdf0e10cSrcweir {
207cdf0e10cSrcweir SvPersistStream aPStm( *IDLAPP->pClassMgr, &rStm );
208cdf0e10cSrcweir aPStm.SetContextFlags( nFlags );
209cdf0e10cSrcweir
210cdf0e10cSrcweir aPStm << (sal_uInt32)DATABASE_SIGNATURE;
211cdf0e10cSrcweir aPStm << (sal_uInt16)DATABASE_VER;
212cdf0e10cSrcweir
213cdf0e10cSrcweir sal_Bool bOnlyStreamedObjs = sal_False;
214cdf0e10cSrcweir if( nFlags & IDL_WRITE_CALLING )
215cdf0e10cSrcweir bOnlyStreamedObjs = sal_True;
216cdf0e10cSrcweir
217cdf0e10cSrcweir if( bOnlyStreamedObjs )
218cdf0e10cSrcweir {
219cdf0e10cSrcweir SvMetaClassMemberList aList;
220cdf0e10cSrcweir for( sal_uLong n = 0; n < GetModuleList().Count(); n++ )
221cdf0e10cSrcweir {
222cdf0e10cSrcweir SvMetaModule * pModule = GetModuleList().GetObject( n );
223cdf0e10cSrcweir if( !pModule->IsImported() )
224cdf0e10cSrcweir aList.Append( pModule->GetClassList() );
225cdf0e10cSrcweir }
226cdf0e10cSrcweir aPStm << aList;
227cdf0e10cSrcweir }
228cdf0e10cSrcweir else
229cdf0e10cSrcweir aPStm << aClassList;
230cdf0e10cSrcweir
231cdf0e10cSrcweir //aClassList.WriteObjects( aPStm, bOnlyStreamedObjs );
232cdf0e10cSrcweir aTypeList.WriteObjects( aPStm, bOnlyStreamedObjs );
233cdf0e10cSrcweir aAttrList.WriteObjects( aPStm, bOnlyStreamedObjs );
234cdf0e10cSrcweir aModuleList.WriteObjects( aPStm, bOnlyStreamedObjs );
235cdf0e10cSrcweir aPStm << nUniqueId;
236cdf0e10cSrcweir }
237cdf0e10cSrcweir
238cdf0e10cSrcweir /*************************************************************************
239cdf0e10cSrcweir |* SvIdlDataBase::SetError()
240cdf0e10cSrcweir |*
241cdf0e10cSrcweir |* Beschreibung
242cdf0e10cSrcweir *************************************************************************/
SetError(const ByteString & rError,SvToken * pTok)243cdf0e10cSrcweir void SvIdlDataBase::SetError( const ByteString & rError, SvToken * pTok )
244cdf0e10cSrcweir {
245cdf0e10cSrcweir if( pTok->GetLine() > 10000 )
246cdf0e10cSrcweir aError.SetText( "hgchcg" );
247cdf0e10cSrcweir
248cdf0e10cSrcweir if( aError.nLine < pTok->GetLine()
249cdf0e10cSrcweir || (aError.nLine == pTok->GetLine() && aError.nColumn < pTok->GetColumn()) )
250cdf0e10cSrcweir {
251cdf0e10cSrcweir aError = SvIdlError( pTok->GetLine(), pTok->GetColumn() );
252cdf0e10cSrcweir aError.SetText( rError );
253cdf0e10cSrcweir }
254cdf0e10cSrcweir }
255cdf0e10cSrcweir
256cdf0e10cSrcweir /*************************************************************************
257cdf0e10cSrcweir |* SvIdlDataBase::Push()
258cdf0e10cSrcweir |*
259cdf0e10cSrcweir |* Beschreibung
260cdf0e10cSrcweir *************************************************************************/
Push(SvMetaObject * pObj)261cdf0e10cSrcweir void SvIdlDataBase::Push( SvMetaObject * pObj )
262cdf0e10cSrcweir {
263cdf0e10cSrcweir GetStack().Push( pObj );
264cdf0e10cSrcweir }
265cdf0e10cSrcweir
266cdf0e10cSrcweir #ifdef IDL_COMPILER
267cdf0e10cSrcweir /*************************************************************************
268cdf0e10cSrcweir |*
269cdf0e10cSrcweir |* SvIdlDataBase::FindId()
270cdf0e10cSrcweir |*
271cdf0e10cSrcweir |* Beschreibung
272cdf0e10cSrcweir |*
273cdf0e10cSrcweir *************************************************************************/
FindId(const ByteString & rIdName,sal_uLong * pVal)274cdf0e10cSrcweir sal_Bool SvIdlDataBase::FindId( const ByteString & rIdName, sal_uLong * pVal )
275cdf0e10cSrcweir {
276cdf0e10cSrcweir if( pIdTable )
277cdf0e10cSrcweir {
278cdf0e10cSrcweir sal_uInt32 nHash;
279cdf0e10cSrcweir if( pIdTable->Test( rIdName, &nHash ) )
280cdf0e10cSrcweir {
281cdf0e10cSrcweir *pVal = pIdTable->Get( nHash )->GetValue();
282cdf0e10cSrcweir return sal_True;
283cdf0e10cSrcweir }
284cdf0e10cSrcweir }
285cdf0e10cSrcweir return sal_False;
286cdf0e10cSrcweir }
287cdf0e10cSrcweir
288cdf0e10cSrcweir /*************************************************************************
289cdf0e10cSrcweir |*
290cdf0e10cSrcweir |* SvIdlDataBase::InsertId()
291cdf0e10cSrcweir |*
292cdf0e10cSrcweir |* Beschreibung
293cdf0e10cSrcweir |*
294cdf0e10cSrcweir *************************************************************************/
InsertId(const ByteString & rIdName,sal_uLong nVal)295cdf0e10cSrcweir sal_Bool SvIdlDataBase::InsertId( const ByteString & rIdName, sal_uLong nVal )
296cdf0e10cSrcweir {
297cdf0e10cSrcweir if( !pIdTable )
298cdf0e10cSrcweir pIdTable = new SvStringHashTable( 20003 );
299cdf0e10cSrcweir
300cdf0e10cSrcweir sal_uInt32 nHash;
301cdf0e10cSrcweir if( pIdTable->Insert( rIdName, &nHash ) )
302cdf0e10cSrcweir {
303cdf0e10cSrcweir pIdTable->Get( nHash )->SetValue( nVal );
304cdf0e10cSrcweir return sal_True;
305cdf0e10cSrcweir }
306cdf0e10cSrcweir return sal_False;
307cdf0e10cSrcweir }
308cdf0e10cSrcweir
309cdf0e10cSrcweir /*************************************************************************
310cdf0e10cSrcweir |* SvIdlDataBase::ReadIdFile()
311cdf0e10cSrcweir |*
312cdf0e10cSrcweir |* Beschreibung
313cdf0e10cSrcweir *************************************************************************/
ReadIdFile(const String & rFileName)314cdf0e10cSrcweir sal_Bool SvIdlDataBase::ReadIdFile( const String & rFileName )
315cdf0e10cSrcweir {
316cdf0e10cSrcweir DirEntry aFullName( rFileName );
317cdf0e10cSrcweir aFullName.Find( GetPath() );
318cdf0e10cSrcweir
319cdf0e10cSrcweir String * pIdFile = aIdFileList.First();
320cdf0e10cSrcweir while( pIdFile )
321cdf0e10cSrcweir {
322cdf0e10cSrcweir if( *pIdFile == rFileName )
323cdf0e10cSrcweir return sal_True; // schon eingelesen
324cdf0e10cSrcweir pIdFile = aIdFileList.Next();
325cdf0e10cSrcweir }
326cdf0e10cSrcweir
327cdf0e10cSrcweir aIdFileList.Insert( new String( rFileName ), LIST_APPEND );
328cdf0e10cSrcweir
329cdf0e10cSrcweir SvTokenStream aTokStm( aFullName.GetFull() );
330cdf0e10cSrcweir if( aTokStm.GetStream().GetError() == SVSTREAM_OK )
331cdf0e10cSrcweir {
332cdf0e10cSrcweir SvToken * pTok = aTokStm.GetToken_Next();
333cdf0e10cSrcweir
334cdf0e10cSrcweir while( !pTok->IsEof() )
335cdf0e10cSrcweir {
336cdf0e10cSrcweir if( pTok->IsChar() && pTok->GetChar() == '#' )
337cdf0e10cSrcweir {
338cdf0e10cSrcweir pTok = aTokStm.GetToken_Next();
339cdf0e10cSrcweir if( pTok->Is( SvHash_define() ) )
340cdf0e10cSrcweir {
341cdf0e10cSrcweir pTok = aTokStm.GetToken_Next();
342cdf0e10cSrcweir ByteString aDefName;
343cdf0e10cSrcweir if( pTok->IsIdentifier() )
344cdf0e10cSrcweir aDefName = pTok->GetString();
345cdf0e10cSrcweir else
346cdf0e10cSrcweir {
347cdf0e10cSrcweir ByteString aStr( "unexpected token after define" );
348cdf0e10cSrcweir // Fehler setzen
349cdf0e10cSrcweir SetError( aStr, pTok );
350cdf0e10cSrcweir WriteError( aTokStm );
351cdf0e10cSrcweir return sal_False;
352cdf0e10cSrcweir }
353cdf0e10cSrcweir
354cdf0e10cSrcweir sal_uLong nVal = 0;
355cdf0e10cSrcweir sal_Bool bOk = sal_True;
356cdf0e10cSrcweir while( bOk )
357cdf0e10cSrcweir {
358cdf0e10cSrcweir pTok = aTokStm.GetToken_Next();
359cdf0e10cSrcweir if( pTok->IsIdentifier() )
360cdf0e10cSrcweir {
361cdf0e10cSrcweir sal_uLong n;
362cdf0e10cSrcweir if( FindId( pTok->GetString(), &n ) )
363cdf0e10cSrcweir nVal += n;
364cdf0e10cSrcweir else
365cdf0e10cSrcweir bOk = sal_False;
366cdf0e10cSrcweir }
367cdf0e10cSrcweir else if( pTok->IsChar() )
368cdf0e10cSrcweir {
369cdf0e10cSrcweir if( pTok->GetChar() == '-'
370cdf0e10cSrcweir || pTok->GetChar() == '/'
371cdf0e10cSrcweir || pTok->GetChar() == '*'
372cdf0e10cSrcweir || pTok->GetChar() == '&'
373cdf0e10cSrcweir || pTok->GetChar() == '|'
374cdf0e10cSrcweir || pTok->GetChar() == '^'
375cdf0e10cSrcweir || pTok->GetChar() == '~' )
376cdf0e10cSrcweir {
377cdf0e10cSrcweir ByteString aStr( "unknown operator '" );
378cdf0e10cSrcweir aStr += pTok->GetChar();
379cdf0e10cSrcweir aStr += "'in define";
380cdf0e10cSrcweir // Fehler setzen
381cdf0e10cSrcweir SetError( aStr, pTok );
382cdf0e10cSrcweir WriteError( aTokStm );
383cdf0e10cSrcweir return sal_False;
384cdf0e10cSrcweir }
385cdf0e10cSrcweir if( pTok->GetChar() != '+'
386cdf0e10cSrcweir && pTok->GetChar() != '('
387cdf0e10cSrcweir && pTok->GetChar() != ')' )
388cdf0e10cSrcweir // nur + erlaubt, Klammern spielen kein Rolle,
389cdf0e10cSrcweir // da + komutativ ist
390cdf0e10cSrcweir break;
391cdf0e10cSrcweir }
392cdf0e10cSrcweir else if( pTok->IsInteger() )
393cdf0e10cSrcweir {
394cdf0e10cSrcweir nVal += pTok->GetNumber();
395cdf0e10cSrcweir }
396cdf0e10cSrcweir else
397cdf0e10cSrcweir break;
398cdf0e10cSrcweir }
399cdf0e10cSrcweir if( bOk )
400cdf0e10cSrcweir {
401cdf0e10cSrcweir if( !InsertId( aDefName, nVal ) )
402cdf0e10cSrcweir {
403cdf0e10cSrcweir ByteString aStr = "hash table overflow: ";
404cdf0e10cSrcweir SetError( aStr, pTok );
405cdf0e10cSrcweir WriteError( aTokStm );
406cdf0e10cSrcweir return sal_False;
407cdf0e10cSrcweir }
408cdf0e10cSrcweir }
409cdf0e10cSrcweir }
410cdf0e10cSrcweir else if( pTok->Is( SvHash_include() ) )
411cdf0e10cSrcweir {
412cdf0e10cSrcweir pTok = aTokStm.GetToken_Next();
413cdf0e10cSrcweir ByteString aName;
414cdf0e10cSrcweir if( pTok->IsString() )
415cdf0e10cSrcweir aName = pTok->GetString();
416cdf0e10cSrcweir else if( pTok->IsChar() && pTok->GetChar() == '<' )
417cdf0e10cSrcweir {
418cdf0e10cSrcweir pTok = aTokStm.GetToken_Next();
419cdf0e10cSrcweir while( !pTok->IsEof()
420cdf0e10cSrcweir && !(pTok->IsChar() && pTok->GetChar() == '>') )
421cdf0e10cSrcweir {
422cdf0e10cSrcweir aName += pTok->GetTokenAsString();
423cdf0e10cSrcweir pTok = aTokStm.GetToken_Next();
424cdf0e10cSrcweir }
425cdf0e10cSrcweir if( pTok->IsEof() )
426cdf0e10cSrcweir {
427cdf0e10cSrcweir ByteString aStr( "unexpected eof in #include" );
428cdf0e10cSrcweir // Fehler setzen
429cdf0e10cSrcweir SetError( aStr, pTok );
430cdf0e10cSrcweir WriteError( aTokStm );
431cdf0e10cSrcweir return sal_False;
432cdf0e10cSrcweir }
433cdf0e10cSrcweir }
434cdf0e10cSrcweir if( !ReadIdFile( String::CreateFromAscii(aName.GetBuffer()) ) )
435cdf0e10cSrcweir {
436cdf0e10cSrcweir ByteString aStr = "cannot read file: ";
437cdf0e10cSrcweir aStr += aName;
438cdf0e10cSrcweir SetError( aStr, pTok );
439cdf0e10cSrcweir WriteError( aTokStm );
440cdf0e10cSrcweir return sal_False;
441cdf0e10cSrcweir }
442cdf0e10cSrcweir }
443cdf0e10cSrcweir }
444cdf0e10cSrcweir else
445cdf0e10cSrcweir pTok = aTokStm.GetToken_Next();
446cdf0e10cSrcweir }
447cdf0e10cSrcweir }
448cdf0e10cSrcweir else
449cdf0e10cSrcweir return sal_False;
450cdf0e10cSrcweir return sal_True;
451cdf0e10cSrcweir }
452cdf0e10cSrcweir
453cdf0e10cSrcweir /*************************************************************************
454cdf0e10cSrcweir |* SvIdlDataBase::FindType()
455cdf0e10cSrcweir |*
456cdf0e10cSrcweir |* Beschreibung
457cdf0e10cSrcweir *************************************************************************/
FindType(const SvMetaType * pPType,SvMetaTypeMemberList & rList)458cdf0e10cSrcweir SvMetaType * SvIdlDataBase::FindType( const SvMetaType * pPType,
459cdf0e10cSrcweir SvMetaTypeMemberList & rList )
460cdf0e10cSrcweir {
461cdf0e10cSrcweir SvMetaType * pType = rList.First();
462cdf0e10cSrcweir while( pType && pPType != pType )
463cdf0e10cSrcweir pType = rList.Next();
464cdf0e10cSrcweir return pType;
465cdf0e10cSrcweir }
466cdf0e10cSrcweir
FindType(const ByteString & rName)467cdf0e10cSrcweir SvMetaType * SvIdlDataBase::FindType( const ByteString & rName )
468cdf0e10cSrcweir {
469cdf0e10cSrcweir SvMetaType * pType = aTypeList.First();
470cdf0e10cSrcweir while( pType && rName != pType->GetName() )
471cdf0e10cSrcweir pType = aTypeList.Next();
472cdf0e10cSrcweir return pType;
473cdf0e10cSrcweir }
474cdf0e10cSrcweir
475cdf0e10cSrcweir /*************************************************************************
476cdf0e10cSrcweir |* SvIdlDataBase::ReadKnownType()
477cdf0e10cSrcweir |*
478cdf0e10cSrcweir |* Beschreibung
479cdf0e10cSrcweir *************************************************************************/
ReadKnownType(SvTokenStream & rInStm)480cdf0e10cSrcweir SvMetaType * SvIdlDataBase::ReadKnownType( SvTokenStream & rInStm )
481cdf0e10cSrcweir {
482cdf0e10cSrcweir sal_Bool bIn = sal_False;
483cdf0e10cSrcweir sal_Bool bOut = sal_False;
484cdf0e10cSrcweir int nCall0 = CALL_VALUE;
485cdf0e10cSrcweir int nCall1 = CALL_VALUE;
486cdf0e10cSrcweir sal_Bool bSet = sal_False; //irgent ein Attribut gesetzt
487cdf0e10cSrcweir
488cdf0e10cSrcweir sal_uInt32 nTokPos = rInStm.Tell();
489cdf0e10cSrcweir SvToken * pTok = rInStm.GetToken_Next();
490cdf0e10cSrcweir
491cdf0e10cSrcweir if( pTok->HasHash() )
492cdf0e10cSrcweir {
493cdf0e10cSrcweir sal_uInt32 nBeginPos = 0; // kann mit Tell nicht vorkommen
494cdf0e10cSrcweir while( nBeginPos != rInStm.Tell() )
495cdf0e10cSrcweir {
496cdf0e10cSrcweir nBeginPos = rInStm.Tell();
497cdf0e10cSrcweir if( pTok->Is( SvHash_in() ) )
498cdf0e10cSrcweir {
499cdf0e10cSrcweir bIn = sal_True;
500cdf0e10cSrcweir pTok = rInStm.GetToken_Next();
501cdf0e10cSrcweir bSet = sal_True;
502cdf0e10cSrcweir }
503cdf0e10cSrcweir if( pTok->Is( SvHash_out() ) )
504cdf0e10cSrcweir {
505cdf0e10cSrcweir bOut = sal_True;
506cdf0e10cSrcweir pTok = rInStm.GetToken_Next();
507cdf0e10cSrcweir bSet = sal_True;
508cdf0e10cSrcweir }
509cdf0e10cSrcweir if( pTok->Is( SvHash_inout() ) )
510cdf0e10cSrcweir {
511cdf0e10cSrcweir bIn = sal_True;
512cdf0e10cSrcweir bOut = sal_True;
513cdf0e10cSrcweir pTok = rInStm.GetToken_Next();
514cdf0e10cSrcweir bSet = sal_True;
515cdf0e10cSrcweir }
516cdf0e10cSrcweir }
517cdf0e10cSrcweir }
518cdf0e10cSrcweir /*
519cdf0e10cSrcweir SvMetaTypeList aTmpTypeList;
520cdf0e10cSrcweir if( FillTypeList( aTmpTypeList, pTok ) )
521cdf0e10cSrcweir */
522cdf0e10cSrcweir if( pTok->IsIdentifier() )
523cdf0e10cSrcweir {
524cdf0e10cSrcweir ByteString aName = pTok->GetString();
525cdf0e10cSrcweir SvMetaTypeMemberList & rList = GetTypeList();
526cdf0e10cSrcweir SvMetaType * pType = rList.First();
527cdf0e10cSrcweir while( pType )
528cdf0e10cSrcweir {
529cdf0e10cSrcweir if( pType->GetName() == aName )
530cdf0e10cSrcweir break;
531cdf0e10cSrcweir pType = rList.Next();
532cdf0e10cSrcweir }
533cdf0e10cSrcweir if( pType )
534cdf0e10cSrcweir {
535cdf0e10cSrcweir pTok = rInStm.GetToken();
536cdf0e10cSrcweir if( pTok->IsChar() )
537cdf0e10cSrcweir {
538cdf0e10cSrcweir if( pTok->GetChar() == '&' || pTok->GetChar() == '*' )
539cdf0e10cSrcweir {
540cdf0e10cSrcweir nCall0 = (pTok->GetChar() == '&') ? CALL_REFERENCE :
541cdf0e10cSrcweir CALL_POINTER;
542cdf0e10cSrcweir rInStm.GetToken_Next();
543cdf0e10cSrcweir pTok = rInStm.GetToken();
544cdf0e10cSrcweir if( pTok->GetChar() == '&' || pTok->GetChar() == '*' )
545cdf0e10cSrcweir {
546cdf0e10cSrcweir nCall1 = (pTok->GetChar() == '&') ? CALL_REFERENCE :
547cdf0e10cSrcweir CALL_POINTER;
548cdf0e10cSrcweir rInStm.GetToken_Next();
549cdf0e10cSrcweir }
550cdf0e10cSrcweir bSet = sal_True;
551cdf0e10cSrcweir }
552cdf0e10cSrcweir }
553cdf0e10cSrcweir /*
554cdf0e10cSrcweir SvMetaType * pMetaType = aTmpTypeList.First();
555cdf0e10cSrcweir while( pMetaType )
556cdf0e10cSrcweir {
557cdf0e10cSrcweir if( pMetaType->GetIn() == bIn
558cdf0e10cSrcweir && pMetaType->GetOut() == bOut
559cdf0e10cSrcweir && pMetaType->GetCall0() == nCall0
560cdf0e10cSrcweir && pMetaType->GetCall1() == nCall1 )
561cdf0e10cSrcweir {
562cdf0e10cSrcweir return pMetaType;
563cdf0e10cSrcweir }
564cdf0e10cSrcweir pMetaType = aTmpTypeList.Next();
565cdf0e10cSrcweir }
566cdf0e10cSrcweir */
567cdf0e10cSrcweir //SvMetaType * pType = aTmpTypeList.First();
568cdf0e10cSrcweir if( !bSet )
569cdf0e10cSrcweir // Ist genau dieser Typ
570cdf0e10cSrcweir return pType;
571cdf0e10cSrcweir
572cdf0e10cSrcweir DBG_ASSERT( aTmpTypeList.First(), "mindestens ein Element" );
573cdf0e10cSrcweir SvMetaTypeRef xType = new SvMetaType( pType->GetName(), 'h', "dummy" );
574cdf0e10cSrcweir xType->SetRef( pType );
575cdf0e10cSrcweir xType->SetIn( bIn );
576cdf0e10cSrcweir xType->SetOut( bOut );
577cdf0e10cSrcweir xType->SetCall0( nCall0 );
578cdf0e10cSrcweir xType->SetCall1( nCall1 );
579cdf0e10cSrcweir
580cdf0e10cSrcweir aTmpTypeList.Append( xType );
581cdf0e10cSrcweir return xType;
582cdf0e10cSrcweir }
583cdf0e10cSrcweir }
584cdf0e10cSrcweir rInStm.Seek( nTokPos );
585cdf0e10cSrcweir return NULL;
586cdf0e10cSrcweir }
587cdf0e10cSrcweir
588cdf0e10cSrcweir /*************************************************************************
589cdf0e10cSrcweir |*
590cdf0e10cSrcweir |* SvIdlDataBase::ReadKnownAttr()
591cdf0e10cSrcweir |*
592cdf0e10cSrcweir |* Beschreibung
593cdf0e10cSrcweir |*
594cdf0e10cSrcweir *************************************************************************/
ReadKnownAttr(SvTokenStream & rInStm,SvMetaType * pType)595cdf0e10cSrcweir SvMetaAttribute * SvIdlDataBase::ReadKnownAttr
596cdf0e10cSrcweir (
597cdf0e10cSrcweir SvTokenStream & rInStm,
598cdf0e10cSrcweir SvMetaType * pType /* Wenn der pType == NULL, dann muss der Typ
599cdf0e10cSrcweir noch gelesen werden. */
600cdf0e10cSrcweir )
601cdf0e10cSrcweir {
602cdf0e10cSrcweir sal_uInt32 nTokPos = rInStm.Tell();
603cdf0e10cSrcweir
604cdf0e10cSrcweir if( !pType )
605cdf0e10cSrcweir pType = ReadKnownType( rInStm );
606cdf0e10cSrcweir
607cdf0e10cSrcweir if( pType )
608cdf0e10cSrcweir {
609cdf0e10cSrcweir // Wenn wir Slots auf die Wiese stellen, d"urfen wir nicht voraussetzen,
610cdf0e10cSrcweir // da\s jeder Slot einen anderen Namen hat!
611cdf0e10cSrcweir /*
612cdf0e10cSrcweir SvToken * pTok = rInStm.GetToken_Next();
613cdf0e10cSrcweir if( pTok->IsIdentifier() )
614cdf0e10cSrcweir for( sal_uLong n = 0; n < aAttrList.Count(); n++ )
615cdf0e10cSrcweir {
616cdf0e10cSrcweir SvMetaAttribute * pAttr = aAttrList.GetObject( n );
617cdf0e10cSrcweir if( pAttr->GetName() == pTok->GetString() )
618cdf0e10cSrcweir return pAttr;
619cdf0e10cSrcweir }
620cdf0e10cSrcweir */
621cdf0e10cSrcweir }
622cdf0e10cSrcweir else
623cdf0e10cSrcweir {
624cdf0e10cSrcweir // sonst SlotId?
625cdf0e10cSrcweir SvToken * pTok = rInStm.GetToken_Next();
626cdf0e10cSrcweir if( pTok->IsIdentifier() )
627cdf0e10cSrcweir {
628cdf0e10cSrcweir sal_uLong n;
629cdf0e10cSrcweir if( FindId( pTok->GetString(), &n ) )
630cdf0e10cSrcweir {
631cdf0e10cSrcweir for( sal_uLong i = 0; i < aAttrList.Count(); i++ )
632cdf0e10cSrcweir {
633cdf0e10cSrcweir SvMetaAttribute * pAttr = aAttrList.GetObject( i );
634cdf0e10cSrcweir if( pAttr->GetSlotId() == pTok->GetString() )
635cdf0e10cSrcweir return pAttr;
636cdf0e10cSrcweir }
637cdf0e10cSrcweir }
638cdf0e10cSrcweir
639cdf0e10cSrcweir ByteString aStr( "Nicht gefunden : " );
640cdf0e10cSrcweir aStr += pTok->GetString();
641cdf0e10cSrcweir DBG_ERROR( aStr.GetBuffer() );
642cdf0e10cSrcweir }
643cdf0e10cSrcweir }
644cdf0e10cSrcweir
645cdf0e10cSrcweir rInStm.Seek( nTokPos );
646cdf0e10cSrcweir return NULL;
647cdf0e10cSrcweir }
648cdf0e10cSrcweir
SearchKnownAttr(const SvNumberIdentifier & rId)649cdf0e10cSrcweir SvMetaAttribute* SvIdlDataBase::SearchKnownAttr
650cdf0e10cSrcweir (
651cdf0e10cSrcweir const SvNumberIdentifier& rId
652cdf0e10cSrcweir )
653cdf0e10cSrcweir {
654cdf0e10cSrcweir sal_uLong n;
655cdf0e10cSrcweir if( FindId( rId, &n ) )
656cdf0e10cSrcweir {
657cdf0e10cSrcweir for( sal_uLong i = 0; i < aAttrList.Count(); i++ )
658cdf0e10cSrcweir {
659cdf0e10cSrcweir SvMetaAttribute * pAttr = aAttrList.GetObject( i );
660cdf0e10cSrcweir if( pAttr->GetSlotId() == rId )
661cdf0e10cSrcweir return pAttr;
662cdf0e10cSrcweir }
663cdf0e10cSrcweir }
664cdf0e10cSrcweir
665cdf0e10cSrcweir return NULL;
666cdf0e10cSrcweir }
667cdf0e10cSrcweir
668cdf0e10cSrcweir /*************************************************************************
669cdf0e10cSrcweir |* SvIdlDataBase::ReadKnownClass()
670cdf0e10cSrcweir |*
671cdf0e10cSrcweir |* Beschreibung
672cdf0e10cSrcweir *************************************************************************/
ReadKnownClass(SvTokenStream & rInStm)673cdf0e10cSrcweir SvMetaClass * SvIdlDataBase::ReadKnownClass( SvTokenStream & rInStm )
674cdf0e10cSrcweir {
675cdf0e10cSrcweir sal_uInt32 nTokPos = rInStm.Tell();
676cdf0e10cSrcweir SvToken * pTok = rInStm.GetToken_Next();
677cdf0e10cSrcweir
678cdf0e10cSrcweir if( pTok->IsIdentifier() )
679cdf0e10cSrcweir for( sal_uLong n = 0; n < aClassList.Count(); n++ )
680cdf0e10cSrcweir {
681cdf0e10cSrcweir SvMetaClass * pClass = aClassList.GetObject( n );
682cdf0e10cSrcweir if( pClass->GetName() == pTok->GetString() )
683cdf0e10cSrcweir return pClass;
684cdf0e10cSrcweir }
685cdf0e10cSrcweir
686cdf0e10cSrcweir rInStm.Seek( nTokPos );
687cdf0e10cSrcweir return NULL;
688cdf0e10cSrcweir }
689cdf0e10cSrcweir
690cdf0e10cSrcweir /*************************************************************************
691cdf0e10cSrcweir |* SvIdlDataBase::Write()
692cdf0e10cSrcweir |*
693cdf0e10cSrcweir |* Beschreibung
694cdf0e10cSrcweir *************************************************************************/
Write(const ByteString & rText)695cdf0e10cSrcweir void SvIdlDataBase::Write( const ByteString & rText )
696cdf0e10cSrcweir {
697cdf0e10cSrcweir if( nVerbosity != 0 )
698cdf0e10cSrcweir fprintf( stdout, "%s", rText.GetBuffer() );
699cdf0e10cSrcweir }
700cdf0e10cSrcweir
701cdf0e10cSrcweir /*************************************************************************
702cdf0e10cSrcweir |* SvIdlDataBase::WriteError()
703cdf0e10cSrcweir |*
704cdf0e10cSrcweir |* Beschreibung
705cdf0e10cSrcweir *************************************************************************/
WriteError(const ByteString & rErrWrn,const ByteString & rFileName,const ByteString & rErrorText,sal_uLong nRow,sal_uLong nColumn) const706cdf0e10cSrcweir void SvIdlDataBase::WriteError( const ByteString & rErrWrn,
707cdf0e10cSrcweir const ByteString & rFileName,
708cdf0e10cSrcweir const ByteString & rErrorText,
709cdf0e10cSrcweir sal_uLong nRow, sal_uLong nColumn ) const
710cdf0e10cSrcweir {
711cdf0e10cSrcweir //Fehlerbehandlung
712cdf0e10cSrcweir fprintf( stderr, "\n%s --- %s: ( %ld, %ld )\n",
713cdf0e10cSrcweir rFileName.GetBuffer(), rErrWrn.GetBuffer(), nRow, nColumn );
714cdf0e10cSrcweir
715cdf0e10cSrcweir if( rErrorText.Len() )
716cdf0e10cSrcweir { // Fehler gesetzt
717cdf0e10cSrcweir fprintf( stderr, "\t%s\n", rErrorText.GetBuffer() );
718cdf0e10cSrcweir }
719cdf0e10cSrcweir }
720cdf0e10cSrcweir
721cdf0e10cSrcweir /*************************************************************************
722cdf0e10cSrcweir |* SvIdlDataBase::WriteError()
723cdf0e10cSrcweir |*
724cdf0e10cSrcweir |* Beschreibung
725cdf0e10cSrcweir *************************************************************************/
WriteError(SvTokenStream & rInStm)726cdf0e10cSrcweir void SvIdlDataBase::WriteError( SvTokenStream & rInStm )
727cdf0e10cSrcweir {
728cdf0e10cSrcweir //Fehlerbehandlung
729cdf0e10cSrcweir String aFileName( rInStm.GetFileName() );
730cdf0e10cSrcweir ByteString aErrorText;
731cdf0e10cSrcweir sal_uLong nRow = 0, nColumn = 0;
732cdf0e10cSrcweir
733cdf0e10cSrcweir rInStm.SeekEnd();
734cdf0e10cSrcweir SvToken *pTok = rInStm.GetToken();
735cdf0e10cSrcweir
736cdf0e10cSrcweir // Fehlerposition
737cdf0e10cSrcweir nRow = pTok->GetLine();
738cdf0e10cSrcweir nColumn = pTok->GetColumn();
739cdf0e10cSrcweir
740cdf0e10cSrcweir if( aError.IsError() )
741cdf0e10cSrcweir { // Fehler gesetzt
742cdf0e10cSrcweir // Fehler Token suchen
743cdf0e10cSrcweir // Fehlertext
744cdf0e10cSrcweir if( aError.GetText().Len() )
745cdf0e10cSrcweir {
746cdf0e10cSrcweir aErrorText = "may be <";
747cdf0e10cSrcweir aErrorText += aError.GetText();
748cdf0e10cSrcweir }
749cdf0e10cSrcweir SvToken * pPrevTok = NULL;
750cdf0e10cSrcweir while( pTok != pPrevTok )
751cdf0e10cSrcweir {
752cdf0e10cSrcweir pPrevTok = pTok;
753cdf0e10cSrcweir if( pTok->GetLine() == aError.nLine
754cdf0e10cSrcweir && pTok->GetColumn() == aError.nColumn )
755cdf0e10cSrcweir break;
756cdf0e10cSrcweir pTok = rInStm.GetToken_PrevAll();
757cdf0e10cSrcweir }
758cdf0e10cSrcweir
759cdf0e10cSrcweir // Fehlerposition
760cdf0e10cSrcweir aErrorText += "> at ( ";
761cdf0e10cSrcweir aErrorText += ByteString::CreateFromInt64(aError.nLine);
762cdf0e10cSrcweir aErrorText += ", ";
763cdf0e10cSrcweir aErrorText += ByteString::CreateFromInt64(aError.nColumn);
764cdf0e10cSrcweir aErrorText += " )";
765cdf0e10cSrcweir
766cdf0e10cSrcweir // Fehler zuruecksetzen
767cdf0e10cSrcweir aError = SvIdlError();
768cdf0e10cSrcweir }
769cdf0e10cSrcweir
770cdf0e10cSrcweir WriteError( "error", ByteString( aFileName, RTL_TEXTENCODING_UTF8 ), aErrorText, nRow, nColumn );
771cdf0e10cSrcweir
772cdf0e10cSrcweir DBG_ASSERT( pTok, "token must be found" );
773cdf0e10cSrcweir if( !pTok )
774cdf0e10cSrcweir return;
775cdf0e10cSrcweir
776cdf0e10cSrcweir // Identifier in der Naehe suchen
777cdf0e10cSrcweir if( !pTok->IsIdentifier() )
778cdf0e10cSrcweir {
779cdf0e10cSrcweir rInStm.GetToken_PrevAll();
780cdf0e10cSrcweir pTok = rInStm.GetToken();
781cdf0e10cSrcweir }
782cdf0e10cSrcweir if( pTok && pTok->IsIdentifier() )
783cdf0e10cSrcweir {
784cdf0e10cSrcweir ByteString aN = IDLAPP->pHashTable->GetNearString( pTok->GetString() );
785cdf0e10cSrcweir if( aN.Len() )
786cdf0e10cSrcweir fprintf( stderr, "%s versus %s\n", pTok->GetString().GetBuffer(), aN.GetBuffer() );
787cdf0e10cSrcweir }
788cdf0e10cSrcweir }
789cdf0e10cSrcweir
790cdf0e10cSrcweir /****************** SvIdlWorkingBase ****************************************/
791cdf0e10cSrcweir /*************************************************************************
792cdf0e10cSrcweir |* SvIdlWorkingBase::SvIdlWorkingBase()
793cdf0e10cSrcweir |*
794cdf0e10cSrcweir |* Beschreibung
795cdf0e10cSrcweir *************************************************************************/
SvIdlWorkingBase(const SvCommand & rCmd)796cdf0e10cSrcweir SvIdlWorkingBase::SvIdlWorkingBase(const SvCommand& rCmd) : SvIdlDataBase(rCmd)
797cdf0e10cSrcweir {
798cdf0e10cSrcweir }
799cdf0e10cSrcweir
800cdf0e10cSrcweir /*************************************************************************
801cdf0e10cSrcweir |* SvIdlWorkingBase::ReadSvIdl()
802cdf0e10cSrcweir |*
803cdf0e10cSrcweir |* Beschreibung
804cdf0e10cSrcweir *************************************************************************/
ReadSvIdl(SvTokenStream & rInStm,sal_Bool bImported,const String & rPath)805cdf0e10cSrcweir sal_Bool SvIdlWorkingBase::ReadSvIdl( SvTokenStream & rInStm, sal_Bool bImported, const String & rPath )
806cdf0e10cSrcweir {
807cdf0e10cSrcweir aPath = rPath; // nur fuer den durchlauf gueltig
808cdf0e10cSrcweir SvToken * pTok;
809cdf0e10cSrcweir sal_Bool bOk = sal_True;
810cdf0e10cSrcweir pTok = rInStm.GetToken();
811cdf0e10cSrcweir // nur ein import ganz am Anfang
812cdf0e10cSrcweir if( pTok->Is( SvHash_import() ) )
813cdf0e10cSrcweir {
814cdf0e10cSrcweir rInStm.GetToken_Next();
815cdf0e10cSrcweir rInStm.Read( '(' ); // optional
816cdf0e10cSrcweir pTok = rInStm.GetToken_Next();
817cdf0e10cSrcweir if( pTok->IsString() )
818cdf0e10cSrcweir {
819cdf0e10cSrcweir DirEntry aFullName( String::CreateFromAscii( pTok->GetString().GetBuffer() ) );
820cdf0e10cSrcweir if( aFullName.Find( rPath ) )
821cdf0e10cSrcweir {
822cdf0e10cSrcweir SvFileStream aStm( aFullName.GetFull(),
823cdf0e10cSrcweir STREAM_STD_READ | STREAM_NOCREATE );
824cdf0e10cSrcweir Load( aStm );
825cdf0e10cSrcweir if( aStm.GetError() != SVSTREAM_OK )
826cdf0e10cSrcweir {
827cdf0e10cSrcweir if( aStm.GetError() == SVSTREAM_WRONGVERSION )
828cdf0e10cSrcweir {
829cdf0e10cSrcweir ByteString aStr( "wrong version, file " );
830cdf0e10cSrcweir aStr += ByteString( aFullName.GetFull(), RTL_TEXTENCODING_UTF8 );
831cdf0e10cSrcweir SetError( aStr, pTok );
832cdf0e10cSrcweir WriteError( rInStm );
833cdf0e10cSrcweir bOk = sal_False;
834cdf0e10cSrcweir }
835cdf0e10cSrcweir else
836cdf0e10cSrcweir {
837cdf0e10cSrcweir aStm.Seek( 0 );
838cdf0e10cSrcweir aStm.ResetError();
839cdf0e10cSrcweir SvTokenStream aTokStm( aStm, aFullName.GetFull() );
840cdf0e10cSrcweir bOk = ReadSvIdl( aTokStm, sal_True, rPath );
841cdf0e10cSrcweir }
842cdf0e10cSrcweir }
843cdf0e10cSrcweir }
844cdf0e10cSrcweir else
845cdf0e10cSrcweir bOk = sal_False;
846cdf0e10cSrcweir }
847cdf0e10cSrcweir else
848cdf0e10cSrcweir bOk = sal_False;
849cdf0e10cSrcweir }
850cdf0e10cSrcweir
851cdf0e10cSrcweir sal_uInt32 nBeginPos = 0xFFFFFFFF; // kann mit Tell nicht vorkommen
852cdf0e10cSrcweir
853cdf0e10cSrcweir while( bOk && nBeginPos != rInStm.Tell() )
854cdf0e10cSrcweir {
855cdf0e10cSrcweir nBeginPos = rInStm.Tell();
856cdf0e10cSrcweir pTok = rInStm.GetToken();
857cdf0e10cSrcweir if( pTok->IsEof() )
858cdf0e10cSrcweir return sal_True;
859cdf0e10cSrcweir if( pTok->IsEmpty() )
860cdf0e10cSrcweir bOk = sal_False;
861cdf0e10cSrcweir
862cdf0e10cSrcweir // nur ein import ganz am Anfang
863cdf0e10cSrcweir /*else */if( pTok->Is( SvHash_module() ) )
864cdf0e10cSrcweir {
865cdf0e10cSrcweir SvMetaModuleRef aModule = new SvMetaModule( rInStm.GetFileName(), bImported );
866cdf0e10cSrcweir if( aModule->ReadSvIdl( *this, rInStm ) )
867cdf0e10cSrcweir GetModuleList().Append( aModule );
868cdf0e10cSrcweir else
869cdf0e10cSrcweir bOk = sal_False;
870cdf0e10cSrcweir }
871cdf0e10cSrcweir else
872cdf0e10cSrcweir bOk = sal_False;
873cdf0e10cSrcweir }
874cdf0e10cSrcweir if( !bOk || !pTok->IsEof() )
875cdf0e10cSrcweir {
876cdf0e10cSrcweir //Fehlerbehandlung
877cdf0e10cSrcweir WriteError( rInStm );
878cdf0e10cSrcweir return sal_False;
879cdf0e10cSrcweir }
880cdf0e10cSrcweir return sal_True;
881cdf0e10cSrcweir }
882cdf0e10cSrcweir
883cdf0e10cSrcweir /*************************************************************************
884cdf0e10cSrcweir |* SvIdlWorkingBase::WriteSvIdl()
885cdf0e10cSrcweir |*
886cdf0e10cSrcweir |* Beschreibung
887cdf0e10cSrcweir *************************************************************************/
WriteSvIdl(SvStream & rOutStm)888cdf0e10cSrcweir sal_Bool SvIdlWorkingBase::WriteSvIdl( SvStream & rOutStm )
889cdf0e10cSrcweir {
890cdf0e10cSrcweir if( rOutStm.GetError() != SVSTREAM_OK )
891cdf0e10cSrcweir return sal_False;
892cdf0e10cSrcweir
893cdf0e10cSrcweir SvStringHashList aList;
894cdf0e10cSrcweir if( GetIdTable() )
895cdf0e10cSrcweir {
896cdf0e10cSrcweir GetIdTable()->FillHashList( &aList );
897cdf0e10cSrcweir SvStringHashEntry * pEntry = aList.First();
898cdf0e10cSrcweir while( pEntry )
899cdf0e10cSrcweir {
900cdf0e10cSrcweir rOutStm << "#define " << pEntry->GetName().GetBuffer()
901cdf0e10cSrcweir << '\t'
902cdf0e10cSrcweir << ByteString::CreateFromInt64(
903cdf0e10cSrcweir pEntry->GetValue() ).GetBuffer()
904cdf0e10cSrcweir << endl;
905cdf0e10cSrcweir pEntry = aList.Next();
906cdf0e10cSrcweir }
907cdf0e10cSrcweir }
908cdf0e10cSrcweir
909cdf0e10cSrcweir for( sal_uLong n = 0; n < GetModuleList().Count(); n++ )
910cdf0e10cSrcweir {
911cdf0e10cSrcweir SvMetaModule * pModule = GetModuleList().GetObject( n );
912cdf0e10cSrcweir //if( !pModule->IsImported() )
913cdf0e10cSrcweir pModule->WriteSvIdl( *this, rOutStm, 0 );
914cdf0e10cSrcweir }
915cdf0e10cSrcweir return sal_True;
916cdf0e10cSrcweir }
917cdf0e10cSrcweir
918cdf0e10cSrcweir /*************************************************************************
919cdf0e10cSrcweir |* SvIdlWorkingBase::WriteSfx()
920cdf0e10cSrcweir |*
921cdf0e10cSrcweir |* Beschreibung
922cdf0e10cSrcweir *************************************************************************/
WriteSfx(SvStream & rOutStm)923cdf0e10cSrcweir sal_Bool SvIdlWorkingBase::WriteSfx( SvStream & rOutStm )
924cdf0e10cSrcweir {
925cdf0e10cSrcweir if( rOutStm.GetError() != SVSTREAM_OK )
926cdf0e10cSrcweir return sal_False;
927cdf0e10cSrcweir
928cdf0e10cSrcweir // alle Tmp-Variablen fuer das Schreiben zuruecksetzen
929cdf0e10cSrcweir WriteReset();
930cdf0e10cSrcweir SvMemoryStream aTmpStm( 256000, 256000 );
931cdf0e10cSrcweir sal_uLong n;
932cdf0e10cSrcweir for( n = 0; n < GetModuleList().Count(); n++ )
933cdf0e10cSrcweir {
934cdf0e10cSrcweir SvMetaModule * pModule = GetModuleList().GetObject( n );
935cdf0e10cSrcweir if( !pModule->IsImported() )
936cdf0e10cSrcweir pModule->WriteSfx( *this, aTmpStm );
937cdf0e10cSrcweir aTmpStm.Seek( 0 );
938cdf0e10cSrcweir }
939cdf0e10cSrcweir for( n = 0; n < aUsedTypes.Count(); n++ )
940cdf0e10cSrcweir {
941cdf0e10cSrcweir SvMetaType * pType = aUsedTypes.GetObject( n );
942cdf0e10cSrcweir pType->WriteSfx( *this, rOutStm );
943cdf0e10cSrcweir }
944cdf0e10cSrcweir aUsedTypes.Clear();
945cdf0e10cSrcweir rOutStm << aTmpStm;
946cdf0e10cSrcweir return sal_True;
947cdf0e10cSrcweir }
948cdf0e10cSrcweir
WriteHelpIds(SvStream & rOutStm)949cdf0e10cSrcweir sal_Bool SvIdlWorkingBase::WriteHelpIds( SvStream& rOutStm )
950cdf0e10cSrcweir {
951cdf0e10cSrcweir if( rOutStm.GetError() != SVSTREAM_OK )
952cdf0e10cSrcweir return sal_False;
953cdf0e10cSrcweir
954cdf0e10cSrcweir Table aIdTable;
955cdf0e10cSrcweir sal_uLong n;
956cdf0e10cSrcweir for( n = 0; n < GetModuleList().Count(); n++ )
957cdf0e10cSrcweir {
958cdf0e10cSrcweir SvMetaModule * pModule = GetModuleList().GetObject( n );
959cdf0e10cSrcweir //if( !pModule->IsImported() )
960cdf0e10cSrcweir pModule->WriteHelpIds( *this, rOutStm, &aIdTable );
961cdf0e10cSrcweir }
962cdf0e10cSrcweir
963cdf0e10cSrcweir const SvMetaAttributeMemberList & rAttrList = GetAttrList();
964cdf0e10cSrcweir for( n = 0; n < rAttrList.Count(); n++ )
965cdf0e10cSrcweir {
966cdf0e10cSrcweir SvMetaAttribute * pAttr = rAttrList.GetObject( n );
967cdf0e10cSrcweir pAttr->WriteHelpId( *this, rOutStm, &aIdTable );
968cdf0e10cSrcweir }
969cdf0e10cSrcweir
970cdf0e10cSrcweir return sal_True;
971cdf0e10cSrcweir }
972cdf0e10cSrcweir
973cdf0e10cSrcweir /*************************************************************************
974cdf0e10cSrcweir |* SvIdlWorkingBase::WriteSfxItem()
975cdf0e10cSrcweir |*
976cdf0e10cSrcweir |* Beschreibung
977cdf0e10cSrcweir *************************************************************************/
WriteSfxItem(SvStream &)978cdf0e10cSrcweir sal_Bool SvIdlWorkingBase::WriteSfxItem( SvStream & )
979cdf0e10cSrcweir {
980cdf0e10cSrcweir return sal_False;
981cdf0e10cSrcweir }
982cdf0e10cSrcweir
StartNewFile(const String & rName)983cdf0e10cSrcweir void SvIdlDataBase::StartNewFile( const String& rName )
984cdf0e10cSrcweir {
985cdf0e10cSrcweir bExport = ( aExportFile.EqualsIgnoreCaseAscii( rName ) );
986cdf0e10cSrcweir }
987cdf0e10cSrcweir
AppendAttr(SvMetaAttribute * pAttr)988cdf0e10cSrcweir void SvIdlDataBase::AppendAttr( SvMetaAttribute *pAttr )
989cdf0e10cSrcweir {
990cdf0e10cSrcweir aAttrList.Append( pAttr );
991cdf0e10cSrcweir if ( bExport )
992cdf0e10cSrcweir pAttr->SetNewAttribute( sal_True );
993cdf0e10cSrcweir }
994cdf0e10cSrcweir
WriteCSV(SvStream & rStrm)995cdf0e10cSrcweir sal_Bool SvIdlWorkingBase::WriteCSV( SvStream& rStrm )
996cdf0e10cSrcweir {
997cdf0e10cSrcweir SvMetaAttributeMemberList &rList = GetAttrList();
998cdf0e10cSrcweir sal_uLong nCount = rList.Count();
999cdf0e10cSrcweir for ( sal_uLong n=0; n<nCount; n++ )
1000cdf0e10cSrcweir {
1001cdf0e10cSrcweir if ( rList.GetObject(n)->IsNewAttribute() )
1002cdf0e10cSrcweir {
1003cdf0e10cSrcweir rList.GetObject(n)->WriteCSV( *this, rStrm );
1004cdf0e10cSrcweir }
1005cdf0e10cSrcweir }
1006cdf0e10cSrcweir
1007cdf0e10cSrcweir if ( rStrm.GetError() != SVSTREAM_OK )
1008cdf0e10cSrcweir return sal_False;
1009cdf0e10cSrcweir else
1010cdf0e10cSrcweir return sal_True;
1011cdf0e10cSrcweir }
1012cdf0e10cSrcweir
1013cdf0e10cSrcweir /*************************************************************************
1014cdf0e10cSrcweir |* SvIdlWorkingBase::WriteDocumentation()
1015cdf0e10cSrcweir |*
1016cdf0e10cSrcweir |* Beschreibung
1017cdf0e10cSrcweir *************************************************************************/
WriteDocumentation(SvStream & rOutStm)1018cdf0e10cSrcweir sal_Bool SvIdlWorkingBase::WriteDocumentation( SvStream & rOutStm )
1019cdf0e10cSrcweir {
1020cdf0e10cSrcweir if( rOutStm.GetError() != SVSTREAM_OK )
1021cdf0e10cSrcweir return sal_False;
1022cdf0e10cSrcweir
1023cdf0e10cSrcweir for( sal_uLong n = 0; n < GetModuleList().Count(); n++ )
1024cdf0e10cSrcweir {
1025cdf0e10cSrcweir SvMetaModule * pModule = GetModuleList().GetObject( n );
1026cdf0e10cSrcweir if( !pModule->IsImported() )
1027cdf0e10cSrcweir pModule->Write( *this, rOutStm, 0, WRITE_DOCU );
1028cdf0e10cSrcweir }
1029cdf0e10cSrcweir return sal_True;
1030cdf0e10cSrcweir }
1031cdf0e10cSrcweir
1032cdf0e10cSrcweir
1033cdf0e10cSrcweir
1034cdf0e10cSrcweir #endif // IDL_COMPILER
1035cdf0e10cSrcweir
1036