merge the formfield patch from ooo-build
[ooovba.git] / autodoc / source / parser_i / idl / pe_excp.cxx
blobbfb51d4a247c4eb1ebe34a13c690fdb6a57bc0f9
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_excp.cxx,v $
10 * $Revision: 1.8 $
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_excp.hxx>
35 // NOT FULLY DECLARED SERVICES
36 #include <ary/idl/i_exception.hxx>
37 #include <ary/idl/i_gate.hxx>
38 #include <ary/idl/i_structelem.hxx>
39 #include <ary/idl/ip_ce.hxx>
40 #include <ary/doc/d_oldidldocu.hxx>
41 #include <s2_luidl/tk_ident.hxx>
42 #include <s2_luidl/tk_punct.hxx>
43 #include <s2_luidl/tk_keyw.hxx>
44 #include <s2_luidl/pe_type2.hxx>
45 #include <s2_luidl/pe_selem.hxx>
49 namespace csi
51 namespace uidl
55 PE_Exception::PE_Exception()
56 // : aWork,
57 // pStati
59 pStati = new S_Stati(*this);
62 void
63 PE_Exception::EstablishContacts( UnoIDL_PE * io_pParentPE,
64 ary::Repository & io_rRepository,
65 TokenProcessing_Result & o_rResult )
67 UnoIDL_PE::EstablishContacts(io_pParentPE,io_rRepository,o_rResult);
68 Work().pPE_Element->EstablishContacts(this,io_rRepository,o_rResult);
69 Work().pPE_Type->EstablishContacts(this,io_rRepository,o_rResult);
72 PE_Exception::~PE_Exception()
76 void
77 PE_Exception::ProcessToken( const Token & i_rToken )
79 i_rToken.Trigger(*Stati().pCurStatus);
83 void
84 PE_Exception::InitData()
86 Work().InitData();
87 Stati().pCurStatus = &Stati().aWaitForName;
90 void
91 PE_Exception::TransferData()
93 if (NOT Work().bIsPreDeclaration)
95 csv_assert(Work().sData_Name.size() > 0);
96 csv_assert(Work().nCurStruct.IsValid());
98 Stati().pCurStatus = &Stati().aNone;
101 void
102 PE_Exception::ReceiveData()
104 Stati().pCurStatus->On_SubPE_Left();
107 PE_Exception::S_Work::S_Work()
108 : sData_Name(),
109 bIsPreDeclaration(false),
110 nCurStruct(0),
111 pPE_Element(0),
112 nCurParsed_ElementRef(0),
113 pPE_Type(0),
114 nCurParsed_Base(0)
117 pPE_Element = new PE_StructElement(nCurParsed_ElementRef,nCurStruct);
118 pPE_Type = new PE_Type(nCurParsed_Base);
121 void
122 PE_Exception::S_Work::InitData()
124 sData_Name.clear();
125 bIsPreDeclaration = false;
126 nCurStruct = 0;
128 nCurParsed_ElementRef = 0;
129 nCurParsed_Base = 0;
132 void
133 PE_Exception::S_Work::Prepare_PE_QualifiedName()
135 nCurParsed_ElementRef = 0;
138 void
139 PE_Exception::S_Work::Prepare_PE_Element()
141 nCurParsed_Base = 0;
144 void
145 PE_Exception::S_Work::Data_Set_Name( const char * i_sName )
147 sData_Name = i_sName;
150 PE_Exception::S_Stati::S_Stati(PE_Exception & io_rStruct)
151 : aNone(io_rStruct),
152 aWaitForName(io_rStruct),
153 aGotName(io_rStruct),
154 aWaitForBase(io_rStruct),
155 aGotBase(io_rStruct),
156 aWaitForElement(io_rStruct),
157 aWaitForFinish(io_rStruct),
158 pCurStatus(0)
160 pCurStatus = &aNone;
164 //*********************** Stati ***************************//
167 UnoIDL_PE &
168 PE_Exception::PE_StructState::MyPE()
170 return rStruct;
174 void
175 PE_Exception::State_WaitForName::Process_Identifier( const TokIdentifier & i_rToken )
177 Work().Data_Set_Name(i_rToken.Text());
178 MoveState( Stati().aGotName );
179 SetResult(done,stay);
182 void
183 PE_Exception::State_GotName::Process_Punctuation( const TokPunctuation & i_rToken )
185 if ( i_rToken.Id() != TokPunctuation::Semicolon )
187 switch (i_rToken.Id())
189 case TokPunctuation::Colon:
190 MoveState( Stati().aWaitForBase );
191 SetResult(done,push_sure,Work().pPE_Type.Ptr());
192 Work().Prepare_PE_QualifiedName();
193 break;
194 case TokPunctuation::CurledBracketOpen:
195 PE().store_Exception();
196 MoveState( Stati().aWaitForElement );
197 SetResult(done,stay);
198 break;
199 default:
200 SetResult(not_done,pop_failure);
201 } // end switch
203 else
205 Work().sData_Name.clear();
206 SetResult(done,pop_success);
210 void
211 PE_Exception::State_WaitForBase::On_SubPE_Left()
213 MoveState(Stati().aGotBase);
216 void
217 PE_Exception::State_GotBase::Process_Punctuation( const TokPunctuation & i_rToken )
219 if ( i_rToken.Id() == TokPunctuation::CurledBracketOpen )
221 PE().store_Exception();
222 MoveState( Stati().aWaitForElement );
223 SetResult(done,stay);
225 else
227 SetResult(not_done,pop_failure);
231 void
232 PE_Exception::State_WaitForElement::Process_Identifier( const TokIdentifier & )
234 SetResult( not_done, push_sure, Work().pPE_Element.Ptr() );
235 Work().Prepare_PE_Element();
238 void
239 PE_Exception::State_WaitForElement::Process_NameSeparator()
241 SetResult( not_done, push_sure, Work().pPE_Element.Ptr());
242 Work().Prepare_PE_Element();
245 void
246 PE_Exception::State_WaitForElement::Process_BuiltInType( const TokBuiltInType & )
248 SetResult( not_done, push_sure, Work().pPE_Element.Ptr());
249 Work().Prepare_PE_Element();
252 void
253 PE_Exception::State_WaitForElement::Process_TypeModifier(const TokTypeModifier & )
255 SetResult( not_done, push_sure, Work().pPE_Element.Ptr());
256 Work().Prepare_PE_Element();
259 void
260 PE_Exception::State_WaitForElement::Process_Punctuation( const TokPunctuation & i_rToken )
262 if ( i_rToken.Id() == TokPunctuation::CurledBracketClose )
264 MoveState( Stati().aWaitForFinish );
265 SetResult( done, stay );
267 else
269 SetResult( not_done, pop_failure );
273 void
274 PE_Exception::State_WaitForFinish::Process_Punctuation( const TokPunctuation & i_rToken )
276 if (i_rToken.Id() == TokPunctuation::Semicolon)
278 MoveState( Stati().aNone );
279 SetResult( done, pop_success );
281 else
283 SetResult( not_done, pop_failure );
287 void
288 PE_Exception::store_Exception()
290 ary::idl::Exception &
291 rCe = Gate().Ces().Store_Exception(
292 CurNamespace().CeId(),
293 Work().sData_Name,
294 Work().nCurParsed_Base );
295 PassDocuAt(rCe);
296 Work().nCurStruct = rCe.Id();
300 } // namespace uidl
301 } // namespace csi