1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
33 // NOT FULLY DEFINED SERVICES
34 #include <cosv/ploc_dir.hxx>
35 #include <ary/idl/i_gate.hxx>
36 #include <ary/idl/i_module.hxx>
37 #include <ary/idl/i_ce.hxx>
38 #include <ary/idl/i_type.hxx>
39 #include <ary/idl/ip_ce.hxx>
40 #include <ary/idl/ip_type.hxx>
43 inline const ary::idl::Gate
&
44 AryAccess::gate() const
47 inline const ary::idl::CePilot
&
48 AryAccess::ces() const
49 { return rGate
.Ces(); }
51 inline const ary::idl::TypePilot
&
52 AryAccess::types() const
53 { return rGate
.Types(); }
55 inline const ary::idl::Module
*
56 AryAccess::find_SubModule( const ary::idl::Module
& i_parent
,
57 const String
& i_name
) const
60 nModule
= i_parent
.Search_Name(i_name
);
61 return ces().Search_Module(nModule
);
65 AryAccess::nextName( const char * & io_TextPtr
,
66 String
& o_name
) const
68 if ( strncmp(io_TextPtr
,"::", 2) == 0 )
71 const char * pEnd
= strchr(io_TextPtr
,':');
72 size_t nLen
= pEnd
== 0
75 o_name
.assign(io_TextPtr
, nLen
);
83 AryAccess::AryAccess( const ary::idl::Gate
& i_rGate
)
88 const ary::idl::Module
&
89 AryAccess::GlobalNamespace() const
91 return ces().GlobalNamespace();
94 const ary::idl::Module
&
95 AryAccess::Find_Module( ary::idl::Ce_id i_ce
) const
97 return ces().Find_Module(i_ce
);
101 const ary::idl::CodeEntity
&
102 AryAccess::Find_Ce( ary::idl::Ce_id i_ce
) const
104 return ces().Find_Ce(i_ce
);
107 const ary::idl::Type
&
108 AryAccess::Find_Type( ary::idl::Type_id i_type
) const
110 return types().Find_Type(i_type
);
114 AryAccess::CeFromType( ary::idl::Type_id i_type
) const
116 return types().Search_CeRelatedTo(i_type
);
120 AryAccess::IsBuiltInOrRelated( const ary::idl::Type
& i_type
) const
122 return types().IsBuiltInOrRelated(i_type
);
126 AryAccess::Search_Ce( StringVector
& o_module
,
127 String
& o_mainEntity
,
128 String
& o_memberEntity
,
129 const char * i_sText
,
130 const ary::idl::Module
& i_referingScope
) const
132 o_module
.erase(o_module
.begin(),o_module
.end());
133 o_mainEntity
= String::Null_();
134 o_memberEntity
= String::Null_();
136 const ary::idl::Module
* pModule
= 0;
138 if ( strncmp(i_sText
, "::", 2) == 0
139 OR
strncmp(i_sText
, "com::sun::star", 14) == 0 )
140 pModule
= &GlobalNamespace();
143 pModule
= &i_referingScope
;
144 ces().Get_Text(o_module
, o_mainEntity
, o_memberEntity
, *pModule
);
147 const char * pNext
= i_sText
;
151 while ( nextName(pNext
, sNextName
) )
153 const ary::idl::Module
*
154 pSub
= find_SubModule(*pModule
, sNextName
);
158 o_module
.push_back(sNextName
);
164 // Find main CodeEntity:
165 if ( sNextName
.length() == 0 )
167 const ary::idl::Ce_id
168 nCe
= pModule
->Search_Name(sNextName
);
169 if (NOT nCe
.IsValid())
171 o_mainEntity
= sNextName
;
176 nextName(pNext
, o_memberEntity
);
177 if (strchr(o_memberEntity
,':') != 0)
178 return false; // This must not happen in IDL
184 AryAccess::Search_CesModule( StringVector
& o_module
,
185 const String
& i_scope
,
187 const ary::idl::Module
& i_referingScope
) const
189 o_module
.erase(o_module
.begin(),o_module
.end());
191 const ary::idl::Module
*
194 if ( strncmp(i_scope
, "::", 2) == 0
195 OR
strncmp(i_scope
, "com::sun::star", 14) == 0 )
196 pModule
= &GlobalNamespace();
199 pModule
= &i_referingScope
;
200 static String Dummy1
;
201 static String Dummy2
;
202 ces().Get_Text(o_module
, Dummy1
, Dummy2
, *pModule
);
205 const char * pNext
= i_scope
;
209 while ( nextName(pNext
, sNextName
) )
211 const ary::idl::Module
*
212 pSub
= find_SubModule(*pModule
, sNextName
);
216 o_module
.push_back(sNextName
);
221 return pModule
->Search_Name(i_ce
).IsValid();
224 const ary::idl::Module
*
225 AryAccess::Search_Module( const StringVector
& i_nameChain
) const
227 const ary::idl::Module
* ret
=
229 for ( StringVector::const_iterator it
= i_nameChain
.begin();
230 it
!= i_nameChain
.end();
233 ret
= find_SubModule(*ret
, *it
);
241 AryAccess::Get_CeText( StringVector
& o_module
,
244 const ary::idl::CodeEntity
& i_ce
) const
246 ces().Get_Text(o_module
, o_ce
, o_member
, i_ce
);
250 AryAccess::Get_TypeText( StringVector
& o_module
,
252 ary::idl::Ce_id
& o_nCe
,
253 int & o_sequenceCount
,
254 const ary::idl::Type
& i_type
) const
256 i_type
.Get_Text(o_module
, o_sCe
, o_nCe
, o_sequenceCount
, gate());
260 AryAccess::Get_IndexData( std::vector
<ary::idl::Ce_id
> & o_data
,
261 ary::idl::alphabetical_index::E_Letter i_letter
) const
263 rGate
.Ces().Get_AlphabeticalIndex(o_data
, i_letter
);
267 const ary::idl::CePilot
&
268 AryAccess::Ces() const
273 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */