1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #include <precomp.h>
29 #include "c_dealer.hxx"
30 
31 
32 // NOT FULLY DECLARED SERVICES
33 #include <ary/cpp/c_gate.hxx>
34 #include <ary/loc/locp_le.hxx>
35 #include <ary/loc/loc_root.hxx>
36 #include <ary/loc/loc_file.hxx>
37 //#include <ary/docu.hxx>
38 #include <adoc/a_rdocu.hxx>
39 #include "all_toks.hxx"
40 #include "c_rcode.hxx"
41 
42 
43 namespace ary
44 {
45 namespace loc
46 {
47     class Root;
48 }
49 }
50 
51 
52 
53 
54 namespace cpp
55 {
56 
57 Distributor::Distributor( ary::cpp::Gate & io_rAryGate )
58 	:   aCppPreProcessor(),
59 		aCodeExplorer(io_rAryGate),
60 		aDocuExplorer(),
61         pGate(&io_rAryGate),
62         pFileEventHandler(0),
63         pDocuDistributor(0)
64 {
65     pFileEventHandler = & aCodeExplorer.FileEventHandler();
66     pDocuDistributor = & aCodeExplorer.DocuDistributor();
67 }
68 
69 void
70 Distributor::AssignPartners( CharacterSource &   io_rSourceText,
71                              const MacroMap &    i_rValidMacros )
72 {
73     aCppPreProcessor.AssignPartners(aCodeExplorer, io_rSourceText, i_rValidMacros);
74 }
75 
76 Distributor::~Distributor()
77 {
78 }
79 
80 void
81 Distributor::StartNewFile( const csv::ploc::Path & i_file )
82 {
83     const csv::ploc::Root &
84         root_dir = i_file.RootDir();
85     StreamLock
86         sl(700);
87     root_dir.Get(sl());
88     csv::ploc::Path
89         root_path( sl().c_str(), true );
90     ary::loc::Le_id
91         root_id = pGate->Locations().CheckIn_Root(root_path).LeId();
92     ary::loc::File &
93         rFile = pGate->Locations().CheckIn_File(
94                                         i_file.File(),
95                                         i_file.DirChain(),
96                                         root_id  );
97     pFileEventHandler->SetCurFile(rFile);
98 
99 	aCodeExplorer.StartNewFile();
100 
101     csv_assert( pDocuDistributor != 0 );
102     aDocuExplorer.StartNewFile(*pDocuDistributor);
103 }
104 
105 
106 void
107 Distributor::Deal_Eol()
108 {
109 	pFileEventHandler->Event_IncrLineCount();
110 }
111 
112 void
113 Distributor::Deal_Eof()
114 {
115 	// Do nothing yet.
116 }
117 
118 void
119 Distributor::Deal_Cpp_UnblockMacro( Tok_UnblockMacro & let_drToken )
120 {
121     aCppPreProcessor.UnblockMacro(let_drToken.Text());
122     delete &let_drToken;
123 }
124 
125 void
126 Distributor::Deal_CppCode( cpp::Token & let_drToken )
127 {
128     aCppPreProcessor.Process_Token(let_drToken);
129 }
130 
131 void
132 Distributor::Deal_AdcDocu( adoc::Token & let_drToken )
133 {
134 	aDocuExplorer.Process_Token(let_drToken);
135 }
136 
137 Distributor *
138 Distributor::AsDistributor()
139 {
140  	return this;
141 }
142 
143 
144 
145 
146 
147 }   // namespace cpp
148 
149 
150