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_selem.hxx> 30 31 // NOT FULLY DECLARED SERVICES 32 #include <ary/idl/i_gate.hxx> 33 #include <ary/idl/i_struct.hxx> 34 #include <ary/idl/i_structelem.hxx> 35 #include <ary/idl/ip_ce.hxx> 36 #include <ary/doc/d_oldidldocu.hxx> 37 #include <s2_luidl/pe_type2.hxx> 38 #include <s2_luidl/tk_ident.hxx> 39 #include <s2_luidl/tk_punct.hxx> 40 41 42 namespace csi 43 { 44 namespace uidl 45 { 46 47 namespace 48 { 49 const String C_sNone; 50 } 51 52 PE_StructElement::PE_StructElement( RStructElement & o_rResult, 53 const RStruct & i_rCurStruct, 54 const String & i_rCurStructTemplateParam ) 55 : eState(e_none), 56 pResult(&o_rResult), 57 pCurStruct(&i_rCurStruct), 58 bIsExceptionElement(false), 59 pPE_Type(0), 60 nType(0), 61 sName(), 62 pCurStructTemplateParam(&i_rCurStructTemplateParam) 63 { 64 pPE_Type = new PE_Type(nType); 65 } 66 67 PE_StructElement::PE_StructElement( RStructElement & o_rResult, 68 const RStruct & i_rCurExc ) 69 : eState(e_none), 70 pResult(&o_rResult), 71 pCurStruct(&i_rCurExc), 72 bIsExceptionElement(true), 73 pPE_Type(0), 74 nType(0), 75 sName(), 76 pCurStructTemplateParam(&C_sNone) 77 { 78 pPE_Type = new PE_Type(nType); 79 } 80 81 void 82 PE_StructElement::EstablishContacts( UnoIDL_PE * io_pParentPE, 83 ary::Repository & io_rRepository, 84 TokenProcessing_Result & o_rResult ) 85 { 86 UnoIDL_PE::EstablishContacts(io_pParentPE,io_rRepository,o_rResult); 87 pPE_Type->EstablishContacts(this,io_rRepository,o_rResult); 88 } 89 90 PE_StructElement::~PE_StructElement() 91 { 92 } 93 94 void 95 PE_StructElement::ProcessToken( const Token & i_rToken ) 96 { 97 i_rToken.Trigger(*this); 98 } 99 100 void 101 PE_StructElement::Process_Default() 102 { 103 if (eState == expect_type) 104 { 105 SetResult( not_done, push_sure, pPE_Type.Ptr() ); 106 eState = expect_name; 107 } 108 else { 109 csv_assert(false); 110 } 111 } 112 113 void 114 PE_StructElement::Process_Identifier( const TokIdentifier & i_rToken ) 115 { 116 csv_assert(*i_rToken.Text() != 0); 117 118 if (eState == expect_type) 119 { 120 if ( *pCurStructTemplateParam == i_rToken.Text() ) 121 { 122 nType = lhf_FindTemplateParamType(); 123 SetResult( done, stay ); 124 eState = expect_name; 125 } 126 else // No template parameter type existing, or not matching: 127 { 128 SetResult( not_done, push_sure, pPE_Type.Ptr() ); 129 eState = expect_name; 130 } 131 } 132 else if (eState == expect_name) 133 { 134 sName = i_rToken.Text(); 135 SetResult( done, stay ); 136 eState = expect_finish; 137 } 138 else { 139 csv_assert(false); 140 } 141 } 142 143 void 144 PE_StructElement::Process_Punctuation( const TokPunctuation &) 145 { 146 csv_assert(eState == expect_finish); 147 148 SetResult( done, pop_success ); 149 } 150 151 void 152 PE_StructElement::InitData() 153 { 154 eState = expect_type; 155 156 nType = 0; 157 sName = ""; 158 } 159 160 void 161 PE_StructElement::TransferData() 162 { 163 csv_assert(pResult != 0 AND pCurStruct != 0); 164 165 ary::idl::StructElement * 166 pCe = 0; 167 if (bIsExceptionElement) 168 { 169 pCe = & Gate().Ces().Store_ExceptionMember( 170 *pCurStruct, 171 sName, 172 nType ); 173 } 174 else 175 { 176 pCe = & Gate().Ces().Store_StructMember( 177 *pCurStruct, 178 sName, 179 nType ); 180 } 181 *pResult = pCe->CeId(); 182 PassDocuAt(*pCe); 183 184 eState = e_none; 185 } 186 187 UnoIDL_PE & 188 PE_StructElement::MyPE() 189 { 190 return *this; 191 } 192 193 ary::idl::Type_id 194 PE_StructElement::lhf_FindTemplateParamType() const 195 { 196 const ary::idl::CodeEntity & 197 rCe = Gate().Ces().Find_Ce(*pCurStruct); 198 const ary::idl::Struct & 199 rStruct = static_cast< const ary::idl::Struct& >(rCe); 200 return rStruct.TemplateParameterType(); 201 } 202 203 204 } // namespace uidl 205 } // namespace csi 206