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_evalu.hxx> 30 31 // NOT FULLY DECLARED SERVICES 32 #include <ary/idl/i_enumvalue.hxx> 33 #include <ary/idl/i_gate.hxx> 34 #include <ary/idl/ip_ce.hxx> 35 #include <ary/doc/d_oldidldocu.hxx> 36 #include <s2_luidl/tk_ident.hxx> 37 #include <s2_luidl/tk_punct.hxx> 38 #include <s2_luidl/tk_const.hxx> 39 40 41 namespace csi 42 { 43 namespace uidl 44 { 45 46 47 #ifdef DF 48 #undef DF 49 #endif 50 #define DF &PE_Value::On_Default 51 52 PE_Value::F_TOK 53 PE_Value::aDispatcher[PE_Value::e_STATES_MAX][PE_Value::tt_MAX] = 54 { { DF, DF, DF }, // e_none 55 { &PE_Value::On_expect_name_Identifier, 56 DF, DF }, // expect_name 57 { DF, &PE_Value::On_got_name_Punctuation, 58 &PE_Value::On_got_name_Assignment } // got_name 59 }; 60 61 62 63 inline void 64 PE_Value::CallHandler( const char * i_sTokenText, 65 E_TokenType i_eTokenType ) 66 { (this->*aDispatcher[eState][i_eTokenType])(i_sTokenText); } 67 68 69 70 71 72 PE_Value::PE_Value( String & o_rName, 73 String & o_rAssignment, 74 bool i_bIsConst ) 75 : eState(e_none), 76 pName(&o_rName), 77 pAssignment(&o_rAssignment), 78 bIsConst(i_bIsConst) 79 { 80 } 81 82 void 83 PE_Value::EstablishContacts( UnoIDL_PE * io_pParentPE, 84 ary::Repository & io_rRepository, 85 TokenProcessing_Result & o_rResult ) 86 { 87 UnoIDL_PE::EstablishContacts(io_pParentPE,io_rRepository,o_rResult); 88 } 89 90 PE_Value::~PE_Value() 91 { 92 } 93 94 void 95 PE_Value::ProcessToken( const Token & i_rToken ) 96 { 97 i_rToken.Trigger(*this); 98 } 99 100 void 101 PE_Value::Process_Identifier( const TokIdentifier & i_rToken ) 102 { 103 CallHandler(i_rToken.Text(), tt_identifier); 104 } 105 106 void 107 PE_Value::Process_Punctuation( const TokPunctuation & i_rToken ) 108 { 109 CallHandler(i_rToken.Text(), tt_punctuation); 110 } 111 112 void 113 PE_Value::Process_Assignment( const TokAssignment & i_rToken ) 114 { 115 CallHandler(i_rToken.Text(), tt_assignment); 116 } 117 118 void 119 PE_Value::On_expect_name_Identifier(const char * i_sText) 120 { 121 *pName = i_sText; 122 SetResult(done,stay); 123 eState = got_name; 124 } 125 126 void 127 PE_Value::On_got_name_Punctuation(const char * i_sText) 128 { 129 if ( (i_sText[0] == ',' AND NOT IsConst()) 130 OR (i_sText[0] == ';' AND IsConst()) ) 131 { 132 SetResult(done,pop_success); 133 eState = e_none; 134 } 135 else if (i_sText[0] == '}' AND NOT IsConst()) 136 { 137 SetResult(not_done,pop_success); 138 eState = e_none; 139 } 140 else 141 On_Default(i_sText); 142 } 143 144 void 145 PE_Value::On_got_name_Assignment(const char * i_sText) 146 { 147 *pAssignment = i_sText; 148 SetResult(done,pop_success); 149 eState = e_none; 150 } 151 152 void 153 PE_Value::On_Default(const char * ) 154 { 155 SetResult(not_done,pop_failure); 156 } 157 158 void 159 PE_Value::InitData() 160 { 161 eState = expect_name; 162 163 *pName = ""; 164 *pAssignment = ""; 165 } 166 167 void 168 PE_Value::TransferData() 169 { 170 csv_assert(pName->length() > 0); 171 eState = e_none; 172 } 173 174 UnoIDL_PE & 175 PE_Value::MyPE() 176 { 177 return *this; 178 } 179 180 } // namespace uidl 181 } // namespace csi 182 183