xref: /AOO41X/main/autodoc/source/display/html/dsply_op.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
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 "dsply_op.hxx"
30 
31 
32 // NOT FULLY DEFINED SERVICES
33 #include <cosv/tpl/tpltools.hxx>
34 #include <ary/cpp/c_funct.hxx>
35 #include <ary/cpp/c_gate.hxx>
36 #include <ary/loc/locp_le.hxx>
37 #include <udm/html/htmlitem.hxx>
38 #include "hd_docu.hxx"
39 #include "hdimpl.hxx"
40 #include "html_kit.hxx"
41 #include "opageenv.hxx"
42 #include "pagemake.hxx"
43 
44 using namespace csi;
45 using namespace adcdisp;
46 
47 
48 
49 
50 OperationsDisplay::OperationsDisplay( OuputPage_Environment & io_rEnv )
51     :   // aMap_GlobalFunctionsDisplay,
52         // pClassMembersDisplay,
53         pEnv( &io_rEnv ),
54         pDocuShow( new Docu_Display(io_rEnv) )
55 {
56 }
57 
58 OperationsDisplay::~OperationsDisplay()
59 {
60     csv::erase_map_of_heap_ptrs( aMap_GlobalFunctionsDisplay );
61 }
62 
63 void
64 OperationsDisplay::PrepareForStdMembers()
65 {
66     csv::erase_map_of_heap_ptrs( aMap_GlobalFunctionsDisplay );
67 
68     pClassMembersDisplay = new PageDisplay(*pEnv);
69     const ary::cpp::Class * pClass = pEnv->CurClass();
70     csv_assert( pClass != 0 );
71     pClassMembersDisplay->Setup_OperationsFile_for(*pClass);
72 }
73 
74 void
75 OperationsDisplay::PrepareForStaticMembers()
76 {
77     // Doesn't need to do anything yet.
78 }
79 
80 void
81 OperationsDisplay::Create_Files()
82 {
83     if (pClassMembersDisplay)
84         pClassMembersDisplay->Create_File();
85     else
86     {
87      	for ( Map_FileId2PagePtr::const_iterator it = aMap_GlobalFunctionsDisplay.begin();
88               it != aMap_GlobalFunctionsDisplay.end();
89               ++it )
90         {
91          	(*it).second->Create_File();
92         }
93     }
94 }
95 
96 void
97 OperationsDisplay::do_Process( const ary::cpp::Function & i_rData )
98 {
99     if ( Ce_IsInternal(i_rData) )
100         return;
101 
102     PageDisplay & rPage = FindPage_for( i_rData );
103 
104     csi::xml::Element & rOut = rPage.CurOut();
105     Display_SglOperation( rOut, i_rData );
106 }
107 
108 const ary::cpp::Gate *
109 OperationsDisplay::inq_Get_ReFinder() const
110 {
111     return & pEnv->Gate();
112 }
113 
114 PageDisplay &
115 OperationsDisplay::FindPage_for( const ary::cpp::Function & i_rData )
116 {
117     if ( pClassMembersDisplay )
118         return *pClassMembersDisplay;
119 
120     SourceFileId
121             nSourceFile = i_rData.Location();
122     PageDisplay *
123             pFound = csv::value_from_map( aMap_GlobalFunctionsDisplay, nSourceFile, (PageDisplay*)0 );
124     if ( pFound == 0 )
125     {
126      	pFound = new PageDisplay( *pEnv );
127         const ary::loc::File &
128                 rFile = pEnv->Gate().Locations().Find_File( nSourceFile );
129         pFound->Setup_OperationsFile_for(rFile);
130         aMap_GlobalFunctionsDisplay[nSourceFile] = pFound;
131     }
132 
133     return *pFound;
134 }
135 
136 void
137 OperationsDisplay::Display_SglOperation( csi::xml::Element &        rOut,
138                                          const ary::cpp::Function & i_rData )
139 {
140     adcdisp::ExplanationList aDocu(rOut, true);
141     aDocu.AddEntry( 0 );
142 
143 
144     adcdisp::OperationTitle fTitle;
145     fTitle( aDocu.Term(),
146             i_rData.LocalName(),
147             i_rData.CeId(),
148             pEnv->Gate() );
149 
150     // Syntax
151     adcdisp::ExplanationList aSyntaxHeader(aDocu.Def());
152     aSyntaxHeader.AddEntry( 0, "simple" );
153     csi::xml::Element & rHeader = aSyntaxHeader.Term();
154 
155     adcdisp::ParameterTable
156         aParams( aSyntaxHeader.Def() );
157 
158     if (i_rData.TemplateParameters().size() > 0)
159     {
160         TemplateClause fTemplateClause;
161         fTemplateClause( rHeader, i_rData.TemplateParameters() );
162         rHeader << new html::LineBreak;
163     }
164     if ( i_rData.Flags().IsExternC() )
165     {
166      	rHeader
167                 << "extern \"C\""
168                 << new html::LineBreak;
169     }
170 
171     bool bConst = false;
172     bool bVolatile = false;
173     WriteOut_LinkedFunctionText( rHeader, aParams, i_rData, *pEnv,
174                                  &bConst, &bVolatile );
175     aDocu.Def() << new html::LineBreak;
176 
177     // Flags
178     aDocu.AddEntry_NoTerm();
179     adcdisp::FlagTable
180         aFlags( aDocu.Def(), 8 );
181 
182     const ary::cpp::FunctionFlags &
183         rFFlags = i_rData.Flags();
184     aFlags.SetColumn( 0, "virtual",
185                       i_rData.Virtuality() != ary::cpp::VIRTUAL_none );
186     aFlags.SetColumn( 1, "abstract",
187                       i_rData.Virtuality() == ary::cpp::VIRTUAL_abstract );
188     aFlags.SetColumn( 2, "const", bConst );
189     aFlags.SetColumn( 3, "volatile", bVolatile );
190     aFlags.SetColumn( 4, "template",
191                       i_rData.TemplateParameters().size() > 0 );
192     aFlags.SetColumn( 5, "static",
193                       rFFlags.IsStaticLocal() OR rFFlags.IsStaticMember() );
194     aFlags.SetColumn( 6, "inline",
195                       rFFlags.IsInline() );
196     aFlags.SetColumn( 7, "C-linkage",
197                       rFFlags.IsExternC() );
198     aDocu.Def() << new html::LineBreak;
199 
200     // Docu
201     aDocu.AddEntry_NoTerm();
202     pDocuShow->Assign_Out(aDocu.Def());
203     pDocuShow->Process(i_rData.Docu());
204     pDocuShow->Unassign_Out();
205 
206     rOut << new html::HorizontalLine;
207 }
208