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 "pm_aldef.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir 32*cdf0e10cSrcweir // NOT FULLY DEFINED SERVICES 33*cdf0e10cSrcweir #include <cosv/tpl/tpltools.hxx> 34*cdf0e10cSrcweir #include <ary/cpp/c_gate.hxx> 35*cdf0e10cSrcweir #include <ary/cpp/c_define.hxx> 36*cdf0e10cSrcweir #include <ary/cpp/c_macro.hxx> 37*cdf0e10cSrcweir #include <ary/cpp/cp_def.hxx> 38*cdf0e10cSrcweir #include <ary/loc/loc_file.hxx> 39*cdf0e10cSrcweir #include <ary/loc/locp_le.hxx> 40*cdf0e10cSrcweir #include <ary/getncast.hxx> 41*cdf0e10cSrcweir #include "hd_docu.hxx" 42*cdf0e10cSrcweir #include "html_kit.hxx" 43*cdf0e10cSrcweir #include "navibar.hxx" 44*cdf0e10cSrcweir #include "opageenv.hxx" 45*cdf0e10cSrcweir #include "pagemake.hxx" 46*cdf0e10cSrcweir #include "strconst.hxx" 47*cdf0e10cSrcweir 48*cdf0e10cSrcweir 49*cdf0e10cSrcweir using namespace csi; 50*cdf0e10cSrcweir using csi::html::HorizontalLine; 51*cdf0e10cSrcweir using csi::html::Link; 52*cdf0e10cSrcweir using csi::html::Label; 53*cdf0e10cSrcweir using csi::html::AlignAttr; 54*cdf0e10cSrcweir 55*cdf0e10cSrcweir 56*cdf0e10cSrcweir 57*cdf0e10cSrcweir PageMaker_AllDefs::PageMaker_AllDefs( PageDisplay & io_rPage ) 58*cdf0e10cSrcweir : SpecializedPageMaker(io_rPage), 59*cdf0e10cSrcweir pDocuDisplay( new Docu_Display(io_rPage.Env()) ), 60*cdf0e10cSrcweir pNavi(0) 61*cdf0e10cSrcweir { 62*cdf0e10cSrcweir } 63*cdf0e10cSrcweir 64*cdf0e10cSrcweir PageMaker_AllDefs::~PageMaker_AllDefs() 65*cdf0e10cSrcweir { 66*cdf0e10cSrcweir } 67*cdf0e10cSrcweir 68*cdf0e10cSrcweir void 69*cdf0e10cSrcweir PageMaker_AllDefs::MakePage() 70*cdf0e10cSrcweir { 71*cdf0e10cSrcweir pNavi = new NavigationBar( Env(), NavigationBar::LOC_AllDefs ); 72*cdf0e10cSrcweir Write_NavBar(); 73*cdf0e10cSrcweir 74*cdf0e10cSrcweir Write_TopArea(); 75*cdf0e10cSrcweir 76*cdf0e10cSrcweir Write_DefinesList(); 77*cdf0e10cSrcweir Write_MacrosList(); 78*cdf0e10cSrcweir 79*cdf0e10cSrcweir pNavi->Write_SubRows(); 80*cdf0e10cSrcweir } 81*cdf0e10cSrcweir 82*cdf0e10cSrcweir void 83*cdf0e10cSrcweir PageMaker_AllDefs::Write_NavBar() 84*cdf0e10cSrcweir { 85*cdf0e10cSrcweir pNavi->MakeSubRow( "" ); 86*cdf0e10cSrcweir pNavi->AddItem( "Defines", "defines", true ); 87*cdf0e10cSrcweir pNavi->AddItem( "Macros", "macros", true ); 88*cdf0e10cSrcweir pNavi->Write( CurOut() ); 89*cdf0e10cSrcweir CurOut() << new HorizontalLine; 90*cdf0e10cSrcweir } 91*cdf0e10cSrcweir 92*cdf0e10cSrcweir void 93*cdf0e10cSrcweir PageMaker_AllDefs::Write_TopArea() 94*cdf0e10cSrcweir { 95*cdf0e10cSrcweir adcdisp::PageTitle_Std fTitle; 96*cdf0e10cSrcweir fTitle( CurOut(), "Defines and ", "Macros" ); 97*cdf0e10cSrcweir 98*cdf0e10cSrcweir CurOut() << new HorizontalLine; 99*cdf0e10cSrcweir } 100*cdf0e10cSrcweir 101*cdf0e10cSrcweir void 102*cdf0e10cSrcweir PageMaker_AllDefs::Write_DocuArea() 103*cdf0e10cSrcweir { 104*cdf0e10cSrcweir // Not needed. 105*cdf0e10cSrcweir } 106*cdf0e10cSrcweir 107*cdf0e10cSrcweir void 108*cdf0e10cSrcweir PageMaker_AllDefs::Write_DefinesList() 109*cdf0e10cSrcweir { 110*cdf0e10cSrcweir CurOut() 111*cdf0e10cSrcweir << new html::LineBreak 112*cdf0e10cSrcweir << new html::LineBreak 113*cdf0e10cSrcweir >> *new xml::AnElement("div") 114*cdf0e10cSrcweir << new html::ClassAttr("define") 115*cdf0e10cSrcweir >> *new html::Label("defines") 116*cdf0e10cSrcweir >> *new html::Headline(3) 117*cdf0e10cSrcweir << "Defines"; 118*cdf0e10cSrcweir 119*cdf0e10cSrcweir ary::cpp::DefsResultList 120*cdf0e10cSrcweir aAllDefines = Env().Gate().Defs().AllDefines(); 121*cdf0e10cSrcweir ary::cpp::DefsConstIterator 122*cdf0e10cSrcweir itEnd = aAllDefines.end(); 123*cdf0e10cSrcweir 124*cdf0e10cSrcweir if (aAllDefines.begin() != itEnd) 125*cdf0e10cSrcweir { 126*cdf0e10cSrcweir for ( ary::cpp::DefsConstIterator it = aAllDefines.begin(); 127*cdf0e10cSrcweir it != itEnd; 128*cdf0e10cSrcweir ++it ) 129*cdf0e10cSrcweir { 130*cdf0e10cSrcweir Write_Define(*it); 131*cdf0e10cSrcweir } 132*cdf0e10cSrcweir } 133*cdf0e10cSrcweir else 134*cdf0e10cSrcweir { 135*cdf0e10cSrcweir CurOut() << "None."; 136*cdf0e10cSrcweir } 137*cdf0e10cSrcweir 138*cdf0e10cSrcweir CurOut() << new HorizontalLine; 139*cdf0e10cSrcweir } 140*cdf0e10cSrcweir 141*cdf0e10cSrcweir void 142*cdf0e10cSrcweir PageMaker_AllDefs::Write_MacrosList() 143*cdf0e10cSrcweir 144*cdf0e10cSrcweir { 145*cdf0e10cSrcweir CurOut() 146*cdf0e10cSrcweir << new html::LineBreak 147*cdf0e10cSrcweir << new html::LineBreak 148*cdf0e10cSrcweir >> *new xml::AnElement("div") 149*cdf0e10cSrcweir << new html::ClassAttr("define") 150*cdf0e10cSrcweir >> *new html::Label("macros") 151*cdf0e10cSrcweir >> *new html::Headline(3) 152*cdf0e10cSrcweir << "Macros"; 153*cdf0e10cSrcweir 154*cdf0e10cSrcweir ary::cpp::DefsResultList 155*cdf0e10cSrcweir aAllMacros = Env().Gate().Defs().AllMacros(); 156*cdf0e10cSrcweir ary::cpp::DefsConstIterator 157*cdf0e10cSrcweir itEnd = aAllMacros.end(); 158*cdf0e10cSrcweir 159*cdf0e10cSrcweir if (aAllMacros.begin() != itEnd) 160*cdf0e10cSrcweir { 161*cdf0e10cSrcweir for ( ary::cpp::DefsConstIterator it = aAllMacros.begin(); 162*cdf0e10cSrcweir it != itEnd; 163*cdf0e10cSrcweir ++it ) 164*cdf0e10cSrcweir { 165*cdf0e10cSrcweir Write_Macro(*it); 166*cdf0e10cSrcweir } 167*cdf0e10cSrcweir } 168*cdf0e10cSrcweir else 169*cdf0e10cSrcweir { 170*cdf0e10cSrcweir CurOut() << "None."; 171*cdf0e10cSrcweir } 172*cdf0e10cSrcweir 173*cdf0e10cSrcweir CurOut() << new HorizontalLine; 174*cdf0e10cSrcweir } 175*cdf0e10cSrcweir 176*cdf0e10cSrcweir void 177*cdf0e10cSrcweir PageMaker_AllDefs::Write_Define(De_id i_nId) 178*cdf0e10cSrcweir { 179*cdf0e10cSrcweir csv_assert( ary::is_type<ary::cpp::Define>( Env().Gate().Defs().Find_Def(i_nId)) ); 180*cdf0e10cSrcweir const ary::cpp::Define & 181*cdf0e10cSrcweir rDef = static_cast< const ary::cpp::Define& >( Env().Gate().Defs().Find_Def(i_nId) ); 182*cdf0e10cSrcweir 183*cdf0e10cSrcweir CurOut() << new html::HorizontalLine; 184*cdf0e10cSrcweir 185*cdf0e10cSrcweir adcdisp::ExplanationList aDocu( CurOut(), true ); 186*cdf0e10cSrcweir aDocu.AddEntry(); 187*cdf0e10cSrcweir 188*cdf0e10cSrcweir aDocu.Term() 189*cdf0e10cSrcweir >> *new html::Label( rDef.LocalName() ) 190*cdf0e10cSrcweir << " "; 191*cdf0e10cSrcweir aDocu.Term() 192*cdf0e10cSrcweir << rDef.LocalName(); 193*cdf0e10cSrcweir 194*cdf0e10cSrcweir Write_DefsDocu( aDocu.Def(), rDef ); 195*cdf0e10cSrcweir } 196*cdf0e10cSrcweir 197*cdf0e10cSrcweir void 198*cdf0e10cSrcweir PageMaker_AllDefs::Write_Macro(De_id i_nId) 199*cdf0e10cSrcweir { 200*cdf0e10cSrcweir csv_assert( Env().Gate().Defs().Find_Def(i_nId).AryClass() == ary::cpp::Macro::class_id ); 201*cdf0e10cSrcweir const ary::cpp::Macro & 202*cdf0e10cSrcweir rDef = static_cast< const ary::cpp::Macro& >( Env().Gate().Defs().Find_Def(i_nId) ); 203*cdf0e10cSrcweir 204*cdf0e10cSrcweir CurOut() << new html::HorizontalLine; 205*cdf0e10cSrcweir 206*cdf0e10cSrcweir adcdisp::ExplanationList aDocu( CurOut(), true ); 207*cdf0e10cSrcweir aDocu.AddEntry(); 208*cdf0e10cSrcweir 209*cdf0e10cSrcweir aDocu.Term() 210*cdf0e10cSrcweir >> *new html::Label( rDef.LocalName() ) 211*cdf0e10cSrcweir << " "; 212*cdf0e10cSrcweir aDocu.Term() 213*cdf0e10cSrcweir << rDef.LocalName() 214*cdf0e10cSrcweir << "("; 215*cdf0e10cSrcweir WriteOut_TokenList( aDocu.Term(), rDef.Params(), ", " ); 216*cdf0e10cSrcweir aDocu.Term() 217*cdf0e10cSrcweir << ")"; 218*cdf0e10cSrcweir 219*cdf0e10cSrcweir Write_DefsDocu( aDocu.Def(), rDef ); 220*cdf0e10cSrcweir } 221*cdf0e10cSrcweir 222*cdf0e10cSrcweir 223*cdf0e10cSrcweir void 224*cdf0e10cSrcweir PageMaker_AllDefs::Write_DefsDocu( csi::xml::Element & o_rOut, 225*cdf0e10cSrcweir const ary::cpp::DefineEntity & i_rTextReplacement ) 226*cdf0e10cSrcweir { 227*cdf0e10cSrcweir if ( i_rTextReplacement.DefinitionText().size() > 0 ) 228*cdf0e10cSrcweir { 229*cdf0e10cSrcweir EraseLeadingSpace( *const_cast< String * >( 230*cdf0e10cSrcweir &(*i_rTextReplacement.DefinitionText().begin()) 231*cdf0e10cSrcweir ) ); 232*cdf0e10cSrcweir } 233*cdf0e10cSrcweir 234*cdf0e10cSrcweir adcdisp::ExplanationTable rList( o_rOut ); 235*cdf0e10cSrcweir 236*cdf0e10cSrcweir rList.AddEntry( "Defined As" ); 237*cdf0e10cSrcweir WriteOut_TokenList( rList.Def(), i_rTextReplacement.DefinitionText(), " " ); 238*cdf0e10cSrcweir 239*cdf0e10cSrcweir const ary::loc::File & 240*cdf0e10cSrcweir rFile = Env().Gate().Locations().Find_File( i_rTextReplacement.Location() ); 241*cdf0e10cSrcweir rList.AddEntry( "In File" ); 242*cdf0e10cSrcweir rList.Def() << rFile.LocalName(); 243*cdf0e10cSrcweir 244*cdf0e10cSrcweir ShowDocu_On( o_rOut, *pDocuDisplay, i_rTextReplacement ); 245*cdf0e10cSrcweir } 246