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