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 #include <precomp.h> 29*cdf0e10cSrcweir #include <parser/unoidl.hxx> 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir 32*cdf0e10cSrcweir // NOT FULLY DECLARED SERVICES 33*cdf0e10cSrcweir #include <stdlib.h> 34*cdf0e10cSrcweir #include <cosv/file.hxx> 35*cdf0e10cSrcweir #include <ary/ary.hxx> 36*cdf0e10cSrcweir #include <ary/idl/i_gate.hxx> 37*cdf0e10cSrcweir #include <ary/doc/d_oldidldocu.hxx> 38*cdf0e10cSrcweir #include <../parser/inc/x_docu.hxx> 39*cdf0e10cSrcweir #include <parser/parserinfo.hxx> 40*cdf0e10cSrcweir #include <tools/filecoll.hxx> 41*cdf0e10cSrcweir #include <tools/tkpchars.hxx> 42*cdf0e10cSrcweir #include <s2_luidl/tkp_uidl.hxx> 43*cdf0e10cSrcweir #include <s2_luidl/distrib.hxx> 44*cdf0e10cSrcweir #include <s2_luidl/pe_file2.hxx> 45*cdf0e10cSrcweir #include <s2_dsapi/cx_dsapi.hxx> 46*cdf0e10cSrcweir #include <adc_msg.hxx> 47*cdf0e10cSrcweir #include <x_parse2.hxx> 48*cdf0e10cSrcweir 49*cdf0e10cSrcweir 50*cdf0e10cSrcweir 51*cdf0e10cSrcweir namespace autodoc 52*cdf0e10cSrcweir { 53*cdf0e10cSrcweir 54*cdf0e10cSrcweir 55*cdf0e10cSrcweir class FileParsePerformers 56*cdf0e10cSrcweir { 57*cdf0e10cSrcweir public: 58*cdf0e10cSrcweir FileParsePerformers( 59*cdf0e10cSrcweir ary::Repository & 60*cdf0e10cSrcweir io_rRepository, 61*cdf0e10cSrcweir ParserInfo & io_rParserInfo ); 62*cdf0e10cSrcweir 63*cdf0e10cSrcweir void ParseFile( 64*cdf0e10cSrcweir const char * i_sFullPath ); 65*cdf0e10cSrcweir 66*cdf0e10cSrcweir void ConnectLinks(); 67*cdf0e10cSrcweir 68*cdf0e10cSrcweir private: 69*cdf0e10cSrcweir CharacterSource aFileLoader; 70*cdf0e10cSrcweir Dyn<csi::uidl::TokenParser_Uidl> 71*cdf0e10cSrcweir pTokens; 72*cdf0e10cSrcweir csi::uidl::TokenDistributor 73*cdf0e10cSrcweir aDistributor; 74*cdf0e10cSrcweir Dyn<csi::uidl::PE_File> 75*cdf0e10cSrcweir pFileParseEnvironment; 76*cdf0e10cSrcweir ary::Repository & 77*cdf0e10cSrcweir rRepository; 78*cdf0e10cSrcweir ParserInfo & rParserInfo; 79*cdf0e10cSrcweir }; 80*cdf0e10cSrcweir 81*cdf0e10cSrcweir 82*cdf0e10cSrcweir IdlParser::IdlParser( ary::Repository & io_rRepository ) 83*cdf0e10cSrcweir : pRepository(&io_rRepository) 84*cdf0e10cSrcweir { 85*cdf0e10cSrcweir } 86*cdf0e10cSrcweir 87*cdf0e10cSrcweir void 88*cdf0e10cSrcweir IdlParser::Run( const autodoc::FileCollector_Ifc & i_rFiles ) 89*cdf0e10cSrcweir { 90*cdf0e10cSrcweir Dyn<FileParsePerformers> 91*cdf0e10cSrcweir pFileParsePerformers( 92*cdf0e10cSrcweir new FileParsePerformers(*pRepository, 93*cdf0e10cSrcweir static_cast< ParserInfo& >(*this)) ); 94*cdf0e10cSrcweir 95*cdf0e10cSrcweir FileCollector::const_iterator iEnd = i_rFiles.End(); 96*cdf0e10cSrcweir for ( FileCollector::const_iterator iter = i_rFiles.Begin(); 97*cdf0e10cSrcweir iter != iEnd; 98*cdf0e10cSrcweir ++iter ) 99*cdf0e10cSrcweir { 100*cdf0e10cSrcweir Cout() << (*iter) << " ..."<< Endl(); 101*cdf0e10cSrcweir 102*cdf0e10cSrcweir try 103*cdf0e10cSrcweir { 104*cdf0e10cSrcweir pFileParsePerformers->ParseFile(*iter); 105*cdf0e10cSrcweir } 106*cdf0e10cSrcweir catch (X_AutodocParser &) 107*cdf0e10cSrcweir { 108*cdf0e10cSrcweir /// Ignore and goon 109*cdf0e10cSrcweir TheMessages().Out_ParseError(CurFile(), CurLine()); 110*cdf0e10cSrcweir pFileParsePerformers 111*cdf0e10cSrcweir = new FileParsePerformers(*pRepository, 112*cdf0e10cSrcweir static_cast< ParserInfo& >(*this)); 113*cdf0e10cSrcweir } 114*cdf0e10cSrcweir catch (X_Docu & xd) 115*cdf0e10cSrcweir { 116*cdf0e10cSrcweir // Currently thic catches only wrong since tags, while since tags are 117*cdf0e10cSrcweir // transformed. In this case the program shall be terminated. 118*cdf0e10cSrcweir Cerr() << xd << Endl(); 119*cdf0e10cSrcweir exit(1); 120*cdf0e10cSrcweir } 121*cdf0e10cSrcweir catch (...) 122*cdf0e10cSrcweir { 123*cdf0e10cSrcweir Cout() << "Unknown error." << Endl(); 124*cdf0e10cSrcweir exit(0); 125*cdf0e10cSrcweir // pFileParsePerformers = new FileParsePerformers( *pRepository ); 126*cdf0e10cSrcweir } 127*cdf0e10cSrcweir } 128*cdf0e10cSrcweir 129*cdf0e10cSrcweir pFileParsePerformers->ConnectLinks(); 130*cdf0e10cSrcweir } 131*cdf0e10cSrcweir 132*cdf0e10cSrcweir FileParsePerformers::FileParsePerformers( ary::Repository & io_rRepository, 133*cdf0e10cSrcweir ParserInfo & io_rParserInfo ) 134*cdf0e10cSrcweir : pTokens(0), 135*cdf0e10cSrcweir aDistributor(io_rRepository, io_rParserInfo), 136*cdf0e10cSrcweir rRepository( io_rRepository ), 137*cdf0e10cSrcweir rParserInfo(io_rParserInfo) 138*cdf0e10cSrcweir { 139*cdf0e10cSrcweir DYN csi::dsapi::Context_Docu * 140*cdf0e10cSrcweir dpDocuContext 141*cdf0e10cSrcweir = new csi::dsapi::Context_Docu( aDistributor.DocuTokens_Receiver() ); 142*cdf0e10cSrcweir pTokens = new csi::uidl::TokenParser_Uidl( aDistributor.CodeTokens_Receiver(), *dpDocuContext ); 143*cdf0e10cSrcweir pFileParseEnvironment 144*cdf0e10cSrcweir = new csi::uidl::PE_File(aDistributor,rParserInfo); 145*cdf0e10cSrcweir 146*cdf0e10cSrcweir aDistributor.SetTokenProvider(*pTokens); 147*cdf0e10cSrcweir aDistributor.SetTopParseEnvironment(*pFileParseEnvironment); 148*cdf0e10cSrcweir } 149*cdf0e10cSrcweir 150*cdf0e10cSrcweir void 151*cdf0e10cSrcweir FileParsePerformers::ParseFile( const char * i_sFullPath ) 152*cdf0e10cSrcweir { 153*cdf0e10cSrcweir csv::File aFile(i_sFullPath); 154*cdf0e10cSrcweir 155*cdf0e10cSrcweir aFile.open( csv::CFM_READ ); 156*cdf0e10cSrcweir csv_assert( aFile.is_open() ); 157*cdf0e10cSrcweir aFileLoader.LoadText(aFile); 158*cdf0e10cSrcweir aFile.close(); 159*cdf0e10cSrcweir 160*cdf0e10cSrcweir rParserInfo.Set_CurFile(i_sFullPath, true); // true = count lines 161*cdf0e10cSrcweir pTokens->Start(aFileLoader); 162*cdf0e10cSrcweir aDistributor.Reset(); 163*cdf0e10cSrcweir 164*cdf0e10cSrcweir do { 165*cdf0e10cSrcweir aDistributor.TradeToken(); 166*cdf0e10cSrcweir } while ( NOT aFileLoader.IsFinished() ); 167*cdf0e10cSrcweir } 168*cdf0e10cSrcweir 169*cdf0e10cSrcweir void 170*cdf0e10cSrcweir FileParsePerformers::ConnectLinks() 171*cdf0e10cSrcweir { 172*cdf0e10cSrcweir // KORR_FUTURE ? 173*cdf0e10cSrcweir // rRepository.RwGate_Idl().ConnectAdditionalLinks(); 174*cdf0e10cSrcweir } 175*cdf0e10cSrcweir 176*cdf0e10cSrcweir } // namespace autodoc 177