1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #include <precomp.h>
29*cdf0e10cSrcweir #include "dsply_op.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir 
32*cdf0e10cSrcweir // NOT FULLY DEFINED SERVICES
33*cdf0e10cSrcweir #include <cosv/tpl/tpltools.hxx>
34*cdf0e10cSrcweir #include <ary/cpp/c_funct.hxx>
35*cdf0e10cSrcweir #include <ary/cpp/c_gate.hxx>
36*cdf0e10cSrcweir #include <ary/loc/locp_le.hxx>
37*cdf0e10cSrcweir #include <udm/html/htmlitem.hxx>
38*cdf0e10cSrcweir #include "hd_docu.hxx"
39*cdf0e10cSrcweir #include "hdimpl.hxx"
40*cdf0e10cSrcweir #include "html_kit.hxx"
41*cdf0e10cSrcweir #include "opageenv.hxx"
42*cdf0e10cSrcweir #include "pagemake.hxx"
43*cdf0e10cSrcweir 
44*cdf0e10cSrcweir using namespace csi;
45*cdf0e10cSrcweir using namespace adcdisp;
46*cdf0e10cSrcweir 
47*cdf0e10cSrcweir 
48*cdf0e10cSrcweir 
49*cdf0e10cSrcweir 
50*cdf0e10cSrcweir OperationsDisplay::OperationsDisplay( OuputPage_Environment & io_rEnv )
51*cdf0e10cSrcweir     :   // aMap_GlobalFunctionsDisplay,
52*cdf0e10cSrcweir         // pClassMembersDisplay,
53*cdf0e10cSrcweir         pEnv( &io_rEnv ),
54*cdf0e10cSrcweir         pDocuShow( new Docu_Display(io_rEnv) )
55*cdf0e10cSrcweir {
56*cdf0e10cSrcweir }
57*cdf0e10cSrcweir 
58*cdf0e10cSrcweir OperationsDisplay::~OperationsDisplay()
59*cdf0e10cSrcweir {
60*cdf0e10cSrcweir     csv::erase_map_of_heap_ptrs( aMap_GlobalFunctionsDisplay );
61*cdf0e10cSrcweir }
62*cdf0e10cSrcweir 
63*cdf0e10cSrcweir void
64*cdf0e10cSrcweir OperationsDisplay::PrepareForStdMembers()
65*cdf0e10cSrcweir {
66*cdf0e10cSrcweir     csv::erase_map_of_heap_ptrs( aMap_GlobalFunctionsDisplay );
67*cdf0e10cSrcweir 
68*cdf0e10cSrcweir     pClassMembersDisplay = new PageDisplay(*pEnv);
69*cdf0e10cSrcweir     const ary::cpp::Class * pClass = pEnv->CurClass();
70*cdf0e10cSrcweir     csv_assert( pClass != 0 );
71*cdf0e10cSrcweir     pClassMembersDisplay->Setup_OperationsFile_for(*pClass);
72*cdf0e10cSrcweir }
73*cdf0e10cSrcweir 
74*cdf0e10cSrcweir void
75*cdf0e10cSrcweir OperationsDisplay::PrepareForStaticMembers()
76*cdf0e10cSrcweir {
77*cdf0e10cSrcweir     // Doesn't need to do anything yet.
78*cdf0e10cSrcweir }
79*cdf0e10cSrcweir 
80*cdf0e10cSrcweir void
81*cdf0e10cSrcweir OperationsDisplay::Create_Files()
82*cdf0e10cSrcweir {
83*cdf0e10cSrcweir     if (pClassMembersDisplay)
84*cdf0e10cSrcweir         pClassMembersDisplay->Create_File();
85*cdf0e10cSrcweir     else
86*cdf0e10cSrcweir     {
87*cdf0e10cSrcweir      	for ( Map_FileId2PagePtr::const_iterator it = aMap_GlobalFunctionsDisplay.begin();
88*cdf0e10cSrcweir               it != aMap_GlobalFunctionsDisplay.end();
89*cdf0e10cSrcweir               ++it )
90*cdf0e10cSrcweir         {
91*cdf0e10cSrcweir          	(*it).second->Create_File();
92*cdf0e10cSrcweir         }
93*cdf0e10cSrcweir     }
94*cdf0e10cSrcweir }
95*cdf0e10cSrcweir 
96*cdf0e10cSrcweir void
97*cdf0e10cSrcweir OperationsDisplay::do_Process( const ary::cpp::Function & i_rData )
98*cdf0e10cSrcweir {
99*cdf0e10cSrcweir     if ( Ce_IsInternal(i_rData) )
100*cdf0e10cSrcweir         return;
101*cdf0e10cSrcweir 
102*cdf0e10cSrcweir     PageDisplay & rPage = FindPage_for( i_rData );
103*cdf0e10cSrcweir 
104*cdf0e10cSrcweir     csi::xml::Element & rOut = rPage.CurOut();
105*cdf0e10cSrcweir     Display_SglOperation( rOut, i_rData );
106*cdf0e10cSrcweir }
107*cdf0e10cSrcweir 
108*cdf0e10cSrcweir const ary::cpp::Gate *
109*cdf0e10cSrcweir OperationsDisplay::inq_Get_ReFinder() const
110*cdf0e10cSrcweir {
111*cdf0e10cSrcweir     return & pEnv->Gate();
112*cdf0e10cSrcweir }
113*cdf0e10cSrcweir 
114*cdf0e10cSrcweir PageDisplay &
115*cdf0e10cSrcweir OperationsDisplay::FindPage_for( const ary::cpp::Function & i_rData )
116*cdf0e10cSrcweir {
117*cdf0e10cSrcweir     if ( pClassMembersDisplay )
118*cdf0e10cSrcweir         return *pClassMembersDisplay;
119*cdf0e10cSrcweir 
120*cdf0e10cSrcweir     SourceFileId
121*cdf0e10cSrcweir             nSourceFile = i_rData.Location();
122*cdf0e10cSrcweir     PageDisplay *
123*cdf0e10cSrcweir             pFound = csv::value_from_map( aMap_GlobalFunctionsDisplay, nSourceFile, (PageDisplay*)0 );
124*cdf0e10cSrcweir     if ( pFound == 0 )
125*cdf0e10cSrcweir     {
126*cdf0e10cSrcweir      	pFound = new PageDisplay( *pEnv );
127*cdf0e10cSrcweir         const ary::loc::File &
128*cdf0e10cSrcweir                 rFile = pEnv->Gate().Locations().Find_File( nSourceFile );
129*cdf0e10cSrcweir         pFound->Setup_OperationsFile_for(rFile);
130*cdf0e10cSrcweir         aMap_GlobalFunctionsDisplay[nSourceFile] = pFound;
131*cdf0e10cSrcweir     }
132*cdf0e10cSrcweir 
133*cdf0e10cSrcweir     return *pFound;
134*cdf0e10cSrcweir }
135*cdf0e10cSrcweir 
136*cdf0e10cSrcweir void
137*cdf0e10cSrcweir OperationsDisplay::Display_SglOperation( csi::xml::Element &        rOut,
138*cdf0e10cSrcweir                                          const ary::cpp::Function & i_rData )
139*cdf0e10cSrcweir {
140*cdf0e10cSrcweir     adcdisp::ExplanationList aDocu(rOut, true);
141*cdf0e10cSrcweir     aDocu.AddEntry( 0 );
142*cdf0e10cSrcweir 
143*cdf0e10cSrcweir 
144*cdf0e10cSrcweir     adcdisp::OperationTitle fTitle;
145*cdf0e10cSrcweir     fTitle( aDocu.Term(),
146*cdf0e10cSrcweir             i_rData.LocalName(),
147*cdf0e10cSrcweir             i_rData.CeId(),
148*cdf0e10cSrcweir             pEnv->Gate() );
149*cdf0e10cSrcweir 
150*cdf0e10cSrcweir     // Syntax
151*cdf0e10cSrcweir     adcdisp::ExplanationList aSyntaxHeader(aDocu.Def());
152*cdf0e10cSrcweir     aSyntaxHeader.AddEntry( 0, "simple" );
153*cdf0e10cSrcweir     csi::xml::Element & rHeader = aSyntaxHeader.Term();
154*cdf0e10cSrcweir 
155*cdf0e10cSrcweir     adcdisp::ParameterTable
156*cdf0e10cSrcweir         aParams( aSyntaxHeader.Def() );
157*cdf0e10cSrcweir 
158*cdf0e10cSrcweir     if (i_rData.TemplateParameters().size() > 0)
159*cdf0e10cSrcweir     {
160*cdf0e10cSrcweir         TemplateClause fTemplateClause;
161*cdf0e10cSrcweir         fTemplateClause( rHeader, i_rData.TemplateParameters() );
162*cdf0e10cSrcweir         rHeader << new html::LineBreak;
163*cdf0e10cSrcweir     }
164*cdf0e10cSrcweir     if ( i_rData.Flags().IsExternC() )
165*cdf0e10cSrcweir     {
166*cdf0e10cSrcweir      	rHeader
167*cdf0e10cSrcweir                 << "extern \"C\""
168*cdf0e10cSrcweir                 << new html::LineBreak;
169*cdf0e10cSrcweir     }
170*cdf0e10cSrcweir 
171*cdf0e10cSrcweir     bool bConst = false;
172*cdf0e10cSrcweir     bool bVolatile = false;
173*cdf0e10cSrcweir     WriteOut_LinkedFunctionText( rHeader, aParams, i_rData, *pEnv,
174*cdf0e10cSrcweir                                  &bConst, &bVolatile );
175*cdf0e10cSrcweir     aDocu.Def() << new html::LineBreak;
176*cdf0e10cSrcweir 
177*cdf0e10cSrcweir     // Flags
178*cdf0e10cSrcweir     aDocu.AddEntry_NoTerm();
179*cdf0e10cSrcweir     adcdisp::FlagTable
180*cdf0e10cSrcweir         aFlags( aDocu.Def(), 8 );
181*cdf0e10cSrcweir 
182*cdf0e10cSrcweir     const ary::cpp::FunctionFlags &
183*cdf0e10cSrcweir         rFFlags = i_rData.Flags();
184*cdf0e10cSrcweir     aFlags.SetColumn( 0, "virtual",
185*cdf0e10cSrcweir                       i_rData.Virtuality() != ary::cpp::VIRTUAL_none );
186*cdf0e10cSrcweir     aFlags.SetColumn( 1, "abstract",
187*cdf0e10cSrcweir                       i_rData.Virtuality() == ary::cpp::VIRTUAL_abstract );
188*cdf0e10cSrcweir     aFlags.SetColumn( 2, "const", bConst );
189*cdf0e10cSrcweir     aFlags.SetColumn( 3, "volatile", bVolatile );
190*cdf0e10cSrcweir     aFlags.SetColumn( 4, "template",
191*cdf0e10cSrcweir                       i_rData.TemplateParameters().size() > 0 );
192*cdf0e10cSrcweir     aFlags.SetColumn( 5, "static",
193*cdf0e10cSrcweir                       rFFlags.IsStaticLocal() OR rFFlags.IsStaticMember() );
194*cdf0e10cSrcweir     aFlags.SetColumn( 6, "inline",
195*cdf0e10cSrcweir                       rFFlags.IsInline() );
196*cdf0e10cSrcweir     aFlags.SetColumn( 7, "C-linkage",
197*cdf0e10cSrcweir                       rFFlags.IsExternC() );
198*cdf0e10cSrcweir     aDocu.Def() << new html::LineBreak;
199*cdf0e10cSrcweir 
200*cdf0e10cSrcweir     // Docu
201*cdf0e10cSrcweir     aDocu.AddEntry_NoTerm();
202*cdf0e10cSrcweir     pDocuShow->Assign_Out(aDocu.Def());
203*cdf0e10cSrcweir     pDocuShow->Process(i_rData.Docu());
204*cdf0e10cSrcweir     pDocuShow->Unassign_Out();
205*cdf0e10cSrcweir 
206*cdf0e10cSrcweir     rOut << new html::HorizontalLine;
207*cdf0e10cSrcweir }
208