Update ooo320-m1
[ooovba.git] / autodoc / source / parser_i / idl / unoidl.cxx
blobb90d4920aed55e3e5c5737160525622bd85b9f99
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
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/inc/x_docu.hxx>
42 #include <parser/parserinfo.hxx>
43 #include <tools/filecoll.hxx>
44 #include <tools/tkpchars.hxx>
45 #include <s2_luidl/tkp_uidl.hxx>
46 #include <s2_luidl/distrib.hxx>
47 #include <s2_luidl/pe_file2.hxx>
48 #include <s2_dsapi/cx_dsapi.hxx>
49 #include <adc_msg.hxx>
50 #include <x_parse2.hxx>
54 namespace autodoc
58 class FileParsePerformers
60 public:
61 FileParsePerformers(
62 ary::Repository &
63 io_rRepository,
64 ParserInfo & io_rParserInfo );
66 void ParseFile(
67 const char * i_sFullPath );
69 void ConnectLinks();
71 private:
72 CharacterSource aFileLoader;
73 Dyn<csi::uidl::TokenParser_Uidl>
74 pTokens;
75 csi::uidl::TokenDistributor
76 aDistributor;
77 Dyn<csi::uidl::PE_File>
78 pFileParseEnvironment;
79 ary::Repository &
80 rRepository;
81 ParserInfo & rParserInfo;
85 IdlParser::IdlParser( ary::Repository & io_rRepository )
86 : pRepository(&io_rRepository)
90 void
91 IdlParser::Run( const autodoc::FileCollector_Ifc & i_rFiles )
93 Dyn<FileParsePerformers>
94 pFileParsePerformers(
95 new FileParsePerformers(*pRepository,
96 static_cast< ParserInfo& >(*this)) );
98 FileCollector::const_iterator iEnd = i_rFiles.End();
99 for ( FileCollector::const_iterator iter = i_rFiles.Begin();
100 iter != iEnd;
101 ++iter )
103 Cout() << (*iter) << " ..."<< Endl();
107 pFileParsePerformers->ParseFile(*iter);
109 catch (X_AutodocParser &)
111 /// Ignore and goon
112 TheMessages().Out_ParseError(CurFile(), CurLine());
113 pFileParsePerformers
114 = new FileParsePerformers(*pRepository,
115 static_cast< ParserInfo& >(*this));
117 catch (X_Docu & xd)
119 // Currently thic catches only wrong since tags, while since tags are
120 // transformed. In this case the program shall be terminated.
121 Cerr() << xd << Endl();
122 exit(1);
124 catch (...)
126 Cout() << "Unknown error." << Endl();
127 exit(0);
128 // pFileParsePerformers = new FileParsePerformers( *pRepository );
132 pFileParsePerformers->ConnectLinks();
135 FileParsePerformers::FileParsePerformers( ary::Repository & io_rRepository,
136 ParserInfo & io_rParserInfo )
137 : pTokens(0),
138 aDistributor(io_rRepository, io_rParserInfo),
139 rRepository( io_rRepository ),
140 rParserInfo(io_rParserInfo)
142 DYN csi::dsapi::Context_Docu *
143 dpDocuContext
144 = new csi::dsapi::Context_Docu( aDistributor.DocuTokens_Receiver() );
145 pTokens = new csi::uidl::TokenParser_Uidl( aDistributor.CodeTokens_Receiver(), *dpDocuContext );
146 pFileParseEnvironment
147 = new csi::uidl::PE_File(aDistributor,rParserInfo);
149 aDistributor.SetTokenProvider(*pTokens);
150 aDistributor.SetTopParseEnvironment(*pFileParseEnvironment);
153 void
154 FileParsePerformers::ParseFile( const char * i_sFullPath )
156 csv::File aFile(i_sFullPath);
158 aFile.open( csv::CFM_READ );
159 csv_assert( aFile.is_open() );
160 aFileLoader.LoadText(aFile);
161 aFile.close();
163 rParserInfo.Set_CurFile(i_sFullPath, true); // true = count lines
164 pTokens->Start(aFileLoader);
165 aDistributor.Reset();
167 do {
168 aDistributor.TradeToken();
169 } while ( NOT aFileLoader.IsFinished() );
172 void
173 FileParsePerformers::ConnectLinks()
175 // KORR_FUTURE ?
176 // rRepository.RwGate_Idl().ConnectAdditionalLinks();
179 } // namespace autodoc