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 "hi_ary.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir 32*cdf0e10cSrcweir // NOT FULLY DEFINED SERVICES 33*cdf0e10cSrcweir #include <cosv/ploc_dir.hxx> 34*cdf0e10cSrcweir #include <ary/idl/i_gate.hxx> 35*cdf0e10cSrcweir #include <ary/idl/i_module.hxx> 36*cdf0e10cSrcweir #include <ary/idl/i_ce.hxx> 37*cdf0e10cSrcweir #include <ary/idl/i_type.hxx> 38*cdf0e10cSrcweir #include <ary/idl/ip_ce.hxx> 39*cdf0e10cSrcweir #include <ary/idl/ip_type.hxx> 40*cdf0e10cSrcweir 41*cdf0e10cSrcweir 42*cdf0e10cSrcweir inline const ary::idl::Gate & 43*cdf0e10cSrcweir AryAccess::gate() const 44*cdf0e10cSrcweir { return rGate; } 45*cdf0e10cSrcweir 46*cdf0e10cSrcweir inline const ary::idl::CePilot & 47*cdf0e10cSrcweir AryAccess::ces() const 48*cdf0e10cSrcweir { return rGate.Ces(); } 49*cdf0e10cSrcweir 50*cdf0e10cSrcweir inline const ary::idl::TypePilot & 51*cdf0e10cSrcweir AryAccess::types() const 52*cdf0e10cSrcweir { return rGate.Types(); } 53*cdf0e10cSrcweir 54*cdf0e10cSrcweir inline const ary::idl::Module * 55*cdf0e10cSrcweir AryAccess::find_SubModule( const ary::idl::Module & i_parent, 56*cdf0e10cSrcweir const String & i_name ) const 57*cdf0e10cSrcweir { 58*cdf0e10cSrcweir ary::idl::Ce_id 59*cdf0e10cSrcweir nModule = i_parent.Search_Name(i_name); 60*cdf0e10cSrcweir return ces().Search_Module(nModule); 61*cdf0e10cSrcweir } 62*cdf0e10cSrcweir 63*cdf0e10cSrcweir bool 64*cdf0e10cSrcweir AryAccess::nextName( const char * & io_TextPtr, 65*cdf0e10cSrcweir String & o_name ) const 66*cdf0e10cSrcweir { 67*cdf0e10cSrcweir if ( strncmp(io_TextPtr,"::", 2) == 0 ) 68*cdf0e10cSrcweir io_TextPtr += 2; 69*cdf0e10cSrcweir 70*cdf0e10cSrcweir const char * pEnd = strchr(io_TextPtr,':'); 71*cdf0e10cSrcweir size_t nLen = pEnd == 0 72*cdf0e10cSrcweir ? strlen(io_TextPtr) 73*cdf0e10cSrcweir : pEnd - io_TextPtr; 74*cdf0e10cSrcweir o_name.assign(io_TextPtr, nLen); 75*cdf0e10cSrcweir io_TextPtr += nLen; 76*cdf0e10cSrcweir 77*cdf0e10cSrcweir return nLen > 0; 78*cdf0e10cSrcweir } 79*cdf0e10cSrcweir 80*cdf0e10cSrcweir 81*cdf0e10cSrcweir 82*cdf0e10cSrcweir AryAccess::AryAccess( const ary::idl::Gate & i_rGate ) 83*cdf0e10cSrcweir : rGate(i_rGate) 84*cdf0e10cSrcweir { 85*cdf0e10cSrcweir } 86*cdf0e10cSrcweir 87*cdf0e10cSrcweir const ary::idl::Module & 88*cdf0e10cSrcweir AryAccess::GlobalNamespace() const 89*cdf0e10cSrcweir { 90*cdf0e10cSrcweir return ces().GlobalNamespace(); 91*cdf0e10cSrcweir } 92*cdf0e10cSrcweir 93*cdf0e10cSrcweir const ary::idl::Module & 94*cdf0e10cSrcweir AryAccess::Find_Module( ary::idl::Ce_id i_ce ) const 95*cdf0e10cSrcweir { 96*cdf0e10cSrcweir return ces().Find_Module(i_ce); 97*cdf0e10cSrcweir } 98*cdf0e10cSrcweir 99*cdf0e10cSrcweir 100*cdf0e10cSrcweir const ary::idl::CodeEntity & 101*cdf0e10cSrcweir AryAccess::Find_Ce( ary::idl::Ce_id i_ce ) const 102*cdf0e10cSrcweir { 103*cdf0e10cSrcweir return ces().Find_Ce(i_ce); 104*cdf0e10cSrcweir } 105*cdf0e10cSrcweir 106*cdf0e10cSrcweir const ary::idl::Type & 107*cdf0e10cSrcweir AryAccess::Find_Type( ary::idl::Type_id i_type ) const 108*cdf0e10cSrcweir { 109*cdf0e10cSrcweir return types().Find_Type(i_type); 110*cdf0e10cSrcweir } 111*cdf0e10cSrcweir 112*cdf0e10cSrcweir ary::idl::Ce_id 113*cdf0e10cSrcweir AryAccess::CeFromType( ary::idl::Type_id i_type ) const 114*cdf0e10cSrcweir { 115*cdf0e10cSrcweir return types().Search_CeRelatedTo(i_type); 116*cdf0e10cSrcweir } 117*cdf0e10cSrcweir 118*cdf0e10cSrcweir bool 119*cdf0e10cSrcweir AryAccess::IsBuiltInOrRelated( const ary::idl::Type & i_type ) const 120*cdf0e10cSrcweir { 121*cdf0e10cSrcweir return types().IsBuiltInOrRelated(i_type); 122*cdf0e10cSrcweir } 123*cdf0e10cSrcweir 124*cdf0e10cSrcweir bool 125*cdf0e10cSrcweir AryAccess::Search_Ce( StringVector & o_module, 126*cdf0e10cSrcweir String & o_mainEntity, 127*cdf0e10cSrcweir String & o_memberEntity, 128*cdf0e10cSrcweir const char * i_sText, 129*cdf0e10cSrcweir const ary::idl::Module & i_referingScope ) const 130*cdf0e10cSrcweir { 131*cdf0e10cSrcweir o_module.erase(o_module.begin(),o_module.end()); 132*cdf0e10cSrcweir o_mainEntity = String::Null_(); 133*cdf0e10cSrcweir o_memberEntity = String::Null_(); 134*cdf0e10cSrcweir 135*cdf0e10cSrcweir const ary::idl::Module * pModule = 0; 136*cdf0e10cSrcweir 137*cdf0e10cSrcweir if ( strncmp(i_sText, "::", 2) == 0 138*cdf0e10cSrcweir OR strncmp(i_sText, "com::sun::star", 14) == 0 ) 139*cdf0e10cSrcweir pModule = &GlobalNamespace(); 140*cdf0e10cSrcweir else 141*cdf0e10cSrcweir { 142*cdf0e10cSrcweir pModule = &i_referingScope; 143*cdf0e10cSrcweir ces().Get_Text(o_module, o_mainEntity, o_memberEntity, *pModule); 144*cdf0e10cSrcweir } 145*cdf0e10cSrcweir 146*cdf0e10cSrcweir const char * pNext = i_sText; 147*cdf0e10cSrcweir String sNextName; 148*cdf0e10cSrcweir 149*cdf0e10cSrcweir // Find Module: 150*cdf0e10cSrcweir while ( nextName(pNext, sNextName) ) 151*cdf0e10cSrcweir { 152*cdf0e10cSrcweir const ary::idl::Module * 153*cdf0e10cSrcweir pSub = find_SubModule(*pModule, sNextName); 154*cdf0e10cSrcweir if (pSub != 0) 155*cdf0e10cSrcweir { 156*cdf0e10cSrcweir pModule = pSub; 157*cdf0e10cSrcweir o_module.push_back(sNextName); 158*cdf0e10cSrcweir } 159*cdf0e10cSrcweir else 160*cdf0e10cSrcweir break; 161*cdf0e10cSrcweir } 162*cdf0e10cSrcweir 163*cdf0e10cSrcweir // Find main CodeEntity: 164*cdf0e10cSrcweir if ( sNextName.length() == 0 ) 165*cdf0e10cSrcweir return true; 166*cdf0e10cSrcweir const ary::idl::Ce_id 167*cdf0e10cSrcweir nCe = pModule->Search_Name(sNextName); 168*cdf0e10cSrcweir if (NOT nCe.IsValid()) 169*cdf0e10cSrcweir return false; 170*cdf0e10cSrcweir o_mainEntity = sNextName; 171*cdf0e10cSrcweir 172*cdf0e10cSrcweir // Find member: 173*cdf0e10cSrcweir if ( *pNext == 0 ) 174*cdf0e10cSrcweir return true; 175*cdf0e10cSrcweir nextName(pNext, o_memberEntity); 176*cdf0e10cSrcweir if (strchr(o_memberEntity,':') != 0) 177*cdf0e10cSrcweir return false; // This must not happen in IDL 178*cdf0e10cSrcweir 179*cdf0e10cSrcweir #if 0 180*cdf0e10cSrcweir // The following code avoids false links, but is rather expensive 181*cdf0e10cSrcweir // in runtime time consumation. 182*cdf0e10cSrcweir 183*cdf0e10cSrcweir const ary::idl::CodeEntity * 184*cdf0e10cSrcweir pCe = Find_Ce(nCe); 185*cdf0e10cSrcweir if (pCe == 0) 186*cdf0e10cSrcweir return false; 187*cdf0e10cSrcweir 188*cdf0e10cSrcweir if ( NOT ary::idl::ifc_ce::attr::Search_Member(*pCe,o_memberEntity) ) 189*cdf0e10cSrcweir return false; 190*cdf0e10cSrcweir #endif 191*cdf0e10cSrcweir 192*cdf0e10cSrcweir return true; 193*cdf0e10cSrcweir } 194*cdf0e10cSrcweir 195*cdf0e10cSrcweir bool 196*cdf0e10cSrcweir AryAccess::Search_CesModule( StringVector & o_module, 197*cdf0e10cSrcweir const String & i_scope, 198*cdf0e10cSrcweir const String & i_ce, 199*cdf0e10cSrcweir const ary::idl::Module & i_referingScope ) const 200*cdf0e10cSrcweir { 201*cdf0e10cSrcweir o_module.erase(o_module.begin(),o_module.end()); 202*cdf0e10cSrcweir 203*cdf0e10cSrcweir const ary::idl::Module * 204*cdf0e10cSrcweir pModule = 0; 205*cdf0e10cSrcweir 206*cdf0e10cSrcweir if ( strncmp(i_scope, "::", 2) == 0 207*cdf0e10cSrcweir OR strncmp(i_scope, "com::sun::star", 14) == 0 ) 208*cdf0e10cSrcweir pModule = &GlobalNamespace(); 209*cdf0e10cSrcweir else 210*cdf0e10cSrcweir { 211*cdf0e10cSrcweir pModule = &i_referingScope; 212*cdf0e10cSrcweir static String Dummy1; 213*cdf0e10cSrcweir static String Dummy2; 214*cdf0e10cSrcweir ces().Get_Text(o_module, Dummy1, Dummy2, *pModule); 215*cdf0e10cSrcweir } 216*cdf0e10cSrcweir 217*cdf0e10cSrcweir const char * pNext = i_scope; 218*cdf0e10cSrcweir String sNextName; 219*cdf0e10cSrcweir 220*cdf0e10cSrcweir // Find Module: 221*cdf0e10cSrcweir while ( nextName(pNext, sNextName) ) 222*cdf0e10cSrcweir { 223*cdf0e10cSrcweir const ary::idl::Module * 224*cdf0e10cSrcweir pSub = find_SubModule(*pModule, sNextName); 225*cdf0e10cSrcweir if (pSub != 0) 226*cdf0e10cSrcweir { 227*cdf0e10cSrcweir pModule = pSub; 228*cdf0e10cSrcweir o_module.push_back(sNextName); 229*cdf0e10cSrcweir } 230*cdf0e10cSrcweir else 231*cdf0e10cSrcweir return false; 232*cdf0e10cSrcweir } // end while 233*cdf0e10cSrcweir return pModule->Search_Name(i_ce).IsValid(); 234*cdf0e10cSrcweir } 235*cdf0e10cSrcweir 236*cdf0e10cSrcweir const ary::idl::Module * 237*cdf0e10cSrcweir AryAccess::Search_Module( const StringVector & i_nameChain ) const 238*cdf0e10cSrcweir { 239*cdf0e10cSrcweir const ary::idl::Module * ret = 240*cdf0e10cSrcweir &GlobalNamespace(); 241*cdf0e10cSrcweir for ( StringVector::const_iterator it = i_nameChain.begin(); 242*cdf0e10cSrcweir it != i_nameChain.end(); 243*cdf0e10cSrcweir ++it ) 244*cdf0e10cSrcweir { 245*cdf0e10cSrcweir ret = find_SubModule(*ret, *it); 246*cdf0e10cSrcweir if (ret == 0) 247*cdf0e10cSrcweir break; 248*cdf0e10cSrcweir } // end for 249*cdf0e10cSrcweir return ret; 250*cdf0e10cSrcweir } 251*cdf0e10cSrcweir 252*cdf0e10cSrcweir void 253*cdf0e10cSrcweir AryAccess::Get_CeText( StringVector & o_module, 254*cdf0e10cSrcweir String & o_ce, 255*cdf0e10cSrcweir String & o_member, 256*cdf0e10cSrcweir const ary::idl::CodeEntity & i_ce ) const 257*cdf0e10cSrcweir { 258*cdf0e10cSrcweir ces().Get_Text(o_module, o_ce, o_member, i_ce); 259*cdf0e10cSrcweir } 260*cdf0e10cSrcweir 261*cdf0e10cSrcweir void 262*cdf0e10cSrcweir AryAccess::Get_TypeText( StringVector & o_module, 263*cdf0e10cSrcweir String & o_sCe, 264*cdf0e10cSrcweir ary::idl::Ce_id & o_nCe, 265*cdf0e10cSrcweir int & o_sequenceCount, 266*cdf0e10cSrcweir const ary::idl::Type & i_type ) const 267*cdf0e10cSrcweir { 268*cdf0e10cSrcweir i_type.Get_Text(o_module, o_sCe, o_nCe, o_sequenceCount, gate()); 269*cdf0e10cSrcweir } 270*cdf0e10cSrcweir 271*cdf0e10cSrcweir void 272*cdf0e10cSrcweir AryAccess::Get_IndexData( std::vector<ary::idl::Ce_id> & o_data, 273*cdf0e10cSrcweir ary::idl::alphabetical_index::E_Letter i_letter ) const 274*cdf0e10cSrcweir { 275*cdf0e10cSrcweir rGate.Ces().Get_AlphabeticalIndex(o_data, i_letter); 276*cdf0e10cSrcweir } 277*cdf0e10cSrcweir 278*cdf0e10cSrcweir 279*cdf0e10cSrcweir const ary::idl::CePilot & 280*cdf0e10cSrcweir AryAccess::Ces() const 281*cdf0e10cSrcweir { 282*cdf0e10cSrcweir return rGate.Ces(); 283*cdf0e10cSrcweir } 284