1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22 #include <precomp.h>
23 #include "hfi_tag.hxx"
24
25
26 // NOT FULLY DEFINED SERVICES
27 #include <ary/idl/i_ce.hxx>
28 #include <ary/idl/i_module.hxx>
29 #include <ary_i/ci_text2.hxx>
30 #include <ary_i/d_token.hxx>
31 #include <toolkit/out_tree.hxx>
32 #include <adc_cl.hxx>
33 #include <adc_msg.hxx>
34 #include "hfi_typetext.hxx"
35 #include "hi_ary.hxx"
36 #include "hi_env.hxx"
37 #include "hi_linkhelper.hxx"
38
39
40 using ary::inf::DocuTex2;
41
42
43 inline void
Enter_TextOut(Xml::Element & o_rText) const44 HF_IdlTag::Enter_TextOut( Xml::Element & o_rText ) const
45 {
46 aTextOut.Out().Enter(o_rText);
47 }
48
49 inline void
Leave_TextOut() const50 HF_IdlTag::Leave_TextOut() const
51 {
52 aTextOut.Out().Leave();
53 }
54
55 inline void
PutText_Out(const ary::inf::DocuTex2 & i_rText) const56 HF_IdlTag::PutText_Out( const ary::inf::DocuTex2 & i_rText ) const
57 {
58 i_rText.DisplayAt( const_cast< HF_IdlDocuTextDisplay& >(aTextOut) );
59 }
60
61
62
HF_IdlTag(Environment & io_rEnv,const ary::idl::CodeEntity & i_rScopeGivingCe)63 HF_IdlTag::HF_IdlTag( Environment & io_rEnv,
64 const ary::idl::CodeEntity & i_rScopeGivingCe )
65 : HtmlFactory_Idl( io_rEnv, 0 ),
66 pTitleOut(0),
67 aTextOut(io_rEnv, 0, i_rScopeGivingCe)
68 {
69 }
70
~HF_IdlTag()71 HF_IdlTag::~HF_IdlTag()
72 {
73 }
74
75 void
Produce_byData(Xml::Element & o_rTitle,Xml::Element & o_rText,const ary::inf::AtTag2 & i_rTag) const76 HF_IdlTag::Produce_byData( Xml::Element & o_rTitle,
77 Xml::Element & o_rText,
78 const ary::inf::AtTag2 & i_rTag ) const
79 {
80 pTitleOut = &o_rTitle;
81 Enter_TextOut(o_rText);
82 i_rTag.DisplayAt( const_cast< HF_IdlTag& >(*this) );
83 Leave_TextOut();
84 }
85
86 void
Produce_byData(Xml::Element & o_rTitle,Xml::Element & o_rText,const std::vector<csi::dsapi::DT_SeeAlsoAtTag * > & i_seeAlsoVector) const87 HF_IdlTag::Produce_byData( Xml::Element & o_rTitle,
88 Xml::Element & o_rText,
89 const std::vector< csi::dsapi::DT_SeeAlsoAtTag* > &
90 i_seeAlsoVector ) const
91 {
92 o_rTitle << "See also";
93 for ( std::vector< csi::dsapi::DT_SeeAlsoAtTag* >::const_iterator
94 it = i_seeAlsoVector.begin();
95 it != i_seeAlsoVector.end();
96 ++it )
97 {
98 if (it != i_seeAlsoVector.begin())
99 {
100 o_rText << ", ";
101 }
102 HF_IdlTypeText
103 aLinkText(Env(), o_rText, true, &aTextOut.ScopeGivingCe());
104 aLinkText.Produce_byData( (*it)->LinkText() );
105 }
106 }
107
108 void
Display_StdAtTag(const csi::dsapi::DT_StdAtTag & i_rTag)109 HF_IdlTag::Display_StdAtTag( const csi::dsapi::DT_StdAtTag & i_rTag )
110 {
111 if ( i_rTag.Text().IsEmpty() )
112 return;
113
114 csv_assert( pTitleOut != 0 );
115 *pTitleOut << i_rTag.Title();
116 PutText_Out( i_rTag.Text() );
117 }
118
119 void
Display_SeeAlsoAtTag(const csi::dsapi::DT_SeeAlsoAtTag & i_rTag)120 HF_IdlTag::Display_SeeAlsoAtTag( const csi::dsapi::DT_SeeAlsoAtTag & i_rTag )
121 {
122 if ( i_rTag.Text().IsEmpty() )
123 return;
124
125 csv_assert( pTitleOut != 0 );
126 *pTitleOut << "See also";
127
128 HF_IdlTypeText aLinkText(Env(),aTextOut.CurOut(),true, &aTextOut.ScopeGivingCe());
129 aLinkText.Produce_byData( i_rTag.LinkText() );
130
131 aTextOut.CurOut() << new Html::LineBreak;
132 PutText_Out( i_rTag.Text() );
133 }
134
135 void
Display_ParameterAtTag(const csi::dsapi::DT_ParameterAtTag & i_rTag)136 HF_IdlTag::Display_ParameterAtTag( const csi::dsapi::DT_ParameterAtTag & i_rTag )
137 {
138 csv_assert( pTitleOut != 0 );
139 StreamLock sl(100);
140 *pTitleOut
141 << ( sl() << "Parameter " << i_rTag.Title() << c_str );
142 PutText_Out( i_rTag.Text() );
143 }
144
145 void
Display_SinceAtTag(const csi::dsapi::DT_SinceAtTag & i_rTag)146 HF_IdlTag::Display_SinceAtTag( const csi::dsapi::DT_SinceAtTag & i_rTag )
147 {
148 csv_assert(pTitleOut != 0);
149
150 if ( i_rTag.Text().IsEmpty() )
151 {
152 return;
153 }
154
155 // Transform the value of the @since tag into the text to be displayed.
156 String sDisplay =
157 autodoc::CommandLine::Get_().DisplayOf_SinceTagValue(
158 i_rTag.Text().TextOfFirstToken() );
159 if (sDisplay.empty())
160 return;
161
162 *pTitleOut << "Since ";
163 DocuTex2 aHelp;
164 aHelp.AddToken(* new csi::dsapi::DT_TextToken(sDisplay));
165 PutText_Out(aHelp);
166 }
167
168
169 //******************** HF_IdlShortDocu *********************/
170
HF_IdlShortDocu(Environment & io_rEnv,Xml::Element & o_rOut)171 HF_IdlShortDocu::HF_IdlShortDocu( Environment & io_rEnv,
172 Xml::Element & o_rOut )
173 : HtmlFactory_Idl( io_rEnv, &o_rOut )
174 {
175 }
176
~HF_IdlShortDocu()177 HF_IdlShortDocu::~HF_IdlShortDocu()
178 {
179 }
180
181 void
Produce_byData(const ary::idl::CodeEntity & i_rCe)182 HF_IdlShortDocu::Produce_byData( const ary::idl::CodeEntity & i_rCe )
183 {
184 const ce_info *
185 pDocu = Get_IdlDocu(i_rCe.Docu());
186 if (pDocu == 0)
187 return;
188
189 const ce_info &
190 rDocu = *pDocu;
191 if ( rDocu.IsDeprecated() )
192 {
193 CurOut()
194 >> *new Html::Bold
195 << "[ DEPRECATED ]" << new Html::LineBreak;
196 }
197 if ( rDocu.IsOptional() )
198 {
199 CurOut()
200 >> *new Html::Bold
201 << "[ OPTIONAL ]" << new Html::LineBreak;
202 }
203
204 HF_IdlDocuTextDisplay
205 aText( Env(), &CurOut(), i_rCe);
206 rDocu.Short().DisplayAt(aText);
207 }
208
209
210 //******************** HF_IdlDocuTextDisplay *********************/
211
212
HF_IdlDocuTextDisplay(Environment & io_rEnv,Xml::Element * o_pOut,const ary::idl::CodeEntity & i_rScopeGivingCe)213 HF_IdlDocuTextDisplay::HF_IdlDocuTextDisplay( Environment & io_rEnv,
214 Xml::Element * o_pOut,
215 const ary::idl::CodeEntity & i_rScopeGivingCe )
216 : HtmlFactory_Idl(io_rEnv, o_pOut),
217 sScope(),
218 sLinkToken(),
219 bGatherLink(false),
220 pScopeGivingCe(&i_rScopeGivingCe)
221 {
222 }
223
~HF_IdlDocuTextDisplay()224 HF_IdlDocuTextDisplay::~HF_IdlDocuTextDisplay()
225 {
226 }
227
228 void
Display_TextToken(const csi::dsapi::DT_TextToken & i_rToken)229 HF_IdlDocuTextDisplay::Display_TextToken( const csi::dsapi::DT_TextToken & i_rToken )
230 {
231 if (bGatherLink)
232 {
233 if (sLinkToken.length() == 0)
234 {
235 sLinkToken = i_rToken.GetText();
236 return;
237 }
238 else
239 {
240 if ( pScopeGivingCe == 0 )
241 { // only in original file
242 TheMessages().Out_TypeVsMemberMisuse(sLinkToken, Env().CurPageCe_AsText(), 0);
243 }
244
245 StopLinkGathering();
246 }
247 } // endif (bGatherLink)
248
249 CurOut() << new Xml::XmlCode( i_rToken.GetText() );
250 }
251
252 void
Display_White()253 HF_IdlDocuTextDisplay::Display_White()
254 {
255 CurOut() << " ";
256 }
257
258 void
Display_MupType(const csi::dsapi::DT_MupType & i_rToken)259 HF_IdlDocuTextDisplay::Display_MupType( const csi::dsapi::DT_MupType & i_rToken )
260 {
261 if (i_rToken.IsBegin())
262 {
263 StartLinkGathering(i_rToken.Scope());
264 }
265 else
266 {
267 if (bGatherLink)
268 {
269 CreateTypeLink();
270 StopLinkGathering();
271 }
272 }
273 }
274
275 void
Display_MupMember(const csi::dsapi::DT_MupMember & i_rToken)276 HF_IdlDocuTextDisplay::Display_MupMember( const csi::dsapi::DT_MupMember & i_rToken )
277 {
278 if (i_rToken.IsBegin())
279 {
280 StartLinkGathering(i_rToken.Scope());
281 }
282 else
283 {
284 if (bGatherLink)
285 {
286 CreateMemberLink();
287 StopLinkGathering();
288 }
289 }
290 }
291
292 void
Display_MupConst(const csi::dsapi::DT_MupConst & i_rToken)293 HF_IdlDocuTextDisplay::Display_MupConst( const csi::dsapi::DT_MupConst & i_rToken )
294 {
295 CurOut()
296 >> *new Html::Bold
297 << i_rToken.GetText();
298 }
299
300 void
Display_Style(const csi::dsapi::DT_Style & i_rToken)301 HF_IdlDocuTextDisplay::Display_Style( const csi::dsapi::DT_Style & i_rToken )
302 {
303 CurOut() << new Xml::XmlCode( i_rToken.GetText() );
304 }
305
306 void
Display_EOL()307 HF_IdlDocuTextDisplay::Display_EOL()
308 {
309 CurOut() << "\n";
310 }
311
312 void
CreateTypeLink()313 HF_IdlDocuTextDisplay::CreateTypeLink()
314 {
315 if (strchr(sLinkToken,':') != 0)
316 {
317 TheMessages().Out_TypeVsMemberMisuse(sLinkToken, Env().CurPageCe_AsFile(".idl"), 0);
318 CurOut() << sLinkToken;
319 return;
320 }
321 HF_IdlTypeText aLink(Env(), CurOut(), true, &ScopeGivingCe());
322 aLink.Produce_LinkInDocu(sScope, sLinkToken, String::Null_());
323 }
324
325 void
CreateMemberLink()326 HF_IdlDocuTextDisplay::CreateMemberLink()
327 {
328
329 HF_IdlTypeText aLink(Env(), CurOut(), true, &ScopeGivingCe());
330
331 const char *
332 sSplit = strchr(sLinkToken,':');
333
334 if (sSplit != 0)
335 {
336 String sCe(sLinkToken.c_str(), sSplit - sLinkToken.c_str());
337 String sMember(sSplit+2);
338
339 if (NOT sScope.empty() OR ScopeGivingCe().LocalName() != sCe )
340 aLink.Produce_LinkInDocu(sScope, sCe, sMember);
341 else
342 aLink.Produce_LocalLinkInDocu(sMember);
343 }
344 else
345 {
346 aLink.Produce_LocalLinkInDocu(sLinkToken);
347 }
348 }
349