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: hi_ary.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 ************************************************************************/
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
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
62 nModule
= i_parent
.Search_Name(i_name
);
63 return ces().Search_Module(nModule
);
67 AryAccess::nextName( const char * & io_TextPtr
,
68 String
& o_name
) const
70 if ( strncmp(io_TextPtr
,"::", 2) == 0 )
73 const char * pEnd
= strchr(io_TextPtr
,':');
74 size_t nLen
= pEnd
== 0
77 o_name
.assign(io_TextPtr
, nLen
);
85 AryAccess::AryAccess( const ary::idl::Gate
& 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
);
116 AryAccess::CeFromType( ary::idl::Type_id i_type
) const
118 return types().Search_CeRelatedTo(i_type
);
122 AryAccess::IsBuiltInOrRelated( const ary::idl::Type
& i_type
) const
124 return types().IsBuiltInOrRelated(i_type
);
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();
145 pModule
= &i_referingScope
;
146 ces().Get_Text(o_module
, o_mainEntity
, o_memberEntity
, *pModule
);
149 const char * pNext
= i_sText
;
153 while ( nextName(pNext
, sNextName
) )
155 const ary::idl::Module
*
156 pSub
= find_SubModule(*pModule
, sNextName
);
160 o_module
.push_back(sNextName
);
166 // Find main CodeEntity:
167 if ( sNextName
.length() == 0 )
169 const ary::idl::Ce_id
170 nCe
= pModule
->Search_Name(sNextName
);
171 if (NOT nCe
.IsValid())
173 o_mainEntity
= sNextName
;
178 nextName(pNext
, o_memberEntity
);
179 if (strchr(o_memberEntity
,':') != 0)
180 return false; // This must not happen in IDL
183 // The following code avoids false links, but is rather expensive
184 // in runtime time consumation.
186 const ary::idl::CodeEntity
*
191 if ( NOT
ary::idl::ifc_ce::attr::Search_Member(*pCe
,o_memberEntity
) )
199 AryAccess::Search_CesModule( StringVector
& o_module
,
200 const String
& i_scope
,
202 const ary::idl::Module
& i_referingScope
) const
204 o_module
.erase(o_module
.begin(),o_module
.end());
206 const ary::idl::Module
*
209 if ( strncmp(i_scope
, "::", 2) == 0
210 OR
strncmp(i_scope
, "com::sun::star", 14) == 0 )
211 pModule
= &GlobalNamespace();
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
;
224 while ( nextName(pNext
, sNextName
) )
226 const ary::idl::Module
*
227 pSub
= find_SubModule(*pModule
, sNextName
);
231 o_module
.push_back(sNextName
);
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
=
244 for ( StringVector::const_iterator it
= i_nameChain
.begin();
245 it
!= i_nameChain
.end();
248 ret
= find_SubModule(*ret
, *it
);
256 AryAccess::Get_CeText( StringVector
& o_module
,
259 const ary::idl::CodeEntity
& i_ce
) const
261 ces().Get_Text(o_module
, o_ce
, o_member
, i_ce
);
265 AryAccess::Get_TypeText( StringVector
& o_module
,
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());
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