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_vari2.hxx>
30 
31 
32 // NOT FULLY DECLARED SERVICES
33 #include <ary/idl/i_gate.hxx>
34 #include <ary/idl/i_property.hxx>
35 #include <ary/idl/ip_ce.hxx>
36 #include <ary/doc/d_oldidldocu.hxx>
37 #include <s2_luidl/pe_type2.hxx>
38 #include <s2_luidl/tk_keyw.hxx>
39 #include <s2_luidl/tk_ident.hxx>
40 #include <s2_luidl/tk_punct.hxx>
41 
42 
43 namespace csi
44 {
45 namespace uidl
46 {
47 
48 
49 PE_Variable::PE_Variable( ary::idl::Type_id &	i_rResult_Type,
50 						  String &	            i_rResult_Name )
51 	:	eState(e_none),
52 		pResult_Type(&i_rResult_Type),
53 		pResult_Name(&i_rResult_Name),
54 		pPE_Type(0)
55 {
56 	pPE_Type = new PE_Type(i_rResult_Type);
57 }
58 
59 void
60 PE_Variable::EstablishContacts( UnoIDL_PE *					io_pParentPE,
61 								ary::Repository &			io_rRepository,
62 								TokenProcessing_Result & 	o_rResult )
63 {
64 	UnoIDL_PE::EstablishContacts(io_pParentPE,io_rRepository,o_rResult);
65 	pPE_Type->EstablishContacts(this,io_rRepository,o_rResult);
66 }
67 
68 PE_Variable::~PE_Variable()
69 {
70 }
71 
72 void
73 PE_Variable::ProcessToken( const Token & i_rToken )
74 {
75 	i_rToken.Trigger(*this);
76 }
77 
78 
79 void
80 PE_Variable::Process_Default()
81 {
82 	if (eState == expect_type)
83 	{
84 		SetResult( not_done, push_sure, pPE_Type.Ptr() );
85 	}
86 	else{
87 		csv_assert(false);
88     }
89 }
90 
91 void
92 PE_Variable::Process_Identifier( const TokIdentifier & i_rToken )
93 {
94 	if (eState == expect_type)
95 	{
96 		SetResult( not_done, push_sure, pPE_Type.Ptr() );
97 	}
98 	else if (eState == expect_name)
99 	{
100 		*pResult_Name = i_rToken.Text();
101 		SetResult( done, stay );
102         eState = expect_finish;
103 	}
104 	else {
105 		csv_assert(false);
106     }
107 }
108 
109 void
110 PE_Variable::Process_Punctuation( const TokPunctuation & )
111 {
112 	if (eState == expect_finish)
113 	{
114 		SetResult( not_done, pop_success );
115         eState = e_none;
116 	}
117 	else if (eState == expect_name)
118 	{
119 		SetResult( not_done, pop_success );
120         eState = e_none;
121 	}
122 	else {
123 		csv_assert(false);
124     }
125 }
126 
127 void
128 PE_Variable::Process_BuiltInType( const TokBuiltInType & i_rToken )
129 {
130 	if (eState == expect_type)
131 	{
132 		SetResult( not_done, push_sure, pPE_Type.Ptr() );
133 	}
134     else if (eState == expect_name AND i_rToken.Id() == TokBuiltInType::bty_ellipse)
135     {
136 		SetResult( not_done, pop_success );
137         eState = e_none;
138     }
139 	else {
140 		csv_assert(false);
141     }
142 }
143 
144 void
145 PE_Variable::InitData()
146 {
147 	eState = expect_type;
148 
149 	*pResult_Type = 0;
150 	*pResult_Name = "";
151 }
152 
153 void
154 PE_Variable::ReceiveData()
155 {
156 	eState = expect_name;
157 }
158 
159 void
160 PE_Variable::TransferData()
161 {
162 	eState = e_none;
163 }
164 
165 UnoIDL_PE &
166 PE_Variable::MyPE()
167 {
168 	return *this;
169 }
170 
171 }   // namespace uidl
172 }   // namespace csi
173 
174