1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: hd_docu.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
32 #include "hd_docu.hxx"
35 // NOT FULLY DEFINED SERVICES
36 #include <ary/cpp/c_gate.hxx>
37 #include <ary/cpp/c_namesp.hxx>
38 #include <ary/cpp/c_class.hxx>
39 #include <ary/cpp/c_enum.hxx>
40 #include <ary/cpp/c_tydef.hxx>
41 #include <ary/cpp/c_funct.hxx>
42 #include <ary/cpp/c_vari.hxx>
43 #include <ary/cpp/c_enuval.hxx>
44 #include <ary/doc/d_oldcppdocu.hxx>
45 #include <ary/info/all_tags.hxx>
46 #include <ary/info/all_dts.hxx>
48 #include "html_kit.hxx"
49 #include "opageenv.hxx"
53 using namespace ary::info
;
57 using html::DefListTerm
;
58 using html::DefListDefinition
;
64 C_sTagHeadlines
[ ary::info::C_eAtTag_NrOfClasses
] =
66 "ATTENTION!", "Author", "Changes", "Collaborators",
67 "Contact", // Contact may be unused
68 "Copyright", "Deprecated", "Description", "Date of Documentation",
69 "How to Derive from this Class",
70 "Heap object - owner is responsible for deletion.",
71 "Important Instances",
73 "Invariant", "Lifecycle",
74 "Multiplicity", "On Error", "Persistency", "Postcondition",
77 "Return", "Summary", "Todos", "Version",
78 "Base Classes", "Exceptions", "Implements", "Keywords", "Parameters",
79 "See Also", "Template Parameters",
85 Docu_Display::Docu_Display( OuputPage_Environment
& io_rEnv
)
86 : HtmlDisplay_Impl(io_rEnv
),
87 bUseHtmlInDocuTokens(false),
92 Docu_Display::~Docu_Display()
97 Docu_Display::Assign_Out( csi::xml::Element
& o_rOut
)
103 Docu_Display::Unassign_Out()
109 Docu_Display::do_Process( const ary::cpp::Namespace
& i_rData
)
111 Process(i_rData
.Docu());
115 Docu_Display::do_Process( const ary::cpp::Class
& i_rData
)
117 pCurClassOverwrite
= &i_rData
;
118 Process(i_rData
.Docu());
119 pCurClassOverwrite
= 0;
123 Docu_Display::do_Process( const ary::cpp::Enum
& i_rData
)
125 Process(i_rData
.Docu());
129 Docu_Display::do_Process( const ary::cpp::Typedef
& i_rData
)
131 Process(i_rData
.Docu());
135 Docu_Display::do_Process( const ary::cpp::Function
& i_rData
)
137 Process(i_rData
.Docu());
141 Docu_Display::do_Process( const ary::cpp::Variable
& i_rData
)
143 Process(i_rData
.Docu());
148 // -------------- Interface ary::info::DocuDisplay ------------------ //
152 Docu_Display::do_Process(const ary::doc::Documentation
& i_rData
)
154 if (i_rData
.Data() == 0)
157 const ary::doc::OldCppDocu
*
158 docdata
= dynamic_cast< const ary::doc::OldCppDocu
* >(i_rData
.Data());
159 csv_assert(docdata
!= 0);
163 if ( docdata
->IsObsolete() )
166 >> *new html::DefListTerm
168 << "D E P R E C A T E D";
172 ary::doc::OldCppDocu::TagList::const_iterator
173 itEnd
= docdata
->Tags().end();
174 for ( ary::doc::OldCppDocu::TagList::const_iterator it
= docdata
->Tags().begin();
178 (*it
)->StoreAt( *this );
185 Docu_Display::Display_StdTag( const StdTag
& i_rData
)
187 csv_assert( uintt(i_rData
.Std_Id()) < uintt(ary::info::C_eAtTag_NrOfClasses
) );
189 const ary::info::DocuText::TokenList
&
190 rText
= i_rData
.CText().Tokens();
191 typedef ary::info::DocuText::TokenList::const_iterator TokenIterator
;
195 else if ( rText
.size() < 3 )
197 bool bIsWhite
= true;
198 for ( TokenIterator it
= rText
.begin();
203 bIsWhite
= (*it
)->IsWhite();
209 Write_TagTitle( C_sTagHeadlines
[i_rData
.Std_Id()] );
210 Write_TagContents( i_rData
.CText() );
214 Docu_Display::Display_BaseTag( const BaseTag
& )
219 Docu_Display::Display_ExceptionTag( const ExceptionTag
& )
224 Docu_Display::Display_ImplementsTag( const ImplementsTag
& )
229 Docu_Display::Display_KeywordTag( const KeywordTag
& )
234 Docu_Display::Display_ParameterTag( const ParameterTag
& i_rData
)
236 Write_TagTitle( "Parameters" );
238 adcdisp::ExplanationTable
239 aParams( CurOut() >> *new DefListDefinition
);
241 for ( const ParameterTag
* pParam
= &i_rData
;
243 pParam
= pParam
->GetNext() ) // KORR_FUTURE
245 aParams
.AddEntry( pParam
->ParamName().c_str() );
247 Easy().Enter( aParams
.Def() );
248 Write_Text( pParam
->CText() );
254 Docu_Display::Display_SeeTag( const SeeTag
& i_rData
)
256 Write_TagTitle( "See Also" );
258 DefListDefinition
* dpDef
= new DefListDefinition
;
260 Easy().Enter(*dpDef
);
262 for ( std::vector
< ary::QualifiedName
>::const_iterator
263 it
= i_rData
.References().begin();
264 it
!= i_rData
.References().end();
267 Write_LinkableText( (*it
) );
268 CurOut() << new html::LineBreak
;
275 Docu_Display::Display_TemplateTag( const TemplateTag
& i_rData
)
277 Write_TagTitle( "Template Parameters" );
279 adcdisp::ExplanationTable
280 aTplParams( CurOut() >> *new DefListDefinition
);
282 for ( const TemplateTag
* pTplParam
= &i_rData
;
284 pTplParam
= pTplParam
->GetNext() )
286 aTplParams
.AddEntry( pTplParam
->TplParamName().c_str() );
288 Easy().Enter( aTplParams
.Def() );
289 Write_Text( pTplParam
->CText() );
295 Docu_Display::Display_LabelTag( const LabelTag
& )
300 Docu_Display::Display_SinceTag( const ary::info::SinceTag
& i_rData
)
302 if ( i_rData
.Version().empty() )
307 // Transform the value of the @since tag into the text to be displayed.
309 if ( autodoc::CommandLine::Get_().DoesTransform_SinceTag() )
311 sDisplay
= autodoc::CommandLine::Get_()
312 .DisplayOf_SinceTagValue( i_rData
.Version() );
316 sDisplay
= i_rData
.Version();
319 if (sDisplay
.empty())
322 Write_TagTitle( "Since " );
324 DefListDefinition
* dpDef
= new DefListDefinition
;
327 Easy().Enter(*dpDef
);
328 CurOut() << sDisplay
;
333 Docu_Display::Display_DT_Text( const DT_Text
& i_rData
)
335 Write_TextToken( i_rData
.Text() );
339 Docu_Display::Display_DT_MaybeLink( const DT_MaybeLink
& i_rData
)
342 Write_TextToken( i_rData
.Text() );
346 Docu_Display::Display_DT_Whitespace( const DT_Whitespace
& i_rData
)
348 static char sSpace
[300] =
355 UINT8 nLength
= i_rData
.Length();
356 sSpace
[nLength
] = NULCH
;
358 sSpace
[nLength
] = ' ';
362 Docu_Display::Display_DT_Eol( const DT_Eol
& )
364 CurOut() << new html::Sbr
;
368 Docu_Display::Display_DT_Xml( const ary::info::DT_Xml
& i_rData
)
370 CurOut() << new xml::XmlCode( i_rData
.Text() );
373 const ary::cpp::Gate
*
374 Docu_Display::inq_Get_ReFinder() const
376 return &Env().Gate();
380 Docu_Display::Start_DocuBlock()
382 DYN DefList
* dpDefList
= new DefList
;
383 CurOut() << dpDefList
;
384 Easy().Enter( *dpDefList
);
388 Docu_Display::Finish_DocuBlock()
394 Docu_Display::Write_TagTitle( const char * i_sText
,
397 if ( strcmp(i_sText
,"ATTENTION!") == 0 )
400 >> *new html::DefListTerm
401 << new html::ClassAttr("attention")
407 >> *new html::DefListTerm
413 Docu_Display::Write_TagContents( const DocuText
& i_rDocuText
)
415 DefListDefinition
* dpDef
= new DefListDefinition
;
418 Easy().Enter(*dpDef
);
419 Write_Text(i_rDocuText
);
424 Docu_Display::Write_Text( const ary::info::DocuText
& i_rDocuText
)
426 if ( i_rDocuText
.IsNoHtml() )
429 << new xml::XmlCode("<pre>");
430 bUseHtmlInDocuTokens
= false;
434 bUseHtmlInDocuTokens
= true;
436 i_rDocuText
.StoreAt( *this );
437 if ( i_rDocuText
.IsNoHtml() )
440 << new xml::XmlCode("</pre>");
445 Docu_Display::Write_TextToken( const String
& i_sText
)
447 if ( bUseHtmlInDocuTokens
)
448 CurOut() << new xml::XmlCode(i_sText
);
454 Docu_Display::Write_LinkableText( const ary::QualifiedName
& i_sQuName
)
456 const ary::cpp::CodeEntity
*
457 pCe
= FindUnambiguousCe( Env(), i_sQuName
, pCurClassOverwrite
);
461 pLink
= new csi::html::Link( Link2Ce(Env(), *pCe
) );
463 Easy().Enter(*pLink
);
464 Write_QualifiedName(i_sQuName
);
469 Write_QualifiedName(i_sQuName
);
475 Docu_Display::Write_QualifiedName( const ary::QualifiedName
& i_sQuName
)
477 if ( i_sQuName
.IsAbsolute() )
479 for ( ary::QualifiedName::namespace_iterator it
= i_sQuName
.first_namespace();
480 it
!= i_sQuName
.end_namespace();
483 CurOut() << (*it
) << "::";
485 CurOut() << i_sQuName
.LocalName();
486 if ( i_sQuName
.IsFunction() )