1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: pe_enum2.cxx,v $
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 ************************************************************************/
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>
56 #define DF &PE_Enum::On_Default
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
,
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
72 PE_Enum::CallHandler( const char * i_sTokenText
,
73 E_TokenType i_eTokenType
)
74 { (this->*aDispatcher
[eState
][i_eTokenType
])(i_sTokenText
); }
87 pPE_Value
= new PE_Value(sName
, sAssignment
, false);
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
);
104 PE_Enum::ProcessToken( const Token
& i_rToken
)
106 i_rToken
.Trigger(*this);
110 PE_Enum::Process_Identifier( const TokIdentifier
& i_rToken
)
112 CallHandler(i_rToken
.Text(), tt_identifier
);
116 PE_Enum::Process_Punctuation( const TokPunctuation
& i_rToken
)
118 CallHandler(i_rToken
.Text(), tt_punctuation
);
122 PE_Enum::On_expect_name_Identifier(const char * i_sText
)
126 SetResult(done
,stay
);
127 eState
= expect_curl_bracket_open
;
131 PE_Enum::On_expect_curl_bracket_open_Punctuation(const char * i_sText
)
133 if ( i_sText
[0] == '{')
137 rCe
= Gate().Ces().Store_Enum(CurNamespace().CeId(), sData_Name
);
139 nDataId
= rCe
.CeId();
141 SetResult(done
,stay
);
142 eState
= expect_value
;
151 PE_Enum::On_expect_value_Punctuation(const char * i_sText
)
153 if ( i_sText
[0] == '}' )
155 SetResult(done
,stay
);
156 eState
= expect_finish
;
165 PE_Enum::On_expect_value_Identifier(const char *)
167 SetResult( not_done
, push_sure
, pPE_Value
.Ptr() );
171 PE_Enum::On_expect_finish_Punctuation(const char * i_sText
)
173 if ( i_sText
[0] == ';')
175 SetResult(done
,pop_success
);
185 PE_Enum::On_Default(const char * )
187 SetResult(not_done
,pop_failure
);
192 PE_Enum::EmptySingleValueData()
199 PE_Enum::CreateSingleValue()
201 ary::idl::EnumValue
&
202 rCe
= Gate().Ces().Store_EnumValue( nDataId
, sName
, sAssignment
);
203 pPE_Value
->PassDocuAt(rCe
);
209 eState
= expect_name
;
214 EmptySingleValueData();
218 PE_Enum::ReceiveData()
224 if (sName
.length() == 0)
231 EmptySingleValueData();
234 SetResult(not_done
, pop_failure
);
240 PE_Enum::TransferData()
242 csv_assert(sData_Name
.length() > 0);