merge the formfield patch from ooo-build
[ooovba.git] / autodoc / source / display / html / pm_aldef.cxx
blob7feaaa074b5a14300694bd558e017531648ec7af
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: pm_aldef.cxx,v $
10 * $Revision: 1.7 $
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 ************************************************************************/
31 #include <precomp.h>
32 #include "pm_aldef.hxx"
35 // NOT FULLY DEFINED SERVICES
36 #include <cosv/tpl/tpltools.hxx>
37 #include <ary/cpp/c_gate.hxx>
38 #include <ary/cpp/c_define.hxx>
39 #include <ary/cpp/c_macro.hxx>
40 #include <ary/cpp/cp_def.hxx>
41 #include <ary/loc/loc_file.hxx>
42 #include <ary/loc/locp_le.hxx>
43 #include <ary/getncast.hxx>
44 #include "hd_docu.hxx"
45 #include "html_kit.hxx"
46 #include "navibar.hxx"
47 #include "opageenv.hxx"
48 #include "pagemake.hxx"
49 #include "strconst.hxx"
52 using namespace csi;
53 using csi::html::HorizontalLine;
54 using csi::html::Link;
55 using csi::html::Label;
56 using csi::html::AlignAttr;
60 PageMaker_AllDefs::PageMaker_AllDefs( PageDisplay & io_rPage )
61 : SpecializedPageMaker(io_rPage),
62 pDocuDisplay( new Docu_Display(io_rPage.Env()) ),
63 pNavi(0)
67 PageMaker_AllDefs::~PageMaker_AllDefs()
71 void
72 PageMaker_AllDefs::MakePage()
74 pNavi = new NavigationBar( Env(), NavigationBar::LOC_AllDefs );
75 Write_NavBar();
77 Write_TopArea();
79 Write_DefinesList();
80 Write_MacrosList();
82 pNavi->Write_SubRows();
85 void
86 PageMaker_AllDefs::Write_NavBar()
88 pNavi->MakeSubRow( "" );
89 pNavi->AddItem( "Defines", "defines", true );
90 pNavi->AddItem( "Macros", "macros", true );
91 pNavi->Write( CurOut() );
92 CurOut() << new HorizontalLine;
95 void
96 PageMaker_AllDefs::Write_TopArea()
98 adcdisp::PageTitle_Std fTitle;
99 fTitle( CurOut(), "Defines and ", "Macros" );
101 CurOut() << new HorizontalLine;
104 void
105 PageMaker_AllDefs::Write_DocuArea()
107 // Not needed.
110 void
111 PageMaker_AllDefs::Write_DefinesList()
113 CurOut()
114 << new html::LineBreak
115 << new html::LineBreak
116 >> *new xml::AnElement("div")
117 << new html::ClassAttr("define")
118 >> *new html::Label("defines")
119 >> *new html::Headline(3)
120 << "Defines";
122 ary::cpp::DefsResultList
123 aAllDefines = Env().Gate().Defs().AllDefines();
124 ary::cpp::DefsConstIterator
125 itEnd = aAllDefines.end();
127 if (aAllDefines.begin() != itEnd)
129 for ( ary::cpp::DefsConstIterator it = aAllDefines.begin();
130 it != itEnd;
131 ++it )
133 Write_Define(*it);
136 else
138 CurOut() << "None.";
141 CurOut() << new HorizontalLine;
144 void
145 PageMaker_AllDefs::Write_MacrosList()
148 CurOut()
149 << new html::LineBreak
150 << new html::LineBreak
151 >> *new xml::AnElement("div")
152 << new html::ClassAttr("define")
153 >> *new html::Label("macros")
154 >> *new html::Headline(3)
155 << "Macros";
157 ary::cpp::DefsResultList
158 aAllMacros = Env().Gate().Defs().AllMacros();
159 ary::cpp::DefsConstIterator
160 itEnd = aAllMacros.end();
162 if (aAllMacros.begin() != itEnd)
164 for ( ary::cpp::DefsConstIterator it = aAllMacros.begin();
165 it != itEnd;
166 ++it )
168 Write_Macro(*it);
171 else
173 CurOut() << "None.";
176 CurOut() << new HorizontalLine;
179 void
180 PageMaker_AllDefs::Write_Define(De_id i_nId)
182 csv_assert( ary::is_type<ary::cpp::Define>( Env().Gate().Defs().Find_Def(i_nId)) );
183 const ary::cpp::Define &
184 rDef = static_cast< const ary::cpp::Define& >( Env().Gate().Defs().Find_Def(i_nId) );
186 CurOut() << new html::HorizontalLine;
188 adcdisp::ExplanationList aDocu( CurOut(), true );
189 aDocu.AddEntry();
191 aDocu.Term()
192 >> *new html::Label( rDef.LocalName() )
193 << " ";
194 aDocu.Term()
195 << rDef.LocalName();
197 Write_DefsDocu( aDocu.Def(), rDef );
200 void
201 PageMaker_AllDefs::Write_Macro(De_id i_nId)
203 csv_assert( Env().Gate().Defs().Find_Def(i_nId).AryClass() == ary::cpp::Macro::class_id );
204 const ary::cpp::Macro &
205 rDef = static_cast< const ary::cpp::Macro& >( Env().Gate().Defs().Find_Def(i_nId) );
207 CurOut() << new html::HorizontalLine;
209 adcdisp::ExplanationList aDocu( CurOut(), true );
210 aDocu.AddEntry();
212 aDocu.Term()
213 >> *new html::Label( rDef.LocalName() )
214 << " ";
215 aDocu.Term()
216 << rDef.LocalName()
217 << "(";
218 WriteOut_TokenList( aDocu.Term(), rDef.Params(), ", " );
219 aDocu.Term()
220 << ")";
222 Write_DefsDocu( aDocu.Def(), rDef );
226 void
227 PageMaker_AllDefs::Write_DefsDocu( csi::xml::Element & o_rOut,
228 const ary::cpp::DefineEntity & i_rTextReplacement )
230 if ( i_rTextReplacement.DefinitionText().size() > 0 )
232 EraseLeadingSpace( *const_cast< String * >(
233 &(*i_rTextReplacement.DefinitionText().begin())
234 ) );
237 adcdisp::ExplanationTable rList( o_rOut );
239 rList.AddEntry( "Defined As" );
240 WriteOut_TokenList( rList.Def(), i_rTextReplacement.DefinitionText(), " " );
242 const ary::loc::File &
243 rFile = Env().Gate().Locations().Find_File( i_rTextReplacement.Location() );
244 rList.AddEntry( "In File" );
245 rList.Def() << rFile.LocalName();
247 ShowDocu_On( o_rOut, *pDocuDisplay, i_rTextReplacement );