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