1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #include <precomp.h>
29*cdf0e10cSrcweir #include <s2_luidl/pe_property.hxx>
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir 
32*cdf0e10cSrcweir // NOT FULLY DEFINED SERVICES
33*cdf0e10cSrcweir #include <ary/idl/i_gate.hxx>
34*cdf0e10cSrcweir #include <ary/idl/i_property.hxx>
35*cdf0e10cSrcweir #include <ary/idl/i_service.hxx>
36*cdf0e10cSrcweir #include <ary/idl/ip_ce.hxx>
37*cdf0e10cSrcweir #include <ary/doc/d_oldidldocu.hxx>
38*cdf0e10cSrcweir #include <s2_luidl/pe_vari2.hxx>
39*cdf0e10cSrcweir #include <s2_luidl/tk_keyw.hxx>
40*cdf0e10cSrcweir #include <s2_luidl/tk_ident.hxx>
41*cdf0e10cSrcweir #include <s2_luidl/tk_punct.hxx>
42*cdf0e10cSrcweir 
43*cdf0e10cSrcweir 
44*cdf0e10cSrcweir 
45*cdf0e10cSrcweir namespace csi
46*cdf0e10cSrcweir {
47*cdf0e10cSrcweir namespace uidl
48*cdf0e10cSrcweir {
49*cdf0e10cSrcweir 
50*cdf0e10cSrcweir 
51*cdf0e10cSrcweir 
52*cdf0e10cSrcweir PE_Property::PE_Property( const Ce_id & i_rCurOwner )
53*cdf0e10cSrcweir     :   eState(e_none),
54*cdf0e10cSrcweir         pCurOwner(&i_rCurOwner),
55*cdf0e10cSrcweir         pPE_Variable(0),
56*cdf0e10cSrcweir         nCurParsedType(0),
57*cdf0e10cSrcweir         sCurParsedName(),
58*cdf0e10cSrcweir         bIsOptional(false),
59*cdf0e10cSrcweir         aStereotypes()
60*cdf0e10cSrcweir {
61*cdf0e10cSrcweir     pPE_Variable    = new PE_Variable(nCurParsedType, sCurParsedName);
62*cdf0e10cSrcweir }
63*cdf0e10cSrcweir 
64*cdf0e10cSrcweir void
65*cdf0e10cSrcweir PE_Property::EstablishContacts( UnoIDL_PE *                io_pParentPE,
66*cdf0e10cSrcweir                                 ary::Repository &		io_rRepository,
67*cdf0e10cSrcweir                                 TokenProcessing_Result & 	o_rResult )
68*cdf0e10cSrcweir {
69*cdf0e10cSrcweir     UnoIDL_PE::EstablishContacts(io_pParentPE,io_rRepository,o_rResult);
70*cdf0e10cSrcweir     pPE_Variable->EstablishContacts(this,io_rRepository,o_rResult);
71*cdf0e10cSrcweir }
72*cdf0e10cSrcweir 
73*cdf0e10cSrcweir PE_Property::~PE_Property()
74*cdf0e10cSrcweir {
75*cdf0e10cSrcweir }
76*cdf0e10cSrcweir 
77*cdf0e10cSrcweir void
78*cdf0e10cSrcweir PE_Property::ProcessToken( const Token & i_rToken )
79*cdf0e10cSrcweir {
80*cdf0e10cSrcweir     i_rToken.Trigger(*this);
81*cdf0e10cSrcweir }
82*cdf0e10cSrcweir 
83*cdf0e10cSrcweir void
84*cdf0e10cSrcweir PE_Property::Process_Stereotype( const TokStereotype & i_rToken )
85*cdf0e10cSrcweir {
86*cdf0e10cSrcweir     switch (i_rToken.Id())
87*cdf0e10cSrcweir     {
88*cdf0e10cSrcweir         case TokStereotype::ste_optional:
89*cdf0e10cSrcweir             bIsOptional = true;
90*cdf0e10cSrcweir             break;
91*cdf0e10cSrcweir         case TokStereotype::ste_readonly:
92*cdf0e10cSrcweir             aStereotypes.Set_Flag(Stereotypes::readonly);
93*cdf0e10cSrcweir             break;
94*cdf0e10cSrcweir         case TokStereotype::ste_bound:
95*cdf0e10cSrcweir             aStereotypes.Set_Flag(Stereotypes::bound);
96*cdf0e10cSrcweir             break;
97*cdf0e10cSrcweir         case TokStereotype::ste_constrained:
98*cdf0e10cSrcweir             aStereotypes.Set_Flag(Stereotypes::constrained);
99*cdf0e10cSrcweir             break;
100*cdf0e10cSrcweir         case TokStereotype::ste_maybeambiguous:
101*cdf0e10cSrcweir             aStereotypes.Set_Flag(Stereotypes::maybeambiguous);
102*cdf0e10cSrcweir             break;
103*cdf0e10cSrcweir         case TokStereotype::ste_maybedefault:
104*cdf0e10cSrcweir             aStereotypes.Set_Flag(Stereotypes::maybedefault);
105*cdf0e10cSrcweir             break;
106*cdf0e10cSrcweir         case TokStereotype::ste_maybevoid:
107*cdf0e10cSrcweir             aStereotypes.Set_Flag(Stereotypes::maybevoid);
108*cdf0e10cSrcweir             break;
109*cdf0e10cSrcweir         case TokStereotype::ste_removable:
110*cdf0e10cSrcweir             aStereotypes.Set_Flag(Stereotypes::removable);
111*cdf0e10cSrcweir             break;
112*cdf0e10cSrcweir         case TokStereotype::ste_transient:
113*cdf0e10cSrcweir             aStereotypes.Set_Flag(Stereotypes::transient);
114*cdf0e10cSrcweir             break;
115*cdf0e10cSrcweir 
116*cdf0e10cSrcweir         default:
117*cdf0e10cSrcweir             SetResult(not_done, pop_failure);
118*cdf0e10cSrcweir             eState = e_none;
119*cdf0e10cSrcweir             return;
120*cdf0e10cSrcweir     }
121*cdf0e10cSrcweir 
122*cdf0e10cSrcweir     SetResult(done, stay);
123*cdf0e10cSrcweir }
124*cdf0e10cSrcweir 
125*cdf0e10cSrcweir void
126*cdf0e10cSrcweir PE_Property::Process_MetaType( const TokMetaType & i_rToken )
127*cdf0e10cSrcweir {
128*cdf0e10cSrcweir     if (eState == e_start)
129*cdf0e10cSrcweir     {
130*cdf0e10cSrcweir         if ( i_rToken.Id() == TokMetaType::mt_property )
131*cdf0e10cSrcweir     	{
132*cdf0e10cSrcweir             SetResult(done, stay);
133*cdf0e10cSrcweir             eState = expect_variable;
134*cdf0e10cSrcweir             return;
135*cdf0e10cSrcweir     	}
136*cdf0e10cSrcweir     }   // endif (eState == e_start)
137*cdf0e10cSrcweir 
138*cdf0e10cSrcweir     SetResult(not_done, pop_failure);
139*cdf0e10cSrcweir     eState = e_none;
140*cdf0e10cSrcweir }
141*cdf0e10cSrcweir 
142*cdf0e10cSrcweir void
143*cdf0e10cSrcweir PE_Property::Process_Punctuation( const TokPunctuation & i_rToken )
144*cdf0e10cSrcweir {
145*cdf0e10cSrcweir     switch (eState)
146*cdf0e10cSrcweir     {
147*cdf0e10cSrcweir         case e_start:
148*cdf0e10cSrcweir             SetResult(done, stay);
149*cdf0e10cSrcweir             break;
150*cdf0e10cSrcweir         case expect_variable:
151*cdf0e10cSrcweir             if (i_rToken.Id() == TokPunctuation::Semicolon)
152*cdf0e10cSrcweir     		{
153*cdf0e10cSrcweir                 SetResult(done, pop_success);
154*cdf0e10cSrcweir                 eState = e_none;
155*cdf0e10cSrcweir     		}
156*cdf0e10cSrcweir             else if (i_rToken.Id() == TokPunctuation::Comma)
157*cdf0e10cSrcweir                 SetResult(done, stay);
158*cdf0e10cSrcweir         	else
159*cdf0e10cSrcweir                 SetResult(not_done, pop_failure);
160*cdf0e10cSrcweir             break;
161*cdf0e10cSrcweir         default:
162*cdf0e10cSrcweir             csv_assert(false);
163*cdf0e10cSrcweir     }
164*cdf0e10cSrcweir }
165*cdf0e10cSrcweir 
166*cdf0e10cSrcweir void
167*cdf0e10cSrcweir PE_Property::Process_Default()
168*cdf0e10cSrcweir {
169*cdf0e10cSrcweir     if (eState == expect_variable)
170*cdf0e10cSrcweir     {
171*cdf0e10cSrcweir         SetResult(not_done, push_sure, pPE_Variable.Ptr());
172*cdf0e10cSrcweir         eState = in_variable;
173*cdf0e10cSrcweir     }
174*cdf0e10cSrcweir     else
175*cdf0e10cSrcweir         SetResult(not_done, pop_failure);
176*cdf0e10cSrcweir }
177*cdf0e10cSrcweir 
178*cdf0e10cSrcweir void
179*cdf0e10cSrcweir PE_Property::InitData()
180*cdf0e10cSrcweir {
181*cdf0e10cSrcweir     eState = e_start;
182*cdf0e10cSrcweir 
183*cdf0e10cSrcweir     nCurParsedType = 0;
184*cdf0e10cSrcweir     sCurParsedName = "";
185*cdf0e10cSrcweir 
186*cdf0e10cSrcweir     // bIsOptional and
187*cdf0e10cSrcweir     // aStereotypes
188*cdf0e10cSrcweir     //   may be preset by the PE_Service-(or PE_Interface-)parent
189*cdf0e10cSrcweir     //   with PresetOptional() or
190*cdf0e10cSrcweir     //   PresetStereotype()
191*cdf0e10cSrcweir     //   - therefore it must not be set here!
192*cdf0e10cSrcweir }
193*cdf0e10cSrcweir 
194*cdf0e10cSrcweir void
195*cdf0e10cSrcweir PE_Property::TransferData()
196*cdf0e10cSrcweir {
197*cdf0e10cSrcweir     if (bIsOptional)
198*cdf0e10cSrcweir     {
199*cdf0e10cSrcweir         SetOptional();
200*cdf0e10cSrcweir         bIsOptional = false;
201*cdf0e10cSrcweir     }
202*cdf0e10cSrcweir 
203*cdf0e10cSrcweir     ary::idl::CodeEntity *
204*cdf0e10cSrcweir         pCe = 0;
205*cdf0e10cSrcweir     csv_assert(pCurOwner->IsValid());
206*cdf0e10cSrcweir 
207*cdf0e10cSrcweir     pCe = &Gate().Ces().Store_Property( *pCurOwner,
208*cdf0e10cSrcweir                                         sCurParsedName,
209*cdf0e10cSrcweir                                         nCurParsedType,
210*cdf0e10cSrcweir                                         aStereotypes );
211*cdf0e10cSrcweir 
212*cdf0e10cSrcweir     csv_assert(pCe != 0);
213*cdf0e10cSrcweir     PassDocuAt(*pCe);
214*cdf0e10cSrcweir 
215*cdf0e10cSrcweir     nCurParsedType = 0;
216*cdf0e10cSrcweir     sCurParsedName.clear();
217*cdf0e10cSrcweir     aStereotypes = Stereotypes();
218*cdf0e10cSrcweir 
219*cdf0e10cSrcweir     eState = e_none;
220*cdf0e10cSrcweir }
221*cdf0e10cSrcweir 
222*cdf0e10cSrcweir void
223*cdf0e10cSrcweir PE_Property::ReceiveData()
224*cdf0e10cSrcweir {
225*cdf0e10cSrcweir     eState = expect_variable;
226*cdf0e10cSrcweir }
227*cdf0e10cSrcweir 
228*cdf0e10cSrcweir 
229*cdf0e10cSrcweir UnoIDL_PE &
230*cdf0e10cSrcweir PE_Property::MyPE()
231*cdf0e10cSrcweir {
232*cdf0e10cSrcweir     return *this;
233*cdf0e10cSrcweir }
234*cdf0e10cSrcweir 
235*cdf0e10cSrcweir 
236*cdf0e10cSrcweir }   // namespace uidl
237*cdf0e10cSrcweir }   // namespace csi
238*cdf0e10cSrcweir 
239