update dev300-m58
[ooovba.git] / autodoc / source / parser_i / idl / unoidl.cxx
blobcb68b9d41664fdd50ebaacb2adfc478da849e3a7
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: unoidl.cxx,v $
10 * $Revision: 1.10 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #include <precomp.h>
32 #include <parser/unoidl.hxx>
35 // NOT FULLY DECLARED SERVICES
36 #include <stdlib.h>
37 #include <cosv/file.hxx>
38 #include <ary/ary.hxx>
39 #include <ary/idl/i_gate.hxx>
40 #include <ary/doc/d_oldidldocu.hxx>
41 #include <parser/parserinfo.hxx>
42 #include <tools/filecoll.hxx>
43 #include <tools/tkpchars.hxx>
44 #include <s2_luidl/tkp_uidl.hxx>
45 #include <s2_luidl/distrib.hxx>
46 #include <s2_luidl/pe_file2.hxx>
47 #include <s2_dsapi/cx_dsapi.hxx>
48 #include <adc_msg.hxx>
49 #include <x_parse2.hxx>
53 namespace autodoc
57 class FileParsePerformers
59 public:
60 FileParsePerformers(
61 ary::Repository &
62 io_rRepository,
63 ParserInfo & io_rParserInfo );
65 void ParseFile(
66 const char * i_sFullPath );
68 void ConnectLinks();
70 private:
71 CharacterSource aFileLoader;
72 Dyn<csi::uidl::TokenParser_Uidl>
73 pTokens;
74 csi::uidl::TokenDistributor
75 aDistributor;
76 Dyn<csi::uidl::PE_File>
77 pFileParseEnvironment;
78 ary::Repository &
79 rRepository;
80 ParserInfo & rParserInfo;
84 IdlParser::IdlParser( ary::Repository & io_rRepository )
85 : pRepository(&io_rRepository)
89 void
90 IdlParser::Run( const autodoc::FileCollector_Ifc & i_rFiles )
92 Dyn<FileParsePerformers>
93 pFileParsePerformers(
94 new FileParsePerformers(*pRepository,
95 static_cast< ParserInfo& >(*this)) );
97 FileCollector::const_iterator iEnd = i_rFiles.End();
98 for ( FileCollector::const_iterator iter = i_rFiles.Begin();
99 iter != iEnd;
100 ++iter )
102 Cout() << (*iter) << " ..."<< Endl();
106 pFileParsePerformers->ParseFile(*iter);
108 catch (X_AutodocParser &)
110 /// Ignore and goon
111 TheMessages().Out_ParseError(CurFile(), CurLine());
112 pFileParsePerformers
113 = new FileParsePerformers(*pRepository,
114 static_cast< ParserInfo& >(*this));
116 catch (...)
118 Cout() << "Unknown error." << Endl();
119 exit(0);
120 // pFileParsePerformers = new FileParsePerformers( *pRepository );
124 pFileParsePerformers->ConnectLinks();
127 FileParsePerformers::FileParsePerformers( ary::Repository & io_rRepository,
128 ParserInfo & io_rParserInfo )
129 : pTokens(0),
130 aDistributor(io_rRepository, io_rParserInfo),
131 rRepository( io_rRepository ),
132 rParserInfo(io_rParserInfo)
134 DYN csi::dsapi::Context_Docu *
135 dpDocuContext
136 = new csi::dsapi::Context_Docu( aDistributor.DocuTokens_Receiver() );
137 pTokens = new csi::uidl::TokenParser_Uidl( aDistributor.CodeTokens_Receiver(), *dpDocuContext );
138 pFileParseEnvironment
139 = new csi::uidl::PE_File(aDistributor,rParserInfo);
141 aDistributor.SetTokenProvider(*pTokens);
142 aDistributor.SetTopParseEnvironment(*pFileParseEnvironment);
145 void
146 FileParsePerformers::ParseFile( const char * i_sFullPath )
148 csv::File aFile(i_sFullPath);
150 aFile.open( csv::CFM_READ );
151 csv_assert( aFile.is_open() );
152 aFileLoader.LoadText(aFile);
153 aFile.close();
155 rParserInfo.Set_CurFile(i_sFullPath, true); // true = count lines
156 pTokens->Start(aFileLoader);
157 aDistributor.Reset();
159 do {
160 aDistributor.TradeToken();
161 } while ( NOT aFileLoader.IsFinished() );
164 void
165 FileParsePerformers::ConnectLinks()
167 // KORR_FUTURE ?
168 // rRepository.RwGate_Idl().ConnectAdditionalLinks();
171 } // namespace autodoc