Update ooo320-m1
[ooovba.git] / autodoc / source / parser_i / idl / pe_enum2.cxx
blob50c9f4e9e99faf10a29e4f5f43dafe020a001ac1
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: pe_enum2.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 <s2_luidl/pe_enum2.hxx>
35 // NOT FULLY DECLARED SERVICES
36 #include <ary/idl/i_enum.hxx>
37 #include <ary/idl/i_enumvalue.hxx>
38 #include <ary/idl/i_gate.hxx>
39 #include <ary/idl/ip_ce.hxx>
40 #include <ary/doc/d_oldidldocu.hxx>
41 #include <s2_luidl/pe_evalu.hxx>
42 #include <s2_luidl/tk_punct.hxx>
43 #include <s2_luidl/tk_ident.hxx>
44 #include <s2_luidl/tk_keyw.hxx>
47 namespace csi
49 namespace uidl
53 #ifdef DF
54 #undef DF
55 #endif
56 #define DF &PE_Enum::On_Default
58 PE_Enum::F_TOK
59 PE_Enum::aDispatcher[PE_Enum::e_STATES_MAX][PE_Enum::tt_MAX] =
60 { { DF, DF }, // e_none
61 { &PE_Enum::On_expect_name_Identifier,
62 DF }, // expect_name
63 { DF, &PE_Enum::On_expect_curl_bracket_open_Punctuation }, // expect_curl_bracket_open
64 { &PE_Enum::On_expect_value_Identifier,
65 &PE_Enum::On_expect_value_Punctuation }, // expect_value
66 { DF, &PE_Enum::On_expect_finish_Punctuation } // expect_finish
71 inline void
72 PE_Enum::CallHandler( const char * i_sTokenText,
73 E_TokenType i_eTokenType )
74 { (this->*aDispatcher[eState][i_eTokenType])(i_sTokenText); }
79 PE_Enum::PE_Enum()
80 : eState(e_none),
81 sData_Name(),
82 nDataId(0),
83 pPE_Value(0),
84 sName(),
85 sAssignment()
87 pPE_Value = new PE_Value(sName, sAssignment, false);
90 void
91 PE_Enum::EstablishContacts( UnoIDL_PE * io_pParentPE,
92 ary::Repository & io_rRepository,
93 TokenProcessing_Result & o_rResult )
95 UnoIDL_PE::EstablishContacts(io_pParentPE,io_rRepository,o_rResult);
96 pPE_Value->EstablishContacts(this,io_rRepository,o_rResult);
99 PE_Enum::~PE_Enum()
103 void
104 PE_Enum::ProcessToken( const Token & i_rToken )
106 i_rToken.Trigger(*this);
109 void
110 PE_Enum::Process_Identifier( const TokIdentifier & i_rToken )
112 CallHandler(i_rToken.Text(), tt_identifier);
115 void
116 PE_Enum::Process_Punctuation( const TokPunctuation & i_rToken )
118 CallHandler(i_rToken.Text(), tt_punctuation);
121 void
122 PE_Enum::On_expect_name_Identifier(const char * i_sText)
124 sName = i_sText;
126 SetResult(done,stay);
127 eState = expect_curl_bracket_open;
130 void
131 PE_Enum::On_expect_curl_bracket_open_Punctuation(const char * i_sText)
133 if ( i_sText[0] == '{')
135 sData_Name = sName;
136 ary::idl::Enum &
137 rCe = Gate().Ces().Store_Enum(CurNamespace().CeId(), sData_Name);
138 PassDocuAt(rCe);
139 nDataId = rCe.CeId();
141 SetResult(done,stay);
142 eState = expect_value;
144 else
146 On_Default(i_sText);
150 void
151 PE_Enum::On_expect_value_Punctuation(const char * i_sText)
153 if ( i_sText[0] == '}' )
155 SetResult(done,stay);
156 eState = expect_finish;
158 else
160 On_Default(i_sText);
164 void
165 PE_Enum::On_expect_value_Identifier(const char *)
167 SetResult( not_done, push_sure, pPE_Value.Ptr() );
170 void
171 PE_Enum::On_expect_finish_Punctuation(const char * i_sText)
173 if ( i_sText[0] == ';')
175 SetResult(done,pop_success);
176 eState = e_none;
178 else
180 On_Default(i_sText);
184 void
185 PE_Enum::On_Default(const char * )
187 SetResult(not_done,pop_failure);
188 eState = e_none;
191 void
192 PE_Enum::EmptySingleValueData()
194 sName = "";
195 sAssignment = "";
198 void
199 PE_Enum::CreateSingleValue()
201 ary::idl::EnumValue &
202 rCe = Gate().Ces().Store_EnumValue( nDataId, sName, sAssignment );
203 pPE_Value->PassDocuAt(rCe);
206 void
207 PE_Enum::InitData()
209 eState = expect_name;
211 sData_Name.clear();
212 nDataId = 0;
214 EmptySingleValueData();
217 void
218 PE_Enum::ReceiveData()
220 switch (eState)
222 case expect_value:
224 if (sName.length() == 0)
226 On_Default("");
227 break;
230 CreateSingleValue();
231 EmptySingleValueData();
232 } break;
233 default:
234 SetResult(not_done, pop_failure);
235 eState = e_none;
236 } // end switch
239 void
240 PE_Enum::TransferData()
242 csv_assert(sData_Name.length() > 0);
243 eState = e_none;
246 UnoIDL_PE &
247 PE_Enum::MyPE()
249 return *this;
252 } // namespace uidl
253 } // namespace csi