Bump for 3.6-28
[LibreOffice.git] / autodoc / source / display / idl / hi_ary.cxx
blob855b9ede1536adb0bf6f2d1103059f5962282423
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 ************************************************************************/
29 #include <precomp.h>
30 #include "hi_ary.hxx"
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
45 { return rGate; }
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
59 ary::idl::Ce_id
60 nModule = i_parent.Search_Name(i_name);
61 return ces().Search_Module(nModule);
64 bool
65 AryAccess::nextName( const char * & io_TextPtr,
66 String & o_name ) const
68 if ( strncmp(io_TextPtr,"::", 2) == 0 )
69 io_TextPtr += 2;
71 const char * pEnd = strchr(io_TextPtr,':');
72 size_t nLen = pEnd == 0
73 ? strlen(io_TextPtr)
74 : pEnd - io_TextPtr;
75 o_name.assign(io_TextPtr, nLen);
76 io_TextPtr += nLen;
78 return nLen > 0;
83 AryAccess::AryAccess( const ary::idl::Gate & i_rGate )
84 : rGate(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);
113 ary::idl::Ce_id
114 AryAccess::CeFromType( ary::idl::Type_id i_type ) const
116 return types().Search_CeRelatedTo(i_type);
119 bool
120 AryAccess::IsBuiltInOrRelated( const ary::idl::Type & i_type ) const
122 return types().IsBuiltInOrRelated(i_type);
125 bool
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();
141 else
143 pModule = &i_referingScope;
144 ces().Get_Text(o_module, o_mainEntity, o_memberEntity, *pModule);
147 const char * pNext = i_sText;
148 String sNextName;
150 // Find Module:
151 while ( nextName(pNext, sNextName) )
153 const ary::idl::Module *
154 pSub = find_SubModule(*pModule, sNextName);
155 if (pSub != 0)
157 pModule = pSub;
158 o_module.push_back(sNextName);
160 else
161 break;
164 // Find main CodeEntity:
165 if ( sNextName.length() == 0 )
166 return true;
167 const ary::idl::Ce_id
168 nCe = pModule->Search_Name(sNextName);
169 if (NOT nCe.IsValid())
170 return false;
171 o_mainEntity = sNextName;
173 // Find member:
174 if ( *pNext == 0 )
175 return true;
176 nextName(pNext, o_memberEntity);
177 if (strchr(o_memberEntity,':') != 0)
178 return false; // This must not happen in IDL
180 return true;
183 bool
184 AryAccess::Search_CesModule( StringVector & o_module,
185 const String & i_scope,
186 const String & i_ce,
187 const ary::idl::Module & i_referingScope ) const
189 o_module.erase(o_module.begin(),o_module.end());
191 const ary::idl::Module *
192 pModule = 0;
194 if ( strncmp(i_scope, "::", 2) == 0
195 OR strncmp(i_scope, "com::sun::star", 14) == 0 )
196 pModule = &GlobalNamespace();
197 else
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;
206 String sNextName;
208 // Find Module:
209 while ( nextName(pNext, sNextName) )
211 const ary::idl::Module *
212 pSub = find_SubModule(*pModule, sNextName);
213 if (pSub != 0)
215 pModule = pSub;
216 o_module.push_back(sNextName);
218 else
219 return false;
220 } // end while
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 =
228 &GlobalNamespace();
229 for ( StringVector::const_iterator it = i_nameChain.begin();
230 it != i_nameChain.end();
231 ++it )
233 ret = find_SubModule(*ret, *it);
234 if (ret == 0)
235 break;
236 } // end for
237 return ret;
240 void
241 AryAccess::Get_CeText( StringVector & o_module,
242 String & o_ce,
243 String & o_member,
244 const ary::idl::CodeEntity & i_ce ) const
246 ces().Get_Text(o_module, o_ce, o_member, i_ce);
249 void
250 AryAccess::Get_TypeText( StringVector & o_module,
251 String & o_sCe,
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());
259 void
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
270 return rGate.Ces();
273 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */