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