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 <s2_luidl/pe_tydf2.hxx>
30 
31 // NOT FULLY DECLARED SERVICES
32 #include <ary/idl/i_gate.hxx>
33 #include <ary/idl/i_typedef.hxx>
34 #include <ary/idl/ip_ce.hxx>
35 #include <ary/doc/d_oldidldocu.hxx>
36 #include <s2_luidl/pe_type2.hxx>
37 #include <s2_luidl/tk_ident.hxx>
38 #include <s2_luidl/tk_punct.hxx>
39 #include <s2_luidl/tk_const.hxx>
40 
41 
42 namespace csi
43 {
44 namespace uidl
45 {
46 
47 
48 #ifdef DF
49 #undef DF
50 #endif
51 #define DF 	&PE_Typedef::On_Default
52 
53 PE_Typedef::F_TOK
54 PE_Typedef::aDispatcher[PE_Typedef::e_STATES_MAX][PE_Typedef::tt_MAX] =
55 		{ 	{ DF, DF, DF },  // e_none
56 			{ &PE_Typedef::On_expect_description_Any,
57 				  &PE_Typedef::On_expect_description_Any,
58 				      DF },  // expect_description
59 			{ DF, &PE_Typedef::On_expect_name_Identifier,
60 					  DF },  // expect_name
61 			{ DF, DF, &PE_Typedef::On_got_name_Punctuation }  // got_name
62 		};
63 
64 
65 
66 inline void
67 PE_Typedef::CallHandler( const char *		i_sTokenText,
68 						 E_TokenType		i_eTokenType )
69 	{ (this->*aDispatcher[eState][i_eTokenType])(i_sTokenText); }
70 
71 
72 
73 
74 
75 PE_Typedef::PE_Typedef()
76 	:	eState(e_none),
77 		pPE_Type(0),
78 		nType(0),
79 		sName()
80 {
81 	pPE_Type = new PE_Type(nType);
82 }
83 
84 void
85 PE_Typedef::EstablishContacts( UnoIDL_PE *				io_pParentPE,
86 							   ary::Repository &	io_rRepository,
87 							   TokenProcessing_Result & o_rResult )
88 {
89 	UnoIDL_PE::EstablishContacts(io_pParentPE,io_rRepository,o_rResult);
90 	pPE_Type->EstablishContacts(this,io_rRepository,o_rResult);
91 }
92 
93 PE_Typedef::~PE_Typedef()
94 {
95 }
96 
97 void
98 PE_Typedef::ProcessToken( const Token & i_rToken )
99 {
100 	i_rToken.Trigger(*this);
101 }
102 
103 void
104 PE_Typedef::Process_Identifier( const TokIdentifier & i_rToken )
105 {
106 	CallHandler(i_rToken.Text(), tt_identifier);
107 }
108 
109 void
110 PE_Typedef::Process_Punctuation( const TokPunctuation & i_rToken )
111 {
112 	CallHandler(i_rToken.Text(), tt_punctuation);
113 }
114 
115 void
116 PE_Typedef::Process_Default()
117 {
118 	CallHandler("", tt_any);
119 }
120 
121 void
122 PE_Typedef::On_expect_description_Any(const char *)
123 {
124 	SetResult(not_done,push_sure, pPE_Type.Ptr());
125 }
126 
127 void
128 PE_Typedef::On_expect_name_Identifier(const char * i_sText)
129 {
130 	sName = i_sText;
131 	SetResult(done,stay);
132 	eState = got_name;
133 }
134 
135 void
136 PE_Typedef::On_got_name_Punctuation(const char * i_sText)
137 {
138 	if ( i_sText[0] == ';' )
139 	{
140 		SetResult(done,pop_success);
141 		eState = e_none;
142 	}
143 	else
144 		On_Default(i_sText);
145 }
146 
147 void
148 PE_Typedef::On_Default(const char * )
149 {
150 	SetResult(not_done,pop_failure);
151 }
152 
153 void
154 PE_Typedef::InitData()
155 {
156 	eState = expect_description;
157 	nType = 0;
158 	sName = "";
159 }
160 
161 void
162 PE_Typedef::ReceiveData()
163 {
164 	eState = expect_name;
165 }
166 
167 void
168 PE_Typedef::TransferData()
169 {
170     ary::idl::Typedef &
171         rCe = Gate().Ces().Store_Typedef(CurNamespace().CeId(), sName, nType);
172 	PassDocuAt(rCe);
173 	eState = e_none;
174 }
175 
176 UnoIDL_PE &
177 PE_Typedef::MyPE()
178 {
179 	return *this;
180 }
181 
182 }   // namespace uidl
183 }   // namespace csi
184 
185