Update ooo320-m1
[ooovba.git] / autodoc / source / display / idl / hi_ary.cxx
blob1b2cb026fc5a232aa73759c9db6743b001c2ed47
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: hi_ary.cxx,v $
10 * $Revision: 1.7 $
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 ************************************************************************/
31 #include <precomp.h>
32 #include "hi_ary.hxx"
35 // NOT FULLY DEFINED SERVICES
36 #include <cosv/ploc_dir.hxx>
37 #include <ary/idl/i_gate.hxx>
38 #include <ary/idl/i_module.hxx>
39 #include <ary/idl/i_ce.hxx>
40 #include <ary/idl/i_type.hxx>
41 #include <ary/idl/ip_ce.hxx>
42 #include <ary/idl/ip_type.hxx>
45 inline const ary::idl::Gate &
46 AryAccess::gate() const
47 { return rGate; }
49 inline const ary::idl::CePilot &
50 AryAccess::ces() const
51 { return rGate.Ces(); }
53 inline const ary::idl::TypePilot &
54 AryAccess::types() const
55 { return rGate.Types(); }
57 inline const ary::idl::Module *
58 AryAccess::find_SubModule( const ary::idl::Module & i_parent,
59 const String & i_name ) const
61 ary::idl::Ce_id
62 nModule = i_parent.Search_Name(i_name);
63 return ces().Search_Module(nModule);
66 bool
67 AryAccess::nextName( const char * & io_TextPtr,
68 String & o_name ) const
70 if ( strncmp(io_TextPtr,"::", 2) == 0 )
71 io_TextPtr += 2;
73 const char * pEnd = strchr(io_TextPtr,':');
74 size_t nLen = pEnd == 0
75 ? strlen(io_TextPtr)
76 : pEnd - io_TextPtr;
77 o_name.assign(io_TextPtr, nLen);
78 io_TextPtr += nLen;
80 return nLen > 0;
85 AryAccess::AryAccess( const ary::idl::Gate & i_rGate )
86 : rGate(i_rGate)
90 const ary::idl::Module &
91 AryAccess::GlobalNamespace() const
93 return ces().GlobalNamespace();
96 const ary::idl::Module &
97 AryAccess::Find_Module( ary::idl::Ce_id i_ce ) const
99 return ces().Find_Module(i_ce);
103 const ary::idl::CodeEntity &
104 AryAccess::Find_Ce( ary::idl::Ce_id i_ce ) const
106 return ces().Find_Ce(i_ce);
109 const ary::idl::Type &
110 AryAccess::Find_Type( ary::idl::Type_id i_type ) const
112 return types().Find_Type(i_type);
115 ary::idl::Ce_id
116 AryAccess::CeFromType( ary::idl::Type_id i_type ) const
118 return types().Search_CeRelatedTo(i_type);
121 bool
122 AryAccess::IsBuiltInOrRelated( const ary::idl::Type & i_type ) const
124 return types().IsBuiltInOrRelated(i_type);
127 bool
128 AryAccess::Search_Ce( StringVector & o_module,
129 String & o_mainEntity,
130 String & o_memberEntity,
131 const char * i_sText,
132 const ary::idl::Module & i_referingScope ) const
134 o_module.erase(o_module.begin(),o_module.end());
135 o_mainEntity = String::Null_();
136 o_memberEntity = String::Null_();
138 const ary::idl::Module * pModule = 0;
140 if ( strncmp(i_sText, "::", 2) == 0
141 OR strncmp(i_sText, "com::sun::star", 14) == 0 )
142 pModule = &GlobalNamespace();
143 else
145 pModule = &i_referingScope;
146 ces().Get_Text(o_module, o_mainEntity, o_memberEntity, *pModule);
149 const char * pNext = i_sText;
150 String sNextName;
152 // Find Module:
153 while ( nextName(pNext, sNextName) )
155 const ary::idl::Module *
156 pSub = find_SubModule(*pModule, sNextName);
157 if (pSub != 0)
159 pModule = pSub;
160 o_module.push_back(sNextName);
162 else
163 break;
166 // Find main CodeEntity:
167 if ( sNextName.length() == 0 )
168 return true;
169 const ary::idl::Ce_id
170 nCe = pModule->Search_Name(sNextName);
171 if (NOT nCe.IsValid())
172 return false;
173 o_mainEntity = sNextName;
175 // Find member:
176 if ( *pNext == 0 )
177 return true;
178 nextName(pNext, o_memberEntity);
179 if (strchr(o_memberEntity,':') != 0)
180 return false; // This must not happen in IDL
182 #if 0
183 // The following code avoids false links, but is rather expensive
184 // in runtime time consumation.
186 const ary::idl::CodeEntity *
187 pCe = Find_Ce(nCe);
188 if (pCe == 0)
189 return false;
191 if ( NOT ary::idl::ifc_ce::attr::Search_Member(*pCe,o_memberEntity) )
192 return false;
193 #endif
195 return true;
198 bool
199 AryAccess::Search_CesModule( StringVector & o_module,
200 const String & i_scope,
201 const String & i_ce,
202 const ary::idl::Module & i_referingScope ) const
204 o_module.erase(o_module.begin(),o_module.end());
206 const ary::idl::Module *
207 pModule = 0;
209 if ( strncmp(i_scope, "::", 2) == 0
210 OR strncmp(i_scope, "com::sun::star", 14) == 0 )
211 pModule = &GlobalNamespace();
212 else
214 pModule = &i_referingScope;
215 static String Dummy1;
216 static String Dummy2;
217 ces().Get_Text(o_module, Dummy1, Dummy2, *pModule);
220 const char * pNext = i_scope;
221 String sNextName;
223 // Find Module:
224 while ( nextName(pNext, sNextName) )
226 const ary::idl::Module *
227 pSub = find_SubModule(*pModule, sNextName);
228 if (pSub != 0)
230 pModule = pSub;
231 o_module.push_back(sNextName);
233 else
234 return false;
235 } // end while
236 return pModule->Search_Name(i_ce).IsValid();
239 const ary::idl::Module *
240 AryAccess::Search_Module( const StringVector & i_nameChain ) const
242 const ary::idl::Module * ret =
243 &GlobalNamespace();
244 for ( StringVector::const_iterator it = i_nameChain.begin();
245 it != i_nameChain.end();
246 ++it )
248 ret = find_SubModule(*ret, *it);
249 if (ret == 0)
250 break;
251 } // end for
252 return ret;
255 void
256 AryAccess::Get_CeText( StringVector & o_module,
257 String & o_ce,
258 String & o_member,
259 const ary::idl::CodeEntity & i_ce ) const
261 ces().Get_Text(o_module, o_ce, o_member, i_ce);
264 void
265 AryAccess::Get_TypeText( StringVector & o_module,
266 String & o_sCe,
267 ary::idl::Ce_id & o_nCe,
268 int & o_sequenceCount,
269 const ary::idl::Type & i_type ) const
271 i_type.Get_Text(o_module, o_sCe, o_nCe, o_sequenceCount, gate());
274 void
275 AryAccess::Get_IndexData( std::vector<ary::idl::Ce_id> & o_data,
276 ary::idl::alphabetical_index::E_Letter i_letter ) const
278 rGate.Ces().Get_AlphabeticalIndex(o_data, i_letter);
282 const ary::idl::CePilot &
283 AryAccess::Ces() const
285 return rGate.Ces();