xref: /AOO41X/main/autodoc/source/display/html/aryattrs.cxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #include <precomp.h>
29 #include "aryattrs.hxx"
30 
31 
32 // NOT FULLY DEFINED SERVICES
33 #include <ary/getncast.hxx>
34 #include <ary/cpp/c_class.hxx>
35 #include <ary/cpp/c_enum.hxx>
36 #include <ary/cpp/c_funct.hxx>
37 #include <ary/cpp/c_gate.hxx>
38 #include <ary/cpp/c_namesp.hxx>
39 #include <ary/cpp/cp_ce.hxx>
40 #include <ary/cpp/cp_type.hxx>
41 #include "strconst.hxx"
42 
43 
44 
45 
46 //********************       HtmlDisplay_Impl        *********************//
47 
48 const char *
49 Get_ClassTypeKey( const ary::cpp::Class & i_rClass )
50 {
51     return i_rClass.ClassKey() == ary::cpp::CK_class
52                             ?   C_sHFTypeTitle_Class
53                             :   i_rClass.ClassKey() == ary::cpp::CK_struct
54                                     ?   C_sHFTypeTitle_Struct
55                                     :   C_sHFTypeTitle_Union;
56 
57 }
58 
59 const char *
60 Get_TypeKey( const ary::cpp::CodeEntity & i_rCe )
61 {
62     if ( ary::is_type<ary::cpp::Class>(i_rCe) )
63     {
64         return Get_ClassTypeKey(
65                     ary::ary_cast<ary::cpp::Class>(i_rCe) );
66     }
67     if ( ary::is_type<ary::cpp::Enum>(i_rCe) )
68     {
69      	return "enum";
70     }
71     return "";
72 }
73 
74 bool
75 Ce_IsInternal( const ary::cpp::CodeEntity & i_rCe )
76 {
77     return NOT i_rCe.IsVisible();
78 }
79 
80 const char *
81 SyntaxText_PreName( const ary::cpp::Function &      i_rFunction,
82                     const ary::cpp::Gate &   i_rAryGate )
83 {
84     static StreamStr  sResult( 150 );
85     sResult.seekp(0);
86 
87     // write pre-name:
88     const ary::cpp::FunctionFlags & rFlags = i_rFunction.Flags();
89     if ( rFlags.IsStaticLocal() OR rFlags.IsStaticMember() )
90         sResult << "static ";
91     if ( rFlags.IsExplicit() )
92         sResult << "explicit ";
93     if ( rFlags.IsMutable() )
94         sResult << "mutable ";
95     if ( i_rFunction.Virtuality() != ary::cpp::VIRTUAL_none )
96         sResult << "virtual ";
97     i_rAryGate.Types().Get_TypeText( sResult, i_rFunction.ReturnType() );
98     sResult << " ";
99 
100     return sResult.c_str();
101 }
102 
103 const char *
104 SyntaxText_PostName( const ary::cpp::Function &     i_rFunction,
105                      const ary::cpp::Gate &  i_rAryGate )
106 {
107     static StreamStr  sResult( 850 );
108     sResult.seekp(0);
109 
110     // parameters and con_vol
111     i_rAryGate.Ces().Get_SignatureText( sResult, i_rFunction.Signature(), &i_rFunction.ParamInfos() );
112 
113     // write Exceptions:
114     const std::vector< ary::cpp::Type_id > *
115             pThrow = i_rFunction.Exceptions();
116     if ( pThrow)
117     {
118 
119         std::vector< ary::cpp::Type_id >::const_iterator
120 		    	it = pThrow->begin();
121         std::vector< ary::cpp::Type_id >::const_iterator
122 	    		it_end = pThrow->end();
123 
124         if (it != it_end)
125         {
126             sResult << " throw( ";
127             i_rAryGate.Types().Get_TypeText(sResult, *it);
128 
129             for ( ++it; it != it_end; ++it )
130             {
131                 sResult << ", ";
132                 i_rAryGate.Types().Get_TypeText(sResult, *it);
133             }
134             sResult << " )";
135         }
136         else
137         {
138             sResult << " throw( )";
139         }
140     }   // endif // pThrow
141 
142     // abstractness:
143     if ( i_rFunction.Virtuality() == ary::cpp::VIRTUAL_abstract )
144         sResult << " = 0";
145 
146     // finish:
147     sResult << ";";
148 
149     return sResult.c_str();
150 }
151 
152 bool
153 Get_TypeText( const char * &                o_rPreName,
154               const char * &                o_rName,
155               const char * &                o_rPostName,
156               ary::cpp::Type_id             i_nTypeid,
157               const ary::cpp::Gate & i_rAryGate )
158 {
159     static StreamStr       sResult_PreName(250);
160     static StreamStr       sResult_Name(250);
161     static StreamStr       sResult_PostName(250);
162 
163     sResult_PreName.seekp(0);
164     sResult_Name.seekp(0);
165     sResult_PostName.seekp(0);
166 
167     bool    ret = i_rAryGate.Types().Get_TypeText(
168                                 sResult_PreName,
169                                 sResult_Name,
170                                 sResult_PostName,
171                                 i_nTypeid );
172     if ( sResult_PreName.tellp() > 0 )
173     {
174         char cLast = *( sResult_PreName.c_str() + (sResult_PreName.tellp() - 1) );
175         if (cLast != ':' AND cLast != ' ')
176             sResult_PreName << " ";
177     }
178 
179 
180     if (ret)
181     {
182         o_rPreName  = sResult_PreName.c_str();
183         o_rName     = sResult_Name.c_str();
184         o_rPostName = sResult_PostName.c_str();
185     }
186     else
187     {
188         o_rPreName  =  o_rName =  o_rPostName = "";
189     }
190     return ret;
191 }
192 
193 
194 
195 
196 //*********************         FunctionParam_Iterator      *****************//
197 
198 
199 FunctionParam_Iterator::FunctionParam_Iterator()
200     :   // itTypes
201         // itTypes_end
202         // itNames_andMore
203         // itNames_andMore_end
204         eConVol(ary::cpp::CONVOL_none)
205 {
206     static std::vector<ary::cpp::Type_id>   aTypesNull_;
207     static StringVector                     aNamesNull_;
208 
209     itTypes = itTypes_end = aTypesNull_.end();
210     itNames_andMore = itNames_andMore_end = aNamesNull_.end();
211 }
212 
213 FunctionParam_Iterator::~FunctionParam_Iterator()
214 {
215 }
216 
217 FunctionParam_Iterator &
218 FunctionParam_Iterator::operator++()
219 {
220     if ( IsValid() )
221     {
222         ++itTypes;
223         ++itNames_andMore;
224     }
225     return *this;
226 }
227 
228 void
229 FunctionParam_Iterator::Assign( const ary::cpp::Function &  i_rFunction )
230 {
231     const ary::cpp::OperationSignature &
232         rSigna = i_rFunction.Signature();
233 
234     const std::vector<ary::cpp::Type_id> &
235         rTypes = rSigna.Parameters();
236     const StringVector &
237         rNames = i_rFunction.ParamInfos();
238 
239     if ( rTypes.size() != rNames.size() OR rTypes.size() == 0 )
240         return;
241 
242     itTypes     = rTypes.begin();
243     itTypes_end = rTypes.end();
244     itNames_andMore     = rNames.begin();
245     itNames_andMore_end = rNames.end();
246 
247     eConVol = rSigna.ConVol();
248 }
249